1 (* tests for IsacKnowledge/Diff_App
2 author Walther Neuper 000301
3 (c) due to copyright terms
5 use"../smltest/IsacKnowledge/diffapp.sml";
9 "Contents----------------------------------------------";
10 " Specify_Problem (match_itms_oris) ";
11 " test specify, fmz <> [] ";
12 " test specify, fmz = [] ";
13 " problemtypes + formalizations ";
14 "-------------------- ctree of {(a,b). is-max ... ----------------";
15 "--------- me .. scripts for maximum-example ---------------------";
16 "--------- autoCalc .. scripts for maximum-example ---------------";
18 "--------------------- 30.4.03: maximum .. rewrite_set_ prog_expr ---------";
19 "---------------------- 1.5.03: Make_fun_by_explicit ---------------------";
20 "---------------------- 2.5.03: Make_fun_by_new_variable -----------------";
26 " #################################################### ";
27 " problemtypes + formalizations ";
28 " #################################################### ";
29 " -------------- [maximum_of,function] --------------- ";
31 ["fixedValues f_ix", "maximum m_m", "valuesFor v_s", "relations r_s"];
32 (*=== inhibit exn 110722=============================================================
33 map (the o (parseold thy)) pbt;
34 === inhibit exn 110722=============================================================*)
36 ["fixedValues [r=Arbfix]", "maximum A",
38 "relations [A=a*b, (a/2) \<up> 2 + (b/2) \<up> 2 = r \<up> 2]",
39 "relations [A=a*b, (a/2) \<up> 2 + (b/2) \<up> 2 = r \<up> 2]",
40 "relations [A=a*b, a/2=r*sin alpha, b/2=r*cos (alpha::real)]",
42 "boundVariable a", "boundVariable b", "boundVariable alpha",
43 "interval {x::real. 0 <= x & x <= 2*r}",
44 "interval {x::real. 0 <= x & x <= 2*r}",
45 "interval {x::real. 0 <= x & x <= pi}",
46 "errorBound (eps=(0::real))"];
47 (*=== inhibit exn 110722=============================================================
48 map (the o (parseold thy)) fmz;
49 " -------------- [make,function] -------------- ";
50 === inhibit exn 110722=============================================================*)
52 ["functionOf f_f", "boundVariable v_v", "equalities eqs",
53 "functionTerm f_0_0"];
54 (*=== inhibit exn 110722=============================================================
55 map (the o (parseold thy)) pbt;
57 ["functionOf A", "boundVariable a", "boundVariable b",
58 "equalities [A=a*b, (a/2) \<up> 2 + (b/2) \<up> 2 = r \<up> 2]",
59 (*28.11.00: "functionTerm (A_0=Undef)"*)"functionTerm (Undef)"];
60 map (the o (parseold thy)) fmz12;
62 ["functionOf A", "boundVariable a", "boundVariable b",
63 "equalities [A=a*b, a/2=r*sin alpha, b/2=r*cos alpha]",
64 (*28.11.00: "functionTerm (A_0=Undef)"*)"functionTerm (Undef)"];
65 map (the o (parseold thy)) fmz3;
66 " --------- [univar,equation] --------- ";
68 ["equality e_e", "solveFor v_v", "solutions v_i_i"];
69 map (the o (parseold thy)) pbt;
71 ["equality ((a/2) \<up> 2 + (b/2) \<up> 2 = r \<up> 2)",
72 "solveFor b", "solutions b_i"];
73 map (the o (parseold thy)) fmz;
74 " ---- [on_interval,maximum_of,function] ---- ";
76 ["functionTerm t_t", "boundVariable v_v", "interval itv_v",
77 "errorBound err_r", "maxArgument v_0"];
78 map (the o (parseold thy)) pbt;
80 [(*28.11.00: "functionTerm (A_0 = a*sqrt(#4*r \<up> #2 - a \<up> #2))",*)
81 "functionTerm (a*sqrt(4*r \<up> 2 - a \<up> 2))",
82 (*28.11.00: "functionTerm (A_0 = b*sqrt(#4*r \<up> #2 - b \<up> #2))",*)
83 "functionTerm (b*sqrt(4*r \<up> 2 - b \<up> 2))",
84 "boundVariable a", "boundVariable b",
85 "interval {x::real. 0 <= x & x <= 2*r}",
86 "errorBound (eps=0)", "maxArgument (a_0=Undef)"];
87 map (the o (parseold thy)) fmz12;
89 [(*28.11.00: "functionTerm (A_0 = (#2*r*sin alpha)*(#2*r*cos alpha))",*)
90 "functionTerm ((2*r*sin alpha)*(2*r*cos alpha))",
91 "boundVariable alpha",
92 "interval {x::real. 0 <= x & x <= pi}",
93 "errorBound (eps=0)", "maxArgument (a_0=Undef)"];
94 map (the o (parseold thy)) fmz3;
95 " --------- [derivative_of,function] --------- ";
97 ["functionTerm f_f", "boundVariable v_v", "derivative f_f'"];
98 map (the o (parseold thy)) pbt;
100 [(*28.11.00: "functionTerm (A_0=a*#2*sqrt r \<up> #2 - (a//#2) \<up> #2)",*)
101 "functionTerm (a*2*sqrt r \<up> 2 - (a/2) \<up> 2)",
103 (*28.11.00: "derivative (A_0'=Undef)"*)"derivative (Undef)"];
104 map (the o (parseold thy)) fmz;
105 " --------- [find_values,tool] --------- ";
107 ["maxArgument ma_a", "functionTerm f_f", "boundVariable v_v",
108 "valuesFor vls_s", "additionalRels r_s"];
109 map (the o (parseold thy)) pbt;
111 ["maxArgument (a_0=(srqt 2)*r)",
112 (*28.11.00: "functionTerm (A_0=a*#2*sqrt r \<up> #2 - (a//#2) \<up> #2)",*)
113 "functionTerm (a*2*sqrt r \<up> 2 - (a/2) \<up> 2)",
115 "valuesFor [a,b]", "maximum A",
116 "additionalRels [(a/2) \<up> 2 + (b/2) \<up> 2 = r \<up> 2]"];
117 map (the o (parseold thy)) fmz1;
119 === inhibit exn 110722=============================================================*)
122 "-------------------- ctree of {(a,b). is-max ... --------------------------";
123 "-------------------- ctree of {(a,b). is-max ... --------------------------";
124 "-------------------- ctree of {(a,b). is-max ... --------------------------";
126 (* --vvv-- ausgeliehen von test-root-equ/sml *)
127 val loc = Istate.empty;
129 ("Program",["sqroot-test", "univariate", "equation"],
130 ["Program", "squ-equ-test2"]);
131 val fmz = ["equality (sqrt(9+4*x)=sqrt x + sqrt(5+x))",
132 "solveFor x", "errorBound (eps=0)",
135 val (mI,m) = ("Init_Proof",Init_Proof (fmz, (dI',pI',mI')));
136 val ((p,p_),_,_,_,_,(_,pt,_)) = CalcTreeTEST [fmz, (dI',pI',mI')))];
137 -- \<up> -- ausgeliehen von test-root-equ/sml *)
138 (*-------------- 9.6.03 --- cappend_ ... term -------irreparabler test
140 cappend_problem EmptyPtree [] loc ([],(dI',pI',mI'), .....);
141 val pos = (lev_on o lev_dn) [];
142 (* val pos = ([1]) *)
143 val (pt,_) = cappend_parent pt pos loc "{(a,b). is-max ..."
144 Empty_Tac TransitiveB;
145 val pos = (lev_on o lev_dn) pos;
146 (*val pos = ([1,1])*)
147 val (pt,_) = cappend_atomic pt pos loc "{(a,b). is-max ..."
148 Empty_Tac ("[1,1]:{(a,b). is-extremum ...",[]) Complete;
149 val pos = lev_on pos;
150 (*val pos = ([1,2])*)
151 val (pt,_) = cappend_atomic pt pos loc "{(a,b). is-extremum ..."
152 Empty_Tac ("[1,2]:{(a,b). f_x(a,b) ...",[]) Complete;
153 val pos = lev_up pos;
155 val (pt,_) = append_result pt pos Istate.empty ("[1#]:{(a,b). f_x(a,b) ...",[])
158 val pos = lev_on pos;
160 val (pt,_) = cappend_atomic pt pos loc "{(a,b). f_x(a,b) ..."
161 Empty_Tac ("[2]:{(a,b). f_x & f_xx &...",[]) Complete;
162 val pos = lev_on pos;
163 (*al pos = [3] : pos*)
164 val (pt,_) = cappend_parent pt pos loc "{(a,b). f_x & f_xx &..."
165 Empty_Tac TransitiveB;
166 val pos = (lev_on o lev_dn) pos;
168 val (pt,_) = cappend_atomic pt pos loc "{(a,b). f_x & f_xx & ..."
169 Empty_Tac ("[3,1]:{(a,b). f_x & f_xx } cup ...",[]) Complete;
170 val pos = lev_on pos;
172 val (pt,_) = cappend_atomic pt pos loc "{(a,b). f_x & f_xx } cup.."
173 Empty_Tac ("[3,2]:{(a,b). f_x ..} cup ...",[]) Complete;
175 val pos = lev_up pos;
177 val (pt,_) = append_result pt pos Istate.empty ("[3#]:{(a,b). f_x ..} cup..",[])
179 val pos = lev_on pos;
180 (*val pos = [4] : pos *)
181 val (pt,_) = cappend_parent pt pos loc "{(a,b). f_x ..} cup ..."
182 Empty_Tac IntersectB;
183 val pos = (lev_on o lev_dn) pos;
184 (*val pos = ([4,1]) *)
185 val (pt,_) = cappend_parent pt pos loc "set_1 = ..."
189 val pos = (lev_on o lev_dn) pos;
190 (*val pos = ([4,1,1]) *)
191 val (pt,_) = cappend_parent(*pbl*) pt pos loc"f_x = d/dx x \<up> 3 ..."
192 Empty_Tac TransitiveB;
193 val pos = (lev_on o lev_dn) pos;
194 (*val pos = ([4,1,1,1]) *)
195 val (pt,_) = cappend_parent pt pos loc "d/dx x \<up> 3 ..."
196 Empty_Tac TransitiveB;
197 val pos = (lev_on o lev_dn) pos;
198 (*val pos = ([4,1,1,1,1]) *)
199 val (pt,_) = cappend_atomic pt pos loc "d/dx x \<up> 3 ..."
200 Empty_Tac ("[4,1,1,1,1]:3x \<up> 2 + d/dx ...",[]) Complete;
201 val pos = lev_on pos;
202 (*val pos = ([4,1,1,1,2]) *)
203 val (pt,_) = cappend_atomic pt pos loc "3x \<up> 2 + d/dx ..."
204 Empty_Tac ("[4,1,1,1,2]:3x \<up> 2 + 0 + d/dx ...",[]) Complete;
205 val pos = lev_on pos;
206 (*pos = ([4,1,1,1,3]) *)
207 val (pt,_) = cappend_atomic pt pos loc "3x \<up> 2 + 0 + d/dx ..."
208 Empty_Tac ("[4,1,1,1,3]:3x \<up> 2 + 0 -3 ...",[]) Complete;
210 val pos = lev_up pos;
211 (*pos = ([4,1,1,1]) *)
212 val (pt,_) = append_result pt pos Istate.empty ("[4,1,1,1#]:3x \<up> 2 -3.",[])Complete;
214 val pos = lev_up pos;
215 (*val pos = ([4,1,1]) *)
216 val (pt,_) = append_result pt pos Istate.empty ("[4,1,1#]:found 3x \<up> 2 -3 ...",[])
219 val pos = lev_on pos;
220 (*val pos = ([4,1,2]+) *)
221 val (pt,_) = cappend_parent(*pbl*) pt pos loc "f_y = d/dy x \<up> 3 ..."
222 Empty_Tac TransitiveB;
224 writeln (pr_ctree pr_short pt);
228 1. {(a,b). is-max ...
229 1.1. {(a,b). is-max ...
230 1.2. {(a,b). is-extremum ...
231 2. {(a,b). f_x(a,b) ...
232 3. {(a,b). f_x & f_xx &...
233 3.1. {(a,b). f_x & f_xx & ...
234 3.2. {(a,b). f_x & f_xx } cup..
235 4. {(a,b). f_x ..} cup ...
237 4.1.1. f_x = d/dx x \<up> 3 ...
238 4.1.1.1. d/dx x \<up> 3 ...
239 4.1.1.1.1. d/dx x \<up> 3 ...
240 4.1.1.1.2. 3x \<up> 2 + d/dx ...
241 4.1.1.1.3. 3x \<up> 2 + 0 + d/dx ...
242 4.1.2. f_y = d/dy x \<up> 3 ...
244 use"test-max-surf1.sml";
246 -------------- 9.6.03 --- cappend_ ... term -------irreparabler test---*)
249 "--------- me .. scripts for maximum-example ---------------------";
250 "--------- me .. scripts for maximum-example ---------------------";
251 "--------- me .. scripts for maximum-example ---------------------";
254 ["fixedValues [r=Arbfix]", "maximum A",
256 "relations [A=a*b, (a/2) \<up> 2 + (b/2) \<up> 2 = r \<up> 2]",
257 "relations [A=a*b, (a/2) \<up> 2 + (b/2) \<up> 2 = r \<up> 2]",
258 "relations [A=a*b, a/2=r*sin alpha, b/2=r*cos (alpha::real)]",
260 "boundVariable a", "boundVariable b", "boundVariable alpha",
261 "interval {x::real. 0 <= x & x <= 2*r}",
262 "interval {x::real. 0 <= x & x <= 2*r}",
263 "interval {x::real. 0 <= x & x <= pi}",
264 "errorBound (eps=(0::real))"];
266 ("Diff_App",["maximum_of", "function"],
267 ["Diff_App", "max_by_calculus"]);
269 val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
270 (*=== inhibit exn 110722=============================================================
271 val (p,_,f,nxt,_,pt) = me nxt p c pt;
272 val (p,_,f,nxt,_,pt) = me nxt p c pt;
273 val (p,_,f,nxt,_,pt) = me nxt p c pt;
274 val (p,_,f,nxt,_,pt) = me nxt p c pt;
275 val (p,_,f,nxt,_,pt) = (me nxt p c pt) handle e => OldGoals.print_exn e;
276 val (p,_,f,nxt,_,pt) = me nxt p c pt;
277 val (p,_,f,nxt,_,pt) = me nxt p c pt;
278 val (p,_,f,nxt,_,pt) = me nxt p c pt;
279 val (p,_,f,nxt,_,pt) = me nxt p c pt;
280 case nxt of (_, Specify_Method ["Diff_App", "max_by_calculus"]) => ()
281 | _ => error "diffapp.sml: max-exp me, nxt = Specify_Method";
283 val oris = fst3 (get_obj g_origin pt (fst p)); writeln(O_Model.to_string oris);
284 val pits = get_obj g_pbl pt (fst p); writeln(I_Model.to_string ctxt pits);
286 val (p,_,f,nxt,_,pt) = me nxt p c pt;
287 val mits = get_obj g_met pt (fst p); writeln(I_Model.to_string ctxt mits);
288 val (p,_,f,nxt,_,pt) = me nxt p c pt;
289 val (p,_,f,nxt,_,pt) = me nxt p c pt;
290 val (p,_,f,nxt,_,pt) = me nxt p c pt;
291 case nxt of (_,Apply_Method ["Diff_App", "max_by_calculus"] ) => ()
292 | _ => error "diffapp.sml: max-exp me, nxt = Apply_Method";
293 val (p,_,f,nxt,_,pt) = me nxt p c pt;
294 === inhibit exn 110722=============================================================*)
296 (*since 0508 Apply_Method does the 1st step, if NONE implicit_take -------------
297 (*val nxt = ("Subproblem",Subproblem ("Diff_App",["make", "function"]))*)
298 val (p,_,f,nxt,_,pt) = (me nxt p c pt) handle e => print_exn_G e;
299 (*val nxt = ("Refine_Tacitly",Refine_Tacitly ["make", "function"])*)
300 val (p,_,f,nxt,_,pt) = me nxt p c pt;
301 (*val nxt = ("Model_Problem",Model_Problem ["by_explicit", "make", "function"])*)
302 ----------------------------------------------------------------------------*)
303 case nxt of (Model_Problem(*["by_explicit", "make", "function"]*)) => ()
304 | _ => error "diffapp.sml: max-exp me, nxt = Model_Problem";
306 (*=== inhibit exn 110722=============================================================
307 val (p,_,f,nxt,_,pt) = me nxt p c pt;
308 val (p,_,f,nxt,_,pt) = me nxt p c pt;
309 val (p,_,f,nxt,_,pt) = me nxt p c pt;
310 val (p,_,f,nxt,_,pt) = me nxt p c pt;
311 val (p,_,f,nxt,_,pt) = me nxt p c pt;
312 === inhibit exn 110722=============================================================*)
314 val oris = fst3 (get_obj g_origin pt (fst p));writeln(O_Model.to_string oris);
315 val pits = get_obj g_pbl pt (fst p);writeln(I_Model.to_string ctxt pits);
317 (*=== inhibit exn 110722=============================================================
318 val (p,_,f,nxt,_,pt) = me nxt p c pt;
319 val (p,_,f,nxt,_,pt) = me nxt p c pt;
320 val (p,_,f,nxt,_,pt) = me nxt p c pt;
321 val (p,_,f,nxt,_,pt) = me nxt p c pt;
322 case nxt of (_, Apply_Method ["Diff_App", "make_fun_by_explicit"]) => ()
323 | _ => error "diffapp.sml: max-exp Apply_Method ([1], Met) ";
324 === inhibit exn 110722=============================================================*)
326 (*----since WN050901 (ie. corr. mathengine#nxt_specify_ ..Specify.find_next_step' Pbl->p_
328 val (p,_,f,nxt,_,pt) = me nxt p c pt;
330 ### associate: Not_Associated m= Subproblem' ,
333 (Subproblem (thy, [normalise, polynomial, univariate, equation])))]
334 (hd (filterVar A [A = a * b, (a / 2) \<up> 2 + (b / 2) \<up> 2 = r \<up> 2]))
335 *** tac_from_prog TODO: no match for Substitute
337 *** (Subproblem (thy, [normalise, polynomial, univariate, equation])))]
338 *** (hd (filterVar A [A = a * b, (a / 2) \<up> 2 + (b / 2) \<up> 2 = r \<up> 2]))
339 Exception- ERROR raised
341 ############################################################################
342 # presumerably didnt work before either, but not detected due to Emtpy_Tac #
343 ############################################################################
345 (*val nxt = Subproblem ("Diff_App",["univariate", "equation"])) *)
346 val (p,_,f,nxt,_,pt) = me nxt p c pt;
347 (*val nxt = Refine_Tacitly ["univariate", "equation"])*)
349 val oris = fst3 (get_obj g_origin pt (fst p));writeln(O_Model.to_string oris);
350 val pits = get_obj g_pbl pt (fst p);writeln(I_Model.to_string ctxt pits);
352 val (p,_,f,nxt,_,pt) = me nxt p c pt;
353 val (p,_,f,nxt,_,pt) = me nxt p c pt;
354 val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
355 val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
356 val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
357 (*val nxt = ("Apply_Method",Apply_Method ["PolyEq", "normalise_poly"])*)
359 val (p,_,f,nxt,_,pt) = me nxt p c pt;
360 (*val f = Form' (Test_Out.FormKF (~1,EdUndef,3,Nundef,"A = a * b"))*)
361 val (p,_,f,nxt,_,pt) = me nxt p c pt;
362 val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
363 val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
364 val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
365 val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
366 val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
367 val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
368 val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
369 (*val f = Form' (Test_Out.FormKF (~1,EdUndef,4,Nundef,"[b = A / a]"))*)
371 ------------------------------------------------------------------------*)
374 Error' (Error_ "Refine_Tacitly [\"univariate\",\"equation\"] not applicable")*)
377 (*----postponed.15.5.03 run scripts for maximum-example: univariate equation*)
378 (*=== inhibit exn 110722=============================================================
380 val (p,_,f,nxt,_,pt) = (me nxt p c pt) handle e => OldGoals.print_exn e;
381 === inhibit exn 110722=============================================================*)
383 val oris = fst3 (get_obj g_origin pt (fst p));writeln(O_Model.to_string oris);
385 val pits = get_obj g_pbl pt (fst p);writeln(I_Model.to_string ctxt pits);
386 val pits = get_obj g_pbl pt [];writeln(I_Model.to_string ctxt pits);
388 val mits = get_obj g_met pt (fst p);writeln(I_Model.to_string ctxt mits);
389 val mits = get_obj g_met pt [];writeln(I_Model.to_string ctxt mits);
391 (*=== inhibit exn 110722=============================================================
392 arguments_from_model ["Diff_App", "max_by_calculus"] mits;
394 val (p,_,f,nxt,_,pt) = me nxt p c pt;
395 === inhibit exn 110722=============================================================*)
399 "--------- autoCalc .. scripts for maximum-example ---------------";
400 "--------- autoCalc .. scripts for maximum-example ---------------";
401 "--------- autoCalc .. scripts for maximum-example ---------------";
402 (*++++++++ see systest/inform.sml 'I_Model.complete' ++++++++*)
405 ["fixedValues [r=Arbfix]", "maximum A",
407 "relations [A=a*b, (a/2) \<up> 2 + (b/2) \<up> 2 = r \<up> 2]",
408 "relations [A=a*b, (a/2) \<up> 2 + (b/2) \<up> 2 = r \<up> 2]",
409 "relations [A=a*b, a/2=r*sin alpha, b/2=r*cos (alpha::real)]",
411 "boundVariable a", "boundVariable b", "boundVariable alpha",
412 "interval {x::real. 0 <= x & x <= 2*r}",
413 "interval {x::real. 0 <= x & x <= 2*r}",
414 "interval {x::real. 0 <= x & x <= pi}",
415 "errorBound (eps=(0::real))"];
417 ("Diff_App",["maximum_of", "function"],
418 ["Diff_App", "max_by_calculus"]);
420 CalcTree [(fmz, (dI',pI',mI'))];
421 Iterator 1; moveActiveRoot 1;
422 autoCalculate 1 CompleteCalcHead;
423 refFormula 1 (States.get_pos 1 1);
425 fetchProposedTactic 1;
426 (*autoCalculate 1 (Steps 1);
427 broken in child of.1790e1073acc : eliminate "handle _ => ..." from Rewrite.rewrite
428 this test is not up to date
429 ERROR exception TERM raised (line 359 of "term.ML"): fastype_of: Bound B.0*)
431 fetchProposedTactic 1;
432 (*autoCalculate 1 (Steps 1);
433 broken in child of.1790e1073acc : eliminate "handle _ => ..." from Rewrite.rewrite
434 this test is not up to date
435 ERROR exception TERM raised (line 359 of "term.ML"): fastype_of: Bound B.0*)
436 (*Subproblem on_interval maximum_of function*)
437 autoCalculate 1 CompleteCalcHead;
439 fetchProposedTactic 1;
440 val ((pt,p),_) = States.get_calc 1;
441 val mits = get_obj g_met pt (fst p);
442 writeln (I_Model.to_string ctxt mits);
444 if I_Model.to_string ctxt mits = "[\n(1 ,[1] ,true ,#Given ,Cor functionEq (hd r_s) ,(t_, [hd r_s])),\n(2 ,[1] ,true ,#Given ,Cor boundVariable v_v ,(v_, [v_])),\n(3 ,[1] ,true ,#Given ,Cor interval itv_ ,(itv_, [itv_])),\n(4 ,[1] ,true ,#Find ,Cor maxArgument v__0 ,(v_0, [v__0]))]" then ()
445 else error "diffapp.sml: diff.behav. in autoCalc .. scripts for max 1";
447 (*FIXME: the environments contain identifers, and NOT values ?!?!?*)
448 (* WN051209 while extending 'fun step' for initac, this became better ...
449 if I_Model.to_string ctxt mits = "[\n(1 ,[1,2,3] ,true ,#Given ,Cor fixedValues [r = Arbfix] ,(f_ix, [[r = Arbfix]])),\n(2 ,[1,2,3] ,true ,#Find ,Cor maximum A ,(m_, [A])),\n(3 ,[1,2,3] ,true ,#Find ,Cor valuesFor [a, b] ,(v_s, [[a],[b]])),\n(4 ,[1,2] ,true ,#Relate ,Cor relations [A = a * b, (a / 2) \<up> 2 + (b / 2) \<up> 2 = r \<up> 2] ,(r_s, [[A = a * b],[(a / 2) \<up> 2 + (b / 2) \<up> 2 = r \<up> 2]])),\n(6 ,[1] ,true ,#undef ,Cor boundVariable a ,(v_, [a])),\n(9 ,[1,2] ,true ,#undef ,Cor interval {x. 0 <= x & x <= 2 * r} ,(itv_, [{x. 0 <= x & x <= 2 * r}])),\n(11 ,[1,2,3] ,true ,#undef ,Cor errorBound (eps = 0) ,(err_, [eps = 0]))]" then ()
450 else error "diffapp.sml: diff.behav. in autoCalc .. scripts for max 1";
455 "--------------------- 30.4.03: maximum .. rewrite_set_ prog_expr ---------";
456 "--------------------- 30.4.03: maximum .. rewrite_set_ prog_expr ---------";
457 "--------------------- 30.4.03: maximum .. rewrite_set_ prog_expr ---------";
458 TermC.parse_test @{context}
459 "Program Maximum_value(f_ix::bool list)(m_m::real) (r_s::bool list)\
460 \ (v_v::real) (itv_v::real set) (err_r::bool) = \
461 \ (let e_e = (hd o (filterVar m_m)) r_s; \
462 \ t_t = (if 1 < length_h r_s \
463 \ then (SubProblem (Reals_s,[make,function],[no_met])\
464 \ [REAL m_m, REAL v_v, BOOL_LIST r_s])\
466 \ (mx_x::real) = SubProblem (Reals_s,[on_interval,max_of,function], \
467 \ [Isac,maximum_on_interval])\
468 \ [BOOL t_t, REAL v_v, REAL_SET itv_v]\
469 \ in ((SubProblem (Reals_s,[find_values,tool],[Isac,find_values]) \
470 \ [REAL mx_x, REAL (Rhs t_t), REAL v_v, REAL m_m, \
471 \ BOOL_LIST (dropWhile (ident e_e) r_s)])::bool list))";
473 val f_ix = (TermC.parse_test @{context} "f_ix::bool list",
474 TermC.parse_test @{context} "[r=Arbfix]");
475 val m_m = (TermC.parse_test @{context} "m_m::real",
476 TermC.parse_test @{context} "A");
477 val r_s = (TermC.parse_test @{context} "rs_s::bool list",
478 TermC.parse_test @{context} "[A = a*b, (a/2) \<up> 2 + (b/2) \<up> 2 = r \<up> 2]");
479 val v_v = (TermC.parse_test @{context} "v_v::real",
480 TermC.parse_test @{context} "b");
481 val itv_v = (TermC.parse_test @{context} "itv_v::real set",
482 TermC.parse_test @{context} "{x::real. 0 <= x & x <= 2*r}");
483 val err_r = (TermC.parse_test @{context} "err_r::bool",
484 TermC.parse_test @{context} "eps=0");
485 val env = [f_ix, m_m, r_s ,v_v, itv_v, err_r];
487 (*--- 1.line in script ---*)
488 val t = TermC.parse_test @{context} "(hd o (filterVar m_m)) (r_s::bool list)";
489 val s = subst_atomic env t;
491 "(hd o filterVar A) [A = a * b, (a / 2) \<up> 2 + (b / 2) \<up> 2 = r \<up> 2]";
492 (*=== inhibit exn 110726=============================================================
493 val SOME (s',_) = rewrite_set_ thy false prog_expr s;
494 val s'' = UnparseC.term s';
495 if s''="A = a * b" then () else error "new behaviour with prog_expr 1.1.";
496 === inhibit exn 110726=============================================================*)
497 val env = env @ [(TermC.parse_test @{context} "e_e::bool",TermC.parse_test @{context} "A = a * b")];
499 (*--- 2.line: condition alone ---*)
500 val t = TermC.parse_test @{context} "1 < length_h (r_s::bool list)";
501 val s = subst_atomic env t;
503 "1 < length_h [A = a * b, (a / 2) \<up> 2 + (b / 2) \<up> 2 = r \<up> 2]";
504 (*=== inhibit exn 110726=============================================================
505 val SOME (s',_) = rewrite_set_ thy false prog_expr s;
506 val s'' = UnparseC.term s';
507 if s''=\<^const_name>\<open>True\<close> then () else error "new behaviour with prog_expr 1.2.";
508 === inhibit exn 110726=============================================================*)
510 (*--- 2.line in script ---*)
511 val t = TermC.parse_test @{context}
512 "(if 1 < length_h r_s \
513 \ then (SubProblem (Reals_s,[make,function],[no_met])\
514 \ [REAL m_m, REAL v_v, BOOL_LIST r_s])\
516 val s = subst_atomic env t;
518 "if 1 < length_h [A = a * b, (a / 2) \<up> 2 + (b / 2) \<up> 2 = r \<up> 2]\
519 \then SubProblem (Reals_s, [make, function], [no_met])\
521 \ BOOL_LIST [A = a * b, (a / 2) \<up> 2 + (b / 2) \<up> 2 = r \<up> 2]]\
522 \else hd [A = a * b, (a / 2) \<up> 2 + (b / 2) \<up> 2 = r \<up> 2]";
523 (*=== inhibit exn 110726=============================================================
524 val SOME (s',_) = rewrite_set_ thy false prog_expr s;
525 val s'' = UnparseC.term s';
527 "SubProblem (Reals_s, [make, function], [no_met])\n\
528 \ [REAL A, REAL b,\n\
529 \ BOOL_LIST [A = a * b, (a / 2) \<up> 2 + (b / 2) \<up> 2 = r \<up> 2]]" then ()
530 else error "new behaviour with prog_expr 1.3.";
531 === inhibit exn 110726=============================================================*)
532 val env = env @ [(TermC.parse_test @{context} "t_t::bool",
533 TermC.parse_test @{context} "A = (2*sqrt(r \<up> 2-(b/2) \<up> 2)) * b")];
537 "---------------------- 1.5.03: Make_fun_by_explicit ---------------------";
538 "---------------------- 1.5.03: Make_fun_by_explicit ---------------------";
539 "---------------------- 1.5.03: Make_fun_by_explicit ---------------------";
540 TermC.parse_test @{context}
541 "Program Make_fun_by_explicit (f_f::real) (v_v::real) \
542 \ (eqs::bool list) = \
543 \ (let h_h = (hd o (filterVar f_f)) eqs; \
544 \ e_1 = hd (dropWhile (ident h_h) eqs); \
545 \ v_s = dropWhile (ident f_f) (Vars h_h); \
546 \ v_1 = hd (dropWhile (ident v_v) v_s); \
547 \ (s_1::bool list)=(SubProblem(Reals_s,[univar,equation],[no_met])\
548 \ [BOOL e_1, REAL v_1])\
549 \ in Substitute [(v_1 = (rhs o hd) s_1)] h_h)";
550 val f_f = (TermC.parse_test @{context} "f_f::real",
551 TermC.parse_test @{context} "A");
552 val v_v = (TermC.parse_test @{context} "v_v::real",
553 TermC.parse_test @{context} "b");
554 val eqs=(TermC.parse_test @{context} "eqs::bool list",
555 TermC.parse_test @{context} "[A = a * b, (a / 2) \<up> 2 + (b / 2) \<up> 2 = r \<up> 2]");
556 val env = [f_f, v_v, eqs];
558 (*--- 1.line in script ---*)
559 val t = TermC.parse_test @{context} "(hd o (filterVar v_v)) (eqs::bool list)";
560 val s = subst_atomic env t;
562 val t = TermC.parse_test @{context}
563 "(hd o filterVar b) [A = a * b, (a / 2) \<up> 2 + (b / 2) \<up> 2 = r \<up> 2]";
564 val SOME (t',_) = rewrite_set_ ctxt false prog_expr t;
565 val s' = UnparseC.term t';
566 (*=== inhibit exn 110726=============================================================
567 if s' = "A = a * b" then () else error "new behaviour with prog_expr 2.1";
568 === inhibit exn 110726=============================================================*)
569 val env = env @ [(TermC.parse_test @{context} "h_h::bool", TermC.parse_test @{context} s')];
571 (*--- 2.line in script ---*)
572 val t = TermC.parse_test @{context} "hd (dropWhile (ident h_h) (eqs::bool list))";
573 val s = subst_atomic env t;
575 val t = TermC.parse_test @{context}
576 "hd (dropWhile (ident (A = a * b))\
577 \ [A = a * b, (a / 2) \<up> 2 + (b / 2) \<up> 2 = r \<up> 2])";
578 (*=== inhibit exn 110726=============================================================
579 mem_rls "dropWhile_Cons" prog_expr;
580 mem_rls "Prog_Expr.ident" prog_expr;
581 val SOME (t',_) = rewrite_set_ thy false prog_expr t;
582 val s' = UnparseC.term t';
583 if s' = "(a / 2) \<up> 2 + (b / 2) \<up> 2 = r \<up> 2" then ()
584 else error "new behaviour with prog_expr 2.2";
585 === inhibit exn 110726=============================================================*)
586 val env = env @ [(TermC.parse_test @{context} "e_1::bool", TermC.parse_test @{context} s')];
588 (*--- 3.line in script ---*)
589 val t = TermC.parse_test @{context} "dropWhile (ident f_f) (Vars (h_h::bool))";
590 val s = subst_atomic env t;
592 val t = TermC.parse_test @{context} "dropWhile (ident A) (Vars (A = a * b))";
593 (*=== inhibit exn 110726=============================================================
594 val SOME (t',_) = rewrite_set_ thy false prog_expr t;
595 val s' = UnparseC.term t';
596 if s' = "[a, b]" then () else error "new behaviour with prog_expr 2.3";
597 === inhibit exn 110726=============================================================*)
598 val env = env @ [(TermC.parse_test @{context} "vs_s::real list", TermC.parse_test @{context} s')];
600 (*--- 4.line in script ---*)
601 val t = TermC.parse_test @{context} "hd (dropWhile (ident v_v) v_s)";
602 val s = subst_atomic env t;
604 val t = TermC.parse_test @{context} "hd (dropWhile (ident b) [a, b])";
605 (*=== inhibit exn 110726=============================================================
606 val SOME (t',_) = rewrite_set_ thy false prog_expr t;
607 val s' = UnparseC.term t';
608 if s' = "a" then () else error "new behaviour with prog_expr 2.4.";
609 === inhibit exn 110726=============================================================*)
610 val env = env @ [(TermC.parse_test @{context} "v_1::real", TermC.parse_test @{context} s')];
612 (*--- 5.line in script ---*)
613 val t = TermC.parse_test @{context} "(SubProblem(Reals_s,[univar,equation],[no_met])\
614 \ [BOOL e_1, REAL v_1])";
615 val s = subst_atomic env t;
617 "SubProblem (Reals_s, [univar, equation], [no_met])\n\
618 \ [BOOL ((a / 2) \<up> 2 + (b / 2) \<up> 2 = r \<up> 2), REAL a]";
619 val env = env @ [(TermC.parse_test @{context} "s_1::bool list",
620 TermC.parse_test @{context} "[a = 2 * sqrt (r \<up> 2 - (b/2) \<up> 2)]")];
622 (*--- 6.line in script ---*)
623 val t = TermC.parse_test @{context} "Substitute [(v_1 = (rhs o hd) (s_1::bool list))] (h_h::bool)";
624 val s = subst_atomic env t;
626 val t = TermC.parse_test @{context}
627 "Substitute [(a = (rhs o hd) [a = 2 * sqrt (r \<up> 2 - (b / 2) \<up> 2)])]\n\
629 (*=== inhibit exn 110726=============================================================
630 mem_rls "Prog_Expr.rhs" prog_expr;
631 val SOME (t',_) = rewrite_set_ thy false prog_expr t;
632 val s' = UnparseC.term t';
633 if s' = "Substitute [a = 2 * sqrt (r \<up> 2 - (b / 2) \<up> 2)] (A = a * b)"
634 then () else error "new behaviour with prog_expr 2.6.";
635 === inhibit exn 110726=============================================================*)
638 "---------------------- 2.5.03: Make_fun_by_new_variable -----------------";
639 "---------------------- 2.5.03: Make_fun_by_new_variable -----------------";
640 "---------------------- 2.5.03: Make_fun_by_new_variable -----------------";
641 TermC.parse_test @{context}
642 "Program Make_fun_by_new_variable (f_f::real) (v_v::real) \
643 \ (eqs::bool list) = \
644 \(let h_h = (hd o (filterVar f_f)) eqs; \
645 \ es_s = dropWhile (ident h_h) eqs; \
646 \ v_s = dropWhile (ident f_f) (Vars h_h); \
647 \ v_1 = nth_h 1 v_s; \
648 \ v_2 = nth_h 2 v_s; \
649 \ e_1 = (hd o (filterVar v_1)) es_s; \
650 \ e_2 = (hd o (filterVar v_2)) es_s; \
651 \ (s_1::bool list) = (SubProblem (Reals_s,[univar,equation],[no_met])\
652 \ [BOOL e_1, REAL v_1]);\
653 \ (s_2::bool list) = (SubProblem (Reals_s,[univar,equation],[no_met])\
654 \ [BOOL e_2, REAL v_2])\
655 \in Substitute [(v_1 = (rhs o hd) s_1),(v_2 = (rhs o hd) s_2)] h_h)";
656 val f_ = (TermC.parse_test @{context} "f_f::real",
657 TermC.parse_test @{context} "A");
658 val v_v = (TermC.parse_test @{context} "v_v::real",
659 TermC.parse_test @{context} "alpha");
660 val eqs=(TermC.parse_test @{context} "eqs::bool list",
661 TermC.parse_test @{context} "[A=a*b, a/2=r*sin alpha, b/2=r*cos (alpha::real)]");
662 val env = [f_f, v_v, eqs];
664 (*--- 1.line in script ---*)
665 val t = TermC.parse_test @{context} "(hd o (filterVar (f_f::real))) (eqs::bool list)";
666 val s = subst_atomic env t;
668 val t = TermC.parse_test @{context}
669 "(hd o filterVar A) [A = a * b, a / 2 = r * sin alpha, b / 2 = r * cos alpha]";
670 val SOME (t',_) = rewrite_set_ ctxt false prog_expr t;
671 val s' = UnparseC.term t';
672 (*=== inhibit exn 110726=============================================================
673 if s' = "A = a * b" then() else error "new behaviour with prog_expr 3.1.";
674 val env = env @ [(TermC.parse_test @{context} "h_h::bool", TermC.parse_test @{context} s')];
675 === inhibit exn 110726=============================================================*)
677 (*--- 2.line in script ---*)
678 val t = TermC.parse_test @{context} "dropWhile (ident (h_h::bool)) (eqs::bool list)";
679 val s = subst_atomic env t;
681 val t = TermC.parse_test @{context}
682 "dropWhile (ident (A = a * b))\
683 \ [A = a * b, a / 2 = r * sin alpha, b / 2 = r * cos alpha]";
684 (*=== inhibit exn 110726=============================================================
685 val SOME (t',_) = rewrite_set_ thy false prog_expr t;
686 val s' = UnparseC.term t';
687 if s' = "[a / 2 = r * sin alpha, b / 2 = r * cos alpha]"
688 then () else error "new behaviour with prog_expr 3.2.";
689 === inhibit exn 110726=============================================================*)
690 val env = env @ [(TermC.parse_test @{context} "es_s::bool list", TermC.parse_test @{context} s')];
692 (*--- 3.line in script ---*)
693 val t = TermC.parse_test @{context} "dropWhile (ident (f_f::real)) (Vars (h_h::bool))";
694 val s = subst_atomic env t;
696 val t = TermC.parse_test @{context} "dropWhile (ident A) (Vars (A = a * b))";
697 (*=== inhibit exn 110726=============================================================
698 val SOME (t',_) = rewrite_set_ thy false prog_expr t;
699 val s' = UnparseC.term t';
700 if s' = "[a, b]" then () else error "new behaviour with prog_expr 3.3.";
701 === inhibit exn 110726=============================================================*)
702 val env = env @ [(TermC.parse_test @{context} "vs_s::real list", TermC.parse_test @{context} s')];
704 (*--- 4.line in script ---*)
705 val t = TermC.parse_test @{context} "nth_h 1 v_s";
706 val s = subst_atomic env t;
708 val t = TermC.parse_test @{context} "nth_h 1 [a, b]";
709 (*=== inhibit exn 110726=============================================================
710 val SOME (t',_) = rewrite_set_ thy false prog_expr t;
711 val s' = UnparseC.term t';
712 if s' = "a" then () else error "new behaviour with prog_expr 3.4.";
713 === inhibit exn 110726=============================================================*)
714 val env = env @ [(TermC.parse_test @{context} "v_1", TermC.parse_test @{context} s')];
716 (*--- 5.line in script ---*)
717 val t = TermC.parse_test @{context} "nth_h 2 v_s";
718 val s = subst_atomic env t;
720 val t = TermC.parse_test @{context} "nth_h 2 [a, b]";
721 (*=== inhibit exn 110726=============================================================
722 val SOME (t',_) = rewrite_set_ thy false prog_expr t;
723 val s' = UnparseC.term t';
724 if s' = "b" then () else error "new behaviour with prog_expr 3.5.";
725 === inhibit exn 110726=============================================================*)
726 val env = env @ [(TermC.parse_test @{context} "v_2", TermC.parse_test @{context} s')];
728 (*--- 6.line in script ---*)
729 val t = TermC.parse_test @{context} "(hd o (filterVar v_1)) (es_s::bool list)";
730 val s = subst_atomic env t;
732 val t = TermC.parse_test @{context}
733 "(hd o filterVar a) [a / 2 = r * sin alpha, b / 2 = r * cos alpha]";
734 val SOME (t',_) = rewrite_set_ ctxt false prog_expr t;
735 val s' = UnparseC.term t';
736 (*=== inhibit exn 110726=============================================================
737 if s' = "a / 2 = r * sin alpha" then ()
738 else error "new behaviour with prog_expr 3.6.";
739 === inhibit exn 110726=============================================================*)
740 val e_1 = TermC.parse_test @{context} "e_1::bool";
741 val env = env @ [(e_1, TermC.parse_test @{context} s')];
743 (*--- 7.line in script ---*)
744 val t = TermC.parse_test @{context} "(hd o (filterVar v_2)) (es_s::bool list)";
745 val s = subst_atomic env t;
747 val t = TermC.parse_test @{context}
748 "(hd o filterVar b) [a / 2 = r * sin alpha, b / 2 = r * cos alpha]";
749 val SOME (t',_) = rewrite_set_ ctxt false prog_expr t;
750 val s' = UnparseC.term t';
751 (*=== inhibit exn 110726=============================================================
752 if s' = "b / 2 = r * cos alpha" then ()
753 else error "new behaviour with prog_expr 3.7.";
754 === inhibit exn 110726=============================================================*)
755 val env = env @ [(TermC.parse_test @{context} "e_2::bool", TermC.parse_test @{context} s')];
757 (*--- 8.line in script ---*)
758 val t = TermC.parse_test @{context} "(SubProblem (Reals_s,[univar,equation],[no_met])\
759 \ [BOOL e_1, REAL v_1])";
760 val s = subst_atomic env t;
762 "SubProblem (Reals_s, [univar, equation], [no_met])\
763 \ [BOOL (a / 2 = r * sin alpha), REAL a]";
764 val s_1 = TermC.parse_test @{context} "[a = 2*r*sin alpha]";
765 val env = env @ [(TermC.parse_test @{context} "s_1::bool list", s_1)];
767 (*--- 9.line in script ---*)
768 val t = TermC.parse_test @{context} "(SubProblem (Reals_s,[univar,equation],[no_met])\
769 \ [BOOL e_2, REAL v_2])";
770 val s = subst_atomic env t;
772 "SubProblem (Reals_s, [univar, equation], [no_met])\
773 \ [BOOL (b / 2 = r * cos alpha), REAL b]";
774 val s_2 = TermC.parse_test @{context} "[b = 2*r*cos alpha]";
775 val env = env @ [(TermC.parse_test @{context} "s_2::bool list", s_2)];
777 (*--- 10.line in script ---*)
778 val t = TermC.parse_test @{context}
779 "Substitute [(v_1 = (rhs o hd) s_1),(v_2 = (rhs o hd) s_2)] (h_h::bool)";
780 val s = subst_atomic env t;
782 "Substitute\n [(a = (rhs o hd) [a = 2 * r * sin alpha]),\
783 \ (b = (rhs o hd) [b = 2 * r * cos alpha])] (A = a * b)";
784 val SOME (s',_) = rewrite_set_ ctxt false prog_expr s;
785 val s'' = UnparseC.term s';
786 (*=== inhibit exn 110726=============================================================
788 "Substitute [a = 2 * r * sin alpha, b = 2 * r * cos alpha] (A = a * b)"
789 then () else error "new behaviour with prog_expr 3.10.";
790 ===== inhibit exn 110722===========================================================*)