test/Tools/isac/Interpret/error-pattern.sml
changeset 59909 821f038df564
parent 59907 4c62e16e842e
child 59911 ff30cec13f4f
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/test/Tools/isac/Interpret/error-pattern.sml	Fri Apr 24 08:51:05 2020 +0200
     1.3 @@ -0,0 +1,1384 @@
     1.4 +(* Title: "Interpret/error-pattern.sml"
     1.5 +   Author: Walther Neuper 060225,
     1.6 +   (c) due to copyright terms 
     1.7 +
     1.8 +Strange ERROR "Undefined fact: "all_left""
     1.9 +*)
    1.10 +
    1.11 +"-----------------------------------------------------------------";
    1.12 +"table of contents -----------------------------------------------";
    1.13 +"-----------------------------------------------------------------";
    1.14 +"appendForm with miniscript with mini-subpbl:";
    1.15 +"--------- appendFormula: on Res + equ_nrls ----------------------";
    1.16 +"--------- appendFormula: on Frm + equ_nrls ----------------------";
    1.17 +"--------- appendFormula: on Res + NO deriv ----------------------";
    1.18 +"--------- appendFormula: on Res + late deriv [x = 3 + -2]---///--";
    1.19 +"replaceForm with miniscript with mini-subpbl:";
    1.20 +"--------- replaceFormula: on Res + = ----------------------------";
    1.21 +"--------- replaceFormula: on Res + = 1st Nd ---------------------";
    1.22 +"--------- replaceFormula: on Frm + = 1st Nd ---------------------";
    1.23 +"--------- replaceFormula: cut calculation -----------------------";
    1.24 +"--------- replaceFormula: cut calculation -----------------------";
    1.25 +(* 040307 copied from informtest.sml ... old versions
    1.26 +"--------- maximum-example, UC: Modeling / modifyCalcHead --------";*)
    1.27 +"--------- syntax error ------------------------------------------";
    1.28 +"CAS-command:";
    1.29 +"--------- CAS-command on ([],Pbl) -------------------------------";
    1.30 +"--------- CAS-command on ([],Pbl) FE-interface ------------------";
    1.31 +"--------- locate_input_term [rational,simplification] ----------------------";
    1.32 +"--------- Take as 1st tac, start with <NEW> (CAS input) ---------";
    1.33 +"--------- Take as 1st tac, start from exp -----------------------";
    1.34 +"--------- implicit_take, start with <NEW> (CAS input) ---------------";
    1.35 +"--------- build fun check_for' ------------------------------";
    1.36 +"--------- build fun check_for' ?bdv -------------------------";
    1.37 +"--------- build fun check_for ------------------------";
    1.38 +"--------- embed fun check_for ------------------------";
    1.39 +"--------- embed fun find_fill_patterns ---------------------------";
    1.40 +"--------- build fun is_exactly_equal, inputFillFormula ----------";
    1.41 +"--------- fun appl_adds -----------------------------------------";
    1.42 +"--------- fun concat_deriv --------------------------------------";
    1.43 +"--------- handle an input formula -------------------------------";
    1.44 +"--------- fun dropwhile' ----------------------------------------";
    1.45 +"-----------------------------------------------------------------";
    1.46 +"-----------------------------------------------------------------";
    1.47 +"-----------------------------------------------------------------";
    1.48 +
    1.49 +
    1.50 +"--------- appendFormula: on Res + equ_nrls ----------------------";
    1.51 +"--------- appendFormula: on Res + equ_nrls ----------------------";
    1.52 +"--------- appendFormula: on Res + equ_nrls ----------------------";
    1.53 + val Prog sc = (#scr o get_met) ["Test","squ-equ-test-subpbl1"];
    1.54 + (writeln o UnparseC.term) sc;
    1.55 + val Prog sc = (#scr o get_met) ["Test","solve_linear"];
    1.56 + (writeln o UnparseC.term) sc;
    1.57 +
    1.58 + reset_states ();
    1.59 + CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"], 
    1.60 +	    ("Test", ["sqroot-test","univariate","equation","test"],
    1.61 +	     ["Test","squ-equ-test-subpbl1"]))];
    1.62 + Iterator 1; moveActiveRoot 1;
    1.63 + autoCalculate 1 CompleteCalcHead;
    1.64 + autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
    1.65 + autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
    1.66 +
    1.67 + appendFormula 1 "-2 * 1 + (1 + x) = 0" (*|> Future.join*); refFormula 1 (get_pos 1 1);
    1.68 + val ((pt,_),_) = get_calc 1;
    1.69 + val str = pr_ctree pr_short pt;
    1.70 +if str =
    1.71 +(".    ----- pblobj -----\n" ^
    1.72 +"1.   x + 1 = 2\n" ^
    1.73 +"2.   x + 1 + -1 * 2 = 0\n" ^
    1.74 +"2.1.   x + 1 + -1 * 2 = 0\n" ^
    1.75 +"2.2.   1 + x + -1 * 2 = 0\n" ^
    1.76 +"2.3.   1 + (x + -1 * 2) = 0\n" ^
    1.77 +"2.4.   1 + (x + -2) = 0\n" ^
    1.78 +"2.5.   1 + (x + -2 * 1) = 0\n" ^
    1.79 +"2.6.   1 + x + -2 * 1 = 0\n" ) then ()
    1.80 +else error "inform.sml: diff.behav.appendFormula: on Res + equ 1";
    1.81 +
    1.82 + moveDown 1 ([ ],Pbl); refFormula 1 ([1],Frm); (*x + 1 = 2*)
    1.83 + moveDown 1 ([1],Frm); refFormula 1 ([1],Res); (*x + 1 + -1 * 2 = 0*)
    1.84 +
    1.85 + (*the seven steps of detailed derivation*)
    1.86 + moveDown 1 ([1  ],Res); refFormula 1 ([2,1],Frm); 
    1.87 + moveDown 1 ([2,1],Frm); refFormula 1 ([2,1],Res);
    1.88 + moveDown 1 ([2,1],Res); refFormula 1 ([2,2],Res);
    1.89 + moveDown 1 ([2,2],Res); refFormula 1 ([2,3],Res); 
    1.90 + moveDown 1 ([2,3],Res); refFormula 1 ([2,4],Res);
    1.91 + moveDown 1 ([2,4],Res); refFormula 1 ([2,5],Res);
    1.92 + moveDown 1 ([2,5],Res); refFormula 1 ([2,6],Res);
    1.93 + val ((pt,_),_) = get_calc 1;
    1.94 + if "-2 * 1 + (1 + x) = 0" = UnparseC.term (fst (get_obj g_result pt [2,6])) then()
    1.95 + else error "inform.sml: diff.behav.appendFormula: on Res + equ 2";
    1.96 +
    1.97 + fetchProposedTactic 1; (*takes Iterator 1 _1_*)
    1.98 +(* <ERROR> error in kernel </ERROR> ALREADY IN 2009-2*)
    1.99 +(*========== inhibit exn WN1130701 broken at Isabelle2002 --> 2009-2 =============
   1.100 + val (_,(tac,_,_)::_) = get_calc 1;
   1.101 + if tac = Rewrite_Set "Test_simplify" then ()
   1.102 + else error "inform.sml: diff.behav.appendFormula: on Res + equ 3";
   1.103 +============ inhibit exn WN1130701 broken at Isabelle2002 --> 2009-2 ============*)
   1.104 +
   1.105 + autoCalculate 1 CompleteCalc;
   1.106 + val ((pt,_),_) = get_calc 1;
   1.107 + if "[x = 1]" = UnparseC.term (fst (get_obj g_result pt [])) then ()
   1.108 + else error "inform.sml: diff.behav.appendFormula: on Res + equ 4";
   1.109 + (* autoCalculate 1 CompleteCalc;
   1.110 +   val ((pt,p),_) = get_calc 1;
   1.111 +   (writeln o istates2str) (get_obj g_loc pt [ ]);  
   1.112 +   (writeln o istates2str) (get_obj g_loc pt [1]);  
   1.113 +   (writeln o istates2str) (get_obj g_loc pt [2]);  
   1.114 +   (writeln o istates2str) (get_obj g_loc pt [3]);  
   1.115 +   (writeln o istates2str) (get_obj g_loc pt [3,1]);  
   1.116 +   (writeln o istates2str) (get_obj g_loc pt [3,2]);  
   1.117 +   (writeln o istates2str) (get_obj g_loc pt [4]);  
   1.118 +
   1.119 +   *)
   1.120 +"----------------------------------------------------------";
   1.121 +
   1.122 + val fod = Derive.do_one (@{theory "Isac_Knowledge"}) Atools_erls 
   1.123 +		       ((#rules o Rule_Set.rep) Test_simplify)
   1.124 +		       (sqrt_right false (@{theory "Pure"})) NONE 
   1.125 +		       (str2term "x + 1 + -1 * 2 = 0");
   1.126 + (writeln o Derive.trtas2str) fod;
   1.127 +
   1.128 + val ifod = Derive.do_one (@{theory "Isac_Knowledge"}) Atools_erls 
   1.129 +		       ((#rules o Rule_Set.rep) Test_simplify)
   1.130 +		       (sqrt_right false (@{theory "Pure"})) NONE 
   1.131 +		       (str2term "-2 * 1 + (1 + x) = 0");
   1.132 + (writeln o Derive.trtas2str) ifod;
   1.133 + fun equal (_,_,(t1, _)) (_,_,(t2, _)) = t1 = t2;
   1.134 + val (fod', rifod') = dropwhile' equal (rev fod) (rev ifod);
   1.135 + val der = fod' @ (map Derive.rev_deriv' rifod');
   1.136 + (writeln o Derive.trtas2str) der;
   1.137 + "----------------------------------------------------------";
   1.138 +DEconstrCalcTree 1;
   1.139 +
   1.140 +"--------- appendFormula: on Frm + equ_nrls ----------------------";
   1.141 +"--------- appendFormula: on Frm + equ_nrls ----------------------";
   1.142 +"--------- appendFormula: on Frm + equ_nrls ----------------------";
   1.143 + reset_states ();
   1.144 + CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"], 
   1.145 +	    ("Test", ["sqroot-test","univariate","equation","test"],
   1.146 +	     ["Test","squ-equ-test-subpbl1"]))];
   1.147 + Iterator 1; moveActiveRoot 1;
   1.148 + autoCalculate 1 CompleteCalcHead;
   1.149 + autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1) (*x + 1 = 2*);
   1.150 + appendFormula 1 "2+ -1 + x = 2" (*|> Future.join*); refFormula 1 (get_pos 1 1);
   1.151 +
   1.152 + moveDown 1 ([],Pbl); refFormula 1 ([1],Frm) (*x + 1 = 2*);
   1.153 +
   1.154 + moveDown 1 ([1  ],Frm); refFormula 1 ([1,1],Frm); 
   1.155 + moveDown 1 ([1,1],Frm); refFormula 1 ([1,1],Res); 
   1.156 + moveDown 1 ([1,1],Res); refFormula 1 ([1,2],Res); 
   1.157 + moveDown 1 ([1,2],Res); refFormula 1 ([1,3],Res); 
   1.158 + moveDown 1 ([1,3],Res); refFormula 1 ([1,4],Res); 
   1.159 + moveDown 1 ([1,4],Res); refFormula 1 ([1,5],Res); 
   1.160 + moveDown 1 ([1,5],Res); refFormula 1 ([1,6],Res); 
   1.161 + val ((pt,_),_) = get_calc 1;
   1.162 + if "2 + -1 + x = 2" = UnparseC.term (fst (get_obj g_result pt [1,6])) then()
   1.163 + else error "inform.sml: diff.behav.appendFormula: on Frm + equ 1";
   1.164 +
   1.165 + fetchProposedTactic 1; (*takes Iterator 1 _1_*)
   1.166 + val (_,(tac,_,_)::_) = get_calc 1;
   1.167 + case tac of Rewrite_Set "norm_equation" => ()
   1.168 + | _ => error "inform.sml: diff.behav.appendFormula: on Frm + equ 2";
   1.169 + autoCalculate 1 CompleteCalc;
   1.170 + val ((pt,_),_) = get_calc 1;
   1.171 + if "[x = 1]" = UnparseC.term (fst (get_obj g_result pt [])) then ()
   1.172 + else error "inform.sml: diff.behav.appendFormula: on Frm + equ 3";
   1.173 +DEconstrCalcTree 1;
   1.174 +
   1.175 +"--------- appendFormula: on Res + NO deriv ----------------------";
   1.176 +"--------- appendFormula: on Res + NO deriv ----------------------";
   1.177 +"--------- appendFormula: on Res + NO deriv ----------------------";
   1.178 + reset_states ();
   1.179 + CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"], 
   1.180 +	    ("Test", ["sqroot-test","univariate","equation","test"],
   1.181 +	     ["Test","squ-equ-test-subpbl1"]))];
   1.182 + Iterator 1; moveActiveRoot 1;
   1.183 + autoCalculate 1 CompleteCalcHead;
   1.184 + autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
   1.185 + autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
   1.186 +
   1.187 + appendFormula 1 "x = 2" (*|> Future.join*);
   1.188 + val ((pt,p),_) = get_calc 1;
   1.189 + val str = pr_ctree pr_short pt;
   1.190 + writeln str;
   1.191 + if str = ".    ----- pblobj -----\n1.   x + 1 = 2\n" andalso p = ([1], Res)
   1.192 + then ()
   1.193 + else error "inform.sml: diff.behav.appendFormula: Res + NOder 1";
   1.194 +
   1.195 + fetchProposedTactic 1;
   1.196 + val (_,(tac,_,_)::_) = get_calc 1;
   1.197 + case tac of Rewrite_Set "Test_simplify" => ()
   1.198 + | _ => error "inform.sml: diff.behav.appendFormula: Res + NOder 2";
   1.199 + autoCalculate 1 CompleteCalc;
   1.200 + val ((pt,_),_) = get_calc 1;
   1.201 + if "[x = 1]" = UnparseC.term (fst (get_obj g_result pt [])) then ()
   1.202 + else error "inform.sml: diff.behav.appendFormula: on Frm + equ 3";
   1.203 +DEconstrCalcTree 1;
   1.204 +
   1.205 +"--------- appendFormula: on Res + late deriv --------------------";
   1.206 +"--------- appendFormula: on Res + late deriv --------------------";
   1.207 +"--------- appendFormula: on Res + late deriv --------------------";
   1.208 +(*cp with "fun me" to test/../lucas-interpreter.sml:
   1.209 + re-build: fun locate_input_term ---------------------------------------------------"; 
   1.210 +*)
   1.211 + reset_states ();
   1.212 + CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"], 
   1.213 +	    ("Test", ["sqroot-test","univariate","equation","test"],
   1.214 +	     ["Test","squ-equ-test-subpbl1"]))];
   1.215 + Iterator 1; moveActiveRoot 1;
   1.216 + autoCalculate 1 CompleteCalcHead;
   1.217 + autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
   1.218 + autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
   1.219 +
   1.220 + appendFormula 1 "x = 1" (*|> Future.join*);
   1.221 + val ((pt,p),_) = get_calc 1;
   1.222 + val str = pr_ctree pr_short pt;
   1.223 + writeln str;
   1.224 + if str = ".    ----- pblobj -----\n1.   x + 1 = 2\n2.   x + 1 + -1 * 2 = 0\n3.    ----- pblobj -----\n3.1.   -1 + x = 0\n3.2.   x = 0 + -1 * -1\n3.2.1.   x = 0 + -1 * -1\n3.2.2.   x = 0 + 1\n" andalso p = ([3,2], Res)
   1.225 + then () (*finds 1 step too early: ([3,2], Res) "x = 1" also by script !!!*)
   1.226 + else error "inform.sml: diff.behav.appendFormula: Res + late d 1";
   1.227 +
   1.228 + fetchProposedTactic 1;
   1.229 + val (_,(tac,_,_)::_) = get_calc 1;
   1.230 + case tac of Check_Postcond ["LINEAR", "univariate", "equation", "test"] => ()
   1.231 + | _ => error "inform.sml: diff.behav.appendFormula: Res + late d 2";
   1.232 + autoCalculate 1 CompleteCalc;
   1.233 + val ((pt,_),_) = get_calc 1;
   1.234 + if "[x = 1]" = UnparseC.term (fst (get_obj g_result pt [])) then ()
   1.235 + else error "inform.sml: diff.behav.appendFormula: Res + late d 3";
   1.236 +DEconstrCalcTree 1;
   1.237 +
   1.238 +"--------- appendFormula: on Res + late deriv [x = 3 + -2]---///--";
   1.239 +"--------- appendFormula: on Res + late deriv [x = 3 + -2]---///--";
   1.240 +"--------- appendFormula: on Res + late deriv [x = 3 + -2]---///--";
   1.241 + reset_states ();
   1.242 + CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"], 
   1.243 +	    ("Test", ["sqroot-test","univariate","equation","test"],
   1.244 +	     ["Test","squ-equ-test-subpbl1"]))];
   1.245 + Iterator 1; moveActiveRoot 1;
   1.246 + autoCalculate 1 CompleteCalcHead;
   1.247 + autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
   1.248 + autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
   1.249 + appendFormula 1 "[x = 3 + -2*1]" (*|> Future.join*);
   1.250 + val ((pt,p),_) = get_calc 1;
   1.251 + val str = pr_ctree pr_short pt;
   1.252 + writeln str;
   1.253 + if str=".    ----- pblobj -----\n1.   x + 1 = 2\n2.   x + 1 + -1 * 2 = 0\n3.    ----- pblobj -----\n3.1.   -1 + x = 0\n3.2.   x = 0 + -1 * -1\n4.   [x = 1]\n4.1.   [x = 1]\n4.2.   [x = -2 + 3]\n4.3.   [x = 3 + -2]\n" then ()
   1.254 + else error "inform.sml: diff.behav.appendFormula: Res + latEE 1";
   1.255 + autoCalculate 1 CompleteCalc;
   1.256 + val ((pt,p),_) = get_calc 1;
   1.257 + if "[x = 3 + -2 * 1]" = UnparseC.term (fst (get_obj g_result pt [])) then ()
   1.258 + (*       ~~~~~~~~~~ simplify as last step in any script ?!*)
   1.259 + else error "inform.sml: diff.behav.appendFormula: Res + latEE 2";
   1.260 +DEconstrCalcTree 1;
   1.261 +
   1.262 +"--------- replaceFormula: on Res + = ----------------------------";
   1.263 +"--------- replaceFormula: on Res + = ----------------------------";
   1.264 +"--------- replaceFormula: on Res + = ----------------------------";
   1.265 + reset_states ();
   1.266 + CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"], 
   1.267 +	    ("Test", ["sqroot-test","univariate","equation","test"],
   1.268 +	     ["Test","squ-equ-test-subpbl1"]))];
   1.269 + Iterator 1; moveActiveRoot 1;
   1.270 + autoCalculate 1 CompleteCalcHead;
   1.271 + autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
   1.272 + autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
   1.273 + autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*-1 + x*);
   1.274 +
   1.275 + replaceFormula 1 "-2 * 1 + (1 + x) = 0"; refFormula 1 (get_pos 1 1);
   1.276 + val ((pt,_),_) = get_calc 1;
   1.277 + val str = pr_ctree pr_short pt;
   1.278 +
   1.279 +(* before AK110725 this was
   1.280 +".    ----- pblobj -----\n
   1.281 +1.   x + 1 = 2\n
   1.282 +2.   x + 1 + -1 * 2 = 0\n
   1.283 +2.1.   x + 1 + -1 * 2 = 0\n
   1.284 +2.2.   1 + x + -1 * 2 = 0\n
   1.285 +2.3.   1 + (x + -1 * 2) = 0\n
   1.286 +2.4.   1 + (x + -2) = 0\n
   1.287 +2.5.   1 + (x + -2 * 1) = 0\n
   1.288 +2.6.   1 + x + -2 * 1 = 0\n";
   1.289 +*)
   1.290 +if str = 
   1.291 +".    ----- pblobj -----\n"^
   1.292 +"1.   x + 1 = 2\n"^
   1.293 +"2.   x + 1 + -1 * 2 = 0\n"^
   1.294 +"2.1.   x + 1 + -1 * 2 = 0\n"^
   1.295 +"2.2.   1 + x + -1 * 2 = 0\n"^
   1.296 +"2.3.   1 + (x + -1 * 2) = 0\n"^
   1.297 +"2.4.   1 + (x + -2) = 0\n"^
   1.298 +"2.5.   1 + (x + -2 * 1) = 0\n"^
   1.299 +"2.6.   1 + x + -2 * 1 = 0\n" then()
   1.300 +else error "inform.sml: diff.behav.replaceFormula: on Res += 1";
   1.301 +
   1.302 + autoCalculate 1 CompleteCalc;
   1.303 + val ((pt,pos as (p,_)),_) = get_calc 1;
   1.304 + if pos = ([],Res) andalso "[x = 1]" = (UnparseC.term o fst) (get_obj g_result pt p) then()
   1.305 + else error "inform.sml: diff.behav.replaceFormula: on Res + = 2";
   1.306 +DEconstrCalcTree 1;
   1.307 +
   1.308 +"--------- replaceFormula: on Res + = 1st Nd ---------------------";
   1.309 +"--------- replaceFormula: on Res + = 1st Nd ---------------------";
   1.310 +"--------- replaceFormula: on Res + = 1st Nd ---------------------";
   1.311 + reset_states ();
   1.312 + CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"], 
   1.313 +	    ("Test", ["sqroot-test","univariate","equation","test"],
   1.314 +	     ["Test","squ-equ-test-subpbl1"]))];
   1.315 + Iterator 1; moveActiveRoot 1;
   1.316 + autoCalculate 1 CompleteCalcHead;
   1.317 + autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
   1.318 + autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
   1.319 +
   1.320 + replaceFormula 1 "x + 1 = 4 + -2"; refFormula 1 (get_pos 1 1);
   1.321 + val ((pt,_),_) = get_calc 1;
   1.322 + val str = pr_ctree pr_short pt;
   1.323 + writeln str;
   1.324 + if str= ".    ----- pblobj -----\n1.   x + 1 = 2\n1.1.   x + 1 = 2\n1.2.   1 + x = 2\n1.3.   1 + x = -2 + 4\n1.4.   x + 1 = -2 + 4\n" then ()
   1.325 + else error "inform.sml: diff.behav.replaceFormula: on Res 1 + = 1";
   1.326 + autoCalculate 1 CompleteCalc;
   1.327 + val ((pt,pos as (p,_)),_) = get_calc 1;
   1.328 + if pos = ([],Res) andalso "[x = 1]" = (UnparseC.term o fst)(get_obj g_result pt p) then()
   1.329 + else error "inform.sml: diff.behav.replaceFormula: on Res + = 2";
   1.330 +DEconstrCalcTree 1;
   1.331 +
   1.332 +"--------- replaceFormula: on Frm + = 1st Nd ---------------------";
   1.333 +"--------- replaceFormula: on Frm + = 1st Nd ---------------------";
   1.334 +"--------- replaceFormula: on Frm + = 1st Nd ---------------------";
   1.335 + reset_states ();
   1.336 + CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"], 
   1.337 +	    ("Test", ["sqroot-test","univariate","equation","test"],
   1.338 +	     ["Test","squ-equ-test-subpbl1"]))];
   1.339 + Iterator 1; moveActiveRoot 1;
   1.340 + autoCalculate 1 CompleteCalcHead;
   1.341 + autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
   1.342 +
   1.343 + replaceFormula 1 "x + 1 = 4 + -2"; refFormula 1 (get_pos 1 1);
   1.344 + val ((pt,_),_) = get_calc 1;
   1.345 + val str = pr_ctree pr_short pt;
   1.346 + writeln str;
   1.347 + if str= ".    ----- pblobj -----\n1.   x + 1 = 2\n1.1.   x + 1 = 2\n1.2.   1 + x = 2\n1.3.   1 + x = -2 + 4\n1.4.   x + 1 = -2 + 4\n" then ()
   1.348 + else error "inform.sml: diff.behav.replaceFormula: on Frm 1 + = 1";
   1.349 + autoCalculate 1 CompleteCalc;
   1.350 + val ((pt,pos as (p,_)),_) = get_calc 1;
   1.351 + if pos = ([],Res) andalso "[x = 1]" = (UnparseC.term o fst)(get_obj g_result pt p) then()
   1.352 + else error "inform.sml: diff.behav.replaceFormula: on Frm 1 + = 2";
   1.353 +DEconstrCalcTree 1;
   1.354 +
   1.355 +"--------- replaceFormula: cut calculation -----------------------";
   1.356 +"--------- replaceFormula: cut calculation -----------------------";
   1.357 +"--------- replaceFormula: cut calculation -----------------------";
   1.358 + reset_states ();
   1.359 + CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"], 
   1.360 +	    ("Test", ["sqroot-test","univariate","equation","test"],
   1.361 +	     ["Test","squ-equ-test-subpbl1"]))];
   1.362 + Iterator 1; moveActiveRoot 1;
   1.363 + autoCalculate 1 CompleteCalc;
   1.364 + moveActiveRoot 1; moveActiveDown 1;
   1.365 + if get_pos 1 1 = ([1], Frm) then ()
   1.366 + else error "inform.sml: diff.behav. cut calculation 1";
   1.367 +
   1.368 + replaceFormula 1 "x + 1 = 4 + -2"; refFormula 1 (get_pos 1 1);
   1.369 + val ((pt,p),_) = get_calc 1;
   1.370 + val str = pr_ctree pr_short pt;
   1.371 + writeln str;
   1.372 + if p = ([1], Res) then ()
   1.373 + else error "inform.sml: diff.behav. cut calculation 2";
   1.374 +
   1.375 +
   1.376 +(* 040307 copied from informtest.sml; ... old version 
   1.377 + "---------------- maximum-example, UC: Modeling / modifyCalcHead -";
   1.378 + "---------------- maximum-example, UC: Modeling / modifyCalcHead -";
   1.379 + "---------------- maximum-example, UC: Modeling / modifyCalcHead -";
   1.380 +
   1.381 + val p = ([],Pbl);
   1.382 + val elems = ["fixedValues [r=Arbfix]","maximum A","valuesFor [a,b]",
   1.383 +	      "relations [A=a*b, (a/2)^^^2 + (b/2)^^^2 = r^^^2]",
   1.384 +	      "relations [A=a*b, (a/2)^^^2 + (b/2)^^^2 = r^^^2]",
   1.385 +        "relations [A=a*b, a/2=r*sin alpha, b/2=r*cos (alpha::real)]",
   1.386 +	      (*^^^ these are the elements for the root-problem (in variants)*)
   1.387 +              (*vvv these are elements required for subproblems*)
   1.388 +	      "boundVariable a","boundVariable b","boundVariable alpha",
   1.389 +	      "interval {x::real. 0 <= x & x <= 2*r}",
   1.390 +	      "interval {x::real. 0 <= x & x <= 2*r}",
   1.391 +	      "interval {x::real. 0 <= x & x <= pi}",
   1.392 +	      "errorBound (eps=(0::real))"]
   1.393 + (*specifying is not interesting for this example*)
   1.394 + val spec = ("DiffApp", ["maximum_of","function"], 
   1.395 +	     ["DiffApp","max_by_calculus"]);
   1.396 + (*the empty model with descriptions for user-guidance by Model_Problem*)
   1.397 + val empty_model = [Given ["fixedValues []"],
   1.398 +		    Find ["maximum", "valuesFor"],
   1.399 +		    Relate ["relations []"]];
   1.400 +
   1.401 +
   1.402 + (*!!!!!!!!!!!!!!!!! DON'T USE me FOR FINDING nxt !!!!!!!!!!!!!!!!!!*)
   1.403 + val (p,_,f,nxt,_,pt) = CalcTreeTEST [(elems, spec)];
   1.404 + (*val nxt = ("Model_Problem", ...*)
   1.405 + val pbl = get_obj g_pbl pt (fst p); (writeln o (itms2str_ ctxt)) pbl; 
   1.406 +
   1.407 + val (p,_,f,nxt,_,pt) = me nxt p c pt;
   1.408 + (*nxt = Add_Given "fixedValues [r = Arbfix]"*)
   1.409 + val pbl = get_obj g_pbl pt (fst p); (writeln o (itms2str_ ctxt)) pbl; 
   1.410 +(*[
   1.411 +(0 ,[] ,false ,#Given ,Inc fixedValues [] ,(??.empty, [])),
   1.412 +(0 ,[] ,false ,#Find ,Inc maximum ,(??.empty, [])),
   1.413 +(0 ,[] ,false ,#Find ,Inc valuesFor ,(??.empty, [])),
   1.414 +(0 ,[] ,false ,#Relate ,Inc relations [] ,(??.empty, []))]*)
   1.415 +
   1.416 + (*the empty CalcHead is checked w.r.t the model and re-established as such*)
   1.417 + val (b,pt,ocalhd) = input_icalhd pt (p,"", empty_model, Pbl, Spec.empty);
   1.418 + val pbl = get_obj g_pbl pt (fst p); (writeln o (itms2str_ ctxt)) pbl; 
   1.419 + if ocalhd2str ocalhd = "(Pbl, ??.empty, [\n(0 ,[] ,false ,#Given ,Inc fixedValues [] ,(??.empty, [])),\n(0 ,[] ,false ,#Find ,Inc maximum ,(??.empty, [])),\n(0 ,[] ,false ,#Find ,Inc valuesFor ,(??.empty, [])),\n(0 ,[] ,false ,#Relate ,Inc relations [] ,(??.empty, []))], [], \n(\"ThyC.id_empty\", [\"e_pblID\"], [\"e_metID\"]) )" then () else error "informtest.sml: diff.behav. max 1";
   1.420 +
   1.421 + (*there is one input to the model (could be more)*)
   1.422 + val (b,pt,ocalhd) = 
   1.423 +     input_icalhd pt (p,"", [Given ["fixedValues [r=Arbfix]"],
   1.424 +			     Find ["maximum", "valuesFor"],
   1.425 +			     Relate ["relations"]], Pbl, Spec.empty);
   1.426 + val pbl = get_obj g_pbl pt (fst p); (writeln o (itms2str_ ctxt)) pbl; 
   1.427 + if ocalhd2str ocalhd = "(Pbl, ??.empty, [\n(1 ,[1,2,3] ,true ,#Given ,Cor fixedValues [r = Arbfix] ,(fix_, [[r = Arbfix]])),\n(0 ,[] ,false ,#Find ,Inc maximum ,(??.empty, [])),\n(0 ,[] ,false ,#Find ,Inc valuesFor ,(??.empty, [])),\n(0 ,[] ,false ,#Relate ,Inc relations [] ,(??.empty, []))], [], \n(\"ThyC.id_empty\", [\"e_pblID\"], [\"e_metID\"]) )" then () 
   1.428 + else error "informtest.sml: diff.behav. max 2";
   1.429 +
   1.430 + (*this input is complete in variant 3, but the ME doesn't recognize FIXXXXME
   1.431 + val (b,pt''''',ocalhd) = 
   1.432 +     input_icalhd pt (p,"", [Given ["fixedValues [r=Arbfix]"],
   1.433 +			     Find ["maximum A", "valuesFor [a,b]"],
   1.434 +			     Relate ["relations [A=a*b, a/2=r*sin alpha, \
   1.435 +				     \b/2=r*cos alpha]"]], Pbl, Spec.empty);
   1.436 + val pbl = get_obj g_pbl pt''''' (fst p); (writeln o (itms2str_ ctxt)) pbl; 
   1.437 + if ocalhd2str ocalhd = ------------^^^^^^^^^^ missing !!!*)
   1.438 +
   1.439 + (*this input is complete in variant 1 (variant 3 does not work yet)*)
   1.440 + val (b,pt''''',ocalhd) = 
   1.441 +     input_icalhd pt (p,"", [Given ["fixedValues [r=Arbfix]"],
   1.442 +			     Find ["maximum A", "valuesFor [a,b]"],
   1.443 +			     Relate ["relations [A=a*b, \
   1.444 +				     \(a/2)^^^2 + (b/2)^^^2 = r^^^2]"]], 
   1.445 +		      Pbl, Spec.empty);
   1.446 + val pbl = get_obj g_pbl pt''''' (fst p); (writeln o (itms2str_ ctxt)) pbl; 
   1.447 +
   1.448 + modifycalcheadOK2xml 111 (bool2str b) ocalhd;
   1.449 +*)
   1.450 +DEconstrCalcTree 1;
   1.451 +
   1.452 +"--------- syntax error ------------------------------------------";
   1.453 +"--------- syntax error ------------------------------------------";
   1.454 +"--------- syntax error ------------------------------------------";
   1.455 + reset_states ();
   1.456 + CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"], 
   1.457 +	    ("Test", ["sqroot-test","univariate","equation","test"],
   1.458 +	     ["Test","squ-equ-test-subpbl1"]))];
   1.459 + Iterator 1; moveActiveRoot 1;
   1.460 + autoCalculate 1 CompleteCalcHead;
   1.461 + autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
   1.462 + autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
   1.463 +
   1.464 + appendFormula 1 " x - "; (*<ERROR> syntax error in ' x - ' </ERROR>*)
   1.465 + val ((pt,_),_) = get_calc 1;
   1.466 + val str = pr_ctree pr_short pt;
   1.467 + writeln str;
   1.468 + if str = ".    ----- pblobj -----\n1.   x + 1 = 2\n" then ()
   1.469 + else error "inform.sml: diff.behav.appendFormula: syntax error";
   1.470 +DEconstrCalcTree 1;
   1.471 +
   1.472 +"--------- CAS-command on ([],Pbl) -------------------------------";
   1.473 +"--------- CAS-command on ([],Pbl) -------------------------------";
   1.474 +"--------- CAS-command on ([],Pbl) -------------------------------";
   1.475 +val (p,_,f,nxt,_,pt) = 
   1.476 +    CalcTreeTEST [([], ("empty_thy_id", ["empty_probl_id"], ["empty_meth_id"]))];
   1.477 +val ifo = "solve(x+1=2,x)";
   1.478 +val (_,(_,c,(pt,p))) = Step_Solve.by_term (pt,p) "solve(x+1=2,x)";
   1.479 +show_pt pt;
   1.480 +val nxt = (Apply_Method ["Test","squ-equ-test-subpbl1"]);
   1.481 +val (p,_,f,nxt,_,pt) = me nxt p [] pt;
   1.482 +if p = ([1], Frm) andalso f2str f = "x + 1 = 2" then ()
   1.483 +else error "inform.sml: diff.behav. CAScmd ([],Pbl)";
   1.484 +DEconstrCalcTree 1;
   1.485 +
   1.486 +"--------- CAS-command on ([],Pbl) FE-interface ------------------";
   1.487 +"--------- CAS-command on ([],Pbl) FE-interface ------------------";
   1.488 +"--------- CAS-command on ([],Pbl) FE-interface ------------------";
   1.489 +reset_states ();
   1.490 +CalcTree [([], ("empty_thy_id", ["empty_probl_id"], ["empty_meth_id"]))];
   1.491 +Iterator 1;
   1.492 +moveActiveRoot 1;
   1.493 +replaceFormula 1 "solve(x+1=2,x)";
   1.494 +autoCalculate 1 CompleteCalc;
   1.495 +val ((pt,p),_) = get_calc 1;
   1.496 +show_pt pt;
   1.497 +if p = ([], Res) then ()
   1.498 +else error "inform.sml: diff.behav. CAScmd ([],Pbl) FE-interface";
   1.499 +DEconstrCalcTree 1;
   1.500 +
   1.501 +"--------- inform [rational,simplification] ----------------------";
   1.502 +"--------- inform [rational,simplification] ----------------------";
   1.503 +"--------- inform [rational,simplification] ----------------------";
   1.504 +reset_states ();
   1.505 +CalcTree [(["Term (a * x / (b * x) + c * x / (d * x) + e / f)", "normalform N"],
   1.506 +	("Rational", ["rational", "simplification"], ["simplification", "of_rationals"]))];
   1.507 +Iterator 1; moveActiveRoot 1;
   1.508 +autoCalculate 1 CompleteCalcHead;
   1.509 +
   1.510 +"--- (-1) give a preview on the calculation without any input";
   1.511 +(*
   1.512 +autoCalculate 1 CompleteCalc;
   1.513 +val ((pt, p), _) = get_calc 1;
   1.514 +show_pt pt;
   1.515 +[
   1.516 +(([], Frm), Simplify (a * x / (b * x) + c * x / (d * x) + e / f)),
   1.517 +(([1], Frm), a * x / (b * x) + c * x / (d * x) + e / f),
   1.518 +(([1], Res), a / b + c / d + e / f),                             <--- (1) input arbitrary
   1.519 +(([2], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
   1.520 +(([3], Res), (a * (d * f) + b * (c * f) + b * (d * e)) / (b * (d * f))),
   1.521 +(([4], Res), (a * d * f + b * c * f + b * d * e) / (b * d * f)), <--- (2) input next
   1.522 +(([], Res), (a * d * f + b * c * f + b * d * e) / (b * d * f))]  <--- (3) is also final result
   1.523 +                                                                          EXAMPLE NOT OPTIMAL
   1.524 +*)
   1.525 +"--- (0) user input as the *first* step does not work, thus impdo at least 1 step";
   1.526 +autoCalculate 1 (Steps 1);
   1.527 +autoCalculate 1 (Steps 1);
   1.528 +val ((pt, p), _) = get_calc 1;
   1.529 +(*show_pt pt;
   1.530 +[
   1.531 +(([], Frm), Simplify (a * x / (b * x) + c * x / (d * x) + e / f)),
   1.532 +(([1], Frm), a * x / (b * x) + c * x / (d * x) + e / f),
   1.533 +(([1], Res), a / b + c / d + e / f)] 
   1.534 +*)
   1.535 +"--- (1) input an arbitrary next formula";
   1.536 +appendFormula 1 "((a * d) + (c * b)) / (b * d) + e / f" (*|> Future.join*);
   1.537 +val ((pt, p), _) = get_calc 1;
   1.538 +(*show_pt pt;
   1.539 +[
   1.540 +(([], Frm), Simplify (a * x / (b * x) + c * x / (d * x) + e / f)),
   1.541 +(([1], Frm), a * x / (b * x) + c * x / (d * x) + e / f),
   1.542 +(([1], Res), a / b + c / d + e / f),
   1.543 +(([2,1], Frm), a / b + c / d + e / f),
   1.544 +(([2,1], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
   1.545 +(([2,2], Res), (a * d + c * b) / (b * d) + e / f),
   1.546 +(([2], Res), (a * d + c * b) / (b * d) + e / f)] 
   1.547 +*)
   1.548 +val ((pt,p),_) = get_calc 1;
   1.549 +if p = ([2], Res) andalso (length o children o (get_nd pt)) (fst p) = 2 then ()
   1.550 +else error ("inform.sml: [rational,simplification] 1");
   1.551 +
   1.552 +"--- (2) input the next formula that would be presented by mat-engine";
   1.553 +(* generate a preview:
   1.554 +autoCalculate 1 (Steps 1);
   1.555 +val ((pt, p), _) = get_calc 1;
   1.556 +show_pt pt;
   1.557 +[
   1.558 +(([], Frm), Simplify (a * x / (b * x) + c * x / (d * x) + e / f)),
   1.559 +(([1], Frm), a * x / (b * x) + c * x / (d * x) + e / f),
   1.560 +(([1], Res), a / b + c / d + e / f),
   1.561 +(([2,1], Frm), a / b + c / d + e / f),
   1.562 +(([2,1], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
   1.563 +(([2,2], Res), (a * d + c * b) / (b * d) + e / f),
   1.564 +(([2], Res), (a * d + c * b) / (b * d) + e / f),
   1.565 +(([3], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f))]   <--- input this
   1.566 +*)
   1.567 +appendFormula 1 "(b * d * e + b * c * f + a * d * f) / (b * d * f)" (*|> Future.join*);
   1.568 +val ((pt, p), _) = get_calc 1;
   1.569 +(*show_pt pt;
   1.570 +[
   1.571 +(([], Frm), Simplify (a * x / (b * x) + c * x / (d * x) + e / f)),
   1.572 +(([1], Frm), a * x / (b * x) + c * x / (d * x) + e / f),
   1.573 +(([1], Res), a / b + c / d + e / f),
   1.574 +(([2,1], Frm), a / b + c / d + e / f),
   1.575 +(([2,1], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
   1.576 +(([2,2], Res), (a * d + c * b) / (b * d) + e / f),
   1.577 +(([2], Res), (a * d + c * b) / (b * d) + e / f),
   1.578 +(([3], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f))] 
   1.579 +*)
   1.580 +if p = ([3], Res) andalso (length o children o (get_nd pt)) (fst p) = 0 then ()
   1.581 +else error ("inform.sml: [rational,simplification] 2");
   1.582 +
   1.583 +"--- (3) input the exact final result";
   1.584 +appendFormula 1 "(b * d * e + b * c * f + a * d * f) / (b * d * f)" (*|> Future.join*);
   1.585 +val ((pt, p), _) = get_calc 1;
   1.586 +(*show_pt pt;
   1.587 +[
   1.588 +(([], Frm), Simplify (a * x / (b * x) + c * x / (d * x) + e / f)),
   1.589 +(([1], Frm), a * x / (b * x) + c * x / (d * x) + e / f),
   1.590 +(([1], Res), a / b + c / d + e / f),
   1.591 +(([2,1], Frm), a / b + c / d + e / f),
   1.592 +(([2,1], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
   1.593 +(([2,2], Res), (a * d + c * b) / (b * d) + e / f),
   1.594 +(([2], Res), (a * d + c * b) / (b * d) + e / f),
   1.595 +(([3], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
   1.596 +(([4,1], Frm), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
   1.597 +(([4,1], Res), (a * (d * f) + b * (c * f) + b * (d * e)) / (b * (d * f))),
   1.598 +(([4,2], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
   1.599 +(([4], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f))] 
   1.600 +*)
   1.601 +if p = ([4], Res) andalso (length o children o (get_nd pt)) (fst p) = 2 then ()
   1.602 +else error ("inform.sml: [rational,simplification] 3");
   1.603 +
   1.604 +"--- (4) finish the calculation + check the postcondition (in the future)";
   1.605 +autoCalculate 1 CompleteCalc;
   1.606 +val ((pt, p), _) = get_calc 1;
   1.607 +val (t, asm) = get_obj g_result pt [];
   1.608 +if UnparseC.term t = "(a * d * f + b * c * f + b * d * e) / (b * d * f)" andalso
   1.609 +UnparseC.terms asm = "[\"b * d * f \<noteq> 0\",\"d \<noteq> 0\",\"b \<noteq> 0\",\"a * x / (b * x) + c * x / (d * x) + e / f is_ratpolyexp\"]"
   1.610 +then () else error "inform [rational,simplification] changed at end";
   1.611 +(*show_pt pt;
   1.612 +[
   1.613 +(([], Frm), Simplify (a * x / (b * x) + c * x / (d * x) + e / f)),
   1.614 +(([1], Frm), a * x / (b * x) + c * x / (d * x) + e / f),
   1.615 +(([1], Res), a / b + c / d + e / f),
   1.616 +(([2,1], Frm), a / b + c / d + e / f),
   1.617 +(([2,1], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
   1.618 +(([2,2], Res), (a * d + c * b) / (b * d) + e / f),
   1.619 +(([2], Res), (a * d + c * b) / (b * d) + e / f),
   1.620 +(([3], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
   1.621 +(([4,1], Frm), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
   1.622 +(([4,1], Res), (a * (d * f) + b * (c * f) + b * (d * e)) / (b * (d * f))),
   1.623 +(([4,2], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
   1.624 +(([4], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
   1.625 +(([5], Res), (a * (d * f) + b * (c * f) + b * (d * e)) / (b * (d * f))),
   1.626 +(([6], Res), (a * d * f + b * c * f + b * d * e) / (b * d * f)),
   1.627 +(([], Res), (a * d * f + b * c * f + b * d * e) / (b * d * f))] 
   1.628 +*)
   1.629 +DEconstrCalcTree 1;
   1.630 +
   1.631 +"--------- Take as 1st tac, start with <NEW> (CAS input) ---------";
   1.632 +"--------- Take as 1st tac, start with <NEW> (CAS input) ---------";
   1.633 +"--------- Take as 1st tac, start with <NEW> (CAS input) ---------";
   1.634 +val t = str2term "Diff (x^^^2 + x + 1, x)";
   1.635 +case t of Const ("Diff.Diff", _) $ _ => ()
   1.636 +	| _ => raise 
   1.637 +	      error "diff.sml behav.changed for CAS Diff (..., x)";
   1.638 +atomty t;
   1.639 +"-----------------------------------------------------------------";
   1.640 +(*1>*)reset_states ();
   1.641 +(*2>*)CalcTree [([], ("empty_thy_id", ["empty_probl_id"], ["empty_meth_id"]))];
   1.642 +(*3>*)Iterator 1;moveActiveRoot 1;
   1.643 +"----- here the Headline has been finished";
   1.644 +(*4>*)moveActiveFormula 1 ([],Pbl);
   1.645 +(*5>*)replaceFormula 1 "Diff (x^2 + x + 1, x)";
   1.646 +val ((pt,_),_) = get_calc 1;
   1.647 +val PblObj {probl, meth, spec, fmz, env, loc, ...} = get_obj I pt [];
   1.648 +val NONE = env;
   1.649 +val (SOME istate, NONE) = loc;
   1.650 +(*default_print_depth 5;*)
   1.651 +writeln"-----------------------------------------------------------";
   1.652 +spec;
   1.653 +writeln (itms2str_ ctxt probl);
   1.654 +writeln (itms2str_ ctxt meth);
   1.655 +writeln (Istate.string_of (fst istate));
   1.656 +
   1.657 +refFormula 1 ([],Pbl) (*--> correct CalcHead*);
   1.658 + (*081016 NOT necessary (but leave it in Java):*)
   1.659 +(*6>*)(*completeCalcHead*)autoCalculate 1 CompleteCalcHead;
   1.660 +"----- here the CalcHead has been completed --- ONCE MORE ?????";
   1.661 +
   1.662 +(***difference II***)
   1.663 +val ((pt,p),_) = get_calc 1;
   1.664 +(*val p = ([], Pbl)*)
   1.665 +val PblObj {probl, meth, spec, fmz, env, loc, ...} = get_obj I pt [];
   1.666 +val NONE = env;
   1.667 +val (SOME istate, NONE) = loc;
   1.668 +(*default_print_depth 5;*) writeln (Istate.string_of (fst istate));  (*default_print_depth 3;*)
   1.669 +(*Pstate ([],
   1.670 + [], NONE,
   1.671 + ??.empty, Sundef, false)*)
   1.672 +(*default_print_depth 5;*) spec; (*default_print_depth 3;*)
   1.673 +(*("Isac_Knowledge",
   1.674 +      ["derivative_of", "function"],
   1.675 +      ["diff", "differentiate_on_R"]) : spec*)
   1.676 +writeln (itms2str_ ctxt probl);
   1.677 +(*[
   1.678 +(1 ,[1] ,true ,#Given ,Cor functionTerm (x ^^^ 2 + x + 1) ,(f_, [x ^^^ 2 + x + 1])),
   1.679 +(2 ,[1] ,true ,#Given ,Cor differentiateFor x ,(v_, [x])),
   1.680 +(3 ,[1] ,true ,#Find ,Cor derivative f_'_f ,(f_'_f, [f_'_f]))]*)
   1.681 +writeln (itms2str_ ctxt meth);
   1.682 +(*[
   1.683 +(1 ,[1] ,true ,#Given ,Cor functionTerm (x ^^^ 2 + x + 1) ,(f_, [x ^^^ 2 + x + 1])),
   1.684 +(2 ,[1] ,true ,#Given ,Cor differentiateFor x ,(v_, [x])),
   1.685 +(3 ,[1] ,true ,#Find ,Cor derivative f_'_f ,(f_'_f, [f_'_f]))]*)
   1.686 +writeln"-----------------------------------------------------------";
   1.687 +(*7>*)fetchProposedTactic 1 (*--> Apply_Method*);
   1.688 +(*WN081028 fixed <ERROR> helpless </ERROR> by inform returning ...(.,Met)*)
   1.689 +autoCalculate 1 CompleteCalc;
   1.690 +val ((pt,p),_) = get_calc 1;
   1.691 +val Form res = (#1 o pt_extract) (pt, ([],Res));
   1.692 +show_pt pt;
   1.693 +if p = ([], Res) andalso UnparseC.term res = "1 + 2 * x" then ()
   1.694 +else error "diff.sml behav.changed for Diff (x^2 + x + 1, x)";
   1.695 +DEconstrCalcTree 1;
   1.696 +
   1.697 +"--------- Take as 1st tac, start from exp -----------------------";
   1.698 +"--------- Take as 1st tac, start from exp -----------------------";
   1.699 +"--------- Take as 1st tac, start from exp -----------------------";
   1.700 +(*the following input is copied from BridgeLog Java <==> SML,
   1.701 +  omitting unnecessary inputs*)
   1.702 +(*1>*)reset_states ();
   1.703 +(*2>*)CalcTree [(["functionTerm (x^2 + x + 1)", "differentiateFor x", "derivative f_'_f"],("Isac_Knowledge",["derivative_of","function"],["diff","differentiate_on_R"]))];
   1.704 +(*3>*)Iterator 1; moveActiveRoot 1;
   1.705 +
   1.706 +(*6>*)(*completeCalcHead*)autoCalculate 1 CompleteCalcHead;
   1.707 +(***difference II***)
   1.708 +val ((pt,_),_) = get_calc 1;
   1.709 +val PblObj {probl, meth, spec, fmz, env, loc, ...} = get_obj I pt [];
   1.710 +val NONE = env;
   1.711 +val (SOME istate, NONE) = loc;
   1.712 +(*default_print_depth 5;*) writeln (Istate.string_of (fst istate));  (*default_print_depth 3;*)
   1.713 +(*Pstate ([],
   1.714 + [], NONE,
   1.715 + ??.empty, Sundef, false)*)
   1.716 +(*default_print_depth 5;*) spec; (*default_print_depth 3;*)
   1.717 +(*("Isac_Knowledge",
   1.718 +      ["derivative_of", "function"],
   1.719 +      ["diff", "differentiate_on_R"]) : spec*)
   1.720 +writeln (itms2str_ ctxt probl);
   1.721 +(*[
   1.722 +(1 ,[1] ,true ,#Given ,Cor functionTerm (x ^^^ 2 + x + 1) ,(f_, [x ^^^ 2 + x + 1])),
   1.723 +(2 ,[1] ,true ,#Given ,Cor differentiateFor x ,(v_, [x])),
   1.724 +(3 ,[1] ,true ,#Find ,Cor derivative f_'_f ,(f_'_f, [f_'_f]))]*)
   1.725 +writeln (itms2str_ ctxt meth);
   1.726 +(*[
   1.727 +(1 ,[1] ,true ,#Given ,Cor functionTerm (x ^^^ 2 + x + 1) ,(f_, [x ^^^ 2 + x + 1])),
   1.728 +(2 ,[1] ,true ,#Given ,Cor differentiateFor x ,(v_, [x])),
   1.729 +(3 ,[1] ,true ,#Find ,Cor derivative f_'_f ,(f_'_f, [f_'_f]))]*)
   1.730 +writeln"-----------------------------------------------------------";
   1.731 +(*7>*)fetchProposedTactic 1 (*--> Apply_Method*);
   1.732 +autoCalculate 1 (Steps 1);
   1.733 +val ((pt,p),_) = get_calc 1;
   1.734 +val Form res = (#1 o pt_extract) (pt, p);
   1.735 +if UnparseC.term res = "d_d x (x ^^^ 2 + x + 1)" then ()
   1.736 +else error "diff.sml Diff (x^2 + x + 1, x) from exp";
   1.737 +DEconstrCalcTree 1;
   1.738 +
   1.739 +"--------- implicit_take, start with <NEW> (CAS input) ---------------";
   1.740 +"--------- implicit_take, start with <NEW> (CAS input) ---------------";
   1.741 +"--------- implicit_take, start with <NEW> (CAS input) ---------------";
   1.742 +reset_states ();
   1.743 +CalcTree [([], ("empty_thy_id", ["empty_probl_id"], ["empty_meth_id"]))];
   1.744 +(*[[from sml: > @@@@@begin@@@@@
   1.745 +[[from sml:  1 
   1.746 +[[from sml: <CALCTREE>
   1.747 +[[from sml:    <CALCID> 1 </CALCID>
   1.748 +[[from sml: </CALCTREE>
   1.749 +[[from sml: @@@@@end@@@@@*)
   1.750 +Iterator 1;
   1.751 +(*[[from sml: > @@@@@begin@@@@@
   1.752 +[[from sml:  1 
   1.753 +[[from sml: <ADDUSER>
   1.754 +[[from sml:   <CALCID> 1 </CALCID>
   1.755 +[[from sml:   <USERID> 1 </USERID>
   1.756 +[[from sml: </ADDUSER>
   1.757 +[[from sml: @@@@@end@@@@@*)
   1.758 +moveActiveRoot 1;
   1.759 +(*[[from sml: > @@@@@begin@@@@@
   1.760 +[[from sml:  1 
   1.761 +[[from sml: <CALCITERATOR>
   1.762 +[[from sml:   <CALCID> 1 </CALCID>
   1.763 +[[from sml:   <POSITION>
   1.764 +[[from sml:     <INTLIST>
   1.765 +[[from sml:     </INTLIST>
   1.766 +[[from sml:     <POS> Pbl </POS>
   1.767 +[[from sml:   </POSITION>
   1.768 +[[from sml: </CALCITERATOR>
   1.769 +[[from sml: @@@@@end@@@@@*)
   1.770 +getFormulaeFromTo 1 ([],Pbl) ([],Pbl) 0 false;
   1.771 +(*[[from sml: > @@@@@begin@@@@@                STILL CORRECT
   1.772 +[[from sml:  1 
   1.773 +[[from sml: <GETELEMENTSFROMTO>
   1.774 +[[from sml:   <CALCID> 1 </CALCID>
   1.775 +[[from sml:   <FORMHEADS>
   1.776 +[[from sml:     <CALCFORMULA>
   1.777 +[[from sml:       <POSITION>
   1.778 +[[from sml:         <INTLIST>
   1.779 +[[from sml:         </INTLIST>
   1.780 +[[from sml:         <POS> Pbl </POS>
   1.781 +[[from sml:       </POSITION>
   1.782 +[[from sml:       <FORMULA>
   1.783 +[[from sml:         <MATHML>
   1.784 +[[from sml:           <ISA> ________________________________________________ </ISA>
   1.785 +[[from sml:         </MATHML>
   1.786 +[[from sml: 
   1.787 +[[from sml:       </FORMULA>
   1.788 +[[from sml:     </CALCFORMULA>
   1.789 +[[from sml:   </FORMHEADS>
   1.790 +[[from sml: </GETELEMENTSFROMTO>
   1.791 +[[from sml: @@@@@end@@@@@*)
   1.792 +refFormula 1 ([],Pbl);
   1.793 +(*[[from sml: > @@@@@begin@@@@@                STILL CORRECT
   1.794 +[[from sml:  1 
   1.795 +[[from sml: <REFFORMULA>
   1.796 +[[from sml:   <CALCID> 1 </CALCID>
   1.797 +[[from sml:   <CALCHEAD status = "incorrect">
   1.798 +[[from sml:     <POSITION>
   1.799 +[[from sml:       <INTLIST>
   1.800 +[[from sml:       </INTLIST>
   1.801 +[[from sml:       <POS> Pbl </POS>
   1.802 +[[from sml:     </POSITION>
   1.803 +[[from sml:     <HEAD>
   1.804 +[[from sml:       <MATHML>
   1.805 +[[from sml:         <ISA> Problem (ThyC.id_empty, [e_pblID]) </ISA>
   1.806 +[[from sml:       </MATHML>
   1.807 +[[from sml:     </HEAD>
   1.808 +[[from sml:     <MODEL>
   1.809 +[[from sml:       <GIVEN>  </GIVEN>
   1.810 +[[from sml:       <WHERE>  </WHERE>
   1.811 +[[from sml:       <FIND>  </FIND>
   1.812 +[[from sml:       <RELATE>  </RELATE>
   1.813 +[[from sml:     </MODEL>
   1.814 +[[from sml:     <BELONGSTO> Pbl </BELONGSTO>
   1.815 +[[from sml:     <SPECIFICATION>
   1.816 +[[from sml:       <THEORYID> ThyC.id_empty </THEORYID>
   1.817 +[[from sml:       <PROBLEMID>
   1.818 +[[from sml:         <STRINGLIST>
   1.819 +[[from sml:           <STRING> Problem.id_empty </STRING>
   1.820 +[[from sml:         </STRINGLIST>
   1.821 +[[from sml:       </PROBLEMID>
   1.822 +[[from sml:       <METHODID>
   1.823 +[[from sml:         <STRINGLIST>
   1.824 +[[from sml:           <STRING> e_metID </STRING>
   1.825 +[[from sml:         </STRINGLIST>
   1.826 +[[from sml:       </METHODID>
   1.827 +[[from sml:     </SPECIFICATION>
   1.828 +[[from sml:   </CALCHEAD>
   1.829 +[[from sml: </REFFORMULA>
   1.830 +[[from sml: @@@@@end@@@@@*)
   1.831 +moveActiveFormula 1 ([],Pbl);
   1.832 +(*[[from sml: > @@@@@begin@@@@@
   1.833 +[[from sml:  1 
   1.834 +[[from sml: <CALCITERATOR>
   1.835 +[[from sml:   <CALCID> 1 </CALCID>
   1.836 +[[from sml:   <POSITION>
   1.837 +[[from sml:     <INTLIST>
   1.838 +[[from sml:     </INTLIST>
   1.839 +[[from sml:     <POS> Pbl </POS>
   1.840 +[[from sml:   </POSITION>
   1.841 +[[from sml: </CALCITERATOR>
   1.842 +[[from sml: @@@@@end@@@@@*)
   1.843 +replaceFormula 1 "Simplify (1+2)";
   1.844 +(*[[from sml: > @@@@@begin@@@@@
   1.845 +[[from sml:  1 
   1.846 +[[from sml: <REPLACEFORMULA>
   1.847 +[[from sml:   <CALCID> 1 </CALCID>
   1.848 +[[from sml:   <CALCCHANGED>
   1.849 +[[from sml:     <UNCHANGED>
   1.850 +[[from sml:       <INTLIST>
   1.851 +[[from sml:       </INTLIST>
   1.852 +[[from sml:       <POS> Pbl </POS>
   1.853 +[[from sml:     </UNCHANGED>
   1.854 +[[from sml:     <DELETED>
   1.855 +[[from sml:       <INTLIST>
   1.856 +[[from sml:       </INTLIST>
   1.857 +[[from sml:       <POS> Pbl </POS>
   1.858 +[[from sml:     </DELETED>
   1.859 +[[from sml:     <GENERATED>
   1.860 +[[from sml:       <INTLIST>
   1.861 +[[from sml:       </INTLIST>
   1.862 +[[from sml:       <POS> Met </POS>                           DIFFERENCE: Pbl
   1.863 +[[from sml:     </GENERATED>
   1.864 +[[from sml:   </CALCCHANGED>
   1.865 +[[from sml: </REPLACEFORMULA>
   1.866 +[[from sml: @@@@@end@@@@@*)
   1.867 +getFormulaeFromTo 1 ([],Pbl) ([],Pbl) 0 false(*              DIFFERENCE: Pbl*);
   1.868 +(*@@@@@begin@@@@@
   1.869 + 1
   1.870 +<GETELEMENTSFROMTO>
   1.871 +  <CALCID> 1 </CALCID>
   1.872 +  <FORMHEADS>
   1.873 +    <CALCFORMULA>
   1.874 +      <POSITION>
   1.875 +        <INTLIST>
   1.876 +        </INTLIST>
   1.877 +        <POS> Pbl </POS>
   1.878 +      </POSITION>
   1.879 +      <FORMULA>
   1.880 +        <MATHML>
   1.881 +          <ISA> Simplify (1 + 2) </ISA>                      WORKS !!!!!
   1.882 +        </MATHML>
   1.883 +      </FORMULA>
   1.884 +    </CALCFORMULA>
   1.885 +  </FORMHEADS>
   1.886 +</GETELEMENTSFROMTO>
   1.887 +@@@@@end@@@@@*)
   1.888 +getFormulaeFromTo 1 ([],Pbl) ([],Met) 0 false;
   1.889 +(*[[from sml: > @@@@@begin@@@@@
   1.890 +[[from sml:  1 
   1.891 +[[from sml: <SYSERROR>
   1.892 +[[from sml:   <CALCID> 1 </CALCID>
   1.893 +[[from sml:   <ERROR> error in getFormulaeFromTo </ERROR>
   1.894 +[[from sml: </SYSERROR>
   1.895 +[[from sml: @@@@@end@@@@@*)
   1.896 +(*step into getFormulaeFromTo --- bug corrected...*)
   1.897 +
   1.898 +"--------- build fun check_for' ------------------------------";
   1.899 +"--------- build fun check_for' ------------------------------";
   1.900 +"--------- build fun check_for' ------------------------------";
   1.901 +val subst = [(str2term "bdv", str2term "x")]: subst;
   1.902 +val rls = norm_Rational
   1.903 +val pat = parse_patt @{theory} "(?a + ?b)/(?b + ?c) = ?a / ?c";
   1.904 +val (res, inf) = (str2term "(2 + 3)/(3 + 4)", str2term "2 / 4");
   1.905 +val (res, inf) = (str2term "(2 + 3)/(3 + 4)", str2term "1 / 2");
   1.906 +
   1.907 +val (res', _, _, rewritten) = (*rewritten: the lhs of the pattern matches in res*)
   1.908 +  rew_sub thy 1 [] e_rew_ord Rule_Set.empty false [] (HOLogic.Trueprop $ pat) res;
   1.909 +if rewritten then NONE else SOME "e_errpatID";
   1.910 +
   1.911 +val norm_res = case rewrite_set_ (Isac()) false rls res' of
   1.912 +  NONE => res'
   1.913 +| SOME (norm_res, _) => norm_res
   1.914 +
   1.915 +val norm_inf = case rewrite_set_ (Isac()) false rls inf of
   1.916 +  NONE => inf
   1.917 +| SOME (norm_inf, _) => norm_inf;
   1.918 +
   1.919 +res' = inf;
   1.920 +norm_res = norm_inf;
   1.921 +
   1.922 +val pat = parse_patt @{theory} "(?a + ?b)/?a = ?b";
   1.923 +val (res, inf) = (str2term "(2 + 3)/2", str2term "3");
   1.924 +if check_for' (res, inf) subst ("errpatID", pat) rls = SOME "errpatID"
   1.925 +then () else error "error patt example1 changed";
   1.926 +
   1.927 +val pat = parse_patt @{theory} "(?a + ?b)/(?a + ?c) = ?b / ?c";
   1.928 +val (res, inf) = (str2term "(2 + 3)/(2 + 4)", str2term "3 / 4");
   1.929 +if check_for' (res, inf) subst ("errpatID", pat) rls = SOME "errpatID"
   1.930 +then () else error "error patt example2 changed";
   1.931 +
   1.932 +val pat = parse_patt @{theory} "(?a + ?b)/(?b + ?c) = ?a / ?c";
   1.933 +val (res, inf) = (str2term "(2 + 3)/(3 + 4)", str2term "2 / 4");
   1.934 +if check_for' (res, inf) subst ("errpatID", pat) rls = SOME "errpatID"
   1.935 +then () else error "error patt example3 changed";
   1.936 +
   1.937 +val inf =  str2term "1 / 2";
   1.938 +if check_for' (res, inf) subst ("errpatID", pat) rls = SOME "errpatID"
   1.939 +then () else error "error patt example3 changed";
   1.940 +
   1.941 +"--------- build fun check_for' ?bdv -------------------------";
   1.942 +"--------- build fun check_for' ?bdv -------------------------";
   1.943 +"--------- build fun check_for' ?bdv -------------------------";
   1.944 +val subst = [(str2term "bdv", str2term "x")]: subst;
   1.945 +val t = str2term "d_d x (x ^^^ 2 + sin (x ^^^ 4))";
   1.946 +val SOME (t, _) = rewrite_set_inst_ thy false subst norm_diff t;
   1.947 +if UnparseC.term t = "2 * x + cos (x ^^^ 4) * 4 * x ^^^ 3" then ()
   1.948 +else error "build fun check_for' ?bdv changed 1"; 
   1.949 +
   1.950 +val rls = norm_diff
   1.951 +val pat = parse_patt @{theory} "d_d ?bdv (sin ?u) = cos (d_d ?bdv ?u)"; 
   1.952 +val (res, inf) = (str2term "2 * x + d_d x (sin (x ^^^ 4))", str2term "2 * x + cos (4 * x ^^^ 3)");
   1.953 +
   1.954 +val (res', _, _, rewritten) = (*rewritten: the lhs of the pattern matches in res*)
   1.955 +  rew_sub thy 1 subst e_rew_ord Rule_Set.empty false [] (HOLogic.Trueprop $ pat) res;
   1.956 +if UnparseC.term res' = "2 * x + cos (d_d x (x ^^^ 4))" andalso rewritten then ()
   1.957 +else error "build fun check_for' ?bdv changed 2";
   1.958 +
   1.959 +val norm_res = case rewrite_set_inst_ (Isac()) false subst rls  res' of
   1.960 +  NONE => res'
   1.961 +| SOME (norm_res, _) => norm_res;
   1.962 +if UnparseC.term norm_res = "2 * x + cos (4 * x ^^^ 3)" then ()
   1.963 +else error "build fun check_for' ?bdv changed 3";
   1.964 +
   1.965 +val norm_inf = case rewrite_set_inst_ (Isac()) false subst rls inf of
   1.966 +  NONE => inf
   1.967 +| SOME (norm_inf, _) => norm_inf;
   1.968 +if UnparseC.term norm_inf = "2 * x + cos (4 * x ^^^ 3)" then ()
   1.969 +else error "build fun check_for' ?bdv changed 4";
   1.970 +
   1.971 +res' = inf;
   1.972 +if norm_res = norm_inf then ()
   1.973 +else error "build fun check_for' ?bdv changed 5";
   1.974 +
   1.975 +if Error_Pattern.check_for' (res, inf) (subst: subst) ("errpatID": errpatID, pat) rls = SOME "errpatID"
   1.976 +then () else error "error patt example1 changed";
   1.977 +
   1.978 +"--------- build fun check_for ------------------------";
   1.979 +"--------- build fun check_for ------------------------";
   1.980 +"--------- build fun check_for ------------------------";
   1.981 +val (res, inf) =
   1.982 +  (str2term "d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))",
   1.983 +   str2term "d_d x (x ^^^ 2) + cos (4 * x ^^^ 3)");
   1.984 +val {errpats, nrls = rls, scr = Prog prog, ...} = get_met ["diff", "differentiate_on_R"]
   1.985 +
   1.986 +val env = [(str2term "v_v", str2term "x")];
   1.987 +val errpats =
   1.988 +  [e_errpat, (*generalised for testing*)
   1.989 +   ("chain-rule-diff-both",
   1.990 +     [parse_patt @{theory} "d_d ?bdv (sin ?u) = cos (d_d ?bdv ?u)",
   1.991 +      parse_patt @{theory} "d_d ?bdv (cos ?u) = - sin (d_d ?bdv ?u)",
   1.992 +      parse_patt @{theory} "d_d ?bdv (?u ^^^ ?n) = ?n * ?u ^^^ (?n - 1)",
   1.993 +      parse_patt @{theory} "d_d ?bdv (LogExp.ln ?u) = 1 / ?u",
   1.994 +      parse_patt @{theory} "d_d ?bdv (LogExp.ln ?u) = 1 / d_d ?bdv ?u"],
   1.995 +     [@{thm diff_sin_chain}, @{thm diff_cos_chain}, @{thm diff_pow_chain}, 
   1.996 +      @{thm diff_ln_chain}, @{thm  diff_exp_chain}])]: errpat list;
   1.997 +case Error_Pattern.check_for (res, inf) (prog, env) (errpats, rls) of SOME _ => () 
   1.998 +| NONE => error "Error_Pattern.check_for broken";
   1.999 +DEconstrCalcTree 1;
  1.1000 +
  1.1001 +"--------- embed fun check_for ------------------------";
  1.1002 +"--------- embed fun check_for ------------------------";
  1.1003 +"--------- embed fun check_for ------------------------";
  1.1004 +reset_states ();     
  1.1005 +CalcTree
  1.1006 +[(["functionTerm (x ^ 2 + sin (x ^ 4))", "differentiateFor x", "derivative f_f'"], 
  1.1007 +  ("Isac_Knowledge", ["derivative_of","function"], ["diff","differentiate_on_R"]))];
  1.1008 +Iterator 1;
  1.1009 +moveActiveRoot 1;
  1.1010 +autoCalculate 1 CompleteCalcHead;
  1.1011 +autoCalculate 1 (Steps 1);
  1.1012 +autoCalculate 1 (Steps 1);(*([1], Res), d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))*)
  1.1013 +(*autoCalculate 1 (Steps 1);([2], Res), d_d x (x ^^^ 2) + cos (x ^^^ 4) * d_d x (x ^^^ 4)*)
  1.1014 +
  1.1015 +"~~~~~ fun appendFormula , args:"; val (cI, (ifo:TermC.as_string)) = (1, "d_d x (x ^ 2) + cos (4 * x ^ 3)");
  1.1016 +"~~~~~ fun appendFormula' , args:"; val (cI, (ifo: TermC.as_string)) = (cI, ifo);
  1.1017 +    val cs = get_calc cI
  1.1018 +    val pos = get_pos cI 1;
  1.1019 +(*+*)if pos = ([1], Res) then () else error "inform with (positive) Error_Pattern.check_for broken 1";
  1.1020 +    val ("ok", cs' as (_, _, ptp)) = (*case*) Step.do_next pos cs (*of*);
  1.1021 +      (*case*) Step_Solve.by_term ptp (encode ifo) (*of*); (*ERROR WAS: "no derivation found"*)
  1.1022 +"~~~~~ fun Step_Solve.by_term , args:"; val (((*next_*)cs as (_, _, (pt, pos as (p, _))): Chead.calcstate'), istr)
  1.1023 +  = (cs', (encode ifo));
  1.1024 +    val ctxt = get_ctxt pt pos (*see TODO.thy*)
  1.1025 +    val SOME f_in = (*case*) TermC.parse (ThyC.get_theory "Isac_Knowledge") istr (*of*);
  1.1026 +    	  val f_in = Thm.term_of f_in
  1.1027 +        val pos_pred = lev_back' pos
  1.1028 +    	  val f_pred = Ctree.get_curr_formula (pt, pos_pred);
  1.1029 +        (*if*) f_pred = f_in; (*else*)
  1.1030 +          val NONE = (*case*) In_Chead.cas_input f_in (*of*);
  1.1031 +       (*old* )val (_, _, metID) = get_obj g_spec pt (par_pblobj pt p)
  1.1032 +       (*old*)val {scr = prog, ...} = Specify.get_met metID
  1.1033 +       (*old*)val istate = get_istate_LI pt pos
  1.1034 +       (*old*)val ctxt = get_ctxt pt pos
  1.1035 +       ( *old*)
  1.1036 +       val LI.Not_Derivable =
  1.1037 +             (*case*) LI.locate_input_term (pt, pos) f_in (*of*);
  1.1038 +            		  val pp = Ctree.par_pblobj pt p
  1.1039 +            		  val (errpats, nrls, prog) = case Specify.get_met (Ctree.get_obj Ctree.g_metID pt pp) of
  1.1040 +              		    {errpats, nrls, scr = Rule.Prog prog, ...} => (errpats, nrls, prog)
  1.1041 +              		  | _ => error "inform: uncovered case of get_met"
  1.1042 +;
  1.1043 +(*+*)if errpats2str errpats = "[(\"chain-rule-diff-both\",\n[\"d_d ?bdv (sin ?u) = cos (d_d ?bdv ?u)\",\"d_d ?bdv (cos ?u) = - sin (d_d ?bdv ?u)\",\"d_d ?bdv (?u ^^^ ?n) = ?n * ?u ^^^ (?n - 1)\",\"d_d ?bdv (LogExp.ln ?u) = 1 / ?u\",\"d_d ?bdv (LogExp.ln ?u) = 1 / d_d ?bdv ?u\"],\n[\"d_d ?bdv (sin ?u) = cos ?u * d_d ?bdv ?u\",\"d_d ?bdv (cos ?u) = - sin ?u * d_d ?bdv ?u\",\"d_d ?bdv (?u ^^^ ?n) = ?n * ?u ^^^ (?n - 1) * d_d ?bdv ?u\",\"d_d ?bdv (LogExp.ln ?u) = d_d ?bdv ?u / ?u\",\"d_d ?bdv (E_ ^^^ ?u) = E_ ^^^ ?u * d_d ?x ?u\"]]"
  1.1044 +(*+*)then () else error "inform with (positive) Error_Pattern.check_for broken 3";
  1.1045 +
  1.1046 +            		  val {env, ...} = Ctree.get_istate_LI pt pos |> Istate.the_pstate
  1.1047 +;
  1.1048 +(*+*)if UnparseC.term f_pred = "d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))" andalso
  1.1049 +(*+*)   UnparseC.term f_in = "d_d x (x ^^^ 2) + cos (4 * x ^^^ 3)"
  1.1050 +(*+*)then () else error "inform with (positive) Error_Pattern.check_for broken 2";
  1.1051 +
  1.1052 +             val SOME "chain-rule-diff-both" = (*case*) Error_Pattern.check_for (f_pred, f_in) (prog, env) (errpats, nrls) (*of*);
  1.1053 +
  1.1054 +"--- final check:";
  1.1055 +(*+*)val (_, _, ptp') = cs';
  1.1056 +case Step_Solve.by_term ptp' (encode ifo) of
  1.1057 +  ("error pattern #chain-rule-diff-both#", calcstate') => ()
  1.1058 +| _ => error "inform with (positive) Error_Pattern.check_for broken"
  1.1059 +
  1.1060 +
  1.1061 +"--------- embed fun find_fill_patterns ---------------------------";
  1.1062 +"--------- embed fun find_fill_patterns ---------------------------";
  1.1063 +"--------- embed fun find_fill_patterns ---------------------------";
  1.1064 +reset_states ();
  1.1065 +CalcTree
  1.1066 +[(["functionTerm (x ^ 2 + sin (x ^ 4))", "differentiateFor x", "derivative f_f'"], 
  1.1067 +  ("Isac_Knowledge", ["derivative_of","function"], ["diff","differentiate_on_R"]))];
  1.1068 +Iterator 1;
  1.1069 +moveActiveRoot 1;
  1.1070 +autoCalculate 1 CompleteCalcHead;
  1.1071 +autoCalculate 1 (Steps 1);
  1.1072 +autoCalculate 1 (Steps 1);(*([1], Res), d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))*)
  1.1073 +appendFormula 1 "d_d x (x ^ 2) + cos (4 * x ^ 3)" (*|> Future.join*);
  1.1074 +  (*<CALCMESSAGE> error pattern #chain-rule-diff-both# </CALCMESSAGE>*)
  1.1075 +  (*or
  1.1076 +    <CALCMESSAGE> no derivation found </CALCMESSAGE>*)
  1.1077 +
  1.1078 +"~~~~~ fun findFillpatterns, args:"; val (cI, errpatID) = (1, "chain-rule-diff-both");
  1.1079 +  val ((pt, _), _) = get_calc cI
  1.1080 +				val pos = get_pos cI 1;
  1.1081 +"~~~~~ fun find_fill_patterns , args:"; val ((pt, pos as (p, _)), errpatID) = ((pt, pos), errpatID);
  1.1082 +    val f_curr = Ctree.get_curr_formula (pt, pos);
  1.1083 +    val pp = Ctree.par_pblobj pt p
  1.1084 +    val (errpats, prog) = case Specify.get_met (Ctree.get_obj Ctree.g_metID pt pp) of
  1.1085 +      {errpats, scr = Rule.Prog prog, ...} => (errpats, prog)
  1.1086 +    | _ => error "find_fill_patterns: uncovered case of get_met"
  1.1087 +    val {env, ...} = Ctree.get_istate_LI pt pos |> Istate.the_pstate
  1.1088 +    val subst = Rtools.get_bdv_subst prog env
  1.1089 +    val errpatthms = errpats
  1.1090 +      |> filter ((curry op = errpatID) o (#1: errpat -> errpatID))
  1.1091 +      |> map (#3: errpat -> thm list)
  1.1092 +      |> flat;
  1.1093 +
  1.1094 +case map (Error_Pattern.fill_from_store subst f_curr errpatID) errpatthms |> flat of
  1.1095 +  ("fill-d_d-arg", tm, thm, subs_opt) :: _ => if UnparseC.term tm = 
  1.1096 +    "d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4)) =\nd_d x (x ^^^ 2) + cos (x ^^^ 4) * d_d x ?_dummy_1"
  1.1097 +    then () else error "find_fill_patterns changed 1a"
  1.1098 +| _ => error "find_fill_patterns changed 1b"
  1.1099 +
  1.1100 +"~~~~~ fun fill_from_store, args:"; val (subst, form, errpatID, thm) =
  1.1101 +  (subst, f_curr, errpatID, hd (*simulate beginning of "map"*) errpatthms);
  1.1102 +        val thmDeriv = Thm.get_name_hint thm
  1.1103 +        val (part, thyID) = thy_containing_thm thmDeriv
  1.1104 +        val theID = [part, thyID, "Theorems", ThmC.cut_id thmDeriv]
  1.1105 +        val Hthm {fillpats, ...} = get_the theID
  1.1106 +        val some = map (Error_Pattern.fill_form subst (thm, form) errpatID) fillpats;
  1.1107 +
  1.1108 +case some |> filter is_some |> map the of
  1.1109 +  ("fill-d_d-arg", tm, thm, subsopt) :: _ => if UnparseC.term tm = 
  1.1110 +    "d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4)) =\nd_d x (x ^^^ 2) + cos (x ^^^ 4) * d_d x ?_dummy_1"
  1.1111 +    then () else error "find_fill_patterns changed 2a"
  1.1112 +| _ => error "find_fill_patterns changed 2b"
  1.1113 +
  1.1114 +"~~~~~ fun fill_form, args:";
  1.1115 +  val ((subs_opt, subst), (thm, form), errpatID, (fillpatID, pat, erpaID)) =
  1.1116 +  (subst, (thm, form), errpatID, hd (*simulate beginning of "map"*) fillpats);
  1.1117 +val (form', _, _, rewritten) =
  1.1118 +      rew_sub (Isac()) 1 subst e_rew_ord Rule_Set.empty false [] (HOLogic.Trueprop $ pat) form;
  1.1119 +
  1.1120 +if UnparseC.term form' = "d_d x (x ^^^ 2) + cos (x ^^^ 4) * d_d x ?_dummy_1" then ()
  1.1121 +else error "find_fill_patterns changed 3";
  1.1122 +
  1.1123 +"~~~~~ to findFillpatterns return val:"; val (fillpats) =
  1.1124 +  (map (Error_Pattern.fill_from_store (subs_opt, subst) f_curr errpatID) errpatthms |> flat) (*only from "hd errpatthms"*);
  1.1125 +
  1.1126 +"vvv--- dropped this code WN120730";
  1.1127 +val msg = "fill patterns " ^
  1.1128 +  ((map ((apsnd UnparseC.term) o quad2pair) fillpats) |> map pair2str_ |> strs2str_);
  1.1129 +msg =
  1.1130 +  "fill patterns #fill-d_d-arg#d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))" ^
  1.1131 +    " =\nd_d x (x ^^^ 2) + cos (x ^^^ 4) * d_d x ?_dummy_1" ^
  1.1132 +  "#fill-both-args#d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))" ^
  1.1133 +    " =\nd_d x (x ^^^ 2) + cos ?_dummy_2 * d_d x ?_dummy_3" ^
  1.1134 +  "#fill-d_d#d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))" ^
  1.1135 +    " =\nd_d x (x ^^^ 2) + cos (x ^^^ 4) * ?_dummy_1 x (x ^^^ 4)" ^
  1.1136 +  "#fill-inner-deriv#d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))" ^
  1.1137 +    " =\nd_d x (x ^^^ 2) + cos (x ^^^ 4) * ?_dummy_1" ^
  1.1138 +  "#fill-all#d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4)) = d_d x (x ^^^ 2) + ?_dummy_1#";
  1.1139 +"^^^--- dropped this code WN120730";
  1.1140 +
  1.1141 +if (map #1 fillpats) =
  1.1142 +  ["fill-d_d-arg", "fill-both-args", "fill-d_d", "fill-inner-deriv", "fill-all"]
  1.1143 +then () else error "find_fill_patterns changed 4b";
  1.1144 +DEconstrCalcTree 1;
  1.1145 +
  1.1146 +"--------- build fun is_exactly_equal, inputFillFormula ----------";
  1.1147 +"--------- build fun is_exactly_equal, inputFillFormula ----------";
  1.1148 +"--------- build fun is_exactly_equal, inputFillFormula ----------";
  1.1149 +reset_states ();
  1.1150 +CalcTree
  1.1151 +[(["functionTerm (x ^ 2 + sin (x ^ 4))", "differentiateFor x", "derivative f_f'"], 
  1.1152 +  ("Isac_Knowledge", ["derivative_of","function"], ["diff","differentiate_on_R"]))];
  1.1153 +Iterator 1;
  1.1154 +moveActiveRoot 1;
  1.1155 +autoCalculate 1 CompleteCalcHead;
  1.1156 +autoCalculate 1 (Steps 1);
  1.1157 +autoCalculate 1 (Steps 1);(*([1], Res), d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))*)
  1.1158 +appendFormula 1 "d_d x (x ^ 2) + cos (4 * x ^ 3)" (*|> Future.join*); (*<<<<<<<=========================*)
  1.1159 +(* the check for errpat is maximally liberal (whole term modulo "nrls" from "type met"),
  1.1160 +  would recognize "cos (4 * x ^ (4 - 1)) + 2 * x" as well.
  1.1161 +  results in <CALCMESSAGE> error pattern #chain-rule-diff-both# </CALCMESSAGE>
  1.1162 +  instead of <CALCMESSAGE> no derivation found </CALCMESSAGE> *)
  1.1163 +  val ((pt,pos), _) = get_calc 1;
  1.1164 +  val p = get_pos 1 1;
  1.1165 +  val (Form f, _, asms) = pt_extract (pt, p);
  1.1166 +
  1.1167 +  if p = ([1], Res) andalso UnparseC.term f = "d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))" then
  1.1168 +    case get_obj g_tac pt (fst p) of Rewrite_Inst (["(''bdv'', x)"], 
  1.1169 +      ("diff_sum", thm)) =>
  1.1170 +      if (UnparseC.term o Thm.prop_of) thm = "d_d ?bdv (?u + ?v) = d_d ?bdv ?u + d_d ?bdv ?v" then ()
  1.1171 +      else error "embed fun fill_form changed 11"
  1.1172 +    | _ => error "embed fun fill_form changed 12"
  1.1173 +  else error "embed fun fill_form changed 13";
  1.1174 +
  1.1175 +findFillpatterns 1 "chain-rule-diff-both"; (*<<<<<<<=================================*)
  1.1176 +(*<CALCMESSAGE> fill patterns #fill-d_d-arg#d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4)) =
  1.1177 +  d_d x (x ^^^ 2) + cos (x ^^^ 4) * d_d x ?_dummy_1#fill-both-args#...#...#... *)
  1.1178 +  val ((pt,pos),_) = get_calc 1;
  1.1179 +  val p = get_pos 1 1;
  1.1180 +
  1.1181 +  val (Form f, _, asms) = pt_extract (pt, p);
  1.1182 +  if p = ([1], Res) andalso UnparseC.term f = "d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))" then
  1.1183 +    case get_obj g_tac pt (fst p) of Rewrite_Inst (["(''bdv'', x)"], 
  1.1184 +      ("diff_sum", thm)) =>
  1.1185 +      if (UnparseC.term o Thm.prop_of) thm = "d_d ?bdv (?u + ?v) = d_d ?bdv ?u + d_d ?bdv ?v" then ()
  1.1186 +      else error "embed fun fill_form changed 21"
  1.1187 +    | _ => error "embed fun fill_form changed 22"
  1.1188 +  else error "embed fun fill_form changed 23";
  1.1189 +
  1.1190 +requestFillformula 1 ("chain-rule-diff-both", "fill-both-args");(*<<<<<<<============*)
  1.1191 +  (*<AUTOCALC> ([1], Res) ([2], Res) ([2], Res) </AUTOCALC>*)
  1.1192 +  val ((pt,pos),_) = get_calc 1;
  1.1193 +  val p = get_pos 1 1;
  1.1194 +  val (Form f, _, asms) = pt_extract (pt, p);
  1.1195 +  if p = ([1], Res) andalso existpt [2] pt
  1.1196 +    andalso UnparseC.term f = "d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))"
  1.1197 +  then case get_obj g_tac pt (fst p) of Rewrite_Inst (["(''bdv'', x)"], 
  1.1198 +      ("diff_sum", thm)) =>
  1.1199 +      if (UnparseC.term o Thm.prop_of) thm = "d_d ?bdv (?u + ?v) = d_d ?bdv ?u + d_d ?bdv ?v" then ()
  1.1200 +      else error "embed fun fill_form changed 31"
  1.1201 +    | _ => error "embed fun fill_form changed 32"
  1.1202 +  else error "embed fun fill_form changed 33";
  1.1203 +
  1.1204 +(* input a formula which exactly fills the gaps in a "fillformula"
  1.1205 +   presented to the learner immediately before by "requestFillformula (errpatID, fillpatID)":
  1.1206 +   errpatID: lhs of the respective thm = lhs of fillformula with fillpatID.
  1.1207 +   the respective thm is in the ctree ................
  1.1208 +*)
  1.1209 +"~~~~~ fun inputFillFormula, args:"; val (cI, ifo) =
  1.1210 +  (1, "d_d x (x ^^^ 2) + cos (x ^^^ 4) * d_d x (x ^^^ 4)");
  1.1211 +    val ((pt, _), _) = get_calc cI
  1.1212 +    val pos = get_pos cI 1;
  1.1213 +
  1.1214 +"~~~~~ fun is_exactly_equal, args:"; val ((pt, pos as (p, p_)), istr) = ((pt, pos), ifo);
  1.1215 +  val SOME ifo = parseNEW (ThyC.get_theory "Isac_Knowledge" |> ThyC.to_ctxt) istr
  1.1216 +  val p' = lev_on p;
  1.1217 +  val tac = get_obj g_tac pt p';
  1.1218 +val Rewrite_Inst ([bbb as "(''bdv'', x)"], ("diff_sin_chain", ttt)) = tac;
  1.1219 +if (UnparseC.term o Thm.prop_of) ttt = "d_d ?bdv (sin ?u) = cos ?u * d_d ?bdv ?u" then ()
  1.1220 +else error "inputFillFormula changed 10";
  1.1221 +  val Appl rew = applicable_in pos pt tac;
  1.1222 +  val Rewrite_Inst' (_, _, _, _, _, _, _, (res, _)) = rew;
  1.1223 +
  1.1224 +"~~~~~ to inputFillFormula return val:"; val ("ok", tac) = ("ok", tac);
  1.1225 +  val ("ok", (_, c, ptp as (_,p'))) = Step.by_tactic tac (pt, pos);
  1.1226 +    upd_calc cI (ptp, []);
  1.1227 +    upd_ipos cI 1 p';
  1.1228 +    autocalculateOK2xml cI pos (if null c then p' else last_elem c) p';
  1.1229 +
  1.1230 +"~~~~~ final check:";
  1.1231 +val ((pt, _),_) = get_calc 1;
  1.1232 +val p = get_pos 1 1;
  1.1233 +val (Form f, _, asms) = pt_extract (pt, p);
  1.1234 +  if p = ([2], Res) andalso UnparseC.term f = "d_d x (x ^^^ 2) + cos (x ^^^ 4) * d_d x (x ^^^ 4)"
  1.1235 +  then case get_obj g_tac pt (fst p) of Rewrite_Inst (["(''bdv'', x)"], 
  1.1236 +      ("diff_sin_chain", thm)) =>
  1.1237 +      if (UnparseC.term o Thm.prop_of) thm = "d_d ?bdv (sin ?u) = cos ?u * d_d ?bdv ?u" then ()
  1.1238 +      else error "inputFillFormula changed 111"
  1.1239 +    | _ => error "inputFillFormula changed 112"
  1.1240 +  else error "inputFillFormula changed 113";
  1.1241 +
  1.1242 +"--------- fun appl_adds -----------------------------------------";
  1.1243 +"--------- fun appl_adds -----------------------------------------";
  1.1244 +"--------- fun appl_adds -----------------------------------------";
  1.1245 +(* val (dI, oris, ppc, pbt, selct::ss) = 
  1.1246 +       (dI, pors, probl, ppc, map itms2fstr probl);
  1.1247 +   ...vvv
  1.1248 +   *)
  1.1249 +(* val (dI, oris, ppc, pbt, (selct::ss))=
  1.1250 +       (#1 (some_spec ospec spec), oris, []:itm list,
  1.1251 +	((#ppc o get_pbt) (#2 (some_spec ospec spec))),(imodel2fstr imodel));
  1.1252 +   val iii = appl_adds dI oris ppc pbt (selct::ss); 
  1.1253 +   tracing(itms2str_ thy iii);
  1.1254 +
  1.1255 + val itm = appl_add' dI oris ppc pbt selct;
  1.1256 + val ppc = insert_ppc' itm ppc;
  1.1257 +
  1.1258 + val _::selct::ss = (selct::ss);
  1.1259 + val itm = appl_add' dI oris ppc pbt selct;
  1.1260 + val ppc = insert_ppc' itm ppc;
  1.1261 +
  1.1262 + val _::selct::ss = (selct::ss);
  1.1263 + val itm = appl_add' dI oris ppc pbt selct;
  1.1264 + val ppc = insert_ppc' itm ppc;
  1.1265 + tracing(itms2str_ thy ppc);
  1.1266 +
  1.1267 + val _::selct::ss = (selct::ss);
  1.1268 + val itm = appl_add' dI oris ppc pbt selct;
  1.1269 + val ppc = insert_ppc' itm ppc;
  1.1270 +   *)
  1.1271 +"--------- fun concat_deriv --------------------------------------";
  1.1272 +"--------- fun concat_deriv --------------------------------------";
  1.1273 +"--------- fun concat_deriv --------------------------------------";
  1.1274 +(*
  1.1275 + val ({rew_ord, erls, rules,...}, fo, ifo) = 
  1.1276 +     (Rule_Set.rep Test_simplify, str2term "x+1+ -1*2=0", str2term "-2*1+(x+1)=0");
  1.1277 + (tracing o Derive.trtas2str) fod';
  1.1278 +> ["
  1.1279 +(x + 1 + -1 * 2 = 0, Thm ("radd_commute","?m + ?n = ?n + ?m"), (-1 * 2 + (x + 1) = 0, []))","
  1.1280 +(-1 * 2 + (x + 1) = 0, Thm ("radd_commute","?m + ?n = ?n + ?m"), (-1 * 2 + (1 + x) = 0, []))","
  1.1281 +(-1 * 2 + (1 + x) = 0, Thm ("radd_left_commute","?x + (?y + ?z) = ?y + (?x + ?z)"), (1 + (-1 * 2 + x) = 0, []))","
  1.1282 +(1 + (-1 * 2 + x) = 0, Thm ("#mult_Float ((~1,0), (0,0)) __ ((2,0), (0,0))","-1 * 2 = -2"), (1 + (-2 + x) = 0, []))"]
  1.1283 +val it = () : unit
  1.1284 + (tracing o Derive.trtas2str) (map Derive.rev_deriv' rifod');
  1.1285 +> ["
  1.1286 +(1 + (-2 + x) = 0, Thm ("sym_#mult_Float ((~2,0), (0,0)) __ ((1,0), (0,0))","-2 = -2 * 1"), (1 + (-2 * 1 + x) = 0, []))","
  1.1287 +(1 + (-2 * 1 + x) = 0, Thm ("sym_radd_left_commute","?y + (?x + ?z) = ?x + (?y + ?z)"), (-2 * 1 + (1 + x) = 0, []))","
  1.1288 +(-2 * 1 + (1 + x) = 0, Thm ("sym_radd_commute","?n + ?m = ?m + ?n"), (-2 * 1 + (x + 1) = 0, []))"]
  1.1289 +val it = () : unit
  1.1290 +*)
  1.1291 +"--------- handle an input formula -------------------------------";
  1.1292 +"--------- handle an input formula -------------------------------";
  1.1293 +"--------- handle an input formula -------------------------------";
  1.1294 +(*
  1.1295 +Untersuchung zur Formeleingabe (appendFormula, replaceFormla) zu einer Anregung von Alan Krempler:
  1.1296 +Welche RICHTIGEN Formeln koennen NICHT abgeleitet werden, 
  1.1297 +wenn Abteilungen nur auf gleichem Level gesucht werden ?
  1.1298 +WN.040216 
  1.1299 +
  1.1300 +Beispiele zum Equationsolver von Richard Lang aus /src/sml/kbtest/rlang.sml
  1.1301 +
  1.1302 +------------------------------------------------------------------------------
  1.1303 +"Schalk I s.87 Bsp 52a ((5*x)/(x - 2) - x/(x+2)=4)";
  1.1304 +------------------------------------------------------------------------------
  1.1305 +1. "5 * x / (x - 2) - x / (x + 2) = 4"
  1.1306 +...
  1.1307 +4. "12 * x + 4 * x ^^^ 2 = 4 * (-4 + x ^^^ 2)",Subproblem["normalise", "poly"..
  1.1308 +...
  1.1309 +4.3. "16 + 12 * x = 0", Subproblem["degree_1", "polynomial", "univariate"..
  1.1310 +...
  1.1311 +4.3.3. "[x = -4 / 3]")), Check_elementwise "Assumptions"
  1.1312 +...
  1.1313 +"[x = -4 / 3]"
  1.1314 +------------------------------------------------------------------------------
  1.1315 +(1)..(6): keine 'richtige' Eingabe kann abgeleitet werden, die einen Summanden auf die andere Seite verschiebt [Ableitung ware in 4.3.n]
  1.1316 +
  1.1317 +(4.1)..(4.3): keine 'richtige' Eingabe kann abgeleitet werden, die einen Summanden auf die andere Seite verschiebt [Ableitung ware in 4.3.n]
  1.1318 +------------------------------------------------------------------------------
  1.1319 +
  1.1320 +
  1.1321 +------------------------------------------------------------------------------
  1.1322 +"Schalk I s.87 Bsp 55b (x/(x^^^2 - 6*x+9) - 1/(x^^^2 - 3*x) =1/x)";
  1.1323 +------------------------------------------------------------------------------
  1.1324 +1. "x / (x ^^^ 2 - 6 * x + 9) - 1 / (x ^^^ 2 - 3 * x) = 1 / x"
  1.1325 +...
  1.1326 +4. "(3 + (-1 * x + x ^^^ 2)) * x = 1 * (9 * x + (x ^^^ 3 + -6 * x ^^^ 2))"
  1.1327 +                         Subproblem["normalise", "polynomial", "univariate"..
  1.1328 +...
  1.1329 +4.4. "-6 * x + 5 * x ^^^ 2 = 0", Subproblem["bdv_only", "degree_2", "poly"..
  1.1330 +...
  1.1331 +4.4.4. "[x = 0, x = 6 / 5]", Check_elementwise "Assumptions"
  1.1332 +4.4.5. "[x = 0, x = 6 / 5]"
  1.1333 +...
  1.1334 +5. "[x = 0, x = 6 / 5]", Check_elementwise "Assumptions"
  1.1335 +   "[x = 6 / 5]"
  1.1336 +------------------------------------------------------------------------------
  1.1337 +(1)..(4): keine 'richtige' Eingabe kann abgeleitet werden, die einen Summanden auf die andere Seite schiebt [Ableitung waere in 4.4.x]
  1.1338 +
  1.1339 +(4.1)..(4.4.5): keine 'richtige' Eingabe kann abgeleitet werden, die dem Ergebnis "[x = 6 / 5]" aequivalent ist [Ableitung waere in 5.]
  1.1340 +------------------------------------------------------------------------------
  1.1341 +
  1.1342 +
  1.1343 +------------------------------------------------------------------------------
  1.1344 +"Schalk II s.56 Bsp 73b (sqrt(x+1)+sqrt(4*x+4)=sqrt(9*x+9))";
  1.1345 +------------------------------------------------------------------------------
  1.1346 +1. "sqrt (x + 1) + sqrt (4 * x + 4) = sqrt (9 * x + 9)"
  1.1347 +...
  1.1348 +6. "13 + 13 * x + -2 * sqrt ((4 + 4 * x) * (9 + 9 * x)) = 1 + x"
  1.1349 +                             Subproblem["sq", "rootX", "univariate", "equation"]
  1.1350 +...
  1.1351 +6.6. "144 + 288 * x + 144 * x ^^^ 2 = 144 + x ^^^ 2 + 288 * x + 143 * x ^^^ 2"
  1.1352 +                Subproblem["normalise", "polynomial", "univariate", "equation"]
  1.1353 +...
  1.1354 +6.6.3 "0 = 0"    Subproblem["degree_0", "polynomial", "univariate", "equation"]
  1.1355 +...                                       Or_to_List
  1.1356 +6.6.3.2 "UniversalList"
  1.1357 +------------------------------------------------------------------------------
  1.1358 +(1)..(6): keine 'richtige' Eingabe kann abgeleitet werden, die eine der Wurzeln auf die andere Seite verschieb [Ableitung ware in 6.6.n]
  1.1359 +
  1.1360 +(6.1)..(6.3): keine 'richtige' Eingabe kann abgeleitet werden, die einen Summanden auf die andere Seite verschiebt [Ableitung ware in 6.6.n]
  1.1361 +------------------------------------------------------------------------------
  1.1362 +*)
  1.1363 +(*sh. comments auf 498*)
  1.1364 +"--------- fun dropwhile' ----------------------------------------";
  1.1365 +"--------- fun dropwhile' ----------------------------------------";
  1.1366 +"--------- fun dropwhile' ----------------------------------------";
  1.1367 +(*
  1.1368 + fun equal a b = a=b;
  1.1369 + val foder = [0,1,2,3,4,5]; val ifoder = [11,12,3,4,5];
  1.1370 + val r_foder = rev foder;  val r_ifoder = rev ifoder;
  1.1371 + dropwhile' equal r_foder r_ifoder;
  1.1372 +> vval it = ([0, 1, 2, 3], [3, 12, 11]) : int list * int list
  1.1373 +
  1.1374 + val foder = [3,4,5]; val ifoder = [11,12,3,4,5];
  1.1375 + val r_foder = rev foder;  val r_ifoder = rev ifoder;
  1.1376 + dropwhile' equal r_foder r_ifoder;
  1.1377 +> val it = ([3], [3, 12, 11]) : int list * int list
  1.1378 +
  1.1379 + val foder = [5]; val ifoder = [11,12,3,4,5];
  1.1380 + val r_foder = rev foder;  val r_ifoder = rev ifoder;
  1.1381 + dropwhile' equal r_foder r_ifoder;
  1.1382 +> val it = ([5], [5, 4, 3, 12, 11]) : int list * int list
  1.1383 +
  1.1384 + val foder = [10,11,12,13,14,15]; val ifoder = [11,12,3,4,5];
  1.1385 + val r_foder = rev foder;  val r_ifoder = rev ifoder;
  1.1386 + dropwhile' equal r_foder r_ifoder;
  1.1387 +> *** dropwhile': did not start with equal elements*)