1 (* Title: "Interpret/error-fill-pattern.sml"
2 Author: Walther Neuper 060225,
3 (c) due to copyright terms
5 Strange ERROR "Undefined fact: "all_left""
8 "-----------------------------------------------------------------";
9 "table of contents -----------------------------------------------";
10 "-----------------------------------------------------------------";
11 "appendForm with miniscript with mini-subpbl:";
12 "--------- appendFormula: on Res + equ_nrls ----------------------";
13 "--------- appendFormula: on Frm + equ_nrls ----------------------";
14 "--------- appendFormula: on Res + NO deriv ----------------------";
15 "--------- appendFormula: on Res + late deriv [x = 3 + -2]---///--";
16 "replaceForm with miniscript with mini-subpbl:";
17 "--------- replaceFormula: on Res + = ----------------------------";
18 "--------- replaceFormula: on Res + = 1st Nd ---------------------";
19 "--------- replaceFormula: on Frm + = 1st Nd ---------------------";
20 "--------- replaceFormula: cut calculation -----------------------";
21 "--------- replaceFormula: cut calculation -----------------------";
22 (* 040307 copied from informtest.sml ... old versions
23 "--------- maximum-example, UC: Modeling / modifyCalcHead --------";*)
24 "--------- syntax error ------------------------------------------";
26 "--------- CAS-command on ([],Pbl) -------------------------------";
27 "--------- CAS-command on ([],Pbl) FE-interface ------------------";
28 "--------- locate_input_term [rational,simplification] ----------------------";
29 "--------- Take as 1st tac, start with <NEW> (CAS input) ---------";
30 "--------- Take as 1st tac, start from exp -----------------------";
31 "--------- implicit_take, start with <NEW> (CAS input) ---------------";
32 "--------- build fun check_err_patt ------------------------------";
33 "--------- build fun check_err_patt ?bdv -------------------------";
34 "--------- build fun Error_Pattern.check_for ------------------------";
35 "--------- embed fun Error_Pattern.check_for ------------------------";
36 "--------- build fun get_fillpats --------------------------------";
37 "--------- embed fun find_fillpatterns ---------------------------";
38 "--------- build fun is_exactly_equal, inputFillFormula ----------";
39 "--------- fun appl_adds -----------------------------------------";
40 "--------- fun concat_deriv --------------------------------------";
41 "--------- handle an input formula -------------------------------";
42 "--------- fun dropwhile' ----------------------------------------";
43 "-----------------------------------------------------------------";
44 "-----------------------------------------------------------------";
45 "-----------------------------------------------------------------";
48 "--------- appendFormula: on Res + equ_nrls ----------------------";
49 "--------- appendFormula: on Res + equ_nrls ----------------------";
50 "--------- appendFormula: on Res + equ_nrls ----------------------";
51 val Prog sc = (#scr o get_met) ["Test","squ-equ-test-subpbl1"];
52 (writeln o UnparseC.term) sc;
53 val Prog sc = (#scr o get_met) ["Test","solve_linear"];
54 (writeln o UnparseC.term) sc;
57 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
58 ("Test", ["sqroot-test","univariate","equation","test"],
59 ["Test","squ-equ-test-subpbl1"]))];
60 Iterator 1; moveActiveRoot 1;
61 autoCalculate 1 CompleteCalcHead;
62 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
63 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
65 appendFormula 1 "-2 * 1 + (1 + x) = 0" (*|> Future.join*); refFormula 1 (get_pos 1 1);
66 val ((pt,_),_) = get_calc 1;
67 val str = pr_ctree pr_short pt;
69 (". ----- pblobj -----\n" ^
71 "2. x + 1 + -1 * 2 = 0\n" ^
72 "2.1. x + 1 + -1 * 2 = 0\n" ^
73 "2.2. 1 + x + -1 * 2 = 0\n" ^
74 "2.3. 1 + (x + -1 * 2) = 0\n" ^
75 "2.4. 1 + (x + -2) = 0\n" ^
76 "2.5. 1 + (x + -2 * 1) = 0\n" ^
77 "2.6. 1 + x + -2 * 1 = 0\n" ) then ()
78 else error "inform.sml: diff.behav.appendFormula: on Res + equ 1";
80 moveDown 1 ([ ],Pbl); refFormula 1 ([1],Frm); (*x + 1 = 2*)
81 moveDown 1 ([1],Frm); refFormula 1 ([1],Res); (*x + 1 + -1 * 2 = 0*)
83 (*the seven steps of detailed derivation*)
84 moveDown 1 ([1 ],Res); refFormula 1 ([2,1],Frm);
85 moveDown 1 ([2,1],Frm); refFormula 1 ([2,1],Res);
86 moveDown 1 ([2,1],Res); refFormula 1 ([2,2],Res);
87 moveDown 1 ([2,2],Res); refFormula 1 ([2,3],Res);
88 moveDown 1 ([2,3],Res); refFormula 1 ([2,4],Res);
89 moveDown 1 ([2,4],Res); refFormula 1 ([2,5],Res);
90 moveDown 1 ([2,5],Res); refFormula 1 ([2,6],Res);
91 val ((pt,_),_) = get_calc 1;
92 if "-2 * 1 + (1 + x) = 0" = UnparseC.term (fst (get_obj g_result pt [2,6])) then()
93 else error "inform.sml: diff.behav.appendFormula: on Res + equ 2";
95 fetchProposedTactic 1; (*takes Iterator 1 _1_*)
96 (* <ERROR> error in kernel </ERROR> ALREADY IN 2009-2*)
97 (*========== inhibit exn WN1130701 broken at Isabelle2002 --> 2009-2 =============
98 val (_,(tac,_,_)::_) = get_calc 1;
99 if tac = Rewrite_Set "Test_simplify" then ()
100 else error "inform.sml: diff.behav.appendFormula: on Res + equ 3";
101 ============ inhibit exn WN1130701 broken at Isabelle2002 --> 2009-2 ============*)
103 autoCalculate 1 CompleteCalc;
104 val ((pt,_),_) = get_calc 1;
105 if "[x = 1]" = UnparseC.term (fst (get_obj g_result pt [])) then ()
106 else error "inform.sml: diff.behav.appendFormula: on Res + equ 4";
107 (* autoCalculate 1 CompleteCalc;
108 val ((pt,p),_) = get_calc 1;
109 (writeln o istates2str) (get_obj g_loc pt [ ]);
110 (writeln o istates2str) (get_obj g_loc pt [1]);
111 (writeln o istates2str) (get_obj g_loc pt [2]);
112 (writeln o istates2str) (get_obj g_loc pt [3]);
113 (writeln o istates2str) (get_obj g_loc pt [3,1]);
114 (writeln o istates2str) (get_obj g_loc pt [3,2]);
115 (writeln o istates2str) (get_obj g_loc pt [4]);
118 "----------------------------------------------------------";
120 val fod = Derive.do_one (@{theory "Isac_Knowledge"}) Atools_erls
121 ((#rules o Rule_Set.rep) Test_simplify)
122 (sqrt_right false (@{theory "Pure"})) NONE
123 (str2term "x + 1 + -1 * 2 = 0");
124 (writeln o Derive.trtas2str) fod;
126 val ifod = Derive.do_one (@{theory "Isac_Knowledge"}) Atools_erls
127 ((#rules o Rule_Set.rep) Test_simplify)
128 (sqrt_right false (@{theory "Pure"})) NONE
129 (str2term "-2 * 1 + (1 + x) = 0");
130 (writeln o Derive.trtas2str) ifod;
131 fun equal (_,_,(t1, _)) (_,_,(t2, _)) = t1 = t2;
132 val (fod', rifod') = dropwhile' equal (rev fod) (rev ifod);
133 val der = fod' @ (map Derive.rev_deriv' rifod');
134 (writeln o Derive.trtas2str) der;
135 "----------------------------------------------------------";
138 "--------- appendFormula: on Frm + equ_nrls ----------------------";
139 "--------- appendFormula: on Frm + equ_nrls ----------------------";
140 "--------- appendFormula: on Frm + equ_nrls ----------------------";
142 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
143 ("Test", ["sqroot-test","univariate","equation","test"],
144 ["Test","squ-equ-test-subpbl1"]))];
145 Iterator 1; moveActiveRoot 1;
146 autoCalculate 1 CompleteCalcHead;
147 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1) (*x + 1 = 2*);
148 appendFormula 1 "2+ -1 + x = 2" (*|> Future.join*); refFormula 1 (get_pos 1 1);
150 moveDown 1 ([],Pbl); refFormula 1 ([1],Frm) (*x + 1 = 2*);
152 moveDown 1 ([1 ],Frm); refFormula 1 ([1,1],Frm);
153 moveDown 1 ([1,1],Frm); refFormula 1 ([1,1],Res);
154 moveDown 1 ([1,1],Res); refFormula 1 ([1,2],Res);
155 moveDown 1 ([1,2],Res); refFormula 1 ([1,3],Res);
156 moveDown 1 ([1,3],Res); refFormula 1 ([1,4],Res);
157 moveDown 1 ([1,4],Res); refFormula 1 ([1,5],Res);
158 moveDown 1 ([1,5],Res); refFormula 1 ([1,6],Res);
159 val ((pt,_),_) = get_calc 1;
160 if "2 + -1 + x = 2" = UnparseC.term (fst (get_obj g_result pt [1,6])) then()
161 else error "inform.sml: diff.behav.appendFormula: on Frm + equ 1";
163 fetchProposedTactic 1; (*takes Iterator 1 _1_*)
164 val (_,(tac,_,_)::_) = get_calc 1;
165 case tac of Rewrite_Set "norm_equation" => ()
166 | _ => error "inform.sml: diff.behav.appendFormula: on Frm + equ 2";
167 autoCalculate 1 CompleteCalc;
168 val ((pt,_),_) = get_calc 1;
169 if "[x = 1]" = UnparseC.term (fst (get_obj g_result pt [])) then ()
170 else error "inform.sml: diff.behav.appendFormula: on Frm + equ 3";
173 "--------- appendFormula: on Res + NO deriv ----------------------";
174 "--------- appendFormula: on Res + NO deriv ----------------------";
175 "--------- appendFormula: on Res + NO deriv ----------------------";
177 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
178 ("Test", ["sqroot-test","univariate","equation","test"],
179 ["Test","squ-equ-test-subpbl1"]))];
180 Iterator 1; moveActiveRoot 1;
181 autoCalculate 1 CompleteCalcHead;
182 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
183 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
185 appendFormula 1 "x = 2" (*|> Future.join*);
186 val ((pt,p),_) = get_calc 1;
187 val str = pr_ctree pr_short pt;
189 if str = ". ----- pblobj -----\n1. x + 1 = 2\n" andalso p = ([1], Res)
191 else error "inform.sml: diff.behav.appendFormula: Res + NOder 1";
193 fetchProposedTactic 1;
194 val (_,(tac,_,_)::_) = get_calc 1;
195 case tac of Rewrite_Set "Test_simplify" => ()
196 | _ => error "inform.sml: diff.behav.appendFormula: Res + NOder 2";
197 autoCalculate 1 CompleteCalc;
198 val ((pt,_),_) = get_calc 1;
199 if "[x = 1]" = UnparseC.term (fst (get_obj g_result pt [])) then ()
200 else error "inform.sml: diff.behav.appendFormula: on Frm + equ 3";
203 "--------- appendFormula: on Res + late deriv --------------------";
204 "--------- appendFormula: on Res + late deriv --------------------";
205 "--------- appendFormula: on Res + late deriv --------------------";
206 (*cp with "fun me" to test/../lucas-interpreter.sml:
207 re-build: fun locate_input_term ---------------------------------------------------";
210 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
211 ("Test", ["sqroot-test","univariate","equation","test"],
212 ["Test","squ-equ-test-subpbl1"]))];
213 Iterator 1; moveActiveRoot 1;
214 autoCalculate 1 CompleteCalcHead;
215 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
216 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
218 appendFormula 1 "x = 1" (*|> Future.join*);
219 val ((pt,p),_) = get_calc 1;
220 val str = pr_ctree pr_short pt;
222 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)
223 then () (*finds 1 step too early: ([3,2], Res) "x = 1" also by script !!!*)
224 else error "inform.sml: diff.behav.appendFormula: Res + late d 1";
226 fetchProposedTactic 1;
227 val (_,(tac,_,_)::_) = get_calc 1;
228 case tac of Check_Postcond ["LINEAR", "univariate", "equation", "test"] => ()
229 | _ => error "inform.sml: diff.behav.appendFormula: Res + late d 2";
230 autoCalculate 1 CompleteCalc;
231 val ((pt,_),_) = get_calc 1;
232 if "[x = 1]" = UnparseC.term (fst (get_obj g_result pt [])) then ()
233 else error "inform.sml: diff.behav.appendFormula: Res + late d 3";
236 "--------- appendFormula: on Res + late deriv [x = 3 + -2]---///--";
237 "--------- appendFormula: on Res + late deriv [x = 3 + -2]---///--";
238 "--------- appendFormula: on Res + late deriv [x = 3 + -2]---///--";
240 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
241 ("Test", ["sqroot-test","univariate","equation","test"],
242 ["Test","squ-equ-test-subpbl1"]))];
243 Iterator 1; moveActiveRoot 1;
244 autoCalculate 1 CompleteCalcHead;
245 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
246 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
247 appendFormula 1 "[x = 3 + -2*1]" (*|> Future.join*);
248 val ((pt,p),_) = get_calc 1;
249 val str = pr_ctree pr_short pt;
251 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 ()
252 else error "inform.sml: diff.behav.appendFormula: Res + latEE 1";
253 autoCalculate 1 CompleteCalc;
254 val ((pt,p),_) = get_calc 1;
255 if "[x = 3 + -2 * 1]" = UnparseC.term (fst (get_obj g_result pt [])) then ()
256 (* ~~~~~~~~~~ simplify as last step in any script ?!*)
257 else error "inform.sml: diff.behav.appendFormula: Res + latEE 2";
260 "--------- replaceFormula: on Res + = ----------------------------";
261 "--------- replaceFormula: on Res + = ----------------------------";
262 "--------- replaceFormula: on Res + = ----------------------------";
264 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
265 ("Test", ["sqroot-test","univariate","equation","test"],
266 ["Test","squ-equ-test-subpbl1"]))];
267 Iterator 1; moveActiveRoot 1;
268 autoCalculate 1 CompleteCalcHead;
269 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
270 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
271 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*-1 + x*);
273 replaceFormula 1 "-2 * 1 + (1 + x) = 0"; refFormula 1 (get_pos 1 1);
274 val ((pt,_),_) = get_calc 1;
275 val str = pr_ctree pr_short pt;
277 (* before AK110725 this was
278 ". ----- pblobj -----\n
280 2. x + 1 + -1 * 2 = 0\n
281 2.1. x + 1 + -1 * 2 = 0\n
282 2.2. 1 + x + -1 * 2 = 0\n
283 2.3. 1 + (x + -1 * 2) = 0\n
284 2.4. 1 + (x + -2) = 0\n
285 2.5. 1 + (x + -2 * 1) = 0\n
286 2.6. 1 + x + -2 * 1 = 0\n";
289 ". ----- pblobj -----\n"^
291 "2. x + 1 + -1 * 2 = 0\n"^
292 "2.1. x + 1 + -1 * 2 = 0\n"^
293 "2.2. 1 + x + -1 * 2 = 0\n"^
294 "2.3. 1 + (x + -1 * 2) = 0\n"^
295 "2.4. 1 + (x + -2) = 0\n"^
296 "2.5. 1 + (x + -2 * 1) = 0\n"^
297 "2.6. 1 + x + -2 * 1 = 0\n" then()
298 else error "inform.sml: diff.behav.replaceFormula: on Res += 1";
300 autoCalculate 1 CompleteCalc;
301 val ((pt,pos as (p,_)),_) = get_calc 1;
302 if pos = ([],Res) andalso "[x = 1]" = (UnparseC.term o fst) (get_obj g_result pt p) then()
303 else error "inform.sml: diff.behav.replaceFormula: on Res + = 2";
306 "--------- replaceFormula: on Res + = 1st Nd ---------------------";
307 "--------- replaceFormula: on Res + = 1st Nd ---------------------";
308 "--------- replaceFormula: on Res + = 1st Nd ---------------------";
310 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
311 ("Test", ["sqroot-test","univariate","equation","test"],
312 ["Test","squ-equ-test-subpbl1"]))];
313 Iterator 1; moveActiveRoot 1;
314 autoCalculate 1 CompleteCalcHead;
315 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
316 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
318 replaceFormula 1 "x + 1 = 4 + -2"; refFormula 1 (get_pos 1 1);
319 val ((pt,_),_) = get_calc 1;
320 val str = pr_ctree pr_short pt;
322 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 ()
323 else error "inform.sml: diff.behav.replaceFormula: on Res 1 + = 1";
324 autoCalculate 1 CompleteCalc;
325 val ((pt,pos as (p,_)),_) = get_calc 1;
326 if pos = ([],Res) andalso "[x = 1]" = (UnparseC.term o fst)(get_obj g_result pt p) then()
327 else error "inform.sml: diff.behav.replaceFormula: on Res + = 2";
330 "--------- replaceFormula: on Frm + = 1st Nd ---------------------";
331 "--------- replaceFormula: on Frm + = 1st Nd ---------------------";
332 "--------- replaceFormula: on Frm + = 1st Nd ---------------------";
334 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
335 ("Test", ["sqroot-test","univariate","equation","test"],
336 ["Test","squ-equ-test-subpbl1"]))];
337 Iterator 1; moveActiveRoot 1;
338 autoCalculate 1 CompleteCalcHead;
339 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
341 replaceFormula 1 "x + 1 = 4 + -2"; refFormula 1 (get_pos 1 1);
342 val ((pt,_),_) = get_calc 1;
343 val str = pr_ctree pr_short pt;
345 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 ()
346 else error "inform.sml: diff.behav.replaceFormula: on Frm 1 + = 1";
347 autoCalculate 1 CompleteCalc;
348 val ((pt,pos as (p,_)),_) = get_calc 1;
349 if pos = ([],Res) andalso "[x = 1]" = (UnparseC.term o fst)(get_obj g_result pt p) then()
350 else error "inform.sml: diff.behav.replaceFormula: on Frm 1 + = 2";
353 "--------- replaceFormula: cut calculation -----------------------";
354 "--------- replaceFormula: cut calculation -----------------------";
355 "--------- replaceFormula: cut calculation -----------------------";
357 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
358 ("Test", ["sqroot-test","univariate","equation","test"],
359 ["Test","squ-equ-test-subpbl1"]))];
360 Iterator 1; moveActiveRoot 1;
361 autoCalculate 1 CompleteCalc;
362 moveActiveRoot 1; moveActiveDown 1;
363 if get_pos 1 1 = ([1], Frm) then ()
364 else error "inform.sml: diff.behav. cut calculation 1";
366 replaceFormula 1 "x + 1 = 4 + -2"; refFormula 1 (get_pos 1 1);
367 val ((pt,p),_) = get_calc 1;
368 val str = pr_ctree pr_short pt;
370 if p = ([1], Res) then ()
371 else error "inform.sml: diff.behav. cut calculation 2";
374 (* 040307 copied from informtest.sml; ... old version
375 "---------------- maximum-example, UC: Modeling / modifyCalcHead -";
376 "---------------- maximum-example, UC: Modeling / modifyCalcHead -";
377 "---------------- maximum-example, UC: Modeling / modifyCalcHead -";
380 val elems = ["fixedValues [r=Arbfix]","maximum A","valuesFor [a,b]",
381 "relations [A=a*b, (a/2)^^^2 + (b/2)^^^2 = r^^^2]",
382 "relations [A=a*b, (a/2)^^^2 + (b/2)^^^2 = r^^^2]",
383 "relations [A=a*b, a/2=r*sin alpha, b/2=r*cos (alpha::real)]",
384 (*^^^ these are the elements for the root-problem (in variants)*)
385 (*vvv these are elements required for subproblems*)
386 "boundVariable a","boundVariable b","boundVariable alpha",
387 "interval {x::real. 0 <= x & x <= 2*r}",
388 "interval {x::real. 0 <= x & x <= 2*r}",
389 "interval {x::real. 0 <= x & x <= pi}",
390 "errorBound (eps=(0::real))"]
391 (*specifying is not interesting for this example*)
392 val spec = ("DiffApp", ["maximum_of","function"],
393 ["DiffApp","max_by_calculus"]);
394 (*the empty model with descriptions for user-guidance by Model_Problem*)
395 val empty_model = [Given ["fixedValues []"],
396 Find ["maximum", "valuesFor"],
397 Relate ["relations []"]];
400 (*!!!!!!!!!!!!!!!!! DON'T USE me FOR FINDING nxt !!!!!!!!!!!!!!!!!!*)
401 val (p,_,f,nxt,_,pt) = CalcTreeTEST [(elems, spec)];
402 (*val nxt = ("Model_Problem", ...*)
403 val pbl = get_obj g_pbl pt (fst p); (writeln o (itms2str_ ctxt)) pbl;
405 val (p,_,f,nxt,_,pt) = me nxt p c pt;
406 (*nxt = Add_Given "fixedValues [r = Arbfix]"*)
407 val pbl = get_obj g_pbl pt (fst p); (writeln o (itms2str_ ctxt)) pbl;
409 (0 ,[] ,false ,#Given ,Inc fixedValues [] ,(??.empty, [])),
410 (0 ,[] ,false ,#Find ,Inc maximum ,(??.empty, [])),
411 (0 ,[] ,false ,#Find ,Inc valuesFor ,(??.empty, [])),
412 (0 ,[] ,false ,#Relate ,Inc relations [] ,(??.empty, []))]*)
414 (*the empty CalcHead is checked w.r.t the model and re-established as such*)
415 val (b,pt,ocalhd) = input_icalhd pt (p,"", empty_model, Pbl, Spec.empty);
416 val pbl = get_obj g_pbl pt (fst p); (writeln o (itms2str_ ctxt)) pbl;
417 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(\"ThyC.id_empty\", [\"e_pblID\"], [\"e_metID\"]) )" then () else error "informtest.sml: diff.behav. max 1";
419 (*there is one input to the model (could be more)*)
421 input_icalhd pt (p,"", [Given ["fixedValues [r=Arbfix]"],
422 Find ["maximum", "valuesFor"],
423 Relate ["relations"]], Pbl, Spec.empty);
424 val pbl = get_obj g_pbl pt (fst p); (writeln o (itms2str_ ctxt)) pbl;
425 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(\"ThyC.id_empty\", [\"e_pblID\"], [\"e_metID\"]) )" then ()
426 else error "informtest.sml: diff.behav. max 2";
428 (*this input is complete in variant 3, but the ME doesn't recognize FIXXXXME
429 val (b,pt''''',ocalhd) =
430 input_icalhd pt (p,"", [Given ["fixedValues [r=Arbfix]"],
431 Find ["maximum A", "valuesFor [a,b]"],
432 Relate ["relations [A=a*b, a/2=r*sin alpha, \
433 \b/2=r*cos alpha]"]], Pbl, Spec.empty);
434 val pbl = get_obj g_pbl pt''''' (fst p); (writeln o (itms2str_ ctxt)) pbl;
435 if ocalhd2str ocalhd = ------------^^^^^^^^^^ missing !!!*)
437 (*this input is complete in variant 1 (variant 3 does not work yet)*)
438 val (b,pt''''',ocalhd) =
439 input_icalhd pt (p,"", [Given ["fixedValues [r=Arbfix]"],
440 Find ["maximum A", "valuesFor [a,b]"],
441 Relate ["relations [A=a*b, \
442 \(a/2)^^^2 + (b/2)^^^2 = r^^^2]"]],
444 val pbl = get_obj g_pbl pt''''' (fst p); (writeln o (itms2str_ ctxt)) pbl;
446 modifycalcheadOK2xml 111 (bool2str b) ocalhd;
450 "--------- syntax error ------------------------------------------";
451 "--------- syntax error ------------------------------------------";
452 "--------- syntax error ------------------------------------------";
454 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
455 ("Test", ["sqroot-test","univariate","equation","test"],
456 ["Test","squ-equ-test-subpbl1"]))];
457 Iterator 1; moveActiveRoot 1;
458 autoCalculate 1 CompleteCalcHead;
459 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
460 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
462 appendFormula 1 " x - "; (*<ERROR> syntax error in ' x - ' </ERROR>*)
463 val ((pt,_),_) = get_calc 1;
464 val str = pr_ctree pr_short pt;
466 if str = ". ----- pblobj -----\n1. x + 1 = 2\n" then ()
467 else error "inform.sml: diff.behav.appendFormula: syntax error";
470 "--------- CAS-command on ([],Pbl) -------------------------------";
471 "--------- CAS-command on ([],Pbl) -------------------------------";
472 "--------- CAS-command on ([],Pbl) -------------------------------";
473 val (p,_,f,nxt,_,pt) =
474 CalcTreeTEST [([], ("empty_thy_id", ["empty_probl_id"], ["empty_meth_id"]))];
475 val ifo = "solve(x+1=2,x)";
476 val (_,(_,c,(pt,p))) = Step_Solve.by_term (pt,p) "solve(x+1=2,x)";
478 val nxt = (Apply_Method ["Test","squ-equ-test-subpbl1"]);
479 val (p,_,f,nxt,_,pt) = me nxt p [] pt;
480 if p = ([1], Frm) andalso f2str f = "x + 1 = 2" then ()
481 else error "inform.sml: diff.behav. CAScmd ([],Pbl)";
484 "--------- CAS-command on ([],Pbl) FE-interface ------------------";
485 "--------- CAS-command on ([],Pbl) FE-interface ------------------";
486 "--------- CAS-command on ([],Pbl) FE-interface ------------------";
488 CalcTree [([], ("empty_thy_id", ["empty_probl_id"], ["empty_meth_id"]))];
491 replaceFormula 1 "solve(x+1=2,x)";
492 autoCalculate 1 CompleteCalc;
493 val ((pt,p),_) = get_calc 1;
495 if p = ([], Res) then ()
496 else error "inform.sml: diff.behav. CAScmd ([],Pbl) FE-interface";
499 "--------- inform [rational,simplification] ----------------------";
500 "--------- inform [rational,simplification] ----------------------";
501 "--------- inform [rational,simplification] ----------------------";
503 CalcTree [(["Term (a * x / (b * x) + c * x / (d * x) + e / f)", "normalform N"],
504 ("Rational", ["rational", "simplification"], ["simplification", "of_rationals"]))];
505 Iterator 1; moveActiveRoot 1;
506 autoCalculate 1 CompleteCalcHead;
508 "--- (-1) give a preview on the calculation without any input";
510 autoCalculate 1 CompleteCalc;
511 val ((pt, p), _) = get_calc 1;
514 (([], Frm), Simplify (a * x / (b * x) + c * x / (d * x) + e / f)),
515 (([1], Frm), a * x / (b * x) + c * x / (d * x) + e / f),
516 (([1], Res), a / b + c / d + e / f), <--- (1) input arbitrary
517 (([2], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
518 (([3], Res), (a * (d * f) + b * (c * f) + b * (d * e)) / (b * (d * f))),
519 (([4], Res), (a * d * f + b * c * f + b * d * e) / (b * d * f)), <--- (2) input next
520 (([], Res), (a * d * f + b * c * f + b * d * e) / (b * d * f))] <--- (3) is also final result
523 "--- (0) user input as the *first* step does not work, thus impdo at least 1 step";
524 autoCalculate 1 (Steps 1);
525 autoCalculate 1 (Steps 1);
526 val ((pt, p), _) = get_calc 1;
529 (([], Frm), Simplify (a * x / (b * x) + c * x / (d * x) + e / f)),
530 (([1], Frm), a * x / (b * x) + c * x / (d * x) + e / f),
531 (([1], Res), a / b + c / d + e / f)]
533 "--- (1) input an arbitrary next formula";
534 appendFormula 1 "((a * d) + (c * b)) / (b * d) + e / f" (*|> Future.join*);
535 val ((pt, p), _) = get_calc 1;
538 (([], Frm), Simplify (a * x / (b * x) + c * x / (d * x) + e / f)),
539 (([1], Frm), a * x / (b * x) + c * x / (d * x) + e / f),
540 (([1], Res), a / b + c / d + e / f),
541 (([2,1], Frm), a / b + c / d + e / f),
542 (([2,1], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
543 (([2,2], Res), (a * d + c * b) / (b * d) + e / f),
544 (([2], Res), (a * d + c * b) / (b * d) + e / f)]
546 val ((pt,p),_) = get_calc 1;
547 if p = ([2], Res) andalso (length o children o (get_nd pt)) (fst p) = 2 then ()
548 else error ("inform.sml: [rational,simplification] 1");
550 "--- (2) input the next formula that would be presented by mat-engine";
551 (* generate a preview:
552 autoCalculate 1 (Steps 1);
553 val ((pt, p), _) = get_calc 1;
556 (([], Frm), Simplify (a * x / (b * x) + c * x / (d * x) + e / f)),
557 (([1], Frm), a * x / (b * x) + c * x / (d * x) + e / f),
558 (([1], Res), a / b + c / d + e / f),
559 (([2,1], Frm), a / b + c / d + e / f),
560 (([2,1], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
561 (([2,2], Res), (a * d + c * b) / (b * d) + e / f),
562 (([2], Res), (a * d + c * b) / (b * d) + e / f),
563 (([3], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f))] <--- input this
565 appendFormula 1 "(b * d * e + b * c * f + a * d * f) / (b * d * f)" (*|> Future.join*);
566 val ((pt, p), _) = get_calc 1;
569 (([], Frm), Simplify (a * x / (b * x) + c * x / (d * x) + e / f)),
570 (([1], Frm), a * x / (b * x) + c * x / (d * x) + e / f),
571 (([1], Res), a / b + c / d + e / f),
572 (([2,1], Frm), a / b + c / d + e / f),
573 (([2,1], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
574 (([2,2], Res), (a * d + c * b) / (b * d) + e / f),
575 (([2], Res), (a * d + c * b) / (b * d) + e / f),
576 (([3], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f))]
578 if p = ([3], Res) andalso (length o children o (get_nd pt)) (fst p) = 0 then ()
579 else error ("inform.sml: [rational,simplification] 2");
581 "--- (3) input the exact final result";
582 appendFormula 1 "(b * d * e + b * c * f + a * d * f) / (b * d * f)" (*|> Future.join*);
583 val ((pt, p), _) = get_calc 1;
586 (([], Frm), Simplify (a * x / (b * x) + c * x / (d * x) + e / f)),
587 (([1], Frm), a * x / (b * x) + c * x / (d * x) + e / f),
588 (([1], Res), a / b + c / d + e / f),
589 (([2,1], Frm), a / b + c / d + e / f),
590 (([2,1], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
591 (([2,2], Res), (a * d + c * b) / (b * d) + e / f),
592 (([2], Res), (a * d + c * b) / (b * d) + e / f),
593 (([3], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
594 (([4,1], Frm), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
595 (([4,1], Res), (a * (d * f) + b * (c * f) + b * (d * e)) / (b * (d * f))),
596 (([4,2], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
597 (([4], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f))]
599 if p = ([4], Res) andalso (length o children o (get_nd pt)) (fst p) = 2 then ()
600 else error ("inform.sml: [rational,simplification] 3");
602 "--- (4) finish the calculation + check the postcondition (in the future)";
603 autoCalculate 1 CompleteCalc;
604 val ((pt, p), _) = get_calc 1;
605 val (t, asm) = get_obj g_result pt [];
606 if UnparseC.term t = "(a * d * f + b * c * f + b * d * e) / (b * d * f)" andalso
607 UnparseC.terms asm = "[\"b * d * f \<noteq> 0\",\"d \<noteq> 0\",\"b \<noteq> 0\",\"a * x / (b * x) + c * x / (d * x) + e / f is_ratpolyexp\"]"
608 then () else error "inform [rational,simplification] changed at end";
611 (([], Frm), Simplify (a * x / (b * x) + c * x / (d * x) + e / f)),
612 (([1], Frm), a * x / (b * x) + c * x / (d * x) + e / f),
613 (([1], Res), a / b + c / d + e / f),
614 (([2,1], Frm), a / b + c / d + e / f),
615 (([2,1], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
616 (([2,2], Res), (a * d + c * b) / (b * d) + e / f),
617 (([2], Res), (a * d + c * b) / (b * d) + e / f),
618 (([3], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
619 (([4,1], Frm), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
620 (([4,1], Res), (a * (d * f) + b * (c * f) + b * (d * e)) / (b * (d * f))),
621 (([4,2], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
622 (([4], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
623 (([5], Res), (a * (d * f) + b * (c * f) + b * (d * e)) / (b * (d * f))),
624 (([6], Res), (a * d * f + b * c * f + b * d * e) / (b * d * f)),
625 (([], Res), (a * d * f + b * c * f + b * d * e) / (b * d * f))]
629 "--------- Take as 1st tac, start with <NEW> (CAS input) ---------";
630 "--------- Take as 1st tac, start with <NEW> (CAS input) ---------";
631 "--------- Take as 1st tac, start with <NEW> (CAS input) ---------";
632 val t = str2term "Diff (x^^^2 + x + 1, x)";
633 case t of Const ("Diff.Diff", _) $ _ => ()
635 error "diff.sml behav.changed for CAS Diff (..., x)";
637 "-----------------------------------------------------------------";
638 (*1>*)reset_states ();
639 (*2>*)CalcTree [([], ("empty_thy_id", ["empty_probl_id"], ["empty_meth_id"]))];
640 (*3>*)Iterator 1;moveActiveRoot 1;
641 "----- here the Headline has been finished";
642 (*4>*)moveActiveFormula 1 ([],Pbl);
643 (*5>*)replaceFormula 1 "Diff (x^2 + x + 1, x)";
644 val ((pt,_),_) = get_calc 1;
645 val PblObj {probl, meth, spec, fmz, env, loc, ...} = get_obj I pt [];
647 val (SOME istate, NONE) = loc;
648 (*default_print_depth 5;*)
649 writeln"-----------------------------------------------------------";
651 writeln (itms2str_ ctxt probl);
652 writeln (itms2str_ ctxt meth);
653 writeln (Istate.string_of (fst istate));
655 refFormula 1 ([],Pbl) (*--> correct CalcHead*);
656 (*081016 NOT necessary (but leave it in Java):*)
657 (*6>*)(*completeCalcHead*)autoCalculate 1 CompleteCalcHead;
658 "----- here the CalcHead has been completed --- ONCE MORE ?????";
660 (***difference II***)
661 val ((pt,p),_) = get_calc 1;
662 (*val p = ([], Pbl)*)
663 val PblObj {probl, meth, spec, fmz, env, loc, ...} = get_obj I pt [];
665 val (SOME istate, NONE) = loc;
666 (*default_print_depth 5;*) writeln (Istate.string_of (fst istate)); (*default_print_depth 3;*)
669 ??.empty, Sundef, false)*)
670 (*default_print_depth 5;*) spec; (*default_print_depth 3;*)
672 ["derivative_of", "function"],
673 ["diff", "differentiate_on_R"]) : spec*)
674 writeln (itms2str_ ctxt probl);
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 (itms2str_ ctxt meth);
681 (1 ,[1] ,true ,#Given ,Cor functionTerm (x ^^^ 2 + x + 1) ,(f_, [x ^^^ 2 + x + 1])),
682 (2 ,[1] ,true ,#Given ,Cor differentiateFor x ,(v_, [x])),
683 (3 ,[1] ,true ,#Find ,Cor derivative f_'_f ,(f_'_f, [f_'_f]))]*)
684 writeln"-----------------------------------------------------------";
685 (*7>*)fetchProposedTactic 1 (*--> Apply_Method*);
686 (*WN081028 fixed <ERROR> helpless </ERROR> by inform returning ...(.,Met)*)
687 autoCalculate 1 CompleteCalc;
688 val ((pt,p),_) = get_calc 1;
689 val Form res = (#1 o pt_extract) (pt, ([],Res));
691 if p = ([], Res) andalso UnparseC.term res = "1 + 2 * x" then ()
692 else error "diff.sml behav.changed for Diff (x^2 + x + 1, x)";
695 "--------- Take as 1st tac, start from exp -----------------------";
696 "--------- Take as 1st tac, start from exp -----------------------";
697 "--------- Take as 1st tac, start from exp -----------------------";
698 (*the following input is copied from BridgeLog Java <==> SML,
699 omitting unnecessary inputs*)
700 (*1>*)reset_states ();
701 (*2>*)CalcTree [(["functionTerm (x^2 + x + 1)", "differentiateFor x", "derivative f_'_f"],("Isac_Knowledge",["derivative_of","function"],["diff","differentiate_on_R"]))];
702 (*3>*)Iterator 1; moveActiveRoot 1;
704 (*6>*)(*completeCalcHead*)autoCalculate 1 CompleteCalcHead;
705 (***difference II***)
706 val ((pt,_),_) = get_calc 1;
707 val PblObj {probl, meth, spec, fmz, env, loc, ...} = get_obj I pt [];
709 val (SOME istate, NONE) = loc;
710 (*default_print_depth 5;*) writeln (Istate.string_of (fst istate)); (*default_print_depth 3;*)
713 ??.empty, Sundef, false)*)
714 (*default_print_depth 5;*) spec; (*default_print_depth 3;*)
716 ["derivative_of", "function"],
717 ["diff", "differentiate_on_R"]) : spec*)
718 writeln (itms2str_ ctxt probl);
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 (itms2str_ ctxt meth);
725 (1 ,[1] ,true ,#Given ,Cor functionTerm (x ^^^ 2 + x + 1) ,(f_, [x ^^^ 2 + x + 1])),
726 (2 ,[1] ,true ,#Given ,Cor differentiateFor x ,(v_, [x])),
727 (3 ,[1] ,true ,#Find ,Cor derivative f_'_f ,(f_'_f, [f_'_f]))]*)
728 writeln"-----------------------------------------------------------";
729 (*7>*)fetchProposedTactic 1 (*--> Apply_Method*);
730 autoCalculate 1 (Steps 1);
731 val ((pt,p),_) = get_calc 1;
732 val Form res = (#1 o pt_extract) (pt, p);
733 if UnparseC.term res = "d_d x (x ^^^ 2 + x + 1)" then ()
734 else error "diff.sml Diff (x^2 + x + 1, x) from exp";
737 "--------- implicit_take, start with <NEW> (CAS input) ---------------";
738 "--------- implicit_take, start with <NEW> (CAS input) ---------------";
739 "--------- implicit_take, start with <NEW> (CAS input) ---------------";
741 CalcTree [([], ("empty_thy_id", ["empty_probl_id"], ["empty_meth_id"]))];
742 (*[[from sml: > @@@@@begin@@@@@
744 [[from sml: <CALCTREE>
745 [[from sml: <CALCID> 1 </CALCID>
746 [[from sml: </CALCTREE>
747 [[from sml: @@@@@end@@@@@*)
749 (*[[from sml: > @@@@@begin@@@@@
751 [[from sml: <ADDUSER>
752 [[from sml: <CALCID> 1 </CALCID>
753 [[from sml: <USERID> 1 </USERID>
754 [[from sml: </ADDUSER>
755 [[from sml: @@@@@end@@@@@*)
757 (*[[from sml: > @@@@@begin@@@@@
759 [[from sml: <CALCITERATOR>
760 [[from sml: <CALCID> 1 </CALCID>
761 [[from sml: <POSITION>
762 [[from sml: <INTLIST>
763 [[from sml: </INTLIST>
764 [[from sml: <POS> Pbl </POS>
765 [[from sml: </POSITION>
766 [[from sml: </CALCITERATOR>
767 [[from sml: @@@@@end@@@@@*)
768 getFormulaeFromTo 1 ([],Pbl) ([],Pbl) 0 false;
769 (*[[from sml: > @@@@@begin@@@@@ STILL CORRECT
771 [[from sml: <GETELEMENTSFROMTO>
772 [[from sml: <CALCID> 1 </CALCID>
773 [[from sml: <FORMHEADS>
774 [[from sml: <CALCFORMULA>
775 [[from sml: <POSITION>
776 [[from sml: <INTLIST>
777 [[from sml: </INTLIST>
778 [[from sml: <POS> Pbl </POS>
779 [[from sml: </POSITION>
780 [[from sml: <FORMULA>
782 [[from sml: <ISA> ________________________________________________ </ISA>
783 [[from sml: </MATHML>
785 [[from sml: </FORMULA>
786 [[from sml: </CALCFORMULA>
787 [[from sml: </FORMHEADS>
788 [[from sml: </GETELEMENTSFROMTO>
789 [[from sml: @@@@@end@@@@@*)
790 refFormula 1 ([],Pbl);
791 (*[[from sml: > @@@@@begin@@@@@ STILL CORRECT
793 [[from sml: <REFFORMULA>
794 [[from sml: <CALCID> 1 </CALCID>
795 [[from sml: <CALCHEAD status = "incorrect">
796 [[from sml: <POSITION>
797 [[from sml: <INTLIST>
798 [[from sml: </INTLIST>
799 [[from sml: <POS> Pbl </POS>
800 [[from sml: </POSITION>
803 [[from sml: <ISA> Problem (ThyC.id_empty, [e_pblID]) </ISA>
804 [[from sml: </MATHML>
807 [[from sml: <GIVEN> </GIVEN>
808 [[from sml: <WHERE> </WHERE>
809 [[from sml: <FIND> </FIND>
810 [[from sml: <RELATE> </RELATE>
812 [[from sml: <BELONGSTO> Pbl </BELONGSTO>
813 [[from sml: <SPECIFICATION>
814 [[from sml: <THEORYID> ThyC.id_empty </THEORYID>
815 [[from sml: <PROBLEMID>
816 [[from sml: <STRINGLIST>
817 [[from sml: <STRING> Problem.id_empty </STRING>
818 [[from sml: </STRINGLIST>
819 [[from sml: </PROBLEMID>
820 [[from sml: <METHODID>
821 [[from sml: <STRINGLIST>
822 [[from sml: <STRING> e_metID </STRING>
823 [[from sml: </STRINGLIST>
824 [[from sml: </METHODID>
825 [[from sml: </SPECIFICATION>
826 [[from sml: </CALCHEAD>
827 [[from sml: </REFFORMULA>
828 [[from sml: @@@@@end@@@@@*)
829 moveActiveFormula 1 ([],Pbl);
830 (*[[from sml: > @@@@@begin@@@@@
832 [[from sml: <CALCITERATOR>
833 [[from sml: <CALCID> 1 </CALCID>
834 [[from sml: <POSITION>
835 [[from sml: <INTLIST>
836 [[from sml: </INTLIST>
837 [[from sml: <POS> Pbl </POS>
838 [[from sml: </POSITION>
839 [[from sml: </CALCITERATOR>
840 [[from sml: @@@@@end@@@@@*)
841 replaceFormula 1 "Simplify (1+2)";
842 (*[[from sml: > @@@@@begin@@@@@
844 [[from sml: <REPLACEFORMULA>
845 [[from sml: <CALCID> 1 </CALCID>
846 [[from sml: <CALCCHANGED>
847 [[from sml: <UNCHANGED>
848 [[from sml: <INTLIST>
849 [[from sml: </INTLIST>
850 [[from sml: <POS> Pbl </POS>
851 [[from sml: </UNCHANGED>
852 [[from sml: <DELETED>
853 [[from sml: <INTLIST>
854 [[from sml: </INTLIST>
855 [[from sml: <POS> Pbl </POS>
856 [[from sml: </DELETED>
857 [[from sml: <GENERATED>
858 [[from sml: <INTLIST>
859 [[from sml: </INTLIST>
860 [[from sml: <POS> Met </POS> DIFFERENCE: Pbl
861 [[from sml: </GENERATED>
862 [[from sml: </CALCCHANGED>
863 [[from sml: </REPLACEFORMULA>
864 [[from sml: @@@@@end@@@@@*)
865 getFormulaeFromTo 1 ([],Pbl) ([],Pbl) 0 false(* DIFFERENCE: Pbl*);
879 <ISA> Simplify (1 + 2) </ISA> WORKS !!!!!
886 getFormulaeFromTo 1 ([],Pbl) ([],Met) 0 false;
887 (*[[from sml: > @@@@@begin@@@@@
889 [[from sml: <SYSERROR>
890 [[from sml: <CALCID> 1 </CALCID>
891 [[from sml: <ERROR> error in getFormulaeFromTo </ERROR>
892 [[from sml: </SYSERROR>
893 [[from sml: @@@@@end@@@@@*)
894 (*step into getFormulaeFromTo --- bug corrected...*)
896 "--------- build fun check_err_patt ------------------------------";
897 "--------- build fun check_err_patt ------------------------------";
898 "--------- build fun check_err_patt ------------------------------";
899 val subst = [(str2term "bdv", str2term "x")]: subst;
900 val rls = norm_Rational
901 val pat = parse_patt @{theory} "(?a + ?b)/(?b + ?c) = ?a / ?c";
902 val (res, inf) = (str2term "(2 + 3)/(3 + 4)", str2term "2 / 4");
903 val (res, inf) = (str2term "(2 + 3)/(3 + 4)", str2term "1 / 2");
905 val (res', _, _, rewritten) = (*rewritten: the lhs of the pattern matches in res*)
906 rew_sub thy 1 [] e_rew_ord Rule_Set.empty false [] (HOLogic.Trueprop $ pat) res;
907 if rewritten then NONE else SOME "e_errpatID";
909 val norm_res = case rewrite_set_ (Isac()) false rls res' of
911 | SOME (norm_res, _) => norm_res
913 val norm_inf = case rewrite_set_ (Isac()) false rls inf of
915 | SOME (norm_inf, _) => norm_inf;
920 val pat = parse_patt @{theory} "(?a + ?b)/?a = ?b";
921 val (res, inf) = (str2term "(2 + 3)/2", str2term "3");
922 if check_err_patt (res, inf) subst ("errpatID", pat) rls = SOME "errpatID"
923 then () else error "error patt example1 changed";
925 val pat = parse_patt @{theory} "(?a + ?b)/(?a + ?c) = ?b / ?c";
926 val (res, inf) = (str2term "(2 + 3)/(2 + 4)", str2term "3 / 4");
927 if check_err_patt (res, inf) subst ("errpatID", pat) rls = SOME "errpatID"
928 then () else error "error patt example2 changed";
930 val pat = parse_patt @{theory} "(?a + ?b)/(?b + ?c) = ?a / ?c";
931 val (res, inf) = (str2term "(2 + 3)/(3 + 4)", str2term "2 / 4");
932 if check_err_patt (res, inf) subst ("errpatID", pat) rls = SOME "errpatID"
933 then () else error "error patt example3 changed";
935 val inf = str2term "1 / 2";
936 if check_err_patt (res, inf) subst ("errpatID", pat) rls = SOME "errpatID"
937 then () else error "error patt example3 changed";
939 "--------- build fun check_err_patt ?bdv -------------------------";
940 "--------- build fun check_err_patt ?bdv -------------------------";
941 "--------- build fun check_err_patt ?bdv -------------------------";
942 val subst = [(str2term "bdv", str2term "x")]: subst;
943 val t = str2term "d_d x (x ^^^ 2 + sin (x ^^^ 4))";
944 val SOME (t, _) = rewrite_set_inst_ thy false subst norm_diff t;
945 if UnparseC.term t = "2 * x + cos (x ^^^ 4) * 4 * x ^^^ 3" then ()
946 else error "build fun check_err_patt ?bdv changed 1";
949 val pat = parse_patt @{theory} "d_d ?bdv (sin ?u) = cos (d_d ?bdv ?u)";
950 val (res, inf) = (str2term "2 * x + d_d x (sin (x ^^^ 4))", str2term "2 * x + cos (4 * x ^^^ 3)");
952 val (res', _, _, rewritten) = (*rewritten: the lhs of the pattern matches in res*)
953 rew_sub thy 1 subst e_rew_ord Rule_Set.empty false [] (HOLogic.Trueprop $ pat) res;
954 if UnparseC.term res' = "2 * x + cos (d_d x (x ^^^ 4))" andalso rewritten then ()
955 else error "build fun check_err_patt ?bdv changed 2";
957 val norm_res = case rewrite_set_inst_ (Isac()) false subst rls res' of
959 | SOME (norm_res, _) => norm_res;
960 if UnparseC.term norm_res = "2 * x + cos (4 * x ^^^ 3)" then ()
961 else error "build fun check_err_patt ?bdv changed 3";
963 val norm_inf = case rewrite_set_inst_ (Isac()) false subst rls inf of
965 | SOME (norm_inf, _) => norm_inf;
966 if UnparseC.term norm_inf = "2 * x + cos (4 * x ^^^ 3)" then ()
967 else error "build fun check_err_patt ?bdv changed 4";
970 if norm_res = norm_inf then ()
971 else error "build fun check_err_patt ?bdv changed 5";
973 if check_err_patt (res, inf) (subst: subst) ("errpatID": errpatID, pat) rls = SOME "errpatID"
974 then () else error "error patt example1 changed";
976 "--------- build fun Error_Pattern.check_for ------------------------";
977 "--------- build fun Error_Pattern.check_for ------------------------";
978 "--------- build fun Error_Pattern.check_for ------------------------";
980 (str2term "d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))",
981 str2term "d_d x (x ^^^ 2) + cos (4 * x ^^^ 3)");
982 val {errpats, nrls = rls, scr = Prog prog, ...} = get_met ["diff", "differentiate_on_R"]
984 val env = [(str2term "v_v", str2term "x")];
986 [e_errpat, (*generalised for testing*)
987 ("chain-rule-diff-both",
988 [parse_patt @{theory} "d_d ?bdv (sin ?u) = cos (d_d ?bdv ?u)",
989 parse_patt @{theory} "d_d ?bdv (cos ?u) = - sin (d_d ?bdv ?u)",
990 parse_patt @{theory} "d_d ?bdv (?u ^^^ ?n) = ?n * ?u ^^^ (?n - 1)",
991 parse_patt @{theory} "d_d ?bdv (LogExp.ln ?u) = 1 / ?u",
992 parse_patt @{theory} "d_d ?bdv (LogExp.ln ?u) = 1 / d_d ?bdv ?u"],
993 [@{thm diff_sin_chain}, @{thm diff_cos_chain}, @{thm diff_pow_chain},
994 @{thm diff_ln_chain}, @{thm diff_exp_chain}])]: errpat list;
995 case Error_Pattern.check_for (res, inf) (prog, env) (errpats, rls) of SOME _ => ()
996 | NONE => error "Error_Pattern.check_for broken";
999 "--------- embed fun Error_Pattern.check_for ------------------------";
1000 "--------- embed fun Error_Pattern.check_for ------------------------";
1001 "--------- embed fun Error_Pattern.check_for ------------------------";
1004 [(["functionTerm (x ^ 2 + sin (x ^ 4))", "differentiateFor x", "derivative f_f'"],
1005 ("Isac_Knowledge", ["derivative_of","function"], ["diff","differentiate_on_R"]))];
1008 autoCalculate 1 CompleteCalcHead;
1009 autoCalculate 1 (Steps 1);
1010 autoCalculate 1 (Steps 1);(*([1], Res), d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))*)
1011 (*autoCalculate 1 (Steps 1);([2], Res), d_d x (x ^^^ 2) + cos (x ^^^ 4) * d_d x (x ^^^ 4)*)
1013 "~~~~~ fun appendFormula , args:"; val (cI, (ifo:TermC.as_string)) = (1, "d_d x (x ^ 2) + cos (4 * x ^ 3)");
1014 "~~~~~ fun appendFormula' , args:"; val (cI, (ifo: TermC.as_string)) = (cI, ifo);
1015 val cs = get_calc cI
1016 val pos = get_pos cI 1;
1017 (*+*)if pos = ([1], Res) then () else error "inform with (positive) Error_Pattern.check_for broken 1";
1018 val ("ok", cs' as (_, _, ptp)) = (*case*) Step.do_next pos cs (*of*);
1019 (*case*) Step_Solve.by_term ptp (encode ifo) (*of*); (*ERROR WAS: "no derivation found"*)
1020 "~~~~~ fun Step_Solve.by_term , args:"; val (((*next_*)cs as (_, _, (pt, pos as (p, _))): Chead.calcstate'), istr)
1021 = (cs', (encode ifo));
1022 val ctxt = get_ctxt pt pos (*see TODO.thy*)
1023 val SOME f_in = (*case*) TermC.parse (ThyC.get_theory "Isac_Knowledge") istr (*of*);
1024 val f_in = Thm.term_of f_in
1025 val pos_pred = lev_back' pos
1026 val f_pred = Ctree.get_curr_formula (pt, pos_pred);
1027 (*if*) f_pred = f_in; (*else*)
1028 val NONE = (*case*) In_Chead.cas_input f_in (*of*);
1029 (*old* )val (_, _, metID) = get_obj g_spec pt (par_pblobj pt p)
1030 (*old*)val {scr = prog, ...} = Specify.get_met metID
1031 (*old*)val istate = get_istate_LI pt pos
1032 (*old*)val ctxt = get_ctxt pt pos
1034 val LI.Not_Derivable =
1035 (*case*) LI.locate_input_term (pt, pos) f_in (*of*);
1036 val pp = Ctree.par_pblobj pt p
1037 val (errpats, nrls, prog) = case Specify.get_met (Ctree.get_obj Ctree.g_metID pt pp) of
1038 {errpats, nrls, scr = Rule.Prog prog, ...} => (errpats, nrls, prog)
1039 | _ => error "inform: uncovered case of get_met"
1041 (*+*)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\"]]"
1042 (*+*)then () else error "inform with (positive) Error_Pattern.check_for broken 3";
1044 val {env, ...} = Ctree.get_istate_LI pt pos |> Istate.the_pstate
1046 (*+*)if UnparseC.term f_pred = "d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))" andalso
1047 (*+*) UnparseC.term f_in = "d_d x (x ^^^ 2) + cos (4 * x ^^^ 3)"
1048 (*+*)then () else error "inform with (positive) Error_Pattern.check_for broken 2";
1050 val SOME "chain-rule-diff-both" = (*case*) Error_Pattern.Error_Pattern.check_for (f_pred, f_in) (prog, env) (errpats, nrls) (*of*);
1053 (*+*)val (_, _, ptp') = cs';
1054 case Step_Solve.by_term ptp' (encode ifo) of
1055 ("error pattern #chain-rule-diff-both#", calcstate') => ()
1056 | _ => error "inform with (positive) Error_Pattern.check_for broken"
1059 "--------- embed fun find_fillpatterns ---------------------------";
1060 "--------- embed fun find_fillpatterns ---------------------------";
1061 "--------- embed fun find_fillpatterns ---------------------------";
1064 [(["functionTerm (x ^ 2 + sin (x ^ 4))", "differentiateFor x", "derivative f_f'"],
1065 ("Isac_Knowledge", ["derivative_of","function"], ["diff","differentiate_on_R"]))];
1068 autoCalculate 1 CompleteCalcHead;
1069 autoCalculate 1 (Steps 1);
1070 autoCalculate 1 (Steps 1);(*([1], Res), d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))*)
1071 appendFormula 1 "d_d x (x ^ 2) + cos (4 * x ^ 3)" (*|> Future.join*);
1072 (*<CALCMESSAGE> error pattern #chain-rule-diff-both# </CALCMESSAGE>*)
1074 <CALCMESSAGE> no derivation found </CALCMESSAGE>*)
1076 "~~~~~ fun findFillpatterns, args:"; val (cI, errpatID) = (1, "chain-rule-diff-both");
1077 val ((pt, _), _) = get_calc cI
1078 val pos = get_pos cI 1;
1079 "~~~~~ fun find_fillpatterns , args:"; val ((pt, pos as (p, _)), errpatID) = ((pt, pos), errpatID);
1080 val f_curr = Ctree.get_curr_formula (pt, pos);
1081 val pp = Ctree.par_pblobj pt p
1082 val (errpats, prog) = case Specify.get_met (Ctree.get_obj Ctree.g_metID pt pp) of
1083 {errpats, scr = Rule.Prog prog, ...} => (errpats, prog)
1084 | _ => error "find_fillpatterns: uncovered case of get_met"
1085 val {env, ...} = Ctree.get_istate_LI pt pos |> Istate.the_pstate
1086 val subst = Rtools.get_bdv_subst prog env
1087 val errpatthms = errpats
1088 |> filter ((curry op = errpatID) o (#1: errpat -> errpatID))
1089 |> map (#3: errpat -> thm list)
1092 case map (get_fillpats subst f_curr errpatID) errpatthms |> flat of
1093 ("fill-d_d-arg", tm, thm, subs_opt) :: _ => if UnparseC.term tm =
1094 "d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4)) =\nd_d x (x ^^^ 2) + cos (x ^^^ 4) * d_d x ?_dummy_1"
1095 then () else error "find_fillpatterns changed 1a"
1096 | _ => error "find_fillpatterns changed 1b"
1098 "~~~~~ fun get_fillpats, args:"; val (subst, form, errpatID, thm) =
1099 (subst, f_curr, errpatID, hd (*simulate beginning of "map"*) errpatthms);
1100 val thmDeriv = Thm.get_name_hint thm
1101 val (part, thyID) = thy_containing_thm thmDeriv
1102 val theID = [part, thyID, "Theorems", ThmC.cut_id thmDeriv]
1103 val Hthm {fillpats, ...} = get_the theID
1104 val some = map (get_fillform subst (thm, form) errpatID) fillpats;
1106 case some |> filter is_some |> map the of
1107 ("fill-d_d-arg", tm, thm, subsopt) :: _ => if UnparseC.term tm =
1108 "d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4)) =\nd_d x (x ^^^ 2) + cos (x ^^^ 4) * d_d x ?_dummy_1"
1109 then () else error "find_fillpatterns changed 2a"
1110 | _ => error "find_fillpatterns changed 2b"
1112 "~~~~~ fun get_fillform, args:";
1113 val ((subs_opt, subst), (thm, form), errpatID, (fillpatID, pat, erpaID)) =
1114 (subst, (thm, form), errpatID, hd (*simulate beginning of "map"*) fillpats);
1115 val (form', _, _, rewritten) =
1116 rew_sub (Isac()) 1 subst e_rew_ord Rule_Set.empty false [] (HOLogic.Trueprop $ pat) form;
1118 if UnparseC.term form' = "d_d x (x ^^^ 2) + cos (x ^^^ 4) * d_d x ?_dummy_1" then ()
1119 else error "find_fillpatterns changed 3";
1121 "~~~~~ to findFillpatterns return val:"; val (fillpats) =
1122 (map (get_fillpats (subs_opt, subst) f_curr errpatID) errpatthms |> flat) (*only from "hd errpatthms"*);
1124 "vvv--- dropped this code WN120730";
1125 val msg = "fill patterns " ^
1126 ((map ((apsnd UnparseC.term) o quad2pair) fillpats) |> map pair2str_ |> strs2str_);
1128 "fill patterns #fill-d_d-arg#d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))" ^
1129 " =\nd_d x (x ^^^ 2) + cos (x ^^^ 4) * d_d x ?_dummy_1" ^
1130 "#fill-both-args#d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))" ^
1131 " =\nd_d x (x ^^^ 2) + cos ?_dummy_2 * d_d x ?_dummy_3" ^
1132 "#fill-d_d#d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))" ^
1133 " =\nd_d x (x ^^^ 2) + cos (x ^^^ 4) * ?_dummy_1 x (x ^^^ 4)" ^
1134 "#fill-inner-deriv#d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))" ^
1135 " =\nd_d x (x ^^^ 2) + cos (x ^^^ 4) * ?_dummy_1" ^
1136 "#fill-all#d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4)) = d_d x (x ^^^ 2) + ?_dummy_1#";
1137 "^^^--- dropped this code WN120730";
1139 if (map #1 fillpats) =
1140 ["fill-d_d-arg", "fill-both-args", "fill-d_d", "fill-inner-deriv", "fill-all"]
1141 then () else error "find_fillpatterns changed 4b";
1144 "--------- build fun is_exactly_equal, inputFillFormula ----------";
1145 "--------- build fun is_exactly_equal, inputFillFormula ----------";
1146 "--------- build fun is_exactly_equal, inputFillFormula ----------";
1149 [(["functionTerm (x ^ 2 + sin (x ^ 4))", "differentiateFor x", "derivative f_f'"],
1150 ("Isac_Knowledge", ["derivative_of","function"], ["diff","differentiate_on_R"]))];
1153 autoCalculate 1 CompleteCalcHead;
1154 autoCalculate 1 (Steps 1);
1155 autoCalculate 1 (Steps 1);(*([1], Res), d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))*)
1156 appendFormula 1 "d_d x (x ^ 2) + cos (4 * x ^ 3)" (*|> Future.join*); (*<<<<<<<=========================*)
1157 (* the check for errpat is maximally liberal (whole term modulo "nrls" from "type met"),
1158 would recognize "cos (4 * x ^ (4 - 1)) + 2 * x" as well.
1159 results in <CALCMESSAGE> error pattern #chain-rule-diff-both# </CALCMESSAGE>
1160 instead of <CALCMESSAGE> no derivation found </CALCMESSAGE> *)
1161 val ((pt,pos), _) = get_calc 1;
1162 val p = get_pos 1 1;
1163 val (Form f, _, asms) = pt_extract (pt, p);
1165 if p = ([1], Res) andalso UnparseC.term f = "d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))" then
1166 case get_obj g_tac pt (fst p) of Rewrite_Inst (["(''bdv'', x)"],
1167 ("diff_sum", thm)) =>
1168 if (UnparseC.term o Thm.prop_of) thm = "d_d ?bdv (?u + ?v) = d_d ?bdv ?u + d_d ?bdv ?v" then ()
1169 else error "embed fun get_fillform changed 11"
1170 | _ => error "embed fun get_fillform changed 12"
1171 else error "embed fun get_fillform changed 13";
1173 findFillpatterns 1 "chain-rule-diff-both"; (*<<<<<<<=================================*)
1174 (*<CALCMESSAGE> fill patterns #fill-d_d-arg#d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4)) =
1175 d_d x (x ^^^ 2) + cos (x ^^^ 4) * d_d x ?_dummy_1#fill-both-args#...#...#... *)
1176 val ((pt,pos),_) = get_calc 1;
1177 val p = get_pos 1 1;
1179 val (Form f, _, asms) = pt_extract (pt, p);
1180 if p = ([1], Res) andalso UnparseC.term f = "d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))" then
1181 case get_obj g_tac pt (fst p) of Rewrite_Inst (["(''bdv'', x)"],
1182 ("diff_sum", thm)) =>
1183 if (UnparseC.term o Thm.prop_of) thm = "d_d ?bdv (?u + ?v) = d_d ?bdv ?u + d_d ?bdv ?v" then ()
1184 else error "embed fun get_fillform changed 21"
1185 | _ => error "embed fun get_fillform changed 22"
1186 else error "embed fun get_fillform changed 23";
1188 requestFillformula 1 ("chain-rule-diff-both", "fill-both-args");(*<<<<<<<============*)
1189 (*<AUTOCALC> ([1], Res) ([2], Res) ([2], Res) </AUTOCALC>*)
1190 val ((pt,pos),_) = get_calc 1;
1191 val p = get_pos 1 1;
1192 val (Form f, _, asms) = pt_extract (pt, p);
1193 if p = ([1], Res) andalso existpt [2] pt
1194 andalso UnparseC.term f = "d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))"
1195 then case get_obj g_tac pt (fst p) of Rewrite_Inst (["(''bdv'', x)"],
1196 ("diff_sum", thm)) =>
1197 if (UnparseC.term o Thm.prop_of) thm = "d_d ?bdv (?u + ?v) = d_d ?bdv ?u + d_d ?bdv ?v" then ()
1198 else error "embed fun get_fillform changed 31"
1199 | _ => error "embed fun get_fillform changed 32"
1200 else error "embed fun get_fillform changed 33";
1202 (* input a formula which exactly fills the gaps in a "fillformula"
1203 presented to the learner immediately before by "requestFillformula (errpatID, fillpatID)":
1204 errpatID: lhs of the respective thm = lhs of fillformula with fillpatID.
1205 the respective thm is in the ctree ................
1207 "~~~~~ fun inputFillFormula, args:"; val (cI, ifo) =
1208 (1, "d_d x (x ^^^ 2) + cos (x ^^^ 4) * d_d x (x ^^^ 4)");
1209 val ((pt, _), _) = get_calc cI
1210 val pos = get_pos cI 1;
1212 "~~~~~ fun is_exactly_equal, args:"; val ((pt, pos as (p, p_)), istr) = ((pt, pos), ifo);
1213 val SOME ifo = parseNEW (ThyC.get_theory "Isac_Knowledge" |> ThyC.to_ctxt) istr
1215 val tac = get_obj g_tac pt p';
1216 val Rewrite_Inst ([bbb as "(''bdv'', x)"], ("diff_sin_chain", ttt)) = tac;
1217 if (UnparseC.term o Thm.prop_of) ttt = "d_d ?bdv (sin ?u) = cos ?u * d_d ?bdv ?u" then ()
1218 else error "inputFillFormula changed 10";
1219 val Appl rew = applicable_in pos pt tac;
1220 val Rewrite_Inst' (_, _, _, _, _, _, _, (res, _)) = rew;
1222 "~~~~~ to inputFillFormula return val:"; val ("ok", tac) = ("ok", tac);
1223 val ("ok", (_, c, ptp as (_,p'))) = Step.by_tactic tac (pt, pos);
1224 upd_calc cI (ptp, []);
1226 autocalculateOK2xml cI pos (if null c then p' else last_elem c) p';
1228 "~~~~~ final check:";
1229 val ((pt, _),_) = get_calc 1;
1230 val p = get_pos 1 1;
1231 val (Form f, _, asms) = pt_extract (pt, p);
1232 if p = ([2], Res) andalso UnparseC.term f = "d_d x (x ^^^ 2) + cos (x ^^^ 4) * d_d x (x ^^^ 4)"
1233 then case get_obj g_tac pt (fst p) of Rewrite_Inst (["(''bdv'', x)"],
1234 ("diff_sin_chain", thm)) =>
1235 if (UnparseC.term o Thm.prop_of) thm = "d_d ?bdv (sin ?u) = cos ?u * d_d ?bdv ?u" then ()
1236 else error "inputFillFormula changed 111"
1237 | _ => error "inputFillFormula changed 112"
1238 else error "inputFillFormula changed 113";
1240 "--------- fun appl_adds -----------------------------------------";
1241 "--------- fun appl_adds -----------------------------------------";
1242 "--------- fun appl_adds -----------------------------------------";
1243 (* val (dI, oris, ppc, pbt, selct::ss) =
1244 (dI, pors, probl, ppc, map itms2fstr probl);
1247 (* val (dI, oris, ppc, pbt, (selct::ss))=
1248 (#1 (some_spec ospec spec), oris, []:itm list,
1249 ((#ppc o get_pbt) (#2 (some_spec ospec spec))),(imodel2fstr imodel));
1250 val iii = appl_adds dI oris ppc pbt (selct::ss);
1251 tracing(itms2str_ thy iii);
1253 val itm = appl_add' dI oris ppc pbt selct;
1254 val ppc = insert_ppc' itm ppc;
1256 val _::selct::ss = (selct::ss);
1257 val itm = appl_add' dI oris ppc pbt selct;
1258 val ppc = insert_ppc' itm ppc;
1260 val _::selct::ss = (selct::ss);
1261 val itm = appl_add' dI oris ppc pbt selct;
1262 val ppc = insert_ppc' itm ppc;
1263 tracing(itms2str_ thy ppc);
1265 val _::selct::ss = (selct::ss);
1266 val itm = appl_add' dI oris ppc pbt selct;
1267 val ppc = insert_ppc' itm ppc;
1269 "--------- fun concat_deriv --------------------------------------";
1270 "--------- fun concat_deriv --------------------------------------";
1271 "--------- fun concat_deriv --------------------------------------";
1273 val ({rew_ord, erls, rules,...}, fo, ifo) =
1274 (Rule_Set.rep Test_simplify, str2term "x+1+ -1*2=0", str2term "-2*1+(x+1)=0");
1275 (tracing o Derive.trtas2str) fod';
1277 (x + 1 + -1 * 2 = 0, Thm ("radd_commute","?m + ?n = ?n + ?m"), (-1 * 2 + (x + 1) = 0, []))","
1278 (-1 * 2 + (x + 1) = 0, Thm ("radd_commute","?m + ?n = ?n + ?m"), (-1 * 2 + (1 + x) = 0, []))","
1279 (-1 * 2 + (1 + x) = 0, Thm ("radd_left_commute","?x + (?y + ?z) = ?y + (?x + ?z)"), (1 + (-1 * 2 + x) = 0, []))","
1280 (1 + (-1 * 2 + x) = 0, Thm ("#mult_Float ((~1,0), (0,0)) __ ((2,0), (0,0))","-1 * 2 = -2"), (1 + (-2 + x) = 0, []))"]
1282 (tracing o Derive.trtas2str) (map Derive.rev_deriv' rifod');
1284 (1 + (-2 + x) = 0, Thm ("sym_#mult_Float ((~2,0), (0,0)) __ ((1,0), (0,0))","-2 = -2 * 1"), (1 + (-2 * 1 + x) = 0, []))","
1285 (1 + (-2 * 1 + x) = 0, Thm ("sym_radd_left_commute","?y + (?x + ?z) = ?x + (?y + ?z)"), (-2 * 1 + (1 + x) = 0, []))","
1286 (-2 * 1 + (1 + x) = 0, Thm ("sym_radd_commute","?n + ?m = ?m + ?n"), (-2 * 1 + (x + 1) = 0, []))"]
1289 "--------- handle an input formula -------------------------------";
1290 "--------- handle an input formula -------------------------------";
1291 "--------- handle an input formula -------------------------------";
1293 Untersuchung zur Formeleingabe (appendFormula, replaceFormla) zu einer Anregung von Alan Krempler:
1294 Welche RICHTIGEN Formeln koennen NICHT abgeleitet werden,
1295 wenn Abteilungen nur auf gleichem Level gesucht werden ?
1298 Beispiele zum Equationsolver von Richard Lang aus /src/sml/kbtest/rlang.sml
1300 ------------------------------------------------------------------------------
1301 "Schalk I s.87 Bsp 52a ((5*x)/(x - 2) - x/(x+2)=4)";
1302 ------------------------------------------------------------------------------
1303 1. "5 * x / (x - 2) - x / (x + 2) = 4"
1305 4. "12 * x + 4 * x ^^^ 2 = 4 * (-4 + x ^^^ 2)",Subproblem["normalise", "poly"..
1307 4.3. "16 + 12 * x = 0", Subproblem["degree_1", "polynomial", "univariate"..
1309 4.3.3. "[x = -4 / 3]")), Check_elementwise "Assumptions"
1312 ------------------------------------------------------------------------------
1313 (1)..(6): keine 'richtige' Eingabe kann abgeleitet werden, die einen Summanden auf die andere Seite verschiebt [Ableitung ware in 4.3.n]
1315 (4.1)..(4.3): keine 'richtige' Eingabe kann abgeleitet werden, die einen Summanden auf die andere Seite verschiebt [Ableitung ware in 4.3.n]
1316 ------------------------------------------------------------------------------
1319 ------------------------------------------------------------------------------
1320 "Schalk I s.87 Bsp 55b (x/(x^^^2 - 6*x+9) - 1/(x^^^2 - 3*x) =1/x)";
1321 ------------------------------------------------------------------------------
1322 1. "x / (x ^^^ 2 - 6 * x + 9) - 1 / (x ^^^ 2 - 3 * x) = 1 / x"
1324 4. "(3 + (-1 * x + x ^^^ 2)) * x = 1 * (9 * x + (x ^^^ 3 + -6 * x ^^^ 2))"
1325 Subproblem["normalise", "polynomial", "univariate"..
1327 4.4. "-6 * x + 5 * x ^^^ 2 = 0", Subproblem["bdv_only", "degree_2", "poly"..
1329 4.4.4. "[x = 0, x = 6 / 5]", Check_elementwise "Assumptions"
1330 4.4.5. "[x = 0, x = 6 / 5]"
1332 5. "[x = 0, x = 6 / 5]", Check_elementwise "Assumptions"
1334 ------------------------------------------------------------------------------
1335 (1)..(4): keine 'richtige' Eingabe kann abgeleitet werden, die einen Summanden auf die andere Seite schiebt [Ableitung waere in 4.4.x]
1337 (4.1)..(4.4.5): keine 'richtige' Eingabe kann abgeleitet werden, die dem Ergebnis "[x = 6 / 5]" aequivalent ist [Ableitung waere in 5.]
1338 ------------------------------------------------------------------------------
1341 ------------------------------------------------------------------------------
1342 "Schalk II s.56 Bsp 73b (sqrt(x+1)+sqrt(4*x+4)=sqrt(9*x+9))";
1343 ------------------------------------------------------------------------------
1344 1. "sqrt (x + 1) + sqrt (4 * x + 4) = sqrt (9 * x + 9)"
1346 6. "13 + 13 * x + -2 * sqrt ((4 + 4 * x) * (9 + 9 * x)) = 1 + x"
1347 Subproblem["sq", "rootX", "univariate", "equation"]
1349 6.6. "144 + 288 * x + 144 * x ^^^ 2 = 144 + x ^^^ 2 + 288 * x + 143 * x ^^^ 2"
1350 Subproblem["normalise", "polynomial", "univariate", "equation"]
1352 6.6.3 "0 = 0" Subproblem["degree_0", "polynomial", "univariate", "equation"]
1354 6.6.3.2 "UniversalList"
1355 ------------------------------------------------------------------------------
1356 (1)..(6): keine 'richtige' Eingabe kann abgeleitet werden, die eine der Wurzeln auf die andere Seite verschieb [Ableitung ware in 6.6.n]
1358 (6.1)..(6.3): keine 'richtige' Eingabe kann abgeleitet werden, die einen Summanden auf die andere Seite verschiebt [Ableitung ware in 6.6.n]
1359 ------------------------------------------------------------------------------
1361 (*sh. comments auf 498*)
1362 "--------- fun dropwhile' ----------------------------------------";
1363 "--------- fun dropwhile' ----------------------------------------";
1364 "--------- fun dropwhile' ----------------------------------------";
1366 fun equal a b = a=b;
1367 val foder = [0,1,2,3,4,5]; val ifoder = [11,12,3,4,5];
1368 val r_foder = rev foder; val r_ifoder = rev ifoder;
1369 dropwhile' equal r_foder r_ifoder;
1370 > vval it = ([0, 1, 2, 3], [3, 12, 11]) : int list * int list
1372 val foder = [3,4,5]; val ifoder = [11,12,3,4,5];
1373 val r_foder = rev foder; val r_ifoder = rev ifoder;
1374 dropwhile' equal r_foder r_ifoder;
1375 > val it = ([3], [3, 12, 11]) : int list * int list
1377 val foder = [5]; val ifoder = [11,12,3,4,5];
1378 val r_foder = rev foder; val r_ifoder = rev ifoder;
1379 dropwhile' equal r_foder r_ifoder;
1380 > val it = ([5], [5, 4, 3, 12, 11]) : int list * int list
1382 val foder = [10,11,12,13,14,15]; val ifoder = [11,12,3,4,5];
1383 val r_foder = rev foder; val r_ifoder = rev ifoder;
1384 dropwhile' equal r_foder r_ifoder;
1385 > *** dropwhile': did not start with equal elements*)