1 (* Title: "Interpret/lucas-interpreter.sml"
3 (c) due to copyright terms
6 "-----------------------------------------------------------------------------------------------";
7 "table of contents -----------------------------------------------------------------------------";
8 "-----------------------------------------------------------------------------------------------";
9 "----------- Take as 1st stac in program -------------------------------------------------------";
10 "----------- re-build: fun locate_input_tactic -------------------------------------------------";
11 "----------- fun locate_input_tactic Helpless, NOT applicable ----------------------------------";
12 "----------- re-build: fun find_next_step, mini ------------------------------------------------";
13 "----------- re-build: fun locate_input_term ---------------------------------------------------";
14 "-----------------------------------------------------------------------------------------------";
15 "-----------------------------------------------------------------------------------------------";
16 "-----------------------------------------------------------------------------------------------";
18 "----------- Take as 1st stac in program -------------------------------------------------------";
19 "----------- Take as 1st stac in program -------------------------------------------------------";
20 "----------- Take as 1st stac in program -------------------------------------------------------";
21 "compare --- Apply_Method with initial Take by Step.do_next --- in test/../step-solve ----------";
22 val p = e_pos'; val c = [];
23 val (p,_,f,nxt,_,pt) =
25 [(["functionTerm (x \<up> 2 + 1)", "integrateBy x", "antiDerivative FF"],
26 ("Integrate", ["integrate", "function"], ["diff", "integration"]))];
27 val (p,_,f,nxt,_,pt) = me nxt p c pt; (*\<rightarrow> Add_Given "functionTerm (x \<up> 2 + 1)"*)
28 val (p,_,f,nxt,_,pt) = me nxt p c pt;
29 val (p,_,f,nxt,_,pt) = me nxt p c pt;
30 val (p,_,f,nxt,_,pt) = me nxt p c pt;
31 val (p,_,f,nxt,_,pt) = me nxt p c pt;
33 val (p''',_,f,nxt''',_,pt''') = me nxt p c pt; (*nxt'''= Specify_Method ["diff", "integration"]*)
34 (*/------------------- step into me Specify_Method ["diff", "integration"] -----------------\*)
35 "~~~~~ fun me , args:"; val (tac, p, _, pt) = (nxt''', p''', c, pt''');
37 (*Step.by_tactic is here for testing by me; do_next would suffice in me*)
38 case Step.by_tactic tac (pt, p) of
39 ("ok", (_, _, ptp)) => ptp
41 val ("ok", ([(Apply_Method ["diff", "integration"], _, _)], _, _)) = (*case*)
42 Step.do_next p ((pt, Pos.e_pos'), []) (*of*);
43 "~~~~~ fun do_next , args:"; val ((ip as (_, p_)), (ptp as (pt, p), tacis))
44 = (p, ((pt, Pos.e_pos'), []));
45 (*if*) Pos.on_calc_end ip (*else*);
46 val (_, probl_id, _) = Calc.references (pt, p);
48 (*case*) tacis (*of*);
49 (*if*) probl_id = Problem.id_empty (*else*);
51 val ("ok", ([(Apply_Method ["diff", "integration"], _, _)], _, _)) =
52 Step.switch_specify_solve p_ (pt, ip);
53 "~~~~~ fun switch_specify_solve , args:"; val (state_pos, (pt, input_pos)) = (p_, (pt, ip));
54 (*if*) Pos.on_specification ([], state_pos) (*then*);
56 Step.specify_do_next (pt, input_pos);
57 "~~~~~ fun specify_do_next , args:"; val (ptp as (pt, (p, p_))) = (pt, input_pos);
58 val (_, (p_', tac)) = Specify.find_next_step ptp
59 val ist_ctxt = Ctree.get_loc pt (p, p_)
60 val Tactic.Apply_Method mI =
63 val ("ok", ([(Apply_Method ["diff", "integration"], _, _)], _, _)) =
64 LI.by_tactic (Tactic.Apply_Method' (mI, NONE, Istate.empty, ContextC.empty))
65 ist_ctxt (pt, (p, p_'));
66 "~~~~~ fun by_tactic , args:"; val ((Tactic.Apply_Method' (mI, _, _, _)), (_, ctxt), (pt, pos as (p, _)))
67 = ((Tactic.Apply_Method' (mI, NONE, Istate.empty, ContextC.empty)),
68 ist_ctxt, (pt, (p, p_')));
69 val (itms, oris, probl) = case get_obj I pt p of (*STILL asms=[]*)
70 PblObj {meth = itms, origin = (oris, _, _), probl, ...} => (itms, oris, probl)
71 | _ => raise ERROR "LI.by_tactic Apply_Method': uncovered case get_obj"
72 val {ppc, ...} = MethodC.from_store ctxt mI;
73 val itms = if itms <> [] then itms else I_Model.complete oris probl [] ppc
74 val srls = LItool.get_simplifier (pt, pos)
75 val (is, env, ctxt, prog) = case LItool.init_pstate srls ctxt itms mI of
76 (is as Pstate {env, ...}, ctxt, scr) => (is, env, ctxt, scr)
77 | _ => raise ERROR "LI.by_tactic Apply_Method': uncovered case init_pstate"
78 val ini = LItool.implicit_take prog env;
79 val pos = start_new_level pos
83 val Next_Step (iii, ccc, ttt) = (*case*)
84 LI.find_next_step prog (pt, (lev_dn p, Res)) is ctxt (*of*);
85 "~~~~~ fun find_next_step , args:"; val ((Rule.Prog prog), (ptp as (pt, pos as (p, _))), (Pstate ist), ctxt)
86 = (prog, (pt, (lev_dn p, Res)), is, ctxt);
89 scan_to_tactic (prog, (ptp, ctxt)) (Pstate ist) (*of*);
90 "~~~~~ fun scan_to_tactic , args:"; val ((prog, cc), (Pstate (ist as {path, ...})))
91 = ((prog, (ptp, ctxt)), (Pstate ist));
92 (*if*) path = [] (*then*);
94 val Accept_Tac (ttt, sss, ccc) =
95 scan_dn cc (trans_scan_dn ist) (Program.body_of prog);
96 "~~~~~ fun scan_dn , args:"; val (cc, ist, (Const (\<^const_name>\<open>Let\<close>(*1*), _) $ e $ (Abs (i, T, b))))
97 = (cc, (trans_scan_dn ist), (Program.body_of prog));
99 val Accept_Tac (ttt, sss, ccc) = (*case*)
100 scan_dn cc (ist |> path_down [L, R]) e (*of*);
101 "~~~~~ fun scan_dn , args:"; val ((cc as (_, ctxt)), (ist as {eval, ...}), t)
102 = (cc, (ist |> path_down [L, R]), e);
103 (*if*) Tactical.contained_in t (*else*);
104 val (Program.Tac prog_tac, form_arg) =
105 (*case*) LItool.check_leaf "next " ctxt eval (get_subst ist) t (*of*);
107 val Accept_Tac (ttt, sss, ccc) =
108 check_tac cc ist (prog_tac, form_arg);
109 "~~~~~ fun check_tac , args:"; val (((pt, p), ctxt), ist, (prog_tac, form_arg))
110 = (cc, ist, (prog_tac, form_arg));
111 val m = LItool.tac_from_prog pt (Proof_Context.theory_of ctxt) prog_tac
116 Solve_Step.check m (pt, p) (*of*);
117 "~~~~~ fun check , args:"; val ((Tactic.Take str), (pt, pos as (p_, p))) = (m, (pt, p));
119 (*+*)val ([0], Res) = pos; (*<<<-------------------------*)
120 (*-------------------- stop step into me Specify_Method ["diff", "integration"] -------------*)
121 (*\------------------- step into me Specify_Method ["diff", "integration"] -----------------/*)
123 val (p,_,f,nxt,_,pt) = me nxt''' p''' c pt''';
124 case nxt of (Apply_Method ["diff", "integration"]) => ()
125 | _ => error "integrate.sml -- me method [diff,integration] -- spec";
126 "----- step 8: returns nxt = Rewrite_Set_Inst ([\"(''bdv'', x)\"],\"integration\")";
128 "~~~~~ fun me, args:"; val (tac, (p:pos'), _, (pt:ctree)) = (nxt, p, c, pt);
129 "~~~~~ fun Step.by_tactic, args:"; val (tac, (ptp as (pt, p))) = (tac, (pt,p));
130 val Applicable.Yes m = Step.check tac (pt, p);
131 (*if*) Tactic.for_specify' m; (*false*)
132 "~~~~~ fun loc_solve_ , args:"; val (m, (pt,pos)) = (m, ptp);
134 "~~~~~ fun Step_Solve.by_tactic , args:"; val (m as Apply_Method' (mI, _, _, ctxt), (pt, (pos as (p,_))))
136 val {srls, ...} = MethodC.from_store ctxt mI;
137 val itms = case get_obj I pt p of
138 PblObj {meth=itms, ...} => itms
139 | _ => error "solve Apply_Method: uncovered case get_obj"
140 val thy' = get_obj g_domID pt p;
141 val thy = ThyC.get_theory thy';
142 val srls = LItool.get_simplifier (pt, pos)
143 val (is, env, ctxt, sc) = case LItool.init_pstate srls ctxt itms mI of
144 (is as Istate.Pstate {env, ...}, ctxt, sc) => (is, env, ctxt, sc)
145 | _ => error "solve Apply_Method: uncovered case init_pstate";
146 (*+*)pstate2str (the_pstate is) = "([\"\n(f_f, x \<up> 2 + 1)\",\"\n(v_v, x)\"], [], empty, NONE, \n??.empty, ORundef, false, true)";
147 val ini = LItool.implicit_take sc env;
150 val NONE = (*case*) ini (*of*);
151 val Next_Step (is', ctxt', m') =
152 LI.find_next_step sc (pt, (p, Res)) is ctxt;
153 (*+*)pstate2str (the_pstate is') = "([\"\n(f_f, x \<up> 2 + 1)\",\"\n(v_v, x)\"], [R,L,R], empty, NONE, \nIntegral x \<up> 2 + 1 D x, ORundef, false, false)";
154 val Safe_Step (_, _, Take' _) = (*case*)
155 locate_input_tactic sc (pt, (p, Res)) is' ctxt' m' (*of*);
156 "~~~~~ fun locate_input_tactic , args:"; val ((Prog prog), cstate, istate, ctxt, tac)
157 = (sc, (pt, (p, Res)), is', ctxt', m');
159 (*case*) scan_to_tactic1 (prog, (cstate, ctxt, tac)) istate (*of*);
160 "~~~~~ fun scan_to_tactic1 , args:"; val ((prog, (cctt as ((_, p), _, _))), (Istate.Pstate (ist as {path, ...})))
161 = ((prog, (cstate, ctxt, tac)), istate);
162 (*if*) path = [] orelse ((last_elem o fst) p = 0 andalso snd p = Res) (*then*);
164 val Accept_Tac1 (_, _, Take' _) =
165 scan_dn1 cctt (ist |> set_path [R] |> set_or ORundef) (Program.body_of prog);
166 "~~~~~ fun scan_dn1 , args:"; val (xxx, ist, (Const (\<^const_name>\<open>Let\<close>, _) $ e $ (Abs (id, T, b))))
167 = (cctt, (ist |> set_path [R] |> set_or ORundef), (Program.body_of prog));
169 (*+*) if UnparseC.term e = "Take (Integral f_f D v_v)" then () else error "scan_dn1 Integral changed";
172 scan_dn1 xxx (ist |> path_down [L, R]) e (*of*);
173 (*======= end of scanning tacticals, a leaf =======*)
174 "~~~~~ fun scan_dn1 , args:"; val (((pt, p), ctxt, tac), (ist as {eval, or, ...}), t)
175 = (xxx, (ist |> path_down [L, R]), e);
176 val (Program.Tac stac, a') = check_leaf "locate" ctxt eval (get_subst ist) t;
180 "----------- re-build: fun locate_input_tactic -------------------------------------------------";
181 "----------- re-build: fun locate_input_tactic -------------------------------------------------";
182 "----------- re-build: fun locate_input_tactic -------------------------------------------------";
183 val fmz = ["equality (x+1=(2::real))", "solveFor x", "solutions L"];
184 val (dI',pI',mI') = ("Test", ["sqroot-test", "univariate", "equation", "test"],
185 ["Test", "squ-equ-test-subpbl1"]);
186 val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
187 val (p,_,f,nxt,_,pt) = me nxt p [] pt;
188 val (p,_,f,nxt,_,pt) = me nxt p [] pt;
189 val (p,_,f,nxt,_,pt) = me nxt p [] pt;
190 val (p,_,f,nxt,_,pt) = me nxt p [] pt;
191 val (p,_,f,nxt,_,pt) = me nxt p [] pt;
192 val (p,_,f,nxt,_,pt) = me nxt p [] pt;
193 (*[], Met*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = (_, Apply_Method ["Test", "squ-equ-test-subpbl1"])*);
194 (*[1], Frm*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = ("Rewrite_Set", Rewrite_Set "norm_equation")*)
196 (*//------------------ begin step into ------------------------------------------------------\\*)
197 (*[1], Res*)val (p'''''_''',_,f,nxt'''''_''',_,pt'''''_''') = me nxt p [] pt; (*nxt = Rewrite_Set "Test_simplify"*)
199 "~~~~~ fun me , args:"; val (tac, p, _(*NEW remove*), pt) = (nxt, p, [], pt);
201 (** )val (***)xxxx(***) ( *("ok", (_, _, (pt, p))) =( **) (*case*)
202 Step.by_tactic tac (pt,p) (*of*);
203 "~~~~~ fun by_tactic , args:"; val (tac, (ptp as (pt, p))) = (tac, (pt,p));
204 val Applicable.Yes m = (*case*) Solve_Step.check tac (pt, p) (*of*);
205 (*if*) Tactic.for_specify' m; (*false*)
207 (** )val (***)xxxxx_x(***) ( *(msg, cs') =( **)
208 Step_Solve.by_tactic m ptp;
209 "~~~~~ fun by_tactic , args:"; val (m, (pt, po as (p, p_))) = (m, ptp);
210 (*+*)val (pt'''''_', (p'''''_', p_'''''_')) = (pt, (p, p_));
211 (*if*) MethodC.id_empty = get_obj g_metID pt (par_pblobj pt p); (*else*)
212 val thy' = get_obj g_domID pt (par_pblobj pt p);
213 val (is, sc) = LItool.resume_prog (p,p_) pt;
215 locate_input_tactic sc (pt, po) (fst is) (snd is) m;
216 "~~~~~ fun locate_input_tactic , args:"; val (Prog prog, cstate, istate, ctxt, tac)
217 = (sc, (pt, po), (fst is), (snd is), m);
218 val srls = get_simplifier cstate;
220 (** )val Accept_Tac1 ((is as (_,_,_,_,_,strong_ass), ctxt, ss as((tac', _, ctree, pos', _) :: _))) =( **)
221 (*case*) scan_to_tactic1 (prog, (cstate, ctxt, tac)) istate (*of*);
222 "~~~~~ fun scan_to_tactic1 , args:"; val ((prog, (cctt as ((_, p), _, _))), (Istate.Pstate (ist as {path, ...})))
223 = ((prog, (cstate, ctxt, tac)), istate);
224 (*if*) path = [] orelse ((last_elem o fst) p = 0 andalso snd p = Res) (*then*);
226 (** )val xxxxx_xx = ( **)
227 scan_dn1 cctt (ist |> set_path [R] |> set_or ORundef) (Program.body_of prog);
228 "~~~~~ fun scan_dn1 , args:"; val (xxx, ist, (Const (\<^const_name>\<open>Let\<close>, _) $ e $ (Abs (id, T, b))))
229 = (cctt, (ist |> set_path [R] |> set_or ORundef), (Program.body_of prog));
231 (*case*) scan_dn1 xxx (ist |> path_down [L, R]) e (*of*);
232 "~~~~~ fun scan_dn1 , args:"; val ((xxx as (cstate, _, _)), ist, (Const (\<^const_name>\<open>Chain\<close>(*1*), _) $ e1 $ e2 $ a))
233 = (xxx, (ist |> path_down [L, R]), e);
235 (*case*) scan_dn1 xxx (ist |> path_down_form ([L, L, R], a)) e1 (*of*);
236 "~~~~~ fun scan_dn1 , args:"; val (xxx, ist, (Const (\<^const_name>\<open>Try\<close>(*2*), _) $ e))
237 = (xxx, (ist |> path_down_form ([L, L, R], a)), e1);
239 (*case*) scan_dn1 xxx (ist |> path_down [R]) e (*of*);
240 (*======= end of scanning tacticals, a leaf =======*)
241 "~~~~~ fun scan_dn1 , args:"; val (((pt, p), ctxt, tac), (ist as {env, eval, or, ...}), t)
242 = (xxx, (ist |> path_down [R]), e);
243 val (Program.Tac stac, a') =
244 (*case*) check_leaf "locate" ctxt eval (get_subst ist) t (*of*);
245 val LItool.Associated (m, v', ctxt) =
246 (*case*) associate pt ctxt (m, stac) (*of*);
248 Accept_Tac1 (ist |> set_subst_true (a', v'), ctxt, m) (*return value*);
249 "~~~~~ from scan_dn1 to scan_to_tactic1 return val:"; val (xxxxx_xx)
250 = (Accept_Tac1 (ist |> set_subst_true (a', v'), ctxt, m));
252 "~~~~~ from scan_to_tactic1 to fun locate_input_tactic return val:"; val Accept_Tac1 ((ist as {assoc, ...}), ctxt, tac')
253 = (Accept_Tac1 (ist |> set_subst_true (a', v'), ctxt, m));
254 (*if*) LibraryC.assoc (*then*);
256 Safe_Step (Istate.Pstate ist, ctxt, tac') (*return value*);
257 "~~~~~ from locate_input_tactic to fun Step_Solve.by_tactic return:"; val Safe_Step (istate, ctxt, tac)
258 = (*xxxxx_xx*)(**)Safe_Step (Istate.Pstate ist, ctxt, tac')(**);
260 (*+*)val (pt, po as (p, p_)) = (pt'''''_', (p'''''_', p_'''''_')); (* from begin of by_tactic *)
261 val (p'', _, _,pt') =
262 Step.add tac (istate, ctxt) (pt, (lev_on p, Pbl));
265 ("ok", ([(Tactic.input_from_T tac, tac, (p'', (istate, ctxt)))],
266 [(*ctree NOT cut*)], (pt', p''))) (*return value*);
267 "~~~~~ from Step_Solve.by_tactic \<longrightarrow> Step.by_tactic return:"; val ((msg, cs' : Calc.state_post))
268 = ("ok", ([(Tactic.input_from_T tac, tac, (p'', (istate, ctxt)) )],
269 [(*ctree NOT cut*)], (pt', p'')));
271 "~~~~~ from Step.by_tactic to me return:"; val (("ok", (_, _, (pt, p)))) = (*** )xxxx( ***) ("ok", cs');
273 (case Step.do_next p ((pt, Pos.e_pos'), []) of
274 ("ok", (ts as (_, _, _) :: _, _, _)) => ("", ts)
275 | ("helpless", _) => ("helpless: cannot propose tac", [])
276 | ("no-fmz-spec", _) => error "no-fmz-spec"
277 | ("end-of-calculation", (ts, _, _)) => ("", ts)
278 | _ => error "me: uncovered case")
279 handle ERROR msg => raise ERROR msg
282 tacis as (_::_) => let val (tac, _, _) = last_elem tacis in tac end
283 | _ => if p = ([], Pos.Res) then Tactic.End_Proof' else Tactic.Empty_Tac;
285 (p, [] : NEW, TESTg_form (pt, p), (Tactic.tac2IDstr tac, tac), Celem.Sundef, pt);
286 "~~~~~ from me to TOOPLEVEL return:"; val (p,_,f,nxt,_,pt)
287 = (*** )xxx( ***) (p, [] : NEW, TESTg_form (pt, p), (Tactic.tac2IDstr tac, tac), Celem.Sundef, pt);
289 (*//--------------------- check results from modified me ----------------------------------\\*)
290 if p = ([2], Res) andalso
291 pr_ctree pr_short pt = ". ----- pblobj -----\n1. x + 1 = 2\n2. x + 1 = 2\n"
293 (case nxt of ("Rewrite_Set", Rewrite_Set "Test_simplify") => ()
295 else error "check results from modified me CHANGED";
296 (*\\--------------------- check results from modified me ----------------------------------//*)
298 "~~~~~ from me to TOPLEVEL return:"; val (p,_,f,nxt,_,pt) = (*** )xxx( ***) (**)(p, 000, f, nxt, 000, pt)(**);
299 (*\\------------------ end step into --------------------------------------------------------//*)
301 (*[3], Res*)val (p,_,f,nxt,_,pt) = me nxt'''''_''' p'''''_''' [] pt'''''_'''; (*nxt = Subproblem ("Test", ["LINEAR", "univariate", "equation", "test"])*)
302 (*[3], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Model_Problem*)
303 (*[3], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Add_Given "equality (- 1 + x = 0)"*)
304 (*[3], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Add_Given "solveFor x"*)
305 (*[3], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Add_Find "solutions x_i"*)
306 (*[3], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Specify_Theory "Test"*)
307 (*[3], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Specify_Problem ["LINEAR", "univariate", "equation", "test"]*)
308 (*[3], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Specify_Method ["Test", "solve_linear"]*)
309 (*[3], Met*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Apply_Method ["Test", "solve_linear"]*)
310 (*[3, 1], Frm*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Rewrite_Set_Inst (["(''bdv'', x)"], "isolate_bdv")*)
311 (*[3, 1], Res*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Rewrite_Set "Test_simplify"*)
312 (*[3, 2], Res*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Check_Postcond ["LINEAR", "univariate", "equation", "test"]*)
313 (*[3], Res*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Check_elementwise "Assumptions"*)
314 (*[4], Res*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Check_Postcond ["sqroot-test", "univariate", "equation", "test"]*)
315 (*[], Res*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = End_Proof'*)
317 (*/--------------------- final test ----------------------------------\\*)
318 if p = ([], Res) andalso f2str f = "[x = 1]" andalso pr_ctree pr_short pt =
319 ". ----- pblobj -----\n" ^
321 "2. x + 1 + - 1 * 2 = 0\n" ^
322 "3. ----- pblobj -----\n" ^
323 "3.1. - 1 + x = 0\n" ^
324 "3.2. x = 0 + - 1 * - 1\n" ^
326 then case nxt of End_Proof' => () | _ => error "re-build: fun locate_input_tactic changed 1"
327 else error "re-build: fun locate_input_tactic changed 2";
330 "----------- fun locate_input_tactic Helpless, NOT applicable ----------------------------------";
331 "----------- fun locate_input_tactic Helpless, NOT applicable ----------------------------------";
332 "----------- fun locate_input_tactic Helpless, NOT applicable ----------------------------------";
333 (*cp from -- try fun applyTactics ------- *)
334 val (p,_,f,nxt,_,pt) = CalcTreeTEST [(["Term (5*e + 6*f - 8*g - 9 - 7*e - 4*f + 10*g + 12)",
336 ("PolyMinus",["plus_minus", "polynom", "vereinfachen"],
337 ["simplification", "for_polynomials", "with_minus"]))];
338 val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
339 val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
340 val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
341 (*[1], Frm*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Rewrite_Set "ordne_alphabetisch"*)
343 (*+*)val Test_Out.FormKF "5 * e + 6 * f - 8 * g - 9 - 7 * e - 4 * f + 10 * g + 12" = f
345 (*[1], Res*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Rewrite_Set "fasse_zusammen"*)
347 (*+*)if map Tactic.input_to_string (specific_from_prog pt p) =
348 ["Rewrite (\"subtrahiere_x_plus_minus\", \"\<lbrakk>?l is_num; ?m is_num\<rbrakk>\n\<Longrightarrow> ?x + ?m * ?v - ?l * ?v = ?x + (?m - ?l) * ?v\")",
349 "Rewrite (\"subtrahiere_x_minus_plus\", \"\<lbrakk>?l is_num; ?m is_num\<rbrakk>\n\<Longrightarrow> ?x - ?m * ?v + ?l * ?v = ?x + (- ?m + ?l) * ?v\")",
350 (*this is new since ThmC.numerals_to_Free.-----\\*)
352 then () else error "specific_from_prog ([1], Res) 1 CHANGED";
353 (*[2], Res*)val ("ok", (_, _, ptp as (pt, p))) = Step.by_tactic (hd (specific_from_prog pt p)) (pt, p);
355 (*+*)if map Tactic.input_to_string (specific_from_prog pt p) = [
356 "Rewrite (\"tausche_minus\", \"\<lbrakk>?b ist_monom; ?a kleiner ?b\<rbrakk>\n\<Longrightarrow> ?b - ?a = - ?a + ?b\")",
357 "Rewrite (\"subtrahiere_x_plus_minus\", \"\<lbrakk>?l is_num; ?m is_num\<rbrakk>\n\<Longrightarrow> ?x + ?m * ?v - ?l * ?v = ?x + (?m - ?l) * ?v\")",
358 "Rewrite (\"subtrahiere_x_minus_plus\", \"\<lbrakk>?l is_num; ?m is_num\<rbrakk>\n\<Longrightarrow> ?x - ?m * ?v + ?l * ?v = ?x + (- ?m + ?l) * ?v\")",
359 (*this is new since ThmC.numerals_to_Free.-----\\*)
361 (*this is new since ThmC.numerals_to_Free.-----//*)
363 then () else error "specific_from_prog ([1], Res) 2 CHANGED";
364 (* = ([3], Res)*)val ("ok", (_, _, ptp as (pt, p))) = Step.by_tactic (hd (specific_from_prog pt p)) (pt, p);
366 (*//----------------- exception PTREE "get_obj f EmptyPtree" raised --------------------------\\*)
367 (**)val ("ok", ([(Rewrite ("tausche_minus", _), _, _)], _, _)) = (*isa*)
368 Step.by_tactic (hd (specific_from_prog pt p)) (pt, p);
369 "~~~~~ fun by_tactic , args:"; val (tac, (ptp as (pt, p))) = (hd (specific_from_prog pt p), (pt, p));
370 val Applicable.Yes m = (*case*) Solve_Step.check tac (pt, p) (*of*);
371 (*if*) Tactic.for_specify' m; (*false*)
373 (**) val ("ok", ([(Rewrite ("tausche_minus", _), _, _)], _, _)) = (*isa*)
374 Step_Solve.by_tactic m (pt, p);
375 "~~~~~ fun by_tactic , args:"; val (m, (pt, po as (p, p_))) = (m, (pt, p));
376 (*if*) MethodC.id_empty = get_obj g_metID pt (par_pblobj pt p) (*else*);
377 val thy' = get_obj g_domID pt (par_pblobj pt p);
378 val (is, sc) = LItool.resume_prog (p,p_) pt;
380 (*case*) locate_input_tactic sc (pt, po) (fst is) (snd is) m (*of*);
381 "~~~~~ fun locate_input_tactic , args:"; val ((Rule.Prog prog), (cstate as (pt, (*?*)pos(*?*))), istate, ctxt, tac)
382 = (sc, (pt, po), (fst is), (snd is), m);
383 val srls = LItool.get_simplifier cstate (*TODO: shift into Istate.T*);
385 (*case*) scan_to_tactic1 (prog, (cstate, ctxt, tac)) istate (*of*);
386 "~~~~~ fun scan_to_tactic1 , args:"; val ((prog, (cctt as ((_, p), _, _))), (Istate.Pstate (ist as {path, ...})))
387 = ((prog, (cstate, ctxt, tac)), istate);
388 (*if*) path = [] orelse ((last_elem o fst) p = 0 andalso snd p = Res) (*else*);
390 go_scan_up1 (prog, cctt) ist;
391 "~~~~~ fun go_scan_up1 , args:"; val ((pcct as (prog, _)), (ist as {path, ...}))
392 = ((prog, cctt), ist);
393 (*if*) 1 < length path (*then*);
395 scan_up1 pcct (ist |> path_up) (TermC.sub_at (path_up' path) prog);
396 "~~~~~ and scan_up1 , args:"; val (pcct, ist, (Const (\<^const_name>\<open>Try\<close>(*2*), _) $ _))
397 = (pcct, (ist |> path_up), (TermC.sub_at (path_up' path) prog));
399 go_scan_up1 pcct ist;
400 "~~~~~ and go_scan_up1 , args:"; val ((pcct as (prog, _)), (ist as {path, ...}))
402 (*if*) 1 < length path (*then*);
404 scan_up1 pcct (ist |> path_up) (TermC.sub_at (path_up' path) prog);
405 "~~~~~ and scan_up1 , args:"; val ((pcct as (prog, cct as (cstate, _, _))), ist,
406 (Const (\<^const_name>\<open>Chain\<close>(*3*), _) $ _ ))
407 = (pcct, (ist |> path_up), (TermC.sub_at (path_up' path) prog));
408 val e2 = check_Seq_up ist prog
410 (*case*) scan_dn1 cct (ist |> path_up_down [R] |> set_or ORundef) e2 (*of*);
411 "~~~~~ fun scan_dn1 , args:"; val (yyy, ist, (Const (\<^const_name>\<open>Chain\<close>(*2*), _) $ e1 $ e2))
412 = (cct, (ist |> path_up_down [R] |> set_or ORundef), e2);
414 (*case*) scan_dn1 cct (ist |> path_down [L, R]) e1 (*of*);
415 "~~~~~ fun scan_dn1 , args:"; val (xxx, ist, (Const (\<^const_name>\<open>Try\<close>(*2*), _) $ e))
416 = (cct, (ist |> path_down [L, R]), e1);
418 (*case*) scan_dn1 cct (ist |> path_down [R]) e (*of*);
419 (*======= end of scanning tacticals, a leaf =======*)
420 "~~~~~ fun scan_dn1 , args:"; val ((cct as (_, ctxt, _)), (ist as {eval, ...}), t)
421 = (cct, (ist |> path_down [R]), e);
422 (*if*) Tactical.contained_in t (*else*);
423 val (Program.Tac prog_tac, form_arg) = (*case*)
424 LItool.check_leaf "locate" ctxt eval (get_subst ist) t (*of*);
426 check_tac1 cct ist (prog_tac, form_arg);
427 "~~~~~ fun check_tac1 , args:"; val (((pt, p), ctxt, tac), (ist as {act_arg, or, ...}), (prog_tac, form_arg)) =
428 (cct, ist, (prog_tac, form_arg));
429 val LItool.Not_Associated = (*case*)
430 LItool.associate pt ctxt (tac, prog_tac) (*of*);
431 val _(*ORundef*) = (*case*) or (*of*);
433 (*+*)Solve_Step.check (LItool.tac_from_prog pt (ThyC.get_theory "Isac_Knowledge") prog_tac) (pt, p);
435 val Applicable.Yes m' =
436 (*case*) Solve_Step.check (LItool.tac_from_prog pt (ThyC.get_theory "Isac_Knowledge") prog_tac) (pt, p) (*of*);
438 Reject_Tac1 (ist |> set_subst_false (form_arg, Tactic.result m'), ctxt, tac)
439 (*return from check_tac1*);
440 "~~~~~ from fun check_tac1 \<longrightarrow>fun scan_dn1 \<longrightarrow>fun scan_dn1 \<longrightarrow>fun locate_input_tactic , return:"; val (Reject_Tac1 _) =
441 (Reject_Tac1 (ist |> set_subst_false (form_arg, Tactic.result m'), ctxt, tac));
443 val Test_Out.FormKF "- 9 + 12 + 5 * e - 7 * e + 6 * f - 4 * f - 8 * g + 10 * g" = f;
447 "----------- re-build: fun find_next_step, mini ------------------------------------------------";
448 "----------- re-build: fun find_next_step, mini ------------------------------------------------";
449 "----------- re-build: fun find_next_step, mini ------------------------------------------------";
450 val fmz = ["Term (a + a ::real)", "normalform n_n"];
451 val (dI',pI',mI') = ("Poly",["polynomial", "simplification"],["simplification", "for_polynomials"]);
452 val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
453 (*[], Pbl*)val (_, ([(tac, _, _)], _, (pt, p))) = Step.do_next p ((pt, Pos.e_pos'), []);(*Model_Problem*)
454 (*[], Pbl*)val (_, ([(tac, _, _)], _, (pt, p))) = Step.do_next p ((pt, Pos.e_pos'), []);(*Specify_Theory "Poly"*)
455 (*[], Pbl*)val (_, ([(tac, _, _)], _, (pt, p))) = Step.do_next p ((pt, Pos.e_pos'), []);(*Specify_Problem ["polynomial", "simplification"]*)
456 (*[], Met*)val (_, ([(tac, _, _)], _, (pt, p))) = Step.do_next p ((pt, e_pos'), []);(*Specify_Method ["simplification", "for_polynomials"]*)
457 (*1], Frm*)val (_, ([(tac, _, _)], _, (pt, p))) = Step.do_next p ((pt, e_pos'), []);(*Apply_Method ["simplification", "for_polynomials"]*)
458 (*[1], Res*)val (_, ([(tac'''''_', _, _)], _, (pt'''''_', p'''''_'))) =
460 Step.do_next p ((pt, e_pos'), []);(*Rewrite_Set "norm_Poly"*)
461 (*//------------------ go into 1 ------------------------------------------------------------\\*)
462 "~~~~~ fun do_next , args:"; val ((ip as (_, p_)), (ptp as (pt, p), tacis))
463 = (p, ((pt, e_pos'), []));
464 val pIopt = Ctree.get_pblID (pt, ip);
465 (*if*) ip = ([], Res) (*else*);
466 val _ = (*case*) tacis (*of*);
467 val SOME _ = (*case*) pIopt (*of*);
468 (*if*) member op = [Pos.Pbl, Pos.Met] p_ (*else*);
470 val ("ok", ([(Rewrite_Set "norm_Poly", _, _)], _, (_, ([1], Res)))) =
471 Step_Solve.do_next (pt, ip);
472 "~~~~~ and do_next , args:"; val (ptp as (pt, pos as (p, p_))) = (pt, ip);
473 (*if*) MethodC.id_empty = get_obj g_metID pt (par_pblobj pt p) (*else*);
474 val thy' = get_obj g_domID pt (par_pblobj pt p);
475 val ((ist, ctxt), sc) = LItool.resume_prog (p,p_) pt;
477 val Next_Step (_, _, Rewrite_Set' ("Poly", _, Rule_Set.Sequence {id = "norm_Poly", ...}, _, _)) =
478 LI.find_next_step sc (pt, pos) ist ctxt (*of*);
479 "~~~~~ fun find_next_step , args:"; val ((Rule.Prog prog), (ptp as(pt, (p, _))), (Pstate ist), ctxt)
480 = (sc, (pt, pos), ist, ctxt);
482 val Accept_Tac (Rewrite_Set' ("Poly", _, Rule_Set.Sequence {id = "norm_Poly", ...}, _, _), _, _) =
483 (*case*) scan_to_tactic (prog, (ptp, ctxt)) (Pstate ist) (*of*);
484 "~~~~~ fun scan_to_tactic , args:"; val ((prog, cc), (Pstate (ist as {path, ...})))
485 = ((prog, (ptp, ctxt)), (Pstate ist));
486 (*if*) path = [] (*then*);
488 val Accept_Tac (Rewrite_Set' ("Poly", _, Rule_Set.Sequence {id = "norm_Poly", ...}, _, _), _, _) =
489 scan_dn cc (trans_scan_dn ist) (Program.body_of prog);
490 "~~~~~ fun scan_dn , args:"; val ((cc as (_, ctxt)), (ist as {eval, ...}), t)
491 = (cc, (trans_scan_dn ist), (Program.body_of prog));
492 (*if*) Tactical.contained_in t (*else*);
493 val (Program.Tac prog_tac, form_arg) = (*case*) LItool.check_leaf "next " ctxt eval (get_subst ist) t (*of*);
495 val Accept_Tac (Rewrite_Set' ("Poly", _, Rule_Set.Sequence {id = "norm_Poly", ...}, _, _), _, _) =
496 check_tac cc ist (prog_tac, form_arg) (*return from xxx*);
497 "~~~~~ from fun scan_dn\<longrightarrow>fun scan_to_tactic\<longrightarrow>fun find_next_step, return:"; val (Accept_Tac (tac, ist, ctxt))
498 = (check_tac cc ist (prog_tac, form_arg));
500 Next_Step (Pstate ist, Tactic.insert_assumptions tac ctxt, tac) (*return from find_next_step*);
501 "~~~~~ from fun find_next_step\<longrightarrow>and do_next\<longrightarrow>fun zzz, return:"; val (Next_Step (ist, ctxt, tac))
502 = (Next_Step (Pstate ist, Tactic.insert_assumptions tac ctxt, tac));
504 LI.by_tactic tac (ist, Tactic.insert_assumptions tac ctxt) ptp (*return from and do_next*);
505 "~~~~~ from and do_next\<longrightarrow>fun do_next\<longrightarrow>toplevel, return:"; val (_, ([(tac''''', _, _)], _, (pt''''', p''''')))
506 = (LI.by_tactic tac (ist, Tactic.insert_assumptions tac ctxt) ptp);
507 (*\\------------------ end of go into 1 -----------------------------------------------------//*)
509 (*[], Res*)val (_, ([(tac''''', _, _)], _, (pt''''', p'''''))) =
511 Step.do_next p'''''_' ((pt'''''_', Pos.e_pos'), []);(* Check_Postcond ["polynomial", "simplification"]*)
512 (*//------------------ go into 2 ------------------------------------------------------------\\*)
513 "~~~~~ fun do_next , args:"; val ((ip as (_, p_)), (ptp as (pt, p), tacis))
514 = (p''''', ((pt''''', e_pos'), []));
515 val pIopt = Ctree.get_pblID (pt, ip);
516 (*if*) ip = ([], Res) (*else*);
517 val _ = (*case*) tacis (*of*);
518 val SOME _ = (*case*) pIopt (*of*);
519 (*if*) member op = [Pos.Pbl, Pos.Met] p_ (*else*);
521 val ("ok", ([(Check_Postcond ["polynomial", "simplification"], _, _)], _, (_, ([], Res)))) =
522 Step_Solve.do_next (pt, ip);
523 "~~~~~ and do_next , args:"; val (ptp as (pt, pos as (p, p_))) = (pt, ip);
524 (*if*) MethodC.id_empty = get_obj g_metID pt (par_pblobj pt p) (*else*);
525 val thy' = get_obj g_domID pt (par_pblobj pt p);
526 val ((ist, ctxt), sc) = LItool.resume_prog (p,p_) pt;
528 (** )val End_Program (ist, tac) =
529 ( *case*) LI.find_next_step sc (pt, pos) ist ctxt (*of*);
530 "~~~~~ fun find_next_step , args:"; val ((Rule.Prog prog), (ptp as(pt, (p, _))), (Pstate ist), ctxt)
531 = (sc, (pt, pos), ist, ctxt);
533 (* val Term_Val (Const (\<^const_name>\<open>times\<close>, _) $ Free ("2", _) $ Free ("a", _))*)
534 (**)val Term_Val prog_result =
535 (*case*) scan_to_tactic (prog, (ptp, ctxt)) (Pstate ist) (*of*);
536 "~~~~~ fun scan_to_tactic , args:"; val ((prog, cc), (Pstate (ist as {path, ...})))
537 = ((prog, (ptp, ctxt)), (Pstate ist));
538 (*if*) path = [] (*else*);
540 go_scan_up (prog, cc) (trans_scan_up ist |> set_found);
541 "~~~~~ fun go_scan_up , args:"; val ((pcc as (sc, _)), (ist as {path, act_arg, found_accept, ...}))
542 = ((prog, cc), (trans_scan_up ist(*|> set_found !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! *)));
543 (*if*) path = [R] (*then*);
544 (*if*) found_accept = true (*then*);
546 Term_Val act_arg (*return from go_scan_up*);
547 "~~~~~ from fun go_scan_up\<longrightarrow>fun scan_to_tactic, return:"; val (Term_Val prog_result) = (Term_Val act_arg);
549 Term_Val prog_result (*return from scan_to_tactic*);
550 "~~~~~ from fun scan_to_tactic\<longrightarrow>fun find_next_step, return:"; val (Term_Val prog_result) = (Term_Val prog_result);
551 val (true, p' as [], Rule_Set.Empty, _) = (*case*) parent_node pt pos (*of*);
552 val (_, pblID, _) = get_obj g_spec pt p';
554 End_Program (Pstate ist, Tactic.Check_Postcond' (pblID, prog_result))
555 (*return from find_next_step*);
556 "~~~~~ from fun find_next_step\<longrightarrow>and do_next\<longrightarrow>fun zzz, return:"; val (End_Program (ist, tac))
557 = (End_Program (Pstate ist, Tactic.Check_Postcond' (pblID,prog_result)));
558 val _ = (*case*) tac (*of*);
560 val ("ok", ([(Check_Postcond ["polynomial", "simplification"], _, _)], _, (_, ([], Res))))
561 = LI.by_tactic tac (ist, ctxt) ptp (*return from and do_next*);
562 "~~~~~ from and do_next\<longrightarrow>top level, return:"; val (_, ([(tac''''', _, _)], _, (pt''''', p''''')))
563 = (LI.by_tactic tac (ist, ctxt) ptp);
564 (*\\------------------ end of go into 2 -----------------------------------------------------//*)
566 (*[], Und*)val (msg, ([], _, (pt, p))) = Step.do_next p''''' ((pt''''', Pos.e_pos'), []);(**)
568 Test_Tool.show_pt_tac pt; (*[
569 ([], Frm), Simplify (a + a)
570 . . . . . . . . . . Apply_Method ["simplification", "for_polynomials"],
572 . . . . . . . . . . Rewrite_Set "norm_Poly",
574 . . . . . . . . . . Check_Postcond ["polynomial", "simplification"],
577 (*/--- final test ---------------------------------------------------------------------------\\*)
578 val (res, asm) = (get_obj g_result pt (fst p));
579 if UnparseC.term res = "2 * a" andalso map UnparseC.term asm = []
580 andalso p = ([], Und) andalso msg = "end-of-calculation"
581 andalso pr_ctree pr_short pt = ". ----- pblobj -----\n1. a + a\n"
583 case tac''''' of Check_Postcond ["polynomial", "simplification"] => ()
584 | _ => error "re-build: fun find_next_step, mini 1"
585 else error "re-build: fun find_next_step, mini 2"
588 "----------- re-build: fun locate_input_term ---------------------------------------------------";
589 "----------- re-build: fun locate_input_term ---------------------------------------------------";
590 "----------- re-build: fun locate_input_term ---------------------------------------------------";
592 ----------- appendFormula: on Res + late deriv ------------------------------------------------*)
593 val fmz = ["equality (x+1=(2::real))", "solveFor x", "solutions L"];
594 val (dI',pI',mI') = ("Test", ["sqroot-test", "univariate", "equation", "test"],
595 ["Test", "squ-equ-test-subpbl1"]);
596 val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
597 val (p,_,f,nxt,_,pt) = me nxt p [] pt;
598 val (p,_,f,nxt,_,pt) = me nxt p [] pt;
599 val (p,_,f,nxt,_,pt) = me nxt p [] pt;
600 val (p,_,f,nxt,_,pt) = me nxt p [] pt;
601 val (p,_,f,nxt,_,pt) = me nxt p [] pt;
602 val (p,_,f,nxt,_,pt) = me nxt p [] pt;
603 (*[], Met*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*Apply_Method ["Test", "squ-equ-test-subpbl1"]*);
605 (*[1], Frm*)val (p,_,f,nxt,_,pt) = me nxt p [] pt;(*Rewrite_Set "norm_equation"*)
606 (*+*)if f2str f = "x + 1 = 2" then () else error "locate_input_term at ([1], Frm) CHANGED";
608 (*[1], Res*)val (p,_,f,nxt,_,pt) = me nxt p [] pt;(*Rewrite_Set "Test_simplify"*)
609 (*+*)if f2str f = "x + 1 + - 1 * 2 = 0" then () else error "locate_input_term at ([1], Frm) CHANGED";
611 Test_Tool.show_pt_tac pt; (*[
612 ([], Frm), solve (x + 1 = 2, x)
613 . . . . . . . . . . Apply_Method ["Test", "squ-equ-test-subpbl1"],
614 ([1], Frm), x + 1 = 2
615 . . . . . . . . . . Rewrite_Set "norm_equation",
616 ([1], Res), x + 1 + - 1 * 2 = 0 ///Check_Postcond..ERROR*)
618 (*//---------- appendFormula 1 "x = 1" \<longrightarrow> Step_Solve.inform \<longrightarrow> LI.locate_input_term ----------\\*)
619 "~~~~~ fun appendFormula , args:"; val ((*cI, *) ifo: TermC.as_string) = ((**) "x = 1");
620 val cs = (*States.get_calc cI*) ((pt, p), [(*nxt, nxt_, (pos, (ist, ctxt))*)])
621 val pos = (*States.get_pos cI 1*) p
623 (*+*)val ptp''''' = (pt, p);
624 (*+*)if snd ptp''''' = ([1], Res) then () else error "old_cs changed";
625 (*+*)Test_Tool.show_pt_tac pt; (*[
626 (*+*)([], Frm), solve (x + 1 = 2, x)
627 (*+*). . . . . . . . . . Apply_Method ["Test", "squ-equ-test-subpbl1"],
628 (*+*)([1], Frm), x + 1 = 2
629 (*+*). . . . . . . . . . Rewrite_Set "norm_equation",
630 (*+*)([1], Res), x + 1 + - 1 * 2 = 0 ///Check_Postcond*)
632 val ("ok", cs' as (_, _, ptp')) =
633 (*case*) Step.do_next pos cs (*of*);
635 val ("ok", (_(*use in DG !!!*), [], ptp''''' as (pt''''', p'''''))) = (*case*)
636 Step_Solve.by_term ptp' (encode ifo) (*of*);
637 "~~~~~ fun Step_Solve.by_term , args:"; val ((pt, pos as (p, _)), istr)
638 = (ptp', (encode ifo));
640 (*case*) TermC.parseNEW (get_ctxt pt pos) istr (*of*);
641 val pos_pred = lev_back(*'*) pos
642 val f_pred = Ctree.get_curr_formula (pt, pos_pred);
643 val f_succ = Ctree.get_curr_formula (pt, pos);
644 (*if*) f_succ = f_in (*else*);
646 (*case*) CAS_Cmd.input f_in (*of*);
648 (*NEW*) LI.locate_input_term (pt, pos) f_in (*of*);
649 "~~~~~ fun locate_input_term , args:"; val ((pt, pos), tm) = ((pt, pos), f_in);
650 val pos_pred = Pos.lev_back' pos (*f_pred ---"step pos cs"---> f_succ in appendFormula*)
652 val ("ok", (_, _, cstate as (pt', pos'))) =
653 (*case*) compare_step ([], [], (pt, pos_pred)) tm (*of*);
656 Found_Step (cstate, get_istate_LI pt' pos', get_ctxt pt' pos') (*return from locate_input_term*);
658 (*NEW*) Found_Step cstate (*return from locate_input_term*);
659 (*LI.Found_Step ( *)cstate(*, _(*istate*), _)( *return from locate_input_term*);
660 "~~~~~ from fun locate_input_term\<longrightarrow>fun Step_Solve.by_term, return:"; val ("ok", (_(*use in DG !!!*), c, ptp as (_, p)))
661 = (("ok" , ([], [], cstate (* already contains istate, ctxt *))));
663 ("ok", ((*_ use in DG !!!,*) c, ptp(* as (_*), p))(*)*)(*return from Step_Solve.by_term*);
664 "~~~~~ from fun Step_Solve.by_term\<longrightarrow>(fun appendFormula)!toplevel, return:"; val ("ok", (_(*use in DG !!!*), [], ptp''''' as (pt''''', p''''')))
665 = ("ok", ([], [], ptp));
667 (*fun me requires nxt...*)
668 Step.do_next p''''' (ptp''''', []);
669 val ("ok", ([(nxt'''''_' as Check_Postcond ["LINEAR", "univariate", "equation", "test"], _, _)], _,
670 (pt'''''_', p'''''_'))) = Step.do_next p''''' (ptp''''', [])
671 (*\\---------- appendFormula 1 "x = 1" \<longrightarrow> Step_Solve.inform \<longrightarrow> LI.locate_input_term ----------//*)
673 (*//----- REPLACED BY appendFormula 1 "x = 1" \<longrightarrow> Step_Solve.inform \<longrightarrow> LI.locate_input_term -----\\* )
674 (*[2], Res*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Subproblem ("Test", ["LINEAR", "univariate", "equation", "test"])*)
675 (*[3], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Model_Problem*)
676 (*[3], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Add_Given "equality (- 1 + x = 0)"*)
677 (*[3], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Add_Given "solveFor x"*)
678 (*[3], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Add_Find "solutions x_i"*)
679 (*[3], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Specify_Theory "Test"*)
680 (*[3], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Specify_Problem ["LINEAR", "univariate", "equation", "test"]*)
681 (*[3], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Specify_Method ["Test", "solve_linear"]*)
682 (*[3], Met*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Apply_Method ["Test", "solve_linear"]*)
683 (*[3, 1], Frm*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Rewrite_Set_Inst (["(''bdv'', x)"], "isolate_bdv")*)
684 (*[3, 1], Res*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Rewrite_Set "Test_simplify"*)
685 (*[3, 2], Res*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Check_Postcond ["LINEAR", "univariate", "equation", "test"]*)
686 ( *\\----- REPLACED BY appendFormula 1 "x = 1" \<longrightarrow> Step_Solve.inform \<longrightarrow> LI.locate_input_term -----//*)
688 (*[3], Res*)val (p,_,f,nxt,_,pt) = me nxt'''''_' p'''''_' [] pt'''''_'; (*nxt = Check_elementwise "Assumptions"*)
689 (*[4], Res*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Check_Postcond ["sqroot-test", "univariate", "equation", "test"]*)
690 (*[], Res*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = End_Proof'*)
692 (*/--- final test ---------------------------------------------------------------------------\\*)
693 if p = ([], Res) andalso f2str f = "[x = 1]" andalso pr_ctree pr_short pt =
694 ". ----- pblobj -----\n" ^
696 "2. x + 1 + - 1 * 2 = 0\n" ^
697 "3. ----- pblobj -----\n" ^
698 "3.1. - 1 + x = 0\n" ^
699 "3.2. x = 0 + - 1 * - 1\n" ^
700 "3.2.1. x = 0 + - 1 * - 1\n" ^
701 "3.2.2. x = 0 + 1\n" (*ATTENTION: see complete Calc below*)
702 then case nxt of End_Proof' => () | _ => error "re-build: fun locate_input_term CHANGED 1"
703 else error "re-build: fun locate_input_term CHANGED 2";
705 Test_Tool.show_pt_tac pt; (*[
706 ([], Frm), solve (x + 1 = 2, x)
707 . . . . . . . . . . Apply_Method ["Test", "squ-equ-test-subpbl1"],
708 ([1], Frm), x + 1 = 2
709 . . . . . . . . . . Rewrite_Set "norm_equation",
710 ([1], Res), x + 1 + - 1 * 2 = 0
711 . . . . . . . . . . Rewrite_Set "Test_simplify",
712 ([2], Res), - 1 + x = 0
713 . . . . . . . . . . Subproblem (Test, ["LINEAR", "univariate", "equation", "test"]),
714 ([3], Pbl), solve (- 1 + x = 0, x)
715 . . . . . . . . . . Apply_Method ["Test", "solve_linear"],
716 ([3,1], Frm), - 1 + x = 0
717 . . . . . . . . . . Rewrite_Set_Inst ([(''bdv'', x)], "isolate_bdv"),
718 ([3,1], Res), x = 0 + - 1 * - 1
719 . . . . . . . . . . Derive Test_simplify,
720 ([3,2,1], Frm), x = 0 + - 1 * - 1
721 . . . . . . . . . . Rewrite ("#: - 1 * - 1 = 1", "- 1 * - 1 = 1"),
722 ([3,2,1], Res), x = 0 + 1
723 . . . . . . . . . . Rewrite ("radd_0", "0 + ?k = ?k"),
724 ([3,2,2], Res), x = 1
725 . . . . . . . . . . Tactic.input_to_string not impl. for ?!,
727 . . . . . . . . . . Check_Postcond ["LINEAR", "univariate", "equation", "test"],
729 . . . . . . . . . . Check_Postcond ["sqroot-test", "univariate", "equation", "test"],
730 ([], Res), [x = 1]]*)