akargl@42176
|
1 |
(* Title: tests on inform.sml
|
akargl@42176
|
2 |
Author: Walther Neuper 060225,
|
neuper@37906
|
3 |
(c) due to copyright terms
|
neuper@37906
|
4 |
|
neuper@37906
|
5 |
use"../smltest/ME/inform.sml";
|
neuper@37906
|
6 |
use"inform.sml";
|
neuper@37906
|
7 |
*)
|
neuper@37906
|
8 |
|
neuper@37906
|
9 |
"-----------------------------------------------------------------";
|
neuper@37906
|
10 |
"table of contents -----------------------------------------------";
|
neuper@37906
|
11 |
"-----------------------------------------------------------------";
|
neuper@37906
|
12 |
"appendForm with miniscript with mini-subpbl:";
|
neuper@37906
|
13 |
"--------- appendFormula: on Res + equ_nrls ----------------------";
|
neuper@37906
|
14 |
"--------- appendFormula: on Frm + equ_nrls ----------------------";
|
neuper@37906
|
15 |
"--------- appendFormula: on Res + NO deriv ----------------------";
|
neuper@37906
|
16 |
"--------- appendFormula: on Res + late deriv --------------------";
|
neuper@37906
|
17 |
"--------- appendFormula: on Res + late deriv [x = 3 + -2]---///--";
|
neuper@37906
|
18 |
"replaceForm with miniscript with mini-subpbl:";
|
neuper@37906
|
19 |
"--------- replaceFormula: on Res + = ----------------------------";
|
neuper@37906
|
20 |
"--------- replaceFormula: on Res + = 1st Nd ---------------------";
|
neuper@37906
|
21 |
"--------- replaceFormula: on Frm + = 1st Nd ---------------------";
|
neuper@37906
|
22 |
"--------- replaceFormula: cut calculation -----------------------";
|
neuper@37906
|
23 |
"--------- replaceFormula: cut calculation -----------------------";
|
neuper@37906
|
24 |
(* 040307 copied from informtest.sml ... old versions
|
neuper@37906
|
25 |
"--------- maximum-example, UC: Modeling / modifyCalcHead --------";*)
|
neuper@37906
|
26 |
"--------- syntax error ------------------------------------------";
|
neuper@37906
|
27 |
"CAS-command:";
|
neuper@37906
|
28 |
"--------- CAS-command on ([],Pbl) -------------------------------";
|
neuper@37906
|
29 |
"--------- CAS-command on ([],Pbl) FE-interface ------------------";
|
neuper@37906
|
30 |
"--------- inform [rational,simplification] ----------------------";
|
neuper@37906
|
31 |
"--------- Take as 1st tac, start with <NEW> (CAS input) ---------";
|
neuper@37906
|
32 |
"--------- Take as 1st tac, start from exp -----------------------";
|
neuper@37906
|
33 |
"--------- init_form, start with <NEW> (CAS input) ---------------";
|
neuper@42423
|
34 |
"--------- build fun check_err_patt ------------------------------";
|
neuper@42426
|
35 |
"--------- build fun check_err_patt ?bdv -------------------------";
|
neuper@42428
|
36 |
"--------- build fun check_error_patterns ------------------------";
|
neuper@42428
|
37 |
"--------- embed fun check_error_patterns ------------------------";
|
neuper@42430
|
38 |
"--------- embed fun find_fillpatterns ---------------------------";
|
neuper@37906
|
39 |
"-----------------------------------------------------------------";
|
neuper@37906
|
40 |
"-----------------------------------------------------------------";
|
neuper@37906
|
41 |
"-----------------------------------------------------------------";
|
neuper@37906
|
42 |
|
neuper@37906
|
43 |
|
neuper@37906
|
44 |
"--------- appendFormula: on Res + equ_nrls ----------------------";
|
neuper@37906
|
45 |
"--------- appendFormula: on Res + equ_nrls ----------------------";
|
neuper@37906
|
46 |
"--------- appendFormula: on Res + equ_nrls ----------------------";
|
akargl@42176
|
47 |
|
neuper@37906
|
48 |
val Script sc = (#scr o get_met) ["Test","squ-equ-test-subpbl1"];
|
neuper@37906
|
49 |
(writeln o term2str) sc;
|
neuper@37906
|
50 |
val Script sc = (#scr o get_met) ["Test","solve_linear"];
|
neuper@37906
|
51 |
(writeln o term2str) sc;
|
neuper@37906
|
52 |
|
neuper@37906
|
53 |
states:=[];
|
neuper@41970
|
54 |
CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
|
neuper@41970
|
55 |
("Test", ["sqroot-test","univariate","equation","test"],
|
neuper@37906
|
56 |
["Test","squ-equ-test-subpbl1"]))];
|
neuper@37906
|
57 |
Iterator 1; moveActiveRoot 1;
|
neuper@37906
|
58 |
autoCalculate 1 CompleteCalcHead;
|
neuper@37906
|
59 |
autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
|
neuper@37906
|
60 |
autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
|
neuper@37906
|
61 |
|
neuper@37906
|
62 |
appendFormula 1 "-2 * 1 + (1 + x) = 0"; refFormula 1 (get_pos 1 1);
|
neuper@37906
|
63 |
val ((pt,_),_) = get_calc 1;
|
neuper@37906
|
64 |
val str = pr_ptree pr_short pt;
|
akargl@42176
|
65 |
|
neuper@37906
|
66 |
writeln str;
|
akargl@42209
|
67 |
(*============ inhibit exn AK110726 ==============================================
|
akargl@42176
|
68 |
(* 2nd string should be the same as 1st one *)
|
akargl@42176
|
69 |
". ----- pblobj -----\n1. x + 1 = 2\n2. x + 1 + -1 * 2 = 0\n2.1. x + 1 + -1 * 2 = 0\n2.2. 1 + x + -1 * 2 = 0\n2.3. 1 + (x + -1 * 2) = 0\n2.4. 1 + (x + -2) = 0\n2.5. 1 + (x + -2 * 1) = 0\n2.6. 1 + x + -2 * 1 = 0\n";
|
akargl@42176
|
70 |
". ----- pblobj -----\n1. x + 1 = 2\n2. x + 1 + -1 * 2 = 0\n2.1. x + 1 + -1 * 2 = 0\n2.2. -1 * 2 + (x + 1) = 0\n2.3. -1 * 2 + (1 + x) = 0\n2.4. 1 + (-1 * 2 + x) = 0\n2.5. 1 + (-2 + x) = 0\n2.6. 1 + (-2 * 1 + x) = 0\n";
|
neuper@37906
|
71 |
if str = ". ----- pblobj -----\n1. x + 1 = 2\n2. x + 1 + -1 * 2 = 0\n2.1. x + 1 + -1 * 2 = 0\n2.2. -1 * 2 + (x + 1) = 0\n2.3. -1 * 2 + (1 + x) = 0\n2.4. 1 + (-1 * 2 + x) = 0\n2.5. 1 + (-2 + x) = 0\n2.6. 1 + (-2 * 1 + x) = 0\n" then ()
|
akargl@42209
|
72 |
else error "inform.sml: diff.behav.appendFormula: on Res + equ 1";
|
akargl@42209
|
73 |
============ inhibit exn AK110726 ==============================================*)
|
neuper@37906
|
74 |
|
neuper@37906
|
75 |
moveDown 1 ([ ],Pbl); refFormula 1 ([1],Frm); (*x + 1 = 2*)
|
neuper@37906
|
76 |
moveDown 1 ([1],Frm); refFormula 1 ([1],Res); (*x + 1 + -1 * 2 = 0*)
|
neuper@37906
|
77 |
|
neuper@37906
|
78 |
(*the seven steps of detailed derivation*)
|
neuper@37906
|
79 |
moveDown 1 ([1 ],Res); refFormula 1 ([2,1],Frm);
|
neuper@37906
|
80 |
moveDown 1 ([2,1],Frm); refFormula 1 ([2,1],Res);
|
neuper@37906
|
81 |
moveDown 1 ([2,1],Res); refFormula 1 ([2,2],Res);
|
neuper@37906
|
82 |
moveDown 1 ([2,2],Res); refFormula 1 ([2,3],Res);
|
neuper@37906
|
83 |
moveDown 1 ([2,3],Res); refFormula 1 ([2,4],Res);
|
neuper@37906
|
84 |
moveDown 1 ([2,4],Res); refFormula 1 ([2,5],Res);
|
neuper@37906
|
85 |
moveDown 1 ([2,5],Res); refFormula 1 ([2,6],Res);
|
neuper@37906
|
86 |
val ((pt,_),_) = get_calc 1;
|
neuper@37906
|
87 |
if "-2 * 1 + (1 + x) = 0" = term2str (fst (get_obj g_result pt [2,6])) then()
|
neuper@38031
|
88 |
else error "inform.sml: diff.behav.appendFormula: on Res + equ 2";
|
neuper@37906
|
89 |
|
neuper@37906
|
90 |
fetchProposedTactic 1; (*takes Iterator 1 _1_*)
|
akargl@42209
|
91 |
|
akargl@42176
|
92 |
(*============ inhibit exn AK110725 ==============================================
|
akargl@42176
|
93 |
(* ERROR: exception Bind raised *)
|
neuper@37906
|
94 |
val (_,(tac,_,_)::_) = get_calc 1;
|
neuper@37906
|
95 |
if tac = Rewrite_Set "Test_simplify" then ()
|
neuper@38031
|
96 |
else error "inform.sml: diff.behav.appendFormula: on Res + equ 3";
|
akargl@42176
|
97 |
============ inhibit exn AK110725 ==============================================*)
|
akargl@42209
|
98 |
|
neuper@37906
|
99 |
autoCalculate 1 CompleteCalc;
|
neuper@37906
|
100 |
val ((pt,_),_) = get_calc 1;
|
neuper@37906
|
101 |
if "[x = 1]" = term2str (fst (get_obj g_result pt [])) then ()
|
neuper@38031
|
102 |
else error "inform.sml: diff.behav.appendFormula: on Res + equ 4";
|
neuper@37906
|
103 |
(* autoCalculate 1 CompleteCalc;
|
neuper@37906
|
104 |
val ((pt,p),_) = get_calc 1;
|
neuper@37906
|
105 |
(writeln o istates2str) (get_obj g_loc pt [ ]);
|
neuper@37906
|
106 |
(writeln o istates2str) (get_obj g_loc pt [1]);
|
neuper@37906
|
107 |
(writeln o istates2str) (get_obj g_loc pt [2]);
|
neuper@37906
|
108 |
(writeln o istates2str) (get_obj g_loc pt [3]);
|
neuper@37906
|
109 |
(writeln o istates2str) (get_obj g_loc pt [3,1]);
|
neuper@37906
|
110 |
(writeln o istates2str) (get_obj g_loc pt [3,2]);
|
neuper@37906
|
111 |
(writeln o istates2str) (get_obj g_loc pt [4]);
|
neuper@37906
|
112 |
|
neuper@37906
|
113 |
*)
|
neuper@37906
|
114 |
"----------------------------------------------------------";
|
akargl@42176
|
115 |
|
akargl@42176
|
116 |
val fod = make_deriv (@{theory "Isac"}) Atools_erls
|
neuper@37906
|
117 |
((#rules o rep_rls) Test_simplify)
|
akargl@42176
|
118 |
(sqrt_right false (@{theory "Pure"})) NONE
|
neuper@37906
|
119 |
(str2term "x + 1 + -1 * 2 = 0");
|
neuper@37906
|
120 |
(writeln o trtas2str) fod;
|
neuper@37906
|
121 |
|
akargl@42176
|
122 |
val ifod = make_deriv (@{theory "Isac"}) Atools_erls
|
neuper@37906
|
123 |
((#rules o rep_rls) Test_simplify)
|
akargl@42176
|
124 |
(sqrt_right false (@{theory "Pure"})) NONE
|
neuper@37906
|
125 |
(str2term "-2 * 1 + (1 + x) = 0");
|
neuper@37906
|
126 |
(writeln o trtas2str) ifod;
|
akargl@42176
|
127 |
fun equal (_,_,(t1, _)) (_,_,(t2, _)) = t1 = t2;
|
neuper@37906
|
128 |
val (fod', rifod') = dropwhile' equal (rev fod) (rev ifod);
|
neuper@37906
|
129 |
val der = fod' @ (map rev_deriv' rifod');
|
neuper@37906
|
130 |
(writeln o trtas2str) der;
|
neuper@37906
|
131 |
"----------------------------------------------------------";
|
neuper@37906
|
132 |
|
neuper@37906
|
133 |
|
neuper@37906
|
134 |
"--------- appendFormula: on Frm + equ_nrls ----------------------";
|
neuper@37906
|
135 |
"--------- appendFormula: on Frm + equ_nrls ----------------------";
|
neuper@37906
|
136 |
"--------- appendFormula: on Frm + equ_nrls ----------------------";
|
neuper@37906
|
137 |
states:=[];
|
neuper@41970
|
138 |
CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
|
neuper@41970
|
139 |
("Test", ["sqroot-test","univariate","equation","test"],
|
neuper@37906
|
140 |
["Test","squ-equ-test-subpbl1"]))];
|
neuper@37906
|
141 |
Iterator 1; moveActiveRoot 1;
|
neuper@37906
|
142 |
autoCalculate 1 CompleteCalcHead;
|
neuper@37906
|
143 |
autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1) (*x + 1 = 2*);
|
neuper@37906
|
144 |
appendFormula 1 "2+ -1 + x = 2"; refFormula 1 (get_pos 1 1);
|
neuper@37906
|
145 |
|
neuper@37906
|
146 |
moveDown 1 ([],Pbl); refFormula 1 ([1],Frm) (*x + 1 = 2*);
|
neuper@37906
|
147 |
|
neuper@37906
|
148 |
moveDown 1 ([1 ],Frm); refFormula 1 ([1,1],Frm);
|
neuper@37906
|
149 |
moveDown 1 ([1,1],Frm); refFormula 1 ([1,1],Res);
|
neuper@37906
|
150 |
moveDown 1 ([1,1],Res); refFormula 1 ([1,2],Res);
|
neuper@37906
|
151 |
moveDown 1 ([1,2],Res); refFormula 1 ([1,3],Res);
|
neuper@37906
|
152 |
moveDown 1 ([1,3],Res); refFormula 1 ([1,4],Res);
|
neuper@37906
|
153 |
moveDown 1 ([1,4],Res); refFormula 1 ([1,5],Res);
|
neuper@37906
|
154 |
moveDown 1 ([1,5],Res); refFormula 1 ([1,6],Res);
|
neuper@37906
|
155 |
val ((pt,_),_) = get_calc 1;
|
neuper@37906
|
156 |
if "2 + -1 + x = 2" = term2str (fst (get_obj g_result pt [1,6])) then()
|
neuper@38031
|
157 |
else error "inform.sml: diff.behav.appendFormula: on Frm + equ 1";
|
neuper@37906
|
158 |
|
neuper@37906
|
159 |
fetchProposedTactic 1; (*takes Iterator 1 _1_*)
|
neuper@37906
|
160 |
val (_,(tac,_,_)::_) = get_calc 1;
|
neuper@37906
|
161 |
if tac = Rewrite_Set "norm_equation" then ()
|
neuper@38031
|
162 |
else error "inform.sml: diff.behav.appendFormula: on Frm + equ 2";
|
neuper@37906
|
163 |
autoCalculate 1 CompleteCalc;
|
neuper@37906
|
164 |
val ((pt,_),_) = get_calc 1;
|
neuper@37906
|
165 |
if "[x = 1]" = term2str (fst (get_obj g_result pt [])) then ()
|
neuper@38031
|
166 |
else error "inform.sml: diff.behav.appendFormula: on Frm + equ 3";
|
neuper@37906
|
167 |
|
neuper@37906
|
168 |
|
neuper@37906
|
169 |
"--------- appendFormula: on Res + NO deriv ----------------------";
|
neuper@37906
|
170 |
"--------- appendFormula: on Res + NO deriv ----------------------";
|
neuper@37906
|
171 |
"--------- appendFormula: on Res + NO deriv ----------------------";
|
neuper@37906
|
172 |
states:=[];
|
neuper@41970
|
173 |
CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
|
neuper@41970
|
174 |
("Test", ["sqroot-test","univariate","equation","test"],
|
neuper@37906
|
175 |
["Test","squ-equ-test-subpbl1"]))];
|
neuper@37906
|
176 |
Iterator 1; moveActiveRoot 1;
|
neuper@37906
|
177 |
autoCalculate 1 CompleteCalcHead;
|
neuper@37906
|
178 |
autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
|
neuper@37906
|
179 |
autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
|
neuper@37906
|
180 |
|
neuper@37906
|
181 |
appendFormula 1 "x = 2";
|
neuper@37906
|
182 |
val ((pt,p),_) = get_calc 1;
|
neuper@37906
|
183 |
val str = pr_ptree pr_short pt;
|
neuper@37906
|
184 |
writeln str;
|
neuper@37906
|
185 |
if str = ". ----- pblobj -----\n1. x + 1 = 2\n" andalso p = ([1], Res)
|
neuper@37906
|
186 |
then ()
|
neuper@38031
|
187 |
else error "inform.sml: diff.behav.appendFormula: Res + NOder 1";
|
neuper@37906
|
188 |
|
neuper@37906
|
189 |
fetchProposedTactic 1;
|
neuper@37906
|
190 |
val (_,(tac,_,_)::_) = get_calc 1;
|
neuper@37906
|
191 |
if tac = Rewrite_Set "Test_simplify" then ()
|
neuper@38031
|
192 |
else error "inform.sml: diff.behav.appendFormula: Res + NOder 2";
|
neuper@37906
|
193 |
autoCalculate 1 CompleteCalc;
|
neuper@37906
|
194 |
val ((pt,_),_) = get_calc 1;
|
neuper@37906
|
195 |
if "[x = 1]" = term2str (fst (get_obj g_result pt [])) then ()
|
neuper@38031
|
196 |
else error "inform.sml: diff.behav.appendFormula: on Frm + equ 3";
|
neuper@37906
|
197 |
|
neuper@37906
|
198 |
|
neuper@37906
|
199 |
"--------- appendFormula: on Res + late deriv --------------------";
|
neuper@37906
|
200 |
"--------- appendFormula: on Res + late deriv --------------------";
|
neuper@37906
|
201 |
"--------- appendFormula: on Res + late deriv --------------------";
|
neuper@37906
|
202 |
states:=[];
|
neuper@41970
|
203 |
CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
|
neuper@41970
|
204 |
("Test", ["sqroot-test","univariate","equation","test"],
|
neuper@37906
|
205 |
["Test","squ-equ-test-subpbl1"]))];
|
neuper@37906
|
206 |
Iterator 1; moveActiveRoot 1;
|
neuper@37906
|
207 |
autoCalculate 1 CompleteCalcHead;
|
neuper@37906
|
208 |
autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
|
neuper@37906
|
209 |
autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
|
neuper@37906
|
210 |
|
neuper@37906
|
211 |
appendFormula 1 "x = 1";
|
neuper@37906
|
212 |
val ((pt,p),_) = get_calc 1;
|
neuper@37906
|
213 |
val str = pr_ptree pr_short pt;
|
neuper@37906
|
214 |
writeln str;
|
neuper@37906
|
215 |
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)
|
neuper@37906
|
216 |
then () (*finds 1 step too early: ([3,2], Res) "x = 1" also by script !!!*)
|
neuper@38031
|
217 |
else error "inform.sml: diff.behav.appendFormula: Res + late d 1";
|
akargl@42176
|
218 |
|
neuper@37906
|
219 |
fetchProposedTactic 1;
|
neuper@37906
|
220 |
val (_,(tac,_,_)::_) = get_calc 1;
|
neuper@37906
|
221 |
if tac = Check_Postcond ["linear", "univariate", "equation", "test"] then ()
|
neuper@38031
|
222 |
else error "inform.sml: diff.behav.appendFormula: Res + late d 2";
|
neuper@37906
|
223 |
autoCalculate 1 CompleteCalc;
|
neuper@37906
|
224 |
val ((pt,_),_) = get_calc 1;
|
neuper@37906
|
225 |
if "[x = 1]" = term2str (fst (get_obj g_result pt [])) then ()
|
neuper@38031
|
226 |
else error "inform.sml: diff.behav.appendFormula: Res + late d 3";
|
neuper@37906
|
227 |
|
neuper@37906
|
228 |
|
neuper@37906
|
229 |
"--------- appendFormula: on Res + late deriv [x = 3 + -2]---///--";
|
neuper@37906
|
230 |
"--------- appendFormula: on Res + late deriv [x = 3 + -2]---///--";
|
neuper@37906
|
231 |
"--------- appendFormula: on Res + late deriv [x = 3 + -2]---///--";
|
neuper@37906
|
232 |
states:=[];
|
neuper@41970
|
233 |
CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
|
neuper@41970
|
234 |
("Test", ["sqroot-test","univariate","equation","test"],
|
neuper@37906
|
235 |
["Test","squ-equ-test-subpbl1"]))];
|
neuper@37906
|
236 |
Iterator 1; moveActiveRoot 1;
|
neuper@37906
|
237 |
autoCalculate 1 CompleteCalcHead;
|
neuper@37906
|
238 |
autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
|
neuper@37906
|
239 |
autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
|
neuper@37906
|
240 |
appendFormula 1 "[x = 3 + -2*1]";
|
neuper@37906
|
241 |
val ((pt,p),_) = get_calc 1;
|
neuper@37906
|
242 |
val str = pr_ptree pr_short pt;
|
neuper@37906
|
243 |
writeln str;
|
neuper@37906
|
244 |
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 ()
|
neuper@38031
|
245 |
else error "inform.sml: diff.behav.appendFormula: Res + latEE 1";
|
neuper@37906
|
246 |
autoCalculate 1 CompleteCalc;
|
neuper@37906
|
247 |
val ((pt,p),_) = get_calc 1;
|
neuper@37906
|
248 |
if "[x = 3 + -2 * 1]" = term2str (fst (get_obj g_result pt [])) then ()
|
neuper@37906
|
249 |
(* ~~~~~~~~~~ simplify as last step in any script ?!*)
|
neuper@38031
|
250 |
else error "inform.sml: diff.behav.appendFormula: Res + latEE 2";
|
neuper@37906
|
251 |
|
neuper@37906
|
252 |
|
neuper@37906
|
253 |
|
neuper@37906
|
254 |
"--------- replaceFormula: on Res + = ----------------------------";
|
neuper@37906
|
255 |
"--------- replaceFormula: on Res + = ----------------------------";
|
neuper@37906
|
256 |
"--------- replaceFormula: on Res + = ----------------------------";
|
neuper@37906
|
257 |
states:=[];
|
neuper@41970
|
258 |
CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
|
neuper@41970
|
259 |
("Test", ["sqroot-test","univariate","equation","test"],
|
neuper@37906
|
260 |
["Test","squ-equ-test-subpbl1"]))];
|
neuper@37906
|
261 |
Iterator 1; moveActiveRoot 1;
|
neuper@37906
|
262 |
autoCalculate 1 CompleteCalcHead;
|
neuper@37906
|
263 |
autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
|
neuper@37906
|
264 |
autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
|
neuper@37906
|
265 |
autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*-1 + x*);
|
neuper@37906
|
266 |
|
neuper@37906
|
267 |
replaceFormula 1 "-2 * 1 + (1 + x) = 0"; refFormula 1 (get_pos 1 1);
|
neuper@37906
|
268 |
val ((pt,_),_) = get_calc 1;
|
neuper@37906
|
269 |
val str = pr_ptree pr_short pt;
|
neuper@37906
|
270 |
writeln str;
|
akargl@42176
|
271 |
|
akargl@42176
|
272 |
(*============ inhibit exn AK110725 ==============================================
|
akargl@42176
|
273 |
(* 2nd string should be the same as 1st one *)
|
akargl@42176
|
274 |
". ----- pblobj -----\n1. x + 1 = 2\n2. x + 1 + -1 * 2 = 0\n2.1. x + 1 + -1 * 2 = 0\n2.2. 1 + x + -1 * 2 = 0\n2.3. 1 + (x + -1 * 2) = 0\n2.4. 1 + (x + -2) = 0\n2.5. 1 + (x + -2 * 1) = 0\n2.6. 1 + x + -2 * 1 = 0\n";
|
akargl@42176
|
275 |
". ----- pblobj -----\n1. x + 1 = 2\n2. x + 1 + -1 * 2 = 0\n2.1. x + 1 + -1 * 2 = 0\n2.2. -1 * 2 + (x + 1) = 0\n2.3. -1 * 2 + (1 + x) = 0\n2.4. 1 + (-1 * 2 + x) = 0\n2.5. 1 + (-2 + x) = 0\n2.6. 1 + (-2 * 1 + x) = 0\n";
|
akargl@42176
|
276 |
if str = ". ----- pblobj -----\n1. x + 1 = 2\n2. x + 1 + -1 * 2 = 0\n2.1. x + 1 + -1 * 2 = 0\n2.2. -1 * 2 + (x + 1) = 0\n2.3. -1 * 2 + (1 + x) = 0\n2.4. 1 + (-1 * 2 + x) = 0\n2.5. 1 + (-2 + x) = 0\n2.6. 1 + (-2 * 1 + x) = 0\n" then()
|
neuper@38031
|
277 |
else error "inform.sml: diff.behav.replaceFormula: on Res += 1";
|
akargl@42176
|
278 |
============ inhibit exn AK110725 ==============================================*)
|
akargl@42176
|
279 |
|
neuper@37906
|
280 |
autoCalculate 1 CompleteCalc;
|
akargl@42176
|
281 |
val ((pt,pos as (p,_)),_) = get_calc 1;
|
akargl@42176
|
282 |
if pos = ([],Res) andalso "[x = 1]" = (term2str o fst) (get_obj g_result pt p) then()
|
neuper@38031
|
283 |
else error "inform.sml: diff.behav.replaceFormula: on Res + = 2";
|
neuper@37906
|
284 |
|
neuper@37906
|
285 |
|
neuper@37906
|
286 |
"--------- replaceFormula: on Res + = 1st Nd ---------------------";
|
neuper@37906
|
287 |
"--------- replaceFormula: on Res + = 1st Nd ---------------------";
|
neuper@37906
|
288 |
"--------- replaceFormula: on Res + = 1st Nd ---------------------";
|
neuper@37906
|
289 |
states:=[];
|
neuper@41970
|
290 |
CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
|
neuper@41970
|
291 |
("Test", ["sqroot-test","univariate","equation","test"],
|
neuper@37906
|
292 |
["Test","squ-equ-test-subpbl1"]))];
|
neuper@37906
|
293 |
Iterator 1; moveActiveRoot 1;
|
neuper@37906
|
294 |
autoCalculate 1 CompleteCalcHead;
|
neuper@37906
|
295 |
autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
|
neuper@37906
|
296 |
autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
|
neuper@37906
|
297 |
|
neuper@37906
|
298 |
replaceFormula 1 "x + 1 = 4 + -2"; refFormula 1 (get_pos 1 1);
|
neuper@37906
|
299 |
val ((pt,_),_) = get_calc 1;
|
neuper@37906
|
300 |
val str = pr_ptree pr_short pt;
|
neuper@37906
|
301 |
writeln str;
|
akargl@42176
|
302 |
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 ()
|
neuper@38031
|
303 |
else error "inform.sml: diff.behav.replaceFormula: on Res 1 + = 1";
|
neuper@37906
|
304 |
autoCalculate 1 CompleteCalc;
|
akargl@42176
|
305 |
val ((pt,pos as (p,_)),_) = get_calc 1;
|
akargl@42176
|
306 |
if pos = ([],Res) andalso "[x = 1]" = (term2str o fst)(get_obj g_result pt p) then()
|
neuper@38031
|
307 |
else error "inform.sml: diff.behav.replaceFormula: on Res + = 2";
|
neuper@37906
|
308 |
|
neuper@37906
|
309 |
|
neuper@37906
|
310 |
"--------- replaceFormula: on Frm + = 1st Nd ---------------------";
|
neuper@37906
|
311 |
"--------- replaceFormula: on Frm + = 1st Nd ---------------------";
|
neuper@37906
|
312 |
"--------- replaceFormula: on Frm + = 1st Nd ---------------------";
|
neuper@37906
|
313 |
states:=[];
|
neuper@41970
|
314 |
CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
|
neuper@41970
|
315 |
("Test", ["sqroot-test","univariate","equation","test"],
|
neuper@37906
|
316 |
["Test","squ-equ-test-subpbl1"]))];
|
neuper@37906
|
317 |
Iterator 1; moveActiveRoot 1;
|
neuper@37906
|
318 |
autoCalculate 1 CompleteCalcHead;
|
neuper@37906
|
319 |
autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
|
neuper@37906
|
320 |
|
neuper@37906
|
321 |
replaceFormula 1 "x + 1 = 4 + -2"; refFormula 1 (get_pos 1 1);
|
neuper@37906
|
322 |
val ((pt,_),_) = get_calc 1;
|
neuper@37906
|
323 |
val str = pr_ptree pr_short pt;
|
neuper@37906
|
324 |
writeln str;
|
akargl@42176
|
325 |
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 ()
|
neuper@38031
|
326 |
else error "inform.sml: diff.behav.replaceFormula: on Frm 1 + = 1";
|
neuper@37906
|
327 |
autoCalculate 1 CompleteCalc;
|
akargl@42176
|
328 |
val ((pt,pos as (p,_)),_) = get_calc 1;
|
akargl@42176
|
329 |
if pos = ([],Res) andalso "[x = 1]" = (term2str o fst)(get_obj g_result pt p) then()
|
neuper@38031
|
330 |
else error "inform.sml: diff.behav.replaceFormula: on Frm 1 + = 2";
|
neuper@37906
|
331 |
|
neuper@37906
|
332 |
|
neuper@37906
|
333 |
"--------- replaceFormula: cut calculation -----------------------";
|
neuper@37906
|
334 |
"--------- replaceFormula: cut calculation -----------------------";
|
neuper@37906
|
335 |
"--------- replaceFormula: cut calculation -----------------------";
|
neuper@37906
|
336 |
states:=[];
|
neuper@41970
|
337 |
CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
|
neuper@41970
|
338 |
("Test", ["sqroot-test","univariate","equation","test"],
|
neuper@37906
|
339 |
["Test","squ-equ-test-subpbl1"]))];
|
neuper@37906
|
340 |
Iterator 1; moveActiveRoot 1;
|
neuper@37906
|
341 |
autoCalculate 1 CompleteCalc;
|
neuper@37906
|
342 |
moveActiveRoot 1; moveActiveDown 1;
|
neuper@37906
|
343 |
if get_pos 1 1 = ([1], Frm) then ()
|
neuper@38031
|
344 |
else error "inform.sml: diff.behav. cut calculation 1";
|
neuper@37906
|
345 |
|
neuper@37906
|
346 |
replaceFormula 1 "x + 1 = 4 + -2"; refFormula 1 (get_pos 1 1);
|
neuper@37906
|
347 |
val ((pt,p),_) = get_calc 1;
|
neuper@37906
|
348 |
val str = pr_ptree pr_short pt;
|
neuper@37906
|
349 |
writeln str;
|
neuper@37906
|
350 |
if p = ([1], Res) then ()
|
neuper@38031
|
351 |
else error "inform.sml: diff.behav. cut calculation 2";
|
neuper@37906
|
352 |
|
neuper@37906
|
353 |
|
neuper@37906
|
354 |
(* 040307 copied from informtest.sml; ... old version
|
neuper@37906
|
355 |
"---------------- maximum-example, UC: Modeling / modifyCalcHead -";
|
neuper@37906
|
356 |
"---------------- maximum-example, UC: Modeling / modifyCalcHead -";
|
neuper@37906
|
357 |
"---------------- maximum-example, UC: Modeling / modifyCalcHead -";
|
neuper@37906
|
358 |
|
neuper@37906
|
359 |
val p = ([],Pbl);
|
neuper@37906
|
360 |
val elems = ["fixedValues [r=Arbfix]","maximum A","valuesFor [a,b]",
|
neuper@37906
|
361 |
"relations [A=a*b, (a/2)^^^2 + (b/2)^^^2 = r^^^2]",
|
neuper@37906
|
362 |
"relations [A=a*b, (a/2)^^^2 + (b/2)^^^2 = r^^^2]",
|
neuper@37906
|
363 |
"relations [A=a*b, a/2=r*sin alpha, b/2=r*cos alpha]",
|
neuper@37906
|
364 |
(*^^^ these are the elements for the root-problem (in variants)*)
|
neuper@37906
|
365 |
(*vvv these are elements required for subproblems*)
|
neuper@37906
|
366 |
"boundVariable a","boundVariable b","boundVariable alpha",
|
neuper@37906
|
367 |
"interval {x::real. 0 <= x & x <= 2*r}",
|
neuper@37906
|
368 |
"interval {x::real. 0 <= x & x <= 2*r}",
|
neuper@37906
|
369 |
"interval {x::real. 0 <= x & x <= pi}",
|
neuper@37906
|
370 |
"errorBound (eps=(0::real))"]
|
neuper@37906
|
371 |
(*specifying is not interesting for this example*)
|
neuper@38058
|
372 |
val spec = ("DiffApp", ["maximum_of","function"],
|
neuper@37906
|
373 |
["DiffApp","max_by_calculus"]);
|
neuper@37906
|
374 |
(*the empty model with descriptions for user-guidance by Model_Problem*)
|
neuper@37906
|
375 |
val empty_model = [Given ["fixedValues []"],
|
neuper@37906
|
376 |
Find ["maximum", "valuesFor"],
|
neuper@37906
|
377 |
Relate ["relations []"]];
|
neuper@37906
|
378 |
|
neuper@37906
|
379 |
|
neuper@37906
|
380 |
(*!!!!!!!!!!!!!!!!! DON'T USE me FOR FINDING nxt !!!!!!!!!!!!!!!!!!*)
|
neuper@37906
|
381 |
val (p,_,f,nxt,_,pt) = CalcTreeTEST [(elems, spec)];
|
neuper@37906
|
382 |
(*val nxt = ("Model_Problem", ...*)
|
neuper@37924
|
383 |
val pbl = get_obj g_pbl pt (fst p); (writeln o (itms2str_ ctxt)) pbl;
|
neuper@37906
|
384 |
|
neuper@37906
|
385 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
neuper@37906
|
386 |
(*nxt = Add_Given "fixedValues [r = Arbfix]"*)
|
neuper@37924
|
387 |
val pbl = get_obj g_pbl pt (fst p); (writeln o (itms2str_ ctxt)) pbl;
|
neuper@37906
|
388 |
(*[
|
neuper@37906
|
389 |
(0 ,[] ,false ,#Given ,Inc fixedValues [] ,(??.empty, [])),
|
neuper@37906
|
390 |
(0 ,[] ,false ,#Find ,Inc maximum ,(??.empty, [])),
|
neuper@37906
|
391 |
(0 ,[] ,false ,#Find ,Inc valuesFor ,(??.empty, [])),
|
neuper@37906
|
392 |
(0 ,[] ,false ,#Relate ,Inc relations [] ,(??.empty, []))]*)
|
neuper@37906
|
393 |
|
neuper@37906
|
394 |
(*the empty CalcHead is checked w.r.t the model and re-established as such*)
|
neuper@37906
|
395 |
val (b,pt,ocalhd) = input_icalhd pt (p,"", empty_model, Pbl, e_spec);
|
neuper@37924
|
396 |
val pbl = get_obj g_pbl pt (fst p); (writeln o (itms2str_ ctxt)) pbl;
|
neuper@38031
|
397 |
if ocalhd2str ocalhd = "(Pbl, ??.empty, [\n(0 ,[] ,false ,#Given ,Inc fixedValues [] ,(??.empty, [])),\n(0 ,[] ,false ,#Find ,Inc maximum ,(??.empty, [])),\n(0 ,[] ,false ,#Find ,Inc valuesFor ,(??.empty, [])),\n(0 ,[] ,false ,#Relate ,Inc relations [] ,(??.empty, []))], [], \n(\"e_domID\", [\"e_pblID\"], [\"e_metID\"]) )" then () else error "informtest.sml: diff.behav. max 1";
|
neuper@37906
|
398 |
|
neuper@37906
|
399 |
(*there is one input to the model (could be more)*)
|
neuper@37906
|
400 |
val (b,pt,ocalhd) =
|
neuper@37906
|
401 |
input_icalhd pt (p,"", [Given ["fixedValues [r=Arbfix]"],
|
neuper@37906
|
402 |
Find ["maximum", "valuesFor"],
|
neuper@37906
|
403 |
Relate ["relations"]], Pbl, e_spec);
|
neuper@37924
|
404 |
val pbl = get_obj g_pbl pt (fst p); (writeln o (itms2str_ ctxt)) pbl;
|
neuper@37906
|
405 |
if ocalhd2str ocalhd = "(Pbl, ??.empty, [\n(1 ,[1,2,3] ,true ,#Given ,Cor fixedValues [r = Arbfix] ,(fix_, [[r = Arbfix]])),\n(0 ,[] ,false ,#Find ,Inc maximum ,(??.empty, [])),\n(0 ,[] ,false ,#Find ,Inc valuesFor ,(??.empty, [])),\n(0 ,[] ,false ,#Relate ,Inc relations [] ,(??.empty, []))], [], \n(\"e_domID\", [\"e_pblID\"], [\"e_metID\"]) )" then ()
|
neuper@38031
|
406 |
else error "informtest.sml: diff.behav. max 2";
|
neuper@37906
|
407 |
|
neuper@37906
|
408 |
(*this input is complete in variant 3, but the ME doesn't recognize FIXXXXME
|
neuper@37906
|
409 |
val (b,pt''''',ocalhd) =
|
neuper@37906
|
410 |
input_icalhd pt (p,"", [Given ["fixedValues [r=Arbfix]"],
|
neuper@37906
|
411 |
Find ["maximum A", "valuesFor [a,b]"],
|
neuper@37906
|
412 |
Relate ["relations [A=a*b, a/2=r*sin alpha, \
|
neuper@37906
|
413 |
\b/2=r*cos alpha]"]], Pbl, e_spec);
|
neuper@37924
|
414 |
val pbl = get_obj g_pbl pt''''' (fst p); (writeln o (itms2str_ ctxt)) pbl;
|
neuper@37906
|
415 |
if ocalhd2str ocalhd = ------------^^^^^^^^^^ missing !!!*)
|
neuper@37906
|
416 |
|
neuper@37906
|
417 |
(*this input is complete in variant 1 (variant 3 does not work yet)*)
|
neuper@37906
|
418 |
val (b,pt''''',ocalhd) =
|
neuper@37906
|
419 |
input_icalhd pt (p,"", [Given ["fixedValues [r=Arbfix]"],
|
neuper@37906
|
420 |
Find ["maximum A", "valuesFor [a,b]"],
|
neuper@37906
|
421 |
Relate ["relations [A=a*b, \
|
neuper@37906
|
422 |
\(a/2)^^^2 + (b/2)^^^2 = r^^^2]"]],
|
neuper@37906
|
423 |
Pbl, e_spec);
|
neuper@37924
|
424 |
val pbl = get_obj g_pbl pt''''' (fst p); (writeln o (itms2str_ ctxt)) pbl;
|
neuper@37906
|
425 |
|
neuper@37906
|
426 |
modifycalcheadOK2xml 111 (bool2str b) ocalhd;
|
neuper@37906
|
427 |
*)
|
neuper@37906
|
428 |
|
neuper@37906
|
429 |
"--------- syntax error ------------------------------------------";
|
neuper@37906
|
430 |
"--------- syntax error ------------------------------------------";
|
neuper@37906
|
431 |
"--------- syntax error ------------------------------------------";
|
neuper@37906
|
432 |
states:=[];
|
neuper@41970
|
433 |
CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
|
neuper@41970
|
434 |
("Test", ["sqroot-test","univariate","equation","test"],
|
neuper@37906
|
435 |
["Test","squ-equ-test-subpbl1"]))];
|
neuper@37906
|
436 |
Iterator 1; moveActiveRoot 1;
|
neuper@37906
|
437 |
autoCalculate 1 CompleteCalcHead;
|
neuper@37906
|
438 |
autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
|
neuper@37906
|
439 |
autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
|
neuper@37906
|
440 |
|
neuper@37906
|
441 |
appendFormula 1 " x - "; (*<ERROR> syntax error in ' x - ' </ERROR>*)
|
neuper@37906
|
442 |
val ((pt,_),_) = get_calc 1;
|
neuper@37906
|
443 |
val str = pr_ptree pr_short pt;
|
neuper@37906
|
444 |
writeln str;
|
neuper@37906
|
445 |
if str = ". ----- pblobj -----\n1. x + 1 = 2\n" then ()
|
neuper@38031
|
446 |
else error "inform.sml: diff.behav.appendFormula: syntax error";
|
neuper@37906
|
447 |
|
neuper@37906
|
448 |
|
neuper@37906
|
449 |
"--------- CAS-command on ([],Pbl) -------------------------------";
|
neuper@37906
|
450 |
"--------- CAS-command on ([],Pbl) -------------------------------";
|
neuper@37906
|
451 |
"--------- CAS-command on ([],Pbl) -------------------------------";
|
neuper@37906
|
452 |
val (p,_,f,nxt,_,pt) =
|
neuper@37906
|
453 |
CalcTreeTEST [([], ("e_domID", ["e_pblID"], ["e_metID"]))];
|
neuper@37906
|
454 |
val ifo = "solve(x+1=2,x)";
|
neuper@37906
|
455 |
val (_,(_,c,(pt,p))) = inform ([],[],(pt,p)) "solve(x+1=2,x)";
|
neuper@37906
|
456 |
show_pt pt;
|
neuper@37906
|
457 |
val nxt = ("Apply_Method",Apply_Method ["Test","squ-equ-test-subpbl1"]);
|
neuper@37906
|
458 |
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
|
neuper@37906
|
459 |
if p = ([1], Frm) andalso f2str f = "x + 1 = 2" then ()
|
neuper@38031
|
460 |
else error "inform.sml: diff.behav. CAScmd ([],Pbl)";
|
neuper@37906
|
461 |
|
neuper@37906
|
462 |
|
neuper@37906
|
463 |
"--------- CAS-command on ([],Pbl) FE-interface ------------------";
|
neuper@37906
|
464 |
"--------- CAS-command on ([],Pbl) FE-interface ------------------";
|
neuper@37906
|
465 |
"--------- CAS-command on ([],Pbl) FE-interface ------------------";
|
neuper@37906
|
466 |
states:=[];
|
neuper@37906
|
467 |
CalcTree [([], ("e_domID", ["e_pblID"], ["e_metID"]))];
|
neuper@37906
|
468 |
Iterator 1;
|
neuper@37906
|
469 |
moveActiveRoot 1;
|
neuper@37906
|
470 |
replaceFormula 1 "solve(x+1=2,x)";
|
neuper@37906
|
471 |
autoCalculate 1 CompleteCalc;
|
neuper@37906
|
472 |
val ((pt,p),_) = get_calc 1;
|
neuper@37906
|
473 |
show_pt pt;
|
neuper@37906
|
474 |
if p = ([], Res) then ()
|
neuper@38031
|
475 |
else error "inform.sml: diff.behav. CAScmd ([],Pbl) FE-interface";
|
neuper@37906
|
476 |
|
neuper@37906
|
477 |
|
neuper@37906
|
478 |
"--------- inform [rational,simplification] ----------------------";
|
neuper@37906
|
479 |
"--------- inform [rational,simplification] ----------------------";
|
neuper@37906
|
480 |
"--------- inform [rational,simplification] ----------------------";
|
neuper@37906
|
481 |
states:=[];
|
neuper@38083
|
482 |
CalcTree [(["Term (4/x - 3/y - 1)", "normalform N"],
|
neuper@38058
|
483 |
("Rational",["rational","simplification"],
|
neuper@37906
|
484 |
["simplification","of_rationals"]))];
|
neuper@37906
|
485 |
Iterator 1; moveActiveRoot 1;
|
neuper@37906
|
486 |
autoCalculate 1 CompleteCalcHead;
|
neuper@37906
|
487 |
autoCalculate 1 (Step 1);
|
neuper@37906
|
488 |
autoCalculate 1 (Step 1);
|
neuper@37906
|
489 |
autoCalculate 1 (Step 1);
|
neuper@37906
|
490 |
autoCalculate 1 (Step 1);
|
neuper@37906
|
491 |
"--- input the next formula that _should_ be presented by mat-engine";
|
neuper@37906
|
492 |
appendFormula 1 "(4 * y + -3 * x) / (x * y) + -1";
|
neuper@37906
|
493 |
val ((pt,p),_) = get_calc 1;
|
neuper@37906
|
494 |
if p = ([4], Res) andalso (length o children o (get_nd pt)) (fst p) = 2 then ()
|
neuper@38031
|
495 |
else error ("inform.sml: [rational,simplification] 1");
|
neuper@37906
|
496 |
|
neuper@37906
|
497 |
"--- input the next formula that would be presented by mat-engine";
|
neuper@37906
|
498 |
(*autoCalculate 1 (Step 1);*)
|
neuper@37906
|
499 |
appendFormula 1 "(4 * y + -3 * x + -1 * (x * y)) / (x * y)";
|
neuper@37906
|
500 |
val ((pt,p),_) = get_calc 1;
|
neuper@37906
|
501 |
if p = ([5], Res) andalso (length o children o (get_nd pt)) (fst p) = 0 then ()
|
neuper@38031
|
502 |
else error ("inform.sml: [rational,simplification] 2");
|
neuper@37906
|
503 |
|
neuper@37906
|
504 |
"--- input the exact final result";(*TODO: Exception- LIST "last_elem" raised*)
|
neuper@37906
|
505 |
appendFormula 1 "(-3 * x + 4 * y + -1 * x * y) / (x * y)";
|
neuper@37906
|
506 |
val ((pt,p),_) = get_calc 1;
|
neuper@37906
|
507 |
if p = ([6], Res) andalso (length o children o (get_nd pt)) (fst p) = 2 then ()
|
neuper@38031
|
508 |
else error ("inform.sml: [rational,simplification] 3");
|
neuper@37906
|
509 |
show_pt pt;
|
neuper@37906
|
510 |
|
neuper@37906
|
511 |
"--------- Take as 1st tac, start with <NEW> (CAS input) ---------";
|
neuper@37906
|
512 |
"--------- Take as 1st tac, start with <NEW> (CAS input) ---------";
|
neuper@37906
|
513 |
"--------- Take as 1st tac, start with <NEW> (CAS input) ---------";
|
neuper@37906
|
514 |
val t = str2term "Diff (x^^^2 + x + 1, x)";
|
neuper@37906
|
515 |
case t of Const ("Diff.Diff", _) $ _ => ()
|
neuper@37906
|
516 |
| _ => raise
|
neuper@37906
|
517 |
error "diff.sml behav.changed for CAS Diff (..., x)";
|
neuper@37906
|
518 |
atomty t;
|
neuper@37906
|
519 |
"-----------------------------------------------------------------";
|
neuper@37906
|
520 |
(*1>*)states:=[];
|
neuper@37906
|
521 |
(*2>*)CalcTree [([], ("e_domID", ["e_pblID"], ["e_metID"]))];
|
neuper@37906
|
522 |
(*3>*)Iterator 1;moveActiveRoot 1;
|
neuper@37906
|
523 |
"----- here the Headline has been finished";
|
neuper@37906
|
524 |
(*4>*)moveActiveFormula 1 ([],Pbl);
|
neuper@37906
|
525 |
(*5>*)replaceFormula 1 "Diff (x^2 + x + 1, x)";
|
neuper@37906
|
526 |
val ((pt,_),_) = get_calc 1;
|
neuper@37906
|
527 |
val PblObj {probl, meth, spec, fmz, env, loc, ...} = get_obj I pt [];
|
neuper@37926
|
528 |
val NONE = env;
|
neuper@37926
|
529 |
val (SOME istate, NONE) = loc;
|
neuper@37906
|
530 |
print_depth 5;
|
neuper@37906
|
531 |
writeln"-----------------------------------------------------------";
|
neuper@37906
|
532 |
spec;
|
neuper@37924
|
533 |
writeln (itms2str_ ctxt probl);
|
neuper@37924
|
534 |
writeln (itms2str_ ctxt meth);
|
akargl@42209
|
535 |
|
akargl@42176
|
536 |
(*============ inhibit exn AK110725 ==============================================
|
akargl@42209
|
537 |
(* ERROR: Argument: istate : istate * Proof.context Reason:
|
akargl@42209
|
538 |
Can't unify istate to istate * Proof.context *)
|
neuper@37906
|
539 |
writeln (istate2str istate);
|
akargl@42176
|
540 |
============ inhibit exn AK110725 ==============================================*)
|
neuper@37906
|
541 |
|
neuper@37906
|
542 |
print_depth 3;
|
neuper@37906
|
543 |
|
neuper@37906
|
544 |
refFormula 1 ([],Pbl) (*--> correct CalcHead*);
|
neuper@37906
|
545 |
(*081016 NOT necessary (but leave it in Java):*)
|
neuper@37906
|
546 |
(*6>*)(*completeCalcHead*)autoCalculate 1 CompleteCalcHead;
|
neuper@37906
|
547 |
"----- here the CalcHead has been completed --- ONCE MORE ?????";
|
neuper@37906
|
548 |
|
neuper@37906
|
549 |
(***difference II***)
|
neuper@37906
|
550 |
val ((pt,p),_) = get_calc 1;
|
neuper@37906
|
551 |
(*val p = ([], Pbl)*)
|
neuper@37906
|
552 |
val PblObj {probl, meth, spec, fmz, env, loc, ...} = get_obj I pt [];
|
neuper@37926
|
553 |
val NONE = env;
|
neuper@37926
|
554 |
val (SOME istate, NONE) = loc;
|
akargl@42176
|
555 |
(*============ inhibit exn AK110725 ==============================================
|
akargl@42176
|
556 |
(* ERROR: Argument: istate : istate * Proof.context Reason: Can't unify istate to istate * Proof.context *)
|
neuper@37906
|
557 |
print_depth 5; writeln (istate2str istate); print_depth 3;
|
akargl@42176
|
558 |
============ inhibit exn AK110725 ==============================================*)
|
neuper@37906
|
559 |
(*ScrState ([],
|
neuper@37926
|
560 |
[], NONE,
|
neuper@37906
|
561 |
??.empty, Sundef, false)*)
|
neuper@37906
|
562 |
print_depth 5; spec; print_depth 3;
|
neuper@38050
|
563 |
(*("Isac",
|
neuper@37906
|
564 |
["derivative_of", "function"],
|
neuper@37906
|
565 |
["diff", "differentiate_on_R"]) : spec*)
|
neuper@37924
|
566 |
writeln (itms2str_ ctxt probl);
|
neuper@37906
|
567 |
(*[
|
neuper@37906
|
568 |
(1 ,[1] ,true ,#Given ,Cor functionTerm (x ^^^ 2 + x + 1) ,(f_, [x ^^^ 2 + x + 1])),
|
neuper@37906
|
569 |
(2 ,[1] ,true ,#Given ,Cor differentiateFor x ,(v_, [x])),
|
akargl@42176
|
570 |
(3 ,[1] ,true ,#Find ,Cor derivative f_'_f ,(f_'_f, [f_'_f]))]*)
|
neuper@37924
|
571 |
writeln (itms2str_ ctxt meth);
|
neuper@37906
|
572 |
(*[
|
neuper@37906
|
573 |
(1 ,[1] ,true ,#Given ,Cor functionTerm (x ^^^ 2 + x + 1) ,(f_, [x ^^^ 2 + x + 1])),
|
neuper@37906
|
574 |
(2 ,[1] ,true ,#Given ,Cor differentiateFor x ,(v_, [x])),
|
akargl@42176
|
575 |
(3 ,[1] ,true ,#Find ,Cor derivative f_'_f ,(f_'_f, [f_'_f]))]*)
|
neuper@37906
|
576 |
writeln"-----------------------------------------------------------";
|
neuper@37906
|
577 |
(*7>*)fetchProposedTactic 1 (*--> Apply_Method*);
|
neuper@37906
|
578 |
(*WN081028 fixed <ERROR> helpless </ERROR> by inform returning ...(.,Met)*)
|
neuper@37906
|
579 |
autoCalculate 1 CompleteCalc;
|
neuper@37906
|
580 |
val ((pt,p),_) = get_calc 1;
|
neuper@37906
|
581 |
val Form res = (#1 o pt_extract) (pt, ([],Res));
|
neuper@37906
|
582 |
show_pt pt;
|
neuper@37906
|
583 |
if p = ([], Res) andalso term2str res = "1 + 2 * x" then ()
|
neuper@38031
|
584 |
else error "diff.sml behav.changed for Diff (x^2 + x + 1, x)";
|
neuper@37906
|
585 |
|
neuper@37906
|
586 |
|
neuper@37906
|
587 |
"--------- Take as 1st tac, start from exp -----------------------";
|
neuper@37906
|
588 |
"--------- Take as 1st tac, start from exp -----------------------";
|
neuper@37906
|
589 |
"--------- Take as 1st tac, start from exp -----------------------";
|
neuper@37906
|
590 |
(*the following input is copied from BridgeLog Java <==> SML,
|
neuper@37906
|
591 |
omitting unnecessary inputs*)
|
neuper@37906
|
592 |
(*1>*)states:=[];
|
akargl@42176
|
593 |
(*2>*)CalcTree [(["functionTerm (x^2 + x + 1)", "differentiateFor x", "derivative f_'_f"],("Isac",["derivative_of","function"],["diff","differentiate_on_R"]))];
|
neuper@37906
|
594 |
(*3>*)Iterator 1; moveActiveRoot 1;
|
neuper@37906
|
595 |
|
neuper@37906
|
596 |
(*6>*)(*completeCalcHead*)autoCalculate 1 CompleteCalcHead;
|
neuper@37906
|
597 |
(***difference II***)
|
neuper@37906
|
598 |
val ((pt,_),_) = get_calc 1;
|
neuper@37906
|
599 |
val PblObj {probl, meth, spec, fmz, env, loc, ...} = get_obj I pt [];
|
neuper@37926
|
600 |
val NONE = env;
|
neuper@37926
|
601 |
val (SOME istate, NONE) = loc;
|
akargl@42176
|
602 |
(*============ inhibit exn AK110725 ==============================================
|
akargl@42176
|
603 |
(* ERROR: Argument: istate : istate * Proof.context Reason: Can't unify istate to istate * Proof.context *)
|
neuper@37906
|
604 |
print_depth 5; writeln (istate2str istate); print_depth 3;
|
akargl@42176
|
605 |
============ inhibit exn AK110725 ==============================================*)
|
neuper@37906
|
606 |
(*ScrState ([],
|
neuper@37926
|
607 |
[], NONE,
|
neuper@37906
|
608 |
??.empty, Sundef, false)*)
|
neuper@37906
|
609 |
print_depth 5; spec; print_depth 3;
|
neuper@38050
|
610 |
(*("Isac",
|
neuper@37906
|
611 |
["derivative_of", "function"],
|
neuper@37906
|
612 |
["diff", "differentiate_on_R"]) : spec*)
|
neuper@37924
|
613 |
writeln (itms2str_ ctxt probl);
|
neuper@37906
|
614 |
(*[
|
neuper@37906
|
615 |
(1 ,[1] ,true ,#Given ,Cor functionTerm (x ^^^ 2 + x + 1) ,(f_, [x ^^^ 2 + x + 1])),
|
neuper@37906
|
616 |
(2 ,[1] ,true ,#Given ,Cor differentiateFor x ,(v_, [x])),
|
akargl@42176
|
617 |
(3 ,[1] ,true ,#Find ,Cor derivative f_'_f ,(f_'_f, [f_'_f]))]*)
|
neuper@37924
|
618 |
writeln (itms2str_ ctxt meth);
|
neuper@37906
|
619 |
(*[
|
neuper@37906
|
620 |
(1 ,[1] ,true ,#Given ,Cor functionTerm (x ^^^ 2 + x + 1) ,(f_, [x ^^^ 2 + x + 1])),
|
neuper@37906
|
621 |
(2 ,[1] ,true ,#Given ,Cor differentiateFor x ,(v_, [x])),
|
akargl@42176
|
622 |
(3 ,[1] ,true ,#Find ,Cor derivative f_'_f ,(f_'_f, [f_'_f]))]*)
|
neuper@37906
|
623 |
writeln"-----------------------------------------------------------";
|
neuper@37906
|
624 |
(*7>*)fetchProposedTactic 1 (*--> Apply_Method*);
|
neuper@37906
|
625 |
autoCalculate 1 (Step 1);
|
neuper@37906
|
626 |
val ((pt,p),_) = get_calc 1;
|
neuper@37906
|
627 |
val Form res = (#1 o pt_extract) (pt, p);
|
neuper@37906
|
628 |
if term2str res = "d_d x (x ^^^ 2 + x + 1)" then ()
|
neuper@38031
|
629 |
else error "diff.sml Diff (x^2 + x + 1, x) from exp";
|
neuper@37906
|
630 |
|
neuper@37906
|
631 |
|
neuper@37906
|
632 |
"--------- init_form, start with <NEW> (CAS input) ---------------";
|
neuper@37906
|
633 |
"--------- init_form, start with <NEW> (CAS input) ---------------";
|
neuper@37906
|
634 |
"--------- init_form, start with <NEW> (CAS input) ---------------";
|
neuper@37906
|
635 |
states:=[];
|
neuper@37906
|
636 |
CalcTree [([], ("e_domID", ["e_pblID"], ["e_metID"]))];
|
neuper@37906
|
637 |
(*[[from sml: > @@@@@begin@@@@@
|
neuper@37906
|
638 |
[[from sml: 1
|
neuper@37906
|
639 |
[[from sml: <CALCTREE>
|
neuper@37906
|
640 |
[[from sml: <CALCID> 1 </CALCID>
|
neuper@37906
|
641 |
[[from sml: </CALCTREE>
|
neuper@37906
|
642 |
[[from sml: @@@@@end@@@@@*)
|
neuper@37906
|
643 |
Iterator 1;
|
neuper@37906
|
644 |
(*[[from sml: > @@@@@begin@@@@@
|
neuper@37906
|
645 |
[[from sml: 1
|
neuper@37906
|
646 |
[[from sml: <ADDUSER>
|
neuper@37906
|
647 |
[[from sml: <CALCID> 1 </CALCID>
|
neuper@37906
|
648 |
[[from sml: <USERID> 1 </USERID>
|
neuper@37906
|
649 |
[[from sml: </ADDUSER>
|
neuper@37906
|
650 |
[[from sml: @@@@@end@@@@@*)
|
neuper@37906
|
651 |
moveActiveRoot 1;
|
neuper@37906
|
652 |
(*[[from sml: > @@@@@begin@@@@@
|
neuper@37906
|
653 |
[[from sml: 1
|
neuper@37906
|
654 |
[[from sml: <CALCITERATOR>
|
neuper@37906
|
655 |
[[from sml: <CALCID> 1 </CALCID>
|
neuper@37906
|
656 |
[[from sml: <POSITION>
|
neuper@37906
|
657 |
[[from sml: <INTLIST>
|
neuper@37906
|
658 |
[[from sml: </INTLIST>
|
neuper@37906
|
659 |
[[from sml: <POS> Pbl </POS>
|
neuper@37906
|
660 |
[[from sml: </POSITION>
|
neuper@37906
|
661 |
[[from sml: </CALCITERATOR>
|
neuper@37906
|
662 |
[[from sml: @@@@@end@@@@@*)
|
neuper@37906
|
663 |
getFormulaeFromTo 1 ([],Pbl) ([],Pbl) 0 false;
|
neuper@37906
|
664 |
(*[[from sml: > @@@@@begin@@@@@ STILL CORRECT
|
neuper@37906
|
665 |
[[from sml: 1
|
neuper@37906
|
666 |
[[from sml: <GETELEMENTSFROMTO>
|
neuper@37906
|
667 |
[[from sml: <CALCID> 1 </CALCID>
|
neuper@37906
|
668 |
[[from sml: <FORMHEADS>
|
neuper@37906
|
669 |
[[from sml: <CALCFORMULA>
|
neuper@37906
|
670 |
[[from sml: <POSITION>
|
neuper@37906
|
671 |
[[from sml: <INTLIST>
|
neuper@37906
|
672 |
[[from sml: </INTLIST>
|
neuper@37906
|
673 |
[[from sml: <POS> Pbl </POS>
|
neuper@37906
|
674 |
[[from sml: </POSITION>
|
neuper@37906
|
675 |
[[from sml: <FORMULA>
|
neuper@37906
|
676 |
[[from sml: <MATHML>
|
neuper@37906
|
677 |
[[from sml: <ISA> ________________________________________________ </ISA>
|
neuper@37906
|
678 |
[[from sml: </MATHML>
|
neuper@37906
|
679 |
[[from sml:
|
neuper@37906
|
680 |
[[from sml: </FORMULA>
|
neuper@37906
|
681 |
[[from sml: </CALCFORMULA>
|
neuper@37906
|
682 |
[[from sml: </FORMHEADS>
|
neuper@37906
|
683 |
[[from sml: </GETELEMENTSFROMTO>
|
neuper@37906
|
684 |
[[from sml: @@@@@end@@@@@*)
|
neuper@37906
|
685 |
refFormula 1 ([],Pbl);
|
neuper@37906
|
686 |
(*[[from sml: > @@@@@begin@@@@@ STILL CORRECT
|
neuper@37906
|
687 |
[[from sml: 1
|
neuper@37906
|
688 |
[[from sml: <REFFORMULA>
|
neuper@37906
|
689 |
[[from sml: <CALCID> 1 </CALCID>
|
neuper@37906
|
690 |
[[from sml: <CALCHEAD status = "incorrect">
|
neuper@37906
|
691 |
[[from sml: <POSITION>
|
neuper@37906
|
692 |
[[from sml: <INTLIST>
|
neuper@37906
|
693 |
[[from sml: </INTLIST>
|
neuper@37906
|
694 |
[[from sml: <POS> Pbl </POS>
|
neuper@37906
|
695 |
[[from sml: </POSITION>
|
neuper@37906
|
696 |
[[from sml: <HEAD>
|
neuper@37906
|
697 |
[[from sml: <MATHML>
|
neuper@37906
|
698 |
[[from sml: <ISA> Problem (e_domID, [e_pblID]) </ISA>
|
neuper@37906
|
699 |
[[from sml: </MATHML>
|
neuper@37906
|
700 |
[[from sml: </HEAD>
|
neuper@37906
|
701 |
[[from sml: <MODEL>
|
neuper@37906
|
702 |
[[from sml: <GIVEN> </GIVEN>
|
neuper@37906
|
703 |
[[from sml: <WHERE> </WHERE>
|
neuper@37906
|
704 |
[[from sml: <FIND> </FIND>
|
neuper@37906
|
705 |
[[from sml: <RELATE> </RELATE>
|
neuper@37906
|
706 |
[[from sml: </MODEL>
|
neuper@37906
|
707 |
[[from sml: <BELONGSTO> Pbl </BELONGSTO>
|
neuper@37906
|
708 |
[[from sml: <SPECIFICATION>
|
neuper@37906
|
709 |
[[from sml: <THEORYID> e_domID </THEORYID>
|
neuper@37906
|
710 |
[[from sml: <PROBLEMID>
|
neuper@37906
|
711 |
[[from sml: <STRINGLIST>
|
neuper@37906
|
712 |
[[from sml: <STRING> e_pblID </STRING>
|
neuper@37906
|
713 |
[[from sml: </STRINGLIST>
|
neuper@37906
|
714 |
[[from sml: </PROBLEMID>
|
neuper@37906
|
715 |
[[from sml: <METHODID>
|
neuper@37906
|
716 |
[[from sml: <STRINGLIST>
|
neuper@37906
|
717 |
[[from sml: <STRING> e_metID </STRING>
|
neuper@37906
|
718 |
[[from sml: </STRINGLIST>
|
neuper@37906
|
719 |
[[from sml: </METHODID>
|
neuper@37906
|
720 |
[[from sml: </SPECIFICATION>
|
neuper@37906
|
721 |
[[from sml: </CALCHEAD>
|
neuper@37906
|
722 |
[[from sml: </REFFORMULA>
|
neuper@37906
|
723 |
[[from sml: @@@@@end@@@@@*)
|
neuper@37906
|
724 |
moveActiveFormula 1 ([],Pbl);
|
neuper@37906
|
725 |
(*[[from sml: > @@@@@begin@@@@@
|
neuper@37906
|
726 |
[[from sml: 1
|
neuper@37906
|
727 |
[[from sml: <CALCITERATOR>
|
neuper@37906
|
728 |
[[from sml: <CALCID> 1 </CALCID>
|
neuper@37906
|
729 |
[[from sml: <POSITION>
|
neuper@37906
|
730 |
[[from sml: <INTLIST>
|
neuper@37906
|
731 |
[[from sml: </INTLIST>
|
neuper@37906
|
732 |
[[from sml: <POS> Pbl </POS>
|
neuper@37906
|
733 |
[[from sml: </POSITION>
|
neuper@37906
|
734 |
[[from sml: </CALCITERATOR>
|
neuper@37906
|
735 |
[[from sml: @@@@@end@@@@@*)
|
neuper@37906
|
736 |
replaceFormula 1 "Simplify (1+2)";
|
neuper@37906
|
737 |
(*[[from sml: > @@@@@begin@@@@@
|
neuper@37906
|
738 |
[[from sml: 1
|
neuper@37906
|
739 |
[[from sml: <REPLACEFORMULA>
|
neuper@37906
|
740 |
[[from sml: <CALCID> 1 </CALCID>
|
neuper@37906
|
741 |
[[from sml: <CALCCHANGED>
|
neuper@37906
|
742 |
[[from sml: <UNCHANGED>
|
neuper@37906
|
743 |
[[from sml: <INTLIST>
|
neuper@37906
|
744 |
[[from sml: </INTLIST>
|
neuper@37906
|
745 |
[[from sml: <POS> Pbl </POS>
|
neuper@37906
|
746 |
[[from sml: </UNCHANGED>
|
neuper@37906
|
747 |
[[from sml: <DELETED>
|
neuper@37906
|
748 |
[[from sml: <INTLIST>
|
neuper@37906
|
749 |
[[from sml: </INTLIST>
|
neuper@37906
|
750 |
[[from sml: <POS> Pbl </POS>
|
neuper@37906
|
751 |
[[from sml: </DELETED>
|
neuper@37906
|
752 |
[[from sml: <GENERATED>
|
neuper@37906
|
753 |
[[from sml: <INTLIST>
|
neuper@37906
|
754 |
[[from sml: </INTLIST>
|
neuper@37906
|
755 |
[[from sml: <POS> Met </POS> DIFFERENCE: Pbl
|
neuper@37906
|
756 |
[[from sml: </GENERATED>
|
neuper@37906
|
757 |
[[from sml: </CALCCHANGED>
|
neuper@37906
|
758 |
[[from sml: </REPLACEFORMULA>
|
neuper@37906
|
759 |
[[from sml: @@@@@end@@@@@*)
|
neuper@37906
|
760 |
getFormulaeFromTo 1 ([],Pbl) ([],Pbl) 0 false(* DIFFERENCE: Pbl*);
|
neuper@37906
|
761 |
(*@@@@@begin@@@@@
|
neuper@37906
|
762 |
1
|
neuper@37906
|
763 |
<GETELEMENTSFROMTO>
|
neuper@37906
|
764 |
<CALCID> 1 </CALCID>
|
neuper@37906
|
765 |
<FORMHEADS>
|
neuper@37906
|
766 |
<CALCFORMULA>
|
neuper@37906
|
767 |
<POSITION>
|
neuper@37906
|
768 |
<INTLIST>
|
neuper@37906
|
769 |
</INTLIST>
|
neuper@37906
|
770 |
<POS> Pbl </POS>
|
neuper@37906
|
771 |
</POSITION>
|
neuper@37906
|
772 |
<FORMULA>
|
neuper@37906
|
773 |
<MATHML>
|
neuper@37906
|
774 |
<ISA> Simplify (1 + 2) </ISA> WORKS !!!!!
|
neuper@37906
|
775 |
</MATHML>
|
neuper@37906
|
776 |
</FORMULA>
|
neuper@37906
|
777 |
</CALCFORMULA>
|
neuper@37906
|
778 |
</FORMHEADS>
|
neuper@37906
|
779 |
</GETELEMENTSFROMTO>
|
neuper@37906
|
780 |
@@@@@end@@@@@*)
|
neuper@37906
|
781 |
getFormulaeFromTo 1 ([],Pbl) ([],Met) 0 false;
|
neuper@37906
|
782 |
(*[[from sml: > @@@@@begin@@@@@
|
neuper@37906
|
783 |
[[from sml: 1
|
neuper@37906
|
784 |
[[from sml: <SYSERROR>
|
neuper@37906
|
785 |
[[from sml: <CALCID> 1 </CALCID>
|
neuper@37906
|
786 |
[[from sml: <ERROR> error in getFormulaeFromTo </ERROR>
|
neuper@37906
|
787 |
[[from sml: </SYSERROR>
|
neuper@37906
|
788 |
[[from sml: @@@@@end@@@@@*)
|
neuper@37906
|
789 |
(*step into getFormulaeFromTo --- bug corrected...*)
|
neuper@42423
|
790 |
|
neuper@42423
|
791 |
"--------- build fun check_err_patt ------------------------------";
|
neuper@42423
|
792 |
"--------- build fun check_err_patt ------------------------------";
|
neuper@42423
|
793 |
"--------- build fun check_err_patt ------------------------------";
|
neuper@42426
|
794 |
val subst = [(str2term "bdv", str2term "x")]: subst;
|
neuper@42423
|
795 |
val rls = norm_Rational
|
neuper@42423
|
796 |
val pat = parse_patt @{theory} "(?a + ?b)/(?b + ?c) = ?a / ?c";
|
neuper@42423
|
797 |
val (res, inf) = (str2term "(2 + 3)/(3 + 4)", str2term "2 / 4");
|
neuper@42423
|
798 |
val (res, inf) = (str2term "(2 + 3)/(3 + 4)", str2term "1 / 2");
|
neuper@42423
|
799 |
|
neuper@42426
|
800 |
val (res', _, _, rewritten) = (*rewritten: the lhs of the pattern matches in res*)
|
neuper@42423
|
801 |
rew_sub thy 1 [] e_rew_ord e_rls false [] (Trueprop $ pat) res;
|
neuper@42423
|
802 |
if rewritten then NONE else SOME "e_errpatID";
|
neuper@42423
|
803 |
|
neuper@42423
|
804 |
val norm_res = case rewrite_set_ (Isac()) false rls res' of
|
neuper@42423
|
805 |
NONE => res'
|
neuper@42423
|
806 |
| SOME (norm_res, _) => norm_res
|
neuper@42423
|
807 |
|
neuper@42423
|
808 |
val norm_inf = case rewrite_set_ (Isac()) false rls inf of
|
neuper@42423
|
809 |
NONE => inf
|
neuper@42423
|
810 |
| SOME (norm_inf, _) => norm_inf;
|
neuper@42423
|
811 |
|
neuper@42423
|
812 |
res' = inf;
|
neuper@42423
|
813 |
norm_res = norm_inf;
|
neuper@42423
|
814 |
|
neuper@42423
|
815 |
val pat = parse_patt @{theory} "(?a + ?b)/?a = ?b";
|
neuper@42423
|
816 |
val (res, inf) = (str2term "(2 + 3)/2", str2term "3");
|
neuper@42426
|
817 |
if check_err_patt (res, inf) subst ("errpatID", pat) rls = SOME "errpatID"
|
neuper@42423
|
818 |
then () else error "error patt example1 changed";
|
neuper@42423
|
819 |
|
neuper@42423
|
820 |
val pat = parse_patt @{theory} "(?a + ?b)/(?a + ?c) = ?b / ?c";
|
neuper@42423
|
821 |
val (res, inf) = (str2term "(2 + 3)/(2 + 4)", str2term "3 / 4");
|
neuper@42426
|
822 |
if check_err_patt (res, inf) subst ("errpatID", pat) rls = SOME "errpatID"
|
neuper@42423
|
823 |
then () else error "error patt example2 changed";
|
neuper@42423
|
824 |
|
neuper@42423
|
825 |
val pat = parse_patt @{theory} "(?a + ?b)/(?b + ?c) = ?a / ?c";
|
neuper@42423
|
826 |
val (res, inf) = (str2term "(2 + 3)/(3 + 4)", str2term "2 / 4");
|
neuper@42426
|
827 |
if check_err_patt (res, inf) subst ("errpatID", pat) rls = SOME "errpatID"
|
neuper@42423
|
828 |
then () else error "error patt example3 changed";
|
neuper@42423
|
829 |
|
neuper@42423
|
830 |
val inf = str2term "1 / 2";
|
neuper@42426
|
831 |
if check_err_patt (res, inf) subst ("errpatID", pat) rls = SOME "errpatID"
|
neuper@42423
|
832 |
then () else error "error patt example3 changed";
|
neuper@42423
|
833 |
|
neuper@42426
|
834 |
"--------- build fun check_err_patt ?bdv -------------------------";
|
neuper@42426
|
835 |
"--------- build fun check_err_patt ?bdv -------------------------";
|
neuper@42426
|
836 |
"--------- build fun check_err_patt ?bdv -------------------------";
|
neuper@42426
|
837 |
val subst = [(str2term "bdv", str2term "x")]: subst;
|
neuper@42426
|
838 |
val t = str2term "d_d x (x ^^^ 2 + sin (x ^^^ 4))";
|
neuper@42426
|
839 |
val SOME (t, _) = rewrite_set_inst_ thy false subst norm_diff t;
|
neuper@42426
|
840 |
if term2str t = "2 * x + cos (x ^^^ 4) * 4 * x ^^^ 3" then ()
|
neuper@42426
|
841 |
else error "build fun check_err_patt ?bdv changed 1";
|
neuper@42423
|
842 |
|
neuper@42426
|
843 |
val rls = norm_diff
|
neuper@42426
|
844 |
val pat = parse_patt @{theory} "d_d ?bdv (sin ?u) = cos (d_d ?bdv ?u)";
|
neuper@42426
|
845 |
val (res, inf) = (str2term "2 * x + d_d x (sin (x ^^^ 4))", str2term "2 * x + cos (4 * x ^^^ 3)");
|
neuper@42426
|
846 |
|
neuper@42426
|
847 |
val (res', _, _, rewritten) = (*rewritten: the lhs of the pattern matches in res*)
|
neuper@42426
|
848 |
rew_sub thy 1 subst e_rew_ord e_rls false [] (Trueprop $ pat) res;
|
neuper@42426
|
849 |
if term2str res' = "2 * x + cos (d_d x (x ^^^ 4))" andalso rewritten then ()
|
neuper@42426
|
850 |
else error "build fun check_err_patt ?bdv changed 2";
|
neuper@42426
|
851 |
|
neuper@42426
|
852 |
val norm_res = case rewrite_set_inst_ (Isac()) false subst rls res' of
|
neuper@42426
|
853 |
NONE => res'
|
neuper@42426
|
854 |
| SOME (norm_res, _) => norm_res;
|
neuper@42426
|
855 |
if term2str norm_res = "2 * x + cos (4 * x ^^^ 3)" then ()
|
neuper@42426
|
856 |
else error "build fun check_err_patt ?bdv changed 3";
|
neuper@42426
|
857 |
|
neuper@42426
|
858 |
val norm_inf = case rewrite_set_inst_ (Isac()) false subst rls inf of
|
neuper@42426
|
859 |
NONE => inf
|
neuper@42426
|
860 |
| SOME (norm_inf, _) => norm_inf;
|
neuper@42426
|
861 |
if term2str norm_inf = "2 * x + cos (4 * x ^^^ 3)" then ()
|
neuper@42426
|
862 |
else error "build fun check_err_patt ?bdv changed 4";
|
neuper@42426
|
863 |
|
neuper@42426
|
864 |
res' = inf;
|
neuper@42426
|
865 |
if norm_res = norm_inf then ()
|
neuper@42426
|
866 |
else error "build fun check_err_patt ?bdv changed 5";
|
neuper@42426
|
867 |
|
neuper@42426
|
868 |
if check_err_patt (res, inf) (subst: subst) ("errpatID": errpatID, pat) rls = SOME "errpatID"
|
neuper@42426
|
869 |
then () else error "error patt example1 changed";
|
neuper@42426
|
870 |
|
neuper@42428
|
871 |
"--------- build fun check_error_patterns ------------------------";
|
neuper@42428
|
872 |
"--------- build fun check_error_patterns ------------------------";
|
neuper@42428
|
873 |
"--------- build fun check_error_patterns ------------------------";
|
neuper@42428
|
874 |
val (res, inf) =
|
neuper@42428
|
875 |
(str2term "d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))",
|
neuper@42428
|
876 |
str2term "d_d x (x ^^^ 2) + cos (4 * x ^^^ 3)");
|
neuper@42428
|
877 |
val {errpats, nrls = rls, scr = Script prog, ...} = get_met ["diff", "differentiate_on_R"]
|
neuper@42426
|
878 |
|
neuper@42428
|
879 |
val env = [(str2term "v_v", str2term "x")];
|
neuper@42428
|
880 |
val errpats =
|
neuper@42428
|
881 |
[e_errpat, (*generalised for testing*)
|
neuper@42428
|
882 |
("chain-rule-diff-both",
|
neuper@42428
|
883 |
[parse_patt @{theory} "d_d ?bdv (sin ?u) = cos (d_d ?bdv ?u)",
|
neuper@42428
|
884 |
parse_patt @{theory} "d_d ?bdv (cos ?u) = - sin (d_d ?bdv ?u)",
|
neuper@42428
|
885 |
parse_patt @{theory} "d_d ?bdv (?u ^^^ ?n) = ?n * ?u ^^^ (?n - 1)",
|
neuper@42428
|
886 |
parse_patt @{theory} "d_d ?bdv (LogExp.ln ?u) = 1 / ?u",
|
neuper@42428
|
887 |
parse_patt @{theory} "d_d ?bdv (LogExp.ln ?u) = 1 / d_d ?bdv ?u"],
|
neuper@42428
|
888 |
[@{thm diff_sin_chain}, @{thm diff_cos_chain}, @{thm diff_pow_chain},
|
neuper@42428
|
889 |
@{thm diff_ln_chain}, @{thm diff_exp_chain}])]: errpat list;
|
neuper@42428
|
890 |
|
neuper@42428
|
891 |
case check_error_patterns (res, inf) (prog, env) (errpats, rls) of SOME _ => ()
|
neuper@42428
|
892 |
| NONE => error "check_error_patterns broken";
|
neuper@42428
|
893 |
|
neuper@42428
|
894 |
|
neuper@42428
|
895 |
"--------- embed fun check_error_patterns ------------------------";
|
neuper@42428
|
896 |
"--------- embed fun check_error_patterns ------------------------";
|
neuper@42428
|
897 |
"--------- embed fun check_error_patterns ------------------------";
|
neuper@42428
|
898 |
states:=[];
|
neuper@42428
|
899 |
CalcTree
|
neuper@42428
|
900 |
[(["functionTerm (x ^ 2 + sin (x ^ 4))", "differentiateFor x", "derivative f_f'"],
|
neuper@42428
|
901 |
("Isac", ["derivative_of","function"], ["diff","differentiate_on_R"]))];
|
neuper@42428
|
902 |
Iterator 1;
|
neuper@42428
|
903 |
moveActiveRoot 1;
|
neuper@42428
|
904 |
autoCalculate 1 CompleteCalcHead;
|
neuper@42428
|
905 |
autoCalculate 1 (Step 1);
|
neuper@42428
|
906 |
autoCalculate 1 (Step 1);(*([1], Res), d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))*)
|
neuper@42428
|
907 |
(*autoCalculate 1 (Step 1);([2], Res), d_d x (x ^^^ 2) + cos (x ^^^ 4) * d_d x (x ^^^ 4)*)
|
neuper@42428
|
908 |
|
neuper@42428
|
909 |
"~~~~~ fun appendFormula, args:"; val (cI, (ifo:cterm')) = (1, "d_d x (x ^ 2) + cos (4 * x ^ 3)");
|
neuper@42428
|
910 |
val cs = get_calc cI
|
neuper@42428
|
911 |
val pos as (_,p_) = get_pos cI 1; (*pos = ([1], Res)*)
|
neuper@42428
|
912 |
val cs' =
|
neuper@42428
|
913 |
case step pos cs of
|
neuper@42428
|
914 |
("ok", cs') => cs';
|
neuper@42428
|
915 |
|
neuper@42428
|
916 |
val (_, _, (pt, ([2], Res))) = cs';
|
neuper@42428
|
917 |
(*show_pt pt;
|
neuper@42428
|
918 |
[(([], Frm), Diff (x ^^^ 2 + sin (x ^^^ 4), x)),
|
neuper@42428
|
919 |
(([1], Frm), d_d x (x ^^^ 2 + sin (x ^^^ 4))),
|
neuper@42428
|
920 |
(([1], Res), d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))), <<=== input follos: "...+ cos(4.x^3)"
|
neuper@42428
|
921 |
(([2], Res), d_d x (x ^^^ 2) + cos (x ^^^ 4) * d_d x (x ^^^ 4))] *)
|
neuper@42428
|
922 |
|
neuper@42428
|
923 |
"~~~~~ fun inform, args:"; val ((cs as (_, _, ptp as (pt, pos as (p, p_))): calcstate'), istr) =
|
neuper@42428
|
924 |
(cs', (encode ifo));
|
neuper@42428
|
925 |
val SOME f_in = parse (assoc_thy "Isac") istr
|
neuper@42428
|
926 |
val f_in = term_of f_in
|
neuper@42428
|
927 |
val pos_pred = lev_back' pos
|
neuper@42428
|
928 |
(* f_pred ---"step pos cs"---> f_succ in appendFormula
|
neuper@42428
|
929 |
TODO.WN120517: one starting point for redesign of pos' *)
|
neuper@42432
|
930 |
val (f_pred, f_succ) = (get_curr_formula (pt, pos_pred), get_curr_formula (pt, pos));
|
neuper@42428
|
931 |
|
neuper@42428
|
932 |
term2str f_pred = "d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))";
|
neuper@42428
|
933 |
term2str f_succ = "d_d x (x ^^^ 2) + cos (x ^^^ 4) * d_d x (x ^^^ 4)";
|
neuper@42428
|
934 |
|
neuper@42428
|
935 |
f_succ = f_in; (* = false*)
|
neuper@42428
|
936 |
cas_input f_in; (* = NONE*)
|
neuper@42428
|
937 |
val msg_calcstate' = compare_step ([], [], (pt, pos_pred)) f_in
|
neuper@42428
|
938 |
val ("no derivation found", calcstate') = msg_calcstate';
|
neuper@42428
|
939 |
val pp = par_pblobj pt p
|
neuper@42428
|
940 |
val {errpats, nrls, scr = Script prog, ...} = get_met (get_obj g_metID pt pp)
|
neuper@42428
|
941 |
val ScrState (env, _, _, _, _, _) = get_istate pt pos;
|
neuper@42428
|
942 |
case check_error_patterns (f_pred, f_in) (prog, env) (errpats, nrls) of
|
neuper@42428
|
943 |
SOME errpatID => ("error pattern #" ^ errpatID ^ "#", calcstate')
|
neuper@42428
|
944 |
| NONE => msg_calcstate';
|
neuper@42428
|
945 |
|
neuper@42428
|
946 |
"~~~~~ from inform return val:"; val () = ();
|
neuper@42428
|
947 |
case check_error_patterns (f_pred, f_in) (prog, env) (errpats, nrls) of
|
neuper@42428
|
948 |
SOME errpatID => ()
|
neuper@42428
|
949 |
| NONE => error "check_error_patterns broken";
|
neuper@42428
|
950 |
|
neuper@42428
|
951 |
"--- final check:";
|
neuper@42428
|
952 |
case inform cs' (encode ifo) of
|
neuper@42428
|
953 |
("error pattern #chain-rule-diff-both#", calcstate') => ()
|
neuper@42428
|
954 |
| _ => error "inform with (positive) check_error_patterns broken"
|
neuper@42428
|
955 |
|
neuper@42430
|
956 |
"--------- embed fun find_fillpatterns ---------------------------";
|
neuper@42430
|
957 |
"--------- embed fun find_fillpatterns ---------------------------";
|
neuper@42430
|
958 |
"--------- embed fun find_fillpatterns ---------------------------";
|
neuper@42430
|
959 |
states:=[];
|
neuper@42430
|
960 |
CalcTree
|
neuper@42430
|
961 |
[(["functionTerm (x ^ 2 + sin (x ^ 4))", "differentiateFor x", "derivative f_f'"],
|
neuper@42430
|
962 |
("Isac", ["derivative_of","function"], ["diff","differentiate_on_R"]))];
|
neuper@42430
|
963 |
Iterator 1;
|
neuper@42430
|
964 |
moveActiveRoot 1;
|
neuper@42430
|
965 |
autoCalculate 1 CompleteCalcHead;
|
neuper@42430
|
966 |
autoCalculate 1 (Step 1);
|
neuper@42430
|
967 |
autoCalculate 1 (Step 1);(*([1], Res), d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))*)
|
neuper@42430
|
968 |
appendFormula 1 "d_d x (x ^ 2) + cos (4 * x ^ 3)";
|
neuper@42430
|
969 |
(*<CALCMESSAGE> error pattern #chain-rule-diff-both# </CALCMESSAGE>*)
|
neuper@42432
|
970 |
(*or
|
neuper@42432
|
971 |
<CALCMESSAGE> no derivation found </CALCMESSAGE>*)
|
neuper@42430
|
972 |
|
neuper@42433
|
973 |
"~~~~~ fun findFillpatterns, args:"; val (cI, errpatID) = (1, "chain-rule-diff-both");
|
neuper@42430
|
974 |
val ((pt, _), _) = get_calc cI
|
neuper@42430
|
975 |
val pos = get_pos cI 1;
|
neuper@42432
|
976 |
"~~~~~ fun find_fillpatterns, args:"; val ((pt, pos as (p, _)), errpatID) = ((pt, pos), errpatID);
|
neuper@42432
|
977 |
val f_curr = get_curr_formula (pt, pos); (* = "d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))"*)
|
neuper@42430
|
978 |
val pp = par_pblobj pt p
|
neuper@42430
|
979 |
val {errpats, scr = Script prog, ...} = get_met (get_obj g_metID pt pp)
|
neuper@42430
|
980 |
val ScrState (env, _, _, _, _, _) = get_istate pt pos
|
neuper@42430
|
981 |
val subst = get_bdv_subst prog env
|
neuper@42430
|
982 |
val errpatthms = errpats
|
neuper@42430
|
983 |
|> filter ((curry op = errpatID) o (#1: errpat -> errpatID))
|
neuper@42430
|
984 |
|> map (#3: errpat -> thm list)
|
neuper@42430
|
985 |
|> flat;
|
neuper@42430
|
986 |
|
neuper@42430
|
987 |
case map (get_fillpats subst f_curr errpatID) errpatthms |> flat of
|
neuper@42433
|
988 |
("fill-d_d-arg", tm, thm, subs_opt) :: _ => if term2str tm =
|
neuper@42432
|
989 |
"d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4)) =\nd_d x (x ^^^ 2) + cos (x ^^^ 4) * d_d x ?_dummy_1"
|
neuper@42432
|
990 |
then () else error "find_fillpatterns changed 1a"
|
neuper@42432
|
991 |
| _ => error "find_fillpatterns changed 1b"
|
neuper@42430
|
992 |
|
neuper@42430
|
993 |
"~~~~~ fun get_fillpats, args:"; val (subst, form, errpatID, thm) =
|
neuper@42432
|
994 |
(subst, f_curr, errpatID, hd (*simulate beginning of "map"*) errpatthms);
|
neuper@42430
|
995 |
val thmDeriv = Thm.get_name_hint thm
|
neuper@42430
|
996 |
val (part, thyID) = thy_containing_thm thmDeriv
|
neuper@42430
|
997 |
val theID = [part, thyID, "Theorems", thmID_of_derivation_name thmDeriv]
|
neuper@42430
|
998 |
val Hthm {fillpats, ...} = get_the theID
|
neuper@42433
|
999 |
val some = map (get_fillform subst (thm, form) errpatID) fillpats;
|
neuper@42430
|
1000 |
|
neuper@42430
|
1001 |
case some |> filter is_some |> map the of
|
neuper@42433
|
1002 |
("fill-d_d-arg", tm, thm, subsopt) :: _ => if term2str tm =
|
neuper@42432
|
1003 |
"d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4)) =\nd_d x (x ^^^ 2) + cos (x ^^^ 4) * d_d x ?_dummy_1"
|
neuper@42432
|
1004 |
then () else error "find_fillpatterns changed 2a"
|
neuper@42432
|
1005 |
| _ => error "find_fillpatterns changed 2b"
|
neuper@42430
|
1006 |
|
neuper@42433
|
1007 |
"~~~~~ fun get_fillform, args:";
|
neuper@42433
|
1008 |
val ((subs_opt, subst), (thm, form), errpatID, (fillpatID, pat, erpaID)) =
|
neuper@42433
|
1009 |
(subst, (thm, form), errpatID, hd (*simulate beginning of "map"*) fillpats);
|
neuper@42433
|
1010 |
val (form', _, _, rewritten) =
|
neuper@42432
|
1011 |
rew_sub (Isac()) 1 subst e_rew_ord e_rls false [] (Trueprop $ pat) form;
|
neuper@42432
|
1012 |
|
neuper@42432
|
1013 |
if term2str form' = "d_d x (x ^^^ 2) + cos (x ^^^ 4) * d_d x ?_dummy_1" then ()
|
neuper@42432
|
1014 |
else error "find_fillpatterns changed 3";
|
neuper@42432
|
1015 |
|
neuper@42433
|
1016 |
"~~~~~ to findFillpatterns return val:"; val (fillpats) =
|
neuper@42433
|
1017 |
(map (get_fillpats (subs_opt, subst) f_curr errpatID) errpatthms |> flat) (*only from "hd errpatthms"*);
|
neuper@42432
|
1018 |
|
neuper@42450
|
1019 |
"vvv--- dropped this code WN120730";
|
neuper@42433
|
1020 |
val msg = "fill patterns " ^
|
neuper@42433
|
1021 |
((map ((apsnd term2str) o quad2pair) fillpats) |> map pair2str_ |> strs2str_);
|
neuper@42450
|
1022 |
msg =
|
neuper@42432
|
1023 |
"fill patterns #fill-d_d-arg#d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))" ^
|
neuper@42432
|
1024 |
" =\nd_d x (x ^^^ 2) + cos (x ^^^ 4) * d_d x ?_dummy_1" ^
|
neuper@42432
|
1025 |
"#fill-both-args#d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))" ^
|
neuper@42432
|
1026 |
" =\nd_d x (x ^^^ 2) + cos ?_dummy_2 * d_d x ?_dummy_3" ^
|
neuper@42432
|
1027 |
"#fill-d_d#d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))" ^
|
neuper@42432
|
1028 |
" =\nd_d x (x ^^^ 2) + cos (x ^^^ 4) * ?_dummy_1 x (x ^^^ 4)" ^
|
neuper@42432
|
1029 |
"#fill-inner-deriv#d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))" ^
|
neuper@42432
|
1030 |
" =\nd_d x (x ^^^ 2) + cos (x ^^^ 4) * ?_dummy_1" ^
|
neuper@42450
|
1031 |
"#fill-all#d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4)) = d_d x (x ^^^ 2) + ?_dummy_1#";
|
neuper@42450
|
1032 |
"^^^--- dropped this code WN120730";
|
neuper@42450
|
1033 |
|
neuper@42450
|
1034 |
if (map #1 fillpats) =
|
neuper@42450
|
1035 |
["fill-d_d-arg", "fill-both-args", "fill-d_d", "fill-inner-deriv", "fill-all"]
|
neuper@42450
|
1036 |
then () else error "find_fillpatterns changed 4b";
|
neuper@42450
|
1037 |
|
neuper@42432
|
1038 |
|
neuper@42437
|
1039 |
"--------- build fun is_exactly_equal, inputFillFormula ----------";
|
neuper@42437
|
1040 |
"--------- build fun is_exactly_equal, inputFillFormula ----------";
|
neuper@42437
|
1041 |
"--------- build fun is_exactly_equal, inputFillFormula ----------";
|
neuper@42437
|
1042 |
states := [];
|
neuper@42437
|
1043 |
CalcTree
|
neuper@42437
|
1044 |
[(["functionTerm (x ^ 2 + sin (x ^ 4))", "differentiateFor x", "derivative f_f'"],
|
neuper@42437
|
1045 |
("Isac", ["derivative_of","function"], ["diff","differentiate_on_R"]))];
|
neuper@42437
|
1046 |
Iterator 1;
|
neuper@42437
|
1047 |
moveActiveRoot 1;
|
neuper@42437
|
1048 |
autoCalculate 1 CompleteCalcHead;
|
neuper@42437
|
1049 |
autoCalculate 1 (Step 1);
|
neuper@42437
|
1050 |
autoCalculate 1 (Step 1);(*([1], Res), d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))*)
|
neuper@42437
|
1051 |
appendFormula 1 "d_d x (x ^ 2) + cos (4 * x ^ 3)"; (*<<<<<<<=========================*)
|
neuper@42437
|
1052 |
(* the check for errpat is maximally liberal (whole term modulo "nrls" from "type met"),
|
neuper@42437
|
1053 |
would recognize "cos (4 * x ^ (4 - 1)) + 2 * x" as well.
|
neuper@42437
|
1054 |
results in <CALCMESSAGE> error pattern #chain-rule-diff-both# </CALCMESSAGE>
|
neuper@42437
|
1055 |
instead of <CALCMESSAGE> no derivation found </CALCMESSAGE> *)
|
neuper@42437
|
1056 |
val ((pt,pos), _) = get_calc 1;
|
neuper@42437
|
1057 |
val p = get_pos 1 1;
|
neuper@42437
|
1058 |
val (Form f, _, asms) = pt_extract (pt, p);
|
neuper@42437
|
1059 |
|
neuper@42437
|
1060 |
if p = ([1], Res) andalso term2str f = "d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))" andalso
|
neuper@42437
|
1061 |
get_obj g_tac pt (fst p) = Rewrite_Inst (["(bdv, x)"], ("diff_sum", "Diff.diff_sum"(*?!?*)))
|
neuper@42437
|
1062 |
then () else error "embed fun get_fillform changed 1";
|
neuper@42437
|
1063 |
|
neuper@42437
|
1064 |
findFillpatterns 1 "chain-rule-diff-both"; (*<<<<<<<=================================*)
|
neuper@42437
|
1065 |
(*<CALCMESSAGE> fill patterns #fill-d_d-arg#d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4)) =
|
neuper@42437
|
1066 |
d_d x (x ^^^ 2) + cos (x ^^^ 4) * d_d x ?_dummy_1#fill-both-args#...#...#... *)
|
neuper@42437
|
1067 |
val ((pt,pos),_) = get_calc 1;
|
neuper@42437
|
1068 |
val p = get_pos 1 1;
|
neuper@42437
|
1069 |
|
neuper@42437
|
1070 |
val (Form f, _, asms) = pt_extract (pt, p);
|
neuper@42437
|
1071 |
if p = ([1], Res) andalso term2str f = "d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))" andalso
|
neuper@42437
|
1072 |
get_obj g_tac pt (fst p) = Rewrite_Inst (["(bdv, x)"], ("diff_sum", "Diff.diff_sum"(*?!?*)))
|
neuper@42437
|
1073 |
then ()
|
neuper@42437
|
1074 |
else error "embed fun get_fillform changed 2";
|
neuper@42437
|
1075 |
|
neuper@42437
|
1076 |
requestFillformula 1 ("chain-rule-diff-both", "fill-both-args");(*<<<<<<<============*)
|
neuper@42437
|
1077 |
(*<AUTOCALC> ([1], Res) ([2], Res) ([2], Res) </AUTOCALC>*)
|
neuper@42437
|
1078 |
val ((pt,pos),_) = get_calc 1;
|
neuper@42437
|
1079 |
val p = get_pos 1 1;
|
neuper@42437
|
1080 |
val (Form f, _, asms) = pt_extract (pt, p);
|
neuper@42437
|
1081 |
if p = ([1], Res) andalso existpt [2] pt andalso
|
neuper@42437
|
1082 |
term2str f = "d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))" andalso
|
neuper@42437
|
1083 |
get_obj g_tac pt (fst p) = Rewrite_Inst (["(bdv, x)"], ("diff_sum", "Diff.diff_sum"))
|
neuper@42437
|
1084 |
then () else error "embed fun get_fillform changed 3";
|
neuper@42437
|
1085 |
|
neuper@42437
|
1086 |
(* input a formula which exactly fills the gaps in a "fillformula"
|
neuper@42437
|
1087 |
presented to the learner immediately before by "requestFillformula (errpatID, fillpatID)":
|
neuper@42437
|
1088 |
errpatID: lhs of the respective thm = lhs of fillformula with fillpatID.
|
neuper@42437
|
1089 |
the respective thm is in the ctree ................
|
neuper@42437
|
1090 |
*)
|
neuper@42437
|
1091 |
"~~~~~ fun inputFillFormula, args:"; val (cI, ifo) =
|
neuper@42437
|
1092 |
(1, "d_d x (x ^^^ 2) + cos (x ^^^ 4) * d_d x (x ^^^ 4)");
|
neuper@42437
|
1093 |
val ((pt, _), _) = get_calc cI
|
neuper@42437
|
1094 |
val pos = get_pos cI 1;
|
neuper@42437
|
1095 |
|
neuper@42437
|
1096 |
"~~~~~ fun is_exactly_equal, args:"; val ((pt, pos as (p, p_)), istr) = ((pt, pos), ifo);
|
neuper@42437
|
1097 |
val SOME ifo = parseNEW (assoc_thy "Isac" |> thy2ctxt) istr
|
neuper@42437
|
1098 |
val p' = lev_on p;
|
neuper@42437
|
1099 |
val tac = get_obj g_tac pt p';
|
neuper@42437
|
1100 |
if tac = Rewrite_Inst (["(bdv, x)"], ("diff_sin_chain", "")) then ()
|
neuper@42437
|
1101 |
else error "inputFillFormula changed 10";
|
neuper@42437
|
1102 |
val Appl rew = applicable_in pos pt tac;
|
neuper@42437
|
1103 |
val Rewrite_Inst' (_, _, _, _, _, _, _, (res, _)) = rew;
|
neuper@42437
|
1104 |
|
neuper@42437
|
1105 |
"~~~~~ to inputFillFormula return val:"; val ("ok", tac) = ("ok", tac);
|
neuper@42437
|
1106 |
val ("ok", (_, c, ptp as (_,p'))) = locatetac tac (pt, pos);
|
neuper@42437
|
1107 |
upd_calc cI (ptp, []);
|
neuper@42437
|
1108 |
upd_ipos cI 1 p';
|
neuper@42437
|
1109 |
autocalculateOK2xml cI pos (if null c then p' else last_elem c) p';
|
neuper@42437
|
1110 |
|
neuper@42437
|
1111 |
"~~~~~ final check:";
|
neuper@42437
|
1112 |
val ((pt, _),_) = get_calc 1;
|
neuper@42437
|
1113 |
val p = get_pos 1 1;
|
neuper@42437
|
1114 |
val (Form f, _, asms) = pt_extract (pt, p);
|
neuper@42437
|
1115 |
if p = ([2], Res) andalso
|
neuper@42437
|
1116 |
term2str f = "d_d x (x ^^^ 2) + cos (x ^^^ 4) * d_d x (x ^^^ 4)" andalso
|
neuper@42437
|
1117 |
get_obj g_tac pt (fst p) = Rewrite_Inst (["(bdv, x)"], ("diff_sin_chain", ""))
|
neuper@42437
|
1118 |
then () else error "inputFillFormula changed 11";
|
neuper@42437
|
1119 |
|