walther@59808
|
1 |
(*//------------------ begin step into ------------------------------------------------------\\*)
|
walther@59808
|
2 |
(*\\------------------ end step into --------------------------------------------------------//*)
|
wneuper@59546
|
3 |
(* Title: "Minisubpbl/300-init-subpbl.sml"
|
neuper@41985
|
4 |
Author: Walther Neuper 1105
|
neuper@41985
|
5 |
(c) copyright due to lincense terms.
|
neuper@41985
|
6 |
*)
|
neuper@41985
|
7 |
|
wneuper@59569
|
8 |
"----------- Minisubpbl/300-init-subpbl.sml ----------------------";
|
wneuper@59569
|
9 |
"----------- Minisubpbl/300-init-subpbl.sml ----------------------";
|
wneuper@59569
|
10 |
"----------- Minisubpbl/300-init-subpbl.sml ----------------------";
|
walther@59997
|
11 |
val fmz = ["equality (x+1=(2::real))", "solveFor x", "solutions L"];
|
neuper@41985
|
12 |
val (dI',pI',mI') =
|
walther@59997
|
13 |
("Test", ["sqroot-test", "univariate", "equation", "test"],
|
walther@59997
|
14 |
["Test", "squ-equ-test-subpbl1"]);
|
walther@59808
|
15 |
(*[], Pbl*)val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
|
walther@59808
|
16 |
(*[], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p [] pt;
|
walther@59808
|
17 |
(*[], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p [] pt;
|
walther@59808
|
18 |
(*[], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p [] pt;
|
walther@59808
|
19 |
(*[], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p [] pt;
|
walther@59808
|
20 |
(*[], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p [] pt;
|
walther@59808
|
21 |
(*[], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p [] pt;
|
wneuper@59582
|
22 |
(*[], Met*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Apply_Method ["Test", "squ-equ-test-subpbl1"]*)
|
wneuper@59582
|
23 |
(*[1], Frm*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Rewrite_Set "norm_equation"*)
|
wneuper@59582
|
24 |
(*[1], Res*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Rewrite_Set "Test_simplify" *)
|
wneuper@59582
|
25 |
(*[2], Res*)val (p''',_,f,nxt''',_,pt''') = me nxt p [] pt; (*nxt = ("Subproblem"*)
|
wneuper@59582
|
26 |
(*//--1 begin step into relevant call -----------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-----\\
|
wneuper@59582
|
27 |
1 relevant for updating ctxt *)
|
walther@59749
|
28 |
"~~~~~ fun me , args:"; val (tac, p, _(*NEW remove*), pt) = (nxt''', p''', [], pt''');
|
wneuper@59582
|
29 |
|
walther@59808
|
30 |
val ("ok", (_, _, (pt'''', p''''))) = (*case*)
|
walther@59808
|
31 |
Step.by_tactic tac (pt, p) (*of*);
|
walther@59846
|
32 |
get_ctxt pt'''' p'''' |> ContextC.is_empty; (*should NOT be true after this step*)
|
walther@59808
|
33 |
"~~~~~ fun by_tactic , args:"; val (tac, ptp as (pt, p)) = (tac, (pt''',p'''));
|
walther@59921
|
34 |
val Applicable.Yes m = Step.check tac (pt, p);
|
walther@59755
|
35 |
(*if*) Tactic.for_specify' m; (*false*)
|
walther@59808
|
36 |
|
walther@59751
|
37 |
(*val (msg, cs') =*)
|
walther@59808
|
38 |
Step_Solve.by_tactic m (pt, p);
|
walther@59808
|
39 |
"~~~~~ fun by_tactic , args:"; val (m, (pt, po as (p,p_))) = (m, (pt, p));
|
walther@59903
|
40 |
(*if*) Method.id_empty = get_obj g_metID pt (par_pblobj pt p) (*false*);
|
neuper@42092
|
41 |
val thy' = get_obj g_domID pt (par_pblobj pt p);
|
walther@59831
|
42 |
val (is, sc) = resume_prog thy' (p,p_) pt;
|
wneuper@59569
|
43 |
|
walther@59808
|
44 |
val Safe_Step (Pstate ist''''', ctxt''''', tac'_''''') =
|
walther@59808
|
45 |
locate_input_tactic sc (pt, po) (fst is) (snd is) m;
|
walther@59808
|
46 |
"~~~~~ fun locate_input_tactic , args:"; val (Rule.Prog prog, cstate, istate, ctxt, tac)
|
wneuper@59569
|
47 |
= (sc, (pt, po), (fst is), (snd is), m);
|
wneuper@59569
|
48 |
|
walther@59718
|
49 |
val Accept_Tac1 (_, _, Subproblem' (_, _, _, _, _, _)) = (*case*)
|
walther@59692
|
50 |
scan_to_tactic1 (prog, (cstate, ctxt, tac)) istate (*of*);
|
walther@59808
|
51 |
"~~~~~ fun scan_to_tactic1 , args:"; val ((prog, (cctt as ((_, p), _, _))), (Pstate (ist as {path, ...})))
|
walther@59808
|
52 |
= ((prog, (cstate, ctxt, tac)), istate);
|
walther@59686
|
53 |
(*if*) path = [] orelse ((last_elem o fst) p = 0 andalso snd p = Res) (*else*);
|
wneuper@59582
|
54 |
|
walther@59808
|
55 |
go_scan_up1 (prog, cctt) ist;
|
walther@59808
|
56 |
"~~~~~ fun go_scan_up1 , args:"; val ((pcct as (prog, _)), (ist as {path, act_arg, ...}))
|
walther@59692
|
57 |
= ((prog, cctt), ist);
|
walther@59686
|
58 |
(*if*) 1 < length path (*true*);
|
neuper@42092
|
59 |
|
walther@60023
|
60 |
scan_up1 pcct (ist |> path_up) (TermC.sub_at (path_up' path) prog);
|
walther@59808
|
61 |
"~~~~~ and scan_up1 , args:"; val (pcct, ist, (Const ("Tactical.Try"(*2*), _) $ _))
|
walther@60023
|
62 |
= (pcct, (ist |> path_up), (TermC.sub_at (path_up' path) prog));
|
neuper@41986
|
63 |
|
walther@59808
|
64 |
go_scan_up1 pcct ist;
|
walther@59808
|
65 |
"~~~~~ fun go_scan_up1 , args:"; val ((pcct as (prog, _)), (ist as {path, ...}))
|
walther@59808
|
66 |
= (pcct, ist);
|
walther@59686
|
67 |
(*if*) 1 < length path (*true*);
|
wneuper@59582
|
68 |
|
walther@60023
|
69 |
scan_up1 pcct (ist |> path_up) (TermC.sub_at (path_up' path) prog);
|
walther@59808
|
70 |
"~~~~~ and scan_up1 , args:"; val (pcct, ist, (Const ("Tactical.Chain"(*2*), _) $ _ $ _))
|
walther@60023
|
71 |
= (pcct, (ist |> path_up), (TermC.sub_at (path_up' path) prog));
|
wneuper@59582
|
72 |
|
walther@59808
|
73 |
go_scan_up1 pcct ist (*2*: comes from e2*);
|
walther@59808
|
74 |
"~~~~~ fun go_scan_up1, args:"; val ((pcct as (prog, _)), (ist as {path, ...}))
|
walther@59808
|
75 |
= (pcct, ist);
|
walther@59686
|
76 |
(*if*) 1 < length path (*true*);
|
wneuper@59582
|
77 |
|
walther@60023
|
78 |
scan_up1 pcct (ist |> path_up) (TermC.sub_at (path_up' path) prog);
|
walther@59808
|
79 |
"~~~~~ and scan_up1 , args:"; val (pcct, ist, (Const ("Tactical.Chain"(*1*), _) $ _ $ _ $ _))
|
walther@60023
|
80 |
= (pcct, (ist |> path_up), (TermC.sub_at (path_up' path) prog));
|
wneuper@59582
|
81 |
|
walther@59808
|
82 |
go_scan_up1 pcct ist (*all has been done in (*2*) below*);
|
walther@59808
|
83 |
"~~~~~ fun go_scan_up1, args:"; val ((pcct as (prog, _)), (ist as {path, ...}))
|
walther@59808
|
84 |
= (pcct, ist);
|
walther@59686
|
85 |
(*if*) 1 < length path (*true*);
|
wneuper@59582
|
86 |
|
walther@60023
|
87 |
scan_up1 pcct (ist |> path_up) (TermC.sub_at (path_up' path) prog);
|
walther@59808
|
88 |
"~~~~~ and scan_up1 , args:"; val ((pcct as (prog, cct as (cstate, _, _))), ist, (Const ("HOL.Let"(*1*), _) $ _))
|
walther@60023
|
89 |
= (pcct, (ist |> path_up), (TermC.sub_at (path_up' path) prog));
|
walther@59808
|
90 |
val (i, body) = check_Let_up ist prog;
|
walther@59686
|
91 |
|
walther@59808
|
92 |
(*case*) scan_dn1 cct (ist |> path_up_down [R, D] |> upd_env i |> set_or ORundef) body (*of*);
|
walther@59808
|
93 |
"~~~~~ fun scan_dn1 , args:"; val (cct, ist, (Const ("HOL.Let", _) $ e $ (Abs (id, T, b))))
|
walther@59808
|
94 |
= (cct, (ist |> path_up_down [R, D] |> upd_env i |> set_or ORundef), body);
|
walther@59808
|
95 |
|
walther@59808
|
96 |
(*case*) scan_dn1 cct (ist |> path_down [L, R]) e (*of*);
|
walther@59657
|
97 |
(*======= end of scanning tacticals, a leaf =======*)
|
walther@59722
|
98 |
"~~~~~ fun scan_dn1 , args:"; val (((pt, p), ctxt, tac), (ist as {eval, or, ...}), t)
|
walther@59808
|
99 |
= (cct, (ist |> path_down [L, R]), e);
|
wneuper@59582
|
100 |
|
walther@59721
|
101 |
val (Program.Tac _, NONE) = (*case*)
|
walther@59772
|
102 |
check_leaf "locate" ctxt eval (get_subst ist) t (*of*);
|
walther@59772
|
103 |
"~~~~~ fun check_leaf , args:"; val (call, thy, srls, (E, (a, v)), t)
|
walther@59722
|
104 |
= ("locate", ctxt, eval, (get_subst ist), t);
|
wneuper@59582
|
105 |
|
walther@59729
|
106 |
val (Program.Tac stac, a) = (*case*) Prog_Tac.eval_leaf E a v t (*of*);
|
walther@59718
|
107 |
"~~~~~ fun eval_leaf , args:"; val (E, _, _, (t as (Const ("Prog_Tac.SubProblem", _) $ _ $ _)))
|
wneuper@59582
|
108 |
= (E, a, v, t);
|
wneuper@59582
|
109 |
|
walther@59722
|
110 |
(Program.Tac (subst_atomic E t), NONE); (*return value*)
|
walther@59808
|
111 |
"~~~~~ from fun eval_leaf \<longrightarrow> fun check_leaf return val:"; val ((Program.Tac stac, a'))
|
walther@59722
|
112 |
= ((Program.Tac (subst_atomic E t), NONE : term option));
|
wneuper@59582
|
113 |
val stac' =
|
walther@59722
|
114 |
Rewrite.eval_prog_expr (Proof_Context.theory_of ctxt) srls
|
walther@59722
|
115 |
(subst_atomic (Env.update_opt E (a,v)) stac);
|
wneuper@59582
|
116 |
|
walther@59808
|
117 |
(Program.Tac stac', a'); (*return from check_leaf*)
|
walther@59808
|
118 |
"~~~~~ from fun check_leaf \<longrightarrow> fun scan_dn1 return val:"; val (Program.Tac prog_tac, form_arg)
|
walther@59808
|
119 |
= (Program.Tac stac', a' : term option);
|
wneuper@59582
|
120 |
|
walther@59808
|
121 |
(Program.Tac prog_tac, form_arg) (*return from check_leaf*);
|
walther@59808
|
122 |
|
walther@59808
|
123 |
check_tac1 cct ist (prog_tac, form_arg) (*return from scan_dn1*);
|
walther@59808
|
124 |
"~~~~~ from fun scan_dn1\<longrightarrow>fun scan_up1 HOL.Let(*1*), return:"; val (Accept_Tac1 iss)
|
walther@59808
|
125 |
= (check_tac1 cct ist (prog_tac, form_arg));
|
walther@59808
|
126 |
|
walther@59808
|
127 |
(*+*)val (pstate, ctxt, tac) = iss;
|
walther@59846
|
128 |
(*+*)if ContextC.is_empty ctxt then error "ERROR: scan_dn1 should NOT return ContextC.empty" else ();
|
walther@59808
|
129 |
"~~~~~ from fun scan_up1 HOL.Let(*1*), --------------------------------- NO return:"; val () = ();
|
walther@59808
|
130 |
|
walther@59846
|
131 |
(*+*)if ContextC.is_empty ctxt''''' then error "locate_input_tactic should NOT return ContextC.empty" else ();
|
walther@59808
|
132 |
|
walther@59808
|
133 |
"~~~~~ from fun locate_input_tactic \<longrightarrow>Step_Solve.by_tactic , return:"; val (LI.Safe_Step (istate, ctxt, tac))
|
walther@59808
|
134 |
= (Safe_Step (Pstate ist''''', ctxt''''', tac'_'''''));
|
walther@59808
|
135 |
val p' = next_in_prog po
|
walther@59808
|
136 |
val (p'', _, _,pt') =
|
walther@59808
|
137 |
|
walther@59932
|
138 |
Step.add tac (istate, ctxt) (pt, (p', p_));
|
walther@59932
|
139 |
"~~~~~ fun add , args:"; val (thy, (Tactic.Subproblem' ((domID, pblID, metID), oris, hdl, fmz_, ctxt_specify, f)),
|
walther@59808
|
140 |
(l as (_, ctxt)), (pos as (p, p_)), pt)
|
walther@59881
|
141 |
= ((ThyC.get_theory "Isac_Knowledge"), tac, (istate, ctxt), (p', p_), pt);
|
walther@59819
|
142 |
val (pt, c) = cappend_problem pt p l (fmz_, (domID, pblID, metID))
|
walther@59819
|
143 |
(oris, (domID, pblID, metID), hdl, ctxt_specify);
|
walther@59808
|
144 |
|
walther@59932
|
145 |
(*+*)if ContextC.is_empty ctxt_specify then error "ERROR: Step.add should NOT get input ContextC.empty" else ();
|
walther@59932
|
146 |
(*+*)if (get_ctxt pt pos |> ContextC.is_empty) then error "Step.add MUST store ctxt"
|
walther@59808
|
147 |
(*+*)else ();
|
wneuper@59582
|
148 |
(*\\--1 end step into relevant call ----------------------------------------------------------//*)
|
wneuper@59582
|
149 |
|
walther@59808
|
150 |
(*[3], Pbl*)val (p,_,f,nxt,_,pt) = me nxt''' p''' [1] pt''';(*nxt = Model_Problem*)
|
wneuper@59582
|
151 |
|
walther@59846
|
152 |
if p = ([3], Pbl) andalso not (get_ctxt pt p |> ContextC.is_empty)
|
wneuper@59582
|
153 |
then
|
walther@59749
|
154 |
case nxt of (Model_Problem) => ()
|
wneuper@59582
|
155 |
| _ => error "minisubpbl: CalcTreeTEST has no nxt = Model_Problem"
|
wneuper@59582
|
156 |
else error "Minisubpbl/300-init-subpbl.sml changed";
|