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 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_"))
222 setup {* KEStore_Elems.add_calcs
223 [("is_root_free", ("Test.is'_root'_free", eval_root_free"#is_root_free_e")),
224 ("contains_root", ("Test.contains'_root", eval_contains_root"#contains_root_")),
225 ("Test.precond'_rootmet", ("Test.precond'_rootmet", eval_precond_rootmet"#Test.precond_rootmet_")),
226 ("Test.precond'_rootpbl", ("Test.precond'_rootpbl",
227 eval_precond_rootpbl"#Test.precond_rootpbl_"))] *}
230 fun term_order (_:subst) tu = (term_ordI [] tu = LESS);
235 Rls {id = "testerls", preconds = [], rew_ord = ("termlessI",termlessI),
236 erls = e_rls, srls = Erls,
237 calc = [], errpatts = [],
238 rules = [Thm ("refl",num_str @{thm refl}),
239 Thm ("order_refl",num_str @{thm order_refl}),
240 Thm ("radd_left_cancel_le",num_str @{thm radd_left_cancel_le}),
241 Thm ("not_true",num_str @{thm not_true}),
242 Thm ("not_false",num_str @{thm not_false}),
243 Thm ("and_true",num_str @{thm and_true}),
244 Thm ("and_false",num_str @{thm and_false}),
245 Thm ("or_true",num_str @{thm or_true}),
246 Thm ("or_false",num_str @{thm or_false}),
247 Thm ("and_commute",num_str @{thm and_commute}),
248 Thm ("or_commute",num_str @{thm or_commute}),
250 Calc ("Atools.is'_const",eval_const "#is_const_"),
251 Calc ("Tools.matches",eval_matches ""),
253 Calc ("Groups.plus_class.plus",eval_binop "#add_"),
254 Calc ("Groups.times_class.times",eval_binop "#mult_"),
255 Calc ("Atools.pow" ,eval_binop "#power_"),
257 Calc ("Orderings.ord_class.less",eval_equ "#less_"),
258 Calc ("Orderings.ord_class.less_eq",eval_equ "#less_equal_"),
260 Calc ("Atools.ident",eval_ident "#ident_")],
261 scr = Prog ((term_of o the o (parse thy)) "empty_script")
265 (*.for evaluation of conditions in rewrite rules.*)
266 (*FIXXXXXXME 10.8.02: handle like _simplify*)
268 Rls{id = "tval_rls", preconds = [],
269 rew_ord = ("sqrt_right",sqrt_right false @{theory "Pure"}),
270 erls=testerls,srls = e_rls,
271 calc=[], errpatts = [],
272 rules = [Thm ("refl",num_str @{thm refl}),
273 Thm ("order_refl",num_str @{thm order_refl}),
274 Thm ("radd_left_cancel_le",num_str @{thm radd_left_cancel_le}),
275 Thm ("not_true",num_str @{thm not_true}),
276 Thm ("not_false",num_str @{thm not_false}),
277 Thm ("and_true",num_str @{thm and_true}),
278 Thm ("and_false",num_str @{thm and_false}),
279 Thm ("or_true",num_str @{thm or_true}),
280 Thm ("or_false",num_str @{thm or_false}),
281 Thm ("and_commute",num_str @{thm and_commute}),
282 Thm ("or_commute",num_str @{thm or_commute}),
284 Thm ("real_diff_minus",num_str @{thm real_diff_minus}),
286 Thm ("root_ge0",num_str @{thm root_ge0}),
287 Thm ("root_add_ge0",num_str @{thm root_add_ge0}),
288 Thm ("root_ge0_1",num_str @{thm root_ge0_1}),
289 Thm ("root_ge0_2",num_str @{thm root_ge0_2}),
291 Calc ("Atools.is'_const",eval_const "#is_const_"),
292 Calc ("Test.is'_root'_free",eval_root_free "#is_root_free_e"),
293 Calc ("Tools.matches",eval_matches ""),
294 Calc ("Test.contains'_root",
295 eval_contains_root"#contains_root_"),
297 Calc ("Groups.plus_class.plus",eval_binop "#add_"),
298 Calc ("Groups.times_class.times",eval_binop "#mult_"),
299 Calc ("NthRoot.sqrt",eval_sqrt "#sqrt_"),
300 Calc ("Atools.pow" ,eval_binop "#power_"),
302 Calc ("Orderings.ord_class.less",eval_equ "#less_"),
303 Calc ("Orderings.ord_class.less_eq",eval_equ "#less_equal_"),
305 Calc ("Atools.ident",eval_ident "#ident_")],
306 scr = Prog ((term_of o the o (parse thy)) "empty_script")
309 setup {* KEStore_Elems.add_rlss [("testerls", (Context.theory_name @{theory}, prep_rls testerls))] *}
312 (*make () dissappear*)
313 val rearrange_assoc =
314 Rls{id = "rearrange_assoc", preconds = [],
315 rew_ord = ("e_rew_ord",e_rew_ord),
316 erls = e_rls, srls = e_rls, calc = [], errpatts = [],
318 [Thm ("sym_add_assoc",num_str (@{thm add_assoc} RS @{thm sym})),
319 Thm ("sym_rmult_assoc",num_str (@{thm rmult_assoc} RS @{thm sym}))],
320 scr = Prog ((term_of o the o (parse thy)) "empty_script")
324 Rls{id = "ac_plus_times", preconds = [], rew_ord = ("term_order",term_order),
325 erls = e_rls, srls = e_rls, calc = [], errpatts = [],
327 [Thm ("radd_commute",num_str @{thm radd_commute}),
328 Thm ("radd_left_commute",num_str @{thm radd_left_commute}),
329 Thm ("add_assoc",num_str @{thm add_assoc}),
330 Thm ("rmult_commute",num_str @{thm rmult_commute}),
331 Thm ("rmult_left_commute",num_str @{thm rmult_left_commute}),
332 Thm ("rmult_assoc",num_str @{thm rmult_assoc})],
333 scr = Prog ((term_of o the o (parse thy)) "empty_script")
336 (*todo: replace by Rewrite("rnorm_equation_add",num_str @{thm rnorm_equation_add)*)
338 Rls{id = "norm_equation", preconds = [], rew_ord = ("e_rew_ord",e_rew_ord),
339 erls = tval_rls, srls = e_rls, calc = [], errpatts = [],
340 rules = [Thm ("rnorm_equation_add",num_str @{thm rnorm_equation_add})
342 scr = Prog ((term_of o the o (parse thy)) "empty_script")
348 val STest_simplify = (* vv--- not changed to real by parse*)
349 "Script STest_simplify (t_t::'z) = " ^
351 " ((Try (Repeat (Rewrite real_diff_minus False))) @@ " ^
352 " (Try (Repeat (Rewrite radd_mult_distrib2 False))) @@ " ^
353 " (Try (Repeat (Rewrite rdistr_right_assoc False))) @@ " ^
354 " (Try (Repeat (Rewrite rdistr_right_assoc_p False))) @@" ^
355 " (Try (Repeat (Rewrite rdistr_div_right False))) @@ " ^
356 " (Try (Repeat (Rewrite rbinom_power_2 False))) @@ " ^
358 " (Try (Repeat (Rewrite radd_commute False))) @@ " ^
359 " (Try (Repeat (Rewrite radd_left_commute False))) @@ " ^
360 " (Try (Repeat (Rewrite add_assoc False))) @@ " ^
361 " (Try (Repeat (Rewrite rmult_commute False))) @@ " ^
362 " (Try (Repeat (Rewrite rmult_left_commute False))) @@ " ^
363 " (Try (Repeat (Rewrite rmult_assoc False))) @@ " ^
365 " (Try (Repeat (Rewrite radd_real_const_eq False))) @@ " ^
366 " (Try (Repeat (Rewrite radd_real_const False))) @@ " ^
367 " (Try (Repeat (Calculate PLUS))) @@ " ^
368 " (Try (Repeat (Calculate TIMES))) @@ " ^
369 " (Try (Repeat (Calculate divide_))) @@" ^
370 " (Try (Repeat (Calculate POWER))) @@ " ^
372 " (Try (Repeat (Rewrite rcollect_right False))) @@ " ^
373 " (Try (Repeat (Rewrite rcollect_one_left False))) @@ " ^
374 " (Try (Repeat (Rewrite rcollect_one_left_assoc False))) @@ " ^
375 " (Try (Repeat (Rewrite rcollect_one_left_assoc_p False))) @@ " ^
377 " (Try (Repeat (Rewrite rshift_nominator False))) @@ " ^
378 " (Try (Repeat (Rewrite rcancel_den False))) @@ " ^
379 " (Try (Repeat (Rewrite rroot_square_inv False))) @@ " ^
380 " (Try (Repeat (Rewrite rroot_times_root False))) @@ " ^
381 " (Try (Repeat (Rewrite rroot_times_root_assoc_p False))) @@ " ^
382 " (Try (Repeat (Rewrite rsqare False))) @@ " ^
383 " (Try (Repeat (Rewrite power_1 False))) @@ " ^
384 " (Try (Repeat (Rewrite rtwo_of_the_same False))) @@ " ^
385 " (Try (Repeat (Rewrite rtwo_of_the_same_assoc_p False))) @@ " ^
387 " (Try (Repeat (Rewrite rmult_1 False))) @@ " ^
388 " (Try (Repeat (Rewrite rmult_1_right False))) @@ " ^
389 " (Try (Repeat (Rewrite rmult_0 False))) @@ " ^
390 " (Try (Repeat (Rewrite rmult_0_right False))) @@ " ^
391 " (Try (Repeat (Rewrite radd_0 False))) @@ " ^
392 " (Try (Repeat (Rewrite radd_0_right False)))) " ^
397 (* expects * distributed over + *)
399 Rls{id = "Test_simplify", preconds = [],
400 rew_ord = ("sqrt_right",sqrt_right false @{theory "Pure"}),
401 erls = tval_rls, srls = e_rls,
402 calc=[(*since 040209 filled by prep_rls*)], errpatts = [],
404 Thm ("real_diff_minus",num_str @{thm real_diff_minus}),
405 Thm ("radd_mult_distrib2",num_str @{thm radd_mult_distrib2}),
406 Thm ("rdistr_right_assoc",num_str @{thm rdistr_right_assoc}),
407 Thm ("rdistr_right_assoc_p",num_str @{thm rdistr_right_assoc_p}),
408 Thm ("rdistr_div_right",num_str @{thm rdistr_div_right}),
409 Thm ("rbinom_power_2",num_str @{thm rbinom_power_2}),
411 Thm ("radd_commute",num_str @{thm radd_commute}),
412 Thm ("radd_left_commute",num_str @{thm radd_left_commute}),
413 Thm ("add_assoc",num_str @{thm add_assoc}),
414 Thm ("rmult_commute",num_str @{thm rmult_commute}),
415 Thm ("rmult_left_commute",num_str @{thm rmult_left_commute}),
416 Thm ("rmult_assoc",num_str @{thm rmult_assoc}),
418 Thm ("radd_real_const_eq",num_str @{thm radd_real_const_eq}),
419 Thm ("radd_real_const",num_str @{thm radd_real_const}),
420 (* these 2 rules are invers to distr_div_right wrt. termination.
421 thus they MUST be done IMMEDIATELY before calc *)
422 Calc ("Groups.plus_class.plus", eval_binop "#add_"),
423 Calc ("Groups.times_class.times", eval_binop "#mult_"),
424 Calc ("Fields.inverse_class.divide", eval_cancel "#divide_e"),
425 Calc ("Atools.pow", eval_binop "#power_"),
427 Thm ("rcollect_right",num_str @{thm rcollect_right}),
428 Thm ("rcollect_one_left",num_str @{thm rcollect_one_left}),
429 Thm ("rcollect_one_left_assoc",num_str @{thm rcollect_one_left_assoc}),
430 Thm ("rcollect_one_left_assoc_p",num_str @{thm rcollect_one_left_assoc_p}),
432 Thm ("rshift_nominator",num_str @{thm rshift_nominator}),
433 Thm ("rcancel_den",num_str @{thm rcancel_den}),
434 Thm ("rroot_square_inv",num_str @{thm rroot_square_inv}),
435 Thm ("rroot_times_root",num_str @{thm rroot_times_root}),
436 Thm ("rroot_times_root_assoc_p",num_str @{thm rroot_times_root_assoc_p}),
437 Thm ("rsqare",num_str @{thm rsqare}),
438 Thm ("power_1",num_str @{thm power_1}),
439 Thm ("rtwo_of_the_same",num_str @{thm rtwo_of_the_same}),
440 Thm ("rtwo_of_the_same_assoc_p",num_str @{thm rtwo_of_the_same_assoc_p}),
442 Thm ("rmult_1",num_str @{thm rmult_1}),
443 Thm ("rmult_1_right",num_str @{thm rmult_1_right}),
444 Thm ("rmult_0",num_str @{thm rmult_0}),
445 Thm ("rmult_0_right",num_str @{thm rmult_0_right}),
446 Thm ("radd_0",num_str @{thm radd_0}),
447 Thm ("radd_0_right",num_str @{thm radd_0_right})
449 scr = Prog ((term_of o the o (parse thy)) "empty_script")
450 (*since 040209 filled by prep_rls: STest_simplify*)
459 (*isolate the root in a root-equation*)
461 Rls{id = "isolate_root", preconds = [], rew_ord = ("e_rew_ord",e_rew_ord),
462 erls=tval_rls,srls = e_rls, calc=[], errpatts = [],
463 rules = [Thm ("rroot_to_lhs",num_str @{thm rroot_to_lhs}),
464 Thm ("rroot_to_lhs_mult",num_str @{thm rroot_to_lhs_mult}),
465 Thm ("rroot_to_lhs_add_mult",num_str @{thm rroot_to_lhs_add_mult}),
466 Thm ("risolate_root_add",num_str @{thm risolate_root_add}),
467 Thm ("risolate_root_mult",num_str @{thm risolate_root_mult}),
468 Thm ("risolate_root_div",num_str @{thm risolate_root_div}) ],
469 scr = Prog ((term_of o the o (parse thy))
473 (*isolate the bound variable in an equation; 'bdv' is a meta-constant*)
475 Rls{id = "isolate_bdv", preconds = [], rew_ord = ("e_rew_ord",e_rew_ord),
476 erls=tval_rls,srls = e_rls, calc= [], errpatts = [],
478 [Thm ("risolate_bdv_add",num_str @{thm risolate_bdv_add}),
479 Thm ("risolate_bdv_mult_add",num_str @{thm risolate_bdv_mult_add}),
480 Thm ("risolate_bdv_mult",num_str @{thm risolate_bdv_mult}),
481 Thm ("mult_square",num_str @{thm mult_square}),
482 Thm ("constant_square",num_str @{thm constant_square}),
483 Thm ("constant_mult_square",num_str @{thm constant_mult_square})
485 scr = Prog ((term_of o the o (parse thy))
491 (* association list for calculate_, calculate
492 "Groups.plus_class.plus" etc. not usable in scripts *)
496 ("Vars" ,("Tools.Vars" ,eval_var "#Vars_")),
497 ("matches",("Tools.matches",eval_matches "#matches_")),
498 ("lhs" ,("Tools.lhs" ,eval_lhs "")),
500 ("PLUS" ,("Groups.plus_class.plus" ,eval_binop "#add_")),
501 ("TIMES" ,("Groups.times_class.times" ,eval_binop "#mult_")),
502 ("DIVIDE" ,("Fields.inverse_class.divide" ,eval_cancel "#divide_e")),
503 ("POWER" ,("Atools.pow" ,eval_binop "#power_")),
504 ("is_const",("Atools.is'_const",eval_const "#is_const_")),
505 ("le" ,("Orderings.ord_class.less" ,eval_equ "#less_")),
506 ("leq" ,("Orderings.ord_class.less_eq" ,eval_equ "#less_equal_")),
507 ("ident" ,("Atools.ident",eval_ident "#ident_")),
508 (*von hier (ehem.SqRoot*)
509 ("sqrt" ,("NthRoot.sqrt" ,eval_sqrt "#sqrt_")),
510 ("Test.is_root_free",("is'_root'_free", eval_root_free"#is_root_free_e")),
511 ("Test.contains_root",("contains'_root",
512 eval_contains_root"#contains_root_"))
515 setup {* KEStore_Elems.add_rlss
516 [("Test_simplify", (Context.theory_name @{theory}, prep_rls Test_simplify)),
517 ("tval_rls", (Context.theory_name @{theory}, prep_rls tval_rls)),
518 ("isolate_root", (Context.theory_name @{theory}, prep_rls isolate_root)),
519 ("isolate_bdv", (Context.theory_name @{theory}, prep_rls isolate_bdv)),
520 ("matches", (Context.theory_name @{theory}, prep_rls
521 (append_rls "matches" testerls [Calc ("Tools.matches",eval_matches "#matches_")])))] *}
524 (** problem types **)
526 (prep_pbt thy "pbl_test" [] e_pblID
531 (prep_pbt thy "pbl_test_equ" [] e_pblID
532 (["equation","test"],
533 [("#Given" ,["equality e_e","solveFor v_v"]),
534 ("#Where" ,["matches (?a = ?b) e_e"]),
535 ("#Find" ,["solutions v_v'i'"])
537 assoc_rls' @{theory} "matches",
538 SOME "solve (e_e::bool, v_v)", []));
541 (prep_pbt thy "pbl_test_uni" [] e_pblID
542 (["univariate","equation","test"],
543 [("#Given" ,["equality e_e","solveFor v_v"]),
544 ("#Where" ,["matches (?a = ?b) e_e"]),
545 ("#Find" ,["solutions v_v'i'"])
547 assoc_rls' @{theory} "matches",
548 SOME "solve (e_e::bool, v_v)", []));
551 (prep_pbt thy "pbl_test_uni_lin" [] e_pblID
552 (["linear","univariate","equation","test"],
553 [("#Given" ,["equality e_e","solveFor v_v"]),
554 ("#Where" ,["(matches ( v_v = 0) e_e) | (matches ( ?b*v_v = 0) e_e) |" ^
555 "(matches (?a+v_v = 0) e_e) | (matches (?a+?b*v_v = 0) e_e) "]),
556 ("#Find" ,["solutions v_v'i'"])
558 assoc_rls' @{theory} "matches",
559 SOME "solve (e_e::bool, v_v)", [["Test","solve_linear"]]));
565 [("#Given" ,"boolTestGiven g_g"),
566 ("#Find" ,"boolTestFind f_f")
573 [("#Given" ,"boolTestGiven g_g"),
574 ("#Find" ,"boolTestFind f_f")
579 val ttt = (term_of o the o (parse (Thy_Info.get_theory "Isac"))) "(matches ( v_v = 0) e_e)";
587 (prep_met @{theory "Diff"} "met_test" [] e_metID
590 {rew_ord'="tless_true",rls'=Atools_erls,calc = [], srls = e_rls, prls=e_rls,
591 crls=Atools_erls, errpats = [], nrls = e_rls}, "empty_script"));
595 (prep_met thy "met_test_solvelin" [] e_metID
596 (["Test","solve_linear"]:metID,
597 [("#Given" ,["equality e_e","solveFor v_v"]),
598 ("#Where" ,["matches (?a = ?b) e_e"]),
599 ("#Find" ,["solutions v_v'i'"])
601 {rew_ord' = "e_rew_ord", rls' = tval_rls, srls = e_rls,
602 prls = assoc_rls' @{theory} "matches", calc = [], crls = tval_rls,
603 errpats = [], nrls = Test_simplify},
604 "Script Solve_linear (e_e::bool) (v_v::real)= " ^
607 " (((Rewrite_Set_Inst [(bdv,v_v::real)] isolate_bdv False) @@ " ^
608 " (Rewrite_Set Test_simplify False))) e_e" ^
611 (*, prep_met thy (*test for equations*)
612 (["Test","testeq"]:metID,
613 [("#Given" ,["boolTestGiven g_g"]),
614 ("#Find" ,["boolTestFind f_f"])
616 {rew_ord'="e_rew_ord",rls'="tval_rls",asm_rls=[],
617 asm_thm=[("square_equation_left","")]},
618 "Script Testeq (e_q::bool) = " ^
620 " (let e_e = Try (Repeat (Rewrite rroot_square_inv False e_q)); " ^
621 " e_e = Try (Repeat (Rewrite square_equation_left True e_e)); " ^
622 " e_e = Try (Repeat (Rewrite rmult_0 False e_e)) " ^
623 " in e_e) Until (is_root_free e_e)" (*deleted*)
629 setup {* KEStore_Elems.add_rlss
630 [("norm_equation", (Context.theory_name @{theory}, prep_rls norm_equation)),
631 ("ac_plus_times", (Context.theory_name @{theory}, prep_rls ac_plus_times)),
632 ("rearrange_assoc", (Context.theory_name @{theory}, prep_rls rearrange_assoc))] *}
636 fun bin_o (Const (op_,(Type ("fun",
637 [Type (s2,[]),Type ("fun",
638 [Type (s4,tl4),Type (s5,tl5)])])))) =
639 if (s2=s4)andalso(s4=s5)then[op_]else[]
642 fun bin_op (t1 $ t2) = union op = (bin_op t1) (bin_op t2)
643 | bin_op t = bin_o t;
644 fun is_bin_op t = ((bin_op t)<>[]);
646 fun bin_op_arg1 ((Const (op_,(Type ("fun",
647 [Type (s2,[]),Type ("fun",
648 [Type (s4,tl4),Type (s5,tl5)])]))))$ arg1 $ arg2) =
650 fun bin_op_arg2 ((Const (op_,(Type ("fun",
651 [Type (s2,[]),Type ("fun",
652 [Type (s4,tl4),Type (s5,tl5)])]))))$ arg1 $ arg2) =
656 exception NO_EQUATION_TERM;
657 fun is_equation ((Const ("HOL.eq",(Type ("fun",
658 [Type (_,[]),Type ("fun",
659 [Type (_,[]),Type ("bool",[])])])))) $ _ $ _)
661 | is_equation _ = false;
662 fun equ_lhs ((Const ("HOL.eq",(Type ("fun",
663 [Type (_,[]),Type ("fun",
664 [Type (_,[]),Type ("bool",[])])])))) $ l $ r)
666 | equ_lhs _ = raise NO_EQUATION_TERM;
667 fun equ_rhs ((Const ("HOL.eq",(Type ("fun",
668 [Type (_,[]),Type ("fun",
669 [Type (_,[]),Type ("bool",[])])])))) $ l $ r)
671 | equ_rhs _ = raise NO_EQUATION_TERM;
674 fun atom (Const (_,Type (_,[]))) = true
675 | atom (Free (_,Type (_,[]))) = true
676 | atom (Var (_,Type (_,[]))) = true
677 (*| atom (_ (_,"?DUMMY" )) = true ..ML-error *)
678 | atom((Const ("Bin.integ_of_bin",_)) $ _) = true
681 fun varids (Const (s,Type (_,[]))) = [strip_thy s]
682 | varids (Free (s,Type (_,[]))) = if is_no s then []
684 | varids (Var((s,_),Type (_,[]))) = [strip_thy s]
685 (*| varids (_ (s,"?DUMMY" )) = ..ML-error *)
686 | varids((Const ("Bin.integ_of_bin",_)) $ _)= [](*8.01: superfluous?*)
687 | varids (Abs(a,T,t)) = union op = [a] (varids t)
688 | varids (t1 $ t2) = union op = (varids t1) (varids t2)
690 (*> val t = term_of (hd (parse Diophant.thy "x"));
691 val t = Free ("x","?DUMMY") : term
693 val it = [] : string list [] !!! *)
696 fun bin_ops_only ((Const op_) $ t1 $ t2) =
697 if(is_bin_op (Const op_))
698 then(bin_ops_only t1)andalso(bin_ops_only t2)
701 if atom t then true else bin_ops_only t;
703 fun polynomial opl t bdVar = (* bdVar TODO *)
704 subset op = (bin_op t, opl) andalso (bin_ops_only t);
706 fun poly_equ opl bdVar t = is_equation t (* bdVar TODO *)
707 andalso polynomial opl (equ_lhs t) bdVar
708 andalso polynomial opl (equ_rhs t) bdVar
709 andalso (subset op = (varids bdVar, varids (equ_lhs t)) orelse
710 subset op = (varids bdVar, varids (equ_lhs t)));
713 let fun max_ m [] = m
714 | max_ m (i::is) = if m<i then max_ i is else max_ m is;
715 in max_ (hd is) is end;
719 fun max (a,b) = if a < b then b else a;
721 fun degree addl mul bdVar t =
723 fun deg _ _ v (Const (s,Type (_,[]))) = if v=strip_thy s then 1 else 0
724 | deg _ _ v (Free (s,Type (_,[]))) = if v=strip_thy s then 1 else 0
725 | deg _ _ v (Var((s,_),Type (_,[]))) = if v=strip_thy s then 1 else 0
726 (*| deg _ _ v (_ (s,"?DUMMY" )) = ..ML-error *)
727 | deg _ _ v((Const ("Bin.integ_of_bin",_)) $ _ )= 0
728 | deg addl mul v (h $ t1 $ t2) =
729 if subset op = (bin_op h, addl)
730 then max (deg addl mul v t1 ,deg addl mul v t2)
731 else (*mul!*)(deg addl mul v t1)+(deg addl mul v t2)
732 in if polynomial (addl @ [mul]) t bdVar
733 then SOME (deg addl mul (id_of bdVar) t) else (NONE:int option)
735 fun degree_ addl mul bdVar t = (* do not export *)
736 let fun opt (SOME i)= i
738 in opt (degree addl mul bdVar t) end;
741 fun linear addl mul t bdVar = (degree_ addl mul bdVar t)<2;
743 fun linear_equ addl mul bdVar t =
745 then let val degl = degree_ addl mul bdVar (equ_lhs t);
746 val degr = degree_ addl mul bdVar (equ_rhs t)
747 in if (degl>0 orelse degr>0)andalso max(degl,degr)<2
751 (* strip_thy op_ before *)
752 fun is_div_op (dv,(Const (op_,(Type ("fun",
753 [Type (s2,[]),Type ("fun",
754 [Type (s4,tl4),Type (s5,tl5)])])))) )= (dv = strip_thy op_)
755 | is_div_op _ = false;
757 fun is_denom bdVar div_op t =
758 let fun is bool[v]dv (Const (s,Type(_,[])))= bool andalso(if v=strip_thy s then true else false)
759 | is bool[v]dv (Free (s,Type(_,[])))= bool andalso(if v=strip_thy s then true else false)
760 | is bool[v]dv (Var((s,_),Type(_,[])))= bool andalso(if v=strip_thy s then true else false)
761 | is bool[v]dv((Const ("Bin.integ_of_bin",_)) $ _) = false
762 | is bool[v]dv (h$n$d) =
764 then (is false[v]dv n)orelse(is true[v]dv d)
765 else (is bool [v]dv n)orelse(is bool[v]dv d)
766 in is false (varids bdVar) (strip_thy div_op) t end;
769 fun rational t div_op bdVar =
770 is_denom bdVar div_op t andalso bin_ops_only t;
775 (** problem types **)
778 (prep_pbt thy "pbl_test_uni_plain2" [] e_pblID
779 (["plain_square","univariate","equation","test"],
780 [("#Given" ,["equality e_e","solveFor v_v"]),
781 ("#Where" ,["(matches (?a + ?b*v_v ^^^2 = 0) e_e) |" ^
782 "(matches ( ?b*v_v ^^^2 = 0) e_e) |" ^
783 "(matches (?a + v_v ^^^2 = 0) e_e) |" ^
784 "(matches ( v_v ^^^2 = 0) e_e)"]),
785 ("#Find" ,["solutions v_v'i'"])
787 assoc_rls' @{theory} "matches",
788 SOME "solve (e_e::bool, v_v)", [["Test","solve_plain_square"]]));
790 val e_e = (term_of o the o (parse thy)) "e_e::bool";
791 val ve = (term_of o the o (parse thy)) "4 + 3*x^^^2 = 0";
794 val pre = (term_of o the o (parse thy))
795 "(matches (a + b*v_v ^^^2 = 0, e_e::bool)) |" ^
796 "(matches ( b*v_v ^^^2 = 0, e_e::bool)) |" ^
797 "(matches (a + v_v ^^^2 = 0, e_e::bool)) |" ^
798 "(matches ( v_v ^^^2 = 0, e_e::bool))";
799 val prei = subst_atomic env pre;
800 val cpre = (cterm_of thy) prei;
802 val SOME (ct,_) = rewrite_set_ thy false tval_rls cpre;
803 val ct = "True | False | False | False" : cterm
805 > val SOME (ct,_) = rewrite_ thy sqrt_right tval_rls false or_false ct;
806 > val SOME (ct,_) = rewrite_ thy sqrt_right tval_rls false or_false ct;
807 > val SOME (ct,_) = rewrite_ thy sqrt_right tval_rls false or_false ct;
808 val ct = "HOL.True" : cterm
815 (prep_pbt thy "pbl_test_uni_poly" [] e_pblID
816 (["polynomial","univariate","equation","test"],
817 [("#Given" ,["equality (v_v ^^^2 + p_p * v_v + q__q = 0)","solveFor v_v"]),
818 ("#Where" ,["HOL.False"]),
819 ("#Find" ,["solutions v_v'i'"])
821 e_rls, SOME "solve (e_e::bool, v_v)", []));
824 (prep_pbt thy "pbl_test_uni_poly_deg2" [] e_pblID
825 (["degree_two","polynomial","univariate","equation","test"],
826 [("#Given" ,["equality (v_v ^^^2 + p_p * v_v + q__q = 0)","solveFor v_v"]),
827 ("#Find" ,["solutions v_v'i'"])
829 e_rls, SOME "solve (v_v ^^^2 + p_p * v_v + q__q = 0, v_v)", []));
832 (prep_pbt thy "pbl_test_uni_poly_deg2_pq" [] e_pblID
833 (["pq_formula","degree_two","polynomial","univariate","equation","test"],
834 [("#Given" ,["equality (v_v ^^^2 + p_p * v_v + q__q = 0)","solveFor v_v"]),
835 ("#Find" ,["solutions v_v'i'"])
837 e_rls, SOME "solve (v_v ^^^2 + p_p * v_v + q__q = 0, v_v)", []));
840 (prep_pbt thy "pbl_test_uni_poly_deg2_abc" [] e_pblID
841 (["abc_formula","degree_two","polynomial","univariate","equation","test"],
842 [("#Given" ,["equality (a_a * x ^^^2 + b_b * x + c_c = 0)","solveFor v_v"]),
843 ("#Find" ,["solutions v_v'i'"])
845 e_rls, SOME "solve (a_a * x ^^^2 + b_b * x + c_c = 0, v_v)", []));
850 (prep_pbt thy "pbl_test_uni_root" [] e_pblID
851 (["squareroot","univariate","equation","test"],
852 [("#Given" ,["equality e_e","solveFor v_v"]),
853 ("#Where" ,["precond_rootpbl v_v"]),
854 ("#Find" ,["solutions v_v'i'"])
856 append_rls "contains_root" e_rls [Calc ("Test.contains'_root",
857 eval_contains_root "#contains_root_")],
858 SOME "solve (e_e::bool, v_v)", [["Test","square_equation"]]));
861 (prep_pbt thy "pbl_test_uni_norm" [] e_pblID
862 (["normalize","univariate","equation","test"],
863 [("#Given" ,["equality e_e","solveFor v_v"]),
865 ("#Find" ,["solutions v_v'i'"])
867 e_rls, SOME "solve (e_e::bool, v_v)", [["Test","norm_univar_equation"]]));
870 (prep_pbt thy "pbl_test_uni_roottest" [] e_pblID
871 (["sqroot-test","univariate","equation","test"],
872 [("#Given" ,["equality e_e","solveFor v_v"]),
873 ("#Where" ,["precond_rootpbl v_v"]),
874 ("#Find" ,["solutions v_v'i'"])
876 e_rls, SOME "solve (e_e::bool, v_v)", []));
879 (prep_pbt thy "pbl_test_intsimp" [] e_pblID
881 [("#Given" ,["intTestGiven t_t"]),
883 ("#Find" ,["intTestFind s_s"])
885 e_rls, NONE, [["Test","intsimp"]]));
888 get_pbt ["inttype","test"];
895 (prep_met thy "met_test_sqrt" [] e_metID
896 (*root-equation, version for tests before 8.01.01*)
897 (["Test","sqrt-equ-test"]:metID,
898 [("#Given" ,["equality e_e","solveFor v_v"]),
899 ("#Where" ,["contains_root (e_e::bool)"]),
900 ("#Find" ,["solutions v_v'i'"])
902 {rew_ord'="e_rew_ord",rls'=tval_rls,
903 srls =append_rls "srls_contains_root" e_rls
904 [Calc ("Test.contains'_root",eval_contains_root "")],
905 prls =append_rls "prls_contains_root" e_rls
906 [Calc ("Test.contains'_root",eval_contains_root "")],
908 crls=tval_rls, errpats = [], nrls = e_rls(*,asm_rls=[],
909 asm_thm=[("square_equation_left",""),
910 ("square_equation_right","")]*)},
911 "Script Solve_root_equation (e_e::bool) (v_v::real) = " ^
913 " ((While (contains_root e_e) Do" ^
914 " ((Rewrite square_equation_left True) @@" ^
915 " (Try (Rewrite_Set Test_simplify False)) @@" ^
916 " (Try (Rewrite_Set rearrange_assoc False)) @@" ^
917 " (Try (Rewrite_Set isolate_root False)) @@" ^
918 " (Try (Rewrite_Set Test_simplify False)))) @@" ^
919 " (Try (Rewrite_Set norm_equation False)) @@" ^
920 " (Try (Rewrite_Set Test_simplify False)) @@" ^
921 " (Rewrite_Set_Inst [(bdv,v_v::real)] isolate_bdv False) @@" ^
922 " (Try (Rewrite_Set Test_simplify False)))" ^
930 (prep_met thy "met_test_sqrt2" [] e_metID
931 (*root-equation ... for test-*.sml until 8.01*)
932 (["Test","squ-equ-test2"]:metID,
933 [("#Given" ,["equality e_e","solveFor v_v"]),
934 ("#Find" ,["solutions v_v'i'"])
936 {rew_ord'="e_rew_ord",rls'=tval_rls,
937 srls = append_rls "srls_contains_root" e_rls
938 [Calc ("Test.contains'_root",eval_contains_root"")],
940 crls=tval_rls, errpats = [], nrls = e_rls(*,asm_rls=[],
941 asm_thm=[("square_equation_left",""),
942 ("square_equation_right","")]*)},
943 "Script Solve_root_equation (e_e::bool) (v_v::real) = " ^
945 " ((While (contains_root e_e) Do" ^
946 " ((Rewrite square_equation_left True) @@" ^
947 " (Try (Rewrite_Set Test_simplify False)) @@" ^
948 " (Try (Rewrite_Set rearrange_assoc False)) @@" ^
949 " (Try (Rewrite_Set isolate_root False)) @@" ^
950 " (Try (Rewrite_Set Test_simplify False)))) @@" ^
951 " (Try (Rewrite_Set norm_equation False)) @@" ^
952 " (Try (Rewrite_Set Test_simplify False)) @@" ^
953 " (Rewrite_Set_Inst [(bdv,v_v::real)] isolate_bdv False) @@" ^
954 " (Try (Rewrite_Set Test_simplify False)))" ^
956 " (L_L::bool list) = Tac subproblem_equation_dummy; " ^
957 " L_L = Tac solve_equation_dummy " ^
958 " in Check_elementwise L_L {(v_v::real). Assumptions})"
964 (prep_met thy "met_test_squ_sub" [] e_metID
965 (*tests subproblem fixed linear*)
966 (["Test","squ-equ-test-subpbl1"]:metID,
967 [("#Given" ,["equality e_e","solveFor v_v"]),
968 ("#Where" ,["precond_rootmet v_v"]),
969 ("#Find" ,["solutions v_v'i'"])
971 {rew_ord' = "e_rew_ord", rls' = tval_rls, srls = e_rls,
972 prls = append_rls "prls_met_test_squ_sub" e_rls
973 [Calc ("Test.precond'_rootmet", eval_precond_rootmet "")],
974 calc=[], crls=tval_rls, errpats = [], nrls = Test_simplify},
975 "Script Solve_root_equation (e_e::bool) (v_v::real) = " ^
976 " (let e_e = ((Try (Rewrite_Set norm_equation False)) @@ " ^
977 " (Try (Rewrite_Set Test_simplify False))) e_e; " ^
978 " (L_L::bool list) = " ^
979 " (SubProblem (Test', " ^
980 " [linear,univariate,equation,test]," ^
981 " [Test,solve_linear]) " ^
982 " [BOOL e_e, REAL v_v]) " ^
983 " in Check_elementwise L_L {(v_v::real). Assumptions}) "
989 (prep_met thy "met_test_squ_sub2" [] e_metID
990 (*tests subproblem fixed degree 2*)
991 (["Test","squ-equ-test-subpbl2"]:metID,
992 [("#Given" ,["equality e_e","solveFor v_v"]),
993 ("#Find" ,["solutions v_v'i'"])
995 {rew_ord'="e_rew_ord",rls'=tval_rls,srls=e_rls,prls=e_rls,calc=[],
996 crls=tval_rls, errpats = [], nrls = e_rls(*,
997 asm_rls=[],asm_thm=[("square_equation_left",""),
998 ("square_equation_right","")]*)},
999 "Script Solve_root_equation (e_e::bool) (v_v::real) = " ^
1000 " (let e_e = Try (Rewrite_Set norm_equation False) e_e; " ^
1001 "(L_L::bool list) = (SubProblem (Test',[linear,univariate,equation,test]," ^
1002 " [Test,solve_by_pq_formula]) [BOOL e_e, REAL v_v])" ^
1003 "in Check_elementwise L_L {(v_v::real). Assumptions})"
1009 (prep_met thy "met_test_squ_nonterm" [] e_metID
1010 (*root-equation: see foils..., but notTerminating*)
1011 (["Test","square_equation...notTerminating"]:metID,
1012 [("#Given" ,["equality e_e","solveFor v_v"]),
1013 ("#Find" ,["solutions v_v'i'"])
1015 {rew_ord'="e_rew_ord",rls'=tval_rls,
1016 srls = append_rls "srls_contains_root" e_rls
1017 [Calc ("Test.contains'_root",eval_contains_root"")],
1019 crls=tval_rls, errpats = [], nrls = e_rls(*,asm_rls=[],
1020 asm_thm=[("square_equation_left",""),
1021 ("square_equation_right","")]*)},
1022 "Script Solve_root_equation (e_e::bool) (v_v::real) = " ^
1024 " ((While (contains_root e_e) Do" ^
1025 " ((Rewrite square_equation_left True) @@" ^
1026 " (Try (Rewrite_Set Test_simplify False)) @@" ^
1027 " (Try (Rewrite_Set rearrange_assoc False)) @@" ^
1028 " (Try (Rewrite_Set isolate_root False)) @@" ^
1029 " (Try (Rewrite_Set Test_simplify False)))) @@" ^
1030 " (Try (Rewrite_Set norm_equation False)) @@" ^
1031 " (Try (Rewrite_Set Test_simplify False)))" ^
1033 " (L_L::bool list) = " ^
1034 " (SubProblem (Test',[linear,univariate,equation,test]," ^
1035 " [Test,solve_linear]) [BOOL e_e, REAL v_v])" ^
1036 "in Check_elementwise L_L {(v_v::real). Assumptions})"
1042 (prep_met thy "met_test_eq1" [] e_metID
1044 (["Test","square_equation1"]:metID,
1045 [("#Given" ,["equality e_e","solveFor v_v"]),
1046 ("#Find" ,["solutions v_v'i'"])
1048 {rew_ord'="e_rew_ord",rls'=tval_rls,
1049 srls = append_rls "srls_contains_root" e_rls
1050 [Calc ("Test.contains'_root",eval_contains_root"")],
1052 crls=tval_rls, errpats = [], nrls = e_rls(*,asm_rls=[],
1053 asm_thm=[("square_equation_left",""),
1054 ("square_equation_right","")]*)},
1055 "Script Solve_root_equation (e_e::bool) (v_v::real) = " ^
1057 " ((While (contains_root e_e) Do" ^
1058 " ((Rewrite square_equation_left True) @@" ^
1059 " (Try (Rewrite_Set Test_simplify False)) @@" ^
1060 " (Try (Rewrite_Set rearrange_assoc False)) @@" ^
1061 " (Try (Rewrite_Set isolate_root False)) @@" ^
1062 " (Try (Rewrite_Set Test_simplify False)))) @@" ^
1063 " (Try (Rewrite_Set norm_equation False)) @@" ^
1064 " (Try (Rewrite_Set Test_simplify False)))" ^
1066 " (L_L::bool list) = (SubProblem (Test',[linear,univariate,equation,test]," ^
1067 " [Test,solve_linear]) [BOOL e_e, REAL v_v])" ^
1068 " in Check_elementwise L_L {(v_v::real). Assumptions})"
1074 (prep_met thy "met_test_squ2" [] e_metID
1076 (["Test","square_equation2"]:metID,
1077 [("#Given" ,["equality e_e","solveFor v_v"]),
1078 ("#Find" ,["solutions v_v'i'"])
1080 {rew_ord'="e_rew_ord",rls'=tval_rls,
1081 srls = append_rls "srls_contains_root" e_rls
1082 [Calc ("Test.contains'_root",eval_contains_root"")],
1084 crls=tval_rls, errpats = [], nrls = e_rls(*,asm_rls=[],
1085 asm_thm=[("square_equation_left",""),
1086 ("square_equation_right","")]*)},
1087 "Script Solve_root_equation (e_e::bool) (v_v::real) = " ^
1089 " ((While (contains_root e_e) Do" ^
1090 " (((Rewrite square_equation_left True) Or " ^
1091 " (Rewrite square_equation_right True)) @@" ^
1092 " (Try (Rewrite_Set Test_simplify False)) @@" ^
1093 " (Try (Rewrite_Set rearrange_assoc False)) @@" ^
1094 " (Try (Rewrite_Set isolate_root False)) @@" ^
1095 " (Try (Rewrite_Set Test_simplify False)))) @@" ^
1096 " (Try (Rewrite_Set norm_equation False)) @@" ^
1097 " (Try (Rewrite_Set Test_simplify False)))" ^
1099 " (L_L::bool list) = (SubProblem (Test',[plain_square,univariate,equation,test]," ^
1100 " [Test,solve_plain_square]) [BOOL e_e, REAL v_v])" ^
1101 " in Check_elementwise L_L {(v_v::real). Assumptions})"
1107 (prep_met thy "met_test_squeq" [] e_metID
1109 (["Test","square_equation"]:metID,
1110 [("#Given" ,["equality e_e","solveFor v_v"]),
1111 ("#Find" ,["solutions v_v'i'"])
1113 {rew_ord'="e_rew_ord",rls'=tval_rls,
1114 srls = append_rls "srls_contains_root" e_rls
1115 [Calc ("Test.contains'_root",eval_contains_root"")],
1117 crls=tval_rls, errpats = [], nrls = e_rls(*,asm_rls=[],
1118 asm_thm=[("square_equation_left",""),
1119 ("square_equation_right","")]*)},
1120 "Script Solve_root_equation (e_e::bool) (v_v::real) = " ^
1122 " ((While (contains_root e_e) Do" ^
1123 " (((Rewrite square_equation_left True) Or" ^
1124 " (Rewrite square_equation_right True)) @@" ^
1125 " (Try (Rewrite_Set Test_simplify False)) @@" ^
1126 " (Try (Rewrite_Set rearrange_assoc False)) @@" ^
1127 " (Try (Rewrite_Set isolate_root False)) @@" ^
1128 " (Try (Rewrite_Set Test_simplify False)))) @@" ^
1129 " (Try (Rewrite_Set norm_equation False)) @@" ^
1130 " (Try (Rewrite_Set Test_simplify False)))" ^
1132 " (L_L::bool list) = (SubProblem (Test',[univariate,equation,test]," ^
1133 " [no_met]) [BOOL e_e, REAL v_v])" ^
1134 " in Check_elementwise L_L {(v_v::real). Assumptions})"
1140 (prep_met thy "met_test_eq_plain" [] e_metID
1141 (*solve_plain_square*)
1142 (["Test","solve_plain_square"]:metID,
1143 [("#Given",["equality e_e","solveFor v_v"]),
1144 ("#Where" ,["(matches (?a + ?b*v_v ^^^2 = 0) e_e) |" ^
1145 "(matches ( ?b*v_v ^^^2 = 0) e_e) |" ^
1146 "(matches (?a + v_v ^^^2 = 0) e_e) |" ^
1147 "(matches ( v_v ^^^2 = 0) e_e)"]),
1148 ("#Find" ,["solutions v_v'i'"])
1150 {rew_ord'="e_rew_ord",rls'=tval_rls,calc=[],srls=e_rls,
1151 prls = assoc_rls' @{theory} "matches",
1152 crls=tval_rls, errpats = [], nrls = e_rls(*,
1153 asm_rls=[],asm_thm=[]*)},
1154 "Script Solve_plain_square (e_e::bool) (v_v::real) = " ^
1155 " (let e_e = ((Try (Rewrite_Set isolate_bdv False)) @@ " ^
1156 " (Try (Rewrite_Set Test_simplify False)) @@ " ^
1157 " ((Rewrite square_equality_0 False) Or " ^
1158 " (Rewrite square_equality True)) @@ " ^
1159 " (Try (Rewrite_Set tval_rls False))) e_e " ^
1160 " in ((Or_to_List e_e)::bool list))"
1167 (prep_met thy "met_test_norm_univ" [] e_metID
1168 (["Test","norm_univar_equation"]:metID,
1169 [("#Given",["equality e_e","solveFor v_v"]),
1171 ("#Find" ,["solutions v_v'i'"])
1173 {rew_ord'="e_rew_ord",rls'=tval_rls,srls = e_rls,prls=e_rls,
1175 crls=tval_rls, errpats = [], nrls = e_rls},
1176 "Script Norm_univar_equation (e_e::bool) (v_v::real) = " ^
1177 " (let e_e = ((Try (Rewrite rnorm_equation_add False)) @@ " ^
1178 " (Try (Rewrite_Set Test_simplify False))) e_e " ^
1179 " in (SubProblem (Test',[univariate,equation,test], " ^
1180 " [no_met]) [BOOL e_e, REAL v_v]))"
1183 (*17.9.02 aus SqRoot.ML------------------------------^^^---*)
1186 (prep_met thy "met_test_intsimp" [] e_metID
1187 (["Test","intsimp"]:metID,
1188 [("#Given" ,["intTestGiven t_t"]),
1190 ("#Find" ,["intTestFind s_s"])
1192 {rew_ord' = "e_rew_ord", rls' = tval_rls, srls = e_rls,
1193 prls = e_rls, calc = [], crls = tval_rls, errpats = [], nrls = Test_simplify},
1194 "Script STest_simplify (t_t::int) = " ^
1196 " ((Try (Calculate PLUS)) @@ " ^
1197 " (Try (Calculate TIMES))) t_t::int)"
1203 (*8.4.03 aus Poly.ML--------------------------------vvv---
1204 make_polynomial ---> make_poly
1205 ^-- for user ^-- for systest _ONLY_*)
1207 local (*. for make_polytest .*)
1209 open Term; (* for type order = EQUAL | LESS | GREATER *)
1211 fun pr_ord EQUAL = "EQUAL"
1212 | pr_ord LESS = "LESS"
1213 | pr_ord GREATER = "GREATER";
1215 fun dest_hd' (Const (a, T)) = (* ~ term.ML *)
1217 "Atools.pow" => ((("|||||||||||||", 0), T), 0) (*WN greatest *)
1218 | _ => (((a, 0), T), 0))
1219 | dest_hd' (Free (a, T)) = (((a, 0), T), 1)
1220 | dest_hd' (Var v) = (v, 2)
1221 | dest_hd' (Bound i) = ((("", i), dummyT), 3)
1222 | dest_hd' (Abs (_, T, _)) = ((("", 0), T), 4);
1224 fun get_order_pow (t $ (Free(order,_))) =
1225 (case int_of_str (order) of
1228 | get_order_pow _ = 0;
1230 fun size_of_term' (Const(str,_) $ t) =
1231 if "Atools.pow"=str then 1000 + size_of_term' t else 1 + size_of_term' t(*WN*)
1232 | size_of_term' (Abs (_,_,body)) = 1 + size_of_term' body
1233 | size_of_term' (f$t) = size_of_term' f + size_of_term' t
1234 | size_of_term' _ = 1;
1235 fun term_ord' pr thy (Abs (_, T, t), Abs(_, U, u)) = (* ~ term.ML *)
1236 (case term_ord' pr thy (t, u) of EQUAL => Term_Ord.typ_ord (T, U)
1238 | term_ord' pr thy (t, u) =
1240 let val (f, ts) = strip_comb t and (g, us) = strip_comb u;
1241 val _ = tracing ("t= f@ts= \"" ^ term2str f ^ "\" @ \"[" ^
1242 commas(map term2str ts) ^ "]\"")
1243 val _ = tracing ("u= g@us= \"" ^ term2str g ^"\" @ \"[" ^
1244 commas(map term2str us) ^"]\"")
1245 val _ = tracing ("size_of_term(t,u)= (" ^
1246 string_of_int (size_of_term' t) ^ ", " ^
1247 string_of_int (size_of_term' u) ^ ")")
1248 val _ = tracing ("hd_ord(f,g) = " ^ (pr_ord o hd_ord) (f,g))
1249 val _ = tracing ("terms_ord(ts,us) = " ^
1250 (pr_ord o terms_ord str false) (ts,us));
1251 val _ = tracing "-------"
1254 case int_ord (size_of_term' t, size_of_term' u) of
1256 let val (f, ts) = strip_comb t and (g, us) = strip_comb u in
1257 (case hd_ord (f, g) of EQUAL => (terms_ord str pr) (ts, us)
1261 and hd_ord (f, g) = (* ~ term.ML *)
1262 prod_ord (prod_ord Term_Ord.indexname_ord Term_Ord.typ_ord) int_ord (dest_hd' f, dest_hd' g)
1263 and terms_ord str pr (ts, us) =
1264 list_ord (term_ord' pr (assoc_thy "Isac"))(ts, us);
1267 fun ord_make_polytest (pr:bool) thy (_:subst) tu =
1268 (term_ord' pr thy(***) tu = LESS );
1274 rew_ord' := overwritel (!rew_ord',
1275 [("termlessI", termlessI),
1276 ("ord_make_polytest", ord_make_polytest false thy)
1279 (*WN060510 this was a preparation for prep_rls ...
1280 val scr_make_polytest =
1281 "Script Expand_binomtest t_t =" ^
1283 "((Try (Repeat (Rewrite real_diff_minus False))) @@ " ^
1285 " (Try (Repeat (Rewrite distrib_right False))) @@ " ^
1286 " (Try (Repeat (Rewrite distrib_left False))) @@ " ^
1287 " (Try (Repeat (Rewrite left_diff_distrib False))) @@ " ^
1288 " (Try (Repeat (Rewrite right_diff_distrib False))) @@ " ^
1290 " (Try (Repeat (Rewrite mult_1_left False))) @@ " ^
1291 " (Try (Repeat (Rewrite mult_zero_left False))) @@ " ^
1292 " (Try (Repeat (Rewrite add_0_left False))) @@ " ^
1294 " (Try (Repeat (Rewrite mult_commute False))) @@ " ^
1295 " (Try (Repeat (Rewrite real_mult_left_commute False))) @@ " ^
1296 " (Try (Repeat (Rewrite mult_assoc False))) @@ " ^
1297 " (Try (Repeat (Rewrite add_commute False))) @@ " ^
1298 " (Try (Repeat (Rewrite add_left_commute False))) @@ " ^
1299 " (Try (Repeat (Rewrite add_assoc False))) @@ " ^
1301 " (Try (Repeat (Rewrite sym_realpow_twoI False))) @@ " ^
1302 " (Try (Repeat (Rewrite realpow_plus_1 False))) @@ " ^
1303 " (Try (Repeat (Rewrite sym_real_mult_2 False))) @@ " ^
1304 " (Try (Repeat (Rewrite real_mult_2_assoc False))) @@ " ^
1306 " (Try (Repeat (Rewrite real_num_collect False))) @@ " ^
1307 " (Try (Repeat (Rewrite real_num_collect_assoc False))) @@ " ^
1309 " (Try (Repeat (Rewrite real_one_collect False))) @@ " ^
1310 " (Try (Repeat (Rewrite real_one_collect_assoc False))) @@ " ^
1312 " (Try (Repeat (Calculate PLUS ))) @@ " ^
1313 " (Try (Repeat (Calculate TIMES ))) @@ " ^
1314 " (Try (Repeat (Calculate POWER)))) " ^
1316 -----------------------------------------------------*)
1319 Rls{id = "make_polytest", preconds = []:term list,
1320 rew_ord = ("ord_make_polytest", ord_make_polytest false @{theory "Poly"}),
1321 erls = testerls, srls = Erls,
1322 calc = [("PLUS" , ("Groups.plus_class.plus", eval_binop "#add_")),
1323 ("TIMES" , ("Groups.times_class.times", eval_binop "#mult_")),
1324 ("POWER", ("Atools.pow", eval_binop "#power_"))
1326 rules = [Thm ("real_diff_minus",num_str @{thm real_diff_minus}),
1327 (*"a - b = a + (-1) * b"*)
1328 Thm ("distrib_right" ,num_str @{thm distrib_right}),
1329 (*"(z1.0 + z2.0) * w = z1.0 * w + z2.0 * w"*)
1330 Thm ("distrib_left",num_str @{thm distrib_left}),
1331 (*"w * (z1.0 + z2.0) = w * z1.0 + w * z2.0"*)
1332 Thm ("left_diff_distrib" ,num_str @{thm left_diff_distrib}),
1333 (*"(z1.0 - z2.0) * w = z1.0 * w - z2.0 * w"*)
1334 Thm ("right_diff_distrib",num_str @{thm right_diff_distrib}),
1335 (*"w * (z1.0 - z2.0) = w * z1.0 - w * z2.0"*)
1336 Thm ("mult_1_left",num_str @{thm mult_1_left}),
1338 Thm ("mult_zero_left",num_str @{thm mult_zero_left}),
1340 Thm ("add_0_left",num_str @{thm add_0_left}),
1344 Thm ("mult_commute",num_str @{thm mult_commute}),
1346 Thm ("real_mult_left_commute",num_str @{thm real_mult_left_commute}),
1347 (*z1.0 * (z2.0 * z3.0) = z2.0 * (z1.0 * z3.0)*)
1348 Thm ("mult_assoc",num_str @{thm mult_assoc}),
1349 (*z1.0 * z2.0 * z3.0 = z1.0 * (z2.0 * z3.0)*)
1350 Thm ("add_commute",num_str @{thm add_commute}),
1352 Thm ("add_left_commute",num_str @{thm add_left_commute}),
1353 (*x + (y + z) = y + (x + z)*)
1354 Thm ("add_assoc",num_str @{thm add_assoc}),
1355 (*z1.0 + z2.0 + z3.0 = z1.0 + (z2.0 + z3.0)*)
1357 Thm ("sym_realpow_twoI",
1358 num_str (@{thm realpow_twoI} RS @{thm sym})),
1359 (*"r1 * r1 = r1 ^^^ 2"*)
1360 Thm ("realpow_plus_1",num_str @{thm realpow_plus_1}),
1361 (*"r * r ^^^ n = r ^^^ (n + 1)"*)
1362 Thm ("sym_real_mult_2",
1363 num_str (@{thm real_mult_2} RS @{thm sym})),
1364 (*"z1 + z1 = 2 * z1"*)
1365 Thm ("real_mult_2_assoc",num_str @{thm real_mult_2_assoc}),
1366 (*"z1 + (z1 + k) = 2 * z1 + k"*)
1368 Thm ("real_num_collect",num_str @{thm real_num_collect}),
1369 (*"[| l is_const; m is_const |]==>l * n + m * n = (l + m) * n"*)
1370 Thm ("real_num_collect_assoc",num_str @{thm real_num_collect_assoc}),
1371 (*"[| l is_const; m is_const |] ==>
1372 l * n + (m * n + k) = (l + m) * n + k"*)
1373 Thm ("real_one_collect",num_str @{thm real_one_collect}),
1374 (*"m is_const ==> n + m * n = (1 + m) * n"*)
1375 Thm ("real_one_collect_assoc",num_str @{thm real_one_collect_assoc}),
1376 (*"m is_const ==> k + (n + m * n) = k + (1 + m) * n"*)
1378 Calc ("Groups.plus_class.plus", eval_binop "#add_"),
1379 Calc ("Groups.times_class.times", eval_binop "#mult_"),
1380 Calc ("Atools.pow", eval_binop "#power_")
1382 scr = EmptyScr(*Prog ((term_of o the o (parse thy))
1383 scr_make_polytest)*)
1387 (*WN060510 this was done before 'fun prep_rls' ...------------------------
1388 val scr_expand_binomtest =
1389 "Script Expand_binomtest t_t =" ^
1391 "((Try (Repeat (Rewrite real_plus_binom_pow2 False))) @@ " ^
1392 " (Try (Repeat (Rewrite real_plus_binom_times False))) @@ " ^
1393 " (Try (Repeat (Rewrite real_minus_binom_pow2 False))) @@ " ^
1394 " (Try (Repeat (Rewrite real_minus_binom_times False))) @@ " ^
1395 " (Try (Repeat (Rewrite real_plus_minus_binom1 False))) @@ " ^
1396 " (Try (Repeat (Rewrite real_plus_minus_binom2 False))) @@ " ^
1398 " (Try (Repeat (Rewrite mult_1_left False))) @@ " ^
1399 " (Try (Repeat (Rewrite mult_zero_left False))) @@ " ^
1400 " (Try (Repeat (Rewrite add_0_left False))) @@ " ^
1402 " (Try (Repeat (Calculate PLUS ))) @@ " ^
1403 " (Try (Repeat (Calculate TIMES ))) @@ " ^
1404 " (Try (Repeat (Calculate POWER))) @@ " ^
1406 " (Try (Repeat (Rewrite sym_realpow_twoI False))) @@ " ^
1407 " (Try (Repeat (Rewrite realpow_plus_1 False))) @@ " ^
1408 " (Try (Repeat (Rewrite sym_real_mult_2 False))) @@ " ^
1409 " (Try (Repeat (Rewrite real_mult_2_assoc False))) @@ " ^
1411 " (Try (Repeat (Rewrite real_num_collect False))) @@ " ^
1412 " (Try (Repeat (Rewrite real_num_collect_assoc False))) @@ " ^
1414 " (Try (Repeat (Rewrite real_one_collect False))) @@ " ^
1415 " (Try (Repeat (Rewrite real_one_collect_assoc False))) @@ " ^
1417 " (Try (Repeat (Calculate PLUS ))) @@ " ^
1418 " (Try (Repeat (Calculate TIMES ))) @@ " ^
1419 " (Try (Repeat (Calculate POWER)))) " ^
1421 --------------------------------------------------------------------------*)
1423 val expand_binomtest =
1424 Rls{id = "expand_binomtest", preconds = [],
1425 rew_ord = ("termlessI",termlessI),
1426 erls = testerls, srls = Erls,
1427 calc = [("PLUS" , ("Groups.plus_class.plus", eval_binop "#add_")),
1428 ("TIMES" , ("Groups.times_class.times", eval_binop "#mult_")),
1429 ("POWER", ("Atools.pow", eval_binop "#power_"))
1432 [Thm ("real_plus_binom_pow2" ,num_str @{thm real_plus_binom_pow2}),
1433 (*"(a + b) ^^^ 2 = a ^^^ 2 + 2 * a * b + b ^^^ 2"*)
1434 Thm ("real_plus_binom_times" ,num_str @{thm real_plus_binom_times}),
1435 (*"(a + b)*(a + b) = ...*)
1436 Thm ("real_minus_binom_pow2" ,num_str @{thm real_minus_binom_pow2}),
1437 (*"(a - b) ^^^ 2 = a ^^^ 2 - 2 * a * b + b ^^^ 2"*)
1438 Thm ("real_minus_binom_times",num_str @{thm real_minus_binom_times}),
1439 (*"(a - b)*(a - b) = ...*)
1440 Thm ("real_plus_minus_binom1",num_str @{thm real_plus_minus_binom1}),
1441 (*"(a + b) * (a - b) = a ^^^ 2 - b ^^^ 2"*)
1442 Thm ("real_plus_minus_binom2",num_str @{thm real_plus_minus_binom2}),
1443 (*"(a - b) * (a + b) = a ^^^ 2 - b ^^^ 2"*)
1445 Thm ("real_pp_binom_times",num_str @{thm real_pp_binom_times}),
1446 (*(a + b)*(c + d) = a*c + a*d + b*c + b*d*)
1447 Thm ("real_pm_binom_times",num_str @{thm real_pm_binom_times}),
1448 (*(a + b)*(c - d) = a*c - a*d + b*c - b*d*)
1449 Thm ("real_mp_binom_times",num_str @{thm real_mp_binom_times}),
1450 (*(a - b)*(c p d) = a*c + a*d - b*c - b*d*)
1451 Thm ("real_mm_binom_times",num_str @{thm real_mm_binom_times}),
1452 (*(a - b)*(c p d) = a*c - a*d - b*c + b*d*)
1453 Thm ("realpow_multI",num_str @{thm realpow_multI}),
1454 (*(a*b)^^^n = a^^^n * b^^^n*)
1455 Thm ("real_plus_binom_pow3",num_str @{thm real_plus_binom_pow3}),
1456 (* (a + b)^^^3 = a^^^3 + 3*a^^^2*b + 3*a*b^^^2 + b^^^3 *)
1457 Thm ("real_minus_binom_pow3",num_str @{thm real_minus_binom_pow3}),
1458 (* (a - b)^^^3 = a^^^3 - 3*a^^^2*b + 3*a*b^^^2 - b^^^3 *)
1461 (* Thm ("distrib_right" ,num_str @{thm distrib_right}),
1462 (*"(z1.0 + z2.0) * w = z1.0 * w + z2.0 * w"*)
1463 Thm ("distrib_left",num_str @{thm distrib_left}),
1464 (*"w * (z1.0 + z2.0) = w * z1.0 + w * z2.0"*)
1465 Thm ("left_diff_distrib" ,num_str @{thm left_diff_distrib}),
1466 (*"(z1.0 - z2.0) * w = z1.0 * w - z2.0 * w"*)
1467 Thm ("right_diff_distrib",num_str @{thm right_diff_distrib}),
1468 (*"w * (z1.0 - z2.0) = w * z1.0 - w * z2.0"*)
1471 Thm ("mult_1_left",num_str @{thm mult_1_left}),
1473 Thm ("mult_zero_left",num_str @{thm mult_zero_left}),
1475 Thm ("add_0_left",num_str @{thm add_0_left}),
1478 Calc ("Groups.plus_class.plus", eval_binop "#add_"),
1479 Calc ("Groups.times_class.times", eval_binop "#mult_"),
1480 Calc ("Atools.pow", eval_binop "#power_"),
1482 Thm ("mult_commute",num_str @{thm mult_commute}),
1484 Thm ("real_mult_left_commute",num_str @{thm real_mult_left_commute}),
1485 Thm ("mult_assoc",num_str @{thm mult_assoc}),
1486 Thm ("add_commute",num_str @{thm add_commute}),
1487 Thm ("add_left_commute",num_str @{thm add_left_commute}),
1488 Thm ("add_assoc",num_str @{thm add_assoc}),
1491 Thm ("sym_realpow_twoI",
1492 num_str (@{thm realpow_twoI} RS @{thm sym})),
1493 (*"r1 * r1 = r1 ^^^ 2"*)
1494 Thm ("realpow_plus_1",num_str @{thm realpow_plus_1}),
1495 (*"r * r ^^^ n = r ^^^ (n + 1)"*)
1496 (*Thm ("sym_real_mult_2",
1497 num_str (@{thm real_mult_2} RS @{thm sym})),
1498 (*"z1 + z1 = 2 * z1"*)*)
1499 Thm ("real_mult_2_assoc",num_str @{thm real_mult_2_assoc}),
1500 (*"z1 + (z1 + k) = 2 * z1 + k"*)
1502 Thm ("real_num_collect",num_str @{thm real_num_collect}),
1503 (*"[| l is_const; m is_const |] ==> l * n + m * n = (l + m) * n"*)
1504 Thm ("real_num_collect_assoc",num_str @{thm real_num_collect_assoc}),
1505 (*"[| l is_const; m is_const |] ==> l * n + (m * n + k) = (l + m) * n + k"*)
1506 Thm ("real_one_collect",num_str @{thm real_one_collect}),
1507 (*"m is_const ==> n + m * n = (1 + m) * n"*)
1508 Thm ("real_one_collect_assoc",num_str @{thm real_one_collect_assoc}),
1509 (*"m is_const ==> k + (n + m * n) = k + (1 + m) * n"*)
1511 Calc ("Groups.plus_class.plus", eval_binop "#add_"),
1512 Calc ("Groups.times_class.times", eval_binop "#mult_"),
1513 Calc ("Atools.pow", eval_binop "#power_")
1516 (*Script ((term_of o the o (parse thy)) scr_expand_binomtest)*)
1519 setup {* KEStore_Elems.add_rlss
1520 [("make_polytest", (Context.theory_name @{theory}, prep_rls make_polytest)),
1521 ("expand_binomtest", (Context.theory_name @{theory}, prep_rls expand_binomtest))] *}