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 MethodC.from_store) ["Test", "squ-equ-test-subpbl1"];
51 (writeln o UnparseC.term) sc;
52 val Prog sc = (#scr o MethodC.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 (TermC.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 (TermC.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) \<up> 2 + (b/2) \<up> 2 = r \<up> 2]",
381 "relations [A=a*b, (a/2) \<up> 2 + (b/2) \<up> 2 = r \<up> 2]",
382 "relations [A=a*b, a/2=r*sin alpha, b/2=r*cos (alpha::real)]",
383 (* \<up> 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 = ------------ \<up> \<up> \<up> ^ 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) \<up> 2 + (b/2) \<up> 2 = r \<up> 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 \<up> \<up> \<up> micked input of \<up> \<up> \<up> \<up> \<up> ^^ 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 ---------------------------------------------------------------------------------------------
483 Test_Tool.show_pt pt;
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;
501 Test_Tool.show_pt pt;
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;
519 Test_Tool.show_pt pt;
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;
534 (*Test_Tool.show_pt pt;
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;
543 (*Test_Tool.show_pt pt;
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;
561 Test_Tool.show_pt pt;
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;
574 (*Test_Tool.show_pt pt;
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;
591 (*Test_Tool.show_pt pt;
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";
617 (*Test_Tool.show_pt pt;
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 = TermC.str2term "Diff (x \<up> 2 + x + 1, x)";
641 case t of Const (\<^const_name>\<open>Diff\<close>, _) $ _ => ()
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 \<up> 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 \<up> 2 + x + 1) ,(f_, [x \<up> 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 \<up> 2 + x + 1) ,(f_, [x \<up> 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 ME_Misc.pt_extract) (pt, ([],Res));
696 Test_Tool.show_pt pt;
698 if p = ([], Res) andalso UnparseC.term res = "1 + 2 * x" then ()
699 else error "diff.sml behav.changed for Diff (x \<up> 2 + x + 1, x)";
702 "--------- Take as 1st tac, start from exp -----------------------";
703 "--------- Take as 1st tac, start from exp -----------------------";
704 "--------- Take as 1st tac, start from exp -----------------------";
705 (*the following input is copied from BridgeLog Java <==> SML,
706 omitting unnecessary inputs*)
707 (*1>*)reset_states ();
708 (*2>*)CalcTree [(["functionTerm (x \<up> 2 + x + 1)", "differentiateFor x", "derivative f_'_f"],("Isac_Knowledge",["derivative_of", "function"],["diff", "differentiate_on_R"]))];
709 (*3>*)Iterator 1; moveActiveRoot 1;
711 (*6>*)(*completeCalcHead*)autoCalculate 1 CompleteCalcHead;
712 (***difference II***)
713 val ((pt,_),_) = get_calc 1;
714 val PblObj {probl, meth, spec, fmz, loc, ...} = get_obj I pt [];
715 val (SOME istate, NONE) = loc;
716 (*default_print_depth 5;*) writeln (Istate.string_of (fst istate)); (*default_print_depth 3;*)
719 ??.empty, Sundef, false)*)
720 (*default_print_depth 5;*) spec; (*default_print_depth 3;*)
722 ["derivative_of", "function"],
723 ["diff", "differentiate_on_R"]) : spec*)
724 writeln (I_Model.to_string ctxt probl);
726 (1 ,[1] ,true ,#Given ,Cor functionTerm (x \<up> 2 + x + 1) ,(f_, [x \<up> 2 + x + 1])),
727 (2 ,[1] ,true ,#Given ,Cor differentiateFor x ,(v_, [x])),
728 (3 ,[1] ,true ,#Find ,Cor derivative f_'_f ,(f_'_f, [f_'_f]))]*)
729 writeln (I_Model.to_string ctxt meth);
731 (1 ,[1] ,true ,#Given ,Cor functionTerm (x \<up> 2 + x + 1) ,(f_, [x \<up> 2 + x + 1])),
732 (2 ,[1] ,true ,#Given ,Cor differentiateFor x ,(v_, [x])),
733 (3 ,[1] ,true ,#Find ,Cor derivative f_'_f ,(f_'_f, [f_'_f]))]*)
734 writeln"-----------------------------------------------------------";
735 (*7>*)fetchProposedTactic 1 (*--> Apply_Method*);
736 autoCalculate 1 (Steps 1);
737 val ((pt,p),_) = get_calc 1;
738 val Form res = (#1 o ME_Misc.pt_extract) (pt, p);
739 if UnparseC.term res = "d_d x (x \<up> 2 + x + 1)" then ()
740 else error "diff.sml Diff (x \<up> 2 + x + 1, x) from exp";
743 "--------- implicit_take, start with <NEW> (CAS input) ---------------";
744 "--------- implicit_take, start with <NEW> (CAS input) ---------------";
745 "--------- implicit_take, start with <NEW> (CAS input) ---------------";
747 CalcTree [([], ("empty_thy_id", ["empty_probl_id"], ["empty_meth_id"]))];
748 (*[[from sml: > @@@@@begin@@@@@
750 [[from sml: <CALCTREE>
751 [[from sml: <CALCID> 1 </CALCID>
752 [[from sml: </CALCTREE>
753 [[from sml: @@@@@end@@@@@*)
755 (*[[from sml: > @@@@@begin@@@@@
757 [[from sml: <ADDUSER>
758 [[from sml: <CALCID> 1 </CALCID>
759 [[from sml: <USERID> 1 </USERID>
760 [[from sml: </ADDUSER>
761 [[from sml: @@@@@end@@@@@*)
763 (*[[from sml: > @@@@@begin@@@@@
765 [[from sml: <CALCITERATOR>
766 [[from sml: <CALCID> 1 </CALCID>
767 [[from sml: <POSITION>
768 [[from sml: <INTLIST>
769 [[from sml: </INTLIST>
770 [[from sml: <POS> Pbl </POS>
771 [[from sml: </POSITION>
772 [[from sml: </CALCITERATOR>
773 [[from sml: @@@@@end@@@@@*)
774 getFormulaeFromTo 1 ([],Pbl) ([],Pbl) 0 false;
775 (*[[from sml: > @@@@@begin@@@@@ STILL CORRECT
777 [[from sml: <GETELEMENTSFROMTO>
778 [[from sml: <CALCID> 1 </CALCID>
779 [[from sml: <FORMHEADS>
780 [[from sml: <CALCFORMULA>
781 [[from sml: <POSITION>
782 [[from sml: <INTLIST>
783 [[from sml: </INTLIST>
784 [[from sml: <POS> Pbl </POS>
785 [[from sml: </POSITION>
786 [[from sml: <FORMULA>
788 [[from sml: <ISA> ________________________________________________ </ISA>
789 [[from sml: </MATHML>
791 [[from sml: </FORMULA>
792 [[from sml: </CALCFORMULA>
793 [[from sml: </FORMHEADS>
794 [[from sml: </GETELEMENTSFROMTO>
795 [[from sml: @@@@@end@@@@@*)
796 refFormula 1 ([],Pbl);
797 (*[[from sml: > @@@@@begin@@@@@ STILL CORRECT
799 [[from sml: <REFFORMULA>
800 [[from sml: <CALCID> 1 </CALCID>
801 [[from sml: <CALCHEAD status = "incorrect">
802 [[from sml: <POSITION>
803 [[from sml: <INTLIST>
804 [[from sml: </INTLIST>
805 [[from sml: <POS> Pbl </POS>
806 [[from sml: </POSITION>
809 [[from sml: <ISA> Problem (ThyC.id_empty, [e_pblID]) </ISA>
810 [[from sml: </MATHML>
813 [[from sml: <GIVEN> </GIVEN>
814 [[from sml: <WHERE> </WHERE>
815 [[from sml: <FIND> </FIND>
816 [[from sml: <RELATE> </RELATE>
818 [[from sml: <BELONGSTO> Pbl </BELONGSTO>
819 [[from sml: <SPECIFICATION>
820 [[from sml: <THEORYID> ThyC.id_empty </THEORYID>
821 [[from sml: <PROBLEMID>
822 [[from sml: <STRINGLIST>
823 [[from sml: <STRING> Problem.id_empty </STRING>
824 [[from sml: </STRINGLIST>
825 [[from sml: </PROBLEMID>
826 [[from sml: <METHODID>
827 [[from sml: <STRINGLIST>
828 [[from sml: <STRING> e_metID </STRING>
829 [[from sml: </STRINGLIST>
830 [[from sml: </METHODID>
831 [[from sml: </SPECIFICATION>
832 [[from sml: </CALCHEAD>
833 [[from sml: </REFFORMULA>
834 [[from sml: @@@@@end@@@@@*)
835 moveActiveFormula 1 ([],Pbl);
836 (*[[from sml: > @@@@@begin@@@@@
838 [[from sml: <CALCITERATOR>
839 [[from sml: <CALCID> 1 </CALCID>
840 [[from sml: <POSITION>
841 [[from sml: <INTLIST>
842 [[from sml: </INTLIST>
843 [[from sml: <POS> Pbl </POS>
844 [[from sml: </POSITION>
845 [[from sml: </CALCITERATOR>
846 [[from sml: @@@@@end@@@@@*)
847 replaceFormula 1 "Simplify (1+2)";
848 (*[[from sml: > @@@@@begin@@@@@
850 [[from sml: <REPLACEFORMULA>
851 [[from sml: <CALCID> 1 </CALCID>
852 [[from sml: <CALCCHANGED>
853 [[from sml: <UNCHANGED>
854 [[from sml: <INTLIST>
855 [[from sml: </INTLIST>
856 [[from sml: <POS> Pbl </POS>
857 [[from sml: </UNCHANGED>
858 [[from sml: <DELETED>
859 [[from sml: <INTLIST>
860 [[from sml: </INTLIST>
861 [[from sml: <POS> Pbl </POS>
862 [[from sml: </DELETED>
863 [[from sml: <GENERATED>
864 [[from sml: <INTLIST>
865 [[from sml: </INTLIST>
866 [[from sml: <POS> Met </POS> DIFFERENCE: Pbl
867 [[from sml: </GENERATED>
868 [[from sml: </CALCCHANGED>
869 [[from sml: </REPLACEFORMULA>
870 [[from sml: @@@@@end@@@@@*)
871 getFormulaeFromTo 1 ([],Pbl) ([],Pbl) 0 false(* DIFFERENCE: Pbl*);
885 <ISA> Simplify (1 + 2) </ISA> WORKS !!!!!
892 getFormulaeFromTo 1 ([],Pbl) ([],Met) 0 false;
893 (*[[from sml: > @@@@@begin@@@@@
895 [[from sml: <SYSERROR>
896 [[from sml: <CALCID> 1 </CALCID>
897 [[from sml: <ERROR> error in getFormulaeFromTo </ERROR>
898 [[from sml: </SYSERROR>
899 [[from sml: @@@@@end@@@@@*)
900 (*step into getFormulaeFromTo --- bug corrected...*)
902 "--------- build fun check_for' ------------------------------";
903 "--------- build fun check_for' ------------------------------";
904 "--------- build fun check_for' ------------------------------";
905 val subst = [(TermC.str2term "bdv", TermC.str2term "x")]: subst;
906 val rls = norm_Rational
907 val pat = TermC.parse_patt @{theory} "(?a + ?b)/(?b + ?c) = ?a / ?c";
908 val (res, inf) = (TermC.str2term "(2 + 3)/(3 + 4)", TermC.str2term "2 / 4");
909 val (res, inf) = (TermC.str2term "(2 + 3)/(3 + 4)", TermC.str2term "1 / 2");
911 val (res', _, _, rewritten) = (*rewritten: the lhs of the pattern TermC.matches in res*)
912 rew_sub thy 1 [] e_rew_ord Rule_Set.empty false [] (HOLogic.Trueprop $ pat) res;
913 if rewritten then NONE else SOME "e_errpatID";
915 val norm_res = case rewrite_set_ (Isac()) false rls res' of
917 | SOME (norm_res, _) => norm_res
919 val norm_inf = case rewrite_set_ (Isac()) false rls inf of
921 | SOME (norm_inf, _) => norm_inf;
926 val pat = TermC.parse_patt @{theory} "(?a + ?b)/?a = ?b";
927 val (res, inf) = (TermC.str2term "(2 + 3)/2", TermC.str2term "3");
928 if check_for' (res, inf) subst ("errpatID", pat) rls = SOME "errpatID"
929 then () else error "error patt example1 changed";
931 val pat = TermC.parse_patt @{theory} "(?a + ?b)/(?a + ?c) = ?b / ?c";
932 val (res, inf) = (TermC.str2term "(2 + 3)/(2 + 4)", TermC.str2term "3 / 4");
933 if check_for' (res, inf) subst ("errpatID", pat) rls = SOME "errpatID"
934 then () else error "error patt example2 changed";
936 val pat = TermC.parse_patt @{theory} "(?a + ?b)/(?b + ?c) = ?a / ?c";
937 val (res, inf) = (TermC.str2term "(2 + 3)/(3 + 4)", TermC.str2term "2 / 4");
938 if check_for' (res, inf) subst ("errpatID", pat) rls = SOME "errpatID"
939 then () else error "error patt example3 changed";
941 val inf = TermC.str2term "1 / 2";
942 if check_for' (res, inf) subst ("errpatID", pat) rls = SOME "errpatID"
943 then () else error "error patt example3 changed";
945 "--------- build fun check_for' ?bdv -------------------------";
946 "--------- build fun check_for' ?bdv -------------------------";
947 "--------- build fun check_for' ?bdv -------------------------";
948 val subst = [(TermC.str2term "bdv", TermC.str2term "x")]: subst;
949 val t = TermC.str2term "d_d x (x \<up> 2 + sin (x \<up> 4))";
950 val SOME (t, _) = rewrite_set_inst_ thy false subst norm_diff t;
951 if UnparseC.term t = "2 * x + cos (x \<up> 4) * 4 * x \<up> 3" then ()
952 else error "build fun check_for' ?bdv changed 1";
955 val pat = TermC.parse_patt @{theory} "d_d ?bdv (sin ?u) = cos (d_d ?bdv ?u)";
956 val (res, inf) = (TermC.str2term "2 * x + d_d x (sin (x \<up> 4))", TermC.str2term "2 * x + cos (4 * x \<up> 3)");
958 val (res', _, _, rewritten) = (*rewritten: the lhs of the pattern TermC.matches in res*)
959 rew_sub thy 1 subst e_rew_ord Rule_Set.empty false [] (HOLogic.Trueprop $ pat) res;
960 if UnparseC.term res' = "2 * x + cos (d_d x (x \<up> 4))" andalso rewritten then ()
961 else error "build fun check_for' ?bdv changed 2";
963 val norm_res = case rewrite_set_inst_ (Isac()) false subst rls res' of
965 | SOME (norm_res, _) => norm_res;
966 if UnparseC.term norm_res = "2 * x + cos (4 * x \<up> 3)" then ()
967 else error "build fun check_for' ?bdv changed 3";
969 val norm_inf = case rewrite_set_inst_ (Isac()) false subst rls inf of
971 | SOME (norm_inf, _) => norm_inf;
972 if UnparseC.term norm_inf = "2 * x + cos (4 * x \<up> 3)" then ()
973 else error "build fun check_for' ?bdv changed 4";
976 if norm_res = norm_inf then ()
977 else error "build fun check_for' ?bdv changed 5";
979 if Error_Pattern.check_for' (res, inf) (subst: subst) ("errpatID": Error_Pattern.id, pat) rls = SOME "errpatID"
980 then () else error "error patt example1 changed";
982 "--------- build fun check_for ------------------------";
983 "--------- build fun check_for ------------------------";
984 "--------- build fun check_for ------------------------";
986 (TermC.str2term "d_d x (x \<up> 2) + d_d x (sin (x \<up> 4))",
987 TermC.str2term "d_d x (x \<up> 2) + cos (4 * x \<up> 3)");
988 val {errpats, nrls = rls, scr = Prog prog, ...} = MethodC.from_store ["diff", "differentiate_on_R"]
990 val env = [(TermC.str2term "v_v", TermC.str2term "x")];
992 [Error_Pattern.empty, (*generalised for testing*)
993 ("chain-rule-diff-both",
994 [TermC.parse_patt @{theory} "d_d ?bdv (sin ?u) = cos (d_d ?bdv ?u)",
995 TermC.parse_patt @{theory} "d_d ?bdv (cos ?u) = - sin (d_d ?bdv ?u)",
996 TermC.parse_patt @{theory} "d_d ?bdv (?u \<up> ?n) = ?n * ?u \<up> (?n - 1)",
997 TermC.parse_patt @{theory} "d_d ?bdv (LogExp.ln ?u) = 1 / ?u",
998 TermC.parse_patt @{theory} "d_d ?bdv (LogExp.ln ?u) = 1 / d_d ?bdv ?u"],
999 [@{thm diff_sin_chain}, @{thm diff_cos_chain}, @{thm diff_pow_chain},
1000 @{thm diff_ln_chain}, @{thm diff_exp_chain}])];
1001 case Error_Pattern.check_for (res, inf) (prog, env) (errpats, rls) of SOME _ => ()
1002 | NONE => error "Error_Pattern.check_for broken";
1005 "--------- embed fun check_for ------------------------";
1006 "--------- embed fun check_for ------------------------";
1007 "--------- embed fun check_for ------------------------";
1010 [(["functionTerm (x \<up> 2 + sin (x \<up> 4))", "differentiateFor x", "derivative f_f'"],
1011 ("Isac_Knowledge", ["derivative_of", "function"], ["diff", "differentiate_on_R"]))];
1014 autoCalculate 1 CompleteCalcHead;
1015 autoCalculate 1 (Steps 1);
1016 autoCalculate 1 (Steps 1);(*([1], Res), d_d x (x \<up> 2) + d_d x (sin (x \<up> 4))*)
1017 (*autoCalculate 1 (Steps 1);([2], Res), d_d x (x \<up> 2) + cos (x \<up> 4) * d_d x (x \<up> \<up> 4)*)
1019 "~~~~~ fun appendFormula , args:"; val (cI, (ifo:TermC.as_string)) = (1, "d_d x (x \<up> 2) + cos (4 * x \<up> 3)");
1020 "~~~~~ fun appendFormula' , args:"; val (cI, (ifo: TermC.as_string)) = (cI, ifo);
1021 val cs = get_calc cI
1022 val pos = get_pos cI 1;
1023 (*+*)if pos = ([1], Res) then () else error "inform with (positive) Error_Pattern.check_for broken 1";
1024 val ("ok", cs' as (_, _, ptp)) = (*case*) Step.do_next pos cs (*of*);
1025 (*case*) Step_Solve.by_term ptp (encode ifo) (*of*); (*ERROR WAS: "no derivation found"*)
1026 "~~~~~ fun Step_Solve.by_term , args:"; val (((*next_*)cs as (_, _, (pt, pos as (p, _))): Calc.state_post), istr)
1027 = (cs', (encode ifo));
1028 val ctxt = get_ctxt pt pos (*see TODO.thy*)
1029 val SOME f_in = (*case*) TermC.parse (ThyC.get_theory "Isac_Knowledge") istr (*of*);
1030 val f_in = Thm.term_of f_in
1031 val pos_pred = lev_back' pos
1032 val f_pred = Ctree.get_curr_formula (pt, pos_pred);
1033 (*if*) f_pred = f_in; (*else*)
1034 val NONE = (*case*) CAS_Cmd.input f_in (*of*);
1035 (*old* )val (_, _, metID) = get_obj g_spec pt (par_pblobj pt p)
1036 (*old*)val {scr = prog, ...} = MethodC.from_store metID
1037 (*old*)val istate = get_istate_LI pt pos
1038 (*old*)val ctxt = get_ctxt pt pos
1040 val LI.Not_Derivable =
1041 (*case*) LI.locate_input_term (pt, pos) f_in (*of*);
1042 val pp = Ctree.par_pblobj pt p
1043 val (errpats, nrls, prog) = case MethodC.from_store (Ctree.get_obj Ctree.g_metID pt pp) of
1044 {errpats, nrls, scr = Rule.Prog prog, ...} => (errpats, nrls, prog)
1045 | _ => error "inform: uncovered case of MethodC.from_store"
1047 (*+*)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\"]]"
1048 (*+*)then () else error "inform with (positive) Error_Pattern.check_for broken 3";
1050 val {env, ...} = Ctree.get_istate_LI pt pos |> Istate.the_pstate
1052 (*+*)if UnparseC.term f_pred = "d_d x (x \<up> 2) + d_d x (sin (x \<up> 4))" andalso
1053 (*+*) UnparseC.term f_in = "d_d x (x \<up> 2) + cos (4 * x \<up> 3)"
1054 (*+*)then () else error "inform with (positive) Error_Pattern.check_for broken 2";
1056 val SOME "chain-rule-diff-both" = (*case*) Error_Pattern.check_for (f_pred, f_in) (prog, env) (errpats, nrls) (*of*);
1059 (*+*)val (_, _, ptp') = cs';
1060 case Step_Solve.by_term ptp' (encode ifo) of
1061 ("error pattern #chain-rule-diff-both#", calcstate') => ()
1062 | _ => error "inform with (positive) Error_Pattern.check_for broken"
1065 "--------- embed fun find_fill_patterns ---------------------------";
1066 "--------- embed fun find_fill_patterns ---------------------------";
1067 "--------- embed fun find_fill_patterns ---------------------------";
1070 [(["functionTerm (x \<up> 2 + sin (x \<up> 4))", "differentiateFor x", "derivative f_f'"],
1071 ("Isac_Knowledge", ["derivative_of", "function"], ["diff", "differentiate_on_R"]))];
1074 autoCalculate 1 CompleteCalcHead;
1075 autoCalculate 1 (Steps 1);
1076 autoCalculate 1 (Steps 1);(*([1], Res), d_d x (x \<up> 2) + d_d x (sin (x \<up> 4))*)
1077 appendFormula 1 "d_d x (x \<up> 2) + cos (4 * x \<up> 3)" (*|> Future.join*);
1078 (*<CALCMESSAGE> error pattern #chain-rule-diff-both# </CALCMESSAGE>*)
1080 <CALCMESSAGE> no derivation found </CALCMESSAGE>*)
1082 "~~~~~ fun findFillpatterns, args:"; val (cI, errpatID) = (1, "chain-rule-diff-both");
1083 val ((pt, _), _) = get_calc cI
1084 val pos = get_pos cI 1;
1085 "~~~~~ fun find_fill_patterns , args:"; val ((pt, pos as (p, _)), errpatID) = ((pt, pos), errpatID);
1086 val f_curr = Ctree.get_curr_formula (pt, pos);
1087 val pp = Ctree.par_pblobj pt p
1088 val (errpats, prog) = case MethodC.from_store (Ctree.get_obj Ctree.g_metID pt pp) of
1089 {errpats, scr = Rule.Prog prog, ...} => (errpats, prog)
1090 | _ => error "find_fill_patterns: uncovered case of MethodC.from_store"
1091 val {env, ...} = Ctree.get_istate_LI pt pos |> Istate.the_pstate
1092 val subst = Subst.for_bdv prog env
1093 val errpatthms = errpats
1094 |> filter ((curry op = errpatID) o (#1: Error_Pattern.T -> Error_Pattern.id))
1095 |> map (#3: Error_Pattern.T -> thm list)
1098 case map (Error_Pattern.fill_from_store subst f_curr errpatID) errpatthms |> flat of
1099 ("fill-d_d-arg", tm, thm, subs_opt) :: _ => if UnparseC.term tm =
1100 "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"
1101 then () else error "find_fill_patterns changed 1a"
1102 | _ => error "find_fill_patterns changed 1b"
1104 "~~~~~ fun fill_from_store, args:"; val (subst, form, errpatID, thm) =
1105 (subst, f_curr, errpatID, hd (*simulate beginning of "map"*) errpatthms);
1106 val thmDeriv = Thm.get_name_hint thm
1107 val (part, thyID) = Thy_Read.thy_containing_thm thmDeriv
1108 val theID = [part, thyID, "Theorems", ThmC.cut_id thmDeriv]
1109 val Thy_Write.Hthm {fillpats, ...} = Thy_Read.from_store theID
1110 val some = map (Error_Pattern.fill_form subst (thm, form) errpatID) fillpats;
1112 case some |> filter is_some |> map the of
1113 ("fill-d_d-arg", tm, thm, subsopt) :: _ => if UnparseC.term tm =
1114 "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"
1115 then () else error "find_fill_patterns changed 2a"
1116 | _ => error "find_fill_patterns changed 2b"
1118 "~~~~~ fun fill_form, args:";
1119 val ((subs_opt, subst), (thm, form), errpatID, (fillpatID, pat, erpaID)) =
1120 (subst, (thm, form), errpatID, hd (*simulate beginning of "map"*) fillpats);
1121 val (form', _, _, rewritten) =
1122 rew_sub (Isac()) 1 subst e_rew_ord Rule_Set.empty false [] (HOLogic.Trueprop $ pat) form;
1124 if UnparseC.term form' = "d_d x (x \<up> 2) + cos (x \<up> 4) * d_d x ?_dummy_1" then ()
1125 else error "find_fill_patterns changed 3";
1127 "~~~~~ to findFillpatterns return val:"; val (fillpats) =
1128 (map (Error_Pattern.fill_from_store (subs_opt, subst) f_curr errpatID) errpatthms |> flat) (*only from "hd errpatthms"*);
1130 "vvv--- dropped this code WN120730";
1131 val msg = "fill patterns " ^
1132 ((map ((apsnd UnparseC.term) o quad2pair) fillpats) |> map pair2str_ |> strs2str_);
1134 "fill patterns #fill-d_d-arg#d_d x (x \<up> 2) + d_d x (sin (x \<up> 4))" ^
1135 " =\nd_d x (x \<up> 2) + cos (x \<up> 4) * d_d x ?_dummy_1" ^
1136 "#fill-both-args#d_d x (x \<up> 2) + d_d x (sin (x \<up> 4))" ^
1137 " =\nd_d x (x \<up> 2) + cos ?_dummy_2 * d_d x ?_dummy_3" ^
1138 "#fill-d_d#d_d x (x \<up> 2) + d_d x (sin (x \<up> 4))" ^
1139 " =\nd_d x (x \<up> 2) + cos (x \<up> 4) * ?_dummy_1 x (x \<up> 4)" ^
1140 "#fill-inner-deriv#d_d x (x \<up> 2) + d_d x (sin (x \<up> 4))" ^
1141 " =\nd_d x (x \<up> 2) + cos (x \<up> 4) * ?_dummy_1" ^
1142 "#fill-all#d_d x (x \<up> 2) + d_d x (sin (x \<up> 4)) = d_d x (x \<up> 2) + ?_dummy_1#";
1143 " \<up> --- dropped this code WN120730";
1145 if (map #1 fillpats) =
1146 ["fill-d_d-arg", "fill-both-args", "fill-d_d", "fill-inner-deriv", "fill-all"]
1147 then () else error "find_fill_patterns changed 4b";
1150 "--------- build fun is_exactly_equal, inputFillFormula ----------";
1151 "--------- build fun is_exactly_equal, inputFillFormula ----------";
1152 "--------- build fun is_exactly_equal, inputFillFormula ----------";
1155 [(["functionTerm (x \<up> 2 + sin (x \<up> 4))", "differentiateFor x", "derivative f_f'"],
1156 ("Isac_Knowledge", ["derivative_of", "function"], ["diff", "differentiate_on_R"]))];
1159 autoCalculate 1 CompleteCalcHead;
1160 autoCalculate 1 (Steps 1);
1161 autoCalculate 1 (Steps 1);(*([1], Res), d_d x (x \<up> 2) + d_d x (sin (x \<up> 4))*)
1162 appendFormula 1 "d_d x (x \<up> 2) + cos (4 * x \<up> 3)" (*|> Future.join*); (*<<<<<<<=========================*)
1163 (* the check for errpat is maximally liberal (whole term modulo "nrls" from "type met"),
1164 would recognize "cos (4 * x \<up> (4 - 1)) + 2 * x" as well.
1165 results in <CALCMESSAGE> error pattern #chain-rule-diff-both# </CALCMESSAGE>
1166 instead of <CALCMESSAGE> no derivation found </CALCMESSAGE> *)
1167 val ((pt,pos), _) = get_calc 1;
1168 val p = get_pos 1 1;
1169 val (Form f, _, asms) = ME_Misc.pt_extract (pt, p);
1171 if p = ([1], Res) andalso UnparseC.term f = "d_d x (x \<up> 2) + d_d x (sin (x \<up> 4))" then
1172 case get_obj g_tac pt (fst p) of Rewrite_Inst (["(''bdv'', x)"],
1173 ("diff_sum", thm)) =>
1174 if (UnparseC.term o Thm.prop_of) thm = "d_d ?bdv (?u + ?v) = d_d ?bdv ?u + d_d ?bdv ?v" then ()
1175 else error "embed fun fill_form changed 11"
1176 | _ => error "embed fun fill_form changed 12"
1177 else error "embed fun fill_form changed 13";
1179 findFillpatterns 1 "chain-rule-diff-both"; (*<<<<<<<=================================*)
1180 (*<CALCMESSAGE> fill patterns #fill-d_d-arg#d_d x (x \<up> 2) + d_d x (sin (x \<up> 4)) =
1181 d_d x (x \<up> 2) + cos (x \<up> 4) * d_d x ?_dummy_1#fill-both-args#...#...#... *)
1182 val ((pt,pos),_) = get_calc 1;
1183 val p = get_pos 1 1;
1185 val (Form f, _, asms) = ME_Misc.pt_extract (pt, p);
1186 if p = ([1], Res) andalso UnparseC.term f = "d_d x (x \<up> 2) + d_d x (sin (x \<up> 4))" then
1187 case get_obj g_tac pt (fst p) of Rewrite_Inst (["(''bdv'', x)"],
1188 ("diff_sum", thm)) =>
1189 if (UnparseC.term o Thm.prop_of) thm = "d_d ?bdv (?u + ?v) = d_d ?bdv ?u + d_d ?bdv ?v" then ()
1190 else error "embed fun fill_form changed 21"
1191 | _ => error "embed fun fill_form changed 22"
1192 else error "embed fun fill_form changed 23";
1194 requestFillformula 1 ("chain-rule-diff-both", "fill-both-args");(*<<<<<<<============*)
1195 (*<AUTOCALC> ([1], Res) ([2], Res) ([2], Res) </AUTOCALC>*)
1196 val ((pt,pos),_) = get_calc 1;
1197 val p = get_pos 1 1;
1198 val (Form f, _, asms) = ME_Misc.pt_extract (pt, p);
1199 if p = ([1], Res) andalso existpt [2] pt
1200 andalso UnparseC.term f = "d_d x (x \<up> 2) + d_d x (sin (x \<up> 4))"
1201 then case get_obj g_tac pt (fst p) of Rewrite_Inst (["(''bdv'', x)"],
1202 ("diff_sum", thm)) =>
1203 if (UnparseC.term o Thm.prop_of) thm = "d_d ?bdv (?u + ?v) = d_d ?bdv ?u + d_d ?bdv ?v" then ()
1204 else error "embed fun fill_form changed 31"
1205 | _ => error "embed fun fill_form changed 32"
1206 else error "embed fun fill_form changed 33";
1208 (* input a formula which exactly fills the gaps in a "fillformula"
1209 presented to the learner immediately before by "requestFillformula (errpatID, fillpatID)":
1210 errpatID: lhs of the respective thm = lhs of fillformula with fillpatID.
1211 the respective thm is in the ctree ................
1213 "~~~~~ fun inputFillFormula, args:"; val (cI, ifo) =
1214 (1, "d_d x (x \<up> 2) + cos (x \<up> 4) * d_d x (x \<up> 4)");
1215 val ((pt, _), _) = get_calc cI
1216 val pos = get_pos cI 1;
1218 "~~~~~ fun is_exactly_equal, args:"; val ((pt, pos as (p, p_)), istr) = ((pt, pos), ifo);
1219 val SOME ifo = parseNEW (ThyC.get_theory "Isac_Knowledge" |> ThyC.to_ctxt) istr
1221 val tac = get_obj g_tac pt p';
1222 val Rewrite_Inst ([bbb as "(''bdv'', x)"], ("diff_sin_chain", ttt)) = tac;
1223 if (UnparseC.term o Thm.prop_of) ttt = "d_d ?bdv (sin ?u) = cos ?u * d_d ?bdv ?u" then ()
1224 else error "inputFillFormula changed 10";
1225 val Applicable.Yes rew = Step.check tac (pt, pos);
1226 val Rewrite_Inst' (_, _, _, _, _, _, _, (res, _)) = rew;
1228 "~~~~~ to inputFillFormula return val:"; val ("ok", tac) = ("ok", tac);
1229 val ("ok", (_, c, ptp as (_,p'))) = Step.by_tactic tac (pt, pos);
1230 upd_calc cI (ptp, []);
1232 autocalculateOK2xml cI pos (if null c then p' else last_elem c) p';
1234 "~~~~~ final check:";
1235 val ((pt, _),_) = get_calc 1;
1236 val p = get_pos 1 1;
1237 val (Form f, _, asms) = ME_Misc.pt_extract (pt, p);
1238 if p = ([2], Res) andalso UnparseC.term f = "d_d x (x \<up> 2) + cos (x \<up> 4) * d_d x (x \<up> 4)"
1239 then case get_obj g_tac pt (fst p) of Rewrite_Inst (["(''bdv'', x)"],
1240 ("diff_sin_chain", thm)) =>
1241 if (UnparseC.term o Thm.prop_of) thm = "d_d ?bdv (sin ?u) = cos ?u * d_d ?bdv ?u" then ()
1242 else error "inputFillFormula changed 111"
1243 | _ => error "inputFillFormula changed 112"
1244 else error "inputFillFormula changed 113";
1246 "--------- fun appl_adds -----------------------------------------";
1247 "--------- fun appl_adds -----------------------------------------";
1248 "--------- fun appl_adds -----------------------------------------";
1249 (* val (dI, oris, ppc, pbt, selct::ss) =
1250 (dI, pors, probl, ppc, map itms2fstr probl);
1253 (* val (dI, oris, ppc, pbt, (selct::ss))=
1254 (#1 (References.select ospec spec), oris, []:I_Model.T,
1255 ((#ppc o Problem.from_store) (#2 (References.select ospec spec))),(imodel2fstr imodel));
1256 val iii = appl_adds dI oris ppc pbt (selct::ss);
1257 tracing(I_Model.to_string thy iii);
1259 val itm = add_single' dI oris ppc pbt selct;
1260 val ppc = I_Model.add itm ppc;
1262 val _::selct::ss = (selct::ss);
1263 val itm = add_single' dI oris ppc pbt selct;
1264 val ppc = I_Model.add itm ppc;
1266 val _::selct::ss = (selct::ss);
1267 val itm = add_single' dI oris ppc pbt selct;
1268 val ppc = I_Model.add itm ppc;
1269 tracing(I_Model.to_string thy ppc);
1271 val _::selct::ss = (selct::ss);
1272 val itm = add_single' dI oris ppc pbt selct;
1273 val ppc = I_Model.add itm ppc;
1275 "--------- fun concat_deriv --------------------------------------";
1276 "--------- fun concat_deriv --------------------------------------";
1277 "--------- fun concat_deriv --------------------------------------";
1279 val ({rew_ord, erls, rules,...}, fo, ifo) =
1280 (Rule_Set.rep Test_simplify, TermC.str2term "x+1+ - 1*2=0", TermC.str2term "-2*1+(x+1)=0");
1281 (tracing o Derive.trtas2str) fod';
1283 (x + 1 + - 1 * 2 = 0, Thm ("radd_commute", "?m + ?n = ?n + ?m"), (- 1 * 2 + (x + 1) = 0, []))", "
1284 (- 1 * 2 + (x + 1) = 0, Thm ("radd_commute", "?m + ?n = ?n + ?m"), (- 1 * 2 + (1 + x) = 0, []))", "
1285 (- 1 * 2 + (1 + x) = 0, Thm ("radd_left_commute", "?x + (?y + ?z) = ?y + (?x + ?z)"), (1 + (- 1 * 2 + x) = 0, []))", "
1286 (1 + (- 1 * 2 + x) = 0, Thm ("#mult_Float ((~1,0), (0,0)) __ ((2,0), (0,0))", "- 1 * 2 = -2"), (1 + (-2 + x) = 0, []))"]
1288 (tracing o Derive.trtas2str) (map Derive.rev_deriv' rifod');
1290 (1 + (-2 + x) = 0, Thm ("sym_#mult_Float ((~2,0), (0,0)) __ ((1,0), (0,0))", "-2 = -2 * 1"), (1 + (-2 * 1 + x) = 0, []))", "
1291 (1 + (-2 * 1 + x) = 0, Thm ("sym_radd_left_commute", "?y + (?x + ?z) = ?x + (?y + ?z)"), (-2 * 1 + (1 + x) = 0, []))", "
1292 (-2 * 1 + (1 + x) = 0, Thm ("sym_radd_commute", "?n + ?m = ?m + ?n"), (-2 * 1 + (x + 1) = 0, []))"]
1295 "--------- handle an input formula -------------------------------";
1296 "--------- handle an input formula -------------------------------";
1297 "--------- handle an input formula -------------------------------";
1299 Untersuchung zur Formeleingabe (appendFormula, replaceFormla) zu einer Anregung von Alan Krempler:
1300 Welche RICHTIGEN Formeln koennen NICHT abgeleitet werden,
1301 wenn Abteilungen nur auf gleichem Level gesucht werden ?
1304 Beispiele zum Equationsolver von Richard Lang aus /src/sml/kbtest/rlang.sml
1306 ------------------------------------------------------------------------------
1307 "Schalk I s.87 Bsp 52a ((5*x)/(x - 2) - x/(x+2)=4)";
1308 ------------------------------------------------------------------------------
1309 1. "5 * x / (x - 2) - x / (x + 2) = 4"
1311 4. "12 * x + 4 * x \<up> 2 = 4 * (-4 + x \<up> 2)",Subproblem["normalise", "poly"..
1313 4.3. "16 + 12 * x = 0", Subproblem["degree_1", "polynomial", "univariate"..
1315 4.3.3. "[x = -4 / 3]")), Check_elementwise "Assumptions"
1318 ------------------------------------------------------------------------------
1319 (1)..(6): keine 'richtige' Eingabe kann abgeleitet werden, die einen Summanden auf die andere Seite verschiebt [Ableitung ware in 4.3.n]
1321 (4.1)..(4.3): keine 'richtige' Eingabe kann abgeleitet werden, die einen Summanden auf die andere Seite verschiebt [Ableitung ware in 4.3.n]
1322 ------------------------------------------------------------------------------
1325 ------------------------------------------------------------------------------
1326 "Schalk I s.87 Bsp 55b (x/(x \<up> 2 - 6*x+9) - 1/(x \<up> 2 - 3*x) =1/x)";
1327 ------------------------------------------------------------------------------
1328 1. "x / (x \<up> 2 - 6 * x + 9) - 1 / (x \<up> 2 - 3 * x) = 1 / x"
1330 4. "(3 + (- 1 * x + x \<up> 2)) * x = 1 * (9 * x + (x \<up> 3 + -6 * x \<up> 2))"
1331 Subproblem["normalise", "polynomial", "univariate"..
1333 4.4. "-6 * x + 5 * x \<up> 2 = 0", Subproblem["bdv_only", "degree_2", "poly"..
1335 4.4.4. "[x = 0, x = 6 / 5]", Check_elementwise "Assumptions"
1336 4.4.5. "[x = 0, x = 6 / 5]"
1338 5. "[x = 0, x = 6 / 5]", Check_elementwise "Assumptions"
1340 ------------------------------------------------------------------------------
1341 (1)..(4): keine 'richtige' Eingabe kann abgeleitet werden, die einen Summanden auf die andere Seite schiebt [Ableitung waere in 4.4.x]
1343 (4.1)..(4.4.5): keine 'richtige' Eingabe kann abgeleitet werden, die dem Ergebnis "[x = 6 / 5]" aequivalent ist [Ableitung waere in 5.]
1344 ------------------------------------------------------------------------------
1347 ------------------------------------------------------------------------------
1348 "Schalk II s.56 Bsp 73b (sqrt(x+1)+sqrt(4*x+4)=sqrt(9*x+9))";
1349 ------------------------------------------------------------------------------
1350 1. "sqrt (x + 1) + sqrt (4 * x + 4) = sqrt (9 * x + 9)"
1352 6. "13 + 13 * x + -2 * sqrt ((4 + 4 * x) * (9 + 9 * x)) = 1 + x"
1353 Subproblem["sq", "rootX", "univariate", "equation"]
1355 6.6. "144 + 288 * x + 144 * x \<up> 2 = 144 + x \<up> 2 + 288 * x + 143 * x \<up> 2"
1356 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*)