reorganise struct. ThmC, part 1
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 Isac.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 Steps 1 ------------";
31 "--------- solve_linear as rootpbl AUTO CompleteCalc ----";
32 "--------- solve_linear as rootpbl AUTO CompleteHead/Num_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 - WITH fun me IN test/../solve.sml";
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 -------------------";
102 CalcTree (*start of calculation, return No.1*)
103 [(["equality (1+-1*2+x=(0::real))", "solveFor x","solutions L"],
105 ["LINEAR","univariate","equation","test"],
106 ["Test","solve_linear"]))];
107 Iterator 1; (*create an active Iterator on CalcTree No.1*)
109 moveActiveRoot 1;(*sets the CalcIterator No.1 at the root of CalcTree No.1*);
110 refFormula 1 (get_pos 1 1) (*gets CalcHead; model is still empty*);
113 (*1*) fetchProposedTactic 1 (*by using Iterator No.1*);
114 setNextTactic 1 (Model_Problem); (*by using Iterator No.1*)
115 autoCalculate 1 (Steps 1);
116 refFormula 1 (get_pos 1 1) (*model contains descriptions for all items*);
117 autoCalculate 1 (Steps 1);
118 (*-----since Model_Problem + complete_mod_ in case cas of SOME-----*
119 (*2*) fetchProposedTactic 1;
120 setNextTactic 1 (Add_Given "equality (1 + -1 * 2 + x = 0)");
121 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1); (*equality added*);
123 (*3*) fetchProposedTactic 1;
124 setNextTactic 1 (Add_Given "solveFor x");
125 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
127 (*4*) fetchProposedTactic 1;
128 setNextTactic 1 (Add_Find "solutions L");
129 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
131 (*5*) fetchProposedTactic 1;
132 setNextTactic 1 (Specify_Theory "Test");
133 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
134 *-----since Model_Problem + complete_mod_ in case cas of SOME-----*)
136 (*6*) fetchProposedTactic 1;
137 setNextTactic 1 (Specify_Problem ["LINEAR","univariate","equation","test"]);
138 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
139 (*-------------------------------------------------------------------------*)
140 (*7*) fetchProposedTactic 1;
141 val (ptp as (pt,p), tacis) = get_calc 1; get_pos 1 1;
143 setNextTactic 1 (Specify_Method ["Test","solve_linear"]);
144 val (ptp as (pt,p), tacis) = get_calc 1; get_pos 1 1;
146 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
147 val (ptp as (pt,p), tacis) = get_calc 1; get_pos 1 1;
149 (*-------------------------------------------------------------------------*)
150 (*8*) fetchProposedTactic 1;
151 val (ptp as (pt,p), tacis) = get_calc 1; get_pos 1 1;
153 (*8*) setNextTactic 1 (Apply_Method ["Test","solve_linear"]);
154 (*ERROR.110620 <SETNEXTTACTIC>..<MESSAGE> end-of-calculation*)
155 val (ptp as (pt,p), tacis) = get_calc 1; get_pos 1 1;
157 is_complete_spec ptp;
159 (*8*) autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1); (*<---------------------- orig. test code*)
161 val (ptp as (pt,p), tacis) = get_calc 1; get_pos 1 1; (*<---------------------- orig. test code*)
162 (*+isa=REP*) if p = ([1], Frm) andalso UnparseC.term (get_obj g_form pt [1]) = "1 + -1 * 2 + x = 0"
163 andalso Istate.string_of (get_istate_LI pt p)
164 = "Pstate ([\"\n(e_e, 1 + -1 * 2 + x = 0)\",\"\n(v_v, x)\"], [], empty, NONE, \n??.empty, ORundef, false, true)"
165 then () else error "refFormula = 1 + -1 * 2 + x = 0 changed";
166 (*-------------------------------------------------------------------------*)
168 (*9*) fetchProposedTactic 1; (*<----------------------------------------------------- orig. test code*)
169 (*+\\------------------------------------------ isa == REP -----------------------------------//* )
170 (*+//========================================== isa <> REP (1) ===============================\\*)
171 (*9*) setNextTactic 1 (Rewrite_Set_Inst (["(''bdv'',x)"], "isolate_bdv")); ( *<------- orig. test code*)
173 "~~~~~ fun setNextTactic , args:"; val (cI, tac) = (1, (Rewrite_Set_Inst (["(''bdv'',x)"], "isolate_bdv")));
174 val ((pt'''''_', _), _) = get_calc cI
175 val ip'''''_' = get_pos cI 1;
177 val xxxxx_x(*"ok", (tacis, _, _)*) = (*case*) Step.by_tactic tac (pt'''''_', ip'''''_') (*of*);
178 (*+isa+REP*)val ("ok", ( [ (Rewrite_Set_Inst (["(''bdv'', x)"], "isolate_bdv"),
179 Rewrite_Set_Inst' _, (pos', (istate, ctxt))) ] , _, cstate)) = xxxxx_x;
181 (*//******************* Step.by_tactic returns tac_ + istate + cstate *****************************\\*)
182 Step.by_tactic : Tactic.input -> state -> string * (taci list * pos' list * state);
183 if Istate.string_of istate
184 = "Pstate ([\"\n(e_e, 1 + -1 * 2 + x = 0)\",\"\n(v_v, x)\"], [R,L,R,L,R,L,R], empty, SOME e_e, \nx = 0 + -1 * (1 + -1 * 2), ORundef, true, true)"
185 then () else error "from Step.by_tactic return --- changed 1";
187 if Istate.string_of (get_istate_LI (fst cstate) (snd cstate))
188 = "Pstate ([\"\n(e_e, 1 + -1 * 2 + x = 0)\",\"\n(v_v, x)\"], [R,L,R,L,R,L,R], empty, SOME e_e, \nx = 0 + -1 * (1 + -1 * 2), ORundef, true, true)"
189 then () else error "from Step.by_tactic return --- changed 2";
190 (*\\******************* Step.by_tactic returns tac_ + istate + cstate *****************************//*)
192 "~~~~~ fun Step.by_tactic , args:"; val (tac, (ptp as (pt, p))) = (tac, (pt'''''_', ip'''''_'));
193 val Applicable.Appl m = (*case*) Applicable.applicable_in p pt tac (*of*);
194 (*if*) Tactic.for_specify' m; (*false*)
196 Step_Solve.by_tactic m (pt, p);
197 "~~~~~ fun by_tactic , args:"; val (m, (pt, po as (p, p_))) = (m, (pt, p));
198 (*if*) Celem.e_metID = get_obj g_metID pt (par_pblobj pt p); (*else*)
199 val thy' = get_obj g_domID pt (par_pblobj pt p);
200 val (is, sc) = LItool.resume_prog thy' (p,p_) pt;
201 val Safe_Step (istate, _, tac) =
202 (*case*) LI.locate_input_tactic sc (pt, po) (fst is) (snd is) m (*of*);
204 (*+*)Safe_Step: Istate.T * Proof.context * Tactic.T -> input_tactic_result;
205 (********************* locate_input_tactic returns cstate * istate * Proof.context *************)
206 (*+*)if Istate.string_of istate
207 (*+isa*) = "Pstate ([\"\n(e_e, 1 + -1 * 2 + x = 0)\",\"\n(v_v, x)\"], [R,L,R,L,R,L,R], empty, SOME e_e, \nx = 0 + -1 * (1 + -1 * 2), ORundef, true, true)"
208 then case m of Rewrite_Set_Inst' _ => ()
209 else error "from locate_input_tactic return --- changed";
211 val ("ok", (tacis'''''_', _, _)) = xxxxx_x;
212 "~~~~~ from TOPLEVEL to states return:"; upd_calc cI ((pt'''''_', ip'''''_'), tacis'''''_');
213 (*\\=========================================== isa <> REP (1) ===============================//*)
214 (*//=========================================== isa <> REP (2) ===============================\\*)
215 (*9* ) autoCalculate 1 (Steps 1); (*<-------------------------------------------------- orig. test code*)
216 ( *isa: <AUTOCALC><CALCID>1</CALCID><CALCCHANGED><UNCHANGED><INTLIST><INT>1</INT></INTLIST><POS>Frm</POS></UNCHANGED><DELETED><INTLIST><INT>1</INT></INTLIST><POS>Frm</POS></DELETED><GENERATED><INTLIST><INT>1</INT></INTLIST><POS>Res</POS></GENERATED></CALCCHANGED></AUTOCALC>*)
218 "~~~~~ fun autoCalculate , args:"; val (cI, auto) = (1, (Steps 1));
219 val pold = get_pos cI 1;
220 val xxx = (get_calc cI);
221 (*isa*) val (**)xxxx(**) (**) = (**)
222 (*case*) Math_Engine.autocalc [] pold (xxx) auto (*of*);
223 "~~~~~ fun autocalc , args:"; val (c, ip, cs, (Solve.Steps s)) = ([], pold, (xxx), auto);
224 (*if*) s <= 1; (*then*)
225 (*val (str, (_, c', ptp)) =*)
228 "~~~~~ fun do_next , args:"; val ((ip as (_, p_)), (ptp as (pt,p), tacis)) = (ip, cs);
230 (*+isa==REP*)val [(Rewrite_Set_Inst (["(''bdv'', x)"], "isolate_bdv"),
231 Rewrite_Set_Inst' _, (pos', (istate, ctxt)))] = tacis;
232 (*+*)if pos' = ([1], Res) andalso Istate.string_of istate
233 = "Pstate ([\"\n(e_e, 1 + -1 * 2 + x = 0)\",\"\n(v_v, x)\"], [R,L,R,L,R,L,R], empty, SOME e_e, \nx = 0 + -1 * (1 + -1 * 2), ORundef, true, true)"
234 then () else error "init. step 1 + -1 * 2 + x = 0 changed";
236 val pIopt = get_pblID (pt,ip);
237 (*if*) ip = ([], Pos.Res);(*else*)
238 val (_::_) = (*case*) tacis (*of*);
239 (*isa==REP*) (*if*) ip = p;(*then*)
240 (*val (pt',c',p') =*) Generate.generate tacis (pt,[],p);
241 (*//------------------------------------- final test -----------------------------------------\\*)
242 val ("ok", [], ptp as (pt, p)) = xxxx;
244 if Istate.string_of (get_istate_LI pt p) (* <> <> <> <> ^^^^^^^^^^^^^*)
245 (*REP*) = "Pstate ([\"\n(e_e, 1 + -1 * 2 + x = 0)\",\"\n(v_v, x)\"], [R,L,R,L,R,L,R], empty, SOME e_e, \nx = 0 + -1 * (1 + -1 * 2), ORundef, true, true)"
246 then () else error "REP autoCalculate on (e_e, 1 + -1 * 2 + x = 0) changed"
248 "~~~~~ from TOPLEVEL to states return:"; upd_calc cI (ptp, []); upd_ipos cI 1 p;
249 (*\\=========================================== isa <> REP (2) ===============================//*)
251 (*10*) fetchProposedTactic 1;
252 setNextTactic 1 (Rewrite_Set "Test_simplify");
253 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
255 (*11*) fetchProposedTactic 1;
256 setNextTactic 1 (Check_Postcond ["LINEAR","univariate","equation","test"]);
257 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
259 (*======= final test ==================================================*)
260 val ((pt,_),_) = get_calc 1;
261 val ip = get_pos 1 1;
263 val (Form f, tac, asms) = pt_extract (pt, ip);
264 (*exception just above means: 'ModSpec' has been returned: error anyway*)
265 if ip = ([], Res) andalso UnparseC.term f = "[x = 1]" then () else
266 error "FE-Kernel-interface.sml: diff.behav. in solve_linear as rootpbl";
269 "--------- inspect the CalcTree No.1 with Iterator No.2 -";
270 "--------- inspect the CalcTree No.1 with Iterator No.2 -";
271 "--------- inspect the CalcTree No.1 with Iterator No.2 -";
272 (*WN041118: inspection shifted to Iterator No.1, because others need pos'*)
273 (*-------- WN190723: doesnt work since changeset 59474 21d4d2868b83
275 refFormula 1 ([],Pbl); getTactic 1 ([],Pbl);(*Error*)
277 refFormula 1 ([1],Frm); getTactic 1 ([1],Frm);(*Error*)
279 refFormula 1 ([1],Res); getTactic 1 ([1],Res);(*OK*)
280 (*getAssumption 1 ([1],Res); TODO.WN041217*)
281 moveActiveDown 1 ; refFormula 1 ([2],Res);
282 moveActiveCalcHead 1; refFormula 1 ([],Pbl);
286 if get_pos 1 1 = ([2], Res) then () else
287 error "FE-interface.sml: diff.behav. in a inspect 1 with Iterator 2";
288 moveActiveDown 1; refFormula 1 ([], Res);
289 if get_pos 1 1 = ([], Res) then () else
290 error "FE-interface.sml: diff.behav. in b inspect 1 with Iterator 2";
291 moveActiveCalcHead 1; refFormula 1 ([],Pbl);
293 ------------------------------------------------------------------------------------------------*)
295 "--------- miniscript with mini-subpbl ------------------";
296 "--------- miniscript with mini-subpbl ------------------";
297 "--------- miniscript with mini-subpbl ------------------";
298 (*WN120210?not ME:\label{SOLVE:MANUAL:TACTIC:enter} UC 30.3.2.1 p.175 !!!!!NOT IMPL IN FE*)
299 "=== this sequence of fun-calls resembles fun me ===";
300 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
301 ("Test", ["sqroot-test","univariate","equation","test"],
302 ["Test","squ-equ-test-subpbl1"]))];
306 refFormula 1 (get_pos 1 1);
307 fetchProposedTactic 1;
308 setNextTactic 1 (Model_Problem);
309 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*gets ModSpec;model is still empty*)
311 fetchProposedTactic 1;
312 setNextTactic 1 (Add_Given "equality (x + 1 = 2)");
313 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
315 fetchProposedTactic 1;
316 setNextTactic 1 (Add_Given "solveFor x");
317 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
319 fetchProposedTactic 1;
320 setNextTactic 1 (Add_Find "solutions L");
321 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
323 fetchProposedTactic 1;
324 setNextTactic 1 (Specify_Theory "Test");
325 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
327 fetchProposedTactic 1;
328 setNextTactic 1 (Specify_Problem
329 ["sqroot-test","univariate","equation","test"]);
330 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
331 "1-----------------------------------------------------------------";
333 fetchProposedTactic 1;
334 setNextTactic 1 (Specify_Method ["Test","squ-equ-test-subpbl1"]);
335 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
337 fetchProposedTactic 1;
338 setNextTactic 1 (Apply_Method ["Test","squ-equ-test-subpbl1"]);
339 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
341 fetchProposedTactic 1;
342 setNextTactic 1 (Rewrite_Set "norm_equation");
343 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
345 fetchProposedTactic 1;
346 setNextTactic 1 (Rewrite_Set "Test_simplify");
347 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
349 fetchProposedTactic 1;(*----------------Subproblem--------------------*);
350 setNextTactic 1 (Subproblem ("Test",
351 ["LINEAR","univariate","equation","test"]));
352 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
354 fetchProposedTactic 1;
355 setNextTactic 1 (Model_Problem );
356 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
358 fetchProposedTactic 1;
359 setNextTactic 1 (Add_Given "equality (-1 + x = 0)");
360 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
362 fetchProposedTactic 1;
363 setNextTactic 1 (Add_Given "solveFor x");
364 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
366 fetchProposedTactic 1;
367 setNextTactic 1 (Add_Find "solutions x_i");
368 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
370 fetchProposedTactic 1;
371 setNextTactic 1 (Specify_Theory "Test");
372 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
374 fetchProposedTactic 1;
375 setNextTactic 1 (Specify_Problem ["LINEAR","univariate","equation","test"]);
376 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
377 "2-----------------------------------------------------------------";
379 fetchProposedTactic 1;
380 setNextTactic 1 (Specify_Method ["Test","solve_linear"]);
381 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
383 fetchProposedTactic 1;
384 setNextTactic 1 (Apply_Method ["Test","solve_linear"]);
385 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
387 fetchProposedTactic 1;
388 setNextTactic 1 (Rewrite_Set_Inst (["(''bdv'',x)"], "isolate_bdv"));
389 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
391 fetchProposedTactic 1;
392 setNextTactic 1 (Rewrite_Set "Test_simplify");
393 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
395 fetchProposedTactic 1;
396 setNextTactic 1 (Check_Postcond ["LINEAR","univariate","equation","test"]);
397 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
399 fetchProposedTactic 1;
400 setNextTactic 1 (Check_elementwise "Assumptions");
401 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
403 val xml = fetchProposedTactic 1;
404 setNextTactic 1 (Check_Postcond
405 ["sqroot-test","univariate","equation","test"]);
406 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
408 val ((pt,_),_) = get_calc 1;
409 val str = pr_ctree pr_short pt;
411 val ip = get_pos 1 1;
412 val (Form f, tac, asms) = pt_extract (pt, ip);
413 (*exception just above means: 'ModSpec' has been returned: error anyway*)
414 if UnparseC.term f = "[x = 1]" then () else
415 error "FE-interface.sml: diff.behav. in miniscript with mini-subpb";
418 "--------- mini-subpbl AUTOCALCULATE Steps 1 -------------";
419 "--------- mini-subpbl AUTOCALCULATE Steps 1 -------------";
420 "--------- mini-subpbl AUTOCALCULATE Steps 1 -------------";
421 (*WN120210?not ME:\label{SOLVE:AUTO:one} UC 30.3.3.2 p.176*)
422 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
423 ("Test", ["sqroot-test","univariate","equation","test"],
424 ["Test","squ-equ-test-subpbl1"]))];
427 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
428 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
429 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
430 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
431 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
432 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
433 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
434 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
435 (*here the solve-phase starts*)
436 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
437 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
438 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
439 (*------------------------------------*)
440 (* (*default_print_depth 13*) get_calc 1;
442 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
443 (*calc-head of subproblem*)
444 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
445 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
446 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
447 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
448 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
449 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
450 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
451 (*solve-phase of the subproblem*)
452 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
453 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
454 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
455 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
456 (*finish subproblem*)
457 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
459 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
461 (*this checks the test for correctness..*)
462 val ((pt,_),_) = get_calc 1;
464 val (Form f, tac, asms) = pt_extract (pt, p);
465 if UnparseC.term f = "[x = 1]" andalso p = ([], Res) then () else
466 error "FE-interface.sml: diff.behav. in miniscript with mini-subpb";
470 "--------- solve_linear as rootpbl AUTO CompleteCalc ----";
471 "--------- solve_linear as rootpbl AUTO CompleteCalc ----";
472 "--------- solve_linear as rootpbl AUTO CompleteCalc ----";
473 (*WN120210?not ME:\label{SPECIFY:START:auto} UC 30.2.4.2 p.174*)
475 [(["equality (1+-1*2+x=(0::real))", "solveFor x","solutions L"],
477 ["LINEAR","univariate","equation","test"],
478 ["Test","solve_linear"]))];
481 getFormulaeFromTo 1 ([],Pbl) ([],Pbl) 999 false;
483 autoCalculate 1 CompleteCalc;
484 val (unc, del, gen) = (([],Pbl), ([],Pbl), ([],Res));
485 getFormulaeFromTo 1 unc gen 1 (*only level 1*) false;
487 val ((pt,_),_) = get_calc 1;
489 val (Form f, tac, asms) = pt_extract (pt, p);
490 if UnparseC.term f = "[x = 1]" andalso p = ([], Res) then () else
491 error "FE-interface.sml: diff.behav. in solve_linear/rt AUTOCALCULATE ";
494 "--------- solve_linear as rootpbl AUTO CompleteHead/Num_Calc ";
495 "--------- solve_linear as rootpbl AUTO CompleteHead/Num_Calc ";
496 "--------- solve_linear as rootpbl AUTO CompleteHead/Num_Calc ";
497 (* ERROR: error in kernel ?? *)
499 [(["equality (1+-1*2+x=(0::real))", "solveFor x","solutions L"],
501 ["LINEAR","univariate","equation","test"],
502 ["Test","solve_linear"]))];
506 autoCalculate 1 CompleteCalcHead;
507 refFormula 1 (get_pos 1 1);
508 val ((pt,p),_) = get_calc 1;
510 autoCalculate 1 CompleteCalc;
511 val ((pt,p),_) = get_calc 1;
512 if p=([], Res) then () else
513 error "FE-interface.sml: diff.behav. in solve_linear AUTOC Head/Num_Calc ";
516 "--------- mini-subpbl AUTOCALCULATE CompleteCalc -------";
517 "--------- mini-subpbl AUTOCALCULATE CompleteCalc -------";
518 "--------- mini-subpbl AUTOCALCULATE CompleteCalc -------";
519 (*WN120210?not ME:\label{SPECIFY:START:auto} UC 30.2.4.2 p.174*)
520 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
521 ("Test", ["sqroot-test","univariate","equation","test"],
522 ["Test","squ-equ-test-subpbl1"]))];
525 autoCalculate 1 CompleteCalc;
526 val ((pt,p),_) = get_calc 1; show_pt pt;
528 getTactic 1 ([1],Frm);
529 getTactic 1 ([1],Res);
530 initContext 1 Thy_ ([1],Res);
532 (*... returns calcChangedEvent with*)
533 val (unc, del, gen) = (([],Pbl), ([],Pbl), ([],Res));
534 getFormulaeFromTo 1 unc gen 0 (*only result*) false;
535 getFormulaeFromTo 1 unc gen 1 (*only level 1*) false;
536 getFormulaeFromTo 1 unc gen 99999 (*all levels*) false;
538 val ((pt,_),_) = get_calc 1;
540 val (Form f, tac, asms) = pt_extract (pt, p);
541 if UnparseC.term f = "[x = 1]" andalso p = ([], Res) then () else
542 error "FE-interface.sml: diff.behav. in mini-subpbl AUTOCALCULATE 6";
545 "--------- mini-subpbl AUTO CompleteCalcHead ------------";
546 "--------- mini-subpbl AUTO CompleteCalcHead ------------";
547 "--------- mini-subpbl AUTO CompleteCalcHead ------------";
548 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
549 ("Test", ["sqroot-test","univariate","equation","test"],
550 ["Test","squ-equ-test-subpbl1"]))];
553 autoCalculate 1 CompleteCalcHead;
555 val ((Nd (PblObj {fmz = (fm, ("Test", pblID, metID)), loc = (SOME (env, ctxt1), NONE),
557 spec = ("Test", ["sqroot-test", "univariate", "equation", "test"],
558 ["Test", "squ-equ-test-subpbl1"]),
559 probl, branch = TransitiveB, origin, ostate = Incomplete, result}, []),
560 ([], Met)), []) = get_calc 1;
561 if length meth = 3 andalso length probl = 3 (*just some items tested*) then ()
562 else error "--- mini-subpbl AUTO CompleteCalcHead ---";
565 "--------- solve_linear as rootpbl AUTO CompleteModel ---";
566 "--------- solve_linear as rootpbl AUTO CompleteModel ---";
567 "--------- solve_linear as rootpbl AUTO CompleteModel ---";
570 [(["equality (1+-1*2+x=(0::real))", "solveFor x","solutions L"],
572 ["LINEAR","univariate","equation","test"],
573 ["Test","solve_linear"]))];
576 autoCalculate 1 CompleteModel;
577 refFormula 1 (get_pos 1 1);
579 setProblem 1 ["LINEAR","univariate","equation","test"];
580 val pos = get_pos 1 1;
581 setContext 1 pos (kestoreID2guh Pbl_["LINEAR","univariate","equation","test"]);
582 refFormula 1 (get_pos 1 1);
584 setMethod 1 ["Test","solve_linear"];
585 setContext 1 pos (kestoreID2guh Met_ ["Test","solve_linear"]);
586 refFormula 1 (get_pos 1 1);
587 val ((pt,_),_) = get_calc 1;
588 if get_obj g_spec pt [] = ("e_domID",
589 ["LINEAR", "univariate","equation","test"],
590 ["Test","solve_linear"]) then ()
591 else error "FE-interface.sml: diff.behav. in setProblem, setMethod";
593 autoCalculate 1 CompleteCalcHead;
594 refFormula 1 (get_pos 1 1);
595 autoCalculate 1 CompleteCalc;
599 refFormula 1 (get_pos 1 1);
600 val ((pt,_),_) = get_calc 1;
602 val (Form f, tac, asms) = pt_extract (pt, p);
603 if UnparseC.term f = "[x = 1]" andalso p = ([], Res) then () else
604 error "FE-interface.sml: diff.behav. in mini-subpbl AUTOCALCULATE 6";
607 "--------- setContext..Thy ------------------------------";
608 "--------- setContext..Thy ------------------------------";
609 "--------- setContext..Thy ------------------------------";
611 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
612 ("Test", ["sqroot-test","univariate","equation","test"],
613 ["Test","squ-equ-test-subpbl1"]))];
614 Iterator 1; moveActiveRoot 1;
615 autoCalculate 1 CompleteCalcHead;
616 autoCalculate 1 (Steps 1);
617 val ((pt,p),_) = get_calc 1; show_pt pt; (*2 lines, OK*)
619 setNextTactic 1 (Rewrite_Set "Test_simplify"); (*--> "thy_isac_Test-rls-Test_simplify"*)
620 autoCalculate 1 (Steps 1);
621 val ((pt,p),_) = get_calc 1; show_pt pt;
623 "-----^^^^^ and vvvvv do the same -----";
624 setContext 1 p "thy_isac_Test-rls-Test_simplify";
625 val ((pt,p),_) = get_calc 1; show_pt pt; (*2 lines, OK*)
627 autoCalculate 1 (Steps 1);
628 setContext 1 p "thy_isac_Test-rls-Test_simplify";
629 val (((pt,_),_), p) = (get_calc 1, get_pos 1 1);
630 val (Form f, tac, asms) = pt_extract (pt, p);
631 if p = ([1], Res) andalso UnparseC.term (get_obj g_res pt (fst p)) = "x + 1 + -1 * 2 = 0"
632 then () else error "--- setContext..Thy --- autoCalculate 1 (Steps 1) #1";
634 autoCalculate 1 CompleteCalc;
635 val (((pt,_),_), p) = (get_calc 1, get_pos 1 1);
636 val (Form f, tac, asms) = pt_extract (pt, p);
638 if UnparseC.term f = "[x = 1]" andalso p = ([], Res) then ()
639 else error "--- setContext..Thy --- autoCalculate CompleteCalc";
642 "--------- mini-subpbl AUTOCALC CompleteToSubpbl --------";
643 "--------- mini-subpbl AUTOCALC CompleteToSubpbl --------";
644 "--------- mini-subpbl AUTOCALC CompleteToSubpbl --------";
646 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
647 ("Test", ["sqroot-test","univariate","equation","test"],
648 ["Test","squ-equ-test-subpbl1"]))];
649 Iterator 1; moveActiveRoot 1;
650 autoCalculate 1 CompleteToSubpbl;
651 refFormula 1 (get_pos 1 1); (*<ISA> -1 + x = 0 </ISA>*);
652 val ((pt,_),_) = get_calc 1;
653 val str = pr_ctree pr_short pt;
655 if str = ". ----- pblobj -----\n1. x + 1 = 2\n2. x + 1 + -1 * 2 = 0\n"
657 error "FE-interface.sml: diff.behav. in mini-subpbl CompleteToSubpbl-1";
659 autoCalculate 1 (Steps 1); (*proceeds only, if NOT 1 step before subplb*)
660 autoCalculate 1 CompleteToSubpbl;
661 val ((pt,_),_) = get_calc 1;
662 val str = pr_ctree pr_short pt;
664 autoCalculate 1 CompleteCalc; (*das geht ohnehin !*);
665 val ((pt,_),_) = get_calc 1;
668 val (Form f, tac, asms) = pt_extract (pt, p);
669 if UnparseC.term f = "[x = 1]" andalso p = ([], Res) then () else
670 error "FE-interface.sml: diff.behav. in mini-subpbl CompleteToSubpbl 1";
673 "--------- rat-eq + subpbl: no_met, NO solution dropped -";
674 "--------- rat-eq + subpbl: no_met, NO solution dropped -";
675 "--------- rat-eq + subpbl: no_met, NO solution dropped -";
676 "--------- rat-eq + subpbl: no_met, NO solution dropped - see LI: '--- simpl.rat.term, '..";
677 (*--- THIS IS RE-USED WITH fun me IN test/../MathEngine/solve.sml -------------------
678 ---- rat-eq + subpbl: set_found in check_tac1 ----*)
680 [(["equality ((5*x)/(x - 2) - x/(x+2)=(4::real))", "solveFor x","solutions L"],
681 ("RatEq", ["univariate","equation"], ["no_met"]))];
684 fetchProposedTactic 1;
686 setNextTactic 1 (Model_Problem);
687 autoCalculate 1 (Steps 1); fetchProposedTactic 1;
689 setNextTactic 1 (Specify_Theory "RatEq");
690 autoCalculate 1 (Steps 1); fetchProposedTactic 1;
691 setNextTactic 1 (Specify_Problem ["rational","univariate","equation"]);
692 autoCalculate 1 (Steps 1); fetchProposedTactic 1;
693 setNextTactic 1 (Specify_Method ["RatEq","solve_rat_equation"]);
694 autoCalculate 1 (Steps 1); fetchProposedTactic 1;
695 setNextTactic 1 (Apply_Method ["RatEq","solve_rat_equation"]);
696 autoCalculate 1 (Steps 1); fetchProposedTactic 1;
697 setNextTactic 1 (Rewrite_Set "RatEq_simplify");
698 autoCalculate 1 (Steps 1); fetchProposedTactic 1;
699 setNextTactic 1 (Rewrite_Set "norm_Rational");
700 autoCalculate 1 (Steps 1); fetchProposedTactic 1;
701 setNextTactic 1 (Rewrite_Set "RatEq_eliminate");
702 autoCalculate 1 (Steps 1); fetchProposedTactic 1;
703 (* __________ for "12 * x + 4 * x ^^^ 2 = 4 * (-4 + x ^^^ 2)"*)
704 setNextTactic 1 (Subproblem ("PolyEq", ["normalise","polynomial",
705 "univariate","equation"]));
706 autoCalculate 1 (Steps 1); fetchProposedTactic 1;
707 setNextTactic 1 (Model_Problem );
708 autoCalculate 1 (Steps 1); fetchProposedTactic 1;
709 setNextTactic 1 (Specify_Theory "PolyEq");
710 autoCalculate 1 (Steps 1); fetchProposedTactic 1;
711 setNextTactic 1 (Specify_Problem ["normalise","polynomial",
712 "univariate","equation"]);
713 autoCalculate 1 (Steps 1); fetchProposedTactic 1;
714 setNextTactic 1 (Specify_Method ["PolyEq","normalise_poly"]);
715 autoCalculate 1 (Steps 1); fetchProposedTactic 1;
716 setNextTactic 1 (Apply_Method ["PolyEq","normalise_poly"]);
717 autoCalculate 1 (Steps 1); fetchProposedTactic 1;
718 setNextTactic 1 (Rewrite ("all_left", ThmC.numerals_to_Free @{thm all_left}));
719 autoCalculate 1 (Steps 1); fetchProposedTactic 1;
720 setNextTactic 1 (Rewrite_Set_Inst (["(''bdv'',x)"], "make_ratpoly_in"));
721 autoCalculate 1 (Steps 1); fetchProposedTactic 1;
722 (* __________ for "16 + 12 * x = 0"*)
723 setNextTactic 1 (Subproblem ("PolyEq",
724 ["degree_1","polynomial","univariate","equation"]));
725 autoCalculate 1 (Steps 1); fetchProposedTactic 1;
726 setNextTactic 1 (Model_Problem );
727 autoCalculate 1 (Steps 1); fetchProposedTactic 1;
728 setNextTactic 1 (Specify_Theory "PolyEq");
729 (*------------- some trials in the problem-hierarchy ---------------*)
730 setNextTactic 1 (Specify_Problem ["LINEAR","univariate","equation"]);
731 autoCalculate 1 (Steps 1); fetchProposedTactic 1; (*<ERROR> helpless </ERROR> !!!*)
732 setNextTactic 1 (Refine_Problem ["univariate","equation"]);
733 (*------------------------------------------------------------------*)
734 autoCalculate 1 (Steps 1); fetchProposedTactic 1;
735 setNextTactic 1 (Specify_Method ["PolyEq","solve_d1_polyeq_equation"]);
736 autoCalculate 1 (Steps 1); fetchProposedTactic 1;
737 setNextTactic 1 (Apply_Method ["PolyEq","solve_d1_polyeq_equation"]);
738 autoCalculate 1 (Steps 1); fetchProposedTactic 1;
739 setNextTactic 1 (Rewrite_Set_Inst (["(''bdv'',x)"], "d1_polyeq_simplify"));
740 autoCalculate 1 (Steps 1); fetchProposedTactic 1;
741 setNextTactic 1 (Rewrite_Set "polyeq_simplify");
742 autoCalculate 1 (Steps 1); fetchProposedTactic 1;
743 setNextTactic 1 Or_to_List;
744 autoCalculate 1 (Steps 1); fetchProposedTactic 1;
745 setNextTactic 1 (Check_elementwise "Assumptions");
746 autoCalculate 1 (Steps 1); fetchProposedTactic 1;
747 setNextTactic 1 (Check_Postcond ["degree_1","polynomial",
748 "univariate","equation"]);
749 autoCalculate 1 (Steps 1); fetchProposedTactic 1;
750 setNextTactic 1 (Check_Postcond ["normalise","polynomial",
751 "univariate","equation"]);
752 autoCalculate 1 (Steps 1); fetchProposedTactic 1;
753 setNextTactic 1 (Check_Postcond ["rational","univariate","equation"]);
754 val (ptp,_) = get_calc 1;
755 val (Form t,_,_) = pt_extract ptp;
756 if get_pos 1 1 = ([], Res) andalso UnparseC.term t = "[x = -4 / 3]" then ()
757 else writeln "FE-inteface.sml: diff.behav. in rat-eq + subpbl: no_met, NO ..";
761 "--------- tryMatchProblem, tryRefineProblem ------------";
762 "--------- tryMatchProblem, tryRefineProblem ------------";
763 "--------- tryMatchProblem, tryRefineProblem ------------";
764 (*{\bf\UC{Having \isac{} Refine the Problem
765 * Automatically}\label{SPECIFY:refine-auto}\\} test match and refine with
766 * x^^^2 + 4*x + 5 = 2
767 see isac.bridge.TestSpecify#testMatchRefine*)
770 [(["equality (x^2 + 4*x + 5 = (2::real))", "solveFor x","solutions L"],
772 ["univariate","equation"],
777 fetchProposedTactic 1;
778 setNextTactic 1 (Model_Problem );
779 (*..this tactic should be done 'tacitly', too !*)
782 autoCalculate 1 CompleteCalcHead;
783 checkContext 1 ([],Pbl) "pbl_equ_univ";
784 checkContext 1 ([],Pbl) (kestoreID2guh Pbl_ ["univariate","equation"]);
787 autoCalculate 1 (Steps 1);
789 fetchProposedTactic 1;
790 setNextTactic 1 (Add_Given "equality (x ^^^ 2 + 4 * x + 5 = (2::real))");
791 autoCalculate 1 (Steps 1);
793 "--------- we go into the ProblemBrowser (_NO_ pblID selected) -";
794 initContext 1 Pbl_ ([],Pbl);
795 (* this would break if a calculation would be inserted before: CALCID...
796 and pattern matching is not available in *.java.
797 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"
798 then () else error "--- tryMatchProblem, tryRefineProblem: initContext 1 Pbl_ ([],Pbl); CHANGED";
800 initContext 1 Met_ ([],Pbl);
801 (*<SYSERROR><CALCID>1</CALCID><ERROR>error in kernel 33</ERROR></SYSERROR>*)
803 "--------- this match will show some incomplete items: ---------";
805 checkContext 1 ([],Pbl) (kestoreID2guh Pbl_ ["univariate","equation"]);
806 checkContext 1 ([],Pbl) (kestoreID2guh Met_ ["LinEq", "solve_lineq_equation"]);
809 fetchProposedTactic 1;
810 setNextTactic 1 (Add_Given "solveFor x"); autoCalculate 1 (Steps 1);
812 fetchProposedTactic 1;
813 setNextTactic 1 (Add_Find "solutions L"); autoCalculate 1 (Steps 1);
815 "--------- this is a matching model (all items correct): -------";
816 checkContext 1 ([],Pbl) (kestoreID2guh Pbl_ ["univariate","equation"]);
817 "--------- this is a NOT matching model (some 'false': ---------";
818 checkContext 1 ([],Pbl)(kestoreID2guh Pbl_ ["LINEAR","univariate","equation"]);
820 "--------- find out a matching problem: ------------------------";
821 "--------- find out a matching problem (FAILING: no new pbl) ---";
822 refineProblem 1([],Pbl)(pblID2guh ["LINEAR","univariate","equation"]);
824 "--------- find out a matching problem (SUCCESSFUL) ------------";
825 refineProblem 1 ([],Pbl) (pblID2guh ["univariate","equation"]);
827 "--------- tryMatch, tryRefine did not change the calculation -";
828 "--------- this is done by <TRANSFER> on the pbl-browser: ------";
829 setNextTactic 1 (Specify_Problem ["normalise","polynomial",
830 "univariate","equation"]);
831 autoCalculate 1 (Steps 1);
832 (*WN050904 fetchProposedTactic again --> Specify_Problem ["normalise",...
833 and Specify_Theory skipped in comparison to below ---^^^-inserted *)
834 (*------------vvv-inserted-----------------------------------------------*)
835 fetchProposedTactic 1;
836 setNextTactic 1 (Specify_Problem ["normalise","polynomial",
837 "univariate","equation"]);
838 autoCalculate 1 (Steps 1);
840 (*and Specify_Theory skipped by fetchProposedTactic ?!?*)
842 fetchProposedTactic 1;
843 setNextTactic 1 (Specify_Method ["PolyEq","normalise_poly"]);
844 autoCalculate 1 (Steps 1);
846 fetchProposedTactic 1;
847 setNextTactic 1 (Apply_Method ["PolyEq","normalise_poly"]);
849 autoCalculate 1 CompleteCalc;
851 val ((pt,_),_) = get_calc 1;
854 val (Form f, tac, asms) = pt_extract (pt, p);
855 if UnparseC.term f = "[x = -1, x = -3]" andalso p = ([], Res) then () else
856 error "FE-interface.sml: diff.behav. in tryMatchProblem, tryRefine";
858 (*------------^^^-inserted-----------------------------------------------*)
859 (*WN050904 the fetchProposedTactic's below may not have worked like that
860 before, too, because there was no check*)
861 fetchProposedTactic 1;
862 setNextTactic 1 (Specify_Theory "PolyEq");
863 autoCalculate 1 (Steps 1);
865 fetchProposedTactic 1;
866 setNextTactic 1 (Specify_Method ["PolyEq","normalise_poly"]);
867 autoCalculate 1 (Steps 1);
869 fetchProposedTactic 1;
870 "--------- now the calc-header is ready for enter 'solving' ----";
871 autoCalculate 1 CompleteCalc;
873 val ((pt,_),_) = get_calc 1;
877 val (Form f, tac, asms) = pt_extract (pt, p);
878 if UnparseC.term f = "[x = -1, x = -3]" andalso p = ([], Res) then () else
879 error "FE-interface.sml: diff.behav. in tryMatchProblem, tryRefine";
882 "--------- modifyCalcHead, resetCalcHead, modelProblem --";
883 "--------- modifyCalcHead, resetCalcHead, modelProblem --";
884 "--------- modifyCalcHead, resetCalcHead, modelProblem --";
886 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
887 ("Test", ["sqroot-test","univariate","equation","test"],
888 ["Test","squ-equ-test-subpbl1"]))];
892 modifyCalcHead 1 (([],Pbl),(*the position from refFormula*)
893 "solve (x+1=2, x)",(*the headline*)
894 [Given ["equality (x+1=(2::real))", "solveFor x"],
895 Find ["solutions L"](*,Relate []*)],
898 ["sqroot-test","univariate","equation","test"],
899 ["Test","squ-equ-test-subpbl1"]));
901 val ((Nd (PblObj {fmz = (fm, tpm),
902 loc = (SOME scrst_ctxt, NONE),
906 ["sqroot-test", "univariate", "equation", "test"],
907 ["Test", "squ-equ-test-subpbl1"]),
909 branch = TransitiveB,
916 (*WN110622: is the same as in 2002, but shouldn't be probl = [3 items?]*)
917 if length meth = 0 andalso length probl = 0 (*just some items tested*) then ()
918 else error "--- modifyCalcHead, resetCalcHead, modelProblem 1 --";
924 val ((Nd (PblObj {fmz = (fm, tpm),
925 loc = (SOME scrst_ctxt, NONE),
928 spec = ("e_domID", ["e_pblID"], ["e_metID"]),
930 branch = TransitiveB,
937 if length meth = 3 andalso length probl = 3 (*just some items tested*) then ()
938 else error "--- modifyCalcHead, resetCalcHead, modelProblem 2 --";
940 "--------- maximum-example, UC: Modeling an example -----";
941 "--------- maximum-example, UC: Modeling an example -----";
942 "--------- maximum-example, UC: Modeling an example -----";
943 (* {\bf\UC{Editing the Model}\label{SPECIFY:enter}\label{SPECIFY:check}\\}
944 see isac.bridge.TestModel#testEditItems
946 val elems = ["fixedValues [r=Arbfix]","maximum A","valuesFor [a,b]",
947 "relations [A=a*b, (a/2)^2 + (b/2)^2 = r^2]",
948 "relations [A=a*b, (a/2)^2 + (b/2)^2 = r^2]",
949 "relations [A=a*b, a/2=r*sin alpha, b/2=r*cos (alpha::real)]",
950 (*^^^ these are the elements for the root-problem (in variants)*)
951 (*vvv these are elements required for subproblems*)
952 "boundVariable a","boundVariable b","boundVariable alpha",
953 "interval {x::real. 0 <= x & x <= 2*r}",
954 "interval {x::real. 0 <= x & x <= 2*r}",
955 "interval {x::real. 0 <= x & x <= pi}",
956 "errorBound (eps=(0::real))"]
957 (*specifying is not interesting for this example*)
958 val spec = ("DiffApp", ["maximum_of","function"],
959 ["DiffApp","max_by_calculus"]);
960 (*the empty model with descriptions for user-guidance by Model_Problem*)
961 val empty_model = [Given ["fixedValues []"],
962 Find ["maximum", "valuesFor"],
963 Relate ["relations []"]];
966 "#################################################################";
968 CalcTree [(elems, spec)];
971 refFormula 1 (get_pos 1 1);
972 (*this gives a completely empty model*)
974 fetchProposedTactic 1;
975 (*fill the CalcHead with Descriptions...*)
976 setNextTactic 1 (Model_Problem );
977 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
979 (*user input is !!!!!EITHER!!!!! _some_ (at least one) items of the model
980 !!!!!OR!!!!! _one_ part of the specification !!!!!!!!!!!!!*)
981 (*input of two items, 'fixedValues [r=Arbfix]' and 'maximum b'...*)
982 modifyCalcHead 1 (([],Pbl) (*position, from previous refFormula*),
983 "Problem (DiffApp.thy, [maximum_of, function])",
984 (*the head-form ^^^ is not used for input here*)
985 [Given ["fixedValues [r=Arbfix]"(*new input*)],
986 Find ["maximum b"(*new input*), "valuesFor"],
987 Relate ["relations"]],
988 (*input (Arbfix will dissappear soon)*)
990 e_spec (*no input to the specification*));
992 (*the user does not know, what 'superfluous' for 'maximum b' may mean
993 and asks what to do next*)
994 fetchProposedTactic 1;
995 (*the student follows the advice*)
996 setNextTactic 1 (Add_Find "maximum A"); (*FIXME.17.11.03: does not yet work*)
997 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
999 (*this input completes the model*)
1000 modifyCalcHead 1 (([],Pbl), "not used here",
1001 [Given ["fixedValues [r=Arbfix]"],
1002 Find ["maximum A", "valuesFor [a,b]"(*new input*)],
1003 Relate ["relations [A=a*b, \
1004 \(a/2)^2 + (b/2)^2 = r^2]"]], Pbl, e_spec);
1006 (*specification is not interesting and should be skipped by the dialogguide;
1007 !!!!!!!!!!!!!!!!!!!! input of ONE part at a time !!!!!!!!!!!!!!!!!!!!!!*)
1008 modifyCalcHead 1 (([],Pbl), "not used here",
1009 [Given ["fixedValues [r=Arbfix]"],
1010 Find ["maximum A", "valuesFor [a,b]"(*new input*)],
1011 Relate ["relations [A=a*b, \
1012 \(a/2)^2 + (b/2)^2 = r^2]"]], Pbl,
1013 ("DiffApp", ["e_pblID"], ["e_metID"]));
1014 modifyCalcHead 1 (([],Pbl), "not used here",
1015 [Given ["fixedValues [r=Arbfix]"],
1016 Find ["maximum A", "valuesFor [a,b]"(*new input*)],
1017 Relate ["relations [A=a*b, \
1018 \(a/2)^2 + (b/2)^2 = r^2]"]], Pbl,
1019 ("DiffApp", ["maximum_of","function"],
1021 modifyCalcHead 1 (([],Pbl), "not used here",
1022 [Given ["fixedValues [r=Arbfix]"],
1023 Find ["maximum A", "valuesFor [a,b]"(*new input*)],
1024 Relate ["relations [A=a*b, \
1025 \(a/2)^2 + (b/2)^2 = r^2]"]], Pbl,
1026 ("DiffApp", ["maximum_of","function"],
1027 ["DiffApp","max_by_calculus"]));
1028 (*this final calcHead now has STATUS 'complete' !*)
1031 "--------- solve_linear from pbl-hierarchy --------------";
1032 "--------- solve_linear from pbl-hierarchy --------------";
1033 "--------- solve_linear from pbl-hierarchy --------------";
1035 val (fmz, sp) = ([], ("", ["LINEAR","univariate","equation","test"], []));
1036 CalcTree [(fmz, sp)];
1037 Iterator 1; moveActiveRoot 1;
1038 refFormula 1 (get_pos 1 1);
1039 modifyCalcHead 1 (([],Pbl),"solve (1+-1*2+x=(0::real))",
1040 [Given ["equality (1+-1*2+x=(0::real))", "solveFor x"],
1041 Find ["solutions L"]],
1043 ("Test", ["LINEAR","univariate","equation","test"],
1044 ["Test","solve_linear"]));
1045 autoCalculate 1 CompleteCalc;
1046 refFormula 1 (get_pos 1 1);
1047 val ((pt,_),_) = get_calc 1;
1048 val p = get_pos 1 1;
1049 val (Form f, tac, asms) = pt_extract (pt, p);
1050 if UnparseC.term f = "[x = 1]" andalso p = ([], Res) andalso map UnparseC.term asms = [] then ()
1051 else error "FE-interface.sml: diff.behav. in from pbl -hierarchy 1";
1054 "--------- solve_linear as in an algebra system (CAS)----";
1055 "--------- solve_linear as in an algebra system (CAS)----";
1056 "--------- solve_linear as in an algebra system (CAS)----";
1057 (*WN120210?not ME:\label{UC:cas-input} UC 30.1.2.5 p.168*)
1059 val (fmz, sp) = ([], ("", [], []));
1060 CalcTree [(fmz, sp)];
1061 Iterator 1; moveActiveRoot 1;
1062 modifyCalcHead 1 (([],Pbl),"solveTest (1+-1*2+x=0,x)", [], Pbl, ("", [], []));
1063 autoCalculate 1 CompleteCalc;
1064 refFormula 1 (get_pos 1 1);
1065 val ((pt,_),_) = get_calc 1;
1066 val p = get_pos 1 1;
1067 val (Form f, tac, asms) = pt_extract (pt, p);
1068 if UnparseC.term f = "[x = 1]" andalso p = ([], Res) andalso map UnparseC.term asms = [] then ()
1069 else error "FE-interface.sml: diff.behav. in from pbl -hierarchy 2";
1072 "--------- interSteps: on 'miniscript with mini-subpbl' -";
1073 "--------- interSteps: on 'miniscript with mini-subpbl' -";
1074 "--------- interSteps: on 'miniscript with mini-subpbl' -";
1075 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
1076 ("Test", ["sqroot-test","univariate","equation","test"],
1077 ["Test","squ-equ-test-subpbl1"]))];
1080 autoCalculate 1 CompleteCalc;
1081 val ((pt,_),_) = get_calc 1;
1084 (*UC\label{UC:inter-steps} UC 30.3.5.5 p.178*)
1085 interSteps 1 ([2],Res);
1086 val ((pt,_),_) = get_calc 1; show_pt pt (*new ([2,1],Frm)..([2,6],Res)*);
1087 val (unc, del, gen) = (([1],Res),([1],Res),([2,6],Res));
1088 getFormulaeFromTo 1 unc gen 1 false;
1090 (*UC\label{UC:inter-steps} UC 30.3.5.5 p.178*)
1091 interSteps 1 ([3,2],Res);
1092 val ((pt,_),_) = get_calc 1; show_pt pt (*new ([3,2,1],Frm)..([3,2,2],Res)*);
1093 val (unc, del, gen) = (([3,1],Res),([3,1],Res),([3,2,2],Res));
1094 getFormulaeFromTo 1 unc gen 1 false;
1096 (*UC\label{UC:inter-steps} UC 30.3.5.5 p.178*)
1097 interSteps 1 ([3],Res) (*no new steps in subproblems*);
1098 val (unc, del, gen) = (([3],Pbl),([3],Pbl),([3,2],Res));
1099 getFormulaeFromTo 1 unc gen 1 false;
1101 (*UC\label{UC:inter-steps} UC 30.3.5.5 p.178*)
1102 interSteps 1 ([],Res) (*no new steps in subproblems*);
1103 val (unc, del, gen) = (([],Pbl),([],Pbl),([4],Res));
1104 getFormulaeFromTo 1 unc gen 1 false;
1107 "--------- getTactic, fetchApplicableTactics ------------";
1108 "--------- getTactic, fetchApplicableTactics ------------";
1109 "--------- getTactic, fetchApplicableTactics ------------";
1110 (* compare test/../script.sml
1111 "----------- fun from_prog ---------------------------------------";
1113 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
1114 ("Test", ["sqroot-test","univariate","equation","test"],
1115 ["Test","squ-equ-test-subpbl1"]))];
1116 Iterator 1; moveActiveRoot 1;
1117 autoCalculate 1 CompleteCalc;
1118 val ((pt,_),_) = get_calc 1;
1121 (*UC\label{SOLVE:HIDE:getTactic} \label{SOLVE:AUTO:tactic} UC 30.3.3.1 p.176
1122 WN120210 not impl. in FE*)
1123 getTactic 1 ([],Pbl);
1124 getTactic 1 ([1],Res);
1125 getTactic 1 ([3],Pbl);
1126 getTactic 1 ([3,1],Frm);
1127 getTactic 1 ([3],Res);
1128 getTactic 1 ([],Res);
1130 (*UC\label{SOLVE:MANUAL:TACTIC:listall} UC 30.3.2.2 p.175*)
1131 fetchApplicableTactics 1 99999 ([],Pbl);
1132 fetchApplicableTactics 1 99999 ([1],Res);
1133 fetchApplicableTactics 1 99999 ([3],Pbl);
1134 fetchApplicableTactics 1 99999 ([3,1],Res);
1135 fetchApplicableTactics 1 99999 ([3],Res);
1136 fetchApplicableTactics 1 99999 ([],Res);
1139 "--------- getAssumptions, getAccumulatedAsms -----------";
1140 "--------- getAssumptions, getAccumulatedAsms -----------";
1141 "--------- getAssumptions, getAccumulatedAsms -----------";
1143 [(["equality (x/(x^2 - 6*x+9) - 1/(x^2 - 3*x) =1/x)",
1144 "solveFor x","solutions L"],
1145 ("RatEq",["univariate","equation"],["no_met"]))];
1146 Iterator 1; moveActiveRoot 1;
1147 autoCalculate 1 CompleteCalc;
1148 val ((pt,_),_) = get_calc 1;
1149 val p = get_pos 1 1;
1150 val (Form f, tac, asms) = pt_extract (pt, p);
1151 (*============ inhibit exn WN120316 compare 2002--2011 ===========================
1152 if map UnparseC.term asms =
1153 ["True |\n~ lhs ((3 + -1 * x + x ^^^ 2) * x =\n" ^
1154 " 1 * (9 * x + -6 * x ^^^ 2 + x ^^^ 3)) is_poly_in x", "-6 * x + 5 * x ^^^ 2 = 0",
1155 "lhs (-6 * x + 5 * x ^^^ 2 = 0) is_poly_in x",
1156 "lhs (-6 * x + 5 * x ^^^ 2 = 0) has_degree_in x = 2",
1157 "9 * x + -6 * x ^^^ 2 + x ^^^ 3 ~= 0"]
1158 andalso UnparseC.term f = "[-6 * x + 5 * x ^^^ 2 = 0]" andalso p = ([], Res) then ()
1159 else error "TODO compare 2002--2011"; (*...data during test --- x / (x ^ 2 - 6 * x + 9) - 1...*)
1160 ============ inhibit exn WN120316 compare 2002--2011 ===========================*)
1162 if p = ([], Res) andalso UnparseC.term f = "[x = 6 / 5]"
1163 andalso map UnparseC.term asms = []
1164 then () else error "rlang.sml: diff.behav. in Schalk I s.87 Bsp 55b [x = 6 / 5]";
1166 (*UC\label{SOLVE:HELP:assumptions} UC 30.3.5.1 p.178*)
1167 getAssumptions 1 ([3], Res);
1168 getAssumptions 1 ([5], Res);
1169 (*UC\label{SOLVE:HELP:assumptions-origin} UC 30.3.5.2 p.178
1170 WN0502 still without positions*)
1171 getAccumulatedAsms 1 ([3], Res);
1172 getAccumulatedAsms 1 ([5], Res);
1175 "--------- arbitrary combinations of steps --------------";
1176 "--------- arbitrary combinations of steps --------------";
1177 "--------- arbitrary combinations of steps --------------";
1178 CalcTree (*start of calculation, return No.1*)
1179 [(["equality (1+-1*2+x=(0::real))", "solveFor x","solutions L"],
1181 ["LINEAR","univariate","equation","test"],
1182 ["Test","solve_linear"]))];
1183 Iterator 1; moveActiveRoot 1;
1185 fetchProposedTactic 1;
1186 (*ERROR get_calc 1 not existent*)
1187 setNextTactic 1 (Model_Problem );
1188 autoCalculate 1 (Steps 1);
1189 fetchProposedTactic 1;
1190 fetchProposedTactic 1;
1192 setNextTactic 1 (Add_Find "solutions L");
1193 setNextTactic 1 (Add_Find "solutions L");
1195 autoCalculate 1 (Steps 1);
1196 autoCalculate 1 (Steps 1);
1198 setNextTactic 1 (Specify_Theory "Test");
1199 fetchProposedTactic 1;
1200 autoCalculate 1 (Steps 1);
1202 autoCalculate 1 (Steps 1);
1203 autoCalculate 1 (Steps 1);
1204 autoCalculate 1 (Steps 1);
1205 autoCalculate 1 (Steps 1);
1206 (*------------------------- end calc-head*)
1208 fetchProposedTactic 1;
1209 setNextTactic 1 (Rewrite_Set_Inst (["(''bdv'',x)"], "isolate_bdv"));
1210 autoCalculate 1 (Steps 1);
1212 setNextTactic 1 (Rewrite_Set "Test_simplify");
1213 fetchProposedTactic 1;
1214 autoCalculate 1 (Steps 1);
1216 autoCalculate 1 CompleteCalc;
1217 val ((pt,_),_) = get_calc 1;
1218 val p = get_pos 1 1;
1219 val (Form f, tac, asms) = pt_extract (pt, p);
1220 if UnparseC.term f = "[x = 1]" andalso p = ([], Res) then () else
1221 error "FE-interface.sml: diff.behav. in combinations of steps";
1224 "--------- appendF label{SOLVE:MANUAL:FORMULA:enter}right"; (*UC 30.3.2.4 p.175*)
1225 "--------- appendF label{SOLVE:MANUAL:FORMULA:enter}right";
1226 "--------- appendF label{SOLVE:MANUAL:FORMULA:enter}right";
1227 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
1228 ("Test", ["sqroot-test","univariate","equation","test"],
1229 ["Test","squ-equ-test-subpbl1"]))];
1232 autoCalculate 1 CompleteCalcHead;
1233 autoCalculate 1 (Steps 1);
1234 autoCalculate 1 (Steps 1);
1235 appendFormula 1 "-1 + x = 0" (*|> Future.join*);
1236 (*... returns calcChangedEvent with*)
1237 val (unc, del, gen) = (([1],Res), ([1],Res), ([2],Res));
1238 getFormulaeFromTo 1 unc gen 99999 (*all levels*) false;
1240 val ((pt,_),_) = get_calc 1;
1241 val p = get_pos 1 1;
1242 val (Form f, tac, asms) = pt_extract (pt, p);
1243 if UnparseC.term f = "-1 + x = 0" andalso p = ([2], Res) then () else
1244 error "FE-interface.sml: diff.behav. in FORMULA:enter} right";
1247 "--------- appendF label{SOLVE:MANUAL:FORMULA:enter}other"; (*UC 30.3.2.4 p.175*)
1248 "--------- appendF label{SOLVE:MANUAL:FORMULA:enter}other";
1249 "--------- appendF label{SOLVE:MANUAL:FORMULA:enter}other";
1250 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
1251 ("Test", ["sqroot-test","univariate","equation","test"],
1252 ["Test","squ-equ-test-subpbl1"]))];
1255 autoCalculate 1 CompleteCalcHead;
1256 autoCalculate 1 (Steps 1);
1257 autoCalculate 1 (Steps 1);
1258 appendFormula 1 "x - 1 = 0" (*|> Future.join*);
1259 val (unc, del, gen) = (([1],Res), ([1],Res), ([2],Res));
1260 getFormulaeFromTo 1 unc gen 99999 (*all levels*) false;
1263 val ((pt,_),_) = get_calc 1;
1264 val p = get_pos 1 1;
1265 val (Form f, tac, asms) = pt_extract (pt, p);
1266 if UnparseC.term f = "x - 1 = 0" andalso p = ([2], Res) then () else
1267 error "FE-interface.sml: diff.behav. in FORMULA:enter} other";
1270 "--------- appendF label{SOLVE:MANUAL:FORMULA:enter}oth 2"; (*UC 30.3.2.4 p.175*)
1271 "--------- appendF label{SOLVE:MANUAL:FORMULA:enter}oth 2";
1272 "--------- appendF label{SOLVE:MANUAL:FORMULA:enter}oth 2";
1273 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
1274 ("Test", ["sqroot-test","univariate","equation","test"],
1275 ["Test","squ-equ-test-subpbl1"]))];
1278 autoCalculate 1 CompleteCalcHead;
1279 autoCalculate 1 (Steps 1);
1280 autoCalculate 1 (Steps 1);
1281 appendFormula 1 "x = 1" (*|> Future.join*);
1282 (*... returns calcChangedEvent with*)
1283 val (unc, del, gen) = (([1],Res), ([1],Res), ([3,2],Res));
1284 getFormulaeFromTo 1 unc gen 99999 (*all levels*) false;
1287 val ((pt,_),_) = get_calc 1;
1288 val p = get_pos 1 1;
1289 val (Form f, tac, asms) = pt_extract (pt, p);
1290 if UnparseC.term f = "x = 1" andalso p = ([3,2], Res) then () else
1291 error "FE-interface.sml: diff.behav. in FORMULA:enter} oth 2";
1294 "--------- appendF label{SOLVE:MANUAL:FORMULA:enter}NOTok"; (*UC 30.3.2.4 p.175*)
1295 "--------- appendF label{SOLVE:MANUAL:FORMULA:enter}NOTok";
1296 "--------- appendF label{SOLVE:MANUAL:FORMULA:enter}NOTok";
1297 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
1298 ("Test", ["sqroot-test","univariate","equation","test"],
1299 ["Test","squ-equ-test-subpbl1"]))];
1302 autoCalculate 1 CompleteCalcHead;
1303 autoCalculate 1 (Steps 1);
1304 autoCalculate 1 (Steps 1);
1305 appendFormula 1 "x - 4711 = 0" (*|> Future.join*);
1306 (*... returns <ERROR> no derivation found </ERROR>*)
1308 val ((pt,_),_) = get_calc 1;
1309 val p = get_pos 1 1;
1310 val (Form f, tac, asms) = pt_extract (pt, p);
1311 if UnparseC.term f = "x + 1 + -1 * 2 = 0" andalso p = ([1], Res) then () else
1312 error "FE-interface.sml: diff.behav. in FORMULA:enter} NOTok";
1315 "--------- replaceFormula {SOL:MAN:FOR:replace} right----"; (*UC 30.3.2.5 p.176*)
1316 "--------- replaceFormula {SOL:MAN:FOR:replace} right----";
1317 "--------- replaceFormula {SOL:MAN:FOR:replace} right----";
1318 (*\label{SOLVE:MANUAL:FORMULA:replace}*)
1319 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
1320 ("Test", ["sqroot-test","univariate","equation","test"],
1321 ["Test","squ-equ-test-subpbl1"]))];
1324 autoCalculate 1 CompleteCalc;
1325 moveActiveFormula 1 ([2],Res);
1326 replaceFormula 1 "-1 + x = 0" (*i.e. repeats input*);
1327 (*... returns <ERROR> formula not changed </ERROR>*)
1329 val ((pt,_),_) = get_calc 1;
1330 val p = get_pos 1 1;
1331 val (Form f, tac, asms) = pt_extract (pt, p);
1332 if UnparseC.term f = "-1 + x = 0" andalso p = ([2], Res) then () else
1333 error "FE-interface.sml: diff.behav. in FORMULA:replace} right 1";
1334 if map fst3 (get_interval ([2],Res) ([],Res) 9999 pt) =
1335 [([2], Res), ([3], Pbl), ([3, 1], Frm), ([3, 1], Res), ([3, 2], Res),
1336 ([3], Res), ([4], Res), ([], Res)] then () (*nothing deleted!*) else
1337 error "FE-interface.sml: diff.behav. in FORMULA:replace} right 2";
1339 (*WN050211 replaceFormula didn't work on second ctree: thus now tested...*)
1340 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
1341 ("Test", ["sqroot-test","univariate","equation","test"],
1342 ["Test","squ-equ-test-subpbl1"]))];
1345 autoCalculate 2 CompleteCalc;
1346 moveActiveFormula 2 ([2],Res);
1347 replaceFormula 2 "-1 + x = 0" (*i.e. repeats input*);
1348 (*... returns <ERROR> formula not changed </ERROR>*)
1350 val ((pt,_),_) = get_calc 2;
1351 val p = get_pos 2 1;
1352 val (Form f, tac, asms) = pt_extract (pt, p);
1353 if UnparseC.term f = "-1 + x = 0" andalso p = ([2], Res) then () else
1354 error "FE-interface.sml: diff.behav. in FORMULA:replace} right 1";
1355 if map fst3 (get_interval ([2],Res) ([],Res) 9999 pt) =
1356 [([2], Res), ([3], Pbl), ([3, 1], Frm), ([3, 1], Res), ([3, 2], Res),
1357 ([3], Res), ([4], Res), ([], Res)] then () (*nothing deleted!*) else
1358 error "FE-interface.sml: diff.behav. in FORMULA:replace} right 2b";
1361 "--------- replaceFormula {SOL:MAN:FOR:replace} other----"; (*UC 30.3.2.5 p.176*)
1362 "--------- replaceFormula {SOL:MAN:FOR:replace} other----";
1363 "--------- replaceFormula {SOL:MAN:FOR:replace} other----";
1364 (*\label{SOLVE:MANUAL:FORMULA:replace}*)
1365 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
1366 ("Test", ["sqroot-test","univariate","equation","test"],
1367 ["Test","squ-equ-test-subpbl1"]))];
1370 autoCalculate 1 CompleteCalc;
1371 moveActiveFormula 1 ([2],Res); (*there is "-1 + x = 0"*)
1372 replaceFormula 1 "x - 1 = 0"; (*<-------------------------------------*)
1373 (*... returns calcChangedEvent with*)
1374 val (unc, del, gen) = (([1],Res), ([4],Res), ([2],Res));
1375 getFormulaeFromTo 1 unc gen 99999 (*all levels*) false;
1377 val ((pt,_),_) = get_calc 1;
1379 val p = get_pos 1 1;
1380 val (Form f, tac, asms) = pt_extract (pt, p);
1381 if UnparseC.term f = "x - 1 = 0" andalso p = ([2], Res) then () else
1382 error "FE-interface.sml: diff.behav. in FORMULA:replace} other 1";
1383 (* for getting the list in whole length ...
1384 (*default_print_depth 99*) map fst3 (get_interval ([1],Res) ([],Res) 9999 pt); (*default_print_depth 3*)
1386 if map fst3 (get_interval ([1],Res) ([],Res) 9999 pt) =
1387 [([1], Res), ([2, 1], Frm), ([2, 1], Res), ([2, 2], Res), ([2, 3], Res),
1388 ([2, 4], Res), ([2, 5], Res), ([2, 6], Res), ([2, 7], Res),
1389 ([2, 8], Res), ([2, 9], Res), ([2], Res)] then () else
1390 error "FE-interface.sml: diff.behav. in FORMULA:replace} other 2";
1393 "--------- replaceFormula {SOL:MAN:FOR:replace} other 2--"; (*UC 30.3.2.5 p.176*)
1394 "--------- replaceFormula {SOL:MAN:FOR:replace} other 2--";
1395 "--------- replaceFormula {SOL:MAN:FOR:replace} other 2--";
1396 (*\label{SOLVE:MANUAL:FORMULA:replace}*)
1397 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
1398 ("Test", ["sqroot-test","univariate","equation","test"],
1399 ["Test","squ-equ-test-subpbl1"]))];
1402 autoCalculate 1 CompleteCalc;
1403 moveActiveFormula 1 ([2],Res); (*there is "-1 + x = 0"*)
1404 replaceFormula 1 "x = 1"; (*<-------------------------------------*)
1405 (*... returns calcChangedEvent with ...*)
1406 val (unc, del, gen) = (([1],Res), ([4],Res), ([3,2],Res));
1407 getFormulaeFromTo 1 unc gen 99999 (*all levels*) false;
1410 val ((pt,_),_) = get_calc 1;
1411 show_pt pt; (*error: ...get_interval drops ([3,2],Res) ...*)
1412 val (t,_) = get_obj g_result pt [3,2]; UnparseC.term t;
1413 if map fst3 (get_interval ([1],Res) ([],Res) 9999 pt) =
1414 [([1], Res), ([2], Res), ([3], Pbl), ([3, 1], Frm), ([3, 1], Res),
1415 ([3, 2, 1], Frm), ([3, 2, 1], Res), ([3, 2, 2], Res),
1416 ([3,2],Res)] then () else
1417 error "FE-interface.sml: diff.behav. in FORMULA:replace} oth2 1";
1419 val p = get_pos 1 1;
1420 val (Form f, tac, asms) = pt_extract (pt, p);
1421 if UnparseC.term f = "x = 1" andalso p = ([3,2], Res) then () else
1422 error "FE-interface.sml: diff.behav. in FORMULA:replace} oth2 2";
1425 "--------- replaceFormula {SOL:MAN:FOR:replace} NOTok----"; (*UC 30.3.2.5 p.176*)
1426 "--------- replaceFormula {SOL:MAN:FOR:replace} NOTok----";
1427 "--------- replaceFormula {SOL:MAN:FOR:replace} NOTok----";
1428 (*\label{SOLVE:MANUAL:FORMULA:replace}*)
1429 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
1430 ("Test", ["sqroot-test","univariate","equation","test"],
1431 ["Test","squ-equ-test-subpbl1"]))];
1434 autoCalculate 1 CompleteCalc;
1435 moveActiveFormula 1 ([2],Res); (*there is "-1 + x = 0"*)
1436 replaceFormula 1 "x - 4711 = 0";
1437 (*... returns <ERROR> no derivation found </ERROR>*)
1439 val ((pt,_),_) = get_calc 1;
1441 val p = get_pos 1 1;
1442 val (Form f, tac, asms) = pt_extract (pt, p);
1443 if UnparseC.term f = "-1 + x = 0" andalso p = ([2], Res) then () else
1444 error "FE-interface.sml: diff.behav. in FORMULA:replace} NOTok";
1447 "--------- UC errpat chain-rule-diff-both, fillpat by input ------";
1448 "--------- UC errpat chain-rule-diff-both, fillpat by input ------";
1449 "--------- UC errpat chain-rule-diff-both, fillpat by input ------";
1451 [(["functionTerm (x ^ 2 + sin (x ^ 4))", "differentiateFor x", "derivative f_f'"],
1452 ("Isac_Knowledge", ["derivative_of","function"], ["diff","differentiate_on_R"]))];
1455 autoCalculate 1 CompleteCalcHead;
1456 autoCalculate 1 (Steps 1);
1457 autoCalculate 1 (Steps 1);(*([1], Res), d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))*)
1458 appendFormula 1 "d_d x (x ^ 2) + cos (4 * x ^ 3)" (*|> Future.join*); (*<<<<<<<=========================*)
1459 (* the check for errpat is maximally liberal (whole term modulo "nrls" from "type met"),
1460 would recognize "cos (4 * x ^ (4 - 1)) + 2 * x" as well.
1461 results in <CALCMESSAGE> error pattern #chain-rule-diff-both# </CALCMESSAGE>
1462 instead of <CALCMESSAGE> no derivation found </CALCMESSAGE> *)
1463 val ((pt,pos), _) = get_calc 1;
1464 val p = get_pos 1 1;
1465 val (Form f, _, asms) = pt_extract (pt, p);
1467 if p = ([1], Res) andalso UnparseC.term f = "d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))"
1468 then case get_obj g_tac pt (fst p) of Rewrite_Inst (["(''bdv'', x)"],
1469 ("diff_sum", thm)) => () | _ => error "embed fun get_fillform changed 0"
1470 | _ => error "embed fun get_fillform changed 1"
1471 else error "embed fun get_fillform changed 2";
1473 (*========== inhibit exn WN1130621 Isabelle2012-->13 !thehier! ====================
1474 findFillpatterns 1 "chain-rule-diff-both"; (*<<<<<<<=================================*)
1475 (*<CALCMESSAGE> fill patterns #fill-d_d-arg#d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4)) =
1476 d_d x (x ^^^ 2) + cos (x ^^^ 4) * d_d x ?_dummy_1#fill-both-args#...#...#... *)
1477 val ((pt,pos),_) = get_calc 1;
1478 val p = get_pos 1 1;
1480 val (Form f, _, asms) = pt_extract (pt, p);
1481 if p = ([1], Res) andalso UnparseC.term f = "d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))" andalso
1482 get_obj g_tac pt (fst p) = Rewrite_Inst (["(''bdv'', x)"], ("diff_sum", "Diff.diff_sum"(*?!?*)))
1484 else error "embed fun get_fillform changed 2";
1486 (* if we assume, that the fill-patterns are ordered such that the 1st has large gaps
1487 and the last has no gaps, then the number of fill-patterns would suffice
1488 for the DialogGuide to select appropriately. *)
1489 requestFillformula 1 ("chain-rule-diff-both", "fill-both-args");(*<<<<<<<============*)
1490 (*<AUTOCALC> ([1], Res) ([2], Res) ([2], Res) </AUTOCALC>*)
1491 val ((pt,pos),_) = get_calc 1;
1492 val p = get_pos 1 1;
1493 val (Form f, _, asms) = pt_extract (pt, p);
1494 if p = ([1], Res) andalso existpt [2] pt andalso
1495 UnparseC.term f = "d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))" andalso
1496 get_obj g_tac pt (fst p) = Rewrite_Inst (["(''bdv'', x)"], ("diff_sum", "Diff.diff_sum"))
1497 then () else error "embed fun get_fillform changed 3";
1499 inputFillFormula 1 "d_d x (x ^^^ 2) + cos (x ^^^ 4) * d_d x (x ^^^ 4)";(*<<<<<<<=====*)
1500 val ((pt, _),_) = get_calc 1;
1501 val p = get_pos 1 1;
1502 val (Form f, _, asms) = pt_extract (pt, p);
1503 if p = ([2], Res) andalso
1504 UnparseC.term f = "d_d x (x ^^^ 2) + cos (x ^^^ 4) * d_d x (x ^^^ 4)" andalso
1505 get_obj g_tac pt (fst p) = Rewrite_Inst (["(''bdv'', x)"], ("diff_sin_chain", ""))
1506 then () else error "inputFillFormula changed 11";
1508 autoCalculate 1 CompleteCalc;
1510 "~~~~~ final check: the input formula is inserted as it would have been correct from beginning";
1511 val ((pt, _),_) = get_calc 1;
1512 val p = get_pos 1 1;
1513 val (Form f, _, asms) = pt_extract (pt, p);
1514 if p = ([], Res) andalso UnparseC.term f = "2 * x + cos (x ^^^ 4) * 4 * x ^^^ 3"
1515 then () else error "inputFillFormula changed 12";
1518 (([], Frm), Diff (x ^^^ 2 + sin (x ^^^ 4), x)),
1519 (([1], Frm), d_d x (x ^^^ 2 + sin (x ^^^ 4))),
1520 (([1], Res), d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))),
1521 (([2], Res), d_d x (x ^^^ 2) + cos (x ^^^ 4) * d_d x (x ^^^ 4)), (*<<<<<<<=====*)
1522 (([3], Res), d_d x (x ^^^ 2) + cos (x ^^^ 4) * (4 * x ^^^ (4 - 1))),
1523 (([4], Res), 2 * x ^^^ (2 - 1) + cos (x ^^^ 4) * (4 * x ^^^ (4 - 1))),
1524 (([5], Res), 2 * x + cos (x ^^^ 4) * 4 * x ^^^ 3),
1525 (([], Res), 2 * x + cos (x ^^^ 4) * 4 * x ^^^ 3)] *)
1526 ============ inhibit exn WN1130621 Isabelle2012-->13 !thehier! ==================*)
1529 "--------- UC errpat add-fraction, fillpat by input --------------";
1530 "--------- UC errpat add-fraction, fillpat by input --------------";
1531 "--------- UC errpat add-fraction, fillpat by input --------------";
1532 (*cp from BridgeLog Java <=> SML*)
1533 CalcTree [([], ("e_domID", ["e_pblID"], ["e_metID"]))];
1536 moveActiveFormula 1 ([],Pbl);
1537 replaceFormula 1 "Simplify (5 * x / (4 * y) + 3 * x / (4 * y))";
1538 autoCalculate 1 CompleteCalcHead;
1539 autoCalculate 1 (Steps 1);
1540 appendFormula 1 "8 * x / (8 * y)" (*|> Future.join*);
1541 (*<CALCMESSAGE> no derivation found </CALCMESSAGE>
1542 --- but in BridgeLog Java <=> SML:
1543 <CALCMESSAGE> error pattern #addition-of-fractions# </CALCMESSAGE>*)
1546 "--------- UC errpat, fillpat step to Rewrite --------------------";
1547 "--------- UC errpat, fillpat step to Rewrite --------------------";
1548 "--------- UC errpat, fillpat step to Rewrite --------------------";
1551 [(["functionTerm ((x ^ 2) ^ 3 + sin (x ^ 4))",
1552 "differentiateFor x", "derivative f_f'"],
1553 ("Isac_Knowledge", ["derivative_of","function"],
1554 ["diff","differentiate_on_R"]))]; (*<<<======= EP is directly in script*)
1557 autoCalculate 1 CompleteCalc;
1558 val ((pt,p),_) = get_calc 1; show_pt pt;
1561 "--------- UC errpat, fillpat step to Rewrite_Set ----------------";
1562 "--------- UC errpat, fillpat step to Rewrite_Set ----------------";
1563 "--------- UC errpat, fillpat step to Rewrite_Set ----------------";
1565 [(["functionTerm ((x ^ 2) ^ 3 + sin (x ^ 4))",
1566 "differentiateFor x", "derivative f_f'"],
1567 ("Isac_Knowledge", ["derivative_of","function"],
1568 ["diff","after_simplification"]))]; (*<<<======= EP is in a ruleset*)
1571 autoCalculate 1 CompleteCalcHead;
1572 autoCalculate 1 (Steps 1); fetchProposedTactic 1;
1573 autoCalculate 1 (Steps 1); fetchProposedTactic 1;
1576 <CALCID> 1 </CALCID>
1577 <TACTICERRORPATTERNS>
1579 <STRING> chain-rule-diff-both </STRING>
1580 <STRING> cancel </STRING>
1582 <REWRITESETINSTTACTIC name="Rewrite_Set_Inst">
1583 <RULESET> norm_diff </RULESET>
1598 </REWRITESETINSTTACTIC>
1599 </TACTICERRORPATTERNS>
1603 (*WN1208 postponed due to efforts required for stepToErrorPatterns (NEW rewrite_set_)*)
1604 stepToErrorPatterns 1; (*--> calcChanged, rule immediately calls... *)
1605 stepOnErrorPatterns 1; (*--> calcChanged, rule calls getTactic and displays it *)
1606 (* then --- UC errpat, fillpat by input ---*)
1608 autoCalculate 1 CompleteCalc;
1609 val ((pt,p),_) = get_calc 1; show_pt pt;
1610 (*WN1208 postponed due to efforts required for stepToErrorPatterns (NEW rewrite_set_)*)