1 (* Title: tests on inform.sml
2 Author: Walther Neuper 060225,
3 (c) due to copyright terms
6 "-----------------------------------------------------------------";
7 "table of contents -----------------------------------------------";
8 "-----------------------------------------------------------------";
9 "appendForm with miniscript with mini-subpbl:";
10 "--------- appendFormula: on Res + equ_nrls ----------------------";
11 "--------- appendFormula: on Frm + equ_nrls ----------------------";
12 "--------- appendFormula: on Res + NO deriv ----------------------";
13 "--------- appendFormula: on Res + late deriv --------------------";
14 "--------- appendFormula: on Res + late deriv [x = 3 + -2]---///--";
15 "replaceForm with miniscript with mini-subpbl:";
16 "--------- replaceFormula: on Res + = ----------------------------";
17 "--------- replaceFormula: on Res + = 1st Nd ---------------------";
18 "--------- replaceFormula: on Frm + = 1st Nd ---------------------";
19 "--------- replaceFormula: cut calculation -----------------------";
20 "--------- replaceFormula: cut calculation -----------------------";
21 (* 040307 copied from informtest.sml ... old versions
22 "--------- maximum-example, UC: Modeling / modifyCalcHead --------";*)
23 "--------- syntax error ------------------------------------------";
25 "--------- CAS-command on ([],Pbl) -------------------------------";
26 "--------- CAS-command on ([],Pbl) FE-interface ------------------";
27 "--------- inform [rational,simplification] ----------------------";
28 "--------- Take as 1st tac, start with <NEW> (CAS input) ---------";
29 "--------- Take as 1st tac, start from exp -----------------------";
30 "--------- init_form, start with <NEW> (CAS input) ---------------";
31 "--------- build fun check_err_patt ------------------------------";
32 "--------- build fun check_err_patt ?bdv -------------------------";
33 "--------- build fun check_error_patterns ------------------------";
34 "--------- embed fun check_error_patterns ------------------------";
35 "--------- build fun get_fillpats --------------------------------";
36 "--------- embed fun find_fillpatterns ---------------------------";
37 "--------- build fun is_exactly_equal, inputFillFormula ----------";
38 "--------- fun appl_adds -----------------------------------------";
39 "--------- fun concat_deriv --------------------------------------";
40 "--------- handle an input formula -------------------------------";
41 "--------- fun dropwhile' ----------------------------------------";
42 "-----------------------------------------------------------------";
43 "-----------------------------------------------------------------";
44 "-----------------------------------------------------------------";
47 "--------- appendFormula: on Res + equ_nrls ----------------------";
48 "--------- appendFormula: on Res + equ_nrls ----------------------";
49 "--------- appendFormula: on Res + equ_nrls ----------------------";
50 val Prog sc = (#scr o get_met) ["Test","squ-equ-test-subpbl1"];
51 (writeln o term2str) sc;
52 val Prog sc = (#scr o get_met) ["Test","solve_linear"];
53 (writeln o term2str) sc;
56 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
57 ("Test", ["sqroot-test","univariate","equation","test"],
58 ["Test","squ-equ-test-subpbl1"]))];
59 Iterator 1; moveActiveRoot 1;
60 autoCalculate 1 CompleteCalcHead;
61 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
62 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
64 appendFormula 1 "-2 * 1 + (1 + x) = 0" (*|> Future.join*); refFormula 1 (get_pos 1 1);
65 val ((pt,_),_) = get_calc 1;
66 val str = pr_ctree pr_short pt;
68 (". ----- pblobj -----\n" ^
70 "2. x + 1 + -1 * 2 = 0\n" ^
71 "2.1. x + 1 + -1 * 2 = 0\n" ^
72 "2.2. 1 + x + -1 * 2 = 0\n" ^
73 "2.3. 1 + (x + -1 * 2) = 0\n" ^
74 "2.4. 1 + (x + -2) = 0\n" ^
75 "2.5. 1 + (x + -2 * 1) = 0\n" ^
76 "2.6. 1 + x + -2 * 1 = 0\n" ) then ()
77 else error "inform.sml: diff.behav.appendFormula: on Res + equ 1";
79 moveDown 1 ([ ],Pbl); refFormula 1 ([1],Frm); (*x + 1 = 2*)
80 moveDown 1 ([1],Frm); refFormula 1 ([1],Res); (*x + 1 + -1 * 2 = 0*)
82 (*the seven steps of detailed derivation*)
83 moveDown 1 ([1 ],Res); refFormula 1 ([2,1],Frm);
84 moveDown 1 ([2,1],Frm); refFormula 1 ([2,1],Res);
85 moveDown 1 ([2,1],Res); refFormula 1 ([2,2],Res);
86 moveDown 1 ([2,2],Res); refFormula 1 ([2,3],Res);
87 moveDown 1 ([2,3],Res); refFormula 1 ([2,4],Res);
88 moveDown 1 ([2,4],Res); refFormula 1 ([2,5],Res);
89 moveDown 1 ([2,5],Res); refFormula 1 ([2,6],Res);
90 val ((pt,_),_) = get_calc 1;
91 if "-2 * 1 + (1 + x) = 0" = term2str (fst (get_obj g_result pt [2,6])) then()
92 else error "inform.sml: diff.behav.appendFormula: on Res + equ 2";
94 fetchProposedTactic 1; (*takes Iterator 1 _1_*)
95 (* <ERROR> error in kernel </ERROR> ALREADY IN 2009-2*)
96 (*========== inhibit exn WN1130701 broken at Isabelle2002 --> 2009-2 =============
97 val (_,(tac,_,_)::_) = get_calc 1;
98 if tac = Rewrite_Set "Test_simplify" then ()
99 else error "inform.sml: diff.behav.appendFormula: on Res + equ 3";
100 ============ inhibit exn WN1130701 broken at Isabelle2002 --> 2009-2 ============*)
102 autoCalculate 1 CompleteCalc;
103 val ((pt,_),_) = get_calc 1;
104 if "[x = 1]" = term2str (fst (get_obj g_result pt [])) then ()
105 else error "inform.sml: diff.behav.appendFormula: on Res + equ 4";
106 (* autoCalculate 1 CompleteCalc;
107 val ((pt,p),_) = get_calc 1;
108 (writeln o istates2str) (get_obj g_loc pt [ ]);
109 (writeln o istates2str) (get_obj g_loc pt [1]);
110 (writeln o istates2str) (get_obj g_loc pt [2]);
111 (writeln o istates2str) (get_obj g_loc pt [3]);
112 (writeln o istates2str) (get_obj g_loc pt [3,1]);
113 (writeln o istates2str) (get_obj g_loc pt [3,2]);
114 (writeln o istates2str) (get_obj g_loc pt [4]);
117 "----------------------------------------------------------";
119 val fod = make_deriv (@{theory "Isac"}) Atools_erls
120 ((#rules o rep_rls) Test_simplify)
121 (sqrt_right false (@{theory "Pure"})) NONE
122 (str2term "x + 1 + -1 * 2 = 0");
123 (writeln o trtas2str) fod;
125 val ifod = make_deriv (@{theory "Isac"}) Atools_erls
126 ((#rules o rep_rls) Test_simplify)
127 (sqrt_right false (@{theory "Pure"})) NONE
128 (str2term "-2 * 1 + (1 + x) = 0");
129 (writeln o trtas2str) ifod;
130 fun equal (_,_,(t1, _)) (_,_,(t2, _)) = t1 = t2;
131 val (fod', rifod') = dropwhile' equal (rev fod) (rev ifod);
132 val der = fod' @ (map rev_deriv' rifod');
133 (writeln o trtas2str) der;
134 "----------------------------------------------------------";
137 "--------- appendFormula: on Frm + equ_nrls ----------------------";
138 "--------- appendFormula: on Frm + equ_nrls ----------------------";
139 "--------- appendFormula: on Frm + equ_nrls ----------------------";
141 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
142 ("Test", ["sqroot-test","univariate","equation","test"],
143 ["Test","squ-equ-test-subpbl1"]))];
144 Iterator 1; moveActiveRoot 1;
145 autoCalculate 1 CompleteCalcHead;
146 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1) (*x + 1 = 2*);
147 appendFormula 1 "2+ -1 + x = 2" (*|> Future.join*); refFormula 1 (get_pos 1 1);
149 moveDown 1 ([],Pbl); refFormula 1 ([1],Frm) (*x + 1 = 2*);
151 moveDown 1 ([1 ],Frm); refFormula 1 ([1,1],Frm);
152 moveDown 1 ([1,1],Frm); refFormula 1 ([1,1],Res);
153 moveDown 1 ([1,1],Res); refFormula 1 ([1,2],Res);
154 moveDown 1 ([1,2],Res); refFormula 1 ([1,3],Res);
155 moveDown 1 ([1,3],Res); refFormula 1 ([1,4],Res);
156 moveDown 1 ([1,4],Res); refFormula 1 ([1,5],Res);
157 moveDown 1 ([1,5],Res); refFormula 1 ([1,6],Res);
158 val ((pt,_),_) = get_calc 1;
159 if "2 + -1 + x = 2" = term2str (fst (get_obj g_result pt [1,6])) then()
160 else error "inform.sml: diff.behav.appendFormula: on Frm + equ 1";
162 fetchProposedTactic 1; (*takes Iterator 1 _1_*)
163 val (_,(tac,_,_)::_) = get_calc 1;
164 case tac of Rewrite_Set "norm_equation" => ()
165 | _ => error "inform.sml: diff.behav.appendFormula: on Frm + equ 2";
166 autoCalculate 1 CompleteCalc;
167 val ((pt,_),_) = get_calc 1;
168 if "[x = 1]" = term2str (fst (get_obj g_result pt [])) then ()
169 else error "inform.sml: diff.behav.appendFormula: on Frm + equ 3";
172 "--------- appendFormula: on Res + NO deriv ----------------------";
173 "--------- appendFormula: on Res + NO deriv ----------------------";
174 "--------- appendFormula: on Res + NO deriv ----------------------";
176 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
177 ("Test", ["sqroot-test","univariate","equation","test"],
178 ["Test","squ-equ-test-subpbl1"]))];
179 Iterator 1; moveActiveRoot 1;
180 autoCalculate 1 CompleteCalcHead;
181 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
182 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
184 appendFormula 1 "x = 2" (*|> Future.join*);
185 val ((pt,p),_) = get_calc 1;
186 val str = pr_ctree pr_short pt;
188 if str = ". ----- pblobj -----\n1. x + 1 = 2\n" andalso p = ([1], Res)
190 else error "inform.sml: diff.behav.appendFormula: Res + NOder 1";
192 fetchProposedTactic 1;
193 val (_,(tac,_,_)::_) = get_calc 1;
194 case tac of Rewrite_Set "Test_simplify" => ()
195 | _ => error "inform.sml: diff.behav.appendFormula: Res + NOder 2";
196 autoCalculate 1 CompleteCalc;
197 val ((pt,_),_) = get_calc 1;
198 if "[x = 1]" = term2str (fst (get_obj g_result pt [])) then ()
199 else error "inform.sml: diff.behav.appendFormula: on Frm + equ 3";
202 "--------- appendFormula: on Res + late deriv --------------------";
203 "--------- appendFormula: on Res + late deriv --------------------";
204 "--------- appendFormula: on Res + late deriv --------------------";
206 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
207 ("Test", ["sqroot-test","univariate","equation","test"],
208 ["Test","squ-equ-test-subpbl1"]))];
209 Iterator 1; moveActiveRoot 1;
210 autoCalculate 1 CompleteCalcHead;
211 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
212 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
214 appendFormula 1 "x = 1" (*|> Future.join*);
215 val ((pt,p),_) = get_calc 1;
216 val str = pr_ctree pr_short pt;
218 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)
219 then () (*finds 1 step too early: ([3,2], Res) "x = 1" also by script !!!*)
220 else error "inform.sml: diff.behav.appendFormula: Res + late d 1";
222 fetchProposedTactic 1;
223 val (_,(tac,_,_)::_) = get_calc 1;
224 case tac of Check_Postcond ["LINEAR", "univariate", "equation", "test"] => ()
225 | _ => error "inform.sml: diff.behav.appendFormula: Res + late d 2";
226 autoCalculate 1 CompleteCalc;
227 val ((pt,_),_) = get_calc 1;
228 if "[x = 1]" = term2str (fst (get_obj g_result pt [])) then ()
229 else error "inform.sml: diff.behav.appendFormula: Res + late d 3";
232 "--------- appendFormula: on Res + late deriv [x = 3 + -2]---///--";
233 "--------- appendFormula: on Res + late deriv [x = 3 + -2]---///--";
234 "--------- appendFormula: on Res + late deriv [x = 3 + -2]---///--";
236 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
237 ("Test", ["sqroot-test","univariate","equation","test"],
238 ["Test","squ-equ-test-subpbl1"]))];
239 Iterator 1; moveActiveRoot 1;
240 autoCalculate 1 CompleteCalcHead;
241 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
242 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
243 appendFormula 1 "[x = 3 + -2*1]" (*|> Future.join*);
244 val ((pt,p),_) = get_calc 1;
245 val str = pr_ctree pr_short pt;
247 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 ()
248 else error "inform.sml: diff.behav.appendFormula: Res + latEE 1";
249 autoCalculate 1 CompleteCalc;
250 val ((pt,p),_) = get_calc 1;
251 if "[x = 3 + -2 * 1]" = term2str (fst (get_obj g_result pt [])) then ()
252 (* ~~~~~~~~~~ simplify as last step in any script ?!*)
253 else error "inform.sml: diff.behav.appendFormula: Res + latEE 2";
256 "--------- replaceFormula: on Res + = ----------------------------";
257 "--------- replaceFormula: on Res + = ----------------------------";
258 "--------- replaceFormula: on Res + = ----------------------------";
260 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
261 ("Test", ["sqroot-test","univariate","equation","test"],
262 ["Test","squ-equ-test-subpbl1"]))];
263 Iterator 1; moveActiveRoot 1;
264 autoCalculate 1 CompleteCalcHead;
265 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
266 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
267 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*-1 + x*);
269 replaceFormula 1 "-2 * 1 + (1 + x) = 0"; refFormula 1 (get_pos 1 1);
270 val ((pt,_),_) = get_calc 1;
271 val str = pr_ctree pr_short pt;
273 (* before AK110725 this was
274 ". ----- pblobj -----\n
276 2. x + 1 + -1 * 2 = 0\n
277 2.1. x + 1 + -1 * 2 = 0\n
278 2.2. 1 + x + -1 * 2 = 0\n
279 2.3. 1 + (x + -1 * 2) = 0\n
280 2.4. 1 + (x + -2) = 0\n
281 2.5. 1 + (x + -2 * 1) = 0\n
282 2.6. 1 + x + -2 * 1 = 0\n";
285 ". ----- pblobj -----\n"^
287 "2. x + 1 + -1 * 2 = 0\n"^
288 "2.1. x + 1 + -1 * 2 = 0\n"^
289 "2.2. 1 + x + -1 * 2 = 0\n"^
290 "2.3. 1 + (x + -1 * 2) = 0\n"^
291 "2.4. 1 + (x + -2) = 0\n"^
292 "2.5. 1 + (x + -2 * 1) = 0\n"^
293 "2.6. 1 + x + -2 * 1 = 0\n" then()
294 else error "inform.sml: diff.behav.replaceFormula: on Res += 1";
296 autoCalculate 1 CompleteCalc;
297 val ((pt,pos as (p,_)),_) = get_calc 1;
298 if pos = ([],Res) andalso "[x = 1]" = (term2str o fst) (get_obj g_result pt p) then()
299 else error "inform.sml: diff.behav.replaceFormula: on Res + = 2";
302 "--------- replaceFormula: on Res + = 1st Nd ---------------------";
303 "--------- replaceFormula: on Res + = 1st Nd ---------------------";
304 "--------- replaceFormula: on Res + = 1st Nd ---------------------";
306 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
307 ("Test", ["sqroot-test","univariate","equation","test"],
308 ["Test","squ-equ-test-subpbl1"]))];
309 Iterator 1; moveActiveRoot 1;
310 autoCalculate 1 CompleteCalcHead;
311 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
312 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
314 replaceFormula 1 "x + 1 = 4 + -2"; refFormula 1 (get_pos 1 1);
315 val ((pt,_),_) = get_calc 1;
316 val str = pr_ctree pr_short pt;
318 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 ()
319 else error "inform.sml: diff.behav.replaceFormula: on Res 1 + = 1";
320 autoCalculate 1 CompleteCalc;
321 val ((pt,pos as (p,_)),_) = get_calc 1;
322 if pos = ([],Res) andalso "[x = 1]" = (term2str o fst)(get_obj g_result pt p) then()
323 else error "inform.sml: diff.behav.replaceFormula: on Res + = 2";
326 "--------- replaceFormula: on Frm + = 1st Nd ---------------------";
327 "--------- replaceFormula: on Frm + = 1st Nd ---------------------";
328 "--------- replaceFormula: on Frm + = 1st Nd ---------------------";
330 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
331 ("Test", ["sqroot-test","univariate","equation","test"],
332 ["Test","squ-equ-test-subpbl1"]))];
333 Iterator 1; moveActiveRoot 1;
334 autoCalculate 1 CompleteCalcHead;
335 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
337 replaceFormula 1 "x + 1 = 4 + -2"; refFormula 1 (get_pos 1 1);
338 val ((pt,_),_) = get_calc 1;
339 val str = pr_ctree pr_short pt;
341 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 ()
342 else error "inform.sml: diff.behav.replaceFormula: on Frm 1 + = 1";
343 autoCalculate 1 CompleteCalc;
344 val ((pt,pos as (p,_)),_) = get_calc 1;
345 if pos = ([],Res) andalso "[x = 1]" = (term2str o fst)(get_obj g_result pt p) then()
346 else error "inform.sml: diff.behav.replaceFormula: on Frm 1 + = 2";
349 "--------- replaceFormula: cut calculation -----------------------";
350 "--------- replaceFormula: cut calculation -----------------------";
351 "--------- replaceFormula: cut calculation -----------------------";
353 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
354 ("Test", ["sqroot-test","univariate","equation","test"],
355 ["Test","squ-equ-test-subpbl1"]))];
356 Iterator 1; moveActiveRoot 1;
357 autoCalculate 1 CompleteCalc;
358 moveActiveRoot 1; moveActiveDown 1;
359 if get_pos 1 1 = ([1], Frm) then ()
360 else error "inform.sml: diff.behav. cut calculation 1";
362 replaceFormula 1 "x + 1 = 4 + -2"; refFormula 1 (get_pos 1 1);
363 val ((pt,p),_) = get_calc 1;
364 val str = pr_ctree pr_short pt;
366 if p = ([1], Res) then ()
367 else error "inform.sml: diff.behav. cut calculation 2";
370 (* 040307 copied from informtest.sml; ... old version
371 "---------------- maximum-example, UC: Modeling / modifyCalcHead -";
372 "---------------- maximum-example, UC: Modeling / modifyCalcHead -";
373 "---------------- maximum-example, UC: Modeling / modifyCalcHead -";
376 val elems = ["fixedValues [r=Arbfix]","maximum A","valuesFor [a,b]",
377 "relations [A=a*b, (a/2)^^^2 + (b/2)^^^2 = r^^^2]",
378 "relations [A=a*b, (a/2)^^^2 + (b/2)^^^2 = r^^^2]",
379 "relations [A=a*b, a/2=r*sin alpha, b/2=r*cos alpha]",
380 (*^^^ these are the elements for the root-problem (in variants)*)
381 (*vvv these are elements required for subproblems*)
382 "boundVariable a","boundVariable b","boundVariable alpha",
383 "interval {x::real. 0 <= x & x <= 2*r}",
384 "interval {x::real. 0 <= x & x <= 2*r}",
385 "interval {x::real. 0 <= x & x <= pi}",
386 "errorBound (eps=(0::real))"]
387 (*specifying is not interesting for this example*)
388 val spec = ("DiffApp", ["maximum_of","function"],
389 ["DiffApp","max_by_calculus"]);
390 (*the empty model with descriptions for user-guidance by Model_Problem*)
391 val empty_model = [Given ["fixedValues []"],
392 Find ["maximum", "valuesFor"],
393 Relate ["relations []"]];
396 (*!!!!!!!!!!!!!!!!! DON'T USE me FOR FINDING nxt !!!!!!!!!!!!!!!!!!*)
397 val (p,_,f,nxt,_,pt) = CalcTreeTEST [(elems, spec)];
398 (*val nxt = ("Model_Problem", ...*)
399 val pbl = get_obj g_pbl pt (fst p); (writeln o (itms2str_ ctxt)) pbl;
401 val (p,_,f,nxt,_,pt) = me nxt p c pt;
402 (*nxt = Add_Given "fixedValues [r = Arbfix]"*)
403 val pbl = get_obj g_pbl pt (fst p); (writeln o (itms2str_ ctxt)) pbl;
405 (0 ,[] ,false ,#Given ,Inc fixedValues [] ,(??.empty, [])),
406 (0 ,[] ,false ,#Find ,Inc maximum ,(??.empty, [])),
407 (0 ,[] ,false ,#Find ,Inc valuesFor ,(??.empty, [])),
408 (0 ,[] ,false ,#Relate ,Inc relations [] ,(??.empty, []))]*)
410 (*the empty CalcHead is checked w.r.t the model and re-established as such*)
411 val (b,pt,ocalhd) = input_icalhd pt (p,"", empty_model, Pbl, e_spec);
412 val pbl = get_obj g_pbl pt (fst p); (writeln o (itms2str_ ctxt)) pbl;
413 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";
415 (*there is one input to the model (could be more)*)
417 input_icalhd pt (p,"", [Given ["fixedValues [r=Arbfix]"],
418 Find ["maximum", "valuesFor"],
419 Relate ["relations"]], Pbl, e_spec);
420 val pbl = get_obj g_pbl pt (fst p); (writeln o (itms2str_ ctxt)) pbl;
421 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 ()
422 else error "informtest.sml: diff.behav. max 2";
424 (*this input is complete in variant 3, but the ME doesn't recognize FIXXXXME
425 val (b,pt''''',ocalhd) =
426 input_icalhd pt (p,"", [Given ["fixedValues [r=Arbfix]"],
427 Find ["maximum A", "valuesFor [a,b]"],
428 Relate ["relations [A=a*b, a/2=r*sin alpha, \
429 \b/2=r*cos alpha]"]], Pbl, e_spec);
430 val pbl = get_obj g_pbl pt''''' (fst p); (writeln o (itms2str_ ctxt)) pbl;
431 if ocalhd2str ocalhd = ------------^^^^^^^^^^ missing !!!*)
433 (*this input is complete in variant 1 (variant 3 does not work yet)*)
434 val (b,pt''''',ocalhd) =
435 input_icalhd pt (p,"", [Given ["fixedValues [r=Arbfix]"],
436 Find ["maximum A", "valuesFor [a,b]"],
437 Relate ["relations [A=a*b, \
438 \(a/2)^^^2 + (b/2)^^^2 = r^^^2]"]],
440 val pbl = get_obj g_pbl pt''''' (fst p); (writeln o (itms2str_ ctxt)) pbl;
442 modifycalcheadOK2xml 111 (bool2str b) ocalhd;
446 "--------- syntax error ------------------------------------------";
447 "--------- syntax error ------------------------------------------";
448 "--------- syntax error ------------------------------------------";
450 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
451 ("Test", ["sqroot-test","univariate","equation","test"],
452 ["Test","squ-equ-test-subpbl1"]))];
453 Iterator 1; moveActiveRoot 1;
454 autoCalculate 1 CompleteCalcHead;
455 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
456 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
458 appendFormula 1 " x - "; (*<ERROR> syntax error in ' x - ' </ERROR>*)
459 val ((pt,_),_) = get_calc 1;
460 val str = pr_ctree pr_short pt;
462 if str = ". ----- pblobj -----\n1. x + 1 = 2\n" then ()
463 else error "inform.sml: diff.behav.appendFormula: syntax error";
466 "--------- CAS-command on ([],Pbl) -------------------------------";
467 "--------- CAS-command on ([],Pbl) -------------------------------";
468 "--------- CAS-command on ([],Pbl) -------------------------------";
469 val (p,_,f,nxt,_,pt) =
470 CalcTreeTEST [([], ("e_domID", ["e_pblID"], ["e_metID"]))];
471 val ifo = "solve(x+1=2,x)";
472 val (_,(_,c,(pt,p))) = inform ([],[],(pt,p)) "solve(x+1=2,x)";
474 val nxt = ("Apply_Method",Apply_Method ["Test","squ-equ-test-subpbl1"]);
475 val (p,_,f,nxt,_,pt) = me nxt p [] pt;
476 if p = ([1], Frm) andalso f2str f = "x + 1 = 2" then ()
477 else error "inform.sml: diff.behav. CAScmd ([],Pbl)";
480 "--------- CAS-command on ([],Pbl) FE-interface ------------------";
481 "--------- CAS-command on ([],Pbl) FE-interface ------------------";
482 "--------- CAS-command on ([],Pbl) FE-interface ------------------";
484 CalcTree [([], ("e_domID", ["e_pblID"], ["e_metID"]))];
487 replaceFormula 1 "solve(x+1=2,x)";
488 autoCalculate 1 CompleteCalc;
489 val ((pt,p),_) = get_calc 1;
491 if p = ([], Res) then ()
492 else error "inform.sml: diff.behav. CAScmd ([],Pbl) FE-interface";
495 "--------- inform [rational,simplification] ----------------------";
496 "--------- inform [rational,simplification] ----------------------";
497 "--------- inform [rational,simplification] ----------------------";
499 CalcTree [(["Term (a * x / (b * x) + c * x / (d * x) + e / f)", "normalform N"],
500 ("Rational", ["rational", "simplification"], ["simplification", "of_rationals"]))];
501 Iterator 1; moveActiveRoot 1;
502 autoCalculate 1 CompleteCalcHead;
504 "--- (-1) give a preview on the calculation without any input";
506 autoCalculate 1 CompleteCalc;
507 val ((pt, p), _) = get_calc 1;
510 (([], Frm), Simplify (a * x / (b * x) + c * x / (d * x) + e / f)),
511 (([1], Frm), a * x / (b * x) + c * x / (d * x) + e / f),
512 (([1], Res), a / b + c / d + e / f), <--- (1) input arbitrary
513 (([2], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
514 (([3], Res), (a * (d * f) + b * (c * f) + b * (d * e)) / (b * (d * f))),
515 (([4], Res), (a * d * f + b * c * f + b * d * e) / (b * d * f)), <--- (2) input next
516 (([], Res), (a * d * f + b * c * f + b * d * e) / (b * d * f))] <--- (3) is also final result
519 "--- (0) user input as the *first* step does not work, thus impdo at least 1 step";
520 autoCalculate 1 (Step 1);
521 autoCalculate 1 (Step 1);
522 val ((pt, p), _) = get_calc 1;
525 (([], Frm), Simplify (a * x / (b * x) + c * x / (d * x) + e / f)),
526 (([1], Frm), a * x / (b * x) + c * x / (d * x) + e / f),
527 (([1], Res), a / b + c / d + e / f)]
529 "--- (1) input an arbitrary next formula";
530 appendFormula 1 "((a * d) + (c * b)) / (b * d) + e / f" (*|> Future.join*);
531 val ((pt, p), _) = get_calc 1;
534 (([], Frm), Simplify (a * x / (b * x) + c * x / (d * x) + e / f)),
535 (([1], Frm), a * x / (b * x) + c * x / (d * x) + e / f),
536 (([1], Res), a / b + c / d + e / f),
537 (([2,1], Frm), a / b + c / d + e / f),
538 (([2,1], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
539 (([2,2], Res), (a * d + c * b) / (b * d) + e / f),
540 (([2], Res), (a * d + c * b) / (b * d) + e / f)]
542 val ((pt,p),_) = get_calc 1;
543 if p = ([2], Res) andalso (length o children o (get_nd pt)) (fst p) = 2 then ()
544 else error ("inform.sml: [rational,simplification] 1");
546 "--- (2) input the next formula that would be presented by mat-engine";
547 (* generate a preview:
548 autoCalculate 1 (Step 1);
549 val ((pt, p), _) = get_calc 1;
552 (([], Frm), Simplify (a * x / (b * x) + c * x / (d * x) + e / f)),
553 (([1], Frm), a * x / (b * x) + c * x / (d * x) + e / f),
554 (([1], Res), a / b + c / d + e / f),
555 (([2,1], Frm), a / b + c / d + e / f),
556 (([2,1], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
557 (([2,2], Res), (a * d + c * b) / (b * d) + e / f),
558 (([2], Res), (a * d + c * b) / (b * d) + e / f),
559 (([3], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f))] <--- input this
561 appendFormula 1 "(b * d * e + b * c * f + a * d * f) / (b * d * f)" (*|> Future.join*);
562 val ((pt, p), _) = get_calc 1;
565 (([], Frm), Simplify (a * x / (b * x) + c * x / (d * x) + e / f)),
566 (([1], Frm), a * x / (b * x) + c * x / (d * x) + e / f),
567 (([1], Res), a / b + c / d + e / f),
568 (([2,1], Frm), a / b + c / d + e / f),
569 (([2,1], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
570 (([2,2], Res), (a * d + c * b) / (b * d) + e / f),
571 (([2], Res), (a * d + c * b) / (b * d) + e / f),
572 (([3], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f))]
574 if p = ([3], Res) andalso (length o children o (get_nd pt)) (fst p) = 0 then ()
575 else error ("inform.sml: [rational,simplification] 2");
577 "--- (3) input the exact final result";
578 appendFormula 1 "(b * d * e + b * c * f + a * d * f) / (b * d * f)" (*|> Future.join*);
579 val ((pt, p), _) = get_calc 1;
582 (([], Frm), Simplify (a * x / (b * x) + c * x / (d * x) + e / f)),
583 (([1], Frm), a * x / (b * x) + c * x / (d * x) + e / f),
584 (([1], Res), a / b + c / d + e / f),
585 (([2,1], Frm), a / b + c / d + e / f),
586 (([2,1], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
587 (([2,2], Res), (a * d + c * b) / (b * d) + e / f),
588 (([2], Res), (a * d + c * b) / (b * d) + e / f),
589 (([3], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
590 (([4,1], Frm), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
591 (([4,1], Res), (a * (d * f) + b * (c * f) + b * (d * e)) / (b * (d * f))),
592 (([4,2], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
593 (([4], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f))]
595 if p = ([4], Res) andalso (length o children o (get_nd pt)) (fst p) = 2 then ()
596 else error ("inform.sml: [rational,simplification] 3");
598 "--- (4) finish the calculation + check the postcondition (in the future)";
599 autoCalculate 1 CompleteCalc;
600 val ((pt, p), _) = get_calc 1;
601 val (t, asm) = get_obj g_result pt [];
602 if term2str t = "(a * d * f + b * c * f + b * d * e) / (b * d * f)" andalso
603 terms2str asm = "[\"b * d * f ~= 0\",\"d ~= 0\",\"b ~= 0\"," ^
604 "\"a * x / (b * x) + c * x / (d * x) + e / f is_ratpolyexp\"]"
605 then () else error "inform [rational,simplification] changed at end";
608 (([], Frm), Simplify (a * x / (b * x) + c * x / (d * x) + e / f)),
609 (([1], Frm), a * x / (b * x) + c * x / (d * x) + e / f),
610 (([1], Res), a / b + c / d + e / f),
611 (([2,1], Frm), a / b + c / d + e / f),
612 (([2,1], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
613 (([2,2], Res), (a * d + c * b) / (b * d) + e / f),
614 (([2], Res), (a * d + c * b) / (b * d) + e / f),
615 (([3], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
616 (([4,1], Frm), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
617 (([4,1], Res), (a * (d * f) + b * (c * f) + b * (d * e)) / (b * (d * f))),
618 (([4,2], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
619 (([4], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
620 (([5], Res), (a * (d * f) + b * (c * f) + b * (d * e)) / (b * (d * f))),
621 (([6], Res), (a * d * f + b * c * f + b * d * e) / (b * d * f)),
622 (([], Res), (a * d * f + b * c * f + b * d * e) / (b * d * f))]
626 "--------- Take as 1st tac, start with <NEW> (CAS input) ---------";
627 "--------- Take as 1st tac, start with <NEW> (CAS input) ---------";
628 "--------- Take as 1st tac, start with <NEW> (CAS input) ---------";
629 val t = str2term "Diff (x^^^2 + x + 1, x)";
630 case t of Const ("Diff.Diff", _) $ _ => ()
632 error "diff.sml behav.changed for CAS Diff (..., x)";
634 "-----------------------------------------------------------------";
635 (*1>*)reset_states ();
636 (*2>*)CalcTree [([], ("e_domID", ["e_pblID"], ["e_metID"]))];
637 (*3>*)Iterator 1;moveActiveRoot 1;
638 "----- here the Headline has been finished";
639 (*4>*)moveActiveFormula 1 ([],Pbl);
640 (*5>*)replaceFormula 1 "Diff (x^2 + x + 1, x)";
641 val ((pt,_),_) = get_calc 1;
642 val PblObj {probl, meth, spec, fmz, env, loc, ...} = get_obj I pt [];
644 val (SOME istate, NONE) = loc;
645 default_print_depth 5;
646 writeln"-----------------------------------------------------------";
648 writeln (itms2str_ ctxt probl);
649 writeln (itms2str_ ctxt meth);
650 writeln (istate2str (fst istate));
652 refFormula 1 ([],Pbl) (*--> correct CalcHead*);
653 (*081016 NOT necessary (but leave it in Java):*)
654 (*6>*)(*completeCalcHead*)autoCalculate 1 CompleteCalcHead;
655 "----- here the CalcHead has been completed --- ONCE MORE ?????";
657 (***difference II***)
658 val ((pt,p),_) = get_calc 1;
659 (*val p = ([], Pbl)*)
660 val PblObj {probl, meth, spec, fmz, env, loc, ...} = get_obj I pt [];
662 val (SOME istate, NONE) = loc;
663 default_print_depth 5; writeln (istate2str (fst istate)); default_print_depth 3;
666 ??.empty, Sundef, false)*)
667 default_print_depth 5; spec; default_print_depth 3;
669 ["derivative_of", "function"],
670 ["diff", "differentiate_on_R"]) : spec*)
671 writeln (itms2str_ ctxt probl);
673 (1 ,[1] ,true ,#Given ,Cor functionTerm (x ^^^ 2 + x + 1) ,(f_, [x ^^^ 2 + x + 1])),
674 (2 ,[1] ,true ,#Given ,Cor differentiateFor x ,(v_, [x])),
675 (3 ,[1] ,true ,#Find ,Cor derivative f_'_f ,(f_'_f, [f_'_f]))]*)
676 writeln (itms2str_ ctxt meth);
678 (1 ,[1] ,true ,#Given ,Cor functionTerm (x ^^^ 2 + x + 1) ,(f_, [x ^^^ 2 + x + 1])),
679 (2 ,[1] ,true ,#Given ,Cor differentiateFor x ,(v_, [x])),
680 (3 ,[1] ,true ,#Find ,Cor derivative f_'_f ,(f_'_f, [f_'_f]))]*)
681 writeln"-----------------------------------------------------------";
682 (*7>*)fetchProposedTactic 1 (*--> Apply_Method*);
683 (*WN081028 fixed <ERROR> helpless </ERROR> by inform returning ...(.,Met)*)
684 autoCalculate 1 CompleteCalc;
685 val ((pt,p),_) = get_calc 1;
686 val Form res = (#1 o pt_extract) (pt, ([],Res));
688 if p = ([], Res) andalso term2str res = "1 + 2 * x" then ()
689 else error "diff.sml behav.changed for Diff (x^2 + x + 1, x)";
692 "--------- Take as 1st tac, start from exp -----------------------";
693 "--------- Take as 1st tac, start from exp -----------------------";
694 "--------- Take as 1st tac, start from exp -----------------------";
695 (*the following input is copied from BridgeLog Java <==> SML,
696 omitting unnecessary inputs*)
697 (*1>*)reset_states ();
698 (*2>*)CalcTree [(["functionTerm (x^2 + x + 1)", "differentiateFor x", "derivative f_'_f"],("Isac",["derivative_of","function"],["diff","differentiate_on_R"]))];
699 (*3>*)Iterator 1; moveActiveRoot 1;
701 (*6>*)(*completeCalcHead*)autoCalculate 1 CompleteCalcHead;
702 (***difference II***)
703 val ((pt,_),_) = get_calc 1;
704 val PblObj {probl, meth, spec, fmz, env, loc, ...} = get_obj I pt [];
706 val (SOME istate, NONE) = loc;
707 default_print_depth 5; writeln (istate2str (fst istate)); default_print_depth 3;
710 ??.empty, Sundef, false)*)
711 default_print_depth 5; spec; default_print_depth 3;
713 ["derivative_of", "function"],
714 ["diff", "differentiate_on_R"]) : spec*)
715 writeln (itms2str_ ctxt probl);
717 (1 ,[1] ,true ,#Given ,Cor functionTerm (x ^^^ 2 + x + 1) ,(f_, [x ^^^ 2 + x + 1])),
718 (2 ,[1] ,true ,#Given ,Cor differentiateFor x ,(v_, [x])),
719 (3 ,[1] ,true ,#Find ,Cor derivative f_'_f ,(f_'_f, [f_'_f]))]*)
720 writeln (itms2str_ ctxt meth);
722 (1 ,[1] ,true ,#Given ,Cor functionTerm (x ^^^ 2 + x + 1) ,(f_, [x ^^^ 2 + x + 1])),
723 (2 ,[1] ,true ,#Given ,Cor differentiateFor x ,(v_, [x])),
724 (3 ,[1] ,true ,#Find ,Cor derivative f_'_f ,(f_'_f, [f_'_f]))]*)
725 writeln"-----------------------------------------------------------";
726 (*7>*)fetchProposedTactic 1 (*--> Apply_Method*);
727 autoCalculate 1 (Step 1);
728 val ((pt,p),_) = get_calc 1;
729 val Form res = (#1 o pt_extract) (pt, p);
730 if term2str res = "d_d x (x ^^^ 2 + x + 1)" then ()
731 else error "diff.sml Diff (x^2 + x + 1, x) from exp";
734 "--------- init_form, start with <NEW> (CAS input) ---------------";
735 "--------- init_form, start with <NEW> (CAS input) ---------------";
736 "--------- init_form, start with <NEW> (CAS input) ---------------";
738 CalcTree [([], ("e_domID", ["e_pblID"], ["e_metID"]))];
739 (*[[from sml: > @@@@@begin@@@@@
741 [[from sml: <CALCTREE>
742 [[from sml: <CALCID> 1 </CALCID>
743 [[from sml: </CALCTREE>
744 [[from sml: @@@@@end@@@@@*)
746 (*[[from sml: > @@@@@begin@@@@@
748 [[from sml: <ADDUSER>
749 [[from sml: <CALCID> 1 </CALCID>
750 [[from sml: <USERID> 1 </USERID>
751 [[from sml: </ADDUSER>
752 [[from sml: @@@@@end@@@@@*)
754 (*[[from sml: > @@@@@begin@@@@@
756 [[from sml: <CALCITERATOR>
757 [[from sml: <CALCID> 1 </CALCID>
758 [[from sml: <POSITION>
759 [[from sml: <INTLIST>
760 [[from sml: </INTLIST>
761 [[from sml: <POS> Pbl </POS>
762 [[from sml: </POSITION>
763 [[from sml: </CALCITERATOR>
764 [[from sml: @@@@@end@@@@@*)
765 getFormulaeFromTo 1 ([],Pbl) ([],Pbl) 0 false;
766 (*[[from sml: > @@@@@begin@@@@@ STILL CORRECT
768 [[from sml: <GETELEMENTSFROMTO>
769 [[from sml: <CALCID> 1 </CALCID>
770 [[from sml: <FORMHEADS>
771 [[from sml: <CALCFORMULA>
772 [[from sml: <POSITION>
773 [[from sml: <INTLIST>
774 [[from sml: </INTLIST>
775 [[from sml: <POS> Pbl </POS>
776 [[from sml: </POSITION>
777 [[from sml: <FORMULA>
779 [[from sml: <ISA> ________________________________________________ </ISA>
780 [[from sml: </MATHML>
782 [[from sml: </FORMULA>
783 [[from sml: </CALCFORMULA>
784 [[from sml: </FORMHEADS>
785 [[from sml: </GETELEMENTSFROMTO>
786 [[from sml: @@@@@end@@@@@*)
787 refFormula 1 ([],Pbl);
788 (*[[from sml: > @@@@@begin@@@@@ STILL CORRECT
790 [[from sml: <REFFORMULA>
791 [[from sml: <CALCID> 1 </CALCID>
792 [[from sml: <CALCHEAD status = "incorrect">
793 [[from sml: <POSITION>
794 [[from sml: <INTLIST>
795 [[from sml: </INTLIST>
796 [[from sml: <POS> Pbl </POS>
797 [[from sml: </POSITION>
800 [[from sml: <ISA> Problem (e_domID, [e_pblID]) </ISA>
801 [[from sml: </MATHML>
804 [[from sml: <GIVEN> </GIVEN>
805 [[from sml: <WHERE> </WHERE>
806 [[from sml: <FIND> </FIND>
807 [[from sml: <RELATE> </RELATE>
809 [[from sml: <BELONGSTO> Pbl </BELONGSTO>
810 [[from sml: <SPECIFICATION>
811 [[from sml: <THEORYID> e_domID </THEORYID>
812 [[from sml: <PROBLEMID>
813 [[from sml: <STRINGLIST>
814 [[from sml: <STRING> e_pblID </STRING>
815 [[from sml: </STRINGLIST>
816 [[from sml: </PROBLEMID>
817 [[from sml: <METHODID>
818 [[from sml: <STRINGLIST>
819 [[from sml: <STRING> e_metID </STRING>
820 [[from sml: </STRINGLIST>
821 [[from sml: </METHODID>
822 [[from sml: </SPECIFICATION>
823 [[from sml: </CALCHEAD>
824 [[from sml: </REFFORMULA>
825 [[from sml: @@@@@end@@@@@*)
826 moveActiveFormula 1 ([],Pbl);
827 (*[[from sml: > @@@@@begin@@@@@
829 [[from sml: <CALCITERATOR>
830 [[from sml: <CALCID> 1 </CALCID>
831 [[from sml: <POSITION>
832 [[from sml: <INTLIST>
833 [[from sml: </INTLIST>
834 [[from sml: <POS> Pbl </POS>
835 [[from sml: </POSITION>
836 [[from sml: </CALCITERATOR>
837 [[from sml: @@@@@end@@@@@*)
838 replaceFormula 1 "Simplify (1+2)";
839 (*[[from sml: > @@@@@begin@@@@@
841 [[from sml: <REPLACEFORMULA>
842 [[from sml: <CALCID> 1 </CALCID>
843 [[from sml: <CALCCHANGED>
844 [[from sml: <UNCHANGED>
845 [[from sml: <INTLIST>
846 [[from sml: </INTLIST>
847 [[from sml: <POS> Pbl </POS>
848 [[from sml: </UNCHANGED>
849 [[from sml: <DELETED>
850 [[from sml: <INTLIST>
851 [[from sml: </INTLIST>
852 [[from sml: <POS> Pbl </POS>
853 [[from sml: </DELETED>
854 [[from sml: <GENERATED>
855 [[from sml: <INTLIST>
856 [[from sml: </INTLIST>
857 [[from sml: <POS> Met </POS> DIFFERENCE: Pbl
858 [[from sml: </GENERATED>
859 [[from sml: </CALCCHANGED>
860 [[from sml: </REPLACEFORMULA>
861 [[from sml: @@@@@end@@@@@*)
862 getFormulaeFromTo 1 ([],Pbl) ([],Pbl) 0 false(* DIFFERENCE: Pbl*);
876 <ISA> Simplify (1 + 2) </ISA> WORKS !!!!!
883 getFormulaeFromTo 1 ([],Pbl) ([],Met) 0 false;
884 (*[[from sml: > @@@@@begin@@@@@
886 [[from sml: <SYSERROR>
887 [[from sml: <CALCID> 1 </CALCID>
888 [[from sml: <ERROR> error in getFormulaeFromTo </ERROR>
889 [[from sml: </SYSERROR>
890 [[from sml: @@@@@end@@@@@*)
891 (*step into getFormulaeFromTo --- bug corrected...*)
893 "--------- build fun check_err_patt ------------------------------";
894 "--------- build fun check_err_patt ------------------------------";
895 "--------- build fun check_err_patt ------------------------------";
896 val subst = [(str2term "bdv", str2term "x")]: subst;
897 val rls = norm_Rational
898 val pat = parse_patt @{theory} "(?a + ?b)/(?b + ?c) = ?a / ?c";
899 val (res, inf) = (str2term "(2 + 3)/(3 + 4)", str2term "2 / 4");
900 val (res, inf) = (str2term "(2 + 3)/(3 + 4)", str2term "1 / 2");
902 val (res', _, _, rewritten) = (*rewritten: the lhs of the pattern matches in res*)
903 rew_sub thy 1 [] e_rew_ord e_rls false [] (Trueprop $ pat) res;
904 if rewritten then NONE else SOME "e_errpatID";
906 val norm_res = case rewrite_set_ (Isac()) false rls res' of
908 | SOME (norm_res, _) => norm_res
910 val norm_inf = case rewrite_set_ (Isac()) false rls inf of
912 | SOME (norm_inf, _) => norm_inf;
917 val pat = parse_patt @{theory} "(?a + ?b)/?a = ?b";
918 val (res, inf) = (str2term "(2 + 3)/2", str2term "3");
919 if check_err_patt (res, inf) subst ("errpatID", pat) rls = SOME "errpatID"
920 then () else error "error patt example1 changed";
922 val pat = parse_patt @{theory} "(?a + ?b)/(?a + ?c) = ?b / ?c";
923 val (res, inf) = (str2term "(2 + 3)/(2 + 4)", str2term "3 / 4");
924 if check_err_patt (res, inf) subst ("errpatID", pat) rls = SOME "errpatID"
925 then () else error "error patt example2 changed";
927 val pat = parse_patt @{theory} "(?a + ?b)/(?b + ?c) = ?a / ?c";
928 val (res, inf) = (str2term "(2 + 3)/(3 + 4)", str2term "2 / 4");
929 if check_err_patt (res, inf) subst ("errpatID", pat) rls = SOME "errpatID"
930 then () else error "error patt example3 changed";
932 val inf = str2term "1 / 2";
933 if check_err_patt (res, inf) subst ("errpatID", pat) rls = SOME "errpatID"
934 then () else error "error patt example3 changed";
936 "--------- build fun check_err_patt ?bdv -------------------------";
937 "--------- build fun check_err_patt ?bdv -------------------------";
938 "--------- build fun check_err_patt ?bdv -------------------------";
939 val subst = [(str2term "bdv", str2term "x")]: subst;
940 val t = str2term "d_d x (x ^^^ 2 + sin (x ^^^ 4))";
941 val SOME (t, _) = rewrite_set_inst_ thy false subst norm_diff t;
942 if term2str t = "2 * x + cos (x ^^^ 4) * 4 * x ^^^ 3" then ()
943 else error "build fun check_err_patt ?bdv changed 1";
946 val pat = parse_patt @{theory} "d_d ?bdv (sin ?u) = cos (d_d ?bdv ?u)";
947 val (res, inf) = (str2term "2 * x + d_d x (sin (x ^^^ 4))", str2term "2 * x + cos (4 * x ^^^ 3)");
949 val (res', _, _, rewritten) = (*rewritten: the lhs of the pattern matches in res*)
950 rew_sub thy 1 subst e_rew_ord e_rls false [] (Trueprop $ pat) res;
951 if term2str res' = "2 * x + cos (d_d x (x ^^^ 4))" andalso rewritten then ()
952 else error "build fun check_err_patt ?bdv changed 2";
954 val norm_res = case rewrite_set_inst_ (Isac()) false subst rls res' of
956 | SOME (norm_res, _) => norm_res;
957 if term2str norm_res = "2 * x + cos (4 * x ^^^ 3)" then ()
958 else error "build fun check_err_patt ?bdv changed 3";
960 val norm_inf = case rewrite_set_inst_ (Isac()) false subst rls inf of
962 | SOME (norm_inf, _) => norm_inf;
963 if term2str norm_inf = "2 * x + cos (4 * x ^^^ 3)" then ()
964 else error "build fun check_err_patt ?bdv changed 4";
967 if norm_res = norm_inf then ()
968 else error "build fun check_err_patt ?bdv changed 5";
970 if check_err_patt (res, inf) (subst: subst) ("errpatID": errpatID, pat) rls = SOME "errpatID"
971 then () else error "error patt example1 changed";
973 "--------- build fun check_error_patterns ------------------------";
974 "--------- build fun check_error_patterns ------------------------";
975 "--------- build fun check_error_patterns ------------------------";
977 (str2term "d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))",
978 str2term "d_d x (x ^^^ 2) + cos (4 * x ^^^ 3)");
979 val {errpats, nrls = rls, scr = Prog prog, ...} = get_met ["diff", "differentiate_on_R"]
981 val env = [(str2term "v_v", str2term "x")];
983 [e_errpat, (*generalised for testing*)
984 ("chain-rule-diff-both",
985 [parse_patt @{theory} "d_d ?bdv (sin ?u) = cos (d_d ?bdv ?u)",
986 parse_patt @{theory} "d_d ?bdv (cos ?u) = - sin (d_d ?bdv ?u)",
987 parse_patt @{theory} "d_d ?bdv (?u ^^^ ?n) = ?n * ?u ^^^ (?n - 1)",
988 parse_patt @{theory} "d_d ?bdv (LogExp.ln ?u) = 1 / ?u",
989 parse_patt @{theory} "d_d ?bdv (LogExp.ln ?u) = 1 / d_d ?bdv ?u"],
990 [@{thm diff_sin_chain}, @{thm diff_cos_chain}, @{thm diff_pow_chain},
991 @{thm diff_ln_chain}, @{thm diff_exp_chain}])]: errpat list;
992 case check_error_patterns (res, inf) (prog, env) (errpats, rls) of SOME _ => ()
993 | NONE => error "check_error_patterns broken";
996 "--------- embed fun check_error_patterns ------------------------";
997 "--------- embed fun check_error_patterns ------------------------";
998 "--------- embed fun check_error_patterns ------------------------";
1001 [(["functionTerm (x ^ 2 + sin (x ^ 4))", "differentiateFor x", "derivative f_f'"],
1002 ("Isac", ["derivative_of","function"], ["diff","differentiate_on_R"]))];
1005 autoCalculate 1 CompleteCalcHead;
1006 autoCalculate 1 (Step 1);
1007 autoCalculate 1 (Step 1);(*([1], Res), d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))*)
1008 (*autoCalculate 1 (Step 1);([2], Res), d_d x (x ^^^ 2) + cos (x ^^^ 4) * d_d x (x ^^^ 4)*)
1010 "~~~~~ fun appendFormula, args:"; val (cI, (ifo:cterm')) = (1, "d_d x (x ^ 2) + cos (4 * x ^ 3)");
1011 val cs = get_calc cI
1012 val pos as (_,p_) = get_pos cI 1; (*pos = ([1], Res)*)
1017 val (_, _, (pt, ([2], Res))) = cs';
1019 [(([], Frm), Diff (x ^^^ 2 + sin (x ^^^ 4), x)),
1020 (([1], Frm), d_d x (x ^^^ 2 + sin (x ^^^ 4))),
1021 (([1], Res), d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))), <<=== input follos: "...+ cos(4.x^3)"
1022 (([2], Res), d_d x (x ^^^ 2) + cos (x ^^^ 4) * d_d x (x ^^^ 4))] *)
1024 "~~~~~ fun inform, args:"; val ((cs as (_, _, ptp as (pt, pos as (p, p_))): calcstate'), istr) =
1025 (cs', (encode ifo));
1026 val SOME f_in = parse (assoc_thy "Isac") istr
1027 val f_in = Thm.term_of f_in
1028 val pos_pred = lev_back' pos
1029 (* f_pred ---"step pos cs"---> f_succ in appendFormula
1030 TODO.WN120517: one starting point for redesign of pos' *)
1031 val (f_pred, f_succ) = (get_curr_formula (pt, pos_pred), get_curr_formula (pt, pos));
1033 term2str f_pred = "d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))";
1034 term2str f_succ = "d_d x (x ^^^ 2) + cos (x ^^^ 4) * d_d x (x ^^^ 4)";
1036 f_succ = f_in; (* = false*)
1037 cas_input f_in; (* = NONE*)
1038 val msg_calcstate' = compare_step ([], [], (pt, pos_pred)) f_in
1039 val ("no derivation found", calcstate') = msg_calcstate';
1040 val pp = par_pblobj pt p
1041 val {errpats, nrls, scr = Prog prog, ...} = get_met (get_obj g_metID pt pp)
1042 val ScrState (env, _, _, _, _, _) = get_istate pt pos;
1043 case check_error_patterns (f_pred, f_in) (prog, env) (errpats, nrls) of
1044 SOME errpatID => ("error pattern #" ^ errpatID ^ "#", calcstate')
1045 | NONE => msg_calcstate';
1047 "~~~~~ from inform return val:"; val () = ();
1048 case check_error_patterns (f_pred, f_in) (prog, env) (errpats, nrls) of
1050 | NONE => error "check_error_patterns broken";
1053 case inform cs' (encode ifo) of
1054 ("error pattern #chain-rule-diff-both#", calcstate') => ()
1055 | _ => error "inform with (positive) check_error_patterns broken"
1057 "--------- build fun get_fillpats --------------------------------";
1058 "--------- build fun get_fillpats --------------------------------";
1059 "--------- build fun get_fillpats --------------------------------";
1060 (*cause for this test was: wrong thy in Build_Thydata.thy in
1061 insert_fillpats ["IsacKnowledge", "Diff", "Theorems", "diff_sin_chain"]*)
1062 val f_curr = str2term "d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))"
1063 val errpatID = "chain-rule-diff-both"
1064 val {errpats, scr = Prog prog, ...} = get_met ["diff", "differentiate_on_R"]
1066 [(str2term "f_f", str2term "x ^^^ 2 + sin (x ^^^ 4)"),
1067 (str2term "v_v", str2term "x"),
1068 (str2term "f_f'", str2term "d_d x (x ^^^ 2 + sin (x ^^^ 4))")]
1069 val subst = get_bdv_subst prog env
1070 val errpatthms = errpats
1071 |> filter ((curry op = errpatID) o (#1: errpat -> errpatID))
1072 |> map (#3: errpat -> thm list)
1074 "~~~~~ fun get_fillpats, args:"; val (subst, form, errpatID, thm) =
1075 (subst, f_curr, errpatID, hd (*simulate beginning of "map"*) errpatthms);
1076 val thmDeriv = Thm.get_name_hint thm
1077 val (part, thyID) = thy_containing_thm thmDeriv
1078 val theID = [part, thyID, "Theorems", thmID_of_derivation_name thmDeriv]
1079 val Hthm {fillpats, ...} = get_the theID
1080 val some = map (get_fillform subst (thm, form) errpatID) fillpats;
1081 "~~~~~ fun get_fillform, args:";
1082 val ((subs_opt, subst), (thm, form), errpatID, (fillpatID, pat, erpaID)) =
1083 (subst, (thm, form), errpatID, hd (*simulate beginning of "map"*) fillpats);
1084 val (form', _, _, rewritten) =
1085 rew_sub (Isac()) 1 subst e_rew_ord e_rls false [] (Trueprop $ pat) form;
1086 "~~~~~ fun rew_sub, args:"; val (thy, i, bdv, tless, rls, put_asm, lrd:lrd list, r, t) =
1087 ((Isac()), 1, subst, e_rew_ord, e_rls, false, [], (Trueprop $ pat), form);
1088 val (lhs, rhs) = (HOLogic.dest_eq o HOLogic.dest_Trueprop
1089 o Logic.strip_imp_concl) r;
1090 (*/-------------catch the planned exception*)
1092 val r' = Envir.subst_term (Pattern.match thy (lhs, t)
1093 (Vartab.empty, Vartab.empty)) r;
1095 ) handle PATTERN (*because only a subterm matches*) => 111;
1096 case t of t1 $ t2 =>
1097 let val (t2', asm2, lrd, rew2) = rew_sub thy i bdv tless rls put_asm (lrd@[R]) r t2
1099 if rew2 then (t1 $ t2', asm2, lrd, true) else
1100 let val (t1', asm1, lrd, rew1) = rew_sub thy i bdv tless rls put_asm (lrd@[L]) r t1
1101 in if rew1 then (t1' $ t2, asm1, lrd, true) else (t1 $ t2,[], lrd, false) end
1103 (*catch the planned exception-------------/*)
1106 val (t2', asm2, lrd, rew2) = rew_sub thy i bdv tless rls put_asm (lrd@[R]) r t2;
1107 "~~~~~ fun rew_sub, args:"; val (thy, i, bdv, tless, rls, put_asm, lrd:lrd list, r, t) =
1108 (thy, i, bdv, tless, rls, put_asm, (lrd@[R]), r, t2);
1109 val (lhs, rhs) = (HOLogic.dest_eq o HOLogic.dest_Trueprop o Logic.strip_imp_concl) r;
1110 val r' = Envir.subst_term (Pattern.match thy (lhs, t) (Vartab.empty, Vartab.empty)) r;
1111 val p' = map HOLogic.dest_Trueprop ((fst o Logic.strip_prems) (Logic.count_prems r', [], r'));
1112 val t' = (snd o HOLogic.dest_eq o HOLogic.dest_Trueprop o Logic.strip_imp_concl) r';
1113 if term2str t' = "cos (x ^^^ 4) * d_d x ?_dummy_1" then ()
1114 else error "get_fillpats changed 1"
1117 "--------- embed fun find_fillpatterns ---------------------------";
1118 "--------- embed fun find_fillpatterns ---------------------------";
1119 "--------- embed fun find_fillpatterns ---------------------------";
1122 [(["functionTerm (x ^ 2 + sin (x ^ 4))", "differentiateFor x", "derivative f_f'"],
1123 ("Isac", ["derivative_of","function"], ["diff","differentiate_on_R"]))];
1126 autoCalculate 1 CompleteCalcHead;
1127 autoCalculate 1 (Step 1);
1128 autoCalculate 1 (Step 1);(*([1], Res), d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))*)
1129 appendFormula 1 "d_d x (x ^ 2) + cos (4 * x ^ 3)" (*|> Future.join*);
1130 (*<CALCMESSAGE> error pattern #chain-rule-diff-both# </CALCMESSAGE>*)
1132 <CALCMESSAGE> no derivation found </CALCMESSAGE>*)
1134 "~~~~~ fun findFillpatterns, args:"; val (cI, errpatID) = (1, "chain-rule-diff-both");
1135 val ((pt, _), _) = get_calc cI
1136 val pos = get_pos cI 1;
1137 "~~~~~ fun find_fillpatterns, args:"; val ((pt, pos as (p, _)), errpatID) = ((pt, pos), errpatID);
1138 val f_curr = get_curr_formula (pt, pos); (* = "d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))"*)
1139 val pp = par_pblobj pt p
1140 val {errpats, scr = Prog prog, ...} = get_met (get_obj g_metID pt pp)
1141 val ScrState (env, _, _, _, _, _) = get_istate pt pos
1142 val subst = get_bdv_subst prog env
1143 val errpatthms = errpats
1144 |> filter ((curry op = errpatID) o (#1: errpat -> errpatID))
1145 |> map (#3: errpat -> thm list)
1148 case map (get_fillpats subst f_curr errpatID) errpatthms |> flat of
1149 ("fill-d_d-arg", tm, thm, subs_opt) :: _ => if term2str tm =
1150 "d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4)) =\nd_d x (x ^^^ 2) + cos (x ^^^ 4) * d_d x ?_dummy_1"
1151 then () else error "find_fillpatterns changed 1a"
1152 | _ => error "find_fillpatterns changed 1b"
1154 "~~~~~ fun get_fillpats, args:"; val (subst, form, errpatID, thm) =
1155 (subst, f_curr, errpatID, hd (*simulate beginning of "map"*) errpatthms);
1156 val thmDeriv = Thm.get_name_hint thm
1157 val (part, thyID) = thy_containing_thm thmDeriv
1158 val theID = [part, thyID, "Theorems", thmID_of_derivation_name thmDeriv]
1159 val Hthm {fillpats, ...} = get_the theID
1160 val some = map (get_fillform subst (thm, form) errpatID) fillpats;
1162 case some |> filter is_some |> map the of
1163 ("fill-d_d-arg", tm, thm, subsopt) :: _ => if term2str tm =
1164 "d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4)) =\nd_d x (x ^^^ 2) + cos (x ^^^ 4) * d_d x ?_dummy_1"
1165 then () else error "find_fillpatterns changed 2a"
1166 | _ => error "find_fillpatterns changed 2b"
1168 "~~~~~ fun get_fillform, args:";
1169 val ((subs_opt, subst), (thm, form), errpatID, (fillpatID, pat, erpaID)) =
1170 (subst, (thm, form), errpatID, hd (*simulate beginning of "map"*) fillpats);
1171 val (form', _, _, rewritten) =
1172 rew_sub (Isac()) 1 subst e_rew_ord e_rls false [] (Trueprop $ pat) form;
1174 if term2str form' = "d_d x (x ^^^ 2) + cos (x ^^^ 4) * d_d x ?_dummy_1" then ()
1175 else error "find_fillpatterns changed 3";
1177 "~~~~~ to findFillpatterns return val:"; val (fillpats) =
1178 (map (get_fillpats (subs_opt, subst) f_curr errpatID) errpatthms |> flat) (*only from "hd errpatthms"*);
1180 "vvv--- dropped this code WN120730";
1181 val msg = "fill patterns " ^
1182 ((map ((apsnd term2str) o quad2pair) fillpats) |> map pair2str_ |> strs2str_);
1184 "fill patterns #fill-d_d-arg#d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))" ^
1185 " =\nd_d x (x ^^^ 2) + cos (x ^^^ 4) * d_d x ?_dummy_1" ^
1186 "#fill-both-args#d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))" ^
1187 " =\nd_d x (x ^^^ 2) + cos ?_dummy_2 * d_d x ?_dummy_3" ^
1188 "#fill-d_d#d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))" ^
1189 " =\nd_d x (x ^^^ 2) + cos (x ^^^ 4) * ?_dummy_1 x (x ^^^ 4)" ^
1190 "#fill-inner-deriv#d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))" ^
1191 " =\nd_d x (x ^^^ 2) + cos (x ^^^ 4) * ?_dummy_1" ^
1192 "#fill-all#d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4)) = d_d x (x ^^^ 2) + ?_dummy_1#";
1193 "^^^--- dropped this code WN120730";
1195 if (map #1 fillpats) =
1196 ["fill-d_d-arg", "fill-both-args", "fill-d_d", "fill-inner-deriv", "fill-all"]
1197 then () else error "find_fillpatterns changed 4b";
1200 "--------- build fun is_exactly_equal, inputFillFormula ----------";
1201 "--------- build fun is_exactly_equal, inputFillFormula ----------";
1202 "--------- build fun is_exactly_equal, inputFillFormula ----------";
1205 [(["functionTerm (x ^ 2 + sin (x ^ 4))", "differentiateFor x", "derivative f_f'"],
1206 ("Isac", ["derivative_of","function"], ["diff","differentiate_on_R"]))];
1209 autoCalculate 1 CompleteCalcHead;
1210 autoCalculate 1 (Step 1);
1211 autoCalculate 1 (Step 1);(*([1], Res), d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))*)
1212 appendFormula 1 "d_d x (x ^ 2) + cos (4 * x ^ 3)" (*|> Future.join*); (*<<<<<<<=========================*)
1213 (* the check for errpat is maximally liberal (whole term modulo "nrls" from "type met"),
1214 would recognize "cos (4 * x ^ (4 - 1)) + 2 * x" as well.
1215 results in <CALCMESSAGE> error pattern #chain-rule-diff-both# </CALCMESSAGE>
1216 instead of <CALCMESSAGE> no derivation found </CALCMESSAGE> *)
1217 val ((pt,pos), _) = get_calc 1;
1218 val p = get_pos 1 1;
1219 val (Form f, _, asms) = pt_extract (pt, p);
1221 if p = ([1], Res) andalso term2str f = "d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))" then
1222 case get_obj g_tac pt (fst p) of Rewrite_Inst (["(bdv, x)"],
1223 ("diff_sum", thm)) =>
1224 if (term2str o Thm.prop_of) thm = "d_d ?bdv (?u + ?v) = d_d ?bdv ?u + d_d ?bdv ?v" then ()
1225 else error "embed fun get_fillform changed 11"
1226 | _ => error "embed fun get_fillform changed 12"
1227 else error "embed fun get_fillform changed 13";
1229 findFillpatterns 1 "chain-rule-diff-both"; (*<<<<<<<=================================*)
1230 (*<CALCMESSAGE> fill patterns #fill-d_d-arg#d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4)) =
1231 d_d x (x ^^^ 2) + cos (x ^^^ 4) * d_d x ?_dummy_1#fill-both-args#...#...#... *)
1232 val ((pt,pos),_) = get_calc 1;
1233 val p = get_pos 1 1;
1235 val (Form f, _, asms) = pt_extract (pt, p);
1236 if p = ([1], Res) andalso term2str f = "d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))" then
1237 case get_obj g_tac pt (fst p) of Rewrite_Inst (["(bdv, x)"],
1238 ("diff_sum", thm)) =>
1239 if (term2str o Thm.prop_of) thm = "d_d ?bdv (?u + ?v) = d_d ?bdv ?u + d_d ?bdv ?v" then ()
1240 else error "embed fun get_fillform changed 21"
1241 | _ => error "embed fun get_fillform changed 22"
1242 else error "embed fun get_fillform changed 23";
1244 requestFillformula 1 ("chain-rule-diff-both", "fill-both-args");(*<<<<<<<============*)
1245 (*<AUTOCALC> ([1], Res) ([2], Res) ([2], Res) </AUTOCALC>*)
1246 val ((pt,pos),_) = get_calc 1;
1247 val p = get_pos 1 1;
1248 val (Form f, _, asms) = pt_extract (pt, p);
1249 if p = ([1], Res) andalso existpt [2] pt
1250 andalso term2str f = "d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))"
1251 then case get_obj g_tac pt (fst p) of Rewrite_Inst (["(bdv, x)"],
1252 ("diff_sum", thm)) =>
1253 if (term2str o Thm.prop_of) thm = "d_d ?bdv (?u + ?v) = d_d ?bdv ?u + d_d ?bdv ?v" then ()
1254 else error "embed fun get_fillform changed 31"
1255 | _ => error "embed fun get_fillform changed 32"
1256 else error "embed fun get_fillform changed 33";
1258 (* input a formula which exactly fills the gaps in a "fillformula"
1259 presented to the learner immediately before by "requestFillformula (errpatID, fillpatID)":
1260 errpatID: lhs of the respective thm = lhs of fillformula with fillpatID.
1261 the respective thm is in the ctree ................
1263 "~~~~~ fun inputFillFormula, args:"; val (cI, ifo) =
1264 (1, "d_d x (x ^^^ 2) + cos (x ^^^ 4) * d_d x (x ^^^ 4)");
1265 val ((pt, _), _) = get_calc cI
1266 val pos = get_pos cI 1;
1268 "~~~~~ fun is_exactly_equal, args:"; val ((pt, pos as (p, p_)), istr) = ((pt, pos), ifo);
1269 val SOME ifo = parseNEW (assoc_thy "Isac" |> thy2ctxt) istr
1271 val tac = get_obj g_tac pt p';
1272 val Rewrite_Inst ([bbb as "(bdv, x)"], ("diff_sin_chain", ttt)) = tac;
1273 if (term2str o Thm.prop_of) ttt = "d_d ?bdv (sin ?u) = cos ?u * d_d ?bdv ?u" then ()
1274 else error "inputFillFormula changed 10";
1275 val Appl rew = applicable_in pos pt tac;
1276 val Rewrite_Inst' (_, _, _, _, _, _, _, (res, _)) = rew;
1278 "~~~~~ to inputFillFormula return val:"; val ("ok", tac) = ("ok", tac);
1279 val ("ok", (_, c, ptp as (_,p'))) = locatetac tac (pt, pos);
1280 upd_calc cI (ptp, []);
1282 autocalculateOK2xml cI pos (if null c then p' else last_elem c) p';
1284 "~~~~~ final check:";
1285 val ((pt, _),_) = get_calc 1;
1286 val p = get_pos 1 1;
1287 val (Form f, _, asms) = pt_extract (pt, p);
1288 if p = ([2], Res) andalso term2str f = "d_d x (x ^^^ 2) + cos (x ^^^ 4) * d_d x (x ^^^ 4)"
1289 then case get_obj g_tac pt (fst p) of Rewrite_Inst (["(bdv, x)"],
1290 ("diff_sin_chain", thm)) =>
1291 if (term2str o Thm.prop_of) thm = "d_d ?bdv (sin ?u) = cos ?u * d_d ?bdv ?u" then ()
1292 else error "inputFillFormula changed 111"
1293 | _ => error "inputFillFormula changed 112"
1294 else error "inputFillFormula changed 113";
1296 "--------- fun appl_adds -----------------------------------------";
1297 "--------- fun appl_adds -----------------------------------------";
1298 "--------- fun appl_adds -----------------------------------------";
1299 (* val (dI, oris, ppc, pbt, selct::ss) =
1300 (dI, pors, probl, ppc, map itms2fstr probl);
1303 (* val (dI, oris, ppc, pbt, (selct::ss))=
1304 (#1 (some_spec ospec spec), oris, []:itm list,
1305 ((#ppc o get_pbt) (#2 (some_spec ospec spec))),(imodel2fstr imodel));
1306 val iii = appl_adds dI oris ppc pbt (selct::ss);
1307 tracing(itms2str_ thy iii);
1309 val itm = appl_add' dI oris ppc pbt selct;
1310 val ppc = insert_ppc' itm ppc;
1312 val _::selct::ss = (selct::ss);
1313 val itm = appl_add' dI oris ppc pbt selct;
1314 val ppc = insert_ppc' itm ppc;
1316 val _::selct::ss = (selct::ss);
1317 val itm = appl_add' dI oris ppc pbt selct;
1318 val ppc = insert_ppc' itm ppc;
1319 tracing(itms2str_ thy ppc);
1321 val _::selct::ss = (selct::ss);
1322 val itm = appl_add' dI oris ppc pbt selct;
1323 val ppc = insert_ppc' itm ppc;
1325 "--------- fun concat_deriv --------------------------------------";
1326 "--------- fun concat_deriv --------------------------------------";
1327 "--------- fun concat_deriv --------------------------------------";
1329 val ({rew_ord, erls, rules,...}, fo, ifo) =
1330 (rep_rls Test_simplify, str2term "x+1+ -1*2=0", str2term "-2*1+(x+1)=0");
1331 (tracing o trtas2str) fod';
1333 (x + 1 + -1 * 2 = 0, Thm ("radd_commute","?m + ?n = ?n + ?m"), (-1 * 2 + (x + 1) = 0, []))","
1334 (-1 * 2 + (x + 1) = 0, Thm ("radd_commute","?m + ?n = ?n + ?m"), (-1 * 2 + (1 + x) = 0, []))","
1335 (-1 * 2 + (1 + x) = 0, Thm ("radd_left_commute","?x + (?y + ?z) = ?y + (?x + ?z)"), (1 + (-1 * 2 + x) = 0, []))","
1336 (1 + (-1 * 2 + x) = 0, Thm ("#mult_Float ((~1,0), (0,0)) __ ((2,0), (0,0))","-1 * 2 = -2"), (1 + (-2 + x) = 0, []))"]
1338 (tracing o trtas2str) (map rev_deriv' rifod');
1340 (1 + (-2 + x) = 0, Thm ("sym_#mult_Float ((~2,0), (0,0)) __ ((1,0), (0,0))","-2 = -2 * 1"), (1 + (-2 * 1 + x) = 0, []))","
1341 (1 + (-2 * 1 + x) = 0, Thm ("sym_radd_left_commute","?y + (?x + ?z) = ?x + (?y + ?z)"), (-2 * 1 + (1 + x) = 0, []))","
1342 (-2 * 1 + (1 + x) = 0, Thm ("sym_radd_commute","?n + ?m = ?m + ?n"), (-2 * 1 + (x + 1) = 0, []))"]
1345 "--------- handle an input formula -------------------------------";
1346 "--------- handle an input formula -------------------------------";
1347 "--------- handle an input formula -------------------------------";
1349 Untersuchung zur Formeleingabe (appendFormula, replaceFormla) zu einer Anregung von Alan Krempler:
1350 Welche RICHTIGEN Formeln koennen NICHT abgeleitet werden,
1351 wenn Abteilungen nur auf gleichem Level gesucht werden ?
1354 Beispiele zum Equationsolver von Richard Lang aus /src/sml/kbtest/rlang.sml
1356 ------------------------------------------------------------------------------
1357 "Schalk I s.87 Bsp 52a ((5*x)/(x - 2) - x/(x+2)=4)";
1358 ------------------------------------------------------------------------------
1359 1. "5 * x / (x - 2) - x / (x + 2) = 4"
1361 4. "12 * x + 4 * x ^^^ 2 = 4 * (-4 + x ^^^ 2)",Subproblem["normalize", "poly"..
1363 4.3. "16 + 12 * x = 0", Subproblem["degree_1", "polynomial", "univariate"..
1365 4.3.3. "[x = -4 / 3]")), Check_elementwise "Assumptions"
1368 ------------------------------------------------------------------------------
1369 (1)..(6): keine 'richtige' Eingabe kann abgeleitet werden, die einen Summanden auf die andere Seite verschiebt [Ableitung ware in 4.3.n]
1371 (4.1)..(4.3): keine 'richtige' Eingabe kann abgeleitet werden, die einen Summanden auf die andere Seite verschiebt [Ableitung ware in 4.3.n]
1372 ------------------------------------------------------------------------------
1375 ------------------------------------------------------------------------------
1376 "Schalk I s.87 Bsp 55b (x/(x^^^2 - 6*x+9) - 1/(x^^^2 - 3*x) =1/x)";
1377 ------------------------------------------------------------------------------
1378 1. "x / (x ^^^ 2 - 6 * x + 9) - 1 / (x ^^^ 2 - 3 * x) = 1 / x"
1380 4. "(3 + (-1 * x + x ^^^ 2)) * x = 1 * (9 * x + (x ^^^ 3 + -6 * x ^^^ 2))"
1381 Subproblem["normalize", "polynomial", "univariate"..
1383 4.4. "-6 * x + 5 * x ^^^ 2 = 0", Subproblem["bdv_only", "degree_2", "poly"..
1385 4.4.4. "[x = 0, x = 6 / 5]", Check_elementwise "Assumptions"
1386 4.4.5. "[x = 0, x = 6 / 5]"
1388 5. "[x = 0, x = 6 / 5]", Check_elementwise "Assumptions"
1390 ------------------------------------------------------------------------------
1391 (1)..(4): keine 'richtige' Eingabe kann abgeleitet werden, die einen Summanden auf die andere Seite schiebt [Ableitung waere in 4.4.x]
1393 (4.1)..(4.4.5): keine 'richtige' Eingabe kann abgeleitet werden, die dem Ergebnis "[x = 6 / 5]" aequivalent ist [Ableitung waere in 5.]
1394 ------------------------------------------------------------------------------
1397 ------------------------------------------------------------------------------
1398 "Schalk II s.56 Bsp 73b (sqrt(x+1)+sqrt(4*x+4)=sqrt(9*x+9))";
1399 ------------------------------------------------------------------------------
1400 1. "sqrt (x + 1) + sqrt (4 * x + 4) = sqrt (9 * x + 9)"
1402 6. "13 + 13 * x + -2 * sqrt ((4 + 4 * x) * (9 + 9 * x)) = 1 + x"
1403 Subproblem["sq", "root'", "univariate", "equation"]
1405 6.6. "144 + 288 * x + 144 * x ^^^ 2 = 144 + x ^^^ 2 + 288 * x + 143 * x ^^^ 2"
1406 Subproblem["normalize", "polynomial", "univariate", "equation"]
1408 6.6.3 "0 = 0" Subproblem["degree_0", "polynomial", "univariate", "equation"]
1410 6.6.3.2 "UniversalList"
1411 ------------------------------------------------------------------------------
1412 (1)..(6): keine 'richtige' Eingabe kann abgeleitet werden, die eine der Wurzeln auf die andere Seite verschieb [Ableitung ware in 6.6.n]
1414 (6.1)..(6.3): keine 'richtige' Eingabe kann abgeleitet werden, die einen Summanden auf die andere Seite verschiebt [Ableitung ware in 6.6.n]
1415 ------------------------------------------------------------------------------
1417 (*sh. comments auf 498*)
1418 "--------- fun dropwhile' ----------------------------------------";
1419 "--------- fun dropwhile' ----------------------------------------";
1420 "--------- fun dropwhile' ----------------------------------------";
1422 fun equal a b = a=b;
1423 val foder = [0,1,2,3,4,5]; val ifoder = [11,12,3,4,5];
1424 val r_foder = rev foder; val r_ifoder = rev ifoder;
1425 dropwhile' equal r_foder r_ifoder;
1426 > vval it = ([0, 1, 2, 3], [3, 12, 11]) : int list * int list
1428 val foder = [3,4,5]; val ifoder = [11,12,3,4,5];
1429 val r_foder = rev foder; val r_ifoder = rev ifoder;
1430 dropwhile' equal r_foder r_ifoder;
1431 > val it = ([3], [3, 12, 11]) : int list * int list
1433 val foder = [5]; val ifoder = [11,12,3,4,5];
1434 val r_foder = rev foder; val r_ifoder = rev ifoder;
1435 dropwhile' equal r_foder r_ifoder;
1436 > val it = ([5], [5, 4, 3, 12, 11]) : int list * int list
1438 val foder = [10,11,12,13,14,15]; val ifoder = [11,12,3,4,5];
1439 val r_foder = rev foder; val r_ifoder = rev ifoder;
1440 dropwhile' equal r_foder r_ifoder;
1441 > *** dropwhile': did not start with equal elements*)