updated "op +", "op -", "op *". "HOL.divide" in src & test
find . -type f -exec sed -i s/"\"op +\""/"\"Groups.plus_class.plus\""/g {} \;
find . -type f -exec sed -i s/"\"op -\""/"\"Groups.minus_class.minus\""/g {} \;
find . -type f -exec sed -i s/"\"op *\""/"\"Groups.times_class.times\""/g {} \;
find . -type f -exec sed -i s/"\"HOL.divide\""/"\"Rings.inverse_class.divide\""/g {} \;
1 (* attempts to perserve binary minus as wanted by Austrian teachers
3 (c) due to copyright terms
6 theory PolyMinus imports (*Poly// due to "is_ratpolyexp" in...*) Rational begin
10 (*predicates for conditions in rewriting*)
11 kleiner :: "['a, 'a] => bool" ("_ kleiner _")
12 ist'_monom :: "'a => bool" ("_ ist'_monom")
15 Probe :: "[bool, bool list] => bool"
16 (*"Probe (3*a+2*b+a = 4*a+2*b) [a=1,b=2]"*)
18 (*descriptions for the pbl and met*)
19 Pruefe :: "bool => una"
20 mitWert :: "bool list => tobooll"
21 Geprueft :: "bool => una"
24 ProbeScript :: "[bool, bool list, bool]
26 ("((Script ProbeScript (_ _ =))// (_))" 9)
30 null_minus: "0 - a = -a"
31 vor_minus_mal: "- a * b = (-a) * b"
33 (*commute with invariant (a.b).c -association*)
34 tausche_plus: "[| b ist_monom; a kleiner b |] ==>
36 tausche_minus: "[| b ist_monom; a kleiner b |] ==>
38 tausche_vor_plus: "[| b ist_monom; a kleiner b |] ==>
40 tausche_vor_minus: "[| b ist_monom; a kleiner b |] ==>
42 tausche_plus_plus: "b kleiner c ==> (a + c + b) = (a + b + c)"
43 tausche_plus_minus: "b kleiner c ==> (a + c - b) = (a - b + c)"
44 tausche_minus_plus: "b kleiner c ==> (a - c + b) = (a + b - c)"
45 tausche_minus_minus: "b kleiner c ==> (a - c - b) = (a - b - c)"
47 (*commute with invariant (a.b).c -association*)
48 tausche_mal: "[| b is_atom; a kleiner b |] ==>
50 tausche_vor_mal: "[| b is_atom; a kleiner b |] ==>
52 tausche_mal_mal: "[| c is_atom; b kleiner c |] ==>
53 (x * c * b) = (x * b * c)"
54 x_quadrat: "(x * a) * a = x * a ^^^ 2"
57 subtrahiere: "[| l is_const; m is_const |] ==>
58 m * v - l * v = (m - l) * v"
59 subtrahiere_von_1: "[| l is_const |] ==>
60 v - l * v = (1 - l) * v"
61 subtrahiere_1: "[| l is_const; m is_const |] ==>
62 m * v - v = (m - 1) * v"
64 subtrahiere_x_plus_minus: "[| l is_const; m is_const |] ==>
65 (x + m * v) - l * v = x + (m - l) * v"
66 subtrahiere_x_plus1_minus: "[| l is_const |] ==>
67 (x + v) - l * v = x + (1 - l) * v"
68 subtrahiere_x_plus_minus1: "[| m is_const |] ==>
69 (x + m * v) - v = x + (m - 1) * v"
71 subtrahiere_x_minus_plus: "[| l is_const; m is_const |] ==>
72 (x - m * v) + l * v = x + (-m + l) * v"
73 subtrahiere_x_minus1_plus: "[| l is_const |] ==>
74 (x - v) + l * v = x + (-1 + l) * v"
75 subtrahiere_x_minus_plus1: "[| m is_const |] ==>
76 (x - m * v) + v = x + (-m + 1) * v"
78 subtrahiere_x_minus_minus: "[| l is_const; m is_const |] ==>
79 (x - m * v) - l * v = x + (-m - l) * v"
80 subtrahiere_x_minus1_minus:"[| l is_const |] ==>
81 (x - v) - l * v = x + (-1 - l) * v"
82 subtrahiere_x_minus_minus1:"[| m is_const |] ==>
83 (x - m * v) - v = x + (-m - 1) * v"
86 addiere_vor_minus: "[| l is_const; m is_const |] ==>
87 - (l * v) + m * v = (-l + m) * v"
88 addiere_eins_vor_minus: "[| m is_const |] ==>
89 - v + m * v = (-1 + m) * v"
90 subtrahiere_vor_minus: "[| l is_const; m is_const |] ==>
91 - (l * v) - m * v = (-l - m) * v"
92 subtrahiere_eins_vor_minus:"[| m is_const |] ==>
93 - v - m * v = (-1 - m) * v"
95 vorzeichen_minus_weg1: "l kleiner 0 ==> a + l * b = a - -1*l * b"
96 vorzeichen_minus_weg2: "l kleiner 0 ==> a - l * b = a + -1*l * b"
97 vorzeichen_minus_weg3: "l kleiner 0 ==> k + a - l * b = k + a + -1*l * b"
98 vorzeichen_minus_weg4: "l kleiner 0 ==> k - a - l * b = k - a + -1*l * b"
100 (*klammer_plus_plus = (add_assoc RS sym)*)
101 klammer_plus_minus: "a + (b - c) = (a + b) - c"
102 klammer_minus_plus: "a - (b + c) = (a - b) - c"
103 klammer_minus_minus: "a - (b - c) = (a - b) + c"
105 klammer_mult_minus: "a * (b - c) = a * b - a * c"
106 klammer_minus_mult: "(b - c) * a = b * a - c * a"
111 (** eval functions **)
113 (*. get the identifier from specific monomials; see fun ist_monom .*)
116 let val s::ss = explode str
117 in implode ((chr (ord s + 1))::ss) end;
118 fun identifier (Free (id,_)) = id (* 2, a *)
119 | identifier (Const ("op *", _) $ Free (num, _) $ Free (id, _)) =
121 | identifier (Const ("op *", _) $ (* 3*a*b *)
123 Free (num, _) $ Free _) $ Free (id, _)) =
124 if is_numeral num then id
126 | identifier (Const ("Atools.pow", _) $ Free (base, _) $ Free (exp, _)) =
127 if is_numeral base then "|||||||||||||" (* a^2 *)
128 else (*increase*) base
129 | identifier (Const ("op *", _) $ Free (num, _) $ (* 3*a^2 *)
130 (Const ("Atools.pow", _) $
131 Free (base, _) $ Free (exp, _))) =
132 if is_numeral num andalso not (is_numeral base) then (*increase*) base
134 | identifier _ = "|||||||||||||"(*the "largest" string*);
136 (*("kleiner", ("PolyMinus.kleiner", eval_kleiner ""))*)
137 (* order "by alphabet" w.r.t. var: num < (var | num*var) > (var*var | ..) *)
138 fun eval_kleiner _ _ (p as (Const ("PolyMinus.kleiner",_) $ a $ b)) _ =
140 if is_num a then (*123 kleiner 32 = True !!!*)
141 if int_of_Free a < int_of_Free b then
142 SOME ((term2str p) ^ " = True",
143 Trueprop $ (mk_equality (p, HOLogic.true_const)))
144 else SOME ((term2str p) ^ " = False",
145 Trueprop $ (mk_equality (p, HOLogic.false_const)))
146 else (* -1 * -2 kleiner 0 *)
147 SOME ((term2str p) ^ " = False",
148 Trueprop $ (mk_equality (p, HOLogic.false_const)))
150 if identifier a < identifier b then
151 SOME ((term2str p) ^ " = True",
152 Trueprop $ (mk_equality (p, HOLogic.true_const)))
153 else SOME ((term2str p) ^ " = False",
154 Trueprop $ (mk_equality (p, HOLogic.false_const)))
155 | eval_kleiner _ _ _ _ = NONE;
157 fun ist_monom (Free (id,_)) = true
158 | ist_monom (Const ("op *", _) $ Free (num, _) $ Free (id, _)) =
159 if is_numeral num then true else false
160 | ist_monom _ = false;
161 (*. this function only accepts the most simple monoms vvvvvvvvvv .*)
162 fun ist_monom (Free (id,_)) = true (* 2, a *)
163 | ist_monom (Const ("op *", _) $ Free _ $ Free (id, _)) = (* 2*a, a*b *)
164 if is_numeral id then false else true
165 | ist_monom (Const ("op *", _) $ (* 3*a*b *)
167 Free (num, _) $ Free _) $ Free (id, _)) =
168 if is_numeral num andalso not (is_numeral id) then true else false
169 | ist_monom (Const ("Atools.pow", _) $ Free (base, _) $ Free (exp, _)) =
171 | ist_monom (Const ("op *", _) $ Free (num, _) $ (* 3*a^2 *)
172 (Const ("Atools.pow", _) $
173 Free (base, _) $ Free (exp, _))) =
174 if is_numeral num then true else false
175 | ist_monom _ = false;
177 (* is this a univariate monomial ? *)
178 (*("ist_monom", ("PolyMinus.ist'_monom", eval_ist_monom ""))*)
179 fun eval_ist_monom _ _ (p as (Const ("PolyMinus.ist'_monom",_) $ a)) _ =
181 SOME ((term2str p) ^ " = True",
182 Trueprop $ (mk_equality (p, HOLogic.true_const)))
183 else SOME ((term2str p) ^ " = False",
184 Trueprop $ (mk_equality (p, HOLogic.false_const)))
185 | eval_ist_monom _ _ _ _ = NONE;
188 (** rewrite order **)
192 val erls_ordne_alphabetisch =
193 append_rls "erls_ordne_alphabetisch" e_rls
194 [Calc ("PolyMinus.kleiner", eval_kleiner ""),
195 Calc ("PolyMinus.ist'_monom", eval_ist_monom "")
198 val ordne_alphabetisch =
199 Rls{id = "ordne_alphabetisch", preconds = [],
200 rew_ord = ("dummy_ord", dummy_ord), srls = Erls, calc = [],
201 erls = erls_ordne_alphabetisch,
202 rules = [Thm ("tausche_plus",num_str @{thm tausche_plus}),
203 (*"b kleiner a ==> (b + a) = (a + b)"*)
204 Thm ("tausche_minus",num_str @{thm tausche_minus}),
205 (*"b kleiner a ==> (b - a) = (-a + b)"*)
206 Thm ("tausche_vor_plus",num_str @{thm tausche_vor_plus}),
207 (*"[| b ist_monom; a kleiner b |] ==> (- b + a) = (a - b)"*)
208 Thm ("tausche_vor_minus",num_str @{thm tausche_vor_minus}),
209 (*"[| b ist_monom; a kleiner b |] ==> (- b - a) = (-a - b)"*)
210 Thm ("tausche_plus_plus",num_str @{thm tausche_plus_plus}),
211 (*"c kleiner b ==> (a + c + b) = (a + b + c)"*)
212 Thm ("tausche_plus_minus",num_str @{thm tausche_plus_minus}),
213 (*"c kleiner b ==> (a + c - b) = (a - b + c)"*)
214 Thm ("tausche_minus_plus",num_str @{thm tausche_minus_plus}),
215 (*"c kleiner b ==> (a - c + b) = (a + b - c)"*)
216 Thm ("tausche_minus_minus",num_str @{thm tausche_minus_minus})
217 (*"c kleiner b ==> (a - c - b) = (a - b - c)"*)
218 ], scr = EmptyScr}:rls;
221 Rls{id = "fasse_zusammen", preconds = [],
222 rew_ord = ("dummy_ord", dummy_ord),
223 erls = append_rls "erls_fasse_zusammen" e_rls
224 [Calc ("Atools.is'_const",eval_const "#is_const_")],
225 srls = Erls, calc = [],
227 [Thm ("real_num_collect",num_str @{thm real_num_collect}),
228 (*"[| l is_const; m is_const |]==>l * n + m * n = (l + m) * n"*)
229 Thm ("real_num_collect_assoc_r",num_str @{thm real_num_collect_assoc_r}),
230 (*"[| l is_const; m..|] ==> (k + m * n) + l * n = k + (l + m)*n"*)
231 Thm ("real_one_collect",num_str @{thm real_one_collect}),
232 (*"m is_const ==> n + m * n = (1 + m) * n"*)
233 Thm ("real_one_collect_assoc_r",num_str @{thm real_one_collect_assoc_r}),
234 (*"m is_const ==> (k + n) + m * n = k + (m + 1) * n"*)
237 Thm ("subtrahiere",num_str @{thm subtrahiere}),
238 (*"[| l is_const; m is_const |] ==> m * v - l * v = (m - l) * v"*)
239 Thm ("subtrahiere_von_1",num_str @{thm subtrahiere_von_1}),
240 (*"[| l is_const |] ==> v - l * v = (1 - l) * v"*)
241 Thm ("subtrahiere_1",num_str @{thm subtrahiere_1}),
242 (*"[| l is_const; m is_const |] ==> m * v - v = (m - 1) * v"*)
244 Thm ("subtrahiere_x_plus_minus",num_str @{thm subtrahiere_x_plus_minus}),
245 (*"[| l is_const; m..|] ==> (k + m * n) - l * n = k + ( m - l) * n"*)
246 Thm ("subtrahiere_x_plus1_minus",num_str @{thm subtrahiere_x_plus1_minus}),
247 (*"[| l is_const |] ==> (x + v) - l * v = x + (1 - l) * v"*)
248 Thm ("subtrahiere_x_plus_minus1",num_str @{thm subtrahiere_x_plus_minus1}),
249 (*"[| m is_const |] ==> (x + m * v) - v = x + (m - 1) * v"*)
251 Thm ("subtrahiere_x_minus_plus",num_str @{thm subtrahiere_x_minus_plus}),
252 (*"[| l is_const; m..|] ==> (k - m * n) + l * n = k + (-m + l) * n"*)
253 Thm ("subtrahiere_x_minus1_plus",num_str @{thm subtrahiere_x_minus1_plus}),
254 (*"[| l is_const |] ==> (x - v) + l * v = x + (-1 + l) * v"*)
255 Thm ("subtrahiere_x_minus_plus1",num_str @{thm subtrahiere_x_minus_plus1}),
256 (*"[| m is_const |] ==> (x - m * v) + v = x + (-m + 1) * v"*)
258 Thm ("subtrahiere_x_minus_minus",num_str @{thm subtrahiere_x_minus_minus}),
259 (*"[| l is_const; m..|] ==> (k - m * n) - l * n = k + (-m - l) * n"*)
260 Thm ("subtrahiere_x_minus1_minus",num_str @{thm subtrahiere_x_minus1_minus}),
261 (*"[| l is_const |] ==> (x - v) - l * v = x + (-1 - l) * v"*)
262 Thm ("subtrahiere_x_minus_minus1",num_str @{thm subtrahiere_x_minus_minus1}),
263 (*"[| m is_const |] ==> (x - m * v) - v = x + (-m - 1) * v"*)
265 Calc ("Groups.plus_class.plus", eval_binop "#add_"),
266 Calc ("Groups.minus_class.minus", eval_binop "#subtr_"),
268 (*MG: Reihenfolge der folgenden 2 Thm muss so bleiben, wegen
269 (a+a)+a --> a + 2*a --> 3*a and not (a+a)+a --> 2*a + a *)
270 Thm ("real_mult_2_assoc_r",num_str @{thm real_mult_2_assoc_r}),
271 (*"(k + z1) + z1 = k + 2 * z1"*)
272 Thm ("sym_real_mult_2",num_str (@{thm real_mult_2} RS @{thm sym})),
273 (*"z1 + z1 = 2 * z1"*)
275 Thm ("addiere_vor_minus",num_str @{thm addiere_vor_minus}),
276 (*"[| l is_const; m is_const |] ==> -(l * v) + m * v = (-l + m) *v"*)
277 Thm ("addiere_eins_vor_minus",num_str @{thm addiere_eins_vor_minus}),
278 (*"[| m is_const |] ==> - v + m * v = (-1 + m) * v"*)
279 Thm ("subtrahiere_vor_minus",num_str @{thm subtrahiere_vor_minus}),
280 (*"[| l is_const; m is_const |] ==> -(l * v) - m * v = (-l - m) *v"*)
281 Thm ("subtrahiere_eins_vor_minus",num_str @{thm subtrahiere_eins_vor_minus})
282 (*"[| m is_const |] ==> - v - m * v = (-1 - m) * v"*)
284 ], scr = EmptyScr}:rls;
287 Rls{id = "verschoenere", preconds = [],
288 rew_ord = ("dummy_ord", dummy_ord), srls = Erls, calc = [],
289 erls = append_rls "erls_verschoenere" e_rls
290 [Calc ("PolyMinus.kleiner", eval_kleiner "")],
291 rules = [Thm ("vorzeichen_minus_weg1",num_str @{thm vorzeichen_minus_weg1}),
292 (*"l kleiner 0 ==> a + l * b = a - -l * b"*)
293 Thm ("vorzeichen_minus_weg2",num_str @{thm vorzeichen_minus_weg2}),
294 (*"l kleiner 0 ==> a - l * b = a + -l * b"*)
295 Thm ("vorzeichen_minus_weg3",num_str @{thm vorzeichen_minus_weg3}),
296 (*"l kleiner 0 ==> k + a - l * b = k + a + -l * b"*)
297 Thm ("vorzeichen_minus_weg4",num_str @{thm vorzeichen_minus_weg4}),
298 (*"l kleiner 0 ==> k - a - l * b = k - a + -l * b"*)
300 Calc ("op *", eval_binop "#mult_"),
302 Thm ("mult_zero_left",num_str @{thm mult_zero_left}),
304 Thm ("mult_1_left",num_str @{thm mult_1_left}),
306 Thm ("add_0_left",num_str @{thm add_0_left}),
308 Thm ("null_minus",num_str @{thm null_minus}),
310 Thm ("vor_minus_mal",num_str @{thm vor_minus_mal})
311 (*"- a * b = (-a) * b"*)
313 (*Thm ("",num_str @{}),*)
315 ], scr = EmptyScr}:rls (*end verschoenere*);
317 val klammern_aufloesen =
318 Rls{id = "klammern_aufloesen", preconds = [],
319 rew_ord = ("dummy_ord", dummy_ord), srls = Erls, calc = [], erls = Erls,
320 rules = [Thm ("sym_add_assoc",
321 num_str (@{thm add_assoc} RS @{thm sym})),
322 (*"a + (b + c) = (a + b) + c"*)
323 Thm ("klammer_plus_minus",num_str @{thm klammer_plus_minus}),
324 (*"a + (b - c) = (a + b) - c"*)
325 Thm ("klammer_minus_plus",num_str @{thm klammer_minus_plus}),
326 (*"a - (b + c) = (a - b) - c"*)
327 Thm ("klammer_minus_minus",num_str @{thm klammer_minus_minus})
328 (*"a - (b - c) = (a - b) + c"*)
329 ], scr = EmptyScr}:rls;
331 val klammern_ausmultiplizieren =
332 Rls{id = "klammern_ausmultiplizieren", preconds = [],
333 rew_ord = ("dummy_ord", dummy_ord), srls = Erls, calc = [], erls = Erls,
334 rules = [Thm ("left_distrib" ,num_str @{thm left_distrib}),
335 (*"(z1.0 + z2.0) * w = z1.0 * w + z2.0 * w"*)
336 Thm ("right_distrib",num_str @{thm right_distrib}),
337 (*"w * (z1.0 + z2.0) = w * z1.0 + w * z2.0"*)
339 Thm ("klammer_mult_minus",num_str @{thm klammer_mult_minus}),
340 (*"a * (b - c) = a * b - a * c"*)
341 Thm ("klammer_minus_mult",num_str @{thm klammer_minus_mult})
342 (*"(b - c) * a = b * a - c * a"*)
344 (*Thm ("",num_str @{}),
346 ], scr = EmptyScr}:rls;
349 Rls{id = "ordne_monome", preconds = [],
350 rew_ord = ("dummy_ord", dummy_ord), srls = Erls, calc = [],
351 erls = append_rls "erls_ordne_monome" e_rls
352 [Calc ("PolyMinus.kleiner", eval_kleiner ""),
353 Calc ("Atools.is'_atom", eval_is_atom "")
355 rules = [Thm ("tausche_mal",num_str @{thm tausche_mal}),
356 (*"[| b is_atom; a kleiner b |] ==> (b * a) = (a * b)"*)
357 Thm ("tausche_vor_mal",num_str @{thm tausche_vor_mal}),
358 (*"[| b is_atom; a kleiner b |] ==> (-b * a) = (-a * b)"*)
359 Thm ("tausche_mal_mal",num_str @{thm tausche_mal_mal}),
360 (*"[| c is_atom; b kleiner c |] ==> (a * c * b) = (a * b *c)"*)
361 Thm ("x_quadrat",num_str @{thm x_quadrat})
362 (*"(x * a) * a = x * a ^^^ 2"*)
364 (*Thm ("",num_str @{}),
366 ], scr = EmptyScr}:rls;
370 append_rls "rls_p_33" e_rls
371 [Rls_ ordne_alphabetisch,
376 append_rls "rls_p_34" e_rls
377 [Rls_ klammern_aufloesen,
378 Rls_ ordne_alphabetisch,
383 append_rls "rechnen" e_rls
384 [Calc ("op *", eval_binop "#mult_"),
385 Calc ("Groups.plus_class.plus", eval_binop "#add_"),
386 Calc ("Groups.minus_class.minus", eval_binop "#subtr_")
390 overwritelthy @{theory} (!ruleset',
391 [("ordne_alphabetisch", prep_rls ordne_alphabetisch),
392 ("fasse_zusammen", prep_rls fasse_zusammen),
393 ("verschoenere", prep_rls verschoenere),
394 ("ordne_monome", prep_rls ordne_monome),
395 ("klammern_aufloesen", prep_rls klammern_aufloesen),
396 ("klammern_ausmultiplizieren",
397 prep_rls klammern_ausmultiplizieren)
403 (prep_pbt thy "pbl_vereinf_poly" [] e_pblID
404 (["polynom","vereinfachen"],
405 [], Erls, NONE, []));
408 (prep_pbt thy "pbl_vereinf_poly_minus" [] e_pblID
409 (["plus_minus","polynom","vereinfachen"],
410 [("#Given" ,["TERM t_t"]),
411 ("#Where" ,["t_t is_polyexp",
412 "Not (matchsub (?a + (?b + ?c)) t_t | " ^
413 " matchsub (?a + (?b - ?c)) t_t | " ^
414 " matchsub (?a - (?b + ?c)) t_t | " ^
415 " matchsub (?a + (?b - ?c)) t_t )",
416 "Not (matchsub (?a * (?b + ?c)) t_t | " ^
417 " matchsub (?a * (?b - ?c)) t_t | " ^
418 " matchsub ((?b + ?c) * ?a) t_t | " ^
419 " matchsub ((?b - ?c) * ?a) t_t )"]),
420 ("#Find" ,["normalform n_n"])
422 append_rls "prls_pbl_vereinf_poly" e_rls
423 [Calc ("Poly.is'_polyexp", eval_is_polyexp ""),
424 Calc ("Tools.matchsub", eval_matchsub ""),
425 Thm ("or_true", num_str @{thm or_true}),
426 (*"(?a | True) = True"*)
427 Thm ("or_false", num_str @{thm or_false}),
428 (*"(?a | False) = ?a"*)
429 Thm ("not_true",num_str @{thm not_true}),
430 (*"(~ True) = False"*)
431 Thm ("not_false",num_str @{thm not_false})
432 (*"(~ False) = True"*)],
433 SOME "Vereinfache t_t",
434 [["simplification","for_polynomials","with_minus"]]));
437 (prep_pbt thy "pbl_vereinf_poly_klammer" [] e_pblID
438 (["klammer","polynom","vereinfachen"],
439 [("#Given" ,["TERM t_t"]),
440 ("#Where" ,["t_t is_polyexp",
441 "Not (matchsub (?a * (?b + ?c)) t_t | " ^
442 " matchsub (?a * (?b - ?c)) t_t | " ^
443 " matchsub ((?b + ?c) * ?a) t_t | " ^
444 " matchsub ((?b - ?c) * ?a) t_t )"]),
445 ("#Find" ,["normalform n_n"])
447 append_rls "prls_pbl_vereinf_poly_klammer" e_rls [Calc ("Poly.is'_polyexp", eval_is_polyexp ""),
448 Calc ("Tools.matchsub", eval_matchsub ""),
449 Thm ("or_true", num_str @{thm or_true}),
450 (*"(?a | True) = True"*)
451 Thm ("or_false", num_str @{thm or_false}),
452 (*"(?a | False) = ?a"*)
453 Thm ("not_true",num_str @{thm not_true}),
454 (*"(~ True) = False"*)
455 Thm ("not_false",num_str @{thm not_false})
456 (*"(~ False) = True"*)],
457 SOME "Vereinfache t_t",
458 [["simplification","for_polynomials","with_parentheses"]]));
461 (prep_pbt thy "pbl_vereinf_poly_klammer_mal" [] e_pblID
462 (["binom_klammer","polynom","vereinfachen"],
463 [("#Given" ,["TERM t_t"]),
464 ("#Where" ,["t_t is_polyexp"]),
465 ("#Find" ,["normalform n_n"])
467 append_rls "e_rls" e_rls [(*for preds in where_*)
468 Calc ("Poly.is'_polyexp", eval_is_polyexp "")],
469 SOME "Vereinfache t_t",
470 [["simplification","for_polynomials","with_parentheses_mult"]]));
473 (prep_pbt thy "pbl_probe" [] e_pblID
475 [], Erls, NONE, []));
478 (prep_pbt thy "pbl_probe_poly" [] e_pblID
479 (["polynom","probe"],
480 [("#Given" ,["Pruefe e_e", "mitWert w_w"]),
481 ("#Where" ,["e_e is_polyexp"]),
482 ("#Find" ,["Geprueft p_p"])
484 append_rls "prls_pbl_probe_poly"
485 e_rls [(*for preds in where_*)
486 Calc ("Poly.is'_polyexp", eval_is_polyexp "")],
487 SOME "Probe e_e w_w",
488 [["probe","fuer_polynom"]]));
491 (prep_pbt thy "pbl_probe_bruch" [] e_pblID
493 [("#Given" ,["Pruefe e_e", "mitWert w_w"]),
494 ("#Where" ,["e_e is_ratpolyexp"]),
495 ("#Find" ,["Geprueft p_p"])
497 append_rls "prls_pbl_probe_bruch"
498 e_rls [(*for preds in where_*)
499 Calc ("Rational.is'_ratpolyexp", eval_is_ratpolyexp "")],
500 SOME "Probe e_e w_w",
501 [["probe","fuer_bruch"]]));
507 (prep_met thy "met_simp_poly_minus" [] e_metID
508 (["simplification","for_polynomials","with_minus"],
509 [("#Given" ,["TERM t_t"]),
510 ("#Where" ,["t_t is_polyexp",
511 "Not (matchsub (?a + (?b + ?c)) t_t | " ^
512 " matchsub (?a + (?b - ?c)) t_t | " ^
513 " matchsub (?a - (?b + ?c)) t_t | " ^
514 " matchsub (?a + (?b - ?c)) t_t )"]),
515 ("#Find" ,["normalform n_n"])
517 {rew_ord'="tless_true", rls' = e_rls, calc = [], srls = e_rls,
518 prls = append_rls "prls_met_simp_poly_minus" e_rls
519 [Calc ("Poly.is'_polyexp", eval_is_polyexp ""),
520 Calc ("Tools.matchsub", eval_matchsub ""),
521 Thm ("and_true",num_str @{thm and_true}),
522 (*"(?a & True) = ?a"*)
523 Thm ("and_false",num_str @{thm and_false}),
524 (*"(?a & False) = False"*)
525 Thm ("not_true",num_str @{thm not_true}),
526 (*"(~ True) = False"*)
527 Thm ("not_false",num_str @{thm not_false})
528 (*"(~ False) = True"*)],
529 crls = e_rls, nrls = rls_p_33},
530 "Script SimplifyScript (t_t::real) = " ^
531 " ((Repeat((Try (Rewrite_Set ordne_alphabetisch False)) @@ " ^
532 " (Try (Rewrite_Set fasse_zusammen False)) @@ " ^
533 " (Try (Rewrite_Set verschoenere False)))) t_t)"
537 (prep_met thy "met_simp_poly_parenth" [] e_metID
538 (["simplification","for_polynomials","with_parentheses"],
539 [("#Given" ,["TERM t_t"]),
540 ("#Where" ,["t_t is_polyexp"]),
541 ("#Find" ,["normalform n_n"])
543 {rew_ord'="tless_true", rls' = e_rls, calc = [], srls = e_rls,
544 prls = append_rls "simplification_for_polynomials_prls" e_rls
545 [(*for preds in where_*)
546 Calc("Poly.is'_polyexp",eval_is_polyexp"")],
547 crls = e_rls, nrls = rls_p_34},
548 "Script SimplifyScript (t_t::real) = " ^
549 " ((Repeat((Try (Rewrite_Set klammern_aufloesen False)) @@ " ^
550 " (Try (Rewrite_Set ordne_alphabetisch False)) @@ " ^
551 " (Try (Rewrite_Set fasse_zusammen False)) @@ " ^
552 " (Try (Rewrite_Set verschoenere False)))) t_t)"
556 (prep_met thy "met_simp_poly_parenth_mult" [] e_metID
557 (["simplification","for_polynomials","with_parentheses_mult"],
558 [("#Given" ,["TERM t_t"]),
559 ("#Where" ,["t_t is_polyexp"]),
560 ("#Find" ,["normalform n_n"])
562 {rew_ord'="tless_true", rls' = e_rls, calc = [], srls = e_rls,
563 prls = append_rls "simplification_for_polynomials_prls" e_rls
564 [(*for preds in where_*)
565 Calc("Poly.is'_polyexp",eval_is_polyexp"")],
566 crls = e_rls, nrls = rls_p_34},
567 "Script SimplifyScript (t_t::real) = " ^
568 " ((Repeat((Try (Rewrite_Set klammern_ausmultiplizieren False)) @@ " ^
569 " (Try (Rewrite_Set discard_parentheses False)) @@ " ^
570 " (Try (Rewrite_Set ordne_monome False)) @@ " ^
571 " (Try (Rewrite_Set klammern_aufloesen False)) @@ " ^
572 " (Try (Rewrite_Set ordne_alphabetisch False)) @@ " ^
573 " (Try (Rewrite_Set fasse_zusammen False)) @@ " ^
574 " (Try (Rewrite_Set verschoenere False)))) t_t)"
578 (prep_met thy "met_probe" [] e_metID
581 {rew_ord'="tless_true", rls' = e_rls, calc = [], srls = e_rls,
582 prls = Erls, crls = e_rls, nrls = Erls},
586 (prep_met thy "met_probe_poly" [] e_metID
587 (["probe","fuer_polynom"],
588 [("#Given" ,["Pruefe e_e", "mitWert w_w"]),
589 ("#Where" ,["e_e is_polyexp"]),
590 ("#Find" ,["Geprueft p_p"])
592 {rew_ord'="tless_true", rls' = e_rls, calc = [], srls = e_rls,
593 prls = append_rls "prls_met_probe_bruch"
594 e_rls [(*for preds in where_*)
595 Calc ("Rational.is'_ratpolyexp",
596 eval_is_ratpolyexp "")],
597 crls = e_rls, nrls = rechnen},
598 "Script ProbeScript (e_e::bool) (w_w::bool list) = " ^
599 " (let e_e = Take e_e; " ^
600 " e_e = Substitute w_w e_e " ^
601 " in (Repeat((Try (Repeat (Calculate TIMES))) @@ " ^
602 " (Try (Repeat (Calculate PLUS ))) @@ " ^
603 " (Try (Repeat (Calculate MINUS))))) e_e)"
607 (prep_met thy "met_probe_bruch" [] e_metID
608 (["probe","fuer_bruch"],
609 [("#Given" ,["Pruefe e_e", "mitWert w_w"]),
610 ("#Where" ,["e_e is_ratpolyexp"]),
611 ("#Find" ,["Geprueft p_p"])
613 {rew_ord'="tless_true", rls' = e_rls, calc = [], srls = e_rls,
614 prls = append_rls "prls_met_probe_bruch"
615 e_rls [(*for preds in where_*)
616 Calc ("Rational.is'_ratpolyexp",
617 eval_is_ratpolyexp "")],
618 crls = e_rls, nrls = Erls},