1 (* tests for IsacKnowledge/DiffApp
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 "-------------------- ptree of {(a,b). is-max ... ----------------";
15 "--------- me .. scripts for maximum-example ---------------------";
16 "--------- autoCalc .. scripts for maximum-example ---------------";
18 "--------------------- 30.4.03: maximum .. rewrite_set_ list_rls ---------";
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)^^^2 + (b/2)^^^2 = r^^^2]",
39 "relations [A=a*b, (a/2)^^^2 + (b/2)^^^2 = r^^^2]",
40 "relations [A=a*b, a/2=r*sin alpha, b/2=r*cos alpha]",
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)^^^2 + (b/2)^^^2 = r^^^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)^^^2 + (b/2)^^^2 = r^^^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^^^#2 - a^^^#2))",*)
81 "functionTerm (a*sqrt(4*r^^^2 - a^^^2))",
82 (*28.11.00: "functionTerm (A_0 = b*sqrt(#4*r^^^#2 - b^^^#2))",*)
83 "functionTerm (b*sqrt(4*r^^^2 - b^^^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^^^#2 - (a//#2)^^^#2)",*)
101 "functionTerm (a*2*sqrt r^^^2 - (a/2)^^^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^^^#2 - (a//#2)^^^#2)",*)
113 "functionTerm (a*2*sqrt r^^^2 - (a/2)^^^2)",
115 "valuesFor [a,b]","maximum A",
116 "additionalRels [(a/2)^^^2 + (b/2)^^^2 = r^^^2]"];
117 map (the o (parseold thy)) fmz1;
119 === inhibit exn 110722=============================================================*)
122 "-------------------- ptree of {(a,b). is-max ... --------------------------";
123 "-------------------- ptree of {(a,b). is-max ... --------------------------";
124 "-------------------- ptree of {(a,b). is-max ... --------------------------";
126 (* Teil von max-on-surface.sml,
127 der nach Init_Proof -> prep_ori wieder l"auft
128 (f"ur tests mit neuer pos')
129 use"test-max-surf1.sml";
131 Compiler.Control.Print.printDepth:=7; (*4 is default*)
132 Compiler.Control.Print.printDepth:=4; (*4 is default*)
135 (* --vvv-- ausgeliehen von test-root-equ/sml *)
138 ("Script",["sqroot-test","univariate","equation"],
139 ["Script","squ-equ-test2"]);
140 val fmz = ["equality (sqrt(9+4*x)=sqrt x + sqrt(5+x))",
141 "solveFor x","errorBound (eps=0)",
144 val (mI,m) = ("Init_Proof",Init_Proof (fmz, (dI',pI',mI')));
145 val ((p,p_),_,_,_,_,(_,pt,_)) = do_ (mI,m) e_pos'[1](e_scr,EmptyPtree,[]);
146 --^^^-- ausgeliehen von test-root-equ/sml *)
147 (*-------------- 9.6.03 --- cappend_ ... term -------irreparabler test
149 cappend_problem EmptyPtree [] loc ([],(dI',pI',mI'));
150 val pos = (lev_on o lev_dn) [];
151 (* val pos = ([1]) *)
152 val (pt,_) = cappend_parent pt pos loc "{(a,b). is-max ..."
153 Empty_Tac TransitiveB;
154 val pos = (lev_on o lev_dn) pos;
155 (*val pos = ([1,1])*)
156 val (pt,_) = cappend_atomic pt pos loc "{(a,b). is-max ..."
157 Empty_Tac ("[1,1]:{(a,b). is-extremum ...",[]) Complete;
158 val pos = lev_on pos;
159 (*val pos = ([1,2])*)
160 val (pt,_) = cappend_atomic pt pos loc "{(a,b). is-extremum ..."
161 Empty_Tac ("[1,2]:{(a,b). f_x(a,b) ...",[]) Complete;
162 val pos = lev_up pos;
164 val (pt,_) = append_result pt pos e_istate ("[1#]:{(a,b). f_x(a,b) ...",[])
167 val pos = lev_on pos;
169 val (pt,_) = cappend_atomic pt pos loc "{(a,b). f_x(a,b) ..."
170 Empty_Tac ("[2]:{(a,b). f_x & f_xx &...",[]) Complete;
171 val pos = lev_on pos;
172 (*al pos = [3] : pos*)
173 val (pt,_) = cappend_parent pt pos loc "{(a,b). f_x & f_xx &..."
174 Empty_Tac TransitiveB;
175 val pos = (lev_on o lev_dn) pos;
177 val (pt,_) = cappend_atomic pt pos loc "{(a,b). f_x & f_xx & ..."
178 Empty_Tac ("[3,1]:{(a,b). f_x & f_xx } cup ...",[]) Complete;
179 val pos = lev_on pos;
181 val (pt,_) = cappend_atomic pt pos loc "{(a,b). f_x & f_xx } cup.."
182 Empty_Tac ("[3,2]:{(a,b). f_x ..} cup ...",[]) Complete;
184 val pos = lev_up pos;
186 val (pt,_) = append_result pt pos e_istate ("[3#]:{(a,b). f_x ..} cup..",[])
188 val pos = lev_on pos;
189 (*val pos = [4] : pos *)
190 val (pt,_) = cappend_parent pt pos loc "{(a,b). f_x ..} cup ..."
191 Empty_Tac IntersectB;
192 val pos = (lev_on o lev_dn) pos;
193 (*val pos = ([4,1]) *)
194 val (pt,_) = cappend_parent pt pos loc "set_1 = ..."
198 val pos = (lev_on o lev_dn) pos;
199 (*val pos = ([4,1,1]) *)
200 val (pt,_) = cappend_parent(*pbl*) pt pos loc"f_x = d/dx x^3 ..."
201 Empty_Tac TransitiveB;
202 val pos = (lev_on o lev_dn) pos;
203 (*val pos = ([4,1,1,1]) *)
204 val (pt,_) = cappend_parent pt pos loc "d/dx x^3 ..."
205 Empty_Tac TransitiveB;
206 val pos = (lev_on o lev_dn) pos;
207 (*val pos = ([4,1,1,1,1]) *)
208 val (pt,_) = cappend_atomic pt pos loc "d/dx x^3 ..."
209 Empty_Tac ("[4,1,1,1,1]:3x^2 + d/dx ...",[]) Complete;
210 val pos = lev_on pos;
211 (*val pos = ([4,1,1,1,2]) *)
212 val (pt,_) = cappend_atomic pt pos loc "3x^2 + d/dx ..."
213 Empty_Tac ("[4,1,1,1,2]:3x^2 + 0 + d/dx ...",[]) Complete;
214 val pos = lev_on pos;
215 (*pos = ([4,1,1,1,3]) *)
216 val (pt,_) = cappend_atomic pt pos loc "3x^2 + 0 + d/dx ..."
217 Empty_Tac ("[4,1,1,1,3]:3x^2 + 0 -3 ...",[]) Complete;
219 val pos = lev_up pos;
220 (*pos = ([4,1,1,1]) *)
221 val (pt,_) = append_result pt pos e_istate ("[4,1,1,1#]:3x^2 -3.",[])Complete;
223 val pos = lev_up pos;
224 (*val pos = ([4,1,1]) *)
225 val (pt,_) = append_result pt pos e_istate ("[4,1,1#]:found 3x^2 -3 ...",[])
228 val pos = lev_on pos;
229 (*val pos = ([4,1,2]+) *)
230 val (pt,_) = cappend_parent(*pbl*) pt pos loc "f_y = d/dy x^3 ..."
231 Empty_Tac TransitiveB;
233 writeln (pr_ptree pr_short pt);
237 1. {(a,b). is-max ...
238 1.1. {(a,b). is-max ...
239 1.2. {(a,b). is-extremum ...
240 2. {(a,b). f_x(a,b) ...
241 3. {(a,b). f_x & f_xx &...
242 3.1. {(a,b). f_x & f_xx & ...
243 3.2. {(a,b). f_x & f_xx } cup..
244 4. {(a,b). f_x ..} cup ...
246 4.1.1. f_x = d/dx x^3 ...
247 4.1.1.1. d/dx x^3 ...
248 4.1.1.1.1. d/dx x^3 ...
249 4.1.1.1.2. 3x^2 + d/dx ...
250 4.1.1.1.3. 3x^2 + 0 + d/dx ...
251 4.1.2. f_y = d/dy x^3 ...
253 use"test-max-surf1.sml";
255 -------------- 9.6.03 --- cappend_ ... term -------irreparabler test---*)
258 "--------- me .. scripts for maximum-example ---------------------";
259 "--------- me .. scripts for maximum-example ---------------------";
260 "--------- me .. scripts for maximum-example ---------------------";
263 ["fixedValues [r=Arbfix]","maximum A",
265 "relations [A=a*b, (a/2)^^^2 + (b/2)^^^2 = r^^^2]",
266 "relations [A=a*b, (a/2)^^^2 + (b/2)^^^2 = r^^^2]",
267 "relations [A=a*b, a/2=r*sin alpha, b/2=r*cos alpha]",
269 "boundVariable a","boundVariable b","boundVariable alpha",
270 "interval {x::real. 0 <= x & x <= 2*r}",
271 "interval {x::real. 0 <= x & x <= 2*r}",
272 "interval {x::real. 0 <= x & x <= pi}",
273 "errorBound (eps=(0::real))"];
275 ("DiffApp",["maximum_of","function"],
276 ["DiffApp","max_by_calculus"]);
278 val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
279 (*=== inhibit exn 110722=============================================================
280 val (p,_,f,nxt,_,pt) = me nxt p c pt;
281 val (p,_,f,nxt,_,pt) = me nxt p c pt;
282 val (p,_,f,nxt,_,pt) = me nxt p c pt;
283 val (p,_,f,nxt,_,pt) = me nxt p c pt;
284 val (p,_,f,nxt,_,pt) = (me nxt p c pt) handle e => OldGoals.print_exn e;
285 val (p,_,f,nxt,_,pt) = me nxt p c pt;
286 val (p,_,f,nxt,_,pt) = me nxt p c pt;
287 val (p,_,f,nxt,_,pt) = me nxt p c pt;
288 val (p,_,f,nxt,_,pt) = me nxt p c pt;
289 case nxt of (_, Specify_Method ["DiffApp","max_by_calculus"]) => ()
290 | _ => error "diffapp.sml: max-exp me, nxt = Specify_Method";
292 val oris = fst3 (get_obj g_origin pt (fst p)); writeln(oris2str oris);
293 val pits = get_obj g_pbl pt (fst p); writeln(itms2str_ ctxt pits);
295 val (p,_,f,nxt,_,pt) = me nxt p c pt;
296 val mits = get_obj g_met pt (fst p); writeln(itms2str_ ctxt mits);
297 val (p,_,f,nxt,_,pt) = me nxt p c pt;
298 val (p,_,f,nxt,_,pt) = me nxt p c pt;
299 val (p,_,f,nxt,_,pt) = me nxt p c pt;
300 case nxt of (_,Apply_Method ["DiffApp","max_by_calculus"] ) => ()
301 | _ => error "diffapp.sml: max-exp me, nxt = Apply_Method";
302 val (p,_,f,nxt,_,pt) = me nxt p c pt;
303 === inhibit exn 110722=============================================================*)
305 (*since 0508 Apply_Method does the 1st step, if NONE init_form -------------
306 (*val nxt = ("Subproblem",Subproblem ("DiffApp",["make","function"]))*)
307 val (p,_,f,nxt,_,pt) = (me nxt p c pt) handle e => print_exn_G e;
308 (*val nxt = ("Refine_Tacitly",Refine_Tacitly ["make","function"])*)
309 val (p,_,f,nxt,_,pt) = me nxt p c pt;
310 (*val nxt = ("Model_Problem",Model_Problem ["by_explicit","make","function"])*)
311 ----------------------------------------------------------------------------*)
312 case nxt of (_, Model_Problem(*["by_explicit", "make", "function"]*)) => ()
313 | _ => error "diffapp.sml: max-exp me, nxt = Model_Problem";
315 (*=== inhibit exn 110722=============================================================
316 val (p,_,f,nxt,_,pt) = me nxt p c pt;
317 val (p,_,f,nxt,_,pt) = me nxt p c pt;
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 === inhibit exn 110722=============================================================*)
323 val oris = fst3 (get_obj g_origin pt (fst p));writeln(oris2str oris);
324 val pits = get_obj g_pbl pt (fst p);writeln(itms2str_ ctxt pits);
326 (*=== inhibit exn 110722=============================================================
327 val (p,_,f,nxt,_,pt) = me nxt p c pt;
328 val (p,_,f,nxt,_,pt) = me nxt p c pt;
329 val (p,_,f,nxt,_,pt) = me nxt p c pt;
330 val (p,_,f,nxt,_,pt) = me nxt p c pt;
331 case nxt of (_, Apply_Method ["DiffApp", "make_fun_by_explicit"]) => ()
332 | _ => error "diffapp.sml: max-exp Apply_Method ([1], Met) ";
333 === inhibit exn 110722=============================================================*)
335 (*----since WN050901 (ie. corr. mathengine#nxt_specify_ ..nxt_spec Pbl->p_
337 val (p,_,f,nxt,_,pt) = me nxt p c pt;
339 ### assod: NotAss m= Subproblem' ,
342 (Subproblem (thy, [normalize, polynomial, univariate, equation])))]
343 (hd (filterVar A [A = a * b, (a / 2) ^^^ 2 + (b / 2) ^^^ 2 = r ^^^ 2]))
344 *** stac2tac_ TODO: no match for Substitute
346 *** (Subproblem (thy, [normalize, polynomial, univariate, equation])))]
347 *** (hd (filterVar A [A = a * b, (a / 2) ^^^ 2 + (b / 2) ^^^ 2 = r ^^^ 2]))
348 Exception- ERROR raised
350 ############################################################################
351 # presumerably didnt work before either, but not detected due to Emtpy_Tac #
352 ############################################################################
354 (*val nxt = Subproblem ("DiffApp",["univariate","equation"])) *)
355 val (p,_,f,nxt,_,pt) = me nxt p c pt;
356 (*val nxt = Refine_Tacitly ["univariate","equation"])*)
358 val oris = fst3 (get_obj g_origin pt (fst p));writeln(oris2str oris);
359 val pits = get_obj g_pbl pt (fst p);writeln(itms2str_ ctxt pits);
361 val (p,_,f,nxt,_,pt) = me nxt p c pt;
362 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 nxt = ("Apply_Method",Apply_Method ["PolyEq","normalize_poly"])*)
368 val (p,_,f,nxt,_,pt) = me nxt p c pt;
369 (*val f = Form' (FormKF (~1,EdUndef,3,Nundef,"A = a * b"))*)
370 val (p,_,f,nxt,_,pt) = me nxt p c pt;
371 val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
372 val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
373 val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
374 val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
375 val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
376 val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
377 val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
378 (*val f = Form' (FormKF (~1,EdUndef,4,Nundef,"[b = A / a]"))*)
380 ------------------------------------------------------------------------*)
383 Error' (Error_ "Refine_Tacitly [\"univariate\",\"equation\"] not applicable")*)
386 (*----postponed.15.5.03 run scripts for maximum-example: univariate equation*)
387 (*=== inhibit exn 110722=============================================================
389 val (p,_,f,nxt,_,pt) = (me nxt p c pt) handle e => OldGoals.print_exn e;
390 === inhibit exn 110722=============================================================*)
392 val oris = fst3 (get_obj g_origin pt (fst p));writeln(oris2str oris);
394 val pits = get_obj g_pbl pt (fst p);writeln(itms2str_ ctxt pits);
395 val pits = get_obj g_pbl pt [];writeln(itms2str_ ctxt pits);
397 val mits = get_obj g_met pt (fst p);writeln(itms2str_ ctxt mits);
398 val mits = get_obj g_met pt [];writeln(itms2str_ ctxt mits);
400 (*=== inhibit exn 110722=============================================================
401 itms2args thy ["DiffApp","max_by_calculus"] mits;
403 val (p,_,f,nxt,_,pt) = me nxt p c pt;
404 === inhibit exn 110722=============================================================*)
408 "--------- autoCalc .. scripts for maximum-example ---------------";
409 "--------- autoCalc .. scripts for maximum-example ---------------";
410 "--------- autoCalc .. scripts for maximum-example ---------------";
411 (*++++++++ see systest/inform.sml 'complete_metitms' ++++++++*)
414 ["fixedValues [r=Arbfix]","maximum A",
416 "relations [A=a*b, (a/2)^2 + (b/2)^2 = r^2]",
417 "relations [A=a*b, (a/2)^2 + (b/2)^2 = r^2]",
418 "relations [A=a*b, a/2=r*sin alpha, b/2=r*cos alpha]",
420 "boundVariable a","boundVariable b","boundVariable alpha",
421 "interval {x::real. 0 <= x & x <= 2*r}",
422 "interval {x::real. 0 <= x & x <= 2*r}",
423 "interval {x::real. 0 <= x & x <= pi}",
424 "errorBound (eps=(0::real))"];
426 ("DiffApp",["maximum_of","function"],
427 ["DiffApp","max_by_calculus"]);
429 CalcTree [(fmz, (dI',pI',mI'))];
430 Iterator 1; moveActiveRoot 1;
431 autoCalculate 1 CompleteCalcHead;
432 refFormula 1 (get_pos 1 1);
434 fetchProposedTactic 1;
435 autoCalculate 1 (Step 1);
437 fetchProposedTactic 1;
438 autoCalculate 1 (Step 1);
439 (*Subproblem on_interval maximum_of function*)
440 autoCalculate 1 CompleteCalcHead;
442 fetchProposedTactic 1;
443 val ((pt,p),_) = get_calc 1;
444 val mits = get_obj g_met pt (fst p);
445 writeln (itms2str_ ctxt mits);
447 if itms2str_ 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 ()
448 else error "diffapp.sml: diff.behav. in autoCalc .. scripts for max 1";
450 (*FIXME: the environments contain identifers, and NOT values ?!?!?*)
451 (* WN051209 while extending 'fun step' for initac, this became better ...
452 if itms2str_ 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) ^^^ 2 + (b / 2) ^^^ 2 = r ^^^ 2] ,(r_s, [[A = a * b],[(a / 2) ^^^ 2 + (b / 2) ^^^ 2 = r ^^^ 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 ()
453 else error "diffapp.sml: diff.behav. in autoCalc .. scripts for max 1";
458 "--------------------- 30.4.03: maximum .. rewrite_set_ list_rls ---------";
459 "--------------------- 30.4.03: maximum .. rewrite_set_ list_rls ---------";
460 "--------------------- 30.4.03: maximum .. rewrite_set_ list_rls ---------";
462 "Script Maximum_value(f_ix::bool list)(m_m::real) (r_s::bool list)\
463 \ (v_v::real) (itv_v::real set) (err_r::bool) = \
464 \ (let e_e = (hd o (filterVar m_m)) r_s; \
465 \ t_t = (if 1 < length_h r_s \
466 \ then (SubProblem (Reals_s,[make,function],[no_met])\
467 \ [REAL m_m, REAL v_v, BOOL_LIST r_s])\
469 \ (mx_x::real) = SubProblem (Reals_s,[on_interval,max_of,function], \
470 \ [Isac,maximum_on_interval])\
471 \ [BOOL t_t, REAL v_v, REAL_SET itv_v]\
472 \ in ((SubProblem (Reals_s,[find_values,tool],[Isac,find_values]) \
473 \ [REAL mx_x, REAL (Rhs t_t), REAL v_v, REAL m_m, \
474 \ BOOL_LIST (dropWhile (ident e_e) r_s)])::bool list))";
476 val f_ix = (str2term "f_ix::bool list",
477 str2term "[r=Arbfix]");
478 val m_m = (str2term "m_m::real",
480 val r_s = (str2term "rs_s::bool list",
481 str2term "[A = a*b, (a/2)^^^2 + (b/2)^^^2 = r^^^2]");
482 val v_v = (str2term "v_v::real",
484 val itv_v = (str2term "itv_v::real set",
485 str2term "{x::real. 0 <= x & x <= 2*r}");
486 val err_r = (str2term "err_r::bool",
488 val env = [f_ix, m_m, r_s ,v_v, itv_v, err_r];
490 (*--- 1.line in script ---*)
491 val t = str2term "(hd o (filterVar m_m)) (r_s::bool list)";
492 val s = subst_atomic env t;
494 "(hd o filterVar A) [A = a * b, (a / 2) ^^^ 2 + (b / 2) ^^^ 2 = r ^^^ 2]";
495 (*=== inhibit exn 110726=============================================================
496 val SOME (s',_) = rewrite_set_ thy false list_rls s;
497 val s'' = term2str s';
498 if s''="A = a * b" then () else error "new behaviour with list_rls 1.1.";
499 === inhibit exn 110726=============================================================*)
500 val env = env @ [(str2term "e_e::bool",str2term "A = a * b")];
502 (*--- 2.line: condition alone ---*)
503 val t = str2term "1 < length_h (r_s::bool list)";
504 val s = subst_atomic env t;
506 "1 < length_h [A = a * b, (a / 2) ^^^ 2 + (b / 2) ^^^ 2 = r ^^^ 2]";
507 (*=== inhibit exn 110726=============================================================
508 val SOME (s',_) = rewrite_set_ thy false list_rls s;
509 val s'' = term2str s';
510 if s''="HOL.True" then () else error "new behaviour with list_rls 1.2.";
511 === inhibit exn 110726=============================================================*)
513 (*--- 2.line in script ---*)
515 "(if 1 < length_h r_s \
516 \ then (SubProblem (Reals_s,[make,function],[no_met])\
517 \ [REAL m_m, REAL v_v, BOOL_LIST r_s])\
519 val s = subst_atomic env t;
521 "if 1 < length_h [A = a * b, (a / 2) ^^^ 2 + (b / 2) ^^^ 2 = r ^^^ 2]\
522 \then SubProblem (Reals_s, [make, function], [no_met])\
524 \ BOOL_LIST [A = a * b, (a / 2) ^^^ 2 + (b / 2) ^^^ 2 = r ^^^ 2]]\
525 \else hd [A = a * b, (a / 2) ^^^ 2 + (b / 2) ^^^ 2 = r ^^^ 2]";
526 (*=== inhibit exn 110726=============================================================
527 val SOME (s',_) = rewrite_set_ thy false list_rls s;
528 val s'' = term2str s';
530 "SubProblem (Reals_s, [make, function], [no_met])\n\
531 \ [REAL A, REAL b,\n\
532 \ BOOL_LIST [A = a * b, (a / 2) ^^^ 2 + (b / 2) ^^^ 2 = r ^^^ 2]]" then ()
533 else error "new behaviour with list_rls 1.3.";
534 === inhibit exn 110726=============================================================*)
535 val env = env @ [(str2term "t_t::bool",
536 str2term "A = (2*sqrt(r^^^2-(b/2)^^^2)) * b")];
540 "---------------------- 1.5.03: Make_fun_by_explicit ---------------------";
541 "---------------------- 1.5.03: Make_fun_by_explicit ---------------------";
542 "---------------------- 1.5.03: Make_fun_by_explicit ---------------------";
544 "Script Make_fun_by_explicit (f_f::real) (v_v::real) \
545 \ (eqs::bool list) = \
546 \ (let h_h = (hd o (filterVar f_f)) eqs; \
547 \ e_1 = hd (dropWhile (ident h_h) eqs); \
548 \ v_s = dropWhile (ident f_f) (Vars h_h); \
549 \ v_1 = hd (dropWhile (ident v_v) v_s); \
550 \ (s_1::bool list)=(SubProblem(Reals_s,[univar,equation],[no_met])\
551 \ [BOOL e_1, REAL v_1])\
552 \ in Substitute [(v_1 = (rhs o hd) s_1)] h_h)";
553 val f_f = (str2term "f_f::real",
555 val v_v = (str2term "v_v::real",
557 val eqs=(str2term "eqs::bool list",
558 str2term "[A = a * b, (a / 2) ^^^ 2 + (b / 2) ^^^ 2 = r ^^^ 2]");
559 val env = [f_f, v_v, eqs];
561 (*--- 1.line in script ---*)
562 val t = str2term "(hd o (filterVar v_v)) (eqs::bool list)";
563 val s = subst_atomic env t;
566 "(hd o filterVar b) [A = a * b, (a / 2) ^^^ 2 + (b / 2) ^^^ 2 = r ^^^ 2]";
567 val SOME (t',_) = rewrite_set_ thy false list_rls t;
568 val s' = term2str t';
569 (*=== inhibit exn 110726=============================================================
570 if s' = "A = a * b" then () else error "new behaviour with list_rls 2.1";
571 === inhibit exn 110726=============================================================*)
572 val env = env @ [(str2term "h_h::bool", str2term s')];
574 (*--- 2.line in script ---*)
575 val t = str2term "hd (dropWhile (ident h_h) (eqs::bool list))";
576 val s = subst_atomic env t;
579 "hd (dropWhile (ident (A = a * b))\
580 \ [A = a * b, (a / 2) ^^^ 2 + (b / 2) ^^^ 2 = r ^^^ 2])";
581 (*=== inhibit exn 110726=============================================================
582 mem_rls "dropWhile_Cons" list_rls;
583 mem_rls "Atools.ident" list_rls;
584 val SOME (t',_) = rewrite_set_ thy false list_rls t;
585 val s' = term2str t';
586 if s' = "(a / 2) ^^^ 2 + (b / 2) ^^^ 2 = r ^^^ 2" then ()
587 else error "new behaviour with list_rls 2.2";
588 === inhibit exn 110726=============================================================*)
589 val env = env @ [(str2term "e_1::bool", str2term s')];
591 (*--- 3.line in script ---*)
592 val t = str2term "dropWhile (ident f_f) (Vars (h_h::bool))";
593 val s = subst_atomic env t;
595 val t = str2term "dropWhile (ident A) (Vars (A = a * b))";
596 (*=== inhibit exn 110726=============================================================
597 val SOME (t',_) = rewrite_set_ thy false list_rls t;
598 val s' = term2str t';
599 if s' = "[a, b]" then () else error "new behaviour with list_rls 2.3";
600 === inhibit exn 110726=============================================================*)
601 val env = env @ [(str2term "vs_s::real list", str2term s')];
603 (*--- 4.line in script ---*)
604 val t = str2term "hd (dropWhile (ident v_v) v_s)";
605 val s = subst_atomic env t;
607 val t = str2term "hd (dropWhile (ident b) [a, b])";
608 (*=== inhibit exn 110726=============================================================
609 val SOME (t',_) = rewrite_set_ thy false list_rls t;
610 val s' = term2str t';
611 if s' = "a" then () else error "new behaviour with list_rls 2.4.";
612 === inhibit exn 110726=============================================================*)
613 val env = env @ [(str2term "v_1::real", str2term s')];
615 (*--- 5.line in script ---*)
616 val t = str2term "(SubProblem(Reals_s,[univar,equation],[no_met])\
617 \ [BOOL e_1, REAL v_1])";
618 val s = subst_atomic env t;
620 "SubProblem (Reals_s, [univar, equation], [no_met])\n\
621 \ [BOOL ((a / 2) ^^^ 2 + (b / 2) ^^^ 2 = r ^^^ 2), REAL a]";
622 val env = env @ [(str2term "s_1::bool list",
623 str2term "[a = 2 * sqrt (r^^^2 - (b/2)^^^2)]")];
625 (*--- 6.line in script ---*)
626 val t = str2term "Substitute [(v_1 = (rhs o hd) (s_1::bool list))] (h_h::bool)";
627 val s = subst_atomic env t;
630 "Substitute [(a = (rhs o hd) [a = 2 * sqrt (r ^^^ 2 - (b / 2) ^^^ 2)])]\n\
632 (*=== inhibit exn 110726=============================================================
633 mem_rls "Tools.rhs" list_rls;
634 val SOME (t',_) = rewrite_set_ thy false list_rls t;
635 val s' = term2str t';
636 if s' = "Substitute [a = 2 * sqrt (r ^^^ 2 - (b / 2) ^^^ 2)] (A = a * b)"
637 then () else error "new behaviour with list_rls 2.6.";
638 === inhibit exn 110726=============================================================*)
641 "---------------------- 2.5.03: Make_fun_by_new_variable -----------------";
642 "---------------------- 2.5.03: Make_fun_by_new_variable -----------------";
643 "---------------------- 2.5.03: Make_fun_by_new_variable -----------------";
645 "Script Make_fun_by_new_variable (f_f::real) (v_v::real) \
646 \ (eqs::bool list) = \
647 \(let h_h = (hd o (filterVar f_f)) eqs; \
648 \ es_s = dropWhile (ident h_h) eqs; \
649 \ v_s = dropWhile (ident f_f) (Vars h_h); \
650 \ v_1 = nth_h 1 v_s; \
651 \ v_2 = nth_h 2 v_s; \
652 \ e_1 = (hd o (filterVar v_1)) es_s; \
653 \ e_2 = (hd o (filterVar v_2)) es_s; \
654 \ (s_1::bool list) = (SubProblem (Reals_s,[univar,equation],[no_met])\
655 \ [BOOL e_1, REAL v_1]);\
656 \ (s_2::bool list) = (SubProblem (Reals_s,[univar,equation],[no_met])\
657 \ [BOOL e_2, REAL v_2])\
658 \in Substitute [(v_1 = (rhs o hd) s_1),(v_2 = (rhs o hd) s_2)] h_h)";
659 val f_ = (str2term "f_f::real",
661 val v_v = (str2term "v_v::real",
663 val eqs=(str2term "eqs::bool list",
664 str2term "[A=a*b, a/2=r*sin alpha, b/2=r*cos alpha]");
665 val env = [f_f, v_v, eqs];
667 (*--- 1.line in script ---*)
668 val t = str2term "(hd o (filterVar (f_f::real))) (eqs::bool list)";
669 val s = subst_atomic env t;
672 "(hd o filterVar A) [A = a * b, a / 2 = r * sin alpha, b / 2 = r * cos alpha]";
674 val SOME (t',_) = rewrite_set_ thy false list_rls t;
675 trace_rewrite:=false;
676 val s' = term2str t';
677 (*=== inhibit exn 110726=============================================================
678 if s' = "A = a * b" then() else error "new behaviour with list_rls 3.1.";
679 val env = env @ [(str2term "h_h::bool", str2term s')];
680 === inhibit exn 110726=============================================================*)
682 (*--- 2.line in script ---*)
683 val t = str2term "dropWhile (ident (h_h::bool)) (eqs::bool list)";
684 val s = subst_atomic env t;
687 "dropWhile (ident (A = a * b))\
688 \ [A = a * b, a / 2 = r * sin alpha, b / 2 = r * cos alpha]";
689 (*=== inhibit exn 110726=============================================================
690 val SOME (t',_) = rewrite_set_ thy false list_rls t;
691 val s' = term2str t';
692 if s' = "[a / 2 = r * sin alpha, b / 2 = r * cos alpha]"
693 then () else error "new behaviour with list_rls 3.2.";
694 === inhibit exn 110726=============================================================*)
695 val env = env @ [(str2term "es_s::bool list", str2term s')];
697 (*--- 3.line in script ---*)
698 val t = str2term "dropWhile (ident (f_f::real)) (Vars (h_h::bool))";
699 val s = subst_atomic env t;
701 val t = str2term "dropWhile (ident A) (Vars (A = a * b))";
702 (*=== inhibit exn 110726=============================================================
703 val SOME (t',_) = rewrite_set_ thy false list_rls t;
704 val s' = term2str t';
705 if s' = "[a, b]" then () else error "new behaviour with list_rls 3.3.";
706 === inhibit exn 110726=============================================================*)
707 val env = env @ [(str2term "vs_s::real list", str2term s')];
709 (*--- 4.line in script ---*)
710 val t = str2term "nth_h 1 v_s";
711 val s = subst_atomic env t;
713 val t = str2term "nth_h 1 [a, b]";
714 (*=== inhibit exn 110726=============================================================
715 val SOME (t',_) = rewrite_set_ thy false list_rls t;
716 val s' = term2str t';
717 if s' = "a" then () else error "new behaviour with list_rls 3.4.";
718 === inhibit exn 110726=============================================================*)
719 val env = env @ [(str2term "v_1", str2term s')];
721 (*--- 5.line in script ---*)
722 val t = str2term "nth_h 2 v_s";
723 val s = subst_atomic env t;
725 val t = str2term "nth_h 2 [a, b]";
726 (*=== inhibit exn 110726=============================================================
727 val SOME (t',_) = rewrite_set_ thy false list_rls t;
728 val s' = term2str t';
729 if s' = "b" then () else error "new behaviour with list_rls 3.5.";
730 === inhibit exn 110726=============================================================*)
731 val env = env @ [(str2term "v_2", str2term s')];
733 (*--- 6.line in script ---*)
734 val t = str2term "(hd o (filterVar v_1)) (es_s::bool list)";
735 val s = subst_atomic env t;
738 "(hd o filterVar a) [a / 2 = r * sin alpha, b / 2 = r * cos alpha]";
739 val SOME (t',_) = rewrite_set_ thy false list_rls t;
740 val s' = term2str t';
741 (*=== inhibit exn 110726=============================================================
742 if s' = "a / 2 = r * sin alpha" then ()
743 else error "new behaviour with list_rls 3.6.";
744 === inhibit exn 110726=============================================================*)
745 val e_1 = str2term "e_1::bool";
746 val env = env @ [(e_1, str2term s')];
748 (*--- 7.line in script ---*)
749 val t = str2term "(hd o (filterVar v_2)) (es_s::bool list)";
750 val s = subst_atomic env t;
753 "(hd o filterVar b) [a / 2 = r * sin alpha, b / 2 = r * cos alpha]";
754 val SOME (t',_) = rewrite_set_ thy false list_rls t;
755 val s' = term2str t';
756 (*=== inhibit exn 110726=============================================================
757 if s' = "b / 2 = r * cos alpha" then ()
758 else error "new behaviour with list_rls 3.7.";
759 === inhibit exn 110726=============================================================*)
760 val env = env @ [(str2term "e_2::bool", str2term s')];
762 (*--- 8.line in script ---*)
763 val t = str2term "(SubProblem (Reals_s,[univar,equation],[no_met])\
764 \ [BOOL e_1, REAL v_1])";
765 val s = subst_atomic env t;
767 "SubProblem (Reals_s, [univar, equation], [no_met])\
768 \ [BOOL (a / 2 = r * sin alpha), REAL a]";
769 val s_1 = str2term "[a = 2*r*sin alpha]";
770 val env = env @ [(str2term "s_1::bool list", s_1)];
772 (*--- 9.line in script ---*)
773 val t = str2term "(SubProblem (Reals_s,[univar,equation],[no_met])\
774 \ [BOOL e_2, REAL v_2])";
775 val s = subst_atomic env t;
777 "SubProblem (Reals_, [univar, equation], [no_met])\
778 \ [BOOL (b / 2 = r * cos alpha), REAL b]";
779 val s_2 = str2term "[b = 2*r*cos alpha]";
780 val env = env @ [(str2term "s_2::bool list", s_2)];
782 (*--- 10.line in script ---*)
784 "Substitute [(v_1 = (rhs o hd) s_1),(v_2 = (rhs o hd) s_2)] (h_h::bool)";
785 val s = subst_atomic env t;
787 "Substitute\n [(a = (rhs o hd) [a = 2 * r * sin alpha]),\
788 \ (b = (rhs o hd) [b = 2 * r * cos alpha])] (A = a * b)";
789 val SOME (s',_) = rewrite_set_ thy false list_rls s;
790 val s'' = term2str s';
791 (*=== inhibit exn 110726=============================================================
793 "Substitute [a = 2 * r * sin alpha, b = 2 * r * cos alpha] (A = a * b)"
794 then () else error "new behaviour with list_rls 3.10.";
795 ===== inhibit exn 110722===========================================================*)