1 (* Title: tests on calchead.sml
2 Author: Walther Neuper 051013,
3 (c) due to copyright terms
5 12345678901234567890123456789012345678901234567890123456789012345678901234567890
6 10 20 30 40 50 60 70 80
9 "--------------------------------------------------------";
10 "table of contents --------------------------------------";
11 "--------------------------------------------------------";
12 "--------- get_interval after replace} other 2 ----------";
13 "--------- maximum example with 'specify' ---------------";
14 "--------- maximum example with 'specify', fmz <> [] ----";
15 "--------- maximum example with 'specify', fmz = [] -----";
16 "--------- match_ags, is_cp, cpy_nam +with EqSystem (!)--";
17 "--------- regression test fun is_copy_named ------------";
18 "--------- regr.test fun cpy_nam ------------------------";
19 "--------- check specify phase --------------------------";
20 "--------------------------------------------------------";
21 "--------------------------------------------------------";
22 "--------------------------------------------------------";
24 (*========== inhibit exn =======================================================
25 "--------- get_interval after replace} other 2 ----------";
26 "--------- get_interval after replace} other 2 ----------";
27 "--------- get_interval after replace} other 2 ----------";
29 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
30 ("Test", ["sqroot-test","univariate","equation","test"],
31 ["Test","squ-equ-test-subpbl1"]))];
34 autoCalculate 1 CompleteCalc;
35 moveActiveFormula 1 ([2],Res); (*there is "-1 + x = 0"*)
36 replaceFormula 1 "x = 1";
37 (*... returns calcChangedEvent with ...*)
38 val (unc, del, gen) = (([1],Res), ([4],Res), ([3,2],Res));
39 val ((pt,_),_) = get_calc 1;
41 print_depth 99;map fst (get_interval ([],Pbl) ([],Res) 9999 pt);print_depth 3;
42 if map fst (get_interval ([],Pbl) ([],Res) 9999 pt) =
43 [([], Pbl), ([1], Frm),([1], Res), ([2], Res), ([3], Pbl), ([3, 1], Frm),
44 ([3, 1], Res), ([3, 2, 1], Frm), ([3, 2, 1], Res), ([3, 2, 2], Res),
45 ([3, 2], Res)] then () else
46 error "calchead.sml: diff.behav. get_interval after replace} other 2 a";
48 print_depth 99;map fst (get_interval ([3, 2, 1], Res) ([],Res) 9999 pt);
50 if map fst (get_interval ([3, 2, 1], Res) ([],Res) 9999 pt) =
51 [([3, 2, 1], Res), ([3, 2, 2], Res), ([3, 2], Res)] then () else
52 error "modspec.sml: diff.behav. get_interval after replace} other 2 b";
57 "--------- maximum example with 'specify' ------------------------";
58 "--------- maximum example with 'specify' ------------------------";
59 "--------- maximum example with 'specify' ------------------------";
60 (*" Specify_Problem (match_itms_oris) ";*)
62 ["fixedValues [r=Arbfix]","maximum A",
64 "relations [A=a*b, (a/2)^^^2 + (b/2)^^^2 = r^^^2]",
65 "relations [A=a*b, (a/2)^^^2 + (b/2)^^^2 = r^^^2]",
66 "relations [A=a*b, a/2=r*sin alpha, b/2=r*cos alpha]",
68 "boundVariable a","boundVariable b","boundVariable alpha",
69 "interval {x::real. 0 <= x & x <= 2*r}",
70 "interval {x::real. 0 <= x & x <= 2*r}",
71 "interval {x::real. 0 <= x & x <= pi}",
72 "errorBound (eps=(0::real))"];
74 ("DiffApp",["maximum_of","function"],
75 ["DiffApp","max_by_calculus"]);
78 (*val nxt = Init_Proof' (fmz,(dI',pI',mI'));
79 val(p,_,Form'(PpcKF(_,_,_,_,ppc)),nxt,_,pt) = specify nxt e_pos' [] EmptyPtree;
81 val (p,_,f,(_,nxt),_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
82 val nxt = tac2tac_ pt p nxt;
83 val(p,_,Form'(PpcKF(_,_,_,_,ppc)),nxt,_,pt) = specify nxt p [] pt;
84 (*val nxt = Add_Given "fixedValues [(r::real) = Arbfix]" : tac*)
86 val nxt = tac2tac_ pt p nxt;
87 val(p,_,Form'(PpcKF(_,_,_,_,ppc)),nxt,_,pt) = specify nxt p [] pt;
91 val nxt = tac2tac_ pt p (Add_Find "valuesFor [(a::real)]");
92 val(p,_,Form'(PpcKF(_,_,_,_,ppc)),nxt,_,pt) = specify nxt p [] pt;
93 (*uncaught exception TYPE 6.5.03*)
96 {Find=[Incompl "maximum",Incompl "valuesFor [a]"],
97 Given=[Correct "fixedValues [r = Arbfix]"],
98 Relate=[Incompl "relations []"], Where=[],With=[]})
99 then error "test-maximum.sml: model stepwise - different behaviour"
100 else (); (*different with show_types !!!*)
103 (*-----appl_add should not create Error', but accept as Sup,Syn
104 val nxt = tac2tac_ pt p (Add_Given "boundVariable a");
105 val(p,_,Form'(PpcKF(_,_,_,_,ppc)),nxt,_,pt) = specify nxt p [] pt;
107 val nxt = tac2tac_ pt p (Add_Given "boundVariable a+");
108 val(p,_,Form'(PpcKF(_,_,_,_,ppc)),nxt,_,pt) = specify nxt p [] pt;
111 val m = Specify_Problem ["maximum_of","function"];
112 val nxt = tac2tac_ pt p m;
113 val(p,_,Form'(PpcKF(_,_,_,_,ppc)),nxt,_,pt) = specify nxt p [] pt;
116 if ppc<>(Problem ["maximum_of","function"],
117 {Find=[Incompl "maximum",Incompl "valuesFor"],
118 Given=[Correct "fixedValues [r = Arbfix]"],
119 Relate=[Incompl "relations []"], Where=[],With=[]})
120 then error "diffappl.sml: Specify_Problem different behaviour"
122 (* WN.3.9.03 (#391) Model_Specify did init_pbl newly
123 if ppc<>(Problem ["maximum_of","function"],
124 {Find=[Missing "maximum m_",Missing "valuesFor vs_"],
125 Given=[Correct "fixedValues [r = Arbfix]"],
126 Relate=[Missing "relations rs_"],Where=[],With=[]})
127 then error "diffappl.sml: Specify_Problem different behaviour"
130 val nxt = tac2tac_ pt p(Specify_Method ["DiffApp","max_by_calculus"]);
131 val(p,_,Form'(PpcKF(_,_,_,_,ppc)),nxt,_,pt) = specify nxt p [] pt;
134 if ppc<>(Method ["DiffApp","max_by_calculus"],
135 {Find=[Incompl "maximum",Incompl "valuesFor"],
136 Given=[Correct "fixedValues [r = Arbfix]",Missing "boundVariable v_v",
137 Missing "interval itv_",Missing "errorBound err_"],
138 Relate=[Incompl "relations []"],Where=[],With=[]})
139 then error "diffappl.sml: Specify_Method different behaviour"
141 (* WN.3.9.03 (#391) Model_Specify did init_pbl newly
142 if ppc<>(Method ["DiffApp","max_by_calculus"],
143 {Find=[Missing "maximum m_",Missing "valuesFor vs_"],
144 Given=[Correct "fixedValues [r = Arbfix]",Missing "boundVariable v_v",
145 Missing "interval itv_",Missing "errorBound err_"],
146 Relate=[Missing "relations rs_"],Where=[],With=[]})
147 then error "diffappl.sml: Specify_Method different behaviour"
152 "--------- maximum example with 'specify', fmz <> [] -------------";
153 "--------- maximum example with 'specify', fmz <> [] -------------";
154 "--------- maximum example with 'specify', fmz <> [] -------------";
156 ["fixedValues [r=Arbfix]","maximum A",
158 "relations [A=a*b, (a/2)^^^2 + (b/2)^^^2 = r^^^2]",
159 "relations [A=a*b, (a/2)^^^2 + (b/2)^^^2 = r^^^2]",
160 "relations [A=a*b, a/2=r*sin alpha, b/2=r*cos alpha]",
162 "boundVariable a","boundVariable b","boundVariable alpha",
163 "interval {x::real. 0 <= x & x <= 2*r}",
164 "interval {x::real. 0 <= x & x <= 2*r}",
165 "interval {x::real. 0 <= x & x <= pi}",
166 "errorBound (eps=(0::real))"];
168 ("DiffApp",["maximum_of","function"],
169 ["DiffApp","max_by_calculus"]);
171 (*val nxt = Init_Proof' (fmz,(dI',pI',mI'));*)
172 val (p,_,f,(_,nxt),_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
174 val nxt = tac2tac_ pt p nxt;
175 val(p,_,Form'(PpcKF(_,_,_,_,ppc)),nxt,_,pt) = specify nxt e_pos' [] pt;
176 val nxt = tac2tac_ pt p nxt;
177 val(p,_,Form'(PpcKF(_,_,_,_,ppc)),nxt,_,pt) = specify nxt p [] pt;
178 (*val nxt = Add_Given "fixedValues [(r::real) = Arbfix]" : tac*)
180 val nxt = tac2tac_ pt p nxt;
181 val(p,_,Form'(PpcKF(_,_,_,_,ppc)),nxt,_,pt) = specify nxt p [] pt;
182 (*val nxt = Add_Find "maximum (A::bool)" : tac*)
184 val nxt = tac2tac_ pt p nxt;
185 val(p,_,Form'(PpcKF(_,_,_,_,ppc)),nxt,_,pt) = specify nxt p [] pt;
186 (*val nxt = Add_Find "valuesFor [(a::real)]" : tac*)
188 val nxt = tac2tac_ pt p nxt;
189 val(p,_,Form'(PpcKF(_,_,_,_,ppc)),nxt,_,pt) = specify nxt p [] pt;
190 (*val nxt = Add_Find "valuesFor [(b::real)]" : tac*)
192 val nxt = tac2tac_ pt p nxt;
193 val(p,_,Form'(PpcKF(_,_,_,_,ppc)),nxt,_,pt) = specify nxt p [] pt;
194 (*val nxt = Add_Relation "relations [A = a * b]" *)
196 val nxt = tac2tac_ pt p nxt;
197 val(p,_,Form'(PpcKF(_,_,_,_,ppc)),nxt,_,pt) = specify nxt p [] pt;
198 (*Add_Relation "relations\n [((a::real) // (#2::real)) ..."*)
200 (*---------------------------- FIXXXXME.meNEW !!! partial Add-Relation !!!
201 nxt_specif <> specify ?!
203 if nxt<>(Add_Relation
204 "relations [(a / 2) ^^^ 2 + (b / 2) ^^^ 2 = r ^^^ 2]")
205 then error "test specify, fmz <> []: nxt <> Add_Relation (a/2)^2.." else (); (*different with show_types !!!*)
207 val nxt = tac2tac_ pt p nxt;
208 val(p,_,Form'(PpcKF(_,_,_,_,ppc)),nxt,_,pt) = specify nxt p [] pt;
209 ------------------------------ FIXXXXME.meNEW !!! ---*)
211 (*val nxt = Specify_Theory "DiffApp" : tac*)
213 val itms = get_obj g_pbl pt (fst p);writeln(itms2str_ ctxt itms);
215 val nxt = tac2tac_ pt p nxt;
216 val(p,_,Form'(PpcKF(_,_,_,_,ppc)),nxt,_,pt) = specify nxt p [] pt;
217 (*val nxt = Specify_Problem ["maximum_of","function"]*)
219 val nxt = tac2tac_ pt p nxt;
220 val(p,_,Form'(PpcKF(_,_,_,_,ppc)),nxt,_,pt) = specify nxt p [] pt;
221 (*val nxt = Specify_Method ("DiffApp","max_by_calculus")*)
223 val nxt = tac2tac_ pt p nxt;
224 val(p,_,Form'(PpcKF(_,_,_,_,ppc)),nxt,_,pt) = specify nxt p [] pt;
225 (*val nxt = Add_Given "boundVariable a" : tac*)
227 val nxt = tac2tac_ pt p nxt;
228 val(p,_,Form'(PpcKF(_,_,_,_,ppc)),nxt,_,pt) = specify nxt p [] pt;
229 (*val nxt = Add_Given "interval {x. #0 <= x & x <= #2 * r}" : *)
231 val nxt = tac2tac_ pt p nxt;
232 val(p,_,Form'(PpcKF(_,_,_,_,ppc)),nxt,_,pt) = specify nxt p [] pt;
233 (*val nxt = Add_Given "errorBound (eps = #0)" : tac*)
235 val nxt = tac2tac_ pt p nxt;
236 val(p,_,Form'(PpcKF(_,_,_,_,ppc)),nxt,_,pt) = specify nxt p [] pt;
237 (*val nxt = Apply_Method ("DiffApp","max_by_calculus") *)
238 if nxt<>(Apply_Method ["DiffApp","max_by_calculus"])
239 then error "test specify, fmz <> []: nxt <> Apply_Method max_by_calculus" else ();
242 "--------- maximum example with 'specify', fmz = [] --------------";
243 "--------- maximum example with 'specify', fmz = [] --------------";
244 "--------- maximum example with 'specify', fmz = [] --------------";
246 val (dI',pI',mI') = empty_spec;
249 val nxt = Init_Proof' (fmz,(dI',pI',mI'));(*!!!!!!!!*)
250 (*val (p,_,f,(_,nxt),_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))]; !!!*)
251 val(p,_,Form'(PpcKF(_,_,_,_,ppc)),nxt,_,pt) = specify nxt e_pos' []
253 val nxt = tac2tac_ pt p nxt;
254 val(p,_,Form'(PpcKF(_,_,_,_,ppc)),nxt,_,pt) = specify nxt p [] pt;
255 (*val nxt = Specify_Theory "e_domID" : tac*)
257 val nxt = Specify_Theory "DiffApp";
258 val nxt = tac2tac_ pt p nxt;
259 val(p,_,Form'(PpcKF(_,_,_,_,ppc)),nxt,_,pt) = specify nxt p [] pt;
260 (*val nxt = Specify_Problem ["e_pblID"] : tac*)
262 val nxt = Specify_Problem ["maximum_of","function"];
263 val nxt = tac2tac_ pt p nxt;
264 val(p,_,Form'(PpcKF(_,_,_,_,ppc)),nxt,_,pt) = specify nxt p [] pt;
265 (*val nxt = Add_Given "fixedValues" : tac*)
267 val nxt = Add_Given "fixedValues [r=Arbfix]";
268 val nxt = tac2tac_ pt p nxt;
269 val(p,_,Form'(PpcKF(_,_,_,_,ppc)),nxt,_,pt) = specify nxt p [] pt;
270 (*val nxt = Add_Find "maximum" : tac*)
272 val nxt = Add_Find "maximum A";
273 val nxt = tac2tac_ pt p nxt;
276 val(p,_,Form'(PpcKF(_,_,_,_,ppc)),nxt,_,pt) = specify nxt p [] pt;
277 (*val nxt = Add_Find "valuesFor" : tac*)
279 val nxt = Add_Find "valuesFor [a]";
280 val nxt = tac2tac_ pt p nxt;
281 val(p,_,Form'(PpcKF(_,_,_,_,ppc)),nxt,_,pt) = specify nxt p [] pt;
282 (*val nxt = Add_Relation "relations" ---
283 --- [b=Arbfix] KANN NICHT VERLANGT WERDEN !!!!*)
285 (*30.8.01 ... funktioniert nicht mehr nach Einfuehrung env ....
286 if nxt<>(Add_Relation "relations []")
287 then error "test specify, fmz <> []: nxt <> Add_Relation.."
288 else (); (*different with show_types !!!*)
291 val nxt = Add_Relation "relations [(A=a+b)]";
292 val nxt = tac2tac_ pt p nxt;
293 val(p,_,Form'(PpcKF(_,_,_,_,ppc)),nxt,_,pt) = specify nxt p [] pt;
294 (*val nxt = Specify_Method ("e_domID","e_metID") : tac*)
296 val nxt = Specify_Method ["DiffApp","max_by_calculus"];
297 val nxt = tac2tac_ pt p nxt;
298 val(p,_,Form'(PpcKF(_,_,_,_,ppc)),nxt,_,pt) = specify nxt p [] pt;
299 (*val nxt = Add_Given "boundVariable" : tac*)
301 val nxt = Add_Given "boundVariable alpha";
302 val nxt = tac2tac_ pt p nxt;
303 val(p,_,Form'(PpcKF(_,_,_,_,ppc)),nxt,_,pt) = specify nxt p [] pt;
304 (*val nxt = Add_Given "interval" : tac*)
306 val nxt = Add_Given "interval {x. 2 <= x & x <= 3}";
307 val nxt = tac2tac_ pt p nxt;
308 val(p,_,Form'(PpcKF(_,_,_,_,ppc)),nxt,_,pt) = specify nxt p [] pt;
309 (*val nxt = Add_Given "errorBound" : tac*)
311 val nxt = Add_Given "errorBound (eps=999)";
312 val nxt = tac2tac_ pt p nxt;
313 val(p,_,Form'(PpcKF(_,_,_,_,ppc)),nxt,_,pt) = specify nxt p [] pt;
314 (*val nxt = Apply_Method ("DiffApp","max_by_calculus") *)
315 (*30.8.01 ... funktioniert nicht mehr nach Einfuehrung env ....
316 if nxt<>(Apply_Method ("DiffApp","max_by_calculus"))
317 then error "test specify, fmz <> []: nxt <> Add_Relation.."
321 (* 2.4.00 nach Transfer specify -> hard_gen
322 val nxt = Apply_Method ("DiffApp","max_by_calculus");
323 val(p,_,Form'(PpcKF(_,_,_,_,ppc)),nxt,_,pt) = specify nxt p [] pt; *)
324 (*val nxt = Empty_Tac : tac*)
326 ============ inhibit exn =====================================================*)
328 (*-.-.-.-.-.-isolate response.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
330 "--------- match_ags, is_cp, cpy_nam +with EqSystem (!)--";
331 "--------- match_ags, is_cp, cpy_nam +with EqSystem (!)--";
332 "--------- match_ags, is_cp, cpy_nam +with EqSystem (!)--";
333 val Const ("Script.SubProblem",_) $
336 (Const ("Pair",_) $ pI' $ mI')) $ ags' =
337 (*...copied from stac2tac_*)
339 "SubProblem (EqSystem', [linear, system], [no_met]) " ^
340 " [BOOL_LIST [c_2 = 0, L * c + c_2 = q_0 * L ^^^ 2 / 2]," ^
341 " REAL_LIST [c, c_2]]");
342 val ags = isalist2list ags';
343 val pI = ["linear","system"];
344 val pats = (#ppc o get_pbt) pI;
345 "-a1-----------------------------------------------------";
346 (*match_ags = fn : theory -> pat list -> term list -> ori list*)
347 val xxx = match_ags (theory "EqSystem") pats ags;
348 "-a2-----------------------------------------------------";
349 case match_ags (theory "Isac") pats ags of
350 [(1, [1], "#Given", Const ("Descript.equalities", _), _),
351 (2, [1], "#Given", Const ("EqSystem.solveForVars", _),
352 [ _ $ Free ("c", _) $ _, _ $ Free ("c_2", _) $ _]),
353 (3, [1], "#Find", Const ("EqSystem.solution", _), [Free ("ss'''", _)])]
355 | _ => error "calchead.sml match_ags 2 args Nok ----------------";
358 "-b------------------------------------------------------";
359 val Const ("Script.SubProblem",_) $
362 (Const ("Pair",_) $ pI' $ mI')) $ ags' =
363 (*...copied from stac2tac_*)
365 "SubProblem (EqSystem', [linear, system], [no_met]) " ^
366 " [BOOL_LIST [c_2 = 0, L * c + c_2 = q_0 * L ^^^ 2 / 2]," ^
367 " REAL_LIST [c, c_2], BOOL_LIST ss''']");
368 val ags = isalist2list ags';
369 val pI = ["linear","system"];
370 val pats = (#ppc o get_pbt) pI;
371 "-b1-----------------------------------------------------";
372 val xxx = match_ags (theory "Isac") pats ags;
373 "-b2-----------------------------------------------------";
374 case match_ags (theory "EqSystem") pats ags of
375 [(1, [1], "#Given", Const ("Descript.equalities", _), _),
376 (2, [1], "#Given", Const ("EqSystem.solveForVars", _),
377 [_ $ Free ("c", _) $ _,
378 _ $ Free ("c_2", _) $ _]),
379 (3, [1], "#Find", Const ("EqSystem.solution", _), [Free ("ss'''", _)])]
380 (* type of Find: [Free ("ss'''", "bool List.list")]*)
382 | _ => error "calchead.sml match_ags copy-named dropped --------";
385 "-c---ERROR case: stac is missing #Given equalities e_s--";
386 val stac as Const ("Script.SubProblem",_) $
389 (Const ("Pair",_) $ pI' $ mI')) $ ags' =
390 (*...copied from stac2tac_*)
392 "SubProblem (EqSystem', [linear, system], [no_met]) " ^
393 " [REAL_LIST [c, c_2]]");
394 val ags = isalist2list ags';
395 val pI = ["linear","system"];
396 val pats = (#ppc o get_pbt) pI;
397 (*---inhibit exn provided by this testcase--------------------------
398 val xxx - match_ags (theory "EqSystem") pats ags;
399 -------------------------------------------------------------------*)
400 "-c1-----------------------------------------------------";
401 "--------------------------step through code match_ags---";
402 val (thy, pbt:pat list, ags) = (theory "EqSystem", pats, ags);
403 fun flattup (i,(var,bool,str,itm_)) = (i,var,bool,str,itm_);
404 val pbt' = filter_out is_copy_named pbt; (*=equalities, solveForVars*)
405 val cy = filter is_copy_named pbt; (*=solution*)
406 (*---inhibit exn provided by this testcase--------------------------
407 val oris' - matc thy pbt' ags [];
408 -------------------------------------------------------------------*)
409 "-------------------------------step through code matc---";
410 val (thy, (p as (s,(d,t)))::pbt, a::ags, oris) = (thy, pbt', ags, []);
411 (is_copy_named_idstr o free2str) t;
413 (*---inhibit exn provided by this testcase--------------------------
414 val opt - mtc thy p a;
415 -------------------------------------------------------------------*)
416 "--------------------------------step through code mtc---";
417 val (thy, (str, (dsc, _)):pat, ty $ var) - (thy, p, a);
419 val ttt - (dsc $ var);
420 (*---inhibit exn provided by this testcase--------------------------
421 cterm_of thy (dsc $ var);
422 -------------------------------------------------------------------*)
423 "-------------------------------------step through end---";
425 case ((match_ags (theory "EqSystem") pats ags)
426 handle ERROR _ => []) of (*why not TYPE ?WN100920*)
427 [] => match_ags_msg pI stac ags
428 | _ => error "calchead.sml match_ags 1st arg missing --------";
431 "-d------------------------------------------------------";
432 val stac as Const ("Script.SubProblem",_) $
435 (Const ("Pair",_) $ pI' $ mI')) $ ags' =
436 (*...copied from stac2tac_*)
438 "SubProblem (Test',[univariate,equation,test]," ^
439 " [no_met]) [BOOL (x+1=2), REAL x]");
440 val AGS = isalist2list ags';
441 val pI = ["univariate","equation","test"];
442 val PATS = (#ppc o get_pbt) pI;
443 "-d1-----------------------------------------------------";
444 "--------------------------step through code match_ags---";
445 val (thy, pbt:pat list, ags) = (theory "Test", PATS, AGS);
446 fun flattup (i,(var,bool,str,itm_)) = (i,var,bool,str,itm_);
447 val pbt' = filter_out is_copy_named pbt;
448 val cy = filter is_copy_named pbt;
449 val oris' = matc thy pbt' ags [];
450 "-------------------------------step through code matc---";
451 val (thy, (p as (s,(d,t)))::pbt, a::ags, oris) = (thy, pbt', ags, []);
452 (is_copy_named_idstr o free2str) t;
454 val opt = mtc thy p a;
455 "--------------------------------step through code mtc---";
456 val (thy, (str, (dsc, _)):pat, ty $ var) = (thy, p, a);
457 val ttt = (dsc $ var);
458 cterm_of thy (dsc $ var);
459 val ori = ((([1], str, dsc, (*[var]*) split_dts' (dsc, var))): preori);
461 "-d2-----------------------------------------------------";
463 "-------------------------------step through code matc---";
464 val (thy, (p as (s,(d,t)))::pbt, a::ags, oris) = (thy, pbt, ags, oris @ [ori]);
465 (is_copy_named_idstr o free2str) t;
467 val opt = mtc thy p a;
468 "--------------------------------step through code mtc---";
469 val (thy, (str, (dsc, _)):pat, ty $ var) = (thy, p, a);
470 val ttt = (dsc $ var);
471 cterm_of thy (dsc $ var);
472 val ori = ((([1], str, dsc, (*[var]*) split_dts' (dsc, var))): preori);
473 "-d3-----------------------------------------------------";
474 pbt = []; (*true, base case*)
475 "-----------------continue step through code match_ags---";
476 val oris' = oris @ [ori]; (*result 2 oris, cpy_nam added later*)
477 "--------------------------------step through cpy_nam----";
478 val (pbt, oris, p as (field, (dsc, t)):pat) = (pbt', oris', hd cy);
479 (*t = "v_v'i'" : term OLD: t = "v_i_"*)
480 "--------------------------------------------------------";
481 fun is_copy_named_generating_idstr str =
482 if is_copy_named_idstr str
483 then case (rev o explode) str of
484 (*"_"::"_"::"_"::_ => false*)
485 "'"::"'"::"'"::_ => false
488 fun is_copy_named_generating (_, (_, t)) =
489 (is_copy_named_generating_idstr o free2str) t;
490 "--------------------------------------------------------";
491 is_copy_named_generating p (*true*);
492 fun sel (_,_,d,ts) = comp_ts (d, ts);
493 val cy' = (implode o (drop_last_n 3) o explode o free2str) t;
495 val ext = (last_elem o drop_last o explode o free2str) t;
497 val vars' = map (free2str o snd o snd) pbt(*cpy-nam filtered_out*);
498 (*["e_e", "v_v"] OLD: ["e_", "v_"]*)
499 val vals = map sel oris;
500 (*[x+1=2, x] OLD: [x+1=2, x] : term list*)
502 (*[("e_e", [x+1=2), ("v_v", x)] OLD: [("e_", [x+1=2), ("v_", x)]*)
503 (assoc (vars'~~vals, cy'));
504 (*SOME (Free ("x", "RealDef.real")) : term option*)
505 val cy_ext = (free2str o the) (assoc (vars'~~vals, cy'))^"_"^ext;
507 "-----------------continue step through code match_ags---";
508 val cy' = map (cpy_nam pbt' oris') cy;
509 (*[([1], "#Find", "solutions, [x_i"] (*as terms*) )]*)
510 "-------------------------------------step through end---";
512 case match_ags thy PATS AGS of
513 [(1, [1], "#Given", Const ("Descript.equality", _),
514 [Const ("HOL.eq", _) $ (Const ("Groups.plus_class.plus", _) $
515 Free ("x", _) $ Free ("1", _)) $ Free ("2", _)]),
516 (2, [1], "#Given", Const ("Descript.solveFor", _), [Free ("x", _)]),
517 (3, [1], "#Find", Const ("Descript.solutions", _), [Free ("x_i", _)])]
519 | _ => error "calchead.sml match_ags [univariate,equation,test]--";
522 "--------- regression test fun is_copy_named ------------";
523 "--------- regression test fun is_copy_named ------------";
524 "--------- regression test fun is_copy_named ------------";
525 val trm = (1, (2, @{term "v'i'"}));
526 if is_copy_named trm then () else error "regr. is_copy_named 1";
527 val trm = (1, (2, @{term "e_e"}));
528 if is_copy_named trm then error "regr. is_copy_named 2" else ();
529 val trm = (1, (2, @{term "L'''"}));
530 if is_copy_named trm then () else error "regr. is_copy_named 3";
532 (* out-comment 'structure CalcHead'...
533 val trm = (1, (2, @{term "v'i'"}));
534 if is_copy_named_generating trm then () else error "regr. is_copy_named";
535 val trm = (1, (2, @{term "L'''"}));
536 if is_copy_named_generating trm then error "regr. is_copy_named" else ();
539 "--------- regr.test fun cpy_nam ------------------------";
540 "--------- regr.test fun cpy_nam ------------------------";
541 "--------- regr.test fun cpy_nam ------------------------";
542 (*data from above - match_ags, is_cp, cpy_nam +with EqSystem (!)-:*)
543 (*the model-pattern, is_copy_named are filter_out*)
544 pbt = [("#Given", (@{term "equality"}, @{term "e_e :: bool"})),
545 ("#Given", (@{term "solveFor"}, @{term "v_v :: real"} ))];
546 (*the model specific for an example*)
547 oris = [([1], "#Given", @{term "equality"} , [str2term "x+1= 2"]),
548 ([1], "#Given", @{term "solveFor"} , [@{term "x :: real"} ])];
549 cy = [("#Find", (@{term "solutions"}, @{term "v_v'i' :: bool list"}))];
550 (*...all must be true*)
552 case cpy_nam pbt oris (hd cy) of
553 ([1], "#Find", Const ("Descript.solutions", _), [Free ("x_i", _)]) => ()
554 | _ => error "calchead.sml regr.test cpy_nam-1-";
556 (*new data: cpy_nam without changing the name*)
557 @{term "equalities"}; type_of @{term "[x_1+1=2,x_2=0]"};
558 @{term "solveForVars"}; type_of @{term "[x_1,x_2]::real list"};
559 @{term "solution"}; type_of @{term "ss''' :: bool list"};
560 (*the model-pattern for ["linear", "system"], is_copy_named are filter_out*)
561 val pbt = [("#Given", (@{term "equalities"}, @{term "e_s :: bool list"})),
562 ("#Given", (@{term "solveForVars v_s"}, @{term "v_s :: bool list"} ))];
563 (*the model specific for an example*)
564 val oris = [([1], "#Given", @{term "equalities"} ,[str2term "[x_1+1=2,x_2=0]"]),
565 ([1], "#Given", @{term "solveForVars"} , [@{term "[x_1,x_2]::real list"}])];
566 val cy = [("#Find", (@{term "solution"}, @{term "ss''' :: bool list"}))
567 (*could be more than 1*)];
569 case cpy_nam pbt oris (hd cy) of
570 ([1], "#Find", Const ("EqSystem.solution", _), [Free ("ss'''", _)]) => ()
571 | _ => error "calchead.sml regr.test cpy_nam-2-";
573 -.-.-.-.-.-.-isolate response.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.*)
576 "--------- check specify phase --------------------------";
577 "--------- check specify phase --------------------------";
578 "--------- check specify phase --------------------------";
579 (*val fmz = ["functionTerm (x^^^2 + 1)",*)
580 val fmz = ["functionTerm (x + 1)",
581 "integrateBy x","antiDerivative FF"];
583 ("Integrate",["integrate","function"],
584 ["diff","integration"]);
585 val p = e_pos'; val c = [];
587 val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
588 (*> val it = "--- step 1 --" : string
592 (0, EdUndef, 0, Nundef,
594 {Find = [], With = [], Given = [], Where = [], Relate = []})))
596 val nxt = ("Model_Problem", Model_Problem) : string * tac
597 val p = ([], Pbl) : pos'
601 (["functionTerm (x^^^2 + 1)", "integrateBy x",
602 "antiDerivative FF"],
603 ("Integrate", ["integrate", "function"],
604 ["diff", "integration"])),
606 (Some (ScrState ([], [], None, Const ("empty", "'a"), Sundef, false)),
608 cell = None, meth = [], spec = ("e_domID", ["e_pblID"], ["e_metID"]),
609 probl = [], branch = TransitiveB,
612 Const ("Descript.functionTerm", "RealDef.real => Tools.una"),
614 "[RealDef.real, RealDef.real] => RealDef.real") $
615 (Const ("Atools.pow",
616 "[RealDef.real, RealDef.real] => RealDef.real") $
617 Free ("x", "RealDef.real") $ Free ("2", "RealDef.real")) $
618 Free ("1", "RealDef.real")]),
620 Const ("Integrate.integrateBy", "RealDef.real => Tools.una"),
621 [Free ("x", "RealDef.real")]),
623 Const ("Integrate.antiDerivative", "RealDef.real => Tools.una"),
624 [Free ("FF", "RealDef.real")])],
625 ("Integrate", ["integrate", "function"], ["diff", "integration"]),
626 Const ("Integrate.Integrate",
627 "(RealDef.real, RealDef.real) * => RealDef.real") $
629 "[RealDef.real, RealDef.real]
630 => (RealDef.real, RealDef.real) *") $
632 "[RealDef.real, RealDef.real] => RealDef.real") $
633 (Const ("Atools.pow",
634 "[RealDef.real, RealDef.real] => RealDef.real") $
635 Free ("x", "RealDef.real") $ Free ("2", "RealDef.real")) $
636 Free ("1", "RealDef.real")) $
637 Free ("x", "RealDef.real"))),
638 ostate = Incomplete, result = (Const ("empty", "'a"), [])},
640 "----- WN101007 worked until here (checked same as isac2002) ---";
641 if nxt = ("Model_Problem", Model_Problem) then ()
642 else error "clchead.sml: check specify phase step 1";
644 val (p,_,f,nxt,_,pt) = me nxt p c pt; (*Florian: see response buffer, top*)
645 (*val it = "--- step 2 --" : string
646 val p = ([], Pbl) : pos'
650 (0, EdUndef, 0, Nundef,
652 {Find = [Incompl "Integrate.antiDerivative"],
654 Given = [Incompl "functionTerm", Incompl "integrateBy"],
656 Relate = []}))) : mout
657 val nxt = ("Add_Given", Add_Given "functionTerm (x ^^^ 2 + 1)") : tac'_
661 (["functionTerm (x^^^2 + 1)", "integrateBy x",
662 "antiDerivative FF"],
663 ("Integrate", ["integrate", "function"],
664 ["diff", "integration"])),
667 (ScrState ([], [], None, Const ("empty", "'a"), Sundef, false)),
669 cell = None, meth = [], spec =
670 ("e_domID", ["e_pblID"], ["e_metID"]), probl =
671 [(0, [], false, "#Given",
672 Inc ((Const ("Descript.functionTerm",
673 "RealDef.real => Tools.una"),[]),
674 (Const ("empty", "'a"), []))),
675 (0, [], false, "#Given",
676 Inc ((Const ("Integrate.integrateBy",
677 "RealDef.real => Tools.una"),[]),
678 (Const ("empty", "'a"), []))),
679 (0, [], false, "#Find",
680 Inc ((Const ("Integrate.antiDerivative",
681 "RealDef.real => Tools.una"),[]),
682 (Const ("empty", "'a"), [])))],
683 branch = TransitiveB, origin =
685 Const ("Descript.functionTerm", "RealDef.real => Tools.una"),
687 "[RealDef.real, RealDef.real] => RealDef.real") $
688 (Const ("Atools.pow",
689 "[RealDef.real, RealDef.real] => RealDef.real") $
690 Free ("x", "RealDef.real") $ Free ("2", "RealDef.real")) $
691 Free ("1", "RealDef.real")]),
693 Const ("Integrate.integrateBy", "RealDef.real => Tools.una"),
694 [Free ("x", "RealDef.real")]),
696 Const ("Integrate.antiDerivative", "RealDef.real => Tools.una"),
697 [Free ("FF", "RealDef.real")])],
698 ("Integrate", ["integrate", "function"], ["diff", "integration"]),
699 Const ("Integrate.Integrate",
700 "(RealDef.real, RealDef.real) * => RealDef.real") $
702 "[RealDef.real, RealDef.real]
703 => (RealDef.real, RealDef.real) *") $
705 "[RealDef.real, RealDef.real] => RealDef.real") $
706 (Const ("Atools.pow",
707 "[RealDef.real, RealDef.real] => RealDef.real") $
708 Free ("x", "RealDef.real") $ Free ("2", "RealDef.real")) $
709 Free ("1", "RealDef.real")) $
710 Free ("x", "RealDef.real"))),
711 ostate = Incomplete, result = (Const ("empty", "'a"), [])},
713 "----- WN101007 ptree checked same as isac2002, diff. in nxt --- REPAIRED";
714 if nxt = ("Add_Given", Add_Given "functionTerm (x + 1)") then ()
715 else error "clchead.sml: check specify phase step 2";
717 val (p,_,f,nxt,_,pt) = me nxt p c pt;
718 "----- WN101008 ptree checked same as isac2002, diff. in nxt --- REPAIRED";
719 if nxt = ("Add_Given", Add_Given "integrateBy x") then ()
720 else error "clchead.sml: check specify phase step 2";
722 (*-.-.-.-.-.-isolate response.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
723 -.-.-.-.-.-.-isolate response.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.*)