test/Tools/isac/Knowledge/eqsystem.sml
author Walther Neuper <neuper@ist.tugraz.at>
Mon, 02 Sep 2013 16:16:08 +0200
changeset 52101 c3f399ce32af
parent 52070 77138c64f4f6
child 52105 2786cc9704c8
permissions -rw-r--r--
Test_Isac works again, almost ..

4 files raise errors:
# Interpret/solve.sml: "solve.sml: interSteps on norm_Rational 2"
# Interpret/inform.sml: "inform.sml: [rational,simplification] 2"
# Knowledge/partial_fractions.sml: "autoCalculate for met_partial_fraction changed: final result"
# Knowledge/eqsystem.sml: "eqsystem.sml: exp 7.70 normalize 4x4 by rewrite changed"

The chunk of changes is due to the fact, that Isac's code still is unstable.
The changes are accumulated since e8f46493af82.
     1 (* tests on systems of equations
     2    author: Walther Neuper 050826,
     3    (c) due to copyright terms
     4 *)
     5 
     6 trace_rewrite := false;
     7 "-----------------------------------------------------------------";
     8 "table of contents -----------------------------------------------";
     9 "-----------------------------------------------------------------";
    10 "----------- occur_exactly_in ------------------------------------";
    11 "----------- problems --------------------------------------------";
    12 "----------- rewrite-order ord_simplify_System -------------------";
    13 "----------- rewrite in [EqSystem,normalize,2x2] -----------------";
    14 "----------- rewrite example from 2nd [EqSystem,normalize,2x2] ---";
    15 "----------- rewrite in [EqSystem,top_down_substitution,2x2] -----";
    16 "----------- rewrite in [EqSystem,normalize,4x4] -----------------";
    17 "----------- script [EqSystem,top_down_substitution,2x2] Vers.1 --";
    18 "----------- refine [linear,system]-------------------------------";
    19 "----------- refine [2x2,linear,system] search error--------------";
    20 "----------- me [EqSystem,normalize,2x2] -------------------------";
    21 "----------- me [linear,system] ..normalize..top_down_sub..-------";
    22 "----------- all systems from Biegelinie -------------------------";
    23 "----------- 4x4 systems from Biegelinie -------------------------";
    24 "-----------------------------------------------------------------";
    25 "-----------------------------------------------------------------";
    26 "-----------------------------------------------------------------";
    27 
    28 val thy = @{theory "EqSystem"};
    29 val ctxt = Proof_Context.init_global thy;
    30 
    31 "----------- occur_exactly_in ------------------------------------";
    32 "----------- occur_exactly_in ------------------------------------";
    33 "----------- occur_exactly_in ------------------------------------";
    34 val all = [str2term"c", str2term"c_2", str2term"c_3"];
    35 val t = str2term"0 = -1 * q_0 * L ^^^ 2 / 2 + L * c + c_2";
    36 
    37 if occur_exactly_in [str2term"c", str2term"c_2"] all t
    38 then () else error "eqsystem.sml occur_exactly_in 1";
    39 
    40 if not (occur_exactly_in [str2term"c", str2term"c_2", str2term"c_3"] all t)
    41 then () else error "eqsystem.sml occur_exactly_in 2";
    42 
    43 if not (occur_exactly_in [str2term"c_2"] all t)
    44 then () else error "eqsystem.sml occur_exactly_in 3";
    45 
    46 val t = str2term"[c,c_2] from [c,c_2,c_3] occur_exactly_in -1 * q_0 * L ^^^ 2 / 2 + L * c + c_2";
    47 eval_occur_exactly_in 0 "EqSystem.occur'_exactly'_in" t 0;
    48 val SOME (str, t') = eval_occur_exactly_in 0 "EqSystem.occur'_exactly'_in" t 0;
    49 if str = "[c, c_2] from [c, c_2,\n" ^
    50   "               c_3] occur_exactly_in -1 * q_0 * L ^^^ 2 / 2 + L * c + c_2 = True"
    51 then () else error "eval_occur_exactly_in [c, c_2]";
    52 
    53 val t = str2term ("[c,c_2,c_3] from [c,c_2,c_3] occur_exactly_in " ^
    54 		  "-1 * q_0 * L ^^^ 2 / 2 + L * c + c_2");
    55 val SOME (str, t') = eval_occur_exactly_in 0 "EqSystem.occur'_exactly'_in" t 0;
    56 if str = "[c, c_2,\n c_3] from [c, c_2,\n" ^
    57 "            c_3] occur_exactly_in -1 * q_0 * L ^^^ 2 / 2 + L * c + c_2 = False"
    58 then () else error "eval_occur_exactly_in [c, c_2, c_3]";
    59 
    60 val t = str2term"[c_2] from [c,c_2,c_3] occur_exactly_in \
    61 		\-1 * q_0 * L ^^^ 2 / 2 + L * c + c_2";
    62 val SOME (str, t') = eval_occur_exactly_in 0 "EqSystem.occur'_exactly'_in" t 0;
    63 if str = "[c_2] from [c, c_2,\n" ^
    64   "            c_3] occur_exactly_in -1 * q_0 * L ^^^ 2 / 2 + L * c + c_2 = False"
    65 then () else error "eval_occur_exactly_in [c, c_2, c_3]";
    66 
    67 val t = str2term"[] from [c,c_2,c_3] occur_exactly_in 0";
    68 val SOME (str, t') = eval_occur_exactly_in 0 "EqSystem.occur'_exactly'_in" t 0;
    69 if str = "[] from [c, c_2, c_3] occur_exactly_in 0 = True" then ()
    70 else error "eval_occur_exactly_in [c, c_2, c_3]";
    71 
    72 val t = 
    73     str2term
    74 	"[] from [c, c_2, c_3, c_4] occur_exactly_in -1 * (q_0 * L ^^^ 2) /2";
    75 val SOME (str, t') = eval_occur_exactly_in 0 "EqSystem.occur'_exactly'_in" t 0;
    76 if str = "[] from [c, c_2, c_3, c_4] occur_exactly_in \
    77 	 \-1 * (q_0 * L ^^^ 2) / 2 = True" then ()
    78 else error "eval_occur_exactly_in [c, c_2, c_3, c_4]";
    79 
    80 "----------- problems --------------------------------------------";
    81 "----------- problems --------------------------------------------";
    82 "----------- problems --------------------------------------------";
    83 val t = str2term "LENGTH [x+y=1,y=2] = 2";
    84 atomty t;
    85 val testrls = append_rls "testrls" e_rls 
    86 			 [(Thm ("LENGTH_NIL",num_str @{thm LENGTH_NIL})),
    87 			  (Thm ("LENGTH_CONS",num_str @{thm LENGTH_CONS})),
    88 			  Calc ("Groups.plus_class.plus", eval_binop "#add_"),
    89 			  Calc ("HOL.eq",eval_equal "#equal_")
    90 			  ];
    91 val SOME (t',_) = rewrite_set_ thy false testrls t;
    92 if term2str t' = "True" then () 
    93 else error "eqsystem.sml: length_ [x+y=1,y=2] = 2";
    94 
    95 val SOME t = parse thy "solution LL";
    96 atomty (term_of t);
    97 val SOME t = parse thy "solution LL";
    98 atomty (term_of t);
    99 
   100 val t = str2term 
   101 "(tl (tl (tl v_s))) from v_s occur_exactly_in (NTH 1 (e_s::bool list))";
   102 atomty t;
   103 val t = str2term ("(tl (tl (tl [c, c_2, c_3, c_4]))) from [c, c_2, c_3, c_4] occur_exactly_in " ^
   104   "(NTH 1 [c_4 = 1, 2 = 2, 3 = 3, 4 = 4])");
   105 val SOME (t,_) = 
   106     rewrite_set_ thy true 
   107 		 (append_rls "prls_" e_rls 
   108 			     [Thm ("NTH_CONS",num_str @{thm NTH_CONS}),
   109 			      Thm ("NTH_NIL",num_str @{thm NTH_NIL}),
   110 			      Thm ("TL_CONS",num_str @{thm tl_Cons}),
   111 			      Thm ("TL_NIL",num_str @{thm tl_Nil}),
   112 			      Calc ("EqSystem.occur'_exactly'_in", eval_occur_exactly_in "#eval_occur_exactly_in_")
   113 			      ]) t;
   114 if t = @{term True} then () 
   115 else error "eqsystem.sml ..occur_exactly_in (nth_ 1 [c_4..";
   116 
   117 "----------- rewrite-order ord_simplify_System -------------------";
   118 "----------- rewrite-order ord_simplify_System -------------------";
   119 "----------- rewrite-order ord_simplify_System -------------------";
   120 "M_b x = c * x + -1 * q_0 * (x ^^^ 2 / 2) + c_2";
   121 "--- add_commute ---";
   122 if ord_simplify_System false thy [] (str2term"-1 * q_0 * (x ^^^ 2 / 2)", 
   123 				       str2term"c * x") then ()
   124 else error "integrate.sml, (-1 * q_0 * (x ^^^ 2 / 2)) < (c * x) not#1";
   125 
   126 if ord_simplify_System false thy [] (str2term"-1 * q_0 * (x ^^^ 2 / 2)", 
   127 				       str2term"c_2") then ()
   128 else error "integrate.sml, (-1 * q_0 * (x ^^^ 2 / 2)) < (c_2) not#2";
   129 
   130 if ord_simplify_System false thy [] (str2term"c * x", 
   131 				       str2term"c_2") then ()
   132 else error "integrate.sml, (c * x) < (c_2) not#3";
   133 
   134 "--- mult_commute ---";
   135 if ord_simplify_System false thy [] (str2term"x * c", 
   136 				       str2term"c * x") then ()
   137 else error "integrate.sml, (x * c) < (c * x) not#4";
   138 
   139 if ord_simplify_System false thy [] (str2term"-1 * q_0 * (x ^^^ 2 / 2) * c", 
   140 				       str2term"-1 * q_0 * c * (x ^^^ 2 / 2)") 
   141 then () else error "integrate.sml, (. * .) < (. * .) not#5";
   142 
   143 if ord_simplify_System false thy [] (str2term"-1 * q_0 * (x ^^^ 2 / 2) * c", 
   144 				       str2term"c * -1 * q_0 * (x ^^^ 2 / 2)") 
   145 then () else error "integrate.sml, (. * .) < (. * .) not#6";
   146 
   147 
   148 "----------- rewrite in [EqSystem,normalize,2x2] -----------------";
   149 "----------- rewrite in [EqSystem,normalize,2x2] -----------------";
   150 "----------- rewrite in [EqSystem,normalize,2x2] -----------------";
   151 val t = str2term"[0 = -1 * q_0 * L ^^^ 2 / 2 + L * c + c_2,\
   152 	        \0 = -1 * q_0 * 0 ^^^ 2 / 2 + 0 * c + c_2]";
   153 val bdvs = [(str2term"bdv_1",str2term"c"),
   154 	    (str2term"bdv_2",str2term"c_2")];
   155 val SOME(t,_)= rewrite_set_inst_ thy true bdvs simplify_System_parenthesized t;
   156 if term2str t = "[0 = -1 * q_0 * L ^^^ 2 / 2 + (L * c + c_2), 0 = c_2]"
   157 then () else error "eqsystem.sml rewrite in 2x2 simplify_System_par.1";
   158 
   159 val SOME (t,_) = rewrite_set_inst_ thy true bdvs isolate_bdvs t;
   160 if term2str t = "[L * c + c_2 = 0 + -1 * (-1 * q_0 * L ^^^ 2 / 2), c_2 = 0]"then () else error "eqsystem.sml rewrite in 2x2 isolate_bdvs";
   161 
   162 val SOME(t,_)= rewrite_set_inst_ thy true bdvs simplify_System t;
   163 if term2str t = "[L * c + c_2 = q_0 * L ^^^ 2 / 2, c_2 = 0]"
   164 then () else error "eqsystem.sml rewrite in 2x2 simplify_System_par.2";
   165 
   166 "--- 3--- see EqSystem.thy (*..if replaced by 'and' ...";
   167 val SOME (t,_) = rewrite_set_ thy true order_system t;
   168 if term2str t = "[c_2 = 0, L * c + c_2 = q_0 * L ^^^ 2 / 2]"
   169 then () else error "eqsystem.sml rewrite in 2x2 simplify_System_par.3";
   170 "--- 4---";
   171 
   172 "----------- rewrite example from 2nd [EqSystem,normalize,2x2] ---";
   173 "----------- rewrite example from 2nd [EqSystem,normalize,2x2] ---";
   174 "----------- rewrite example from 2nd [EqSystem,normalize,2x2] ---";
   175 val thy = @{theory "Isac"} (*because of Undeclared constant "Biegelinie.EI*);
   176 val t = 
   177     str2term"[0 = c_2 + c * 0 + 1 / EI * (L * q_0 / 12 * 0 ^^^ 3 +         \
   178 	    \                                     -1 * q_0 / 24 * 0 ^^^ 4),\
   179 	    \ 0 = c_2 + c * L + 1 / EI * (L * q_0 / 12 * L ^^^ 3 +         \
   180 	    \                                     -1 * q_0 / 24 * L ^^^ 4)]";
   181 val SOME (t,_) = rewrite_set_ thy true norm_Rational t;
   182 if term2str t="[0 = c_2, 0 = c_2 + L * c + L ^^^ 4 * q_0 / (EI * 24)]"
   183 then () else error "eqsystem.sml rewrite in 2x2 simplify_System_par.0b";
   184 
   185 val SOME(t,_)= rewrite_set_inst_ thy true bdvs simplify_System_parenthesized t;
   186 if term2str t = "[0 = c_2, 0 = q_0 * L ^^^ 4 / (24 * EI) + (L * c + c_2)]"
   187 then () else error "eqsystem.sml rewrite in 2x2 simplify_System_par.1b";
   188 
   189 val SOME (t,_) = rewrite_set_inst_ thy true bdvs isolate_bdvs t;
   190 if term2str t = "[c_2 = 0, L * c + c_2 = 0 + -1 * (q_0 * L ^^^ 4 / (24 * EI))]"
   191 then () else error "eqsystem.sml rewrite in 2x2 isolate_bdvs b";
   192 
   193 val SOME(t,_)= rewrite_set_inst_ thy true bdvs simplify_System t;
   194 if term2str t = "[c_2 = 0, L * c + c_2 = -1 * q_0 * L ^^^ 4 / (24 * EI)]"
   195 then () else error "eqsystem.sml rewrite in 2x2 simplify_System.2b";
   196 
   197 val xxx = rewrite_set_ thy true order_system t;
   198 if is_none xxx
   199 then () else error "eqsystem.sml rewrite in 2x2 simplify_System.3b";
   200 
   201 
   202 "----------- rewrite in [EqSystem,top_down_substitution,2x2] -----";
   203 "----------- rewrite in [EqSystem,top_down_substitution,2x2] -----";
   204 "----------- rewrite in [EqSystem,top_down_substitution,2x2] -----";
   205 val e1__ = str2term "c_2 = 77";
   206 val e2__ = str2term "L * c + c_2 = q_0 * L ^^^ 2 / 2";
   207 val bdvs = [(str2term"bdv_1",str2term"c"),
   208 	    (str2term"bdv_2",str2term"c_2")];
   209 val SOME (e2__,_) = rewrite_terms_ thy dummy_ord Erls [e1__] e2__;
   210 if term2str e2__ = "L * c + 77 = q_0 * L ^^^ 2 / 2" then ()
   211 else error "eqsystem.sml top_down_substitution,2x2] subst";
   212 
   213 val SOME (e2__,_) = 
   214     rewrite_set_inst_ thy true bdvs simplify_System_parenthesized e2__;
   215 if term2str e2__ = "77 + L * c = q_0 * L ^^^ 2 / 2" then ()
   216 else error "eqsystem.sml top_down_substitution,2x2] simpl_par";
   217 
   218 val SOME (e2__,_) = rewrite_set_inst_ thy true bdvs isolate_bdvs e2__;
   219 if term2str e2__ = "c = (q_0 * L ^^^ 2 / 2 + -1 * 77) / L" then ()
   220 else error "eqsystem.sml top_down_substitution,2x2] isolate";
   221 
   222 val t = str2term "[c_2 = 77, c = (q_0 * L ^^^ 2 / 2 + -1 * 77) / L]";
   223 val SOME (t,_) = rewrite_set_ thy true order_system t;
   224 if term2str t = "[c = (q_0 * L ^^^ 2 / 2 + -1 * 77) / L, c_2 = 77]" then ()
   225 else error "eqsystem.sml top_down_substitution,2x2] order_system";
   226 
   227 if not (ord_simplify_System
   228 	    false thy [] 
   229 	    (str2term"[c_2 = 77, c = (q_0 * L ^^^ 2 / 2 + -1 * 77) / L]", 
   230 	     str2term"[c = (q_0 * L ^^^ 2 / 2 + -1 * 77) / L, c_2 = 77]")) 
   231 then () else error "eqsystem.sml, order_result rew_ord";
   232 
   233 trace_rewrite:=true;
   234 trace_rewrite:=false;
   235 
   236 
   237 "----------- rewrite in [EqSystem,normalize,4x4] -----------------";
   238 "----------- rewrite in [EqSystem,normalize,4x4] -----------------";
   239 "----------- rewrite in [EqSystem,normalize,4x4] -----------------";
   240 (*STOPPED.WN06?: revise rewrite in [EqSystem,normalize,4x4] from before 0609*)
   241 val t = str2term"[0 = -1 * q_0 * 0 ^^^ 2 / 2 + 0 * c_3 + c_4,\
   242 	        \0 = -1 * q_0 * L ^^^ 2 / 2 + L * c_3 + c_4,\
   243 		\c + c_2 + c_3 + c_4 = 0,\
   244 		\c_2 + c_3 + c_4 = 0]";
   245 val bdvs = [(str2term"bdv_1",str2term"c"),
   246 	    (str2term"bdv_2",str2term"c_2"),
   247 	    (str2term"bdv_3",str2term"c_3"),
   248 	    (str2term"bdv_4",str2term"c_4")];
   249 val SOME (t,_) = 
   250     rewrite_set_inst_ thy true bdvs simplify_System_parenthesized t;
   251 if term2str t = "[0 = c_4, 0 = -1 * q_0 * L ^^^ 2 / 2 + (L * c_3 + c_4),\n\
   252 	        \ c + (c_2 + (c_3 + c_4)) = 0, c_2 + (c_3 + c_4) = 0]"
   253 then () else error "eqsystem.sml rewrite in 4x4 simplify_System_paren";
   254 
   255 val SOME (t,_) = rewrite_set_inst_ thy true bdvs isolate_bdvs t;
   256 if term2str t = "[c_4 = 0, \
   257 	        \L * c_3 + c_4 = 0 + -1 * (-1 * q_0 * L ^^^ 2 / 2),\n \
   258 		\c + (c_2 + (c_3 + c_4)) = 0, c_2 + (c_3 + c_4) = 0]"
   259 then () else error "eqsystem.sml rewrite in 4x4 isolate_bdvs";
   260 
   261 val SOME(t,_)= rewrite_set_inst_ thy true bdvs simplify_System_parenthesized t;
   262 if term2str t = "[c_4 = 0,\
   263 		\ L * c_3 + c_4 = q_0 * L ^^^ 2 / 2,\
   264 		\ c + (c_2 + (c_3 + c_4)) = 0,\n\
   265 		\ c_2 + (c_3 + c_4) = 0]"
   266 then () else error "eqsystem.sml rewrite in 4x4 simplify_System_p..2";
   267 
   268 val SOME (t,_) = rewrite_set_ thy true order_system t;
   269 if term2str t = "[c_4 = 0,\
   270 		\ L * c_3 + c_4 = q_0 * L ^^^ 2 / 2,\
   271 		\ c_2 + (c_3 + c_4) = 0,\n\
   272 		\ c + (c_2 + (c_3 + c_4)) = 0]"
   273 then () else error "eqsystem.sml rewrite in 4x4 order_system";
   274 
   275 "----------- refine [linear,system]-------------------------------";
   276 "----------- refine [linear,system]-------------------------------";
   277 "----------- refine [linear,system]-------------------------------";
   278 val fmz =
   279   ["equalities [0 = -1 * q_0 * 0 ^^^ 2 / 2 + 0 * c + c_2," ^
   280                "0 = -1 * q_0 * L ^^^ 2 / 2 + L * c + (c_2::real)]", 
   281 	   "solveForVars [c, c_2]", "solution LL"];
   282 
   283 (*WN120313 in "solution L" above "refine fmz ["linear","system"]" caused an error...*)
   284 "~~~~~ fun refine, args:"; val ((fmz:fmz_), (pblID:pblID)) = (fmz, ["linear","system"]);
   285 "~~~~~ fun refin', args:"; val ((pblRD: pblRD), fmz, pbls, ((Ptyp (pI, [py], [])): pbt ptyp)) =
   286    ((rev o tl) pblID, fmz, [(*match list*)],
   287      ((Ptyp ("linear", [get_pbt ["linear","system"]], [])): pbt ptyp));
   288       val {thy, ppc, where_, prls, ...} = py ;
   289 "~~~~~ fun prep_ori, args:"; val (fmz, thy, pbt) = (fmz, thy, ppc);
   290 (*      val ctxt = Proof_Context.init_global thy |> fold declare_constraints fmz;*)
   291         val ctxt = Proof_Context.init_global thy;
   292 "~~~~~ fun declare_constraints, args:"; val (t, ctxt) = (nth 1 fmz, ctxt);
   293       fun get_vars ((v,T)::vs) = (case raw_explode v |> Library.read_int of
   294               (_, _::_) => (Free (v,T)::get_vars vs)
   295             | (_, []  ) => get_vars vs) (*filter out nums as long as 
   296                                           we have Free ("123",_)*)
   297         | get_vars [] = [];
   298                                         t = "equalities [0 = -1 * q_0 * 0 ^^^ 2 / 2 + 0 * c + c_2,"^
   299                                             "0 = -1 * q_0 * L ^^^ 2 / 2 + L * c + (c_2::real)]";
   300       val ts = Term.add_frees (Syntax.read_term ctxt t) [] |> get_vars;
   301 val ctxt = Variable.declare_constraints (nth 1 ts) ctxt;
   302 val ctxt = Variable.declare_constraints (nth 2 ts) ctxt;
   303 val ctxt = Variable.declare_constraints (nth 3 ts) ctxt;
   304 val ctxt = Variable.declare_constraints (nth 4 ts) ctxt;
   305                                         val t = nth 2 fmz; t = "solveForVars [c, c_2]";
   306       val ts = Term.add_frees (Syntax.read_term ctxt t) [] |> get_vars;
   307 val ctxt = Variable.declare_constraints (nth 1 ts) ctxt;
   308                                         val t = nth 3 fmz; t = "solution LL";
   309       (*(Syntax.read_term ctxt t); 
   310 Type unification failed: Clash of types "real" and "_ list"
   311 Type error in application: incompatible operand type
   312 
   313 Operator:  solution :: bool list \<Rightarrow> toreall
   314 Operand:   L :: real                 ========== L was already present in equalities ========== *)
   315 
   316 "===== case 1 =====";
   317 val matches = refine fmz ["linear","system"];
   318 case matches of 
   319  [Matches (["linear", "system"], _),
   320   Matches (["2x2", "linear", "system"], _),
   321   NoMatch (["triangular", "2x2", "linear", "system"], _),
   322 		  Matches (["normalize", "2x2", "linear", "system"],
   323 			    {Find = [Correct "solution LL"],
   324 			     With = [],
   325 			     Given =
   326 			       [Correct
   327 				"equalities\n [0 = -1 * q_0 * 0 ^^^ 2 / 2 + 0 * c + c_2,\n  0 = -1 * q_0 * L ^^^ 2 / 2 + L * c + c_2]",
   328 				        Correct "solveForVars [c, c_2]"],
   329 				     Where = [],
   330 				     Relate = []})] => ()
   331 | _ => error "eqsystem.sml refine ['normalize','2x2'...]";
   332 
   333 "===== case 2 =====";
   334 val fmz = ["equalities [c_2 = 0, L * c + c_2 = q_0 * L ^^^ 2 / 2]", 
   335 	   "solveForVars [c, c_2]", "solution LL"];
   336 val matches = refine fmz ["linear","system"];
   337 case matches of [_,_,
   338 		  Matches
   339 		    (["triangular", "2x2", "linear", "system"],
   340 		      {Find = [Correct "solution LL"],
   341 		       With = [],
   342 		       Given =
   343 		        [Correct "equalities [c_2 = 0, L * c + c_2 = q_0 * L ^^^ 2 / 2]",
   344 		         Correct "solveForVars [c, c_2]"],
   345 		       Where = [Correct
   346 			"tl [c, c_2] from [c, c_2] occur_exactly_in NTH 1\n      [c_2 = 0, L * c + c_2 = q_0 * L ^^^ 2 / 2]",
   347 			                Correct
   348 				"[c, c_2] from [c, c_2] occur_exactly_in NTH 2\n   [c_2 = 0, L * c + c_2 = q_0 * L ^^^ 2 / 2]"],
   349 		       Relate = []})] => ()
   350 | _ => error "eqsystem.sml refine ['triangular','2x2'...]";
   351 
   352 (*WN051014---------------------------------------------------------------- 
   353   the above 'val matches = refine fmz ["linear","system"]'
   354   didn't work anymore; we investigated in these steps:*)
   355 val fmz = ["equalities [c_2 = 0, L * c + c_2 = q_0 * L ^^^ 2 / 2]", 
   356 	  "solveForVars [c, c_2]", "solution LL"];
   357 val matches = refine fmz ["triangular", "2x2", "linear","system"];
   358 (*... resulted in 
   359    False "[c, c_2] from_ [c, c_2] occur_exactly_in nth_ 2\n    
   360           [c_2 = 0, L * c + c_2 = q_0 * L ^^^ 2 / 2]"]*)
   361 val t = str2term ("[c, c_2] from [c, c_2] occur_exactly_in NTH 2" ^   
   362 		  "[c_2 = 0, L * c + c_2 = q_0 * L ^^^ 2 / 2]");
   363 trace_rewrite := false;
   364 val SOME (t',_) = rewrite_set_ thy false prls_triangular t;
   365 (*found:...
   366 ##  try thm: NTH_CONS
   367 ###  eval asms: 1 < 2 + - 1
   368 ==> nth_ (2 + - 1) [L * c + c_2 = q_0 * L ^^^ 2 / 2] =
   369     nth_ (2 + - 1 + - 1) []
   370 ####  rls: erls_prls_triangular on: 1 < 2 + - 1
   371 #####  try calc: op <'
   372 ###  asms accepted: ["1 < 2 + - 1"]   stored: ["1 < 2 + -1"]
   373 
   374 ... i.e Calc ("Groups.plus_class.plus", eval_binop "#add_") was missing in erls_prls_triangular*)
   375 trace_rewrite:=false;
   376 
   377 "===== case 3: relaxed preconditions for triangular system =====";
   378 val fmz = ["equalities [L * q_0 = c,                               \
   379 	   \            0 = (2 * c_2 + 2 * L * c + -1 * L ^^^ 2 * q_0) / 2,\
   380 	   \            0 = c_4,                                           \
   381 	   \            0 = c_3]", 
   382 	   "solveForVars [c, c_2, c_3, c_4]", "solution LL"];
   383 (*============ inhibit exn WN120314 TODO: investigate type error (same) in these 2 cases:
   384 probably exn thrown by fun declare_constraints
   385 /-------------------------------------------------------\
   386 Type unification failed
   387 Type error in application: incompatible operand type
   388 
   389 Operator:  op # c_3 :: 'a list \<Rightarrow> 'a list
   390 Operand:   [c_4] :: 'b list
   391 \-------------------------------------------------------/
   392 val matches = refine fmz ["linear","system"];
   393 case matches of 
   394     [Matches (["linear", "system"], _),
   395      NoMatch (["2x2", "linear", "system"], _),
   396      NoMatch (["3x3", "linear", "system"], _),
   397      Matches (["4x4", "linear", "system"], _),
   398      NoMatch (["triangular", "4x4", "linear", "system"], _),
   399      Matches (["normalize", "4x4", "linear", "system"], _)] => ()
   400   | _ => error "eqsystem.sml: refine relaxed triangular sys NoMatch";
   401 (*WN060914 does NOT match, because 3rd and 4th equ are not ordered*)
   402 
   403 "===== case 4 =====";
   404 val fmz = ["equalities [L * q_0 = c,                                       \
   405 	   \            0 = (2 * c_2 + 2 * L * c + -1 * L ^^^ 2 * q_0) / 2,\
   406 	   \            0 = c_3,                           \
   407 	   \            0 = c_4]", 
   408 	   "solveForVars [c, c_2, c_3, c_4]", "solution LL"];
   409 val matches = refine fmz ["triangular", "4x4", "linear","system"];
   410 case matches of 
   411     [Matches (["triangular", "4x4", "linear", "system"], _)] => ()
   412   | _ => error "eqsystem.sml: refine relaxed triangular sys Matches";
   413 val matches = refine fmz ["linear","system"];
   414 ============ inhibit exn WN120314 ==============================================*)
   415 
   416 "----------- refine [2x2,linear,system] search error--------------";
   417 "----------- refine [2x2,linear,system] search error--------------";
   418 "----------- refine [2x2,linear,system] search error--------------";
   419 (*didn't go into ["2x2", "linear", "system"]; 
   420   we investigated in these steps:*)
   421 val fmz = ["equalities [0 = -1 * q_0 * 0 ^^^ 2 / 2 + 0 * c + c_2,\
   422 	               \0 = -1 * q_0 * L ^^^ 2 / 2 + L * c + c_2]", 
   423 	   "solveForVars [c, c_2]", "solution LL"];
   424 trace_rewrite := false;
   425 val matches = refine fmz ["2x2", "linear","system"];
   426 trace_rewrite:=false;
   427 print_depth 11; matches; print_depth 3;
   428 (*brought: 'False "length_ es_ = 2"'*)
   429 
   430 (*-----fun refin' (pblRD:pblRD) fmz pbls ((Ptyp (pI,[py],[])):pbt ptyp) =
   431 (* val ((pblRD:pblRD), fmz, pbls, ((Ptyp (pI,[py],[])):pbt ptyp)) =
   432        (rev ["linear","system"], fmz, [(*match list*)],
   433 	((Ptyp ("2x2",[get_pbt ["2x2","linear","system"]],[])):pbt ptyp));
   434    *)
   435 > show_types:=true; term2str (hd where_); show_types:=false;
   436 val it = "length_ (es_::real list) = (2::real)" : string
   437 
   438 =========================================================================\
   439 -------fun prep_pbt
   440 (* val (thy, (pblID, dsc_dats: (string * (string list)) list, 
   441 		  ev:rls, ca: string option, metIDs:metID list)) =
   442        (EqSystem.thy, (["system"],
   443 		       [("#Given" ,["equalities es_", "solveForVars v_s"]),
   444 			("#Find"  ,["solution ss___"](*___ is copy-named*))
   445 			],
   446 		       append_rls "e_rls" e_rls [(*for preds in where_*)], 
   447 		       SOME "solveSystem es_ v_s", 
   448 		       []));
   449    *)
   450 > val [("#Given", [equalities_es_, "solveForVars v_s"])] = gi;
   451 val equalities_es_ = "equalities es_" : string
   452 > val (dd, ii) = (split_did o term_of o the o (parse thy)) equalities_es_;
   453 > show_types:=true; term2str ii; show_types:=false;
   454 val it = "es_::bool list" : string
   455 ~~~~~~~~~~~~~~~^^^^^^^^^ OK~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   456 
   457 > val {where_,...} = get_pbt ["2x2", "linear","system"];
   458 > show_types:=true; term2str (hd where_); show_types:=false;
   459 
   460 =========================================================================/
   461 
   462 -----fun refin' ff:
   463 > (writeln o (itms2str_ (thy2ctxt @{theory Isac}))) itms;
   464 [
   465 (1 ,[1] ,true ,#Given ,Cor equalities
   466  [0 = -1 * q_0 * 0 ^^^ 2 / 2 + 0 * c + c_2,
   467   0 = -1 * q_0 * L ^^^ 2 / 2 + L * c + c_2] ,(es_, [[0 = -1 * q_0 * 0 ^^^ 2 / 2 + 0 * c + c_2,
   468  0 = -1 * q_0 * L ^^^ 2 / 2 + L * c + c_2]])),
   469 (2 ,[1] ,true ,#Given ,Cor solveForVars [c, c_2] ,(v_s, [[c, c_2]])),
   470 (3 ,[1] ,true ,#Find ,Cor solution L ,(ss___, [L]))]
   471 
   472 > (writeln o pres2str) pre';
   473 [
   474 (false, length_ es_ = 2),
   475 (true, length_ [c, c_2] = 2)]
   476 
   477 ----- fun match_oris':
   478 > (writeln o (itms2str_ (thy2ctxt @{theory Isac}))) itms;
   479 > (writeln o pres2str) pre';
   480 ..as in refin'
   481 
   482 ----- fun check_preconds'
   483 > (writeln o env2str) env;
   484 ["
   485 (es_, [0 = -1 * q_0 * 0 ^^^ 2 / 2 + 0 * c + c_2,
   486  0 = -1 * q_0 * L ^^^ 2 / 2 + L * c + c_2])","
   487 (v_s, [c, c_2])","
   488 (ss___, L)"]
   489 
   490 > val es_ = (fst o hd) env;
   491 val es_ = Free ("es_", "bool List.list") : Term.term
   492 
   493 > val pre1 = hd pres;
   494 atomty pre1;
   495 ***
   496 *** Const (op =, [real, real] => bool)
   497 *** . Const (ListG.length_, real list => real)
   498 *** . . Free (es_, real list)
   499 ~~~~~~~~~~~~~~~~~~~^^^^^^^^^ should be bool list~~~~~~~~~~~~~~~~~~~
   500 *** . Free (2, real)
   501 ***
   502 
   503 THE REASON WAS A non-type-constrained variable IN #WHERE OF PROBLEM
   504 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   505 *)
   506 
   507 "----------- me [EqSystem,normalize,2x2] -------------------------";
   508 "----------- me [EqSystem,normalize,2x2] -------------------------";
   509 "----------- me [EqSystem,normalize,2x2] -------------------------";
   510 val fmz = ["equalities [0 = -1 * q_0 * 0 ^^^ 2 / 2 + 0 * c + c_2,\
   511 	               \0 = -1 * q_0 * L ^^^ 2 / 2 + L * c + c_2]", 
   512 	   "solveForVars [c, c_2]", "solution LL"];
   513 val (dI',pI',mI') =
   514   ("Biegelinie",["normalize", "2x2", "linear", "system"],
   515    ["EqSystem","normalize","2x2"]);
   516 val p = e_pos'; val c = []; 
   517 val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
   518 val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
   519 val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
   520 val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
   521 val (p,_,f,nxt,_,pt) = me nxt p c pt;
   522 case nxt of ("Specify_Method",_) => ()
   523 	  | _ => error "eqsystem.sml [EqSystem,normalize,2x2] specify";
   524 
   525 val (p,_,f,nxt,_,pt) = me nxt p c pt;
   526 val (p,_,f,nxt,_,pt) = me nxt p c pt;f2str f;
   527 val (p,_,f,nxt,_,pt) = me nxt p c pt;f2str f(*["(bdv_1, c)", "(bdv_2, hd (tl [c, c_2] ... corrected srls; ran only AFTER use"RCODE-root.sml", store_met was NOT SUFFICIENT*);
   528 val (p,_,f,nxt,_,pt) = me nxt p c pt;f2str f;
   529 val (p,_,f,nxt,_,pt) = me nxt p c pt;f2str f;
   530 val (p,_,f,nxt,_,pt) = me nxt p c pt;f2str f;
   531 case nxt of
   532     (_, Subproblem ("Biegelinie", ["triangular", "2x2", "linear",_])) => ()
   533   | _ => error "eqsystem.sml me [EqSystem,normalize,2x2] SubProblem";
   534 
   535 val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
   536 val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
   537 val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
   538 val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
   539 case nxt of
   540     (_, Specify_Method ["EqSystem", "top_down_substitution", "2x2"]) => ()
   541   | _ => error "eqsystem.sml me [EqSys...2x2] top_down_substitution";
   542 
   543 val (p,_,f,nxt,_,pt) = me nxt p c pt;
   544 val PblObj {probl,...} = get_obj I pt [5];
   545     (writeln o (itms2str_ (thy2ctxt @{theory Isac}))) probl;
   546 (*[
   547 (1 ,[1] ,true ,#Given ,Cor equalities [c_2 = 0, L * c + c_2 = q_0 * L ^^^ 2 / 2] ,(es_, [[c_2 = 0, L * c + c_2 = q_0 * L ^^^ 2 / 2]])),
   548 (2 ,[1] ,true ,#Given ,Cor solveForVars [c, c_2] ,(v_s, [[c, c_2]])),
   549 (3 ,[1] ,true ,#Find ,Cor solution ss___ ,(ss___, [ss___]))]
   550 *)
   551 val (p,_,f,nxt,_,pt) = me nxt p c pt;f2str f;
   552 val (p,_,f,nxt,_,pt) = me nxt p c pt;f2str f;
   553 val (p,_,f,nxt,_,pt) = me nxt p c pt;f2str f;
   554 val (p,_,f,nxt,_,pt) = me nxt p c pt;f2str f;
   555 val (p,_,f,nxt,_,pt) = me nxt p c pt;f2str f;
   556 val (p,_,f,nxt,_,pt) = me nxt p c pt;f2str f;
   557 val (p,_,f,nxt,_,pt) = me nxt p c pt;f2str f;
   558 val (p,_,f,nxt,_,pt) = me nxt p c pt;f2str f;
   559 case nxt of
   560     (_, Check_Postcond ["triangular", "2x2", "linear", "system"]) => ()
   561   | _ => error "eqsystem.sml me Subpbl .[EqSys...2x2] finished";
   562 val (p,_,f,nxt,_,pt) = me nxt p c pt;f2str f;
   563 val (p,_,f,nxt,_,pt) = me nxt p c pt;f2str f;
   564 if f2str f = "[c = L * q_0 / 2, c_2 = 0]" then ()
   565 else error "eqsystem.sml me [EqSys...2x2] finished f2str f";
   566 case nxt of
   567     (_, End_Proof') => ()
   568   | _ => error "eqsystem.sml me [EqSys...2x2] finished End_Proof'";
   569 
   570 "----------- me [linear,system] ..normalize..top_down_sub..-------";
   571 "----------- me [linear,system] ..normalize..top_down_sub..-------";
   572 "----------- me [linear,system] ..normalize..top_down_sub..-------";
   573 val fmz = 
   574     ["equalities\
   575      \[0 = c_2 + c * 0 + 1 / EI * (L * q_0 / 12 * 0 ^^^ 3 +                \
   576      \                                            -1 * q_0 / 24 * 0 ^^^ 4),\
   577      \ 0 = c_2 + c * L + 1 / EI * (L * q_0 / 12 * L ^^^ 3 +                \
   578      \                                            -1 * q_0 / 24 * L ^^^ 4)]",
   579      "solveForVars [c, c_2]", "solution LL"];
   580 val (dI',pI',mI') =
   581   ("Biegelinie",["linear", "system"], ["no_met"]);
   582 val p = e_pos'; val c = []; 
   583 val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
   584 val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
   585 val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
   586 val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
   587 val (p,_,f,nxt,_,pt) = me nxt p c pt;
   588 case nxt of (_,Specify_Method ["EqSystem", "normalize", "2x2"]) => ()
   589 	  | _ => error "eqsystem.sml [linear,system] specify b";
   590 val (p,_,f,nxt,_,pt) = me nxt p c pt;
   591 val (p,_,f,nxt,_,pt) = me nxt p c pt;f2str f;
   592 val (p,_,f,nxt,_,pt) = me nxt p c pt;f2str f;
   593 val (p,_,f,nxt,_,pt) = me nxt p c pt;f2str f;
   594 val (p,_,f,nxt,_,pt) = me nxt p c pt;f2str f;
   595 val (p,_,f,nxt,_,pt) = me nxt p c pt;f2str f;
   596 if f2str f = 
   597 "[c_2 = 0, L * c + c_2 = -1 * q_0 * L ^^^ 4 / (24 * EI)]"
   598 then () else error "eqsystem.sml me simpl. before SubProblem b";
   599 case nxt of
   600     (_, Subproblem ("Biegelinie", ["triangular", "2x2", "linear",_])) => ()
   601   | _ => error "eqsystem.sml me [linear,system] SubProblem b";
   602 
   603 val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
   604 val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
   605 val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
   606 val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
   607 case nxt of
   608     (_, Specify_Method ["EqSystem", "top_down_substitution", "2x2"]) => ()
   609   | _ => error "eqsystem.sml me [EqSys...2x2] top_down_substitution b";
   610 
   611 val (p,_,f,nxt,_,pt) = me nxt p c pt;
   612 val PblObj {probl,...} = get_obj I pt [5];
   613     (writeln o (itms2str_ (thy2ctxt @{theory Isac}))) probl;
   614 (*[
   615 (1 ,[1] ,true ,#Given ,Cor equalities [c_2 = 0, L * c + c_2 = q_0 * L ^^^ 2 / 2] ,(es_, [[c_2 = 0, L * c + c_2 = q_0 * L ^^^ 2 / 2]])),
   616 (2 ,[1] ,true ,#Given ,Cor solveForVars [c, c_2] ,(v_s, [[c, c_2]])),
   617 (3 ,[1] ,true ,#Find ,Cor solution ss___ ,(ss___, [ss___]))]
   618 *)
   619 val (p,_,f,nxt,_,pt) = me nxt p c pt;f2str f;
   620 val (p,_,f,nxt,_,pt) = me nxt p c pt;f2str f;
   621 val (p,_,f,nxt,_,pt) = me nxt p c pt;f2str f;
   622 val (p,_,f,nxt,_,pt) = me nxt p c pt;f2str f;
   623 val (p,_,f,nxt,_,pt) = me nxt p c pt;f2str f;
   624 val (p,_,f,nxt,_,pt) = me nxt p c pt;f2str f;
   625 val (p,_,f,nxt,_,pt) = me nxt p c pt;f2str f;
   626 val (p,_,f,nxt,_,pt) = me nxt p c pt;f2str f;
   627 case nxt of
   628     (_, Check_Postcond ["triangular", "2x2", "linear", "system"]) => ()
   629   | _ => error "eqsystem.sml me Subpbl .[EqSys...2x2] finished b";
   630 val (p,_,f,nxt,_,pt) = me nxt p c pt;f2str f;
   631 val (p,_,f,nxt,_,pt) = me nxt p c pt;f2str f;
   632 if f2str f = 
   633 "[c = -1 * q_0 * L ^^^ 4 / (24 * EI * L), c_2 = 0]"
   634 then () else error "eqsystem.sml me [EqSys...2x2] finished f2str f b";
   635 case nxt of
   636     (_, End_Proof') => ()
   637   | _ => error "eqsystem.sml me [EqSys...2x2] finished End_Proof'";
   638 
   639 
   640 "----------- all systems from Biegelinie -------------------------";
   641 "----------- all systems from Biegelinie -------------------------";
   642 "----------- all systems from Biegelinie -------------------------";
   643 val subst = [(str2term "bdv_1", str2term "c"),
   644 	     (str2term "bdv_2", str2term "c_2"),
   645 	     (str2term "bdv_3", str2term "c_3"),
   646 	     (str2term "bdv_4", str2term "c_4")]; 
   647 "------- Bsp 7.27";
   648 states:=[];
   649 CalcTree [(["Traegerlaenge L","Streckenlast q_0","Biegelinie y",
   650 	     "Randbedingungen [y 0 = 0, y L = 0, M_b 0 = 0, M_b L = 0]",
   651 	     "FunktionsVariable x"],
   652 	    ("Biegelinie", ["Biegelinien"],
   653 		     ["IntegrierenUndKonstanteBestimmen2"]))];
   654 moveActiveRoot 1;
   655 (*
   656 trace_script := true; autoCalculate 1 CompleteCalc; trace_script := false;
   657 ##7.27##          ordered           substs
   658           c_4       c_2           
   659 c c_2 c_3 c_4     c c_2             1->2: c
   660   c_2                       c_4	  
   661 c c_2             c c_2 c_3 c_4     [2':c, 1:c_2, 3:c_4] -> 4:c_3*)
   662 val t = str2term"[0 = c_4,                           \
   663 \ 0 = c_4 + L * c_3 +(12 * L ^^^ 2 * c_2 + 4 * L ^^^ 3 * c + -1 * L ^^^ 4 * q_0) / (-24 * EI),                                       \
   664 \ 0 = c_2,                                           \
   665 \ 0 = (2 * c_2 + 2 * L * c + -1 * L ^^^ 2 * q_0) / 2]";
   666 val SOME (t',_) = rewrite_set_ thy false isolate_bdvs_4x4 t;
   667 term2str t';
   668 "[c_4 = 0,\n (12 * L ^^^ 2 * c_2 + 4 * L ^^^ 3 * c + -1 * L ^^^ 4 * q_0) / (-24 * EI) =\n 0 + -1 * (c_4 + L * c_3),\n c_2 = 0, (2 * c_2 + 2 * L * c + -1 * L ^^^ 2 * q_0) / 2 = 0]";
   669 
   670 "----- 7.27 go through the rewrites in met_eqsys_norm_4x4";
   671 val t = str2term "0 = (2 * c_2 + 2 * L * c + -1 * L ^^^ 2 * q_0) / 2";
   672 val NONE = rewrite_set_ thy false norm_Rational t;
   673 val SOME (t,_) = 
   674     rewrite_set_inst_ thy false subst simplify_System_parenthesized t;
   675 term2str t = "0 = -1 * q_0 * L ^^^ 2 / 2 + (L * c + c_2)";
   676 "--- isolate_bdvs_4x4";
   677 (*
   678 val SOME (t,_) = rewrite_set_inst_ thy false subst isolate_bdvs_4x4 t;
   679 term2str t;
   680 val SOME (t,_) = rewrite_set_inst_ thy false subst simplify_System t;
   681 term2str t;
   682 val SOME (t,_) = rewrite_set_ thy false order_system t;
   683 term2str t;
   684 *)
   685 
   686 "------- Bsp 7.28 ---------------vvvvvvvvvvvvv Momentenlinie postponed";
   687 states:=[];
   688 CalcTree [(["Traegerlaenge L","Momentenlinie (-q_0 / L * x^3 / 6)",
   689 	    "Biegelinie y",
   690 	    "Randbedingungen [y L = 0, y' L = 0]",
   691 	    "FunktionsVariable x"],
   692 	   ("Biegelinie", ["vonMomentenlinieZu","Biegelinien"],
   693 	    ["Biegelinien", "AusMomentenlinie"]))];
   694 moveActiveRoot 1;
   695 (*
   696 trace_script := true; autoCalculate 1 CompleteCalc; trace_script := false;
   697 *)
   698 
   699 "------- Bsp 7.69";
   700 states:=[];
   701 CalcTree [(["Traegerlaenge L","Streckenlast q_0","Biegelinie y",
   702 	     "Randbedingungen [y 0 = 0, y L = 0, y' 0 = 0, y' L = 0]",
   703 	     "FunktionsVariable x"],
   704 	    ("Biegelinie", ["Biegelinien"],
   705 	     ["IntegrierenUndKonstanteBestimmen2"] ))];
   706 moveActiveRoot 1;
   707 (*
   708 trace_script := true; autoCalculate 1 CompleteCalc; trace_script := false;
   709 ##7.69##          ordered           subst                   2x2
   710           c_4           c_3         
   711 c c_2 c_3 c_4     c c_2 c_3	    1:c_3 -> 2:c c_2        2:         c c_2
   712       c_3                   c_4	 			   
   713 c c_2 c_3         c c_2 c_3 c_4     3:c_4 -> 4:c c_2 c_3    1:c_3 -> 4:c c_2*)
   714 val t = str2term"[0 = c_4 + 0 / (-1 * EI),                                   \
   715 \ 0 = c_4 + L * c_3 + (12 * L ^^^ 2 * c_2 + 4 * L ^^^ 3 * c + -1 * L ^^^ 4 * q_0) / (-24 * EI),                                                              \
   716 \ 0 = c_3 + 0 / (-1 * EI),                                                   \
   717 \ 0 = c_3 + (6 * L * c_2 + 3 * L ^^^ 2 * c + -1 * L ^^^ 3 * q_0) / (-6 * EI)]";
   718 
   719 "------- Bsp 7.70";
   720 states:=[];
   721 CalcTree [(["Traegerlaenge L","Streckenlast q_0","Biegelinie y",
   722 	     "Randbedingungen [Q 0 = q_0 * L, M_b L = 0, y 0 = 0, y' 0 = 0]",
   723 	     "FunktionsVariable x"],
   724 	    ("Biegelinie", ["Biegelinien"],
   725 	     ["IntegrierenUndKonstanteBestimmen2"] ))];
   726 moveActiveRoot 1;
   727 (*
   728 trace_script := true; autoCalculate 1 CompleteCalc; trace_script := false;
   729 ##7.70##        |subst
   730 c		|
   731 c c_2           |1:c -> 2:c_2
   732       c_3	|
   733           c_4   |            STOPPED.WN06? test methods @@@@@@@@@@@@@@@@@@@@@@@*)
   734 
   735 
   736 "----- 7.70 go through the rewrites in met_eqsys_norm_4x4";
   737 val t = str2term"[L * q_0 = c,                       \
   738 		\ 0 = (2 * c_2 + 2 * L * c + -1 * L ^^^ 2 * q_0) / 2,\
   739 		\ 0 = c_4,                           \
   740 		\ 0 = c_3]";
   741 val SOME (t,_) =
   742     rewrite_ thy e_rew_ord e_rls false (num_str @{thm commute_0_equality}) t;
   743 val SOME (t,_) =
   744     rewrite_ thy e_rew_ord e_rls false (num_str @{thm commute_0_equality}) t;
   745 val SOME (t,_) =
   746     rewrite_ thy e_rew_ord e_rls false (num_str @{thm commute_0_equality}) t;
   747 term2str t =
   748    "[L * q_0 = c, (2 * c_2 + 2 * L * c + -1 * L ^^^ 2 * q_0) / 2 = 0, c_4 = 0,\n c_3 = 0]";
   749 val SOME (t,_) = 
   750     rewrite_set_inst_ thy false subst simplify_System_parenthesized t;
   751 term2str t =
   752 "[L * q_0 = c, -1 * q_0 * L ^^^ 2 / 2 + (L * c + c_2) = 0, c_4 = 0, c_3 = 0]";
   753 val SOME (t,_) = rewrite_set_inst_ thy false subst isolate_bdvs_4x4 t;
   754 term2str t =
   755    "[c = (-1 * (L * q_0) + 0) / -1,\n L * c + c_2 = -1 * (-1 * q_0 * L ^^^ 2 / 2) + 0, c_4 = 0, c_3 = 0]";
   756 val SOME (t,_) = 
   757     rewrite_set_inst_ thy false subst simplify_System_parenthesized t;
   758 
   759 term2str t ="[c = L * q_0, L * c + c_2 = q_0 * L ^^^ 2 / 2, c_4 = 0, c_3 = 0]";
   760 val SOME (t,_) = rewrite_set_ thy false order_system t;
   761 if term2str t ="[c = L * q_0, L * c + c_2 = q_0 * L ^^^ 2 / 2, c_3 = 0, c_4 = 0]" then ()
   762 else error "eqsystem.sml: exp 7.70 normalize 4x4 by rewrite changed";
   763 
   764 
   765 "----- 7.70 with met normalize: ";
   766 val fmz = ["equalities                                         \
   767 	    \[L * q_0 = c,                       \
   768 		\ 0 = (2 * c_2 + 2 * L * c + -1 * L ^^^ 2 * q_0) / 2,\
   769 		\ 0 = c_4,                           \
   770 		\ 0 = c_3]", 
   771 	    "solveForVars [c, c_2, c_3, c_4]", "solution LL"];
   772 val (dI',pI',mI') =
   773   ("Biegelinie",["linear", "system"],["no_met"]);
   774 val p = e_pos'; val c = []; 
   775 (*============ inhibit exn WN120314 TODO: investigate type error (same as above)==
   776   in next but one test below the same type error.
   777 /-------------------------------------------------------\
   778 Type unification failed
   779 Type error in application: incompatible operand type
   780 
   781 Operator:  op # c_3 :: 'a list \<Rightarrow> 'a list
   782 Operand:   [c_4] :: 'b list
   783 \-------------------------------------------------------/
   784 
   785 val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
   786 val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
   787 val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
   788 val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
   789 val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
   790 case nxt of (_,Apply_Method ["EqSystem", "normalize", "4x4"]) => ()
   791 	  | _ => error "eqsystem.sml [EqSystem,normalize,4x4] specify";
   792 val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
   793 "----- outcommented before Isabelle2002 --> 2011 -------------------------";
   794 (*vvvWN080102 Exception- Match raised 
   795   since assod Rewrite .. Rewrite'_Set
   796 val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
   797 
   798 val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
   799 val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
   800 
   801 val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
   802 val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
   803 val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
   804 val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
   805 if f2str f ="[c = L * q_0, L * c + c_2 = q_0 * L ^^^ 2 / 2, c_3 = 0, c_4 = 0]" 
   806 then () else error "eqsystem.sml: exp 7.70 normalize 4x4 by met changed";
   807 --------------------------------------------------------------------------*)
   808 
   809 "----- 7.70 with met top_down_: me";
   810 val fmz = ["equalities                                         \
   811 	    \[c = L * q_0, L * c + c_2 = q_0 * L ^^^ 2 / 2, c_3 = 0, c_4 = 0]",
   812 	    "solveForVars [c, c_2, c_3, c_4]", "solution LL"];
   813 val (dI',pI',mI') =
   814   ("Biegelinie",["linear", "system"],["no_met"]);
   815 val p = e_pos'; val c = []; 
   816 val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
   817 val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
   818 val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
   819 val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
   820 val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
   821 case nxt of (_,Apply_Method ["EqSystem", "top_down_substitution", "4x4"]) => ()
   822 	  | _ => error "eqsystem.sml [EqSystem,top_down_,4x4] specify";
   823 val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
   824 val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
   825 val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
   826 val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
   827 val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
   828 val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
   829 if nxt = ("End_Proof'", End_Proof') andalso
   830    f2str f = "[c = L * q_0, c_2 = -1 * L ^^^ 2 * q_0 / 2, c_3 = 0, c_4 = 0]"
   831 then () else error "eqsystem.sml: 7.70 with met top_down_: me";
   832 ============ inhibit exn WN120314 ==============================================*)
   833 
   834 "------- Bsp 7.71";
   835 states:=[];
   836 CalcTree [(["Traegerlaenge L","Streckenlast q_0","Biegelinie y",
   837 	     "Randbedingungen [M_b L = 0, y 0 = 0, y L = 0, y' 0 = 0]",
   838 	     "FunktionsVariable x"],
   839 	    ("Biegelinie", ["Biegelinien"],
   840 	     ["IntegrierenUndKonstanteBestimmen2"] ))];
   841 moveActiveRoot 1;
   842 (*
   843 trace_script := true; autoCalculate 1 CompleteCalc; trace_script := false;
   844 ##7.71##       |ordered       |subst.singles (recurs) |2x2       |diagonal
   845 c c_2          |c c_2	      |1'		      |1': c c_2 |
   846           c_4  |      c_3     |2:c_3 -> 4' :c c_2 c_4 |	         |
   847 c c_2 c_3 c_4  |          c_4 |3'                     |	         |
   848       c_3      |c c_2 c_3 c_4 |3:c_4 -> 4'':c c_2     |4'':c c_2 |      *)
   849 val t = str2term"[0 = (2 * c_2 + 2 * L * c + -1 * L ^^^ 2 * q_0) / 2, \
   850 \ 0 = c_4 + 0 / (-1 * EI),                            \
   851 \ 0 = c_4 + L * c_3 +(12 * L ^^^ 2 * c_2 + 4 * L ^^^ 3 * c + -1 * L ^^^ 4 * q_0) /(-24 * EI),\
   852 \ 0 = c_3 + 0 / (-1 * EI)]";
   853 
   854 "------- Bsp 7.72a ---------------vvvvvvvvvvvvv Momentenlinie postponed";
   855 states:=[];
   856 CalcTree [(["Traegerlaenge L",
   857 	    "Momentenlinie ((q_0 * L)/ 6 * x - q_0 /(6 * L) * x^3)",
   858 	    "Biegelinie y",
   859 	    "Randbedingungen [y 0 = 0, y L = 0]",
   860 	    "FunktionsVariable x"],
   861 	   ("Biegelinie", ["vonMomentenlinieZu","Biegelinien"],
   862 	    ["Biegelinien", "AusMomentenlinie"]))];
   863 moveActiveRoot 1;
   864 (*
   865 trace_script := true; autoCalculate 1 CompleteCalc; trace_script := false;
   866 *)
   867 
   868 "------- Bsp 7.72b";
   869 states:=[];
   870 CalcTree [(["Traegerlaenge L","Streckenlast (q_0 / L * x)","Biegelinie y",
   871 	    "Randbedingungen [M_b 0 = 0, M_b L = 0, y 0 = 0, y L = 0]",
   872 	    "FunktionsVariable x"],
   873 	   ("Biegelinie", ["Biegelinien"],
   874 	    ["IntegrierenUndKonstanteBestimmen2"] ))];
   875 moveActiveRoot 1;
   876 (*
   877 trace_script := true; autoCalculate 1 CompleteCalc; trace_script := false;
   878 ##7.72b##      |ord. |subst.singles         |ord.triang.
   879   c_2          |     |			    |c_2  
   880 c c_2	       |     |1:c_2 -> 2':c	    |c_2 c
   881           c_4  |     |			    |
   882 c c_2 c_3 c_4  |     |3:c_4 -> 4':c c_2 c_3 |c_2 c c_3*)
   883 val t = str2term"[0 = c_2,                                            \
   884 \ 0 = (6 * c_2 + 6 * L * c + -1 * L ^^^ 2 * q_0) / 6, \
   885 \ 0 = c_4 + 0 / (-1 * EI),                            \
   886 \ 0 = c_4 + L * c_3 + (60 * L ^^^ 2 * c_2 + 20 * L ^^^ 3 * c + -1 * L ^^^ 4 * q_0) / (-120 * EI)]";
   887 
   888 "------- Bsp 7.73 ---------------vvvvvvvvvvvvv Momentenlinie postponed";
   889 states:=[];
   890 CalcTree [(["Traegerlaenge L","Momentenlinie ???",(*description unclear*)
   891 	    "Biegelinie y",
   892 	    "Randbedingungen [y L = 0, y' L = 0]",
   893 	    "FunktionsVariable x"],
   894 	   ("Biegelinie", ["vonMomentenlinieZu","Biegelinien"],
   895 	    ["Biegelinien", "AusMomentenlinie"]))];
   896 moveActiveRoot 1;
   897 (*
   898 trace_script := true; autoCalculate 1 CompleteCalc; trace_script := false;
   899 *)
   900 
   901 "----------- 4x4 systems from Biegelinie -------------------------";
   902 "----------- 4x4 systems from Biegelinie -------------------------";
   903 "----------- 4x4 systems from Biegelinie -------------------------";
   904 (*STOPPED.WN08?? replace this test with 7.70 *)
   905 "----- Bsp 7.27";
   906 val fmz = ["equalities \
   907 	   \[0 = c_4,                           \
   908 	   \ 0 = c_4 + L * c_3 +(12 * L ^^^ 2 * c_2 + 4 * L ^^^ 3 * c + -1 * L ^^^ 4 * q_0) / (-24 * EI),                                       \
   909 	   \ 0 = c_2,                                           \
   910 	   \ 0 = (2 * c_2 + 2 * L * c + -1 * L ^^^ 2 * q_0) / 2]", 
   911 	   "solveForVars [c, c_2, c_3, c_4]", "solution LL"];
   912 val (dI',pI',mI') =
   913   ("Biegelinie",["normalize", "4x4", "linear", "system"],
   914    ["EqSystem","normalize","4x4"]);
   915 val p = e_pos'; val c = []; 
   916 val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
   917 val (p,_,f,nxt,_,pt) = me nxt p c pt; val (p,_,f,nxt,_,pt) = me nxt p c pt;
   918 val (p,_,f,nxt,_,pt) = me nxt p c pt; val (p,_,f,nxt,_,pt) = me nxt p c pt;
   919 val (p,_,f,nxt,_,pt) = me nxt p c pt; val (p,_,f,nxt,_,pt) = me nxt p c pt;
   920 val (p,_,f,nxt,_,pt) = me nxt p c pt; val (p,_,f,nxt,_,pt) = me nxt p c pt;
   921 "------------------------------------------- Apply_Method...";
   922 val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
   923 "[0 = c_4,                                          \
   924 \ 0 = c_4 + L * c_3 +\n (12 * L ^^^ 2 * c_2 + 4 * L ^^^ 3 * c + -1 * L ^^^ 4 * q_0) / (-24 * EI),                                   \
   925 \ 0 = c_2,                                          \
   926 \ 0 = (2 * c_2 + 2 * L * c + -1 * L ^^^ 2 * q_0) / 2]";
   927 (*vvvWN080102 Exception- Match raised 
   928   since assod Rewrite .. Rewrite'_Set
   929 "------------------------------------------- simplify_System_parenthesized...";
   930 val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
   931 "[0 = c_4,                                  \
   932 \ 0 = -1 * q_0 * L ^^^ 4 / (-24 * EI) +     \
   933 \     (4 * L ^^^ 3 * c / (-24 * EI) +       \
   934 \     (12 * L ^^^ 2 * c_2 / (-24 * EI) +    \
   935 \     (L * c_3 + c_4))),                    \
   936 \ 0 = c_2,                                  \
   937 \ 0 = -1 * q_0 * L ^^^ 2 / 2 + (L * c + c_2)]";
   938 (*? "(4 * L ^^^ 3 / (-24 * EI) * c" statt "(4 * L ^^^ 3 * c / (-24 * EI)" ?*)
   939 "------------------------------------------- isolate_bdvs...";
   940 val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
   941 "[c_4 = 0,\
   942 \ c_4 = 0 + -1 * (-1 * q_0 * L ^^^ 4 / (-24 * EI)) + -1 * (4 * L ^^^ 3 * c / (-24 * EI)) + -1 * (12 * L ^^^ 2 * c_2 / (-24 * EI)) + -1 * (L * c_3),\
   943 \ c_2 = 0, \
   944 \ c_2 = 0 + -1 * (-1 * q_0 * L ^^^ 2 / 2) + -1 * (L * c)]";
   945 val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
   946 
   947 ---------------------------------------------------------------------*)