1 (* Title: test/../script.sml
2 Author: Walther Neuper 050908
3 (c) copyright due to lincense terms.
5 "-----------------------------------------------------------------";
6 "table of contents -----------------------------------------------";
7 "-----------------------------------------------------------------";
8 "----------- WN0509 why does next_tac doesnt find Substitute -----";
9 "----------- WN0509 Substitute 2nd part --------------------------";
10 "----------- fun sel_appl_atomic_tacs ----------------------------";
11 "----------- fun init_form, fun get_stac -------------------------";
12 "----------- x+1=2 start SubProblem 'stac2tac_ TODO: no match for ";
13 "----------- Take as 1st stac in script --------------------------";
14 "----------- 'trace_script' from outside 'fun me '----------------";
15 "----------- fun sel_rules ---------------------------------------";
16 "----------- fun sel_appl_atomic_tacs ----------------------------";
17 "-----------------------------------------------------------------";
18 "-----------------------------------------------------------------";
19 "-----------------------------------------------------------------";
21 val thy = @{theory Isac};
23 "----------- WN0509 why does next_tac doesnt find Substitute -----";
24 "----------- WN0509 why does next_tac doesnt find Substitute -----";
25 "----------- WN0509 why does next_tac doesnt find Substitute -----";
27 (*replace met 'IntegrierenUndKonstanteBestimmen' with this script...*)
29 "Script BiegelinieScript " ^
30 "(l_l::real) (q__q::real) (v_v::real) (b_b::real=>real) " ^
31 "(rb_rb::bool list) (rm_rm::bool list) = " ^
32 " (let q___q = Take (M_b v_v = q__q); " ^
33 " (M1__M1::bool) = ((Substitute [v_v = 0])) q___q " ^
36 val sc' = ((inst_abs thy) o term_of o the o (parse thy)) str;
39 "Script BiegelinieScript " ^
40 "(l_l::real) (q__q::real) (v_v::real) (b_b::real=>real) " ^
41 "(rb_rb::bool list) (rm_rm::bool list) = " ^
42 " (M1__M1::bool) = ((Substitute [v_v = 0]) @@ " ^
43 " in True)";(*..doesnt find Substitute with ..@@ !!!!!!!!!!!!!!!!!!!!!*)
46 "Script BiegelinieScript " ^
47 "(l_l::real) (q__q::real) (v_v::real) (b_b::real=>real) " ^
48 "(rb_rb::bool list) (rm_rm::bool list) = " ^
49 " (let q___q = Take (q_q v_v = q__q); " ^
50 " (M1__M1::bool) = Substitute [v_v = 0] q___q ; " ^
51 " M1__m1 = Substitute [M_b 0 = 0] M1__M1 " ^
55 "Script BiegelinieScript " ^
56 "(l_l::real) (q__q::real) (v_v::real) (b_b::real=>real) " ^
57 "(rb_rb::bool list) (rm_rm::bool list) = " ^
58 " (let q___q = Take (q_q v_v = q__q); " ^
59 " (M1__M1::bool) = Substitute [v_v = 0] q___q ; " ^
60 " M1__M1 = Substitute [v_v = 1] q___q ; " ^
61 " M1__M1 = Substitute [v_v = 2] q___q ; " ^
62 " M1__M1 = Substitute [v_v = 3] q___q ; " ^
63 " M1__M1 = Substitute [M_b 0 = 0] M1__M1 " ^
67 "Script BiegelinieScript " ^
68 "(l_l::real) (q__q::real) (v_v::real) (b_b::real=>real) " ^
69 "(rb_rb::bool list) (rm_rm::bool list) = " ^
70 " (let q___q = Take (M_b v_v = q__q); " ^
71 " (M1__M1::bool) = Substitute [v_v = 0] q___q ; " ^
72 " M2__M2 = Take q___q ; " ^
73 " M2__M2 = Substitute [v_v = 2] q___q " ^
77 val sc' = ((inst_abs thy) o term_of o the o (parse thy)) str;
80 val {scr = Prog sc,...} = get_met ["IntegrierenUndKonstanteBestimmen"];
81 (*---------------------------------------------------------------------
82 if sc = sc' then () else error"script.sml, doesnt find Substitute #1";
83 ---------------------------------------------------------------------*)
85 "----------- WN0509 Substitute 2nd part --------------------------";
86 "----------- WN0509 Substitute 2nd part --------------------------";
87 "----------- WN0509 Substitute 2nd part --------------------------";
88 (*replace met 'IntegrierenUndKonstanteBestimmen' with this script...*)
89 val str = (*Substitute ; Substitute works*)
90 "Script BiegelinieScript " ^
91 "(l_l::real) (q__q::real) (v_v::real) (b_b::real=>real) " ^
92 "(rb_rb::bool list) (rm_rm::bool list) = "^
93 (*begin after the 2nd integrate*)
94 " (let M__M = Take (M_b v_v = q__q); " ^
95 " e1__e1 = nth_nth 1 rm_rm ; " ^
96 " (x1__x1::real) = argument_in (lhs e1__e1); " ^
97 " (M1__M1::bool) = Substitute [v_v = x1__x1] M__M; " ^
98 " M1__M1 = Substitute [e1__e1] M1__M1 " ^
101 val sc' = ((inst_abs thy) o term_of o the o (parse thy)) str;
104 val str = (*Substitute @@ Substitute does NOT work???*)
105 "Script BiegelinieScript " ^
106 "(l_l::real) (q__q::real) (v_v::real) (b_b::real=>real) " ^
107 "(rb_rb::bool list) (rm_rm::bool list) = "^
108 (*begin after the 2nd integrate*)
109 " (let M__M = Take (M_b v_v = q__q); " ^
110 " e1__e1 = nth_nth 1 rm_rm ; " ^
111 " (x1__x1::real) = argument_in (lhs e1__e1); " ^
112 " (M1__M1::bool) = ((Substitute [v_v = x1__x1]) @@ " ^
113 " (Substitute [e1__e1])) M__M " ^
117 val {scr = Prog sc,...} = get_met ["IntegrierenUndKonstanteBestimmen"];
118 (*---------------------------------------------------------------------
119 if sc = sc' then () else error "script.sml, doesnt find Substitute #1";
120 ---------------------------------------------------------------------*)
121 val fmz = ["Traegerlaenge L",
122 "Streckenlast (- q_0 * x^^^2 / 2 + x * c + c_2)",
124 "RandbedingungenBiegung [y 0 = 0, y L = 0]",
125 "RandbedingungenMoment [M_b 0 = 0, M_b L = 0]",
126 "FunktionsVariable x"];
128 ("Biegelinie",["MomentBestimmte","Biegelinien"],
129 ["IntegrierenUndKonstanteBestimmen"]);
130 val p = e_pos'; val c = [];
131 val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
132 val (p,_,f,nxt,_,pt) = me nxt p c pt; val (p,_,f,nxt,_,pt) = me nxt p c pt;
133 val (p,_,f,nxt,_,pt) = me nxt p c pt; val (p,_,f,nxt,_,pt) = me nxt p c pt;
134 val (p,_,f,nxt,_,pt) = me nxt p c pt; val (p,_,f,nxt,_,pt) = me nxt p c pt;
135 val (p,_,f,nxt,_,pt) = me nxt p c pt; val (p,_,f,nxt,_,pt) = me nxt p c pt;
136 val (p,_,f,nxt,_,pt) = me nxt p c pt; val (p,_,f,nxt,_,pt) = me nxt p c pt;
137 val (p,_,f,nxt,_,pt) = me nxt p c pt;
138 val (p,_,f,nxt,_,pt) = me nxt p c pt;
139 case nxt of (_, Apply_Method ["IntegrierenUndKonstanteBestimmen"]) => ()
140 | _ => error "script.sml, doesnt find Substitute #2";
141 (* ERROR: caused by f2str f *)
144 val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f(*------------------------*);
145 trace_rewrite:=false;
146 (*Exception TYPE raised:
147 Illegal type for constant "HOL.eq" :: "[real, bool] => bool"
148 Atools.argument'_in (Tools.lhs (ListG.nth_ (1 + -1 + -1) [])) =
149 ListG.nth_ (1 + -1 + -1) []
152 ("Illegal type for constant \"op =\" :: \"[real, bool] => bool\"",
154 [Const ("HOL.Trueprop", "bool => prop") $
155 (Const ("HOL.eq", "[RealDef.real, bool] => bool") $ ... $ ...)])
157 ... this was because eval_argument_in took "argument_in (lhs (M_b 0 = 0))"
158 ie. the argument had not been simplified before ^^^^^^^^^^^^^^^
159 thus corrected eval_argument_in OK*)
160 val {srls,...} = get_met ["IntegrierenUndKonstanteBestimmen"];
161 val e1__e1 = str2term "NTH 1 [M_b 0 = 0, M_b L = 0]";
162 val e1__e1 = eval_listexpr_ @{theory Biegelinie} srls e1__e1; term2str e1__e1;
163 if term2str e1__e1 = "M_b 0 = 0"
165 else error"script.sml diff.beh. eval_listexpr_ nth_nth 1 [...";
167 (*TODO.WN050913 ??? doesnt eval_listexpr_ go into subterms ???...
168 val x1__ = str2term"argument_in (lhs (M_b 0 = 0))";
169 val x1__ = eval_listexpr_ Biegelinie.thy srls x1__; term2str x1__;
171 calculate_ Biegelinie.thy ("Tools.lhs", eval_rhs"eval_lhs_") x1__;
172 val SOME (str, t) = eval_lhs 0 "Tools.lhs" (str2term"lhs (M_b 0 = 0)") 0;*)
174 val l__l = str2term "lhs (M_b 0 = 0)";
175 val l__l = eval_listexpr_ @{theory Biegelinie} srls l__l; term2str l__l;
176 val SOME (str, t) = eval_lhs 0 "Tools.lhs" (str2term "lhs (M_b 0 = 0)") 0;
178 val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f (*------------------------*);
179 if nxt = ("Rewrite", Rewrite ("Belastung_Querkraft", "Biegelinie.Belastung_Querkraft"))
180 then () else error "";
183 "----------- fun sel_appl_atomic_tacs ----------------------------";
184 "----------- fun sel_appl_atomic_tacs ----------------------------";
185 "----------- fun sel_appl_atomic_tacs ----------------------------";
188 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
189 ("Test", ["sqroot-test","univariate","equation","test"],
190 ["Test","squ-equ-test-subpbl1"]))];
193 autoCalculate 1 CompleteCalcHead;
194 autoCalculate 1 (Step 1);
195 autoCalculate 1 (Step 1);
196 val ((pt, p), _) = get_calc 1; show_pt pt;
197 val appltacs = sel_appl_atomic_tacs pt p;
199 (*========== inhibit exn AK110721 ================================================
200 (*(*These SHOULD be the same*)
203 [Rewrite ("radd_commute", "?m + ?n = ?n + ?m"),
204 Rewrite ("radd_assoc", "?m + ?n + ?k = ?m + (?n + ?k)"),
205 Calculate "TIMES"];*)
208 [Rewrite ("radd_commute", "?m + ?n = ?n + ?m"),
209 Rewrite ("radd_assoc", "?m + ?n + ?k = ?m + (?n + ?k)"),
210 Calculate "TIMES"] then ()
211 else error "script.sml fun sel_appl_atomic_tacs diff.behav.";
212 ========== inhibit exn AK110721 ================================================*)
214 trace_script := true;
215 trace_script := false;
216 applyTactic 1 p (hd appltacs);
217 val ((pt, p), _) = get_calc 1; show_pt pt;
218 val appltacs = sel_appl_atomic_tacs pt p;
220 (*(* AK110722 Debugging start*)
221 (*applyTactic 1 p (hd appltacs); WAS assy: call by ([3], Pbl)*)
222 "~~~~~ fun applyTactic, args:"; val ((cI:calcID), ip, tac) = (1, p, (hd appltacs));
223 val ((pt, _), _) = get_calc cI;
224 val p = get_pos cI 1;
230 (*locatetac tac (pt, ip); (*WAS assy: call by ([3], Pbl)*)*)
231 "~~~~~ fun locatetac, args:"; val (tac, (ptp as (pt, p))) = (tac, (pt, ip));
232 val (mI,m) = mk_tac'_ tac;
234 applicable_in p pt m ; (*Appl*)
236 member op = specsteps mI; (*false*)
238 (*loc_solve_ (mI,m) ptp; (*Argument: (mI, m) : string * tac Reason: Can't unify tac_ with tac*)*)
239 loc_solve_; (*without _ ??? result is -> lOc writing error ???*)
240 (*val it = fn: string * tac_ -> ptree * (pos * pos_) -> lOc_*)
241 (mI,m); (*string * tac*)
242 ptp (*ptree * pos'*);
244 "~~~~~ fun loc_solve_, args:"; val (m ,(pt,pos)) = ((mI,m), ptp);
245 (*val (msg, cs') = solve m (pt, pos);
246 (*Argument: m : string * tac Reason: Can't unify tac_ with tac (Different type constructors)*)*)
251 "~~~~~ fun solve, args:"; val ((mI,m), (pt, po as (p,p_))) = (m, (pt, pos));
252 (*solve has still p_!!!!!!!!!!!!!!!!!!!!!!!!!*)
254 e_metID = get_obj g_metID pt (par_pblobj pt p); (*false*)
255 val ctxt = get_ctxt pt po;
257 (*generate1 (assoc_thy (get_obj g_domID pt (par_pblobj pt p))) m (e_istate, ctxt) (p,p_) pt;
258 (*Argument: m : tac Reason: Can't unify tac_ with tac (Different type constructors)*)*)
259 (assoc_thy (get_obj g_domID pt (par_pblobj pt p)));
262 (*not finished - error continues in fun generate1*)
263 (* AK110722 Debugging end*)*)
264 (*========== inhibit exn AK110721 ================================================
265 "----- WN080102 these vvv do not work, because locatetac starts the search" ^
267 (* AK110722 ERROR: assy: call by ([3], Pbl) *)
268 applyTactic 1 p (hd appltacs);
269 ============ inhibit exn AK110721 ==============================================*)
271 autoCalculate 1 CompleteCalc;
273 "----------- fun init_form, fun get_stac -------------------------";
274 "----------- fun init_form, fun get_stac -------------------------";
275 "----------- fun init_form, fun get_stac -------------------------";
276 val fmz = ["equality (x+1=(2::real))", "solveFor x", "solutions L"];
277 val (dI',pI',mI') = ("Test",["sqroot-test","univariate","equation","test"],
278 ["Test","squ-equ-test-subpbl1"]);
279 val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
280 val (p,_,f,nxt,_,pt) = me nxt p [] pt;
281 val (p,_,f,nxt,_,pt) = me nxt p [] pt;
282 val (p,_,f,nxt,_,pt) = me nxt p [] pt;
283 val (p,_,f,nxt,_,pt) = me nxt p [] pt;
284 val (p,_,f,nxt,_,pt) = me nxt p [] pt;
285 val (p,_,f,nxt,_,pt) = me nxt p [] pt;
286 val (p,_,f,nxt,_,pt) = me nxt p [] pt;
287 "~~~~~ fun me, args:"; val (_,tac) = nxt;
288 "~~~~~ fun locatetac, args:"; val ptp as (pt, p) = (pt, p);
289 val (mI,m) = mk_tac'_ tac;
290 val Appl m = applicable_in p pt m;
291 member op = specsteps mI; (*false*)
292 "~~~~~ fun loc_solve_, args:"; val (m, (pt, pos) ) = ((mI, m), ptp);
293 "~~~~~ fun solve, args:"; val (("Apply_Method", Apply_Method' (mI,_,_,_)), pos as (p,_)) = (m, pos);
294 val {srls, ...} = get_met mI;
295 val PblObj {meth=itms, ...} = get_obj I pt p;
296 val thy' = get_obj g_domID pt p;
297 val thy = assoc_thy thy';
298 val (is as ScrState (env,_,_,_,_,_), ctxt, sc) = init_scrstate thy itms mI;
299 val ini = init_form thy sc env;
300 "----- fun init_form, args:"; val (Prog sc) = sc;
301 "----- fun get_stac, args:"; val (y, h $ body) = (thy, sc);
302 case get_stac thy sc of SOME (Free ("e_e", _)) => ()
303 | _ => error "script: Const (?, ?) in script (as term) changed";;
306 "----------- x+1=2 start SubProblem 'stac2tac_ TODO: no match for ";
307 "----------- x+1=2 start SubProblem 'stac2tac_ TODO: no match for ";
308 "----------- x+1=2 start SubProblem 'stac2tac_ TODO: no match for ";
309 val fmz = ["equality (x+1=(2::real))", "solveFor x","solutions L"];
311 ("Test", ["sqroot-test","univariate","equation","test"],
312 ["Test","squ-equ-test-subpbl1"]);
313 val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
314 val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
315 val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
316 val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
317 val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
318 val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
319 val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
320 val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
321 val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
322 val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
323 (*val (p,_,f,nxt,_,pt) = me nxt p [1] pt; WAS: Empty_Tac, helpless*)
325 "~~~~~ fun me, args:"; val (_,tac) = nxt;
326 val (pt, p) = case locatetac tac (pt,p) of
327 ("ok", (_, _, ptp)) => ptp | _ => error "script.sml locatetac";
328 "~~~~~ fun step, args:"; val (ip as (_,p_), (ptp as (pt,p), tacis)) = (p, ((pt, e_pos'), []))
329 val pIopt = get_pblID (pt,ip); (*SOME ["linear", "univariate", "equation", "test"]*)
331 member op = [Pbl,Met] p_ andalso is_none (get_obj g_env pt (fst p)); (*= false*)
332 "~~~~~ fun nxt_solve_, args:"; val (ptp as (pt, pos as (p, p_))) = (pt, ip);
333 (*WAS stac2tac_ TODO: no match for SubProblem*)
334 val thy' = get_obj g_domID pt (par_pblobj pt p);
335 val (srls, is, sc) = from_pblobj_or_detail' thy' (p,p_) pt;
336 "~~~~~ fun next_tac, args:"; val (thy, (ptp as (pt,(p,_)):ptree * pos'), (sc as Prog (h $ body)),
337 (ScrState (E,l,a,v,s,b), ctxt)) = ((thy',srls), (pt,pos), sc, is);
338 l; (*= [R, L, R, L, R, R]*)
339 val Appy (m', scrst as (_,_,_,v,_,_)) = nstep_up thy ptp sc E l Skip_ a v;
340 "~~~~~ dont like to go into nstep_up...";
341 val t = str2term ("SubProblem" ^
342 "(Test', [linear, univariate, equation, test], [Test, solve_linear])" ^
343 "[BOOL (-1 + x = 0), REAL x]");
344 val (tac, tac_) = stac2tac_ pt @{theory "Isac"} t; (*WAS stac2tac_ TODO: no match for SubProblem*)
347 | _ => error "script.sml x+1=2 start SubProblem from script";
350 "----------- Take as 1st stac in script --------------------------";
351 "----------- Take as 1st stac in script --------------------------";
352 "----------- Take as 1st stac in script --------------------------";
353 val p = e_pos'; val c = [];
354 val (p,_,f,nxt,_,pt) =
356 [(["functionTerm (x^^^2 + 1)", "integrateBy x", "antiDerivative FF"],
357 ("Integrate", ["integrate","function"], ["diff","integration"]))];
358 val (p,_,f,nxt,_,pt) = me nxt p c pt; (*nxt = ("Tac ", ...) --> Add_Given...*)
359 val (p,_,f,nxt,_,pt) = me nxt p c pt;
360 val (p,_,f,nxt,_,pt) = me nxt p c pt;
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;
364 val (p,_,f,nxt,_,pt) = me nxt p c pt;
365 case nxt of (_, Apply_Method ["diff", "integration"]) => ()
366 | _ => error "integrate.sml -- me method [diff,integration] -- spec";
367 "----- step 8: returns nxt = Rewrite_Set_Inst ([\"(bdv, x)\"],\"integration\")";
369 "~~~~~ fun me, args:"; val (((_,tac):tac'_), (p:pos'), _, (pt:ptree)) = (nxt, p, c, pt);
370 "~~~~~ fun locatetac, args:"; val (tac, (ptp as (pt, p))) = (tac, (pt,p));
371 val (mI,m) = mk_tac'_ tac;
372 val Appl m = applicable_in p pt m;
373 member op = specsteps mI (*false*);
374 "~~~~~ fun loc_solve_, args:"; val (m, (pt,pos)) = ((mI,m), ptp);
375 "~~~~~ fun solve, args:"; val ((_, m as Apply_Method' (mI, _, _, _)), (pt, (pos as (p,_)))) =
377 val {srls, ...} = get_met mI;
378 val PblObj {meth=itms, ...} = get_obj I pt p;
379 val thy' = get_obj g_domID pt p;
380 val thy = assoc_thy thy';
381 val (is as ScrState (env,_,_,_,_,_), ctxt, sc) = init_scrstate thy itms mI;
382 val ini = init_form thy sc env;
385 val (m', (is', ctxt'), _) = next_tac (thy', srls) (pt, (p, Res)) sc (is, ctxt);
386 val d = e_rls (*FIXME: get simplifier from domID*);
387 "~~~~~ fun locate_gen, args:"; val ((ts as (thy',srls)), (m:tac_), ((pt,p):ptree * pos'),
388 (scr as Prog (h $ body),d), (ScrState (E,l,a,v,S,b), ctxt)) =
389 ((thy',srls), m', (pt,(p, Res)), (sc,d), (is', ctxt'));
390 val thy = assoc_thy thy';
391 l = [] orelse ((*init.in solve..Apply_Method...*)
392 (last_elem o fst) p = 0 andalso snd p = Res); (*true*)
393 "~~~~~ fun assy, args:"; val (ya, (is as (E,l,a,v,S,b),ss),
394 (Const ("HOL.Let",_) $ e $ (Abs (id,T,body)))) =
395 ((thy',ctxt,srls,d,Aundef), ((E,[R],a,v,S,b), [(m,EmptyMout,pt,p,[])]), body);
396 (*check: true*) term2str e = "Take (Integral f_f D v_v)";
397 "~~~~~ fun assy, args:"; val ((thy',ctxt,sr,d,ap), (is as (E,l,a,v,S,b), (m,_,pt,(p,p_),c)::ss), t) =
398 (ya, ((E , l@[L,R], a,v,S,b),ss), e);
399 val (a', STac stac) = handle_leaf "locate" thy' sr E a v t;
400 (* val ctxt = get_ctxt pt (p,p_)
401 exception PTREE "get_obj: pos = [0] does not exist" raised
402 (line 908 of "/usr/local/isabisac/src/Tools/isac/Interpret/ctree.sml")*)
405 "----------- 'trace_script' from outside 'fun me '----------------";
406 "----------- 'trace_script' from outside 'fun me '----------------";
407 "----------- 'trace_script' from outside 'fun me '----------------";
408 val fmz = ["equality (x+1=(2::real))", "solveFor x","solutions L"];
410 ("Test", ["sqroot-test","univariate","equation","test"],
411 ["Test","squ-equ-test-subpbl1"]);
412 val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
413 val (p,_,f,nxt,_,pt) = me nxt p [] pt;
414 val (p,_,f,nxt,_,pt) = me nxt p [] pt;
415 val (p,_,f,nxt,_,pt) = me nxt p [] pt;
416 val (p,_,f,nxt,_,pt) = me nxt p [] pt;
417 val (p,_,f,nxt,_,pt) = me nxt p [] pt;
418 val (p,_,f,nxt,_,pt) = me nxt p [] pt;
419 val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Apply_Method ["Test", "squ-equ-test-subpbl1"]*)
420 (*from_pblobj_or_detail': no istate = from_pblobj_or_detail' "Isac" p pt;*)
422 val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*---------------------------------------------------*)
423 val (p'''', pt'''') = (p, pt);
424 f2str f = "x + 1 = 2"; snd nxt = Rewrite_Set "norm_equation";
425 val (p, p_) = p(* = ([1], Frm)*);
426 val (srls, (ScrState scrstate, ctxt), Prog sc) = from_pblobj_or_detail' "Isac" (p, p_) pt;
427 val (env, loc_, curry_arg, res, Safe, true) = scrstate;
428 env2str env = "[\"\n(e_e, x + 1 = 2)\",\"\n(v_v, x)\"]";
431 term2str res = "??.empty"; (* scrstate before starting interpretation *)
432 (*term2str (go loc_ sc) = "Prog Solve_root_equation e_e v_v = ...*)
434 val (p,_,f,nxt,_,pt) = me nxt p'''' [] pt''''; (*-------------------------------------------*)
435 val (p'''', pt'''') = (p, pt);
436 f2str f = "x + 1 + -1 * 2 = 0"; snd nxt = Rewrite_Set "Test_simplify";
437 val (p, p_) = p(* = ([1], Res)*);
438 val (srls, (ScrState scrstate, ctxt), Prog sc) = from_pblobj_or_detail' "Isac" (p, p_) pt;
439 val (env, loc_, curry_arg, res, Safe, true) = scrstate;
440 env2str env = "[\"\n(e_e, x + 1 = 2)\",\"\n(v_v, x)\"]";
441 loc_ = [R, L, R, L, L, R, R];
442 curry_arg = SOME (str2term "e_e::bool");
443 term2str res = "x + 1 + -1 * 2 = 0";(* scrstate after norm_equation, before Test_simplify *)
444 term2str (go loc_ sc) = "Rewrite_Set norm_equation False";
446 val (p,_,f,nxt,_,pt) = me nxt p'''' [] pt''''; (*-------------------------------------------*)
447 val (p'''', pt'''') = (p, pt);
448 f2str f = "-1 + x = 0"; snd nxt = Subproblem ("Test", ["linear", "univariate", "equation", "test"]);
449 val (p, p_) = p(* = ([2], Res)*);
450 val (srls, (ScrState scrstate, ctxt), Prog sc) = from_pblobj_or_detail' "Isac" (p, p_) pt;
451 val (env, loc_, curry_arg, res, Safe, false) = scrstate;
452 env2str env = "[\"\n(e_e, x + 1 = 2)\",\"\n(v_v, x)\"]";
453 loc_ = [R, L, R, L, R, R];
454 curry_arg = SOME (str2term "e_e::bool");
455 term2str res = "-1 + x = 0"; (* scrstate after Test_simplify, before Subproblem *)
456 term2str (go loc_ sc) = "Rewrite_Set Test_simplify False";
458 val (p,_,f,nxt,_,pt) = me nxt p'''' [] pt''''; (*-------------------------------------------*)
459 val (p'''', pt'''') = (p, pt); (*f2str f = exception Match; ...is a model, not a formula*)
460 val (p,_,f,nxt,_,pt) = me nxt p'''' [] pt''''; (*-------------------------------------------*)
461 val (p'''', pt'''') = (p, pt);
462 val (p,_,f,nxt,_,pt) = me nxt p'''' [] pt''''; (*-------------------------------------------*)
463 val (p'''', pt'''') = (p, pt);
464 val (p,_,f,nxt,_,pt) = me nxt p'''' [] pt''''; (*-------------------------------------------*)
465 val (p'''', pt'''') = (p, pt);
466 val (p,_,f,nxt,_,pt) = me nxt p'''' [] pt''''; (*-------------------------------------------*)
467 val (p'''', pt'''') = (p, pt);
468 val (p,_,f,nxt,_,pt) = me nxt p'''' [] pt''''; (*-------------------------------------------*)
469 val (p'''', pt'''') = (p, pt);
470 val (p,_,f,nxt,_,pt) = me nxt p'''' [] pt''''; (*-------------------------------------------*)
471 val (p'''', pt'''') = (p, pt);
472 val (p,_,f,nxt,_,pt) = me nxt p'''' [] pt''''; (*nxt = Apply_Method ["Test", "solve_linear"]*)
473 (*from_pblobj_or_detail': no istate = from_pblobj_or_detail' "Isac" p pt;*)
475 val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*---------------------------------------------------*)
476 val (p'''', pt'''') = (p, pt);
477 f2str f = "-1 + x = 0"; snd nxt = Rewrite_Set_Inst (["(bdv, x)"], "isolate_bdv");
478 val (p, p_) = p(* = ([3, 1], Frm)*);
479 val (srls, (ScrState scrstate, ctxt), Prog sc) = from_pblobj_or_detail' "Isac" (p, p_) pt;
480 val (env, loc_, curry_arg, res, Safe, true) = scrstate;
481 env2str env = "[\"\n(e_e, -1 + x = 0)\",\"\n(v_v, x)\"]";
484 term2str res = "??.empty"; (* scrstate before starting interpretation *)
485 (*term2str (go loc_ sc) = "Prog Solve_linear e_e v_v = ...*)
487 val (p,_,f,nxt,_,pt) = me nxt p'''' [] pt''''; (*-------------------------------------------*)
488 val (p'''', pt'''') = (p, pt);
489 f2str f = "x = 0 + -1 * -1"; snd nxt = Rewrite_Set "Test_simplify";
490 val (p, p_) = p(* = ([3, 1], Res)*);
491 val (srls, (ScrState scrstate, ctxt), Prog sc) = from_pblobj_or_detail' "Isac" (p, p_) pt;
492 val (env, loc_, curry_arg, res, Safe, true) = scrstate;
493 env2str env = "[\"\n(e_e, -1 + x = 0)\",\"\n(v_v, x)\"]";
494 loc_ = [R, L, R, L, R, L, R];
495 curry_arg = SOME (str2term "e_e::bool");
496 term2str res = "x = 0 + -1 * -1";(* scrstate after isolate_bdv, before Test_simplify *)
497 term2str (go loc_ sc) = "Rewrite_Set_Inst [(bdv, v_v)] isolate_bdv False";
499 "----------- fun sel_rules ---------------------------------------";
500 "----------- fun sel_rules ---------------------------------------";
501 "----------- fun sel_rules ---------------------------------------";
502 (* compare test/../interface.sml
503 "--------- getTactic, fetchApplicableTactics ------------";
506 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
507 ("Test", ["sqroot-test","univariate","equation","test"],
508 ["Test","squ-equ-test-subpbl1"]))];
511 autoCalculate 1 CompleteCalc;
512 val ((pt,_),_) = get_calc 1;
515 (*UC\label{SOLVE:MANUAL:TACTIC:listall} UC 30.3.2.2 p.175*)
516 val tacs = sel_rules pt ([],Pbl);
517 if tacs = [Apply_Method ["Test", "squ-equ-test-subpbl1"]] then ()
518 else error "script.sml: diff.behav. in sel_rules ([],Pbl)";
520 val tacs = sel_rules pt ([1],Res);
521 if tacs = [Rewrite_Set "norm_equation", Rewrite_Set "Test_simplify",
522 Subproblem ("Test", ["linear", "univariate", "equation", "test"]),
523 Check_elementwise "Assumptions"] then ()
524 else error "script.sml: diff.behav. in sel_rules ([1],Res)";
526 val tacs = sel_rules pt ([3],Pbl);
527 if tacs = [Apply_Method ["Test", "solve_linear"]] then ()
528 else error "script.sml: diff.behav. in sel_rules ([3],Pbl)";
530 val tacs = sel_rules pt ([3,1],Res);
531 if tacs = [Rewrite_Set_Inst (["(bdv, x)"], "isolate_bdv"),
532 Rewrite_Set "Test_simplify"] then ()
533 else error "script.sml: diff.behav. in sel_rules ([3,1],Res)";
535 val tacs = sel_rules pt ([3],Res);
536 if tacs = [Rewrite_Set "norm_equation", Rewrite_Set "Test_simplify",
537 Subproblem ("Test", ["linear", "univariate", "equation", "test"]),
538 Check_elementwise "Assumptions"] then ()
539 else error "script.sml: diff.behav. in sel_rules ([3],Res)";
541 val tacs = (sel_rules pt ([],Res)) handle PTREE str => [Tac str];
542 if tacs = [Tac "no tactics applicable at the end of a calculation"] then ()
543 else error "script.sml: diff.behav. in sel_rules ([],Res)";
545 "----------- fun sel_appl_atomic_tacs ----------------------------";
546 "----------- fun sel_appl_atomic_tacs ----------------------------";
547 "----------- fun sel_appl_atomic_tacs ----------------------------";
549 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
550 ("Test", ["sqroot-test","univariate","equation","test"],
551 ["Test","squ-equ-test-subpbl1"]))];
554 autoCalculate 1 CompleteCalc;
556 (*UC\label{SOLVE:MANUAL:TACTIC:listall} UC 30.3.2.2 p.175*)
557 fetchApplicableTactics 1 99999 ([],Pbl);
559 fetchApplicableTactics 1 99999 ([1],Res);
560 "~~~~~ fun fetchApplicableTactics, args:"; val (cI, (scope:int), (p:pos')) = (1, 99999, ([1],Res));
561 val ((pt, _), _) = get_calc cI;
563 if sel_rules pt p = [Rewrite_Set "norm_equation", Rewrite_Set "Test_simplify",
564 Subproblem ("Test", ["linear", "univariate", "equation", "test"]),
565 Check_elementwise "Assumptions"] then ()
566 else error "fetchApplicableTactics ([1],Res) changed";
569 sel_appl_atomic_tacs pt p;
571 ### atomic_appl_tacs: not impl. for tac='Subproblem(Test,["linear","univariate","equation","test"])'
572 ### atomic_appl_tacs: not impl. for tac = 'Check_elementwise "Assumptions"'
575 "~~~~~ fun sel_appl_atomic_tacs, args:"; val (pt, (p,p_)) = (pt, p);
576 is_spec_pos p_ = false;
577 val pp = par_pblobj pt p
578 val thy' = (get_obj g_domID pt pp):theory'
579 val thy = assoc_thy thy'
580 val metID = get_obj g_metID pt pp
583 then (thd3 o snd3) (get_obj g_origin pt pp)
585 val {scr=Prog sc,srls,erls,rew_ord'=ro,...} = get_met metID'
586 val ScrState (env,_,a,v,_,_) = get_istate pt (p,p_)
587 val alltacs = (*we expect at least 1 stac in a script*)
588 map ((stac2tac pt thy) o rep_stacexpr o #2 o
589 (handle_leaf "selrul" thy' srls env a v)) (stacpbls sc)
592 Frm => get_obj g_form pt p
593 | Res => (fst o (get_obj g_result pt)) p
594 (*WN120611 stopped and took version 1 again for fetchApplicableTactics !
595 (distinct o flat o (map (atomic_appl_tacs thy ro erls f))) alltacs
597 ### atomic_appl_tacs: not impl. for tac='Subproblem(Test,["linear","univariate","equation","test"])'
598 ### atomic_appl_tacs: not impl. for tac = 'Check_elementwise "Assumptions"'