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)", "solveFor x","solutions L"],
55 ["sqroot-test","univariate","equation","test"],
56 ["Test","squ-equ-test-subpbl1"]))];
57 Iterator 1; moveActiveRoot 1;
58 autoCalculate 1 CompleteCalcHead;
59 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
60 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
62 appendFormula 1 "-2 * 1 + (1 + x) = 0"; refFormula 1 (get_pos 1 1);
63 val ((pt,_),_) = get_calc 1;
64 val str = pr_ptree pr_short pt;
66 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 ()
67 else raise error "inform.sml: diff.behav.appendFormula: on Res + equ 1";
69 moveDown 1 ([ ],Pbl); refFormula 1 ([1],Frm); (*x + 1 = 2*)
70 moveDown 1 ([1],Frm); refFormula 1 ([1],Res); (*x + 1 + -1 * 2 = 0*)
72 (*the seven steps of detailed derivation*)
73 moveDown 1 ([1 ],Res); refFormula 1 ([2,1],Frm);
74 moveDown 1 ([2,1],Frm); refFormula 1 ([2,1],Res);
75 moveDown 1 ([2,1],Res); refFormula 1 ([2,2],Res);
76 moveDown 1 ([2,2],Res); refFormula 1 ([2,3],Res);
77 moveDown 1 ([2,3],Res); refFormula 1 ([2,4],Res);
78 moveDown 1 ([2,4],Res); refFormula 1 ([2,5],Res);
79 moveDown 1 ([2,5],Res); refFormula 1 ([2,6],Res);
80 val ((pt,_),_) = get_calc 1;
81 if "-2 * 1 + (1 + x) = 0" = term2str (fst (get_obj g_result pt [2,6])) then()
82 else raise error "inform.sml: diff.behav.appendFormula: on Res + equ 2";
84 fetchProposedTactic 1; (*takes Iterator 1 _1_*)
85 val (_,(tac,_,_)::_) = get_calc 1;
86 if tac = Rewrite_Set "Test_simplify" then ()
87 else raise error "inform.sml: diff.behav.appendFormula: on Res + equ 3";
88 autoCalculate 1 CompleteCalc;
89 val ((pt,_),_) = get_calc 1;
90 if "[x = 1]" = term2str (fst (get_obj g_result pt [])) then ()
91 else raise error "inform.sml: diff.behav.appendFormula: on Res + equ 4";
92 (* autoCalculate 1 CompleteCalc;
93 val ((pt,p),_) = get_calc 1;
94 (writeln o istates2str) (get_obj g_loc pt [ ]);
95 (writeln o istates2str) (get_obj g_loc pt [1]);
96 (writeln o istates2str) (get_obj g_loc pt [2]);
97 (writeln o istates2str) (get_obj g_loc pt [3]);
98 (writeln o istates2str) (get_obj g_loc pt [3,1]);
99 (writeln o istates2str) (get_obj g_loc pt [3,2]);
100 (writeln o istates2str) (get_obj g_loc pt [4]);
103 "----------------------------------------------------------";
104 val fod = make_deriv Isac.thy Atools_erls
105 ((#rules o rep_rls) Test_simplify)
106 (sqrt_right false ProtoPure.thy) None
107 (str2term "x + 1 + -1 * 2 = 0");
108 (writeln o trtas2str) fod;
110 val ifod = make_deriv Isac.thy Atools_erls
111 ((#rules o rep_rls) Test_simplify)
112 (sqrt_right false ProtoPure.thy) None
113 (str2term "-2 * 1 + (1 + x) = 0");
114 (writeln o trtas2str) ifod;
115 fun equal (_,_,(t1, _)) (_,_,(t2, _)) = t1=t2;
116 val (fod', rifod') = dropwhile' equal (rev fod) (rev ifod);
117 val der = fod' @ (map rev_deriv' rifod');
118 (writeln o trtas2str) der;
119 "----------------------------------------------------------";
122 "--------- appendFormula: on Frm + equ_nrls ----------------------";
123 "--------- appendFormula: on Frm + equ_nrls ----------------------";
124 "--------- appendFormula: on Frm + equ_nrls ----------------------";
126 CalcTree [(["equality (x+1=2)", "solveFor x","solutions L"],
128 ["sqroot-test","univariate","equation","test"],
129 ["Test","squ-equ-test-subpbl1"]))];
130 Iterator 1; moveActiveRoot 1;
131 autoCalculate 1 CompleteCalcHead;
132 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1) (*x + 1 = 2*);
134 appendFormula 1 "2+ -1 + x = 2"; refFormula 1 (get_pos 1 1);
136 moveDown 1 ([],Pbl); refFormula 1 ([1],Frm) (*x + 1 = 2*);
138 moveDown 1 ([1 ],Frm); refFormula 1 ([1,1],Frm);
139 moveDown 1 ([1,1],Frm); refFormula 1 ([1,1],Res);
140 moveDown 1 ([1,1],Res); refFormula 1 ([1,2],Res);
141 moveDown 1 ([1,2],Res); refFormula 1 ([1,3],Res);
142 moveDown 1 ([1,3],Res); refFormula 1 ([1,4],Res);
143 moveDown 1 ([1,4],Res); refFormula 1 ([1,5],Res);
144 moveDown 1 ([1,5],Res); refFormula 1 ([1,6],Res);
145 val ((pt,_),_) = get_calc 1;
146 if "2 + -1 + x = 2" = term2str (fst (get_obj g_result pt [1,6])) then()
147 else raise error "inform.sml: diff.behav.appendFormula: on Frm + equ 1";
149 fetchProposedTactic 1; (*takes Iterator 1 _1_*)
150 val (_,(tac,_,_)::_) = get_calc 1;
151 if tac = Rewrite_Set "norm_equation" then ()
152 else raise error "inform.sml: diff.behav.appendFormula: on Frm + equ 2";
153 autoCalculate 1 CompleteCalc;
154 val ((pt,_),_) = get_calc 1;
155 if "[x = 1]" = term2str (fst (get_obj g_result pt [])) then ()
156 else raise error "inform.sml: diff.behav.appendFormula: on Frm + equ 3";
159 "--------- appendFormula: on Res + NO deriv ----------------------";
160 "--------- appendFormula: on Res + NO deriv ----------------------";
161 "--------- appendFormula: on Res + NO deriv ----------------------";
163 CalcTree [(["equality (x+1=2)", "solveFor x","solutions L"],
165 ["sqroot-test","univariate","equation","test"],
166 ["Test","squ-equ-test-subpbl1"]))];
167 Iterator 1; moveActiveRoot 1;
168 autoCalculate 1 CompleteCalcHead;
169 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
170 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
172 appendFormula 1 "x = 2";
173 val ((pt,p),_) = get_calc 1;
174 val str = pr_ptree pr_short pt;
176 if str = ". ----- pblobj -----\n1. x + 1 = 2\n" andalso p = ([1], Res)
178 else raise error "inform.sml: diff.behav.appendFormula: Res + NOder 1";
180 fetchProposedTactic 1;
181 val (_,(tac,_,_)::_) = get_calc 1;
182 if tac = Rewrite_Set "Test_simplify" then ()
183 else raise error "inform.sml: diff.behav.appendFormula: Res + NOder 2";
184 autoCalculate 1 CompleteCalc;
185 val ((pt,_),_) = get_calc 1;
186 if "[x = 1]" = term2str (fst (get_obj g_result pt [])) then ()
187 else raise error "inform.sml: diff.behav.appendFormula: on Frm + equ 3";
190 "--------- appendFormula: on Res + late deriv --------------------";
191 "--------- appendFormula: on Res + late deriv --------------------";
192 "--------- appendFormula: on Res + late deriv --------------------";
194 CalcTree [(["equality (x+1=2)", "solveFor x","solutions L"],
196 ["sqroot-test","univariate","equation","test"],
197 ["Test","squ-equ-test-subpbl1"]))];
198 Iterator 1; moveActiveRoot 1;
199 autoCalculate 1 CompleteCalcHead;
200 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
201 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
203 appendFormula 1 "x = 1";
204 val ((pt,p),_) = get_calc 1;
205 val str = pr_ptree pr_short pt;
207 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)
208 then () (*finds 1 step too early: ([3,2], Res) "x = 1" also by script !!!*)
209 else raise error "inform.sml: diff.behav.appendFormula: Res + late d 1";
211 fetchProposedTactic 1;
212 val (_,(tac,_,_)::_) = get_calc 1;
213 if tac = Check_Postcond ["linear", "univariate", "equation", "test"] then ()
214 else raise error "inform.sml: diff.behav.appendFormula: Res + late d 2";
215 autoCalculate 1 CompleteCalc;
216 val ((pt,_),_) = get_calc 1;
217 if "[x = 1]" = term2str (fst (get_obj g_result pt [])) then ()
218 else raise error "inform.sml: diff.behav.appendFormula: Res + late d 3";
221 "--------- appendFormula: on Res + late deriv [x = 3 + -2]---///--";
222 "--------- appendFormula: on Res + late deriv [x = 3 + -2]---///--";
223 "--------- appendFormula: on Res + late deriv [x = 3 + -2]---///--";
225 CalcTree [(["equality (x+1=2)", "solveFor x","solutions L"],
227 ["sqroot-test","univariate","equation","test"],
228 ["Test","squ-equ-test-subpbl1"]))];
229 Iterator 1; moveActiveRoot 1;
230 autoCalculate 1 CompleteCalcHead;
231 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
232 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
233 appendFormula 1 "[x = 3 + -2*1]";
234 val ((pt,p),_) = get_calc 1;
235 val str = pr_ptree pr_short pt;
237 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 ()
238 else raise error "inform.sml: diff.behav.appendFormula: Res + latEE 1";
239 autoCalculate 1 CompleteCalc;
240 val ((pt,p),_) = get_calc 1;
241 if "[x = 3 + -2 * 1]" = term2str (fst (get_obj g_result pt [])) then ()
242 (* ~~~~~~~~~~ simplify as last step in any script ?!*)
243 else raise error "inform.sml: diff.behav.appendFormula: Res + latEE 2";
247 "--------- replaceFormula: on Res + = ----------------------------";
248 "--------- replaceFormula: on Res + = ----------------------------";
249 "--------- replaceFormula: on Res + = ----------------------------";
251 CalcTree [(["equality (x+1=2)", "solveFor x","solutions L"],
253 ["sqroot-test","univariate","equation","test"],
254 ["Test","squ-equ-test-subpbl1"]))];
255 Iterator 1; moveActiveRoot 1;
256 autoCalculate 1 CompleteCalcHead;
257 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
258 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
259 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*-1 + x*);
261 replaceFormula 1 "-2 * 1 + (1 + x) = 0"; refFormula 1 (get_pos 1 1);
262 val ((pt,_),_) = get_calc 1;
263 val str = pr_ptree pr_short pt;
265 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()
266 else raise error "inform.sml: diff.behav.replaceFormula: on Res += 1";
267 autoCalculate 1 CompleteCalc;
268 val ((pt,pos as(p,_)),_) = get_calc 1;
269 if pos=([],Res)andalso"[x = 1]"=(term2str o fst)(get_obj g_result pt p)then()
270 else raise error "inform.sml: diff.behav.replaceFormula: on Res + = 2";
273 "--------- replaceFormula: on Res + = 1st Nd ---------------------";
274 "--------- replaceFormula: on Res + = 1st Nd ---------------------";
275 "--------- replaceFormula: on Res + = 1st Nd ---------------------";
277 CalcTree [(["equality (x+1=2)", "solveFor x","solutions L"],
279 ["sqroot-test","univariate","equation","test"],
280 ["Test","squ-equ-test-subpbl1"]))];
281 Iterator 1; moveActiveRoot 1;
282 autoCalculate 1 CompleteCalcHead;
283 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
284 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
286 replaceFormula 1 "x + 1 = 4 + -2"; refFormula 1 (get_pos 1 1);
287 val ((pt,_),_) = get_calc 1;
288 val str = pr_ptree pr_short pt;
290 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 ()
291 else raise error "inform.sml: diff.behav.replaceFormula: on Res 1 + = 1";
292 autoCalculate 1 CompleteCalc;
293 val ((pt,pos as(p,_)),_) = get_calc 1;
294 if pos=([],Res)andalso"[x = 1]"=(term2str o fst)(get_obj g_result pt p)then()
295 else raise error "inform.sml: diff.behav.replaceFormula: on Res + = 2";
298 "--------- replaceFormula: on Frm + = 1st Nd ---------------------";
299 "--------- replaceFormula: on Frm + = 1st Nd ---------------------";
300 "--------- replaceFormula: on Frm + = 1st Nd ---------------------";
302 CalcTree [(["equality (x+1=2)", "solveFor x","solutions L"],
304 ["sqroot-test","univariate","equation","test"],
305 ["Test","squ-equ-test-subpbl1"]))];
306 Iterator 1; moveActiveRoot 1;
307 autoCalculate 1 CompleteCalcHead;
308 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
310 replaceFormula 1 "x + 1 = 4 + -2"; refFormula 1 (get_pos 1 1);
311 val ((pt,_),_) = get_calc 1;
312 val str = pr_ptree pr_short pt;
314 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 ()
315 else raise error "inform.sml: diff.behav.replaceFormula: on Frm 1 + = 1";
316 autoCalculate 1 CompleteCalc;
317 val ((pt,pos as(p,_)),_) = get_calc 1;
318 if pos=([],Res)andalso"[x = 1]"=(term2str o fst)(get_obj g_result pt p)then()
319 else raise error "inform.sml: diff.behav.replaceFormula: on Frm 1 + = 2";
322 "--------- replaceFormula: cut calculation -----------------------";
323 "--------- replaceFormula: cut calculation -----------------------";
324 "--------- replaceFormula: cut calculation -----------------------";
326 CalcTree [(["equality (x+1=2)", "solveFor x","solutions L"],
328 ["sqroot-test","univariate","equation","test"],
329 ["Test","squ-equ-test-subpbl1"]))];
330 Iterator 1; moveActiveRoot 1;
331 autoCalculate 1 CompleteCalc;
332 moveActiveRoot 1; moveActiveDown 1;
333 if get_pos 1 1 = ([1], Frm) then ()
334 else raise error "inform.sml: diff.behav. cut calculation 1";
336 replaceFormula 1 "x + 1 = 4 + -2"; refFormula 1 (get_pos 1 1);
337 val ((pt,p),_) = get_calc 1;
338 val str = pr_ptree pr_short pt;
340 if p = ([1], Res) then ()
341 else raise error "inform.sml: diff.behav. cut calculation 2";
345 (* 040307 copied from informtest.sml; ... old version
346 "---------------- maximum-example, UC: Modeling / modifyCalcHead -";
347 "---------------- maximum-example, UC: Modeling / modifyCalcHead -";
348 "---------------- maximum-example, UC: Modeling / modifyCalcHead -";
351 val elems = ["fixedValues [r=Arbfix]","maximum A","valuesFor [a,b]",
352 "relations [A=a*b, (a/2)^^^2 + (b/2)^^^2 = r^^^2]",
353 "relations [A=a*b, (a/2)^^^2 + (b/2)^^^2 = r^^^2]",
354 "relations [A=a*b, a/2=r*sin alpha, b/2=r*cos alpha]",
355 (*^^^ these are the elements for the root-problem (in variants)*)
356 (*vvv these are elements required for subproblems*)
357 "boundVariable a","boundVariable b","boundVariable alpha",
358 "interval {x::real. 0 <= x & x <= 2*r}",
359 "interval {x::real. 0 <= x & x <= 2*r}",
360 "interval {x::real. 0 <= x & x <= pi}",
361 "errorBound (eps=(0::real))"]
362 (*specifying is not interesting for this example*)
363 val spec = ("DiffApp.thy", ["maximum_of","function"],
364 ["DiffApp","max_by_calculus"]);
365 (*the empty model with descriptions for user-guidance by Model_Problem*)
366 val empty_model = [Given ["fixedValues []"],
367 Find ["maximum", "valuesFor"],
368 Relate ["relations []"]];
371 (*!!!!!!!!!!!!!!!!! DON'T USE me FOR FINDING nxt !!!!!!!!!!!!!!!!!!*)
372 val (p,_,f,nxt,_,pt) = CalcTreeTEST [(elems, spec)];
373 (*val nxt = ("Model_Problem", ...*)
374 val pbl = get_obj g_pbl pt (fst p); (writeln o (itms2str_ ctxt)) pbl;
376 val (p,_,f,nxt,_,pt) = me nxt p c pt;
377 (*nxt = Add_Given "fixedValues [r = Arbfix]"*)
378 val pbl = get_obj g_pbl pt (fst p); (writeln o (itms2str_ ctxt)) pbl;
380 (0 ,[] ,false ,#Given ,Inc fixedValues [] ,(??.empty, [])),
381 (0 ,[] ,false ,#Find ,Inc maximum ,(??.empty, [])),
382 (0 ,[] ,false ,#Find ,Inc valuesFor ,(??.empty, [])),
383 (0 ,[] ,false ,#Relate ,Inc relations [] ,(??.empty, []))]*)
385 (*the empty CalcHead is checked w.r.t the model and re-established as such*)
386 val (b,pt,ocalhd) = input_icalhd pt (p,"", empty_model, Pbl, e_spec);
387 val pbl = get_obj g_pbl pt (fst p); (writeln o (itms2str_ ctxt)) pbl;
388 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 raise error "informtest.sml: diff.behav. max 1";
390 (*there is one input to the model (could be more)*)
392 input_icalhd pt (p,"", [Given ["fixedValues [r=Arbfix]"],
393 Find ["maximum", "valuesFor"],
394 Relate ["relations"]], Pbl, e_spec);
395 val pbl = get_obj g_pbl pt (fst p); (writeln o (itms2str_ ctxt)) pbl;
396 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 ()
397 else raise error "informtest.sml: diff.behav. max 2";
399 (*this input is complete in variant 3, but the ME doesn't recognize FIXXXXME
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, a/2=r*sin alpha, \
404 \b/2=r*cos alpha]"]], Pbl, e_spec);
405 val pbl = get_obj g_pbl pt''''' (fst p); (writeln o (itms2str_ ctxt)) pbl;
406 if ocalhd2str ocalhd = ------------^^^^^^^^^^ missing !!!*)
408 (*this input is complete in variant 1 (variant 3 does not work yet)*)
409 val (b,pt''''',ocalhd) =
410 input_icalhd pt (p,"", [Given ["fixedValues [r=Arbfix]"],
411 Find ["maximum A", "valuesFor [a,b]"],
412 Relate ["relations [A=a*b, \
413 \(a/2)^^^2 + (b/2)^^^2 = r^^^2]"]],
415 val pbl = get_obj g_pbl pt''''' (fst p); (writeln o (itms2str_ ctxt)) pbl;
417 modifycalcheadOK2xml 111 (bool2str b) ocalhd;
420 "--------- syntax error ------------------------------------------";
421 "--------- syntax error ------------------------------------------";
422 "--------- syntax error ------------------------------------------";
424 CalcTree [(["equality (x+1=2)", "solveFor x","solutions L"],
426 ["sqroot-test","univariate","equation","test"],
427 ["Test","squ-equ-test-subpbl1"]))];
428 Iterator 1; moveActiveRoot 1;
429 autoCalculate 1 CompleteCalcHead;
430 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
431 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
433 appendFormula 1 " x - "; (*<ERROR> syntax error in ' x - ' </ERROR>*)
434 val ((pt,_),_) = get_calc 1;
435 val str = pr_ptree pr_short pt;
437 if str = ". ----- pblobj -----\n1. x + 1 = 2\n" then ()
438 else raise error "inform.sml: diff.behav.appendFormula: syntax error";
441 "--------- CAS-command on ([],Pbl) -------------------------------";
442 "--------- CAS-command on ([],Pbl) -------------------------------";
443 "--------- CAS-command on ([],Pbl) -------------------------------";
444 val (p,_,f,nxt,_,pt) =
445 CalcTreeTEST [([], ("e_domID", ["e_pblID"], ["e_metID"]))];
446 val ifo = "solve(x+1=2,x)";
447 val (_,(_,c,(pt,p))) = inform ([],[],(pt,p)) "solve(x+1=2,x)";
449 val nxt = ("Apply_Method",Apply_Method ["Test","squ-equ-test-subpbl1"]);
450 val (p,_,f,nxt,_,pt) = me nxt p [] pt;
451 if p = ([1], Frm) andalso f2str f = "x + 1 = 2" then ()
452 else raise error "inform.sml: diff.behav. CAScmd ([],Pbl)";
455 "--------- CAS-command on ([],Pbl) FE-interface ------------------";
456 "--------- CAS-command on ([],Pbl) FE-interface ------------------";
457 "--------- CAS-command on ([],Pbl) FE-interface ------------------";
459 CalcTree [([], ("e_domID", ["e_pblID"], ["e_metID"]))];
462 replaceFormula 1 "solve(x+1=2,x)";
463 autoCalculate 1 CompleteCalc;
464 val ((pt,p),_) = get_calc 1;
466 if p = ([], Res) then ()
467 else raise error "inform.sml: diff.behav. CAScmd ([],Pbl) FE-interface";
470 "--------- inform [rational,simplification] ----------------------";
471 "--------- inform [rational,simplification] ----------------------";
472 "--------- inform [rational,simplification] ----------------------";
474 CalcTree [(["term (4/x - 3/y - 1)", "normalform N"],
475 ("Rational.thy",["rational","simplification"],
476 ["simplification","of_rationals"]))];
477 Iterator 1; moveActiveRoot 1;
478 autoCalculate 1 CompleteCalcHead;
479 autoCalculate 1 (Step 1);
480 autoCalculate 1 (Step 1);
481 autoCalculate 1 (Step 1);
482 autoCalculate 1 (Step 1);
483 "--- input the next formula that _should_ be presented by mat-engine";
484 appendFormula 1 "(4 * y + -3 * x) / (x * y) + -1";
485 val ((pt,p),_) = get_calc 1;
486 if p = ([4], Res) andalso (length o children o (get_nd pt)) (fst p) = 2 then ()
487 else raise error ("inform.sml: [rational,simplification] 1");
489 "--- input the next formula that would be presented by mat-engine";
490 (*autoCalculate 1 (Step 1);*)
491 appendFormula 1 "(4 * y + -3 * x + -1 * (x * y)) / (x * y)";
492 val ((pt,p),_) = get_calc 1;
493 if p = ([5], Res) andalso (length o children o (get_nd pt)) (fst p) = 0 then ()
494 else raise error ("inform.sml: [rational,simplification] 2");
496 "--- input the exact final result";(*TODO: Exception- LIST "last_elem" raised*)
497 appendFormula 1 "(-3 * x + 4 * y + -1 * x * y) / (x * y)";
498 val ((pt,p),_) = get_calc 1;
499 if p = ([6], Res) andalso (length o children o (get_nd pt)) (fst p) = 2 then ()
500 else raise error ("inform.sml: [rational,simplification] 3");
503 "--------- Take as 1st tac, start with <NEW> (CAS input) ---------";
504 "--------- Take as 1st tac, start with <NEW> (CAS input) ---------";
505 "--------- Take as 1st tac, start with <NEW> (CAS input) ---------";
506 val t = str2term "Diff (x^^^2 + x + 1, x)";
507 case t of Const ("Diff.Diff", _) $ _ => ()
509 error "diff.sml behav.changed for CAS Diff (..., x)";
511 "-----------------------------------------------------------------";
513 (*2>*)CalcTree [([], ("e_domID", ["e_pblID"], ["e_metID"]))];
514 (*3>*)Iterator 1;moveActiveRoot 1;
515 "----- here the Headline has been finished";
516 (*4>*)moveActiveFormula 1 ([],Pbl);
517 (*5>*)replaceFormula 1 "Diff (x^2 + x + 1, x)";
518 val ((pt,_),_) = get_calc 1;
519 val PblObj {probl, meth, spec, fmz, env, loc, ...} = get_obj I pt [];
521 val (Some istate, None) = loc;
523 writeln"-----------------------------------------------------------";
525 writeln (itms2str_ ctxt probl);
526 writeln (itms2str_ ctxt meth);
527 writeln (istate2str istate);
531 refFormula 1 ([],Pbl) (*--> correct CalcHead*);
532 (*081016 NOT necessary (but leave it in Java):*)
533 (*6>*)(*completeCalcHead*)autoCalculate 1 CompleteCalcHead;
534 "----- here the CalcHead has been completed --- ONCE MORE ?????";
536 (***difference II***)
537 val ((pt,p),_) = get_calc 1;
538 (*val p = ([], Pbl)*)
539 val PblObj {probl, meth, spec, fmz, env, loc, ...} = get_obj I pt [];
541 val (Some istate, None) = loc;
542 print_depth 5; writeln (istate2str istate); print_depth 3;
545 ??.empty, Sundef, false)*)
546 print_depth 5; spec; print_depth 3;
548 ["derivative_of", "function"],
549 ["diff", "differentiate_on_R"]) : spec*)
550 writeln (itms2str_ ctxt probl);
552 (1 ,[1] ,true ,#Given ,Cor functionTerm (x ^^^ 2 + x + 1) ,(f_, [x ^^^ 2 + x + 1])),
553 (2 ,[1] ,true ,#Given ,Cor differentiateFor x ,(v_, [x])),
554 (3 ,[1] ,true ,#Find ,Cor derivative f_'_ ,(f_'_, [f_'_]))]*)
555 writeln (itms2str_ ctxt meth);
557 (1 ,[1] ,true ,#Given ,Cor functionTerm (x ^^^ 2 + x + 1) ,(f_, [x ^^^ 2 + x + 1])),
558 (2 ,[1] ,true ,#Given ,Cor differentiateFor x ,(v_, [x])),
559 (3 ,[1] ,true ,#Find ,Cor derivative f_'_ ,(f_'_, [f_'_]))]*)
560 writeln"-----------------------------------------------------------";
561 (*7>*)fetchProposedTactic 1 (*--> Apply_Method*);
562 (*WN081028 fixed <ERROR> helpless </ERROR> by inform returning ...(.,Met)*)
563 autoCalculate 1 CompleteCalc;
564 val ((pt,p),_) = get_calc 1;
565 val Form res = (#1 o pt_extract) (pt, ([],Res));
567 if p = ([], Res) andalso term2str res = "1 + 2 * x" then ()
568 else raise error "diff.sml behav.changed for Diff (x^2 + x + 1, x)";
571 "--------- Take as 1st tac, start from exp -----------------------";
572 "--------- Take as 1st tac, start from exp -----------------------";
573 "--------- Take as 1st tac, start from exp -----------------------";
574 (*the following input is copied from BridgeLog Java <==> SML,
575 omitting unnecessary inputs*)
577 (*2>*)CalcTree [(["functionTerm (x^2 + x + 1)", "differentiateFor x", "derivative f_'_"],("Isac.thy",["derivative_of","function"],["diff","differentiate_on_R"]))];
578 (*3>*)Iterator 1; moveActiveRoot 1;
580 (*6>*)(*completeCalcHead*)autoCalculate 1 CompleteCalcHead;
582 (***difference II***)
583 val ((pt,_),_) = get_calc 1;
584 val PblObj {probl, meth, spec, fmz, env, loc, ...} = get_obj I pt [];
586 val (Some istate, None) = loc;
587 print_depth 5; writeln (istate2str istate); print_depth 3;
590 ??.empty, Sundef, false)*)
591 print_depth 5; spec; print_depth 3;
593 ["derivative_of", "function"],
594 ["diff", "differentiate_on_R"]) : spec*)
595 writeln (itms2str_ ctxt probl);
597 (1 ,[1] ,true ,#Given ,Cor functionTerm (x ^^^ 2 + x + 1) ,(f_, [x ^^^ 2 + x + 1])),
598 (2 ,[1] ,true ,#Given ,Cor differentiateFor x ,(v_, [x])),
599 (3 ,[1] ,true ,#Find ,Cor derivative f_'_ ,(f_'_, [f_'_]))]*)
600 writeln (itms2str_ ctxt meth);
602 (1 ,[1] ,true ,#Given ,Cor functionTerm (x ^^^ 2 + x + 1) ,(f_, [x ^^^ 2 + x + 1])),
603 (2 ,[1] ,true ,#Given ,Cor differentiateFor x ,(v_, [x])),
604 (3 ,[1] ,true ,#Find ,Cor derivative f_'_ ,(f_'_, [f_'_]))]*)
605 writeln"-----------------------------------------------------------";
606 (*7>*)fetchProposedTactic 1 (*--> Apply_Method*);
608 autoCalculate 1 (Step 1);
609 val ((pt,p),_) = get_calc 1;
610 val Form res = (#1 o pt_extract) (pt, p);
611 if term2str res = "d_d x (x ^^^ 2 + x + 1)" then ()
612 else raise error "diff.sml Diff (x^2 + x + 1, x) from exp";
615 "--------- init_form, start with <NEW> (CAS input) ---------------";
616 "--------- init_form, start with <NEW> (CAS input) ---------------";
617 "--------- init_form, start with <NEW> (CAS input) ---------------";
619 CalcTree [([], ("e_domID", ["e_pblID"], ["e_metID"]))];
620 (*[[from sml: > @@@@@begin@@@@@
622 [[from sml: <CALCTREE>
623 [[from sml: <CALCID> 1 </CALCID>
624 [[from sml: </CALCTREE>
625 [[from sml: @@@@@end@@@@@*)
627 (*[[from sml: > @@@@@begin@@@@@
629 [[from sml: <ADDUSER>
630 [[from sml: <CALCID> 1 </CALCID>
631 [[from sml: <USERID> 1 </USERID>
632 [[from sml: </ADDUSER>
633 [[from sml: @@@@@end@@@@@*)
635 (*[[from sml: > @@@@@begin@@@@@
637 [[from sml: <CALCITERATOR>
638 [[from sml: <CALCID> 1 </CALCID>
639 [[from sml: <POSITION>
640 [[from sml: <INTLIST>
641 [[from sml: </INTLIST>
642 [[from sml: <POS> Pbl </POS>
643 [[from sml: </POSITION>
644 [[from sml: </CALCITERATOR>
645 [[from sml: @@@@@end@@@@@*)
646 getFormulaeFromTo 1 ([],Pbl) ([],Pbl) 0 false;
647 (*[[from sml: > @@@@@begin@@@@@ STILL CORRECT
649 [[from sml: <GETELEMENTSFROMTO>
650 [[from sml: <CALCID> 1 </CALCID>
651 [[from sml: <FORMHEADS>
652 [[from sml: <CALCFORMULA>
653 [[from sml: <POSITION>
654 [[from sml: <INTLIST>
655 [[from sml: </INTLIST>
656 [[from sml: <POS> Pbl </POS>
657 [[from sml: </POSITION>
658 [[from sml: <FORMULA>
660 [[from sml: <ISA> ________________________________________________ </ISA>
661 [[from sml: </MATHML>
663 [[from sml: </FORMULA>
664 [[from sml: </CALCFORMULA>
665 [[from sml: </FORMHEADS>
666 [[from sml: </GETELEMENTSFROMTO>
667 [[from sml: @@@@@end@@@@@*)
668 refFormula 1 ([],Pbl);
669 (*[[from sml: > @@@@@begin@@@@@ STILL CORRECT
671 [[from sml: <REFFORMULA>
672 [[from sml: <CALCID> 1 </CALCID>
673 [[from sml: <CALCHEAD status = "incorrect">
674 [[from sml: <POSITION>
675 [[from sml: <INTLIST>
676 [[from sml: </INTLIST>
677 [[from sml: <POS> Pbl </POS>
678 [[from sml: </POSITION>
681 [[from sml: <ISA> Problem (e_domID, [e_pblID]) </ISA>
682 [[from sml: </MATHML>
685 [[from sml: <GIVEN> </GIVEN>
686 [[from sml: <WHERE> </WHERE>
687 [[from sml: <FIND> </FIND>
688 [[from sml: <RELATE> </RELATE>
690 [[from sml: <BELONGSTO> Pbl </BELONGSTO>
691 [[from sml: <SPECIFICATION>
692 [[from sml: <THEORYID> e_domID </THEORYID>
693 [[from sml: <PROBLEMID>
694 [[from sml: <STRINGLIST>
695 [[from sml: <STRING> e_pblID </STRING>
696 [[from sml: </STRINGLIST>
697 [[from sml: </PROBLEMID>
698 [[from sml: <METHODID>
699 [[from sml: <STRINGLIST>
700 [[from sml: <STRING> e_metID </STRING>
701 [[from sml: </STRINGLIST>
702 [[from sml: </METHODID>
703 [[from sml: </SPECIFICATION>
704 [[from sml: </CALCHEAD>
705 [[from sml: </REFFORMULA>
706 [[from sml: @@@@@end@@@@@*)
707 moveActiveFormula 1 ([],Pbl);
708 (*[[from sml: > @@@@@begin@@@@@
710 [[from sml: <CALCITERATOR>
711 [[from sml: <CALCID> 1 </CALCID>
712 [[from sml: <POSITION>
713 [[from sml: <INTLIST>
714 [[from sml: </INTLIST>
715 [[from sml: <POS> Pbl </POS>
716 [[from sml: </POSITION>
717 [[from sml: </CALCITERATOR>
718 [[from sml: @@@@@end@@@@@*)
719 replaceFormula 1 "Simplify (1+2)";
720 (*[[from sml: > @@@@@begin@@@@@
722 [[from sml: <REPLACEFORMULA>
723 [[from sml: <CALCID> 1 </CALCID>
724 [[from sml: <CALCCHANGED>
725 [[from sml: <UNCHANGED>
726 [[from sml: <INTLIST>
727 [[from sml: </INTLIST>
728 [[from sml: <POS> Pbl </POS>
729 [[from sml: </UNCHANGED>
730 [[from sml: <DELETED>
731 [[from sml: <INTLIST>
732 [[from sml: </INTLIST>
733 [[from sml: <POS> Pbl </POS>
734 [[from sml: </DELETED>
735 [[from sml: <GENERATED>
736 [[from sml: <INTLIST>
737 [[from sml: </INTLIST>
738 [[from sml: <POS> Met </POS> DIFFERENCE: Pbl
739 [[from sml: </GENERATED>
740 [[from sml: </CALCCHANGED>
741 [[from sml: </REPLACEFORMULA>
742 [[from sml: @@@@@end@@@@@*)
743 getFormulaeFromTo 1 ([],Pbl) ([],Pbl) 0 false(* DIFFERENCE: Pbl*);
757 <ISA> Simplify (1 + 2) </ISA> WORKS !!!!!
764 getFormulaeFromTo 1 ([],Pbl) ([],Met) 0 false;
765 (*[[from sml: > @@@@@begin@@@@@
767 [[from sml: <SYSERROR>
768 [[from sml: <CALCID> 1 </CALCID>
769 [[from sml: <ERROR> error in getFormulaeFromTo </ERROR>
770 [[from sml: </SYSERROR>
771 [[from sml: @@@@@end@@@@@*)
772 (*step into getFormulaeFromTo --- bug corrected...*)