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