1 (* Title: tests the interface of isac's SML-kernel in accordance to
2 java-tests/isac.bridge.
4 (c) copyright due to lincense terms.
6 WN050707 ... if true, the test ist marked with a \label referring
7 to the same UC in isac-docu.tex as the JUnit testcase.
8 WN120210?not ME: added some labels, which are not among the above,
9 repaired lost \label (s).
11 theory Test_Some imports Build_Thydata begin
12 ML {* KEStore_Elems.set_ref_thy @{theory};
13 fun autoCalculate' cI auto = autoCalculate cI auto (*|> Future.join*) *}
14 ML_file "Frontend/use-cases.sml"
17 "--------------------------------------------------------";
18 "table of contents --------------------------------------";
19 "--------------------------------------------------------";
20 "within struct ------------------------------------------";
21 "--------------------------------------------------------";
22 "--------- encode ^ -> ^^^ ------------------------------";
23 "--------------------------------------------------------";
24 "exported from struct -----------------------------------";
25 "--------------------------------------------------------";
26 "--------- empty rootpbl --------------------------------";
27 "--------- solve_linear as rootpbl FE -------------------";
28 "--------- inspect the CalcTree No.1 with Iterator No.2 -";
29 "--------- miniscript with mini-subpbl ------------------";
30 "--------- mini-subpbl AUTOCALCULATE Step 1 -------------";
31 "--------- solve_linear as rootpbl AUTO CompleteCalc ----";
32 "--------- solve_linear as rootpbl AUTO CompleteHead/Calc ";
33 "--------- mini-subpbl AUTOCALCULATE CompleteCalc -------";
34 "--------- mini-subpbl AUTO CompleteCalcHead ------------";
35 "--------- solve_linear as rootpbl AUTO CompleteModel ---";
36 "--------- setContext..Thy ------------------------------";
37 "--------- mini-subpbl AUTOCALC CompleteToSubpbl --------";
38 "--------- rat-eq + subpbl: no_met, NO solution dropped -";
39 "--------- tryMatchProblem, tryRefineProblem ------------";
40 "--------- modifyCalcHead, resetCalcHead, modelProblem --";
41 "--------- maximum-example, UC: Modeling an example -----";
42 "--------- solve_linear from pbl-hierarchy --------------";
43 "--------- solve_linear as in an algebra system (CAS)----";
44 "--------- interSteps: on 'miniscript with mini-subpbl' -";
45 "--------- getTactic, fetchApplicableTactics ------------";
46 "--------- getAssumptions, getAccumulatedAsms -----------";
47 "--------- arbitrary combinations of steps --------------";
48 "--------- appendF label{SOLVE:MANUAL:FORMULA:enter}right";
49 "--------- appendF label{SOLVE:MANUAL:FORMULA:enter}other";
50 "--------- appendF label{SOLVE:MANUAL:FORMULA:enter}oth 2";
51 "--------- appendF label{SOLVE:MANUAL:FORMULA:enter}NOTok";
52 "--------- replaceFormula {SOL:MAN:FOR:replace} right----";
53 "--------- replaceFormula {SOL:MAN:FOR:replace} other----";
54 "--------- replaceFormula {SOL:MAN:FOR:replace} other 2--";
55 "--------- replaceFormula {SOL:MAN:FOR:replace} NOTok----";
56 "--------- UC errpat chain-rule-diff-both, fillpat by input ------";
57 "--------- UC errpat add-fraction, fillpat by input --------------";
58 "--------- UC errpat, fillpat step to Rewrite --------------------";
59 "--------- UC errpat, fillpat step to Rewrite_Set ----------------";
60 "--------------------------------------------------------";
62 "within struct ---------------------------------------------------";
63 "within struct ---------------------------------------------------";
64 "within struct ---------------------------------------------------";
65 (*==================================================================
68 "--------- encode ^ -> ^^^ ------------------------------";
69 "--------- encode ^ -> ^^^ ------------------------------";
70 "--------- encode ^ -> ^^^ ------------------------------";
71 if encode "a^2+b^2=c^2" = "a^^^2+b^^^2=c^^^2" then ()
72 else error "interface.sml: diff.behav. in encode ^ -> ^^^ ";
74 if (decode o encode) "a^2+b^2=c^2" = "a^2+b^2=c^2" then ()
75 else error "interface.sml: diff.behav. in de/encode ^ <-> ^^^ ";
77 ==================================================================*)
78 "exported from struct --------------------------------------------";
79 "exported from struct --------------------------------------------";
80 "exported from struct --------------------------------------------";
83 (*------------ set at startup of the Kernel ----------------------*)
84 reset_states (); (*resets all state information in Kernel *)
85 (*----------------------------------------------------------------*)
87 "--------- empty rootpbl --------------------------------";
88 "--------- empty rootpbl --------------------------------";
89 "--------- empty rootpbl --------------------------------";
90 CalcTree [([], ("", [], []))];
93 refFormula 1 (get_pos 1 1);
94 (*WN.040222: stoert das sehr, dass e_domID etc. statt leer kommt ???*)
97 "--------- solve_linear as rootpbl FE -------------------";
98 "--------- solve_linear as rootpbl FE -------------------";
99 "--------- solve_linear as rootpbl FE -------------------";
100 CalcTree (*start of calculation, return No.1*)
101 [(["equality (1+-1*2+x=(0::real))", "solveFor x","solutions L"],
103 ["LINEAR","univariate","equation","test"],
104 ["Test","solve_linear"]))];
105 Iterator 1; (*create an active Iterator on CalcTree No.1*)
107 moveActiveRoot 1;(*sets the CalcIterator No.1 at the root of CalcTree No.1*);
108 refFormula 1 (get_pos 1 1) (*gets CalcHead; model is still empty*);
111 fetchProposedTactic 1 (*by using Iterator No.1*);
112 setNextTactic 1 (Model_Problem); (*by using Iterator No.1*)
113 autoCalculate 1 (Step 1);
114 refFormula 1 (get_pos 1 1) (*model contains descriptions for all items*);
115 autoCalculate 1 (Step 1);
116 (*-----since Model_Problem + complete_mod_ in case cas of SOME-----*
117 fetchProposedTactic 1;
118 setNextTactic 1 (Add_Given "equality (1 + -1 * 2 + x = 0)");
119 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1); (*equality added*);
121 fetchProposedTactic 1;
122 setNextTactic 1 (Add_Given "solveFor x");
123 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
125 fetchProposedTactic 1;
126 setNextTactic 1 (Add_Find "solutions L");
127 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
129 fetchProposedTactic 1;
130 setNextTactic 1 (Specify_Theory "Test");
131 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
132 *-----since Model_Problem + complete_mod_ in case cas of SOME-----*)
134 fetchProposedTactic 1;
135 setNextTactic 1 (Specify_Problem ["LINEAR","univariate","equation","test"]);
136 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
137 (*-------------------------------------------------------------------------*)
138 fetchProposedTactic 1;
139 val (ptp as (pt,p), tacis) = get_calc 1; get_pos 1 1;
141 setNextTactic 1 (Specify_Method ["Test","solve_linear"]);
142 val (ptp as (pt,p), tacis) = get_calc 1; get_pos 1 1;
144 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
145 val (ptp as (pt,p), tacis) = get_calc 1; get_pos 1 1;
147 (*-------------------------------------------------------------------------*)
148 fetchProposedTactic 1;
149 val (ptp as (pt,p), tacis) = get_calc 1; get_pos 1 1;
151 setNextTactic 1 (Apply_Method ["Test","solve_linear"]);
152 (*ERROR.110620 <SETNEXTTACTIC>..<MESSAGE> end-of-calculation*)
153 val (ptp as (pt,p), tacis) = get_calc 1; get_pos 1 1;
155 is_complete_spec ptp;
157 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
158 val (ptp as (pt,p), tacis) = get_calc 1; get_pos 1 1;
159 (*term2str (get_obj g_form pt [1]);*)
160 (*-------------------------------------------------------------------------*)
162 fetchProposedTactic 1;
163 setNextTactic 1 (Rewrite_Set_Inst (["(bdv,x)"], "isolate_bdv"));
164 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
166 fetchProposedTactic 1;
167 setNextTactic 1 (Rewrite_Set "Test_simplify");
168 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
170 fetchProposedTactic 1;
171 setNextTactic 1 (Check_Postcond ["LINEAR","univariate","equation","test"]);
172 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
174 val ((pt,_),_) = get_calc 1;
175 val ip = get_pos 1 1;
176 val (Form f, tac, asms) = pt_extract (pt, ip);
177 (*exception just above means: 'ModSpec' has been returned: error anyway*)
178 if term2str f = "[x = 1]" then () else
179 error "FE-Kernel-interface.sml: diff.behav. in solve_linear as rootpbl";
181 "--------- inspect the CalcTree No.1 with Iterator No.2 -";
182 "--------- inspect the CalcTree No.1 with Iterator No.2 -";
183 "--------- inspect the CalcTree No.1 with Iterator No.2 -";
184 (*WN041118: inspection shifted to Iterator No.1, because others need pos'*)
186 refFormula 1 ([],Pbl); getTactic 1 ([],Pbl);(*Error*)
188 refFormula 1 ([1],Frm); getTactic 1 ([1],Frm);(*Error*)
190 refFormula 1 ([1],Res); getTactic 1 ([1],Res);(*OK*)
191 (*getAssumption 1 ([1],Res); TODO.WN041217*)
192 moveActiveDown 1 ; refFormula 1 ([2],Res);
193 moveActiveCalcHead 1; refFormula 1 ([],Pbl);
197 if get_pos 1 1 = ([2], Res) then () else
198 error "FE-interface.sml: diff.behav. in a inspect 1 with Iterator 2";
199 moveActiveDown 1; refFormula 1 ([], Res);
200 if get_pos 1 1 = ([], Res) then () else
201 error "FE-interface.sml: diff.behav. in b inspect 1 with Iterator 2";
202 moveActiveCalcHead 1; refFormula 1 ([],Pbl);
205 "--------- miniscript with mini-subpbl ------------------";
206 "--------- miniscript with mini-subpbl ------------------";
207 "--------- miniscript with mini-subpbl ------------------";
208 (*WN120210?not ME:\label{SOLVE:MANUAL:TACTIC:enter} UC 30.3.2.1 p.175 !!!!!NOT IMPL IN FE*)
209 "=== this sequence of fun-calls resembles fun me ===";
210 reset_states (); (*start of calculation, return No.1*)
211 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
212 ("Test", ["sqroot-test","univariate","equation","test"],
213 ["Test","squ-equ-test-subpbl1"]))];
217 refFormula 1 (get_pos 1 1);
218 fetchProposedTactic 1;
219 setNextTactic 1 (Model_Problem);
220 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*gets ModSpec;model is still empty*)
222 fetchProposedTactic 1;
223 setNextTactic 1 (Add_Given "equality (x + 1 = 2)");
224 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
226 fetchProposedTactic 1;
227 setNextTactic 1 (Add_Given "solveFor x");
228 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
230 fetchProposedTactic 1;
231 setNextTactic 1 (Add_Find "solutions L");
232 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
234 fetchProposedTactic 1;
235 setNextTactic 1 (Specify_Theory "Test");
236 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
238 fetchProposedTactic 1;
239 setNextTactic 1 (Specify_Problem
240 ["sqroot-test","univariate","equation","test"]);
241 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
242 "1-----------------------------------------------------------------";
244 fetchProposedTactic 1;
245 setNextTactic 1 (Specify_Method ["Test","squ-equ-test-subpbl1"]);
246 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
248 fetchProposedTactic 1;
249 setNextTactic 1 (Apply_Method ["Test","squ-equ-test-subpbl1"]);
250 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
252 fetchProposedTactic 1;
253 setNextTactic 1 (Rewrite_Set "norm_equation");
254 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
256 fetchProposedTactic 1;
257 setNextTactic 1 (Rewrite_Set "Test_simplify");
258 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
260 fetchProposedTactic 1;(*----------------Subproblem--------------------*);
261 setNextTactic 1 (Subproblem ("Test",
262 ["LINEAR","univariate","equation","test"]));
263 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
265 fetchProposedTactic 1;
266 setNextTactic 1 (Model_Problem );
267 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
269 fetchProposedTactic 1;
270 setNextTactic 1 (Add_Given "equality (-1 + x = 0)");
271 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
273 fetchProposedTactic 1;
274 setNextTactic 1 (Add_Given "solveFor x");
275 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
277 fetchProposedTactic 1;
278 setNextTactic 1 (Add_Find "solutions x_i");
279 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
281 fetchProposedTactic 1;
282 setNextTactic 1 (Specify_Theory "Test");
283 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
285 fetchProposedTactic 1;
286 setNextTactic 1 (Specify_Problem ["LINEAR","univariate","equation","test"]);
287 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
288 "2-----------------------------------------------------------------";
290 fetchProposedTactic 1;
291 setNextTactic 1 (Specify_Method ["Test","solve_linear"]);
292 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
294 fetchProposedTactic 1;
295 setNextTactic 1 (Apply_Method ["Test","solve_linear"]);
296 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
298 fetchProposedTactic 1;
299 setNextTactic 1 (Rewrite_Set_Inst (["(bdv,x)"], "isolate_bdv"));
300 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
302 fetchProposedTactic 1;
303 setNextTactic 1 (Rewrite_Set "Test_simplify");
304 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
306 fetchProposedTactic 1;
307 setNextTactic 1 (Check_Postcond ["LINEAR","univariate","equation","test"]);
308 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
310 fetchProposedTactic 1;
311 setNextTactic 1 (Check_elementwise "Assumptions");
312 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
314 val xml = fetchProposedTactic 1;
315 setNextTactic 1 (Check_Postcond
316 ["sqroot-test","univariate","equation","test"]);
317 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
319 val ((pt,_),_) = get_calc 1;
320 val str = pr_ptree pr_short pt;
322 val ip = get_pos 1 1;
323 val (Form f, tac, asms) = pt_extract (pt, ip);
324 (*exception just above means: 'ModSpec' has been returned: error anyway*)
325 if term2str f = "[x = 1]" then () else
326 error "FE-interface.sml: diff.behav. in miniscript with mini-subpb";
329 "--------- mini-subpbl AUTOCALCULATE Step 1 -------------";
330 "--------- mini-subpbl AUTOCALCULATE Step 1 -------------";
331 "--------- mini-subpbl AUTOCALCULATE Step 1 -------------";
332 (*WN120210?not ME:\label{SOLVE:AUTO:one} UC 30.3.3.2 p.176*)
333 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
334 ("Test", ["sqroot-test","univariate","equation","test"],
335 ["Test","squ-equ-test-subpbl1"]))];
338 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
339 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
340 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
341 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
342 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
343 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
344 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
345 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
346 (*here the solve-phase starts*)
347 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
348 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
349 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
350 (*------------------------------------*)
351 (* default_print_depth 13; get_calc 1;
353 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
354 (*calc-head of subproblem*)
355 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
356 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
357 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
358 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
359 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
360 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
361 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
362 (*solve-phase of the subproblem*)
363 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
364 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
365 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
366 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
367 (*finish subproblem*)
368 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
370 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
372 (*this checks the test for correctness..*)
373 val ((pt,_),_) = get_calc 1;
375 val (Form f, tac, asms) = pt_extract (pt, p);
376 if term2str f = "[x = 1]" andalso p = ([], Res) then () else
377 error "FE-interface.sml: diff.behav. in miniscript with mini-subpb";
381 "--------- solve_linear as rootpbl AUTO CompleteCalc ----";
382 "--------- solve_linear as rootpbl AUTO CompleteCalc ----";
383 "--------- solve_linear as rootpbl AUTO CompleteCalc ----";
384 (*WN120210?not ME:\label{SPECIFY:START:auto} UC 30.2.4.2 p.174*)
386 [(["equality (1+-1*2+x=(0::real))", "solveFor x","solutions L"],
388 ["LINEAR","univariate","equation","test"],
389 ["Test","solve_linear"]))];
392 getFormulaeFromTo 1 ([],Pbl) ([],Pbl) 999 false;
394 autoCalculate 1 CompleteCalc;
395 val (unc, del, gen) = (([],Pbl), ([],Pbl), ([],Res));
396 getFormulaeFromTo 1 unc gen 1 (*only level 1*) false;
398 val ((pt,_),_) = get_calc 1;
400 val (Form f, tac, asms) = pt_extract (pt, p);
401 if term2str f = "[x = 1]" andalso p = ([], Res) then () else
402 error "FE-interface.sml: diff.behav. in solve_linear/rt AUTOCALCULATE ";
405 "--------- solve_linear as rootpbl AUTO CompleteHead/Calc ";
406 "--------- solve_linear as rootpbl AUTO CompleteHead/Calc ";
407 "--------- solve_linear as rootpbl AUTO CompleteHead/Calc ";
408 (* ERROR: error in kernel ?? *)
410 [(["equality (1+-1*2+x=(0::real))", "solveFor x","solutions L"],
412 ["LINEAR","univariate","equation","test"],
413 ["Test","solve_linear"]))];
417 autoCalculate 1 CompleteCalcHead;
418 refFormula 1 (get_pos 1 1);
419 val ((pt,p),_) = get_calc 1;
421 autoCalculate 1 CompleteCalc;
422 val ((pt,p),_) = get_calc 1;
423 if p=([], Res) then () else
424 error "FE-interface.sml: diff.behav. in solve_linear AUTOC Head/Calc ";
427 "--------- mini-subpbl AUTOCALCULATE CompleteCalc -------";
428 "--------- mini-subpbl AUTOCALCULATE CompleteCalc -------";
429 "--------- mini-subpbl AUTOCALCULATE CompleteCalc -------";
430 (*WN120210?not ME:\label{SPECIFY:START:auto} UC 30.2.4.2 p.174*)
431 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
432 ("Test", ["sqroot-test","univariate","equation","test"],
433 ["Test","squ-equ-test-subpbl1"]))];
436 autoCalculate 1 CompleteCalc;
437 val ((pt,p),_) = get_calc 1; show_pt pt;
439 getTactic 1 ([1],Frm);
440 getTactic 1 ([1],Res);
441 initContext 1 Thy_ ([1],Res);
443 (*... returns calcChangedEvent with*)
444 val (unc, del, gen) = (([],Pbl), ([],Pbl), ([],Res));
445 getFormulaeFromTo 1 unc gen 0 (*only result*) false;
446 getFormulaeFromTo 1 unc gen 1 (*only level 1*) false;
447 getFormulaeFromTo 1 unc gen 99999 (*all levels*) false;
449 val ((pt,_),_) = get_calc 1;
451 val (Form f, tac, asms) = pt_extract (pt, p);
452 if term2str f = "[x = 1]" andalso p = ([], Res) then () else
453 error "FE-interface.sml: diff.behav. in mini-subpbl AUTOCALCULATE 6";
456 "--------- mini-subpbl AUTO CompleteCalcHead ------------";
457 "--------- mini-subpbl AUTO CompleteCalcHead ------------";
458 "--------- mini-subpbl AUTO CompleteCalcHead ------------";
459 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
460 ("Test", ["sqroot-test","univariate","equation","test"],
461 ["Test","squ-equ-test-subpbl1"]))];
464 autoCalculate 1 CompleteCalcHead;
466 val ((Nd (PblObj {env = NONE, fmz = (fm, ("Test", pblID, metID)), loc = (SOME (env, ctxt1), NONE),
467 cell = NONE, ctxt = ctxt2, meth,
468 spec = ("Test", ["sqroot-test", "univariate", "equation", "test"],
469 ["Test", "squ-equ-test-subpbl1"]),
470 probl, branch = TransitiveB, origin, ostate = Incomplete, result}, []),
471 ([], Met)), []) = get_calc 1;
472 if length meth = 3 andalso length probl = 3 (*just some items tested*) then ()
473 else error "--- mini-subpbl AUTO CompleteCalcHead ---";
476 "--------- solve_linear as rootpbl AUTO CompleteModel ---";
477 "--------- solve_linear as rootpbl AUTO CompleteModel ---";
478 "--------- solve_linear as rootpbl AUTO CompleteModel ---";
480 [(["equality (1+-1*2+x=(0::real))", "solveFor x","solutions L"],
482 ["LINEAR","univariate","equation","test"],
483 ["Test","solve_linear"]))];
486 autoCalculate 1 CompleteModel;
487 refFormula 1 (get_pos 1 1);
489 setProblem 1 ["LINEAR","univariate","equation","test"];
490 val pos = get_pos 1 1;
491 setContext 1 pos (kestoreID2guh Pbl_["LINEAR","univariate","equation","test"]);
492 refFormula 1 (get_pos 1 1);
494 setMethod 1 ["Test","solve_linear"];
495 setContext 1 pos (kestoreID2guh Met_ ["Test","solve_linear"]);
496 refFormula 1 (get_pos 1 1);
497 val ((pt,_),_) = get_calc 1;
498 if get_obj g_spec pt [] = ("e_domID",
499 ["LINEAR", "univariate","equation","test"],
500 ["Test","solve_linear"]) then ()
501 else error "FE-interface.sml: diff.behav. in setProblem, setMethod";
503 autoCalculate 1 CompleteCalcHead;
504 refFormula 1 (get_pos 1 1);
505 autoCalculate 1 CompleteCalc;
509 refFormula 1 (get_pos 1 1);
510 val ((pt,_),_) = get_calc 1;
512 val (Form f, tac, asms) = pt_extract (pt, p);
513 if term2str f = "[x = 1]" andalso p = ([], Res) then () else
514 error "FE-interface.sml: diff.behav. in mini-subpbl AUTOCALCULATE 6";
517 "--------- setContext..Thy ------------------------------";
518 "--------- setContext..Thy ------------------------------";
519 "--------- setContext..Thy ------------------------------";
521 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
522 ("Test", ["sqroot-test","univariate","equation","test"],
523 ["Test","squ-equ-test-subpbl1"]))];
524 Iterator 1; moveActiveRoot 1;
525 autoCalculate 1 CompleteCalcHead;
526 autoCalculate 1 (Step 1);
527 val ((pt,p),_) = get_calc 1; show_pt pt; (*2 lines, OK*)
529 setNextTactic 1 (Rewrite_Set "Test_simplify"); (*--> "thy_isac_Test-rls-Test_simplify"*)
530 autoCalculate 1 (Step 1);
531 val ((pt,p),_) = get_calc 1; show_pt pt;
533 "-----^^^^^ and vvvvv do the same -----";
534 setContext 1 p "thy_isac_Test-rls-Test_simplify";
535 val ((pt,p),_) = get_calc 1; show_pt pt; (*2 lines, OK*)
537 autoCalculate 1 (Step 1);
538 setContext 1 p "thy_isac_Test-rls-Test_simplify";
539 val (((pt,_),_), p) = (get_calc 1, get_pos 1 1);
540 val (Form f, tac, asms) = pt_extract (pt, p);
541 if p = ([1], Res) andalso term2str (get_obj g_res pt (fst p)) = "x + 1 + -1 * 2 = 0"
542 then () else error "--- setContext..Thy --- autoCalculate 1 (Step 1) #1";
544 autoCalculate 1 CompleteCalc;
545 val (((pt,_),_), p) = (get_calc 1, get_pos 1 1);
546 val (Form f, tac, asms) = pt_extract (pt, p);
548 if term2str f = "[x = 1]" andalso p = ([], Res) then ()
549 else error "--- setContext..Thy --- autoCalculate CompleteCalc";
552 "--------- mini-subpbl AUTOCALC CompleteToSubpbl --------";
553 "--------- mini-subpbl AUTOCALC CompleteToSubpbl --------";
554 "--------- mini-subpbl AUTOCALC CompleteToSubpbl --------";
555 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
556 ("Test", ["sqroot-test","univariate","equation","test"],
557 ["Test","squ-equ-test-subpbl1"]))];
558 Iterator 1; moveActiveRoot 1;
559 autoCalculate 1 CompleteToSubpbl;
560 refFormula 1 (get_pos 1 1); (*<ISA> -1 + x = 0 </ISA>*);
561 val ((pt,_),_) = get_calc 1;
562 val str = pr_ptree pr_short pt;
564 if str = ". ----- pblobj -----\n1. x + 1 = 2\n2. x + 1 + -1 * 2 = 0\n"
566 error "FE-interface.sml: diff.behav. in mini-subpbl CompleteToSubpbl-1";
568 autoCalculate 1 (Step 1); (*proceeds only, of NOT 1 step before subplb*)
569 autoCalculate 1 CompleteToSubpbl;
570 val ((pt,_),_) = get_calc 1;
571 val str = pr_ptree pr_short pt;
573 autoCalculate 1 CompleteCalc; (*das geht ohnehin !*);
574 val ((pt,_),_) = get_calc 1;
577 val (Form f, tac, asms) = pt_extract (pt, p);
578 if term2str f = "[x = 1]" andalso p = ([], Res) then () else
579 error "FE-interface.sml: diff.behav. in mini-subpbl CompleteToSubpbl 1";
582 "--------- rat-eq + subpbl: no_met, NO solution dropped -";
583 "--------- rat-eq + subpbl: no_met, NO solution dropped -";
584 "--------- rat-eq + subpbl: no_met, NO solution dropped -";
586 [(["equality ((5*x)/(x - 2) - x/(x+2)=(4::real))", "solveFor x","solutions L"],
587 ("RatEq", ["univariate","equation"], ["no_met"]))];
590 fetchProposedTactic 1;
592 setNextTactic 1 (Model_Problem);
593 autoCalculate 1 (Step 1); fetchProposedTactic 1;
595 setNextTactic 1 (Specify_Theory "RatEq");
596 autoCalculate 1 (Step 1); fetchProposedTactic 1;
597 setNextTactic 1 (Specify_Problem ["rational","univariate","equation"]);
598 autoCalculate 1 (Step 1); fetchProposedTactic 1;
599 setNextTactic 1 (Specify_Method ["RatEq","solve_rat_equation"]);
600 autoCalculate 1 (Step 1); fetchProposedTactic 1;
601 setNextTactic 1 (Apply_Method ["RatEq","solve_rat_equation"]);
602 autoCalculate 1 (Step 1); fetchProposedTactic 1;
603 setNextTactic 1 (Rewrite_Set "RatEq_simplify");
604 autoCalculate 1 (Step 1); fetchProposedTactic 1;
605 setNextTactic 1 (Rewrite_Set "norm_Rational");
606 autoCalculate 1 (Step 1); fetchProposedTactic 1;
607 setNextTactic 1 (Rewrite_Set "RatEq_eliminate");
608 autoCalculate 1 (Step 1); fetchProposedTactic 1;
609 (* __________ for "12 * x + 4 * x ^^^ 2 = 4 * (-4 + x ^^^ 2)"*)
610 setNextTactic 1 (Subproblem ("PolyEq", ["normalize","polynomial",
611 "univariate","equation"]));
612 autoCalculate 1 (Step 1); fetchProposedTactic 1;
613 setNextTactic 1 (Model_Problem );
614 autoCalculate 1 (Step 1); fetchProposedTactic 1;
615 setNextTactic 1 (Specify_Theory "PolyEq");
616 autoCalculate 1 (Step 1); fetchProposedTactic 1;
617 setNextTactic 1 (Specify_Problem ["normalize","polynomial",
618 "univariate","equation"]);
619 autoCalculate 1 (Step 1); fetchProposedTactic 1;
620 setNextTactic 1 (Specify_Method ["PolyEq","normalize_poly"]);
621 autoCalculate 1 (Step 1); fetchProposedTactic 1;
622 setNextTactic 1 (Apply_Method ["PolyEq","normalize_poly"]);
623 autoCalculate 1 (Step 1); fetchProposedTactic 1;
624 setNextTactic 1 (Rewrite ("all_left",""));
625 autoCalculate 1 (Step 1); fetchProposedTactic 1;
626 setNextTactic 1 (Rewrite_Set_Inst (["(bdv,x)"], "make_ratpoly_in"));
627 autoCalculate 1 (Step 1); fetchProposedTactic 1;
628 (* __________ for "16 + 12 * x = 0"*)
629 setNextTactic 1 (Subproblem ("PolyEq",
630 ["degree_1","polynomial","univariate","equation"]));
631 autoCalculate 1 (Step 1); fetchProposedTactic 1;
632 setNextTactic 1 (Model_Problem );
633 autoCalculate 1 (Step 1); fetchProposedTactic 1;
634 setNextTactic 1 (Specify_Theory "PolyEq");
635 (*------------- some trials in the problem-hierarchy ---------------*)
636 setNextTactic 1 (Specify_Problem ["LINEAR","univariate","equation"]);
637 autoCalculate 1 (Step 1); fetchProposedTactic 1; (*<ERROR> helpless </ERROR> !!!*)
638 setNextTactic 1 (Refine_Problem ["univariate","equation"]);
639 (*------------------------------------------------------------------*)
640 autoCalculate 1 (Step 1); fetchProposedTactic 1;
641 setNextTactic 1 (Specify_Method ["PolyEq","solve_d1_polyeq_equation"]);
642 autoCalculate 1 (Step 1); fetchProposedTactic 1;
643 setNextTactic 1 (Apply_Method ["PolyEq","solve_d1_polyeq_equation"]);
644 autoCalculate 1 (Step 1); fetchProposedTactic 1;
645 setNextTactic 1 (Rewrite_Set_Inst (["(bdv,x)"], "d1_polyeq_simplify"));
646 autoCalculate 1 (Step 1); fetchProposedTactic 1;
647 setNextTactic 1 (Rewrite_Set "polyeq_simplify");
648 autoCalculate 1 (Step 1); fetchProposedTactic 1;
649 setNextTactic 1 Or_to_List;
650 autoCalculate 1 (Step 1); fetchProposedTactic 1;
651 setNextTactic 1 (Check_elementwise "Assumptions");
652 autoCalculate 1 (Step 1); fetchProposedTactic 1;
653 setNextTactic 1 (Check_Postcond ["degree_1","polynomial",
654 "univariate","equation"]);
655 autoCalculate 1 (Step 1); fetchProposedTactic 1;
656 setNextTactic 1 (Check_Postcond ["normalize","polynomial",
657 "univariate","equation"]);
658 autoCalculate 1 (Step 1); fetchProposedTactic 1;
659 setNextTactic 1 (Check_Postcond ["rational","univariate","equation"]);
660 val (ptp,_) = get_calc 1;
661 val (Form t,_,_) = pt_extract ptp;
662 if get_pos 1 1 = ([], Res) andalso term2str t = "[x = -4 / 3]" then ()
663 else writeln "FE-inteface.sml: diff.behav. in rat-eq + subpbl: no_met, NO ..";
666 "--------- tryMatchProblem, tryRefineProblem ------------";
667 "--------- tryMatchProblem, tryRefineProblem ------------";
668 "--------- tryMatchProblem, tryRefineProblem ------------";
669 (*{\bf\UC{Having \isac{} Refine the Problem
670 * Automatically}\label{SPECIFY:refine-auto}\\} test match and refine with
671 * x^^^2 + 4*x + 5 = 2
672 see isac.bridge.TestSpecify#testMatchRefine*)
674 [(["equality (x^2 + 4*x + 5 = (2::real))", "solveFor x","solutions L"],
676 ["univariate","equation"],
681 fetchProposedTactic 1;
682 setNextTactic 1 (Model_Problem );
683 (*..this tactic should be done 'tacitly', too !*)
686 autoCalculate 1 CompleteCalcHead;
687 checkContext 1 ([],Pbl) "pbl_equ_univ";
688 checkContext 1 ([],Pbl) (kestoreID2guh Pbl_ ["univariate","equation"]);
691 autoCalculate 1 (Step 1);
693 fetchProposedTactic 1;
694 setNextTactic 1 (Add_Given "equality (x ^^^ 2 + 4 * x + 5 = (2::real))");
695 autoCalculate 1 (Step 1);
697 "--------- we go into the ProblemBrowser (_NO_ pblID selected) -";
698 initContext 1 Pbl_ ([],Pbl);
699 (* this would break if a calculation would be inserted before: CALCID...
700 and pattern matching is not available in *.java.
701 if cut_xml xml = "(CONTEXTPBL)\n. (CALCID)\n. . 1\n. (/CALCID)\n. (CONTEXTDATA)\n. . (GUH)\n. . . pbl_equ_univ\n. . (/GUH)\n. . (STATUS)\n. . . correct\n. . (/STATUS)\n. . (HEAD)\n. . . (MATHML)\n. . . . (ISA)\n. . . . . solve (x ^ 2 + 4 * x + 5 = 2, x)\n. . . . (/ISA)\n. . . (/MATHML)\n. . (/HEAD)\n. . (MODEL)\n. . . (GIVEN)\n. . . . (ITEM status=correct)\n. . . . . (MATHML)\n. . . . . . (ISA)\n. . . . . . . equality (x ^ 2 + 4 * x + 5 = 2)\n. . . . . . (/ISA)\n. . . . . (/MATHML)\n. . . . (/ITEM)\n. . . . (ITEM status=correct)\n. . . . . (MATHML)\n. . . . . . (ISA)\n. . . . . . . solveFor x\n. . . . . . (/ISA)\n. . . . . (/MATHML)\n. . . . (/ITEM)\n. . . (/GIVEN)\n. . . (WHERE)\n. . . . (ITEM status=correct)\n. . . . . (MATHML)\n. . . . . . (ISA)\n. . . . . . . matches (?a = ?b) (x ^ 2 + 4 * x + 5 = 2)\n. . . . . . (/ISA)\n. . . . . (/MATHML)\n. . . . (/ITEM)\n. . . (/WHERE)\n. . . (FIND)\n. . . . (ITEM status=correct)\n. . . . . (MATHML)\n. . . . . . (ISA)\n. . . . . . . solutions L\n. . . . . . (/ISA)\n. . . . . (/MATHML)\n. . . . (/ITEM)\n. . . (/FI"
702 then () else error "--- tryMatchProblem, tryRefineProblem: initContext 1 Pbl_ ([],Pbl); CHANGED";
704 initContext 1 Met_ ([],Pbl);
705 (*<SYSERROR><CALCID>1</CALCID><ERROR>error in kernel 33</ERROR></SYSERROR>*)
707 "--------- this match will show some incomplete items: ---------";
709 checkContext 1 ([],Pbl) (kestoreID2guh Pbl_ ["univariate","equation"]);
710 checkContext 1 ([],Pbl) (kestoreID2guh Met_ ["LinEq", "solve_lineq_equation"]);
713 fetchProposedTactic 1;
714 setNextTactic 1 (Add_Given "solveFor x"); autoCalculate 1 (Step 1);
716 fetchProposedTactic 1;
717 setNextTactic 1 (Add_Find "solutions L"); autoCalculate 1 (Step 1);
719 "--------- this is a matching model (all items correct): -------";
720 checkContext 1 ([],Pbl) (kestoreID2guh Pbl_ ["univariate","equation"]);
721 "--------- this is a NOT matching model (some 'false': ---------";
722 checkContext 1 ([],Pbl)(kestoreID2guh Pbl_ ["LINEAR","univariate","equation"]);
724 "--------- find out a matching problem: ------------------------";
725 "--------- find out a matching problem (FAILING: no new pbl) ---";
726 refineProblem 1([],Pbl)(pblID2guh ["LINEAR","univariate","equation"]);
728 "--------- find out a matching problem (SUCCESSFUL) ------------";
729 refineProblem 1 ([],Pbl) (pblID2guh ["univariate","equation"]);
731 "--------- tryMatch, tryRefine did not change the calculation -";
732 "--------- this is done by <TRANSFER> on the pbl-browser: ------";
733 setNextTactic 1 (Specify_Problem ["normalize","polynomial",
734 "univariate","equation"]);
735 autoCalculate 1 (Step 1);
736 (*WN050904 fetchProposedTactic again --> Specify_Problem ["normalize",...
737 and Specify_Theory skipped in comparison to below ---^^^-inserted *)
738 (*------------vvv-inserted-----------------------------------------------*)
739 fetchProposedTactic 1;
740 setNextTactic 1 (Specify_Problem ["normalize","polynomial",
741 "univariate","equation"]);
742 autoCalculate 1 (Step 1);
744 (*and Specify_Theory skipped by fetchProposedTactic ?!?*)
746 fetchProposedTactic 1;
747 setNextTactic 1 (Specify_Method ["PolyEq","normalize_poly"]);
748 autoCalculate 1 (Step 1);
750 fetchProposedTactic 1;
751 setNextTactic 1 (Apply_Method ["PolyEq","normalize_poly"]);
753 autoCalculate 1 CompleteCalc;
755 val ((pt,_),_) = get_calc 1;
758 val (Form f, tac, asms) = pt_extract (pt, p);
759 if term2str f = "[x = -1, x = -3]" andalso p = ([], Res) then () else
760 error "FE-interface.sml: diff.behav. in tryMatchProblem, tryRefine";
762 (*------------^^^-inserted-----------------------------------------------*)
763 (*WN050904 the fetchProposedTactic's below may not have worked like that
764 before, too, because there was no check*)
765 fetchProposedTactic 1;
766 setNextTactic 1 (Specify_Theory "PolyEq");
767 autoCalculate 1 (Step 1);
769 fetchProposedTactic 1;
770 setNextTactic 1 (Specify_Method ["PolyEq","normalize_poly"]);
771 autoCalculate 1 (Step 1);
773 fetchProposedTactic 1;
774 "--------- now the calc-header is ready for enter 'solving' ----";
775 autoCalculate 1 CompleteCalc;
777 val ((pt,_),_) = get_calc 1;
781 val (Form f, tac, asms) = pt_extract (pt, p);
782 if term2str f = "[x = -1, x = -3]" andalso p = ([], Res) then () else
783 error "FE-interface.sml: diff.behav. in tryMatchProblem, tryRefine";
787 "--------- modifyCalcHead, resetCalcHead, modelProblem --";
788 "--------- modifyCalcHead, resetCalcHead, modelProblem --";
789 "--------- modifyCalcHead, resetCalcHead, modelProblem --";
790 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
791 ("Test", ["sqroot-test","univariate","equation","test"],
792 ["Test","squ-equ-test-subpbl1"]))];
796 modifyCalcHead 1 (([],Pbl),(*the position from refFormula*)
797 "solve (x+1=2, x)",(*the headline*)
798 [Given ["equality (x+1=(2::real))", "solveFor x"],
799 Find ["solutions L"](*,Relate []*)],
802 ["sqroot-test","univariate","equation","test"],
803 ["Test","squ-equ-test-subpbl1"]));
805 val ((Nd (PblObj {env = NONE,
807 loc = (SOME scrst_ctxt, NONE),
812 ["sqroot-test", "univariate", "equation", "test"],
813 ["Test", "squ-equ-test-subpbl1"]),
815 branch = TransitiveB,
822 (*WN110622: is the same as in 2002, but shouldn't be probl = [3 items?]*)
823 if length meth = 0 andalso length probl = 0 (*just some items tested*) then ()
824 else error "--- modifyCalcHead, resetCalcHead, modelProblem 1 --";
830 val ((Nd (PblObj {env = NONE,
832 loc = (SOME scrst_ctxt, NONE),
836 spec = ("e_domID", ["e_pblID"], ["e_metID"]),
838 branch = TransitiveB,
845 if length meth = 3 andalso length probl = 3 (*just some items tested*) then ()
846 else error "--- modifyCalcHead, resetCalcHead, modelProblem 2 --";
848 "--------- maximum-example, UC: Modeling an example -----";
849 "--------- maximum-example, UC: Modeling an example -----";
850 "--------- maximum-example, UC: Modeling an example -----";
851 (* {\bf\UC{Editing the Model}\label{SPECIFY:enter}\label{SPECIFY:check}\\}
852 see isac.bridge.TestModel#testEditItems
854 val elems = ["fixedValues [r=Arbfix]","maximum A","valuesFor [a,b]",
855 "relations [A=a*b, (a/2)^2 + (b/2)^2 = r^2]",
856 "relations [A=a*b, (a/2)^2 + (b/2)^2 = r^2]",
857 "relations [A=a*b, a/2=r*sin alpha, b/2=r*cos alpha]",
858 (*^^^ these are the elements for the root-problem (in variants)*)
859 (*vvv these are elements required for subproblems*)
860 "boundVariable a","boundVariable b","boundVariable alpha",
861 "interval {x::real. 0 <= x & x <= 2*r}",
862 "interval {x::real. 0 <= x & x <= 2*r}",
863 "interval {x::real. 0 <= x & x <= pi}",
864 "errorBound (eps=(0::real))"]
865 (*specifying is not interesting for this example*)
866 val spec = ("DiffApp", ["maximum_of","function"],
867 ["DiffApp","max_by_calculus"]);
868 (*the empty model with descriptions for user-guidance by Model_Problem*)
869 val empty_model = [Given ["fixedValues []"],
870 Find ["maximum", "valuesFor"],
871 Relate ["relations []"]];
874 "#################################################################";
876 CalcTree [(elems, spec)];
879 refFormula 1 (get_pos 1 1);
880 (*this gives a completely empty model*)
882 fetchProposedTactic 1;
883 (*fill the CalcHead with Descriptions...*)
884 setNextTactic 1 (Model_Problem );
885 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
887 (*user input is !!!!!EITHER!!!!! _some_ (at least one) items of the model
888 !!!!!OR!!!!! _one_ part of the specification !!!!!!!!!!!!!*)
889 (*input of two items, 'fixedValues [r=Arbfix]' and 'maximum b'...*)
890 modifyCalcHead 1 (([],Pbl) (*position, from previous refFormula*),
891 "Problem (DiffApp.thy, [maximum_of, function])",
892 (*the head-form ^^^ is not used for input here*)
893 [Given ["fixedValues [r=Arbfix]"(*new input*)],
894 Find ["maximum b"(*new input*), "valuesFor"],
895 Relate ["relations"]],
896 (*input (Arbfix will dissappear soon)*)
898 e_spec (*no input to the specification*));
900 (*the user does not know, what 'superfluous' for 'maximum b' may mean
901 and asks what to do next*)
902 fetchProposedTactic 1;
903 (*the student follows the advice*)
904 setNextTactic 1 (Add_Find "maximum A"); (*FIXME.17.11.03: does not yet work*)
905 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
907 (*this input completes the model*)
908 modifyCalcHead 1 (([],Pbl), "not used here",
909 [Given ["fixedValues [r=Arbfix]"],
910 Find ["maximum A", "valuesFor [a,b]"(*new input*)],
911 Relate ["relations [A=a*b, \
912 \(a/2)^2 + (b/2)^2 = r^2]"]], Pbl, e_spec);
914 (*specification is not interesting and should be skipped by the dialogguide;
915 !!!!!!!!!!!!!!!!!!!! input of ONE part at a time !!!!!!!!!!!!!!!!!!!!!!*)
916 modifyCalcHead 1 (([],Pbl), "not used here",
917 [Given ["fixedValues [r=Arbfix]"],
918 Find ["maximum A", "valuesFor [a,b]"(*new input*)],
919 Relate ["relations [A=a*b, \
920 \(a/2)^2 + (b/2)^2 = r^2]"]], Pbl,
921 ("DiffApp", ["e_pblID"], ["e_metID"]));
922 modifyCalcHead 1 (([],Pbl), "not used here",
923 [Given ["fixedValues [r=Arbfix]"],
924 Find ["maximum A", "valuesFor [a,b]"(*new input*)],
925 Relate ["relations [A=a*b, \
926 \(a/2)^2 + (b/2)^2 = r^2]"]], Pbl,
927 ("DiffApp", ["maximum_of","function"],
929 modifyCalcHead 1 (([],Pbl), "not used here",
930 [Given ["fixedValues [r=Arbfix]"],
931 Find ["maximum A", "valuesFor [a,b]"(*new input*)],
932 Relate ["relations [A=a*b, \
933 \(a/2)^2 + (b/2)^2 = r^2]"]], Pbl,
934 ("DiffApp", ["maximum_of","function"],
935 ["DiffApp","max_by_calculus"]));
936 (*this final calcHead now has STATUS 'complete' !*)
939 "--------- solve_linear from pbl-hierarchy --------------";
940 "--------- solve_linear from pbl-hierarchy --------------";
941 "--------- solve_linear from pbl-hierarchy --------------";
942 val (fmz, sp) = ([], ("", ["LINEAR","univariate","equation","test"], []));
943 CalcTree [(fmz, sp)];
944 Iterator 1; moveActiveRoot 1;
945 refFormula 1 (get_pos 1 1);
946 modifyCalcHead 1 (([],Pbl),"solve (1+-1*2+x=(0::real))",
947 [Given ["equality (1+-1*2+x=(0::real))", "solveFor x"],
948 Find ["solutions L"]],
950 ("Test", ["LINEAR","univariate","equation","test"],
951 ["Test","solve_linear"]));
952 autoCalculate 1 CompleteCalc;
953 refFormula 1 (get_pos 1 1);
954 val ((pt,_),_) = get_calc 1;
956 val (Form f, tac, asms) = pt_extract (pt, p);
957 if term2str f = "[x = 1]" andalso p = ([], Res)
958 andalso terms2str asms = "[\"matches (?a = ?b) (1 + -1 * 2 + x = 0)\"]" then ()
959 else error "FE-interface.sml: diff.behav. in from pbl -hierarchy";
962 "--------- solve_linear as in an algebra system (CAS)----";
963 "--------- solve_linear as in an algebra system (CAS)----";
964 "--------- solve_linear as in an algebra system (CAS)----";
965 (*WN120210?not ME:\label{UC:cas-input} UC 30.1.2.5 p.168*)
966 val (fmz, sp) = ([], ("", [], []));
967 CalcTree [(fmz, sp)];
968 Iterator 1; moveActiveRoot 1;
969 modifyCalcHead 1 (([],Pbl),"solveTest (1+-1*2+x=0,x)", [], Pbl, ("", [], []));
970 autoCalculate 1 CompleteCalc;
971 refFormula 1 (get_pos 1 1);
972 val ((pt,_),_) = get_calc 1;
974 val (Form f, tac, asms) = pt_extract (pt, p);
975 if term2str f = "[x = 1]" andalso p = ([], Res)
976 andalso terms2str asms = "[\"matches (?a = ?b) (1 + -1 * 2 + x = 0)\"]" then ()
977 else error "FE-interface.sml: diff.behav. in from pbl -hierarchy";
980 "--------- interSteps: on 'miniscript with mini-subpbl' -";
981 "--------- interSteps: on 'miniscript with mini-subpbl' -";
982 "--------- interSteps: on 'miniscript with mini-subpbl' -";
983 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
984 ("Test", ["sqroot-test","univariate","equation","test"],
985 ["Test","squ-equ-test-subpbl1"]))];
988 autoCalculate 1 CompleteCalc;
989 val ((pt,_),_) = get_calc 1;
992 (*UC\label{UC:inter-steps} UC 30.3.5.5 p.178*)
993 interSteps 1 ([2],Res);
994 val ((pt,_),_) = get_calc 1; show_pt pt (*new ([2,1],Frm)..([2,6],Res)*);
995 val (unc, del, gen) = (([1],Res),([1],Res),([2,6],Res));
996 getFormulaeFromTo 1 unc gen 1 false;
998 (*UC\label{UC:inter-steps} UC 30.3.5.5 p.178*)
999 interSteps 1 ([3,2],Res);
1000 val ((pt,_),_) = get_calc 1; show_pt pt (*new ([3,2,1],Frm)..([3,2,2],Res)*);
1001 val (unc, del, gen) = (([3,1],Res),([3,1],Res),([3,2,2],Res));
1002 getFormulaeFromTo 1 unc gen 1 false;
1004 (*UC\label{UC:inter-steps} UC 30.3.5.5 p.178*)
1005 interSteps 1 ([3],Res) (*no new steps in subproblems*);
1006 val (unc, del, gen) = (([3],Pbl),([3],Pbl),([3,2],Res));
1007 getFormulaeFromTo 1 unc gen 1 false;
1009 (*UC\label{UC:inter-steps} UC 30.3.5.5 p.178*)
1010 interSteps 1 ([],Res) (*no new steps in subproblems*);
1011 val (unc, del, gen) = (([],Pbl),([],Pbl),([4],Res));
1012 getFormulaeFromTo 1 unc gen 1 false;
1015 "--------- getTactic, fetchApplicableTactics ------------";
1016 "--------- getTactic, fetchApplicableTactics ------------";
1017 "--------- getTactic, fetchApplicableTactics ------------";
1018 (* compare test/../script.sml
1019 "----------- fun sel_rules ---------------------------------------";
1021 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
1022 ("Test", ["sqroot-test","univariate","equation","test"],
1023 ["Test","squ-equ-test-subpbl1"]))];
1024 Iterator 1; moveActiveRoot 1;
1025 autoCalculate 1 CompleteCalc;
1026 val ((pt,_),_) = get_calc 1;
1029 (*UC\label{SOLVE:HIDE:getTactic} \label{SOLVE:AUTO:tactic} UC 30.3.3.1 p.176
1030 WN120210 not impl. in FE*)
1031 getTactic 1 ([],Pbl);
1032 getTactic 1 ([1],Res);
1033 getTactic 1 ([3],Pbl);
1034 getTactic 1 ([3,1],Frm);
1035 getTactic 1 ([3],Res);
1036 getTactic 1 ([],Res);
1038 (*UC\label{SOLVE:MANUAL:TACTIC:listall} UC 30.3.2.2 p.175*)
1039 fetchApplicableTactics 1 99999 ([],Pbl);
1040 fetchApplicableTactics 1 99999 ([1],Res);
1041 fetchApplicableTactics 1 99999 ([3],Pbl);
1042 fetchApplicableTactics 1 99999 ([3,1],Res);
1043 fetchApplicableTactics 1 99999 ([3],Res);
1044 fetchApplicableTactics 1 99999 ([],Res);
1047 "--------- getAssumptions, getAccumulatedAsms -----------";
1048 "--------- getAssumptions, getAccumulatedAsms -----------";
1049 "--------- getAssumptions, getAccumulatedAsms -----------";
1051 [(["equality (x/(x^2 - 6*x+9) - 1/(x^2 - 3*x) =1/x)",
1052 "solveFor x","solutions L"],
1053 ("RatEq",["univariate","equation"],["no_met"]))];
1054 Iterator 1; moveActiveRoot 1;
1055 autoCalculate 1 CompleteCalc;
1056 val ((pt,_),_) = get_calc 1;
1057 val p = get_pos 1 1;
1058 val (Form f, tac, asms) = pt_extract (pt, p);
1059 (*============ inhibit exn WN120316 compare 2002--2011 ===========================
1060 if map term2str asms =
1061 ["True |\n~ lhs ((3 + -1 * x + x ^^^ 2) * x =\n" ^
1062 " 1 * (9 * x + -6 * x ^^^ 2 + x ^^^ 3)) is_poly_in x", "-6 * x + 5 * x ^^^ 2 = 0",
1063 "lhs (-6 * x + 5 * x ^^^ 2 = 0) is_poly_in x",
1064 "lhs (-6 * x + 5 * x ^^^ 2 = 0) has_degree_in x = 2",
1065 "9 * x + -6 * x ^^^ 2 + x ^^^ 3 ~= 0"]
1066 andalso term2str f = "[-6 * x + 5 * x ^^^ 2 = 0]" andalso p = ([], Res) then ()
1067 else error "TODO compare 2002--2011"; (*...data during test --- x / (x ^ 2 - 6 * x + 9) - 1...*)
1068 ============ inhibit exn WN120316 compare 2002--2011 ===========================*)
1069 if p = ([], Res) andalso term2str f = "[]" (*see WN120317.TODO dropped rateq*)
1070 andalso asms = [] (*STRANGE!, compare test --- x / (x ^ 2 - 6 * x + 9) - 1 / (x ^ 2 ...*)
1071 then () else error "rlang.sml: diff.behav. in Schalk I s.87 Bsp 55b [x = 6 / 5]";
1073 (*UC\label{SOLVE:HELP:assumptions} UC 30.3.5.1 p.178*)
1074 getAssumptions 1 ([3], Res);
1075 getAssumptions 1 ([5], Res);
1076 (*UC\label{SOLVE:HELP:assumptions-origin} UC 30.3.5.2 p.178
1077 WN0502 still without positions*)
1078 getAccumulatedAsms 1 ([3], Res);
1079 getAccumulatedAsms 1 ([5], Res);
1082 "--------- arbitrary combinations of steps --------------";
1083 "--------- arbitrary combinations of steps --------------";
1084 "--------- arbitrary combinations of steps --------------";
1085 CalcTree (*start of calculation, return No.1*)
1086 [(["equality (1+-1*2+x=(0::real))", "solveFor x","solutions L"],
1088 ["LINEAR","univariate","equation","test"],
1089 ["Test","solve_linear"]))];
1090 Iterator 1; moveActiveRoot 1;
1092 fetchProposedTactic 1;
1093 (*ERROR get_calc 1 not existent*)
1094 setNextTactic 1 (Model_Problem );
1095 autoCalculate 1 (Step 1);
1096 fetchProposedTactic 1;
1097 fetchProposedTactic 1;
1099 setNextTactic 1 (Add_Find "solutions L");
1100 setNextTactic 1 (Add_Find "solutions L");
1102 autoCalculate 1 (Step 1);
1103 autoCalculate 1 (Step 1);
1105 setNextTactic 1 (Specify_Theory "Test");
1106 fetchProposedTactic 1;
1107 autoCalculate 1 (Step 1);
1109 autoCalculate 1 (Step 1);
1110 autoCalculate 1 (Step 1);
1111 autoCalculate 1 (Step 1);
1112 autoCalculate 1 (Step 1);
1113 (*------------------------- end calc-head*)
1115 fetchProposedTactic 1;
1116 setNextTactic 1 (Rewrite_Set_Inst (["(bdv,x)"], "isolate_bdv"));
1117 autoCalculate 1 (Step 1);
1119 setNextTactic 1 (Rewrite_Set "Test_simplify");
1120 fetchProposedTactic 1;
1121 autoCalculate 1 (Step 1);
1123 autoCalculate 1 CompleteCalc;
1124 val ((pt,_),_) = get_calc 1;
1125 val p = get_pos 1 1;
1126 val (Form f, tac, asms) = pt_extract (pt, p);
1127 if term2str f = "[x = 1]" andalso p = ([], Res) then () else
1128 error "FE-interface.sml: diff.behav. in combinations of steps";
1131 "--------- appendF label{SOLVE:MANUAL:FORMULA:enter}right"; (*UC 30.3.2.4 p.175*)
1132 "--------- appendF label{SOLVE:MANUAL:FORMULA:enter}right";
1133 "--------- appendF label{SOLVE:MANUAL:FORMULA:enter}right";
1134 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
1135 ("Test", ["sqroot-test","univariate","equation","test"],
1136 ["Test","squ-equ-test-subpbl1"]))];
1139 autoCalculate 1 CompleteCalcHead;
1140 autoCalculate 1 (Step 1);
1141 autoCalculate 1 (Step 1);
1142 appendFormula 1 "-1 + x = 0" (*|> Future.join*);
1143 (*... returns calcChangedEvent with*)
1144 val (unc, del, gen) = (([1],Res), ([1],Res), ([2],Res));
1145 getFormulaeFromTo 1 unc gen 99999 (*all levels*) false;
1147 val ((pt,_),_) = get_calc 1;
1148 val p = get_pos 1 1;
1149 val (Form f, tac, asms) = pt_extract (pt, p);
1150 if term2str f = "-1 + x = 0" andalso p = ([2], Res) then () else
1151 error "FE-interface.sml: diff.behav. in FORMULA:enter} right";
1154 "--------- appendF label{SOLVE:MANUAL:FORMULA:enter}other"; (*UC 30.3.2.4 p.175*)
1155 "--------- appendF label{SOLVE:MANUAL:FORMULA:enter}other";
1156 "--------- appendF label{SOLVE:MANUAL:FORMULA:enter}other";
1157 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
1158 ("Test", ["sqroot-test","univariate","equation","test"],
1159 ["Test","squ-equ-test-subpbl1"]))];
1162 autoCalculate 1 CompleteCalcHead;
1163 autoCalculate 1 (Step 1);
1164 autoCalculate 1 (Step 1);
1165 appendFormula 1 "x - 1 = 0" (*|> Future.join*);
1166 val (unc, del, gen) = (([1],Res), ([1],Res), ([2],Res));
1167 getFormulaeFromTo 1 unc gen 99999 (*all levels*) false;
1170 val ((pt,_),_) = get_calc 1;
1171 val p = get_pos 1 1;
1172 val (Form f, tac, asms) = pt_extract (pt, p);
1173 if term2str f = "x - 1 = 0" andalso p = ([2], Res) then () else
1174 error "FE-interface.sml: diff.behav. in FORMULA:enter} other";
1177 "--------- appendF label{SOLVE:MANUAL:FORMULA:enter}oth 2"; (*UC 30.3.2.4 p.175*)
1178 "--------- appendF label{SOLVE:MANUAL:FORMULA:enter}oth 2";
1179 "--------- appendF label{SOLVE:MANUAL:FORMULA:enter}oth 2";
1180 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
1181 ("Test", ["sqroot-test","univariate","equation","test"],
1182 ["Test","squ-equ-test-subpbl1"]))];
1185 autoCalculate 1 CompleteCalcHead;
1186 autoCalculate 1 (Step 1);
1187 autoCalculate 1 (Step 1);
1188 appendFormula 1 "x = 1" (*|> Future.join*);
1189 (*... returns calcChangedEvent with*)
1190 val (unc, del, gen) = (([1],Res), ([1],Res), ([3,2],Res));
1191 getFormulaeFromTo 1 unc gen 99999 (*all levels*) false;
1194 val ((pt,_),_) = get_calc 1;
1195 val p = get_pos 1 1;
1196 val (Form f, tac, asms) = pt_extract (pt, p);
1197 if term2str f = "x = 1" andalso p = ([3,2], Res) then () else
1198 error "FE-interface.sml: diff.behav. in FORMULA:enter} oth 2";
1201 "--------- appendF label{SOLVE:MANUAL:FORMULA:enter}NOTok"; (*UC 30.3.2.4 p.175*)
1202 "--------- appendF label{SOLVE:MANUAL:FORMULA:enter}NOTok";
1203 "--------- appendF label{SOLVE:MANUAL:FORMULA:enter}NOTok";
1204 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
1205 ("Test", ["sqroot-test","univariate","equation","test"],
1206 ["Test","squ-equ-test-subpbl1"]))];
1209 autoCalculate 1 CompleteCalcHead;
1210 autoCalculate 1 (Step 1);
1211 autoCalculate 1 (Step 1);
1212 appendFormula 1 "x - 4711 = 0" (*|> Future.join*);
1213 (*... returns <ERROR> no derivation found </ERROR>*)
1215 val ((pt,_),_) = get_calc 1;
1216 val p = get_pos 1 1;
1217 val (Form f, tac, asms) = pt_extract (pt, p);
1218 if term2str f = "x + 1 + -1 * 2 = 0" andalso p = ([1], Res) then () else
1219 error "FE-interface.sml: diff.behav. in FORMULA:enter} NOTok";
1222 "--------- replaceFormula {SOL:MAN:FOR:replace} right----"; (*UC 30.3.2.5 p.176*)
1223 "--------- replaceFormula {SOL:MAN:FOR:replace} right----";
1224 "--------- replaceFormula {SOL:MAN:FOR:replace} right----";
1225 (*\label{SOLVE:MANUAL:FORMULA:replace}*)
1226 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
1227 ("Test", ["sqroot-test","univariate","equation","test"],
1228 ["Test","squ-equ-test-subpbl1"]))];
1231 autoCalculate 1 CompleteCalc;
1232 moveActiveFormula 1 ([2],Res);
1233 replaceFormula 1 "-1 + x = 0" (*i.e. repeats input*);
1234 (*... returns <ERROR> formula not changed </ERROR>*)
1236 val ((pt,_),_) = get_calc 1;
1237 val p = get_pos 1 1;
1238 val (Form f, tac, asms) = pt_extract (pt, p);
1239 if term2str f = "-1 + x = 0" andalso p = ([2], Res) then () else
1240 error "FE-interface.sml: diff.behav. in FORMULA:replace} right 1";
1241 if map fst (get_interval ([2],Res) ([],Res) 9999 pt) =
1242 [([2], Res), ([3], Pbl), ([3, 1], Frm), ([3, 1], Res), ([3, 2], Res),
1243 ([3], Res), ([4], Res), ([], Res)] then () (*nothing deleted!*) else
1244 error "FE-interface.sml: diff.behav. in FORMULA:replace} right 2";
1246 (*WN050211 replaceFormula didn't work on second ctree: thus now tested...*)
1247 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
1248 ("Test", ["sqroot-test","univariate","equation","test"],
1249 ["Test","squ-equ-test-subpbl1"]))];
1252 autoCalculate 2 CompleteCalc;
1253 moveActiveFormula 2 ([2],Res);
1254 replaceFormula 2 "-1 + x = 0" (*i.e. repeats input*);
1255 (*... returns <ERROR> formula not changed </ERROR>*)
1257 val ((pt,_),_) = get_calc 2;
1258 val p = get_pos 2 1;
1259 val (Form f, tac, asms) = pt_extract (pt, p);
1260 if term2str f = "-1 + x = 0" andalso p = ([2], Res) then () else
1261 error "FE-interface.sml: diff.behav. in FORMULA:replace} right 1";
1262 if map fst (get_interval ([2],Res) ([],Res) 9999 pt) =
1263 [([2], Res), ([3], Pbl), ([3, 1], Frm), ([3, 1], Res), ([3, 2], Res),
1264 ([3], Res), ([4], Res), ([], Res)] then () (*nothing deleted!*) else
1265 error "FE-interface.sml: diff.behav. in FORMULA:replace} right 2b";
1268 "--------- replaceFormula {SOL:MAN:FOR:replace} other----"; (*UC 30.3.2.5 p.176*)
1269 "--------- replaceFormula {SOL:MAN:FOR:replace} other----";
1270 "--------- replaceFormula {SOL:MAN:FOR:replace} other----";
1271 (*\label{SOLVE:MANUAL:FORMULA:replace}*)
1272 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
1273 ("Test", ["sqroot-test","univariate","equation","test"],
1274 ["Test","squ-equ-test-subpbl1"]))];
1277 autoCalculate 1 CompleteCalc;
1278 moveActiveFormula 1 ([2],Res); (*there is "-1 + x = 0"*)
1279 replaceFormula 1 "x - 1 = 0"; (*<-------------------------------------*)
1280 (*... returns calcChangedEvent with*)
1281 val (unc, del, gen) = (([1],Res), ([4],Res), ([2],Res));
1282 getFormulaeFromTo 1 unc gen 99999 (*all levels*) false;
1284 val ((pt,_),_) = get_calc 1;
1286 val p = get_pos 1 1;
1287 val (Form f, tac, asms) = pt_extract (pt, p);
1288 if term2str f = "x - 1 = 0" andalso p = ([2], Res) then () else
1289 error "FE-interface.sml: diff.behav. in FORMULA:replace} other 1";
1290 (* for getting the list in whole length ...
1291 default_print_depth 99;map fst (get_interval ([1],Res) ([],Res) 9999 pt);default_print_depth 3;
1293 if map fst (get_interval ([1],Res) ([],Res) 9999 pt) =
1294 [([1], Res), ([2, 1], Frm), ([2, 1], Res), ([2, 2], Res), ([2, 3], Res),
1295 ([2, 4], Res), ([2, 5], Res), ([2, 6], Res), ([2, 7], Res),
1296 ([2, 8], Res), ([2, 9], Res), ([2], Res)
1297 (*WN060727 {cutlevup->test_trans} removed: ,
1298 ([], Res)(*dropped, if test_trans doesnt stop at PblNd*)*)] then () else
1299 error "FE-interface.sml: diff.behav. in FORMULA:replace} other 2";
1302 "--------- replaceFormula {SOL:MAN:FOR:replace} other 2--"; (*UC 30.3.2.5 p.176*)
1303 "--------- replaceFormula {SOL:MAN:FOR:replace} other 2--";
1304 "--------- replaceFormula {SOL:MAN:FOR:replace} other 2--";
1305 (*\label{SOLVE:MANUAL:FORMULA:replace}*)
1306 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
1307 ("Test", ["sqroot-test","univariate","equation","test"],
1308 ["Test","squ-equ-test-subpbl1"]))];
1311 autoCalculate 1 CompleteCalc;
1312 moveActiveFormula 1 ([2],Res); (*there is "-1 + x = 0"*)
1313 replaceFormula 1 "x = 1"; (*<-------------------------------------*)
1314 (*... returns calcChangedEvent with ...*)
1315 val (unc, del, gen) = (([1],Res), ([4],Res), ([3,2],Res));
1316 getFormulaeFromTo 1 unc gen 99999 (*all levels*) false;
1319 val ((pt,_),_) = get_calc 1;
1320 show_pt pt; (*error: ...get_interval drops ([3,2],Res) ...*)
1321 val (t,_) = get_obj g_result pt [3,2]; term2str t;
1322 if map fst (get_interval ([1],Res) ([],Res) 9999 pt) =
1323 [([1], Res), ([2], Res), ([3], Pbl), ([3, 1], Frm), ([3, 1], Res),
1324 ([3, 2, 1], Frm), ([3, 2, 1], Res), ([3, 2, 2], Res),
1325 ([3,2],Res)] then () else
1326 error "FE-interface.sml: diff.behav. in FORMULA:replace} oth2 1";
1328 val p = get_pos 1 1;
1329 val (Form f, tac, asms) = pt_extract (pt, p);
1330 if term2str f = "x = 1" andalso p = ([3,2], Res) then () else
1331 error "FE-interface.sml: diff.behav. in FORMULA:replace} oth2 2";
1334 "--------- replaceFormula {SOL:MAN:FOR:replace} NOTok----"; (*UC 30.3.2.5 p.176*)
1335 "--------- replaceFormula {SOL:MAN:FOR:replace} NOTok----";
1336 "--------- replaceFormula {SOL:MAN:FOR:replace} NOTok----";
1337 (*\label{SOLVE:MANUAL:FORMULA:replace}*)
1338 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
1339 ("Test", ["sqroot-test","univariate","equation","test"],
1340 ["Test","squ-equ-test-subpbl1"]))];
1343 autoCalculate 1 CompleteCalc;
1344 moveActiveFormula 1 ([2],Res); (*there is "-1 + x = 0"*)
1345 replaceFormula 1 "x - 4711 = 0";
1346 (*... returns <ERROR> no derivation found </ERROR>*)
1348 val ((pt,_),_) = get_calc 1;
1350 val p = get_pos 1 1;
1351 val (Form f, tac, asms) = pt_extract (pt, p);
1352 if term2str f = "-1 + x = 0" andalso p = ([2], Res) then () else
1353 error "FE-interface.sml: diff.behav. in FORMULA:replace} NOTok";
1356 "--------- UC errpat chain-rule-diff-both, fillpat by input ------";
1357 "--------- UC errpat chain-rule-diff-both, fillpat by input ------";
1358 "--------- UC errpat chain-rule-diff-both, fillpat by input ------";
1361 [(["functionTerm (x ^ 2 + sin (x ^ 4))", "differentiateFor x", "derivative f_f'"],
1362 ("Isac", ["derivative_of","function"], ["diff","differentiate_on_R"]))];
1365 autoCalculate 1 CompleteCalcHead;
1366 autoCalculate 1 (Step 1);
1367 autoCalculate 1 (Step 1);(*([1], Res), d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))*)
1368 appendFormula 1 "d_d x (x ^ 2) + cos (4 * x ^ 3)" (*|> Future.join*); (*<<<<<<<=========================*)
1369 (* the check for errpat is maximally liberal (whole term modulo "nrls" from "type met"),
1370 would recognize "cos (4 * x ^ (4 - 1)) + 2 * x" as well.
1371 results in <CALCMESSAGE> error pattern #chain-rule-diff-both# </CALCMESSAGE>
1372 instead of <CALCMESSAGE> no derivation found </CALCMESSAGE> *)
1373 val ((pt,pos), _) = get_calc 1;
1374 val p = get_pos 1 1;
1375 val (Form f, _, asms) = pt_extract (pt, p);
1377 if p = ([1], Res) andalso term2str f = "d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))" andalso
1378 get_obj g_tac pt (fst p) = Rewrite_Inst (["(bdv, x)"],
1379 ("diff_sum", "d_d ?bdv (?u + ?v) = d_d ?bdv ?u + d_d ?bdv ?v"))
1380 then () else error "embed fun get_fillform changed 1";
1382 (*========== inhibit exn WN1130621 Isabelle2012-->13 !thehier! ====================
1383 findFillpatterns 1 "chain-rule-diff-both"; (*<<<<<<<=================================*)
1384 (*<CALCMESSAGE> fill patterns #fill-d_d-arg#d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4)) =
1385 d_d x (x ^^^ 2) + cos (x ^^^ 4) * d_d x ?_dummy_1#fill-both-args#...#...#... *)
1386 val ((pt,pos),_) = get_calc 1;
1387 val p = get_pos 1 1;
1389 val (Form f, _, asms) = pt_extract (pt, p);
1390 if p = ([1], Res) andalso term2str f = "d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))" andalso
1391 get_obj g_tac pt (fst p) = Rewrite_Inst (["(bdv, x)"], ("diff_sum", "Diff.diff_sum"(*?!?*)))
1393 else error "embed fun get_fillform changed 2";
1395 (* if we assume, that the fill-patterns are ordered such that the 1st has large gaps
1396 and the last has no gaps, then the number of fill-patterns would suffice
1397 for the DialogGuide to select appropriately. *)
1398 requestFillformula 1 ("chain-rule-diff-both", "fill-both-args");(*<<<<<<<============*)
1399 (*<AUTOCALC> ([1], Res) ([2], Res) ([2], Res) </AUTOCALC>*)
1400 val ((pt,pos),_) = get_calc 1;
1401 val p = get_pos 1 1;
1402 val (Form f, _, asms) = pt_extract (pt, p);
1403 if p = ([1], Res) andalso existpt [2] pt andalso
1404 term2str f = "d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))" andalso
1405 get_obj g_tac pt (fst p) = Rewrite_Inst (["(bdv, x)"], ("diff_sum", "Diff.diff_sum"))
1406 then () else error "embed fun get_fillform changed 3";
1408 inputFillFormula 1 "d_d x (x ^^^ 2) + cos (x ^^^ 4) * d_d x (x ^^^ 4)";(*<<<<<<<=====*)
1409 val ((pt, _),_) = get_calc 1;
1410 val p = get_pos 1 1;
1411 val (Form f, _, asms) = pt_extract (pt, p);
1412 if p = ([2], Res) andalso
1413 term2str f = "d_d x (x ^^^ 2) + cos (x ^^^ 4) * d_d x (x ^^^ 4)" andalso
1414 get_obj g_tac pt (fst p) = Rewrite_Inst (["(bdv, x)"], ("diff_sin_chain", ""))
1415 then () else error "inputFillFormula changed 11";
1417 autoCalculate 1 CompleteCalc;
1419 "~~~~~ final check: the input formula is inserted as it would have been correct from beginning";
1420 val ((pt, _),_) = get_calc 1;
1421 val p = get_pos 1 1;
1422 val (Form f, _, asms) = pt_extract (pt, p);
1423 if p = ([], Res) andalso term2str f = "2 * x + cos (x ^^^ 4) * 4 * x ^^^ 3"
1424 then () else error "inputFillFormula changed 12";
1427 (([], Frm), Diff (x ^^^ 2 + sin (x ^^^ 4), x)),
1428 (([1], Frm), d_d x (x ^^^ 2 + sin (x ^^^ 4))),
1429 (([1], Res), d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))),
1430 (([2], Res), d_d x (x ^^^ 2) + cos (x ^^^ 4) * d_d x (x ^^^ 4)), (*<<<<<<<=====*)
1431 (([3], Res), d_d x (x ^^^ 2) + cos (x ^^^ 4) * (4 * x ^^^ (4 - 1))),
1432 (([4], Res), 2 * x ^^^ (2 - 1) + cos (x ^^^ 4) * (4 * x ^^^ (4 - 1))),
1433 (([5], Res), 2 * x + cos (x ^^^ 4) * 4 * x ^^^ 3),
1434 (([], Res), 2 * x + cos (x ^^^ 4) * 4 * x ^^^ 3)] *)
1435 ============ inhibit exn WN1130621 Isabelle2012-->13 !thehier! ==================*)
1437 "--------- UC errpat add-fraction, fillpat by input --------------";
1438 "--------- UC errpat add-fraction, fillpat by input --------------";
1439 "--------- UC errpat add-fraction, fillpat by input --------------";
1440 (*cp from BridgeLog Java <=> SML*)
1442 CalcTree [([], ("e_domID", ["e_pblID"], ["e_metID"]))];
1445 moveActiveFormula 1 ([],Pbl);
1446 replaceFormula 1 "Simplify (5 * x / (4 * y) + 3 * x / (4 * y))";
1447 autoCalculate 1 CompleteCalcHead;
1448 autoCalculate 1 (Step 1);
1449 appendFormula 1 "8 * x / (8 * y)" (*|> Future.join*);
1450 (*<CALCMESSAGE> no derivation found </CALCMESSAGE>
1451 --- but in BridgeLog Java <=> SML:
1452 <CALCMESSAGE> error pattern #addition-of-fractions# </CALCMESSAGE>*)
1454 "--------- UC errpat, fillpat step to Rewrite --------------------";
1455 "--------- UC errpat, fillpat step to Rewrite --------------------";
1456 "--------- UC errpat, fillpat step to Rewrite --------------------";
1460 [(["functionTerm ((x ^ 2) ^ 3 + sin (x ^ 4))",
1461 "differentiateFor x", "derivative f_f'"],
1462 ("Isac", ["derivative_of","function"],
1463 ["diff","differentiate_on_R"]))]; (*<<<======= EP is directly in script*)
1466 autoCalculate 1 CompleteCalc;
1467 val ((pt,p),_) = get_calc 1; show_pt pt;
1469 "--------- UC errpat, fillpat step to Rewrite_Set ----------------";
1470 "--------- UC errpat, fillpat step to Rewrite_Set ----------------";
1471 "--------- UC errpat, fillpat step to Rewrite_Set ----------------";
1474 [(["functionTerm ((x ^ 2) ^ 3 + sin (x ^ 4))",
1475 "differentiateFor x", "derivative f_f'"],
1476 ("Isac", ["derivative_of","function"],
1477 ["diff","after_simplification"]))]; (*<<<======= EP is in a ruleset*)
1480 autoCalculate 1 CompleteCalcHead;
1481 autoCalculate 1 (Step 1); fetchProposedTactic 1;
1482 autoCalculate 1 (Step 1); fetchProposedTactic 1;
1485 <CALCID> 1 </CALCID>
1486 <TACTICERRORPATTERNS>
1488 <STRING> chain-rule-diff-both </STRING>
1489 <STRING> cancel </STRING>
1491 <REWRITESETINSTTACTIC name="Rewrite_Set_Inst">
1492 <RULESET> norm_diff </RULESET>
1507 </REWRITESETINSTTACTIC>
1508 </TACTICERRORPATTERNS>
1512 (*WN1208 postponed due to efforts required for stepToErrorPatterns (NEW rewrite_set_)*)
1513 stepToErrorPatterns 1; (*--> calcChanged, rule immediately calls... *)
1514 stepOnErrorPatterns 1; (*--> calcChanged, rule calls getTactic and displays it *)
1515 (* then --- UC errpat, fillpat by input ---*)
1517 autoCalculate 1 CompleteCalc;
1518 val ((pt,p),_) = get_calc 1; show_pt pt;
1519 (*WN1208 postponed due to efforts required for stepToErrorPatterns (NEW rewrite_set_)*)