1 (* equational systems, minimal -- for use in Biegelinie
4 (c) due to copyright terms
7 theory EqSystem imports Integrate Rational Root begin
12 "[real list, real list, 'a] => bool" ("_ from'_ _ occur'_exactly'_in _")
14 (*descriptions in the related problems*)
15 solveForVars :: "real list => toreall"
16 solution :: "bool list => toreall"
18 (*the CAS-command, eg. "solveSystem [x+y=1,y=2] [x,y]"*)
19 solveSystem :: "[bool list, real list] => bool list"
22 SolveSystemScript :: "[bool list, real list, bool list]
24 ("((Script SolveSystemScript (_ _ =))// (_))" 9)
27 (*stated as axioms, todo: prove as theorems
28 'bdv' is a constant handled on the meta-level
29 specifically as a 'bound variable' *)
31 commute_0_equality: "(0 = a) = (a = 0)"
33 (*WN0510 see simliar rules 'isolate_' 'separate_' (by RL)
34 [bdv_1,bdv_2,bdv_3,bdv_4] work also for 2 and 3 bdvs, ugly !*)
36 "[| [] from_ [bdv_1,bdv_2,bdv_3,bdv_4] occur_exactly_in a |]
37 ==> (a + b = c) = (b = c + -1*a)"
39 "[| some_of [bdv_1,bdv_2,bdv_3,bdv_4] occur_in b; Not (b=!=0) |]
40 ==> (a = b) = (a + -1*b = 0)"
42 "[| some_of [bdv_1,bdv_2,bdv_3,bdv_4] occur_in c |]
43 ==> (a = b + c) = (a + -1*c = b)"
45 "[| Not (some_of [bdv_1,bdv_2,bdv_3,bdv_4] occur_in a) |]
46 ==> (a + b = c) = (b = -1*a + c)"
51 "[| [] from_ [bdv_1,bdv_2,bdv_3,bdv_4] occur_exactly_in a; Not (a=!=0) |]
52 ==>(a * b = c) = (b = c / a)"
54 (*requires rew_ord for termination, eg. ord_simplify_Integral;
55 works for lists of any length, interestingly !?!*)
56 order_system_NxN: "[a,b] = [b,a]"
61 (** eval functions **)
63 (*certain variables of a given list occur _all_ in a term
64 args: all: ..variables, which are under consideration (eg. the bound vars)
65 vs: variables which must be in t,
66 and none of the others in all must be in t
67 t: the term under consideration
69 fun occur_exactly_in vs all t =
70 let fun occurs_in' a b = occurs_in b a
71 in foldl and_ (true, map (occurs_in' t) vs)
72 andalso not (foldl or_ (false, map (occurs_in' t)
73 (subtract op = vs all)))
76 (*("occur_exactly_in", ("EqSystem.occur'_exactly'_in",
77 eval_occur_exactly_in "#eval_occur_exactly_in_"))*)
78 fun eval_occur_exactly_in _ "EqSystem.occur'_exactly'_in"
79 (p as (Const ("EqSystem.occur'_exactly'_in",_)
81 if occur_exactly_in (isalist2list vs) (isalist2list all) t
82 then SOME ((term2str p) ^ " = True",
83 Trueprop $ (mk_equality (p, HOLogic.true_const)))
84 else SOME ((term2str p) ^ " = False",
85 Trueprop $ (mk_equality (p, HOLogic.false_const)))
86 | eval_occur_exactly_in _ _ _ _ = NONE;
89 overwritel (!calclist',
91 ("EqSystem.occur'_exactly'_in",
92 eval_occur_exactly_in "#eval_occur_exactly_in_"))
96 (** rewrite order 'ord_simplify_System' **)
98 (* order wrt. several linear (i.e. without exponents) variables "c","c_2",..
99 which leaves the monomials containing c, c_2,... at the end of an Integral
100 and puts the c, c_2,... rightmost within a monomial.
102 WN050906 this is a quick and dirty adaption of ord_make_polynomial_in,
103 which was most adequate, because it uses size_of_term*)
105 local (*. for simplify_System .*)
107 open Term; (* for type order = EQUAL | LESS | GREATER *)
109 fun pr_ord EQUAL = "EQUAL"
110 | pr_ord LESS = "LESS"
111 | pr_ord GREATER = "GREATER";
113 fun dest_hd' (Const (a, T)) = (((a, 0), T), 0)
114 | dest_hd' (Free (ccc, T)) =
116 "c"::[] => ((("|||||||||||||||||||||", 0), T), 1)(*greatest string WN*)
117 | "c"::"_"::_ => ((("|||||||||||||||||||||", 0), T), 1)
118 | _ => (((ccc, 0), T), 1))
119 | dest_hd' (Var v) = (v, 2)
120 | dest_hd' (Bound i) = ((("", i), dummyT), 3)
121 | dest_hd' (Abs (_, T, _)) = ((("", 0), T), 4);
123 fun size_of_term' (Free (ccc, _)) =
124 (case explode ccc of (*WN0510 hack for the bound variables*)
126 | "c"::"_"::is => 1000 * ((str2int o implode) is)
128 | size_of_term' (Abs (_,_,body)) = 1 + size_of_term' body
129 | size_of_term' (f$t) = size_of_term' f + size_of_term' t
130 | size_of_term' _ = 1;
132 fun term_ord' pr thy (Abs (_, T, t), Abs(_, U, u)) = (* ~ term.ML *)
133 (case term_ord' pr thy (t, u) of EQUAL => Term_Ord.typ_ord (T, U) | ord => ord)
134 | term_ord' pr thy (t, u) =
137 val (f, ts) = strip_comb t and (g, us) = strip_comb u;
138 val _=writeln("t= f@ts= \""^
139 ((Syntax.string_of_term (thy2ctxt thy)) f)^"\" @ \"["^
140 (commas(map(Syntax.string_of_term (thy2ctxt thy)) ts))^"]\"");
141 val _=writeln("u= g@us= \""^
142 ((Syntax.string_of_term (thy2ctxt thy)) g)^"\" @ \"["^
143 (commas(map(Syntax.string_of_term (thy2ctxt thy)) us))^"]\"");
144 val _=writeln("size_of_term(t,u)= ("^
145 (string_of_int(size_of_term' t))^", "^
146 (string_of_int(size_of_term' u))^")");
147 val _=writeln("hd_ord(f,g) = "^((pr_ord o hd_ord)(f,g)));
148 val _=writeln("terms_ord(ts,us) = "^
149 ((pr_ord o terms_ord str false)(ts,us)));
150 val _=writeln("-------");
153 case int_ord (size_of_term' t, size_of_term' u) of
155 let val (f, ts) = strip_comb t and (g, us) = strip_comb u in
156 (case hd_ord (f, g) of EQUAL => (terms_ord str pr) (ts, us)
160 and hd_ord (f, g) = (* ~ term.ML *)
161 prod_ord (prod_ord Term_Ord.indexname_ord Term_Ord.typ_ord) int_ord (dest_hd' f,
163 and terms_ord str pr (ts, us) =
164 list_ord (term_ord' pr (assoc_thy "Isac"))(ts, us);
168 (*WN0510 for preliminary use in eval_order_system, see case-study mat-eng.tex
169 fun ord_simplify_System_rev (pr:bool) thy subst tu =
170 (term_ord' pr thy (Library.swap tu) = LESS);*)
173 fun ord_simplify_System (pr:bool) thy subst tu =
174 (term_ord' pr thy tu = LESS);
178 rew_ord' := overwritel (!rew_ord',
179 [("ord_simplify_System", ord_simplify_System false thy)
185 (*.adapted from 'order_add_mult_in' by just replacing the rew_ord.*)
186 val order_add_mult_System =
187 Rls{id = "order_add_mult_System", preconds = [],
188 rew_ord = ("ord_simplify_System",
189 ord_simplify_System false (theory "Integrate")),
190 erls = e_rls,srls = Erls, calc = [],
191 rules = [Thm ("real_mult_commute",num_str @{thm real_mult_commute}),
193 Thm ("real_mult_left_commute",num_str @{thm real_mult_left_commute}),
194 (*z1.0 * (z2.0 * z3.0) = z2.0 * (z1.0 * z3.0)*)
195 Thm ("real_mult_assoc",num_str @{thm real_mult_assoc}),
196 (*z1.0 * z2.0 * z3.0 = z1.0 * (z2.0 * z3.0)*)
197 Thm ("add_commute",num_str @{thm add_commute}),
199 Thm ("add_left_commute",num_str @{thm add_left_commute}),
200 (*x + (y + z) = y + (x + z)*)
201 Thm ("add_assoc",num_str @{thm add_assoc})
202 (*z1.0 + z2.0 + z3.0 = z1.0 + (z2.0 + z3.0)*)
207 (*.adapted from 'norm_Rational' by
208 #1 using 'ord_simplify_System' in 'order_add_mult_System'
209 #2 NOT using common_nominator_p .*)
210 val norm_System_noadd_fractions =
211 Rls {id = "norm_System_noadd_fractions", preconds = [],
212 rew_ord = ("dummy_ord",dummy_ord),
213 erls = norm_rat_erls, srls = Erls, calc = [],
214 rules = [(*sequence given by operator precedence*)
217 Rls_ rat_mult_divide,
220 Rls_ (*order_add_mult #1*) order_add_mult_System,
221 Rls_ collect_numerals,
222 (*Rls_ add_fractions_p, #2*)
225 scr = Script ((term_of o the o (parse thy))
230 (*.adapted from 'norm_Rational' by
231 *1* using 'ord_simplify_System' in 'order_add_mult_System'.*)
233 Rls {id = "norm_System", preconds = [],
234 rew_ord = ("dummy_ord",dummy_ord),
235 erls = norm_rat_erls, srls = Erls, calc = [],
236 rules = [(*sequence given by operator precedence*)
239 Rls_ rat_mult_divide,
242 Rls_ (*order_add_mult *1*) order_add_mult_System,
243 Rls_ collect_numerals,
244 Rls_ add_fractions_p,
247 scr = Script ((term_of o the o (parse thy))
252 (*.simplify an equational system BEFORE solving it such that parentheses are
253 ( ((u0*v0)*w0) + ( ((u1*v1)*w1) * c + ... +((u4*v4)*w4) * c_4 ) )
254 ATTENTION: works ONLY for bound variables c, c_1, c_2, c_3, c_4 :ATTENTION
255 This is a copy from 'make_ratpoly_in' with respective reductions:
256 *0* expand the term, ie. distribute * and / over +
257 *1* ord_simplify_System instead of termlessI
258 *2* no add_fractions_p (= common_nominator_p_rls !)
259 *3* discard_parentheses only for (.*(.*.))
260 analoguous to simplify_Integral .*)
261 val simplify_System_parenthesized =
262 Seq {id = "simplify_System_parenthesized", preconds = []:term list,
263 rew_ord = ("dummy_ord", dummy_ord),
264 erls = Atools_erls, srls = Erls, calc = [],
265 rules = [Thm ("left_distrib",num_str @{thm left_distrib}),
266 (*"(?z1.0 + ?z2.0) * ?w = ?z1.0 * ?w + ?z2.0 * ?w"*)
267 Thm ("add_divide_distrib",num_str @{thm add_divide_distrib}),
268 (*"(?x + ?y) / ?z = ?x / ?z + ?y / ?z"*)
269 (*^^^^^ *0* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*)
270 Rls_ norm_Rational_noadd_fractions(**2**),
271 Rls_ (*order_add_mult_in*) norm_System_noadd_fractions (**1**),
272 Thm ("sym_real_mult_assoc",
273 num_str (@{thm real_mult_assoc} RS @{thm sym}))
274 (*Rls_ discard_parentheses *3**),
275 Rls_ collect_bdv, (*from make_polynomial_in WN051031 welldone?*)
277 Calc ("HOL.divide" ,eval_cancel "#divide_e")
282 (*.simplify an equational system AFTER solving it;
283 This is a copy of 'make_ratpoly_in' with the differences
284 *1* ord_simplify_System instead of termlessI .*)
285 (*TODO.WN051031 ^^^^^^^^^^ should be in EACH rls contained *)
286 val simplify_System =
287 Seq {id = "simplify_System", preconds = []:term list,
288 rew_ord = ("dummy_ord", dummy_ord),
289 erls = Atools_erls, srls = Erls, calc = [],
290 rules = [Rls_ norm_Rational,
291 Rls_ (*order_add_mult_in*) norm_System (**1**),
292 Rls_ discard_parentheses,
293 Rls_ collect_bdv, (*from make_polynomial_in WN051031 welldone?*)
295 Calc ("HOL.divide" ,eval_cancel "#divide_e")
299 val simplify_System =
300 append_rls "simplify_System" simplify_System_parenthesized
301 [Thm ("sym_add_assoc",
302 num_str (@{thm add_assoc} RS @{thm sym}))];
307 Rls {id="isolate_bdvs", preconds = [],
308 rew_ord = ("e_rew_ord", e_rew_ord),
309 erls = append_rls "erls_isolate_bdvs" e_rls
310 [(Calc ("EqSystem.occur'_exactly'_in",
311 eval_occur_exactly_in
312 "#eval_occur_exactly_in_"))
314 srls = Erls, calc = [],
316 [Thm ("commute_0_equality", num_str @{thm commute_0_equality}),
317 Thm ("separate_bdvs_add", num_str @{thm separate_bdvs_add}),
318 Thm ("separate_bdvs_mult", num_str @{thm separate_bdvs_mult})],
322 val isolate_bdvs_4x4 =
323 Rls {id="isolate_bdvs_4x4", preconds = [],
324 rew_ord = ("e_rew_ord", e_rew_ord),
326 "erls_isolate_bdvs_4x4" e_rls
327 [Calc ("EqSystem.occur'_exactly'_in",
328 eval_occur_exactly_in "#eval_occur_exactly_in_"),
329 Calc ("Atools.ident",eval_ident "#ident_"),
330 Calc ("Atools.some'_occur'_in",
331 eval_some_occur_in "#some_occur_in_"),
332 Thm ("not_true",num_str @{thm not_true}),
333 Thm ("not_false",num_str @{thm not_false})
335 srls = Erls, calc = [],
336 rules = [Thm ("commute_0_equality", num_str @{thm commute_0_equality}),
337 Thm ("separate_bdvs0", num_str @{thm separate_bdvs0}),
338 Thm ("separate_bdvs_add1", num_str @{thm separate_bdvs_add1}),
339 Thm ("separate_bdvs_add1", num_str @{thm separate_bdvs_add2}),
340 Thm ("separate_bdvs_mult", num_str @{thm separate_bdvs_mult})
346 (*.order the equations in a system such, that a triangular system (if any)
347 appears as [..c_4 = .., ..., ..., ..c_1 + ..c_2 + ..c_3 ..c_4 = ..].*)
349 Rls {id="order_system", preconds = [],
350 rew_ord = ("ord_simplify_System",
351 ord_simplify_System false thy),
352 erls = Erls, srls = Erls, calc = [],
353 rules = [Thm ("order_system_NxN", num_str @{thm order_system_NxN})
357 val prls_triangular =
358 Rls {id="prls_triangular", preconds = [],
359 rew_ord = ("e_rew_ord", e_rew_ord),
360 erls = Rls {id="erls_prls_triangular", preconds = [],
361 rew_ord = ("e_rew_ord", e_rew_ord),
362 erls = Erls, srls = Erls, calc = [],
363 rules = [(*for precond NTH_CONS ...*)
364 Calc ("op <",eval_equ "#less_"),
365 Calc ("op +", eval_binop "#add_")
366 (*immediately repeated rewrite pushes
367 '+' into precondition !*)
370 srls = Erls, calc = [],
371 rules = [Thm ("NTH_CONS",num_str @{thm NTH_CONS}),
372 Calc ("op +", eval_binop "#add_"),
373 Thm ("NTH_NIL",num_str @{thm NTH_NIL}),
374 Thm ("tl_Cons",num_str @{thm tl_Cons}),
375 Thm ("tl_Nil",num_str @{thm tl_Nil}),
376 Calc ("EqSystem.occur'_exactly'_in",
377 eval_occur_exactly_in
378 "#eval_occur_exactly_in_")
384 (*WN060914 quickly created for 4x4;
385 more similarity to prls_triangular desirable*)
386 val prls_triangular4 =
387 Rls {id="prls_triangular4", preconds = [],
388 rew_ord = ("e_rew_ord", e_rew_ord),
389 erls = Rls {id="erls_prls_triangular4", preconds = [],
390 rew_ord = ("e_rew_ord", e_rew_ord),
391 erls = Erls, srls = Erls, calc = [],
392 rules = [(*for precond NTH_CONS ...*)
393 Calc ("op <",eval_equ "#less_"),
394 Calc ("op +", eval_binop "#add_")
395 (*immediately repeated rewrite pushes
396 '+' into precondition !*)
399 srls = Erls, calc = [],
400 rules = [Thm ("NTH_CONS",num_str @{thm NTH_CONS}),
401 Calc ("op +", eval_binop "#add_"),
402 Thm ("NTH_NIL",num_str @{thm NTH_NIL}),
403 Thm ("tl_Cons",num_str @{thm tl_Cons}),
404 Thm ("tl_Nil",num_str @{thm tl_Nil}),
405 Calc ("EqSystem.occur'_exactly'_in",
406 eval_occur_exactly_in
407 "#eval_occur_exactly_in_")
414 overwritelthy @{theory}
416 [("simplify_System_parenthesized", prep_rls simplify_System_parenthesized),
417 ("simplify_System", prep_rls simplify_System),
418 ("isolate_bdvs", prep_rls isolate_bdvs),
419 ("isolate_bdvs_4x4", prep_rls isolate_bdvs_4x4),
420 ("order_system", prep_rls order_system),
421 ("order_add_mult_System", prep_rls order_add_mult_System),
422 ("norm_System_noadd_fractions", prep_rls norm_System_noadd_fractions),
423 ("norm_System", prep_rls norm_System)
432 (prep_pbt thy "pbl_equsys" [] e_pblID
434 [("#Given" ,["equalities e_s", "solveForVars v_s"]),
435 ("#Find" ,["solution ss'''"](*''' is copy-named*))
437 append_rls "e_rls" e_rls [(*for preds in where_*)],
438 SOME "solveSystem e_s v_s",
441 (prep_pbt thy "pbl_equsys_lin" [] e_pblID
442 (["linear", "system"],
443 [("#Given" ,["equalities e_s", "solveForVars v_s"]),
444 (*TODO.WN050929 check linearity*)
445 ("#Find" ,["solution ss'''"])
447 append_rls "e_rls" e_rls [(*for preds in where_*)],
448 SOME "solveSystem e_s v_s",
451 (prep_pbt thy "pbl_equsys_lin_2x2" [] e_pblID
452 (["2x2", "linear", "system"],
453 (*~~~~~~~~~~~~~~~~~~~~~~~~~*)
454 [("#Given" ,["equalities e_s", "solveForVars v_s"]),
455 ("#Where" ,["LENGTH (e_s:: bool list) = 2", "LENGTH v_s = 2"]),
456 ("#Find" ,["solution ss'''"])
458 append_rls "prls_2x2_linear_system" e_rls
459 [Thm ("LENGTH_CONS",num_str @{thm LENGTH_CONS}),
460 Thm ("LENGTH_NIL",num_str @{thm LENGTH_NIL}),
461 Calc ("op +", eval_binop "#add_"),
462 Calc ("op =",eval_equal "#equal_")
464 SOME "solveSystem e_s v_s",
469 (prep_pbt thy "pbl_equsys_lin_2x2_tri" [] e_pblID
470 (["triangular", "2x2", "linear", "system"],
471 [("#Given" ,["equalities e_s", "solveForVars v_s"]),
473 ["(tl v_s) from_ v_s occur_exactly_in (NTH 1 (e_s::bool list))",
474 " v_s from_ v_s occur_exactly_in (NTH 2 (e_s::bool list))"]),
475 ("#Find" ,["solution ss'''"])
478 SOME "solveSystem e_s v_s",
479 [["EqSystem","top_down_substitution","2x2"]]));
481 (prep_pbt thy "pbl_equsys_lin_2x2_norm" [] e_pblID
482 (["normalize", "2x2", "linear", "system"],
483 [("#Given" ,["equalities e_s", "solveForVars v_s"]),
484 ("#Find" ,["solution ss'''"])
486 append_rls "e_rls" e_rls [(*for preds in where_*)],
487 SOME "solveSystem e_s v_s",
488 [["EqSystem","normalize","2x2"]]));
490 (prep_pbt thy "pbl_equsys_lin_3x3" [] e_pblID
491 (["3x3", "linear", "system"],
492 (*~~~~~~~~~~~~~~~~~~~~~~~~~*)
493 [("#Given" ,["equalities e_s", "solveForVars v_s"]),
494 ("#Where" ,["LENGTH (e_s:: bool list) = 3", "LENGTH v_s = 3"]),
495 ("#Find" ,["solution ss'''"])
497 append_rls "prls_3x3_linear_system" e_rls
498 [Thm ("LENGTH_CONS",num_str @{thm LENGTH_CONS}),
499 Thm ("LENGTH_NIL",num_str @{thm LENGTH_NIL}),
500 Calc ("op +", eval_binop "#add_"),
501 Calc ("op =",eval_equal "#equal_")
503 SOME "solveSystem e_s v_s",
506 (prep_pbt thy "pbl_equsys_lin_4x4" [] e_pblID
507 (["4x4", "linear", "system"],
508 (*~~~~~~~~~~~~~~~~~~~~~~~~~*)
509 [("#Given" ,["equalities e_s", "solveForVars v_s"]),
510 ("#Where" ,["LENGTH (e_s:: bool list) = 4", "LENGTH v_s = 4"]),
511 ("#Find" ,["solution ss'''"])
513 append_rls "prls_4x4_linear_system" e_rls
514 [Thm ("LENGTH_CONS",num_str @{thm LENGTH_CONS}),
515 Thm ("LENGTH_NIL",num_str @{thm LENGTH_NIL}),
516 Calc ("op +", eval_binop "#add_"),
517 Calc ("op =",eval_equal "#equal_")
519 SOME "solveSystem e_s v_s",
524 (prep_pbt thy "pbl_equsys_lin_4x4_tri" [] e_pblID
525 (["triangular", "4x4", "linear", "system"],
526 [("#Given" ,["equalities e_s", "solveForVars v_s"]),
527 ("#Where" , (*accepts missing variables up to diagional form*)
528 ["(NTH 1 (v_s::real list)) occurs_in (NTH 1 (e_s::bool list))",
529 "(NTH 2 (v_s::real list)) occurs_in (NTH 2 (e_s::bool list))",
530 "(NTH 3 (v_s::real list)) occurs_in (NTH 3 (e_s::bool list))",
531 "(NTH 4 (v_s::real list)) occurs_in (NTH 4 (e_s::bool list))"
533 ("#Find" ,["solution ss'''"])
535 append_rls "prls_tri_4x4_lin_sys" prls_triangular
536 [Calc ("Atools.occurs'_in",eval_occurs_in "")],
537 SOME "solveSystem e_s v_s",
538 [["EqSystem","top_down_substitution","4x4"]]));
542 (prep_pbt thy "pbl_equsys_lin_4x4_norm" [] e_pblID
543 (["normalize", "4x4", "linear", "system"],
544 [("#Given" ,["equalities e_s", "solveForVars v_s"]),
545 (*LENGTH is checked 1 level above*)
546 ("#Find" ,["solution ss'''"])
548 append_rls "e_rls" e_rls [(*for preds in where_*)],
549 SOME "solveSystem e_s v_s",
550 [["EqSystem","normalize","4x4"]]));
561 (prep_met thy "met_eqsys" [] e_metID
564 {rew_ord'="tless_true", rls' = Erls, calc = [],
565 srls = Erls, prls = Erls, crls = Erls, nrls = Erls},
569 (prep_met thy "met_eqsys_topdown" [] e_metID
570 (["EqSystem","top_down_substitution"],
572 {rew_ord'="tless_true", rls' = Erls, calc = [],
573 srls = Erls, prls = Erls, crls = Erls, nrls = Erls},
579 (prep_met thy "met_eqsys_topdown_2x2" [] e_metID
580 (["EqSystem","top_down_substitution","2x2"],
581 [("#Given" ,["equalities e_s", "solveForVars v_s"]),
583 ["(tl v_s) from_ v_s occur_exactly_in (NTH 1 (e_s::bool list))",
584 " v_s from_ v_s occur_exactly_in (NTH 2 (e_s::bool list))"]),
585 ("#Find" ,["solution ss'''"])
587 {rew_ord'="ord_simplify_System", rls' = Erls, calc = [],
588 srls = append_rls "srls_top_down_2x2" e_rls
589 [Thm ("hd_thm",num_str @{thm hd_thm}),
590 Thm ("tl_Cons",num_str @{thm tl_Cons}),
591 Thm ("tl_Nil",num_str @{thm tl_Nil})
593 prls = prls_triangular, crls = Erls, nrls = Erls},
594 "Script SolveSystemScript (e_s::bool list) (v_s::real list) = " ^
595 " (let e_1 = Take (hd e_s); " ^
596 " e_1 = ((Try (Rewrite_Set_Inst [(bdv_1, hd v_s),(bdv_2, hd (tl v_s))]" ^
597 " isolate_bdvs False)) @@ " ^
598 " (Try (Rewrite_Set_Inst [(bdv_1, hd v_s),(bdv_2, hd (tl v_s))]" ^
599 " simplify_System False))) e_1; " ^
600 " e_2 = Take (hd (tl e_s)); " ^
601 " e_2 = ((Substitute [e_1]) @@ " ^
602 " (Try (Rewrite_Set_Inst [(bdv_1, hd v_s),(bdv_2, hd (tl v_s))]" ^
603 " simplify_System_parenthesized False)) @@ " ^
604 " (Try (Rewrite_Set_Inst [(bdv_1, hd v_s),(bdv_2, hd (tl v_s))]" ^
605 " isolate_bdvs False)) @@ " ^
606 " (Try (Rewrite_Set_Inst [(bdv_1, hd v_s),(bdv_2, hd (tl v_s))]" ^
607 " simplify_System False))) e_2; " ^
608 " e__s = Take [e_1, e_2] " ^
609 " in (Try (Rewrite_Set order_system False)) e__s)"
610 (*---------------------------------------------------------------------------
611 this script does NOT separate the equations as above,
612 but it does not yet work due to preliminary script-interpreter,
613 see eqsystem.sml 'script [EqSystem,top_down_substitution,2x2] Vers.2'
615 "Script SolveSystemScript (e_s::bool list) (v_s::real list) = " ^
616 " (let e__s = Take e_s; " ^
618 " e_2 = hd (tl e__s); " ^
619 " e__s = [e_1, Substitute [e_1] e_2] " ^
620 " in ((Try (Rewrite_Set_Inst [(bdv_1, hd v_s),(bdv_2, hd (tl v_s))]" ^
621 " simplify_System_parenthesized False)) @@ " ^
622 " (Try (Rewrite_Set_Inst [(bdv_1, hd v_s),(bdv_2, hd (tl v_s))] " ^
623 " isolate_bdvs False)) @@ " ^
624 " (Try (Rewrite_Set_Inst [(bdv_1, hd v_s),(bdv_2, hd (tl v_s))]" ^
625 " simplify_System False))) e__s)"
626 ---------------------------------------------------------------------------*)
631 (prep_met thy "met_eqsys_norm" [] e_metID
632 (["EqSystem","normalize"],
634 {rew_ord'="tless_true", rls' = Erls, calc = [],
635 srls = Erls, prls = Erls, crls = Erls, nrls = Erls},
639 (prep_met thy "met_eqsys_norm_2x2" [] e_metID
640 (["EqSystem","normalize","2x2"],
641 [("#Given" ,["equalities e_s", "solveForVars v_s"]),
642 ("#Find" ,["solution ss'''"])],
643 {rew_ord'="tless_true", rls' = Erls, calc = [],
644 srls = append_rls "srls_normalize_2x2" e_rls
645 [Thm ("hd_thm",num_str @{thm hd_thm}),
646 Thm ("tl_Cons",num_str @{thm tl_Cons}),
647 Thm ("tl_Nil",num_str @{thm tl_Nil})
649 prls = Erls, crls = Erls, nrls = Erls},
650 "Script SolveSystemScript (e_s::bool list) (v_s::real list) = " ^
651 " (let e__s = ((Try (Rewrite_Set norm_Rational False)) @@ " ^
652 " (Try (Rewrite_Set_Inst [(bdv_1, hd v_s),(bdv_2, hd (tl v_s))]" ^
653 " simplify_System_parenthesized False)) @@ " ^
654 " (Try (Rewrite_Set_Inst [(bdv_1, hd v_s),(bdv_2, hd (tl v_s))]" ^
655 " isolate_bdvs False)) @@ " ^
656 " (Try (Rewrite_Set_Inst [(bdv_1, hd v_s),(bdv_2, hd (tl v_s))]" ^
657 " simplify_System_parenthesized False)) @@ " ^
658 " (Try (Rewrite_Set order_system False))) e_s " ^
659 " in (SubProblem (EqSystem_,[linear,system],[no_met]) " ^
660 " [BOOL_LIST e__s, REAL_LIST v_s]))"
663 (*this is for NTH only*)
664 val srls = Rls {id="srls_normalize_4x4",
666 rew_ord = ("termlessI",termlessI),
667 erls = append_rls "erls_in_srls_IntegrierenUnd.." e_rls
668 [(*for asm in NTH_CONS ...*)
669 Calc ("op <",eval_equ "#less_"),
670 (*2nd NTH_CONS pushes n+-1 into asms*)
671 Calc("op +", eval_binop "#add_")
673 srls = Erls, calc = [],
674 rules = [Thm ("NTH_CONS",num_str @{thm NTH_CONS}),
675 Calc("op +", eval_binop "#add_"),
676 Thm ("NTH_NIL",num_str @{thm NTH_NIL})],
679 (prep_met thy "met_eqsys_norm_4x4" [] e_metID
680 (["EqSystem","normalize","4x4"],
681 [("#Given" ,["equalities e_s", "solveForVars v_s"]),
682 ("#Find" ,["solution ss'''"])],
683 {rew_ord'="tless_true", rls' = Erls, calc = [],
684 srls = append_rls "srls_normalize_4x4" srls
685 [Thm ("hd_thm",num_str @{thm hd_thm}),
686 Thm ("tl_Cons",num_str @{thm tl_Cons}),
687 Thm ("tl_Nil",num_str @{thm tl_Nil})
689 prls = Erls, crls = Erls, nrls = Erls},
690 (*GOON met ["EqSystem","normalize","4x4"] @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*)
691 "Script SolveSystemScript (e_s::bool list) (v_s::real list) = " ^
693 " ((Try (Rewrite_Set norm_Rational False)) @@ " ^
694 " (Repeat (Rewrite commute_0_equality False)) @@ " ^
695 " (Try (Rewrite_Set_Inst [(bdv_1, NTH 1 v_s),(bdv_2, NTH 2 v_s ), " ^
696 " (bdv_3, NTH 3 v_s),(bdv_3, NTH 4 v_s )] " ^
697 " simplify_System_parenthesized False)) @@ " ^
698 " (Try (Rewrite_Set_Inst [(bdv_1, NTH 1 v_s),(bdv_2, NTH 2 v_s ), " ^
699 " (bdv_3, NTH 3 v_s),(bdv_3, NTH 4 v_s )] " ^
700 " isolate_bdvs_4x4 False)) @@ " ^
701 " (Try (Rewrite_Set_Inst [(bdv_1, NTH 1 v_s),(bdv_2, NTH 2 v_s ), " ^
702 " (bdv_3, NTH 3 v_s),(bdv_3, NTH 4 v_s )] " ^
703 " simplify_System_parenthesized False)) @@ " ^
704 " (Try (Rewrite_Set order_system False))) e_s " ^
705 " in (SubProblem (EqSystem_,[linear,system],[no_met]) " ^
706 " [BOOL_LIST e__s, REAL_LIST v_s]))"
709 (prep_met thy "met_eqsys_topdown_4x4" [] e_metID
710 (["EqSystem","top_down_substitution","4x4"],
711 [("#Given" ,["equalities e_s", "solveForVars v_s"]),
712 ("#Where" , (*accepts missing variables up to diagonal form*)
713 ["(NTH 1 (v_s::real list)) occurs_in (NTH 1 (e_s::bool list))",
714 "(NTH 2 (v_s::real list)) occurs_in (NTH 2 (e_s::bool list))",
715 "(NTH 3 (v_s::real list)) occurs_in (NTH 3 (e_s::bool list))",
716 "(NTH 4 (v_s::real list)) occurs_in (NTH 4 (e_s::bool list))"
718 ("#Find" ,["solution ss'''"])
720 {rew_ord'="ord_simplify_System", rls' = Erls, calc = [],
721 srls = append_rls "srls_top_down_4x4" srls [],
722 prls = append_rls "prls_tri_4x4_lin_sys" prls_triangular
723 [Calc ("Atools.occurs'_in",eval_occurs_in "")],
724 crls = Erls, nrls = Erls},
725 (*FIXXXXME.WN060916: this script works ONLY for exp 7.79 @@@@@@@@@@@@@@@@@@@@*)
726 "Script SolveSystemScript (e_s::bool list) (v_s::real list) = " ^
727 " (let e_1 = NTH 1 e_s; " ^
728 " e_2 = Take (NTH 2 e_s); " ^
729 " e_2 = ((Substitute [e_1]) @@ " ^
730 " (Try (Rewrite_Set_Inst [(bdv_1,NTH 1 v_s),(bdv_2,NTH 2 v_s)," ^
731 " (bdv_3,NTH 3 v_s),(bdv_4,NTH 4 v_s)]" ^
732 " simplify_System_parenthesized False)) @@ " ^
733 " (Try (Rewrite_Set_Inst [(bdv_1,NTH 1 v_s),(bdv_2,NTH 2 v_s)," ^
734 " (bdv_3,NTH 3 v_s),(bdv_4,NTH 4 v_s)]" ^
735 " isolate_bdvs False)) @@ " ^
736 " (Try (Rewrite_Set_Inst [(bdv_1,NTH 1 v_s),(bdv_2,NTH 2 v_s)," ^
737 " (bdv_3,NTH 3 v_s),(bdv_4,NTH 4 v_s)]" ^
738 " norm_Rational False))) e_2 " ^
739 " in [e_1, e_2, NTH 3 e_s, NTH 4 e_s])"