4 (c) due to copyright terms
6 use"../smltest/ME/inform.sml";
10 "-----------------------------------------------------------------";
11 "table of contents -----------------------------------------------";
12 "-----------------------------------------------------------------";
13 "appendForm with miniscript with mini-subpbl:";
14 "--------- appendFormula: on Res + equ_nrls ----------------------";
15 "--------- appendFormula: on Frm + equ_nrls ----------------------";
16 "--------- appendFormula: on Res + NO deriv ----------------------";
17 "--------- appendFormula: on Res + late deriv --------------------";
18 "--------- appendFormula: on Res + late deriv [x = 3 + -2]---///--";
19 "replaceForm with miniscript with mini-subpbl:";
20 "--------- replaceFormula: on Res + = ----------------------------";
21 "--------- replaceFormula: on Res + = 1st Nd ---------------------";
22 "--------- replaceFormula: on Frm + = 1st Nd ---------------------";
23 "--------- replaceFormula: cut calculation -----------------------";
24 "--------- replaceFormula: cut calculation -----------------------";
25 (* 040307 copied from informtest.sml ... old versions
26 "--------- maximum-example, UC: Modeling / modifyCalcHead --------";*)
27 "--------- syntax error ------------------------------------------";
29 "--------- CAS-command on ([],Pbl) -------------------------------";
30 "--------- CAS-command on ([],Pbl) FE-interface ------------------";
31 "--------- inform [rational,simplification] ----------------------";
32 "--------- Take as 1st tac, start with <NEW> (CAS input) ---------";
33 "--------- Take as 1st tac, start from exp -----------------------";
34 "--------- init_form, start with <NEW> (CAS input) ---------------";
35 "-----------------------------------------------------------------";
36 "-----------------------------------------------------------------";
37 "-----------------------------------------------------------------";
44 "--------- appendFormula: on Res + equ_nrls ----------------------";
45 "--------- appendFormula: on Res + equ_nrls ----------------------";
46 "--------- appendFormula: on Res + equ_nrls ----------------------";
47 val Script sc = (#scr o get_met) ["Test","squ-equ-test-subpbl1"];
48 (writeln o term2str) sc;
49 val Script sc = (#scr o get_met) ["Test","solve_linear"];
50 (writeln o term2str) sc;
53 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
54 ("Test", ["sqroot-test","univariate","equation","test"],
55 ["Test","squ-equ-test-subpbl1"]))];
56 Iterator 1; moveActiveRoot 1;
57 autoCalculate 1 CompleteCalcHead;
58 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
59 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
61 appendFormula 1 "-2 * 1 + (1 + x) = 0"; refFormula 1 (get_pos 1 1);
62 val ((pt,_),_) = get_calc 1;
63 val str = pr_ptree pr_short pt;
65 if str = ". ----- pblobj -----\n1. x + 1 = 2\n2. x + 1 + -1 * 2 = 0\n2.1. x + 1 + -1 * 2 = 0\n2.2. -1 * 2 + (x + 1) = 0\n2.3. -1 * 2 + (1 + x) = 0\n2.4. 1 + (-1 * 2 + x) = 0\n2.5. 1 + (-2 + x) = 0\n2.6. 1 + (-2 * 1 + x) = 0\n" then ()
66 else error "inform.sml: diff.behav.appendFormula: on Res + equ 1";
68 moveDown 1 ([ ],Pbl); refFormula 1 ([1],Frm); (*x + 1 = 2*)
69 moveDown 1 ([1],Frm); refFormula 1 ([1],Res); (*x + 1 + -1 * 2 = 0*)
71 (*the seven steps of detailed derivation*)
72 moveDown 1 ([1 ],Res); refFormula 1 ([2,1],Frm);
73 moveDown 1 ([2,1],Frm); refFormula 1 ([2,1],Res);
74 moveDown 1 ([2,1],Res); refFormula 1 ([2,2],Res);
75 moveDown 1 ([2,2],Res); refFormula 1 ([2,3],Res);
76 moveDown 1 ([2,3],Res); refFormula 1 ([2,4],Res);
77 moveDown 1 ([2,4],Res); refFormula 1 ([2,5],Res);
78 moveDown 1 ([2,5],Res); refFormula 1 ([2,6],Res);
79 val ((pt,_),_) = get_calc 1;
80 if "-2 * 1 + (1 + x) = 0" = term2str (fst (get_obj g_result pt [2,6])) then()
81 else error "inform.sml: diff.behav.appendFormula: on Res + equ 2";
83 fetchProposedTactic 1; (*takes Iterator 1 _1_*)
84 val (_,(tac,_,_)::_) = get_calc 1;
85 if tac = Rewrite_Set "Test_simplify" then ()
86 else error "inform.sml: diff.behav.appendFormula: on Res + equ 3";
87 autoCalculate 1 CompleteCalc;
88 val ((pt,_),_) = get_calc 1;
89 if "[x = 1]" = term2str (fst (get_obj g_result pt [])) then ()
90 else error "inform.sml: diff.behav.appendFormula: on Res + equ 4";
91 (* autoCalculate 1 CompleteCalc;
92 val ((pt,p),_) = get_calc 1;
93 (writeln o istates2str) (get_obj g_loc pt [ ]);
94 (writeln o istates2str) (get_obj g_loc pt [1]);
95 (writeln o istates2str) (get_obj g_loc pt [2]);
96 (writeln o istates2str) (get_obj g_loc pt [3]);
97 (writeln o istates2str) (get_obj g_loc pt [3,1]);
98 (writeln o istates2str) (get_obj g_loc pt [3,2]);
99 (writeln o istates2str) (get_obj g_loc pt [4]);
102 "----------------------------------------------------------";
103 val fod = make_deriv (theory "Isac") Atools_erls
104 ((#rules o rep_rls) Test_simplify)
105 (sqrt_right false (theory "Pure")) NONE
106 (str2term "x + 1 + -1 * 2 = 0");
107 (writeln o trtas2str) fod;
109 val ifod = make_deriv (theory "Isac") Atools_erls
110 ((#rules o rep_rls) Test_simplify)
111 (sqrt_right false (theory "Pure")) NONE
112 (str2term "-2 * 1 + (1 + x) = 0");
113 (writeln o trtas2str) ifod;
114 fun equal (_,_,(t1, _)) (_,_,(t2, _)) = t1=t2;
115 val (fod', rifod') = dropwhile' equal (rev fod) (rev ifod);
116 val der = fod' @ (map rev_deriv' rifod');
117 (writeln o trtas2str) der;
118 "----------------------------------------------------------";
121 "--------- appendFormula: on Frm + equ_nrls ----------------------";
122 "--------- appendFormula: on Frm + equ_nrls ----------------------";
123 "--------- appendFormula: on Frm + equ_nrls ----------------------";
125 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
126 ("Test", ["sqroot-test","univariate","equation","test"],
127 ["Test","squ-equ-test-subpbl1"]))];
128 Iterator 1; moveActiveRoot 1;
129 autoCalculate 1 CompleteCalcHead;
130 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1) (*x + 1 = 2*);
132 appendFormula 1 "2+ -1 + x = 2"; refFormula 1 (get_pos 1 1);
134 moveDown 1 ([],Pbl); refFormula 1 ([1],Frm) (*x + 1 = 2*);
136 moveDown 1 ([1 ],Frm); refFormula 1 ([1,1],Frm);
137 moveDown 1 ([1,1],Frm); refFormula 1 ([1,1],Res);
138 moveDown 1 ([1,1],Res); refFormula 1 ([1,2],Res);
139 moveDown 1 ([1,2],Res); refFormula 1 ([1,3],Res);
140 moveDown 1 ([1,3],Res); refFormula 1 ([1,4],Res);
141 moveDown 1 ([1,4],Res); refFormula 1 ([1,5],Res);
142 moveDown 1 ([1,5],Res); refFormula 1 ([1,6],Res);
143 val ((pt,_),_) = get_calc 1;
144 if "2 + -1 + x = 2" = term2str (fst (get_obj g_result pt [1,6])) then()
145 else error "inform.sml: diff.behav.appendFormula: on Frm + equ 1";
147 fetchProposedTactic 1; (*takes Iterator 1 _1_*)
148 val (_,(tac,_,_)::_) = get_calc 1;
149 if tac = Rewrite_Set "norm_equation" then ()
150 else error "inform.sml: diff.behav.appendFormula: on Frm + equ 2";
151 autoCalculate 1 CompleteCalc;
152 val ((pt,_),_) = get_calc 1;
153 if "[x = 1]" = term2str (fst (get_obj g_result pt [])) then ()
154 else error "inform.sml: diff.behav.appendFormula: on Frm + equ 3";
157 "--------- appendFormula: on Res + NO deriv ----------------------";
158 "--------- appendFormula: on Res + NO deriv ----------------------";
159 "--------- appendFormula: on Res + NO deriv ----------------------";
161 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
162 ("Test", ["sqroot-test","univariate","equation","test"],
163 ["Test","squ-equ-test-subpbl1"]))];
164 Iterator 1; moveActiveRoot 1;
165 autoCalculate 1 CompleteCalcHead;
166 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
167 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
169 appendFormula 1 "x = 2";
170 val ((pt,p),_) = get_calc 1;
171 val str = pr_ptree pr_short pt;
173 if str = ". ----- pblobj -----\n1. x + 1 = 2\n" andalso p = ([1], Res)
175 else error "inform.sml: diff.behav.appendFormula: Res + NOder 1";
177 fetchProposedTactic 1;
178 val (_,(tac,_,_)::_) = get_calc 1;
179 if tac = Rewrite_Set "Test_simplify" then ()
180 else error "inform.sml: diff.behav.appendFormula: Res + NOder 2";
181 autoCalculate 1 CompleteCalc;
182 val ((pt,_),_) = get_calc 1;
183 if "[x = 1]" = term2str (fst (get_obj g_result pt [])) then ()
184 else error "inform.sml: diff.behav.appendFormula: on Frm + equ 3";
187 "--------- appendFormula: on Res + late deriv --------------------";
188 "--------- appendFormula: on Res + late deriv --------------------";
189 "--------- appendFormula: on Res + late deriv --------------------";
191 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
192 ("Test", ["sqroot-test","univariate","equation","test"],
193 ["Test","squ-equ-test-subpbl1"]))];
194 Iterator 1; moveActiveRoot 1;
195 autoCalculate 1 CompleteCalcHead;
196 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
197 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
199 appendFormula 1 "x = 1";
200 val ((pt,p),_) = get_calc 1;
201 val str = pr_ptree pr_short pt;
203 if str = ". ----- pblobj -----\n1. x + 1 = 2\n2. x + 1 + -1 * 2 = 0\n3. ----- pblobj -----\n3.1. -1 + x = 0\n3.2. x = 0 + -1 * -1\n3.2.1. x = 0 + -1 * -1\n3.2.2. x = 0 + 1\n" andalso p = ([3,2], Res)
204 then () (*finds 1 step too early: ([3,2], Res) "x = 1" also by script !!!*)
205 else error "inform.sml: diff.behav.appendFormula: Res + late d 1";
207 fetchProposedTactic 1;
208 val (_,(tac,_,_)::_) = get_calc 1;
209 if tac = Check_Postcond ["linear", "univariate", "equation", "test"] then ()
210 else error "inform.sml: diff.behav.appendFormula: Res + late d 2";
211 autoCalculate 1 CompleteCalc;
212 val ((pt,_),_) = get_calc 1;
213 if "[x = 1]" = term2str (fst (get_obj g_result pt [])) then ()
214 else error "inform.sml: diff.behav.appendFormula: Res + late d 3";
217 "--------- appendFormula: on Res + late deriv [x = 3 + -2]---///--";
218 "--------- appendFormula: on Res + late deriv [x = 3 + -2]---///--";
219 "--------- appendFormula: on Res + late deriv [x = 3 + -2]---///--";
221 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
222 ("Test", ["sqroot-test","univariate","equation","test"],
223 ["Test","squ-equ-test-subpbl1"]))];
224 Iterator 1; moveActiveRoot 1;
225 autoCalculate 1 CompleteCalcHead;
226 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
227 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
228 appendFormula 1 "[x = 3 + -2*1]";
229 val ((pt,p),_) = get_calc 1;
230 val str = pr_ptree pr_short pt;
232 if str=". ----- pblobj -----\n1. x + 1 = 2\n2. x + 1 + -1 * 2 = 0\n3. ----- pblobj -----\n3.1. -1 + x = 0\n3.2. x = 0 + -1 * -1\n4. [x = 1]\n4.1. [x = 1]\n4.2. [x = -2 + 3]\n4.3. [x = 3 + -2]\n" then ()
233 else error "inform.sml: diff.behav.appendFormula: Res + latEE 1";
234 autoCalculate 1 CompleteCalc;
235 val ((pt,p),_) = get_calc 1;
236 if "[x = 3 + -2 * 1]" = term2str (fst (get_obj g_result pt [])) then ()
237 (* ~~~~~~~~~~ simplify as last step in any script ?!*)
238 else error "inform.sml: diff.behav.appendFormula: Res + latEE 2";
242 "--------- replaceFormula: on Res + = ----------------------------";
243 "--------- replaceFormula: on Res + = ----------------------------";
244 "--------- replaceFormula: on Res + = ----------------------------";
246 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
247 ("Test", ["sqroot-test","univariate","equation","test"],
248 ["Test","squ-equ-test-subpbl1"]))];
249 Iterator 1; moveActiveRoot 1;
250 autoCalculate 1 CompleteCalcHead;
251 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
252 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
253 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*-1 + x*);
255 replaceFormula 1 "-2 * 1 + (1 + x) = 0"; refFormula 1 (get_pos 1 1);
256 val ((pt,_),_) = get_calc 1;
257 val str = pr_ptree pr_short pt;
259 if str=". ----- pblobj -----\n1. x + 1 = 2\n2. x + 1 + -1 * 2 = 0\n2.1. x + 1 + -1 * 2 = 0\n2.2. -1 * 2 + (x + 1) = 0\n2.3. -1 * 2 + (1 + x) = 0\n2.4. 1 + (-1 * 2 + x) = 0\n2.5. 1 + (-2 + x) = 0\n2.6. 1 + (-2 * 1 + x) = 0\n" then()
260 else error "inform.sml: diff.behav.replaceFormula: on Res += 1";
261 autoCalculate 1 CompleteCalc;
262 val ((pt,pos as(p,_)),_) = get_calc 1;
263 if pos=([],Res)andalso"[x = 1]"=(term2str o fst)(get_obj g_result pt p)then()
264 else error "inform.sml: diff.behav.replaceFormula: on Res + = 2";
267 "--------- replaceFormula: on Res + = 1st Nd ---------------------";
268 "--------- replaceFormula: on Res + = 1st Nd ---------------------";
269 "--------- replaceFormula: on Res + = 1st Nd ---------------------";
271 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
272 ("Test", ["sqroot-test","univariate","equation","test"],
273 ["Test","squ-equ-test-subpbl1"]))];
274 Iterator 1; moveActiveRoot 1;
275 autoCalculate 1 CompleteCalcHead;
276 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
277 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
279 replaceFormula 1 "x + 1 = 4 + -2"; refFormula 1 (get_pos 1 1);
280 val ((pt,_),_) = get_calc 1;
281 val str = pr_ptree pr_short pt;
283 if str=". ----- pblobj -----\n1. x + 1 = 2\n1.1. x + 1 = 2\n1.2. 1 + x = 2\n1.3. 1 + x = -2 + 4\n1.4. x + 1 = -2 + 4\n" then ()
284 else error "inform.sml: diff.behav.replaceFormula: on Res 1 + = 1";
285 autoCalculate 1 CompleteCalc;
286 val ((pt,pos as(p,_)),_) = get_calc 1;
287 if pos=([],Res)andalso"[x = 1]"=(term2str o fst)(get_obj g_result pt p)then()
288 else error "inform.sml: diff.behav.replaceFormula: on Res + = 2";
291 "--------- replaceFormula: on Frm + = 1st Nd ---------------------";
292 "--------- replaceFormula: on Frm + = 1st Nd ---------------------";
293 "--------- replaceFormula: on Frm + = 1st Nd ---------------------";
295 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
296 ("Test", ["sqroot-test","univariate","equation","test"],
297 ["Test","squ-equ-test-subpbl1"]))];
298 Iterator 1; moveActiveRoot 1;
299 autoCalculate 1 CompleteCalcHead;
300 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
302 replaceFormula 1 "x + 1 = 4 + -2"; refFormula 1 (get_pos 1 1);
303 val ((pt,_),_) = get_calc 1;
304 val str = pr_ptree pr_short pt;
306 if str=". ----- pblobj -----\n1. x + 1 = 2\n1.1. x + 1 = 2\n1.2. 1 + x = 2\n1.3. 1 + x = -2 + 4\n1.4. x + 1 = -2 + 4\n" then ()
307 else error "inform.sml: diff.behav.replaceFormula: on Frm 1 + = 1";
308 autoCalculate 1 CompleteCalc;
309 val ((pt,pos as(p,_)),_) = get_calc 1;
310 if pos=([],Res)andalso"[x = 1]"=(term2str o fst)(get_obj g_result pt p)then()
311 else error "inform.sml: diff.behav.replaceFormula: on Frm 1 + = 2";
314 "--------- replaceFormula: cut calculation -----------------------";
315 "--------- replaceFormula: cut calculation -----------------------";
316 "--------- replaceFormula: cut calculation -----------------------";
318 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
319 ("Test", ["sqroot-test","univariate","equation","test"],
320 ["Test","squ-equ-test-subpbl1"]))];
321 Iterator 1; moveActiveRoot 1;
322 autoCalculate 1 CompleteCalc;
323 moveActiveRoot 1; moveActiveDown 1;
324 if get_pos 1 1 = ([1], Frm) then ()
325 else error "inform.sml: diff.behav. cut calculation 1";
327 replaceFormula 1 "x + 1 = 4 + -2"; refFormula 1 (get_pos 1 1);
328 val ((pt,p),_) = get_calc 1;
329 val str = pr_ptree pr_short pt;
331 if p = ([1], Res) then ()
332 else error "inform.sml: diff.behav. cut calculation 2";
336 (* 040307 copied from informtest.sml; ... old version
337 "---------------- maximum-example, UC: Modeling / modifyCalcHead -";
338 "---------------- maximum-example, UC: Modeling / modifyCalcHead -";
339 "---------------- maximum-example, UC: Modeling / modifyCalcHead -";
342 val elems = ["fixedValues [r=Arbfix]","maximum A","valuesFor [a,b]",
343 "relations [A=a*b, (a/2)^^^2 + (b/2)^^^2 = r^^^2]",
344 "relations [A=a*b, (a/2)^^^2 + (b/2)^^^2 = r^^^2]",
345 "relations [A=a*b, a/2=r*sin alpha, b/2=r*cos alpha]",
346 (*^^^ these are the elements for the root-problem (in variants)*)
347 (*vvv these are elements required for subproblems*)
348 "boundVariable a","boundVariable b","boundVariable alpha",
349 "interval {x::real. 0 <= x & x <= 2*r}",
350 "interval {x::real. 0 <= x & x <= 2*r}",
351 "interval {x::real. 0 <= x & x <= pi}",
352 "errorBound (eps=(0::real))"]
353 (*specifying is not interesting for this example*)
354 val spec = ("DiffApp", ["maximum_of","function"],
355 ["DiffApp","max_by_calculus"]);
356 (*the empty model with descriptions for user-guidance by Model_Problem*)
357 val empty_model = [Given ["fixedValues []"],
358 Find ["maximum", "valuesFor"],
359 Relate ["relations []"]];
362 (*!!!!!!!!!!!!!!!!! DON'T USE me FOR FINDING nxt !!!!!!!!!!!!!!!!!!*)
363 val (p,_,f,nxt,_,pt) = CalcTreeTEST [(elems, spec)];
364 (*val nxt = ("Model_Problem", ...*)
365 val pbl = get_obj g_pbl pt (fst p); (writeln o (itms2str_ ctxt)) pbl;
367 val (p,_,f,nxt,_,pt) = me nxt p c pt;
368 (*nxt = Add_Given "fixedValues [r = Arbfix]"*)
369 val pbl = get_obj g_pbl pt (fst p); (writeln o (itms2str_ ctxt)) pbl;
371 (0 ,[] ,false ,#Given ,Inc fixedValues [] ,(??.empty, [])),
372 (0 ,[] ,false ,#Find ,Inc maximum ,(??.empty, [])),
373 (0 ,[] ,false ,#Find ,Inc valuesFor ,(??.empty, [])),
374 (0 ,[] ,false ,#Relate ,Inc relations [] ,(??.empty, []))]*)
376 (*the empty CalcHead is checked w.r.t the model and re-established as such*)
377 val (b,pt,ocalhd) = input_icalhd pt (p,"", empty_model, Pbl, e_spec);
378 val pbl = get_obj g_pbl pt (fst p); (writeln o (itms2str_ ctxt)) pbl;
379 if ocalhd2str ocalhd = "(Pbl, ??.empty, [\n(0 ,[] ,false ,#Given ,Inc fixedValues [] ,(??.empty, [])),\n(0 ,[] ,false ,#Find ,Inc maximum ,(??.empty, [])),\n(0 ,[] ,false ,#Find ,Inc valuesFor ,(??.empty, [])),\n(0 ,[] ,false ,#Relate ,Inc relations [] ,(??.empty, []))], [], \n(\"e_domID\", [\"e_pblID\"], [\"e_metID\"]) )" then () else error "informtest.sml: diff.behav. max 1";
381 (*there is one input to the model (could be more)*)
383 input_icalhd pt (p,"", [Given ["fixedValues [r=Arbfix]"],
384 Find ["maximum", "valuesFor"],
385 Relate ["relations"]], Pbl, e_spec);
386 val pbl = get_obj g_pbl pt (fst p); (writeln o (itms2str_ ctxt)) pbl;
387 if ocalhd2str ocalhd = "(Pbl, ??.empty, [\n(1 ,[1,2,3] ,true ,#Given ,Cor fixedValues [r = Arbfix] ,(fix_, [[r = Arbfix]])),\n(0 ,[] ,false ,#Find ,Inc maximum ,(??.empty, [])),\n(0 ,[] ,false ,#Find ,Inc valuesFor ,(??.empty, [])),\n(0 ,[] ,false ,#Relate ,Inc relations [] ,(??.empty, []))], [], \n(\"e_domID\", [\"e_pblID\"], [\"e_metID\"]) )" then ()
388 else error "informtest.sml: diff.behav. max 2";
390 (*this input is complete in variant 3, but the ME doesn't recognize FIXXXXME
391 val (b,pt''''',ocalhd) =
392 input_icalhd pt (p,"", [Given ["fixedValues [r=Arbfix]"],
393 Find ["maximum A", "valuesFor [a,b]"],
394 Relate ["relations [A=a*b, a/2=r*sin alpha, \
395 \b/2=r*cos alpha]"]], Pbl, e_spec);
396 val pbl = get_obj g_pbl pt''''' (fst p); (writeln o (itms2str_ ctxt)) pbl;
397 if ocalhd2str ocalhd = ------------^^^^^^^^^^ missing !!!*)
399 (*this input is complete in variant 1 (variant 3 does not work yet)*)
400 val (b,pt''''',ocalhd) =
401 input_icalhd pt (p,"", [Given ["fixedValues [r=Arbfix]"],
402 Find ["maximum A", "valuesFor [a,b]"],
403 Relate ["relations [A=a*b, \
404 \(a/2)^^^2 + (b/2)^^^2 = r^^^2]"]],
406 val pbl = get_obj g_pbl pt''''' (fst p); (writeln o (itms2str_ ctxt)) pbl;
408 modifycalcheadOK2xml 111 (bool2str b) ocalhd;
411 "--------- syntax error ------------------------------------------";
412 "--------- syntax error ------------------------------------------";
413 "--------- syntax error ------------------------------------------";
415 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
416 ("Test", ["sqroot-test","univariate","equation","test"],
417 ["Test","squ-equ-test-subpbl1"]))];
418 Iterator 1; moveActiveRoot 1;
419 autoCalculate 1 CompleteCalcHead;
420 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
421 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
423 appendFormula 1 " x - "; (*<ERROR> syntax error in ' x - ' </ERROR>*)
424 val ((pt,_),_) = get_calc 1;
425 val str = pr_ptree pr_short pt;
427 if str = ". ----- pblobj -----\n1. x + 1 = 2\n" then ()
428 else error "inform.sml: diff.behav.appendFormula: syntax error";
431 "--------- CAS-command on ([],Pbl) -------------------------------";
432 "--------- CAS-command on ([],Pbl) -------------------------------";
433 "--------- CAS-command on ([],Pbl) -------------------------------";
434 val (p,_,f,nxt,_,pt) =
435 CalcTreeTEST [([], ("e_domID", ["e_pblID"], ["e_metID"]))];
436 val ifo = "solve(x+1=2,x)";
437 val (_,(_,c,(pt,p))) = inform ([],[],(pt,p)) "solve(x+1=2,x)";
439 val nxt = ("Apply_Method",Apply_Method ["Test","squ-equ-test-subpbl1"]);
440 val (p,_,f,nxt,_,pt) = me nxt p [] pt;
441 if p = ([1], Frm) andalso f2str f = "x + 1 = 2" then ()
442 else error "inform.sml: diff.behav. CAScmd ([],Pbl)";
445 "--------- CAS-command on ([],Pbl) FE-interface ------------------";
446 "--------- CAS-command on ([],Pbl) FE-interface ------------------";
447 "--------- CAS-command on ([],Pbl) FE-interface ------------------";
449 CalcTree [([], ("e_domID", ["e_pblID"], ["e_metID"]))];
452 replaceFormula 1 "solve(x+1=2,x)";
453 autoCalculate 1 CompleteCalc;
454 val ((pt,p),_) = get_calc 1;
456 if p = ([], Res) then ()
457 else error "inform.sml: diff.behav. CAScmd ([],Pbl) FE-interface";
460 "--------- inform [rational,simplification] ----------------------";
461 "--------- inform [rational,simplification] ----------------------";
462 "--------- inform [rational,simplification] ----------------------";
464 CalcTree [(["Term (4/x - 3/y - 1)", "normalform N"],
465 ("Rational",["rational","simplification"],
466 ["simplification","of_rationals"]))];
467 Iterator 1; moveActiveRoot 1;
468 autoCalculate 1 CompleteCalcHead;
469 autoCalculate 1 (Step 1);
470 autoCalculate 1 (Step 1);
471 autoCalculate 1 (Step 1);
472 autoCalculate 1 (Step 1);
473 "--- input the next formula that _should_ be presented by mat-engine";
474 appendFormula 1 "(4 * y + -3 * x) / (x * y) + -1";
475 val ((pt,p),_) = get_calc 1;
476 if p = ([4], Res) andalso (length o children o (get_nd pt)) (fst p) = 2 then ()
477 else error ("inform.sml: [rational,simplification] 1");
479 "--- input the next formula that would be presented by mat-engine";
480 (*autoCalculate 1 (Step 1);*)
481 appendFormula 1 "(4 * y + -3 * x + -1 * (x * y)) / (x * y)";
482 val ((pt,p),_) = get_calc 1;
483 if p = ([5], Res) andalso (length o children o (get_nd pt)) (fst p) = 0 then ()
484 else error ("inform.sml: [rational,simplification] 2");
486 "--- input the exact final result";(*TODO: Exception- LIST "last_elem" raised*)
487 appendFormula 1 "(-3 * x + 4 * y + -1 * x * y) / (x * y)";
488 val ((pt,p),_) = get_calc 1;
489 if p = ([6], Res) andalso (length o children o (get_nd pt)) (fst p) = 2 then ()
490 else error ("inform.sml: [rational,simplification] 3");
493 "--------- Take as 1st tac, start with <NEW> (CAS input) ---------";
494 "--------- Take as 1st tac, start with <NEW> (CAS input) ---------";
495 "--------- Take as 1st tac, start with <NEW> (CAS input) ---------";
496 val t = str2term "Diff (x^^^2 + x + 1, x)";
497 case t of Const ("Diff.Diff", _) $ _ => ()
499 error "diff.sml behav.changed for CAS Diff (..., x)";
501 "-----------------------------------------------------------------";
503 (*2>*)CalcTree [([], ("e_domID", ["e_pblID"], ["e_metID"]))];
504 (*3>*)Iterator 1;moveActiveRoot 1;
505 "----- here the Headline has been finished";
506 (*4>*)moveActiveFormula 1 ([],Pbl);
507 (*5>*)replaceFormula 1 "Diff (x^2 + x + 1, x)";
508 val ((pt,_),_) = get_calc 1;
509 val PblObj {probl, meth, spec, fmz, env, loc, ...} = get_obj I pt [];
511 val (SOME istate, NONE) = loc;
513 writeln"-----------------------------------------------------------";
515 writeln (itms2str_ ctxt probl);
516 writeln (itms2str_ ctxt meth);
517 writeln (istate2str istate);
521 refFormula 1 ([],Pbl) (*--> correct CalcHead*);
522 (*081016 NOT necessary (but leave it in Java):*)
523 (*6>*)(*completeCalcHead*)autoCalculate 1 CompleteCalcHead;
524 "----- here the CalcHead has been completed --- ONCE MORE ?????";
526 (***difference II***)
527 val ((pt,p),_) = get_calc 1;
528 (*val p = ([], Pbl)*)
529 val PblObj {probl, meth, spec, fmz, env, loc, ...} = get_obj I pt [];
531 val (SOME istate, NONE) = loc;
532 print_depth 5; writeln (istate2str istate); print_depth 3;
535 ??.empty, Sundef, false)*)
536 print_depth 5; spec; print_depth 3;
538 ["derivative_of", "function"],
539 ["diff", "differentiate_on_R"]) : spec*)
540 writeln (itms2str_ ctxt probl);
542 (1 ,[1] ,true ,#Given ,Cor functionTerm (x ^^^ 2 + x + 1) ,(f_, [x ^^^ 2 + x + 1])),
543 (2 ,[1] ,true ,#Given ,Cor differentiateFor x ,(v_, [x])),
544 (3 ,[1] ,true ,#Find ,Cor derivative f_'_ ,(f_'_, [f_'_]))]*)
545 writeln (itms2str_ ctxt meth);
547 (1 ,[1] ,true ,#Given ,Cor functionTerm (x ^^^ 2 + x + 1) ,(f_, [x ^^^ 2 + x + 1])),
548 (2 ,[1] ,true ,#Given ,Cor differentiateFor x ,(v_, [x])),
549 (3 ,[1] ,true ,#Find ,Cor derivative f_'_ ,(f_'_, [f_'_]))]*)
550 writeln"-----------------------------------------------------------";
551 (*7>*)fetchProposedTactic 1 (*--> Apply_Method*);
552 (*WN081028 fixed <ERROR> helpless </ERROR> by inform returning ...(.,Met)*)
553 autoCalculate 1 CompleteCalc;
554 val ((pt,p),_) = get_calc 1;
555 val Form res = (#1 o pt_extract) (pt, ([],Res));
557 if p = ([], Res) andalso term2str res = "1 + 2 * x" then ()
558 else error "diff.sml behav.changed for Diff (x^2 + x + 1, x)";
561 "--------- Take as 1st tac, start from exp -----------------------";
562 "--------- Take as 1st tac, start from exp -----------------------";
563 "--------- Take as 1st tac, start from exp -----------------------";
564 (*the following input is copied from BridgeLog Java <==> SML,
565 omitting unnecessary inputs*)
567 (*2>*)CalcTree [(["functionTerm (x^2 + x + 1)", "differentiateFor x", "derivative f_'_"],("Isac",["derivative_of","function"],["diff","differentiate_on_R"]))];
568 (*3>*)Iterator 1; moveActiveRoot 1;
570 (*6>*)(*completeCalcHead*)autoCalculate 1 CompleteCalcHead;
572 (***difference II***)
573 val ((pt,_),_) = get_calc 1;
574 val PblObj {probl, meth, spec, fmz, env, loc, ...} = get_obj I pt [];
576 val (SOME istate, NONE) = loc;
577 print_depth 5; writeln (istate2str istate); print_depth 3;
580 ??.empty, Sundef, false)*)
581 print_depth 5; spec; print_depth 3;
583 ["derivative_of", "function"],
584 ["diff", "differentiate_on_R"]) : spec*)
585 writeln (itms2str_ ctxt probl);
587 (1 ,[1] ,true ,#Given ,Cor functionTerm (x ^^^ 2 + x + 1) ,(f_, [x ^^^ 2 + x + 1])),
588 (2 ,[1] ,true ,#Given ,Cor differentiateFor x ,(v_, [x])),
589 (3 ,[1] ,true ,#Find ,Cor derivative f_'_ ,(f_'_, [f_'_]))]*)
590 writeln (itms2str_ ctxt meth);
592 (1 ,[1] ,true ,#Given ,Cor functionTerm (x ^^^ 2 + x + 1) ,(f_, [x ^^^ 2 + x + 1])),
593 (2 ,[1] ,true ,#Given ,Cor differentiateFor x ,(v_, [x])),
594 (3 ,[1] ,true ,#Find ,Cor derivative f_'_ ,(f_'_, [f_'_]))]*)
595 writeln"-----------------------------------------------------------";
596 (*7>*)fetchProposedTactic 1 (*--> Apply_Method*);
598 autoCalculate 1 (Step 1);
599 val ((pt,p),_) = get_calc 1;
600 val Form res = (#1 o pt_extract) (pt, p);
601 if term2str res = "d_d x (x ^^^ 2 + x + 1)" then ()
602 else error "diff.sml Diff (x^2 + x + 1, x) from exp";
605 "--------- init_form, start with <NEW> (CAS input) ---------------";
606 "--------- init_form, start with <NEW> (CAS input) ---------------";
607 "--------- init_form, start with <NEW> (CAS input) ---------------";
609 CalcTree [([], ("e_domID", ["e_pblID"], ["e_metID"]))];
610 (*[[from sml: > @@@@@begin@@@@@
612 [[from sml: <CALCTREE>
613 [[from sml: <CALCID> 1 </CALCID>
614 [[from sml: </CALCTREE>
615 [[from sml: @@@@@end@@@@@*)
617 (*[[from sml: > @@@@@begin@@@@@
619 [[from sml: <ADDUSER>
620 [[from sml: <CALCID> 1 </CALCID>
621 [[from sml: <USERID> 1 </USERID>
622 [[from sml: </ADDUSER>
623 [[from sml: @@@@@end@@@@@*)
625 (*[[from sml: > @@@@@begin@@@@@
627 [[from sml: <CALCITERATOR>
628 [[from sml: <CALCID> 1 </CALCID>
629 [[from sml: <POSITION>
630 [[from sml: <INTLIST>
631 [[from sml: </INTLIST>
632 [[from sml: <POS> Pbl </POS>
633 [[from sml: </POSITION>
634 [[from sml: </CALCITERATOR>
635 [[from sml: @@@@@end@@@@@*)
636 getFormulaeFromTo 1 ([],Pbl) ([],Pbl) 0 false;
637 (*[[from sml: > @@@@@begin@@@@@ STILL CORRECT
639 [[from sml: <GETELEMENTSFROMTO>
640 [[from sml: <CALCID> 1 </CALCID>
641 [[from sml: <FORMHEADS>
642 [[from sml: <CALCFORMULA>
643 [[from sml: <POSITION>
644 [[from sml: <INTLIST>
645 [[from sml: </INTLIST>
646 [[from sml: <POS> Pbl </POS>
647 [[from sml: </POSITION>
648 [[from sml: <FORMULA>
650 [[from sml: <ISA> ________________________________________________ </ISA>
651 [[from sml: </MATHML>
653 [[from sml: </FORMULA>
654 [[from sml: </CALCFORMULA>
655 [[from sml: </FORMHEADS>
656 [[from sml: </GETELEMENTSFROMTO>
657 [[from sml: @@@@@end@@@@@*)
658 refFormula 1 ([],Pbl);
659 (*[[from sml: > @@@@@begin@@@@@ STILL CORRECT
661 [[from sml: <REFFORMULA>
662 [[from sml: <CALCID> 1 </CALCID>
663 [[from sml: <CALCHEAD status = "incorrect">
664 [[from sml: <POSITION>
665 [[from sml: <INTLIST>
666 [[from sml: </INTLIST>
667 [[from sml: <POS> Pbl </POS>
668 [[from sml: </POSITION>
671 [[from sml: <ISA> Problem (e_domID, [e_pblID]) </ISA>
672 [[from sml: </MATHML>
675 [[from sml: <GIVEN> </GIVEN>
676 [[from sml: <WHERE> </WHERE>
677 [[from sml: <FIND> </FIND>
678 [[from sml: <RELATE> </RELATE>
680 [[from sml: <BELONGSTO> Pbl </BELONGSTO>
681 [[from sml: <SPECIFICATION>
682 [[from sml: <THEORYID> e_domID </THEORYID>
683 [[from sml: <PROBLEMID>
684 [[from sml: <STRINGLIST>
685 [[from sml: <STRING> e_pblID </STRING>
686 [[from sml: </STRINGLIST>
687 [[from sml: </PROBLEMID>
688 [[from sml: <METHODID>
689 [[from sml: <STRINGLIST>
690 [[from sml: <STRING> e_metID </STRING>
691 [[from sml: </STRINGLIST>
692 [[from sml: </METHODID>
693 [[from sml: </SPECIFICATION>
694 [[from sml: </CALCHEAD>
695 [[from sml: </REFFORMULA>
696 [[from sml: @@@@@end@@@@@*)
697 moveActiveFormula 1 ([],Pbl);
698 (*[[from sml: > @@@@@begin@@@@@
700 [[from sml: <CALCITERATOR>
701 [[from sml: <CALCID> 1 </CALCID>
702 [[from sml: <POSITION>
703 [[from sml: <INTLIST>
704 [[from sml: </INTLIST>
705 [[from sml: <POS> Pbl </POS>
706 [[from sml: </POSITION>
707 [[from sml: </CALCITERATOR>
708 [[from sml: @@@@@end@@@@@*)
709 replaceFormula 1 "Simplify (1+2)";
710 (*[[from sml: > @@@@@begin@@@@@
712 [[from sml: <REPLACEFORMULA>
713 [[from sml: <CALCID> 1 </CALCID>
714 [[from sml: <CALCCHANGED>
715 [[from sml: <UNCHANGED>
716 [[from sml: <INTLIST>
717 [[from sml: </INTLIST>
718 [[from sml: <POS> Pbl </POS>
719 [[from sml: </UNCHANGED>
720 [[from sml: <DELETED>
721 [[from sml: <INTLIST>
722 [[from sml: </INTLIST>
723 [[from sml: <POS> Pbl </POS>
724 [[from sml: </DELETED>
725 [[from sml: <GENERATED>
726 [[from sml: <INTLIST>
727 [[from sml: </INTLIST>
728 [[from sml: <POS> Met </POS> DIFFERENCE: Pbl
729 [[from sml: </GENERATED>
730 [[from sml: </CALCCHANGED>
731 [[from sml: </REPLACEFORMULA>
732 [[from sml: @@@@@end@@@@@*)
733 getFormulaeFromTo 1 ([],Pbl) ([],Pbl) 0 false(* DIFFERENCE: Pbl*);
747 <ISA> Simplify (1 + 2) </ISA> WORKS !!!!!
754 getFormulaeFromTo 1 ([],Pbl) ([],Met) 0 false;
755 (*[[from sml: > @@@@@begin@@@@@
757 [[from sml: <SYSERROR>
758 [[from sml: <CALCID> 1 </CALCID>
759 [[from sml: <ERROR> error in getFormulaeFromTo </ERROR>
760 [[from sml: </SYSERROR>
761 [[from sml: @@@@@end@@@@@*)
762 (*step into getFormulaeFromTo --- bug corrected...*)