Test_Isac works again, perfectly ..
# the same tests works as in 8df4b6196660 (the *child* of "Test_Isac works...")
# ..EXCEPT those marked with "exception Div raised"
# for general state of tests see Test_Isac section {* history of tests *}.
1 (* some tests are based on specficially simple scripts etc.
2 Author: Walther Neuper 2003
3 (c) due to copyright terms
6 theory Test imports Atools Poly Rational Root Diff begin
10 (*"cancel":: [real, real] => real (infixl "'/'/'/" 70) ...divide 2002*)
15 ("((Script Expand'_binomtest (_ =))//
20 bool list] => bool list"
21 ("((Script Solve'_univar'_err (_ _ _ =))//
26 bool list] => bool list"
27 ("((Script Solve'_linear (_ _ =))//
30 (*17.9.02 aus SqRoot.thy------------------------------vvv---*)
32 "is'_root'_free" :: "'a => bool" ("is'_root'_free _" 10)
33 "contains'_root" :: "'a => bool" ("contains'_root _" 10)
35 "precond'_rootmet" :: "'a => bool" ("precond'_rootmet _" 10)
36 "precond'_rootpbl" :: "'a => bool" ("precond'_rootpbl _" 10)
37 "precond'_submet" :: "'a => bool" ("precond'_submet _" 10)
38 "precond'_subpbl" :: "'a => bool" ("precond'_subpbl _" 10)
42 bool list] => bool list"
43 ("((Script Solve'_root'_equation (_ _ =))//
48 bool list] => bool list"
49 ("((Script Solve'_plain'_square (_ _ =))//
52 Norm'_univar'_equation
55 ("((Script Norm'_univar'_equation (_ _ =))//
61 ("((Script STest'_simplify (_ =))//
64 (*17.9.02 aus SqRoot.thy------------------------------^^^---*)
66 axioms(*axiomatization where*) (*TODO: prove as theorems*)
68 radd_mult_distrib2: "(k::real) * (m + n) = k * m + k * n" (*and*)
69 rdistr_right_assoc: "(k::real) + l * n + m * n = k + (l + m) * n" (*and*)
70 rdistr_right_assoc_p: "l * n + (m * n + (k::real)) = (l + m) * n + k" (*and*)
71 rdistr_div_right: "((k::real) + l) / n = k / n + l / n" (*and*)
73 "[| l is_const; m is_const |] ==> (l::real)*n + m*n = (l + m) * n" (*and*)
75 "m is_const ==> (n::real) + m * n = (1 + m) * n" (*and*)
76 rcollect_one_left_assoc:
77 "m is_const ==> (k::real) + n + m * n = k + (1 + m) * n" (*and*)
78 rcollect_one_left_assoc_p:
79 "m is_const ==> n + (m * n + (k::real)) = (1 + m) * n + k" (*and*)
81 rtwo_of_the_same: "a + a = 2 * a" (*and*)
82 rtwo_of_the_same_assoc: "(x + a) + a = x + 2 * a" (*and*)
83 rtwo_of_the_same_assoc_p:"a + (a + x) = 2 * a + x" (*and*)
85 rcancel_den: "not(a=0) ==> a * (b / a) = b" (*and*)
86 rcancel_const: "[| a is_const; b is_const |] ==> a*(x/b) = a/b*x" (*and*)
87 rshift_nominator: "(a::real) * b / c = a / c * b" (*and*)
89 exp_pow: "(a ^^^ b) ^^^ c = a ^^^ (b * c)" (*and*)
90 rsqare: "(a::real) * a = a ^^^ 2" (*and*)
91 power_1: "(a::real) ^^^ 1 = a" (*and*)
92 rbinom_power_2: "((a::real) + b)^^^ 2 = a^^^ 2 + 2*a*b + b^^^ 2" (*and*)
94 rmult_1: "1 * k = (k::real)" (*and*)
95 rmult_1_right: "k * 1 = (k::real)" (*and*)
96 rmult_0: "0 * k = (0::real)" (*and*)
97 rmult_0_right: "k * 0 = (0::real)" (*and*)
98 radd_0: "0 + k = (k::real)" (*and*)
99 radd_0_right: "k + 0 = (k::real)" (*and*)
102 "[| a is_const; c is_const; d is_const |] ==> a/d + c/d = (a+c)/(d::real)" (*and*)
104 "[| a is_const; b is_const; c is_const; d is_const |] ==> a/b + c/d = (a*d + b*c)/(b*(d::real))"
107 radd_commute: "(m::real) + (n::real) = n + m" (*and*)
108 radd_left_commute: "(x::real) + (y + z) = y + (x + z)" (*and*)
109 radd_assoc: "(m::real) + n + k = m + (n + k)" (*and*)
110 rmult_commute: "(m::real) * n = n * m" (*and*)
111 rmult_left_commute: "(x::real) * (y * z) = y * (x * z)" (*and*)
112 rmult_assoc: "(m::real) * n * k = m * (n * k)" (*and*)
114 (*for equations: 'bdv' is a meta-constant*)
115 risolate_bdv_add: "((k::real) + bdv = m) = (bdv = m + (-1)*k)" (*and*)
116 risolate_bdv_mult_add: "((k::real) + n*bdv = m) = (n*bdv = m + (-1)*k)" (*and*)
117 risolate_bdv_mult: "((n::real) * bdv = m) = (bdv = m / n)" (*and*)
120 "~(b =!= 0) ==> (a = b) = (a + (-1)*b = 0)" (*and*)
122 (*17.9.02 aus SqRoot.thy------------------------------vvv---*)
123 root_ge0: "0 <= a ==> 0 <= sqrt a" (*and*)
124 (*should be dropped with better simplification in eval_rls ...*)
126 "[| 0 <= a; 0 <= b |] ==> (0 <= sqrt a + sqrt b) = True" (*and*)
128 "[| 0<=a; 0<=b; 0<=c |] ==> (0 <= a * sqrt b + sqrt c) = True" (*and*)
130 "[| 0<=a; 0<=b; 0<=c |] ==> (0 <= sqrt a + b * sqrt c) = True" (*and*)
133 rroot_square_inv: "(sqrt a)^^^ 2 = a" (*and*)
134 rroot_times_root: "sqrt a * sqrt b = sqrt(a*b)" (*and*)
135 rroot_times_root_assoc: "(a * sqrt b) * sqrt c = a * sqrt(b*c)" (*and*)
136 rroot_times_root_assoc_p: "sqrt b * (sqrt c * a)= sqrt(b*c) * a" (*and*)
139 (*for root-equations*)
140 square_equation_left:
141 "[| 0 <= a; 0 <= b |] ==> (((sqrt a)=b)=(a=(b^^^ 2)))" (*and*)
142 square_equation_right:
143 "[| 0 <= a; 0 <= b |] ==> ((a=(sqrt b))=((a^^^ 2)=b))" (*and*)
144 (*causes frequently non-termination:*)
146 "[| 0 <= a; 0 <= b |] ==> ((a=b)=((a^^^ 2)=b^^^ 2))" (*and*)
148 risolate_root_add: "(a+ sqrt c = d) = ( sqrt c = d + (-1)*a)" (*and*)
149 risolate_root_mult: "(a+b*sqrt c = d) = (b*sqrt c = d + (-1)*a)" (*and*)
150 risolate_root_div: "(a * sqrt c = d) = ( sqrt c = d / a)" (*and*)
152 (*for polynomial equations of degree 2; linear case in RatArith*)
153 mult_square: "(a*bdv^^^2 = b) = (bdv^^^2 = b / a)" (*and*)
154 constant_square: "(a + bdv^^^2 = b) = (bdv^^^2 = b + -1*a)" (*and*)
155 constant_mult_square: "(a + b*bdv^^^2 = c) = (b*bdv^^^2 = c + -1*a)" (*and*)
158 "0 <= a ==> (x^^^2 = a) = ((x=sqrt a) | (x=-1*sqrt a))" (*and*)
160 "(x^^^2 = 0) = (x = 0)" (*and*)
162 (*isolate root on the LEFT hand side of the equation
163 otherwise shuffling from left to right would not terminate*)
166 "is_root_free a ==> (a = sqrt b) = (a + (-1)*sqrt b = 0)" (*and*)
168 "is_root_free a ==> (a = c*sqrt b) = (a + (-1)*c*sqrt b = 0)" (*and*)
169 rroot_to_lhs_add_mult:
170 "is_root_free a ==> (a = d+c*sqrt b) = (a + (-1)*c*sqrt b = d)"
171 (*17.9.02 aus SqRoot.thy------------------------------^^^---*)
176 (** evaluation of numerals and predicates **)
178 (*does a term contain a root ? WN110518 seems incorrect, compare contains_root*)
179 fun eval_root_free (thmid:string) _ (t as (Const (op0, t0) $ arg)) thy =
180 if strip_thy op0 <> "is'_root'_free"
181 then error ("eval_root_free: wrong " ^ op0)
182 else if const_in (strip_thy op0) arg
183 then SOME (mk_thmid thmid "" (term_to_string''' thy arg)"",
184 Trueprop $ (mk_equality (t, @{term False})))
185 else SOME (mk_thmid thmid "" (term_to_string''' thy arg)"",
186 Trueprop $ (mk_equality (t, @{term True})))
187 | eval_root_free _ _ _ _ = NONE;
189 (*does a term contain a root ?*)
190 fun eval_contains_root (thmid:string) _
191 (t as (Const("Test.contains'_root",t0) $ arg)) thy =
192 if member op = (ids_of arg) "sqrt"
193 then SOME (mk_thmid thmid "" (term_to_string''' thy arg)"",
194 Trueprop $ (mk_equality (t, @{term True})))
195 else SOME (mk_thmid thmid "" (term_to_string''' thy arg)"",
196 Trueprop $ (mk_equality (t, @{term False})))
197 | eval_contains_root _ _ _ _ = NONE;
199 (*dummy precondition for root-met of x+1=2*)
200 fun eval_precond_rootmet (thmid:string) _ (t as (Const ("Test.precond'_rootmet", _) $ arg)) thy =
201 SOME (mk_thmid thmid "" (term_to_string''' thy arg)"",
202 Trueprop $ (mk_equality (t, @{term True})))
203 | eval_precond_rootmet _ _ _ _ = NONE;
205 (*dummy precondition for root-pbl of x+1=2*)
206 fun eval_precond_rootpbl (thmid:string) _ (t as (Const ("Test.precond'_rootpbl", _) $ arg)) thy =
207 SOME (mk_thmid thmid "" (term_to_string''' thy arg) "",
208 Trueprop $ (mk_equality (t, @{term True})))
209 | eval_precond_rootpbl _ _ _ _ = NONE;
211 calclist':= overwritel (!calclist',
212 [("is_root_free", ("Test.is'_root'_free",
213 eval_root_free"#is_root_free_e")),
214 ("contains_root", ("Test.contains'_root",
215 eval_contains_root"#contains_root_")),
216 ("Test.precond'_rootmet", ("Test.precond'_rootmet",
217 eval_precond_rootmet"#Test.precond_rootmet_")),
218 ("Test.precond'_rootpbl", ("Test.precond'_rootpbl",
219 eval_precond_rootpbl"#Test.precond_rootpbl_"))
223 fun term_order (_:subst) tu = (term_ordI [] tu = LESS);
229 Rls {id = "testerls", preconds = [], rew_ord = ("termlessI",termlessI),
230 erls = e_rls, srls = Erls,
231 calc = [], errpatts = [],
232 rules = [Thm ("refl",num_str @{thm refl}),
233 Thm ("order_refl",num_str @{thm order_refl}),
234 Thm ("radd_left_cancel_le",num_str @{thm radd_left_cancel_le}),
235 Thm ("not_true",num_str @{thm not_true}),
236 Thm ("not_false",num_str @{thm not_false}),
237 Thm ("and_true",num_str @{thm and_true}),
238 Thm ("and_false",num_str @{thm and_false}),
239 Thm ("or_true",num_str @{thm or_true}),
240 Thm ("or_false",num_str @{thm or_false}),
241 Thm ("and_commute",num_str @{thm and_commute}),
242 Thm ("or_commute",num_str @{thm or_commute}),
244 Calc ("Atools.is'_const",eval_const "#is_const_"),
245 Calc ("Tools.matches",eval_matches ""),
247 Calc ("Groups.plus_class.plus",eval_binop "#add_"),
248 Calc ("Groups.times_class.times",eval_binop "#mult_"),
249 Calc ("Atools.pow" ,eval_binop "#power_"),
251 Calc ("Orderings.ord_class.less",eval_equ "#less_"),
252 Calc ("Orderings.ord_class.less_eq",eval_equ "#less_equal_"),
254 Calc ("Atools.ident",eval_ident "#ident_")],
255 scr = Prog ((term_of o the o (parse thy)) "empty_script")
259 (*.for evaluation of conditions in rewrite rules.*)
260 (*FIXXXXXXME 10.8.02: handle like _simplify*)
262 Rls{id = "tval_rls", preconds = [],
263 rew_ord = ("sqrt_right",sqrt_right false (Thy_Info.get_theory "Pure")),
264 erls=testerls,srls = e_rls,
265 calc=[], errpatts = [],
266 rules = [Thm ("refl",num_str @{thm refl}),
267 Thm ("order_refl",num_str @{thm order_refl}),
268 Thm ("radd_left_cancel_le",num_str @{thm radd_left_cancel_le}),
269 Thm ("not_true",num_str @{thm not_true}),
270 Thm ("not_false",num_str @{thm not_false}),
271 Thm ("and_true",num_str @{thm and_true}),
272 Thm ("and_false",num_str @{thm and_false}),
273 Thm ("or_true",num_str @{thm or_true}),
274 Thm ("or_false",num_str @{thm or_false}),
275 Thm ("and_commute",num_str @{thm and_commute}),
276 Thm ("or_commute",num_str @{thm or_commute}),
278 Thm ("real_diff_minus",num_str @{thm real_diff_minus}),
280 Thm ("root_ge0",num_str @{thm root_ge0}),
281 Thm ("root_add_ge0",num_str @{thm root_add_ge0}),
282 Thm ("root_ge0_1",num_str @{thm root_ge0_1}),
283 Thm ("root_ge0_2",num_str @{thm root_ge0_2}),
285 Calc ("Atools.is'_const",eval_const "#is_const_"),
286 Calc ("Test.is'_root'_free",eval_root_free "#is_root_free_e"),
287 Calc ("Tools.matches",eval_matches ""),
288 Calc ("Test.contains'_root",
289 eval_contains_root"#contains_root_"),
291 Calc ("Groups.plus_class.plus",eval_binop "#add_"),
292 Calc ("Groups.times_class.times",eval_binop "#mult_"),
293 Calc ("NthRoot.sqrt",eval_sqrt "#sqrt_"),
294 Calc ("Atools.pow" ,eval_binop "#power_"),
296 Calc ("Orderings.ord_class.less",eval_equ "#less_"),
297 Calc ("Orderings.ord_class.less_eq",eval_equ "#less_equal_"),
299 Calc ("Atools.ident",eval_ident "#ident_")],
300 scr = Prog ((term_of o the o (parse thy)) "empty_script")
305 ruleset' := overwritelthy @{theory} (!ruleset',
306 [("testerls", prep_rls testerls)
310 (*make () dissappear*)
311 val rearrange_assoc =
312 Rls{id = "rearrange_assoc", preconds = [],
313 rew_ord = ("e_rew_ord",e_rew_ord),
314 erls = e_rls, srls = e_rls, calc = [], errpatts = [],
316 [Thm ("sym_add_assoc",num_str (@{thm add_assoc} RS @{thm sym})),
317 Thm ("sym_rmult_assoc",num_str (@{thm rmult_assoc} RS @{thm sym}))],
318 scr = Prog ((term_of o the o (parse thy)) "empty_script")
322 Rls{id = "ac_plus_times", preconds = [], rew_ord = ("term_order",term_order),
323 erls = e_rls, srls = e_rls, calc = [], errpatts = [],
325 [Thm ("radd_commute",num_str @{thm radd_commute}),
326 Thm ("radd_left_commute",num_str @{thm radd_left_commute}),
327 Thm ("add_assoc",num_str @{thm add_assoc}),
328 Thm ("rmult_commute",num_str @{thm rmult_commute}),
329 Thm ("rmult_left_commute",num_str @{thm rmult_left_commute}),
330 Thm ("rmult_assoc",num_str @{thm rmult_assoc})],
331 scr = Prog ((term_of o the o (parse thy)) "empty_script")
334 (*todo: replace by Rewrite("rnorm_equation_add",num_str @{thm rnorm_equation_add)*)
336 Rls{id = "norm_equation", preconds = [], rew_ord = ("e_rew_ord",e_rew_ord),
337 erls = tval_rls, srls = e_rls, calc = [], errpatts = [],
338 rules = [Thm ("rnorm_equation_add",num_str @{thm rnorm_equation_add})
340 scr = Prog ((term_of o the o (parse thy)) "empty_script")
346 val STest_simplify = (* vv--- not changed to real by parse*)
347 "Script STest_simplify (t_t::'z) = " ^
349 " ((Try (Repeat (Rewrite real_diff_minus False))) @@ " ^
350 " (Try (Repeat (Rewrite radd_mult_distrib2 False))) @@ " ^
351 " (Try (Repeat (Rewrite rdistr_right_assoc False))) @@ " ^
352 " (Try (Repeat (Rewrite rdistr_right_assoc_p False))) @@" ^
353 " (Try (Repeat (Rewrite rdistr_div_right False))) @@ " ^
354 " (Try (Repeat (Rewrite rbinom_power_2 False))) @@ " ^
356 " (Try (Repeat (Rewrite radd_commute False))) @@ " ^
357 " (Try (Repeat (Rewrite radd_left_commute False))) @@ " ^
358 " (Try (Repeat (Rewrite add_assoc False))) @@ " ^
359 " (Try (Repeat (Rewrite rmult_commute False))) @@ " ^
360 " (Try (Repeat (Rewrite rmult_left_commute False))) @@ " ^
361 " (Try (Repeat (Rewrite rmult_assoc False))) @@ " ^
363 " (Try (Repeat (Rewrite radd_real_const_eq False))) @@ " ^
364 " (Try (Repeat (Rewrite radd_real_const False))) @@ " ^
365 " (Try (Repeat (Calculate PLUS))) @@ " ^
366 " (Try (Repeat (Calculate TIMES))) @@ " ^
367 " (Try (Repeat (Calculate divide_))) @@" ^
368 " (Try (Repeat (Calculate POWER))) @@ " ^
370 " (Try (Repeat (Rewrite rcollect_right False))) @@ " ^
371 " (Try (Repeat (Rewrite rcollect_one_left False))) @@ " ^
372 " (Try (Repeat (Rewrite rcollect_one_left_assoc False))) @@ " ^
373 " (Try (Repeat (Rewrite rcollect_one_left_assoc_p False))) @@ " ^
375 " (Try (Repeat (Rewrite rshift_nominator False))) @@ " ^
376 " (Try (Repeat (Rewrite rcancel_den False))) @@ " ^
377 " (Try (Repeat (Rewrite rroot_square_inv False))) @@ " ^
378 " (Try (Repeat (Rewrite rroot_times_root False))) @@ " ^
379 " (Try (Repeat (Rewrite rroot_times_root_assoc_p False))) @@ " ^
380 " (Try (Repeat (Rewrite rsqare False))) @@ " ^
381 " (Try (Repeat (Rewrite power_1 False))) @@ " ^
382 " (Try (Repeat (Rewrite rtwo_of_the_same False))) @@ " ^
383 " (Try (Repeat (Rewrite rtwo_of_the_same_assoc_p False))) @@ " ^
385 " (Try (Repeat (Rewrite rmult_1 False))) @@ " ^
386 " (Try (Repeat (Rewrite rmult_1_right False))) @@ " ^
387 " (Try (Repeat (Rewrite rmult_0 False))) @@ " ^
388 " (Try (Repeat (Rewrite rmult_0_right False))) @@ " ^
389 " (Try (Repeat (Rewrite radd_0 False))) @@ " ^
390 " (Try (Repeat (Rewrite radd_0_right False)))) " ^
395 (* expects * distributed over + *)
397 Rls{id = "Test_simplify", preconds = [],
398 rew_ord = ("sqrt_right",sqrt_right false (Thy_Info.get_theory "Pure")),
399 erls = tval_rls, srls = e_rls,
400 calc=[(*since 040209 filled by prep_rls*)], errpatts = [],
402 Thm ("real_diff_minus",num_str @{thm real_diff_minus}),
403 Thm ("radd_mult_distrib2",num_str @{thm radd_mult_distrib2}),
404 Thm ("rdistr_right_assoc",num_str @{thm rdistr_right_assoc}),
405 Thm ("rdistr_right_assoc_p",num_str @{thm rdistr_right_assoc_p}),
406 Thm ("rdistr_div_right",num_str @{thm rdistr_div_right}),
407 Thm ("rbinom_power_2",num_str @{thm rbinom_power_2}),
409 Thm ("radd_commute",num_str @{thm radd_commute}),
410 Thm ("radd_left_commute",num_str @{thm radd_left_commute}),
411 Thm ("add_assoc",num_str @{thm add_assoc}),
412 Thm ("rmult_commute",num_str @{thm rmult_commute}),
413 Thm ("rmult_left_commute",num_str @{thm rmult_left_commute}),
414 Thm ("rmult_assoc",num_str @{thm rmult_assoc}),
416 Thm ("radd_real_const_eq",num_str @{thm radd_real_const_eq}),
417 Thm ("radd_real_const",num_str @{thm radd_real_const}),
418 (* these 2 rules are invers to distr_div_right wrt. termination.
419 thus they MUST be done IMMEDIATELY before calc *)
420 Calc ("Groups.plus_class.plus", eval_binop "#add_"),
421 Calc ("Groups.times_class.times", eval_binop "#mult_"),
422 Calc ("Fields.inverse_class.divide", eval_cancel "#divide_e"),
423 Calc ("Atools.pow", eval_binop "#power_"),
425 Thm ("rcollect_right",num_str @{thm rcollect_right}),
426 Thm ("rcollect_one_left",num_str @{thm rcollect_one_left}),
427 Thm ("rcollect_one_left_assoc",num_str @{thm rcollect_one_left_assoc}),
428 Thm ("rcollect_one_left_assoc_p",num_str @{thm rcollect_one_left_assoc_p}),
430 Thm ("rshift_nominator",num_str @{thm rshift_nominator}),
431 Thm ("rcancel_den",num_str @{thm rcancel_den}),
432 Thm ("rroot_square_inv",num_str @{thm rroot_square_inv}),
433 Thm ("rroot_times_root",num_str @{thm rroot_times_root}),
434 Thm ("rroot_times_root_assoc_p",num_str @{thm rroot_times_root_assoc_p}),
435 Thm ("rsqare",num_str @{thm rsqare}),
436 Thm ("power_1",num_str @{thm power_1}),
437 Thm ("rtwo_of_the_same",num_str @{thm rtwo_of_the_same}),
438 Thm ("rtwo_of_the_same_assoc_p",num_str @{thm rtwo_of_the_same_assoc_p}),
440 Thm ("rmult_1",num_str @{thm rmult_1}),
441 Thm ("rmult_1_right",num_str @{thm rmult_1_right}),
442 Thm ("rmult_0",num_str @{thm rmult_0}),
443 Thm ("rmult_0_right",num_str @{thm rmult_0_right}),
444 Thm ("radd_0",num_str @{thm radd_0}),
445 Thm ("radd_0_right",num_str @{thm radd_0_right})
447 scr = Prog ((term_of o the o (parse thy)) "empty_script")
448 (*since 040209 filled by prep_rls: STest_simplify*)
457 (*isolate the root in a root-equation*)
459 Rls{id = "isolate_root", preconds = [], rew_ord = ("e_rew_ord",e_rew_ord),
460 erls=tval_rls,srls = e_rls, calc=[], errpatts = [],
461 rules = [Thm ("rroot_to_lhs",num_str @{thm rroot_to_lhs}),
462 Thm ("rroot_to_lhs_mult",num_str @{thm rroot_to_lhs_mult}),
463 Thm ("rroot_to_lhs_add_mult",num_str @{thm rroot_to_lhs_add_mult}),
464 Thm ("risolate_root_add",num_str @{thm risolate_root_add}),
465 Thm ("risolate_root_mult",num_str @{thm risolate_root_mult}),
466 Thm ("risolate_root_div",num_str @{thm risolate_root_div}) ],
467 scr = Prog ((term_of o the o (parse thy))
471 (*isolate the bound variable in an equation; 'bdv' is a meta-constant*)
473 Rls{id = "isolate_bdv", preconds = [], rew_ord = ("e_rew_ord",e_rew_ord),
474 erls=tval_rls,srls = e_rls, calc= [], errpatts = [],
476 [Thm ("risolate_bdv_add",num_str @{thm risolate_bdv_add}),
477 Thm ("risolate_bdv_mult_add",num_str @{thm risolate_bdv_mult_add}),
478 Thm ("risolate_bdv_mult",num_str @{thm risolate_bdv_mult}),
479 Thm ("mult_square",num_str @{thm mult_square}),
480 Thm ("constant_square",num_str @{thm constant_square}),
481 Thm ("constant_mult_square",num_str @{thm constant_mult_square})
483 scr = Prog ((term_of o the o (parse thy))
489 (* association list for calculate_, calculate
490 "Groups.plus_class.plus" etc. not usable in scripts *)
494 ("Vars" ,("Tools.Vars" ,eval_var "#Vars_")),
495 ("matches",("Tools.matches",eval_matches "#matches_")),
496 ("lhs" ,("Tools.lhs" ,eval_lhs "")),
498 ("PLUS" ,("Groups.plus_class.plus" ,eval_binop "#add_")),
499 ("TIMES" ,("Groups.times_class.times" ,eval_binop "#mult_")),
500 ("DIVIDE" ,("Fields.inverse_class.divide" ,eval_cancel "#divide_e")),
501 ("POWER" ,("Atools.pow" ,eval_binop "#power_")),
502 ("is_const",("Atools.is'_const",eval_const "#is_const_")),
503 ("le" ,("Orderings.ord_class.less" ,eval_equ "#less_")),
504 ("leq" ,("Orderings.ord_class.less_eq" ,eval_equ "#less_equal_")),
505 ("ident" ,("Atools.ident",eval_ident "#ident_")),
506 (*von hier (ehem.SqRoot*)
507 ("sqrt" ,("NthRoot.sqrt" ,eval_sqrt "#sqrt_")),
508 ("Test.is_root_free",("is'_root'_free", eval_root_free"#is_root_free_e")),
509 ("Test.contains_root",("contains'_root",
510 eval_contains_root"#contains_root_"))
513 ruleset' := overwritelthy @{theory} (!ruleset',
514 [("Test_simplify", prep_rls Test_simplify),
515 ("tval_rls", prep_rls tval_rls),
516 ("isolate_root", prep_rls isolate_root),
517 ("isolate_bdv", prep_rls isolate_bdv),
519 prep_rls (append_rls "matches" testerls
520 [Calc ("Tools.matches",eval_matches "#matches_")]))
525 (** problem types **)
527 (prep_pbt thy "pbl_test" [] e_pblID
532 (prep_pbt thy "pbl_test_equ" [] e_pblID
533 (["equation","test"],
534 [("#Given" ,["equality e_e","solveFor v_v"]),
535 ("#Where" ,["matches (?a = ?b) e_e"]),
536 ("#Find" ,["solutions v_v'i'"])
539 SOME "solve (e_e::bool, v_v)", []));
542 (prep_pbt thy "pbl_test_uni" [] e_pblID
543 (["univariate","equation","test"],
544 [("#Given" ,["equality e_e","solveFor v_v"]),
545 ("#Where" ,["matches (?a = ?b) e_e"]),
546 ("#Find" ,["solutions v_v'i'"])
549 SOME "solve (e_e::bool, v_v)", []));
552 (prep_pbt thy "pbl_test_uni_lin" [] e_pblID
553 (["linear","univariate","equation","test"],
554 [("#Given" ,["equality e_e","solveFor v_v"]),
555 ("#Where" ,["(matches ( v_v = 0) e_e) | (matches ( ?b*v_v = 0) e_e) |" ^
556 "(matches (?a+v_v = 0) e_e) | (matches (?a+?b*v_v = 0) e_e) "]),
557 ("#Find" ,["solutions v_v'i'"])
560 SOME "solve (e_e::bool, v_v)", [["Test","solve_linear"]]));
566 [("#Given" ,"boolTestGiven g_g"),
567 ("#Find" ,"boolTestFind f_f")
574 [("#Given" ,"boolTestGiven g_g"),
575 ("#Find" ,"boolTestFind f_f")
580 val ttt = (term_of o the o (parse (Thy_Info.get_theory "Isac"))) "(matches ( v_v = 0) e_e)";
588 (prep_met @{theory "Diff"} "met_test" [] e_metID
591 {rew_ord'="tless_true",rls'=Atools_erls,calc = [], srls = e_rls, prls=e_rls,
592 crls=Atools_erls, errpats = [], nrls = e_rls}, "empty_script"));
596 (prep_met thy "met_test_solvelin" [] e_metID
597 (["Test","solve_linear"]:metID,
598 [("#Given" ,["equality e_e","solveFor v_v"]),
599 ("#Where" ,["matches (?a = ?b) e_e"]),
600 ("#Find" ,["solutions v_v'i'"])
602 {rew_ord' = "e_rew_ord", rls' = tval_rls, srls = e_rls,
603 prls = assoc_rls "matches", calc = [], crls = tval_rls,
604 errpats = [], nrls = Test_simplify},
605 "Script Solve_linear (e_e::bool) (v_v::real)= " ^
608 " (((Rewrite_Set_Inst [(bdv,v_v::real)] isolate_bdv False) @@ " ^
609 " (Rewrite_Set Test_simplify False))) e_e" ^
612 (*, prep_met thy (*test for equations*)
613 (["Test","testeq"]:metID,
614 [("#Given" ,["boolTestGiven g_g"]),
615 ("#Find" ,["boolTestFind f_f"])
617 {rew_ord'="e_rew_ord",rls'="tval_rls",asm_rls=[],
618 asm_thm=[("square_equation_left","")]},
619 "Script Testeq (e_q::bool) = " ^
621 " (let e_e = Try (Repeat (Rewrite rroot_square_inv False e_q)); " ^
622 " e_e = Try (Repeat (Rewrite square_equation_left True e_e)); " ^
623 " e_e = Try (Repeat (Rewrite rmult_0 False e_e)) " ^
624 " in e_e) Until (is_root_free e_e)" (*deleted*)
631 ruleset' := overwritelthy @{theory} (!ruleset',
632 [("norm_equation", prep_rls norm_equation),
633 ("ac_plus_times", prep_rls ac_plus_times),
634 ("rearrange_assoc", prep_rls rearrange_assoc)
638 fun bin_o (Const (op_,(Type ("fun",
639 [Type (s2,[]),Type ("fun",
640 [Type (s4,tl4),Type (s5,tl5)])])))) =
641 if (s2=s4)andalso(s4=s5)then[op_]else[]
644 fun bin_op (t1 $ t2) = union op = (bin_op t1) (bin_op t2)
645 | bin_op t = bin_o t;
646 fun is_bin_op t = ((bin_op t)<>[]);
648 fun bin_op_arg1 ((Const (op_,(Type ("fun",
649 [Type (s2,[]),Type ("fun",
650 [Type (s4,tl4),Type (s5,tl5)])]))))$ arg1 $ arg2) =
652 fun bin_op_arg2 ((Const (op_,(Type ("fun",
653 [Type (s2,[]),Type ("fun",
654 [Type (s4,tl4),Type (s5,tl5)])]))))$ arg1 $ arg2) =
658 exception NO_EQUATION_TERM;
659 fun is_equation ((Const ("HOL.eq",(Type ("fun",
660 [Type (_,[]),Type ("fun",
661 [Type (_,[]),Type ("bool",[])])])))) $ _ $ _)
663 | is_equation _ = false;
664 fun equ_lhs ((Const ("HOL.eq",(Type ("fun",
665 [Type (_,[]),Type ("fun",
666 [Type (_,[]),Type ("bool",[])])])))) $ l $ r)
668 | equ_lhs _ = raise NO_EQUATION_TERM;
669 fun equ_rhs ((Const ("HOL.eq",(Type ("fun",
670 [Type (_,[]),Type ("fun",
671 [Type (_,[]),Type ("bool",[])])])))) $ l $ r)
673 | equ_rhs _ = raise NO_EQUATION_TERM;
676 fun atom (Const (_,Type (_,[]))) = true
677 | atom (Free (_,Type (_,[]))) = true
678 | atom (Var (_,Type (_,[]))) = true
679 (*| atom (_ (_,"?DUMMY" )) = true ..ML-error *)
680 | atom((Const ("Bin.integ_of_bin",_)) $ _) = true
683 fun varids (Const (s,Type (_,[]))) = [strip_thy s]
684 | varids (Free (s,Type (_,[]))) = if is_no s then []
686 | varids (Var((s,_),Type (_,[]))) = [strip_thy s]
687 (*| varids (_ (s,"?DUMMY" )) = ..ML-error *)
688 | varids((Const ("Bin.integ_of_bin",_)) $ _)= [](*8.01: superfluous?*)
689 | varids (Abs(a,T,t)) = union op = [a] (varids t)
690 | varids (t1 $ t2) = union op = (varids t1) (varids t2)
692 (*> val t = term_of (hd (parse Diophant.thy "x"));
693 val t = Free ("x","?DUMMY") : term
695 val it = [] : string list [] !!! *)
698 fun bin_ops_only ((Const op_) $ t1 $ t2) =
699 if(is_bin_op (Const op_))
700 then(bin_ops_only t1)andalso(bin_ops_only t2)
703 if atom t then true else bin_ops_only t;
705 fun polynomial opl t bdVar = (* bdVar TODO *)
706 subset op = (bin_op t, opl) andalso (bin_ops_only t);
708 fun poly_equ opl bdVar t = is_equation t (* bdVar TODO *)
709 andalso polynomial opl (equ_lhs t) bdVar
710 andalso polynomial opl (equ_rhs t) bdVar
711 andalso (subset op = (varids bdVar, varids (equ_lhs t)) orelse
712 subset op = (varids bdVar, varids (equ_lhs t)));
715 let fun max_ m [] = m
716 | max_ m (i::is) = if m<i then max_ i is else max_ m is;
717 in max_ (hd is) is end;
721 fun max (a,b) = if a < b then b else a;
723 fun degree addl mul bdVar t =
725 fun deg _ _ v (Const (s,Type (_,[]))) = if v=strip_thy s then 1 else 0
726 | deg _ _ v (Free (s,Type (_,[]))) = if v=strip_thy s then 1 else 0
727 | deg _ _ v (Var((s,_),Type (_,[]))) = if v=strip_thy s then 1 else 0
728 (*| deg _ _ v (_ (s,"?DUMMY" )) = ..ML-error *)
729 | deg _ _ v((Const ("Bin.integ_of_bin",_)) $ _ )= 0
730 | deg addl mul v (h $ t1 $ t2) =
731 if subset op = (bin_op h, addl)
732 then max (deg addl mul v t1 ,deg addl mul v t2)
733 else (*mul!*)(deg addl mul v t1)+(deg addl mul v t2)
734 in if polynomial (addl @ [mul]) t bdVar
735 then SOME (deg addl mul (id_of bdVar) t) else (NONE:int option)
737 fun degree_ addl mul bdVar t = (* do not export *)
738 let fun opt (SOME i)= i
740 in opt (degree addl mul bdVar t) end;
743 fun linear addl mul t bdVar = (degree_ addl mul bdVar t)<2;
745 fun linear_equ addl mul bdVar t =
747 then let val degl = degree_ addl mul bdVar (equ_lhs t);
748 val degr = degree_ addl mul bdVar (equ_rhs t)
749 in if (degl>0 orelse degr>0)andalso max(degl,degr)<2
753 (* strip_thy op_ before *)
754 fun is_div_op (dv,(Const (op_,(Type ("fun",
755 [Type (s2,[]),Type ("fun",
756 [Type (s4,tl4),Type (s5,tl5)])])))) )= (dv = strip_thy op_)
757 | is_div_op _ = false;
759 fun is_denom bdVar div_op t =
760 let fun is bool[v]dv (Const (s,Type(_,[])))= bool andalso(if v=strip_thy s then true else false)
761 | is bool[v]dv (Free (s,Type(_,[])))= bool andalso(if v=strip_thy s then true else false)
762 | is bool[v]dv (Var((s,_),Type(_,[])))= bool andalso(if v=strip_thy s then true else false)
763 | is bool[v]dv((Const ("Bin.integ_of_bin",_)) $ _) = false
764 | is bool[v]dv (h$n$d) =
766 then (is false[v]dv n)orelse(is true[v]dv d)
767 else (is bool [v]dv n)orelse(is bool[v]dv d)
768 in is false (varids bdVar) (strip_thy div_op) t end;
771 fun rational t div_op bdVar =
772 is_denom bdVar div_op t andalso bin_ops_only t;
777 (** problem types **)
780 (prep_pbt thy "pbl_test_uni_plain2" [] e_pblID
781 (["plain_square","univariate","equation","test"],
782 [("#Given" ,["equality e_e","solveFor v_v"]),
783 ("#Where" ,["(matches (?a + ?b*v_v ^^^2 = 0) e_e) |" ^
784 "(matches ( ?b*v_v ^^^2 = 0) e_e) |" ^
785 "(matches (?a + v_v ^^^2 = 0) e_e) |" ^
786 "(matches ( v_v ^^^2 = 0) e_e)"]),
787 ("#Find" ,["solutions v_v'i'"])
790 SOME "solve (e_e::bool, v_v)", [["Test","solve_plain_square"]]));
792 val e_e = (term_of o the o (parse thy)) "e_e::bool";
793 val ve = (term_of o the o (parse thy)) "4 + 3*x^^^2 = 0";
796 val pre = (term_of o the o (parse thy))
797 "(matches (a + b*v_v ^^^2 = 0, e_e::bool)) |" ^
798 "(matches ( b*v_v ^^^2 = 0, e_e::bool)) |" ^
799 "(matches (a + v_v ^^^2 = 0, e_e::bool)) |" ^
800 "(matches ( v_v ^^^2 = 0, e_e::bool))";
801 val prei = subst_atomic env pre;
802 val cpre = (cterm_of thy) prei;
804 val SOME (ct,_) = rewrite_set_ thy false tval_rls cpre;
805 val ct = "True | False | False | False" : cterm
807 > val SOME (ct,_) = rewrite_ thy sqrt_right tval_rls false or_false ct;
808 > val SOME (ct,_) = rewrite_ thy sqrt_right tval_rls false or_false ct;
809 > val SOME (ct,_) = rewrite_ thy sqrt_right tval_rls false or_false ct;
810 val ct = "HOL.True" : cterm
817 (prep_pbt thy "pbl_test_uni_poly" [] e_pblID
818 (["polynomial","univariate","equation","test"],
819 [("#Given" ,["equality (v_v ^^^2 + p_p * v_v + q__q = 0)","solveFor v_v"]),
820 ("#Where" ,["HOL.False"]),
821 ("#Find" ,["solutions v_v'i'"])
823 e_rls, SOME "solve (e_e::bool, v_v)", []));
826 (prep_pbt thy "pbl_test_uni_poly_deg2" [] e_pblID
827 (["degree_two","polynomial","univariate","equation","test"],
828 [("#Given" ,["equality (v_v ^^^2 + p_p * v_v + q__q = 0)","solveFor v_v"]),
829 ("#Find" ,["solutions v_v'i'"])
831 e_rls, SOME "solve (v_v ^^^2 + p_p * v_v + q__q = 0, v_v)", []));
834 (prep_pbt thy "pbl_test_uni_poly_deg2_pq" [] e_pblID
835 (["pq_formula","degree_two","polynomial","univariate","equation","test"],
836 [("#Given" ,["equality (v_v ^^^2 + p_p * v_v + q__q = 0)","solveFor v_v"]),
837 ("#Find" ,["solutions v_v'i'"])
839 e_rls, SOME "solve (v_v ^^^2 + p_p * v_v + q__q = 0, v_v)", []));
842 (prep_pbt thy "pbl_test_uni_poly_deg2_abc" [] e_pblID
843 (["abc_formula","degree_two","polynomial","univariate","equation","test"],
844 [("#Given" ,["equality (a_a * x ^^^2 + b_b * x + c_c = 0)","solveFor v_v"]),
845 ("#Find" ,["solutions v_v'i'"])
847 e_rls, SOME "solve (a_a * x ^^^2 + b_b * x + c_c = 0, v_v)", []));
852 (prep_pbt thy "pbl_test_uni_root" [] e_pblID
853 (["squareroot","univariate","equation","test"],
854 [("#Given" ,["equality e_e","solveFor v_v"]),
855 ("#Where" ,["precond_rootpbl v_v"]),
856 ("#Find" ,["solutions v_v'i'"])
858 append_rls "contains_root" e_rls [Calc ("Test.contains'_root",
859 eval_contains_root "#contains_root_")],
860 SOME "solve (e_e::bool, v_v)", [["Test","square_equation"]]));
863 (prep_pbt thy "pbl_test_uni_norm" [] e_pblID
864 (["normalize","univariate","equation","test"],
865 [("#Given" ,["equality e_e","solveFor v_v"]),
867 ("#Find" ,["solutions v_v'i'"])
869 e_rls, SOME "solve (e_e::bool, v_v)", [["Test","norm_univar_equation"]]));
872 (prep_pbt thy "pbl_test_uni_roottest" [] e_pblID
873 (["sqroot-test","univariate","equation","test"],
874 [("#Given" ,["equality e_e","solveFor v_v"]),
875 ("#Where" ,["precond_rootpbl v_v"]),
876 ("#Find" ,["solutions v_v'i'"])
878 e_rls, SOME "solve (e_e::bool, v_v)", []));
881 (prep_pbt thy "pbl_test_intsimp" [] e_pblID
883 [("#Given" ,["intTestGiven t_t"]),
885 ("#Find" ,["intTestFind s_s"])
887 e_rls, NONE, [["Test","intsimp"]]));
890 get_pbt ["inttype","test"];
897 (prep_met thy "met_test_sqrt" [] e_metID
898 (*root-equation, version for tests before 8.01.01*)
899 (["Test","sqrt-equ-test"]:metID,
900 [("#Given" ,["equality e_e","solveFor v_v"]),
901 ("#Where" ,["contains_root (e_e::bool)"]),
902 ("#Find" ,["solutions v_v'i'"])
904 {rew_ord'="e_rew_ord",rls'=tval_rls,
905 srls =append_rls "srls_contains_root" e_rls
906 [Calc ("Test.contains'_root",eval_contains_root "")],
907 prls =append_rls "prls_contains_root" e_rls
908 [Calc ("Test.contains'_root",eval_contains_root "")],
910 crls=tval_rls, errpats = [], nrls = e_rls(*,asm_rls=[],
911 asm_thm=[("square_equation_left",""),
912 ("square_equation_right","")]*)},
913 "Script Solve_root_equation (e_e::bool) (v_v::real) = " ^
915 " ((While (contains_root e_e) Do" ^
916 " ((Rewrite square_equation_left True) @@" ^
917 " (Try (Rewrite_Set Test_simplify False)) @@" ^
918 " (Try (Rewrite_Set rearrange_assoc False)) @@" ^
919 " (Try (Rewrite_Set isolate_root False)) @@" ^
920 " (Try (Rewrite_Set Test_simplify False)))) @@" ^
921 " (Try (Rewrite_Set norm_equation False)) @@" ^
922 " (Try (Rewrite_Set Test_simplify False)) @@" ^
923 " (Rewrite_Set_Inst [(bdv,v_v::real)] isolate_bdv False) @@" ^
924 " (Try (Rewrite_Set Test_simplify False)))" ^
932 (prep_met thy "met_test_sqrt2" [] e_metID
933 (*root-equation ... for test-*.sml until 8.01*)
934 (["Test","squ-equ-test2"]:metID,
935 [("#Given" ,["equality e_e","solveFor v_v"]),
936 ("#Find" ,["solutions v_v'i'"])
938 {rew_ord'="e_rew_ord",rls'=tval_rls,
939 srls = append_rls "srls_contains_root" e_rls
940 [Calc ("Test.contains'_root",eval_contains_root"")],
942 crls=tval_rls, errpats = [], nrls = e_rls(*,asm_rls=[],
943 asm_thm=[("square_equation_left",""),
944 ("square_equation_right","")]*)},
945 "Script Solve_root_equation (e_e::bool) (v_v::real) = " ^
947 " ((While (contains_root e_e) Do" ^
948 " ((Rewrite square_equation_left True) @@" ^
949 " (Try (Rewrite_Set Test_simplify False)) @@" ^
950 " (Try (Rewrite_Set rearrange_assoc False)) @@" ^
951 " (Try (Rewrite_Set isolate_root False)) @@" ^
952 " (Try (Rewrite_Set Test_simplify False)))) @@" ^
953 " (Try (Rewrite_Set norm_equation False)) @@" ^
954 " (Try (Rewrite_Set Test_simplify False)) @@" ^
955 " (Rewrite_Set_Inst [(bdv,v_v::real)] isolate_bdv False) @@" ^
956 " (Try (Rewrite_Set Test_simplify False)))" ^
958 " (L_L::bool list) = Tac subproblem_equation_dummy; " ^
959 " L_L = Tac solve_equation_dummy " ^
960 " in Check_elementwise L_L {(v_v::real). Assumptions})"
966 (prep_met thy "met_test_squ_sub" [] e_metID
967 (*tests subproblem fixed linear*)
968 (["Test","squ-equ-test-subpbl1"]:metID,
969 [("#Given" ,["equality e_e","solveFor v_v"]),
970 ("#Where" ,["precond_rootmet v_v"]),
971 ("#Find" ,["solutions v_v'i'"])
973 {rew_ord' = "e_rew_ord", rls' = tval_rls, srls = e_rls,
974 prls = append_rls "prls_met_test_squ_sub" e_rls
975 [Calc ("Test.precond'_rootmet", eval_precond_rootmet "")],
976 calc=[], crls=tval_rls, errpats = [], nrls = Test_simplify},
977 "Script Solve_root_equation (e_e::bool) (v_v::real) = " ^
978 " (let e_e = ((Try (Rewrite_Set norm_equation False)) @@ " ^
979 " (Try (Rewrite_Set Test_simplify False))) e_e; " ^
980 " (L_L::bool list) = " ^
981 " (SubProblem (Test', " ^
982 " [linear,univariate,equation,test]," ^
983 " [Test,solve_linear]) " ^
984 " [BOOL e_e, REAL v_v]) " ^
985 " in Check_elementwise L_L {(v_v::real). Assumptions}) "
991 (prep_met thy "met_test_squ_sub2" [] e_metID
992 (*tests subproblem fixed degree 2*)
993 (["Test","squ-equ-test-subpbl2"]:metID,
994 [("#Given" ,["equality e_e","solveFor v_v"]),
995 ("#Find" ,["solutions v_v'i'"])
997 {rew_ord'="e_rew_ord",rls'=tval_rls,srls=e_rls,prls=e_rls,calc=[],
998 crls=tval_rls, errpats = [], nrls = e_rls(*,
999 asm_rls=[],asm_thm=[("square_equation_left",""),
1000 ("square_equation_right","")]*)},
1001 "Script Solve_root_equation (e_e::bool) (v_v::real) = " ^
1002 " (let e_e = Try (Rewrite_Set norm_equation False) e_e; " ^
1003 "(L_L::bool list) = (SubProblem (Test',[linear,univariate,equation,test]," ^
1004 " [Test,solve_by_pq_formula]) [BOOL e_e, REAL v_v])" ^
1005 "in Check_elementwise L_L {(v_v::real). Assumptions})"
1011 (prep_met thy "met_test_squ_nonterm" [] e_metID
1012 (*root-equation: see foils..., but notTerminating*)
1013 (["Test","square_equation...notTerminating"]:metID,
1014 [("#Given" ,["equality e_e","solveFor v_v"]),
1015 ("#Find" ,["solutions v_v'i'"])
1017 {rew_ord'="e_rew_ord",rls'=tval_rls,
1018 srls = append_rls "srls_contains_root" e_rls
1019 [Calc ("Test.contains'_root",eval_contains_root"")],
1021 crls=tval_rls, errpats = [], nrls = e_rls(*,asm_rls=[],
1022 asm_thm=[("square_equation_left",""),
1023 ("square_equation_right","")]*)},
1024 "Script Solve_root_equation (e_e::bool) (v_v::real) = " ^
1026 " ((While (contains_root e_e) Do" ^
1027 " ((Rewrite square_equation_left True) @@" ^
1028 " (Try (Rewrite_Set Test_simplify False)) @@" ^
1029 " (Try (Rewrite_Set rearrange_assoc False)) @@" ^
1030 " (Try (Rewrite_Set isolate_root False)) @@" ^
1031 " (Try (Rewrite_Set Test_simplify False)))) @@" ^
1032 " (Try (Rewrite_Set norm_equation False)) @@" ^
1033 " (Try (Rewrite_Set Test_simplify False)))" ^
1035 " (L_L::bool list) = " ^
1036 " (SubProblem (Test',[linear,univariate,equation,test]," ^
1037 " [Test,solve_linear]) [BOOL e_e, REAL v_v])" ^
1038 "in Check_elementwise L_L {(v_v::real). Assumptions})"
1044 (prep_met thy "met_test_eq1" [] e_metID
1046 (["Test","square_equation1"]:metID,
1047 [("#Given" ,["equality e_e","solveFor v_v"]),
1048 ("#Find" ,["solutions v_v'i'"])
1050 {rew_ord'="e_rew_ord",rls'=tval_rls,
1051 srls = append_rls "srls_contains_root" e_rls
1052 [Calc ("Test.contains'_root",eval_contains_root"")],
1054 crls=tval_rls, errpats = [], nrls = e_rls(*,asm_rls=[],
1055 asm_thm=[("square_equation_left",""),
1056 ("square_equation_right","")]*)},
1057 "Script Solve_root_equation (e_e::bool) (v_v::real) = " ^
1059 " ((While (contains_root e_e) Do" ^
1060 " ((Rewrite square_equation_left True) @@" ^
1061 " (Try (Rewrite_Set Test_simplify False)) @@" ^
1062 " (Try (Rewrite_Set rearrange_assoc False)) @@" ^
1063 " (Try (Rewrite_Set isolate_root False)) @@" ^
1064 " (Try (Rewrite_Set Test_simplify False)))) @@" ^
1065 " (Try (Rewrite_Set norm_equation False)) @@" ^
1066 " (Try (Rewrite_Set Test_simplify False)))" ^
1068 " (L_L::bool list) = (SubProblem (Test',[linear,univariate,equation,test]," ^
1069 " [Test,solve_linear]) [BOOL e_e, REAL v_v])" ^
1070 " in Check_elementwise L_L {(v_v::real). Assumptions})"
1076 (prep_met thy "met_test_squ2" [] e_metID
1078 (["Test","square_equation2"]:metID,
1079 [("#Given" ,["equality e_e","solveFor v_v"]),
1080 ("#Find" ,["solutions v_v'i'"])
1082 {rew_ord'="e_rew_ord",rls'=tval_rls,
1083 srls = append_rls "srls_contains_root" e_rls
1084 [Calc ("Test.contains'_root",eval_contains_root"")],
1086 crls=tval_rls, errpats = [], nrls = e_rls(*,asm_rls=[],
1087 asm_thm=[("square_equation_left",""),
1088 ("square_equation_right","")]*)},
1089 "Script Solve_root_equation (e_e::bool) (v_v::real) = " ^
1091 " ((While (contains_root e_e) Do" ^
1092 " (((Rewrite square_equation_left True) Or " ^
1093 " (Rewrite square_equation_right True)) @@" ^
1094 " (Try (Rewrite_Set Test_simplify False)) @@" ^
1095 " (Try (Rewrite_Set rearrange_assoc False)) @@" ^
1096 " (Try (Rewrite_Set isolate_root False)) @@" ^
1097 " (Try (Rewrite_Set Test_simplify False)))) @@" ^
1098 " (Try (Rewrite_Set norm_equation False)) @@" ^
1099 " (Try (Rewrite_Set Test_simplify False)))" ^
1101 " (L_L::bool list) = (SubProblem (Test',[plain_square,univariate,equation,test]," ^
1102 " [Test,solve_plain_square]) [BOOL e_e, REAL v_v])" ^
1103 " in Check_elementwise L_L {(v_v::real). Assumptions})"
1109 (prep_met thy "met_test_squeq" [] e_metID
1111 (["Test","square_equation"]:metID,
1112 [("#Given" ,["equality e_e","solveFor v_v"]),
1113 ("#Find" ,["solutions v_v'i'"])
1115 {rew_ord'="e_rew_ord",rls'=tval_rls,
1116 srls = append_rls "srls_contains_root" e_rls
1117 [Calc ("Test.contains'_root",eval_contains_root"")],
1119 crls=tval_rls, errpats = [], nrls = e_rls(*,asm_rls=[],
1120 asm_thm=[("square_equation_left",""),
1121 ("square_equation_right","")]*)},
1122 "Script Solve_root_equation (e_e::bool) (v_v::real) = " ^
1124 " ((While (contains_root e_e) Do" ^
1125 " (((Rewrite square_equation_left True) Or" ^
1126 " (Rewrite square_equation_right True)) @@" ^
1127 " (Try (Rewrite_Set Test_simplify False)) @@" ^
1128 " (Try (Rewrite_Set rearrange_assoc False)) @@" ^
1129 " (Try (Rewrite_Set isolate_root False)) @@" ^
1130 " (Try (Rewrite_Set Test_simplify False)))) @@" ^
1131 " (Try (Rewrite_Set norm_equation False)) @@" ^
1132 " (Try (Rewrite_Set Test_simplify False)))" ^
1134 " (L_L::bool list) = (SubProblem (Test',[univariate,equation,test]," ^
1135 " [no_met]) [BOOL e_e, REAL v_v])" ^
1136 " in Check_elementwise L_L {(v_v::real). Assumptions})"
1142 (prep_met thy "met_test_eq_plain" [] e_metID
1143 (*solve_plain_square*)
1144 (["Test","solve_plain_square"]:metID,
1145 [("#Given",["equality e_e","solveFor v_v"]),
1146 ("#Where" ,["(matches (?a + ?b*v_v ^^^2 = 0) e_e) |" ^
1147 "(matches ( ?b*v_v ^^^2 = 0) e_e) |" ^
1148 "(matches (?a + v_v ^^^2 = 0) e_e) |" ^
1149 "(matches ( v_v ^^^2 = 0) e_e)"]),
1150 ("#Find" ,["solutions v_v'i'"])
1152 {rew_ord'="e_rew_ord",rls'=tval_rls,calc=[],srls=e_rls,
1153 prls = assoc_rls "matches",
1154 crls=tval_rls, errpats = [], nrls = e_rls(*,
1155 asm_rls=[],asm_thm=[]*)},
1156 "Script Solve_plain_square (e_e::bool) (v_v::real) = " ^
1157 " (let e_e = ((Try (Rewrite_Set isolate_bdv False)) @@ " ^
1158 " (Try (Rewrite_Set Test_simplify False)) @@ " ^
1159 " ((Rewrite square_equality_0 False) Or " ^
1160 " (Rewrite square_equality True)) @@ " ^
1161 " (Try (Rewrite_Set tval_rls False))) e_e " ^
1162 " in ((Or_to_List e_e)::bool list))"
1169 (prep_met thy "met_test_norm_univ" [] e_metID
1170 (["Test","norm_univar_equation"]:metID,
1171 [("#Given",["equality e_e","solveFor v_v"]),
1173 ("#Find" ,["solutions v_v'i'"])
1175 {rew_ord'="e_rew_ord",rls'=tval_rls,srls = e_rls,prls=e_rls,
1177 crls=tval_rls, errpats = [], nrls = e_rls},
1178 "Script Norm_univar_equation (e_e::bool) (v_v::real) = " ^
1179 " (let e_e = ((Try (Rewrite rnorm_equation_add False)) @@ " ^
1180 " (Try (Rewrite_Set Test_simplify False))) e_e " ^
1181 " in (SubProblem (Test',[univariate,equation,test], " ^
1182 " [no_met]) [BOOL e_e, REAL v_v]))"
1185 (*17.9.02 aus SqRoot.ML------------------------------^^^---*)
1188 (prep_met thy "met_test_intsimp" [] e_metID
1189 (["Test","intsimp"]:metID,
1190 [("#Given" ,["intTestGiven t_t"]),
1192 ("#Find" ,["intTestFind s_s"])
1194 {rew_ord' = "e_rew_ord", rls' = tval_rls, srls = e_rls,
1195 prls = e_rls, calc = [], crls = tval_rls, errpats = [], nrls = Test_simplify},
1196 "Script STest_simplify (t_t::int) = " ^
1198 " ((Try (Calculate PLUS)) @@ " ^
1199 " (Try (Calculate TIMES))) t_t::int)"
1205 (*8.4.03 aus Poly.ML--------------------------------vvv---
1206 make_polynomial ---> make_poly
1207 ^-- for user ^-- for systest _ONLY_*)
1209 local (*. for make_polytest .*)
1211 open Term; (* for type order = EQUAL | LESS | GREATER *)
1213 fun pr_ord EQUAL = "EQUAL"
1214 | pr_ord LESS = "LESS"
1215 | pr_ord GREATER = "GREATER";
1217 fun dest_hd' (Const (a, T)) = (* ~ term.ML *)
1219 "Atools.pow" => ((("|||||||||||||", 0), T), 0) (*WN greatest *)
1220 | _ => (((a, 0), T), 0))
1221 | dest_hd' (Free (a, T)) = (((a, 0), T), 1)
1222 | dest_hd' (Var v) = (v, 2)
1223 | dest_hd' (Bound i) = ((("", i), dummyT), 3)
1224 | dest_hd' (Abs (_, T, _)) = ((("", 0), T), 4);
1226 fun get_order_pow (t $ (Free(order,_))) =
1227 (case int_of_str (order) of
1230 | get_order_pow _ = 0;
1232 fun size_of_term' (Const(str,_) $ t) =
1233 if "Atools.pow"=str then 1000 + size_of_term' t else 1 + size_of_term' t(*WN*)
1234 | size_of_term' (Abs (_,_,body)) = 1 + size_of_term' body
1235 | size_of_term' (f$t) = size_of_term' f + size_of_term' t
1236 | size_of_term' _ = 1;
1237 fun term_ord' pr thy (Abs (_, T, t), Abs(_, U, u)) = (* ~ term.ML *)
1238 (case term_ord' pr thy (t, u) of EQUAL => Term_Ord.typ_ord (T, U)
1240 | term_ord' pr thy (t, u) =
1242 let val (f, ts) = strip_comb t and (g, us) = strip_comb u;
1243 val _ = tracing ("t= f@ts= \"" ^ term2str f ^ "\" @ \"[" ^
1244 commas(map term2str ts) ^ "]\"")
1245 val _ = tracing ("u= g@us= \"" ^ term2str g ^"\" @ \"[" ^
1246 commas(map term2str us) ^"]\"")
1247 val _ = tracing ("size_of_term(t,u)= (" ^
1248 string_of_int (size_of_term' t) ^ ", " ^
1249 string_of_int (size_of_term' u) ^ ")")
1250 val _ = tracing ("hd_ord(f,g) = " ^ (pr_ord o hd_ord) (f,g))
1251 val _ = tracing ("terms_ord(ts,us) = " ^
1252 (pr_ord o terms_ord str false) (ts,us));
1253 val _ = tracing "-------"
1256 case int_ord (size_of_term' t, size_of_term' u) of
1258 let val (f, ts) = strip_comb t and (g, us) = strip_comb u in
1259 (case hd_ord (f, g) of EQUAL => (terms_ord str pr) (ts, us)
1263 and hd_ord (f, g) = (* ~ term.ML *)
1264 prod_ord (prod_ord Term_Ord.indexname_ord Term_Ord.typ_ord) int_ord (dest_hd' f, dest_hd' g)
1265 and terms_ord str pr (ts, us) =
1266 list_ord (term_ord' pr (assoc_thy "Isac"))(ts, us);
1269 fun ord_make_polytest (pr:bool) thy (_:subst) tu =
1270 (term_ord' pr thy(***) tu = LESS );
1276 rew_ord' := overwritel (!rew_ord',
1277 [("termlessI", termlessI),
1278 ("ord_make_polytest", ord_make_polytest false thy)
1281 (*WN060510 this was a preparation for prep_rls ...
1282 val scr_make_polytest =
1283 "Script Expand_binomtest t_t =" ^
1285 "((Try (Repeat (Rewrite real_diff_minus False))) @@ " ^
1287 " (Try (Repeat (Rewrite distrib_right False))) @@ " ^
1288 " (Try (Repeat (Rewrite distrib_left False))) @@ " ^
1289 " (Try (Repeat (Rewrite left_diff_distrib False))) @@ " ^
1290 " (Try (Repeat (Rewrite right_diff_distrib False))) @@ " ^
1292 " (Try (Repeat (Rewrite mult_1_left False))) @@ " ^
1293 " (Try (Repeat (Rewrite mult_zero_left False))) @@ " ^
1294 " (Try (Repeat (Rewrite add_0_left False))) @@ " ^
1296 " (Try (Repeat (Rewrite mult_commute False))) @@ " ^
1297 " (Try (Repeat (Rewrite real_mult_left_commute False))) @@ " ^
1298 " (Try (Repeat (Rewrite mult_assoc False))) @@ " ^
1299 " (Try (Repeat (Rewrite add_commute False))) @@ " ^
1300 " (Try (Repeat (Rewrite add_left_commute False))) @@ " ^
1301 " (Try (Repeat (Rewrite add_assoc False))) @@ " ^
1303 " (Try (Repeat (Rewrite sym_realpow_twoI False))) @@ " ^
1304 " (Try (Repeat (Rewrite realpow_plus_1 False))) @@ " ^
1305 " (Try (Repeat (Rewrite sym_real_mult_2 False))) @@ " ^
1306 " (Try (Repeat (Rewrite real_mult_2_assoc False))) @@ " ^
1308 " (Try (Repeat (Rewrite real_num_collect False))) @@ " ^
1309 " (Try (Repeat (Rewrite real_num_collect_assoc False))) @@ " ^
1311 " (Try (Repeat (Rewrite real_one_collect False))) @@ " ^
1312 " (Try (Repeat (Rewrite real_one_collect_assoc False))) @@ " ^
1314 " (Try (Repeat (Calculate PLUS ))) @@ " ^
1315 " (Try (Repeat (Calculate TIMES ))) @@ " ^
1316 " (Try (Repeat (Calculate POWER)))) " ^
1318 -----------------------------------------------------*)
1321 Rls{id = "make_polytest", preconds = []:term list,
1322 rew_ord = ("ord_make_polytest", ord_make_polytest false @{theory "Poly"}),
1323 erls = testerls, srls = Erls,
1324 calc = [("PLUS" , ("Groups.plus_class.plus", eval_binop "#add_")),
1325 ("TIMES" , ("Groups.times_class.times", eval_binop "#mult_")),
1326 ("POWER", ("Atools.pow", eval_binop "#power_"))
1328 rules = [Thm ("real_diff_minus",num_str @{thm real_diff_minus}),
1329 (*"a - b = a + (-1) * b"*)
1330 Thm ("distrib_right" ,num_str @{thm distrib_right}),
1331 (*"(z1.0 + z2.0) * w = z1.0 * w + z2.0 * w"*)
1332 Thm ("distrib_left",num_str @{thm distrib_left}),
1333 (*"w * (z1.0 + z2.0) = w * z1.0 + w * z2.0"*)
1334 Thm ("left_diff_distrib" ,num_str @{thm left_diff_distrib}),
1335 (*"(z1.0 - z2.0) * w = z1.0 * w - z2.0 * w"*)
1336 Thm ("right_diff_distrib",num_str @{thm right_diff_distrib}),
1337 (*"w * (z1.0 - z2.0) = w * z1.0 - w * z2.0"*)
1338 Thm ("mult_1_left",num_str @{thm mult_1_left}),
1340 Thm ("mult_zero_left",num_str @{thm mult_zero_left}),
1342 Thm ("add_0_left",num_str @{thm add_0_left}),
1346 Thm ("mult_commute",num_str @{thm mult_commute}),
1348 Thm ("real_mult_left_commute",num_str @{thm real_mult_left_commute}),
1349 (*z1.0 * (z2.0 * z3.0) = z2.0 * (z1.0 * z3.0)*)
1350 Thm ("mult_assoc",num_str @{thm mult_assoc}),
1351 (*z1.0 * z2.0 * z3.0 = z1.0 * (z2.0 * z3.0)*)
1352 Thm ("add_commute",num_str @{thm add_commute}),
1354 Thm ("add_left_commute",num_str @{thm add_left_commute}),
1355 (*x + (y + z) = y + (x + z)*)
1356 Thm ("add_assoc",num_str @{thm add_assoc}),
1357 (*z1.0 + z2.0 + z3.0 = z1.0 + (z2.0 + z3.0)*)
1359 Thm ("sym_realpow_twoI",
1360 num_str (@{thm realpow_twoI} RS @{thm sym})),
1361 (*"r1 * r1 = r1 ^^^ 2"*)
1362 Thm ("realpow_plus_1",num_str @{thm realpow_plus_1}),
1363 (*"r * r ^^^ n = r ^^^ (n + 1)"*)
1364 Thm ("sym_real_mult_2",
1365 num_str (@{thm real_mult_2} RS @{thm sym})),
1366 (*"z1 + z1 = 2 * z1"*)
1367 Thm ("real_mult_2_assoc",num_str @{thm real_mult_2_assoc}),
1368 (*"z1 + (z1 + k) = 2 * z1 + k"*)
1370 Thm ("real_num_collect",num_str @{thm real_num_collect}),
1371 (*"[| l is_const; m is_const |]==>l * n + m * n = (l + m) * n"*)
1372 Thm ("real_num_collect_assoc",num_str @{thm real_num_collect_assoc}),
1373 (*"[| l is_const; m is_const |] ==>
1374 l * n + (m * n + k) = (l + m) * n + k"*)
1375 Thm ("real_one_collect",num_str @{thm real_one_collect}),
1376 (*"m is_const ==> n + m * n = (1 + m) * n"*)
1377 Thm ("real_one_collect_assoc",num_str @{thm real_one_collect_assoc}),
1378 (*"m is_const ==> k + (n + m * n) = k + (1 + m) * n"*)
1380 Calc ("Groups.plus_class.plus", eval_binop "#add_"),
1381 Calc ("Groups.times_class.times", eval_binop "#mult_"),
1382 Calc ("Atools.pow", eval_binop "#power_")
1384 scr = EmptyScr(*Prog ((term_of o the o (parse thy))
1385 scr_make_polytest)*)
1389 (*WN060510 this was done before 'fun prep_rls' ...------------------------
1390 val scr_expand_binomtest =
1391 "Script Expand_binomtest t_t =" ^
1393 "((Try (Repeat (Rewrite real_plus_binom_pow2 False))) @@ " ^
1394 " (Try (Repeat (Rewrite real_plus_binom_times False))) @@ " ^
1395 " (Try (Repeat (Rewrite real_minus_binom_pow2 False))) @@ " ^
1396 " (Try (Repeat (Rewrite real_minus_binom_times False))) @@ " ^
1397 " (Try (Repeat (Rewrite real_plus_minus_binom1 False))) @@ " ^
1398 " (Try (Repeat (Rewrite real_plus_minus_binom2 False))) @@ " ^
1400 " (Try (Repeat (Rewrite mult_1_left False))) @@ " ^
1401 " (Try (Repeat (Rewrite mult_zero_left False))) @@ " ^
1402 " (Try (Repeat (Rewrite add_0_left False))) @@ " ^
1404 " (Try (Repeat (Calculate PLUS ))) @@ " ^
1405 " (Try (Repeat (Calculate TIMES ))) @@ " ^
1406 " (Try (Repeat (Calculate POWER))) @@ " ^
1408 " (Try (Repeat (Rewrite sym_realpow_twoI False))) @@ " ^
1409 " (Try (Repeat (Rewrite realpow_plus_1 False))) @@ " ^
1410 " (Try (Repeat (Rewrite sym_real_mult_2 False))) @@ " ^
1411 " (Try (Repeat (Rewrite real_mult_2_assoc False))) @@ " ^
1413 " (Try (Repeat (Rewrite real_num_collect False))) @@ " ^
1414 " (Try (Repeat (Rewrite real_num_collect_assoc False))) @@ " ^
1416 " (Try (Repeat (Rewrite real_one_collect False))) @@ " ^
1417 " (Try (Repeat (Rewrite real_one_collect_assoc False))) @@ " ^
1419 " (Try (Repeat (Calculate PLUS ))) @@ " ^
1420 " (Try (Repeat (Calculate TIMES ))) @@ " ^
1421 " (Try (Repeat (Calculate POWER)))) " ^
1423 --------------------------------------------------------------------------*)
1425 val expand_binomtest =
1426 Rls{id = "expand_binomtest", preconds = [],
1427 rew_ord = ("termlessI",termlessI),
1428 erls = testerls, srls = Erls,
1429 calc = [("PLUS" , ("Groups.plus_class.plus", eval_binop "#add_")),
1430 ("TIMES" , ("Groups.times_class.times", eval_binop "#mult_")),
1431 ("POWER", ("Atools.pow", eval_binop "#power_"))
1434 [Thm ("real_plus_binom_pow2" ,num_str @{thm real_plus_binom_pow2}),
1435 (*"(a + b) ^^^ 2 = a ^^^ 2 + 2 * a * b + b ^^^ 2"*)
1436 Thm ("real_plus_binom_times" ,num_str @{thm real_plus_binom_times}),
1437 (*"(a + b)*(a + b) = ...*)
1438 Thm ("real_minus_binom_pow2" ,num_str @{thm real_minus_binom_pow2}),
1439 (*"(a - b) ^^^ 2 = a ^^^ 2 - 2 * a * b + b ^^^ 2"*)
1440 Thm ("real_minus_binom_times",num_str @{thm real_minus_binom_times}),
1441 (*"(a - b)*(a - b) = ...*)
1442 Thm ("real_plus_minus_binom1",num_str @{thm real_plus_minus_binom1}),
1443 (*"(a + b) * (a - b) = a ^^^ 2 - b ^^^ 2"*)
1444 Thm ("real_plus_minus_binom2",num_str @{thm real_plus_minus_binom2}),
1445 (*"(a - b) * (a + b) = a ^^^ 2 - b ^^^ 2"*)
1447 Thm ("real_pp_binom_times",num_str @{thm real_pp_binom_times}),
1448 (*(a + b)*(c + d) = a*c + a*d + b*c + b*d*)
1449 Thm ("real_pm_binom_times",num_str @{thm real_pm_binom_times}),
1450 (*(a + b)*(c - d) = a*c - a*d + b*c - b*d*)
1451 Thm ("real_mp_binom_times",num_str @{thm real_mp_binom_times}),
1452 (*(a - b)*(c p d) = a*c + a*d - b*c - b*d*)
1453 Thm ("real_mm_binom_times",num_str @{thm real_mm_binom_times}),
1454 (*(a - b)*(c p d) = a*c - a*d - b*c + b*d*)
1455 Thm ("realpow_multI",num_str @{thm realpow_multI}),
1456 (*(a*b)^^^n = a^^^n * b^^^n*)
1457 Thm ("real_plus_binom_pow3",num_str @{thm real_plus_binom_pow3}),
1458 (* (a + b)^^^3 = a^^^3 + 3*a^^^2*b + 3*a*b^^^2 + b^^^3 *)
1459 Thm ("real_minus_binom_pow3",num_str @{thm real_minus_binom_pow3}),
1460 (* (a - b)^^^3 = a^^^3 - 3*a^^^2*b + 3*a*b^^^2 - b^^^3 *)
1463 (* Thm ("distrib_right" ,num_str @{thm distrib_right}),
1464 (*"(z1.0 + z2.0) * w = z1.0 * w + z2.0 * w"*)
1465 Thm ("distrib_left",num_str @{thm distrib_left}),
1466 (*"w * (z1.0 + z2.0) = w * z1.0 + w * z2.0"*)
1467 Thm ("left_diff_distrib" ,num_str @{thm left_diff_distrib}),
1468 (*"(z1.0 - z2.0) * w = z1.0 * w - z2.0 * w"*)
1469 Thm ("right_diff_distrib",num_str @{thm right_diff_distrib}),
1470 (*"w * (z1.0 - z2.0) = w * z1.0 - w * z2.0"*)
1473 Thm ("mult_1_left",num_str @{thm mult_1_left}),
1475 Thm ("mult_zero_left",num_str @{thm mult_zero_left}),
1477 Thm ("add_0_left",num_str @{thm add_0_left}),
1480 Calc ("Groups.plus_class.plus", eval_binop "#add_"),
1481 Calc ("Groups.times_class.times", eval_binop "#mult_"),
1482 Calc ("Atools.pow", eval_binop "#power_"),
1484 Thm ("mult_commute",num_str @{thm mult_commute}),
1486 Thm ("real_mult_left_commute",num_str @{thm real_mult_left_commute}),
1487 Thm ("mult_assoc",num_str @{thm mult_assoc}),
1488 Thm ("add_commute",num_str @{thm add_commute}),
1489 Thm ("add_left_commute",num_str @{thm add_left_commute}),
1490 Thm ("add_assoc",num_str @{thm add_assoc}),
1493 Thm ("sym_realpow_twoI",
1494 num_str (@{thm realpow_twoI} RS @{thm sym})),
1495 (*"r1 * r1 = r1 ^^^ 2"*)
1496 Thm ("realpow_plus_1",num_str @{thm realpow_plus_1}),
1497 (*"r * r ^^^ n = r ^^^ (n + 1)"*)
1498 (*Thm ("sym_real_mult_2",
1499 num_str (@{thm real_mult_2} RS @{thm sym})),
1500 (*"z1 + z1 = 2 * z1"*)*)
1501 Thm ("real_mult_2_assoc",num_str @{thm real_mult_2_assoc}),
1502 (*"z1 + (z1 + k) = 2 * z1 + k"*)
1504 Thm ("real_num_collect",num_str @{thm real_num_collect}),
1505 (*"[| l is_const; m is_const |] ==> l * n + m * n = (l + m) * n"*)
1506 Thm ("real_num_collect_assoc",num_str @{thm real_num_collect_assoc}),
1507 (*"[| l is_const; m is_const |] ==> l * n + (m * n + k) = (l + m) * n + k"*)
1508 Thm ("real_one_collect",num_str @{thm real_one_collect}),
1509 (*"m is_const ==> n + m * n = (1 + m) * n"*)
1510 Thm ("real_one_collect_assoc",num_str @{thm real_one_collect_assoc}),
1511 (*"m is_const ==> k + (n + m * n) = k + (1 + m) * n"*)
1513 Calc ("Groups.plus_class.plus", eval_binop "#add_"),
1514 Calc ("Groups.times_class.times", eval_binop "#mult_"),
1515 Calc ("Atools.pow", eval_binop "#power_")
1518 (*Script ((term_of o the o (parse thy)) scr_expand_binomtest)*)
1522 ruleset' := overwritelthy @{theory} (!ruleset',
1523 [("make_polytest", prep_rls make_polytest),
1524 ("expand_binomtest", prep_rls expand_binomtest)