1 (* Knowledge for tests, specifically simplified or bound to a fixed state
2 for the purpose of simplifying tests.
3 Author: Walther Neuper 2003
4 (c) due to copyright terms
7 (0) revert import Test -- DiophantEq, this raises issues related to (1..4)
8 (1) transfer methods to respective theories, if only test, then hierarchy at ["...", "Test"]:
9 differentiate, root equatioh, polynomial equation, diophantine equation
10 (2) transfer problems accordingly
11 (3) rearrange rls according to (1..2)
12 (4) rearrange axiomatizations according to (3)
15 theory Test imports Base_Tools Poly Rational Root Diff begin
17 section \<open>consts\<close>
18 subsection \<open>for scripts\<close>
22 bool list] => bool list"
23 ("((Script Solve'_univar'_err (_ _ _ =))// (_))" 9)
26 bool list] => bool list"
27 ("((Script Solve'_linear (_ _ =))// (_))" 9)
30 bool list] => bool list"
31 ("((Script Solve'_root'_equation (_ _ =))// (_))" 9)
34 bool list] => bool list"
35 ("((Script Solve'_plain'_square (_ _ =))// (_))" 9)
36 Norm'_univar'_equation
39 ("((Script Norm'_univar'_equation (_ _ =))// (_))" 9)
43 ("((Script STest'_simplify (_ =))// (_))" 9)
46 subsection \<open>for problems\<close>
48 "is'_root'_free" :: "'a => bool" ("is'_root'_free _" 10)
49 "contains'_root" :: "'a => bool" ("contains'_root _" 10)
51 "precond'_rootmet" :: "'a => bool" ("precond'_rootmet _" 10)
52 "precond'_rootpbl" :: "'a => bool" ("precond'_rootpbl _" 10)
53 "precond'_submet" :: "'a => bool" ("precond'_submet _" 10)
54 "precond'_subpbl" :: "'a => bool" ("precond'_subpbl _" 10)
57 section \<open>functions\<close>
59 fun bin_o (Const (op_, (Type ("fun", [Type (s2, []), Type ("fun", [Type (s4, _),Type (s5, _)])]))))
60 = if s2 = s4 andalso s4 = s5 then [op_] else []
63 fun bin_op (t1 $ t2) = union op = (bin_op t1) (bin_op t2)
65 fun is_bin_op t = (bin_op t <> []);
67 fun bin_op_arg1 ((Const (_,
68 (Type ("fun", [Type (_, []), Type ("fun", [Type _, Type _])])))) $ arg1 $ _) = arg1
69 | bin_op_arg1 t = raise ERROR ("bin_op_arg1: t = " ^ Rule.term2str t);
70 fun bin_op_arg2 ((Const (_,
71 (Type ("fun", [Type (_, []),Type ("fun", [Type _, Type _])]))))$ _ $ arg2) = arg2
72 | bin_op_arg2 t = raise ERROR ("bin_op_arg1: t = " ^ Rule.term2str t);
74 exception NO_EQUATION_TERM;
75 fun is_equation ((Const ("HOL.eq",
76 (Type ("fun", [Type (_, []), Type ("fun", [Type (_, []),Type ("bool",[])])])))) $ _ $ _) = true
77 | is_equation _ = false;
78 fun equ_lhs ((Const ("HOL.eq",
79 (Type ("fun", [Type (_, []), Type ("fun", [Type (_, []),Type ("bool",[])])])))) $ l $ _) = l
80 | equ_lhs _ = raise NO_EQUATION_TERM;
81 fun equ_rhs ((Const ("HOL.eq", (Type ("fun",
82 [Type (_, []), Type ("fun", [Type (_, []), Type ("bool",[])])])))) $ _ $ r) = r
83 | equ_rhs _ = raise NO_EQUATION_TERM;
85 fun atom (Const (_, Type (_,[]))) = true
86 | atom (Free (_, Type (_,[]))) = true
87 | atom (Var (_, Type (_,[]))) = true
88 | atom((Const ("Bin.integ_of_bin",_)) $ _) = true
91 fun varids (Const (s, Type (_,[]))) = [strip_thy s]
92 | varids (Free (s, Type (_,[]))) = if TermC.is_num' s then [] else [strip_thy s]
93 | varids (Var((s, _),Type (_,[]))) = [strip_thy s]
94 (*| varids (_ (s,"?DUMMY" )) = ..ML-error *)
95 | varids((Const ("Bin.integ_of_bin",_)) $ _)= [](*8.01: superfluous?*)
96 | varids (Abs (a, _, t)) = union op = [a] (varids t)
97 | varids (t1 $ t2) = union op = (varids t1) (varids t2)
100 fun bin_ops_only ((Const op_) $ t1 $ t2) =
101 if is_bin_op (Const op_) then bin_ops_only t1 andalso bin_ops_only t2 else false
102 | bin_ops_only t = if atom t then true else bin_ops_only t;
104 fun polynomial opl t _(* bdVar TODO *) =
105 subset op = (bin_op t, opl) andalso (bin_ops_only t);
107 fun poly_equ opl bdVar t = is_equation t (* bdVar TODO *)
108 andalso polynomial opl (equ_lhs t) bdVar
109 andalso polynomial opl (equ_rhs t) bdVar
110 andalso (subset op = (varids bdVar, varids (equ_lhs t)) orelse
111 subset op = (varids bdVar, varids (equ_lhs t)));
113 fun max (a,b) = if a < b then b else a;
115 fun degree addl mul bdVar t =
117 fun deg _ _ v (Const (s, Type (_, []))) = if v=strip_thy s then 1 else 0
118 | deg _ _ v (Free (s, Type (_, []))) = if v=strip_thy s then 1 else 0
119 | deg _ _ v (Var((s, _), Type (_, []))) = if v=strip_thy s then 1 else 0
120 (*| deg _ _ v (_ (s,"?DUMMY" )) = ..ML-error *)
121 | deg _ _ _ ((Const ("Bin.integ_of_bin", _)) $ _ ) = 0
122 | deg addl mul v (h $ t1 $ t2) =
123 if subset op = (bin_op h, addl)
124 then max (deg addl mul v t1 , deg addl mul v t2)
125 else (*mul!*)(deg addl mul v t1) + (deg addl mul v t2)
126 | deg _ _ _ t = raise ERROR ("deg: t = " ^ Rule.term2str t)
128 if polynomial (addl @ [mul]) t bdVar
129 then SOME (deg addl mul (id_of bdVar) t)
130 else (NONE:int option)
132 fun degree_ addl mul bdVar t = (* do not export *)
136 in opt (degree addl mul bdVar t) end;
138 fun linear addl mul t bdVar = (degree_ addl mul bdVar t) < 2;
140 fun linear_equ addl mul bdVar t =
144 val degl = degree_ addl mul bdVar (equ_lhs t);
145 val degr = degree_ addl mul bdVar (equ_rhs t)
146 in if (degl>0 orelse degr>0)andalso max(degl,degr) < 2 then true else false end
148 (* strip_thy op_ before *)
149 fun is_div_op (dv, (Const (op_,
150 (Type ("fun", [Type (_, []), Type ("fun", [Type _, Type _])])))) ) = (dv = strip_thy op_)
151 | is_div_op _ = false;
153 fun is_denom bdVar div_op t =
154 let fun is bool[v]dv (Const (s,Type(_,[])))= bool andalso(if v=strip_thy s then true else false)
155 | is bool[v]dv (Free (s,Type(_,[])))= bool andalso(if v=strip_thy s then true else false)
156 | is bool[v]dv (Var((s,_),Type(_,[])))= bool andalso(if v=strip_thy s then true else false)
157 | is bool[v]dv((Const ("Bin.integ_of_bin",_)) $ _) = false
158 | is bool[v]dv (h$n$d) =
160 then (is false[v]dv n)orelse(is true[v]dv d)
161 else (is bool [v]dv n)orelse(is bool[v]dv d)
162 in is false (varids bdVar) (strip_thy div_op) t end;
165 fun rational t div_op bdVar =
166 is_denom bdVar div_op t andalso bin_ops_only t;
170 section \<open>axiomatizations\<close>
171 axiomatization where (*TODO: prove as theorems*)
173 radd_mult_distrib2: "(k::real) * (m + n) = k * m + k * n" and
174 rdistr_right_assoc: "(k::real) + l * n + m * n = k + (l + m) * n" and
175 rdistr_right_assoc_p: "l * n + (m * n + (k::real)) = (l + m) * n + k" and
176 rdistr_div_right: "((k::real) + l) / n = k / n + l / n" and
178 "[| l is_const; m is_const |] ==> (l::real)*n + m*n = (l + m) * n" and
180 "m is_const ==> (n::real) + m * n = (1 + m) * n" and
181 rcollect_one_left_assoc:
182 "m is_const ==> (k::real) + n + m * n = k + (1 + m) * n" and
183 rcollect_one_left_assoc_p:
184 "m is_const ==> n + (m * n + (k::real)) = (1 + m) * n + k" and
186 rtwo_of_the_same: "a + a = 2 * a" and
187 rtwo_of_the_same_assoc: "(x + a) + a = x + 2 * a" and
188 rtwo_of_the_same_assoc_p:"a + (a + x) = 2 * a + x" and
190 rcancel_den: "not(a=0) ==> a * (b / a) = b" and
191 rcancel_const: "[| a is_const; b is_const |] ==> a*(x/b) = a/b*x" and
192 rshift_nominator: "(a::real) * b / c = a / c * b" and
194 exp_pow: "(a ^^^ b) ^^^ c = a ^^^ (b * c)" and
195 rsqare: "(a::real) * a = a ^^^ 2" and
196 power_1: "(a::real) ^^^ 1 = a" and
197 rbinom_power_2: "((a::real) + b)^^^ 2 = a^^^ 2 + 2*a*b + b^^^ 2" and
199 rmult_1: "1 * k = (k::real)" and
200 rmult_1_right: "k * 1 = (k::real)" and
201 rmult_0: "0 * k = (0::real)" and
202 rmult_0_right: "k * 0 = (0::real)" and
203 radd_0: "0 + k = (k::real)" and
204 radd_0_right: "k + 0 = (k::real)" and
207 "[| a is_const; c is_const; d is_const |] ==> a/d + c/d = (a+c)/(d::real)" and
209 "[| a is_const; b is_const; c is_const; d is_const |] ==> a/b + c/d = (a*d + b*c)/(b*(d::real))"
212 radd_commute: "(m::real) + (n::real) = n + m" and
213 radd_left_commute: "(x::real) + (y + z) = y + (x + z)" and
214 radd_assoc: "(m::real) + n + k = m + (n + k)" and
215 rmult_commute: "(m::real) * n = n * m" and
216 rmult_left_commute: "(x::real) * (y * z) = y * (x * z)" and
217 rmult_assoc: "(m::real) * n * k = m * (n * k)" and
219 (*for equations: 'bdv' is a meta-constant*)
220 risolate_bdv_add: "((k::real) + bdv = m) = (bdv = m + (-1)*k)" and
221 risolate_bdv_mult_add: "((k::real) + n*bdv = m) = (n*bdv = m + (-1)*k)" and
222 risolate_bdv_mult: "((n::real) * bdv = m) = (bdv = m / n)" and
225 "~(b =!= 0) ==> (a = b) = (a + (-1)*b = 0)" and
227 (*17.9.02 aus SqRoot.thy------------------------------vvv---*)
228 root_ge0: "0 <= a ==> 0 <= sqrt a" and
229 (*should be dropped with better simplification in eval_rls ...*)
231 "[| 0 <= a; 0 <= b |] ==> (0 <= sqrt a + sqrt b) = True" and
233 "[| 0<=a; 0<=b; 0<=c |] ==> (0 <= a * sqrt b + sqrt c) = True" and
235 "[| 0<=a; 0<=b; 0<=c |] ==> (0 <= sqrt a + b * sqrt c) = True" and
238 rroot_square_inv: "(sqrt a)^^^ 2 = a" and
239 rroot_times_root: "sqrt a * sqrt b = sqrt(a*b)" and
240 rroot_times_root_assoc: "(a * sqrt b) * sqrt c = a * sqrt(b*c)" and
241 rroot_times_root_assoc_p: "sqrt b * (sqrt c * a)= sqrt(b*c) * a" and
244 (*for root-equations*)
245 square_equation_left:
246 "[| 0 <= a; 0 <= b |] ==> (((sqrt a)=b)=(a=(b^^^ 2)))" and
247 square_equation_right:
248 "[| 0 <= a; 0 <= b |] ==> ((a=(sqrt b))=((a^^^ 2)=b))" and
249 (*causes frequently non-termination:*)
251 "[| 0 <= a; 0 <= b |] ==> ((a=b)=((a^^^ 2)=b^^^ 2))" and
253 risolate_root_add: "(a+ sqrt c = d) = ( sqrt c = d + (-1)*a)" and
254 risolate_root_mult: "(a+b*sqrt c = d) = (b*sqrt c = d + (-1)*a)" and
255 risolate_root_div: "(a * sqrt c = d) = ( sqrt c = d / a)" and
257 (*for polynomial equations of degree 2; linear case in RatArith*)
258 mult_square: "(a*bdv^^^2 = b) = (bdv^^^2 = b / a)" and
259 constant_square: "(a + bdv^^^2 = b) = (bdv^^^2 = b + -1*a)" and
260 constant_mult_square: "(a + b*bdv^^^2 = c) = (b*bdv^^^2 = c + -1*a)" and
263 "0 <= a ==> (x^^^2 = a) = ((x=sqrt a) | (x=-1*sqrt a))" and
265 "(x^^^2 = 0) = (x = 0)" and
267 (*isolate root on the LEFT hand side of the equation
268 otherwise shuffling from left to right would not terminate*)
271 "is_root_free a ==> (a = sqrt b) = (a + (-1)*sqrt b = 0)" and
273 "is_root_free a ==> (a = c*sqrt b) = (a + (-1)*c*sqrt b = 0)" and
274 rroot_to_lhs_add_mult:
275 "is_root_free a ==> (a = d+c*sqrt b) = (a + (-1)*c*sqrt b = d)"
276 (*17.9.02 aus SqRoot.thy------------------------------^^^---*)
278 section \<open>eval functions\<close>
282 (** evaluation of numerals and predicates **)
284 (*does a term contain a root ?*)
285 fun eval_contains_root (thmid:string) _
286 (t as (Const("Test.contains'_root",t0) $ arg)) thy =
287 if member op = (ids_of arg) "sqrt"
288 then SOME (TermC.mk_thmid thmid (Rule.term_to_string''' thy arg)"",
289 HOLogic.Trueprop $ (TermC.mk_equality (t, @{term True})))
290 else SOME (TermC.mk_thmid thmid (Rule.term_to_string''' thy arg)"",
291 HOLogic.Trueprop $ (TermC.mk_equality (t, @{term False})))
292 | eval_contains_root _ _ _ _ = NONE;
294 (*dummy precondition for root-met of x+1=2*)
295 fun eval_precond_rootmet (thmid:string) _ (t as (Const ("Test.precond'_rootmet", _) $ arg)) thy =
296 SOME (TermC.mk_thmid thmid (Rule.term_to_string''' thy arg)"",
297 HOLogic.Trueprop $ (TermC.mk_equality (t, @{term True})))
298 | eval_precond_rootmet _ _ _ _ = NONE;
300 (*dummy precondition for root-pbl of x+1=2*)
301 fun eval_precond_rootpbl (thmid:string) _ (t as (Const ("Test.precond'_rootpbl", _) $ arg)) thy =
302 SOME (TermC.mk_thmid thmid (Rule.term_to_string''' thy arg) "",
303 HOLogic.Trueprop $ (TermC.mk_equality (t, @{term True})))
304 | eval_precond_rootpbl _ _ _ _ = NONE;
306 setup \<open>KEStore_Elems.add_calcs
307 [("contains_root", ("Test.contains'_root", eval_contains_root"#contains_root_")),
308 ("Test.precond'_rootmet", ("Test.precond'_rootmet", eval_precond_rootmet"#Test.precond_rootmet_")),
309 ("Test.precond'_rootpbl", ("Test.precond'_rootpbl",
310 eval_precond_rootpbl"#Test.precond_rootpbl_"))]
313 (*8.4.03 aus Poly.ML--------------------------------vvv---
314 make_polynomial ---> make_poly
315 ^-- for user ^-- for systest _ONLY_*)
317 local (*. for make_polytest .*)
319 open Term; (* for type order = EQUAL | LESS | GREATER *)
321 fun pr_ord EQUAL = "EQUAL"
322 | pr_ord LESS = "LESS"
323 | pr_ord GREATER = "GREATER";
325 fun dest_hd' (Const (a, T)) = (* ~ term.ML *)
327 "Atools.pow" => ((("|||||||||||||", 0), T), 0) (*WN greatest *)
328 | _ => (((a, 0), T), 0))
329 | dest_hd' (Free (a, T)) = (((a, 0), T), 1)
330 | dest_hd' (Var v) = (v, 2)
331 | dest_hd' (Bound i) = ((("", i), dummyT), 3)
332 | dest_hd' (Abs (_, T, _)) = ((("", 0), T), 4);
334 fun get_order_pow (t $ (Free(order,_))) =
335 (case TermC.int_of_str_opt (order) of
338 | get_order_pow _ = 0;
340 fun size_of_term' (Const(str,_) $ t) =
341 if "Atools.pow"=str then 1000 + size_of_term' t else 1 + size_of_term' t(*WN*)
342 | size_of_term' (Abs (_,_,body)) = 1 + size_of_term' body
343 | size_of_term' (f$t) = size_of_term' f + size_of_term' t
344 | size_of_term' _ = 1;
345 fun term_ord' pr thy (Abs (_, T, t), Abs(_, U, u)) = (* ~ term.ML *)
346 (case term_ord' pr thy (t, u) of EQUAL => Term_Ord.typ_ord (T, U)
348 | term_ord' pr thy (t, u) =
350 let val (f, ts) = strip_comb t and (g, us) = strip_comb u;
351 val _ = tracing ("t= f@ts= \"" ^ Rule.term2str f ^ "\" @ \"[" ^
352 commas(map Rule.term2str ts) ^ "]\"")
353 val _ = tracing ("u= g@us= \"" ^ Rule.term2str g ^"\" @ \"[" ^
354 commas(map Rule.term2str us) ^"]\"")
355 val _ = tracing ("size_of_term(t,u)= (" ^
356 string_of_int (size_of_term' t) ^ ", " ^
357 string_of_int (size_of_term' u) ^ ")")
358 val _ = tracing ("hd_ord(f,g) = " ^ (pr_ord o hd_ord) (f,g))
359 val _ = tracing ("terms_ord(ts,us) = " ^
360 (pr_ord o terms_ord str false) (ts,us));
361 val _ = tracing "-------"
364 case int_ord (size_of_term' t, size_of_term' u) of
366 let val (f, ts) = strip_comb t and (g, us) = strip_comb u in
367 (case hd_ord (f, g) of EQUAL => (terms_ord str pr) (ts, us)
371 and hd_ord (f, g) = (* ~ term.ML *)
372 prod_ord (prod_ord Term_Ord.indexname_ord Term_Ord.typ_ord) int_ord (dest_hd' f, dest_hd' g)
373 and terms_ord str pr (ts, us) =
374 list_ord (term_ord' pr (Celem.assoc_thy "Isac"))(ts, us);
377 fun ord_make_polytest (pr:bool) thy (_: Rule.subst) tu =
378 (term_ord' pr thy(***) tu = LESS );
383 section \<open>term order\<close>
385 fun term_order (_: Rule.subst) tu = (term_ordI [] tu = LESS);
388 section \<open>rulesets\<close>
391 Rule.Rls {id = "testerls", preconds = [], rew_ord = ("termlessI",termlessI),
392 erls = Rule.e_rls, srls = Rule.Erls,
393 calc = [], errpatts = [],
394 rules = [Rule.Thm ("refl",TermC.num_str @{thm refl}),
395 Rule.Thm ("order_refl",TermC.num_str @{thm order_refl}),
396 Rule.Thm ("radd_left_cancel_le",TermC.num_str @{thm radd_left_cancel_le}),
397 Rule.Thm ("not_true",TermC.num_str @{thm not_true}),
398 Rule.Thm ("not_false",TermC.num_str @{thm not_false}),
399 Rule.Thm ("and_true",TermC.num_str @{thm and_true}),
400 Rule.Thm ("and_false",TermC.num_str @{thm and_false}),
401 Rule.Thm ("or_true",TermC.num_str @{thm or_true}),
402 Rule.Thm ("or_false",TermC.num_str @{thm or_false}),
403 Rule.Thm ("and_commute",TermC.num_str @{thm and_commute}),
404 Rule.Thm ("or_commute",TermC.num_str @{thm or_commute}),
406 Rule.Calc ("Atools.is'_const",eval_const "#is_const_"),
407 Rule.Calc ("Tools.matches", Tools.eval_matches ""),
409 Rule.Calc ("Groups.plus_class.plus",eval_binop "#add_"),
410 Rule.Calc ("Groups.times_class.times",eval_binop "#mult_"),
411 Rule.Calc ("Atools.pow" ,eval_binop "#power_"),
413 Rule.Calc ("Orderings.ord_class.less",eval_equ "#less_"),
414 Rule.Calc ("Orderings.ord_class.less_eq",eval_equ "#less_equal_"),
416 Rule.Calc ("Atools.ident",eval_ident "#ident_")],
417 scr = Rule.Prog ((Thm.term_of o the o (TermC.parse thy)) "empty_script")
421 (*.for evaluation of conditions in rewrite rules.*)
422 (*FIXXXXXXME 10.8.02: handle like _simplify*)
424 Rule.Rls{id = "tval_rls", preconds = [],
425 rew_ord = ("sqrt_right",sqrt_right false @{theory "Pure"}),
426 erls=testerls,srls = Rule.e_rls,
427 calc=[], errpatts = [],
428 rules = [Rule.Thm ("refl",TermC.num_str @{thm refl}),
429 Rule.Thm ("order_refl",TermC.num_str @{thm order_refl}),
430 Rule.Thm ("radd_left_cancel_le",TermC.num_str @{thm radd_left_cancel_le}),
431 Rule.Thm ("not_true",TermC.num_str @{thm not_true}),
432 Rule.Thm ("not_false",TermC.num_str @{thm not_false}),
433 Rule.Thm ("and_true",TermC.num_str @{thm and_true}),
434 Rule.Thm ("and_false",TermC.num_str @{thm and_false}),
435 Rule.Thm ("or_true",TermC.num_str @{thm or_true}),
436 Rule.Thm ("or_false",TermC.num_str @{thm or_false}),
437 Rule.Thm ("and_commute",TermC.num_str @{thm and_commute}),
438 Rule.Thm ("or_commute",TermC.num_str @{thm or_commute}),
440 Rule.Thm ("real_diff_minus",TermC.num_str @{thm real_diff_minus}),
442 Rule.Thm ("root_ge0",TermC.num_str @{thm root_ge0}),
443 Rule.Thm ("root_add_ge0",TermC.num_str @{thm root_add_ge0}),
444 Rule.Thm ("root_ge0_1",TermC.num_str @{thm root_ge0_1}),
445 Rule.Thm ("root_ge0_2",TermC.num_str @{thm root_ge0_2}),
447 Rule.Calc ("Atools.is'_const",eval_const "#is_const_"),
448 Rule.Calc ("Test.contains'_root",eval_contains_root "#eval_contains_root"),
449 Rule.Calc ("Tools.matches", Tools.eval_matches ""),
450 Rule.Calc ("Test.contains'_root",
451 eval_contains_root"#contains_root_"),
453 Rule.Calc ("Groups.plus_class.plus",eval_binop "#add_"),
454 Rule.Calc ("Groups.times_class.times",eval_binop "#mult_"),
455 Rule.Calc ("NthRoot.sqrt",eval_sqrt "#sqrt_"),
456 Rule.Calc ("Atools.pow" ,eval_binop "#power_"),
458 Rule.Calc ("Orderings.ord_class.less",eval_equ "#less_"),
459 Rule.Calc ("Orderings.ord_class.less_eq",eval_equ "#less_equal_"),
461 Rule.Calc ("Atools.ident",eval_ident "#ident_")],
462 scr = Rule.Prog ((Thm.term_of o the o (TermC.parse thy)) "empty_script")
465 setup \<open>KEStore_Elems.add_rlss [("testerls", (Context.theory_name @{theory}, prep_rls' testerls))]\<close>
468 (*make () dissappear*)
469 val rearrange_assoc =
470 Rule.Rls{id = "rearrange_assoc", preconds = [],
471 rew_ord = ("e_rew_ord",Rule.e_rew_ord),
472 erls = Rule.e_rls, srls = Rule.e_rls, calc = [], errpatts = [],
474 [Rule.Thm ("sym_add_assoc",TermC.num_str (@{thm add.assoc} RS @{thm sym})),
475 Rule.Thm ("sym_rmult_assoc",TermC.num_str (@{thm rmult_assoc} RS @{thm sym}))],
476 scr = Rule.Prog ((Thm.term_of o the o (TermC.parse thy)) "empty_script")
480 Rule.Rls{id = "ac_plus_times", preconds = [], rew_ord = ("term_order",term_order),
481 erls = Rule.e_rls, srls = Rule.e_rls, calc = [], errpatts = [],
483 [Rule.Thm ("radd_commute",TermC.num_str @{thm radd_commute}),
484 Rule.Thm ("radd_left_commute",TermC.num_str @{thm radd_left_commute}),
485 Rule.Thm ("add_assoc",TermC.num_str @{thm add.assoc}),
486 Rule.Thm ("rmult_commute",TermC.num_str @{thm rmult_commute}),
487 Rule.Thm ("rmult_left_commute",TermC.num_str @{thm rmult_left_commute}),
488 Rule.Thm ("rmult_assoc",TermC.num_str @{thm rmult_assoc})],
489 scr = Rule.Prog ((Thm.term_of o the o (TermC.parse thy)) "empty_script")
492 (*todo: replace by Rewrite("rnorm_equation_add",TermC.num_str @{thm rnorm_equation_add)*)
494 Rule.Rls{id = "norm_equation", preconds = [], rew_ord = ("e_rew_ord",Rule.e_rew_ord),
495 erls = tval_rls, srls = Rule.e_rls, calc = [], errpatts = [],
496 rules = [Rule.Thm ("rnorm_equation_add",TermC.num_str @{thm rnorm_equation_add})
498 scr = Rule.Prog ((Thm.term_of o the o (TermC.parse thy)) "empty_script")
502 (* expects * distributed over + *)
504 Rule.Rls{id = "Test_simplify", preconds = [],
505 rew_ord = ("sqrt_right",sqrt_right false @{theory "Pure"}),
506 erls = tval_rls, srls = Rule.e_rls,
507 calc=[(*since 040209 filled by prep_rls'*)], errpatts = [],
509 Rule.Thm ("real_diff_minus",TermC.num_str @{thm real_diff_minus}),
510 Rule.Thm ("radd_mult_distrib2",TermC.num_str @{thm radd_mult_distrib2}),
511 Rule.Thm ("rdistr_right_assoc",TermC.num_str @{thm rdistr_right_assoc}),
512 Rule.Thm ("rdistr_right_assoc_p",TermC.num_str @{thm rdistr_right_assoc_p}),
513 Rule.Thm ("rdistr_div_right",TermC.num_str @{thm rdistr_div_right}),
514 Rule.Thm ("rbinom_power_2",TermC.num_str @{thm rbinom_power_2}),
516 Rule.Thm ("radd_commute",TermC.num_str @{thm radd_commute}),
517 Rule.Thm ("radd_left_commute",TermC.num_str @{thm radd_left_commute}),
518 Rule.Thm ("add_assoc",TermC.num_str @{thm add.assoc}),
519 Rule.Thm ("rmult_commute",TermC.num_str @{thm rmult_commute}),
520 Rule.Thm ("rmult_left_commute",TermC.num_str @{thm rmult_left_commute}),
521 Rule.Thm ("rmult_assoc",TermC.num_str @{thm rmult_assoc}),
523 Rule.Thm ("radd_real_const_eq",TermC.num_str @{thm radd_real_const_eq}),
524 Rule.Thm ("radd_real_const",TermC.num_str @{thm radd_real_const}),
525 (* these 2 rules are invers to distr_div_right wrt. termination.
526 thus they MUST be done IMMEDIATELY before calc *)
527 Rule.Calc ("Groups.plus_class.plus", eval_binop "#add_"),
528 Rule.Calc ("Groups.times_class.times", eval_binop "#mult_"),
529 Rule.Calc ("Rings.divide_class.divide", eval_cancel "#divide_e"),
530 Rule.Calc ("Atools.pow", eval_binop "#power_"),
532 Rule.Thm ("rcollect_right",TermC.num_str @{thm rcollect_right}),
533 Rule.Thm ("rcollect_one_left",TermC.num_str @{thm rcollect_one_left}),
534 Rule.Thm ("rcollect_one_left_assoc",TermC.num_str @{thm rcollect_one_left_assoc}),
535 Rule.Thm ("rcollect_one_left_assoc_p",TermC.num_str @{thm rcollect_one_left_assoc_p}),
537 Rule.Thm ("rshift_nominator",TermC.num_str @{thm rshift_nominator}),
538 Rule.Thm ("rcancel_den",TermC.num_str @{thm rcancel_den}),
539 Rule.Thm ("rroot_square_inv",TermC.num_str @{thm rroot_square_inv}),
540 Rule.Thm ("rroot_times_root",TermC.num_str @{thm rroot_times_root}),
541 Rule.Thm ("rroot_times_root_assoc_p",TermC.num_str @{thm rroot_times_root_assoc_p}),
542 Rule.Thm ("rsqare",TermC.num_str @{thm rsqare}),
543 Rule.Thm ("power_1",TermC.num_str @{thm power_1}),
544 Rule.Thm ("rtwo_of_the_same",TermC.num_str @{thm rtwo_of_the_same}),
545 Rule.Thm ("rtwo_of_the_same_assoc_p",TermC.num_str @{thm rtwo_of_the_same_assoc_p}),
547 Rule.Thm ("rmult_1",TermC.num_str @{thm rmult_1}),
548 Rule.Thm ("rmult_1_right",TermC.num_str @{thm rmult_1_right}),
549 Rule.Thm ("rmult_0",TermC.num_str @{thm rmult_0}),
550 Rule.Thm ("rmult_0_right",TermC.num_str @{thm rmult_0_right}),
551 Rule.Thm ("radd_0",TermC.num_str @{thm radd_0}),
552 Rule.Thm ("radd_0_right",TermC.num_str @{thm radd_0_right})
554 scr = Rule.Prog ((Thm.term_of o the o (TermC.parse thy)) "empty_script")
555 (*since 040209 filled by prep_rls': STest_simplify*)
559 (*isolate the root in a root-equation*)
561 Rule.Rls{id = "isolate_root", preconds = [], rew_ord = ("e_rew_ord",Rule.e_rew_ord),
562 erls=tval_rls,srls = Rule.e_rls, calc=[], errpatts = [],
563 rules = [Rule.Thm ("rroot_to_lhs",TermC.num_str @{thm rroot_to_lhs}),
564 Rule.Thm ("rroot_to_lhs_mult",TermC.num_str @{thm rroot_to_lhs_mult}),
565 Rule.Thm ("rroot_to_lhs_add_mult",TermC.num_str @{thm rroot_to_lhs_add_mult}),
566 Rule.Thm ("risolate_root_add",TermC.num_str @{thm risolate_root_add}),
567 Rule.Thm ("risolate_root_mult",TermC.num_str @{thm risolate_root_mult}),
568 Rule.Thm ("risolate_root_div",TermC.num_str @{thm risolate_root_div}) ],
569 scr = Rule.Prog ((Thm.term_of o the o (TermC.parse thy))
573 (*isolate the bound variable in an equation; 'bdv' is a meta-constant*)
575 Rule.Rls{id = "isolate_bdv", preconds = [], rew_ord = ("e_rew_ord",Rule.e_rew_ord),
576 erls=tval_rls,srls = Rule.e_rls, calc= [], errpatts = [],
578 [Rule.Thm ("risolate_bdv_add",TermC.num_str @{thm risolate_bdv_add}),
579 Rule.Thm ("risolate_bdv_mult_add",TermC.num_str @{thm risolate_bdv_mult_add}),
580 Rule.Thm ("risolate_bdv_mult",TermC.num_str @{thm risolate_bdv_mult}),
581 Rule.Thm ("mult_square",TermC.num_str @{thm mult_square}),
582 Rule.Thm ("constant_square",TermC.num_str @{thm constant_square}),
583 Rule.Thm ("constant_mult_square",TermC.num_str @{thm constant_mult_square})
585 scr = Rule.Prog ((Thm.term_of o the o (TermC.parse thy))
589 ML \<open>val prep_rls' = LTool.prep_rls @{theory};\<close>
590 setup \<open>KEStore_Elems.add_rlss
591 [("Test_simplify", (Context.theory_name @{theory}, prep_rls' Test_simplify)),
592 ("tval_rls", (Context.theory_name @{theory}, prep_rls' tval_rls)),
593 ("isolate_root", (Context.theory_name @{theory}, prep_rls' isolate_root)),
594 ("isolate_bdv", (Context.theory_name @{theory}, prep_rls' isolate_bdv)),
595 ("matches", (Context.theory_name @{theory}, prep_rls'
596 (Rule.append_rls "matches" testerls [Rule.Calc ("Tools.matches", Tools.eval_matches "#matches_")])))]
599 subsection \<open>problems\<close>
600 (** problem types **)
601 setup \<open>KEStore_Elems.add_pbts
602 [(Specify.prep_pbt thy "pbl_test" [] Celem.e_pblID (["test"], [], Rule.e_rls, NONE, [])),
603 (Specify.prep_pbt thy "pbl_test_equ" [] Celem.e_pblID
604 (["equation","test"],
605 [("#Given" ,["equality e_e","solveFor v_v"]),
606 ("#Where" ,["matches (?a = ?b) e_e"]),
607 ("#Find" ,["solutions v_v'i'"])],
608 assoc_rls' @{theory} "matches", SOME "solve (e_e::bool, v_v)", [])),
609 (Specify.prep_pbt thy "pbl_test_uni" [] Celem.e_pblID
610 (["univariate","equation","test"],
611 [("#Given" ,["equality e_e","solveFor v_v"]),
612 ("#Where" ,["matches (?a = ?b) e_e"]),
613 ("#Find" ,["solutions v_v'i'"])],
614 assoc_rls' @{theory} "matches", SOME "solve (e_e::bool, v_v)", [])),
615 (Specify.prep_pbt thy "pbl_test_uni_lin" [] Celem.e_pblID
616 (["LINEAR","univariate","equation","test"],
617 [("#Given" ,["equality e_e","solveFor v_v"]),
618 ("#Where" ,["(matches ( v_v = 0) e_e) | (matches ( ?b*v_v = 0) e_e) |" ^
619 "(matches (?a+v_v = 0) e_e) | (matches (?a+?b*v_v = 0) e_e) "]),
620 ("#Find" ,["solutions v_v'i'"])],
621 assoc_rls' @{theory} "matches",
622 SOME "solve (e_e::bool, v_v)", [["Test","solve_linear"]]))]
625 Rule.rew_ord' := overwritel (! Rule.rew_ord',
626 [("termlessI", termlessI),
627 ("ord_make_polytest", ord_make_polytest false thy)
631 Rule.Rls{id = "make_polytest", preconds = []:term list,
632 rew_ord = ("ord_make_polytest", ord_make_polytest false @{theory "Poly"}),
633 erls = testerls, srls = Rule.Erls,
634 calc = [("PLUS" , ("Groups.plus_class.plus", eval_binop "#add_")),
635 ("TIMES" , ("Groups.times_class.times", eval_binop "#mult_")),
636 ("POWER", ("Atools.pow", eval_binop "#power_"))
638 rules = [Rule.Thm ("real_diff_minus",TermC.num_str @{thm real_diff_minus}),
639 (*"a - b = a + (-1) * b"*)
640 Rule.Thm ("distrib_right" ,TermC.num_str @{thm distrib_right}),
641 (*"(z1.0 + z2.0) * w = z1.0 * w + z2.0 * w"*)
642 Rule.Thm ("distrib_left",TermC.num_str @{thm distrib_left}),
643 (*"w * (z1.0 + z2.0) = w * z1.0 + w * z2.0"*)
644 Rule.Thm ("left_diff_distrib" ,TermC.num_str @{thm left_diff_distrib}),
645 (*"(z1.0 - z2.0) * w = z1.0 * w - z2.0 * w"*)
646 Rule.Thm ("right_diff_distrib",TermC.num_str @{thm right_diff_distrib}),
647 (*"w * (z1.0 - z2.0) = w * z1.0 - w * z2.0"*)
648 Rule.Thm ("mult_1_left",TermC.num_str @{thm mult_1_left}),
650 Rule.Thm ("mult_zero_left",TermC.num_str @{thm mult_zero_left}),
652 Rule.Thm ("add_0_left",TermC.num_str @{thm add_0_left}),
656 Rule.Thm ("mult_commute",TermC.num_str @{thm mult.commute}),
658 Rule.Thm ("real_mult_left_commute",TermC.num_str @{thm real_mult_left_commute}),
659 (*z1.0 * (z2.0 * z3.0) = z2.0 * (z1.0 * z3.0)*)
660 Rule.Thm ("mult_assoc",TermC.num_str @{thm mult.assoc}),
661 (*z1.0 * z2.0 * z3.0 = z1.0 * (z2.0 * z3.0)*)
662 Rule.Thm ("add_commute",TermC.num_str @{thm add.commute}),
664 Rule.Thm ("add_left_commute",TermC.num_str @{thm add.left_commute}),
665 (*x + (y + z) = y + (x + z)*)
666 Rule.Thm ("add_assoc",TermC.num_str @{thm add.assoc}),
667 (*z1.0 + z2.0 + z3.0 = z1.0 + (z2.0 + z3.0)*)
669 Rule.Thm ("sym_realpow_twoI",
670 TermC.num_str (@{thm realpow_twoI} RS @{thm sym})),
671 (*"r1 * r1 = r1 ^^^ 2"*)
672 Rule.Thm ("realpow_plus_1",TermC.num_str @{thm realpow_plus_1}),
673 (*"r * r ^^^ n = r ^^^ (n + 1)"*)
674 Rule.Thm ("sym_real_mult_2",
675 TermC.num_str (@{thm real_mult_2} RS @{thm sym})),
676 (*"z1 + z1 = 2 * z1"*)
677 Rule.Thm ("real_mult_2_assoc",TermC.num_str @{thm real_mult_2_assoc}),
678 (*"z1 + (z1 + k) = 2 * z1 + k"*)
680 Rule.Thm ("real_num_collect",TermC.num_str @{thm real_num_collect}),
681 (*"[| l is_const; m is_const |]==>l * n + m * n = (l + m) * n"*)
682 Rule.Thm ("real_num_collect_assoc",TermC.num_str @{thm real_num_collect_assoc}),
683 (*"[| l is_const; m is_const |] ==>
684 l * n + (m * n + k) = (l + m) * n + k"*)
685 Rule.Thm ("real_one_collect",TermC.num_str @{thm real_one_collect}),
686 (*"m is_const ==> n + m * n = (1 + m) * n"*)
687 Rule.Thm ("real_one_collect_assoc",TermC.num_str @{thm real_one_collect_assoc}),
688 (*"m is_const ==> k + (n + m * n) = k + (1 + m) * n"*)
690 Rule.Calc ("Groups.plus_class.plus", eval_binop "#add_"),
691 Rule.Calc ("Groups.times_class.times", eval_binop "#mult_"),
692 Rule.Calc ("Atools.pow", eval_binop "#power_")
694 scr = Rule.EmptyScr(*Rule.Prog ((Thm.term_of o the o (parse thy))
698 val expand_binomtest =
699 Rule.Rls{id = "expand_binomtest", preconds = [],
700 rew_ord = ("termlessI",termlessI),
701 erls = testerls, srls = Rule.Erls,
702 calc = [("PLUS" , ("Groups.plus_class.plus", eval_binop "#add_")),
703 ("TIMES" , ("Groups.times_class.times", eval_binop "#mult_")),
704 ("POWER", ("Atools.pow", eval_binop "#power_"))
707 [Rule.Thm ("real_plus_binom_pow2" ,TermC.num_str @{thm real_plus_binom_pow2}),
708 (*"(a + b) ^^^ 2 = a ^^^ 2 + 2 * a * b + b ^^^ 2"*)
709 Rule.Thm ("real_plus_binom_times" ,TermC.num_str @{thm real_plus_binom_times}),
710 (*"(a + b)*(a + b) = ...*)
711 Rule.Thm ("real_minus_binom_pow2" ,TermC.num_str @{thm real_minus_binom_pow2}),
712 (*"(a - b) ^^^ 2 = a ^^^ 2 - 2 * a * b + b ^^^ 2"*)
713 Rule.Thm ("real_minus_binom_times",TermC.num_str @{thm real_minus_binom_times}),
714 (*"(a - b)*(a - b) = ...*)
715 Rule.Thm ("real_plus_minus_binom1",TermC.num_str @{thm real_plus_minus_binom1}),
716 (*"(a + b) * (a - b) = a ^^^ 2 - b ^^^ 2"*)
717 Rule.Thm ("real_plus_minus_binom2",TermC.num_str @{thm real_plus_minus_binom2}),
718 (*"(a - b) * (a + b) = a ^^^ 2 - b ^^^ 2"*)
720 Rule.Thm ("real_pp_binom_times",TermC.num_str @{thm real_pp_binom_times}),
721 (*(a + b)*(c + d) = a*c + a*d + b*c + b*d*)
722 Rule.Thm ("real_pm_binom_times",TermC.num_str @{thm real_pm_binom_times}),
723 (*(a + b)*(c - d) = a*c - a*d + b*c - b*d*)
724 Rule.Thm ("real_mp_binom_times",TermC.num_str @{thm real_mp_binom_times}),
725 (*(a - b)*(c p d) = a*c + a*d - b*c - b*d*)
726 Rule.Thm ("real_mm_binom_times",TermC.num_str @{thm real_mm_binom_times}),
727 (*(a - b)*(c p d) = a*c - a*d - b*c + b*d*)
728 Rule.Thm ("realpow_multI",TermC.num_str @{thm realpow_multI}),
729 (*(a*b)^^^n = a^^^n * b^^^n*)
730 Rule.Thm ("real_plus_binom_pow3",TermC.num_str @{thm real_plus_binom_pow3}),
731 (* (a + b)^^^3 = a^^^3 + 3*a^^^2*b + 3*a*b^^^2 + b^^^3 *)
732 Rule.Thm ("real_minus_binom_pow3",TermC.num_str @{thm real_minus_binom_pow3}),
733 (* (a - b)^^^3 = a^^^3 - 3*a^^^2*b + 3*a*b^^^2 - b^^^3 *)
736 (* Rule.Thm ("distrib_right" ,TermC.num_str @{thm distrib_right}),
737 (*"(z1.0 + z2.0) * w = z1.0 * w + z2.0 * w"*)
738 Rule.Thm ("distrib_left",TermC.num_str @{thm distrib_left}),
739 (*"w * (z1.0 + z2.0) = w * z1.0 + w * z2.0"*)
740 Rule.Thm ("left_diff_distrib" ,TermC.num_str @{thm left_diff_distrib}),
741 (*"(z1.0 - z2.0) * w = z1.0 * w - z2.0 * w"*)
742 Rule.Thm ("right_diff_distrib",TermC.num_str @{thm right_diff_distrib}),
743 (*"w * (z1.0 - z2.0) = w * z1.0 - w * z2.0"*)
746 Rule.Thm ("mult_1_left",TermC.num_str @{thm mult_1_left}),
748 Rule.Thm ("mult_zero_left",TermC.num_str @{thm mult_zero_left}),
750 Rule.Thm ("add_0_left",TermC.num_str @{thm add_0_left}),
753 Rule.Calc ("Groups.plus_class.plus", eval_binop "#add_"),
754 Rule.Calc ("Groups.times_class.times", eval_binop "#mult_"),
755 Rule.Calc ("Atools.pow", eval_binop "#power_"),
757 Rule.Thm ("mult_commute",TermC.num_str @{thm mult_commute}),
759 Rule.Thm ("real_mult_left_commute",TermC.num_str @{thm real_mult_left_commute}),
760 Rule.Thm ("mult_assoc",TermC.num_str @{thm mult.assoc}),
761 Rule.Thm ("add_commute",TermC.num_str @{thm add_commute}),
762 Rule.Thm ("add_left_commute",TermC.num_str @{thm add_left_commute}),
763 Rule.Thm ("add_assoc",TermC.num_str @{thm add_assoc}),
766 Rule.Thm ("sym_realpow_twoI",
767 TermC.num_str (@{thm realpow_twoI} RS @{thm sym})),
768 (*"r1 * r1 = r1 ^^^ 2"*)
769 Rule.Thm ("realpow_plus_1",TermC.num_str @{thm realpow_plus_1}),
770 (*"r * r ^^^ n = r ^^^ (n + 1)"*)
771 (*Rule.Thm ("sym_real_mult_2",
772 TermC.num_str (@{thm real_mult_2} RS @{thm sym})),
773 (*"z1 + z1 = 2 * z1"*)*)
774 Rule.Thm ("real_mult_2_assoc",TermC.num_str @{thm real_mult_2_assoc}),
775 (*"z1 + (z1 + k) = 2 * z1 + k"*)
777 Rule.Thm ("real_num_collect",TermC.num_str @{thm real_num_collect}),
778 (*"[| l is_const; m is_const |] ==> l * n + m * n = (l + m) * n"*)
779 Rule.Thm ("real_num_collect_assoc",TermC.num_str @{thm real_num_collect_assoc}),
780 (*"[| l is_const; m is_const |] ==> l * n + (m * n + k) = (l + m) * n + k"*)
781 Rule.Thm ("real_one_collect",TermC.num_str @{thm real_one_collect}),
782 (*"m is_const ==> n + m * n = (1 + m) * n"*)
783 Rule.Thm ("real_one_collect_assoc",TermC.num_str @{thm real_one_collect_assoc}),
784 (*"m is_const ==> k + (n + m * n) = k + (1 + m) * n"*)
786 Rule.Calc ("Groups.plus_class.plus", eval_binop "#add_"),
787 Rule.Calc ("Groups.times_class.times", eval_binop "#mult_"),
788 Rule.Calc ("Atools.pow", eval_binop "#power_")
791 (*Script ((Thm.term_of o the o (parse thy)) scr_expand_binomtest)*)
794 setup \<open>KEStore_Elems.add_rlss
795 [("make_polytest", (Context.theory_name @{theory}, prep_rls' make_polytest)),
796 ("expand_binomtest", (Context.theory_name @{theory}, prep_rls' expand_binomtest))]\<close>
797 setup \<open>KEStore_Elems.add_rlss
798 [("norm_equation", (Context.theory_name @{theory}, prep_rls' norm_equation)),
799 ("ac_plus_times", (Context.theory_name @{theory}, prep_rls' ac_plus_times)),
800 ("rearrange_assoc", (Context.theory_name @{theory}, prep_rls' rearrange_assoc))]\<close>
802 section \<open>problems\<close>
803 setup \<open>KEStore_Elems.add_pbts
804 [(Specify.prep_pbt thy "pbl_test_uni_plain2" [] Celem.e_pblID
805 (["plain_square","univariate","equation","test"],
806 [("#Given" ,["equality e_e","solveFor v_v"]),
807 ("#Where" ,["(matches (?a + ?b*v_v ^^^2 = 0) e_e) |" ^
808 "(matches ( ?b*v_v ^^^2 = 0) e_e) |" ^
809 "(matches (?a + v_v ^^^2 = 0) e_e) |" ^
810 "(matches ( v_v ^^^2 = 0) e_e)"]),
811 ("#Find" ,["solutions v_v'i'"])],
812 assoc_rls' @{theory} "matches",
813 SOME "solve (e_e::bool, v_v)", [["Test","solve_plain_square"]])),
814 (Specify.prep_pbt thy "pbl_test_uni_poly" [] Celem.e_pblID
815 (["polynomial","univariate","equation","test"],
816 [("#Given" ,["equality (v_v ^^^2 + p_p * v_v + q__q = 0)","solveFor v_v"]),
817 ("#Where" ,["HOL.False"]),
818 ("#Find" ,["solutions v_v'i'"])],
819 Rule.e_rls, SOME "solve (e_e::bool, v_v)", [])),
820 (Specify.prep_pbt thy "pbl_test_uni_poly_deg2" [] Celem.e_pblID
821 (["degree_two","polynomial","univariate","equation","test"],
822 [("#Given" ,["equality (v_v ^^^2 + p_p * v_v + q__q = 0)","solveFor v_v"]),
823 ("#Find" ,["solutions v_v'i'"])],
824 Rule.e_rls, SOME "solve (v_v ^^^2 + p_p * v_v + q__q = 0, v_v)", [])),
825 (Specify.prep_pbt thy "pbl_test_uni_poly_deg2_pq" [] Celem.e_pblID
826 (["pq_formula","degree_two","polynomial","univariate","equation","test"],
827 [("#Given" ,["equality (v_v ^^^2 + p_p * v_v + q__q = 0)","solveFor v_v"]),
828 ("#Find" ,["solutions v_v'i'"])],
829 Rule.e_rls, SOME "solve (v_v ^^^2 + p_p * v_v + q__q = 0, v_v)", [])),
830 (Specify.prep_pbt thy "pbl_test_uni_poly_deg2_abc" [] Celem.e_pblID
831 (["abc_formula","degree_two","polynomial","univariate","equation","test"],
832 [("#Given" ,["equality (a_a * x ^^^2 + b_b * x + c_c = 0)","solveFor v_v"]),
833 ("#Find" ,["solutions v_v'i'"])],
834 Rule.e_rls, SOME "solve (a_a * x ^^^2 + b_b * x + c_c = 0, v_v)", [])),
835 (Specify.prep_pbt thy "pbl_test_uni_root" [] Celem.e_pblID
836 (["squareroot","univariate","equation","test"],
837 [("#Given" ,["equality e_e","solveFor v_v"]),
838 ("#Where" ,["precond_rootpbl v_v"]),
839 ("#Find" ,["solutions v_v'i'"])],
840 Rule.append_rls "contains_root" Rule.e_rls [Rule.Calc ("Test.contains'_root",
841 eval_contains_root "#contains_root_")],
842 SOME "solve (e_e::bool, v_v)", [["Test","square_equation"]])),
843 (Specify.prep_pbt thy "pbl_test_uni_norm" [] Celem.e_pblID
844 (["normalise","univariate","equation","test"],
845 [("#Given" ,["equality e_e","solveFor v_v"]),
847 ("#Find" ,["solutions v_v'i'"])],
848 Rule.e_rls, SOME "solve (e_e::bool, v_v)", [["Test","norm_univar_equation"]])),
849 (Specify.prep_pbt thy "pbl_test_uni_roottest" [] Celem.e_pblID
850 (["sqroot-test","univariate","equation","test"],
851 [("#Given" ,["equality e_e","solveFor v_v"]),
852 ("#Where" ,["precond_rootpbl v_v"]),
853 ("#Find" ,["solutions v_v'i'"])],
854 Rule.e_rls, SOME "solve (e_e::bool, v_v)", [])),
855 (Specify.prep_pbt thy "pbl_test_intsimp" [] Celem.e_pblID
857 [("#Given" ,["intTestGiven t_t"]),
859 ("#Find" ,["intTestFind s_s"])],
860 Rule.e_rls, NONE, [["Test","intsimp"]]))]\<close>
862 section \<open>methods\<close>
863 subsection \<open>differentiate\<close>
864 setup \<open>KEStore_Elems.add_mets
865 [Specify.prep_met @{theory "Diff"} "met_test" [] Celem.e_metID
867 {rew_ord'="tless_true",rls'=Atools_erls,calc = [], srls = Rule.e_rls, prls=Rule.e_rls,
868 crls=Atools_erls, errpats = [], nrls = Rule.e_rls}, "empty_script")]
870 partial_function (tailrec) solve_linear :: "bool \<Rightarrow> real \<Rightarrow> bool list"
872 "solve_linear e_e v_v =
875 (((Rewrite_Set_Inst [(''bdv'', v_v)] ''isolate_bdv'' False) @@
876 (Rewrite_Set ''Test_simplify'' False))) e_e
878 setup \<open>KEStore_Elems.add_mets
879 [Specify.prep_met thy "met_test_solvelin" [] Celem.e_metID
880 (["Test","solve_linear"],
881 [("#Given" ,["equality e_e","solveFor v_v"]),
882 ("#Where" ,["matches (?a = ?b) e_e"]),
883 ("#Find" ,["solutions v_v'i'"])],
884 {rew_ord' = "e_rew_ord", rls' = tval_rls, srls = Rule.e_rls,
885 prls = assoc_rls' @{theory} "matches", calc = [], crls = tval_rls, errpats = [],
886 nrls = Test_simplify},
887 "Script Solve_linear (e_e::bool) (v_v::real)= " ^
890 " (((Rewrite_Set_Inst [(''bdv'',v_v::real)] ''isolate_bdv'' False) @@ " ^
891 " (Rewrite_Set ''Test_simplify'' False))) e_e" ^
894 subsection \<open>root equation\<close>
895 partial_function (tailrec) solve_root_equ :: "bool \<Rightarrow> real \<Rightarrow> bool list"
897 "solve_root_equ e_e v_v =
899 ((While (contains_root e_e) Do
900 ((Rewrite ''square_equation_left'' True) @@
901 (Try (Rewrite_Set ''Test_simplify'' False)) @@
902 (Try (Rewrite_Set ''rearrange_assoc'' False)) @@
903 (Try (Rewrite_Set ''isolate_root'' False)) @@
904 (Try (Rewrite_Set ''Test_simplify'' False)))) @@
905 (Try (Rewrite_Set ''norm_equation'' False)) @@
906 (Try (Rewrite_Set ''Test_simplify'' False)) @@
907 (Rewrite_Set_Inst [(''bdv'', v_v)] ''isolate_bdv'' False) @@
908 (Try (Rewrite_Set ''Test_simplify'' False))) e_e
910 setup \<open>KEStore_Elems.add_mets
911 [Specify.prep_met thy "met_test_sqrt" [] Celem.e_metID
912 (*root-equation, version for tests before 8.01.01*)
913 (["Test","sqrt-equ-test"],
914 [("#Given" ,["equality e_e","solveFor v_v"]),
915 ("#Where" ,["contains_root (e_e::bool)"]),
916 ("#Find" ,["solutions v_v'i'"])],
917 {rew_ord'="e_rew_ord",rls'=tval_rls,
918 srls = Rule.append_rls "srls_contains_root" Rule.e_rls
919 [Rule.Calc ("Test.contains'_root",eval_contains_root "")],
920 prls = Rule.append_rls "prls_contains_root" Rule.e_rls
921 [Rule.Calc ("Test.contains'_root",eval_contains_root "")],
922 calc=[], crls=tval_rls, errpats = [], nrls = Rule.e_rls (*,asm_rls=[],
923 asm_thm=[("square_equation_left",""), ("square_equation_right","")]*)},
924 "Script Solve_root_equation (e_e::bool) (v_v::real) = " ^
926 " ((While (contains_root e_e) Do" ^
927 " ((Rewrite ''square_equation_left'' True) @@" ^
928 " (Try (Rewrite_Set ''Test_simplify'' False)) @@" ^
929 " (Try (Rewrite_Set ''rearrange_assoc'' False)) @@" ^
930 " (Try (Rewrite_Set ''isolate_root'' False)) @@" ^
931 " (Try (Rewrite_Set ''Test_simplify'' False)))) @@" ^
932 " (Try (Rewrite_Set ''norm_equation'' False)) @@" ^
933 " (Try (Rewrite_Set ''Test_simplify'' False)) @@" ^
934 " (Rewrite_Set_Inst [(''bdv'',v_v::real)] ''isolate_bdv'' False) @@" ^
935 " (Try (Rewrite_Set ''Test_simplify'' False)))" ^
940 partial_function (tailrec) solve_root_equ2 :: "bool \<Rightarrow> real \<Rightarrow> bool list"
941 where "solve_root_equ e_e v_v =
943 ((While (contains_root e_e) Do
944 ((Rewrite ''square_equation_left'' True) @@
945 (Try (Rewrite_Set ''Test_simplify'' False)) @@
946 (Try (Rewrite_Set ''rearrange_assoc'' False)) @@
947 (Try (Rewrite_Set ''isolate_root'' False)) @@
948 (Try (Rewrite_Set ''Test_simplify'' False)))) @@
949 (Try (Rewrite_Set ''norm_equation'' False)) @@
950 (Try (Rewrite_Set ''Test_simplify'' False)) @@
951 (Rewrite_Set_Inst [(''bdv'',v_v::real)] ''isolate_bdv'' False) @@
952 (Try (Rewrite_Set ''Test_simplify'' False)))
954 (L_L::bool list) = Tac ''subproblem_equation_dummy'';
955 L_L = Tac ''solve_equation_dummy''
956 in Check_elementwise L_L {(v_v::real). Assumptions}) "
957 setup \<open>KEStore_Elems.add_mets
958 [Specify.prep_met thy "met_test_sqrt2" [] Celem.e_metID
959 (*root-equation ... for test-*.sml until 8.01*)
960 (["Test","squ-equ-test2"],
961 [("#Given" ,["equality e_e","solveFor v_v"]),
962 ("#Find" ,["solutions v_v'i'"])],
963 {rew_ord'="e_rew_ord",rls'=tval_rls,
964 srls = Rule.append_rls "srls_contains_root" Rule.e_rls
965 [Rule.Calc ("Test.contains'_root",eval_contains_root"")],
966 prls=Rule.e_rls,calc=[], crls=tval_rls, errpats = [], nrls = Rule.e_rls(*,asm_rls=[],
967 asm_thm=[("square_equation_left",""), ("square_equation_right","")]*)},
968 "Script Solve_root_equation (e_e::bool) (v_v::real) = " ^
970 " ((While (contains_root e_e) Do" ^
971 " ((Rewrite ''square_equation_left'' True) @@" ^
972 " (Try (Rewrite_Set ''Test_simplify'' False)) @@" ^
973 " (Try (Rewrite_Set ''rearrange_assoc'' False)) @@" ^
974 " (Try (Rewrite_Set ''isolate_root'' False)) @@" ^
975 " (Try (Rewrite_Set ''Test_simplify'' False)))) @@" ^
976 " (Try (Rewrite_Set ''norm_equation'' False)) @@" ^
977 " (Try (Rewrite_Set ''Test_simplify'' False)) @@" ^
978 " (Rewrite_Set_Inst [(''bdv'',v_v::real)] ''isolate_bdv'' False) @@" ^
979 " (Try (Rewrite_Set ''Test_simplify'' False)))" ^
981 " (L_L::bool list) = Tac subproblem_equation_dummy; " ^
982 " L_L = Tac solve_equation_dummy " ^
983 " in Check_elementwise L_L {(v_v::real). Assumptions})")]
987 partial_function (tailrec) solve_root_equation ::
988 "bool \<Rightarrow> real \<Rightarrow> bool list"
989 where "minisubpbl e_e v_v =
990 (let e_e = ((Try (Rewrite_Set ''norm_equation'' False)) @@
991 (Try (Rewrite_Set ''Test_simplify'' False))) e_e;
993 SubProblem (''TestX'', [''LINEAR'', ''univariate'', ''equation'', ''test''],
994 [''Test'', ''solve_linear'']) [BOOL e_e, REAL v_v]
995 in Check_elementwise L_L {(v_v::real). Assumptions})"
997 (* ^^^used for test/../Minisubpbl/
998 # difference between partial_function above and Script below:
999 "Solve_root_equation" is a constant, which is NOT accepted by partial_function
1001 # differences between original "Solve_root_equation" and the version below:
1002 (1) the program name, see note above
1003 (2) the first argument of SubProblem: ''Test''' is NOT accepted by partial_function,
1004 thus previous change-set Test' \<longrightarrow> TestX
1005 ''Test'#TODO#''. Note: this change is NOT recognised by Interpret!
1007 setup \<open>KEStore_Elems.add_mets
1008 [Specify.prep_met thy "met_test_squ_sub" [] Celem.e_metID
1009 (*tests subproblem fixed linear*)
1010 (["Test","squ-equ-test-subpbl1"],
1011 [("#Given" ,["equality e_e","solveFor v_v"]),
1012 ("#Where" ,["precond_rootmet v_v"]),
1013 ("#Find" ,["solutions v_v'i'"])],
1014 {rew_ord' = "e_rew_ord", rls' = tval_rls, srls = Rule.e_rls,
1015 prls = Rule.append_rls "prls_met_test_squ_sub" Rule.e_rls
1016 [Rule.Calc ("Test.precond'_rootmet", eval_precond_rootmet "")],
1017 calc=[], crls=tval_rls, errpats = [], nrls = Test_simplify},
1018 "Script Solve_root_equation (e_e::bool) (v_v::real) = " ^
1019 " (let e_e = ((Try (Rewrite_Set ''norm_equation'' False)) @@ " ^
1020 " (Try (Rewrite_Set ''Test_simplify'' False))) e_e; " ^
1021 " (L_L::bool list) = " ^
1022 " (SubProblem (''Test'', " ^
1023 " [''LINEAR'', ''univariate'', ''equation'', ''test''], " ^
1024 " [''Test'', ''solve_linear'']) " ^
1025 " [BOOL e_e, REAL v_v]) " ^
1026 " in Check_elementwise L_L {(v_v::real). Assumptions}) ")]
1028 partial_function (tailrec) solve_root_equ2 :: "bool \<Rightarrow> real \<Rightarrow> bool list"
1029 where "solve_root_equ e_e v_v =
1031 ((While (contains_root e_e) Do
1032 ((Rewrite ''square_equation_left'' True) @@
1033 (Try (Rewrite_Set ''Test_simplify'' False)) @@
1034 (Try (Rewrite_Set ''rearrange_assoc'' False)) @@
1035 (Try (Rewrite_Set ''isolate_root'' False)) @@
1036 (Try (Rewrite_Set ''Test_simplify'' False)))) @@
1037 (Try (Rewrite_Set ''norm_equation'' False)) @@
1038 (Try (Rewrite_Set ''Test_simplify'' False))) e_e;
1039 L_L = SubProblem (''Test'', [''LINEAR'', ''univariate'', ''equation'', ''test''],
1040 [''Test'', ''solve_linear'']) [BOOL e_e, REAL v_v]
1041 in Check_elementwise L_L {(v_v::real). Assumptions}) "
1042 setup \<open>KEStore_Elems.add_mets
1043 [Specify.prep_met thy "met_test_eq1" [] Celem.e_metID
1045 (["Test","square_equation1"],
1046 [("#Given" ,["equality e_e","solveFor v_v"]),
1047 ("#Find" ,["solutions v_v'i'"])],
1048 {rew_ord'="e_rew_ord",rls'=tval_rls,
1049 srls = Rule.append_rls "srls_contains_root" Rule.e_rls
1050 [Rule.Calc ("Test.contains'_root",eval_contains_root"")], prls=Rule.e_rls, calc=[], crls=tval_rls,
1051 errpats = [], nrls = Rule.e_rls(*,asm_rls=[], asm_thm=[("square_equation_left",""),
1052 ("square_equation_right","")]*)},
1053 "Script Solve_root_equation (e_e::bool) (v_v::real) = " ^
1055 " ((While (contains_root e_e) Do" ^
1056 " ((Rewrite ''square_equation_left'' True) @@" ^
1057 " (Try (Rewrite_Set ''Test_simplify'' False)) @@" ^
1058 " (Try (Rewrite_Set ''rearrange_assoc'' False)) @@" ^
1059 " (Try (Rewrite_Set ''isolate_root'' False)) @@" ^
1060 " (Try (Rewrite_Set ''Test_simplify'' False)))) @@" ^
1061 " (Try (Rewrite_Set ''norm_equation'' False)) @@" ^
1062 " (Try (Rewrite_Set ''Test_simplify'' False)))" ^
1064 " (L_L::bool list) = (SubProblem (''Test'',[''LINEAR'',''univariate'',''equation'',''test'']," ^
1065 " [''Test'',''solve_linear'']) [BOOL e_e, REAL v_v])" ^
1066 " in Check_elementwise L_L {(v_v::real). Assumptions})")]
1068 partial_function (tailrec) solve_root_equ3 :: "bool \<Rightarrow> real \<Rightarrow> bool list"
1070 "solve_root_equ e_e v_v =
1072 ((While (contains_root e_e) Do
1073 (((Rewrite ''square_equation_left'' True) Or
1074 (Rewrite ''square_equation_right'' True)) @@
1075 (Try (Rewrite_Set ''Test_simplify'' False)) @@
1076 (Try (Rewrite_Set ''rearrange_assoc'' False)) @@
1077 (Try (Rewrite_Set ''isolate_root'' False)) @@
1078 (Try (Rewrite_Set ''Test_simplify'' False)))) @@
1079 (Try (Rewrite_Set ''norm_equation'' False)) @@
1080 (Try (Rewrite_Set ''Test_simplify'' False))) e_e;
1081 L_L = SubProblem (''Test'', [''plain_square'', ''univariate'', ''equation'', ''test''],
1082 [''Test'', ''solve_plain_square'']) [BOOL e_e, REAL v_v]
1083 in Check_elementwise L_L {(v_v::real). Assumptions})"
1084 setup \<open>KEStore_Elems.add_mets
1085 [Specify.prep_met thy "met_test_squ2" [] Celem.e_metID
1087 (["Test","square_equation2"],
1088 [("#Given" ,["equality e_e","solveFor v_v"]),
1089 ("#Find" ,["solutions v_v'i'"])],
1090 {rew_ord'="e_rew_ord",rls'=tval_rls,
1091 srls = Rule.append_rls "srls_contains_root" Rule.e_rls
1092 [Rule.Calc ("Test.contains'_root",eval_contains_root"")],
1093 prls=Rule.e_rls,calc=[], crls=tval_rls, errpats = [], nrls = Rule.e_rls(*,asm_rls=[],
1094 asm_thm=[("square_equation_left",""), ("square_equation_right","")]*)},
1095 "Script Solve_root_equation (e_e::bool) (v_v::real) = " ^
1097 " ((While (contains_root e_e) Do" ^
1098 " (((Rewrite ''square_equation_left'' True) Or " ^
1099 " (Rewrite ''square_equation_right'' True)) @@" ^
1100 " (Try (Rewrite_Set ''Test_simplify'' False)) @@" ^
1101 " (Try (Rewrite_Set ''rearrange_assoc'' False)) @@" ^
1102 " (Try (Rewrite_Set ''isolate_root'' False)) @@" ^
1103 " (Try (Rewrite_Set ''Test_simplify'' False)))) @@" ^
1104 " (Try (Rewrite_Set ''norm_equation'' False)) @@" ^
1105 " (Try (Rewrite_Set ''Test_simplify'' False)))" ^
1107 " (L_L::bool list) = (SubProblem (''Test'',[''plain_square'',''univariate'',''equation'',''test'']," ^
1108 " [''Test'',''solve_plain_square'']) [BOOL e_e, REAL v_v])" ^
1109 " in Check_elementwise L_L {(v_v::real). Assumptions})")]
1111 partial_function (tailrec) solve_root_equ4 :: "bool \<Rightarrow> real \<Rightarrow> bool list"
1113 "solve_root_equ e_e v_v =
1115 ((While (contains_root e_e) Do
1116 (((Rewrite ''square_equation_left'' True) Or
1117 (Rewrite ''square_equation_right'' True)) @@
1118 (Try (Rewrite_Set ''Test_simplify'' False)) @@
1119 (Try (Rewrite_Set ''rearrange_assoc'' False)) @@
1120 (Try (Rewrite_Set ''isolate_root'' False)) @@
1121 (Try (Rewrite_Set ''Test_simplify'' False)))) @@
1122 (Try (Rewrite_Set ''norm_equation'' False)) @@
1123 (Try (Rewrite_Set ''Test_simplify'' False))) e_e;
1124 L_L = SubProblem (''Test'', [''univariate'', ''equation'', ''test''],
1125 [''no_met'']) [BOOL e_e, REAL v_v]
1126 in Check_elementwise L_L {(v_v::real). Assumptions})"
1127 setup \<open>KEStore_Elems.add_mets
1128 [Specify.prep_met thy "met_test_squeq" [] Celem.e_metID
1130 (["Test","square_equation"],
1131 [("#Given" ,["equality e_e","solveFor v_v"]),
1132 ("#Find" ,["solutions v_v'i'"])],
1133 {rew_ord'="e_rew_ord",rls'=tval_rls,
1134 srls = Rule.append_rls "srls_contains_root" Rule.e_rls
1135 [Rule.Calc ("Test.contains'_root",eval_contains_root"")],
1136 prls=Rule.e_rls,calc=[], crls=tval_rls, errpats = [], nrls = Rule.e_rls (*,asm_rls=[],
1137 asm_thm=[("square_equation_left",""), ("square_equation_right","")]*)},
1138 "Script Solve_root_equation (e_e::bool) (v_v::real) = " ^
1140 " ((While (contains_root e_e) Do" ^
1141 " (((Rewrite ''square_equation_left'' True) Or" ^
1142 " (Rewrite ''square_equation_right'' True)) @@" ^
1143 " (Try (Rewrite_Set ''Test_simplify'' False)) @@" ^
1144 " (Try (Rewrite_Set ''rearrange_assoc'' False)) @@" ^
1145 " (Try (Rewrite_Set ''isolate_root'' False)) @@" ^
1146 " (Try (Rewrite_Set ''Test_simplify'' False)))) @@" ^
1147 " (Try (Rewrite_Set ''norm_equation'' False)) @@" ^
1148 " (Try (Rewrite_Set ''Test_simplify'' False)))" ^
1150 " (L_L::bool list) = (SubProblem (''Test'',[''univariate'',''equation'',''test'']," ^
1151 " [''no_met'']) [BOOL e_e, REAL v_v])" ^
1152 " in Check_elementwise L_L {(v_v::real). Assumptions})")]
1154 partial_function (tailrec) solve_plain_square :: "bool \<Rightarrow> real \<Rightarrow> bool list"
1156 "solve_plain_square e_e v_v =
1157 (let e_e = ((Try (Rewrite_Set ''isolate_bdv'' False)) @@
1158 (Try (Rewrite_Set ''Test_simplify'' False)) @@
1159 ((Rewrite ''square_equality_0'' False) Or
1160 (Rewrite ''square_equality'' True)) @@
1161 (Try (Rewrite_Set ''tval_rls'' False))) e_e
1163 setup \<open>KEStore_Elems.add_mets
1164 [Specify.prep_met thy "met_test_eq_plain" [] Celem.e_metID
1165 (*solve_plain_square*)
1166 (["Test","solve_plain_square"],
1167 [("#Given",["equality e_e","solveFor v_v"]),
1168 ("#Where" ,["(matches (?a + ?b*v_v ^^^2 = 0) e_e) |" ^
1169 "(matches ( ?b*v_v ^^^2 = 0) e_e) |" ^
1170 "(matches (?a + v_v ^^^2 = 0) e_e) |" ^
1171 "(matches ( v_v ^^^2 = 0) e_e)"]),
1172 ("#Find" ,["solutions v_v'i'"])],
1173 {rew_ord'="e_rew_ord",rls'=tval_rls,calc=[],srls=Rule.e_rls,
1174 prls = assoc_rls' @{theory} "matches", crls=tval_rls, errpats = [], nrls = Rule.e_rls(*,
1175 asm_rls=[],asm_thm=[]*)},
1176 "Script Solve_plain_square (e_e::bool) (v_v::real) = " ^
1177 " (let e_e = ((Try (Rewrite_Set ''isolate_bdv'' False)) @@ " ^
1178 " (Try (Rewrite_Set ''Test_simplify'' False)) @@ " ^
1179 " ((Rewrite ''square_equality_0'' False) Or " ^
1180 " (Rewrite ''square_equality'' True)) @@ " ^
1181 " (Try (Rewrite_Set ''tval_rls'' False))) e_e " ^
1182 " in ((Or_to_List e_e)::bool list))")]
1184 subsection \<open>polynomial equation\<close>
1185 partial_function (tailrec) norm_univariate_equ :: "bool \<Rightarrow> real \<Rightarrow> bool list"
1187 "norm_univariate_equ e_e v_v =
1188 (let e_e = ((Try (Rewrite ''rnorm_equation_add'' False)) @@
1189 (Try (Rewrite_Set ''Test_simplify'' False))) e_e
1190 in SubProblem (''Test'', [''univariate'', ''equation'', ''test''],
1191 [''no_met'']) [BOOL e_e, REAL v_v])"
1192 setup \<open>KEStore_Elems.add_mets
1193 [Specify.prep_met thy "met_test_norm_univ" [] Celem.e_metID
1194 (["Test","norm_univar_equation"],
1195 [("#Given",["equality e_e","solveFor v_v"]),
1197 ("#Find" ,["solutions v_v'i'"])],
1198 {rew_ord'="e_rew_ord",rls'=tval_rls,srls = Rule.e_rls,prls=Rule.e_rls, calc=[], crls=tval_rls,
1199 errpats = [], nrls = Rule.e_rls},
1200 "Script Norm_univar_equation (e_e::bool) (v_v::real) = " ^
1201 " (let e_e = ((Try (Rewrite ''rnorm_equation_add'' False)) @@ " ^
1202 " (Try (Rewrite_Set ''Test_simplify'' False))) e_e " ^
1203 " in (SubProblem (''Test'',[''univariate'',''equation'',''test''], " ^
1204 " [''no_met'']) [BOOL e_e, REAL v_v]))")]
1206 subsection \<open>diophantine equation\<close>
1207 partial_function (tailrec) test_simplify :: "int \<Rightarrow> int"
1209 "test_simplify t_t =
1211 ((Try (Calculate ''PLUS'')) @@
1212 (Try (Calculate ''TIMES''))) t_t)"
1213 setup \<open>KEStore_Elems.add_mets
1214 [Specify.prep_met thy "met_test_intsimp" [] Celem.e_metID
1215 (["Test","intsimp"],
1216 [("#Given" ,["intTestGiven t_t"]),
1218 ("#Find" ,["intTestFind s_s"])],
1219 {rew_ord' = "e_rew_ord", rls' = tval_rls, srls = Rule.e_rls, prls = Rule.e_rls, calc = [],
1220 crls = tval_rls, errpats = [], nrls = Test_simplify},
1221 "Script STest_simplify (t_t::int) = " ^
1223 " ((Try (Calculate ''PLUS'')) @@ " ^
1224 " (Try (Calculate ''TIMES''))) t_t::int)")]