//reduce the number of TermC.parse*; "//"means: tests broken .
broken tests are outcommented with "reduce the number of TermC.parse*"
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 (*TOODOO broken with "reduce the number of TermC.parse*"------------------------------------\\
48 "--------- appendFormula: on Res + equ_nrls ----------------------";
49 "--------- appendFormula: on Res + equ_nrls ----------------------";
50 "--------- appendFormula: on Res + equ_nrls ----------------------";
51 val Prog sc = (#scr o MethodC.from_store) ["Test", "squ-equ-test-subpbl1"];
52 (writeln o UnparseC.term) sc;
53 val Prog sc = (#scr o MethodC.from_store) ["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 (TermC.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 (TermC.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";
172 ----- broken with "reduce the number of TermC.parse*"---------------------------------------//*)
174 "--------- appendFormula: on Res + NO deriv ----------------------";
175 "--------- appendFormula: on Res + NO deriv ----------------------";
176 "--------- appendFormula: on Res + NO deriv ----------------------";
178 CalcTree [(["equality (x+1=(2::real))", "solveFor x", "solutions L"],
179 ("Test", ["sqroot-test", "univariate", "equation", "test"],
180 ["Test", "squ-equ-test-subpbl1"]))];
181 Iterator 1; moveActiveRoot 1;
182 autoCalculate 1 CompleteCalcHead;
183 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
184 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 + - 1 * 2 = 0*);
186 appendFormula 1 "x = 2" (*|> Future.join*);
187 val ((pt,p),_) = get_calc 1;
188 val str = pr_ctree pr_short pt;
190 if str = ". ----- pblobj -----\n1. x + 1 = 2\n" andalso p = ([1], Res)
192 else error "inform.sml: diff.behav.appendFormula: Res + NOder 1";
194 fetchProposedTactic 1;
195 val (_,(tac,_,_)::_) = get_calc 1;
196 case tac of Rewrite_Set "Test_simplify" => ()
197 | _ => error "inform.sml: diff.behav.appendFormula: Res + NOder 2";
198 autoCalculate 1 CompleteCalc;
199 val ((pt,_),_) = get_calc 1;
200 if "[x = 1]" = UnparseC.term (fst (get_obj g_result pt [])) then ()
201 else error "inform.sml: diff.behav.appendFormula: on Frm + equ 3";
204 (*TOODOO broken with "reduce the number of TermC.parse*"------------------------------------\\
205 "--------- appendFormula: on Res + late deriv --------------------";
206 "--------- appendFormula: on Res + late deriv --------------------";
207 "--------- appendFormula: on Res + late deriv --------------------";
208 (*cp with "fun me" to test/../lucas-interpreter.sml:
209 re-build: fun locate_input_term ---------------------------------------------------";
212 CalcTree [(["equality (x+1=(2::real))", "solveFor x", "solutions L"],
213 ("Test", ["sqroot-test", "univariate", "equation", "test"],
214 ["Test", "squ-equ-test-subpbl1"]))];
215 Iterator 1; moveActiveRoot 1;
216 autoCalculate 1 CompleteCalcHead;
217 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
218 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 + - 1 * 2 = 0*);
220 appendFormula 1 "x = 1" (*|> Future.join*);
221 val ((pt,p),_) = get_calc 1;
222 val str = pr_ctree pr_short pt;
224 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)
225 then () (*finds 1 step too early: ([3,2], Res) "x = 1" also by script !!!*)
226 else error "inform.sml: diff.behav.appendFormula: Res + late d 1";
228 fetchProposedTactic 1;
229 val (_,(tac,_,_)::_) = get_calc 1;
230 case tac of Check_Postcond ["LINEAR", "univariate", "equation", "test"] => ()
231 | _ => error "inform.sml: diff.behav.appendFormula: Res + late d 2";
232 autoCalculate 1 CompleteCalc;
233 val ((pt,_),_) = get_calc 1;
234 if "[x = 1]" = UnparseC.term (fst (get_obj g_result pt [])) then ()
235 else error "inform.sml: diff.behav.appendFormula: Res + late d 3";
238 "--------- appendFormula: on Res + late deriv [x = 3 + - 2]---///--";
239 "--------- appendFormula: on Res + late deriv [x = 3 + - 2]---///--";
240 "--------- appendFormula: on Res + late deriv [x = 3 + - 2]---///--";
242 CalcTree [(["equality (x+1=(2::real))", "solveFor x", "solutions L"],
243 ("Test", ["sqroot-test", "univariate", "equation", "test"],
244 ["Test", "squ-equ-test-subpbl1"]))];
245 Iterator 1; moveActiveRoot 1;
246 autoCalculate 1 CompleteCalcHead;
247 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
248 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 + - 1 * 2 = 0*);
249 appendFormula 1 "[x = 3 + -2*1]" (*|> Future.join*);
250 val ((pt,p),_) = get_calc 1;
251 val str = pr_ctree pr_short pt;
253 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 ()
254 else error "inform.sml: diff.behav.appendFormula: Res + latEE 1";
255 autoCalculate 1 CompleteCalc;
256 val ((pt,p),_) = get_calc 1;
257 if "[x = 3 + - 2 * 1]" = UnparseC.term (fst (get_obj g_result pt [])) then ()
258 (* ~~~~~~~~~~ simplify as last step in any script ?!*)
259 else error "inform.sml: diff.behav.appendFormula: Res + latEE 2";
261 ----- broken with "reduce the number of TermC.parse*"---------------------------------------//*)
263 (*TOODOO broken with "reduce the number of TermC.parse*"------------------------------------\\
264 "--------- replaceFormula: on Res + = ----------------------------";
265 "--------- replaceFormula: on Res + = ----------------------------";
266 "--------- replaceFormula: on Res + = ----------------------------";
268 CalcTree [(["equality (x+1=(2::real))", "solveFor x", "solutions L"],
269 ("Test", ["sqroot-test", "univariate", "equation", "test"],
270 ["Test", "squ-equ-test-subpbl1"]))];
271 Iterator 1; moveActiveRoot 1;
272 autoCalculate 1 CompleteCalcHead;
273 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
274 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 + - 1 * 2 = 0*);
275 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*- 1 + x*);
277 replaceFormula 1 "-2 * 1 + (1 + x) = 0"; refFormula 1 (get_pos 1 1);
278 val ((pt,_),_) = get_calc 1;
279 val str = pr_ctree pr_short pt;
281 (* before AK110725 this was
282 ". ----- pblobj -----\n
284 2. x + 1 + - 1 * 2 = 0\n
285 2.1. x + 1 + - 1 * 2 = 0\n
286 2.2. 1 + x + - 1 * 2 = 0\n
287 2.3. 1 + (x + - 1 * 2) = 0\n
288 2.4. 1 + (x + -2) = 0\n
289 2.5. 1 + (x + -2 * 1) = 0\n
290 2.6. 1 + x + -2 * 1 = 0\n";
293 ". ----- pblobj -----\n"^
295 "2. x + 1 + - 1 * 2 = 0\n"^
296 "2.1. x + 1 + - 1 * 2 = 0\n"^
297 "2.2. 1 + x + - 1 * 2 = 0\n"^
298 "2.3. 1 + (x + - 1 * 2) = 0\n"^
299 "2.4. 1 + (x + - 2) = 0\n"^
300 "2.5. 1 + (x + - 2 * 1) = 0\n"^
301 "2.6. 1 + x + - 2 * 1 = 0\n" then()
302 else error "inform.sml: diff.behav.replaceFormula: on Res += 1";
304 autoCalculate 1 CompleteCalc;
305 val ((pt,pos as (p,_)),_) = get_calc 1;
306 if pos = ([],Res) andalso "[x = 1]" = (UnparseC.term o fst) (get_obj g_result pt p) then()
307 else error "inform.sml: diff.behav.replaceFormula: on Res + = 2";
309 ----- broken with "reduce the number of TermC.parse*"---------------------------------------//*)
311 (*TOODOO broken with "reduce the number of TermC.parse*"------------------------------------\\
312 "--------- replaceFormula: on Res + = 1st Nd ---------------------";
313 "--------- replaceFormula: on Res + = 1st Nd ---------------------";
314 "--------- replaceFormula: on Res + = 1st Nd ---------------------";
316 CalcTree [(["equality (x+1=(2::real))", "solveFor x", "solutions L"],
317 ("Test", ["sqroot-test", "univariate", "equation", "test"],
318 ["Test", "squ-equ-test-subpbl1"]))];
319 Iterator 1; moveActiveRoot 1;
320 autoCalculate 1 CompleteCalcHead;
321 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
322 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 + - 1 * 2 = 0*);
324 replaceFormula 1 "x + 1 = 4 + -2"; refFormula 1 (get_pos 1 1);
325 val ((pt,_),_) = get_calc 1;
326 val str = pr_ctree pr_short pt;
328 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 ()
329 else error "inform.sml: diff.behav.replaceFormula: on Res 1 + = 1";
330 autoCalculate 1 CompleteCalc;
331 val ((pt,pos as (p,_)),_) = get_calc 1;
332 if pos = ([],Res) andalso "[x = 1]" = (UnparseC.term o fst)(get_obj g_result pt p) then()
333 else error "inform.sml: diff.behav.replaceFormula: on Res + = 2";
335 ----- broken with "reduce the number of TermC.parse*"---------------------------------------//*)
337 "--------- replaceFormula: on Frm + = 1st Nd ---------------------";
338 "--------- replaceFormula: on Frm + = 1st Nd ---------------------";
339 "--------- replaceFormula: on Frm + = 1st Nd ---------------------";
341 CalcTree [(["equality (x+1=(2::real))", "solveFor x", "solutions L"],
342 ("Test", ["sqroot-test", "univariate", "equation", "test"],
343 ["Test", "squ-equ-test-subpbl1"]))];
344 Iterator 1; moveActiveRoot 1;
345 autoCalculate 1 CompleteCalcHead;
346 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
348 replaceFormula 1 "x + 1 = 4 + -2"; refFormula 1 (get_pos 1 1);
349 val ((pt,_),_) = get_calc 1;
350 val str = pr_ctree pr_short pt;
351 (*TOODOO broken with "reduce the number of TermC.parse*"------------------------------------\\
352 str = ". ----- pblobj -----\n1. x + 1 = 2\n";
354 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 ()
355 else error "inform.sml: diff.behav.replaceFormula: on Frm 1 + = 1";
356 autoCalculate 1 CompleteCalc;
357 val ((pt,pos as (p,_)),_) = get_calc 1;
359 if pos = ([],Res) andalso "[x = 1]" = (UnparseC.term o fst)(get_obj g_result pt p) then()
360 else error "inform.sml: diff.behav.replaceFormula: on Frm 1 + = 2";
362 ----- broken with "reduce the number of TermC.parse*"---------------------------------------//*)
364 "--------- replaceFormula: cut calculation -----------------------";
365 "--------- replaceFormula: cut calculation -----------------------";
366 "--------- replaceFormula: cut calculation -----------------------";
368 CalcTree [(["equality (x+1=(2::real))", "solveFor x", "solutions L"],
369 ("Test", ["sqroot-test", "univariate", "equation", "test"],
370 ["Test", "squ-equ-test-subpbl1"]))];
371 Iterator 1; moveActiveRoot 1;
372 autoCalculate 1 CompleteCalc;
373 moveActiveRoot 1; moveActiveDown 1;
374 if get_pos 1 1 = ([1], Frm) then ()
375 else error "inform.sml: diff.behav. cut calculation 1";
377 replaceFormula 1 "x + 1 = 4 + -2"; refFormula 1 (get_pos 1 1);
378 val ((pt,p),_) = get_calc 1;
379 val str = pr_ctree pr_short pt;
381 (*TOODOO broken with "reduce the number of TermC.parse*"------------------------------------\\
383 if p = ([1], Res) then ()
384 else error "inform.sml: diff.behav. cut calculation 2";
385 ----- broken with "reduce the number of TermC.parse*"---------------------------------------//*)
388 (* 040307 copied from informtest.sml; ... old version
389 "---------------- maximum-example, UC: Modeling / modifyCalcHead -";
390 "---------------- maximum-example, UC: Modeling / modifyCalcHead -";
391 "---------------- maximum-example, UC: Modeling / modifyCalcHead -";
394 val elems = ["fixedValues [r=Arbfix]", "maximum A", "valuesFor [a,b]",
395 "relations [A=a*b, (a/2) \<up> 2 + (b/2) \<up> 2 = r \<up> 2]",
396 "relations [A=a*b, (a/2) \<up> 2 + (b/2) \<up> 2 = r \<up> 2]",
397 "relations [A=a*b, a/2=r*sin alpha, b/2=r*cos (alpha::real)]",
398 (* \<up> these are the elements for the root-problem (in variants)*)
399 (*vvv these are elements required for subproblems*)
400 "boundVariable a", "boundVariable b", "boundVariable alpha",
401 "interval {x::real. 0 <= x & x <= 2*r}",
402 "interval {x::real. 0 <= x & x <= 2*r}",
403 "interval {x::real. 0 <= x & x <= pi}",
404 "errorBound (eps=(0::real))"]
405 (*specifying is not interesting for this example*)
406 val spec = ("DiffApp", ["maximum_of", "function"],
407 ["DiffApp", "max_by_calculus"]);
408 (*the empty model with descriptions for user-guidance by Model_Problem*)
409 val empty_model = [Given ["fixedValues []"],
410 Find ["maximum", "valuesFor"],
411 Relate ["relations []"]];
414 (*!!!!!!!!!!!!!!!!! DON'T USE me FOR FINDING nxt !!!!!!!!!!!!!!!!!!*)
415 val (p,_,f,nxt,_,pt) = CalcTreeTEST [(elems, spec)];
416 (*val nxt = ("Model_Problem", ...*)
417 val pbl = get_obj g_pbl pt (fst p); (writeln o (I_Model.to_string ctxt)) pbl;
419 val (p,_,f,nxt,_,pt) = me nxt p c pt;
420 (*nxt = Add_Given "fixedValues [r = Arbfix]"*)
421 val pbl = get_obj g_pbl pt (fst p); (writeln o (I_Model.to_string ctxt)) pbl;
423 (0 ,[] ,false ,#Given ,Inc fixedValues [] ,(??.empty, [])),
424 (0 ,[] ,false ,#Find ,Inc maximum ,(??.empty, [])),
425 (0 ,[] ,false ,#Find ,Inc valuesFor ,(??.empty, [])),
426 (0 ,[] ,false ,#Relate ,Inc relations [] ,(??.empty, []))]*)
428 (*the empty CalcHead is checked w.r.t the model and re-established as such*)
429 val (b,pt,ocalhd) = input_icalhd pt (p,"", empty_model, Pbl, References.empty);
430 val pbl = get_obj g_pbl pt (fst p); (writeln o (I_Model.to_string ctxt)) pbl;
431 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";
433 (*there is one input to the model (could be more)*)
435 input_icalhd pt (p,"", [Given ["fixedValues [r=Arbfix]"],
436 Find ["maximum", "valuesFor"],
437 Relate ["relations"]], Pbl, References.empty);
438 val pbl = get_obj g_pbl pt (fst p); (writeln o (I_Model.to_string ctxt)) pbl;
439 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 ()
440 else error "informtest.sml: diff.behav. max 2";
442 (*this input is complete in variant 3, but the ME doesn't recognize FIXXXXME
443 val (b,pt''''',ocalhd) =
444 input_icalhd pt (p,"", [Given ["fixedValues [r=Arbfix]"],
445 Find ["maximum A", "valuesFor [a,b]"],
446 Relate ["relations [A=a*b, a/2=r*sin alpha, \
447 \b/2=r*cos alpha]"]], Pbl, References.empty);
448 val pbl = get_obj g_pbl pt''''' (fst p); (writeln o (I_Model.to_string ctxt)) pbl;
449 if ocalhd2str ocalhd = ------------ \<up> \<up> \<up> ^ missing !!!*)
451 (*this input is complete in variant 1 (variant 3 does not work yet)*)
452 val (b,pt''''',ocalhd) =
453 input_icalhd pt (p,"", [Given ["fixedValues [r=Arbfix]"],
454 Find ["maximum A", "valuesFor [a,b]"],
455 Relate ["relations [A=a*b, \
456 \(a/2) \<up> 2 + (b/2) \<up> 2 = r \<up> 2]"]],
457 Pbl, References.empty);
458 val pbl = get_obj g_pbl pt''''' (fst p); (writeln o (I_Model.to_string ctxt)) pbl;
460 modifycalcheadOK2xml 111 (bool2str b) ocalhd;
464 "--------- syntax error ------------------------------------------";
465 "--------- syntax error ------------------------------------------";
466 "--------- syntax error ------------------------------------------";
468 CalcTree [(["equality (x+1=(2::real))", "solveFor x", "solutions L"],
469 ("Test", ["sqroot-test", "univariate", "equation", "test"],
470 ["Test", "squ-equ-test-subpbl1"]))];
471 Iterator 1; moveActiveRoot 1;
472 autoCalculate 1 CompleteCalcHead;
473 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
474 autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 + - 1 * 2 = 0*);
476 appendFormula 1 " x - "; (*<ERROR> syntax error in ' x - ' </ERROR>*)
477 val ((pt,_),_) = get_calc 1;
478 val str = pr_ctree pr_short pt;
480 if str = ". ----- pblobj -----\n1. x + 1 = 2\n" then ()
481 else error "inform.sml: diff.behav.appendFormula: syntax error";
484 "--------- CAS-command on ([],Pbl) -------------------------------";
485 "--------- CAS-command on ([],Pbl) -------------------------------";
486 "--------- CAS-command on ([],Pbl) -------------------------------";
487 val (p,_,f,nxt,_,pt) =
488 CalcTreeTEST [([], ("empty_thy_id", ["empty_probl_id"], ["empty_meth_id"]))];
489 val ifo = "solve (x + 1 = (2::real), x::real)";
490 (*TOODOO broken with "reduce the number of TermC.parse*"------------------------------------\\
491 ERROR lev_back': called by ([],_)
493 val (_,(_,c,(pt,p))) = Step_Solve.by_term (pt,p) "solve (x + 1 = (2::real), x::real)";
494 ----- broken with "reduce the number of TermC.parse*"---------------------------------------//*)
496 This trick \<up> \<up> \<up> micked input of \<up> \<up> \<up> \<up> \<up> ^^ in the front-end.
497 The trick worked in changeset fbaff8cf0179, it does not work in 59c5dd27d589 anymore
498 (TODO hg bisect ?) and raises the ERROR Undefined fact: "xfoldr_Nil".
500 Compare tests "CAS-command" in test/../inssort.sml etc.
501 ---------------------------------------------------------------------------------------------
502 Test_Tool.show_pt pt;
503 val nxt = (Apply_Method ["Test", "squ-equ-test-subpbl1"]);
504 val (p,_,f,nxt,_,pt) = me nxt p [] pt;
505 if p = ([1], Frm) andalso f2str f = "x + 1 = 2" then ()
506 else error "inform.sml: diff.behav. CAScmd ([],Pbl)";
508 -----------------------------------------------------------------------------------------------*)
510 "--------- CAS-command on ([],Pbl) FE-interface ------------------";
511 "--------- CAS-command on ([],Pbl) FE-interface ------------------";
512 "--------- CAS-command on ([],Pbl) FE-interface ------------------";
514 CalcTree [([], ("empty_thy_id", ["empty_probl_id"], ["empty_meth_id"]))];
517 replaceFormula 1 "solve(x + 1 = (2::real), x)";
518 autoCalculate 1 CompleteCalc;
519 val ((pt,p),_) = get_calc 1;
520 Test_Tool.show_pt pt;
521 (*TOODOO broken with "reduce the number of TermC.parse*"------------------------------------\\
524 if p = ([], Res) then ()
525 else error "inform.sml: diff.behav. CAScmd ([],Pbl) FE-interface";
527 ----- broken with "reduce the number of TermC.parse*"---------------------------------------//*)
529 "--------- inform [rational,simplification] ----------------------";
530 "--------- inform [rational,simplification] ----------------------";
531 "--------- inform [rational,simplification] ----------------------";
533 CalcTree [(["Term (a * x / (b * x) + c * x / (d * x) + e / f)", "normalform N"],
534 ("Rational", ["rational", "simplification"], ["simplification", "of_rationals"]))];
535 Iterator 1; moveActiveRoot 1;
536 autoCalculate 1 CompleteCalcHead;
538 "--- (- 1) give a preview on the calculation without any input";
540 autoCalculate 1 CompleteCalc;
541 val ((pt, p), _) = get_calc 1;
542 Test_Tool.show_pt pt;
544 (([], Frm), Simplify (a * x / (b * x) + c * x / (d * x) + e / f)),
545 (([1], Frm), a * x / (b * x) + c * x / (d * x) + e / f),
546 (([1], Res), a / b + c / d + e / f), <--- (1) input arbitrary
547 (([2], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
548 (([3], Res), (a * (d * f) + b * (c * f) + b * (d * e)) / (b * (d * f))),
549 (([4], Res), (a * d * f + b * c * f + b * d * e) / (b * d * f)), <--- (2) input next
550 (([], Res), (a * d * f + b * c * f + b * d * e) / (b * d * f))] <--- (3) is also final result
553 "--- (0) user input as the *first* step does not work, thus impdo at least 1 step";
554 autoCalculate 1 (Steps 1);
555 autoCalculate 1 (Steps 1);
556 val ((pt, p), _) = get_calc 1;
557 (*Test_Tool.show_pt pt;
559 (([], Frm), Simplify (a * x / (b * x) + c * x / (d * x) + e / f)),
560 (([1], Frm), a * x / (b * x) + c * x / (d * x) + e / f),
561 (([1], Res), a / b + c / d + e / f)]
563 "--- (1) input an arbitrary next formula";
564 appendFormula 1 "((a * d) + (c * b)) / (b * d) + e / f" (*|> Future.join*);
565 val ((pt, p), _) = get_calc 1;
566 (*Test_Tool.show_pt pt;
568 (([], Frm), Simplify (a * x / (b * x) + c * x / (d * x) + e / f)),
569 (([1], Frm), a * x / (b * x) + c * x / (d * x) + e / f),
570 (([1], Res), a / b + c / d + e / f),
571 (([2,1], Frm), a / b + c / d + e / f),
572 (([2,1], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
573 (([2,2], Res), (a * d + c * b) / (b * d) + e / f),
574 (([2], Res), (a * d + c * b) / (b * d) + e / f)]
576 val ((pt,p),_) = get_calc 1;
578 (*TOODOO broken with "reduce the number of TermC.parse*"------------------------------------\\* )
581 if p = ([2], Res) andalso (length o children o (get_nd pt)) (fst p) = 2 then ()
582 else error ("inform.sml: [rational,simplification] 1");
584 "--- (2) input the next formula that would be presented by mat-engine";
585 (* generate a preview:
586 autoCalculate 1 (Steps 1);
587 val ((pt, p), _) = get_calc 1;
588 Test_Tool.show_pt pt;
590 (([], Frm), Simplify (a * x / (b * x) + c * x / (d * x) + e / f)),
591 (([1], Frm), a * x / (b * x) + c * x / (d * x) + e / f),
592 (([1], Res), a / b + c / d + e / f),
593 (([2,1], Frm), a / b + c / d + e / f),
594 (([2,1], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
595 (([2,2], Res), (a * d + c * b) / (b * d) + e / f),
596 (([2], Res), (a * d + c * b) / (b * d) + e / f),
597 (([3], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f))] <--- input this
599 appendFormula 1 "(b * d * e + b * c * f + a * d * f) / (b * d * f)" (*|> Future.join*);
600 val ((pt, p), _) = get_calc 1;
601 (*Test_Tool.show_pt pt;
603 (([], Frm), Simplify (a * x / (b * x) + c * x / (d * x) + e / f)),
604 (([1], Frm), a * x / (b * x) + c * x / (d * x) + e / f),
605 (([1], Res), a / b + c / d + e / f),
606 (([2,1], Frm), a / b + c / d + e / f),
607 (([2,1], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
608 (([2,2], Res), (a * d + c * b) / (b * d) + e / f),
609 (([2], Res), (a * d + c * b) / (b * d) + e / f),
610 (([3], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f))]
612 if p = ([3], Res) andalso (length o children o (get_nd pt)) (fst p) = 0 then ()
613 else error ("inform.sml: [rational,simplification] 2");
615 "--- (3) input the exact final result";
616 appendFormula 1 "(b * d * e + b * c * f + a * d * f) / (b * d * f)" (*|> Future.join*);
617 val ((pt, p), _) = get_calc 1;
618 (*Test_Tool.show_pt pt;
620 (([], Frm), Simplify (a * x / (b * x) + c * x / (d * x) + e / f)),
621 (([1], Frm), a * x / (b * x) + c * x / (d * x) + e / f),
622 (([1], Res), a / b + c / d + e / f),
623 (([2,1], Frm), a / b + c / d + e / f),
624 (([2,1], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
625 (([2,2], Res), (a * d + c * b) / (b * d) + e / f),
626 (([2], Res), (a * d + c * b) / (b * d) + e / f),
627 (([3], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
628 (([4,1], Frm), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
629 (([4,1], Res), (a * (d * f) + b * (c * f) + b * (d * e)) / (b * (d * f))),
630 (([4,2], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
631 (([4], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f))]
633 if p = ([4], Res) andalso (length o children o (get_nd pt)) (fst p) = 2 then ()
634 else error ("inform.sml: [rational,simplification] 3");
636 "--- (4) finish the calculation + check the postcondition (in the future)";
637 autoCalculate 1 CompleteCalc;
638 val ((pt, p), _) = get_calc 1;
639 val (t, asm) = get_obj g_result pt [];
640 if UnparseC.term t = "(a * d * f + b * c * f + b * d * e) / (b * d * f)" andalso
641 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\"]"*)
642 "[]" (*..found broken in child of 33913fe24685, error covered by CAS-command *)
643 then () else error "inform [rational,simplification] changed at end";
644 (*Test_Tool.show_pt pt;
646 (([], Frm), Simplify (a * x / (b * x) + c * x / (d * x) + e / f)),
647 (([1], Frm), a * x / (b * x) + c * x / (d * x) + e / f),
648 (([1], Res), a / b + c / d + e / f),
649 (([2,1], Frm), a / b + c / d + e / f),
650 (([2,1], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
651 (([2,2], Res), (a * d + c * b) / (b * d) + e / f),
652 (([2], Res), (a * d + c * b) / (b * d) + e / f),
653 (([3], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
654 (([4,1], Frm), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
655 (([4,1], Res), (a * (d * f) + b * (c * f) + b * (d * e)) / (b * (d * f))),
656 (([4,2], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
657 (([4], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
658 (([5], Res), (a * (d * f) + b * (c * f) + b * (d * e)) / (b * (d * f))),
659 (([6], Res), (a * d * f + b * c * f + b * d * e) / (b * d * f)),
660 (([], Res), (a * d * f + b * c * f + b * d * e) / (b * d * f))]
663 ----- broken with "reduce the number of TermC.parse*"------------------------------------//*)
665 "--------- Take as 1st tac, start with <NEW> (CAS input) ---------";
666 "--------- Take as 1st tac, start with <NEW> (CAS input) ---------";
667 "--------- Take as 1st tac, start with <NEW> (CAS input) ---------";
668 val t = TermC.str2term "Diff (x \<up> 2 + x + 1, x)";
669 case t of Const (\<^const_name>\<open>Diff\<close>, _) $ _ => ()
671 error "diff.sml behav.changed for CAS Diff (..., x)";
673 "-----------------------------------------------------------------";
674 (*1>*)reset_states ();
675 (*2>*)CalcTree [([], ("empty_thy_id", ["empty_probl_id"], ["empty_meth_id"]))];
676 (*3>*)Iterator 1;moveActiveRoot 1;
677 "----- here the Headline has been finished";
678 (*4>*)moveActiveFormula 1 ([],Pbl);
679 (*5>*)replaceFormula 1 "Diff (x \<up> 2 + x + 1, x)";
680 val ((pt,_),_) = get_calc 1;
681 val PblObj {probl, meth, spec, fmz, loc, ...} = get_obj I pt [];
682 val (SOME istate, NONE) = loc;
683 (*default_print_depth 5;*)
684 writeln"-----------------------------------------------------------";
686 writeln (I_Model.to_string ctxt probl);
687 writeln (I_Model.to_string ctxt meth);
688 writeln (Istate.string_of (fst istate));
690 refFormula 1 ([],Pbl) (*--> correct CalcHead*);
691 (*081016 NOT necessary (but leave it in Java):*)
692 (*6>*)(*completeCalcHead*)autoCalculate 1 CompleteCalcHead;
693 "----- here the CalcHead has been completed --- ONCE MORE ?????";
695 (***difference II***)
696 val ((pt,p),_) = get_calc 1;
697 (*val p = ([], Pbl)*)
698 val PblObj {probl, meth, spec, fmz, loc, ...} = get_obj I pt [];
699 val (SOME istate, NONE) = loc;
700 (*default_print_depth 5;*) writeln (Istate.string_of (fst istate)); (*default_print_depth 3;*)
703 ??.empty, Sundef, false)*)
704 (*default_print_depth 5;*) spec; (*default_print_depth 3;*)
706 ["derivative_of", "function"],
707 ["diff", "differentiate_on_R"]) : spec*)
708 writeln (I_Model.to_string ctxt probl);
710 (1 ,[1] ,true ,#Given ,Cor functionTerm (x \<up> 2 + x + 1) ,(f_, [x \<up> 2 + x + 1])),
711 (2 ,[1] ,true ,#Given ,Cor differentiateFor x ,(v_, [x])),
712 (3 ,[1] ,true ,#Find ,Cor derivative f_'_f ,(f_'_f, [f_'_f]))]*)
713 writeln (I_Model.to_string ctxt meth);
715 (1 ,[1] ,true ,#Given ,Cor functionTerm (x \<up> 2 + x + 1) ,(f_, [x \<up> 2 + x + 1])),
716 (2 ,[1] ,true ,#Given ,Cor differentiateFor x ,(v_, [x])),
717 (3 ,[1] ,true ,#Find ,Cor derivative f_'_f ,(f_'_f, [f_'_f]))]*)
718 writeln"-----------------------------------------------------------";
719 (*7>*)fetchProposedTactic 1 (*--> Apply_Method*);
720 (*WN081028 fixed <ERROR> helpless </ERROR> by inform returning ...(.,Met)*)
721 autoCalculate 1 CompleteCalc;
722 val ((pt,p),_) = get_calc 1;
723 val Form res = (#1 o ME_Misc.pt_extract) (pt, ([],Res));
724 Test_Tool.show_pt pt;
726 if p = ([], Res) andalso UnparseC.term res = "1 + 2 * x" then ()
727 else error "diff.sml behav.changed for Diff (x \<up> 2 + x + 1, x)";
730 "--------- Take as 1st tac, start from exp -----------------------";
731 "--------- Take as 1st tac, start from exp -----------------------";
732 "--------- Take as 1st tac, start from exp -----------------------";
733 (*the following input is copied from BridgeLog Java <==> SML,
734 omitting unnecessary inputs*)
735 (*1>*)reset_states ();
736 (*2>*)CalcTree [(["functionTerm (x \<up> 2 + x + 1)", "differentiateFor x", "derivative f_'_f"],("Isac_Knowledge",["derivative_of", "function"],["diff", "differentiate_on_R"]))];
737 (*3>*)Iterator 1; moveActiveRoot 1;
739 (*6>*)(*completeCalcHead*)autoCalculate 1 CompleteCalcHead;
740 (***difference II***)
741 val ((pt,_),_) = get_calc 1;
742 val PblObj {probl, meth, spec, fmz, loc, ...} = get_obj I pt [];
743 val (SOME istate, NONE) = loc;
744 (*default_print_depth 5;*) writeln (Istate.string_of (fst istate)); (*default_print_depth 3;*)
747 ??.empty, Sundef, false)*)
748 (*default_print_depth 5;*) spec; (*default_print_depth 3;*)
750 ["derivative_of", "function"],
751 ["diff", "differentiate_on_R"]) : spec*)
752 writeln (I_Model.to_string ctxt probl);
754 (1 ,[1] ,true ,#Given ,Cor functionTerm (x \<up> 2 + x + 1) ,(f_, [x \<up> 2 + x + 1])),
755 (2 ,[1] ,true ,#Given ,Cor differentiateFor x ,(v_, [x])),
756 (3 ,[1] ,true ,#Find ,Cor derivative f_'_f ,(f_'_f, [f_'_f]))]*)
757 writeln (I_Model.to_string ctxt meth);
759 (1 ,[1] ,true ,#Given ,Cor functionTerm (x \<up> 2 + x + 1) ,(f_, [x \<up> 2 + x + 1])),
760 (2 ,[1] ,true ,#Given ,Cor differentiateFor x ,(v_, [x])),
761 (3 ,[1] ,true ,#Find ,Cor derivative f_'_f ,(f_'_f, [f_'_f]))]*)
762 writeln"-----------------------------------------------------------";
763 (*7>*)fetchProposedTactic 1 (*--> Apply_Method*);
764 autoCalculate 1 (Steps 1);
765 val ((pt,p),_) = get_calc 1;
766 val Form res = (#1 o ME_Misc.pt_extract) (pt, p);
767 if UnparseC.term res = "d_d x (x \<up> 2 + x + 1)" then ()
768 else error "diff.sml Diff (x \<up> 2 + x + 1, x) from exp";
771 "--------- implicit_take, start with <NEW> (CAS input) ---------------";
772 "--------- implicit_take, start with <NEW> (CAS input) ---------------";
773 "--------- implicit_take, start with <NEW> (CAS input) ---------------";
775 CalcTree [([], ("empty_thy_id", ["empty_probl_id"], ["empty_meth_id"]))];
776 (*[[from sml: > @@@@@begin@@@@@
778 [[from sml: <CALCTREE>
779 [[from sml: <CALCID> 1 </CALCID>
780 [[from sml: </CALCTREE>
781 [[from sml: @@@@@end@@@@@*)
783 (*[[from sml: > @@@@@begin@@@@@
785 [[from sml: <ADDUSER>
786 [[from sml: <CALCID> 1 </CALCID>
787 [[from sml: <USERID> 1 </USERID>
788 [[from sml: </ADDUSER>
789 [[from sml: @@@@@end@@@@@*)
791 (*[[from sml: > @@@@@begin@@@@@
793 [[from sml: <CALCITERATOR>
794 [[from sml: <CALCID> 1 </CALCID>
795 [[from sml: <POSITION>
796 [[from sml: <INTLIST>
797 [[from sml: </INTLIST>
798 [[from sml: <POS> Pbl </POS>
799 [[from sml: </POSITION>
800 [[from sml: </CALCITERATOR>
801 [[from sml: @@@@@end@@@@@*)
802 getFormulaeFromTo 1 ([],Pbl) ([],Pbl) 0 false;
803 (*[[from sml: > @@@@@begin@@@@@ STILL CORRECT
805 [[from sml: <GETELEMENTSFROMTO>
806 [[from sml: <CALCID> 1 </CALCID>
807 [[from sml: <FORMHEADS>
808 [[from sml: <CALCFORMULA>
809 [[from sml: <POSITION>
810 [[from sml: <INTLIST>
811 [[from sml: </INTLIST>
812 [[from sml: <POS> Pbl </POS>
813 [[from sml: </POSITION>
814 [[from sml: <FORMULA>
816 [[from sml: <ISA> ________________________________________________ </ISA>
817 [[from sml: </MATHML>
819 [[from sml: </FORMULA>
820 [[from sml: </CALCFORMULA>
821 [[from sml: </FORMHEADS>
822 [[from sml: </GETELEMENTSFROMTO>
823 [[from sml: @@@@@end@@@@@*)
824 refFormula 1 ([],Pbl);
825 (*[[from sml: > @@@@@begin@@@@@ STILL CORRECT
827 [[from sml: <REFFORMULA>
828 [[from sml: <CALCID> 1 </CALCID>
829 [[from sml: <CALCHEAD status = "incorrect">
830 [[from sml: <POSITION>
831 [[from sml: <INTLIST>
832 [[from sml: </INTLIST>
833 [[from sml: <POS> Pbl </POS>
834 [[from sml: </POSITION>
837 [[from sml: <ISA> Problem (ThyC.id_empty, [e_pblID]) </ISA>
838 [[from sml: </MATHML>
841 [[from sml: <GIVEN> </GIVEN>
842 [[from sml: <WHERE> </WHERE>
843 [[from sml: <FIND> </FIND>
844 [[from sml: <RELATE> </RELATE>
846 [[from sml: <BELONGSTO> Pbl </BELONGSTO>
847 [[from sml: <SPECIFICATION>
848 [[from sml: <THEORYID> ThyC.id_empty </THEORYID>
849 [[from sml: <PROBLEMID>
850 [[from sml: <STRINGLIST>
851 [[from sml: <STRING> Problem.id_empty </STRING>
852 [[from sml: </STRINGLIST>
853 [[from sml: </PROBLEMID>
854 [[from sml: <METHODID>
855 [[from sml: <STRINGLIST>
856 [[from sml: <STRING> e_metID </STRING>
857 [[from sml: </STRINGLIST>
858 [[from sml: </METHODID>
859 [[from sml: </SPECIFICATION>
860 [[from sml: </CALCHEAD>
861 [[from sml: </REFFORMULA>
862 [[from sml: @@@@@end@@@@@*)
863 moveActiveFormula 1 ([],Pbl);
864 (*[[from sml: > @@@@@begin@@@@@
866 [[from sml: <CALCITERATOR>
867 [[from sml: <CALCID> 1 </CALCID>
868 [[from sml: <POSITION>
869 [[from sml: <INTLIST>
870 [[from sml: </INTLIST>
871 [[from sml: <POS> Pbl </POS>
872 [[from sml: </POSITION>
873 [[from sml: </CALCITERATOR>
874 [[from sml: @@@@@end@@@@@*)
875 replaceFormula 1 "Simplify (1+2)";
876 (*[[from sml: > @@@@@begin@@@@@
878 [[from sml: <REPLACEFORMULA>
879 [[from sml: <CALCID> 1 </CALCID>
880 [[from sml: <CALCCHANGED>
881 [[from sml: <UNCHANGED>
882 [[from sml: <INTLIST>
883 [[from sml: </INTLIST>
884 [[from sml: <POS> Pbl </POS>
885 [[from sml: </UNCHANGED>
886 [[from sml: <DELETED>
887 [[from sml: <INTLIST>
888 [[from sml: </INTLIST>
889 [[from sml: <POS> Pbl </POS>
890 [[from sml: </DELETED>
891 [[from sml: <GENERATED>
892 [[from sml: <INTLIST>
893 [[from sml: </INTLIST>
894 [[from sml: <POS> Met </POS> DIFFERENCE: Pbl
895 [[from sml: </GENERATED>
896 [[from sml: </CALCCHANGED>
897 [[from sml: </REPLACEFORMULA>
898 [[from sml: @@@@@end@@@@@*)
899 getFormulaeFromTo 1 ([],Pbl) ([],Pbl) 0 false(* DIFFERENCE: Pbl*);
913 <ISA> Simplify (1 + 2) </ISA> WORKS !!!!!
920 getFormulaeFromTo 1 ([],Pbl) ([],Met) 0 false;
921 (*[[from sml: > @@@@@begin@@@@@
923 [[from sml: <SYSERROR>
924 [[from sml: <CALCID> 1 </CALCID>
925 [[from sml: <ERROR> error in getFormulaeFromTo </ERROR>
926 [[from sml: </SYSERROR>
927 [[from sml: @@@@@end@@@@@*)
928 (*step into getFormulaeFromTo --- bug corrected...*)
930 "--------- build fun check_for' ------------------------------";
931 "--------- build fun check_for' ------------------------------";
932 "--------- build fun check_for' ------------------------------";
933 val subst = [(TermC.str2term "bdv", TermC.str2term "x")]: subst;
934 val rls = norm_Rational
935 val pat = TermC.parse_patt @{theory} "(?a + ?b)/(?b + ?c) = ?a / ?c";
936 val (res, inf) = (TermC.str2term "(2 + 3)/(3 + 4)", TermC.str2term "2 / 4");
937 val (res, inf) = (TermC.str2term "(2 + 3)/(3 + 4)", TermC.str2term "1 / 2");
939 val (res', _, _, rewritten) = (*rewritten: the lhs of the pattern TermC.matches in res*)
940 rew_sub thy 1 [] e_rew_ord Rule_Set.empty false [] (HOLogic.Trueprop $ pat) res;
941 if rewritten then NONE else SOME "e_errpatID";
943 val norm_res = case rewrite_set_ (Isac()) false rls res' of
945 | SOME (norm_res, _) => norm_res
947 val norm_inf = case rewrite_set_ (Isac()) false rls inf of
949 | SOME (norm_inf, _) => norm_inf;
954 val pat = TermC.parse_patt @{theory} "(?a + ?b)/?a = ?b";
955 val (res, inf) = (TermC.str2term "(2 + 3)/2", TermC.str2term "3");
956 if check_for' (res, inf) subst ("errpatID", pat) rls = SOME "errpatID"
957 then () else error "error patt example1 changed";
959 val pat = TermC.parse_patt @{theory} "(?a + ?b)/(?a + ?c) = ?b / ?c";
960 val (res, inf) = (TermC.str2term "(2 + 3)/(2 + 4)", TermC.str2term "3 / 4");
961 if check_for' (res, inf) subst ("errpatID", pat) rls = SOME "errpatID"
962 then () else error "error patt example2 changed";
964 val pat = TermC.parse_patt @{theory} "(?a + ?b)/(?b + ?c) = ?a / ?c";
965 val (res, inf) = (TermC.str2term "(2 + 3)/(3 + 4)", TermC.str2term "2 / 4");
966 if check_for' (res, inf) subst ("errpatID", pat) rls = SOME "errpatID"
967 then () else error "error patt example3 changed";
969 val inf = TermC.str2term "1 / 2";
970 if check_for' (res, inf) subst ("errpatID", pat) rls = SOME "errpatID"
971 then () else error "error patt example3 changed";
973 "--------- build fun check_for' ?bdv -------------------------";
974 "--------- build fun check_for' ?bdv -------------------------";
975 "--------- build fun check_for' ?bdv -------------------------";
976 val subst = [(TermC.str2term "bdv", TermC.str2term "x")]: subst;
977 val t = TermC.str2term "d_d x (x \<up> 2 + sin (x \<up> 4))";
978 val SOME (t, _) = rewrite_set_inst_ thy false subst norm_diff t;
979 if UnparseC.term t = "2 * x + cos (x \<up> 4) * 4 * x \<up> 3" then ()
980 else error "build fun check_for' ?bdv changed 1";
983 val pat = TermC.parse_patt @{theory} "d_d ?bdv (sin ?u) = cos (d_d ?bdv ?u)";
984 val (res, inf) = (TermC.str2term "2 * x + d_d x (sin (x \<up> 4))", TermC.str2term "2 * x + cos (4 * x \<up> 3)");
986 val (res', _, _, rewritten) = (*rewritten: the lhs of the pattern TermC.matches in res*)
987 rew_sub thy 1 subst e_rew_ord Rule_Set.empty false [] (HOLogic.Trueprop $ pat) res;
988 if UnparseC.term res' = "2 * x + cos (d_d x (x \<up> 4))" andalso rewritten then ()
989 else error "build fun check_for' ?bdv changed 2";
991 val norm_res = case rewrite_set_inst_ (Isac()) false subst rls res' of
993 | SOME (norm_res, _) => norm_res;
994 if UnparseC.term norm_res = "2 * x + cos (4 * x \<up> 3)" then ()
995 else error "build fun check_for' ?bdv changed 3";
997 val norm_inf = case rewrite_set_inst_ (Isac()) false subst rls inf of
999 | SOME (norm_inf, _) => norm_inf;
1000 if UnparseC.term norm_inf = "2 * x + cos (4 * x \<up> 3)" then ()
1001 else error "build fun check_for' ?bdv changed 4";
1004 if norm_res = norm_inf then ()
1005 else error "build fun check_for' ?bdv changed 5";
1007 if Error_Pattern.check_for' (res, inf) (subst: subst) ("errpatID": Error_Pattern.id, pat) rls = SOME "errpatID"
1008 then () else error "error patt example1 changed";
1010 "--------- build fun check_for ------------------------";
1011 "--------- build fun check_for ------------------------";
1012 "--------- build fun check_for ------------------------";
1014 (TermC.str2term "d_d x (x \<up> 2) + d_d x (sin (x \<up> 4))",
1015 TermC.str2term "d_d x (x \<up> 2) + cos (4 * x \<up> 3)");
1016 val {errpats, nrls = rls, scr = Prog prog, ...} = MethodC.from_store ["diff", "differentiate_on_R"]
1018 val env = [(TermC.str2term "v_v", TermC.str2term "x")];
1020 [Error_Pattern.empty, (*generalised for testing*)
1021 ("chain-rule-diff-both",
1022 [TermC.parse_patt @{theory} "d_d ?bdv (sin ?u) = cos (d_d ?bdv ?u)",
1023 TermC.parse_patt @{theory} "d_d ?bdv (cos ?u) = - sin (d_d ?bdv ?u)",
1024 TermC.parse_patt @{theory} "d_d ?bdv (?u \<up> ?n) = ?n * ?u \<up> (?n - 1)",
1025 TermC.parse_patt @{theory} "d_d ?bdv (LogExp.ln ?u) = 1 / ?u",
1026 TermC.parse_patt @{theory} "d_d ?bdv (LogExp.ln ?u) = 1 / d_d ?bdv ?u"],
1027 [@{thm diff_sin_chain}, @{thm diff_cos_chain}, @{thm diff_pow_chain},
1028 @{thm diff_ln_chain}, @{thm diff_exp_chain}])];
1029 case Error_Pattern.check_for (res, inf) (prog, env) (errpats, rls) of SOME _ => ()
1030 | NONE => error "Error_Pattern.check_for broken";
1033 "--------- embed fun check_for ------------------------";
1034 "--------- embed fun check_for ------------------------";
1035 "--------- embed fun check_for ------------------------";
1038 [(["functionTerm (x \<up> 2 + sin (x \<up> 4))", "differentiateFor x", "derivative f_f'"],
1039 ("Isac_Knowledge", ["derivative_of", "function"], ["diff", "differentiate_on_R"]))];
1042 autoCalculate 1 CompleteCalcHead;
1043 autoCalculate 1 (Steps 1);
1044 autoCalculate 1 (Steps 1);(*([1], Res), d_d x (x \<up> 2) + d_d x (sin (x \<up> 4))*)
1045 (*autoCalculate 1 (Steps 1);([2], Res), d_d x (x \<up> 2) + cos (x \<up> 4) * d_d x (x \<up> \<up> 4)*)
1047 "~~~~~ fun appendFormula , args:"; val (cI, (ifo:TermC.as_string)) = (1, "d_d x (x \<up> 2) + cos (4 * x \<up> 3)");
1048 "~~~~~ fun appendFormula' , args:"; val (cI, (ifo: TermC.as_string)) = (cI, ifo);
1049 val cs = get_calc cI
1050 val pos = get_pos cI 1;
1051 (*+*)if pos = ([1], Res) then () else error "inform with (positive) Error_Pattern.check_for broken 1";
1052 val ("ok", cs' as (_, _, ptp)) = (*case*) Step.do_next pos cs (*of*);
1053 (*case*) Step_Solve.by_term ptp (encode ifo) (*of*); (*ERROR WAS: "no derivation found"*)
1054 "~~~~~ fun Step_Solve.by_term , args:"; val (((*next_*)cs as (_, _, (pt, pos as (p, _))): Calc.state_post), istr)
1055 = (cs', (encode ifo));
1056 val ctxt = get_ctxt pt pos (*see TODO.thy*)
1057 val SOME f_in = (*case*) TermC.parseNEW (ThyC.id_to_ctxt "Isac_Knowledge") istr (*of*);
1058 val pos_pred = lev_back' pos
1059 val f_pred = Ctree.get_curr_formula (pt, pos_pred);
1060 (*if*) f_pred = f_in; (*else*)
1061 val NONE = (*case*) CAS_Cmd.input f_in (*of*);
1062 (*old* )val (_, _, metID) = get_obj g_spec pt (par_pblobj pt p)
1063 (*old*)val {scr = prog, ...} = MethodC.from_store metID
1064 (*old*)val istate = get_istate_LI pt pos
1065 (*old*)val ctxt = get_ctxt pt pos
1067 val LI.Not_Derivable =
1068 (*case*) LI.locate_input_term (pt, pos) f_in (*of*);
1069 val pp = Ctree.par_pblobj pt p
1070 val (errpats, nrls, prog) = case MethodC.from_store (Ctree.get_obj Ctree.g_metID pt pp) of
1071 {errpats, nrls, scr = Rule.Prog prog, ...} => (errpats, nrls, prog)
1072 | _ => error "inform: uncovered case of MethodC.from_store"
1074 (*+*)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 \<up> ?n) = ?n * ?u \<up> (?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 \<up> ?n) = ?n * ?u \<up> (?n - 1) * d_d ?bdv ?u\", \"d_d ?bdv (LogExp.ln ?u) = d_d ?bdv ?u / ?u\", \"d_d ?bdv (exp ?u) = exp ?u * d_d ?x ?u\"]]"
1075 (*+*)then () else error "inform with (positive) Error_Pattern.check_for broken 3";
1077 val {env, ...} = Ctree.get_istate_LI pt pos |> Istate.the_pstate
1079 (*+*)if UnparseC.term f_pred = "d_d x (x \<up> 2) + d_d x (sin (x \<up> 4))" andalso
1080 (*+*) UnparseC.term f_in = "d_d x (x \<up> 2) + cos (4 * x \<up> 3)"
1081 (*+*)then () else error "inform with (positive) Error_Pattern.check_for broken 2";
1083 val SOME "chain-rule-diff-both" = (*case*) Error_Pattern.check_for (f_pred, f_in) (prog, env) (errpats, nrls) (*of*);
1086 (*+*)val (_, _, ptp') = cs';
1087 case Step_Solve.by_term ptp' (encode ifo) of
1088 ("error pattern #chain-rule-diff-both#", calcstate') => ()
1089 | _ => error "inform with (positive) Error_Pattern.check_for broken"
1092 "--------- embed fun find_fill_patterns ---------------------------";
1093 "--------- embed fun find_fill_patterns ---------------------------";
1094 "--------- embed fun find_fill_patterns ---------------------------";
1097 [(["functionTerm (x \<up> 2 + sin (x \<up> 4))", "differentiateFor x", "derivative f_f'"],
1098 ("Isac_Knowledge", ["derivative_of", "function"], ["diff", "differentiate_on_R"]))];
1101 autoCalculate 1 CompleteCalcHead;
1102 autoCalculate 1 (Steps 1);
1103 autoCalculate 1 (Steps 1);(*([1], Res), d_d x (x \<up> 2) + d_d x (sin (x \<up> 4))*)
1104 appendFormula 1 "d_d x (x \<up> 2) + cos (4 * x \<up> 3)" (*|> Future.join*);
1105 (*<CALCMESSAGE> error pattern #chain-rule-diff-both# </CALCMESSAGE>*)
1107 <CALCMESSAGE> no derivation found </CALCMESSAGE>*)
1109 "~~~~~ fun findFillpatterns, args:"; val (cI, errpatID) = (1, "chain-rule-diff-both");
1110 val ((pt, _), _) = get_calc cI
1111 val pos = get_pos cI 1;
1112 "~~~~~ fun find_fill_patterns , args:"; val ((pt, pos as (p, _)), errpatID) = ((pt, pos), errpatID);
1113 val f_curr = Ctree.get_curr_formula (pt, pos);
1114 val pp = Ctree.par_pblobj pt p
1115 val (errpats, prog) = case MethodC.from_store (Ctree.get_obj Ctree.g_metID pt pp) of
1116 {errpats, scr = Rule.Prog prog, ...} => (errpats, prog)
1117 | _ => error "find_fill_patterns: uncovered case of MethodC.from_store"
1118 val {env, ...} = Ctree.get_istate_LI pt pos |> Istate.the_pstate
1119 val subst = Subst.for_bdv prog env
1120 val errpatthms = errpats
1121 |> filter ((curry op = errpatID) o (#1: Error_Pattern.T -> Error_Pattern.id))
1122 |> map (#3: Error_Pattern.T -> thm list)
1125 case map (Error_Pattern.fill_from_store subst f_curr errpatID) errpatthms |> flat of
1126 ("fill-d_d-arg", tm, thm, subs_opt) :: _ => if UnparseC.term tm =
1127 "d_d x (x \<up> 2) + d_d x (sin (x \<up> 4)) =\nd_d x (x \<up> 2) + cos (x \<up> 4) * d_d x ?_dummy_1"
1128 then () else error "find_fill_patterns changed 1a"
1129 | _ => error "find_fill_patterns changed 1b"
1131 "~~~~~ fun fill_from_store, args:"; val (subst, form, errpatID, thm) =
1132 (subst, f_curr, errpatID, hd (*simulate beginning of "map"*) errpatthms);
1133 val thmDeriv = Thm.get_name_hint thm
1134 val (part, thyID) = Thy_Read.thy_containing_thm thmDeriv
1135 val theID = [part, thyID, "Theorems", ThmC.cut_id thmDeriv]
1136 val Thy_Write.Hthm {fillpats, ...} = Thy_Read.from_store theID
1137 val some = map (Error_Pattern.fill_form subst (thm, form) errpatID) fillpats;
1139 case some |> filter is_some |> map the of
1140 ("fill-d_d-arg", tm, thm, subsopt) :: _ => if UnparseC.term tm =
1141 "d_d x (x \<up> 2) + d_d x (sin (x \<up> 4)) =\nd_d x (x \<up> 2) + cos (x \<up> 4) * d_d x ?_dummy_1"
1142 then () else error "find_fill_patterns changed 2a"
1143 | _ => error "find_fill_patterns changed 2b"
1145 "~~~~~ fun fill_form, args:";
1146 val ((subs_opt, subst), (thm, form), errpatID, (fillpatID, pat, erpaID)) =
1147 (subst, (thm, form), errpatID, hd (*simulate beginning of "map"*) fillpats);
1148 val (form', _, _, rewritten) =
1149 rew_sub (Isac()) 1 subst e_rew_ord Rule_Set.empty false [] (HOLogic.Trueprop $ pat) form;
1151 if UnparseC.term form' = "d_d x (x \<up> 2) + cos (x \<up> 4) * d_d x ?_dummy_1" then ()
1152 else error "find_fill_patterns changed 3";
1154 "~~~~~ to findFillpatterns return val:"; val (fillpats) =
1155 (map (Error_Pattern.fill_from_store (subs_opt, subst) f_curr errpatID) errpatthms |> flat) (*only from "hd errpatthms"*);
1157 "vvv--- dropped this code WN120730";
1158 val msg = "fill patterns " ^
1159 ((map ((apsnd UnparseC.term) o quad2pair) fillpats) |> map pair2str_ |> strs2str_);
1161 "fill patterns #fill-d_d-arg#d_d x (x \<up> 2) + d_d x (sin (x \<up> 4))" ^
1162 " =\nd_d x (x \<up> 2) + cos (x \<up> 4) * d_d x ?_dummy_1" ^
1163 "#fill-both-args#d_d x (x \<up> 2) + d_d x (sin (x \<up> 4))" ^
1164 " =\nd_d x (x \<up> 2) + cos ?_dummy_2 * d_d x ?_dummy_3" ^
1165 "#fill-d_d#d_d x (x \<up> 2) + d_d x (sin (x \<up> 4))" ^
1166 " =\nd_d x (x \<up> 2) + cos (x \<up> 4) * ?_dummy_1 x (x \<up> 4)" ^
1167 "#fill-inner-deriv#d_d x (x \<up> 2) + d_d x (sin (x \<up> 4))" ^
1168 " =\nd_d x (x \<up> 2) + cos (x \<up> 4) * ?_dummy_1" ^
1169 "#fill-all#d_d x (x \<up> 2) + d_d x (sin (x \<up> 4)) = d_d x (x \<up> 2) + ?_dummy_1#";
1170 " \<up> --- dropped this code WN120730";
1172 if (map #1 fillpats) =
1173 ["fill-d_d-arg", "fill-both-args", "fill-d_d", "fill-inner-deriv", "fill-all"]
1174 then () else error "find_fill_patterns changed 4b";
1177 "--------- build fun is_exactly_equal, inputFillFormula ----------";
1178 "--------- build fun is_exactly_equal, inputFillFormula ----------";
1179 "--------- build fun is_exactly_equal, inputFillFormula ----------";
1182 [(["functionTerm (x \<up> 2 + sin (x \<up> 4))", "differentiateFor x", "derivative f_f'"],
1183 ("Isac_Knowledge", ["derivative_of", "function"], ["diff", "differentiate_on_R"]))];
1186 autoCalculate 1 CompleteCalcHead;
1187 autoCalculate 1 (Steps 1);
1188 autoCalculate 1 (Steps 1);(*([1], Res), d_d x (x \<up> 2) + d_d x (sin (x \<up> 4))*)
1189 appendFormula 1 "d_d x (x \<up> 2) + cos (4 * x \<up> 3)" (*|> Future.join*); (*<<<<<<<=========================*)
1190 (* the check for errpat is maximally liberal (whole term modulo "nrls" from "type met"),
1191 would recognize "cos (4 * x \<up> (4 - 1)) + 2 * x" as well.
1192 results in <CALCMESSAGE> error pattern #chain-rule-diff-both# </CALCMESSAGE>
1193 instead of <CALCMESSAGE> no derivation found </CALCMESSAGE> *)
1194 val ((pt,pos), _) = get_calc 1;
1195 val p = get_pos 1 1;
1196 val (Form f, _, asms) = ME_Misc.pt_extract (pt, p);
1198 if p = ([1], Res) andalso UnparseC.term f = "d_d x (x \<up> 2) + d_d x (sin (x \<up> 4))" then
1199 case get_obj g_tac pt (fst p) of Rewrite_Inst (["(''bdv'', x)"],
1200 ("diff_sum", thm)) =>
1201 if (UnparseC.term o Thm.prop_of) thm = "d_d ?bdv (?u + ?v) = d_d ?bdv ?u + d_d ?bdv ?v" then ()
1202 else error "embed fun fill_form changed 11"
1203 | _ => error "embed fun fill_form changed 12"
1204 else error "embed fun fill_form changed 13";
1206 findFillpatterns 1 "chain-rule-diff-both"; (*<<<<<<<=================================*)
1207 (*<CALCMESSAGE> fill patterns #fill-d_d-arg#d_d x (x \<up> 2) + d_d x (sin (x \<up> 4)) =
1208 d_d x (x \<up> 2) + cos (x \<up> 4) * d_d x ?_dummy_1#fill-both-args#...#...#... *)
1209 val ((pt,pos),_) = get_calc 1;
1210 val p = get_pos 1 1;
1212 val (Form f, _, asms) = ME_Misc.pt_extract (pt, p);
1213 if p = ([1], Res) andalso UnparseC.term f = "d_d x (x \<up> 2) + d_d x (sin (x \<up> 4))" then
1214 case get_obj g_tac pt (fst p) of Rewrite_Inst (["(''bdv'', x)"],
1215 ("diff_sum", thm)) =>
1216 if (UnparseC.term o Thm.prop_of) thm = "d_d ?bdv (?u + ?v) = d_d ?bdv ?u + d_d ?bdv ?v" then ()
1217 else error "embed fun fill_form changed 21"
1218 | _ => error "embed fun fill_form changed 22"
1219 else error "embed fun fill_form changed 23";
1221 requestFillformula 1 ("chain-rule-diff-both", "fill-both-args");(*<<<<<<<============*)
1222 (*<AUTOCALC> ([1], Res) ([2], Res) ([2], Res) </AUTOCALC>*)
1223 val ((pt,pos),_) = get_calc 1;
1224 val p = get_pos 1 1;
1225 val (Form f, _, asms) = ME_Misc.pt_extract (pt, p);
1226 if p = ([1], Res) andalso existpt [2] pt
1227 andalso UnparseC.term f = "d_d x (x \<up> 2) + d_d x (sin (x \<up> 4))"
1228 then case get_obj g_tac pt (fst p) of Rewrite_Inst (["(''bdv'', x)"],
1229 ("diff_sum", thm)) =>
1230 if (UnparseC.term o Thm.prop_of) thm = "d_d ?bdv (?u + ?v) = d_d ?bdv ?u + d_d ?bdv ?v" then ()
1231 else error "embed fun fill_form changed 31"
1232 | _ => error "embed fun fill_form changed 32"
1233 else error "embed fun fill_form changed 33";
1235 (* input a formula which exactly fills the gaps in a "fillformula"
1236 presented to the learner immediately before by "requestFillformula (errpatID, fillpatID)":
1237 errpatID: lhs of the respective thm = lhs of fillformula with fillpatID.
1238 the respective thm is in the ctree ................
1240 "~~~~~ fun inputFillFormula, args:"; val (cI, ifo) =
1241 (1, "d_d x (x \<up> 2) + cos (x \<up> 4) * d_d x (x \<up> 4)");
1242 val ((pt, _), _) = get_calc cI
1243 val pos = get_pos cI 1;
1245 "~~~~~ fun is_exactly_equal, args:"; val ((pt, pos as (p, p_)), istr) = ((pt, pos), ifo);
1246 val SOME ifo = parseNEW (ThyC.get_theory "Isac_Knowledge" |> ThyC.to_ctxt) istr
1248 val tac = get_obj g_tac pt p';
1249 val Rewrite_Inst ([bbb as "(''bdv'', x)"], ("diff_sin_chain", ttt)) = tac;
1250 if (UnparseC.term o Thm.prop_of) ttt = "d_d ?bdv (sin ?u) = cos ?u * d_d ?bdv ?u" then ()
1251 else error "inputFillFormula changed 10";
1252 val Applicable.Yes rew = Step.check tac (pt, pos);
1253 val Rewrite_Inst' (_, _, _, _, _, _, _, (res, _)) = rew;
1255 "~~~~~ to inputFillFormula return val:"; val ("ok", tac) = ("ok", tac);
1256 val ("ok", (_, c, ptp as (_,p'))) = Step.by_tactic tac (pt, pos);
1257 upd_calc cI (ptp, []);
1259 autocalculateOK2xml cI pos (if null c then p' else last_elem c) p';
1261 "~~~~~ final check:";
1262 val ((pt, _),_) = get_calc 1;
1263 val p = get_pos 1 1;
1264 val (Form f, _, asms) = ME_Misc.pt_extract (pt, p);
1265 if p = ([2], Res) andalso UnparseC.term f = "d_d x (x \<up> 2) + cos (x \<up> 4) * d_d x (x \<up> 4)"
1266 then case get_obj g_tac pt (fst p) of Rewrite_Inst (["(''bdv'', x)"],
1267 ("diff_sin_chain", thm)) =>
1268 if (UnparseC.term o Thm.prop_of) thm = "d_d ?bdv (sin ?u) = cos ?u * d_d ?bdv ?u" then ()
1269 else error "inputFillFormula changed 111"
1270 | _ => error "inputFillFormula changed 112"
1271 else error "inputFillFormula changed 113";
1273 "--------- fun appl_adds -----------------------------------------";
1274 "--------- fun appl_adds -----------------------------------------";
1275 "--------- fun appl_adds -----------------------------------------";
1276 (* val (dI, oris, ppc, pbt, selct::ss) =
1277 (dI, pors, probl, ppc, map itms2fstr probl);
1280 (* val (dI, oris, ppc, pbt, (selct::ss))=
1281 (#1 (References.select ospec spec), oris, []:I_Model.T,
1282 ((#ppc o Problem.from_store) (#2 (References.select ospec spec))),(imodel2fstr imodel));
1283 val iii = appl_adds dI oris ppc pbt (selct::ss);
1284 tracing(I_Model.to_string thy iii);
1286 val itm = add_single' dI oris ppc pbt selct;
1287 val ppc = I_Model.add itm ppc;
1289 val _::selct::ss = (selct::ss);
1290 val itm = add_single' dI oris ppc pbt selct;
1291 val ppc = I_Model.add itm ppc;
1293 val _::selct::ss = (selct::ss);
1294 val itm = add_single' dI oris ppc pbt selct;
1295 val ppc = I_Model.add itm ppc;
1296 tracing(I_Model.to_string thy ppc);
1298 val _::selct::ss = (selct::ss);
1299 val itm = add_single' dI oris ppc pbt selct;
1300 val ppc = I_Model.add itm ppc;
1302 "--------- fun concat_deriv --------------------------------------";
1303 "--------- fun concat_deriv --------------------------------------";
1304 "--------- fun concat_deriv --------------------------------------";
1306 val ({rew_ord, erls, rules,...}, fo, ifo) =
1307 (Rule_Set.rep Test_simplify, TermC.str2term "x+1+ - 1*2=0", TermC.str2term "-2*1+(x+1)=0");
1308 (tracing o Derive.trtas2str) fod';
1310 (x + 1 + - 1 * 2 = 0, Thm ("radd_commute", "?m + ?n = ?n + ?m"), (- 1 * 2 + (x + 1) = 0, []))", "
1311 (- 1 * 2 + (x + 1) = 0, Thm ("radd_commute", "?m + ?n = ?n + ?m"), (- 1 * 2 + (1 + x) = 0, []))", "
1312 (- 1 * 2 + (1 + x) = 0, Thm ("radd_left_commute", "?x + (?y + ?z) = ?y + (?x + ?z)"), (1 + (- 1 * 2 + x) = 0, []))", "
1313 (1 + (- 1 * 2 + x) = 0, Thm ("#mult_Float ((~1,0), (0,0)) __ ((2,0), (0,0))", "- 1 * 2 = -2"), (1 + (-2 + x) = 0, []))"]
1315 (tracing o Derive.trtas2str) (map Derive.rev_deriv' rifod');
1317 (1 + (-2 + x) = 0, Thm ("sym_#mult_Float ((~2,0), (0,0)) __ ((1,0), (0,0))", "-2 = -2 * 1"), (1 + (-2 * 1 + x) = 0, []))", "
1318 (1 + (-2 * 1 + x) = 0, Thm ("sym_radd_left_commute", "?y + (?x + ?z) = ?x + (?y + ?z)"), (-2 * 1 + (1 + x) = 0, []))", "
1319 (-2 * 1 + (1 + x) = 0, Thm ("sym_radd_commute", "?n + ?m = ?m + ?n"), (-2 * 1 + (x + 1) = 0, []))"]
1322 "--------- handle an input formula -------------------------------";
1323 "--------- handle an input formula -------------------------------";
1324 "--------- handle an input formula -------------------------------";
1326 Untersuchung zur Formeleingabe (appendFormula, replaceFormla) zu einer Anregung von Alan Krempler:
1327 Welche RICHTIGEN Formeln koennen NICHT abgeleitet werden,
1328 wenn Abteilungen nur auf gleichem Level gesucht werden ?
1331 Beispiele zum Equationsolver von Richard Lang aus /src/sml/kbtest/rlang.sml
1333 ------------------------------------------------------------------------------
1334 "Schalk I s.87 Bsp 52a ((5*x)/(x - 2) - x/(x+2)=4)";
1335 ------------------------------------------------------------------------------
1336 1. "5 * x / (x - 2) - x / (x + 2) = 4"
1338 4. "12 * x + 4 * x \<up> 2 = 4 * (-4 + x \<up> 2)",Subproblem["normalise", "poly"..
1340 4.3. "16 + 12 * x = 0", Subproblem["degree_1", "polynomial", "univariate"..
1342 4.3.3. "[x = -4 / 3]")), Check_elementwise "Assumptions"
1345 ------------------------------------------------------------------------------
1346 (1)..(6): keine 'richtige' Eingabe kann abgeleitet werden, die einen Summanden auf die andere Seite verschiebt [Ableitung ware in 4.3.n]
1348 (4.1)..(4.3): keine 'richtige' Eingabe kann abgeleitet werden, die einen Summanden auf die andere Seite verschiebt [Ableitung ware in 4.3.n]
1349 ------------------------------------------------------------------------------
1352 ------------------------------------------------------------------------------
1353 "Schalk I s.87 Bsp 55b (x/(x \<up> 2 - 6*x+9) - 1/(x \<up> 2 - 3*x) =1/x)";
1354 ------------------------------------------------------------------------------
1355 1. "x / (x \<up> 2 - 6 * x + 9) - 1 / (x \<up> 2 - 3 * x) = 1 / x"
1357 4. "(3 + (- 1 * x + x \<up> 2)) * x = 1 * (9 * x + (x \<up> 3 + -6 * x \<up> 2))"
1358 Subproblem["normalise", "polynomial", "univariate"..
1360 4.4. "-6 * x + 5 * x \<up> 2 = 0", Subproblem["bdv_only", "degree_2", "poly"..
1362 4.4.4. "[x = 0, x = 6 / 5]", Check_elementwise "Assumptions"
1363 4.4.5. "[x = 0, x = 6 / 5]"
1365 5. "[x = 0, x = 6 / 5]", Check_elementwise "Assumptions"
1367 ------------------------------------------------------------------------------
1368 (1)..(4): keine 'richtige' Eingabe kann abgeleitet werden, die einen Summanden auf die andere Seite schiebt [Ableitung waere in 4.4.x]
1370 (4.1)..(4.4.5): keine 'richtige' Eingabe kann abgeleitet werden, die dem Ergebnis "[x = 6 / 5]" aequivalent ist [Ableitung waere in 5.]
1371 ------------------------------------------------------------------------------
1374 ------------------------------------------------------------------------------
1375 "Schalk II s.56 Bsp 73b (sqrt(x+1)+sqrt(4*x+4)=sqrt(9*x+9))";
1376 ------------------------------------------------------------------------------
1377 1. "sqrt (x + 1) + sqrt (4 * x + 4) = sqrt (9 * x + 9)"
1379 6. "13 + 13 * x + -2 * sqrt ((4 + 4 * x) * (9 + 9 * x)) = 1 + x"
1380 Subproblem["sq", "rootX", "univariate", "equation"]
1382 6.6. "144 + 288 * x + 144 * x \<up> 2 = 144 + x \<up> 2 + 288 * x + 143 * x \<up> 2"
1383 Subproblem["normalise", "polynomial", "univariate", "equation"]
1384 ...6.6.3 "0 = 0" Subproblem["degree_0", "polynomial", "univariate", "equation"]
1386 6.6.3.2 "UniversalList"
1387 ------------------------------------------------------------------------------
1388 (1)..(6): keine 'richtige' Eingabe kann abgeleitet werden, die eine der Wurzeln auf die andere Seite verschieb [Ableitung ware in 6.6.n]
1390 (6.1)..(6.3): keine 'richtige' Eingabe kann abgeleitet werden, die einen Summanden auf die andere Seite verschiebt [Ableitung ware in 6.6.n]
1391 ------------------------------------------------------------------------------
1393 (*sh. comments auf 498*)
1394 "--------- fun dropwhile' ----------------------------------------";
1395 "--------- fun dropwhile' ----------------------------------------";
1396 "--------- fun dropwhile' ----------------------------------------";
1398 fun equal a b = a=b;
1399 val foder = [0,1,2,3,4,5]; val ifoder = [11,12,3,4,5];
1400 val r_foder = rev foder; val r_ifoder = rev ifoder;
1401 dropwhile' equal r_foder r_ifoder;
1402 > vval it = ([0, 1, 2, 3], [3, 12, 11]) : int list * int list
1404 val foder = [3,4,5]; val ifoder = [11,12,3,4,5];
1405 val r_foder = rev foder; val r_ifoder = rev ifoder;
1406 dropwhile' equal r_foder r_ifoder;
1407 > val it = ([3], [3, 12, 11]) : int list * int list
1409 val foder = [5]; val ifoder = [11,12,3,4,5];
1410 val r_foder = rev foder; val r_ifoder = rev ifoder;
1411 dropwhile' equal r_foder r_ifoder;
1412 > val it = ([5], [5, 4, 3, 12, 11]) : int list * int list
1414 val foder = [10,11,12,13,14,15]; val ifoder = [11,12,3,4,5];
1415 val r_foder = rev foder; val r_ifoder = rev ifoder;
1416 dropwhile' equal r_foder r_ifoder;
1417 > *** dropwhile': did not start with equal elements*)