neuper@37906
|
1 |
(* tests on inform.sml
|
neuper@37906
|
2 |
author: Walther Neuper
|
neuper@37906
|
3 |
060225,
|
neuper@37906
|
4 |
(c) due to copyright terms
|
neuper@37906
|
5 |
|
neuper@37906
|
6 |
use"../smltest/ME/inform.sml";
|
neuper@37906
|
7 |
use"inform.sml";
|
neuper@37906
|
8 |
*)
|
neuper@37906
|
9 |
|
neuper@37906
|
10 |
"-----------------------------------------------------------------";
|
neuper@37906
|
11 |
"table of contents -----------------------------------------------";
|
neuper@37906
|
12 |
"-----------------------------------------------------------------";
|
neuper@37906
|
13 |
"appendForm with miniscript with mini-subpbl:";
|
neuper@37906
|
14 |
"--------- appendFormula: on Res + equ_nrls ----------------------";
|
neuper@37906
|
15 |
"--------- appendFormula: on Frm + equ_nrls ----------------------";
|
neuper@37906
|
16 |
"--------- appendFormula: on Res + NO deriv ----------------------";
|
neuper@37906
|
17 |
"--------- appendFormula: on Res + late deriv --------------------";
|
neuper@37906
|
18 |
"--------- appendFormula: on Res + late deriv [x = 3 + -2]---///--";
|
neuper@37906
|
19 |
"replaceForm with miniscript with mini-subpbl:";
|
neuper@37906
|
20 |
"--------- replaceFormula: on Res + = ----------------------------";
|
neuper@37906
|
21 |
"--------- replaceFormula: on Res + = 1st Nd ---------------------";
|
neuper@37906
|
22 |
"--------- replaceFormula: on Frm + = 1st Nd ---------------------";
|
neuper@37906
|
23 |
"--------- replaceFormula: cut calculation -----------------------";
|
neuper@37906
|
24 |
"--------- replaceFormula: cut calculation -----------------------";
|
neuper@37906
|
25 |
(* 040307 copied from informtest.sml ... old versions
|
neuper@37906
|
26 |
"--------- maximum-example, UC: Modeling / modifyCalcHead --------";*)
|
neuper@37906
|
27 |
"--------- syntax error ------------------------------------------";
|
neuper@37906
|
28 |
"CAS-command:";
|
neuper@37906
|
29 |
"--------- CAS-command on ([],Pbl) -------------------------------";
|
neuper@37906
|
30 |
"--------- CAS-command on ([],Pbl) FE-interface ------------------";
|
neuper@37906
|
31 |
"--------- inform [rational,simplification] ----------------------";
|
neuper@37906
|
32 |
"--------- Take as 1st tac, start with <NEW> (CAS input) ---------";
|
neuper@37906
|
33 |
"--------- Take as 1st tac, start from exp -----------------------";
|
neuper@37906
|
34 |
"--------- init_form, start with <NEW> (CAS input) ---------------";
|
neuper@37906
|
35 |
"-----------------------------------------------------------------";
|
neuper@37906
|
36 |
"-----------------------------------------------------------------";
|
neuper@37906
|
37 |
"-----------------------------------------------------------------";
|
neuper@37906
|
38 |
|
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 ----------------------";
|
neuper@37906
|
47 |
val Script sc = (#scr o get_met) ["Test","squ-equ-test-subpbl1"];
|
neuper@37906
|
48 |
(writeln o term2str) sc;
|
neuper@37906
|
49 |
val Script sc = (#scr o get_met) ["Test","solve_linear"];
|
neuper@37906
|
50 |
(writeln o term2str) sc;
|
neuper@37906
|
51 |
|
neuper@37906
|
52 |
states:=[];
|
neuper@41970
|
53 |
CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
|
neuper@41970
|
54 |
("Test", ["sqroot-test","univariate","equation","test"],
|
neuper@37906
|
55 |
["Test","squ-equ-test-subpbl1"]))];
|
neuper@37906
|
56 |
Iterator 1; moveActiveRoot 1;
|
neuper@37906
|
57 |
autoCalculate 1 CompleteCalcHead;
|
neuper@37906
|
58 |
autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
|
neuper@37906
|
59 |
autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
|
neuper@37906
|
60 |
|
neuper@37906
|
61 |
appendFormula 1 "-2 * 1 + (1 + x) = 0"; refFormula 1 (get_pos 1 1);
|
neuper@37906
|
62 |
val ((pt,_),_) = get_calc 1;
|
neuper@37906
|
63 |
val str = pr_ptree pr_short pt;
|
neuper@37906
|
64 |
writeln str;
|
neuper@37906
|
65 |
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
|
66 |
else error "inform.sml: diff.behav.appendFormula: on Res + equ 1";
|
neuper@37906
|
67 |
|
neuper@37906
|
68 |
moveDown 1 ([ ],Pbl); refFormula 1 ([1],Frm); (*x + 1 = 2*)
|
neuper@37906
|
69 |
moveDown 1 ([1],Frm); refFormula 1 ([1],Res); (*x + 1 + -1 * 2 = 0*)
|
neuper@37906
|
70 |
|
neuper@37906
|
71 |
(*the seven steps of detailed derivation*)
|
neuper@37906
|
72 |
moveDown 1 ([1 ],Res); refFormula 1 ([2,1],Frm);
|
neuper@37906
|
73 |
moveDown 1 ([2,1],Frm); refFormula 1 ([2,1],Res);
|
neuper@37906
|
74 |
moveDown 1 ([2,1],Res); refFormula 1 ([2,2],Res);
|
neuper@37906
|
75 |
moveDown 1 ([2,2],Res); refFormula 1 ([2,3],Res);
|
neuper@37906
|
76 |
moveDown 1 ([2,3],Res); refFormula 1 ([2,4],Res);
|
neuper@37906
|
77 |
moveDown 1 ([2,4],Res); refFormula 1 ([2,5],Res);
|
neuper@37906
|
78 |
moveDown 1 ([2,5],Res); refFormula 1 ([2,6],Res);
|
neuper@37906
|
79 |
val ((pt,_),_) = get_calc 1;
|
neuper@37906
|
80 |
if "-2 * 1 + (1 + x) = 0" = term2str (fst (get_obj g_result pt [2,6])) then()
|
neuper@38031
|
81 |
else error "inform.sml: diff.behav.appendFormula: on Res + equ 2";
|
neuper@37906
|
82 |
|
neuper@37906
|
83 |
fetchProposedTactic 1; (*takes Iterator 1 _1_*)
|
neuper@37906
|
84 |
val (_,(tac,_,_)::_) = get_calc 1;
|
neuper@37906
|
85 |
if tac = Rewrite_Set "Test_simplify" then ()
|
neuper@38031
|
86 |
else error "inform.sml: diff.behav.appendFormula: on Res + equ 3";
|
neuper@37906
|
87 |
autoCalculate 1 CompleteCalc;
|
neuper@37906
|
88 |
val ((pt,_),_) = get_calc 1;
|
neuper@37906
|
89 |
if "[x = 1]" = term2str (fst (get_obj g_result pt [])) then ()
|
neuper@38031
|
90 |
else error "inform.sml: diff.behav.appendFormula: on Res + equ 4";
|
neuper@37906
|
91 |
(* autoCalculate 1 CompleteCalc;
|
neuper@37906
|
92 |
val ((pt,p),_) = get_calc 1;
|
neuper@37906
|
93 |
(writeln o istates2str) (get_obj g_loc pt [ ]);
|
neuper@37906
|
94 |
(writeln o istates2str) (get_obj g_loc pt [1]);
|
neuper@37906
|
95 |
(writeln o istates2str) (get_obj g_loc pt [2]);
|
neuper@37906
|
96 |
(writeln o istates2str) (get_obj g_loc pt [3]);
|
neuper@37906
|
97 |
(writeln o istates2str) (get_obj g_loc pt [3,1]);
|
neuper@37906
|
98 |
(writeln o istates2str) (get_obj g_loc pt [3,2]);
|
neuper@37906
|
99 |
(writeln o istates2str) (get_obj g_loc pt [4]);
|
neuper@37906
|
100 |
|
neuper@37906
|
101 |
*)
|
neuper@37906
|
102 |
"----------------------------------------------------------";
|
neuper@38050
|
103 |
val fod = make_deriv (theory "Isac") Atools_erls
|
neuper@37906
|
104 |
((#rules o rep_rls) Test_simplify)
|
neuper@37935
|
105 |
(sqrt_right false (theory "Pure")) NONE
|
neuper@37906
|
106 |
(str2term "x + 1 + -1 * 2 = 0");
|
neuper@37906
|
107 |
(writeln o trtas2str) fod;
|
neuper@37906
|
108 |
|
neuper@38050
|
109 |
val ifod = make_deriv (theory "Isac") Atools_erls
|
neuper@37906
|
110 |
((#rules o rep_rls) Test_simplify)
|
neuper@37935
|
111 |
(sqrt_right false (theory "Pure")) NONE
|
neuper@37906
|
112 |
(str2term "-2 * 1 + (1 + x) = 0");
|
neuper@37906
|
113 |
(writeln o trtas2str) ifod;
|
neuper@37906
|
114 |
fun equal (_,_,(t1, _)) (_,_,(t2, _)) = t1=t2;
|
neuper@37906
|
115 |
val (fod', rifod') = dropwhile' equal (rev fod) (rev ifod);
|
neuper@37906
|
116 |
val der = fod' @ (map rev_deriv' rifod');
|
neuper@37906
|
117 |
(writeln o trtas2str) der;
|
neuper@37906
|
118 |
"----------------------------------------------------------";
|
neuper@37906
|
119 |
|
neuper@37906
|
120 |
|
neuper@37906
|
121 |
"--------- appendFormula: on Frm + equ_nrls ----------------------";
|
neuper@37906
|
122 |
"--------- appendFormula: on Frm + equ_nrls ----------------------";
|
neuper@37906
|
123 |
"--------- appendFormula: on Frm + equ_nrls ----------------------";
|
neuper@37906
|
124 |
states:=[];
|
neuper@41970
|
125 |
CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
|
neuper@41970
|
126 |
("Test", ["sqroot-test","univariate","equation","test"],
|
neuper@37906
|
127 |
["Test","squ-equ-test-subpbl1"]))];
|
neuper@37906
|
128 |
Iterator 1; moveActiveRoot 1;
|
neuper@37906
|
129 |
autoCalculate 1 CompleteCalcHead;
|
neuper@37906
|
130 |
autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1) (*x + 1 = 2*);
|
neuper@37906
|
131 |
|
neuper@37906
|
132 |
appendFormula 1 "2+ -1 + x = 2"; refFormula 1 (get_pos 1 1);
|
neuper@37906
|
133 |
|
neuper@37906
|
134 |
moveDown 1 ([],Pbl); refFormula 1 ([1],Frm) (*x + 1 = 2*);
|
neuper@37906
|
135 |
|
neuper@37906
|
136 |
moveDown 1 ([1 ],Frm); refFormula 1 ([1,1],Frm);
|
neuper@37906
|
137 |
moveDown 1 ([1,1],Frm); refFormula 1 ([1,1],Res);
|
neuper@37906
|
138 |
moveDown 1 ([1,1],Res); refFormula 1 ([1,2],Res);
|
neuper@37906
|
139 |
moveDown 1 ([1,2],Res); refFormula 1 ([1,3],Res);
|
neuper@37906
|
140 |
moveDown 1 ([1,3],Res); refFormula 1 ([1,4],Res);
|
neuper@37906
|
141 |
moveDown 1 ([1,4],Res); refFormula 1 ([1,5],Res);
|
neuper@37906
|
142 |
moveDown 1 ([1,5],Res); refFormula 1 ([1,6],Res);
|
neuper@37906
|
143 |
val ((pt,_),_) = get_calc 1;
|
neuper@37906
|
144 |
if "2 + -1 + x = 2" = term2str (fst (get_obj g_result pt [1,6])) then()
|
neuper@38031
|
145 |
else error "inform.sml: diff.behav.appendFormula: on Frm + equ 1";
|
neuper@37906
|
146 |
|
neuper@37906
|
147 |
fetchProposedTactic 1; (*takes Iterator 1 _1_*)
|
neuper@37906
|
148 |
val (_,(tac,_,_)::_) = get_calc 1;
|
neuper@37906
|
149 |
if tac = Rewrite_Set "norm_equation" then ()
|
neuper@38031
|
150 |
else error "inform.sml: diff.behav.appendFormula: on Frm + equ 2";
|
neuper@37906
|
151 |
autoCalculate 1 CompleteCalc;
|
neuper@37906
|
152 |
val ((pt,_),_) = get_calc 1;
|
neuper@37906
|
153 |
if "[x = 1]" = term2str (fst (get_obj g_result pt [])) then ()
|
neuper@38031
|
154 |
else error "inform.sml: diff.behav.appendFormula: on Frm + equ 3";
|
neuper@37906
|
155 |
|
neuper@37906
|
156 |
|
neuper@37906
|
157 |
"--------- appendFormula: on Res + NO deriv ----------------------";
|
neuper@37906
|
158 |
"--------- appendFormula: on Res + NO deriv ----------------------";
|
neuper@37906
|
159 |
"--------- appendFormula: on Res + NO deriv ----------------------";
|
neuper@37906
|
160 |
states:=[];
|
neuper@41970
|
161 |
CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
|
neuper@41970
|
162 |
("Test", ["sqroot-test","univariate","equation","test"],
|
neuper@37906
|
163 |
["Test","squ-equ-test-subpbl1"]))];
|
neuper@37906
|
164 |
Iterator 1; moveActiveRoot 1;
|
neuper@37906
|
165 |
autoCalculate 1 CompleteCalcHead;
|
neuper@37906
|
166 |
autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
|
neuper@37906
|
167 |
autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
|
neuper@37906
|
168 |
|
neuper@37906
|
169 |
appendFormula 1 "x = 2";
|
neuper@37906
|
170 |
val ((pt,p),_) = get_calc 1;
|
neuper@37906
|
171 |
val str = pr_ptree pr_short pt;
|
neuper@37906
|
172 |
writeln str;
|
neuper@37906
|
173 |
if str = ". ----- pblobj -----\n1. x + 1 = 2\n" andalso p = ([1], Res)
|
neuper@37906
|
174 |
then ()
|
neuper@38031
|
175 |
else error "inform.sml: diff.behav.appendFormula: Res + NOder 1";
|
neuper@37906
|
176 |
|
neuper@37906
|
177 |
fetchProposedTactic 1;
|
neuper@37906
|
178 |
val (_,(tac,_,_)::_) = get_calc 1;
|
neuper@37906
|
179 |
if tac = Rewrite_Set "Test_simplify" then ()
|
neuper@38031
|
180 |
else error "inform.sml: diff.behav.appendFormula: Res + NOder 2";
|
neuper@37906
|
181 |
autoCalculate 1 CompleteCalc;
|
neuper@37906
|
182 |
val ((pt,_),_) = get_calc 1;
|
neuper@37906
|
183 |
if "[x = 1]" = term2str (fst (get_obj g_result pt [])) then ()
|
neuper@38031
|
184 |
else error "inform.sml: diff.behav.appendFormula: on Frm + equ 3";
|
neuper@37906
|
185 |
|
neuper@37906
|
186 |
|
neuper@37906
|
187 |
"--------- appendFormula: on Res + late deriv --------------------";
|
neuper@37906
|
188 |
"--------- appendFormula: on Res + late deriv --------------------";
|
neuper@37906
|
189 |
"--------- appendFormula: on Res + late deriv --------------------";
|
neuper@37906
|
190 |
states:=[];
|
neuper@41970
|
191 |
CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
|
neuper@41970
|
192 |
("Test", ["sqroot-test","univariate","equation","test"],
|
neuper@37906
|
193 |
["Test","squ-equ-test-subpbl1"]))];
|
neuper@37906
|
194 |
Iterator 1; moveActiveRoot 1;
|
neuper@37906
|
195 |
autoCalculate 1 CompleteCalcHead;
|
neuper@37906
|
196 |
autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
|
neuper@37906
|
197 |
autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
|
neuper@37906
|
198 |
|
neuper@37906
|
199 |
appendFormula 1 "x = 1";
|
neuper@37906
|
200 |
val ((pt,p),_) = get_calc 1;
|
neuper@37906
|
201 |
val str = pr_ptree pr_short pt;
|
neuper@37906
|
202 |
writeln str;
|
neuper@37906
|
203 |
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
|
204 |
then () (*finds 1 step too early: ([3,2], Res) "x = 1" also by script !!!*)
|
neuper@38031
|
205 |
else error "inform.sml: diff.behav.appendFormula: Res + late d 1";
|
neuper@37906
|
206 |
|
neuper@37906
|
207 |
fetchProposedTactic 1;
|
neuper@37906
|
208 |
val (_,(tac,_,_)::_) = get_calc 1;
|
neuper@37906
|
209 |
if tac = Check_Postcond ["linear", "univariate", "equation", "test"] then ()
|
neuper@38031
|
210 |
else error "inform.sml: diff.behav.appendFormula: Res + late d 2";
|
neuper@37906
|
211 |
autoCalculate 1 CompleteCalc;
|
neuper@37906
|
212 |
val ((pt,_),_) = get_calc 1;
|
neuper@37906
|
213 |
if "[x = 1]" = term2str (fst (get_obj g_result pt [])) then ()
|
neuper@38031
|
214 |
else error "inform.sml: diff.behav.appendFormula: Res + late d 3";
|
neuper@37906
|
215 |
|
neuper@37906
|
216 |
|
neuper@37906
|
217 |
"--------- appendFormula: on Res + late deriv [x = 3 + -2]---///--";
|
neuper@37906
|
218 |
"--------- appendFormula: on Res + late deriv [x = 3 + -2]---///--";
|
neuper@37906
|
219 |
"--------- appendFormula: on Res + late deriv [x = 3 + -2]---///--";
|
neuper@37906
|
220 |
states:=[];
|
neuper@41970
|
221 |
CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
|
neuper@41970
|
222 |
("Test", ["sqroot-test","univariate","equation","test"],
|
neuper@37906
|
223 |
["Test","squ-equ-test-subpbl1"]))];
|
neuper@37906
|
224 |
Iterator 1; moveActiveRoot 1;
|
neuper@37906
|
225 |
autoCalculate 1 CompleteCalcHead;
|
neuper@37906
|
226 |
autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
|
neuper@37906
|
227 |
autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
|
neuper@37906
|
228 |
appendFormula 1 "[x = 3 + -2*1]";
|
neuper@37906
|
229 |
val ((pt,p),_) = get_calc 1;
|
neuper@37906
|
230 |
val str = pr_ptree pr_short pt;
|
neuper@37906
|
231 |
writeln str;
|
neuper@37906
|
232 |
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
|
233 |
else error "inform.sml: diff.behav.appendFormula: Res + latEE 1";
|
neuper@37906
|
234 |
autoCalculate 1 CompleteCalc;
|
neuper@37906
|
235 |
val ((pt,p),_) = get_calc 1;
|
neuper@37906
|
236 |
if "[x = 3 + -2 * 1]" = term2str (fst (get_obj g_result pt [])) then ()
|
neuper@37906
|
237 |
(* ~~~~~~~~~~ simplify as last step in any script ?!*)
|
neuper@38031
|
238 |
else error "inform.sml: diff.behav.appendFormula: Res + latEE 2";
|
neuper@37906
|
239 |
|
neuper@37906
|
240 |
|
neuper@37906
|
241 |
|
neuper@37906
|
242 |
"--------- replaceFormula: on Res + = ----------------------------";
|
neuper@37906
|
243 |
"--------- replaceFormula: on Res + = ----------------------------";
|
neuper@37906
|
244 |
"--------- replaceFormula: on Res + = ----------------------------";
|
neuper@37906
|
245 |
states:=[];
|
neuper@41970
|
246 |
CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
|
neuper@41970
|
247 |
("Test", ["sqroot-test","univariate","equation","test"],
|
neuper@37906
|
248 |
["Test","squ-equ-test-subpbl1"]))];
|
neuper@37906
|
249 |
Iterator 1; moveActiveRoot 1;
|
neuper@37906
|
250 |
autoCalculate 1 CompleteCalcHead;
|
neuper@37906
|
251 |
autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
|
neuper@37906
|
252 |
autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
|
neuper@37906
|
253 |
autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*-1 + x*);
|
neuper@37906
|
254 |
|
neuper@37906
|
255 |
replaceFormula 1 "-2 * 1 + (1 + x) = 0"; refFormula 1 (get_pos 1 1);
|
neuper@37906
|
256 |
val ((pt,_),_) = get_calc 1;
|
neuper@37906
|
257 |
val str = pr_ptree pr_short pt;
|
neuper@37906
|
258 |
writeln str;
|
neuper@37906
|
259 |
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
|
260 |
else error "inform.sml: diff.behav.replaceFormula: on Res += 1";
|
neuper@37906
|
261 |
autoCalculate 1 CompleteCalc;
|
neuper@37906
|
262 |
val ((pt,pos as(p,_)),_) = get_calc 1;
|
neuper@37906
|
263 |
if pos=([],Res)andalso"[x = 1]"=(term2str o fst)(get_obj g_result pt p)then()
|
neuper@38031
|
264 |
else error "inform.sml: diff.behav.replaceFormula: on Res + = 2";
|
neuper@37906
|
265 |
|
neuper@37906
|
266 |
|
neuper@37906
|
267 |
"--------- replaceFormula: on Res + = 1st Nd ---------------------";
|
neuper@37906
|
268 |
"--------- replaceFormula: on Res + = 1st Nd ---------------------";
|
neuper@37906
|
269 |
"--------- replaceFormula: on Res + = 1st Nd ---------------------";
|
neuper@37906
|
270 |
states:=[];
|
neuper@41970
|
271 |
CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
|
neuper@41970
|
272 |
("Test", ["sqroot-test","univariate","equation","test"],
|
neuper@37906
|
273 |
["Test","squ-equ-test-subpbl1"]))];
|
neuper@37906
|
274 |
Iterator 1; moveActiveRoot 1;
|
neuper@37906
|
275 |
autoCalculate 1 CompleteCalcHead;
|
neuper@37906
|
276 |
autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
|
neuper@37906
|
277 |
autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
|
neuper@37906
|
278 |
|
neuper@37906
|
279 |
replaceFormula 1 "x + 1 = 4 + -2"; refFormula 1 (get_pos 1 1);
|
neuper@37906
|
280 |
val ((pt,_),_) = get_calc 1;
|
neuper@37906
|
281 |
val str = pr_ptree pr_short pt;
|
neuper@37906
|
282 |
writeln str;
|
neuper@37906
|
283 |
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
|
284 |
else error "inform.sml: diff.behav.replaceFormula: on Res 1 + = 1";
|
neuper@37906
|
285 |
autoCalculate 1 CompleteCalc;
|
neuper@37906
|
286 |
val ((pt,pos as(p,_)),_) = get_calc 1;
|
neuper@37906
|
287 |
if pos=([],Res)andalso"[x = 1]"=(term2str o fst)(get_obj g_result pt p)then()
|
neuper@38031
|
288 |
else error "inform.sml: diff.behav.replaceFormula: on Res + = 2";
|
neuper@37906
|
289 |
|
neuper@37906
|
290 |
|
neuper@37906
|
291 |
"--------- replaceFormula: on Frm + = 1st Nd ---------------------";
|
neuper@37906
|
292 |
"--------- replaceFormula: on Frm + = 1st Nd ---------------------";
|
neuper@37906
|
293 |
"--------- replaceFormula: on Frm + = 1st Nd ---------------------";
|
neuper@37906
|
294 |
states:=[];
|
neuper@41970
|
295 |
CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
|
neuper@41970
|
296 |
("Test", ["sqroot-test","univariate","equation","test"],
|
neuper@37906
|
297 |
["Test","squ-equ-test-subpbl1"]))];
|
neuper@37906
|
298 |
Iterator 1; moveActiveRoot 1;
|
neuper@37906
|
299 |
autoCalculate 1 CompleteCalcHead;
|
neuper@37906
|
300 |
autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
|
neuper@37906
|
301 |
|
neuper@37906
|
302 |
replaceFormula 1 "x + 1 = 4 + -2"; refFormula 1 (get_pos 1 1);
|
neuper@37906
|
303 |
val ((pt,_),_) = get_calc 1;
|
neuper@37906
|
304 |
val str = pr_ptree pr_short pt;
|
neuper@37906
|
305 |
writeln str;
|
neuper@37906
|
306 |
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
|
307 |
else error "inform.sml: diff.behav.replaceFormula: on Frm 1 + = 1";
|
neuper@37906
|
308 |
autoCalculate 1 CompleteCalc;
|
neuper@37906
|
309 |
val ((pt,pos as(p,_)),_) = get_calc 1;
|
neuper@37906
|
310 |
if pos=([],Res)andalso"[x = 1]"=(term2str o fst)(get_obj g_result pt p)then()
|
neuper@38031
|
311 |
else error "inform.sml: diff.behav.replaceFormula: on Frm 1 + = 2";
|
neuper@37906
|
312 |
|
neuper@37906
|
313 |
|
neuper@37906
|
314 |
"--------- replaceFormula: cut calculation -----------------------";
|
neuper@37906
|
315 |
"--------- replaceFormula: cut calculation -----------------------";
|
neuper@37906
|
316 |
"--------- replaceFormula: cut calculation -----------------------";
|
neuper@37906
|
317 |
states:=[];
|
neuper@41970
|
318 |
CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
|
neuper@41970
|
319 |
("Test", ["sqroot-test","univariate","equation","test"],
|
neuper@37906
|
320 |
["Test","squ-equ-test-subpbl1"]))];
|
neuper@37906
|
321 |
Iterator 1; moveActiveRoot 1;
|
neuper@37906
|
322 |
autoCalculate 1 CompleteCalc;
|
neuper@37906
|
323 |
moveActiveRoot 1; moveActiveDown 1;
|
neuper@37906
|
324 |
if get_pos 1 1 = ([1], Frm) then ()
|
neuper@38031
|
325 |
else error "inform.sml: diff.behav. cut calculation 1";
|
neuper@37906
|
326 |
|
neuper@37906
|
327 |
replaceFormula 1 "x + 1 = 4 + -2"; refFormula 1 (get_pos 1 1);
|
neuper@37906
|
328 |
val ((pt,p),_) = get_calc 1;
|
neuper@37906
|
329 |
val str = pr_ptree pr_short pt;
|
neuper@37906
|
330 |
writeln str;
|
neuper@37906
|
331 |
if p = ([1], Res) then ()
|
neuper@38031
|
332 |
else error "inform.sml: diff.behav. cut calculation 2";
|
neuper@37906
|
333 |
|
neuper@37906
|
334 |
|
neuper@37906
|
335 |
|
neuper@37906
|
336 |
(* 040307 copied from informtest.sml; ... old version
|
neuper@37906
|
337 |
"---------------- maximum-example, UC: Modeling / modifyCalcHead -";
|
neuper@37906
|
338 |
"---------------- maximum-example, UC: Modeling / modifyCalcHead -";
|
neuper@37906
|
339 |
"---------------- maximum-example, UC: Modeling / modifyCalcHead -";
|
neuper@37906
|
340 |
|
neuper@37906
|
341 |
val p = ([],Pbl);
|
neuper@37906
|
342 |
val elems = ["fixedValues [r=Arbfix]","maximum A","valuesFor [a,b]",
|
neuper@37906
|
343 |
"relations [A=a*b, (a/2)^^^2 + (b/2)^^^2 = r^^^2]",
|
neuper@37906
|
344 |
"relations [A=a*b, (a/2)^^^2 + (b/2)^^^2 = r^^^2]",
|
neuper@37906
|
345 |
"relations [A=a*b, a/2=r*sin alpha, b/2=r*cos alpha]",
|
neuper@37906
|
346 |
(*^^^ these are the elements for the root-problem (in variants)*)
|
neuper@37906
|
347 |
(*vvv these are elements required for subproblems*)
|
neuper@37906
|
348 |
"boundVariable a","boundVariable b","boundVariable alpha",
|
neuper@37906
|
349 |
"interval {x::real. 0 <= x & x <= 2*r}",
|
neuper@37906
|
350 |
"interval {x::real. 0 <= x & x <= 2*r}",
|
neuper@37906
|
351 |
"interval {x::real. 0 <= x & x <= pi}",
|
neuper@37906
|
352 |
"errorBound (eps=(0::real))"]
|
neuper@37906
|
353 |
(*specifying is not interesting for this example*)
|
neuper@38058
|
354 |
val spec = ("DiffApp", ["maximum_of","function"],
|
neuper@37906
|
355 |
["DiffApp","max_by_calculus"]);
|
neuper@37906
|
356 |
(*the empty model with descriptions for user-guidance by Model_Problem*)
|
neuper@37906
|
357 |
val empty_model = [Given ["fixedValues []"],
|
neuper@37906
|
358 |
Find ["maximum", "valuesFor"],
|
neuper@37906
|
359 |
Relate ["relations []"]];
|
neuper@37906
|
360 |
|
neuper@37906
|
361 |
|
neuper@37906
|
362 |
(*!!!!!!!!!!!!!!!!! DON'T USE me FOR FINDING nxt !!!!!!!!!!!!!!!!!!*)
|
neuper@37906
|
363 |
val (p,_,f,nxt,_,pt) = CalcTreeTEST [(elems, spec)];
|
neuper@37906
|
364 |
(*val nxt = ("Model_Problem", ...*)
|
neuper@37924
|
365 |
val pbl = get_obj g_pbl pt (fst p); (writeln o (itms2str_ ctxt)) pbl;
|
neuper@37906
|
366 |
|
neuper@37906
|
367 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
neuper@37906
|
368 |
(*nxt = Add_Given "fixedValues [r = Arbfix]"*)
|
neuper@37924
|
369 |
val pbl = get_obj g_pbl pt (fst p); (writeln o (itms2str_ ctxt)) pbl;
|
neuper@37906
|
370 |
(*[
|
neuper@37906
|
371 |
(0 ,[] ,false ,#Given ,Inc fixedValues [] ,(??.empty, [])),
|
neuper@37906
|
372 |
(0 ,[] ,false ,#Find ,Inc maximum ,(??.empty, [])),
|
neuper@37906
|
373 |
(0 ,[] ,false ,#Find ,Inc valuesFor ,(??.empty, [])),
|
neuper@37906
|
374 |
(0 ,[] ,false ,#Relate ,Inc relations [] ,(??.empty, []))]*)
|
neuper@37906
|
375 |
|
neuper@37906
|
376 |
(*the empty CalcHead is checked w.r.t the model and re-established as such*)
|
neuper@37906
|
377 |
val (b,pt,ocalhd) = input_icalhd pt (p,"", empty_model, Pbl, e_spec);
|
neuper@37924
|
378 |
val pbl = get_obj g_pbl pt (fst p); (writeln o (itms2str_ ctxt)) pbl;
|
neuper@38031
|
379 |
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
|
380 |
|
neuper@37906
|
381 |
(*there is one input to the model (could be more)*)
|
neuper@37906
|
382 |
val (b,pt,ocalhd) =
|
neuper@37906
|
383 |
input_icalhd pt (p,"", [Given ["fixedValues [r=Arbfix]"],
|
neuper@37906
|
384 |
Find ["maximum", "valuesFor"],
|
neuper@37906
|
385 |
Relate ["relations"]], Pbl, e_spec);
|
neuper@37924
|
386 |
val pbl = get_obj g_pbl pt (fst p); (writeln o (itms2str_ ctxt)) pbl;
|
neuper@37906
|
387 |
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
|
388 |
else error "informtest.sml: diff.behav. max 2";
|
neuper@37906
|
389 |
|
neuper@37906
|
390 |
(*this input is complete in variant 3, but the ME doesn't recognize FIXXXXME
|
neuper@37906
|
391 |
val (b,pt''''',ocalhd) =
|
neuper@37906
|
392 |
input_icalhd pt (p,"", [Given ["fixedValues [r=Arbfix]"],
|
neuper@37906
|
393 |
Find ["maximum A", "valuesFor [a,b]"],
|
neuper@37906
|
394 |
Relate ["relations [A=a*b, a/2=r*sin alpha, \
|
neuper@37906
|
395 |
\b/2=r*cos alpha]"]], Pbl, e_spec);
|
neuper@37924
|
396 |
val pbl = get_obj g_pbl pt''''' (fst p); (writeln o (itms2str_ ctxt)) pbl;
|
neuper@37906
|
397 |
if ocalhd2str ocalhd = ------------^^^^^^^^^^ missing !!!*)
|
neuper@37906
|
398 |
|
neuper@37906
|
399 |
(*this input is complete in variant 1 (variant 3 does not work yet)*)
|
neuper@37906
|
400 |
val (b,pt''''',ocalhd) =
|
neuper@37906
|
401 |
input_icalhd pt (p,"", [Given ["fixedValues [r=Arbfix]"],
|
neuper@37906
|
402 |
Find ["maximum A", "valuesFor [a,b]"],
|
neuper@37906
|
403 |
Relate ["relations [A=a*b, \
|
neuper@37906
|
404 |
\(a/2)^^^2 + (b/2)^^^2 = r^^^2]"]],
|
neuper@37906
|
405 |
Pbl, e_spec);
|
neuper@37924
|
406 |
val pbl = get_obj g_pbl pt''''' (fst p); (writeln o (itms2str_ ctxt)) pbl;
|
neuper@37906
|
407 |
|
neuper@37906
|
408 |
modifycalcheadOK2xml 111 (bool2str b) ocalhd;
|
neuper@37906
|
409 |
*)
|
neuper@37906
|
410 |
|
neuper@37906
|
411 |
"--------- syntax error ------------------------------------------";
|
neuper@37906
|
412 |
"--------- syntax error ------------------------------------------";
|
neuper@37906
|
413 |
"--------- syntax error ------------------------------------------";
|
neuper@37906
|
414 |
states:=[];
|
neuper@41970
|
415 |
CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
|
neuper@41970
|
416 |
("Test", ["sqroot-test","univariate","equation","test"],
|
neuper@37906
|
417 |
["Test","squ-equ-test-subpbl1"]))];
|
neuper@37906
|
418 |
Iterator 1; moveActiveRoot 1;
|
neuper@37906
|
419 |
autoCalculate 1 CompleteCalcHead;
|
neuper@37906
|
420 |
autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
|
neuper@37906
|
421 |
autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
|
neuper@37906
|
422 |
|
neuper@37906
|
423 |
appendFormula 1 " x - "; (*<ERROR> syntax error in ' x - ' </ERROR>*)
|
neuper@37906
|
424 |
val ((pt,_),_) = get_calc 1;
|
neuper@37906
|
425 |
val str = pr_ptree pr_short pt;
|
neuper@37906
|
426 |
writeln str;
|
neuper@37906
|
427 |
if str = ". ----- pblobj -----\n1. x + 1 = 2\n" then ()
|
neuper@38031
|
428 |
else error "inform.sml: diff.behav.appendFormula: syntax error";
|
neuper@37906
|
429 |
|
neuper@37906
|
430 |
|
neuper@37906
|
431 |
"--------- CAS-command on ([],Pbl) -------------------------------";
|
neuper@37906
|
432 |
"--------- CAS-command on ([],Pbl) -------------------------------";
|
neuper@37906
|
433 |
"--------- CAS-command on ([],Pbl) -------------------------------";
|
neuper@37906
|
434 |
val (p,_,f,nxt,_,pt) =
|
neuper@37906
|
435 |
CalcTreeTEST [([], ("e_domID", ["e_pblID"], ["e_metID"]))];
|
neuper@37906
|
436 |
val ifo = "solve(x+1=2,x)";
|
neuper@37906
|
437 |
val (_,(_,c,(pt,p))) = inform ([],[],(pt,p)) "solve(x+1=2,x)";
|
neuper@37906
|
438 |
show_pt pt;
|
neuper@37906
|
439 |
val nxt = ("Apply_Method",Apply_Method ["Test","squ-equ-test-subpbl1"]);
|
neuper@37906
|
440 |
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
|
neuper@37906
|
441 |
if p = ([1], Frm) andalso f2str f = "x + 1 = 2" then ()
|
neuper@38031
|
442 |
else error "inform.sml: diff.behav. CAScmd ([],Pbl)";
|
neuper@37906
|
443 |
|
neuper@37906
|
444 |
|
neuper@37906
|
445 |
"--------- CAS-command on ([],Pbl) FE-interface ------------------";
|
neuper@37906
|
446 |
"--------- CAS-command on ([],Pbl) FE-interface ------------------";
|
neuper@37906
|
447 |
"--------- CAS-command on ([],Pbl) FE-interface ------------------";
|
neuper@37906
|
448 |
states:=[];
|
neuper@37906
|
449 |
CalcTree [([], ("e_domID", ["e_pblID"], ["e_metID"]))];
|
neuper@37906
|
450 |
Iterator 1;
|
neuper@37906
|
451 |
moveActiveRoot 1;
|
neuper@37906
|
452 |
replaceFormula 1 "solve(x+1=2,x)";
|
neuper@37906
|
453 |
autoCalculate 1 CompleteCalc;
|
neuper@37906
|
454 |
val ((pt,p),_) = get_calc 1;
|
neuper@37906
|
455 |
show_pt pt;
|
neuper@37906
|
456 |
if p = ([], Res) then ()
|
neuper@38031
|
457 |
else error "inform.sml: diff.behav. CAScmd ([],Pbl) FE-interface";
|
neuper@37906
|
458 |
|
neuper@37906
|
459 |
|
neuper@37906
|
460 |
"--------- inform [rational,simplification] ----------------------";
|
neuper@37906
|
461 |
"--------- inform [rational,simplification] ----------------------";
|
neuper@37906
|
462 |
"--------- inform [rational,simplification] ----------------------";
|
neuper@37906
|
463 |
states:=[];
|
neuper@38083
|
464 |
CalcTree [(["Term (4/x - 3/y - 1)", "normalform N"],
|
neuper@38058
|
465 |
("Rational",["rational","simplification"],
|
neuper@37906
|
466 |
["simplification","of_rationals"]))];
|
neuper@37906
|
467 |
Iterator 1; moveActiveRoot 1;
|
neuper@37906
|
468 |
autoCalculate 1 CompleteCalcHead;
|
neuper@37906
|
469 |
autoCalculate 1 (Step 1);
|
neuper@37906
|
470 |
autoCalculate 1 (Step 1);
|
neuper@37906
|
471 |
autoCalculate 1 (Step 1);
|
neuper@37906
|
472 |
autoCalculate 1 (Step 1);
|
neuper@37906
|
473 |
"--- input the next formula that _should_ be presented by mat-engine";
|
neuper@37906
|
474 |
appendFormula 1 "(4 * y + -3 * x) / (x * y) + -1";
|
neuper@37906
|
475 |
val ((pt,p),_) = get_calc 1;
|
neuper@37906
|
476 |
if p = ([4], Res) andalso (length o children o (get_nd pt)) (fst p) = 2 then ()
|
neuper@38031
|
477 |
else error ("inform.sml: [rational,simplification] 1");
|
neuper@37906
|
478 |
|
neuper@37906
|
479 |
"--- input the next formula that would be presented by mat-engine";
|
neuper@37906
|
480 |
(*autoCalculate 1 (Step 1);*)
|
neuper@37906
|
481 |
appendFormula 1 "(4 * y + -3 * x + -1 * (x * y)) / (x * y)";
|
neuper@37906
|
482 |
val ((pt,p),_) = get_calc 1;
|
neuper@37906
|
483 |
if p = ([5], Res) andalso (length o children o (get_nd pt)) (fst p) = 0 then ()
|
neuper@38031
|
484 |
else error ("inform.sml: [rational,simplification] 2");
|
neuper@37906
|
485 |
|
neuper@37906
|
486 |
"--- input the exact final result";(*TODO: Exception- LIST "last_elem" raised*)
|
neuper@37906
|
487 |
appendFormula 1 "(-3 * x + 4 * y + -1 * x * y) / (x * y)";
|
neuper@37906
|
488 |
val ((pt,p),_) = get_calc 1;
|
neuper@37906
|
489 |
if p = ([6], Res) andalso (length o children o (get_nd pt)) (fst p) = 2 then ()
|
neuper@38031
|
490 |
else error ("inform.sml: [rational,simplification] 3");
|
neuper@37906
|
491 |
show_pt pt;
|
neuper@37906
|
492 |
|
neuper@37906
|
493 |
"--------- Take as 1st tac, start with <NEW> (CAS input) ---------";
|
neuper@37906
|
494 |
"--------- Take as 1st tac, start with <NEW> (CAS input) ---------";
|
neuper@37906
|
495 |
"--------- Take as 1st tac, start with <NEW> (CAS input) ---------";
|
neuper@37906
|
496 |
val t = str2term "Diff (x^^^2 + x + 1, x)";
|
neuper@37906
|
497 |
case t of Const ("Diff.Diff", _) $ _ => ()
|
neuper@37906
|
498 |
| _ => raise
|
neuper@37906
|
499 |
error "diff.sml behav.changed for CAS Diff (..., x)";
|
neuper@37906
|
500 |
atomty t;
|
neuper@37906
|
501 |
"-----------------------------------------------------------------";
|
neuper@37906
|
502 |
(*1>*)states:=[];
|
neuper@37906
|
503 |
(*2>*)CalcTree [([], ("e_domID", ["e_pblID"], ["e_metID"]))];
|
neuper@37906
|
504 |
(*3>*)Iterator 1;moveActiveRoot 1;
|
neuper@37906
|
505 |
"----- here the Headline has been finished";
|
neuper@37906
|
506 |
(*4>*)moveActiveFormula 1 ([],Pbl);
|
neuper@37906
|
507 |
(*5>*)replaceFormula 1 "Diff (x^2 + x + 1, x)";
|
neuper@37906
|
508 |
val ((pt,_),_) = get_calc 1;
|
neuper@37906
|
509 |
val PblObj {probl, meth, spec, fmz, env, loc, ...} = get_obj I pt [];
|
neuper@37926
|
510 |
val NONE = env;
|
neuper@37926
|
511 |
val (SOME istate, NONE) = loc;
|
neuper@37906
|
512 |
print_depth 5;
|
neuper@37906
|
513 |
writeln"-----------------------------------------------------------";
|
neuper@37906
|
514 |
spec;
|
neuper@37924
|
515 |
writeln (itms2str_ ctxt probl);
|
neuper@37924
|
516 |
writeln (itms2str_ ctxt meth);
|
neuper@37906
|
517 |
writeln (istate2str istate);
|
neuper@37906
|
518 |
|
neuper@37906
|
519 |
print_depth 3;
|
neuper@37906
|
520 |
|
neuper@37906
|
521 |
refFormula 1 ([],Pbl) (*--> correct CalcHead*);
|
neuper@37906
|
522 |
(*081016 NOT necessary (but leave it in Java):*)
|
neuper@37906
|
523 |
(*6>*)(*completeCalcHead*)autoCalculate 1 CompleteCalcHead;
|
neuper@37906
|
524 |
"----- here the CalcHead has been completed --- ONCE MORE ?????";
|
neuper@37906
|
525 |
|
neuper@37906
|
526 |
(***difference II***)
|
neuper@37906
|
527 |
val ((pt,p),_) = get_calc 1;
|
neuper@37906
|
528 |
(*val p = ([], Pbl)*)
|
neuper@37906
|
529 |
val PblObj {probl, meth, spec, fmz, env, loc, ...} = get_obj I pt [];
|
neuper@37926
|
530 |
val NONE = env;
|
neuper@37926
|
531 |
val (SOME istate, NONE) = loc;
|
neuper@37906
|
532 |
print_depth 5; writeln (istate2str istate); print_depth 3;
|
neuper@37906
|
533 |
(*ScrState ([],
|
neuper@37926
|
534 |
[], NONE,
|
neuper@37906
|
535 |
??.empty, Sundef, false)*)
|
neuper@37906
|
536 |
print_depth 5; spec; print_depth 3;
|
neuper@38050
|
537 |
(*("Isac",
|
neuper@37906
|
538 |
["derivative_of", "function"],
|
neuper@37906
|
539 |
["diff", "differentiate_on_R"]) : spec*)
|
neuper@37924
|
540 |
writeln (itms2str_ ctxt probl);
|
neuper@37906
|
541 |
(*[
|
neuper@37906
|
542 |
(1 ,[1] ,true ,#Given ,Cor functionTerm (x ^^^ 2 + x + 1) ,(f_, [x ^^^ 2 + x + 1])),
|
neuper@37906
|
543 |
(2 ,[1] ,true ,#Given ,Cor differentiateFor x ,(v_, [x])),
|
neuper@37906
|
544 |
(3 ,[1] ,true ,#Find ,Cor derivative f_'_ ,(f_'_, [f_'_]))]*)
|
neuper@37924
|
545 |
writeln (itms2str_ ctxt meth);
|
neuper@37906
|
546 |
(*[
|
neuper@37906
|
547 |
(1 ,[1] ,true ,#Given ,Cor functionTerm (x ^^^ 2 + x + 1) ,(f_, [x ^^^ 2 + x + 1])),
|
neuper@37906
|
548 |
(2 ,[1] ,true ,#Given ,Cor differentiateFor x ,(v_, [x])),
|
neuper@37906
|
549 |
(3 ,[1] ,true ,#Find ,Cor derivative f_'_ ,(f_'_, [f_'_]))]*)
|
neuper@37906
|
550 |
writeln"-----------------------------------------------------------";
|
neuper@37906
|
551 |
(*7>*)fetchProposedTactic 1 (*--> Apply_Method*);
|
neuper@37906
|
552 |
(*WN081028 fixed <ERROR> helpless </ERROR> by inform returning ...(.,Met)*)
|
neuper@37906
|
553 |
autoCalculate 1 CompleteCalc;
|
neuper@37906
|
554 |
val ((pt,p),_) = get_calc 1;
|
neuper@37906
|
555 |
val Form res = (#1 o pt_extract) (pt, ([],Res));
|
neuper@37906
|
556 |
show_pt pt;
|
neuper@37906
|
557 |
if p = ([], Res) andalso term2str res = "1 + 2 * x" then ()
|
neuper@38031
|
558 |
else error "diff.sml behav.changed for Diff (x^2 + x + 1, x)";
|
neuper@37906
|
559 |
|
neuper@37906
|
560 |
|
neuper@37906
|
561 |
"--------- Take as 1st tac, start from exp -----------------------";
|
neuper@37906
|
562 |
"--------- Take as 1st tac, start from exp -----------------------";
|
neuper@37906
|
563 |
"--------- Take as 1st tac, start from exp -----------------------";
|
neuper@37906
|
564 |
(*the following input is copied from BridgeLog Java <==> SML,
|
neuper@37906
|
565 |
omitting unnecessary inputs*)
|
neuper@37906
|
566 |
(*1>*)states:=[];
|
neuper@38050
|
567 |
(*2>*)CalcTree [(["functionTerm (x^2 + x + 1)", "differentiateFor x", "derivative f_'_"],("Isac",["derivative_of","function"],["diff","differentiate_on_R"]))];
|
neuper@37906
|
568 |
(*3>*)Iterator 1; moveActiveRoot 1;
|
neuper@37906
|
569 |
|
neuper@37906
|
570 |
(*6>*)(*completeCalcHead*)autoCalculate 1 CompleteCalcHead;
|
neuper@37906
|
571 |
|
neuper@37906
|
572 |
(***difference II***)
|
neuper@37906
|
573 |
val ((pt,_),_) = get_calc 1;
|
neuper@37906
|
574 |
val PblObj {probl, meth, spec, fmz, env, loc, ...} = get_obj I pt [];
|
neuper@37926
|
575 |
val NONE = env;
|
neuper@37926
|
576 |
val (SOME istate, NONE) = loc;
|
neuper@37906
|
577 |
print_depth 5; writeln (istate2str istate); print_depth 3;
|
neuper@37906
|
578 |
(*ScrState ([],
|
neuper@37926
|
579 |
[], NONE,
|
neuper@37906
|
580 |
??.empty, Sundef, false)*)
|
neuper@37906
|
581 |
print_depth 5; spec; print_depth 3;
|
neuper@38050
|
582 |
(*("Isac",
|
neuper@37906
|
583 |
["derivative_of", "function"],
|
neuper@37906
|
584 |
["diff", "differentiate_on_R"]) : spec*)
|
neuper@37924
|
585 |
writeln (itms2str_ ctxt probl);
|
neuper@37906
|
586 |
(*[
|
neuper@37906
|
587 |
(1 ,[1] ,true ,#Given ,Cor functionTerm (x ^^^ 2 + x + 1) ,(f_, [x ^^^ 2 + x + 1])),
|
neuper@37906
|
588 |
(2 ,[1] ,true ,#Given ,Cor differentiateFor x ,(v_, [x])),
|
neuper@37906
|
589 |
(3 ,[1] ,true ,#Find ,Cor derivative f_'_ ,(f_'_, [f_'_]))]*)
|
neuper@37924
|
590 |
writeln (itms2str_ ctxt meth);
|
neuper@37906
|
591 |
(*[
|
neuper@37906
|
592 |
(1 ,[1] ,true ,#Given ,Cor functionTerm (x ^^^ 2 + x + 1) ,(f_, [x ^^^ 2 + x + 1])),
|
neuper@37906
|
593 |
(2 ,[1] ,true ,#Given ,Cor differentiateFor x ,(v_, [x])),
|
neuper@37906
|
594 |
(3 ,[1] ,true ,#Find ,Cor derivative f_'_ ,(f_'_, [f_'_]))]*)
|
neuper@37906
|
595 |
writeln"-----------------------------------------------------------";
|
neuper@37906
|
596 |
(*7>*)fetchProposedTactic 1 (*--> Apply_Method*);
|
neuper@37906
|
597 |
|
neuper@37906
|
598 |
autoCalculate 1 (Step 1);
|
neuper@37906
|
599 |
val ((pt,p),_) = get_calc 1;
|
neuper@37906
|
600 |
val Form res = (#1 o pt_extract) (pt, p);
|
neuper@37906
|
601 |
if term2str res = "d_d x (x ^^^ 2 + x + 1)" then ()
|
neuper@38031
|
602 |
else error "diff.sml Diff (x^2 + x + 1, x) from exp";
|
neuper@37906
|
603 |
|
neuper@37906
|
604 |
|
neuper@37906
|
605 |
"--------- init_form, start with <NEW> (CAS input) ---------------";
|
neuper@37906
|
606 |
"--------- init_form, start with <NEW> (CAS input) ---------------";
|
neuper@37906
|
607 |
"--------- init_form, start with <NEW> (CAS input) ---------------";
|
neuper@37906
|
608 |
states:=[];
|
neuper@37906
|
609 |
CalcTree [([], ("e_domID", ["e_pblID"], ["e_metID"]))];
|
neuper@37906
|
610 |
(*[[from sml: > @@@@@begin@@@@@
|
neuper@37906
|
611 |
[[from sml: 1
|
neuper@37906
|
612 |
[[from sml: <CALCTREE>
|
neuper@37906
|
613 |
[[from sml: <CALCID> 1 </CALCID>
|
neuper@37906
|
614 |
[[from sml: </CALCTREE>
|
neuper@37906
|
615 |
[[from sml: @@@@@end@@@@@*)
|
neuper@37906
|
616 |
Iterator 1;
|
neuper@37906
|
617 |
(*[[from sml: > @@@@@begin@@@@@
|
neuper@37906
|
618 |
[[from sml: 1
|
neuper@37906
|
619 |
[[from sml: <ADDUSER>
|
neuper@37906
|
620 |
[[from sml: <CALCID> 1 </CALCID>
|
neuper@37906
|
621 |
[[from sml: <USERID> 1 </USERID>
|
neuper@37906
|
622 |
[[from sml: </ADDUSER>
|
neuper@37906
|
623 |
[[from sml: @@@@@end@@@@@*)
|
neuper@37906
|
624 |
moveActiveRoot 1;
|
neuper@37906
|
625 |
(*[[from sml: > @@@@@begin@@@@@
|
neuper@37906
|
626 |
[[from sml: 1
|
neuper@37906
|
627 |
[[from sml: <CALCITERATOR>
|
neuper@37906
|
628 |
[[from sml: <CALCID> 1 </CALCID>
|
neuper@37906
|
629 |
[[from sml: <POSITION>
|
neuper@37906
|
630 |
[[from sml: <INTLIST>
|
neuper@37906
|
631 |
[[from sml: </INTLIST>
|
neuper@37906
|
632 |
[[from sml: <POS> Pbl </POS>
|
neuper@37906
|
633 |
[[from sml: </POSITION>
|
neuper@37906
|
634 |
[[from sml: </CALCITERATOR>
|
neuper@37906
|
635 |
[[from sml: @@@@@end@@@@@*)
|
neuper@37906
|
636 |
getFormulaeFromTo 1 ([],Pbl) ([],Pbl) 0 false;
|
neuper@37906
|
637 |
(*[[from sml: > @@@@@begin@@@@@ STILL CORRECT
|
neuper@37906
|
638 |
[[from sml: 1
|
neuper@37906
|
639 |
[[from sml: <GETELEMENTSFROMTO>
|
neuper@37906
|
640 |
[[from sml: <CALCID> 1 </CALCID>
|
neuper@37906
|
641 |
[[from sml: <FORMHEADS>
|
neuper@37906
|
642 |
[[from sml: <CALCFORMULA>
|
neuper@37906
|
643 |
[[from sml: <POSITION>
|
neuper@37906
|
644 |
[[from sml: <INTLIST>
|
neuper@37906
|
645 |
[[from sml: </INTLIST>
|
neuper@37906
|
646 |
[[from sml: <POS> Pbl </POS>
|
neuper@37906
|
647 |
[[from sml: </POSITION>
|
neuper@37906
|
648 |
[[from sml: <FORMULA>
|
neuper@37906
|
649 |
[[from sml: <MATHML>
|
neuper@37906
|
650 |
[[from sml: <ISA> ________________________________________________ </ISA>
|
neuper@37906
|
651 |
[[from sml: </MATHML>
|
neuper@37906
|
652 |
[[from sml:
|
neuper@37906
|
653 |
[[from sml: </FORMULA>
|
neuper@37906
|
654 |
[[from sml: </CALCFORMULA>
|
neuper@37906
|
655 |
[[from sml: </FORMHEADS>
|
neuper@37906
|
656 |
[[from sml: </GETELEMENTSFROMTO>
|
neuper@37906
|
657 |
[[from sml: @@@@@end@@@@@*)
|
neuper@37906
|
658 |
refFormula 1 ([],Pbl);
|
neuper@37906
|
659 |
(*[[from sml: > @@@@@begin@@@@@ STILL CORRECT
|
neuper@37906
|
660 |
[[from sml: 1
|
neuper@37906
|
661 |
[[from sml: <REFFORMULA>
|
neuper@37906
|
662 |
[[from sml: <CALCID> 1 </CALCID>
|
neuper@37906
|
663 |
[[from sml: <CALCHEAD status = "incorrect">
|
neuper@37906
|
664 |
[[from sml: <POSITION>
|
neuper@37906
|
665 |
[[from sml: <INTLIST>
|
neuper@37906
|
666 |
[[from sml: </INTLIST>
|
neuper@37906
|
667 |
[[from sml: <POS> Pbl </POS>
|
neuper@37906
|
668 |
[[from sml: </POSITION>
|
neuper@37906
|
669 |
[[from sml: <HEAD>
|
neuper@37906
|
670 |
[[from sml: <MATHML>
|
neuper@37906
|
671 |
[[from sml: <ISA> Problem (e_domID, [e_pblID]) </ISA>
|
neuper@37906
|
672 |
[[from sml: </MATHML>
|
neuper@37906
|
673 |
[[from sml: </HEAD>
|
neuper@37906
|
674 |
[[from sml: <MODEL>
|
neuper@37906
|
675 |
[[from sml: <GIVEN> </GIVEN>
|
neuper@37906
|
676 |
[[from sml: <WHERE> </WHERE>
|
neuper@37906
|
677 |
[[from sml: <FIND> </FIND>
|
neuper@37906
|
678 |
[[from sml: <RELATE> </RELATE>
|
neuper@37906
|
679 |
[[from sml: </MODEL>
|
neuper@37906
|
680 |
[[from sml: <BELONGSTO> Pbl </BELONGSTO>
|
neuper@37906
|
681 |
[[from sml: <SPECIFICATION>
|
neuper@37906
|
682 |
[[from sml: <THEORYID> e_domID </THEORYID>
|
neuper@37906
|
683 |
[[from sml: <PROBLEMID>
|
neuper@37906
|
684 |
[[from sml: <STRINGLIST>
|
neuper@37906
|
685 |
[[from sml: <STRING> e_pblID </STRING>
|
neuper@37906
|
686 |
[[from sml: </STRINGLIST>
|
neuper@37906
|
687 |
[[from sml: </PROBLEMID>
|
neuper@37906
|
688 |
[[from sml: <METHODID>
|
neuper@37906
|
689 |
[[from sml: <STRINGLIST>
|
neuper@37906
|
690 |
[[from sml: <STRING> e_metID </STRING>
|
neuper@37906
|
691 |
[[from sml: </STRINGLIST>
|
neuper@37906
|
692 |
[[from sml: </METHODID>
|
neuper@37906
|
693 |
[[from sml: </SPECIFICATION>
|
neuper@37906
|
694 |
[[from sml: </CALCHEAD>
|
neuper@37906
|
695 |
[[from sml: </REFFORMULA>
|
neuper@37906
|
696 |
[[from sml: @@@@@end@@@@@*)
|
neuper@37906
|
697 |
moveActiveFormula 1 ([],Pbl);
|
neuper@37906
|
698 |
(*[[from sml: > @@@@@begin@@@@@
|
neuper@37906
|
699 |
[[from sml: 1
|
neuper@37906
|
700 |
[[from sml: <CALCITERATOR>
|
neuper@37906
|
701 |
[[from sml: <CALCID> 1 </CALCID>
|
neuper@37906
|
702 |
[[from sml: <POSITION>
|
neuper@37906
|
703 |
[[from sml: <INTLIST>
|
neuper@37906
|
704 |
[[from sml: </INTLIST>
|
neuper@37906
|
705 |
[[from sml: <POS> Pbl </POS>
|
neuper@37906
|
706 |
[[from sml: </POSITION>
|
neuper@37906
|
707 |
[[from sml: </CALCITERATOR>
|
neuper@37906
|
708 |
[[from sml: @@@@@end@@@@@*)
|
neuper@37906
|
709 |
replaceFormula 1 "Simplify (1+2)";
|
neuper@37906
|
710 |
(*[[from sml: > @@@@@begin@@@@@
|
neuper@37906
|
711 |
[[from sml: 1
|
neuper@37906
|
712 |
[[from sml: <REPLACEFORMULA>
|
neuper@37906
|
713 |
[[from sml: <CALCID> 1 </CALCID>
|
neuper@37906
|
714 |
[[from sml: <CALCCHANGED>
|
neuper@37906
|
715 |
[[from sml: <UNCHANGED>
|
neuper@37906
|
716 |
[[from sml: <INTLIST>
|
neuper@37906
|
717 |
[[from sml: </INTLIST>
|
neuper@37906
|
718 |
[[from sml: <POS> Pbl </POS>
|
neuper@37906
|
719 |
[[from sml: </UNCHANGED>
|
neuper@37906
|
720 |
[[from sml: <DELETED>
|
neuper@37906
|
721 |
[[from sml: <INTLIST>
|
neuper@37906
|
722 |
[[from sml: </INTLIST>
|
neuper@37906
|
723 |
[[from sml: <POS> Pbl </POS>
|
neuper@37906
|
724 |
[[from sml: </DELETED>
|
neuper@37906
|
725 |
[[from sml: <GENERATED>
|
neuper@37906
|
726 |
[[from sml: <INTLIST>
|
neuper@37906
|
727 |
[[from sml: </INTLIST>
|
neuper@37906
|
728 |
[[from sml: <POS> Met </POS> DIFFERENCE: Pbl
|
neuper@37906
|
729 |
[[from sml: </GENERATED>
|
neuper@37906
|
730 |
[[from sml: </CALCCHANGED>
|
neuper@37906
|
731 |
[[from sml: </REPLACEFORMULA>
|
neuper@37906
|
732 |
[[from sml: @@@@@end@@@@@*)
|
neuper@37906
|
733 |
getFormulaeFromTo 1 ([],Pbl) ([],Pbl) 0 false(* DIFFERENCE: Pbl*);
|
neuper@37906
|
734 |
(*@@@@@begin@@@@@
|
neuper@37906
|
735 |
1
|
neuper@37906
|
736 |
<GETELEMENTSFROMTO>
|
neuper@37906
|
737 |
<CALCID> 1 </CALCID>
|
neuper@37906
|
738 |
<FORMHEADS>
|
neuper@37906
|
739 |
<CALCFORMULA>
|
neuper@37906
|
740 |
<POSITION>
|
neuper@37906
|
741 |
<INTLIST>
|
neuper@37906
|
742 |
</INTLIST>
|
neuper@37906
|
743 |
<POS> Pbl </POS>
|
neuper@37906
|
744 |
</POSITION>
|
neuper@37906
|
745 |
<FORMULA>
|
neuper@37906
|
746 |
<MATHML>
|
neuper@37906
|
747 |
<ISA> Simplify (1 + 2) </ISA> WORKS !!!!!
|
neuper@37906
|
748 |
</MATHML>
|
neuper@37906
|
749 |
</FORMULA>
|
neuper@37906
|
750 |
</CALCFORMULA>
|
neuper@37906
|
751 |
</FORMHEADS>
|
neuper@37906
|
752 |
</GETELEMENTSFROMTO>
|
neuper@37906
|
753 |
@@@@@end@@@@@*)
|
neuper@37906
|
754 |
getFormulaeFromTo 1 ([],Pbl) ([],Met) 0 false;
|
neuper@37906
|
755 |
(*[[from sml: > @@@@@begin@@@@@
|
neuper@37906
|
756 |
[[from sml: 1
|
neuper@37906
|
757 |
[[from sml: <SYSERROR>
|
neuper@37906
|
758 |
[[from sml: <CALCID> 1 </CALCID>
|
neuper@37906
|
759 |
[[from sml: <ERROR> error in getFormulaeFromTo </ERROR>
|
neuper@37906
|
760 |
[[from sml: </SYSERROR>
|
neuper@37906
|
761 |
[[from sml: @@@@@end@@@@@*)
|
neuper@37906
|
762 |
(*step into getFormulaeFromTo --- bug corrected...*)
|