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 [x = 3 + -2]---///--";
14 "replaceForm with miniscript with mini-subpbl:";
15 "--------- replaceFormula: on Res + = ----------------------------";
16 "--------- replaceFormula: on Res + = 1st Nd ---------------------";
17 "--------- replaceFormula: on Frm + = 1st Nd ---------------------";
18 "--------- replaceFormula: cut calculation -----------------------";
19 "--------- replaceFormula: cut calculation -----------------------";
20 (* 040307 copied from informtest.sml ... old versions
21 "--------- maximum-example, UC: Modeling / modifyCalcHead --------";*)
22 "--------- syntax error ------------------------------------------";
24 "--------- CAS-command on ([],Pbl) -------------------------------";
25 "--------- CAS-command on ([],Pbl) FE-interface ------------------";
26 "--------- locate_input_term [rational,simplification] ----------------------";
27 "--------- Take as 1st tac, start with <NEW> (CAS input) ---------";
28 "--------- Take as 1st tac, start from exp -----------------------";
29 "--------- init_form, start with <NEW> (CAS input) ---------------";
30 "--------- build fun check_err_patt ------------------------------";
31 "--------- build fun check_err_patt ?bdv -------------------------";
32 "--------- build fun check_error_patterns ------------------------";
33 "--------- embed fun check_error_patterns ------------------------";
34 "--------- build fun get_fillpats --------------------------------";
35 "--------- embed fun find_fillpatterns ---------------------------";
36 "--------- build fun is_exactly_equal, inputFillFormula ----------";
37 "--------- fun appl_adds -----------------------------------------";
38 "--------- fun concat_deriv --------------------------------------";
39 "--------- handle an input formula -------------------------------";
40 "--------- fun dropwhile' ----------------------------------------";
41 "-----------------------------------------------------------------";
42 "-----------------------------------------------------------------";
43 "-----------------------------------------------------------------";
46 "--------- appendFormula: on Res + equ_nrls ----------------------";
47 "--------- appendFormula: on Res + equ_nrls ----------------------";
48 "--------- appendFormula: on Res + equ_nrls ----------------------";
49 val Prog sc = (#scr o get_met) ["Test","squ-equ-test-subpbl1"];
50 (writeln o term2str) sc;
51 val Prog sc = (#scr o get_met) ["Test","solve_linear"];
52 (writeln o term2str) sc;
55 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
56 ("Test", ["sqroot-test","univariate","equation","test"],
57 ["Test","squ-equ-test-subpbl1"]))];
58 Iterator 1; moveActiveRoot 1;
59 autoCalculate 1 CompleteCalcHead;
60 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
61 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
63 appendFormula 1 "-2 * 1 + (1 + x) = 0" (*|> Future.join*); refFormula 1 (get_pos 1 1);
64 val ((pt,_),_) = get_calc 1;
65 val str = pr_ctree pr_short pt;
67 (". ----- pblobj -----\n" ^
69 "2. x + 1 + -1 * 2 = 0\n" ^
70 "2.1. x + 1 + -1 * 2 = 0\n" ^
71 "2.2. 1 + x + -1 * 2 = 0\n" ^
72 "2.3. 1 + (x + -1 * 2) = 0\n" ^
73 "2.4. 1 + (x + -2) = 0\n" ^
74 "2.5. 1 + (x + -2 * 1) = 0\n" ^
75 "2.6. 1 + x + -2 * 1 = 0\n" ) then ()
76 else error "inform.sml: diff.behav.appendFormula: on Res + equ 1";
78 moveDown 1 ([ ],Pbl); refFormula 1 ([1],Frm); (*x + 1 = 2*)
79 moveDown 1 ([1],Frm); refFormula 1 ([1],Res); (*x + 1 + -1 * 2 = 0*)
81 (*the seven steps of detailed derivation*)
82 moveDown 1 ([1 ],Res); refFormula 1 ([2,1],Frm);
83 moveDown 1 ([2,1],Frm); refFormula 1 ([2,1],Res);
84 moveDown 1 ([2,1],Res); refFormula 1 ([2,2],Res);
85 moveDown 1 ([2,2],Res); refFormula 1 ([2,3],Res);
86 moveDown 1 ([2,3],Res); refFormula 1 ([2,4],Res);
87 moveDown 1 ([2,4],Res); refFormula 1 ([2,5],Res);
88 moveDown 1 ([2,5],Res); refFormula 1 ([2,6],Res);
89 val ((pt,_),_) = get_calc 1;
90 if "-2 * 1 + (1 + x) = 0" = term2str (fst (get_obj g_result pt [2,6])) then()
91 else error "inform.sml: diff.behav.appendFormula: on Res + equ 2";
93 fetchProposedTactic 1; (*takes Iterator 1 _1_*)
94 (* <ERROR> error in kernel </ERROR> ALREADY IN 2009-2*)
95 (*========== inhibit exn WN1130701 broken at Isabelle2002 --> 2009-2 =============
96 val (_,(tac,_,_)::_) = get_calc 1;
97 if tac = Rewrite_Set "Test_simplify" then ()
98 else error "inform.sml: diff.behav.appendFormula: on Res + equ 3";
99 ============ inhibit exn WN1130701 broken at Isabelle2002 --> 2009-2 ============*)
101 autoCalculate 1 CompleteCalc;
102 val ((pt,_),_) = get_calc 1;
103 if "[x = 1]" = term2str (fst (get_obj g_result pt [])) then ()
104 else error "inform.sml: diff.behav.appendFormula: on Res + equ 4";
105 (* autoCalculate 1 CompleteCalc;
106 val ((pt,p),_) = get_calc 1;
107 (writeln o istates2str) (get_obj g_loc pt [ ]);
108 (writeln o istates2str) (get_obj g_loc pt [1]);
109 (writeln o istates2str) (get_obj g_loc pt [2]);
110 (writeln o istates2str) (get_obj g_loc pt [3]);
111 (writeln o istates2str) (get_obj g_loc pt [3,1]);
112 (writeln o istates2str) (get_obj g_loc pt [3,2]);
113 (writeln o istates2str) (get_obj g_loc pt [4]);
116 "----------------------------------------------------------";
118 val fod = make_deriv (@{theory "Isac_Knowledge"}) Atools_erls
119 ((#rules o rep_rls) Test_simplify)
120 (sqrt_right false (@{theory "Pure"})) NONE
121 (str2term "x + 1 + -1 * 2 = 0");
122 (writeln o trtas2str) fod;
124 val ifod = make_deriv (@{theory "Isac_Knowledge"}) Atools_erls
125 ((#rules o rep_rls) Test_simplify)
126 (sqrt_right false (@{theory "Pure"})) NONE
127 (str2term "-2 * 1 + (1 + x) = 0");
128 (writeln o trtas2str) ifod;
129 fun equal (_,_,(t1, _)) (_,_,(t2, _)) = t1 = t2;
130 val (fod', rifod') = dropwhile' equal (rev fod) (rev ifod);
131 val der = fod' @ (map rev_deriv' rifod');
132 (writeln o trtas2str) der;
133 "----------------------------------------------------------";
136 "--------- appendFormula: on Frm + equ_nrls ----------------------";
137 "--------- appendFormula: on Frm + equ_nrls ----------------------";
138 "--------- appendFormula: on Frm + equ_nrls ----------------------";
140 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
141 ("Test", ["sqroot-test","univariate","equation","test"],
142 ["Test","squ-equ-test-subpbl1"]))];
143 Iterator 1; moveActiveRoot 1;
144 autoCalculate 1 CompleteCalcHead;
145 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1) (*x + 1 = 2*);
146 appendFormula 1 "2+ -1 + x = 2" (*|> Future.join*); refFormula 1 (get_pos 1 1);
148 moveDown 1 ([],Pbl); refFormula 1 ([1],Frm) (*x + 1 = 2*);
150 moveDown 1 ([1 ],Frm); refFormula 1 ([1,1],Frm);
151 moveDown 1 ([1,1],Frm); refFormula 1 ([1,1],Res);
152 moveDown 1 ([1,1],Res); refFormula 1 ([1,2],Res);
153 moveDown 1 ([1,2],Res); refFormula 1 ([1,3],Res);
154 moveDown 1 ([1,3],Res); refFormula 1 ([1,4],Res);
155 moveDown 1 ([1,4],Res); refFormula 1 ([1,5],Res);
156 moveDown 1 ([1,5],Res); refFormula 1 ([1,6],Res);
157 val ((pt,_),_) = get_calc 1;
158 if "2 + -1 + x = 2" = term2str (fst (get_obj g_result pt [1,6])) then()
159 else error "inform.sml: diff.behav.appendFormula: on Frm + equ 1";
161 fetchProposedTactic 1; (*takes Iterator 1 _1_*)
162 val (_,(tac,_,_)::_) = get_calc 1;
163 case tac of Rewrite_Set "norm_equation" => ()
164 | _ => error "inform.sml: diff.behav.appendFormula: on Frm + equ 2";
165 autoCalculate 1 CompleteCalc;
166 val ((pt,_),_) = get_calc 1;
167 if "[x = 1]" = term2str (fst (get_obj g_result pt [])) then ()
168 else error "inform.sml: diff.behav.appendFormula: on Frm + equ 3";
171 "--------- appendFormula: on Res + NO deriv ----------------------";
172 "--------- appendFormula: on Res + NO deriv ----------------------";
173 "--------- appendFormula: on Res + NO deriv ----------------------";
175 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
176 ("Test", ["sqroot-test","univariate","equation","test"],
177 ["Test","squ-equ-test-subpbl1"]))];
178 Iterator 1; moveActiveRoot 1;
179 autoCalculate 1 CompleteCalcHead;
180 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
181 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
183 appendFormula 1 "x = 2" (*|> Future.join*);
184 val ((pt,p),_) = get_calc 1;
185 val str = pr_ctree pr_short pt;
187 if str = ". ----- pblobj -----\n1. x + 1 = 2\n" andalso p = ([1], Res)
189 else error "inform.sml: diff.behav.appendFormula: Res + NOder 1";
191 fetchProposedTactic 1;
192 val (_,(tac,_,_)::_) = get_calc 1;
193 case tac of Rewrite_Set "Test_simplify" => ()
194 | _ => error "inform.sml: diff.behav.appendFormula: Res + NOder 2";
195 autoCalculate 1 CompleteCalc;
196 val ((pt,_),_) = get_calc 1;
197 if "[x = 1]" = term2str (fst (get_obj g_result pt [])) then ()
198 else error "inform.sml: diff.behav.appendFormula: on Frm + equ 3";
201 "--------- appendFormula: on Res + late deriv --------------------";
202 "--------- appendFormula: on Res + late deriv --------------------";
203 "--------- appendFormula: on Res + late deriv --------------------";
205 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
206 ("Test", ["sqroot-test","univariate","equation","test"],
207 ["Test","squ-equ-test-subpbl1"]))];
208 Iterator 1; moveActiveRoot 1;
209 autoCalculate 1 CompleteCalcHead;
210 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
211 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
213 appendFormula 1 "x = 1" (*|> Future.join*);
214 val ((pt,p),_) = get_calc 1;
215 val str = pr_ctree pr_short pt;
217 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)
218 then () (*finds 1 step too early: ([3,2], Res) "x = 1" also by script !!!*)
219 else error "inform.sml: diff.behav.appendFormula: Res + late d 1";
221 fetchProposedTactic 1;
222 val (_,(tac,_,_)::_) = get_calc 1;
223 case tac of Check_Postcond ["LINEAR", "univariate", "equation", "test"] => ()
224 | _ => error "inform.sml: diff.behav.appendFormula: Res + late d 2";
225 autoCalculate 1 CompleteCalc;
226 val ((pt,_),_) = get_calc 1;
227 if "[x = 1]" = term2str (fst (get_obj g_result pt [])) then ()
228 else error "inform.sml: diff.behav.appendFormula: Res + late d 3";
231 "--------- appendFormula: on Res + late deriv [x = 3 + -2]---///--";
232 "--------- appendFormula: on Res + late deriv [x = 3 + -2]---///--";
233 "--------- appendFormula: on Res + late deriv [x = 3 + -2]---///--";
235 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
236 ("Test", ["sqroot-test","univariate","equation","test"],
237 ["Test","squ-equ-test-subpbl1"]))];
238 Iterator 1; moveActiveRoot 1;
239 autoCalculate 1 CompleteCalcHead;
240 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
241 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
242 appendFormula 1 "[x = 3 + -2*1]" (*|> Future.join*);
243 val ((pt,p),_) = get_calc 1;
244 val str = pr_ctree pr_short pt;
246 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 ()
247 else error "inform.sml: diff.behav.appendFormula: Res + latEE 1";
248 autoCalculate 1 CompleteCalc;
249 val ((pt,p),_) = get_calc 1;
250 if "[x = 3 + -2 * 1]" = term2str (fst (get_obj g_result pt [])) then ()
251 (* ~~~~~~~~~~ simplify as last step in any script ?!*)
252 else error "inform.sml: diff.behav.appendFormula: Res + latEE 2";
255 "--------- replaceFormula: on Res + = ----------------------------";
256 "--------- replaceFormula: on Res + = ----------------------------";
257 "--------- replaceFormula: on Res + = ----------------------------";
259 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
260 ("Test", ["sqroot-test","univariate","equation","test"],
261 ["Test","squ-equ-test-subpbl1"]))];
262 Iterator 1; moveActiveRoot 1;
263 autoCalculate 1 CompleteCalcHead;
264 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
265 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
266 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*-1 + x*);
268 replaceFormula 1 "-2 * 1 + (1 + x) = 0"; refFormula 1 (get_pos 1 1);
269 val ((pt,_),_) = get_calc 1;
270 val str = pr_ctree pr_short pt;
272 (* before AK110725 this was
273 ". ----- pblobj -----\n
275 2. x + 1 + -1 * 2 = 0\n
276 2.1. x + 1 + -1 * 2 = 0\n
277 2.2. 1 + x + -1 * 2 = 0\n
278 2.3. 1 + (x + -1 * 2) = 0\n
279 2.4. 1 + (x + -2) = 0\n
280 2.5. 1 + (x + -2 * 1) = 0\n
281 2.6. 1 + x + -2 * 1 = 0\n";
284 ". ----- pblobj -----\n"^
286 "2. x + 1 + -1 * 2 = 0\n"^
287 "2.1. x + 1 + -1 * 2 = 0\n"^
288 "2.2. 1 + x + -1 * 2 = 0\n"^
289 "2.3. 1 + (x + -1 * 2) = 0\n"^
290 "2.4. 1 + (x + -2) = 0\n"^
291 "2.5. 1 + (x + -2 * 1) = 0\n"^
292 "2.6. 1 + x + -2 * 1 = 0\n" then()
293 else error "inform.sml: diff.behav.replaceFormula: on Res += 1";
295 autoCalculate 1 CompleteCalc;
296 val ((pt,pos as (p,_)),_) = get_calc 1;
297 if pos = ([],Res) andalso "[x = 1]" = (term2str o fst) (get_obj g_result pt p) then()
298 else error "inform.sml: diff.behav.replaceFormula: on Res + = 2";
301 "--------- replaceFormula: on Res + = 1st Nd ---------------------";
302 "--------- replaceFormula: on Res + = 1st Nd ---------------------";
303 "--------- replaceFormula: on Res + = 1st Nd ---------------------";
305 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
306 ("Test", ["sqroot-test","univariate","equation","test"],
307 ["Test","squ-equ-test-subpbl1"]))];
308 Iterator 1; moveActiveRoot 1;
309 autoCalculate 1 CompleteCalcHead;
310 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
311 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
313 replaceFormula 1 "x + 1 = 4 + -2"; refFormula 1 (get_pos 1 1);
314 val ((pt,_),_) = get_calc 1;
315 val str = pr_ctree pr_short pt;
317 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 ()
318 else error "inform.sml: diff.behav.replaceFormula: on Res 1 + = 1";
319 autoCalculate 1 CompleteCalc;
320 val ((pt,pos as (p,_)),_) = get_calc 1;
321 if pos = ([],Res) andalso "[x = 1]" = (term2str o fst)(get_obj g_result pt p) then()
322 else error "inform.sml: diff.behav.replaceFormula: on Res + = 2";
325 "--------- replaceFormula: on Frm + = 1st Nd ---------------------";
326 "--------- replaceFormula: on Frm + = 1st Nd ---------------------";
327 "--------- replaceFormula: on Frm + = 1st Nd ---------------------";
329 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
330 ("Test", ["sqroot-test","univariate","equation","test"],
331 ["Test","squ-equ-test-subpbl1"]))];
332 Iterator 1; moveActiveRoot 1;
333 autoCalculate 1 CompleteCalcHead;
334 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
336 replaceFormula 1 "x + 1 = 4 + -2"; refFormula 1 (get_pos 1 1);
337 val ((pt,_),_) = get_calc 1;
338 val str = pr_ctree pr_short pt;
340 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 ()
341 else error "inform.sml: diff.behav.replaceFormula: on Frm 1 + = 1";
342 autoCalculate 1 CompleteCalc;
343 val ((pt,pos as (p,_)),_) = get_calc 1;
344 if pos = ([],Res) andalso "[x = 1]" = (term2str o fst)(get_obj g_result pt p) then()
345 else error "inform.sml: diff.behav.replaceFormula: on Frm 1 + = 2";
348 "--------- replaceFormula: cut calculation -----------------------";
349 "--------- replaceFormula: cut calculation -----------------------";
350 "--------- replaceFormula: cut calculation -----------------------";
352 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
353 ("Test", ["sqroot-test","univariate","equation","test"],
354 ["Test","squ-equ-test-subpbl1"]))];
355 Iterator 1; moveActiveRoot 1;
356 autoCalculate 1 CompleteCalc;
357 moveActiveRoot 1; moveActiveDown 1;
358 if get_pos 1 1 = ([1], Frm) then ()
359 else error "inform.sml: diff.behav. cut calculation 1";
361 replaceFormula 1 "x + 1 = 4 + -2"; refFormula 1 (get_pos 1 1);
362 val ((pt,p),_) = get_calc 1;
363 val str = pr_ctree pr_short pt;
365 if p = ([1], Res) then ()
366 else error "inform.sml: diff.behav. cut calculation 2";
369 (* 040307 copied from informtest.sml; ... old version
370 "---------------- maximum-example, UC: Modeling / modifyCalcHead -";
371 "---------------- maximum-example, UC: Modeling / modifyCalcHead -";
372 "---------------- maximum-example, UC: Modeling / modifyCalcHead -";
375 val elems = ["fixedValues [r=Arbfix]","maximum A","valuesFor [a,b]",
376 "relations [A=a*b, (a/2)^^^2 + (b/2)^^^2 = r^^^2]",
377 "relations [A=a*b, (a/2)^^^2 + (b/2)^^^2 = r^^^2]",
378 "relations [A=a*b, a/2=r*sin alpha, b/2=r*cos (alpha::real)]",
379 (*^^^ these are the elements for the root-problem (in variants)*)
380 (*vvv these are elements required for subproblems*)
381 "boundVariable a","boundVariable b","boundVariable alpha",
382 "interval {x::real. 0 <= x & x <= 2*r}",
383 "interval {x::real. 0 <= x & x <= 2*r}",
384 "interval {x::real. 0 <= x & x <= pi}",
385 "errorBound (eps=(0::real))"]
386 (*specifying is not interesting for this example*)
387 val spec = ("DiffApp", ["maximum_of","function"],
388 ["DiffApp","max_by_calculus"]);
389 (*the empty model with descriptions for user-guidance by Model_Problem*)
390 val empty_model = [Given ["fixedValues []"],
391 Find ["maximum", "valuesFor"],
392 Relate ["relations []"]];
395 (*!!!!!!!!!!!!!!!!! DON'T USE me FOR FINDING nxt !!!!!!!!!!!!!!!!!!*)
396 val (p,_,f,nxt,_,pt) = CalcTreeTEST [(elems, spec)];
397 (*val nxt = ("Model_Problem", ...*)
398 val pbl = get_obj g_pbl pt (fst p); (writeln o (itms2str_ ctxt)) pbl;
400 val (p,_,f,nxt,_,pt) = me nxt p c pt;
401 (*nxt = Add_Given "fixedValues [r = Arbfix]"*)
402 val pbl = get_obj g_pbl pt (fst p); (writeln o (itms2str_ ctxt)) pbl;
404 (0 ,[] ,false ,#Given ,Inc fixedValues [] ,(??.empty, [])),
405 (0 ,[] ,false ,#Find ,Inc maximum ,(??.empty, [])),
406 (0 ,[] ,false ,#Find ,Inc valuesFor ,(??.empty, [])),
407 (0 ,[] ,false ,#Relate ,Inc relations [] ,(??.empty, []))]*)
409 (*the empty CalcHead is checked w.r.t the model and re-established as such*)
410 val (b,pt,ocalhd) = input_icalhd pt (p,"", empty_model, Pbl, e_spec);
411 val pbl = get_obj g_pbl pt (fst p); (writeln o (itms2str_ ctxt)) pbl;
412 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";
414 (*there is one input to the model (could be more)*)
416 input_icalhd pt (p,"", [Given ["fixedValues [r=Arbfix]"],
417 Find ["maximum", "valuesFor"],
418 Relate ["relations"]], Pbl, e_spec);
419 val pbl = get_obj g_pbl pt (fst p); (writeln o (itms2str_ ctxt)) pbl;
420 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 ()
421 else error "informtest.sml: diff.behav. max 2";
423 (*this input is complete in variant 3, but the ME doesn't recognize FIXXXXME
424 val (b,pt''''',ocalhd) =
425 input_icalhd pt (p,"", [Given ["fixedValues [r=Arbfix]"],
426 Find ["maximum A", "valuesFor [a,b]"],
427 Relate ["relations [A=a*b, a/2=r*sin alpha, \
428 \b/2=r*cos alpha]"]], Pbl, e_spec);
429 val pbl = get_obj g_pbl pt''''' (fst p); (writeln o (itms2str_ ctxt)) pbl;
430 if ocalhd2str ocalhd = ------------^^^^^^^^^^ missing !!!*)
432 (*this input is complete in variant 1 (variant 3 does not work yet)*)
433 val (b,pt''''',ocalhd) =
434 input_icalhd pt (p,"", [Given ["fixedValues [r=Arbfix]"],
435 Find ["maximum A", "valuesFor [a,b]"],
436 Relate ["relations [A=a*b, \
437 \(a/2)^^^2 + (b/2)^^^2 = r^^^2]"]],
439 val pbl = get_obj g_pbl pt''''' (fst p); (writeln o (itms2str_ ctxt)) pbl;
441 modifycalcheadOK2xml 111 (bool2str b) ocalhd;
445 "--------- syntax error ------------------------------------------";
446 "--------- syntax error ------------------------------------------";
447 "--------- syntax error ------------------------------------------";
449 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
450 ("Test", ["sqroot-test","univariate","equation","test"],
451 ["Test","squ-equ-test-subpbl1"]))];
452 Iterator 1; moveActiveRoot 1;
453 autoCalculate 1 CompleteCalcHead;
454 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
455 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
457 appendFormula 1 " x - "; (*<ERROR> syntax error in ' x - ' </ERROR>*)
458 val ((pt,_),_) = get_calc 1;
459 val str = pr_ctree pr_short pt;
461 if str = ". ----- pblobj -----\n1. x + 1 = 2\n" then ()
462 else error "inform.sml: diff.behav.appendFormula: syntax error";
465 "--------- CAS-command on ([],Pbl) -------------------------------";
466 "--------- CAS-command on ([],Pbl) -------------------------------";
467 "--------- CAS-command on ([],Pbl) -------------------------------";
468 val (p,_,f,nxt,_,pt) =
469 CalcTreeTEST [([], ("e_domID", ["e_pblID"], ["e_metID"]))];
470 val ifo = "solve(x+1=2,x)";
471 val (_,(_,c,(pt,p))) = inform ([],[],(pt,p)) "solve(x+1=2,x)";
473 val nxt = (Apply_Method ["Test","squ-equ-test-subpbl1"]);
474 val (p,_,f,nxt,_,pt) = me nxt p [] pt;
475 if p = ([1], Frm) andalso f2str f = "x + 1 = 2" then ()
476 else error "inform.sml: diff.behav. CAScmd ([],Pbl)";
479 "--------- CAS-command on ([],Pbl) FE-interface ------------------";
480 "--------- CAS-command on ([],Pbl) FE-interface ------------------";
481 "--------- CAS-command on ([],Pbl) FE-interface ------------------";
483 CalcTree [([], ("e_domID", ["e_pblID"], ["e_metID"]))];
486 replaceFormula 1 "solve(x+1=2,x)";
487 autoCalculate 1 CompleteCalc;
488 val ((pt,p),_) = get_calc 1;
490 if p = ([], Res) then ()
491 else error "inform.sml: diff.behav. CAScmd ([],Pbl) FE-interface";
494 "--------- inform [rational,simplification] ----------------------";
495 "--------- inform [rational,simplification] ----------------------";
496 "--------- inform [rational,simplification] ----------------------";
498 CalcTree [(["Term (a * x / (b * x) + c * x / (d * x) + e / f)", "normalform N"],
499 ("Rational", ["rational", "simplification"], ["simplification", "of_rationals"]))];
500 Iterator 1; moveActiveRoot 1;
501 autoCalculate 1 CompleteCalcHead;
503 "--- (-1) give a preview on the calculation without any input";
505 autoCalculate 1 CompleteCalc;
506 val ((pt, p), _) = get_calc 1;
509 (([], Frm), Simplify (a * x / (b * x) + c * x / (d * x) + e / f)),
510 (([1], Frm), a * x / (b * x) + c * x / (d * x) + e / f),
511 (([1], Res), a / b + c / d + e / f), <--- (1) input arbitrary
512 (([2], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
513 (([3], Res), (a * (d * f) + b * (c * f) + b * (d * e)) / (b * (d * f))),
514 (([4], Res), (a * d * f + b * c * f + b * d * e) / (b * d * f)), <--- (2) input next
515 (([], Res), (a * d * f + b * c * f + b * d * e) / (b * d * f))] <--- (3) is also final result
518 "--- (0) user input as the *first* step does not work, thus impdo at least 1 step";
519 autoCalculate 1 (Steps 1);
520 autoCalculate 1 (Steps 1);
521 val ((pt, p), _) = get_calc 1;
524 (([], Frm), Simplify (a * x / (b * x) + c * x / (d * x) + e / f)),
525 (([1], Frm), a * x / (b * x) + c * x / (d * x) + e / f),
526 (([1], Res), a / b + c / d + e / f)]
528 "--- (1) input an arbitrary next formula";
529 appendFormula 1 "((a * d) + (c * b)) / (b * d) + e / f" (*|> Future.join*);
530 val ((pt, p), _) = get_calc 1;
533 (([], Frm), Simplify (a * x / (b * x) + c * x / (d * x) + e / f)),
534 (([1], Frm), a * x / (b * x) + c * x / (d * x) + e / f),
535 (([1], Res), a / b + c / d + e / f),
536 (([2,1], Frm), a / b + c / d + e / f),
537 (([2,1], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
538 (([2,2], Res), (a * d + c * b) / (b * d) + e / f),
539 (([2], Res), (a * d + c * b) / (b * d) + e / f)]
541 val ((pt,p),_) = get_calc 1;
542 if p = ([2], Res) andalso (length o children o (get_nd pt)) (fst p) = 2 then ()
543 else error ("inform.sml: [rational,simplification] 1");
545 "--- (2) input the next formula that would be presented by mat-engine";
546 (* generate a preview:
547 autoCalculate 1 (Steps 1);
548 val ((pt, p), _) = get_calc 1;
551 (([], Frm), Simplify (a * x / (b * x) + c * x / (d * x) + e / f)),
552 (([1], Frm), a * x / (b * x) + c * x / (d * x) + e / f),
553 (([1], Res), a / b + c / d + e / f),
554 (([2,1], Frm), a / b + c / d + e / f),
555 (([2,1], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
556 (([2,2], Res), (a * d + c * b) / (b * d) + e / f),
557 (([2], Res), (a * d + c * b) / (b * d) + e / f),
558 (([3], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f))] <--- input this
560 appendFormula 1 "(b * d * e + b * c * f + a * d * f) / (b * d * f)" (*|> Future.join*);
561 val ((pt, p), _) = get_calc 1;
564 (([], Frm), Simplify (a * x / (b * x) + c * x / (d * x) + e / f)),
565 (([1], Frm), a * x / (b * x) + c * x / (d * x) + e / f),
566 (([1], Res), a / b + c / d + e / f),
567 (([2,1], Frm), a / b + c / d + e / f),
568 (([2,1], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
569 (([2,2], Res), (a * d + c * b) / (b * d) + e / f),
570 (([2], Res), (a * d + c * b) / (b * d) + e / f),
571 (([3], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f))]
573 if p = ([3], Res) andalso (length o children o (get_nd pt)) (fst p) = 0 then ()
574 else error ("inform.sml: [rational,simplification] 2");
576 "--- (3) input the exact final result";
577 appendFormula 1 "(b * d * e + b * c * f + a * d * f) / (b * d * f)" (*|> Future.join*);
578 val ((pt, p), _) = get_calc 1;
581 (([], Frm), Simplify (a * x / (b * x) + c * x / (d * x) + e / f)),
582 (([1], Frm), a * x / (b * x) + c * x / (d * x) + e / f),
583 (([1], Res), a / b + c / d + e / f),
584 (([2,1], Frm), a / b + c / d + e / f),
585 (([2,1], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
586 (([2,2], Res), (a * d + c * b) / (b * d) + e / f),
587 (([2], Res), (a * d + c * b) / (b * d) + e / f),
588 (([3], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
589 (([4,1], Frm), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
590 (([4,1], Res), (a * (d * f) + b * (c * f) + b * (d * e)) / (b * (d * f))),
591 (([4,2], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
592 (([4], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f))]
594 if p = ([4], Res) andalso (length o children o (get_nd pt)) (fst p) = 2 then ()
595 else error ("inform.sml: [rational,simplification] 3");
597 "--- (4) finish the calculation + check the postcondition (in the future)";
598 autoCalculate 1 CompleteCalc;
599 val ((pt, p), _) = get_calc 1;
600 val (t, asm) = get_obj g_result pt [];
601 if term2str t = "(a * d * f + b * c * f + b * d * e) / (b * d * f)" andalso
602 terms2str asm = "[\"b * d * f \<noteq> 0\",\"d \<noteq> 0\",\"b \<noteq> 0\",\"a * x / (b * x) + c * x / (d * x) + e / f is_ratpolyexp\"]"
603 then () else error "inform [rational,simplification] changed at end";
606 (([], Frm), Simplify (a * x / (b * x) + c * x / (d * x) + e / f)),
607 (([1], Frm), a * x / (b * x) + c * x / (d * x) + e / f),
608 (([1], Res), a / b + c / d + e / f),
609 (([2,1], Frm), a / b + c / d + e / f),
610 (([2,1], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
611 (([2,2], Res), (a * d + c * b) / (b * d) + e / f),
612 (([2], Res), (a * d + c * b) / (b * d) + e / f),
613 (([3], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
614 (([4,1], Frm), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
615 (([4,1], Res), (a * (d * f) + b * (c * f) + b * (d * e)) / (b * (d * f))),
616 (([4,2], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
617 (([4], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
618 (([5], Res), (a * (d * f) + b * (c * f) + b * (d * e)) / (b * (d * f))),
619 (([6], Res), (a * d * f + b * c * f + b * d * e) / (b * d * f)),
620 (([], Res), (a * d * f + b * c * f + b * d * e) / (b * d * f))]
624 "--------- Take as 1st tac, start with <NEW> (CAS input) ---------";
625 "--------- Take as 1st tac, start with <NEW> (CAS input) ---------";
626 "--------- Take as 1st tac, start with <NEW> (CAS input) ---------";
627 val t = str2term "Diff (x^^^2 + x + 1, x)";
628 case t of Const ("Diff.Diff", _) $ _ => ()
630 error "diff.sml behav.changed for CAS Diff (..., x)";
632 "-----------------------------------------------------------------";
633 (*1>*)reset_states ();
634 (*2>*)CalcTree [([], ("e_domID", ["e_pblID"], ["e_metID"]))];
635 (*3>*)Iterator 1;moveActiveRoot 1;
636 "----- here the Headline has been finished";
637 (*4>*)moveActiveFormula 1 ([],Pbl);
638 (*5>*)replaceFormula 1 "Diff (x^2 + x + 1, x)";
639 val ((pt,_),_) = get_calc 1;
640 val PblObj {probl, meth, spec, fmz, env, loc, ...} = get_obj I pt [];
642 val (SOME istate, NONE) = loc;
643 (*default_print_depth 5;*)
644 writeln"-----------------------------------------------------------";
646 writeln (itms2str_ ctxt probl);
647 writeln (itms2str_ ctxt meth);
648 writeln (istate2str (fst istate));
650 refFormula 1 ([],Pbl) (*--> correct CalcHead*);
651 (*081016 NOT necessary (but leave it in Java):*)
652 (*6>*)(*completeCalcHead*)autoCalculate 1 CompleteCalcHead;
653 "----- here the CalcHead has been completed --- ONCE MORE ?????";
655 (***difference II***)
656 val ((pt,p),_) = get_calc 1;
657 (*val p = ([], Pbl)*)
658 val PblObj {probl, meth, spec, fmz, env, loc, ...} = get_obj I pt [];
660 val (SOME istate, NONE) = loc;
661 (*default_print_depth 5;*) writeln (istate2str (fst istate)); (*default_print_depth 3;*)
664 ??.empty, Sundef, false)*)
665 (*default_print_depth 5;*) spec; (*default_print_depth 3;*)
667 ["derivative_of", "function"],
668 ["diff", "differentiate_on_R"]) : spec*)
669 writeln (itms2str_ ctxt probl);
671 (1 ,[1] ,true ,#Given ,Cor functionTerm (x ^^^ 2 + x + 1) ,(f_, [x ^^^ 2 + x + 1])),
672 (2 ,[1] ,true ,#Given ,Cor differentiateFor x ,(v_, [x])),
673 (3 ,[1] ,true ,#Find ,Cor derivative f_'_f ,(f_'_f, [f_'_f]))]*)
674 writeln (itms2str_ ctxt meth);
676 (1 ,[1] ,true ,#Given ,Cor functionTerm (x ^^^ 2 + x + 1) ,(f_, [x ^^^ 2 + x + 1])),
677 (2 ,[1] ,true ,#Given ,Cor differentiateFor x ,(v_, [x])),
678 (3 ,[1] ,true ,#Find ,Cor derivative f_'_f ,(f_'_f, [f_'_f]))]*)
679 writeln"-----------------------------------------------------------";
680 (*7>*)fetchProposedTactic 1 (*--> Apply_Method*);
681 (*WN081028 fixed <ERROR> helpless </ERROR> by inform returning ...(.,Met)*)
682 autoCalculate 1 CompleteCalc;
683 val ((pt,p),_) = get_calc 1;
684 val Form res = (#1 o pt_extract) (pt, ([],Res));
686 if p = ([], Res) andalso term2str res = "1 + 2 * x" then ()
687 else error "diff.sml behav.changed for Diff (x^2 + x + 1, x)";
690 "--------- Take as 1st tac, start from exp -----------------------";
691 "--------- Take as 1st tac, start from exp -----------------------";
692 "--------- Take as 1st tac, start from exp -----------------------";
693 (*the following input is copied from BridgeLog Java <==> SML,
694 omitting unnecessary inputs*)
695 (*1>*)reset_states ();
696 (*2>*)CalcTree [(["functionTerm (x^2 + x + 1)", "differentiateFor x", "derivative f_'_f"],("Isac_Knowledge",["derivative_of","function"],["diff","differentiate_on_R"]))];
697 (*3>*)Iterator 1; moveActiveRoot 1;
699 (*6>*)(*completeCalcHead*)autoCalculate 1 CompleteCalcHead;
700 (***difference II***)
701 val ((pt,_),_) = get_calc 1;
702 val PblObj {probl, meth, spec, fmz, env, loc, ...} = get_obj I pt [];
704 val (SOME istate, NONE) = loc;
705 (*default_print_depth 5;*) writeln (istate2str (fst istate)); (*default_print_depth 3;*)
708 ??.empty, Sundef, false)*)
709 (*default_print_depth 5;*) spec; (*default_print_depth 3;*)
711 ["derivative_of", "function"],
712 ["diff", "differentiate_on_R"]) : spec*)
713 writeln (itms2str_ ctxt probl);
715 (1 ,[1] ,true ,#Given ,Cor functionTerm (x ^^^ 2 + x + 1) ,(f_, [x ^^^ 2 + x + 1])),
716 (2 ,[1] ,true ,#Given ,Cor differentiateFor x ,(v_, [x])),
717 (3 ,[1] ,true ,#Find ,Cor derivative f_'_f ,(f_'_f, [f_'_f]))]*)
718 writeln (itms2str_ ctxt meth);
720 (1 ,[1] ,true ,#Given ,Cor functionTerm (x ^^^ 2 + x + 1) ,(f_, [x ^^^ 2 + x + 1])),
721 (2 ,[1] ,true ,#Given ,Cor differentiateFor x ,(v_, [x])),
722 (3 ,[1] ,true ,#Find ,Cor derivative f_'_f ,(f_'_f, [f_'_f]))]*)
723 writeln"-----------------------------------------------------------";
724 (*7>*)fetchProposedTactic 1 (*--> Apply_Method*);
725 autoCalculate 1 (Steps 1);
726 val ((pt,p),_) = get_calc 1;
727 val Form res = (#1 o pt_extract) (pt, p);
728 if term2str res = "d_d x (x ^^^ 2 + x + 1)" then ()
729 else error "diff.sml Diff (x^2 + x + 1, x) from exp";
732 "--------- init_form, start with <NEW> (CAS input) ---------------";
733 "--------- init_form, start with <NEW> (CAS input) ---------------";
734 "--------- init_form, start with <NEW> (CAS input) ---------------";
736 CalcTree [([], ("e_domID", ["e_pblID"], ["e_metID"]))];
737 (*[[from sml: > @@@@@begin@@@@@
739 [[from sml: <CALCTREE>
740 [[from sml: <CALCID> 1 </CALCID>
741 [[from sml: </CALCTREE>
742 [[from sml: @@@@@end@@@@@*)
744 (*[[from sml: > @@@@@begin@@@@@
746 [[from sml: <ADDUSER>
747 [[from sml: <CALCID> 1 </CALCID>
748 [[from sml: <USERID> 1 </USERID>
749 [[from sml: </ADDUSER>
750 [[from sml: @@@@@end@@@@@*)
752 (*[[from sml: > @@@@@begin@@@@@
754 [[from sml: <CALCITERATOR>
755 [[from sml: <CALCID> 1 </CALCID>
756 [[from sml: <POSITION>
757 [[from sml: <INTLIST>
758 [[from sml: </INTLIST>
759 [[from sml: <POS> Pbl </POS>
760 [[from sml: </POSITION>
761 [[from sml: </CALCITERATOR>
762 [[from sml: @@@@@end@@@@@*)
763 getFormulaeFromTo 1 ([],Pbl) ([],Pbl) 0 false;
764 (*[[from sml: > @@@@@begin@@@@@ STILL CORRECT
766 [[from sml: <GETELEMENTSFROMTO>
767 [[from sml: <CALCID> 1 </CALCID>
768 [[from sml: <FORMHEADS>
769 [[from sml: <CALCFORMULA>
770 [[from sml: <POSITION>
771 [[from sml: <INTLIST>
772 [[from sml: </INTLIST>
773 [[from sml: <POS> Pbl </POS>
774 [[from sml: </POSITION>
775 [[from sml: <FORMULA>
777 [[from sml: <ISA> ________________________________________________ </ISA>
778 [[from sml: </MATHML>
780 [[from sml: </FORMULA>
781 [[from sml: </CALCFORMULA>
782 [[from sml: </FORMHEADS>
783 [[from sml: </GETELEMENTSFROMTO>
784 [[from sml: @@@@@end@@@@@*)
785 refFormula 1 ([],Pbl);
786 (*[[from sml: > @@@@@begin@@@@@ STILL CORRECT
788 [[from sml: <REFFORMULA>
789 [[from sml: <CALCID> 1 </CALCID>
790 [[from sml: <CALCHEAD status = "incorrect">
791 [[from sml: <POSITION>
792 [[from sml: <INTLIST>
793 [[from sml: </INTLIST>
794 [[from sml: <POS> Pbl </POS>
795 [[from sml: </POSITION>
798 [[from sml: <ISA> Problem (e_domID, [e_pblID]) </ISA>
799 [[from sml: </MATHML>
802 [[from sml: <GIVEN> </GIVEN>
803 [[from sml: <WHERE> </WHERE>
804 [[from sml: <FIND> </FIND>
805 [[from sml: <RELATE> </RELATE>
807 [[from sml: <BELONGSTO> Pbl </BELONGSTO>
808 [[from sml: <SPECIFICATION>
809 [[from sml: <THEORYID> e_domID </THEORYID>
810 [[from sml: <PROBLEMID>
811 [[from sml: <STRINGLIST>
812 [[from sml: <STRING> e_pblID </STRING>
813 [[from sml: </STRINGLIST>
814 [[from sml: </PROBLEMID>
815 [[from sml: <METHODID>
816 [[from sml: <STRINGLIST>
817 [[from sml: <STRING> e_metID </STRING>
818 [[from sml: </STRINGLIST>
819 [[from sml: </METHODID>
820 [[from sml: </SPECIFICATION>
821 [[from sml: </CALCHEAD>
822 [[from sml: </REFFORMULA>
823 [[from sml: @@@@@end@@@@@*)
824 moveActiveFormula 1 ([],Pbl);
825 (*[[from sml: > @@@@@begin@@@@@
827 [[from sml: <CALCITERATOR>
828 [[from sml: <CALCID> 1 </CALCID>
829 [[from sml: <POSITION>
830 [[from sml: <INTLIST>
831 [[from sml: </INTLIST>
832 [[from sml: <POS> Pbl </POS>
833 [[from sml: </POSITION>
834 [[from sml: </CALCITERATOR>
835 [[from sml: @@@@@end@@@@@*)
836 replaceFormula 1 "Simplify (1+2)";
837 (*[[from sml: > @@@@@begin@@@@@
839 [[from sml: <REPLACEFORMULA>
840 [[from sml: <CALCID> 1 </CALCID>
841 [[from sml: <CALCCHANGED>
842 [[from sml: <UNCHANGED>
843 [[from sml: <INTLIST>
844 [[from sml: </INTLIST>
845 [[from sml: <POS> Pbl </POS>
846 [[from sml: </UNCHANGED>
847 [[from sml: <DELETED>
848 [[from sml: <INTLIST>
849 [[from sml: </INTLIST>
850 [[from sml: <POS> Pbl </POS>
851 [[from sml: </DELETED>
852 [[from sml: <GENERATED>
853 [[from sml: <INTLIST>
854 [[from sml: </INTLIST>
855 [[from sml: <POS> Met </POS> DIFFERENCE: Pbl
856 [[from sml: </GENERATED>
857 [[from sml: </CALCCHANGED>
858 [[from sml: </REPLACEFORMULA>
859 [[from sml: @@@@@end@@@@@*)
860 getFormulaeFromTo 1 ([],Pbl) ([],Pbl) 0 false(* DIFFERENCE: Pbl*);
874 <ISA> Simplify (1 + 2) </ISA> WORKS !!!!!
881 getFormulaeFromTo 1 ([],Pbl) ([],Met) 0 false;
882 (*[[from sml: > @@@@@begin@@@@@
884 [[from sml: <SYSERROR>
885 [[from sml: <CALCID> 1 </CALCID>
886 [[from sml: <ERROR> error in getFormulaeFromTo </ERROR>
887 [[from sml: </SYSERROR>
888 [[from sml: @@@@@end@@@@@*)
889 (*step into getFormulaeFromTo --- bug corrected...*)
891 "--------- build fun check_err_patt ------------------------------";
892 "--------- build fun check_err_patt ------------------------------";
893 "--------- build fun check_err_patt ------------------------------";
894 val subst = [(str2term "bdv", str2term "x")]: subst;
895 val rls = norm_Rational
896 val pat = parse_patt @{theory} "(?a + ?b)/(?b + ?c) = ?a / ?c";
897 val (res, inf) = (str2term "(2 + 3)/(3 + 4)", str2term "2 / 4");
898 val (res, inf) = (str2term "(2 + 3)/(3 + 4)", str2term "1 / 2");
900 val (res', _, _, rewritten) = (*rewritten: the lhs of the pattern matches in res*)
901 rew_sub thy 1 [] e_rew_ord e_rls false [] (HOLogic.Trueprop $ pat) res;
902 if rewritten then NONE else SOME "e_errpatID";
904 val norm_res = case rewrite_set_ (Isac()) false rls res' of
906 | SOME (norm_res, _) => norm_res
908 val norm_inf = case rewrite_set_ (Isac()) false rls inf of
910 | SOME (norm_inf, _) => norm_inf;
915 val pat = parse_patt @{theory} "(?a + ?b)/?a = ?b";
916 val (res, inf) = (str2term "(2 + 3)/2", str2term "3");
917 if check_err_patt (res, inf) subst ("errpatID", pat) rls = SOME "errpatID"
918 then () else error "error patt example1 changed";
920 val pat = parse_patt @{theory} "(?a + ?b)/(?a + ?c) = ?b / ?c";
921 val (res, inf) = (str2term "(2 + 3)/(2 + 4)", str2term "3 / 4");
922 if check_err_patt (res, inf) subst ("errpatID", pat) rls = SOME "errpatID"
923 then () else error "error patt example2 changed";
925 val pat = parse_patt @{theory} "(?a + ?b)/(?b + ?c) = ?a / ?c";
926 val (res, inf) = (str2term "(2 + 3)/(3 + 4)", str2term "2 / 4");
927 if check_err_patt (res, inf) subst ("errpatID", pat) rls = SOME "errpatID"
928 then () else error "error patt example3 changed";
930 val inf = str2term "1 / 2";
931 if check_err_patt (res, inf) subst ("errpatID", pat) rls = SOME "errpatID"
932 then () else error "error patt example3 changed";
934 "--------- build fun check_err_patt ?bdv -------------------------";
935 "--------- build fun check_err_patt ?bdv -------------------------";
936 "--------- build fun check_err_patt ?bdv -------------------------";
937 val subst = [(str2term "bdv", str2term "x")]: subst;
938 val t = str2term "d_d x (x ^^^ 2 + sin (x ^^^ 4))";
939 val SOME (t, _) = rewrite_set_inst_ thy false subst norm_diff t;
940 if term2str t = "2 * x + cos (x ^^^ 4) * 4 * x ^^^ 3" then ()
941 else error "build fun check_err_patt ?bdv changed 1";
944 val pat = parse_patt @{theory} "d_d ?bdv (sin ?u) = cos (d_d ?bdv ?u)";
945 val (res, inf) = (str2term "2 * x + d_d x (sin (x ^^^ 4))", str2term "2 * x + cos (4 * x ^^^ 3)");
947 val (res', _, _, rewritten) = (*rewritten: the lhs of the pattern matches in res*)
948 rew_sub thy 1 subst e_rew_ord e_rls false [] (HOLogic.Trueprop $ pat) res;
949 if term2str res' = "2 * x + cos (d_d x (x ^^^ 4))" andalso rewritten then ()
950 else error "build fun check_err_patt ?bdv changed 2";
952 val norm_res = case rewrite_set_inst_ (Isac()) false subst rls res' of
954 | SOME (norm_res, _) => norm_res;
955 if term2str norm_res = "2 * x + cos (4 * x ^^^ 3)" then ()
956 else error "build fun check_err_patt ?bdv changed 3";
958 val norm_inf = case rewrite_set_inst_ (Isac()) false subst rls inf of
960 | SOME (norm_inf, _) => norm_inf;
961 if term2str norm_inf = "2 * x + cos (4 * x ^^^ 3)" then ()
962 else error "build fun check_err_patt ?bdv changed 4";
965 if norm_res = norm_inf then ()
966 else error "build fun check_err_patt ?bdv changed 5";
968 if check_err_patt (res, inf) (subst: subst) ("errpatID": errpatID, pat) rls = SOME "errpatID"
969 then () else error "error patt example1 changed";
971 "--------- build fun check_error_patterns ------------------------";
972 "--------- build fun check_error_patterns ------------------------";
973 "--------- build fun check_error_patterns ------------------------";
975 (str2term "d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))",
976 str2term "d_d x (x ^^^ 2) + cos (4 * x ^^^ 3)");
977 val {errpats, nrls = rls, scr = Prog prog, ...} = get_met ["diff", "differentiate_on_R"]
979 val env = [(str2term "v_v", str2term "x")];
981 [e_errpat, (*generalised for testing*)
982 ("chain-rule-diff-both",
983 [parse_patt @{theory} "d_d ?bdv (sin ?u) = cos (d_d ?bdv ?u)",
984 parse_patt @{theory} "d_d ?bdv (cos ?u) = - sin (d_d ?bdv ?u)",
985 parse_patt @{theory} "d_d ?bdv (?u ^^^ ?n) = ?n * ?u ^^^ (?n - 1)",
986 parse_patt @{theory} "d_d ?bdv (LogExp.ln ?u) = 1 / ?u",
987 parse_patt @{theory} "d_d ?bdv (LogExp.ln ?u) = 1 / d_d ?bdv ?u"],
988 [@{thm diff_sin_chain}, @{thm diff_cos_chain}, @{thm diff_pow_chain},
989 @{thm diff_ln_chain}, @{thm diff_exp_chain}])]: errpat list;
990 case check_error_patterns (res, inf) (prog, env) (errpats, rls) of SOME _ => ()
991 | NONE => error "check_error_patterns broken";
994 "--------- embed fun check_error_patterns ------------------------";
995 "--------- embed fun check_error_patterns ------------------------";
996 "--------- embed fun check_error_patterns ------------------------";
999 [(["functionTerm (x ^ 2 + sin (x ^ 4))", "differentiateFor x", "derivative f_f'"],
1000 ("Isac_Knowledge", ["derivative_of","function"], ["diff","differentiate_on_R"]))];
1003 autoCalculate 1 CompleteCalcHead;
1004 autoCalculate 1 (Steps 1);
1005 autoCalculate 1 (Steps 1);(*([1], Res), d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))*)
1006 (*autoCalculate 1 (Steps 1);([2], Res), d_d x (x ^^^ 2) + cos (x ^^^ 4) * d_d x (x ^^^ 4)*)
1008 "~~~~~ fun appendFormula , args:"; val (cI, (ifo:cterm')) = (1, "d_d x (x ^ 2) + cos (4 * x ^ 3)");
1009 "~~~~~ fun appendFormula' , args:"; val (cI, (ifo: Rule.cterm')) = (cI, ifo);
1010 val cs = get_calc cI
1011 val pos = get_pos cI 1;
1012 (*+*)if pos = ([1], Res) then () else error "inform with (positive) check_error_patterns broken 1";
1013 val ("ok", cs') = (*case*) Step.do_next pos cs (*of*);
1014 (*case*) Solve.inform cs' (encode ifo) (*of*); (*ERROR WAS: "no derivation found"*)
1015 "~~~~~ fun inform , args:"; val (((*next_*)cs as (_, _, (pt, pos as (p, _))): Chead.calcstate'), istr)
1016 = (cs', (encode ifo));
1017 val ctxt = get_ctxt pt pos (*see TODO.thy*)
1018 val SOME f_in = (*case*) TermC.parse (Celem.assoc_thy "Isac_Knowledge") istr (*of*);
1019 val f_in = Thm.term_of f_in
1020 val pos_pred = lev_back' pos
1021 val f_pred = Ctree.get_curr_formula (pt, pos_pred);
1022 (*if*) f_pred = f_in; (*else*)
1023 val NONE = (*case*) Inform.cas_input f_in (*of*);
1024 (*NEW*)val (_, _, metID) = get_obj g_spec pt (par_pblobj pt p)
1025 (*NEW*)val {scr = prog, ...} = Specify.get_met metID
1026 (*NEW*)val istate = get_istate pt pos
1027 (*NEW*)val ctxt = get_ctxt pt pos
1028 val LI.Not_Derivable calcstate' =
1029 (*case*) LI.locate_input_term prog (pt, pos) istate ctxt f_in (*of*);
1030 val pp = Ctree.par_pblobj pt p
1031 val (errpats, nrls, prog) = case Specify.get_met (Ctree.get_obj Ctree.g_metID pt pp) of
1032 {errpats, nrls, scr = Rule.Prog prog, ...} => (errpats, nrls, prog)
1033 | _ => error "inform: uncovered case of get_met"
1035 (*+*)if errpats2str errpats = "[(\"chain-rule-diff-both\",\n[\"d_d ?bdv (sin ?u) = cos (d_d ?bdv ?u)\",\"d_d ?bdv (cos ?u) = - sin (d_d ?bdv ?u)\",\"d_d ?bdv (?u ^^^ ?n) = ?n * ?u ^^^ (?n - 1)\",\"d_d ?bdv (LogExp.ln ?u) = 1 / ?u\",\"d_d ?bdv (LogExp.ln ?u) = 1 / d_d ?bdv ?u\"],\n[\"d_d ?bdv (sin ?u) = cos ?u * d_d ?bdv ?u\",\"d_d ?bdv (cos ?u) = - sin ?u * d_d ?bdv ?u\",\"d_d ?bdv (?u ^^^ ?n) = ?n * ?u ^^^ (?n - 1) * d_d ?bdv ?u\",\"d_d ?bdv (LogExp.ln ?u) = d_d ?bdv ?u / ?u\",\"d_d ?bdv (E_ ^^^ ?u) = E_ ^^^ ?u * d_d ?x ?u\"]]"
1036 (*+*)then () else error "inform with (positive) check_error_patterns broken 3";
1038 val {env, ...} = Ctree.get_istate pt pos |> Istate.the_pstate
1040 (*+*)if term2str f_pred = "d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))" andalso
1041 (*+*) term2str f_in = "d_d x (x ^^^ 2) + cos (4 * x ^^^ 3)"
1042 (*+*)then () else error "inform with (positive) check_error_patterns broken 2";
1044 val SOME "chain-rule-diff-both" = (*case*) Inform.check_error_patterns (f_pred, f_in) (prog, env) (errpats, nrls) (*of*);
1047 case inform cs' (encode ifo) of
1048 ("error pattern #chain-rule-diff-both#", calcstate') => ()
1049 | _ => error "inform with (positive) check_error_patterns broken"
1052 "--------- embed fun find_fillpatterns ---------------------------";
1053 "--------- embed fun find_fillpatterns ---------------------------";
1054 "--------- embed fun find_fillpatterns ---------------------------";
1057 [(["functionTerm (x ^ 2 + sin (x ^ 4))", "differentiateFor x", "derivative f_f'"],
1058 ("Isac_Knowledge", ["derivative_of","function"], ["diff","differentiate_on_R"]))];
1061 autoCalculate 1 CompleteCalcHead;
1062 autoCalculate 1 (Steps 1);
1063 autoCalculate 1 (Steps 1);(*([1], Res), d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))*)
1064 appendFormula 1 "d_d x (x ^ 2) + cos (4 * x ^ 3)" (*|> Future.join*);
1065 (*<CALCMESSAGE> error pattern #chain-rule-diff-both# </CALCMESSAGE>*)
1067 <CALCMESSAGE> no derivation found </CALCMESSAGE>*)
1069 "~~~~~ fun findFillpatterns, args:"; val (cI, errpatID) = (1, "chain-rule-diff-both");
1070 val ((pt, _), _) = get_calc cI
1071 val pos = get_pos cI 1;
1072 "~~~~~ fun find_fillpatterns , args:"; val ((pt, pos as (p, _)), errpatID) = ((pt, pos), errpatID);
1073 val f_curr = Ctree.get_curr_formula (pt, pos);
1074 val pp = Ctree.par_pblobj pt p
1075 val (errpats, prog) = case Specify.get_met (Ctree.get_obj Ctree.g_metID pt pp) of
1076 {errpats, scr = Rule.Prog prog, ...} => (errpats, prog)
1077 | _ => error "find_fillpatterns: uncovered case of get_met"
1078 val {env, ...} = Ctree.get_istate pt pos |> Istate.the_pstate
1079 val subst = Rtools.get_bdv_subst prog env
1080 val errpatthms = errpats
1081 |> filter ((curry op = errpatID) o (#1: errpat -> errpatID))
1082 |> map (#3: errpat -> thm list)
1085 case map (get_fillpats subst f_curr errpatID) errpatthms |> flat of
1086 ("fill-d_d-arg", tm, thm, subs_opt) :: _ => if term2str tm =
1087 "d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4)) =\nd_d x (x ^^^ 2) + cos (x ^^^ 4) * d_d x ?_dummy_1"
1088 then () else error "find_fillpatterns changed 1a"
1089 | _ => error "find_fillpatterns changed 1b"
1091 "~~~~~ fun get_fillpats, args:"; val (subst, form, errpatID, thm) =
1092 (subst, f_curr, errpatID, hd (*simulate beginning of "map"*) errpatthms);
1093 val thmDeriv = Thm.get_name_hint thm
1094 val (part, thyID) = thy_containing_thm thmDeriv
1095 val theID = [part, thyID, "Theorems", thmID_of_derivation_name thmDeriv]
1096 val Hthm {fillpats, ...} = get_the theID
1097 val some = map (get_fillform subst (thm, form) errpatID) fillpats;
1099 case some |> filter is_some |> map the of
1100 ("fill-d_d-arg", tm, thm, subsopt) :: _ => if term2str tm =
1101 "d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4)) =\nd_d x (x ^^^ 2) + cos (x ^^^ 4) * d_d x ?_dummy_1"
1102 then () else error "find_fillpatterns changed 2a"
1103 | _ => error "find_fillpatterns changed 2b"
1105 "~~~~~ fun get_fillform, args:";
1106 val ((subs_opt, subst), (thm, form), errpatID, (fillpatID, pat, erpaID)) =
1107 (subst, (thm, form), errpatID, hd (*simulate beginning of "map"*) fillpats);
1108 val (form', _, _, rewritten) =
1109 rew_sub (Isac()) 1 subst e_rew_ord e_rls false [] (HOLogic.Trueprop $ pat) form;
1111 if term2str form' = "d_d x (x ^^^ 2) + cos (x ^^^ 4) * d_d x ?_dummy_1" then ()
1112 else error "find_fillpatterns changed 3";
1114 "~~~~~ to findFillpatterns return val:"; val (fillpats) =
1115 (map (get_fillpats (subs_opt, subst) f_curr errpatID) errpatthms |> flat) (*only from "hd errpatthms"*);
1117 "vvv--- dropped this code WN120730";
1118 val msg = "fill patterns " ^
1119 ((map ((apsnd term2str) o quad2pair) fillpats) |> map pair2str_ |> strs2str_);
1121 "fill patterns #fill-d_d-arg#d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))" ^
1122 " =\nd_d x (x ^^^ 2) + cos (x ^^^ 4) * d_d x ?_dummy_1" ^
1123 "#fill-both-args#d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))" ^
1124 " =\nd_d x (x ^^^ 2) + cos ?_dummy_2 * d_d x ?_dummy_3" ^
1125 "#fill-d_d#d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))" ^
1126 " =\nd_d x (x ^^^ 2) + cos (x ^^^ 4) * ?_dummy_1 x (x ^^^ 4)" ^
1127 "#fill-inner-deriv#d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))" ^
1128 " =\nd_d x (x ^^^ 2) + cos (x ^^^ 4) * ?_dummy_1" ^
1129 "#fill-all#d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4)) = d_d x (x ^^^ 2) + ?_dummy_1#";
1130 "^^^--- dropped this code WN120730";
1132 if (map #1 fillpats) =
1133 ["fill-d_d-arg", "fill-both-args", "fill-d_d", "fill-inner-deriv", "fill-all"]
1134 then () else error "find_fillpatterns changed 4b";
1137 "--------- build fun is_exactly_equal, inputFillFormula ----------";
1138 "--------- build fun is_exactly_equal, inputFillFormula ----------";
1139 "--------- build fun is_exactly_equal, inputFillFormula ----------";
1142 [(["functionTerm (x ^ 2 + sin (x ^ 4))", "differentiateFor x", "derivative f_f'"],
1143 ("Isac_Knowledge", ["derivative_of","function"], ["diff","differentiate_on_R"]))];
1146 autoCalculate 1 CompleteCalcHead;
1147 autoCalculate 1 (Steps 1);
1148 autoCalculate 1 (Steps 1);(*([1], Res), d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))*)
1149 appendFormula 1 "d_d x (x ^ 2) + cos (4 * x ^ 3)" (*|> Future.join*); (*<<<<<<<=========================*)
1150 (* the check for errpat is maximally liberal (whole term modulo "nrls" from "type met"),
1151 would recognize "cos (4 * x ^ (4 - 1)) + 2 * x" as well.
1152 results in <CALCMESSAGE> error pattern #chain-rule-diff-both# </CALCMESSAGE>
1153 instead of <CALCMESSAGE> no derivation found </CALCMESSAGE> *)
1154 val ((pt,pos), _) = get_calc 1;
1155 val p = get_pos 1 1;
1156 val (Form f, _, asms) = pt_extract (pt, p);
1158 if p = ([1], Res) andalso term2str f = "d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))" then
1159 case get_obj g_tac pt (fst p) of Rewrite_Inst (["(''bdv'', x)"],
1160 ("diff_sum", thm)) =>
1161 if (term2str o Thm.prop_of) thm = "d_d ?bdv (?u + ?v) = d_d ?bdv ?u + d_d ?bdv ?v" then ()
1162 else error "embed fun get_fillform changed 11"
1163 | _ => error "embed fun get_fillform changed 12"
1164 else error "embed fun get_fillform changed 13";
1166 findFillpatterns 1 "chain-rule-diff-both"; (*<<<<<<<=================================*)
1167 (*<CALCMESSAGE> fill patterns #fill-d_d-arg#d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4)) =
1168 d_d x (x ^^^ 2) + cos (x ^^^ 4) * d_d x ?_dummy_1#fill-both-args#...#...#... *)
1169 val ((pt,pos),_) = get_calc 1;
1170 val p = get_pos 1 1;
1172 val (Form f, _, asms) = pt_extract (pt, p);
1173 if p = ([1], Res) andalso term2str f = "d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))" then
1174 case get_obj g_tac pt (fst p) of Rewrite_Inst (["(''bdv'', x)"],
1175 ("diff_sum", thm)) =>
1176 if (term2str o Thm.prop_of) thm = "d_d ?bdv (?u + ?v) = d_d ?bdv ?u + d_d ?bdv ?v" then ()
1177 else error "embed fun get_fillform changed 21"
1178 | _ => error "embed fun get_fillform changed 22"
1179 else error "embed fun get_fillform changed 23";
1181 requestFillformula 1 ("chain-rule-diff-both", "fill-both-args");(*<<<<<<<============*)
1182 (*<AUTOCALC> ([1], Res) ([2], Res) ([2], Res) </AUTOCALC>*)
1183 val ((pt,pos),_) = get_calc 1;
1184 val p = get_pos 1 1;
1185 val (Form f, _, asms) = pt_extract (pt, p);
1186 if p = ([1], Res) andalso existpt [2] pt
1187 andalso term2str f = "d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))"
1188 then case get_obj g_tac pt (fst p) of Rewrite_Inst (["(''bdv'', x)"],
1189 ("diff_sum", thm)) =>
1190 if (term2str o Thm.prop_of) thm = "d_d ?bdv (?u + ?v) = d_d ?bdv ?u + d_d ?bdv ?v" then ()
1191 else error "embed fun get_fillform changed 31"
1192 | _ => error "embed fun get_fillform changed 32"
1193 else error "embed fun get_fillform changed 33";
1195 (* input a formula which exactly fills the gaps in a "fillformula"
1196 presented to the learner immediately before by "requestFillformula (errpatID, fillpatID)":
1197 errpatID: lhs of the respective thm = lhs of fillformula with fillpatID.
1198 the respective thm is in the ctree ................
1200 "~~~~~ fun inputFillFormula, args:"; val (cI, ifo) =
1201 (1, "d_d x (x ^^^ 2) + cos (x ^^^ 4) * d_d x (x ^^^ 4)");
1202 val ((pt, _), _) = get_calc cI
1203 val pos = get_pos cI 1;
1205 "~~~~~ fun is_exactly_equal, args:"; val ((pt, pos as (p, p_)), istr) = ((pt, pos), ifo);
1206 val SOME ifo = parseNEW (assoc_thy "Isac_Knowledge" |> thy2ctxt) istr
1208 val tac = get_obj g_tac pt p';
1209 val Rewrite_Inst ([bbb as "(''bdv'', x)"], ("diff_sin_chain", ttt)) = tac;
1210 if (term2str o Thm.prop_of) ttt = "d_d ?bdv (sin ?u) = cos ?u * d_d ?bdv ?u" then ()
1211 else error "inputFillFormula changed 10";
1212 val Appl rew = applicable_in pos pt tac;
1213 val Rewrite_Inst' (_, _, _, _, _, _, _, (res, _)) = rew;
1215 "~~~~~ to inputFillFormula return val:"; val ("ok", tac) = ("ok", tac);
1216 val ("ok", (_, c, ptp as (_,p'))) = locatetac tac (pt, pos);
1217 upd_calc cI (ptp, []);
1219 autocalculateOK2xml cI pos (if null c then p' else last_elem c) p';
1221 "~~~~~ final check:";
1222 val ((pt, _),_) = get_calc 1;
1223 val p = get_pos 1 1;
1224 val (Form f, _, asms) = pt_extract (pt, p);
1225 if p = ([2], Res) andalso term2str f = "d_d x (x ^^^ 2) + cos (x ^^^ 4) * d_d x (x ^^^ 4)"
1226 then case get_obj g_tac pt (fst p) of Rewrite_Inst (["(''bdv'', x)"],
1227 ("diff_sin_chain", thm)) =>
1228 if (term2str o Thm.prop_of) thm = "d_d ?bdv (sin ?u) = cos ?u * d_d ?bdv ?u" then ()
1229 else error "inputFillFormula changed 111"
1230 | _ => error "inputFillFormula changed 112"
1231 else error "inputFillFormula changed 113";
1233 "--------- fun appl_adds -----------------------------------------";
1234 "--------- fun appl_adds -----------------------------------------";
1235 "--------- fun appl_adds -----------------------------------------";
1236 (* val (dI, oris, ppc, pbt, selct::ss) =
1237 (dI, pors, probl, ppc, map itms2fstr probl);
1240 (* val (dI, oris, ppc, pbt, (selct::ss))=
1241 (#1 (some_spec ospec spec), oris, []:itm list,
1242 ((#ppc o get_pbt) (#2 (some_spec ospec spec))),(imodel2fstr imodel));
1243 val iii = appl_adds dI oris ppc pbt (selct::ss);
1244 tracing(itms2str_ thy iii);
1246 val itm = appl_add' dI oris ppc pbt selct;
1247 val ppc = insert_ppc' itm ppc;
1249 val _::selct::ss = (selct::ss);
1250 val itm = appl_add' dI oris ppc pbt selct;
1251 val ppc = insert_ppc' itm ppc;
1253 val _::selct::ss = (selct::ss);
1254 val itm = appl_add' dI oris ppc pbt selct;
1255 val ppc = insert_ppc' itm ppc;
1256 tracing(itms2str_ thy ppc);
1258 val _::selct::ss = (selct::ss);
1259 val itm = appl_add' dI oris ppc pbt selct;
1260 val ppc = insert_ppc' itm ppc;
1262 "--------- fun concat_deriv --------------------------------------";
1263 "--------- fun concat_deriv --------------------------------------";
1264 "--------- fun concat_deriv --------------------------------------";
1266 val ({rew_ord, erls, rules,...}, fo, ifo) =
1267 (rep_rls Test_simplify, str2term "x+1+ -1*2=0", str2term "-2*1+(x+1)=0");
1268 (tracing o trtas2str) fod';
1270 (x + 1 + -1 * 2 = 0, Thm ("radd_commute","?m + ?n = ?n + ?m"), (-1 * 2 + (x + 1) = 0, []))","
1271 (-1 * 2 + (x + 1) = 0, Thm ("radd_commute","?m + ?n = ?n + ?m"), (-1 * 2 + (1 + x) = 0, []))","
1272 (-1 * 2 + (1 + x) = 0, Thm ("radd_left_commute","?x + (?y + ?z) = ?y + (?x + ?z)"), (1 + (-1 * 2 + x) = 0, []))","
1273 (1 + (-1 * 2 + x) = 0, Thm ("#mult_Float ((~1,0), (0,0)) __ ((2,0), (0,0))","-1 * 2 = -2"), (1 + (-2 + x) = 0, []))"]
1275 (tracing o trtas2str) (map rev_deriv' rifod');
1277 (1 + (-2 + x) = 0, Thm ("sym_#mult_Float ((~2,0), (0,0)) __ ((1,0), (0,0))","-2 = -2 * 1"), (1 + (-2 * 1 + x) = 0, []))","
1278 (1 + (-2 * 1 + x) = 0, Thm ("sym_radd_left_commute","?y + (?x + ?z) = ?x + (?y + ?z)"), (-2 * 1 + (1 + x) = 0, []))","
1279 (-2 * 1 + (1 + x) = 0, Thm ("sym_radd_commute","?n + ?m = ?m + ?n"), (-2 * 1 + (x + 1) = 0, []))"]
1282 "--------- handle an input formula -------------------------------";
1283 "--------- handle an input formula -------------------------------";
1284 "--------- handle an input formula -------------------------------";
1286 Untersuchung zur Formeleingabe (appendFormula, replaceFormla) zu einer Anregung von Alan Krempler:
1287 Welche RICHTIGEN Formeln koennen NICHT abgeleitet werden,
1288 wenn Abteilungen nur auf gleichem Level gesucht werden ?
1291 Beispiele zum Equationsolver von Richard Lang aus /src/sml/kbtest/rlang.sml
1293 ------------------------------------------------------------------------------
1294 "Schalk I s.87 Bsp 52a ((5*x)/(x - 2) - x/(x+2)=4)";
1295 ------------------------------------------------------------------------------
1296 1. "5 * x / (x - 2) - x / (x + 2) = 4"
1298 4. "12 * x + 4 * x ^^^ 2 = 4 * (-4 + x ^^^ 2)",Subproblem["normalise", "poly"..
1300 4.3. "16 + 12 * x = 0", Subproblem["degree_1", "polynomial", "univariate"..
1302 4.3.3. "[x = -4 / 3]")), Check_elementwise "Assumptions"
1305 ------------------------------------------------------------------------------
1306 (1)..(6): keine 'richtige' Eingabe kann abgeleitet werden, die einen Summanden auf die andere Seite verschiebt [Ableitung ware in 4.3.n]
1308 (4.1)..(4.3): keine 'richtige' Eingabe kann abgeleitet werden, die einen Summanden auf die andere Seite verschiebt [Ableitung ware in 4.3.n]
1309 ------------------------------------------------------------------------------
1312 ------------------------------------------------------------------------------
1313 "Schalk I s.87 Bsp 55b (x/(x^^^2 - 6*x+9) - 1/(x^^^2 - 3*x) =1/x)";
1314 ------------------------------------------------------------------------------
1315 1. "x / (x ^^^ 2 - 6 * x + 9) - 1 / (x ^^^ 2 - 3 * x) = 1 / x"
1317 4. "(3 + (-1 * x + x ^^^ 2)) * x = 1 * (9 * x + (x ^^^ 3 + -6 * x ^^^ 2))"
1318 Subproblem["normalise", "polynomial", "univariate"..
1320 4.4. "-6 * x + 5 * x ^^^ 2 = 0", Subproblem["bdv_only", "degree_2", "poly"..
1322 4.4.4. "[x = 0, x = 6 / 5]", Check_elementwise "Assumptions"
1323 4.4.5. "[x = 0, x = 6 / 5]"
1325 5. "[x = 0, x = 6 / 5]", Check_elementwise "Assumptions"
1327 ------------------------------------------------------------------------------
1328 (1)..(4): keine 'richtige' Eingabe kann abgeleitet werden, die einen Summanden auf die andere Seite schiebt [Ableitung waere in 4.4.x]
1330 (4.1)..(4.4.5): keine 'richtige' Eingabe kann abgeleitet werden, die dem Ergebnis "[x = 6 / 5]" aequivalent ist [Ableitung waere in 5.]
1331 ------------------------------------------------------------------------------
1334 ------------------------------------------------------------------------------
1335 "Schalk II s.56 Bsp 73b (sqrt(x+1)+sqrt(4*x+4)=sqrt(9*x+9))";
1336 ------------------------------------------------------------------------------
1337 1. "sqrt (x + 1) + sqrt (4 * x + 4) = sqrt (9 * x + 9)"
1339 6. "13 + 13 * x + -2 * sqrt ((4 + 4 * x) * (9 + 9 * x)) = 1 + x"
1340 Subproblem["sq", "rootX", "univariate", "equation"]
1342 6.6. "144 + 288 * x + 144 * x ^^^ 2 = 144 + x ^^^ 2 + 288 * x + 143 * x ^^^ 2"
1343 Subproblem["normalise", "polynomial", "univariate", "equation"]
1345 6.6.3 "0 = 0" Subproblem["degree_0", "polynomial", "univariate", "equation"]
1347 6.6.3.2 "UniversalList"
1348 ------------------------------------------------------------------------------
1349 (1)..(6): keine 'richtige' Eingabe kann abgeleitet werden, die eine der Wurzeln auf die andere Seite verschieb [Ableitung ware in 6.6.n]
1351 (6.1)..(6.3): keine 'richtige' Eingabe kann abgeleitet werden, die einen Summanden auf die andere Seite verschiebt [Ableitung ware in 6.6.n]
1352 ------------------------------------------------------------------------------
1354 (*sh. comments auf 498*)
1355 "--------- fun dropwhile' ----------------------------------------";
1356 "--------- fun dropwhile' ----------------------------------------";
1357 "--------- fun dropwhile' ----------------------------------------";
1359 fun equal a b = a=b;
1360 val foder = [0,1,2,3,4,5]; val ifoder = [11,12,3,4,5];
1361 val r_foder = rev foder; val r_ifoder = rev ifoder;
1362 dropwhile' equal r_foder r_ifoder;
1363 > vval it = ([0, 1, 2, 3], [3, 12, 11]) : int list * int list
1365 val foder = [3,4,5]; val ifoder = [11,12,3,4,5];
1366 val r_foder = rev foder; val r_ifoder = rev ifoder;
1367 dropwhile' equal r_foder r_ifoder;
1368 > val it = ([3], [3, 12, 11]) : int list * int list
1370 val foder = [5]; val ifoder = [11,12,3,4,5];
1371 val r_foder = rev foder; val r_ifoder = rev ifoder;
1372 dropwhile' equal r_foder r_ifoder;
1373 > val it = ([5], [5, 4, 3, 12, 11]) : int list * int list
1375 val foder = [10,11,12,13,14,15]; val ifoder = [11,12,3,4,5];
1376 val r_foder = rev foder; val r_ifoder = rev ifoder;
1377 dropwhile' equal r_foder r_ifoder;
1378 > *** dropwhile': did not start with equal elements*)