ad 967c8a1eb6b1 (7): remove all code concerned with 'mets = Unsynchronized.ref'
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 setup {* KEStore_Elems.add_calcs
212 [("is_root_free", ("Test.is'_root'_free", eval_root_free"#is_root_free_e")),
213 ("contains_root", ("Test.contains'_root", eval_contains_root"#contains_root_")),
214 ("Test.precond'_rootmet", ("Test.precond'_rootmet", eval_precond_rootmet"#Test.precond_rootmet_")),
215 ("Test.precond'_rootpbl", ("Test.precond'_rootpbl",
216 eval_precond_rootpbl"#Test.precond_rootpbl_"))] *}
219 fun term_order (_:subst) tu = (term_ordI [] tu = LESS);
224 Rls {id = "testerls", preconds = [], rew_ord = ("termlessI",termlessI),
225 erls = e_rls, srls = Erls,
226 calc = [], errpatts = [],
227 rules = [Thm ("refl",num_str @{thm refl}),
228 Thm ("order_refl",num_str @{thm order_refl}),
229 Thm ("radd_left_cancel_le",num_str @{thm radd_left_cancel_le}),
230 Thm ("not_true",num_str @{thm not_true}),
231 Thm ("not_false",num_str @{thm not_false}),
232 Thm ("and_true",num_str @{thm and_true}),
233 Thm ("and_false",num_str @{thm and_false}),
234 Thm ("or_true",num_str @{thm or_true}),
235 Thm ("or_false",num_str @{thm or_false}),
236 Thm ("and_commute",num_str @{thm and_commute}),
237 Thm ("or_commute",num_str @{thm or_commute}),
239 Calc ("Atools.is'_const",eval_const "#is_const_"),
240 Calc ("Tools.matches",eval_matches ""),
242 Calc ("Groups.plus_class.plus",eval_binop "#add_"),
243 Calc ("Groups.times_class.times",eval_binop "#mult_"),
244 Calc ("Atools.pow" ,eval_binop "#power_"),
246 Calc ("Orderings.ord_class.less",eval_equ "#less_"),
247 Calc ("Orderings.ord_class.less_eq",eval_equ "#less_equal_"),
249 Calc ("Atools.ident",eval_ident "#ident_")],
250 scr = Prog ((term_of o the o (parse thy)) "empty_script")
254 (*.for evaluation of conditions in rewrite rules.*)
255 (*FIXXXXXXME 10.8.02: handle like _simplify*)
257 Rls{id = "tval_rls", preconds = [],
258 rew_ord = ("sqrt_right",sqrt_right false @{theory "Pure"}),
259 erls=testerls,srls = e_rls,
260 calc=[], errpatts = [],
261 rules = [Thm ("refl",num_str @{thm refl}),
262 Thm ("order_refl",num_str @{thm order_refl}),
263 Thm ("radd_left_cancel_le",num_str @{thm radd_left_cancel_le}),
264 Thm ("not_true",num_str @{thm not_true}),
265 Thm ("not_false",num_str @{thm not_false}),
266 Thm ("and_true",num_str @{thm and_true}),
267 Thm ("and_false",num_str @{thm and_false}),
268 Thm ("or_true",num_str @{thm or_true}),
269 Thm ("or_false",num_str @{thm or_false}),
270 Thm ("and_commute",num_str @{thm and_commute}),
271 Thm ("or_commute",num_str @{thm or_commute}),
273 Thm ("real_diff_minus",num_str @{thm real_diff_minus}),
275 Thm ("root_ge0",num_str @{thm root_ge0}),
276 Thm ("root_add_ge0",num_str @{thm root_add_ge0}),
277 Thm ("root_ge0_1",num_str @{thm root_ge0_1}),
278 Thm ("root_ge0_2",num_str @{thm root_ge0_2}),
280 Calc ("Atools.is'_const",eval_const "#is_const_"),
281 Calc ("Test.is'_root'_free",eval_root_free "#is_root_free_e"),
282 Calc ("Tools.matches",eval_matches ""),
283 Calc ("Test.contains'_root",
284 eval_contains_root"#contains_root_"),
286 Calc ("Groups.plus_class.plus",eval_binop "#add_"),
287 Calc ("Groups.times_class.times",eval_binop "#mult_"),
288 Calc ("NthRoot.sqrt",eval_sqrt "#sqrt_"),
289 Calc ("Atools.pow" ,eval_binop "#power_"),
291 Calc ("Orderings.ord_class.less",eval_equ "#less_"),
292 Calc ("Orderings.ord_class.less_eq",eval_equ "#less_equal_"),
294 Calc ("Atools.ident",eval_ident "#ident_")],
295 scr = Prog ((term_of o the o (parse thy)) "empty_script")
298 setup {* KEStore_Elems.add_rlss [("testerls", (Context.theory_name @{theory}, prep_rls testerls))] *}
301 (*make () dissappear*)
302 val rearrange_assoc =
303 Rls{id = "rearrange_assoc", preconds = [],
304 rew_ord = ("e_rew_ord",e_rew_ord),
305 erls = e_rls, srls = e_rls, calc = [], errpatts = [],
307 [Thm ("sym_add_assoc",num_str (@{thm add_assoc} RS @{thm sym})),
308 Thm ("sym_rmult_assoc",num_str (@{thm rmult_assoc} RS @{thm sym}))],
309 scr = Prog ((term_of o the o (parse thy)) "empty_script")
313 Rls{id = "ac_plus_times", preconds = [], rew_ord = ("term_order",term_order),
314 erls = e_rls, srls = e_rls, calc = [], errpatts = [],
316 [Thm ("radd_commute",num_str @{thm radd_commute}),
317 Thm ("radd_left_commute",num_str @{thm radd_left_commute}),
318 Thm ("add_assoc",num_str @{thm add_assoc}),
319 Thm ("rmult_commute",num_str @{thm rmult_commute}),
320 Thm ("rmult_left_commute",num_str @{thm rmult_left_commute}),
321 Thm ("rmult_assoc",num_str @{thm rmult_assoc})],
322 scr = Prog ((term_of o the o (parse thy)) "empty_script")
325 (*todo: replace by Rewrite("rnorm_equation_add",num_str @{thm rnorm_equation_add)*)
327 Rls{id = "norm_equation", preconds = [], rew_ord = ("e_rew_ord",e_rew_ord),
328 erls = tval_rls, srls = e_rls, calc = [], errpatts = [],
329 rules = [Thm ("rnorm_equation_add",num_str @{thm rnorm_equation_add})
331 scr = Prog ((term_of o the o (parse thy)) "empty_script")
337 val STest_simplify = (* vv--- not changed to real by parse*)
338 "Script STest_simplify (t_t::'z) = " ^
340 " ((Try (Repeat (Rewrite real_diff_minus False))) @@ " ^
341 " (Try (Repeat (Rewrite radd_mult_distrib2 False))) @@ " ^
342 " (Try (Repeat (Rewrite rdistr_right_assoc False))) @@ " ^
343 " (Try (Repeat (Rewrite rdistr_right_assoc_p False))) @@" ^
344 " (Try (Repeat (Rewrite rdistr_div_right False))) @@ " ^
345 " (Try (Repeat (Rewrite rbinom_power_2 False))) @@ " ^
347 " (Try (Repeat (Rewrite radd_commute False))) @@ " ^
348 " (Try (Repeat (Rewrite radd_left_commute False))) @@ " ^
349 " (Try (Repeat (Rewrite add_assoc False))) @@ " ^
350 " (Try (Repeat (Rewrite rmult_commute False))) @@ " ^
351 " (Try (Repeat (Rewrite rmult_left_commute False))) @@ " ^
352 " (Try (Repeat (Rewrite rmult_assoc False))) @@ " ^
354 " (Try (Repeat (Rewrite radd_real_const_eq False))) @@ " ^
355 " (Try (Repeat (Rewrite radd_real_const False))) @@ " ^
356 " (Try (Repeat (Calculate PLUS))) @@ " ^
357 " (Try (Repeat (Calculate TIMES))) @@ " ^
358 " (Try (Repeat (Calculate divide_))) @@" ^
359 " (Try (Repeat (Calculate POWER))) @@ " ^
361 " (Try (Repeat (Rewrite rcollect_right False))) @@ " ^
362 " (Try (Repeat (Rewrite rcollect_one_left False))) @@ " ^
363 " (Try (Repeat (Rewrite rcollect_one_left_assoc False))) @@ " ^
364 " (Try (Repeat (Rewrite rcollect_one_left_assoc_p False))) @@ " ^
366 " (Try (Repeat (Rewrite rshift_nominator False))) @@ " ^
367 " (Try (Repeat (Rewrite rcancel_den False))) @@ " ^
368 " (Try (Repeat (Rewrite rroot_square_inv False))) @@ " ^
369 " (Try (Repeat (Rewrite rroot_times_root False))) @@ " ^
370 " (Try (Repeat (Rewrite rroot_times_root_assoc_p False))) @@ " ^
371 " (Try (Repeat (Rewrite rsqare False))) @@ " ^
372 " (Try (Repeat (Rewrite power_1 False))) @@ " ^
373 " (Try (Repeat (Rewrite rtwo_of_the_same False))) @@ " ^
374 " (Try (Repeat (Rewrite rtwo_of_the_same_assoc_p False))) @@ " ^
376 " (Try (Repeat (Rewrite rmult_1 False))) @@ " ^
377 " (Try (Repeat (Rewrite rmult_1_right False))) @@ " ^
378 " (Try (Repeat (Rewrite rmult_0 False))) @@ " ^
379 " (Try (Repeat (Rewrite rmult_0_right False))) @@ " ^
380 " (Try (Repeat (Rewrite radd_0 False))) @@ " ^
381 " (Try (Repeat (Rewrite radd_0_right False)))) " ^
386 (* expects * distributed over + *)
388 Rls{id = "Test_simplify", preconds = [],
389 rew_ord = ("sqrt_right",sqrt_right false @{theory "Pure"}),
390 erls = tval_rls, srls = e_rls,
391 calc=[(*since 040209 filled by prep_rls*)], errpatts = [],
393 Thm ("real_diff_minus",num_str @{thm real_diff_minus}),
394 Thm ("radd_mult_distrib2",num_str @{thm radd_mult_distrib2}),
395 Thm ("rdistr_right_assoc",num_str @{thm rdistr_right_assoc}),
396 Thm ("rdistr_right_assoc_p",num_str @{thm rdistr_right_assoc_p}),
397 Thm ("rdistr_div_right",num_str @{thm rdistr_div_right}),
398 Thm ("rbinom_power_2",num_str @{thm rbinom_power_2}),
400 Thm ("radd_commute",num_str @{thm radd_commute}),
401 Thm ("radd_left_commute",num_str @{thm radd_left_commute}),
402 Thm ("add_assoc",num_str @{thm add_assoc}),
403 Thm ("rmult_commute",num_str @{thm rmult_commute}),
404 Thm ("rmult_left_commute",num_str @{thm rmult_left_commute}),
405 Thm ("rmult_assoc",num_str @{thm rmult_assoc}),
407 Thm ("radd_real_const_eq",num_str @{thm radd_real_const_eq}),
408 Thm ("radd_real_const",num_str @{thm radd_real_const}),
409 (* these 2 rules are invers to distr_div_right wrt. termination.
410 thus they MUST be done IMMEDIATELY before calc *)
411 Calc ("Groups.plus_class.plus", eval_binop "#add_"),
412 Calc ("Groups.times_class.times", eval_binop "#mult_"),
413 Calc ("Fields.inverse_class.divide", eval_cancel "#divide_e"),
414 Calc ("Atools.pow", eval_binop "#power_"),
416 Thm ("rcollect_right",num_str @{thm rcollect_right}),
417 Thm ("rcollect_one_left",num_str @{thm rcollect_one_left}),
418 Thm ("rcollect_one_left_assoc",num_str @{thm rcollect_one_left_assoc}),
419 Thm ("rcollect_one_left_assoc_p",num_str @{thm rcollect_one_left_assoc_p}),
421 Thm ("rshift_nominator",num_str @{thm rshift_nominator}),
422 Thm ("rcancel_den",num_str @{thm rcancel_den}),
423 Thm ("rroot_square_inv",num_str @{thm rroot_square_inv}),
424 Thm ("rroot_times_root",num_str @{thm rroot_times_root}),
425 Thm ("rroot_times_root_assoc_p",num_str @{thm rroot_times_root_assoc_p}),
426 Thm ("rsqare",num_str @{thm rsqare}),
427 Thm ("power_1",num_str @{thm power_1}),
428 Thm ("rtwo_of_the_same",num_str @{thm rtwo_of_the_same}),
429 Thm ("rtwo_of_the_same_assoc_p",num_str @{thm rtwo_of_the_same_assoc_p}),
431 Thm ("rmult_1",num_str @{thm rmult_1}),
432 Thm ("rmult_1_right",num_str @{thm rmult_1_right}),
433 Thm ("rmult_0",num_str @{thm rmult_0}),
434 Thm ("rmult_0_right",num_str @{thm rmult_0_right}),
435 Thm ("radd_0",num_str @{thm radd_0}),
436 Thm ("radd_0_right",num_str @{thm radd_0_right})
438 scr = Prog ((term_of o the o (parse thy)) "empty_script")
439 (*since 040209 filled by prep_rls: STest_simplify*)
448 (*isolate the root in a root-equation*)
450 Rls{id = "isolate_root", preconds = [], rew_ord = ("e_rew_ord",e_rew_ord),
451 erls=tval_rls,srls = e_rls, calc=[], errpatts = [],
452 rules = [Thm ("rroot_to_lhs",num_str @{thm rroot_to_lhs}),
453 Thm ("rroot_to_lhs_mult",num_str @{thm rroot_to_lhs_mult}),
454 Thm ("rroot_to_lhs_add_mult",num_str @{thm rroot_to_lhs_add_mult}),
455 Thm ("risolate_root_add",num_str @{thm risolate_root_add}),
456 Thm ("risolate_root_mult",num_str @{thm risolate_root_mult}),
457 Thm ("risolate_root_div",num_str @{thm risolate_root_div}) ],
458 scr = Prog ((term_of o the o (parse thy))
462 (*isolate the bound variable in an equation; 'bdv' is a meta-constant*)
464 Rls{id = "isolate_bdv", preconds = [], rew_ord = ("e_rew_ord",e_rew_ord),
465 erls=tval_rls,srls = e_rls, calc= [], errpatts = [],
467 [Thm ("risolate_bdv_add",num_str @{thm risolate_bdv_add}),
468 Thm ("risolate_bdv_mult_add",num_str @{thm risolate_bdv_mult_add}),
469 Thm ("risolate_bdv_mult",num_str @{thm risolate_bdv_mult}),
470 Thm ("mult_square",num_str @{thm mult_square}),
471 Thm ("constant_square",num_str @{thm constant_square}),
472 Thm ("constant_mult_square",num_str @{thm constant_mult_square})
474 scr = Prog ((term_of o the o (parse thy))
480 (* association list for calculate_, calculate
481 "Groups.plus_class.plus" etc. not usable in scripts *)
485 ("Vars" ,("Tools.Vars" ,eval_var "#Vars_")),
486 ("matches",("Tools.matches",eval_matches "#matches_")),
487 ("lhs" ,("Tools.lhs" ,eval_lhs "")),
489 ("PLUS" ,("Groups.plus_class.plus" ,eval_binop "#add_")),
490 ("TIMES" ,("Groups.times_class.times" ,eval_binop "#mult_")),
491 ("DIVIDE" ,("Fields.inverse_class.divide" ,eval_cancel "#divide_e")),
492 ("POWER" ,("Atools.pow" ,eval_binop "#power_")),
493 ("is_const",("Atools.is'_const",eval_const "#is_const_")),
494 ("le" ,("Orderings.ord_class.less" ,eval_equ "#less_")),
495 ("leq" ,("Orderings.ord_class.less_eq" ,eval_equ "#less_equal_")),
496 ("ident" ,("Atools.ident",eval_ident "#ident_")),
497 (*von hier (ehem.SqRoot*)
498 ("sqrt" ,("NthRoot.sqrt" ,eval_sqrt "#sqrt_")),
499 ("Test.is_root_free",("is'_root'_free", eval_root_free"#is_root_free_e")),
500 ("Test.contains_root",("contains'_root",
501 eval_contains_root"#contains_root_"))
504 setup {* KEStore_Elems.add_rlss
505 [("Test_simplify", (Context.theory_name @{theory}, prep_rls Test_simplify)),
506 ("tval_rls", (Context.theory_name @{theory}, prep_rls tval_rls)),
507 ("isolate_root", (Context.theory_name @{theory}, prep_rls isolate_root)),
508 ("isolate_bdv", (Context.theory_name @{theory}, prep_rls isolate_bdv)),
509 ("matches", (Context.theory_name @{theory}, prep_rls
510 (append_rls "matches" testerls [Calc ("Tools.matches",eval_matches "#matches_")])))] *}
512 (** problem types **)
513 setup {* KEStore_Elems.add_pbts
514 [(prep_pbt thy "pbl_test" [] e_pblID (["test"], [], e_rls, NONE, [])),
515 (prep_pbt thy "pbl_test_equ" [] e_pblID
516 (["equation","test"],
517 [("#Given" ,["equality e_e","solveFor v_v"]),
518 ("#Where" ,["matches (?a = ?b) e_e"]),
519 ("#Find" ,["solutions v_v'i'"])],
520 assoc_rls' @{theory} "matches", SOME "solve (e_e::bool, v_v)", [])),
521 (prep_pbt thy "pbl_test_uni" [] e_pblID
522 (["univariate","equation","test"],
523 [("#Given" ,["equality e_e","solveFor v_v"]),
524 ("#Where" ,["matches (?a = ?b) e_e"]),
525 ("#Find" ,["solutions v_v'i'"])],
526 assoc_rls' @{theory} "matches", SOME "solve (e_e::bool, v_v)", [])),
527 (prep_pbt thy "pbl_test_uni_lin" [] e_pblID
528 (["LINEAR","univariate","equation","test"],
529 [("#Given" ,["equality e_e","solveFor v_v"]),
530 ("#Where" ,["(matches ( v_v = 0) e_e) | (matches ( ?b*v_v = 0) e_e) |" ^
531 "(matches (?a+v_v = 0) e_e) | (matches (?a+?b*v_v = 0) e_e) "]),
532 ("#Find" ,["solutions v_v'i'"])],
533 assoc_rls' @{theory} "matches",
534 SOME "solve (e_e::bool, v_v)", [["Test","solve_linear"]]))(*,
537 [("#Given" ,"boolTestGiven g_g"),
538 ("#Find" ,"boolTestFind f_f")],
542 [("#Given" ,"boolTestGiven g_g"),
543 ("#Find" ,"boolTestFind f_f")],
545 (*val ttt = (term_of o the o (parse (Thy_Info.get_theory "Isac"))) "(matches ( v_v = 0) e_e)";
550 setup {* KEStore_Elems.add_mets
551 [prep_met @{theory "Diff"} "met_test" [] e_metID
553 {rew_ord'="tless_true",rls'=Atools_erls,calc = [], srls = e_rls, prls=e_rls,
554 crls=Atools_erls, errpats = [], nrls = e_rls}, "empty_script"),
555 prep_met thy "met_test_solvelin" [] e_metID
556 (["Test","solve_linear"]:metID,
557 [("#Given" ,["equality e_e","solveFor v_v"]),
558 ("#Where" ,["matches (?a = ?b) e_e"]),
559 ("#Find" ,["solutions v_v'i'"])],
560 {rew_ord' = "e_rew_ord", rls' = tval_rls, srls = e_rls,
561 prls = assoc_rls' @{theory} "matches", calc = [], crls = tval_rls, errpats = [],
562 nrls = Test_simplify},
563 "Script Solve_linear (e_e::bool) (v_v::real)= " ^
566 " (((Rewrite_Set_Inst [(bdv,v_v::real)] isolate_bdv False) @@ " ^
567 " (Rewrite_Set Test_simplify False))) e_e" ^
568 " in [e_e::bool])")(*,
569 prep_met thy (*test for equations*)
570 (["Test","testeq"]:metID,
571 [("#Given" ,["boolTestGiven g_g"]),
572 ("#Find" ,["boolTestFind f_f"])],
573 {rew_ord'="e_rew_ord",rls'="tval_rls",asm_rls=[], asm_thm=[("square_equation_left","")]},
574 "Script Testeq (e_q::bool) = " ^
576 " (let e_e = Try (Repeat (Rewrite rroot_square_inv False e_q)); " ^
577 " e_e = Try (Repeat (Rewrite square_equation_left True e_e)); " ^
578 " e_e = Try (Repeat (Rewrite rmult_0 False e_e)) " ^
579 " in e_e) Until (is_root_free e_e)" (*deleted*)) ---------27.4.02*)]
582 setup {* KEStore_Elems.add_rlss
583 [("norm_equation", (Context.theory_name @{theory}, prep_rls norm_equation)),
584 ("ac_plus_times", (Context.theory_name @{theory}, prep_rls ac_plus_times)),
585 ("rearrange_assoc", (Context.theory_name @{theory}, prep_rls rearrange_assoc))] *}
589 fun bin_o (Const (op_,(Type ("fun",
590 [Type (s2,[]),Type ("fun",
591 [Type (s4,tl4),Type (s5,tl5)])])))) =
592 if (s2=s4)andalso(s4=s5)then[op_]else[]
595 fun bin_op (t1 $ t2) = union op = (bin_op t1) (bin_op t2)
596 | bin_op t = bin_o t;
597 fun is_bin_op t = ((bin_op t)<>[]);
599 fun bin_op_arg1 ((Const (op_,(Type ("fun",
600 [Type (s2,[]),Type ("fun",
601 [Type (s4,tl4),Type (s5,tl5)])]))))$ arg1 $ arg2) =
603 fun bin_op_arg2 ((Const (op_,(Type ("fun",
604 [Type (s2,[]),Type ("fun",
605 [Type (s4,tl4),Type (s5,tl5)])]))))$ arg1 $ arg2) =
609 exception NO_EQUATION_TERM;
610 fun is_equation ((Const ("HOL.eq",(Type ("fun",
611 [Type (_,[]),Type ("fun",
612 [Type (_,[]),Type ("bool",[])])])))) $ _ $ _)
614 | is_equation _ = false;
615 fun equ_lhs ((Const ("HOL.eq",(Type ("fun",
616 [Type (_,[]),Type ("fun",
617 [Type (_,[]),Type ("bool",[])])])))) $ l $ r)
619 | equ_lhs _ = raise NO_EQUATION_TERM;
620 fun equ_rhs ((Const ("HOL.eq",(Type ("fun",
621 [Type (_,[]),Type ("fun",
622 [Type (_,[]),Type ("bool",[])])])))) $ l $ r)
624 | equ_rhs _ = raise NO_EQUATION_TERM;
627 fun atom (Const (_,Type (_,[]))) = true
628 | atom (Free (_,Type (_,[]))) = true
629 | atom (Var (_,Type (_,[]))) = true
630 (*| atom (_ (_,"?DUMMY" )) = true ..ML-error *)
631 | atom((Const ("Bin.integ_of_bin",_)) $ _) = true
634 fun varids (Const (s,Type (_,[]))) = [strip_thy s]
635 | varids (Free (s,Type (_,[]))) = if is_no s then []
637 | varids (Var((s,_),Type (_,[]))) = [strip_thy s]
638 (*| varids (_ (s,"?DUMMY" )) = ..ML-error *)
639 | varids((Const ("Bin.integ_of_bin",_)) $ _)= [](*8.01: superfluous?*)
640 | varids (Abs(a,T,t)) = union op = [a] (varids t)
641 | varids (t1 $ t2) = union op = (varids t1) (varids t2)
643 (*> val t = term_of (hd (parse Diophant.thy "x"));
644 val t = Free ("x","?DUMMY") : term
646 val it = [] : string list [] !!! *)
649 fun bin_ops_only ((Const op_) $ t1 $ t2) =
650 if(is_bin_op (Const op_))
651 then(bin_ops_only t1)andalso(bin_ops_only t2)
654 if atom t then true else bin_ops_only t;
656 fun polynomial opl t bdVar = (* bdVar TODO *)
657 subset op = (bin_op t, opl) andalso (bin_ops_only t);
659 fun poly_equ opl bdVar t = is_equation t (* bdVar TODO *)
660 andalso polynomial opl (equ_lhs t) bdVar
661 andalso polynomial opl (equ_rhs t) bdVar
662 andalso (subset op = (varids bdVar, varids (equ_lhs t)) orelse
663 subset op = (varids bdVar, varids (equ_lhs t)));
666 let fun max_ m [] = m
667 | max_ m (i::is) = if m<i then max_ i is else max_ m is;
668 in max_ (hd is) is end;
672 fun max (a,b) = if a < b then b else a;
674 fun degree addl mul bdVar t =
676 fun deg _ _ v (Const (s,Type (_,[]))) = if v=strip_thy s then 1 else 0
677 | deg _ _ v (Free (s,Type (_,[]))) = if v=strip_thy s then 1 else 0
678 | deg _ _ v (Var((s,_),Type (_,[]))) = if v=strip_thy s then 1 else 0
679 (*| deg _ _ v (_ (s,"?DUMMY" )) = ..ML-error *)
680 | deg _ _ v((Const ("Bin.integ_of_bin",_)) $ _ )= 0
681 | deg addl mul v (h $ t1 $ t2) =
682 if subset op = (bin_op h, addl)
683 then max (deg addl mul v t1 ,deg addl mul v t2)
684 else (*mul!*)(deg addl mul v t1)+(deg addl mul v t2)
685 in if polynomial (addl @ [mul]) t bdVar
686 then SOME (deg addl mul (id_of bdVar) t) else (NONE:int option)
688 fun degree_ addl mul bdVar t = (* do not export *)
689 let fun opt (SOME i)= i
691 in opt (degree addl mul bdVar t) end;
694 fun linear addl mul t bdVar = (degree_ addl mul bdVar t)<2;
696 fun linear_equ addl mul bdVar t =
698 then let val degl = degree_ addl mul bdVar (equ_lhs t);
699 val degr = degree_ addl mul bdVar (equ_rhs t)
700 in if (degl>0 orelse degr>0)andalso max(degl,degr)<2
704 (* strip_thy op_ before *)
705 fun is_div_op (dv,(Const (op_,(Type ("fun",
706 [Type (s2,[]),Type ("fun",
707 [Type (s4,tl4),Type (s5,tl5)])])))) )= (dv = strip_thy op_)
708 | is_div_op _ = false;
710 fun is_denom bdVar div_op t =
711 let fun is bool[v]dv (Const (s,Type(_,[])))= bool andalso(if v=strip_thy s then true else false)
712 | is bool[v]dv (Free (s,Type(_,[])))= bool andalso(if v=strip_thy s then true else false)
713 | is bool[v]dv (Var((s,_),Type(_,[])))= bool andalso(if v=strip_thy s then true else false)
714 | is bool[v]dv((Const ("Bin.integ_of_bin",_)) $ _) = false
715 | is bool[v]dv (h$n$d) =
717 then (is false[v]dv n)orelse(is true[v]dv d)
718 else (is bool [v]dv n)orelse(is bool[v]dv d)
719 in is false (varids bdVar) (strip_thy div_op) t end;
722 fun rational t div_op bdVar =
723 is_denom bdVar div_op t andalso bin_ops_only t;
726 (** problem types **)
727 setup {* KEStore_Elems.add_pbts
728 [(prep_pbt thy "pbl_test_uni_plain2" [] e_pblID
729 (["plain_square","univariate","equation","test"],
730 [("#Given" ,["equality e_e","solveFor v_v"]),
731 ("#Where" ,["(matches (?a + ?b*v_v ^^^2 = 0) e_e) |" ^
732 "(matches ( ?b*v_v ^^^2 = 0) e_e) |" ^
733 "(matches (?a + v_v ^^^2 = 0) e_e) |" ^
734 "(matches ( v_v ^^^2 = 0) e_e)"]),
735 ("#Find" ,["solutions v_v'i'"])],
736 assoc_rls' @{theory} "matches",
737 SOME "solve (e_e::bool, v_v)", [["Test","solve_plain_square"]]))] *}
739 val e_e = (term_of o the o (parse thy)) "e_e::bool";
740 val ve = (term_of o the o (parse thy)) "4 + 3*x^^^2 = 0";
743 val pre = (term_of o the o (parse thy))
744 "(matches (a + b*v_v ^^^2 = 0, e_e::bool)) |" ^
745 "(matches ( b*v_v ^^^2 = 0, e_e::bool)) |" ^
746 "(matches (a + v_v ^^^2 = 0, e_e::bool)) |" ^
747 "(matches ( v_v ^^^2 = 0, e_e::bool))";
748 val prei = subst_atomic env pre;
749 val cpre = (cterm_of thy) prei;
751 val SOME (ct,_) = rewrite_set_ thy false tval_rls cpre;
752 val ct = "True | False | False | False" : cterm
754 > val SOME (ct,_) = rewrite_ thy sqrt_right tval_rls false or_false ct;
755 > val SOME (ct,_) = rewrite_ thy sqrt_right tval_rls false or_false ct;
756 > val SOME (ct,_) = rewrite_ thy sqrt_right tval_rls false or_false ct;
757 val ct = "HOL.True" : cterm
760 setup {* KEStore_Elems.add_pbts
761 [(prep_pbt thy "pbl_test_uni_poly" [] e_pblID
762 (["polynomial","univariate","equation","test"],
763 [("#Given" ,["equality (v_v ^^^2 + p_p * v_v + q__q = 0)","solveFor v_v"]),
764 ("#Where" ,["HOL.False"]),
765 ("#Find" ,["solutions v_v'i'"])],
766 e_rls, SOME "solve (e_e::bool, v_v)", [])),
767 (prep_pbt thy "pbl_test_uni_poly_deg2" [] e_pblID
768 (["degree_two","polynomial","univariate","equation","test"],
769 [("#Given" ,["equality (v_v ^^^2 + p_p * v_v + q__q = 0)","solveFor v_v"]),
770 ("#Find" ,["solutions v_v'i'"])],
771 e_rls, SOME "solve (v_v ^^^2 + p_p * v_v + q__q = 0, v_v)", [])),
772 (prep_pbt thy "pbl_test_uni_poly_deg2_pq" [] e_pblID
773 (["pq_formula","degree_two","polynomial","univariate","equation","test"],
774 [("#Given" ,["equality (v_v ^^^2 + p_p * v_v + q__q = 0)","solveFor v_v"]),
775 ("#Find" ,["solutions v_v'i'"])],
776 e_rls, SOME "solve (v_v ^^^2 + p_p * v_v + q__q = 0, v_v)", [])),
777 (prep_pbt thy "pbl_test_uni_poly_deg2_abc" [] e_pblID
778 (["abc_formula","degree_two","polynomial","univariate","equation","test"],
779 [("#Given" ,["equality (a_a * x ^^^2 + b_b * x + c_c = 0)","solveFor v_v"]),
780 ("#Find" ,["solutions v_v'i'"])],
781 e_rls, SOME "solve (a_a * x ^^^2 + b_b * x + c_c = 0, v_v)", [])),
782 (prep_pbt thy "pbl_test_uni_root" [] e_pblID
783 (["squareroot","univariate","equation","test"],
784 [("#Given" ,["equality e_e","solveFor v_v"]),
785 ("#Where" ,["precond_rootpbl v_v"]),
786 ("#Find" ,["solutions v_v'i'"])],
787 append_rls "contains_root" e_rls [Calc ("Test.contains'_root",
788 eval_contains_root "#contains_root_")],
789 SOME "solve (e_e::bool, v_v)", [["Test","square_equation"]])),
790 (prep_pbt thy "pbl_test_uni_norm" [] e_pblID
791 (["normalize","univariate","equation","test"],
792 [("#Given" ,["equality e_e","solveFor v_v"]),
794 ("#Find" ,["solutions v_v'i'"])],
795 e_rls, SOME "solve (e_e::bool, v_v)", [["Test","norm_univar_equation"]])),
796 (prep_pbt thy "pbl_test_uni_roottest" [] e_pblID
797 (["sqroot-test","univariate","equation","test"],
798 [("#Given" ,["equality e_e","solveFor v_v"]),
799 ("#Where" ,["precond_rootpbl v_v"]),
800 ("#Find" ,["solutions v_v'i'"])],
801 e_rls, SOME "solve (e_e::bool, v_v)", [])),
802 (prep_pbt thy "pbl_test_intsimp" [] e_pblID
804 [("#Given" ,["intTestGiven t_t"]),
806 ("#Find" ,["intTestFind s_s"])],
807 e_rls, NONE, [["Test","intsimp"]]))] *}
810 get_pbt ["inttype","test"];
813 setup {* KEStore_Elems.add_mets
814 [prep_met thy "met_test_sqrt" [] e_metID
815 (*root-equation, version for tests before 8.01.01*)
816 (["Test","sqrt-equ-test"]:metID,
817 [("#Given" ,["equality e_e","solveFor v_v"]),
818 ("#Where" ,["contains_root (e_e::bool)"]),
819 ("#Find" ,["solutions v_v'i'"])],
820 {rew_ord'="e_rew_ord",rls'=tval_rls,
821 srls = append_rls "srls_contains_root" e_rls
822 [Calc ("Test.contains'_root",eval_contains_root "")],
823 prls = append_rls "prls_contains_root" e_rls
824 [Calc ("Test.contains'_root",eval_contains_root "")],
825 calc=[], crls=tval_rls, errpats = [], nrls = e_rls (*,asm_rls=[],
826 asm_thm=[("square_equation_left",""), ("square_equation_right","")]*)},
827 "Script Solve_root_equation (e_e::bool) (v_v::real) = " ^
829 " ((While (contains_root e_e) Do" ^
830 " ((Rewrite square_equation_left True) @@" ^
831 " (Try (Rewrite_Set Test_simplify False)) @@" ^
832 " (Try (Rewrite_Set rearrange_assoc False)) @@" ^
833 " (Try (Rewrite_Set isolate_root False)) @@" ^
834 " (Try (Rewrite_Set Test_simplify False)))) @@" ^
835 " (Try (Rewrite_Set norm_equation False)) @@" ^
836 " (Try (Rewrite_Set Test_simplify False)) @@" ^
837 " (Rewrite_Set_Inst [(bdv,v_v::real)] isolate_bdv False) @@" ^
838 " (Try (Rewrite_Set Test_simplify False)))" ^
841 prep_met thy "met_test_sqrt2" [] e_metID
842 (*root-equation ... for test-*.sml until 8.01*)
843 (["Test","squ-equ-test2"]:metID,
844 [("#Given" ,["equality e_e","solveFor v_v"]),
845 ("#Find" ,["solutions v_v'i'"])],
846 {rew_ord'="e_rew_ord",rls'=tval_rls,
847 srls = append_rls "srls_contains_root" e_rls
848 [Calc ("Test.contains'_root",eval_contains_root"")],
849 prls=e_rls,calc=[], crls=tval_rls, errpats = [], nrls = e_rls(*,asm_rls=[],
850 asm_thm=[("square_equation_left",""), ("square_equation_right","")]*)},
851 "Script Solve_root_equation (e_e::bool) (v_v::real) = " ^
853 " ((While (contains_root e_e) Do" ^
854 " ((Rewrite square_equation_left True) @@" ^
855 " (Try (Rewrite_Set Test_simplify False)) @@" ^
856 " (Try (Rewrite_Set rearrange_assoc False)) @@" ^
857 " (Try (Rewrite_Set isolate_root False)) @@" ^
858 " (Try (Rewrite_Set Test_simplify False)))) @@" ^
859 " (Try (Rewrite_Set norm_equation False)) @@" ^
860 " (Try (Rewrite_Set Test_simplify False)) @@" ^
861 " (Rewrite_Set_Inst [(bdv,v_v::real)] isolate_bdv False) @@" ^
862 " (Try (Rewrite_Set Test_simplify False)))" ^
864 " (L_L::bool list) = Tac subproblem_equation_dummy; " ^
865 " L_L = Tac solve_equation_dummy " ^
866 " in Check_elementwise L_L {(v_v::real). Assumptions})"),
867 prep_met thy "met_test_squ_sub" [] e_metID
868 (*tests subproblem fixed linear*)
869 (["Test","squ-equ-test-subpbl1"]:metID,
870 [("#Given" ,["equality e_e","solveFor v_v"]),
871 ("#Where" ,["precond_rootmet v_v"]),
872 ("#Find" ,["solutions v_v'i'"])],
873 {rew_ord' = "e_rew_ord", rls' = tval_rls, srls = e_rls,
874 prls = append_rls "prls_met_test_squ_sub" e_rls
875 [Calc ("Test.precond'_rootmet", eval_precond_rootmet "")],
876 calc=[], crls=tval_rls, errpats = [], nrls = Test_simplify},
877 "Script Solve_root_equation (e_e::bool) (v_v::real) = " ^
878 " (let e_e = ((Try (Rewrite_Set norm_equation False)) @@ " ^
879 " (Try (Rewrite_Set Test_simplify False))) e_e; " ^
880 " (L_L::bool list) = " ^
881 " (SubProblem (Test', " ^
882 " [LINEAR,univariate,equation,test]," ^
883 " [Test,solve_linear]) " ^
884 " [BOOL e_e, REAL v_v]) " ^
885 " in Check_elementwise L_L {(v_v::real). Assumptions}) "),
886 prep_met thy "met_test_squ_sub2" [] e_metID
887 (*tests subproblem fixed degree 2*)
888 (["Test","squ-equ-test-subpbl2"]:metID,
889 [("#Given" ,["equality e_e","solveFor v_v"]),
890 ("#Find" ,["solutions v_v'i'"])],
891 {rew_ord'="e_rew_ord",rls'=tval_rls,srls=e_rls,prls=e_rls,calc=[], crls=tval_rls,
892 errpats = [], nrls = e_rls (*, asm_rls=[],asm_thm=[("square_equation_left",""),
893 ("square_equation_right","")]*)},
894 "Script Solve_root_equation (e_e::bool) (v_v::real) = " ^
895 " (let e_e = Try (Rewrite_Set norm_equation False) e_e; " ^
896 "(L_L::bool list) = (SubProblem (Test',[LINEAR,univariate,equation,test]," ^
897 " [Test,solve_by_pq_formula]) [BOOL e_e, REAL v_v])" ^
898 "in Check_elementwise L_L {(v_v::real). Assumptions})"),
899 prep_met thy "met_test_squ_nonterm" [] e_metID
900 (*root-equation: see foils..., but notTerminating*)
901 (["Test","square_equation...notTerminating"]:metID,
902 [("#Given" ,["equality e_e","solveFor v_v"]),
903 ("#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=e_rls,calc=[], crls=tval_rls, errpats = [], nrls = e_rls(*,asm_rls=[],
908 asm_thm=[("square_equation_left",""), ("square_equation_right","")]*)},
909 "Script Solve_root_equation (e_e::bool) (v_v::real) = " ^
911 " ((While (contains_root e_e) Do" ^
912 " ((Rewrite square_equation_left True) @@" ^
913 " (Try (Rewrite_Set Test_simplify False)) @@" ^
914 " (Try (Rewrite_Set rearrange_assoc False)) @@" ^
915 " (Try (Rewrite_Set isolate_root False)) @@" ^
916 " (Try (Rewrite_Set Test_simplify False)))) @@" ^
917 " (Try (Rewrite_Set norm_equation False)) @@" ^
918 " (Try (Rewrite_Set Test_simplify False)))" ^
920 " (L_L::bool list) = " ^
921 " (SubProblem (Test',[LINEAR,univariate,equation,test]," ^
922 " [Test,solve_linear]) [BOOL e_e, REAL v_v])" ^
923 "in Check_elementwise L_L {(v_v::real). Assumptions})"),
924 prep_met thy "met_test_eq1" [] e_metID
926 (["Test","square_equation1"]:metID,
927 [("#Given" ,["equality e_e","solveFor v_v"]),
928 ("#Find" ,["solutions v_v'i'"])],
929 {rew_ord'="e_rew_ord",rls'=tval_rls,
930 srls = append_rls "srls_contains_root" e_rls
931 [Calc ("Test.contains'_root",eval_contains_root"")], prls=e_rls, calc=[], crls=tval_rls,
932 errpats = [], nrls = e_rls(*,asm_rls=[], asm_thm=[("square_equation_left",""),
933 ("square_equation_right","")]*)},
934 "Script Solve_root_equation (e_e::bool) (v_v::real) = " ^
936 " ((While (contains_root e_e) Do" ^
937 " ((Rewrite square_equation_left True) @@" ^
938 " (Try (Rewrite_Set Test_simplify False)) @@" ^
939 " (Try (Rewrite_Set rearrange_assoc False)) @@" ^
940 " (Try (Rewrite_Set isolate_root False)) @@" ^
941 " (Try (Rewrite_Set Test_simplify False)))) @@" ^
942 " (Try (Rewrite_Set norm_equation False)) @@" ^
943 " (Try (Rewrite_Set Test_simplify False)))" ^
945 " (L_L::bool list) = (SubProblem (Test',[LINEAR,univariate,equation,test]," ^
946 " [Test,solve_linear]) [BOOL e_e, REAL v_v])" ^
947 " in Check_elementwise L_L {(v_v::real). Assumptions})"),
948 prep_met thy "met_test_squ2" [] e_metID
950 (["Test","square_equation2"]:metID,
951 [("#Given" ,["equality e_e","solveFor v_v"]),
952 ("#Find" ,["solutions v_v'i'"])],
953 {rew_ord'="e_rew_ord",rls'=tval_rls,
954 srls = append_rls "srls_contains_root" e_rls
955 [Calc ("Test.contains'_root",eval_contains_root"")],
956 prls=e_rls,calc=[], crls=tval_rls, errpats = [], nrls = e_rls(*,asm_rls=[],
957 asm_thm=[("square_equation_left",""), ("square_equation_right","")]*)},
958 "Script Solve_root_equation (e_e::bool) (v_v::real) = " ^
960 " ((While (contains_root e_e) Do" ^
961 " (((Rewrite square_equation_left True) Or " ^
962 " (Rewrite square_equation_right True)) @@" ^
963 " (Try (Rewrite_Set Test_simplify False)) @@" ^
964 " (Try (Rewrite_Set rearrange_assoc False)) @@" ^
965 " (Try (Rewrite_Set isolate_root False)) @@" ^
966 " (Try (Rewrite_Set Test_simplify False)))) @@" ^
967 " (Try (Rewrite_Set norm_equation False)) @@" ^
968 " (Try (Rewrite_Set Test_simplify False)))" ^
970 " (L_L::bool list) = (SubProblem (Test',[plain_square,univariate,equation,test]," ^
971 " [Test,solve_plain_square]) [BOOL e_e, REAL v_v])" ^
972 " in Check_elementwise L_L {(v_v::real). Assumptions})"),
973 prep_met thy "met_test_squeq" [] e_metID
975 (["Test","square_equation"]:metID,
976 [("#Given" ,["equality e_e","solveFor v_v"]),
977 ("#Find" ,["solutions v_v'i'"])],
978 {rew_ord'="e_rew_ord",rls'=tval_rls,
979 srls = append_rls "srls_contains_root" e_rls
980 [Calc ("Test.contains'_root",eval_contains_root"")],
981 prls=e_rls,calc=[], crls=tval_rls, errpats = [], nrls = e_rls (*,asm_rls=[],
982 asm_thm=[("square_equation_left",""), ("square_equation_right","")]*)},
983 "Script Solve_root_equation (e_e::bool) (v_v::real) = " ^
985 " ((While (contains_root e_e) Do" ^
986 " (((Rewrite square_equation_left True) Or" ^
987 " (Rewrite square_equation_right True)) @@" ^
988 " (Try (Rewrite_Set Test_simplify False)) @@" ^
989 " (Try (Rewrite_Set rearrange_assoc False)) @@" ^
990 " (Try (Rewrite_Set isolate_root False)) @@" ^
991 " (Try (Rewrite_Set Test_simplify False)))) @@" ^
992 " (Try (Rewrite_Set norm_equation False)) @@" ^
993 " (Try (Rewrite_Set Test_simplify False)))" ^
995 " (L_L::bool list) = (SubProblem (Test',[univariate,equation,test]," ^
996 " [no_met]) [BOOL e_e, REAL v_v])" ^
997 " in Check_elementwise L_L {(v_v::real). Assumptions})"),
998 prep_met thy "met_test_eq_plain" [] e_metID
999 (*solve_plain_square*)
1000 (["Test","solve_plain_square"]:metID,
1001 [("#Given",["equality e_e","solveFor v_v"]),
1002 ("#Where" ,["(matches (?a + ?b*v_v ^^^2 = 0) e_e) |" ^
1003 "(matches ( ?b*v_v ^^^2 = 0) e_e) |" ^
1004 "(matches (?a + v_v ^^^2 = 0) e_e) |" ^
1005 "(matches ( v_v ^^^2 = 0) e_e)"]),
1006 ("#Find" ,["solutions v_v'i'"])],
1007 {rew_ord'="e_rew_ord",rls'=tval_rls,calc=[],srls=e_rls,
1008 prls = assoc_rls' @{theory} "matches", crls=tval_rls, errpats = [], nrls = e_rls(*,
1009 asm_rls=[],asm_thm=[]*)},
1010 "Script Solve_plain_square (e_e::bool) (v_v::real) = " ^
1011 " (let e_e = ((Try (Rewrite_Set isolate_bdv False)) @@ " ^
1012 " (Try (Rewrite_Set Test_simplify False)) @@ " ^
1013 " ((Rewrite square_equality_0 False) Or " ^
1014 " (Rewrite square_equality True)) @@ " ^
1015 " (Try (Rewrite_Set tval_rls False))) e_e " ^
1016 " in ((Or_to_List e_e)::bool list))"),
1017 prep_met thy "met_test_norm_univ" [] e_metID
1018 (["Test","norm_univar_equation"]:metID,
1019 [("#Given",["equality e_e","solveFor v_v"]),
1021 ("#Find" ,["solutions v_v'i'"])],
1022 {rew_ord'="e_rew_ord",rls'=tval_rls,srls = e_rls,prls=e_rls, calc=[], crls=tval_rls,
1023 errpats = [], nrls = e_rls},
1024 "Script Norm_univar_equation (e_e::bool) (v_v::real) = " ^
1025 " (let e_e = ((Try (Rewrite rnorm_equation_add False)) @@ " ^
1026 " (Try (Rewrite_Set Test_simplify False))) e_e " ^
1027 " in (SubProblem (Test',[univariate,equation,test], " ^
1028 " [no_met]) [BOOL e_e, REAL v_v]))"),
1029 (*17.9.02 aus SqRoot.ML------------------------------^^^---*)
1030 prep_met thy "met_test_intsimp" [] e_metID
1031 (["Test","intsimp"]:metID,
1032 [("#Given" ,["intTestGiven t_t"]),
1034 ("#Find" ,["intTestFind s_s"])],
1035 {rew_ord' = "e_rew_ord", rls' = tval_rls, srls = e_rls, prls = e_rls, calc = [],
1036 crls = tval_rls, errpats = [], nrls = Test_simplify},
1037 "Script STest_simplify (t_t::int) = " ^
1039 " ((Try (Calculate PLUS)) @@ " ^
1040 " (Try (Calculate TIMES))) t_t::int)")]
1044 (*8.4.03 aus Poly.ML--------------------------------vvv---
1045 make_polynomial ---> make_poly
1046 ^-- for user ^-- for systest _ONLY_*)
1048 local (*. for make_polytest .*)
1050 open Term; (* for type order = EQUAL | LESS | GREATER *)
1052 fun pr_ord EQUAL = "EQUAL"
1053 | pr_ord LESS = "LESS"
1054 | pr_ord GREATER = "GREATER";
1056 fun dest_hd' (Const (a, T)) = (* ~ term.ML *)
1058 "Atools.pow" => ((("|||||||||||||", 0), T), 0) (*WN greatest *)
1059 | _ => (((a, 0), T), 0))
1060 | dest_hd' (Free (a, T)) = (((a, 0), T), 1)
1061 | dest_hd' (Var v) = (v, 2)
1062 | dest_hd' (Bound i) = ((("", i), dummyT), 3)
1063 | dest_hd' (Abs (_, T, _)) = ((("", 0), T), 4);
1065 fun get_order_pow (t $ (Free(order,_))) =
1066 (case int_of_str (order) of
1069 | get_order_pow _ = 0;
1071 fun size_of_term' (Const(str,_) $ t) =
1072 if "Atools.pow"=str then 1000 + size_of_term' t else 1 + size_of_term' t(*WN*)
1073 | size_of_term' (Abs (_,_,body)) = 1 + size_of_term' body
1074 | size_of_term' (f$t) = size_of_term' f + size_of_term' t
1075 | size_of_term' _ = 1;
1076 fun term_ord' pr thy (Abs (_, T, t), Abs(_, U, u)) = (* ~ term.ML *)
1077 (case term_ord' pr thy (t, u) of EQUAL => Term_Ord.typ_ord (T, U)
1079 | term_ord' pr thy (t, u) =
1081 let val (f, ts) = strip_comb t and (g, us) = strip_comb u;
1082 val _ = tracing ("t= f@ts= \"" ^ term2str f ^ "\" @ \"[" ^
1083 commas(map term2str ts) ^ "]\"")
1084 val _ = tracing ("u= g@us= \"" ^ term2str g ^"\" @ \"[" ^
1085 commas(map term2str us) ^"]\"")
1086 val _ = tracing ("size_of_term(t,u)= (" ^
1087 string_of_int (size_of_term' t) ^ ", " ^
1088 string_of_int (size_of_term' u) ^ ")")
1089 val _ = tracing ("hd_ord(f,g) = " ^ (pr_ord o hd_ord) (f,g))
1090 val _ = tracing ("terms_ord(ts,us) = " ^
1091 (pr_ord o terms_ord str false) (ts,us));
1092 val _ = tracing "-------"
1095 case int_ord (size_of_term' t, size_of_term' u) of
1097 let val (f, ts) = strip_comb t and (g, us) = strip_comb u in
1098 (case hd_ord (f, g) of EQUAL => (terms_ord str pr) (ts, us)
1102 and hd_ord (f, g) = (* ~ term.ML *)
1103 prod_ord (prod_ord Term_Ord.indexname_ord Term_Ord.typ_ord) int_ord (dest_hd' f, dest_hd' g)
1104 and terms_ord str pr (ts, us) =
1105 list_ord (term_ord' pr (assoc_thy "Isac"))(ts, us);
1108 fun ord_make_polytest (pr:bool) thy (_:subst) tu =
1109 (term_ord' pr thy(***) tu = LESS );
1115 rew_ord' := overwritel (!rew_ord',
1116 [("termlessI", termlessI),
1117 ("ord_make_polytest", ord_make_polytest false thy)
1120 (*WN060510 this was a preparation for prep_rls ...
1121 val scr_make_polytest =
1122 "Script Expand_binomtest t_t =" ^
1124 "((Try (Repeat (Rewrite real_diff_minus False))) @@ " ^
1126 " (Try (Repeat (Rewrite distrib_right False))) @@ " ^
1127 " (Try (Repeat (Rewrite distrib_left False))) @@ " ^
1128 " (Try (Repeat (Rewrite left_diff_distrib False))) @@ " ^
1129 " (Try (Repeat (Rewrite right_diff_distrib False))) @@ " ^
1131 " (Try (Repeat (Rewrite mult_1_left False))) @@ " ^
1132 " (Try (Repeat (Rewrite mult_zero_left False))) @@ " ^
1133 " (Try (Repeat (Rewrite add_0_left False))) @@ " ^
1135 " (Try (Repeat (Rewrite mult_commute False))) @@ " ^
1136 " (Try (Repeat (Rewrite real_mult_left_commute False))) @@ " ^
1137 " (Try (Repeat (Rewrite mult_assoc False))) @@ " ^
1138 " (Try (Repeat (Rewrite add_commute False))) @@ " ^
1139 " (Try (Repeat (Rewrite add_left_commute False))) @@ " ^
1140 " (Try (Repeat (Rewrite add_assoc False))) @@ " ^
1142 " (Try (Repeat (Rewrite sym_realpow_twoI False))) @@ " ^
1143 " (Try (Repeat (Rewrite realpow_plus_1 False))) @@ " ^
1144 " (Try (Repeat (Rewrite sym_real_mult_2 False))) @@ " ^
1145 " (Try (Repeat (Rewrite real_mult_2_assoc False))) @@ " ^
1147 " (Try (Repeat (Rewrite real_num_collect False))) @@ " ^
1148 " (Try (Repeat (Rewrite real_num_collect_assoc False))) @@ " ^
1150 " (Try (Repeat (Rewrite real_one_collect False))) @@ " ^
1151 " (Try (Repeat (Rewrite real_one_collect_assoc False))) @@ " ^
1153 " (Try (Repeat (Calculate PLUS ))) @@ " ^
1154 " (Try (Repeat (Calculate TIMES ))) @@ " ^
1155 " (Try (Repeat (Calculate POWER)))) " ^
1157 -----------------------------------------------------*)
1160 Rls{id = "make_polytest", preconds = []:term list,
1161 rew_ord = ("ord_make_polytest", ord_make_polytest false @{theory "Poly"}),
1162 erls = testerls, srls = Erls,
1163 calc = [("PLUS" , ("Groups.plus_class.plus", eval_binop "#add_")),
1164 ("TIMES" , ("Groups.times_class.times", eval_binop "#mult_")),
1165 ("POWER", ("Atools.pow", eval_binop "#power_"))
1167 rules = [Thm ("real_diff_minus",num_str @{thm real_diff_minus}),
1168 (*"a - b = a + (-1) * b"*)
1169 Thm ("distrib_right" ,num_str @{thm distrib_right}),
1170 (*"(z1.0 + z2.0) * w = z1.0 * w + z2.0 * w"*)
1171 Thm ("distrib_left",num_str @{thm distrib_left}),
1172 (*"w * (z1.0 + z2.0) = w * z1.0 + w * z2.0"*)
1173 Thm ("left_diff_distrib" ,num_str @{thm left_diff_distrib}),
1174 (*"(z1.0 - z2.0) * w = z1.0 * w - z2.0 * w"*)
1175 Thm ("right_diff_distrib",num_str @{thm right_diff_distrib}),
1176 (*"w * (z1.0 - z2.0) = w * z1.0 - w * z2.0"*)
1177 Thm ("mult_1_left",num_str @{thm mult_1_left}),
1179 Thm ("mult_zero_left",num_str @{thm mult_zero_left}),
1181 Thm ("add_0_left",num_str @{thm add_0_left}),
1185 Thm ("mult_commute",num_str @{thm mult_commute}),
1187 Thm ("real_mult_left_commute",num_str @{thm real_mult_left_commute}),
1188 (*z1.0 * (z2.0 * z3.0) = z2.0 * (z1.0 * z3.0)*)
1189 Thm ("mult_assoc",num_str @{thm mult_assoc}),
1190 (*z1.0 * z2.0 * z3.0 = z1.0 * (z2.0 * z3.0)*)
1191 Thm ("add_commute",num_str @{thm add_commute}),
1193 Thm ("add_left_commute",num_str @{thm add_left_commute}),
1194 (*x + (y + z) = y + (x + z)*)
1195 Thm ("add_assoc",num_str @{thm add_assoc}),
1196 (*z1.0 + z2.0 + z3.0 = z1.0 + (z2.0 + z3.0)*)
1198 Thm ("sym_realpow_twoI",
1199 num_str (@{thm realpow_twoI} RS @{thm sym})),
1200 (*"r1 * r1 = r1 ^^^ 2"*)
1201 Thm ("realpow_plus_1",num_str @{thm realpow_plus_1}),
1202 (*"r * r ^^^ n = r ^^^ (n + 1)"*)
1203 Thm ("sym_real_mult_2",
1204 num_str (@{thm real_mult_2} RS @{thm sym})),
1205 (*"z1 + z1 = 2 * z1"*)
1206 Thm ("real_mult_2_assoc",num_str @{thm real_mult_2_assoc}),
1207 (*"z1 + (z1 + k) = 2 * z1 + k"*)
1209 Thm ("real_num_collect",num_str @{thm real_num_collect}),
1210 (*"[| l is_const; m is_const |]==>l * n + m * n = (l + m) * n"*)
1211 Thm ("real_num_collect_assoc",num_str @{thm real_num_collect_assoc}),
1212 (*"[| l is_const; m is_const |] ==>
1213 l * n + (m * n + k) = (l + m) * n + k"*)
1214 Thm ("real_one_collect",num_str @{thm real_one_collect}),
1215 (*"m is_const ==> n + m * n = (1 + m) * n"*)
1216 Thm ("real_one_collect_assoc",num_str @{thm real_one_collect_assoc}),
1217 (*"m is_const ==> k + (n + m * n) = k + (1 + m) * n"*)
1219 Calc ("Groups.plus_class.plus", eval_binop "#add_"),
1220 Calc ("Groups.times_class.times", eval_binop "#mult_"),
1221 Calc ("Atools.pow", eval_binop "#power_")
1223 scr = EmptyScr(*Prog ((term_of o the o (parse thy))
1224 scr_make_polytest)*)
1228 (*WN060510 this was done before 'fun prep_rls' ...------------------------
1229 val scr_expand_binomtest =
1230 "Script Expand_binomtest t_t =" ^
1232 "((Try (Repeat (Rewrite real_plus_binom_pow2 False))) @@ " ^
1233 " (Try (Repeat (Rewrite real_plus_binom_times False))) @@ " ^
1234 " (Try (Repeat (Rewrite real_minus_binom_pow2 False))) @@ " ^
1235 " (Try (Repeat (Rewrite real_minus_binom_times False))) @@ " ^
1236 " (Try (Repeat (Rewrite real_plus_minus_binom1 False))) @@ " ^
1237 " (Try (Repeat (Rewrite real_plus_minus_binom2 False))) @@ " ^
1239 " (Try (Repeat (Rewrite mult_1_left False))) @@ " ^
1240 " (Try (Repeat (Rewrite mult_zero_left False))) @@ " ^
1241 " (Try (Repeat (Rewrite add_0_left False))) @@ " ^
1243 " (Try (Repeat (Calculate PLUS ))) @@ " ^
1244 " (Try (Repeat (Calculate TIMES ))) @@ " ^
1245 " (Try (Repeat (Calculate POWER))) @@ " ^
1247 " (Try (Repeat (Rewrite sym_realpow_twoI False))) @@ " ^
1248 " (Try (Repeat (Rewrite realpow_plus_1 False))) @@ " ^
1249 " (Try (Repeat (Rewrite sym_real_mult_2 False))) @@ " ^
1250 " (Try (Repeat (Rewrite real_mult_2_assoc False))) @@ " ^
1252 " (Try (Repeat (Rewrite real_num_collect False))) @@ " ^
1253 " (Try (Repeat (Rewrite real_num_collect_assoc False))) @@ " ^
1255 " (Try (Repeat (Rewrite real_one_collect False))) @@ " ^
1256 " (Try (Repeat (Rewrite real_one_collect_assoc False))) @@ " ^
1258 " (Try (Repeat (Calculate PLUS ))) @@ " ^
1259 " (Try (Repeat (Calculate TIMES ))) @@ " ^
1260 " (Try (Repeat (Calculate POWER)))) " ^
1262 --------------------------------------------------------------------------*)
1264 val expand_binomtest =
1265 Rls{id = "expand_binomtest", preconds = [],
1266 rew_ord = ("termlessI",termlessI),
1267 erls = testerls, srls = Erls,
1268 calc = [("PLUS" , ("Groups.plus_class.plus", eval_binop "#add_")),
1269 ("TIMES" , ("Groups.times_class.times", eval_binop "#mult_")),
1270 ("POWER", ("Atools.pow", eval_binop "#power_"))
1273 [Thm ("real_plus_binom_pow2" ,num_str @{thm real_plus_binom_pow2}),
1274 (*"(a + b) ^^^ 2 = a ^^^ 2 + 2 * a * b + b ^^^ 2"*)
1275 Thm ("real_plus_binom_times" ,num_str @{thm real_plus_binom_times}),
1276 (*"(a + b)*(a + b) = ...*)
1277 Thm ("real_minus_binom_pow2" ,num_str @{thm real_minus_binom_pow2}),
1278 (*"(a - b) ^^^ 2 = a ^^^ 2 - 2 * a * b + b ^^^ 2"*)
1279 Thm ("real_minus_binom_times",num_str @{thm real_minus_binom_times}),
1280 (*"(a - b)*(a - b) = ...*)
1281 Thm ("real_plus_minus_binom1",num_str @{thm real_plus_minus_binom1}),
1282 (*"(a + b) * (a - b) = a ^^^ 2 - b ^^^ 2"*)
1283 Thm ("real_plus_minus_binom2",num_str @{thm real_plus_minus_binom2}),
1284 (*"(a - b) * (a + b) = a ^^^ 2 - b ^^^ 2"*)
1286 Thm ("real_pp_binom_times",num_str @{thm real_pp_binom_times}),
1287 (*(a + b)*(c + d) = a*c + a*d + b*c + b*d*)
1288 Thm ("real_pm_binom_times",num_str @{thm real_pm_binom_times}),
1289 (*(a + b)*(c - d) = a*c - a*d + b*c - b*d*)
1290 Thm ("real_mp_binom_times",num_str @{thm real_mp_binom_times}),
1291 (*(a - b)*(c p d) = a*c + a*d - b*c - b*d*)
1292 Thm ("real_mm_binom_times",num_str @{thm real_mm_binom_times}),
1293 (*(a - b)*(c p d) = a*c - a*d - b*c + b*d*)
1294 Thm ("realpow_multI",num_str @{thm realpow_multI}),
1295 (*(a*b)^^^n = a^^^n * b^^^n*)
1296 Thm ("real_plus_binom_pow3",num_str @{thm real_plus_binom_pow3}),
1297 (* (a + b)^^^3 = a^^^3 + 3*a^^^2*b + 3*a*b^^^2 + b^^^3 *)
1298 Thm ("real_minus_binom_pow3",num_str @{thm real_minus_binom_pow3}),
1299 (* (a - b)^^^3 = a^^^3 - 3*a^^^2*b + 3*a*b^^^2 - b^^^3 *)
1302 (* Thm ("distrib_right" ,num_str @{thm distrib_right}),
1303 (*"(z1.0 + z2.0) * w = z1.0 * w + z2.0 * w"*)
1304 Thm ("distrib_left",num_str @{thm distrib_left}),
1305 (*"w * (z1.0 + z2.0) = w * z1.0 + w * z2.0"*)
1306 Thm ("left_diff_distrib" ,num_str @{thm left_diff_distrib}),
1307 (*"(z1.0 - z2.0) * w = z1.0 * w - z2.0 * w"*)
1308 Thm ("right_diff_distrib",num_str @{thm right_diff_distrib}),
1309 (*"w * (z1.0 - z2.0) = w * z1.0 - w * z2.0"*)
1312 Thm ("mult_1_left",num_str @{thm mult_1_left}),
1314 Thm ("mult_zero_left",num_str @{thm mult_zero_left}),
1316 Thm ("add_0_left",num_str @{thm add_0_left}),
1319 Calc ("Groups.plus_class.plus", eval_binop "#add_"),
1320 Calc ("Groups.times_class.times", eval_binop "#mult_"),
1321 Calc ("Atools.pow", eval_binop "#power_"),
1323 Thm ("mult_commute",num_str @{thm mult_commute}),
1325 Thm ("real_mult_left_commute",num_str @{thm real_mult_left_commute}),
1326 Thm ("mult_assoc",num_str @{thm mult_assoc}),
1327 Thm ("add_commute",num_str @{thm add_commute}),
1328 Thm ("add_left_commute",num_str @{thm add_left_commute}),
1329 Thm ("add_assoc",num_str @{thm add_assoc}),
1332 Thm ("sym_realpow_twoI",
1333 num_str (@{thm realpow_twoI} RS @{thm sym})),
1334 (*"r1 * r1 = r1 ^^^ 2"*)
1335 Thm ("realpow_plus_1",num_str @{thm realpow_plus_1}),
1336 (*"r * r ^^^ n = r ^^^ (n + 1)"*)
1337 (*Thm ("sym_real_mult_2",
1338 num_str (@{thm real_mult_2} RS @{thm sym})),
1339 (*"z1 + z1 = 2 * z1"*)*)
1340 Thm ("real_mult_2_assoc",num_str @{thm real_mult_2_assoc}),
1341 (*"z1 + (z1 + k) = 2 * z1 + k"*)
1343 Thm ("real_num_collect",num_str @{thm real_num_collect}),
1344 (*"[| l is_const; m is_const |] ==> l * n + m * n = (l + m) * n"*)
1345 Thm ("real_num_collect_assoc",num_str @{thm real_num_collect_assoc}),
1346 (*"[| l is_const; m is_const |] ==> l * n + (m * n + k) = (l + m) * n + k"*)
1347 Thm ("real_one_collect",num_str @{thm real_one_collect}),
1348 (*"m is_const ==> n + m * n = (1 + m) * n"*)
1349 Thm ("real_one_collect_assoc",num_str @{thm real_one_collect_assoc}),
1350 (*"m is_const ==> k + (n + m * n) = k + (1 + m) * n"*)
1352 Calc ("Groups.plus_class.plus", eval_binop "#add_"),
1353 Calc ("Groups.times_class.times", eval_binop "#mult_"),
1354 Calc ("Atools.pow", eval_binop "#power_")
1357 (*Script ((term_of o the o (parse thy)) scr_expand_binomtest)*)
1360 setup {* KEStore_Elems.add_rlss
1361 [("make_polytest", (Context.theory_name @{theory}, prep_rls make_polytest)),
1362 ("expand_binomtest", (Context.theory_name @{theory}, prep_rls expand_binomtest))] *}