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 Tests the interface of isac's SML-kernel in accordance to java-tests/isac.bridge.
7 Some tests are outcommented since "eliminate ThmC.numerals_to_Free";
8 these are considered irrelevant for Isabelle/Isac.
10 WN050707 ... if true, the test ist marked with a \label referring
11 to the same UC in isac-docu.tex as the JUnit testcase.
12 WN120210?not ME: added some labels, which are not among the above,
13 repaired lost \label (s).
15 theory Test_Some imports Isac.Build_Thydata begin
16 ML {* KEStore_Elems.set_ref_thy @{theory};
17 fun autoCalculate' cI auto = autoCalculate cI auto (*|> Future.join*) *}
18 ML_file "Frontend/use-cases.sml"
21 "--------------------------------------------------------";
22 "table of contents --------------------------------------";
23 "--------------------------------------------------------";
24 "within struct ------------------------------------------";
25 "--------------------------------------------------------";
26 "--------- encode ^ -> ^^ ------------------------------";
27 "--------------------------------------------------------";
28 "exported from struct -----------------------------------";
29 "--------------------------------------------------------";
30 "--------- empty rootpbl --------------------------------";
31 "--------- solve_linear as rootpbl FE -------------------";
32 "--------- inspect the CalcTree No.1 with Iterator No.2 -";
33 "--------- miniscript with mini-subpbl ------------------";
34 "--------- mini-subpbl AUTOCALCULATE Steps 1 ------------";
35 "--------- solve_linear as rootpbl AUTO CompleteCalc ----";
36 "--------- solve_linear as rootpbl AUTO CompleteHead/Eval ";
37 "--------- mini-subpbl AUTOCALCULATE CompleteCalc -------";
38 "--------- mini-subpbl AUTO CompleteCalcHead ------------";
39 "--------- solve_linear as rootpbl AUTO CompleteModel ---";
40 "--------- setContext..Thy ------------------------------";
41 "--------- mini-subpbl AUTOCALC CompleteToSubpbl --------";
42 "--------- rat-eq + subpbl: no_met, NO solution dropped - WITH fun me IN test/../solve.sml";
43 "--------- tryMatchProblem, tryRefineProblem ------------";
44 "--------- modifyCalcHead, resetCalcHead, modelProblem --";
45 "--------- maximum-example, UC: Modeling an example -----";
46 "--------- solve_linear from pbl-hierarchy --------------";
47 "--------- solve_linear as in an algebra system (CAS)----";
48 "--------- interSteps: on 'miniscript with mini-subpbl' -";
49 "--------- getTactic, fetchApplicableTactics ------------";
50 "--------- getAssumptions, getAccumulatedAsms -----------";
51 "--------- arbitrary combinations of steps --------------";
52 "--------- appendF label{SOLVE:MANUAL:FORMULA:enter}right";
53 "--------- appendF label{SOLVE:MANUAL:FORMULA:enter}other";
54 "--------- appendF label{SOLVE:MANUAL:FORMULA:enter}oth 2";
55 "--------- appendF label{SOLVE:MANUAL:FORMULA:enter}NOTok";
56 "--------- replaceFormula {SOL:MAN:FOR:replace} right----";
57 "--------- replaceFormula {SOL:MAN:FOR:replace} other----";
58 "--------- replaceFormula {SOL:MAN:FOR:replace} other 2--";
59 "--------- replaceFormula {SOL:MAN:FOR:replace} NOTok----";
60 "--------- UC errpat chain-rule-diff-both, fillpat by input ------";
61 "--------- UC errpat add-fraction, fillpat by input --------------";
62 "--------- UC errpat, fillpat step to Rewrite --------------------";
63 "--------- UC errpat, fillpat step to Rewrite_Set ----------------";
64 "--------------------------------------------------------";
66 "within struct ---------------------------------------------------";
67 "within struct ---------------------------------------------------";
68 "within struct ---------------------------------------------------";
69 (*==================================================================
71 ==================================================================*)
72 "exported from struct --------------------------------------------";
73 "exported from struct --------------------------------------------";
74 "exported from struct --------------------------------------------";
77 (*------------ set at startup of the Kernel ----------------------*)
78 reset_states (); (*resets all state information in Kernel *)
79 (*----------------------------------------------------------------*)
81 "--------- empty rootpbl --------------------------------";
82 "--------- empty rootpbl --------------------------------";
83 "--------- empty rootpbl --------------------------------";
84 CalcTree [([], ("", [], []))];
87 refFormula 1 (get_pos 1 1);
88 (*WN.040222: stoert das sehr, dass ThyC.id_empty etc. statt leer kommt ???*)
91 "--------- solve_linear as rootpbl FE -------------------";
92 "--------- solve_linear as rootpbl FE -------------------";
93 "--------- solve_linear as rootpbl FE -------------------";
96 CalcTree (*start of calculation, return No.1*)
97 [(["equality (1+- 1*2+x=(0::real))", "solveFor x", "solutions L"],
99 ["LINEAR", "univariate", "equation", "test"],
100 ["Test", "solve_linear"]))];
101 Iterator 1; (*create an active Iterator on CalcTree No.1*)
103 moveActiveRoot 1;(*sets the CalcIterator No.1 at the root of CalcTree No.1*);
104 refFormula 1 (get_pos 1 1) (*gets CalcHead; model is still empty*);
107 (*1*) fetchProposedTactic 1 (*by using Iterator No.1*);
108 setNextTactic 1 (Model_Problem); (*by using Iterator No.1*)
109 autoCalculate 1 (Steps 1);
110 refFormula 1 (get_pos 1 1) (*model contains descriptions for all items*);
111 autoCalculate 1 (Steps 1);
112 (*-----since Model_Problem + complete_mod_ in case cas of SOME-----*
113 (*2*) fetchProposedTactic 1;
114 setNextTactic 1 (Add_Given "equality (1 + - 1 * 2 + x = 0)");
115 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1); (*equality added*);
117 (*3*) fetchProposedTactic 1;
118 setNextTactic 1 (Add_Given "solveFor x");
119 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
121 (*4*) fetchProposedTactic 1;
122 setNextTactic 1 (Add_Find "solutions L");
123 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
125 (*5*) fetchProposedTactic 1;
126 setNextTactic 1 (Specify_Theory "Test");
127 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
128 *-----since Model_Problem + complete_mod_ in case cas of SOME-----*)
130 (*6*) fetchProposedTactic 1;
131 setNextTactic 1 (Specify_Problem ["LINEAR", "univariate", "equation", "test"]);
132 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
133 (*-------------------------------------------------------------------------*)
134 (*7*) fetchProposedTactic 1;
135 val (ptp as (pt,p), tacis) = get_calc 1; get_pos 1 1;
137 setNextTactic 1 (Specify_Method ["Test", "solve_linear"]);
138 val (ptp as (pt,p), tacis) = get_calc 1; get_pos 1 1;
140 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
141 val (ptp as (pt,p), tacis) = get_calc 1; get_pos 1 1;
143 (*-------------------------------------------------------------------------*)
144 (*8*) fetchProposedTactic 1;
145 val (ptp as (pt,p), tacis) = get_calc 1; get_pos 1 1;
147 (*8*) setNextTactic 1 (Apply_Method ["Test", "solve_linear"]);
148 (*ERROR.110620 <SETNEXTTACTIC>..<MESSAGE> end-of-calculation*)
149 val (ptp as (pt,p), tacis) = get_calc 1; get_pos 1 1;
150 SpecificationC.is_complete ptp;
151 References.are_complete ptp;
153 (*8*) autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1); (*<---------------------- orig. test code*)
155 val (ptp as (pt,p), tacis) = get_calc 1; get_pos 1 1; (*<---------------------- orig. test code*)
156 (*+isa=REP*) if p = ([1], Frm) andalso UnparseC.term (get_obj g_form pt [1]) = "1 + - 1 * 2 + x = 0"
157 andalso Istate.string_of (get_istate_LI pt p)
158 = "Pstate ([\"\n(e_e, 1 + - 1 * 2 + x = 0)\", \"\n(v_v, x)\"], [], empty, NONE, \n??.empty, ORundef, false, true)"
159 then () else error "refFormula = 1 + - 1 * 2 + x = 0 changed";
160 (*-------------------------------------------------------------------------*)
162 (*9*) fetchProposedTactic 1; (*<----------------------------------------------------- orig. test code*)
163 (*+\\------------------------------------------ isa == REP -----------------------------------//* )
164 (*+//========================================== isa <> REP (1) ===============================\\*)
165 (*9*) setNextTactic 1 (Rewrite_Set_Inst (["(''bdv'',x)"], "isolate_bdv")); ( *<------- orig. test code*)
167 "~~~~~ fun setNextTactic , args:"; val (cI, tac) = (1, (Rewrite_Set_Inst (["(''bdv'',x)"], "isolate_bdv")));
168 val ((pt'''''_', _), _) = get_calc cI
169 val ip'''''_' = get_pos cI 1;
171 val xxxxx_x(*"ok", (tacis, _, _)*) = (*case*) Step.by_tactic tac (pt'''''_', ip'''''_') (*of*);
172 (*+isa+REP*)val ("ok", ( [ (Rewrite_Set_Inst (["(''bdv'', x)"], "isolate_bdv"),
173 Rewrite_Set_Inst' _, (pos', (istate, ctxt))) ] , _, cstate)) = xxxxx_x;
175 (*//******************* Step.by_tactic returns tac_ + istate + cstate *****************************\\*)
176 Step.by_tactic : Tactic.input -> state -> string * (State_Steps.T * pos' list * state);
177 if Istate.string_of istate
178 = "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)"
179 then () else error "from Step.by_tactic return --- changed 1";
181 if Istate.string_of (get_istate_LI (fst cstate) (snd cstate))
182 = "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)"
183 then () else error "from Step.by_tactic return --- changed 2";
184 (*\\******************* Step.by_tactic returns tac_ + istate + cstate *****************************//*)
186 "~~~~~ fun Step.by_tactic , args:"; val (tac, (ptp as (pt, p))) = (tac, (pt'''''_', ip'''''_'));
187 val Applicable.Yes m = (*case*) Step.check tac (pt, p) (*of*);
188 (*if*) Tactic.for_specify' m; (*false*)
190 Step_Solve.by_tactic m (pt, p);
191 "~~~~~ fun by_tactic , args:"; val (m, (pt, po as (p, p_))) = (m, (pt, p));
192 (*if*) MethodC.id_empty = get_obj g_metID pt (par_pblobj pt p); (*else*)
193 val thy' = get_obj g_domID pt (par_pblobj pt p);
194 val (is, sc) = LItool.resume_prog thy' (p,p_) pt;
195 val Safe_Step (istate, _, tac) =
196 (*case*) LI.locate_input_tactic sc (pt, po) (fst is) (snd is) m (*of*);
198 (*+*)Safe_Step: Istate.T * Proof.context * Tactic.T -> input_tactic_result;
199 (********************* locate_input_tactic returns cstate * istate * Proof.context *************)
200 (*+*)if Istate.string_of istate
201 (*+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)"
202 then case m of Rewrite_Set_Inst' _ => ()
203 else error "from locate_input_tactic return --- changed";
205 val ("ok", (tacis'''''_', _, _)) = xxxxx_x;
206 "~~~~~ from TOPLEVEL to states return:"; upd_calc cI ((pt'''''_', ip'''''_'), tacis'''''_');
207 (*\\=========================================== isa <> REP (1) ===============================//*)
208 (*//=========================================== isa <> REP (2) ===============================\\*)
209 (*9* ) autoCalculate 1 (Steps 1); (*<-------------------------------------------------- orig. test code*)
210 ( *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>*)
212 "~~~~~ fun autoCalculate , args:"; val (cI, auto) = (1, (Steps 1));
213 val pold = get_pos cI 1;
214 val xxx = (get_calc cI);
215 (*isa*) val (**)xxxx(**) (**) = (**)
216 (*case*) Math_Engine.autocalc [] pold (xxx) auto (*of*);
217 "~~~~~ fun autocalc , args:"; val (c, ip, cs, (Solve.Steps s)) = ([], pold, (xxx), auto);
218 (*if*) s <= 1; (*then*)
219 (*val (str, (_, c', ptp)) =*)
222 "~~~~~ fun do_next , args:"; val ((ip as (_, p_)), (ptp as (pt,p), tacis)) = (ip, cs);
224 (*+isa==REP*)val [(Rewrite_Set_Inst (["(''bdv'', x)"], "isolate_bdv"),
225 Rewrite_Set_Inst' _, (pos', (istate, ctxt)))] = tacis;
226 (*+*)if pos' = ([1], Res) andalso Istate.string_of istate
227 = "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)"
228 then () else error "init. step 1 + - 1 * 2 + x = 0 changed";
230 val pIopt = get_pblID (pt,ip);
231 (*if*) ip = ([], Pos.Res);(*else*)
232 val (_::_) = (*case*) tacis (*of*);
233 (*isa==REP*) (*if*) ip = p;(*then*)
234 (*val (pt',c',p') =*) Solve_Step.s_add_general tacis (pt,[],p);
235 (*//------------------------------------- final test -----------------------------------------\\*)
236 val ("ok", [], ptp as (pt, p)) = xxxx;
238 if Istate.string_of (get_istate_LI pt p) (* <> <> <> <> \<up> \<up> \<up> \<up> ^*)
239 (*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)"
240 then () else error "REP autoCalculate on (e_e, 1 + - 1 * 2 + x = 0) changed"
242 "~~~~~ from TOPLEVEL to states return:"; upd_calc cI (ptp, []); upd_ipos cI 1 p;
243 (*\\=========================================== isa <> REP (2) ===============================//*)
245 (*10*) fetchProposedTactic 1;
246 setNextTactic 1 (Rewrite_Set "Test_simplify");
247 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
249 (*11*) fetchProposedTactic 1;
250 setNextTactic 1 (Check_Postcond ["LINEAR", "univariate", "equation", "test"]);
251 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
253 (*======= final test ==================================================*)
254 val ((pt,_),_) = get_calc 1;
255 val ip = get_pos 1 1;
257 val (Form f, tac, asms) = ME_Misc.pt_extract (pt, ip);
258 (*exception just above means: 'ModSpec' has been returned: error anyway*)
259 if ip = ([], Res) andalso UnparseC.term f = "[x = 1]" then () else
260 error "FE-Kernel-interface.sml: diff.behav. in solve_linear as rootpbl";
263 "--------- inspect the CalcTree No.1 with Iterator No.2 -";
264 "--------- inspect the CalcTree No.1 with Iterator No.2 -";
265 "--------- inspect the CalcTree No.1 with Iterator No.2 -";
266 (*WN041118: inspection shifted to Iterator No.1, because others need pos'*)
267 (*-------- WN190723: doesnt work since changeset 59474 21d4d2868b83
269 refFormula 1 ([],Pbl); getTactic 1 ([],Pbl);(*Error*)
271 refFormula 1 ([1],Frm); getTactic 1 ([1],Frm);(*Error*)
273 refFormula 1 ([1],Res); getTactic 1 ([1],Res);(*OK*)
274 (*getAssumption 1 ([1],Res); TODO.WN041217*)
275 moveActiveDown 1 ; refFormula 1 ([2],Res);
276 moveActiveCalcHead 1; refFormula 1 ([],Pbl);
280 if get_pos 1 1 = ([2], Res) then () else
281 error "FE-interface.sml: diff.behav. in a inspect 1 with Iterator 2";
282 moveActiveDown 1; refFormula 1 ([], Res);
283 if get_pos 1 1 = ([], Res) then () else
284 error "FE-interface.sml: diff.behav. in b inspect 1 with Iterator 2";
285 moveActiveCalcHead 1; refFormula 1 ([],Pbl);
287 ------------------------------------------------------------------------------------------------*)
289 "--------- miniscript with mini-subpbl ------------------";
290 "--------- miniscript with mini-subpbl ------------------";
291 "--------- miniscript with mini-subpbl ------------------";
292 (*WN120210?not ME:\label{SOLVE:MANUAL:TACTIC:enter} UC 30.3.2.1 p.175 !!!!!NOT IMPL IN FE*)
293 "=== this sequence of fun-calls resembles fun me ===";
294 CalcTree [(["equality (x+1=(2::real))", "solveFor x", "solutions L"],
295 ("Test", ["sqroot-test", "univariate", "equation", "test"],
296 ["Test", "squ-equ-test-subpbl1"]))];
300 refFormula 1 (get_pos 1 1);
301 fetchProposedTactic 1;
302 setNextTactic 1 (Model_Problem);
303 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*gets ModSpec;model is still empty*)
305 fetchProposedTactic 1; (*<SYSERROR><CALCID>1</CALCID><ERROR>error in kernel 3</ERROR></SYSERROR>* )
306 setNextTactic 1 (Add_Given "equality (x + 1 = 2)");
307 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
309 fetchProposedTactic 1;
310 setNextTactic 1 (Add_Given "solveFor x");
311 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
313 fetchProposedTactic 1;
314 setNextTactic 1 (Add_Find "solutions L");
315 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
317 fetchProposedTactic 1;
318 setNextTactic 1 (Specify_Theory "Test");
319 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
321 fetchProposedTactic 1;
322 setNextTactic 1 (Specify_Problem
323 ["sqroot-test", "univariate", "equation", "test"]);
324 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
325 "1-----------------------------------------------------------------";
327 fetchProposedTactic 1;
328 setNextTactic 1 (Specify_Method ["Test", "squ-equ-test-subpbl1"]);
329 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
331 fetchProposedTactic 1;
332 setNextTactic 1 (Apply_Method ["Test", "squ-equ-test-subpbl1"]);
333 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
335 fetchProposedTactic 1;
336 setNextTactic 1 (Rewrite_Set "norm_equation");
337 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
339 fetchProposedTactic 1;
340 setNextTactic 1 (Rewrite_Set "Test_simplify");
341 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
343 fetchProposedTactic 1;(*----------------Subproblem--------------------*);
344 setNextTactic 1 (Subproblem ("Test",
345 ["LINEAR", "univariate", "equation", "test"]));
346 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
348 fetchProposedTactic 1;
349 setNextTactic 1 (Model_Problem );
350 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
352 fetchProposedTactic 1;
353 setNextTactic 1 (Add_Given "equality (- 1 + x = 0)");
354 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
356 fetchProposedTactic 1;
357 setNextTactic 1 (Add_Given "solveFor x");
358 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
360 fetchProposedTactic 1;
361 setNextTactic 1 (Add_Find "solutions x_i");
362 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
364 fetchProposedTactic 1;
365 setNextTactic 1 (Specify_Theory "Test");
366 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
368 fetchProposedTactic 1;
369 setNextTactic 1 (Specify_Problem ["LINEAR", "univariate", "equation", "test"]);
370 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
371 "2-----------------------------------------------------------------";
373 fetchProposedTactic 1;
374 setNextTactic 1 (Specify_Method ["Test", "solve_linear"]);
375 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
377 fetchProposedTactic 1;
378 setNextTactic 1 (Apply_Method ["Test", "solve_linear"]);
379 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
381 fetchProposedTactic 1;
382 setNextTactic 1 (Rewrite_Set_Inst (["(''bdv'',x)"], "isolate_bdv"));
383 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
385 fetchProposedTactic 1;
386 setNextTactic 1 (Rewrite_Set "Test_simplify");
387 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
389 fetchProposedTactic 1;
390 setNextTactic 1 (Check_Postcond ["LINEAR", "univariate", "equation", "test"]);
391 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
393 fetchProposedTactic 1;
394 setNextTactic 1 (Check_elementwise "Assumptions");
395 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
397 val xml = fetchProposedTactic 1;
398 setNextTactic 1 (Check_Postcond
399 ["sqroot-test", "univariate", "equation", "test"]);
400 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
402 val ((pt,_),_) = get_calc 1;
403 val str = pr_ctree pr_short pt;
405 val ip = get_pos 1 1;
406 val (Form f, tac, asms) = ME_Misc.pt_extract (pt, ip);
407 (*exception just above means: 'ModSpec' has been returned: error anyway*)
408 if UnparseC.term f = "[x = 1]" then () else
409 error "FE-interface.sml: diff.behav. in miniscript with mini-subpb";
410 (**)-------------------------------------------------------------------------------------------*)
413 "--------- mini-subpbl AUTOCALCULATE Steps 1 -------------";
414 "--------- mini-subpbl AUTOCALCULATE Steps 1 -------------";
415 "--------- mini-subpbl AUTOCALCULATE Steps 1 -------------";
416 (*WN120210?not ME:\label{SOLVE:AUTO:one} UC 30.3.3.2 p.176*)
417 CalcTree [(["equality (x+1=(2::real))", "solveFor x", "solutions L"],
418 ("Test", ["sqroot-test", "univariate", "equation", "test"],
419 ["Test", "squ-equ-test-subpbl1"]))];
422 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
423 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
424 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
425 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
426 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
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 (*here the solve-phase starts*)
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 (*------------------------------------*)
435 (* (*default_print_depth 13*) get_calc 1;
437 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
438 (*calc-head of subproblem*)
439 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
440 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
441 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
442 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
443 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
444 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
445 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
446 (*solve-phase of the subproblem*)
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 (*finish subproblem*)
452 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
454 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
456 (*this checks the test for correctness..*)
457 val ((pt,_),_) = get_calc 1;
459 val (Form f, tac, asms) = ME_Misc.pt_extract (pt, p);
460 if UnparseC.term f = "[x = 1]" andalso p = ([], Res) then () else
461 error "FE-interface.sml: diff.behav. in miniscript with mini-subpb";
465 "--------- solve_linear as rootpbl AUTO CompleteCalc ----";
466 "--------- solve_linear as rootpbl AUTO CompleteCalc ----";
467 "--------- solve_linear as rootpbl AUTO CompleteCalc ----";
468 (*WN120210?not ME:\label{SPECIFY:START:auto} UC 30.2.4.2 p.174*)
470 [(["equality (1+- 1*2+x=(0::real))", "solveFor x", "solutions L"],
472 ["LINEAR", "univariate", "equation", "test"],
473 ["Test", "solve_linear"]))];
476 getFormulaeFromTo 1 ([],Pbl) ([],Pbl) 999 false;
478 autoCalculate 1 CompleteCalc;
479 val (unc, del, gen) = (([],Pbl), ([],Pbl), ([],Res));
480 getFormulaeFromTo 1 unc gen 1 (*only level 1*) false;
482 val ((pt,_),_) = get_calc 1;
484 val (Form f, tac, asms) = ME_Misc.pt_extract (pt, p);
485 if UnparseC.term f = "[x = 1]" andalso p = ([], Res) then () else
486 error "FE-interface.sml: diff.behav. in solve_linear/rt AUTOCALCULATE ";
489 "--------- solve_linear as rootpbl AUTO CompleteHead/Eval ";
490 "--------- solve_linear as rootpbl AUTO CompleteHead/Eval ";
491 "--------- solve_linear as rootpbl AUTO CompleteHead/Eval ";
492 (* ERROR: error in kernel ?? *)
494 [(["equality (1+- 1*2+x=(0::real))", "solveFor x", "solutions L"],
496 ["LINEAR", "univariate", "equation", "test"],
497 ["Test", "solve_linear"]))];
501 autoCalculate 1 CompleteCalcHead;
502 refFormula 1 (get_pos 1 1);
503 val ((pt,p),_) = get_calc 1;
505 autoCalculate 1 CompleteCalc;
506 val ((pt,p),_) = get_calc 1;
507 if p=([], Res) then () else
508 error "FE-interface.sml: diff.behav. in solve_linear AUTOC Head/Eval ";
511 "--------- mini-subpbl AUTOCALCULATE CompleteCalc -------";
512 "--------- mini-subpbl AUTOCALCULATE CompleteCalc -------";
513 "--------- mini-subpbl AUTOCALCULATE CompleteCalc -------";
514 (*WN120210?not ME:\label{SPECIFY:START:auto} UC 30.2.4.2 p.174*)
515 CalcTree [(["equality (x+1=(2::real))", "solveFor x", "solutions L"],
516 ("Test", ["sqroot-test", "univariate", "equation", "test"],
517 ["Test", "squ-equ-test-subpbl1"]))];
520 autoCalculate 1 CompleteCalc;
521 val ((pt,p),_) = get_calc 1; Test_Tool.show_pt pt;
523 getTactic 1 ([1],Frm);
524 getTactic 1 ([1],Res);
525 initContext 1 Ptool.Thy_ ([1],Res);
527 (*... returns calcChangedEvent with*)
528 val (unc, del, gen) = (([],Pbl), ([],Pbl), ([],Res));
529 getFormulaeFromTo 1 unc gen 0 (*only result*) false;
530 getFormulaeFromTo 1 unc gen 1 (*only level 1*) false;
531 getFormulaeFromTo 1 unc gen 99999 (*all levels*) false;
533 val ((pt,_),_) = get_calc 1;
535 val (Form f, tac, asms) = ME_Misc.pt_extract (pt, p);
536 if UnparseC.term f = "[x = 1]" andalso p = ([], Res) then () else
537 error "FE-interface.sml: diff.behav. in mini-subpbl AUTOCALCULATE 6";
540 "--------- mini-subpbl AUTO CompleteCalcHead ------------";
541 "--------- mini-subpbl AUTO CompleteCalcHead ------------";
542 "--------- mini-subpbl AUTO CompleteCalcHead ------------";
543 CalcTree [(["equality (x+1=(2::real))", "solveFor x", "solutions L"],
544 ("Test", ["sqroot-test", "univariate", "equation", "test"],
545 ["Test", "squ-equ-test-subpbl1"]))];
548 autoCalculate 1 CompleteCalcHead;
550 val ((Nd (PblObj {fmz = (fm, ("Test", pblID, metID)), loc = (SOME (env, ctxt1), NONE),
552 spec = ("Test", ["sqroot-test", "univariate", "equation", "test"],
553 ["Test", "squ-equ-test-subpbl1"]),
554 branch = TransitiveB, ostate = Incomplete (*!?\<forall>*), ...}, []),
555 ([], Met)), []) = get_calc 1;
556 if length meth = 3 andalso length probl = 3 (*just some items tested*) then ()
557 else error "--- mini-subpbl AUTO CompleteCalcHead ---";
560 "--------- solve_linear as rootpbl AUTO CompleteModel ---";
561 "--------- solve_linear as rootpbl AUTO CompleteModel ---";
562 "--------- solve_linear as rootpbl AUTO CompleteModel ---";
565 [(["equality (1+- 1*2+x=(0::real))", "solveFor x", "solutions L"],
567 ["LINEAR", "univariate", "equation", "test"],
568 ["Test", "solve_linear"]))];
571 autoCalculate 1 CompleteModel;
572 refFormula 1 (get_pos 1 1);
574 setProblem 1 ["LINEAR", "univariate", "equation", "test"];
575 val pos = get_pos 1 1;
576 (*setContext 1 pos (Ptool.kestoreID2guh Ptool.Pbl_["LINEAR", "univariate", "equation", "test"]);*)
577 refFormula 1 (get_pos 1 1);
579 setMethod 1 ["Test", "solve_linear"];
580 (*setContext 1 pos (Ptool.kestoreID2guh Ptool.Met_ ["Test", "solve_linear"]);*)
581 refFormula 1 (get_pos 1 1);
582 val ((pt,_),_) = get_calc 1;
583 if get_obj g_spec pt [] = (ThyC.id_empty,
584 ["LINEAR", "univariate", "equation", "test"],
585 ["Test", "solve_linear"]) then ()
586 else error "FE-interface.sml: diff.behav. in setProblem, setMethod";
588 autoCalculate 1 CompleteCalcHead;
589 refFormula 1 (get_pos 1 1);
590 autoCalculate 1 CompleteCalc;
594 refFormula 1 (get_pos 1 1);
595 val ((pt,_),_) = get_calc 1;
597 val (Form f, tac, asms) = ME_Misc.pt_extract (pt, p);
598 if UnparseC.term f = "[x = 1]" andalso p = ([], Res) then () else
599 error "FE-interface.sml: diff.behav. in mini-subpbl AUTOCALCULATE 6";
602 "--------- setContext..Thy ------------------------------";
603 "--------- setContext..Thy ------------------------------";
604 "--------- setContext..Thy ------------------------------";
606 CalcTree [(["equality (x+1=(2::real))", "solveFor x", "solutions L"],
607 ("Test", ["sqroot-test", "univariate", "equation", "test"],
608 ["Test", "squ-equ-test-subpbl1"]))];
609 Iterator 1; moveActiveRoot 1;
610 autoCalculate 1 CompleteCalcHead;
611 autoCalculate 1 (Steps 1);
612 val ((pt,p),_) = get_calc 1; Test_Tool.show_pt pt; (*2 lines, OK*)
614 setNextTactic 1 (Rewrite_Set "Test_simplify"); (*--> "thy_isac_Test-rls-Test_simplify"*)
615 autoCalculate 1 (Steps 1);
616 val ((pt,p),_) = get_calc 1; Test_Tool.show_pt pt;
618 "----- \<up> ^^ and vvvvv do the same -----";
619 (*setContext 1 p "thy_isac_Test-rls-Test_simplify";*)
620 val ((pt,p),_) = get_calc 1; Test_Tool.show_pt pt; (*2 lines, OK*)
622 autoCalculate 1 (Steps 1);
623 (*setContext 1 p "thy_isac_Test-rls-Test_simplify";*)
624 val (((pt,_),_), p) = (get_calc 1, get_pos 1 1);
625 val (Form f, tac, asms) = ME_Misc.pt_extract (pt, p);
626 if p = ([1], Res) andalso UnparseC.term (get_obj g_res pt (fst p)) = "x + 1 + - 1 * 2 = 0"
627 then () else error "--- setContext..Thy --- autoCalculate 1 (Steps 1) #1";
629 autoCalculate 1 CompleteCalc;
630 val (((pt,_),_), p) = (get_calc 1, get_pos 1 1);
631 val (Form f, tac, asms) = ME_Misc.pt_extract (pt, p);
633 if UnparseC.term f = "[x = 1]" andalso p = ([], Res) then ()
634 else error "--- setContext..Thy --- autoCalculate CompleteCalc";
637 "--------- mini-subpbl AUTOCALC CompleteToSubpbl --------";
638 "--------- mini-subpbl AUTOCALC CompleteToSubpbl --------";
639 "--------- mini-subpbl AUTOCALC CompleteToSubpbl --------";
641 CalcTree [(["equality (x+1=(2::real))", "solveFor x", "solutions L"],
642 ("Test", ["sqroot-test", "univariate", "equation", "test"],
643 ["Test", "squ-equ-test-subpbl1"]))];
644 Iterator 1; moveActiveRoot 1;
645 autoCalculate 1 CompleteToSubpbl;
646 refFormula 1 (get_pos 1 1); (*<ISA> - 1 + x = 0 </ISA>*);
647 val ((pt,_),_) = get_calc 1;
648 val str = pr_ctree pr_short pt;
650 if str = ". ----- pblobj -----\n1. x + 1 = 2\n2. x + 1 + - 1 * 2 = 0\n"
652 error "FE-interface.sml: diff.behav. in mini-subpbl CompleteToSubpbl- 1";
654 autoCalculate 1 (Steps 1); (*proceeds only, if NOT 1 step before subplb*)
655 autoCalculate 1 CompleteToSubpbl;
656 val ((pt,_),_) = get_calc 1;
657 val str = pr_ctree pr_short pt;
659 autoCalculate 1 CompleteCalc; (*das geht ohnehin !*);
660 val ((pt,_),_) = get_calc 1;
663 val (Form f, tac, asms) = ME_Misc.pt_extract (pt, p);
664 if UnparseC.term f = "[x = 1]" andalso p = ([], Res) then () else
665 error "FE-interface.sml: diff.behav. in mini-subpbl CompleteToSubpbl 1";
668 "--------- rat-eq + subpbl: no_met, NO solution dropped -";
669 "--------- rat-eq + subpbl: no_met, NO solution dropped -";
670 "--------- rat-eq + subpbl: no_met, NO solution dropped -";
671 "--------- rat-eq + subpbl: no_met, NO solution dropped - see LI: '--- simpl.rat.term, '..";
672 (*--- THIS IS RE-USED WITH fun me IN test/../MathEngine/solve.sml -------------------
673 ---- rat-eq + subpbl: set_found in check_tac1 ----*)
675 [(["equality ((5*x)/(x - 2) - x/(x+2)=(4::real))", "solveFor x", "solutions L"],
676 ((** )"RatEq"( **)"PolyEq"(*required for "make_ratpoly_in"*),
677 ["univariate", "equation"], ["no_met"]))];
680 fetchProposedTactic 1;
682 setNextTactic 1 (Model_Problem);
683 autoCalculate 1 (Steps 1); fetchProposedTactic 1;
685 setNextTactic 1 (Specify_Theory "RatEq");
686 autoCalculate 1 (Steps 1); fetchProposedTactic 1;
687 setNextTactic 1 (Specify_Problem ["rational", "univariate", "equation"]);
688 autoCalculate 1 (Steps 1); fetchProposedTactic 1;
689 setNextTactic 1 (Specify_Method ["RatEq", "solve_rat_equation"]);
690 autoCalculate 1 (Steps 1); fetchProposedTactic 1;
691 setNextTactic 1 (Apply_Method ["RatEq", "solve_rat_equation"]);
692 autoCalculate 1 (Steps 1); fetchProposedTactic 1;
693 setNextTactic 1 (Rewrite_Set "RatEq_simplify");
694 autoCalculate 1 (Steps 1); fetchProposedTactic 1;
695 setNextTactic 1 (Rewrite_Set "norm_Rational");
696 autoCalculate 1 (Steps 1); fetchProposedTactic 1;
697 setNextTactic 1 (Rewrite_Set "RatEq_eliminate");
698 autoCalculate 1 (Steps 1); fetchProposedTactic 1;
699 (* __________ for "12 * x + 4 * x \<up> 2 = 4 * (-4 + x \<up> 2)"*)
700 setNextTactic 1 (Subproblem ("PolyEq", ["normalise", "polynomial",
701 "univariate", "equation"]));
702 autoCalculate 1 (Steps 1); fetchProposedTactic 1;
703 setNextTactic 1 (Model_Problem );
704 autoCalculate 1 (Steps 1); fetchProposedTactic 1;
705 setNextTactic 1 (Specify_Theory "PolyEq");
706 autoCalculate 1 (Steps 1); fetchProposedTactic 1;
707 setNextTactic 1 (Specify_Problem ["normalise", "polynomial",
708 "univariate", "equation"]);
709 autoCalculate 1 (Steps 1); fetchProposedTactic 1;
710 setNextTactic 1 (Specify_Method ["PolyEq", "normalise_poly"]);
711 autoCalculate 1 (Steps 1); fetchProposedTactic 1;
712 setNextTactic 1 (Apply_Method ["PolyEq", "normalise_poly"]);
713 autoCalculate 1 (Steps 1); fetchProposedTactic 1;
714 setNextTactic 1 (Rewrite ("all_left", @{thm all_left}));
715 autoCalculate 1 (Steps 1); fetchProposedTactic 1;
716 setNextTactic 1 (Rewrite_Set_Inst (["(''bdv'',x)"], "make_ratpoly_in"));
717 autoCalculate 1 (Steps 1); fetchProposedTactic 1;
718 (* __________ for "16 + 12 * x = 0"*)
719 setNextTactic 1 (Subproblem ("PolyEq",
720 ["degree_1", "polynomial", "univariate", "equation"]));
721 autoCalculate 1 (Steps 1); fetchProposedTactic 1;
722 setNextTactic 1 (Model_Problem );
723 autoCalculate 1 (Steps 1); fetchProposedTactic 1;
724 setNextTactic 1 (Specify_Theory "PolyEq");
725 (*------------- some trials in the problem-hierarchy ---------------*)
726 setNextTactic 1 (Specify_Problem ["LINEAR", "univariate", "equation"]);
727 autoCalculate 1 (Steps 1); fetchProposedTactic 1; (*<ERROR> helpless </ERROR> !!!*)
728 setNextTactic 1 (Refine_Problem ["univariate", "equation"]);
729 (*------------------------------------------------------------------*)
730 autoCalculate 1 (Steps 1); fetchProposedTactic 1;
731 setNextTactic 1 (Specify_Method ["PolyEq", "solve_d1_polyeq_equation"]);
732 autoCalculate 1 (Steps 1); fetchProposedTactic 1;
733 setNextTactic 1 (Apply_Method ["PolyEq", "solve_d1_polyeq_equation"]);
734 autoCalculate 1 (Steps 1); fetchProposedTactic 1;
735 setNextTactic 1 (Rewrite_Set_Inst (["(''bdv'',x)"], "d1_polyeq_simplify"));
736 autoCalculate 1 (Steps 1); fetchProposedTactic 1;
737 setNextTactic 1 (Rewrite_Set "polyeq_simplify");
738 autoCalculate 1 (Steps 1); fetchProposedTactic 1;
739 setNextTactic 1 Or_to_List;
740 autoCalculate 1 (Steps 1); fetchProposedTactic 1;
741 setNextTactic 1 (Check_elementwise "Assumptions");
742 autoCalculate 1 (Steps 1); fetchProposedTactic 1;
743 setNextTactic 1 (Check_Postcond ["degree_1", "polynomial",
744 "univariate", "equation"]);
745 autoCalculate 1 (Steps 1); fetchProposedTactic 1;
746 setNextTactic 1 (Check_Postcond ["normalise", "polynomial",
747 "univariate", "equation"]);
748 autoCalculate 1 (Steps 1); fetchProposedTactic 1;
749 setNextTactic 1 (Check_Postcond ["rational", "univariate", "equation"]);
750 val (ptp,_) = get_calc 1;
751 val (Form t,_,_) = ME_Misc.pt_extract ptp;
752 if get_pos 1 1 = ([], Res) andalso UnparseC.term t = "[x = -4 / 3]" then ()
753 else writeln "FE-inteface.sml: diff.behav. in rat-eq + subpbl: no_met, NO ..";
757 "--------- tryMatchProblem, tryRefineProblem ------------";
758 "--------- tryMatchProblem, tryRefineProblem ------------";
759 "--------- tryMatchProblem, tryRefineProblem ------------";
760 (*{\bf\UC{Having \isac{} Refine the Problem
761 * Automatically}\label{SPECIFY:refine-auto}\\} test match and refine with
762 * x \<up>2 + 4*x + 5 = 2
763 see isac.bridge.TestSpecify#testMatchRefine*)
766 [(["equality (x \<up> 2 + 4*x + 5 = (2::real))", "solveFor x", "solutions L"],
768 ["univariate", "equation"],
773 fetchProposedTactic 1;
774 setNextTactic 1 (Model_Problem );
775 (*..this tactic should be done 'tacitly', too !*)
778 autoCalculate 1 CompleteCalcHead;
779 checkContext 1 ([],Pbl) "pbl_equ_univ";
780 checkContext 1 ([],Pbl) (Ptool.kestoreID2guh Ptool.Pbl_ ["univariate", "equation"]);
783 autoCalculate 1 (Steps 1);
785 fetchProposedTactic 1;
786 setNextTactic 1 (Add_Given "equality (x \<up> 2 + 4 * x + 5 = (2::real))");
787 autoCalculate 1 (Steps 1);
789 "--------- we go into the ProblemBrowser (_NO_ pblID selected) -";
790 (*initContext 1 Ptool.Pbl_ ([],Pbl);*)
791 (* this would break if a calculation would be inserted before: CALCID...
792 and pattern matching is not available in *.java.
793 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. . . . . . . TermC.matches (?a = ?b) (x \<up> ^ 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"
794 then () else error "--- tryMatchProblem, tryRefineProblem: initContext 1 Ptool.Pbl_ ([],Pbl); CHANGED";
796 (*initContext 1 Ptool.Met_ ([],Pbl);*)
797 (*<SYSERROR><CALCID>1</CALCID><ERROR>error in kernel 33</ERROR></SYSERROR>*)
799 "--------- this match will show some incomplete items: ---------";
801 (*checkContext 1 ([],Pbl) (Ptool.kestoreID2guh Ptool.Pbl_ ["univariate", "equation"]);
802 checkContext 1 ([],Pbl) (Ptool.kestoreID2guh Ptool.Met_ ["LinEq", "solve_lineq_equation"]);*)
805 fetchProposedTactic 1;
806 setNextTactic 1 (Add_Given "solveFor x"); autoCalculate 1 (Steps 1);
808 fetchProposedTactic 1;
809 setNextTactic 1 (Add_Find "solutions L"); autoCalculate 1 (Steps 1);
811 "--------- this is a matching model (all items correct): -------";
812 (*checkContext 1 ([],Pbl) (Ptool.kestoreID2guh Ptool.Pbl_ ["univariate", "equation"]);*)
813 "--------- this is a NOT matching model (some 'false': ---------";
814 (*checkContext 1 ([],Pbl)(Ptool.kestoreID2guh Ptool.Pbl_ ["LINEAR", "univariate", "equation"]);*)
816 "--------- find out a matching problem: ------------------------";
817 "--------- find out a matching problem (FAILING: no new pbl) ---";
818 refineProblem 1([],Pbl)(Ptool.pblID2guh ["LINEAR", "univariate", "equation"]);
820 "--------- find out a matching problem (SUCCESSFUL) ------------";
821 refineProblem 1 ([],Pbl) (Ptool.pblID2guh ["univariate", "equation"]);
823 "--------- tryMatch, tryRefine did not change the calculation -";
824 "--------- this is done by <TRANSFER> on the pbl-browser: ------";
825 setNextTactic 1 (Specify_Problem ["normalise", "polynomial",
826 "univariate", "equation"]);
827 autoCalculate 1 (Steps 1);
828 (*WN050904 fetchProposedTactic again --> Specify_Problem ["normalise",...
829 and Specify_Theory skipped in comparison to below --- \<up> -inserted *)
830 (*------------vvv-inserted-----------------------------------------------*)
831 fetchProposedTactic 1;
832 (*/-----ERROR INTRODUCED BY CHILD OF 33913fe24685 --------------------------------------------\* )
833 setNextTactic 1 (Specify_Problem ["normalise", "polynomial",
834 "univariate", "equation"]);
835 autoCalculate 1 (Steps 1);
837 (*and Specify_Theory skipped by fetchProposedTactic ?!?*)
839 fetchProposedTactic 1;
840 setNextTactic 1 (Specify_Method ["PolyEq", "normalise_poly"]);
841 autoCalculate 1 (Steps 1);
843 fetchProposedTactic 1;
844 setNextTactic 1 (Apply_Method ["PolyEq", "normalise_poly"]);
846 autoCalculate 1 CompleteCalc;
848 val ((pt,_),_) = get_calc 1;
849 Test_Tool.show_pt pt;
851 val (Form f, tac, asms) = ME_Misc.pt_extract (pt, p);
852 if UnparseC.term f = "[x = - 1, x = -3]" andalso p = ([], Res) then () else
853 error "FE-interface.sml: diff.behav. in tryMatchProblem, tryRefine";
855 (*------------ \<up> -inserted-----------------------------------------------*)
856 (*WN050904 the fetchProposedTactic's below may not have worked like that
857 before, too, because there was no check*)
858 fetchProposedTactic 1;
859 setNextTactic 1 (Specify_Theory "PolyEq");
860 autoCalculate 1 (Steps 1);
862 fetchProposedTactic 1;
863 setNextTactic 1 (Specify_Method ["PolyEq", "normalise_poly"]);
864 autoCalculate 1 (Steps 1);
866 fetchProposedTactic 1;
867 "--------- now the calc-header is ready for enter 'solving' ----";
868 autoCalculate 1 CompleteCalc;
870 val ((pt,_),_) = get_calc 1;
872 Test_Tool.show_pt pt;
874 val (Form f, tac, asms) = ME_Misc.pt_extract (pt, p);
875 if UnparseC.term f = "[x = - 1, x = -3]" andalso p = ([], Res) then () else
876 error "FE-interface.sml: diff.behav. in tryMatchProblem, tryRefine";
878 ( *\-----ERROR INTRODUCED BY CHILD OF 33913fe24685 --------------------------------------------/*)
880 "--------- modifyCalcHead, resetCalcHead, modelProblem --";
881 "--------- modifyCalcHead, resetCalcHead, modelProblem --";
882 "--------- modifyCalcHead, resetCalcHead, modelProblem --";
884 CalcTree [(["equality (x+1=(2::real))", "solveFor x", "solutions L"],
885 ("Test", ["sqroot-test", "univariate", "equation", "test"],
886 ["Test", "squ-equ-test-subpbl1"]))];
890 modifyCalcHead 1 (([],Pbl),(*the position from refFormula*)
891 "solve (x+1=2, x)",(*the headline*)
892 [P_Spec.Given ["equality (x+1=(2::real))", "solveFor x"],
893 P_Spec.Find ["solutions L"](*,P_Spec.Relate []*)],
896 ["sqroot-test", "univariate", "equation", "test"],
897 ["Test", "squ-equ-test-subpbl1"]));
899 val ((Nd (PblObj {fmz = (fm, tpm),
900 loc = (SOME scrst_ctxt, NONE),
904 ["sqroot-test", "univariate", "equation", "test"],
905 ["Test", "squ-equ-test-subpbl1"]),
907 branch = TransitiveB,
914 (*WN110622: is the same as in 2002, but shouldn't be probl = [3 items?]*)
915 if length meth = 0 andalso length probl = 0 (*just some items tested*) then ()
916 else error "--- modifyCalcHead, resetCalcHead, modelProblem 1 --";
922 val ((Nd (PblObj {fmz = (fm, tpm),
923 loc = (SOME scrst_ctxt, NONE),
926 spec = ("empty_thy_id", ["empty_probl_id"], ["empty_meth_id"]),
928 branch = TransitiveB,
935 if length meth = 3 andalso length probl = 3 (*just some items tested*) then ()
936 else error "--- modifyCalcHead, resetCalcHead, modelProblem 2 --";
938 "--------- maximum-example, UC: Modeling an example -----";
939 "--------- maximum-example, UC: Modeling an example -----";
940 "--------- maximum-example, UC: Modeling an example -----";
941 (* {\bf\UC{Editing the Model}\label{SPECIFY:enter}\label{SPECIFY:check}\\}
942 see isac.bridge.TestModel#testEditItems
944 val elems = ["fixedValues [r=Arbfix]", "maximum A", "valuesFor [a,b]",
945 "relations [A=a*b, (a/2) \<up> 2 + (b/2) \<up> 2 = r \<up> 2]",
946 "relations [A=a*b, (a/2) \<up> 2 + (b/2) \<up> 2 = r \<up> 2]",
947 "relations [A=a*b, a/2=r*sin alpha, b/2=r*cos (alpha::real)]",
948 (* \<up> these are the elements for the root-problem (in variants)*)
949 (*vvv these are elements required for subproblems*)
950 "boundVariable a", "boundVariable b", "boundVariable alpha",
951 "interval {x::real. 0 <= x & x <= 2*r}",
952 "interval {x::real. 0 <= x & x <= 2*r}",
953 "interval {x::real. 0 <= x & x <= pi}",
954 "errorBound (eps=(0::real))"]
955 (*specifying is not interesting for this example*)
956 val spec = ("Diff_App", ["maximum_of", "function"],
957 ["Diff_App", "max_by_calculus"]);
958 (*the empty model with descriptions for user-guidance by Model_Problem*)
959 val empty_model = [P_Spec.Given ["fixedValues []"],
960 P_Spec.Find ["maximum", "valuesFor"],
961 P_Spec.Relate ["relations []"]];
964 "#################################################################";
966 CalcTree [(elems, spec)];
969 refFormula 1 (get_pos 1 1);
970 (*this gives a completely empty model*)
972 fetchProposedTactic 1;
973 (*fill the CalcHead with Descriptions...*)
974 setNextTactic 1 (Model_Problem );
975 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
977 (*user input is !!!!!EITHER!!!!! _some_ (at least one) items of the model
978 !!!!!OR!!!!! _one_ part of the specification !!!!!!!!!!!!!*)
979 (*input of two items, 'fixedValues [r=Arbfix]' and 'maximum b'...*)
980 modifyCalcHead 1 (([],Pbl) (*position, from previous refFormula*),
981 "Problem (Diff_App.thy, [maximum_of, function])",
982 (*the head-form \<up> is not used for input here*)
983 [P_Spec.Given ["fixedValues [r=Arbfix]"(*new input*)],
984 P_Spec.Find ["maximum b"(*new input*), "valuesFor"],
985 P_Spec.Relate ["relations"]],
986 (*input (Arbfix will dissappear soon)*)
988 References.empty (*no input to the specification*));
990 (*the user does not know, what 'superfluous' for 'maximum b' may mean
991 and asks what to do next*)
992 fetchProposedTactic 1;
993 (*the student follows the advice*)
994 setNextTactic 1 (Add_Find "maximum A"); (*FIXME.17.11.03: does not yet work*)
995 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
997 (*this input completes the model*)
998 modifyCalcHead 1 (([],Pbl), "not used here",
999 [P_Spec.Given ["fixedValues [r=Arbfix]"],
1000 P_Spec.Find ["maximum A", "valuesFor [a,b]"(*new input*)],
1001 P_Spec.Relate ["relations [A=a*b, \
1002 \(a/2) \<up> 2 + (b/2) \<up> 2 = r \<up> 2]"]], Pbl, References.empty);
1004 (*specification is not interesting and should be skipped by the dialogguide;
1005 !!!!!!!!!!!!!!!!!!!! input of ONE part at a time !!!!!!!!!!!!!!!!!!!!!!*)
1006 modifyCalcHead 1 (([],Pbl), "not used here",
1007 [P_Spec.Given ["fixedValues [r=Arbfix]"],
1008 P_Spec.Find ["maximum A", "valuesFor [a,b]"(*new input*)],
1009 P_Spec.Relate ["relations [A=a*b, \
1010 \(a/2) \<up> 2 + (b/2) \<up> 2 = r \<up> 2]"]], Pbl,
1011 ("Diff_App", Problem.id_empty, MethodC.id_empty));
1012 modifyCalcHead 1 (([],Pbl), "not used here",
1013 [P_Spec.Given ["fixedValues [r=Arbfix]"],
1014 P_Spec.Find ["maximum A", "valuesFor [a,b]"(*new input*)],
1015 P_Spec.Relate ["relations [A=a*b, \
1016 \(a/2) \<up> 2 + (b/2) \<up> 2 = r \<up> 2]"]], Pbl,
1017 ("Diff_App", ["maximum_of", "function"],
1019 modifyCalcHead 1 (([],Pbl), "not used here",
1020 [P_Spec.Given ["fixedValues [r=Arbfix]"],
1021 P_Spec.Find ["maximum A", "valuesFor [a,b]"(*new input*)],
1022 P_Spec.Relate ["relations [A=a*b, \
1023 \(a/2) \<up> 2 + (b/2) \<up> 2 = r \<up> 2]"]], Pbl,
1024 ("Diff_App", ["maximum_of", "function"],
1025 ["Diff_App", "max_by_calculus"]));
1026 (*this final calcHead now has STATUS 'complete' !*)
1029 "--------- solve_linear from pbl-hierarchy --------------";
1030 "--------- solve_linear from pbl-hierarchy --------------";
1031 "--------- solve_linear from pbl-hierarchy --------------";
1033 val (fmz, sp) = ([], ("", ["LINEAR", "univariate", "equation", "test"], []));
1034 CalcTree [(fmz, sp)];
1035 Iterator 1; moveActiveRoot 1;
1036 refFormula 1 (get_pos 1 1);
1037 modifyCalcHead 1 (([],Pbl),"solve (1+- 1*2+x=(0::real))",
1038 [P_Spec.Given ["equality (1+- 1*2+x=(0::real))", "solveFor x"],
1039 P_Spec.Find ["solutions L"]],
1041 ("Test", ["LINEAR", "univariate", "equation", "test"],
1042 ["Test", "solve_linear"]));
1043 autoCalculate 1 CompleteCalc;
1044 refFormula 1 (get_pos 1 1);
1045 val ((pt,_),_) = get_calc 1;
1046 val p = get_pos 1 1;
1047 val (Form f, tac, asms) = ME_Misc.pt_extract (pt, p);
1048 if UnparseC.term f = "[x = 1]" andalso p = ([], Res) andalso map UnparseC.term asms = [] then ()
1049 else error "FE-interface.sml: diff.behav. in from pbl -hierarchy 1";
1052 "--------- solve_linear as in an algebra system (CAS)----";
1053 "--------- solve_linear as in an algebra system (CAS)----";
1054 "--------- solve_linear as in an algebra system (CAS)----";
1055 (*WN120210?not ME:\label{UC:cas-input} UC 30.1.2.5 p.168*)
1057 val (fmz, sp) = ([], ("", [], []));
1058 CalcTree [(fmz, sp)];
1059 Iterator 1; moveActiveRoot 1;
1060 modifyCalcHead 1 (([],Pbl),"solveTest (1+- 1*2+x=0,x)", [], Pbl, ("", [], []));
1061 autoCalculate 1 CompleteCalc;
1062 refFormula 1 (get_pos 1 1);
1063 val ((pt,_),_) = get_calc 1;
1064 val p = get_pos 1 1;
1065 val (Form f, tac, asms) = ME_Misc.pt_extract (pt, p);
1066 if UnparseC.term f = "[x = 1]" andalso p = ([], Res) andalso map UnparseC.term asms = [] then ()
1067 else error "FE-interface.sml: diff.behav. in from pbl -hierarchy 2";
1070 "--------- interSteps: on 'miniscript with mini-subpbl' -";
1071 "--------- interSteps: on 'miniscript with mini-subpbl' -";
1072 "--------- interSteps: on 'miniscript with mini-subpbl' -";
1073 CalcTree [(["equality (x+1=(2::real))", "solveFor x", "solutions L"],
1074 ("Test", ["sqroot-test", "univariate", "equation", "test"],
1075 ["Test", "squ-equ-test-subpbl1"]))];
1078 autoCalculate 1 CompleteCalc;
1079 val ((pt,_),_) = get_calc 1;
1080 Test_Tool.show_pt pt;
1082 (*UC\label{UC:inter-steps} UC 30.3.5.5 p.178*)
1083 interSteps 1 ([2],Res);
1084 val ((pt,_),_) = get_calc 1; Test_Tool.show_pt pt (*new ([2,1],Frm)..([2,6],Res)*);
1085 val (unc, del, gen) = (([1],Res),([1],Res),([2,6],Res));
1086 getFormulaeFromTo 1 unc gen 1 false;
1088 (*UC\label{UC:inter-steps} UC 30.3.5.5 p.178*)
1089 interSteps 1 ([3,2],Res);
1090 val ((pt,_),_) = get_calc 1; Test_Tool.show_pt pt (*new ([3,2,1],Frm)..([3,2,2],Res)*);
1091 val (unc, del, gen) = (([3,1],Res),([3,1],Res),([3,2,2],Res));
1092 getFormulaeFromTo 1 unc gen 1 false;
1094 (*UC\label{UC:inter-steps} UC 30.3.5.5 p.178*)
1095 interSteps 1 ([3],Res) (*no new steps in subproblems*);
1096 val (unc, del, gen) = (([3],Pbl),([3],Pbl),([3,2],Res));
1097 getFormulaeFromTo 1 unc gen 1 false;
1099 (*UC\label{UC:inter-steps} UC 30.3.5.5 p.178*)
1100 interSteps 1 ([],Res) (*no new steps in subproblems*);
1101 val (unc, del, gen) = (([],Pbl),([],Pbl),([4],Res));
1102 getFormulaeFromTo 1 unc gen 1 false;
1105 "--------- getTactic, fetchApplicableTactics ------------";
1106 "--------- getTactic, fetchApplicableTactics ------------";
1107 "--------- getTactic, fetchApplicableTactics ------------";
1108 (* compare test/../script.sml
1109 "----------- fun from_prog ---------------------------------------";
1111 CalcTree [(["equality (x+1=(2::real))", "solveFor x", "solutions L"],
1112 ("Test", ["sqroot-test", "univariate", "equation", "test"],
1113 ["Test", "squ-equ-test-subpbl1"]))];
1114 Iterator 1; moveActiveRoot 1;
1115 autoCalculate 1 CompleteCalc;
1116 val ((pt,_),_) = get_calc 1;
1117 Test_Tool.show_pt pt;
1119 (*UC\label{SOLVE:HIDE:getTactic} \label{SOLVE:AUTO:tactic} UC 30.3.3.1 p.176
1120 WN120210 not impl. in FE*)
1121 getTactic 1 ([],Pbl);
1122 getTactic 1 ([1],Res);
1123 getTactic 1 ([3],Pbl);
1124 getTactic 1 ([3,1],Frm);
1125 getTactic 1 ([3],Res);
1126 getTactic 1 ([],Res);
1128 (*UC\label{SOLVE:MANUAL:TACTIC:listall} UC 30.3.2.2 p.175*)
1129 fetchApplicableTactics 1 99999 ([],Pbl);
1130 fetchApplicableTactics 1 99999 ([1],Res);
1131 fetchApplicableTactics 1 99999 ([3],Pbl);
1132 fetchApplicableTactics 1 99999 ([3,1],Res);
1133 fetchApplicableTactics 1 99999 ([3],Res);
1134 fetchApplicableTactics 1 99999 ([],Res);
1137 (*SINCE eliminate ThmC.numerals_to_Free: loops ---------------------------------------------\\* )
1138 "--------- getAssumptions, getAccumulatedAsms -----------";
1139 "--------- getAssumptions, getAccumulatedAsms -----------";
1140 "--------- getAssumptions, getAccumulatedAsms -----------";
1143 [(["equality (x/(x \<up> 2 - 6*x+9) - 1/(x \<up> 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) = ME_Misc.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 \<up> 2) * x =\n" ^
1154 " 1 * (9 * x + -6 * x \<up> 2 + x \<up> 3)) is_poly_in x", "-6 * x + 5 * x \<up>\<up> 2 = 0",
1155 "lhs (-6 * x + 5 * x \<up> 2 = 0) is_poly_in x",
1156 "lhs (-6 * x + 5 * x \<up>\<up> 2 = 0) has_degree_in x = 2",
1157 "9 * x + -6 * x \<up> 2 + x \<up> 3 ~= 0"]
1158 andalso UnparseC.term f = "[-6 * x + 5 * x \<up> 2 = 0]" andalso p = ([], Res) then ()
1159 else error "TODO compare 2002-- 2011"; (*...data during test --- x / (x \<up> 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);
1174 ( *SINCE eliminate ThmC.numerals_to_Free: loops ---------------------------------------------//*)
1176 "--------- arbitrary combinations of steps --------------";
1177 "--------- arbitrary combinations of steps --------------";
1178 "--------- arbitrary combinations of steps --------------";
1179 CalcTree (*start of calculation, return No.1*)
1180 [(["equality (1+- 1*2+x=(0::real))", "solveFor x", "solutions L"],
1182 ["LINEAR", "univariate", "equation", "test"],
1183 ["Test", "solve_linear"]))];
1184 Iterator 1; moveActiveRoot 1;
1186 fetchProposedTactic 1;
1187 (*ERROR get_calc 1 not existent*)
1188 setNextTactic 1 (Model_Problem );
1189 autoCalculate 1 (Steps 1);
1190 fetchProposedTactic 1;
1191 fetchProposedTactic 1;
1193 setNextTactic 1 (Add_Find "solutions L");
1194 setNextTactic 1 (Add_Find "solutions L");
1196 autoCalculate 1 (Steps 1);
1197 autoCalculate 1 (Steps 1);
1199 setNextTactic 1 (Specify_Theory "Test");
1200 fetchProposedTactic 1;
1201 autoCalculate 1 (Steps 1);
1203 autoCalculate 1 (Steps 1);
1204 autoCalculate 1 (Steps 1);
1205 autoCalculate 1 (Steps 1);
1206 autoCalculate 1 (Steps 1);
1207 (*------------------------- end calc-head*)
1209 fetchProposedTactic 1;
1210 setNextTactic 1 (Rewrite_Set_Inst (["(''bdv'',x)"], "isolate_bdv"));
1211 autoCalculate 1 (Steps 1);
1213 setNextTactic 1 (Rewrite_Set "Test_simplify");
1214 fetchProposedTactic 1;
1215 autoCalculate 1 (Steps 1);
1217 autoCalculate 1 CompleteCalc;
1218 val ((pt,_),_) = get_calc 1;
1219 val p = get_pos 1 1;
1220 val (Form f, tac, asms) = ME_Misc.pt_extract (pt, p);
1221 if UnparseC.term f = "[x = 1]" andalso p = ([], Res) then () else
1222 error "FE-interface.sml: diff.behav. in combinations of steps";
1225 "--------- appendF label{SOLVE:MANUAL:FORMULA:enter}right"; (*UC 30.3.2.4 p.175*)
1226 "--------- appendF label{SOLVE:MANUAL:FORMULA:enter}right";
1227 "--------- appendF label{SOLVE:MANUAL:FORMULA:enter}right";
1228 CalcTree [(["equality (x+1=(2::real))", "solveFor x", "solutions L"],
1229 ("Test", ["sqroot-test", "univariate", "equation", "test"],
1230 ["Test", "squ-equ-test-subpbl1"]))];
1233 autoCalculate 1 CompleteCalcHead;
1234 autoCalculate 1 (Steps 1);
1235 autoCalculate 1 (Steps 1);
1236 appendFormula 1 "- 1 + x = 0" (*|> Future.join*);
1237 (*... returns calcChangedEvent with*)
1238 val (unc, del, gen) = (([1],Res), ([1],Res), ([2],Res));
1239 getFormulaeFromTo 1 unc gen 99999 (*all levels*) false;
1241 val ((pt,_),_) = get_calc 1;
1242 val p = get_pos 1 1;
1243 val (Form f, tac, asms) = ME_Misc.pt_extract (pt, p);
1244 if UnparseC.term f = "- 1 + x = 0" andalso p = ([2], Res) then () else
1245 error "FE-interface.sml: diff.behav. in FORMULA:enter} right";
1248 "--------- appendF label{SOLVE:MANUAL:FORMULA:enter}other"; (*UC 30.3.2.4 p.175*)
1249 "--------- appendF label{SOLVE:MANUAL:FORMULA:enter}other";
1250 "--------- appendF label{SOLVE:MANUAL:FORMULA:enter}other";
1251 CalcTree [(["equality (x+1=(2::real))", "solveFor x", "solutions L"],
1252 ("Test", ["sqroot-test", "univariate", "equation", "test"],
1253 ["Test", "squ-equ-test-subpbl1"]))];
1256 autoCalculate 1 CompleteCalcHead;
1257 autoCalculate 1 (Steps 1);
1258 autoCalculate 1 (Steps 1);
1259 appendFormula 1 "x - 1 = 0" (*|> Future.join*);
1260 val (unc, del, gen) = (([1],Res), ([1],Res), ([2],Res));
1261 getFormulaeFromTo 1 unc gen 99999 (*all levels*) false;
1264 val ((pt,_),_) = get_calc 1;
1265 val p = get_pos 1 1;
1266 val (Form f, tac, asms) = ME_Misc.pt_extract (pt, p);
1267 if UnparseC.term f = "x - 1 = 0" andalso p = ([2], Res) then () else
1268 error "FE-interface.sml: diff.behav. in FORMULA:enter} other";
1271 "--------- appendF label{SOLVE:MANUAL:FORMULA:enter}oth 2"; (*UC 30.3.2.4 p.175*)
1272 "--------- appendF label{SOLVE:MANUAL:FORMULA:enter}oth 2";
1273 "--------- appendF label{SOLVE:MANUAL:FORMULA:enter}oth 2";
1274 CalcTree [(["equality (x+1=(2::real))", "solveFor x", "solutions L"],
1275 ("Test", ["sqroot-test", "univariate", "equation", "test"],
1276 ["Test", "squ-equ-test-subpbl1"]))];
1279 autoCalculate 1 CompleteCalcHead;
1280 autoCalculate 1 (Steps 1);
1281 autoCalculate 1 (Steps 1);
1282 appendFormula 1 "x = 1" (*|> Future.join*);
1283 (*... returns calcChangedEvent with*)
1284 val (unc, del, gen) = (([1],Res), ([1],Res), ([3,2],Res));
1285 getFormulaeFromTo 1 unc gen 99999 (*all levels*) false;
1288 val ((pt,_),_) = get_calc 1;
1289 val p = get_pos 1 1;
1290 val (Form f, tac, asms) = ME_Misc.pt_extract (pt, p);
1291 if UnparseC.term f = "x = 1" andalso p = ([3,2], Res) then () else
1292 error "FE-interface.sml: diff.behav. in FORMULA:enter} oth 2";
1295 "--------- appendF label{SOLVE:MANUAL:FORMULA:enter}NOTok"; (*UC 30.3.2.4 p.175*)
1296 "--------- appendF label{SOLVE:MANUAL:FORMULA:enter}NOTok";
1297 "--------- appendF label{SOLVE:MANUAL:FORMULA:enter}NOTok";
1298 CalcTree [(["equality (x+1=(2::real))", "solveFor x", "solutions L"],
1299 ("Test", ["sqroot-test", "univariate", "equation", "test"],
1300 ["Test", "squ-equ-test-subpbl1"]))];
1303 autoCalculate 1 CompleteCalcHead;
1304 autoCalculate 1 (Steps 1);
1305 autoCalculate 1 (Steps 1);
1306 appendFormula 1 "x - 4711 = 0" (*|> Future.join*);
1307 (*... returns <ERROR> no derivation found </ERROR>*)
1309 val ((pt,_),_) = get_calc 1;
1310 val p = get_pos 1 1;
1311 val (Form f, tac, asms) = ME_Misc.pt_extract (pt, p);
1312 if UnparseC.term f = "x + 1 + - 1 * 2 = 0" andalso p = ([1], Res) then () else
1313 error "FE-interface.sml: diff.behav. in FORMULA:enter} NOTok";
1316 "--------- replaceFormula {SOL:MAN:FOR:replace} right----"; (*UC 30.3.2.5 p.176*)
1317 "--------- replaceFormula {SOL:MAN:FOR:replace} right----";
1318 "--------- replaceFormula {SOL:MAN:FOR:replace} right----";
1319 (*\label{SOLVE:MANUAL:FORMULA:replace}*)
1320 CalcTree [(["equality (x+1=(2::real))", "solveFor x", "solutions L"],
1321 ("Test", ["sqroot-test", "univariate", "equation", "test"],
1322 ["Test", "squ-equ-test-subpbl1"]))];
1325 autoCalculate 1 CompleteCalc;
1326 moveActiveFormula 1 ([2],Res);
1327 replaceFormula 1 "- 1 + x = 0" (*i.e. repeats input*);
1328 (*... returns <ERROR> formula not changed </ERROR>*)
1330 val ((pt,_),_) = get_calc 1;
1331 val p = get_pos 1 1;
1332 val (Form f, tac, asms) = ME_Misc.pt_extract (pt, p);
1333 if UnparseC.term f = "- 1 + x = 0" andalso p = ([2], Res) then () else
1334 error "FE-interface.sml: diff.behav. in FORMULA:replace} right 1";
1335 if map fst3 (ME_Misc.get_interval ([2],Res) ([],Res) 9999 pt) =
1336 [([2], Res), ([3], Pbl), ([3, 1], Frm), ([3, 1], Res), ([3, 2], Res),
1337 ([3], Res), ([4], Res), ([], Res)] then () (*nothing deleted!*) else
1338 error "FE-interface.sml: diff.behav. in FORMULA:replace} right 2";
1340 (*WN050211 replaceFormula didn't work on second ctree: thus now tested...*)
1341 CalcTree [(["equality (x+1=(2::real))", "solveFor x", "solutions L"],
1342 ("Test", ["sqroot-test", "univariate", "equation", "test"],
1343 ["Test", "squ-equ-test-subpbl1"]))];
1344 Iterator 2; (*! ! ! 1 CalcTree inbetween reset_states (); *)
1346 autoCalculate 2 CompleteCalc;
1347 moveActiveFormula 2 ([2],Res);
1348 replaceFormula 2 "- 1 + x = 0" (*i.e. repeats input*);
1349 (*... returns <ERROR> formula not changed </ERROR>*)
1351 val ((pt,_),_) = get_calc 2;
1352 val p = get_pos 2 1;
1353 val (Form f, tac, asms) = ME_Misc.pt_extract (pt, p);
1354 if UnparseC.term f = "- 1 + x = 0" andalso p = ([2], Res) then () else
1355 error "FE-interface.sml: diff.behav. in FORMULA:replace} right 1";
1356 if map fst3 (ME_Misc.get_interval ([2],Res) ([],Res) 9999 pt) =
1357 [([2], Res), ([3], Pbl), ([3, 1], Frm), ([3, 1], Res), ([3, 2], Res),
1358 ([3], Res), ([4], Res), ([], Res)] then () (*nothing deleted!*) else
1359 error "FE-interface.sml: diff.behav. in FORMULA:replace} right 2b";
1362 "--------- replaceFormula {SOL:MAN:FOR:replace} other----"; (*UC 30.3.2.5 p.176*)
1363 "--------- replaceFormula {SOL:MAN:FOR:replace} other----";
1364 "--------- replaceFormula {SOL:MAN:FOR:replace} other----";
1365 (*\label{SOLVE:MANUAL:FORMULA:replace}*)
1366 CalcTree [(["equality (x+1=(2::real))", "solveFor x", "solutions L"],
1367 ("Test", ["sqroot-test", "univariate", "equation", "test"],
1368 ["Test", "squ-equ-test-subpbl1"]))];
1371 autoCalculate 1 CompleteCalc;
1372 moveActiveFormula 1 ([2],Res); (*there is "- 1 + x = 0"*)
1373 replaceFormula 1 "x - 1 = 0"; (*<-------------------------------------*)
1374 (*... returns calcChangedEvent with*)
1375 val (unc, del, gen) = (([1],Res), ([4],Res), ([2],Res));
1376 getFormulaeFromTo 1 unc gen 99999 (*all levels*) false;
1378 val ((pt,_),_) = get_calc 1;
1379 Test_Tool.show_pt pt;
1380 val p = get_pos 1 1;
1381 val (Form f, tac, asms) = ME_Misc.pt_extract (pt, p);
1382 if UnparseC.term f = "x - 1 = 0" andalso p = ([2], Res) then () else
1383 error "FE-interface.sml: diff.behav. in FORMULA:replace} other 1";
1384 (* for getting the list in whole length ...
1385 (*default_print_depth 99*) map fst3 (ME_Misc.get_interval ([1],Res) ([],Res) 9999 pt); (*default_print_depth 3*)
1387 if map fst3 (ME_Misc.get_interval ([1],Res) ([],Res) 9999 pt) =
1388 [([1], Res), ([2, 1], Frm), ([2, 1], Res), ([2, 2], Res), ([2, 3], Res),
1389 ([2, 4], Res), ([2, 5], Res), ([2, 6], Res), ([2, 7], Res),
1390 ([2, 8], Res), ([2, 9], Res), ([2], Res)] then () else
1391 error "FE-interface.sml: diff.behav. in FORMULA:replace} other 2";
1394 "--------- replaceFormula {SOL:MAN:FOR:replace} other 2--"; (*UC 30.3.2.5 p.176*)
1395 "--------- replaceFormula {SOL:MAN:FOR:replace} other 2--";
1396 "--------- replaceFormula {SOL:MAN:FOR:replace} other 2--";
1397 (*\label{SOLVE:MANUAL:FORMULA:replace}*)
1398 CalcTree [(["equality (x+1=(2::real))", "solveFor x", "solutions L"],
1399 ("Test", ["sqroot-test", "univariate", "equation", "test"],
1400 ["Test", "squ-equ-test-subpbl1"]))];
1403 autoCalculate 1 CompleteCalc;
1404 moveActiveFormula 1 ([2],Res); (*there is "- 1 + x = 0"*)
1405 replaceFormula 1 "x = 1"; (*<-------------------------------------*)
1406 (*... returns calcChangedEvent with ...*)
1407 val (unc, del, gen) = (([1],Res), ([4],Res), ([3,2],Res));
1408 getFormulaeFromTo 1 unc gen 99999 (*all levels*) false;
1411 val ((pt,_),_) = get_calc 1;
1412 Test_Tool.show_pt pt; (*error: ...ME_Misc.get_interval drops ([3,2],Res) ...*)
1413 val (t,_) = get_obj g_result pt [3,2]; UnparseC.term t;
1414 if map fst3 (ME_Misc.get_interval ([1],Res) ([],Res) 9999 pt) =
1415 [([1], Res), ([2], Res), ([3], Pbl), ([3, 1], Frm), ([3, 1], Res),
1416 ([3, 2, 1], Frm), ([3, 2, 1], Res), ([3, 2, 2], Res),
1417 ([3,2],Res)] then () else
1418 error "FE-interface.sml: diff.behav. in FORMULA:replace} oth2 1";
1420 val p = get_pos 1 1;
1421 val (Form f, tac, asms) = ME_Misc.pt_extract (pt, p);
1422 if UnparseC.term f = "x = 1" andalso p = ([3,2], Res) then () else
1423 error "FE-interface.sml: diff.behav. in FORMULA:replace} oth2 2";
1426 "--------- replaceFormula {SOL:MAN:FOR:replace} NOTok----"; (*UC 30.3.2.5 p.176*)
1427 "--------- replaceFormula {SOL:MAN:FOR:replace} NOTok----";
1428 "--------- replaceFormula {SOL:MAN:FOR:replace} NOTok----";
1429 (*\label{SOLVE:MANUAL:FORMULA:replace}*)
1430 CalcTree [(["equality (x+1=(2::real))", "solveFor x", "solutions L"],
1431 ("Test", ["sqroot-test", "univariate", "equation", "test"],
1432 ["Test", "squ-equ-test-subpbl1"]))];
1435 autoCalculate 1 CompleteCalc;
1436 moveActiveFormula 1 ([2],Res); (*there is "- 1 + x = 0"*)
1437 replaceFormula 1 "x - 4711 = 0";
1438 (*... returns <ERROR> no derivation found </ERROR>*)
1440 val ((pt,_),_) = get_calc 1;
1441 Test_Tool.show_pt pt;
1442 val p = get_pos 1 1;
1443 val (Form f, tac, asms) = ME_Misc.pt_extract (pt, p);
1444 if UnparseC.term f = "- 1 + x = 0" andalso p = ([2], Res) then () else
1445 error "FE-interface.sml: diff.behav. in FORMULA:replace} NOTok";
1448 "--------- UC errpat chain-rule-diff-both, fillpat by input ------";
1449 "--------- UC errpat chain-rule-diff-both, fillpat by input ------";
1450 "--------- UC errpat chain-rule-diff-both, fillpat by input ------";
1452 [(["functionTerm (x \<up> 2 + sin (x \<up> 4))", "differentiateFor x", "derivative f_f'"],
1453 ("Isac_Knowledge", ["derivative_of", "function"], ["diff", "differentiate_on_R"]))];
1456 autoCalculate 1 CompleteCalcHead;
1457 autoCalculate 1 (Steps 1);
1458 autoCalculate 1 (Steps 1);(*([1], Res), d_d x (x \<up> 2) + d_d x (sin (x \<up> 4))*)
1459 appendFormula 1 "d_d x (x \<up> 2) + cos (4 * x \<up> 3)" (*|> Future.join*); (*<<<<<<<=========================*)
1460 (* the check for errpat is maximally liberal (whole term modulo "nrls" from "type met"),
1461 would recognize "cos (4 * x \<up> (4 - 1)) + 2 * x" as well.
1462 results in <CALCMESSAGE> error pattern #chain-rule-diff-both# </CALCMESSAGE>
1463 instead of <CALCMESSAGE> no derivation found </CALCMESSAGE> *)
1464 val ((pt,pos), _) = get_calc 1;
1465 val p = get_pos 1 1;
1466 val (Form f, _, asms) = ME_Misc.pt_extract (pt, p);
1468 if p = ([1], Res) andalso UnparseC.term f = "d_d x (x \<up> 2) + d_d x (sin (x \<up> 4))"
1469 then case get_obj g_tac pt (fst p) of Rewrite_Inst (["(''bdv'', x)"],
1470 ("diff_sum", thm)) => () | _ => error "embed fun fill_form changed 0"
1471 | _ => error "embed fun fill_form changed 1"
1472 else error "embed fun fill_form changed 2";
1474 (*========== inhibit exn WN1130621 Isabelle2012-->13 !thehier! ====================
1475 findFillpatterns 1 "chain-rule-diff-both"; (*<<<<<<<=================================*)
1476 (*<CALCMESSAGE> fill patterns #fill-d_d-arg#d_d x (x \<up> 2) + d_d x (sin (x \<up> 4)) =
1477 d_d x (x \<up> 2) + cos (x \<up> 4) * d_d x ?_dummy_1#fill-both-args#...#...#... *)
1478 val ((pt,pos),_) = get_calc 1;
1479 val p = get_pos 1 1;
1481 val (Form f, _, asms) = ME_Misc.pt_extract (pt, p);
1482 if p = ([1], Res) andalso UnparseC.term f = "d_d x (x \<up> 2) + d_d x (sin (x \<up> 4))" andalso
1483 get_obj g_tac pt (fst p) = Rewrite_Inst (["(''bdv'', x)"], ("diff_sum", "Diff.diff_sum"(*?!?*)))
1485 else error "embed fun fill_form changed 2";
1487 (* if we assume, that the fill-patterns are ordered such that the 1st has large gaps
1488 and the last has no gaps, then the number of fill-patterns would suffice
1489 for the DialogGuide to select appropriately. *)
1490 requestFillformula 1 ("chain-rule-diff-both", "fill-both-args");(*<<<<<<<============*)
1491 (*<AUTOCALC> ([1], Res) ([2], Res) ([2], Res) </AUTOCALC>*)
1492 val ((pt,pos),_) = get_calc 1;
1493 val p = get_pos 1 1;
1494 val (Form f, _, asms) = ME_Misc.pt_extract (pt, p);
1495 if p = ([1], Res) andalso existpt [2] pt andalso
1496 UnparseC.term f = "d_d x (x \<up> 2) + d_d x (sin (x \<up>\<up> 4))" andalso
1497 get_obj g_tac pt (fst p) = Rewrite_Inst (["(''bdv'', x)"], ("diff_sum", "Diff.diff_sum"))
1498 then () else error "embed fun fill_form changed 3";
1500 inputFillFormula 1 "d_d x (x \<up> 2) + cos (x \<up> 4) * d_d x (x \<up> 4)";(*<<<<<<<=====*)
1501 val ((pt, _),_) = get_calc 1;
1502 val p = get_pos 1 1;
1503 val (Form f, _, asms) = ME_Misc.pt_extract (pt, p);
1504 if p = ([2], Res) andalso
1505 UnparseC.term f = "d_d x (x \<up> 2) + cos (x \<up> 4) * d_d x (x \<up> 4)" andalso
1506 get_obj g_tac pt (fst p) = Rewrite_Inst (["(''bdv'', x)"], ("diff_sin_chain", ""))
1507 then () else error "inputFillFormula changed 11";
1509 autoCalculate 1 CompleteCalc;
1511 "~~~~~ final check: the input formula is inserted as it would have been correct from beginning";
1512 val ((pt, _),_) = get_calc 1;
1513 val p = get_pos 1 1;
1514 val (Form f, _, asms) = ME_Misc.pt_extract (pt, p);
1515 if p = ([], Res) andalso UnparseC.term f = "2 * x + cos (x \<up> 4) * 4 * x \<up> 3"
1516 then () else error "inputFillFormula changed 12";
1517 Test_Tool.show_pt pt;
1519 (([], Frm), Diff (x \<up> 2 + sin (x \<up> 4), x)),
1520 (([1], Frm), d_d x (x \<up> 2 + sin (x \<up> 4))),
1521 (([1], Res), d_d x (x \<up> 2) + d_d x (sin (x \<up> 4))),
1522 (([2], Res), d_d x (x \<up> 2) + cos (x \<up> 4) * d_d x (x \<up> 4)), (*<<<<<<<=====*)
1523 (([3], Res), d_d x (x \<up> 2) + cos (x \<up> 4) * (4 * x \<up> (4 - 1))),
1524 (([4], Res), 2 * x \<up> (2 - 1) + cos (x \<up> 4) * (4 * x \<up> (4 - 1))),
1525 (([5], Res), 2 * x + cos (x \<up> 4) * 4 * x \<up> 3),
1526 (([], Res), 2 * x + cos (x \<up> 4) * 4 * x \<up> 3)] *)
1527 ============ inhibit exn WN1130621 Isabelle2012-->13 !thehier! ==================*)
1530 "--------- UC errpat add-fraction, fillpat by input --------------";
1531 "--------- UC errpat add-fraction, fillpat by input --------------";
1532 "--------- UC errpat add-fraction, fillpat by input --------------";
1533 (*cp from BridgeLog Java <=> SML*)
1534 CalcTree [([], References.empty)];
1537 moveActiveFormula 1 ([],Pbl);
1538 replaceFormula 1 "Simplify (5 * x / (4 * y) + 3 * x / (4 * y))";
1539 autoCalculate 1 CompleteCalcHead;
1540 autoCalculate 1 (Steps 1);
1541 appendFormula 1 "8 * x / (8 * y)" (*|> Future.join*);
1542 (*<CALCMESSAGE> no derivation found </CALCMESSAGE>
1543 --- but in BridgeLog Java <=> SML:
1544 <CALCMESSAGE> error pattern #addition-of-fractions# </CALCMESSAGE>*)
1547 "--------- UC errpat, fillpat step to Rewrite --------------------";
1548 "--------- UC errpat, fillpat step to Rewrite --------------------";
1549 "--------- UC errpat, fillpat step to Rewrite --------------------";
1552 [(["functionTerm ((x \<up> 2) \<up> 3 + sin (x \<up> 4))",
1553 "differentiateFor x", "derivative f_f'"],
1554 ("Isac_Knowledge", ["derivative_of", "function"],
1555 ["diff", "differentiate_on_R"]))]; (*<<<======= EP is directly in script*)
1558 autoCalculate 1 CompleteCalc;
1559 val ((pt,p),_) = get_calc 1; Test_Tool.show_pt pt;
1562 "--------- UC errpat, fillpat step to Rewrite_Set ----------------";
1563 "--------- UC errpat, fillpat step to Rewrite_Set ----------------";
1564 "--------- UC errpat, fillpat step to Rewrite_Set ----------------";
1566 [(["functionTerm ((x \<up> 2) \<up> 3 + sin (x \<up> 4))",
1567 "differentiateFor x", "derivative f_f'"],
1568 ("Isac_Knowledge", ["derivative_of", "function"],
1569 ["diff", "after_simplification"]))]; (*<<<======= EP is in a ruleset*)
1572 autoCalculate 1 CompleteCalcHead;
1573 autoCalculate 1 (Steps 1); fetchProposedTactic 1;
1574 autoCalculate 1 (Steps 1); fetchProposedTactic 1;
1577 <CALCID> 1 </CALCID>
1578 <TACTICERRORPATTERNS>
1580 <STRING> chain-rule-diff-both </STRING>
1581 <STRING> cancel </STRING>
1583 <REWRITESETINSTTACTIC name="Rewrite_Set_Inst">
1584 <RULESET> norm_diff </RULESET>
1599 </REWRITESETINSTTACTIC>
1600 </TACTICERRORPATTERNS>
1604 (*WN1208 postponed due to efforts required for stepToErrorPatterns (NEW rewrite_set_)*)
1605 stepToErrorPatterns 1; (*--> calcChanged, rule immediately calls... *)
1606 stepOnErrorPatterns 1; (*--> calcChanged, rule calls getTactic and displays it *)
1607 (* then --- UC errpat, fillpat by input ---*)
1609 autoCalculate 1 CompleteCalc;
1610 val ((pt,p),_) = get_calc 1; Test_Tool.show_pt pt;
1611 (*WN1208 postponed due to efforts required for stepToErrorPatterns (NEW rewrite_set_)*)