wneuper@523
|
1 |
(* tests on inform.sml
|
wneuper@523
|
2 |
author: Walther Neuper
|
wneuper@523
|
3 |
060225,
|
wneuper@523
|
4 |
(c) due to copyright terms
|
wneuper@523
|
5 |
|
wneuper@523
|
6 |
use"../smltest/ME/inform.sml";
|
wneuper@523
|
7 |
use"inform.sml";
|
wneuper@523
|
8 |
*)
|
wneuper@523
|
9 |
|
wneuper@524
|
10 |
"-----------------------------------------------------------------";
|
wneuper@524
|
11 |
"table of contents -----------------------------------------------";
|
wneuper@524
|
12 |
"-----------------------------------------------------------------";
|
wneuper@523
|
13 |
"appendForm with miniscript with mini-subpbl:";
|
wneuper@523
|
14 |
"--------- appendFormula: on Res + equ_nrls ----------------------";
|
wneuper@523
|
15 |
"--------- appendFormula: on Frm + equ_nrls ----------------------";
|
wneuper@523
|
16 |
"--------- appendFormula: on Res + NO deriv ----------------------";
|
wneuper@523
|
17 |
"--------- appendFormula: on Res + late deriv --------------------";
|
wneuper@523
|
18 |
"--------- appendFormula: on Res + late deriv [x = 3 + -2]---///--";
|
wneuper@523
|
19 |
"replaceForm with miniscript with mini-subpbl:";
|
wneuper@523
|
20 |
"--------- replaceFormula: on Res + = ----------------------------";
|
wneuper@523
|
21 |
"--------- replaceFormula: on Res + = 1st Nd ---------------------";
|
wneuper@523
|
22 |
"--------- replaceFormula: on Frm + = 1st Nd ---------------------";
|
wneuper@523
|
23 |
"--------- replaceFormula: cut calculation -----------------------";
|
wneuper@523
|
24 |
"--------- replaceFormula: cut calculation -----------------------";
|
wneuper@525
|
25 |
(* 040307 copied from informtest.sml ... old versions
|
wneuper@524
|
26 |
"--------- maximum-example, UC: Modeling / modifyCalcHead --------";*)
|
wneuper@533
|
27 |
"--------- syntax error ------------------------------------------";
|
wneuper@524
|
28 |
"CAS-command:";
|
wneuper@527
|
29 |
"--------- CAS-command on ([],Pbl) -------------------------------";
|
wneuper@527
|
30 |
"--------- CAS-command on ([],Pbl) FE-interface ------------------";
|
wneuper@669
|
31 |
"--------- inform [rational,simplification] ----------------------";
|
wneuper@524
|
32 |
"-----------------------------------------------------------------";
|
wneuper@524
|
33 |
"-----------------------------------------------------------------";
|
wneuper@524
|
34 |
"-----------------------------------------------------------------";
|
wneuper@523
|
35 |
|
wneuper@523
|
36 |
|
wneuper@523
|
37 |
|
wneuper@523
|
38 |
|
wneuper@523
|
39 |
|
wneuper@523
|
40 |
|
wneuper@523
|
41 |
"--------- appendFormula: on Res + equ_nrls ----------------------";
|
wneuper@523
|
42 |
"--------- appendFormula: on Res + equ_nrls ----------------------";
|
wneuper@523
|
43 |
"--------- appendFormula: on Res + equ_nrls ----------------------";
|
wneuper@523
|
44 |
val Script sc = (#scr o get_met) ["Test","squ-equ-test-subpbl1"];
|
wneuper@523
|
45 |
(writeln o term2str) sc;
|
wneuper@523
|
46 |
val Script sc = (#scr o get_met) ["Test","solve_linear"];
|
wneuper@523
|
47 |
(writeln o term2str) sc;
|
wneuper@523
|
48 |
|
wneuper@523
|
49 |
states:=[];
|
wneuper@523
|
50 |
CalcTree [(["equality (x+1=2)", "solveFor x","solutions L"],
|
wneuper@523
|
51 |
("Test.thy",
|
wneuper@523
|
52 |
["sqroot-test","univariate","equation","test"],
|
wneuper@523
|
53 |
["Test","squ-equ-test-subpbl1"]))];
|
wneuper@523
|
54 |
Iterator 1; moveActiveRoot 1;
|
wneuper@523
|
55 |
autoCalculate 1 CompleteCalcHead;
|
wneuper@523
|
56 |
autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
|
wneuper@523
|
57 |
autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
|
wneuper@523
|
58 |
|
wneuper@523
|
59 |
appendFormula 1 "-2 * 1 + (1 + x) = 0"; refFormula 1 (get_pos 1 1);
|
wneuper@523
|
60 |
val ((pt,_),_) = get_calc 1;
|
wneuper@523
|
61 |
val str = pr_ptree pr_short pt;
|
wneuper@523
|
62 |
writeln str;
|
wneuper@523
|
63 |
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 ()
|
wneuper@525
|
64 |
else raise error "inform.sml: diff.behav.appendFormula: on Res + equ 1";
|
wneuper@523
|
65 |
|
wneuper@523
|
66 |
moveDown 1 ([ ],Pbl); refFormula 1 ([1],Frm); (*x + 1 = 2*)
|
wneuper@523
|
67 |
moveDown 1 ([1],Frm); refFormula 1 ([1],Res); (*x + 1 + -1 * 2 = 0*)
|
wneuper@523
|
68 |
|
wneuper@523
|
69 |
(*the seven steps of detailed derivation*)
|
wneuper@523
|
70 |
moveDown 1 ([1 ],Res); refFormula 1 ([2,1],Frm);
|
wneuper@523
|
71 |
moveDown 1 ([2,1],Frm); refFormula 1 ([2,1],Res);
|
wneuper@523
|
72 |
moveDown 1 ([2,1],Res); refFormula 1 ([2,2],Res);
|
wneuper@523
|
73 |
moveDown 1 ([2,2],Res); refFormula 1 ([2,3],Res);
|
wneuper@523
|
74 |
moveDown 1 ([2,3],Res); refFormula 1 ([2,4],Res);
|
wneuper@523
|
75 |
moveDown 1 ([2,4],Res); refFormula 1 ([2,5],Res);
|
wneuper@523
|
76 |
moveDown 1 ([2,5],Res); refFormula 1 ([2,6],Res);
|
wneuper@523
|
77 |
val ((pt,_),_) = get_calc 1;
|
wneuper@523
|
78 |
if "-2 * 1 + (1 + x) = 0" = term2str (fst (get_obj g_result pt [2,6])) then()
|
wneuper@525
|
79 |
else raise error "inform.sml: diff.behav.appendFormula: on Res + equ 2";
|
wneuper@523
|
80 |
|
wneuper@523
|
81 |
fetchProposedTactic 1; (*takes Iterator 1 _1_*)
|
wneuper@523
|
82 |
val (_,(tac,_,_)::_) = get_calc 1;
|
wneuper@523
|
83 |
if tac = Rewrite_Set "Test_simplify" then ()
|
wneuper@525
|
84 |
else raise error "inform.sml: diff.behav.appendFormula: on Res + equ 3";
|
wneuper@523
|
85 |
autoCalculate 1 CompleteCalc;
|
wneuper@523
|
86 |
val ((pt,_),_) = get_calc 1;
|
wneuper@523
|
87 |
if "[x = 1]" = term2str (fst (get_obj g_result pt [])) then ()
|
wneuper@525
|
88 |
else raise error "inform.sml: diff.behav.appendFormula: on Res + equ 4";
|
wneuper@523
|
89 |
(* autoCalculate 1 CompleteCalc;
|
wneuper@523
|
90 |
val ((pt,p),_) = get_calc 1;
|
wneuper@523
|
91 |
(writeln o istates2str) (get_obj g_loc pt [ ]);
|
wneuper@523
|
92 |
(writeln o istates2str) (get_obj g_loc pt [1]);
|
wneuper@523
|
93 |
(writeln o istates2str) (get_obj g_loc pt [2]);
|
wneuper@523
|
94 |
(writeln o istates2str) (get_obj g_loc pt [3]);
|
wneuper@523
|
95 |
(writeln o istates2str) (get_obj g_loc pt [3,1]);
|
wneuper@523
|
96 |
(writeln o istates2str) (get_obj g_loc pt [3,2]);
|
wneuper@523
|
97 |
(writeln o istates2str) (get_obj g_loc pt [4]);
|
wneuper@523
|
98 |
|
wneuper@523
|
99 |
*)
|
wneuper@523
|
100 |
"----------------------------------------------------------";
|
wneuper@523
|
101 |
val fod = make_deriv Isac.thy Atools_erls
|
wneuper@523
|
102 |
((#rules o rep_rls) Test_simplify)
|
wneuper@523
|
103 |
(sqrt_right false ProtoPure.thy) None
|
wneuper@523
|
104 |
(str2term "x + 1 + -1 * 2 = 0");
|
wneuper@523
|
105 |
(writeln o trtas2str) fod;
|
wneuper@523
|
106 |
|
wneuper@523
|
107 |
val ifod = make_deriv Isac.thy Atools_erls
|
wneuper@523
|
108 |
((#rules o rep_rls) Test_simplify)
|
wneuper@523
|
109 |
(sqrt_right false ProtoPure.thy) None
|
wneuper@523
|
110 |
(str2term "-2 * 1 + (1 + x) = 0");
|
wneuper@523
|
111 |
(writeln o trtas2str) ifod;
|
wneuper@523
|
112 |
fun equal (_,_,(t1, _)) (_,_,(t2, _)) = t1=t2;
|
wneuper@523
|
113 |
val (fod', rifod') = dropwhile' equal (rev fod) (rev ifod);
|
wneuper@523
|
114 |
val der = fod' @ (map rev_deriv' rifod');
|
wneuper@523
|
115 |
(writeln o trtas2str) der;
|
wneuper@523
|
116 |
"----------------------------------------------------------";
|
wneuper@523
|
117 |
|
wneuper@523
|
118 |
|
wneuper@523
|
119 |
"--------- appendFormula: on Frm + equ_nrls ----------------------";
|
wneuper@523
|
120 |
"--------- appendFormula: on Frm + equ_nrls ----------------------";
|
wneuper@523
|
121 |
"--------- appendFormula: on Frm + equ_nrls ----------------------";
|
wneuper@523
|
122 |
states:=[];
|
wneuper@523
|
123 |
CalcTree [(["equality (x+1=2)", "solveFor x","solutions L"],
|
wneuper@523
|
124 |
("Test.thy",
|
wneuper@523
|
125 |
["sqroot-test","univariate","equation","test"],
|
wneuper@523
|
126 |
["Test","squ-equ-test-subpbl1"]))];
|
wneuper@523
|
127 |
Iterator 1; moveActiveRoot 1;
|
wneuper@523
|
128 |
autoCalculate 1 CompleteCalcHead;
|
wneuper@523
|
129 |
autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1) (*x + 1 = 2*);
|
wneuper@523
|
130 |
|
wneuper@523
|
131 |
appendFormula 1 "2+ -1 + x = 2"; refFormula 1 (get_pos 1 1);
|
wneuper@523
|
132 |
|
wneuper@523
|
133 |
moveDown 1 ([],Pbl); refFormula 1 ([1],Frm) (*x + 1 = 2*);
|
wneuper@523
|
134 |
|
wneuper@523
|
135 |
moveDown 1 ([1 ],Frm); refFormula 1 ([1,1],Frm);
|
wneuper@523
|
136 |
moveDown 1 ([1,1],Frm); refFormula 1 ([1,1],Res);
|
wneuper@523
|
137 |
moveDown 1 ([1,1],Res); refFormula 1 ([1,2],Res);
|
wneuper@523
|
138 |
moveDown 1 ([1,2],Res); refFormula 1 ([1,3],Res);
|
wneuper@523
|
139 |
moveDown 1 ([1,3],Res); refFormula 1 ([1,4],Res);
|
wneuper@523
|
140 |
moveDown 1 ([1,4],Res); refFormula 1 ([1,5],Res);
|
wneuper@523
|
141 |
moveDown 1 ([1,5],Res); refFormula 1 ([1,6],Res);
|
wneuper@523
|
142 |
val ((pt,_),_) = get_calc 1;
|
wneuper@523
|
143 |
if "2 + -1 + x = 2" = term2str (fst (get_obj g_result pt [1,6])) then()
|
wneuper@525
|
144 |
else raise error "inform.sml: diff.behav.appendFormula: on Frm + equ 1";
|
wneuper@523
|
145 |
|
wneuper@523
|
146 |
fetchProposedTactic 1; (*takes Iterator 1 _1_*)
|
wneuper@523
|
147 |
val (_,(tac,_,_)::_) = get_calc 1;
|
wneuper@523
|
148 |
if tac = Rewrite_Set "norm_equation" then ()
|
wneuper@525
|
149 |
else raise error "inform.sml: diff.behav.appendFormula: on Frm + equ 2";
|
wneuper@523
|
150 |
autoCalculate 1 CompleteCalc;
|
wneuper@523
|
151 |
val ((pt,_),_) = get_calc 1;
|
wneuper@523
|
152 |
if "[x = 1]" = term2str (fst (get_obj g_result pt [])) then ()
|
wneuper@525
|
153 |
else raise error "inform.sml: diff.behav.appendFormula: on Frm + equ 3";
|
wneuper@523
|
154 |
|
wneuper@523
|
155 |
|
wneuper@523
|
156 |
"--------- appendFormula: on Res + NO deriv ----------------------";
|
wneuper@523
|
157 |
"--------- appendFormula: on Res + NO deriv ----------------------";
|
wneuper@523
|
158 |
"--------- appendFormula: on Res + NO deriv ----------------------";
|
wneuper@523
|
159 |
states:=[];
|
wneuper@523
|
160 |
CalcTree [(["equality (x+1=2)", "solveFor x","solutions L"],
|
wneuper@523
|
161 |
("Test.thy",
|
wneuper@523
|
162 |
["sqroot-test","univariate","equation","test"],
|
wneuper@523
|
163 |
["Test","squ-equ-test-subpbl1"]))];
|
wneuper@523
|
164 |
Iterator 1; moveActiveRoot 1;
|
wneuper@523
|
165 |
autoCalculate 1 CompleteCalcHead;
|
wneuper@523
|
166 |
autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
|
wneuper@523
|
167 |
autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
|
wneuper@523
|
168 |
|
wneuper@523
|
169 |
appendFormula 1 "x = 2";
|
wneuper@523
|
170 |
val ((pt,p),_) = get_calc 1;
|
wneuper@523
|
171 |
val str = pr_ptree pr_short pt;
|
wneuper@523
|
172 |
writeln str;
|
wneuper@523
|
173 |
if str = ". ----- pblobj -----\n1. x + 1 = 2\n" andalso p = ([1], Res)
|
wneuper@523
|
174 |
then ()
|
wneuper@525
|
175 |
else raise error "inform.sml: diff.behav.appendFormula: Res + NOder 1";
|
wneuper@523
|
176 |
|
wneuper@523
|
177 |
fetchProposedTactic 1;
|
wneuper@523
|
178 |
val (_,(tac,_,_)::_) = get_calc 1;
|
wneuper@523
|
179 |
if tac = Rewrite_Set "Test_simplify" then ()
|
wneuper@525
|
180 |
else raise error "inform.sml: diff.behav.appendFormula: Res + NOder 2";
|
wneuper@523
|
181 |
autoCalculate 1 CompleteCalc;
|
wneuper@523
|
182 |
val ((pt,_),_) = get_calc 1;
|
wneuper@523
|
183 |
if "[x = 1]" = term2str (fst (get_obj g_result pt [])) then ()
|
wneuper@525
|
184 |
else raise error "inform.sml: diff.behav.appendFormula: on Frm + equ 3";
|
wneuper@523
|
185 |
|
wneuper@523
|
186 |
|
wneuper@523
|
187 |
"--------- appendFormula: on Res + late deriv --------------------";
|
wneuper@523
|
188 |
"--------- appendFormula: on Res + late deriv --------------------";
|
wneuper@523
|
189 |
"--------- appendFormula: on Res + late deriv --------------------";
|
wneuper@523
|
190 |
states:=[];
|
wneuper@523
|
191 |
CalcTree [(["equality (x+1=2)", "solveFor x","solutions L"],
|
wneuper@523
|
192 |
("Test.thy",
|
wneuper@523
|
193 |
["sqroot-test","univariate","equation","test"],
|
wneuper@523
|
194 |
["Test","squ-equ-test-subpbl1"]))];
|
wneuper@523
|
195 |
Iterator 1; moveActiveRoot 1;
|
wneuper@523
|
196 |
autoCalculate 1 CompleteCalcHead;
|
wneuper@523
|
197 |
autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
|
wneuper@523
|
198 |
autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
|
wneuper@523
|
199 |
|
wneuper@523
|
200 |
appendFormula 1 "x = 1";
|
wneuper@523
|
201 |
val ((pt,p),_) = get_calc 1;
|
wneuper@523
|
202 |
val str = pr_ptree pr_short pt;
|
wneuper@523
|
203 |
writeln str;
|
wneuper@523
|
204 |
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)
|
wneuper@523
|
205 |
then () (*finds 1 step too early: ([3,2], Res) "x = 1" also by script !!!*)
|
wneuper@525
|
206 |
else raise error "inform.sml: diff.behav.appendFormula: Res + late d 1";
|
wneuper@523
|
207 |
|
wneuper@523
|
208 |
fetchProposedTactic 1;
|
wneuper@523
|
209 |
val (_,(tac,_,_)::_) = get_calc 1;
|
wneuper@523
|
210 |
if tac = Check_Postcond ["linear", "univariate", "equation", "test"] then ()
|
wneuper@525
|
211 |
else raise error "inform.sml: diff.behav.appendFormula: Res + late d 2";
|
wneuper@523
|
212 |
autoCalculate 1 CompleteCalc;
|
wneuper@523
|
213 |
val ((pt,_),_) = get_calc 1;
|
wneuper@523
|
214 |
if "[x = 1]" = term2str (fst (get_obj g_result pt [])) then ()
|
wneuper@525
|
215 |
else raise error "inform.sml: diff.behav.appendFormula: Res + late d 3";
|
wneuper@523
|
216 |
|
wneuper@523
|
217 |
|
wneuper@523
|
218 |
"--------- appendFormula: on Res + late deriv [x = 3 + -2]---///--";
|
wneuper@523
|
219 |
"--------- appendFormula: on Res + late deriv [x = 3 + -2]---///--";
|
wneuper@523
|
220 |
"--------- appendFormula: on Res + late deriv [x = 3 + -2]---///--";
|
wneuper@523
|
221 |
states:=[];
|
wneuper@523
|
222 |
CalcTree [(["equality (x+1=2)", "solveFor x","solutions L"],
|
wneuper@523
|
223 |
("Test.thy",
|
wneuper@523
|
224 |
["sqroot-test","univariate","equation","test"],
|
wneuper@523
|
225 |
["Test","squ-equ-test-subpbl1"]))];
|
wneuper@523
|
226 |
Iterator 1; moveActiveRoot 1;
|
wneuper@523
|
227 |
autoCalculate 1 CompleteCalcHead;
|
wneuper@523
|
228 |
autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
|
wneuper@523
|
229 |
autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
|
wneuper@523
|
230 |
appendFormula 1 "[x = 3 + -2*1]";
|
wneuper@523
|
231 |
val ((pt,p),_) = get_calc 1;
|
wneuper@523
|
232 |
val str = pr_ptree pr_short pt;
|
wneuper@523
|
233 |
writeln str;
|
wneuper@523
|
234 |
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 ()
|
wneuper@525
|
235 |
else raise error "inform.sml: diff.behav.appendFormula: Res + latEE 1";
|
wneuper@523
|
236 |
autoCalculate 1 CompleteCalc;
|
wneuper@523
|
237 |
val ((pt,p),_) = get_calc 1;
|
wneuper@523
|
238 |
if "[x = 3 + -2 * 1]" = term2str (fst (get_obj g_result pt [])) then ()
|
wneuper@523
|
239 |
(* ~~~~~~~~~~ simplify as last step in any script ?!*)
|
wneuper@525
|
240 |
else raise error "inform.sml: diff.behav.appendFormula: Res + latEE 2";
|
wneuper@523
|
241 |
|
wneuper@523
|
242 |
|
wneuper@523
|
243 |
|
wneuper@523
|
244 |
"--------- replaceFormula: on Res + = ----------------------------";
|
wneuper@523
|
245 |
"--------- replaceFormula: on Res + = ----------------------------";
|
wneuper@523
|
246 |
"--------- replaceFormula: on Res + = ----------------------------";
|
wneuper@523
|
247 |
states:=[];
|
wneuper@523
|
248 |
CalcTree [(["equality (x+1=2)", "solveFor x","solutions L"],
|
wneuper@523
|
249 |
("Test.thy",
|
wneuper@523
|
250 |
["sqroot-test","univariate","equation","test"],
|
wneuper@523
|
251 |
["Test","squ-equ-test-subpbl1"]))];
|
wneuper@523
|
252 |
Iterator 1; moveActiveRoot 1;
|
wneuper@523
|
253 |
autoCalculate 1 CompleteCalcHead;
|
wneuper@523
|
254 |
autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
|
wneuper@523
|
255 |
autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
|
wneuper@523
|
256 |
autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*-1 + x*);
|
wneuper@523
|
257 |
|
wneuper@523
|
258 |
replaceFormula 1 "-2 * 1 + (1 + x) = 0"; refFormula 1 (get_pos 1 1);
|
wneuper@523
|
259 |
val ((pt,_),_) = get_calc 1;
|
wneuper@523
|
260 |
val str = pr_ptree pr_short pt;
|
wneuper@523
|
261 |
writeln str;
|
wneuper@523
|
262 |
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()
|
wneuper@525
|
263 |
else raise error "inform.sml: diff.behav.replaceFormula: on Res += 1";
|
wneuper@523
|
264 |
autoCalculate 1 CompleteCalc;
|
wneuper@523
|
265 |
val ((pt,pos as(p,_)),_) = get_calc 1;
|
wneuper@523
|
266 |
if pos=([],Res)andalso"[x = 1]"=(term2str o fst)(get_obj g_result pt p)then()
|
wneuper@525
|
267 |
else raise error "inform.sml: diff.behav.replaceFormula: on Res + = 2";
|
wneuper@523
|
268 |
|
wneuper@523
|
269 |
|
wneuper@523
|
270 |
"--------- replaceFormula: on Res + = 1st Nd ---------------------";
|
wneuper@523
|
271 |
"--------- replaceFormula: on Res + = 1st Nd ---------------------";
|
wneuper@523
|
272 |
"--------- replaceFormula: on Res + = 1st Nd ---------------------";
|
wneuper@523
|
273 |
states:=[];
|
wneuper@523
|
274 |
CalcTree [(["equality (x+1=2)", "solveFor x","solutions L"],
|
wneuper@523
|
275 |
("Test.thy",
|
wneuper@523
|
276 |
["sqroot-test","univariate","equation","test"],
|
wneuper@523
|
277 |
["Test","squ-equ-test-subpbl1"]))];
|
wneuper@523
|
278 |
Iterator 1; moveActiveRoot 1;
|
wneuper@523
|
279 |
autoCalculate 1 CompleteCalcHead;
|
wneuper@523
|
280 |
autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
|
wneuper@523
|
281 |
autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
|
wneuper@523
|
282 |
|
wneuper@523
|
283 |
replaceFormula 1 "x + 1 = 4 + -2"; refFormula 1 (get_pos 1 1);
|
wneuper@523
|
284 |
val ((pt,_),_) = get_calc 1;
|
wneuper@523
|
285 |
val str = pr_ptree pr_short pt;
|
wneuper@523
|
286 |
writeln str;
|
wneuper@523
|
287 |
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 ()
|
wneuper@525
|
288 |
else raise error "inform.sml: diff.behav.replaceFormula: on Res 1 + = 1";
|
wneuper@523
|
289 |
autoCalculate 1 CompleteCalc;
|
wneuper@523
|
290 |
val ((pt,pos as(p,_)),_) = get_calc 1;
|
wneuper@523
|
291 |
if pos=([],Res)andalso"[x = 1]"=(term2str o fst)(get_obj g_result pt p)then()
|
wneuper@525
|
292 |
else raise error "inform.sml: diff.behav.replaceFormula: on Res + = 2";
|
wneuper@523
|
293 |
|
wneuper@523
|
294 |
|
wneuper@523
|
295 |
"--------- replaceFormula: on Frm + = 1st Nd ---------------------";
|
wneuper@523
|
296 |
"--------- replaceFormula: on Frm + = 1st Nd ---------------------";
|
wneuper@523
|
297 |
"--------- replaceFormula: on Frm + = 1st Nd ---------------------";
|
wneuper@523
|
298 |
states:=[];
|
wneuper@523
|
299 |
CalcTree [(["equality (x+1=2)", "solveFor x","solutions L"],
|
wneuper@523
|
300 |
("Test.thy",
|
wneuper@523
|
301 |
["sqroot-test","univariate","equation","test"],
|
wneuper@523
|
302 |
["Test","squ-equ-test-subpbl1"]))];
|
wneuper@523
|
303 |
Iterator 1; moveActiveRoot 1;
|
wneuper@523
|
304 |
autoCalculate 1 CompleteCalcHead;
|
wneuper@523
|
305 |
autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
|
wneuper@523
|
306 |
|
wneuper@523
|
307 |
replaceFormula 1 "x + 1 = 4 + -2"; refFormula 1 (get_pos 1 1);
|
wneuper@523
|
308 |
val ((pt,_),_) = get_calc 1;
|
wneuper@523
|
309 |
val str = pr_ptree pr_short pt;
|
wneuper@523
|
310 |
writeln str;
|
wneuper@523
|
311 |
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 ()
|
wneuper@525
|
312 |
else raise error "inform.sml: diff.behav.replaceFormula: on Frm 1 + = 1";
|
wneuper@523
|
313 |
autoCalculate 1 CompleteCalc;
|
wneuper@523
|
314 |
val ((pt,pos as(p,_)),_) = get_calc 1;
|
wneuper@523
|
315 |
if pos=([],Res)andalso"[x = 1]"=(term2str o fst)(get_obj g_result pt p)then()
|
wneuper@525
|
316 |
else raise error "inform.sml: diff.behav.replaceFormula: on Frm 1 + = 2";
|
wneuper@523
|
317 |
|
wneuper@523
|
318 |
|
wneuper@523
|
319 |
"--------- replaceFormula: cut calculation -----------------------";
|
wneuper@523
|
320 |
"--------- replaceFormula: cut calculation -----------------------";
|
wneuper@523
|
321 |
"--------- replaceFormula: cut calculation -----------------------";
|
wneuper@523
|
322 |
states:=[];
|
wneuper@523
|
323 |
CalcTree [(["equality (x+1=2)", "solveFor x","solutions L"],
|
wneuper@523
|
324 |
("Test.thy",
|
wneuper@523
|
325 |
["sqroot-test","univariate","equation","test"],
|
wneuper@523
|
326 |
["Test","squ-equ-test-subpbl1"]))];
|
wneuper@523
|
327 |
Iterator 1; moveActiveRoot 1;
|
wneuper@523
|
328 |
autoCalculate 1 CompleteCalc;
|
wneuper@523
|
329 |
moveActiveRoot 1; moveActiveDown 1;
|
wneuper@523
|
330 |
if get_pos 1 1 = ([1], Frm) then ()
|
wneuper@525
|
331 |
else raise error "inform.sml: diff.behav. cut calculation 1";
|
wneuper@523
|
332 |
|
wneuper@523
|
333 |
replaceFormula 1 "x + 1 = 4 + -2"; refFormula 1 (get_pos 1 1);
|
wneuper@523
|
334 |
val ((pt,p),_) = get_calc 1;
|
wneuper@523
|
335 |
val str = pr_ptree pr_short pt;
|
wneuper@523
|
336 |
writeln str;
|
wneuper@523
|
337 |
if p = ([1], Res) then ()
|
wneuper@525
|
338 |
else raise error "inform.sml: diff.behav. cut calculation 2";
|
wneuper@523
|
339 |
|
wneuper@523
|
340 |
|
wneuper@523
|
341 |
|
wneuper@523
|
342 |
(* 040307 copied from informtest.sml; ... old version
|
wneuper@523
|
343 |
"---------------- maximum-example, UC: Modeling / modifyCalcHead -";
|
wneuper@523
|
344 |
"---------------- maximum-example, UC: Modeling / modifyCalcHead -";
|
wneuper@523
|
345 |
"---------------- maximum-example, UC: Modeling / modifyCalcHead -";
|
wneuper@523
|
346 |
|
wneuper@523
|
347 |
val p = ([],Pbl);
|
wneuper@523
|
348 |
val elems = ["fixedValues [r=Arbfix]","maximum A","valuesFor [a,b]",
|
wneuper@523
|
349 |
"relations [A=a*b, (a/2)^^^2 + (b/2)^^^2 = r^^^2]",
|
wneuper@523
|
350 |
"relations [A=a*b, (a/2)^^^2 + (b/2)^^^2 = r^^^2]",
|
wneuper@523
|
351 |
"relations [A=a*b, a/2=r*sin alpha, b/2=r*cos alpha]",
|
wneuper@523
|
352 |
(*^^^ these are the elements for the root-problem (in variants)*)
|
wneuper@523
|
353 |
(*vvv these are elements required for subproblems*)
|
wneuper@523
|
354 |
"boundVariable a","boundVariable b","boundVariable alpha",
|
wneuper@523
|
355 |
"interval {x::real. 0 <= x & x <= 2*r}",
|
wneuper@523
|
356 |
"interval {x::real. 0 <= x & x <= 2*r}",
|
wneuper@523
|
357 |
"interval {x::real. 0 <= x & x <= pi}",
|
wneuper@523
|
358 |
"errorBound (eps=(0::real))"]
|
wneuper@523
|
359 |
(*specifying is not interesting for this example*)
|
wneuper@523
|
360 |
val spec = ("DiffApp.thy", ["maximum_of","function"],
|
wneuper@523
|
361 |
["DiffApp","max_by_calculus"]);
|
wneuper@523
|
362 |
(*the empty model with descriptions for user-guidance by Model_Problem*)
|
wneuper@523
|
363 |
val empty_model = [Given ["fixedValues []"],
|
wneuper@523
|
364 |
Find ["maximum", "valuesFor"],
|
wneuper@523
|
365 |
Relate ["relations []"]];
|
wneuper@523
|
366 |
|
wneuper@523
|
367 |
|
wneuper@523
|
368 |
(*!!!!!!!!!!!!!!!!! DON'T USE me FOR FINDING nxt !!!!!!!!!!!!!!!!!!*)
|
wneuper@523
|
369 |
val (p,_,f,nxt,_,pt) = CalcTreeTEST [(elems, spec)];
|
wneuper@523
|
370 |
(*val nxt = ("Model_Problem", ...*)
|
wneuper@523
|
371 |
val pbl = get_obj g_pbl pt (fst p); (writeln o (itms2str thy)) pbl;
|
wneuper@523
|
372 |
|
wneuper@523
|
373 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
wneuper@523
|
374 |
(*nxt = Add_Given "fixedValues [r = Arbfix]"*)
|
wneuper@523
|
375 |
val pbl = get_obj g_pbl pt (fst p); (writeln o (itms2str thy)) pbl;
|
wneuper@523
|
376 |
(*[
|
wneuper@523
|
377 |
(0 ,[] ,false ,#Given ,Inc fixedValues [] ,(??.empty, [])),
|
wneuper@523
|
378 |
(0 ,[] ,false ,#Find ,Inc maximum ,(??.empty, [])),
|
wneuper@523
|
379 |
(0 ,[] ,false ,#Find ,Inc valuesFor ,(??.empty, [])),
|
wneuper@523
|
380 |
(0 ,[] ,false ,#Relate ,Inc relations [] ,(??.empty, []))]*)
|
wneuper@523
|
381 |
|
wneuper@523
|
382 |
(*the empty CalcHead is checked w.r.t the model and re-established as such*)
|
wneuper@523
|
383 |
val (b,pt,ocalhd) = input_icalhd pt (p,"", empty_model, Pbl, e_spec);
|
wneuper@523
|
384 |
val pbl = get_obj g_pbl pt (fst p); (writeln o (itms2str thy)) pbl;
|
wneuper@523
|
385 |
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 raise error "informtest.sml: diff.behav. max 1";
|
wneuper@523
|
386 |
|
wneuper@523
|
387 |
(*there is one input to the model (could be more)*)
|
wneuper@523
|
388 |
val (b,pt,ocalhd) =
|
wneuper@523
|
389 |
input_icalhd pt (p,"", [Given ["fixedValues [r=Arbfix]"],
|
wneuper@523
|
390 |
Find ["maximum", "valuesFor"],
|
wneuper@523
|
391 |
Relate ["relations"]], Pbl, e_spec);
|
wneuper@523
|
392 |
val pbl = get_obj g_pbl pt (fst p); (writeln o (itms2str thy)) pbl;
|
wneuper@523
|
393 |
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 ()
|
wneuper@523
|
394 |
else raise error "informtest.sml: diff.behav. max 2";
|
wneuper@523
|
395 |
|
wneuper@523
|
396 |
(*this input is complete in variant 3, but the ME doesn't recognize FIXXXXME
|
wneuper@523
|
397 |
val (b,pt''''',ocalhd) =
|
wneuper@523
|
398 |
input_icalhd pt (p,"", [Given ["fixedValues [r=Arbfix]"],
|
wneuper@523
|
399 |
Find ["maximum A", "valuesFor [a,b]"],
|
wneuper@523
|
400 |
Relate ["relations [A=a*b, a/2=r*sin alpha, \
|
wneuper@523
|
401 |
\b/2=r*cos alpha]"]], Pbl, e_spec);
|
wneuper@523
|
402 |
val pbl = get_obj g_pbl pt''''' (fst p); (writeln o (itms2str thy)) pbl;
|
wneuper@663
|
403 |
if ocalhd2str ocalhd = ------------^^^^^^^^^^ missing !!!*)
|
wneuper@523
|
404 |
|
wneuper@523
|
405 |
(*this input is complete in variant 1 (variant 3 does not work yet)*)
|
wneuper@523
|
406 |
val (b,pt''''',ocalhd) =
|
wneuper@523
|
407 |
input_icalhd pt (p,"", [Given ["fixedValues [r=Arbfix]"],
|
wneuper@523
|
408 |
Find ["maximum A", "valuesFor [a,b]"],
|
wneuper@523
|
409 |
Relate ["relations [A=a*b, \
|
wneuper@523
|
410 |
\(a/2)^^^2 + (b/2)^^^2 = r^^^2]"]],
|
wneuper@523
|
411 |
Pbl, e_spec);
|
wneuper@523
|
412 |
val pbl = get_obj g_pbl pt''''' (fst p); (writeln o (itms2str thy)) pbl;
|
wneuper@523
|
413 |
|
wneuper@523
|
414 |
modifycalcheadOK2xml 111 (bool2str b) ocalhd;
|
wneuper@524
|
415 |
*)
|
wneuper@524
|
416 |
|
wneuper@533
|
417 |
"--------- syntax error ------------------------------------------";
|
wneuper@533
|
418 |
"--------- syntax error ------------------------------------------";
|
wneuper@533
|
419 |
"--------- syntax error ------------------------------------------";
|
wneuper@533
|
420 |
states:=[];
|
wneuper@533
|
421 |
CalcTree [(["equality (x+1=2)", "solveFor x","solutions L"],
|
wneuper@533
|
422 |
("Test.thy",
|
wneuper@533
|
423 |
["sqroot-test","univariate","equation","test"],
|
wneuper@533
|
424 |
["Test","squ-equ-test-subpbl1"]))];
|
wneuper@533
|
425 |
Iterator 1; moveActiveRoot 1;
|
wneuper@533
|
426 |
autoCalculate 1 CompleteCalcHead;
|
wneuper@533
|
427 |
autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
|
wneuper@533
|
428 |
autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
|
wneuper@533
|
429 |
|
wneuper@533
|
430 |
appendFormula 1 " x - "; (*<ERROR> syntax error in ' x - ' </ERROR>*)
|
wneuper@533
|
431 |
val ((pt,_),_) = get_calc 1;
|
wneuper@533
|
432 |
val str = pr_ptree pr_short pt;
|
wneuper@533
|
433 |
writeln str;
|
wneuper@533
|
434 |
if str = ". ----- pblobj -----\n1. x + 1 = 2\n" then ()
|
wneuper@533
|
435 |
else raise error "inform.sml: diff.behav.appendFormula: syntax error";
|
wneuper@533
|
436 |
|
wneuper@525
|
437 |
|
wneuper@527
|
438 |
"--------- CAS-command on ([],Pbl) -------------------------------";
|
wneuper@527
|
439 |
"--------- CAS-command on ([],Pbl) -------------------------------";
|
wneuper@527
|
440 |
"--------- CAS-command on ([],Pbl) -------------------------------";
|
wneuper@525
|
441 |
val (p,_,f,nxt,_,pt) =
|
wneuper@525
|
442 |
CalcTreeTEST [([], ("e_domID", ["e_pblID"], ["e_metID"]))];
|
wneuper@525
|
443 |
val ifo = "solve(x+1=2,x)";
|
wneuper@527
|
444 |
val (_,(_,c,(pt,p))) = inform ([],[],(pt,p)) "solve(x+1=2,x)";
|
wneuper@527
|
445 |
show_pt pt;
|
wneuper@527
|
446 |
val nxt = ("Apply_Method",Apply_Method ["Test","squ-equ-test-subpbl1"]);
|
wneuper@527
|
447 |
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
|
wneuper@527
|
448 |
if p = ([1], Frm) andalso f2str f = "x + 1 = 2" then ()
|
wneuper@527
|
449 |
else raise error "inform.sml: diff.behav. CAScmd ([],Pbl)";
|
wneuper@525
|
450 |
|
wneuper@524
|
451 |
|
wneuper@527
|
452 |
"--------- CAS-command on ([],Pbl) FE-interface ------------------";
|
wneuper@527
|
453 |
"--------- CAS-command on ([],Pbl) FE-interface ------------------";
|
wneuper@527
|
454 |
"--------- CAS-command on ([],Pbl) FE-interface ------------------";
|
wneuper@525
|
455 |
states:=[];
|
wneuper@525
|
456 |
CalcTree [([], ("e_domID", ["e_pblID"], ["e_metID"]))];
|
wneuper@525
|
457 |
Iterator 1;
|
wneuper@525
|
458 |
moveActiveRoot 1;
|
wneuper@525
|
459 |
replaceFormula 1 "solve(x+1=2,x)";
|
wneuper@527
|
460 |
autoCalculate 1 CompleteCalc;
|
wneuper@527
|
461 |
val ((pt,p),_) = get_calc 1;
|
wneuper@527
|
462 |
show_pt pt;
|
wneuper@527
|
463 |
if p = ([], Res) then ()
|
wneuper@527
|
464 |
else raise error "inform.sml: diff.behav. CAScmd ([],Pbl) FE-interface";
|
wneuper@527
|
465 |
|
wneuper@527
|
466 |
|
wneuper@669
|
467 |
"--------- inform [rational,simplification] ----------------------";
|
wneuper@669
|
468 |
"--------- inform [rational,simplification] ----------------------";
|
wneuper@669
|
469 |
"--------- inform [rational,simplification] ----------------------";
|
wneuper@669
|
470 |
states:=[];
|
wneuper@669
|
471 |
CalcTree [(["term (4/x - 3/y - 1)", "normalform N"],
|
wneuper@669
|
472 |
("Rational.thy",["rational","simplification"],
|
wneuper@669
|
473 |
["simplification","of_rationals"]))];
|
wneuper@669
|
474 |
Iterator 1; moveActiveRoot 1;
|
wneuper@669
|
475 |
autoCalculate 1 CompleteCalcHead;
|
wneuper@669
|
476 |
autoCalculate 1 (Step 1);
|
wneuper@669
|
477 |
autoCalculate 1 (Step 1);
|
wneuper@669
|
478 |
autoCalculate 1 (Step 1);
|
wneuper@669
|
479 |
autoCalculate 1 (Step 1);
|
wneuper@669
|
480 |
"--- input the next formula that would be presented by mat-engine";
|
wneuper@669
|
481 |
appendFormula 1 "(4 * y + -3 * x) / (x * y) + -1";
|
wneuper@669
|
482 |
|
wneuper@675
|
483 |
(*
|
wneuper@675
|
484 |
print_depth 9;
|
wneuper@675
|
485 |
print_depth 5; cs'; print_depth 3;
|
wneuper@675
|
486 |
val (_,_,(pptt,pp)) = cs';
|
wneuper@675
|
487 |
val tt = get_obj g_res pptt [4];
|
wneuper@675
|
488 |
term2str tt;
|
wneuper@675
|
489 |
|
wneuper@675
|
490 |
(mk_tacis rew_ord erls) (nth 1 der);
|
wneuper@675
|
491 |
*)
|
wneuper@675
|
492 |
|
wneuper@675
|
493 |
|
wneuper@669
|
494 |
|
wneuper@669
|
495 |
"--- input the exact final result";(*TODO: Exception- LIST "last_elem" raised*)
|
wneuper@669
|
496 |
appendFormula 1 "(-3 * x + 4 * y + -1 * x * y) / (x * y)";
|