1 (* Title: "Interpret/error-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_for' ------------------------------";
33 "--------- build fun check_for' ?bdv -------------------------";
34 "--------- build fun check_for ------------------------";
35 "--------- embed fun check_for ------------------------";
36 "--------- embed fun find_fill_patterns ---------------------------";
37 "--------- build fun is_exactly_equal, inputFillFormula ----------";
38 "--------- fun appl_adds -----------------------------------------";
39 "--------- fun concat_deriv --------------------------------------";
40 "--------- handle an input formula -------------------------------";
41 "--------- fun dropwhile' ----------------------------------------";
42 "-----------------------------------------------------------------";
43 "-----------------------------------------------------------------";
44 "-----------------------------------------------------------------";
47 "--------- appendFormula: on Res + equ_nrls ----------------------";
48 "--------- appendFormula: on Res + equ_nrls ----------------------";
49 "--------- appendFormula: on Res + equ_nrls ----------------------";
50 val Prog sc = (#scr o Method.from_store) ["Test","squ-equ-test-subpbl1"];
51 (writeln o UnparseC.term) sc;
52 val Prog sc = (#scr o Method.from_store) ["Test","solve_linear"];
53 (writeln o UnparseC.term) sc;
56 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
57 ("Test", ["sqroot-test","univariate","equation","test"],
58 ["Test","squ-equ-test-subpbl1"]))];
59 Iterator 1; moveActiveRoot 1;
60 autoCalculate 1 CompleteCalcHead;
61 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
62 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
64 appendFormula 1 "-2 * 1 + (1 + x) = 0" (*|> Future.join*); refFormula 1 (get_pos 1 1);
65 val ((pt,_),_) = get_calc 1;
66 val str = pr_ctree pr_short pt;
68 (". ----- pblobj -----\n" ^
70 "2. x + 1 + -1 * 2 = 0\n" ^
71 "2.1. x + 1 + -1 * 2 = 0\n" ^
72 "2.2. 1 + x + -1 * 2 = 0\n" ^
73 "2.3. 1 + (x + -1 * 2) = 0\n" ^
74 "2.4. 1 + (x + -2) = 0\n" ^
75 "2.5. 1 + (x + -2 * 1) = 0\n" ^
76 "2.6. 1 + x + -2 * 1 = 0\n" ) then ()
77 else error "inform.sml: diff.behav.appendFormula: on Res + equ 1";
79 moveDown 1 ([ ],Pbl); refFormula 1 ([1],Frm); (*x + 1 = 2*)
80 moveDown 1 ([1],Frm); refFormula 1 ([1],Res); (*x + 1 + -1 * 2 = 0*)
82 (*the seven steps of detailed derivation*)
83 moveDown 1 ([1 ],Res); refFormula 1 ([2,1],Frm);
84 moveDown 1 ([2,1],Frm); refFormula 1 ([2,1],Res);
85 moveDown 1 ([2,1],Res); refFormula 1 ([2,2],Res);
86 moveDown 1 ([2,2],Res); refFormula 1 ([2,3],Res);
87 moveDown 1 ([2,3],Res); refFormula 1 ([2,4],Res);
88 moveDown 1 ([2,4],Res); refFormula 1 ([2,5],Res);
89 moveDown 1 ([2,5],Res); refFormula 1 ([2,6],Res);
90 val ((pt,_),_) = get_calc 1;
91 if "-2 * 1 + (1 + x) = 0" = UnparseC.term (fst (get_obj g_result pt [2,6])) then()
92 else error "inform.sml: diff.behav.appendFormula: on Res + equ 2";
94 fetchProposedTactic 1; (*takes Iterator 1 _1_*)
95 (* <ERROR> error in kernel </ERROR> ALREADY IN 2009-2*)
96 (*========== inhibit exn WN1130701 broken at Isabelle2002 --> 2009-2 =============
97 val (_,(tac,_,_)::_) = get_calc 1;
98 if tac = Rewrite_Set "Test_simplify" then ()
99 else error "inform.sml: diff.behav.appendFormula: on Res + equ 3";
100 ============ inhibit exn WN1130701 broken at Isabelle2002 --> 2009-2 ============*)
102 autoCalculate 1 CompleteCalc;
103 val ((pt,_),_) = get_calc 1;
104 if "[x = 1]" = UnparseC.term (fst (get_obj g_result pt [])) then ()
105 else error "inform.sml: diff.behav.appendFormula: on Res + equ 4";
106 (* autoCalculate 1 CompleteCalc;
107 val ((pt,p),_) = get_calc 1;
108 (writeln o istates2str) (get_obj g_loc pt [ ]);
109 (writeln o istates2str) (get_obj g_loc pt [1]);
110 (writeln o istates2str) (get_obj g_loc pt [2]);
111 (writeln o istates2str) (get_obj g_loc pt [3]);
112 (writeln o istates2str) (get_obj g_loc pt [3,1]);
113 (writeln o istates2str) (get_obj g_loc pt [3,2]);
114 (writeln o istates2str) (get_obj g_loc pt [4]);
117 "----------------------------------------------------------";
119 val fod = Derive.do_one (@{theory "Isac_Knowledge"}) Atools_erls
120 ((#rules o Rule_Set.rep) Test_simplify)
121 (sqrt_right false (@{theory "Pure"})) NONE
122 (str2term "x + 1 + -1 * 2 = 0");
123 (writeln o Derive.trtas2str) fod;
125 val ifod = Derive.do_one (@{theory "Isac_Knowledge"}) Atools_erls
126 ((#rules o Rule_Set.rep) Test_simplify)
127 (sqrt_right false (@{theory "Pure"})) NONE
128 (str2term "-2 * 1 + (1 + x) = 0");
129 (writeln o Derive.trtas2str) ifod;
130 fun equal (_,_,(t1, _)) (_,_,(t2, _)) = t1 = t2;
131 val (fod', rifod') = dropwhile' equal (rev fod) (rev ifod);
132 val der = fod' @ (map Derive.rev_deriv' rifod');
133 (writeln o Derive.trtas2str) der;
134 "----------------------------------------------------------";
137 "--------- appendFormula: on Frm + equ_nrls ----------------------";
138 "--------- appendFormula: on Frm + equ_nrls ----------------------";
139 "--------- appendFormula: on Frm + equ_nrls ----------------------";
141 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
142 ("Test", ["sqroot-test","univariate","equation","test"],
143 ["Test","squ-equ-test-subpbl1"]))];
144 Iterator 1; moveActiveRoot 1;
145 autoCalculate 1 CompleteCalcHead;
146 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1) (*x + 1 = 2*);
147 appendFormula 1 "2+ -1 + x = 2" (*|> Future.join*); refFormula 1 (get_pos 1 1);
149 moveDown 1 ([],Pbl); refFormula 1 ([1],Frm) (*x + 1 = 2*);
151 moveDown 1 ([1 ],Frm); refFormula 1 ([1,1],Frm);
152 moveDown 1 ([1,1],Frm); refFormula 1 ([1,1],Res);
153 moveDown 1 ([1,1],Res); refFormula 1 ([1,2],Res);
154 moveDown 1 ([1,2],Res); refFormula 1 ([1,3],Res);
155 moveDown 1 ([1,3],Res); refFormula 1 ([1,4],Res);
156 moveDown 1 ([1,4],Res); refFormula 1 ([1,5],Res);
157 moveDown 1 ([1,5],Res); refFormula 1 ([1,6],Res);
158 val ((pt,_),_) = get_calc 1;
159 if "2 + -1 + x = 2" = UnparseC.term (fst (get_obj g_result pt [1,6])) then()
160 else error "inform.sml: diff.behav.appendFormula: on Frm + equ 1";
162 fetchProposedTactic 1; (*takes Iterator 1 _1_*)
163 val (_,(tac,_,_)::_) = get_calc 1;
164 case tac of Rewrite_Set "norm_equation" => ()
165 | _ => error "inform.sml: diff.behav.appendFormula: on Frm + equ 2";
166 autoCalculate 1 CompleteCalc;
167 val ((pt,_),_) = get_calc 1;
168 if "[x = 1]" = UnparseC.term (fst (get_obj g_result pt [])) then ()
169 else error "inform.sml: diff.behav.appendFormula: on Frm + equ 3";
172 "--------- appendFormula: on Res + NO deriv ----------------------";
173 "--------- appendFormula: on Res + NO deriv ----------------------";
174 "--------- appendFormula: on Res + NO deriv ----------------------";
176 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
177 ("Test", ["sqroot-test","univariate","equation","test"],
178 ["Test","squ-equ-test-subpbl1"]))];
179 Iterator 1; moveActiveRoot 1;
180 autoCalculate 1 CompleteCalcHead;
181 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
182 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
184 appendFormula 1 "x = 2" (*|> Future.join*);
185 val ((pt,p),_) = get_calc 1;
186 val str = pr_ctree pr_short pt;
188 if str = ". ----- pblobj -----\n1. x + 1 = 2\n" andalso p = ([1], Res)
190 else error "inform.sml: diff.behav.appendFormula: Res + NOder 1";
192 fetchProposedTactic 1;
193 val (_,(tac,_,_)::_) = get_calc 1;
194 case tac of Rewrite_Set "Test_simplify" => ()
195 | _ => error "inform.sml: diff.behav.appendFormula: Res + NOder 2";
196 autoCalculate 1 CompleteCalc;
197 val ((pt,_),_) = get_calc 1;
198 if "[x = 1]" = UnparseC.term (fst (get_obj g_result pt [])) then ()
199 else error "inform.sml: diff.behav.appendFormula: on Frm + equ 3";
202 "--------- appendFormula: on Res + late deriv --------------------";
203 "--------- appendFormula: on Res + late deriv --------------------";
204 "--------- appendFormula: on Res + late deriv --------------------";
205 (*cp with "fun me" to test/../lucas-interpreter.sml:
206 re-build: fun locate_input_term ---------------------------------------------------";
209 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
210 ("Test", ["sqroot-test","univariate","equation","test"],
211 ["Test","squ-equ-test-subpbl1"]))];
212 Iterator 1; moveActiveRoot 1;
213 autoCalculate 1 CompleteCalcHead;
214 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
215 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
217 appendFormula 1 "x = 1" (*|> Future.join*);
218 val ((pt,p),_) = get_calc 1;
219 val str = pr_ctree pr_short pt;
221 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)
222 then () (*finds 1 step too early: ([3,2], Res) "x = 1" also by script !!!*)
223 else error "inform.sml: diff.behav.appendFormula: Res + late d 1";
225 fetchProposedTactic 1;
226 val (_,(tac,_,_)::_) = get_calc 1;
227 case tac of Check_Postcond ["LINEAR", "univariate", "equation", "test"] => ()
228 | _ => error "inform.sml: diff.behav.appendFormula: Res + late d 2";
229 autoCalculate 1 CompleteCalc;
230 val ((pt,_),_) = get_calc 1;
231 if "[x = 1]" = UnparseC.term (fst (get_obj g_result pt [])) then ()
232 else error "inform.sml: diff.behav.appendFormula: Res + late d 3";
235 "--------- appendFormula: on Res + late deriv [x = 3 + -2]---///--";
236 "--------- appendFormula: on Res + late deriv [x = 3 + -2]---///--";
237 "--------- appendFormula: on Res + late deriv [x = 3 + -2]---///--";
239 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
240 ("Test", ["sqroot-test","univariate","equation","test"],
241 ["Test","squ-equ-test-subpbl1"]))];
242 Iterator 1; moveActiveRoot 1;
243 autoCalculate 1 CompleteCalcHead;
244 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
245 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
246 appendFormula 1 "[x = 3 + -2*1]" (*|> Future.join*);
247 val ((pt,p),_) = get_calc 1;
248 val str = pr_ctree pr_short pt;
250 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 ()
251 else error "inform.sml: diff.behav.appendFormula: Res + latEE 1";
252 autoCalculate 1 CompleteCalc;
253 val ((pt,p),_) = get_calc 1;
254 if "[x = 3 + -2 * 1]" = UnparseC.term (fst (get_obj g_result pt [])) then ()
255 (* ~~~~~~~~~~ simplify as last step in any script ?!*)
256 else error "inform.sml: diff.behav.appendFormula: Res + latEE 2";
259 "--------- replaceFormula: on Res + = ----------------------------";
260 "--------- replaceFormula: on Res + = ----------------------------";
261 "--------- replaceFormula: on Res + = ----------------------------";
263 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
264 ("Test", ["sqroot-test","univariate","equation","test"],
265 ["Test","squ-equ-test-subpbl1"]))];
266 Iterator 1; moveActiveRoot 1;
267 autoCalculate 1 CompleteCalcHead;
268 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
269 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
270 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*-1 + x*);
272 replaceFormula 1 "-2 * 1 + (1 + x) = 0"; refFormula 1 (get_pos 1 1);
273 val ((pt,_),_) = get_calc 1;
274 val str = pr_ctree pr_short pt;
276 (* before AK110725 this was
277 ". ----- pblobj -----\n
279 2. x + 1 + -1 * 2 = 0\n
280 2.1. x + 1 + -1 * 2 = 0\n
281 2.2. 1 + x + -1 * 2 = 0\n
282 2.3. 1 + (x + -1 * 2) = 0\n
283 2.4. 1 + (x + -2) = 0\n
284 2.5. 1 + (x + -2 * 1) = 0\n
285 2.6. 1 + x + -2 * 1 = 0\n";
288 ". ----- pblobj -----\n"^
290 "2. x + 1 + -1 * 2 = 0\n"^
291 "2.1. x + 1 + -1 * 2 = 0\n"^
292 "2.2. 1 + x + -1 * 2 = 0\n"^
293 "2.3. 1 + (x + -1 * 2) = 0\n"^
294 "2.4. 1 + (x + -2) = 0\n"^
295 "2.5. 1 + (x + -2 * 1) = 0\n"^
296 "2.6. 1 + x + -2 * 1 = 0\n" then()
297 else error "inform.sml: diff.behav.replaceFormula: on Res += 1";
299 autoCalculate 1 CompleteCalc;
300 val ((pt,pos as (p,_)),_) = get_calc 1;
301 if pos = ([],Res) andalso "[x = 1]" = (UnparseC.term o fst) (get_obj g_result pt p) then()
302 else error "inform.sml: diff.behav.replaceFormula: on Res + = 2";
305 "--------- replaceFormula: on Res + = 1st Nd ---------------------";
306 "--------- replaceFormula: on Res + = 1st Nd ---------------------";
307 "--------- replaceFormula: on Res + = 1st Nd ---------------------";
309 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
310 ("Test", ["sqroot-test","univariate","equation","test"],
311 ["Test","squ-equ-test-subpbl1"]))];
312 Iterator 1; moveActiveRoot 1;
313 autoCalculate 1 CompleteCalcHead;
314 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
315 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
317 replaceFormula 1 "x + 1 = 4 + -2"; refFormula 1 (get_pos 1 1);
318 val ((pt,_),_) = get_calc 1;
319 val str = pr_ctree pr_short pt;
321 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 ()
322 else error "inform.sml: diff.behav.replaceFormula: on Res 1 + = 1";
323 autoCalculate 1 CompleteCalc;
324 val ((pt,pos as (p,_)),_) = get_calc 1;
325 if pos = ([],Res) andalso "[x = 1]" = (UnparseC.term o fst)(get_obj g_result pt p) then()
326 else error "inform.sml: diff.behav.replaceFormula: on Res + = 2";
329 "--------- replaceFormula: on Frm + = 1st Nd ---------------------";
330 "--------- replaceFormula: on Frm + = 1st Nd ---------------------";
331 "--------- replaceFormula: on Frm + = 1st Nd ---------------------";
333 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
334 ("Test", ["sqroot-test","univariate","equation","test"],
335 ["Test","squ-equ-test-subpbl1"]))];
336 Iterator 1; moveActiveRoot 1;
337 autoCalculate 1 CompleteCalcHead;
338 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
340 replaceFormula 1 "x + 1 = 4 + -2"; refFormula 1 (get_pos 1 1);
341 val ((pt,_),_) = get_calc 1;
342 val str = pr_ctree pr_short pt;
344 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 ()
345 else error "inform.sml: diff.behav.replaceFormula: on Frm 1 + = 1";
346 autoCalculate 1 CompleteCalc;
347 val ((pt,pos as (p,_)),_) = get_calc 1;
348 if pos = ([],Res) andalso "[x = 1]" = (UnparseC.term o fst)(get_obj g_result pt p) then()
349 else error "inform.sml: diff.behav.replaceFormula: on Frm 1 + = 2";
352 "--------- replaceFormula: cut calculation -----------------------";
353 "--------- replaceFormula: cut calculation -----------------------";
354 "--------- replaceFormula: cut calculation -----------------------";
356 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
357 ("Test", ["sqroot-test","univariate","equation","test"],
358 ["Test","squ-equ-test-subpbl1"]))];
359 Iterator 1; moveActiveRoot 1;
360 autoCalculate 1 CompleteCalc;
361 moveActiveRoot 1; moveActiveDown 1;
362 if get_pos 1 1 = ([1], Frm) then ()
363 else error "inform.sml: diff.behav. cut calculation 1";
365 replaceFormula 1 "x + 1 = 4 + -2"; refFormula 1 (get_pos 1 1);
366 val ((pt,p),_) = get_calc 1;
367 val str = pr_ctree pr_short pt;
369 if p = ([1], Res) then ()
370 else error "inform.sml: diff.behav. cut calculation 2";
373 (* 040307 copied from informtest.sml; ... old version
374 "---------------- maximum-example, UC: Modeling / modifyCalcHead -";
375 "---------------- maximum-example, UC: Modeling / modifyCalcHead -";
376 "---------------- maximum-example, UC: Modeling / modifyCalcHead -";
379 val elems = ["fixedValues [r=Arbfix]","maximum A","valuesFor [a,b]",
380 "relations [A=a*b, (a/2)^^^2 + (b/2)^^^2 = r^^^2]",
381 "relations [A=a*b, (a/2)^^^2 + (b/2)^^^2 = r^^^2]",
382 "relations [A=a*b, a/2=r*sin alpha, b/2=r*cos (alpha::real)]",
383 (*^^^ these are the elements for the root-problem (in variants)*)
384 (*vvv these are elements required for subproblems*)
385 "boundVariable a","boundVariable b","boundVariable alpha",
386 "interval {x::real. 0 <= x & x <= 2*r}",
387 "interval {x::real. 0 <= x & x <= 2*r}",
388 "interval {x::real. 0 <= x & x <= pi}",
389 "errorBound (eps=(0::real))"]
390 (*specifying is not interesting for this example*)
391 val spec = ("DiffApp", ["maximum_of","function"],
392 ["DiffApp","max_by_calculus"]);
393 (*the empty model with descriptions for user-guidance by Model_Problem*)
394 val empty_model = [Given ["fixedValues []"],
395 Find ["maximum", "valuesFor"],
396 Relate ["relations []"]];
399 (*!!!!!!!!!!!!!!!!! DON'T USE me FOR FINDING nxt !!!!!!!!!!!!!!!!!!*)
400 val (p,_,f,nxt,_,pt) = CalcTreeTEST [(elems, spec)];
401 (*val nxt = ("Model_Problem", ...*)
402 val pbl = get_obj g_pbl pt (fst p); (writeln o (I_Model.to_string ctxt)) pbl;
404 val (p,_,f,nxt,_,pt) = me nxt p c pt;
405 (*nxt = Add_Given "fixedValues [r = Arbfix]"*)
406 val pbl = get_obj g_pbl pt (fst p); (writeln o (I_Model.to_string ctxt)) pbl;
408 (0 ,[] ,false ,#Given ,Inc fixedValues [] ,(??.empty, [])),
409 (0 ,[] ,false ,#Find ,Inc maximum ,(??.empty, [])),
410 (0 ,[] ,false ,#Find ,Inc valuesFor ,(??.empty, [])),
411 (0 ,[] ,false ,#Relate ,Inc relations [] ,(??.empty, []))]*)
413 (*the empty CalcHead is checked w.r.t the model and re-established as such*)
414 val (b,pt,ocalhd) = input_icalhd pt (p,"", empty_model, Pbl, References.empty);
415 val pbl = get_obj g_pbl pt (fst p); (writeln o (I_Model.to_string ctxt)) pbl;
416 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";
418 (*there is one input to the model (could be more)*)
420 input_icalhd pt (p,"", [Given ["fixedValues [r=Arbfix]"],
421 Find ["maximum", "valuesFor"],
422 Relate ["relations"]], Pbl, References.empty);
423 val pbl = get_obj g_pbl pt (fst p); (writeln o (I_Model.to_string ctxt)) pbl;
424 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 ()
425 else error "informtest.sml: diff.behav. max 2";
427 (*this input is complete in variant 3, but the ME doesn't recognize FIXXXXME
428 val (b,pt''''',ocalhd) =
429 input_icalhd pt (p,"", [Given ["fixedValues [r=Arbfix]"],
430 Find ["maximum A", "valuesFor [a,b]"],
431 Relate ["relations [A=a*b, a/2=r*sin alpha, \
432 \b/2=r*cos alpha]"]], Pbl, References.empty);
433 val pbl = get_obj g_pbl pt''''' (fst p); (writeln o (I_Model.to_string ctxt)) pbl;
434 if ocalhd2str ocalhd = ------------^^^^^^^^^^ missing !!!*)
436 (*this input is complete in variant 1 (variant 3 does not work yet)*)
437 val (b,pt''''',ocalhd) =
438 input_icalhd pt (p,"", [Given ["fixedValues [r=Arbfix]"],
439 Find ["maximum A", "valuesFor [a,b]"],
440 Relate ["relations [A=a*b, \
441 \(a/2)^^^2 + (b/2)^^^2 = r^^^2]"]],
442 Pbl, References.empty);
443 val pbl = get_obj g_pbl pt''''' (fst p); (writeln o (I_Model.to_string ctxt)) pbl;
445 modifycalcheadOK2xml 111 (bool2str b) ocalhd;
449 "--------- syntax error ------------------------------------------";
450 "--------- syntax error ------------------------------------------";
451 "--------- syntax error ------------------------------------------";
453 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
454 ("Test", ["sqroot-test","univariate","equation","test"],
455 ["Test","squ-equ-test-subpbl1"]))];
456 Iterator 1; moveActiveRoot 1;
457 autoCalculate 1 CompleteCalcHead;
458 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
459 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
461 appendFormula 1 " x - "; (*<ERROR> syntax error in ' x - ' </ERROR>*)
462 val ((pt,_),_) = get_calc 1;
463 val str = pr_ctree pr_short pt;
465 if str = ". ----- pblobj -----\n1. x + 1 = 2\n" then ()
466 else error "inform.sml: diff.behav.appendFormula: syntax error";
469 "--------- CAS-command on ([],Pbl) -------------------------------";
470 "--------- CAS-command on ([],Pbl) -------------------------------";
471 "--------- CAS-command on ([],Pbl) -------------------------------";
472 val (p,_,f,nxt,_,pt) =
473 CalcTreeTEST [([], ("empty_thy_id", ["empty_probl_id"], ["empty_meth_id"]))];
474 val ifo = "solve(x+1=2,x)";
475 val (_,(_,c,(pt,p))) = Step_Solve.by_term (pt,p) "solve(x+1=2,x)";
477 This trick ^^^^^^^^^ micked input of ^^^^^^^^^^^^^^^^^ in the front-end.
478 The trick worked in changeset fbaff8cf0179, it does not work in 59c5dd27d589 anymore
479 (TODO hg bisect ?) and raises the ERROR Undefined fact: "xfoldr_Nil".
481 Compare tests "CAS-command" in test/../inssort.sml etc.
482 ---------------------------------------------------------------------------------------------
484 val nxt = (Apply_Method ["Test","squ-equ-test-subpbl1"]);
485 val (p,_,f,nxt,_,pt) = me nxt p [] pt;
486 if p = ([1], Frm) andalso f2str f = "x + 1 = 2" then ()
487 else error "inform.sml: diff.behav. CAScmd ([],Pbl)";
489 -----------------------------------------------------------------------------------------------*)
491 "--------- CAS-command on ([],Pbl) FE-interface ------------------";
492 "--------- CAS-command on ([],Pbl) FE-interface ------------------";
493 "--------- CAS-command on ([],Pbl) FE-interface ------------------";
495 CalcTree [([], ("empty_thy_id", ["empty_probl_id"], ["empty_meth_id"]))];
498 replaceFormula 1 "solve(x+1=2,x)";
499 autoCalculate 1 CompleteCalc;
500 val ((pt,p),_) = get_calc 1;
502 if p = ([], Res) then ()
503 else error "inform.sml: diff.behav. CAScmd ([],Pbl) FE-interface";
506 "--------- inform [rational,simplification] ----------------------";
507 "--------- inform [rational,simplification] ----------------------";
508 "--------- inform [rational,simplification] ----------------------";
510 CalcTree [(["Term (a * x / (b * x) + c * x / (d * x) + e / f)", "normalform N"],
511 ("Rational", ["rational", "simplification"], ["simplification", "of_rationals"]))];
512 Iterator 1; moveActiveRoot 1;
513 autoCalculate 1 CompleteCalcHead;
515 "--- (-1) give a preview on the calculation without any input";
517 autoCalculate 1 CompleteCalc;
518 val ((pt, p), _) = get_calc 1;
521 (([], Frm), Simplify (a * x / (b * x) + c * x / (d * x) + e / f)),
522 (([1], Frm), a * x / (b * x) + c * x / (d * x) + e / f),
523 (([1], Res), a / b + c / d + e / f), <--- (1) input arbitrary
524 (([2], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
525 (([3], Res), (a * (d * f) + b * (c * f) + b * (d * e)) / (b * (d * f))),
526 (([4], Res), (a * d * f + b * c * f + b * d * e) / (b * d * f)), <--- (2) input next
527 (([], Res), (a * d * f + b * c * f + b * d * e) / (b * d * f))] <--- (3) is also final result
530 "--- (0) user input as the *first* step does not work, thus impdo at least 1 step";
531 autoCalculate 1 (Steps 1);
532 autoCalculate 1 (Steps 1);
533 val ((pt, p), _) = get_calc 1;
536 (([], Frm), Simplify (a * x / (b * x) + c * x / (d * x) + e / f)),
537 (([1], Frm), a * x / (b * x) + c * x / (d * x) + e / f),
538 (([1], Res), a / b + c / d + e / f)]
540 "--- (1) input an arbitrary next formula";
541 appendFormula 1 "((a * d) + (c * b)) / (b * d) + e / f" (*|> Future.join*);
542 val ((pt, p), _) = get_calc 1;
545 (([], Frm), Simplify (a * x / (b * x) + c * x / (d * x) + e / f)),
546 (([1], Frm), a * x / (b * x) + c * x / (d * x) + e / f),
547 (([1], Res), a / b + c / d + e / f),
548 (([2,1], Frm), a / b + c / d + e / f),
549 (([2,1], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
550 (([2,2], Res), (a * d + c * b) / (b * d) + e / f),
551 (([2], Res), (a * d + c * b) / (b * d) + e / f)]
553 val ((pt,p),_) = get_calc 1;
554 if p = ([2], Res) andalso (length o children o (get_nd pt)) (fst p) = 2 then ()
555 else error ("inform.sml: [rational,simplification] 1");
557 "--- (2) input the next formula that would be presented by mat-engine";
558 (* generate a preview:
559 autoCalculate 1 (Steps 1);
560 val ((pt, p), _) = get_calc 1;
563 (([], Frm), Simplify (a * x / (b * x) + c * x / (d * x) + e / f)),
564 (([1], Frm), a * x / (b * x) + c * x / (d * x) + e / f),
565 (([1], Res), a / b + c / d + e / f),
566 (([2,1], Frm), a / b + c / d + e / f),
567 (([2,1], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
568 (([2,2], Res), (a * d + c * b) / (b * d) + e / f),
569 (([2], Res), (a * d + c * b) / (b * d) + e / f),
570 (([3], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f))] <--- input this
572 appendFormula 1 "(b * d * e + b * c * f + a * d * f) / (b * d * f)" (*|> Future.join*);
573 val ((pt, p), _) = get_calc 1;
576 (([], Frm), Simplify (a * x / (b * x) + c * x / (d * x) + e / f)),
577 (([1], Frm), a * x / (b * x) + c * x / (d * x) + e / f),
578 (([1], Res), a / b + c / d + e / f),
579 (([2,1], Frm), a / b + c / d + e / f),
580 (([2,1], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
581 (([2,2], Res), (a * d + c * b) / (b * d) + e / f),
582 (([2], Res), (a * d + c * b) / (b * d) + e / f),
583 (([3], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f))]
585 if p = ([3], Res) andalso (length o children o (get_nd pt)) (fst p) = 0 then ()
586 else error ("inform.sml: [rational,simplification] 2");
588 "--- (3) input the exact final result";
589 appendFormula 1 "(b * d * e + b * c * f + a * d * f) / (b * d * f)" (*|> Future.join*);
590 val ((pt, p), _) = get_calc 1;
593 (([], Frm), Simplify (a * x / (b * x) + c * x / (d * x) + e / f)),
594 (([1], Frm), a * x / (b * x) + c * x / (d * x) + e / f),
595 (([1], Res), a / b + c / d + e / f),
596 (([2,1], Frm), a / b + c / d + e / f),
597 (([2,1], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
598 (([2,2], Res), (a * d + c * b) / (b * d) + e / f),
599 (([2], Res), (a * d + c * b) / (b * d) + e / f),
600 (([3], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
601 (([4,1], Frm), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
602 (([4,1], Res), (a * (d * f) + b * (c * f) + b * (d * e)) / (b * (d * f))),
603 (([4,2], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
604 (([4], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f))]
606 if p = ([4], Res) andalso (length o children o (get_nd pt)) (fst p) = 2 then ()
607 else error ("inform.sml: [rational,simplification] 3");
609 "--- (4) finish the calculation + check the postcondition (in the future)";
610 autoCalculate 1 CompleteCalc;
611 val ((pt, p), _) = get_calc 1;
612 val (t, asm) = get_obj g_result pt [];
613 if UnparseC.term t = "(a * d * f + b * c * f + b * d * e) / (b * d * f)" andalso
614 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\"]"*)
615 "[]" (*..found broken in child of 33913fe24685, error covered by CAS-command *)
616 then () else error "inform [rational,simplification] changed at end";
619 (([], Frm), Simplify (a * x / (b * x) + c * x / (d * x) + e / f)),
620 (([1], Frm), a * x / (b * x) + c * x / (d * x) + e / f),
621 (([1], Res), a / b + c / d + e / f),
622 (([2,1], Frm), a / b + c / d + e / f),
623 (([2,1], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
624 (([2,2], Res), (a * d + c * b) / (b * d) + e / f),
625 (([2], Res), (a * d + c * b) / (b * d) + e / f),
626 (([3], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
627 (([4,1], Frm), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
628 (([4,1], Res), (a * (d * f) + b * (c * f) + b * (d * e)) / (b * (d * f))),
629 (([4,2], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
630 (([4], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
631 (([5], Res), (a * (d * f) + b * (c * f) + b * (d * e)) / (b * (d * f))),
632 (([6], Res), (a * d * f + b * c * f + b * d * e) / (b * d * f)),
633 (([], Res), (a * d * f + b * c * f + b * d * e) / (b * d * f))]
637 "--------- Take as 1st tac, start with <NEW> (CAS input) ---------";
638 "--------- Take as 1st tac, start with <NEW> (CAS input) ---------";
639 "--------- Take as 1st tac, start with <NEW> (CAS input) ---------";
640 val t = str2term "Diff (x^^^2 + x + 1, x)";
641 case t of Const ("Diff.Diff", _) $ _ => ()
643 error "diff.sml behav.changed for CAS Diff (..., x)";
645 "-----------------------------------------------------------------";
646 (*1>*)reset_states ();
647 (*2>*)CalcTree [([], ("empty_thy_id", ["empty_probl_id"], ["empty_meth_id"]))];
648 (*3>*)Iterator 1;moveActiveRoot 1;
649 "----- here the Headline has been finished";
650 (*4>*)moveActiveFormula 1 ([],Pbl);
651 (*5>*)replaceFormula 1 "Diff (x^2 + x + 1, x)";
652 val ((pt,_),_) = get_calc 1;
653 val PblObj {probl, meth, spec, fmz, loc, ...} = get_obj I pt [];
654 val (SOME istate, NONE) = loc;
655 (*default_print_depth 5;*)
656 writeln"-----------------------------------------------------------";
658 writeln (I_Model.to_string ctxt probl);
659 writeln (I_Model.to_string ctxt meth);
660 writeln (Istate.string_of (fst istate));
662 refFormula 1 ([],Pbl) (*--> correct CalcHead*);
663 (*081016 NOT necessary (but leave it in Java):*)
664 (*6>*)(*completeCalcHead*)autoCalculate 1 CompleteCalcHead;
665 "----- here the CalcHead has been completed --- ONCE MORE ?????";
667 (***difference II***)
668 val ((pt,p),_) = get_calc 1;
669 (*val p = ([], Pbl)*)
670 val PblObj {probl, meth, spec, fmz, loc, ...} = get_obj I pt [];
671 val (SOME istate, NONE) = loc;
672 (*default_print_depth 5;*) writeln (Istate.string_of (fst istate)); (*default_print_depth 3;*)
675 ??.empty, Sundef, false)*)
676 (*default_print_depth 5;*) spec; (*default_print_depth 3;*)
678 ["derivative_of", "function"],
679 ["diff", "differentiate_on_R"]) : spec*)
680 writeln (I_Model.to_string ctxt probl);
682 (1 ,[1] ,true ,#Given ,Cor functionTerm (x ^^^ 2 + x + 1) ,(f_, [x ^^^ 2 + x + 1])),
683 (2 ,[1] ,true ,#Given ,Cor differentiateFor x ,(v_, [x])),
684 (3 ,[1] ,true ,#Find ,Cor derivative f_'_f ,(f_'_f, [f_'_f]))]*)
685 writeln (I_Model.to_string ctxt meth);
687 (1 ,[1] ,true ,#Given ,Cor functionTerm (x ^^^ 2 + x + 1) ,(f_, [x ^^^ 2 + x + 1])),
688 (2 ,[1] ,true ,#Given ,Cor differentiateFor x ,(v_, [x])),
689 (3 ,[1] ,true ,#Find ,Cor derivative f_'_f ,(f_'_f, [f_'_f]))]*)
690 writeln"-----------------------------------------------------------";
691 (*7>*)fetchProposedTactic 1 (*--> Apply_Method*);
692 (*WN081028 fixed <ERROR> helpless </ERROR> by inform returning ...(.,Met)*)
693 autoCalculate 1 CompleteCalc;
694 val ((pt,p),_) = get_calc 1;
695 val Form res = (#1 o pt_extract) (pt, ([],Res));
697 if p = ([], Res) andalso UnparseC.term res = "1 + 2 * x" then ()
698 else error "diff.sml behav.changed for Diff (x^2 + x + 1, x)";
701 "--------- Take as 1st tac, start from exp -----------------------";
702 "--------- Take as 1st tac, start from exp -----------------------";
703 "--------- Take as 1st tac, start from exp -----------------------";
704 (*the following input is copied from BridgeLog Java <==> SML,
705 omitting unnecessary inputs*)
706 (*1>*)reset_states ();
707 (*2>*)CalcTree [(["functionTerm (x^2 + x + 1)", "differentiateFor x", "derivative f_'_f"],("Isac_Knowledge",["derivative_of","function"],["diff","differentiate_on_R"]))];
708 (*3>*)Iterator 1; moveActiveRoot 1;
710 (*6>*)(*completeCalcHead*)autoCalculate 1 CompleteCalcHead;
711 (***difference II***)
712 val ((pt,_),_) = get_calc 1;
713 val PblObj {probl, meth, spec, fmz, loc, ...} = get_obj I pt [];
714 val (SOME istate, NONE) = loc;
715 (*default_print_depth 5;*) writeln (Istate.string_of (fst istate)); (*default_print_depth 3;*)
718 ??.empty, Sundef, false)*)
719 (*default_print_depth 5;*) spec; (*default_print_depth 3;*)
721 ["derivative_of", "function"],
722 ["diff", "differentiate_on_R"]) : spec*)
723 writeln (I_Model.to_string ctxt probl);
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 (I_Model.to_string ctxt meth);
730 (1 ,[1] ,true ,#Given ,Cor functionTerm (x ^^^ 2 + x + 1) ,(f_, [x ^^^ 2 + x + 1])),
731 (2 ,[1] ,true ,#Given ,Cor differentiateFor x ,(v_, [x])),
732 (3 ,[1] ,true ,#Find ,Cor derivative f_'_f ,(f_'_f, [f_'_f]))]*)
733 writeln"-----------------------------------------------------------";
734 (*7>*)fetchProposedTactic 1 (*--> Apply_Method*);
735 autoCalculate 1 (Steps 1);
736 val ((pt,p),_) = get_calc 1;
737 val Form res = (#1 o pt_extract) (pt, p);
738 if UnparseC.term res = "d_d x (x ^^^ 2 + x + 1)" then ()
739 else error "diff.sml Diff (x^2 + x + 1, x) from exp";
742 "--------- implicit_take, start with <NEW> (CAS input) ---------------";
743 "--------- implicit_take, start with <NEW> (CAS input) ---------------";
744 "--------- implicit_take, start with <NEW> (CAS input) ---------------";
746 CalcTree [([], ("empty_thy_id", ["empty_probl_id"], ["empty_meth_id"]))];
747 (*[[from sml: > @@@@@begin@@@@@
749 [[from sml: <CALCTREE>
750 [[from sml: <CALCID> 1 </CALCID>
751 [[from sml: </CALCTREE>
752 [[from sml: @@@@@end@@@@@*)
754 (*[[from sml: > @@@@@begin@@@@@
756 [[from sml: <ADDUSER>
757 [[from sml: <CALCID> 1 </CALCID>
758 [[from sml: <USERID> 1 </USERID>
759 [[from sml: </ADDUSER>
760 [[from sml: @@@@@end@@@@@*)
762 (*[[from sml: > @@@@@begin@@@@@
764 [[from sml: <CALCITERATOR>
765 [[from sml: <CALCID> 1 </CALCID>
766 [[from sml: <POSITION>
767 [[from sml: <INTLIST>
768 [[from sml: </INTLIST>
769 [[from sml: <POS> Pbl </POS>
770 [[from sml: </POSITION>
771 [[from sml: </CALCITERATOR>
772 [[from sml: @@@@@end@@@@@*)
773 getFormulaeFromTo 1 ([],Pbl) ([],Pbl) 0 false;
774 (*[[from sml: > @@@@@begin@@@@@ STILL CORRECT
776 [[from sml: <GETELEMENTSFROMTO>
777 [[from sml: <CALCID> 1 </CALCID>
778 [[from sml: <FORMHEADS>
779 [[from sml: <CALCFORMULA>
780 [[from sml: <POSITION>
781 [[from sml: <INTLIST>
782 [[from sml: </INTLIST>
783 [[from sml: <POS> Pbl </POS>
784 [[from sml: </POSITION>
785 [[from sml: <FORMULA>
787 [[from sml: <ISA> ________________________________________________ </ISA>
788 [[from sml: </MATHML>
790 [[from sml: </FORMULA>
791 [[from sml: </CALCFORMULA>
792 [[from sml: </FORMHEADS>
793 [[from sml: </GETELEMENTSFROMTO>
794 [[from sml: @@@@@end@@@@@*)
795 refFormula 1 ([],Pbl);
796 (*[[from sml: > @@@@@begin@@@@@ STILL CORRECT
798 [[from sml: <REFFORMULA>
799 [[from sml: <CALCID> 1 </CALCID>
800 [[from sml: <CALCHEAD status = "incorrect">
801 [[from sml: <POSITION>
802 [[from sml: <INTLIST>
803 [[from sml: </INTLIST>
804 [[from sml: <POS> Pbl </POS>
805 [[from sml: </POSITION>
808 [[from sml: <ISA> Problem (ThyC.id_empty, [e_pblID]) </ISA>
809 [[from sml: </MATHML>
812 [[from sml: <GIVEN> </GIVEN>
813 [[from sml: <WHERE> </WHERE>
814 [[from sml: <FIND> </FIND>
815 [[from sml: <RELATE> </RELATE>
817 [[from sml: <BELONGSTO> Pbl </BELONGSTO>
818 [[from sml: <SPECIFICATION>
819 [[from sml: <THEORYID> ThyC.id_empty </THEORYID>
820 [[from sml: <PROBLEMID>
821 [[from sml: <STRINGLIST>
822 [[from sml: <STRING> Problem.id_empty </STRING>
823 [[from sml: </STRINGLIST>
824 [[from sml: </PROBLEMID>
825 [[from sml: <METHODID>
826 [[from sml: <STRINGLIST>
827 [[from sml: <STRING> e_metID </STRING>
828 [[from sml: </STRINGLIST>
829 [[from sml: </METHODID>
830 [[from sml: </SPECIFICATION>
831 [[from sml: </CALCHEAD>
832 [[from sml: </REFFORMULA>
833 [[from sml: @@@@@end@@@@@*)
834 moveActiveFormula 1 ([],Pbl);
835 (*[[from sml: > @@@@@begin@@@@@
837 [[from sml: <CALCITERATOR>
838 [[from sml: <CALCID> 1 </CALCID>
839 [[from sml: <POSITION>
840 [[from sml: <INTLIST>
841 [[from sml: </INTLIST>
842 [[from sml: <POS> Pbl </POS>
843 [[from sml: </POSITION>
844 [[from sml: </CALCITERATOR>
845 [[from sml: @@@@@end@@@@@*)
846 replaceFormula 1 "Simplify (1+2)";
847 (*[[from sml: > @@@@@begin@@@@@
849 [[from sml: <REPLACEFORMULA>
850 [[from sml: <CALCID> 1 </CALCID>
851 [[from sml: <CALCCHANGED>
852 [[from sml: <UNCHANGED>
853 [[from sml: <INTLIST>
854 [[from sml: </INTLIST>
855 [[from sml: <POS> Pbl </POS>
856 [[from sml: </UNCHANGED>
857 [[from sml: <DELETED>
858 [[from sml: <INTLIST>
859 [[from sml: </INTLIST>
860 [[from sml: <POS> Pbl </POS>
861 [[from sml: </DELETED>
862 [[from sml: <GENERATED>
863 [[from sml: <INTLIST>
864 [[from sml: </INTLIST>
865 [[from sml: <POS> Met </POS> DIFFERENCE: Pbl
866 [[from sml: </GENERATED>
867 [[from sml: </CALCCHANGED>
868 [[from sml: </REPLACEFORMULA>
869 [[from sml: @@@@@end@@@@@*)
870 getFormulaeFromTo 1 ([],Pbl) ([],Pbl) 0 false(* DIFFERENCE: Pbl*);
884 <ISA> Simplify (1 + 2) </ISA> WORKS !!!!!
891 getFormulaeFromTo 1 ([],Pbl) ([],Met) 0 false;
892 (*[[from sml: > @@@@@begin@@@@@
894 [[from sml: <SYSERROR>
895 [[from sml: <CALCID> 1 </CALCID>
896 [[from sml: <ERROR> error in getFormulaeFromTo </ERROR>
897 [[from sml: </SYSERROR>
898 [[from sml: @@@@@end@@@@@*)
899 (*step into getFormulaeFromTo --- bug corrected...*)
901 "--------- build fun check_for' ------------------------------";
902 "--------- build fun check_for' ------------------------------";
903 "--------- build fun check_for' ------------------------------";
904 val subst = [(str2term "bdv", str2term "x")]: subst;
905 val rls = norm_Rational
906 val pat = parse_patt @{theory} "(?a + ?b)/(?b + ?c) = ?a / ?c";
907 val (res, inf) = (str2term "(2 + 3)/(3 + 4)", str2term "2 / 4");
908 val (res, inf) = (str2term "(2 + 3)/(3 + 4)", str2term "1 / 2");
910 val (res', _, _, rewritten) = (*rewritten: the lhs of the pattern matches in res*)
911 rew_sub thy 1 [] e_rew_ord Rule_Set.empty false [] (HOLogic.Trueprop $ pat) res;
912 if rewritten then NONE else SOME "e_errpatID";
914 val norm_res = case rewrite_set_ (Isac()) false rls res' of
916 | SOME (norm_res, _) => norm_res
918 val norm_inf = case rewrite_set_ (Isac()) false rls inf of
920 | SOME (norm_inf, _) => norm_inf;
925 val pat = parse_patt @{theory} "(?a + ?b)/?a = ?b";
926 val (res, inf) = (str2term "(2 + 3)/2", str2term "3");
927 if check_for' (res, inf) subst ("errpatID", pat) rls = SOME "errpatID"
928 then () else error "error patt example1 changed";
930 val pat = parse_patt @{theory} "(?a + ?b)/(?a + ?c) = ?b / ?c";
931 val (res, inf) = (str2term "(2 + 3)/(2 + 4)", str2term "3 / 4");
932 if check_for' (res, inf) subst ("errpatID", pat) rls = SOME "errpatID"
933 then () else error "error patt example2 changed";
935 val pat = parse_patt @{theory} "(?a + ?b)/(?b + ?c) = ?a / ?c";
936 val (res, inf) = (str2term "(2 + 3)/(3 + 4)", str2term "2 / 4");
937 if check_for' (res, inf) subst ("errpatID", pat) rls = SOME "errpatID"
938 then () else error "error patt example3 changed";
940 val inf = str2term "1 / 2";
941 if check_for' (res, inf) subst ("errpatID", pat) rls = SOME "errpatID"
942 then () else error "error patt example3 changed";
944 "--------- build fun check_for' ?bdv -------------------------";
945 "--------- build fun check_for' ?bdv -------------------------";
946 "--------- build fun check_for' ?bdv -------------------------";
947 val subst = [(str2term "bdv", str2term "x")]: subst;
948 val t = str2term "d_d x (x ^^^ 2 + sin (x ^^^ 4))";
949 val SOME (t, _) = rewrite_set_inst_ thy false subst norm_diff t;
950 if UnparseC.term t = "2 * x + cos (x ^^^ 4) * 4 * x ^^^ 3" then ()
951 else error "build fun check_for' ?bdv changed 1";
954 val pat = parse_patt @{theory} "d_d ?bdv (sin ?u) = cos (d_d ?bdv ?u)";
955 val (res, inf) = (str2term "2 * x + d_d x (sin (x ^^^ 4))", str2term "2 * x + cos (4 * x ^^^ 3)");
957 val (res', _, _, rewritten) = (*rewritten: the lhs of the pattern matches in res*)
958 rew_sub thy 1 subst e_rew_ord Rule_Set.empty false [] (HOLogic.Trueprop $ pat) res;
959 if UnparseC.term res' = "2 * x + cos (d_d x (x ^^^ 4))" andalso rewritten then ()
960 else error "build fun check_for' ?bdv changed 2";
962 val norm_res = case rewrite_set_inst_ (Isac()) false subst rls res' of
964 | SOME (norm_res, _) => norm_res;
965 if UnparseC.term norm_res = "2 * x + cos (4 * x ^^^ 3)" then ()
966 else error "build fun check_for' ?bdv changed 3";
968 val norm_inf = case rewrite_set_inst_ (Isac()) false subst rls inf of
970 | SOME (norm_inf, _) => norm_inf;
971 if UnparseC.term norm_inf = "2 * x + cos (4 * x ^^^ 3)" then ()
972 else error "build fun check_for' ?bdv changed 4";
975 if norm_res = norm_inf then ()
976 else error "build fun check_for' ?bdv changed 5";
978 if Error_Pattern.check_for' (res, inf) (subst: subst) ("errpatID": Error_Pattern.id, pat) rls = SOME "errpatID"
979 then () else error "error patt example1 changed";
981 "--------- build fun check_for ------------------------";
982 "--------- build fun check_for ------------------------";
983 "--------- build fun check_for ------------------------";
985 (str2term "d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))",
986 str2term "d_d x (x ^^^ 2) + cos (4 * x ^^^ 3)");
987 val {errpats, nrls = rls, scr = Prog prog, ...} = Method.from_store ["diff", "differentiate_on_R"]
989 val env = [(str2term "v_v", str2term "x")];
991 [Error_Pattern.empty, (*generalised for testing*)
992 ("chain-rule-diff-both",
993 [parse_patt @{theory} "d_d ?bdv (sin ?u) = cos (d_d ?bdv ?u)",
994 parse_patt @{theory} "d_d ?bdv (cos ?u) = - sin (d_d ?bdv ?u)",
995 parse_patt @{theory} "d_d ?bdv (?u ^^^ ?n) = ?n * ?u ^^^ (?n - 1)",
996 parse_patt @{theory} "d_d ?bdv (LogExp.ln ?u) = 1 / ?u",
997 parse_patt @{theory} "d_d ?bdv (LogExp.ln ?u) = 1 / d_d ?bdv ?u"],
998 [@{thm diff_sin_chain}, @{thm diff_cos_chain}, @{thm diff_pow_chain},
999 @{thm diff_ln_chain}, @{thm diff_exp_chain}])];
1000 case Error_Pattern.check_for (res, inf) (prog, env) (errpats, rls) of SOME _ => ()
1001 | NONE => error "Error_Pattern.check_for broken";
1004 "--------- embed fun check_for ------------------------";
1005 "--------- embed fun check_for ------------------------";
1006 "--------- embed fun check_for ------------------------";
1009 [(["functionTerm (x ^ 2 + sin (x ^ 4))", "differentiateFor x", "derivative f_f'"],
1010 ("Isac_Knowledge", ["derivative_of","function"], ["diff","differentiate_on_R"]))];
1013 autoCalculate 1 CompleteCalcHead;
1014 autoCalculate 1 (Steps 1);
1015 autoCalculate 1 (Steps 1);(*([1], Res), d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))*)
1016 (*autoCalculate 1 (Steps 1);([2], Res), d_d x (x ^^^ 2) + cos (x ^^^ 4) * d_d x (x ^^^ 4)*)
1018 "~~~~~ fun appendFormula , args:"; val (cI, (ifo:TermC.as_string)) = (1, "d_d x (x ^ 2) + cos (4 * x ^ 3)");
1019 "~~~~~ fun appendFormula' , args:"; val (cI, (ifo: TermC.as_string)) = (cI, ifo);
1020 val cs = get_calc cI
1021 val pos = get_pos cI 1;
1022 (*+*)if pos = ([1], Res) then () else error "inform with (positive) Error_Pattern.check_for broken 1";
1023 val ("ok", cs' as (_, _, ptp)) = (*case*) Step.do_next pos cs (*of*);
1024 (*case*) Step_Solve.by_term ptp (encode ifo) (*of*); (*ERROR WAS: "no derivation found"*)
1025 "~~~~~ fun Step_Solve.by_term , args:"; val (((*next_*)cs as (_, _, (pt, pos as (p, _))): Calc.state_post), istr)
1026 = (cs', (encode ifo));
1027 val ctxt = get_ctxt pt pos (*see TODO.thy*)
1028 val SOME f_in = (*case*) TermC.parse (ThyC.get_theory "Isac_Knowledge") istr (*of*);
1029 val f_in = Thm.term_of f_in
1030 val pos_pred = lev_back' pos
1031 val f_pred = Ctree.get_curr_formula (pt, pos_pred);
1032 (*if*) f_pred = f_in; (*else*)
1033 val NONE = (*case*) P_Specific.cas_input f_in (*of*);
1034 (*old* )val (_, _, metID) = get_obj g_spec pt (par_pblobj pt p)
1035 (*old*)val {scr = prog, ...} = Method.from_store metID
1036 (*old*)val istate = get_istate_LI pt pos
1037 (*old*)val ctxt = get_ctxt pt pos
1039 val LI.Not_Derivable =
1040 (*case*) LI.locate_input_term (pt, pos) f_in (*of*);
1041 val pp = Ctree.par_pblobj pt p
1042 val (errpats, nrls, prog) = case Method.from_store (Ctree.get_obj Ctree.g_metID pt pp) of
1043 {errpats, nrls, scr = Rule.Prog prog, ...} => (errpats, nrls, prog)
1044 | _ => error "inform: uncovered case of Method.from_store"
1046 (*+*)if Error_Pattern.s_to_string 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\"]]"
1047 (*+*)then () else error "inform with (positive) Error_Pattern.check_for broken 3";
1049 val {env, ...} = Ctree.get_istate_LI pt pos |> Istate.the_pstate
1051 (*+*)if UnparseC.term f_pred = "d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))" andalso
1052 (*+*) UnparseC.term f_in = "d_d x (x ^^^ 2) + cos (4 * x ^^^ 3)"
1053 (*+*)then () else error "inform with (positive) Error_Pattern.check_for broken 2";
1055 val SOME "chain-rule-diff-both" = (*case*) Error_Pattern.check_for (f_pred, f_in) (prog, env) (errpats, nrls) (*of*);
1058 (*+*)val (_, _, ptp') = cs';
1059 case Step_Solve.by_term ptp' (encode ifo) of
1060 ("error pattern #chain-rule-diff-both#", calcstate') => ()
1061 | _ => error "inform with (positive) Error_Pattern.check_for broken"
1064 "--------- embed fun find_fill_patterns ---------------------------";
1065 "--------- embed fun find_fill_patterns ---------------------------";
1066 "--------- embed fun find_fill_patterns ---------------------------";
1069 [(["functionTerm (x ^ 2 + sin (x ^ 4))", "differentiateFor x", "derivative f_f'"],
1070 ("Isac_Knowledge", ["derivative_of","function"], ["diff","differentiate_on_R"]))];
1073 autoCalculate 1 CompleteCalcHead;
1074 autoCalculate 1 (Steps 1);
1075 autoCalculate 1 (Steps 1);(*([1], Res), d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))*)
1076 appendFormula 1 "d_d x (x ^ 2) + cos (4 * x ^ 3)" (*|> Future.join*);
1077 (*<CALCMESSAGE> error pattern #chain-rule-diff-both# </CALCMESSAGE>*)
1079 <CALCMESSAGE> no derivation found </CALCMESSAGE>*)
1081 "~~~~~ fun findFillpatterns, args:"; val (cI, errpatID) = (1, "chain-rule-diff-both");
1082 val ((pt, _), _) = get_calc cI
1083 val pos = get_pos cI 1;
1084 "~~~~~ fun find_fill_patterns , args:"; val ((pt, pos as (p, _)), errpatID) = ((pt, pos), errpatID);
1085 val f_curr = Ctree.get_curr_formula (pt, pos);
1086 val pp = Ctree.par_pblobj pt p
1087 val (errpats, prog) = case Method.from_store (Ctree.get_obj Ctree.g_metID pt pp) of
1088 {errpats, scr = Rule.Prog prog, ...} => (errpats, prog)
1089 | _ => error "find_fill_patterns: uncovered case of Method.from_store"
1090 val {env, ...} = Ctree.get_istate_LI pt pos |> Istate.the_pstate
1091 val subst = Subst.for_bdv prog env
1092 val errpatthms = errpats
1093 |> filter ((curry op = errpatID) o (#1: Error_Pattern.T -> Error_Pattern.id))
1094 |> map (#3: Error_Pattern.T -> thm list)
1097 case map (Error_Pattern.fill_from_store subst f_curr errpatID) errpatthms |> flat of
1098 ("fill-d_d-arg", tm, thm, subs_opt) :: _ => if UnparseC.term tm =
1099 "d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4)) =\nd_d x (x ^^^ 2) + cos (x ^^^ 4) * d_d x ?_dummy_1"
1100 then () else error "find_fill_patterns changed 1a"
1101 | _ => error "find_fill_patterns changed 1b"
1103 "~~~~~ fun fill_from_store, args:"; val (subst, form, errpatID, thm) =
1104 (subst, f_curr, errpatID, hd (*simulate beginning of "map"*) errpatthms);
1105 val thmDeriv = Thm.get_name_hint thm
1106 val (part, thyID) = Thy_Read.thy_containing_thm thmDeriv
1107 val theID = [part, thyID, "Theorems", ThmC.cut_id thmDeriv]
1108 val Thy_Write.Hthm {fillpats, ...} = Thy_Read.from_store theID
1109 val some = map (Error_Pattern.fill_form subst (thm, form) errpatID) fillpats;
1111 case some |> filter is_some |> map the of
1112 ("fill-d_d-arg", tm, thm, subsopt) :: _ => if UnparseC.term tm =
1113 "d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4)) =\nd_d x (x ^^^ 2) + cos (x ^^^ 4) * d_d x ?_dummy_1"
1114 then () else error "find_fill_patterns changed 2a"
1115 | _ => error "find_fill_patterns changed 2b"
1117 "~~~~~ fun fill_form, args:";
1118 val ((subs_opt, subst), (thm, form), errpatID, (fillpatID, pat, erpaID)) =
1119 (subst, (thm, form), errpatID, hd (*simulate beginning of "map"*) fillpats);
1120 val (form', _, _, rewritten) =
1121 rew_sub (Isac()) 1 subst e_rew_ord Rule_Set.empty false [] (HOLogic.Trueprop $ pat) form;
1123 if UnparseC.term form' = "d_d x (x ^^^ 2) + cos (x ^^^ 4) * d_d x ?_dummy_1" then ()
1124 else error "find_fill_patterns changed 3";
1126 "~~~~~ to findFillpatterns return val:"; val (fillpats) =
1127 (map (Error_Pattern.fill_from_store (subs_opt, subst) f_curr errpatID) errpatthms |> flat) (*only from "hd errpatthms"*);
1129 "vvv--- dropped this code WN120730";
1130 val msg = "fill patterns " ^
1131 ((map ((apsnd UnparseC.term) o quad2pair) fillpats) |> map pair2str_ |> strs2str_);
1133 "fill patterns #fill-d_d-arg#d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))" ^
1134 " =\nd_d x (x ^^^ 2) + cos (x ^^^ 4) * d_d x ?_dummy_1" ^
1135 "#fill-both-args#d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))" ^
1136 " =\nd_d x (x ^^^ 2) + cos ?_dummy_2 * d_d x ?_dummy_3" ^
1137 "#fill-d_d#d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))" ^
1138 " =\nd_d x (x ^^^ 2) + cos (x ^^^ 4) * ?_dummy_1 x (x ^^^ 4)" ^
1139 "#fill-inner-deriv#d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))" ^
1140 " =\nd_d x (x ^^^ 2) + cos (x ^^^ 4) * ?_dummy_1" ^
1141 "#fill-all#d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4)) = d_d x (x ^^^ 2) + ?_dummy_1#";
1142 "^^^--- dropped this code WN120730";
1144 if (map #1 fillpats) =
1145 ["fill-d_d-arg", "fill-both-args", "fill-d_d", "fill-inner-deriv", "fill-all"]
1146 then () else error "find_fill_patterns changed 4b";
1149 "--------- build fun is_exactly_equal, inputFillFormula ----------";
1150 "--------- build fun is_exactly_equal, inputFillFormula ----------";
1151 "--------- build fun is_exactly_equal, inputFillFormula ----------";
1154 [(["functionTerm (x ^ 2 + sin (x ^ 4))", "differentiateFor x", "derivative f_f'"],
1155 ("Isac_Knowledge", ["derivative_of","function"], ["diff","differentiate_on_R"]))];
1158 autoCalculate 1 CompleteCalcHead;
1159 autoCalculate 1 (Steps 1);
1160 autoCalculate 1 (Steps 1);(*([1], Res), d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))*)
1161 appendFormula 1 "d_d x (x ^ 2) + cos (4 * x ^ 3)" (*|> Future.join*); (*<<<<<<<=========================*)
1162 (* the check for errpat is maximally liberal (whole term modulo "nrls" from "type met"),
1163 would recognize "cos (4 * x ^ (4 - 1)) + 2 * x" as well.
1164 results in <CALCMESSAGE> error pattern #chain-rule-diff-both# </CALCMESSAGE>
1165 instead of <CALCMESSAGE> no derivation found </CALCMESSAGE> *)
1166 val ((pt,pos), _) = get_calc 1;
1167 val p = get_pos 1 1;
1168 val (Form f, _, asms) = pt_extract (pt, p);
1170 if p = ([1], Res) andalso UnparseC.term f = "d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))" then
1171 case get_obj g_tac pt (fst p) of Rewrite_Inst (["(''bdv'', x)"],
1172 ("diff_sum", thm)) =>
1173 if (UnparseC.term o Thm.prop_of) thm = "d_d ?bdv (?u + ?v) = d_d ?bdv ?u + d_d ?bdv ?v" then ()
1174 else error "embed fun fill_form changed 11"
1175 | _ => error "embed fun fill_form changed 12"
1176 else error "embed fun fill_form changed 13";
1178 findFillpatterns 1 "chain-rule-diff-both"; (*<<<<<<<=================================*)
1179 (*<CALCMESSAGE> fill patterns #fill-d_d-arg#d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4)) =
1180 d_d x (x ^^^ 2) + cos (x ^^^ 4) * d_d x ?_dummy_1#fill-both-args#...#...#... *)
1181 val ((pt,pos),_) = get_calc 1;
1182 val p = get_pos 1 1;
1184 val (Form f, _, asms) = pt_extract (pt, p);
1185 if p = ([1], Res) andalso UnparseC.term f = "d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))" then
1186 case get_obj g_tac pt (fst p) of Rewrite_Inst (["(''bdv'', x)"],
1187 ("diff_sum", thm)) =>
1188 if (UnparseC.term o Thm.prop_of) thm = "d_d ?bdv (?u + ?v) = d_d ?bdv ?u + d_d ?bdv ?v" then ()
1189 else error "embed fun fill_form changed 21"
1190 | _ => error "embed fun fill_form changed 22"
1191 else error "embed fun fill_form changed 23";
1193 requestFillformula 1 ("chain-rule-diff-both", "fill-both-args");(*<<<<<<<============*)
1194 (*<AUTOCALC> ([1], Res) ([2], Res) ([2], Res) </AUTOCALC>*)
1195 val ((pt,pos),_) = get_calc 1;
1196 val p = get_pos 1 1;
1197 val (Form f, _, asms) = pt_extract (pt, p);
1198 if p = ([1], Res) andalso existpt [2] pt
1199 andalso UnparseC.term f = "d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))"
1200 then case get_obj g_tac pt (fst p) of Rewrite_Inst (["(''bdv'', x)"],
1201 ("diff_sum", thm)) =>
1202 if (UnparseC.term o Thm.prop_of) thm = "d_d ?bdv (?u + ?v) = d_d ?bdv ?u + d_d ?bdv ?v" then ()
1203 else error "embed fun fill_form changed 31"
1204 | _ => error "embed fun fill_form changed 32"
1205 else error "embed fun fill_form changed 33";
1207 (* input a formula which exactly fills the gaps in a "fillformula"
1208 presented to the learner immediately before by "requestFillformula (errpatID, fillpatID)":
1209 errpatID: lhs of the respective thm = lhs of fillformula with fillpatID.
1210 the respective thm is in the ctree ................
1212 "~~~~~ fun inputFillFormula, args:"; val (cI, ifo) =
1213 (1, "d_d x (x ^^^ 2) + cos (x ^^^ 4) * d_d x (x ^^^ 4)");
1214 val ((pt, _), _) = get_calc cI
1215 val pos = get_pos cI 1;
1217 "~~~~~ fun is_exactly_equal, args:"; val ((pt, pos as (p, p_)), istr) = ((pt, pos), ifo);
1218 val SOME ifo = parseNEW (ThyC.get_theory "Isac_Knowledge" |> ThyC.to_ctxt) istr
1220 val tac = get_obj g_tac pt p';
1221 val Rewrite_Inst ([bbb as "(''bdv'', x)"], ("diff_sin_chain", ttt)) = tac;
1222 if (UnparseC.term o Thm.prop_of) ttt = "d_d ?bdv (sin ?u) = cos ?u * d_d ?bdv ?u" then ()
1223 else error "inputFillFormula changed 10";
1224 val Applicable.Yes rew = Step.check tac (pt, pos);
1225 val Rewrite_Inst' (_, _, _, _, _, _, _, (res, _)) = rew;
1227 "~~~~~ to inputFillFormula return val:"; val ("ok", tac) = ("ok", tac);
1228 val ("ok", (_, c, ptp as (_,p'))) = Step.by_tactic tac (pt, pos);
1229 upd_calc cI (ptp, []);
1231 autocalculateOK2xml cI pos (if null c then p' else last_elem c) p';
1233 "~~~~~ final check:";
1234 val ((pt, _),_) = get_calc 1;
1235 val p = get_pos 1 1;
1236 val (Form f, _, asms) = pt_extract (pt, p);
1237 if p = ([2], Res) andalso UnparseC.term f = "d_d x (x ^^^ 2) + cos (x ^^^ 4) * d_d x (x ^^^ 4)"
1238 then case get_obj g_tac pt (fst p) of Rewrite_Inst (["(''bdv'', x)"],
1239 ("diff_sin_chain", thm)) =>
1240 if (UnparseC.term o Thm.prop_of) thm = "d_d ?bdv (sin ?u) = cos ?u * d_d ?bdv ?u" then ()
1241 else error "inputFillFormula changed 111"
1242 | _ => error "inputFillFormula changed 112"
1243 else error "inputFillFormula changed 113";
1245 "--------- fun appl_adds -----------------------------------------";
1246 "--------- fun appl_adds -----------------------------------------";
1247 "--------- fun appl_adds -----------------------------------------";
1248 (* val (dI, oris, ppc, pbt, selct::ss) =
1249 (dI, pors, probl, ppc, map itms2fstr probl);
1252 (* val (dI, oris, ppc, pbt, (selct::ss))=
1253 (#1 (some_spec ospec spec), oris, []:I_Model.T,
1254 ((#ppc o Problem.from_store) (#2 (some_spec ospec spec))),(imodel2fstr imodel));
1255 val iii = appl_adds dI oris ppc pbt (selct::ss);
1256 tracing(I_Model.to_string thy iii);
1258 val itm = add_single' dI oris ppc pbt selct;
1259 val ppc = insert_ppc' itm ppc;
1261 val _::selct::ss = (selct::ss);
1262 val itm = add_single' dI oris ppc pbt selct;
1263 val ppc = insert_ppc' itm ppc;
1265 val _::selct::ss = (selct::ss);
1266 val itm = add_single' dI oris ppc pbt selct;
1267 val ppc = insert_ppc' itm ppc;
1268 tracing(I_Model.to_string thy ppc);
1270 val _::selct::ss = (selct::ss);
1271 val itm = add_single' dI oris ppc pbt selct;
1272 val ppc = insert_ppc' itm ppc;
1274 "--------- fun concat_deriv --------------------------------------";
1275 "--------- fun concat_deriv --------------------------------------";
1276 "--------- fun concat_deriv --------------------------------------";
1278 val ({rew_ord, erls, rules,...}, fo, ifo) =
1279 (Rule_Set.rep Test_simplify, str2term "x+1+ -1*2=0", str2term "-2*1+(x+1)=0");
1280 (tracing o Derive.trtas2str) fod';
1282 (x + 1 + -1 * 2 = 0, Thm ("radd_commute","?m + ?n = ?n + ?m"), (-1 * 2 + (x + 1) = 0, []))","
1283 (-1 * 2 + (x + 1) = 0, Thm ("radd_commute","?m + ?n = ?n + ?m"), (-1 * 2 + (1 + x) = 0, []))","
1284 (-1 * 2 + (1 + x) = 0, Thm ("radd_left_commute","?x + (?y + ?z) = ?y + (?x + ?z)"), (1 + (-1 * 2 + x) = 0, []))","
1285 (1 + (-1 * 2 + x) = 0, Thm ("#mult_Float ((~1,0), (0,0)) __ ((2,0), (0,0))","-1 * 2 = -2"), (1 + (-2 + x) = 0, []))"]
1287 (tracing o Derive.trtas2str) (map Derive.rev_deriv' rifod');
1289 (1 + (-2 + x) = 0, Thm ("sym_#mult_Float ((~2,0), (0,0)) __ ((1,0), (0,0))","-2 = -2 * 1"), (1 + (-2 * 1 + x) = 0, []))","
1290 (1 + (-2 * 1 + x) = 0, Thm ("sym_radd_left_commute","?y + (?x + ?z) = ?x + (?y + ?z)"), (-2 * 1 + (1 + x) = 0, []))","
1291 (-2 * 1 + (1 + x) = 0, Thm ("sym_radd_commute","?n + ?m = ?m + ?n"), (-2 * 1 + (x + 1) = 0, []))"]
1294 "--------- handle an input formula -------------------------------";
1295 "--------- handle an input formula -------------------------------";
1296 "--------- handle an input formula -------------------------------";
1298 Untersuchung zur Formeleingabe (appendFormula, replaceFormla) zu einer Anregung von Alan Krempler:
1299 Welche RICHTIGEN Formeln koennen NICHT abgeleitet werden,
1300 wenn Abteilungen nur auf gleichem Level gesucht werden ?
1303 Beispiele zum Equationsolver von Richard Lang aus /src/sml/kbtest/rlang.sml
1305 ------------------------------------------------------------------------------
1306 "Schalk I s.87 Bsp 52a ((5*x)/(x - 2) - x/(x+2)=4)";
1307 ------------------------------------------------------------------------------
1308 1. "5 * x / (x - 2) - x / (x + 2) = 4"
1310 4. "12 * x + 4 * x ^^^ 2 = 4 * (-4 + x ^^^ 2)",Subproblem["normalise", "poly"..
1312 4.3. "16 + 12 * x = 0", Subproblem["degree_1", "polynomial", "univariate"..
1314 4.3.3. "[x = -4 / 3]")), Check_elementwise "Assumptions"
1317 ------------------------------------------------------------------------------
1318 (1)..(6): keine 'richtige' Eingabe kann abgeleitet werden, die einen Summanden auf die andere Seite verschiebt [Ableitung ware in 4.3.n]
1320 (4.1)..(4.3): keine 'richtige' Eingabe kann abgeleitet werden, die einen Summanden auf die andere Seite verschiebt [Ableitung ware in 4.3.n]
1321 ------------------------------------------------------------------------------
1324 ------------------------------------------------------------------------------
1325 "Schalk I s.87 Bsp 55b (x/(x^^^2 - 6*x+9) - 1/(x^^^2 - 3*x) =1/x)";
1326 ------------------------------------------------------------------------------
1327 1. "x / (x ^^^ 2 - 6 * x + 9) - 1 / (x ^^^ 2 - 3 * x) = 1 / x"
1329 4. "(3 + (-1 * x + x ^^^ 2)) * x = 1 * (9 * x + (x ^^^ 3 + -6 * x ^^^ 2))"
1330 Subproblem["normalise", "polynomial", "univariate"..
1332 4.4. "-6 * x + 5 * x ^^^ 2 = 0", Subproblem["bdv_only", "degree_2", "poly"..
1334 4.4.4. "[x = 0, x = 6 / 5]", Check_elementwise "Assumptions"
1335 4.4.5. "[x = 0, x = 6 / 5]"
1337 5. "[x = 0, x = 6 / 5]", Check_elementwise "Assumptions"
1339 ------------------------------------------------------------------------------
1340 (1)..(4): keine 'richtige' Eingabe kann abgeleitet werden, die einen Summanden auf die andere Seite schiebt [Ableitung waere in 4.4.x]
1342 (4.1)..(4.4.5): keine 'richtige' Eingabe kann abgeleitet werden, die dem Ergebnis "[x = 6 / 5]" aequivalent ist [Ableitung waere in 5.]
1343 ------------------------------------------------------------------------------
1346 ------------------------------------------------------------------------------
1347 "Schalk II s.56 Bsp 73b (sqrt(x+1)+sqrt(4*x+4)=sqrt(9*x+9))";
1348 ------------------------------------------------------------------------------
1349 1. "sqrt (x + 1) + sqrt (4 * x + 4) = sqrt (9 * x + 9)"
1351 6. "13 + 13 * x + -2 * sqrt ((4 + 4 * x) * (9 + 9 * x)) = 1 + x"
1352 Subproblem["sq", "rootX", "univariate", "equation"]
1354 6.6. "144 + 288 * x + 144 * x ^^^ 2 = 144 + x ^^^ 2 + 288 * x + 143 * x ^^^ 2"
1355 Subproblem["normalise", "polynomial", "univariate", "equation"]
1357 6.6.3 "0 = 0" Subproblem["degree_0", "polynomial", "univariate", "equation"]
1359 6.6.3.2 "UniversalList"
1360 ------------------------------------------------------------------------------
1361 (1)..(6): keine 'richtige' Eingabe kann abgeleitet werden, die eine der Wurzeln auf die andere Seite verschieb [Ableitung ware in 6.6.n]
1363 (6.1)..(6.3): keine 'richtige' Eingabe kann abgeleitet werden, die einen Summanden auf die andere Seite verschiebt [Ableitung ware in 6.6.n]
1364 ------------------------------------------------------------------------------
1366 (*sh. comments auf 498*)
1367 "--------- fun dropwhile' ----------------------------------------";
1368 "--------- fun dropwhile' ----------------------------------------";
1369 "--------- fun dropwhile' ----------------------------------------";
1371 fun equal a b = a=b;
1372 val foder = [0,1,2,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 > vval it = ([0, 1, 2, 3], [3, 12, 11]) : int list * int list
1377 val foder = [3,4,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 = ([3], [3, 12, 11]) : int list * int list
1382 val foder = [5]; 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 > val it = ([5], [5, 4, 3, 12, 11]) : int list * int list
1387 val foder = [10,11,12,13,14,15]; val ifoder = [11,12,3,4,5];
1388 val r_foder = rev foder; val r_ifoder = rev ifoder;
1389 dropwhile' equal r_foder r_ifoder;
1390 > *** dropwhile': did not start with equal elements*)