1 (* tests on calchead.sml
4 (c) due to copyright terms
6 12345678901234567890123456789012345678901234567890123456789012345678901234567890
7 10 20 30 40 50 60 70 80
10 "--------------------------------------------------------";
11 "table of contents --------------------------------------";
12 "--------------------------------------------------------";
13 "--------- get_interval after replace} other 2 ----------";
14 "--------- maximum example with 'specify' ---------------";
15 "--------- maximum example with 'specify', fmz <> [] ----";
16 "--------- maximum example with 'specify', fmz = [] -----";
17 "--------- match_ags, is_cp, cpy_nam +with EqSystem (!)--";
18 "--------- regression test fun is_copy_named ------------";
19 "--------- regr.test fun cpy_nam ------------------------";
20 "--------------------------------------------------------";
21 "--------------------------------------------------------";
22 "--------------------------------------------------------";
24 (*WN100914======================================================================
25 "--------- get_interval after replace} other 2 ----------";
26 "--------- get_interval after replace} other 2 ----------";
27 "--------- get_interval after replace} other 2 ----------";
30 [(["equality (x+1=2)", "solveFor x","solutions L"],
32 ["sqroot-test","univariate","equation","test"],
33 ["Test","squ-equ-test-subpbl1"]))];
36 autoCalculate 1 CompleteCalc;
37 moveActiveFormula 1 ([2],Res); (*there is "-1 + x = 0"*)
38 replaceFormula 1 "x = 1";
39 (*... returns calcChangedEvent with ...*)
40 val (unc, del, gen) = (([1],Res), ([4],Res), ([3,2],Res));
41 val ((pt,_),_) = get_calc 1;
43 print_depth 99;map fst (get_interval ([],Pbl) ([],Res) 9999 pt);print_depth 3;
44 if map fst (get_interval ([],Pbl) ([],Res) 9999 pt) =
45 [([], Pbl), ([1], Frm),([1], Res), ([2], Res), ([3], Pbl), ([3, 1], Frm),
46 ([3, 1], Res), ([3, 2, 1], Frm), ([3, 2, 1], Res), ([3, 2, 2], Res),
47 ([3, 2], Res)] then () else
48 error "calchead.sml: diff.behav. get_interval after replace} other 2 a";
50 print_depth 99;map fst (get_interval ([3, 2, 1], Res) ([],Res) 9999 pt);
52 if map fst (get_interval ([3, 2, 1], Res) ([],Res) 9999 pt) =
53 [([3, 2, 1], Res), ([3, 2, 2], Res), ([3, 2], Res)] then () else
54 error "modspec.sml: diff.behav. get_interval after replace} other 2 b";
59 "--------- maximum example with 'specify' ------------------------";
60 "--------- maximum example with 'specify' ------------------------";
61 "--------- maximum example with 'specify' ------------------------";
62 (*" Specify_Problem (match_itms_oris) ";*)
64 ["fixedValues [r=Arbfix]","maximum A",
66 "relations [A=a*b, (a/2)^^^2 + (b/2)^^^2 = r^^^2]",
67 "relations [A=a*b, (a/2)^^^2 + (b/2)^^^2 = r^^^2]",
68 "relations [A=a*b, a/2=r*sin alpha, b/2=r*cos alpha]",
70 "boundVariable a","boundVariable b","boundVariable alpha",
71 "interval {x::real. 0 <= x & x <= 2*r}",
72 "interval {x::real. 0 <= x & x <= 2*r}",
73 "interval {x::real. 0 <= x & x <= pi}",
74 "errorBound (eps=(0::real))"];
76 ("DiffApp.thy",["maximum_of","function"],
77 ["DiffApp","max_by_calculus"]);
80 (*val nxt = Init_Proof' (fmz,(dI',pI',mI'));
81 val(p,_,Form'(PpcKF(_,_,_,_,ppc)),nxt,_,pt) = specify nxt e_pos' [] EmptyPtree;
83 val (p,_,f,(_,nxt),_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
84 val nxt = tac2tac_ pt p nxt;
85 val(p,_,Form'(PpcKF(_,_,_,_,ppc)),nxt,_,pt) = specify nxt p [] pt;
86 (*val nxt = Add_Given "fixedValues [(r::real) = Arbfix]" : tac*)
88 val nxt = tac2tac_ pt p nxt;
89 val(p,_,Form'(PpcKF(_,_,_,_,ppc)),nxt,_,pt) = specify nxt p [] pt;
93 val nxt = tac2tac_ pt p (Add_Find "valuesFor [(a::real)]");
94 val(p,_,Form'(PpcKF(_,_,_,_,ppc)),nxt,_,pt) = specify nxt p [] pt;
95 (*uncaught exception TYPE 6.5.03*)
98 {Find=[Incompl "maximum",Incompl "valuesFor [a]"],
99 Given=[Correct "fixedValues [r = Arbfix]"],
100 Relate=[Incompl "relations []"], Where=[],With=[]})
101 then error "test-maximum.sml: model stepwise - different behaviour"
102 else (); (*different with show_types !!!*)
105 (*-----appl_add should not create Error', but accept as Sup,Syn
106 val nxt = tac2tac_ pt p (Add_Given "boundVariable a");
107 val(p,_,Form'(PpcKF(_,_,_,_,ppc)),nxt,_,pt) = specify nxt p [] pt;
109 val nxt = tac2tac_ pt p (Add_Given "boundVariable a+");
110 val(p,_,Form'(PpcKF(_,_,_,_,ppc)),nxt,_,pt) = specify nxt p [] pt;
113 val m = Specify_Problem ["maximum_of","function"];
114 val nxt = tac2tac_ pt p m;
115 val(p,_,Form'(PpcKF(_,_,_,_,ppc)),nxt,_,pt) = specify nxt p [] pt;
118 if ppc<>(Problem ["maximum_of","function"],
119 {Find=[Incompl "maximum",Incompl "valuesFor"],
120 Given=[Correct "fixedValues [r = Arbfix]"],
121 Relate=[Incompl "relations []"], Where=[],With=[]})
122 then error "diffappl.sml: Specify_Problem different behaviour"
124 (* WN.3.9.03 (#391) Model_Specify did init_pbl newly
125 if ppc<>(Problem ["maximum_of","function"],
126 {Find=[Missing "maximum m_",Missing "valuesFor vs_"],
127 Given=[Correct "fixedValues [r = Arbfix]"],
128 Relate=[Missing "relations rs_"],Where=[],With=[]})
129 then error "diffappl.sml: Specify_Problem different behaviour"
132 val nxt = tac2tac_ pt p(Specify_Method ["DiffApp","max_by_calculus"]);
133 val(p,_,Form'(PpcKF(_,_,_,_,ppc)),nxt,_,pt) = specify nxt p [] pt;
136 if ppc<>(Method ["DiffApp","max_by_calculus"],
137 {Find=[Incompl "maximum",Incompl "valuesFor"],
138 Given=[Correct "fixedValues [r = Arbfix]",Missing "boundVariable v_v",
139 Missing "interval itv_",Missing "errorBound err_"],
140 Relate=[Incompl "relations []"],Where=[],With=[]})
141 then error "diffappl.sml: Specify_Method different behaviour"
143 (* WN.3.9.03 (#391) Model_Specify did init_pbl newly
144 if ppc<>(Method ["DiffApp","max_by_calculus"],
145 {Find=[Missing "maximum m_",Missing "valuesFor vs_"],
146 Given=[Correct "fixedValues [r = Arbfix]",Missing "boundVariable v_v",
147 Missing "interval itv_",Missing "errorBound err_"],
148 Relate=[Missing "relations rs_"],Where=[],With=[]})
149 then error "diffappl.sml: Specify_Method different behaviour"
154 "--------- maximum example with 'specify', fmz <> [] -------------";
155 "--------- maximum example with 'specify', fmz <> [] -------------";
156 "--------- maximum example with 'specify', fmz <> [] -------------";
158 ["fixedValues [r=Arbfix]","maximum A",
160 "relations [A=a*b, (a/2)^^^2 + (b/2)^^^2 = r^^^2]",
161 "relations [A=a*b, (a/2)^^^2 + (b/2)^^^2 = r^^^2]",
162 "relations [A=a*b, a/2=r*sin alpha, b/2=r*cos alpha]",
164 "boundVariable a","boundVariable b","boundVariable alpha",
165 "interval {x::real. 0 <= x & x <= 2*r}",
166 "interval {x::real. 0 <= x & x <= 2*r}",
167 "interval {x::real. 0 <= x & x <= pi}",
168 "errorBound (eps=(0::real))"];
170 ("DiffApp.thy",["maximum_of","function"],
171 ["DiffApp","max_by_calculus"]);
173 (*val nxt = Init_Proof' (fmz,(dI',pI',mI'));*)
174 val (p,_,f,(_,nxt),_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
176 val nxt = tac2tac_ pt p nxt;
177 val(p,_,Form'(PpcKF(_,_,_,_,ppc)),nxt,_,pt) = specify nxt e_pos' [] pt;
178 val nxt = tac2tac_ pt p nxt;
179 val(p,_,Form'(PpcKF(_,_,_,_,ppc)),nxt,_,pt) = specify nxt p [] pt;
180 (*val nxt = Add_Given "fixedValues [(r::real) = Arbfix]" : tac*)
182 val nxt = tac2tac_ pt p nxt;
183 val(p,_,Form'(PpcKF(_,_,_,_,ppc)),nxt,_,pt) = specify nxt p [] pt;
184 (*val nxt = Add_Find "maximum (A::bool)" : tac*)
186 val nxt = tac2tac_ pt p nxt;
187 val(p,_,Form'(PpcKF(_,_,_,_,ppc)),nxt,_,pt) = specify nxt p [] pt;
188 (*val nxt = Add_Find "valuesFor [(a::real)]" : tac*)
190 val nxt = tac2tac_ pt p nxt;
191 val(p,_,Form'(PpcKF(_,_,_,_,ppc)),nxt,_,pt) = specify nxt p [] pt;
192 (*val nxt = Add_Find "valuesFor [(b::real)]" : tac*)
194 val nxt = tac2tac_ pt p nxt;
195 val(p,_,Form'(PpcKF(_,_,_,_,ppc)),nxt,_,pt) = specify nxt p [] pt;
196 (*val nxt = Add_Relation "relations [A = a * b]" *)
198 val nxt = tac2tac_ pt p nxt;
199 val(p,_,Form'(PpcKF(_,_,_,_,ppc)),nxt,_,pt) = specify nxt p [] pt;
200 (*Add_Relation "relations\n [((a::real) // (#2::real)) ..."*)
202 (*---------------------------- FIXXXXME.meNEW !!! partial Add-Relation !!!
203 nxt_specif <> specify ?!
205 if nxt<>(Add_Relation
206 "relations [(a / 2) ^^^ 2 + (b / 2) ^^^ 2 = r ^^^ 2]")
207 then error "test specify, fmz <> []: nxt <> Add_Relation (a/2)^2.." else (); (*different with show_types !!!*)
209 val nxt = tac2tac_ pt p nxt;
210 val(p,_,Form'(PpcKF(_,_,_,_,ppc)),nxt,_,pt) = specify nxt p [] pt;
211 ------------------------------ FIXXXXME.meNEW !!! ---*)
213 (*val nxt = Specify_Theory "DiffApp.thy" : tac*)
215 val itms = get_obj g_pbl pt (fst p);writeln(itms2str_ ctxt itms);
217 val nxt = tac2tac_ pt p nxt;
218 val(p,_,Form'(PpcKF(_,_,_,_,ppc)),nxt,_,pt) = specify nxt p [] pt;
219 (*val nxt = Specify_Problem ["maximum_of","function"]*)
221 val nxt = tac2tac_ pt p nxt;
222 val(p,_,Form'(PpcKF(_,_,_,_,ppc)),nxt,_,pt) = specify nxt p [] pt;
223 (*val nxt = Specify_Method ("DiffApp.thy","max_by_calculus")*)
225 val nxt = tac2tac_ pt p nxt;
226 val(p,_,Form'(PpcKF(_,_,_,_,ppc)),nxt,_,pt) = specify nxt p [] pt;
227 (*val nxt = Add_Given "boundVariable a" : tac*)
229 val nxt = tac2tac_ pt p nxt;
230 val(p,_,Form'(PpcKF(_,_,_,_,ppc)),nxt,_,pt) = specify nxt p [] pt;
231 (*val nxt = Add_Given "interval {x. #0 <= x & x <= #2 * r}" : *)
233 val nxt = tac2tac_ pt p nxt;
234 val(p,_,Form'(PpcKF(_,_,_,_,ppc)),nxt,_,pt) = specify nxt p [] pt;
235 (*val nxt = Add_Given "errorBound (eps = #0)" : tac*)
237 val nxt = tac2tac_ pt p nxt;
238 val(p,_,Form'(PpcKF(_,_,_,_,ppc)),nxt,_,pt) = specify nxt p [] pt;
239 (*val nxt = Apply_Method ("DiffApp.thy","max_by_calculus") *)
240 if nxt<>(Apply_Method ["DiffApp","max_by_calculus"])
241 then error "test specify, fmz <> []: nxt <> Apply_Method max_by_calculus" else ();
244 "--------- maximum example with 'specify', fmz = [] --------------";
245 "--------- maximum example with 'specify', fmz = [] --------------";
246 "--------- maximum example with 'specify', fmz = [] --------------";
248 val (dI',pI',mI') = empty_spec;
251 val nxt = Init_Proof' (fmz,(dI',pI',mI'));(*!!!!!!!!*)
252 (*val (p,_,f,(_,nxt),_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))]; !!!*)
253 val(p,_,Form'(PpcKF(_,_,_,_,ppc)),nxt,_,pt) = specify nxt e_pos' []
255 val nxt = tac2tac_ pt p nxt;
256 val(p,_,Form'(PpcKF(_,_,_,_,ppc)),nxt,_,pt) = specify nxt p [] pt;
257 (*val nxt = Specify_Theory "e_domID" : tac*)
259 val nxt = Specify_Theory "DiffApp.thy";
260 val nxt = tac2tac_ pt p nxt;
261 val(p,_,Form'(PpcKF(_,_,_,_,ppc)),nxt,_,pt) = specify nxt p [] pt;
262 (*val nxt = Specify_Problem ["e_pblID"] : tac*)
264 val nxt = Specify_Problem ["maximum_of","function"];
265 val nxt = tac2tac_ pt p nxt;
266 val(p,_,Form'(PpcKF(_,_,_,_,ppc)),nxt,_,pt) = specify nxt p [] pt;
267 (*val nxt = Add_Given "fixedValues" : tac*)
269 val nxt = Add_Given "fixedValues [r=Arbfix]";
270 val nxt = tac2tac_ pt p nxt;
271 val(p,_,Form'(PpcKF(_,_,_,_,ppc)),nxt,_,pt) = specify nxt p [] pt;
272 (*val nxt = Add_Find "maximum" : tac*)
274 val nxt = Add_Find "maximum A";
275 val nxt = tac2tac_ pt p nxt;
278 val(p,_,Form'(PpcKF(_,_,_,_,ppc)),nxt,_,pt) = specify nxt p [] pt;
279 (*val nxt = Add_Find "valuesFor" : tac*)
281 val nxt = Add_Find "valuesFor [a]";
282 val nxt = tac2tac_ pt p nxt;
283 val(p,_,Form'(PpcKF(_,_,_,_,ppc)),nxt,_,pt) = specify nxt p [] pt;
284 (*val nxt = Add_Relation "relations" ---
285 --- [b=Arbfix] KANN NICHT VERLANGT WERDEN !!!!*)
287 (*30.8.01 ... funktioniert nicht mehr nach Einfuehrung env ....
288 if nxt<>(Add_Relation "relations []")
289 then error "test specify, fmz <> []: nxt <> Add_Relation.."
290 else (); (*different with show_types !!!*)
293 val nxt = Add_Relation "relations [(A=a+b)]";
294 val nxt = tac2tac_ pt p nxt;
295 val(p,_,Form'(PpcKF(_,_,_,_,ppc)),nxt,_,pt) = specify nxt p [] pt;
296 (*val nxt = Specify_Method ("e_domID","e_metID") : tac*)
298 val nxt = Specify_Method ["DiffApp","max_by_calculus"];
299 val nxt = tac2tac_ pt p nxt;
300 val(p,_,Form'(PpcKF(_,_,_,_,ppc)),nxt,_,pt) = specify nxt p [] pt;
301 (*val nxt = Add_Given "boundVariable" : tac*)
303 val nxt = Add_Given "boundVariable alpha";
304 val nxt = tac2tac_ pt p nxt;
305 val(p,_,Form'(PpcKF(_,_,_,_,ppc)),nxt,_,pt) = specify nxt p [] pt;
306 (*val nxt = Add_Given "interval" : tac*)
308 val nxt = Add_Given "interval {x. 2 <= x & x <= 3}";
309 val nxt = tac2tac_ pt p nxt;
310 val(p,_,Form'(PpcKF(_,_,_,_,ppc)),nxt,_,pt) = specify nxt p [] pt;
311 (*val nxt = Add_Given "errorBound" : tac*)
313 val nxt = Add_Given "errorBound (eps=999)";
314 val nxt = tac2tac_ pt p nxt;
315 val(p,_,Form'(PpcKF(_,_,_,_,ppc)),nxt,_,pt) = specify nxt p [] pt;
316 (*val nxt = Apply_Method ("DiffApp","max_by_calculus") *)
317 (*30.8.01 ... funktioniert nicht mehr nach Einfuehrung env ....
318 if nxt<>(Apply_Method ("DiffApp.thy","max_by_calculus"))
319 then error "test specify, fmz <> []: nxt <> Add_Relation.."
323 (* 2.4.00 nach Transfer specify -> hard_gen
324 val nxt = Apply_Method ("DiffApp.thy","max_by_calculus");
325 val(p,_,Form'(PpcKF(_,_,_,_,ppc)),nxt,_,pt) = specify nxt p [] pt; *)
326 (*val nxt = Empty_Tac : tac*)
328 ====================================================================WN100914*)
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 ("op =", _) $ (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-";