wneuper@59578
|
1 |
(* Title: "Minisubplb/400-start-meth-subpbl.sml"
|
neuper@41985
|
2 |
Author: Walther Neuper 1105
|
neuper@41985
|
3 |
(c) copyright due to lincense terms.
|
Walther@60706
|
4 |
|
Walther@60706
|
5 |
ATTENTION: THE FILE IS TOO BIG FOR Java BUFFERS, so copy in pieces.
|
neuper@41985
|
6 |
*)
|
Walther@60706
|
7 |
open Test_Code
|
Walther@60706
|
8 |
open Pos;
|
Walther@60706
|
9 |
open Ctree;
|
Walther@60706
|
10 |
open Istate;
|
Walther@60706
|
11 |
open TermC;
|
Walther@60706
|
12 |
open Step;
|
Walther@60706
|
13 |
open LI;
|
Walther@60706
|
14 |
open Tactic;
|
Walther@60706
|
15 |
open Refine;
|
Walther@60706
|
16 |
open Specify;
|
neuper@41985
|
17 |
|
wneuper@59578
|
18 |
"----------- Minisubpbl/400-start-meth-subpbl.sml ----------------";
|
wneuper@59578
|
19 |
"----------- Minisubpbl/400-start-meth-subpbl.sml ----------------";
|
wneuper@59578
|
20 |
"----------- Minisubpbl/400-start-meth-subpbl.sml ----------------";
|
walther@59997
|
21 |
val fmz = ["equality (x+1=(2::real))", "solveFor x", "solutions L"];
|
neuper@41985
|
22 |
val (dI',pI',mI') =
|
walther@59997
|
23 |
("Test", ["sqroot-test", "univariate", "equation", "test"],
|
walther@59997
|
24 |
["Test", "squ-equ-test-subpbl1"]);
|
Walther@60571
|
25 |
val (p,_,f,nxt,_,pt) = Test_Code.init_calc @{context} [(fmz, (dI',pI',mI'))];
|
neuper@41985
|
26 |
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
|
neuper@41990
|
27 |
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
|
neuper@41990
|
28 |
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
|
neuper@41990
|
29 |
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
|
neuper@41990
|
30 |
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
|
neuper@41990
|
31 |
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
|
Walther@60725
|
32 |
val (p,_,f,nxt,_,pt) = me nxt p [] pt; val Apply_Method ["Test", "squ-equ-test-subpbl1"] = nxt;
|
neuper@41990
|
33 |
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
|
neuper@41990
|
34 |
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
|
Walther@60725
|
35 |
val (p,_,f,nxt,_,pt) = me nxt p [] pt; val Subproblem ("Test", ["LINEAR", "univariate", "equation", "test"]) = nxt;
|
neuper@41990
|
36 |
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
|
neuper@41990
|
37 |
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
|
neuper@41990
|
38 |
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
|
Walther@60706
|
39 |
val (p,_,f,nxt,_,pt) = me nxt p [] pt; val Add_Find "solutions x_i" = nxt;
|
Walther@60611
|
40 |
|
Walther@60706
|
41 |
val return_Add_Find = me nxt p [] pt;
|
Walther@60706
|
42 |
(*/------------------- step into me Add_Find ------------------------------------------------\*)
|
Walther@60706
|
43 |
"~~~~~ fun me , args:"; val (tac, p, _(*NEW remove*), pt) = (nxt, p, [], pt);
|
Walther@60706
|
44 |
val ctxt = Ctree.get_ctxt pt p
|
Walther@60706
|
45 |
val ("ok", (_, _, ptp as (pt, p))) =
|
Walther@60706
|
46 |
(*case*) Step.by_tactic tac (pt, p) (*of*);
|
Walther@60706
|
47 |
|
Walther@60706
|
48 |
(*case*)
|
Walther@60706
|
49 |
Step.do_next p ((pt, Pos.e_pos'), []) (*of*);
|
Walther@60706
|
50 |
"~~~~~ fun do_next , args:"; val ((ip as (_, p_)), (ptp as (pt, p), tacis)) =
|
Walther@60706
|
51 |
(p, ((pt, Pos.e_pos'), []));
|
Walther@60706
|
52 |
(*if*) Pos.on_calc_end ip (*else*);
|
Walther@60706
|
53 |
val (_, probl_id, _) = Calc.references (pt, p);
|
Walther@60706
|
54 |
val _ =
|
Walther@60706
|
55 |
(*case*) tacis (*of*);
|
Walther@60706
|
56 |
(*if*) probl_id = Problem.id_empty (*else*);
|
Walther@60706
|
57 |
|
Walther@60706
|
58 |
switch_specify_solve p_ (pt, ip);
|
Walther@60706
|
59 |
"~~~~~ fun switch_specify_solve , args:"; val (state_pos, (pt, input_pos)) = (p_, (pt, ip));
|
Walther@60706
|
60 |
(*if*) Pos.on_specification ([], state_pos) (*then*);
|
Walther@60706
|
61 |
|
Walther@60706
|
62 |
specify_do_next (pt, input_pos);
|
Walther@60706
|
63 |
"~~~~~ fun specify_do_next , args:"; val (ptp as (pt, (p, p_))) = (pt, input_pos);
|
Walther@60706
|
64 |
|
Walther@60706
|
65 |
val (_, (p_', tac)) =
|
Walther@60706
|
66 |
Specify.find_next_step ptp;
|
Walther@60706
|
67 |
"~~~~~ fun find_next_step , args:"; val (pt, pos as (_, p_)) = (ptp);
|
Walther@60706
|
68 |
|
Walther@60706
|
69 |
(*+isa* )val Refine_Problem ["LINEAR", "univariate", "equation", "test"] = tac;( **)
|
Walther@60706
|
70 |
(*+isa2*)val Specify_Theory "Test" = tac;(**)
|
Walther@60706
|
71 |
|
Walther@60706
|
72 |
val {meth = met, origin = origin as (oris, o_refs as (_, pI', mI'), _), probl = pbl,
|
Walther@60706
|
73 |
spec = refs, ...} = Calc.specify_data (pt, pos); (*I_Model.T------------------^^^*)
|
Walther@60706
|
74 |
val ctxt = Ctree.get_ctxt pt pos;
|
Walther@60706
|
75 |
(*if*) Ctree.just_created (pt, pos) andalso origin <> Ctree.e_origin (*else*);
|
Walther@60706
|
76 |
(*if*) p_ = Pos.Pbl (*then*);
|
Walther@60706
|
77 |
|
Walther@60706
|
78 |
val return_for_problem as (_, (_, xxx)) =
|
Walther@60780
|
79 |
Specify.for_problem ctxt oris (o_refs, refs) (pbl, met);
|
Walther@60706
|
80 |
"~~~~~ fun for_problem , args:"; val (ctxt, oris, ((dI', pI', mI'), (dI, pI, mI)), (pbl, met)) =
|
Walther@60780
|
81 |
(ctxt, oris, (o_refs, refs), (pbl, met));
|
Walther@60706
|
82 |
val cpI = if pI = Problem.id_empty then pI' else pI;
|
Walther@60706
|
83 |
val cmI = if mI = MethodC.id_empty then mI' else mI;
|
Walther@60706
|
84 |
val {model = pbt, where_rls, where_, ...} = Problem.from_store ctxt cpI;
|
Walther@60706
|
85 |
val {model = mpc, ...} = MethodC.from_store ctxt cmI
|
Walther@60706
|
86 |
|
Walther@60706
|
87 |
val (preok, xxxxx) =
|
Walther@60776
|
88 |
Pre_Conds.check ctxt where_rls where_ (pbt, pbl);
|
Walther@60706
|
89 |
|
Walther@60706
|
90 |
(*+*)val [(true, xxx)] = xxxxx;
|
Walther@60706
|
91 |
(*+*)if (xxx |> UnparseC.term @{context}) =
|
Walther@60706
|
92 |
"matches (x = 0) (- 1 + x = 0) \<or>\n" ^
|
Walther@60706
|
93 |
"matches (?b * x = 0) (- 1 + x = 0) \<or>\n" ^
|
Walther@60706
|
94 |
"matches (?a + x = 0) (- 1 + x = 0) \<or>\n" ^
|
Walther@60706
|
95 |
"matches (?a + ?b * x = 0) (- 1 + x = 0)"
|
Walther@60706
|
96 |
then () else error "pre-cond, to be evaluated, CHANGED";
|
Walther@60706
|
97 |
|
Walther@60741
|
98 |
"~~~~~ fun check , args:"; val (ctxt, where_rls, pres, (model_patt, i_model)) =
|
Walther@60776
|
99 |
(ctxt, where_rls, where_, (pbt, pbl)); (*..delete double above --- adhoc inserted n ---*)
|
Walther@60706
|
100 |
|
Walther@60758
|
101 |
val (env_model, (env_subst, env_eval)) =
|
Walther@60758
|
102 |
make_environments model_patt i_model;
|
Walther@60732
|
103 |
"~~~~~ fun of_max_variant , args:"; val (model_patt, i_model) = (model_patt, i_model);
|
Walther@60706
|
104 |
|
Walther@60706
|
105 |
(*+*)(pbt |> Model_Pattern.to_string @{context}) = "[\"" ^
|
Walther@60706
|
106 |
"(#Given, (equality, e_e))\", \"" ^
|
Walther@60706
|
107 |
"(#Given, (solveFor, v_v))\", \"" ^
|
Walther@60706
|
108 |
"(#Find, (solutions, v_v'i'))\"]";
|
Walther@60782
|
109 |
(*+*)(( pbl) |> I_Model.to_string @{context}) = "[\n" ^
|
Walther@60782
|
110 |
"(1, [1], true ,#Given, (Cor equality (- 1 + x = 0) ,(e_e, [- 1 + x = 0]), Position.T)), \n" ^
|
Walther@60782
|
111 |
"(2, [1], true ,#Given, (Cor solveFor x ,(v_v, [x]), Position.T)), \n" ^
|
Walther@60782
|
112 |
"(3, [1], true ,#Find, (Cor solutions x_i ,(v_v'i', [x_i]), Position.T))]";
|
Walther@60706
|
113 |
|
Walther@60706
|
114 |
val all_variants =
|
Walther@60732
|
115 |
map (fn (_, variants, _, _, _) => variants) i_model
|
Walther@60706
|
116 |
|> flat
|
Walther@60706
|
117 |
|> distinct op =
|
Walther@60732
|
118 |
val variants_separated = map (filter_variants' i_model) all_variants
|
Walther@60748
|
119 |
val sums_corr = map (Model_Def.cnt_corrects) variants_separated
|
Walther@60748
|
120 |
val sum_variant_s = Model_Def.arrange_args sums_corr (1, all_variants)
|
Walther@60732
|
121 |
val (_, max_variant) = hd (*..crude decision, up to improvement *)
|
Walther@60732
|
122 |
(sort (fn ((i, _), (j, _)) => int_ord (i, j)) sum_variant_s)
|
Walther@60732
|
123 |
val i_model_max =
|
Walther@60732
|
124 |
filter (fn (_, variants, _ , _ ,_) => member (op =) variants max_variant) i_model
|
Walther@60732
|
125 |
val equal_descr_pairs = map (get_equal_descr i_model) model_patt |> flat
|
Walther@60732
|
126 |
val env_model = make_env_model equal_descr_pairs
|
Walther@60732
|
127 |
val equal_givens = filter (fn ((m_field, _), _) => m_field = "#Given") equal_descr_pairs
|
Walther@60706
|
128 |
|
Walther@60732
|
129 |
val subst_eval_list =
|
Walther@60732
|
130 |
make_envs_preconds equal_givens;
|
Walther@60732
|
131 |
(*//------------------ step into make_envs_preconds ----------------------------------------\\*)
|
Walther@60732
|
132 |
"~~~~~ fun make_envs_preconds , args:"; val (equal_givens) = (equal_givens);
|
Walther@60732
|
133 |
"~~~~~ fun xxx , args:"; val (((_, (_, id)), (_, _, _, _, (feedb, _)))) = (nth 1 equal_givens);
|
Walther@60706
|
134 |
|
Walther@60732
|
135 |
val [] =
|
Walther@60732
|
136 |
discern_feedback id feedb;
|
Walther@60732
|
137 |
(*\\------------------ step into make_envs_preconds ----------------------------------------//*)
|
Walther@60706
|
138 |
|
Walther@60732
|
139 |
(*-------------------- continuing of_max_variant ---------------------------------------------*)
|
Walther@60732
|
140 |
val (env_subst, env_eval) = split_list subst_eval_list
|
Walther@60732
|
141 |
val return_of_max_variant = (i_model_max, env_model, (env_subst, env_eval))
|
Walther@60706
|
142 |
(*\------------------- step into me Add_Find ------------------------------------------------/*)
|
Walther@60706
|
143 |
val (p,_,f,nxt,_,pt) = return_Add_Find; (** )val Specify_Theory "Test" = nxt;( **)
|
Walther@60706
|
144 |
|
Walther@60706
|
145 |
(*isa* )val Empty_Tac = nxt;( **)
|
Walther@60706
|
146 |
(*isa2*)val Specify_Theory "Test" = nxt;(**)
|
Walther@60706
|
147 |
val (p,_,f,nxt,_,pt) = me nxt p [] pt; (** )val Specify_Problem ["LINEAR", "univariate", "equation", "test"] = nxt;( **)
|
Walther@60706
|
148 |
|
Walther@60706
|
149 |
val return_Specify_Method
|
Walther@60706
|
150 |
= me nxt p [] pt;
|
Walther@60706
|
151 |
(*/------------------- step into me Specify_Problem -----------------------------------------\*)
|
Walther@60706
|
152 |
(*\------------------- step into me Specify_Problem -----------------------------------------/*)
|
Walther@60706
|
153 |
val (p,_,f,nxt,_,pt) = return_Specify_Method; val Specify_Method ["Test", "solve_linear"] = nxt;
|
Walther@60706
|
154 |
|
Walther@60706
|
155 |
val return_Specify_Method
|
Walther@60706
|
156 |
= me nxt p [] pt;
|
Walther@60706
|
157 |
(*/------------------- step into me Specify_Method ------------------------------------------\*)
|
Walther@60706
|
158 |
(*\------------------- step into me Specify_Method ------------------------------------------/*)
|
Walther@60706
|
159 |
val (p_return_Specify_Method,_,f,nxt,_,pt) = return_Specify_Method; val Apply_Method ["Test", "solve_linear"] = nxt;
|
Walther@60706
|
160 |
|
Walther@60706
|
161 |
val return_Apply_Method
|
Walther@60706
|
162 |
= me nxt p_return_Specify_Method [] pt;
|
Walther@60558
|
163 |
(*+*)val ([3], Pbl) = p;
|
Walther@60558
|
164 |
(*+*)if get_ctxt pt p |> ContextC.is_empty then error "ctxt not initialised by specify, PblObj{ctxt,...}" else ();
|
Walther@60706
|
165 |
(*+*)if get_ctxt pt p_return_Specify_Method |> ContextC.is_empty then error "ctxt NOT initialised by Subproblem'}" else ();
|
Walther@60706
|
166 |
(*/------------------- step into me Apply_Method --------------------------------------------\*)
|
Walther@60706
|
167 |
"~~~~~ fun me , args:"; val (tac, p, _(*NEW remove*), pt) = (nxt, p_return_Specify_Method, [], pt);
|
Walther@60558
|
168 |
val ("ok", (_, _, (_, _))) = (*case*)
|
walther@59806
|
169 |
Step.by_tactic tac (pt, p) (*of*);
|
Walther@60611
|
170 |
(*//------------------ step into by_tactic Apply_Method ------------------------------------\\*)
|
walther@59806
|
171 |
"~~~~~ fun by_tactic , args:"; val (tac, (ptp as (pt, p))) = (tac, (pt,p));
|
Walther@60558
|
172 |
val Applicable.Yes tac' = (*case*) Step.check tac (pt, p) (*of*);
|
Walther@60558
|
173 |
(*if*) Tactic.for_specify' tac'; (*else*)
|
wneuper@59578
|
174 |
|
Walther@60558
|
175 |
Step_Solve.by_tactic tac' ptp;
|
Walther@60558
|
176 |
"~~~~~ fun by_tactic , args:"; val (tac as Tactic.Apply_Method' _, ptp as (pt, p))
|
Walther@60558
|
177 |
= (tac', ptp);
|
wneuper@59578
|
178 |
|
Walther@60558
|
179 |
(*+*)val PblObj {ctxt, ...} = get_obj I pt [3];
|
Walther@60558
|
180 |
(*+isa==isa2*)ContextC.get_assumptions ctxt = [];
|
Walther@60675
|
181 |
(*+isa==isa2*)(Ctree.get_assumptions pt p |> map (UnparseC.term @{context})) = [];
|
neuper@42020
|
182 |
|
Walther@60558
|
183 |
LI.by_tactic tac (get_istate_LI pt p, get_ctxt_LI pt p) ptp;
|
Walther@60558
|
184 |
"~~~~~ fun by_tactic , args:"; val (Tactic.Apply_Method' (mI, _, _, _), (_, ctxt), (pt, (pos as (p, _))))
|
Walther@60558
|
185 |
= (tac, (get_istate_LI pt p, get_ctxt_LI pt p), (pt, p));
|
wneuper@59578
|
186 |
|
Walther@60675
|
187 |
(*+isa==isa2*)if (ContextC.get_assumptions ctxt |> map (UnparseC.term ctxt))
|
Walther@60611
|
188 |
(*+*) = ["precond_rootmet x"]
|
Walther@60558
|
189 |
(*+*)then () else error "assumptions 7 from Apply_Method'";
|
walther@59686
|
190 |
|
Walther@60558
|
191 |
(*+*)val [3] = p;
|
Walther@60754
|
192 |
val (itms, oris, probl, o_spec, spec) = case get_obj I pt p of
|
Walther@60754
|
193 |
PblObj {meth = itms, origin = (oris, o_spec, _), probl, spec, ...}
|
Walther@60754
|
194 |
=> (itms, oris, probl, o_spec, spec)
|
Walther@60558
|
195 |
| _ => raise ERROR "LI.by_tactic Apply_Method': uncovered case get_obj";
|
walther@59686
|
196 |
|
Walther@60675
|
197 |
(*+isa==isa2*)if (ContextC.get_assumptions ctxt |> map (UnparseC.term ctxt))
|
Walther@60611
|
198 |
(*+*) = ["precond_rootmet x"]
|
Walther@60558
|
199 |
(*+*)then () else error "assumptions 8";
|
neuper@41990
|
200 |
|
Walther@60754
|
201 |
val (_, pI', _) = References.select_input o_spec spec
|
Walther@60780
|
202 |
val (_, itms) = I_Model.s_make_complete ctxt oris (probl, itms) (pI', mI)
|
Walther@60586
|
203 |
val prog_rls = LItool.get_simplifier (pt, pos)
|
Walther@60710
|
204 |
|
Walther@60710
|
205 |
val (is, env, ctxt, prog) = case
|
Walther@60754
|
206 |
LItool.init_pstate ctxt itms mI of
|
Walther@60710
|
207 |
(is as Pstate {env, ...}, ctxt, program) => (is, env, ctxt, program)
|
Walther@60558
|
208 |
| _ => raise ERROR "LI.by_tactic Apply_Method': uncovered case init_pstate";
|
Walther@60558
|
209 |
|
Walther@60675
|
210 |
(*+*)(ContextC.get_assumptions ctxt |> map (UnparseC.term ctxt))
|
Walther@60558
|
211 |
(*+isa==isa2*) = ["matches (?a = ?b) (- 1 + x = 0)", "precond_rootmet x"];
|
Walther@60558
|
212 |
|
Walther@60673
|
213 |
val ini = LItool.implicit_take ctxt prog env;
|
Walther@60558
|
214 |
val pos = start_new_level pos
|
Walther@60558
|
215 |
val SOME t =
|
Walther@60558
|
216 |
(*case*) ini (*of*);
|
Walther@60558
|
217 |
val show_add = Tactic.Apply_Method' (mI, SOME t, is, ctxt);
|
Walther@60558
|
218 |
val (pos, c, _, pt) = Solve_Step.add show_add (is, ctxt) (pt, pos);
|
Walther@60558
|
219 |
|
Walther@60675
|
220 |
(*+*)if (ContextC.get_assumptions ctxt |> map (UnparseC.term ctxt))
|
Walther@60558
|
221 |
(*+isa==isa2*) = ["matches (?a = ?b) (- 1 + x = 0)", "precond_rootmet x"]
|
Walther@60558
|
222 |
(*+*)then () else error "assumptions 9";
|
Walther@60558
|
223 |
|
Walther@60558
|
224 |
val return = ("ok", ([(Tactic.Apply_Method mI, show_add, (pos, (is, ctxt)))], c, (pt, pos)));
|
Walther@60558
|
225 |
"~~~~~ from LI.by_tactic to..to me return"; val ("ok", (_, _, ptp)) = return;
|
Walther@60558
|
226 |
val (pt, p) = ptp;
|
Walther@60611
|
227 |
(*\\------------------ step into by_tactic Apply_Method ------------------------------------//*)
|
Walther@60558
|
228 |
|
Walther@60706
|
229 |
(*|------------------- continue me Applythod ------------------------------------------------|*)
|
Walther@60558
|
230 |
(*case*)
|
Walther@60558
|
231 |
Step.do_next p ((pt, Pos.e_pos'), []) (*of*);
|
Walther@60611
|
232 |
(*//------------------ step into do_next ---------------------------------------------------\\*)
|
Walther@60558
|
233 |
"~~~~~ fun do_next , args:"; val ((ip as (_, p_)), (ptp as (pt, p), tacis))
|
Walther@60558
|
234 |
= (p, ((pt, Pos.e_pos'), []));
|
Walther@60558
|
235 |
(*if*) Pos.on_calc_end ip (*else*);
|
Walther@60558
|
236 |
val (_, probl_id, _) = Calc.references (pt, p);
|
Walther@60558
|
237 |
val _ =
|
Walther@60558
|
238 |
(*case*) tacis (*of*);
|
Walther@60558
|
239 |
(*if*) probl_id = Problem.id_empty (*else*);
|
Walther@60558
|
240 |
|
Walther@60558
|
241 |
switch_specify_solve p_ (pt, ip);
|
Walther@60558
|
242 |
"~~~~~ fun switch_specify_solve , args:"; val (state_pos, (pt, input_pos))
|
Walther@60558
|
243 |
= (p_, (pt, ip));
|
Walther@60611
|
244 |
(*if*) Pos.on_specification ([], state_pos) (*else*);
|
Walther@60611
|
245 |
|
Walther@60611
|
246 |
LI.do_next (pt, input_pos);
|
Walther@60611
|
247 |
"~~~~~ and do_next , args:"; val (ptp as (pt, pos as (p, p_))) = (pt, input_pos);
|
Walther@60611
|
248 |
(*if*) MethodC.id_empty = get_obj g_metID pt (par_pblobj pt p) (*else*);
|
Walther@60611
|
249 |
val ((ist, ctxt), sc) = LItool.resume_prog (p,p_) pt;
|
Walther@60611
|
250 |
val Next_Step (ist, ctxt, tac) =
|
Walther@60706
|
251 |
(*case*) LI.find_next_step sc (pt, pos) ist ctxt (*of*);
|
Walther@60611
|
252 |
|
Walther@60611
|
253 |
val continue_do_next = (ist, ctxt, tac, ptp)(*keep for continuing LI.do_next*);
|
Walther@60611
|
254 |
(*///----------------- step into find_next_step -------------------------------------------\\\*)
|
Walther@60611
|
255 |
"~~~~~ fun find_next_step , args:"; val ((Rule.Prog prog), (ptp as (pt, pos as (p, _))), (Pstate ist), ctxt) =
|
Walther@60611
|
256 |
(sc, (pt, pos), ist, ctxt);
|
Walther@60611
|
257 |
|
Walther@60611
|
258 |
(*case*) scan_to_tactic (prog, (ptp, ctxt)) (Pstate ist) (*of*);
|
Walther@60611
|
259 |
"~~~~~ fun scan_to_tactic , args:"; val ((prog, cc), (Pstate (ist as {path, ...}))) =
|
Walther@60611
|
260 |
((prog, (ptp, ctxt)), (Pstate ist));
|
Walther@60611
|
261 |
(*if*) path = [] (*then*);
|
Walther@60611
|
262 |
|
Walther@60611
|
263 |
scan_dn cc (trans_scan_dn ist) (Program.body_of prog);
|
Walther@60611
|
264 |
"~~~~~ fun scan_dn , args:"; val (cc, ist, (Const (\<^const_name>\<open>Let\<close>(*1*), _) $ e $ (Abs (i, T, b)))) =
|
Walther@60611
|
265 |
(cc, (trans_scan_dn ist), (Program.body_of prog));
|
Walther@60611
|
266 |
|
Walther@60611
|
267 |
(*case*) scan_dn cc (ist |> path_down [L, R]) e (*of*);
|
Walther@60611
|
268 |
"~~~~~ fun scan_dn , args:"; val (cc, ist, (Const (\<^const_name>\<open>Tactical.Repeat\<close>(*1*), _) $ e $ a)) =
|
Walther@60611
|
269 |
(cc, (ist |> path_down [L, R]), e);
|
Walther@60611
|
270 |
|
Walther@60611
|
271 |
scan_dn cc (ist |> path_down_form ([L, R], a)) e;
|
Walther@60611
|
272 |
"~~~~~ fun scan_dn , args:"; val (cc, ist, (Const (\<^const_name>\<open>Tactical.Chain\<close>(*2*), _) $ e1 $ e2)) =
|
Walther@60611
|
273 |
(cc, (ist |> path_down_form ([L, R], a)), e);
|
Walther@60611
|
274 |
|
Walther@60611
|
275 |
(*case*) scan_dn cc (ist |> path_down [L, R]) e1 (*of*);
|
Walther@60611
|
276 |
"~~~~~ fun scan_dn , args:"; val ((cc as (_, ctxt)), (ist as {eval, ...}), t (*fall-through*)) =
|
Walther@60611
|
277 |
(cc, (ist |> path_down [L, R]), e1);
|
Walther@60611
|
278 |
(*if*) Tactical.contained_in t (*else*);
|
Walther@60611
|
279 |
val (Program.Tac prog_tac, form_arg) =
|
Walther@60611
|
280 |
(*case*) LItool.check_leaf "next " ctxt eval (get_subst ist) t (*of*);
|
Walther@60611
|
281 |
|
Walther@60611
|
282 |
check_tac cc ist (prog_tac, form_arg);
|
Walther@60611
|
283 |
"~~~~~ fun check_tac , args:"; val (((pt, p), ctxt), ist, (prog_tac, form_arg)) =
|
Walther@60611
|
284 |
(cc, ist, (prog_tac, form_arg));
|
Walther@60611
|
285 |
|
Walther@60611
|
286 |
val m =
|
Walther@60640
|
287 |
LItool.tac_from_prog (pt, p) prog_tac;
|
Walther@60611
|
288 |
"~~~~~ fun tac_from_prog , args:"; val (_, _, (Const (\<^const_name>\<open>Prog_Tac.Rewrite_Set_Inst\<close>, _) $ sub $ rls $ _)) =
|
Walther@60611
|
289 |
((pt, p), (Proof_Context.theory_of ctxt), prog_tac);
|
Walther@60611
|
290 |
val sub' =
|
Walther@60611
|
291 |
Subst.program_to_input ctxt sub
|
Walther@60611
|
292 |
(*-------------------- stop step into find_next_step -----------------------------------------*)
|
Walther@60611
|
293 |
(*\\\----------------- step into find_next_step -------------------------------------------///*)
|
Walther@60611
|
294 |
(*kept for continuing LI.do_next*)val (ist, ctxt, tac, ptp) = continue_do_next;
|
Walther@60611
|
295 |
|
Walther@60611
|
296 |
LI.by_tactic tac (ist, Tactic.insert_assumptions tac ctxt) ptp;
|
Walther@60611
|
297 |
"~~~~~ fun by_tactic , args:"; val (tac_, ic, (pt, pos) (*fall through*)) =
|
Walther@60611
|
298 |
(tac, (ist, Tactic.insert_assumptions tac ctxt), ptp);
|
Walther@60611
|
299 |
val pos = next_in_prog' pos
|
Walther@60611
|
300 |
|
Walther@60611
|
301 |
val (pos', c, _, pt) =
|
Walther@60611
|
302 |
Solve_Step.add_general tac_ ic (pt, pos);
|
Walther@60611
|
303 |
"~~~~~ fun add_general , args:"; val (tac, ic, cs) = (tac_, ic, (pt, pos));
|
Walther@60611
|
304 |
(*if*) Tactic.for_specify' tac (*else*);
|
Walther@60611
|
305 |
|
Walther@60611
|
306 |
add tac ic cs;
|
Walther@60611
|
307 |
"~~~~~ fun add , args:"; val ((Tactic.Rewrite_Set_Inst' (_, _, subs', rls', f, (f', asm))), (is, ctxt), (pt, (p, _))) =
|
Walther@60611
|
308 |
(tac, ic, cs);
|
Walther@60611
|
309 |
val (pt, c) =
|
Walther@60611
|
310 |
Ctree.cappend_atomic pt p (is, ctxt) f
|
Walther@60611
|
311 |
(Tactic.Rewrite_Set_Inst (Subst.T_to_input ctxt subs', Rule_Set.id rls')) (f', asm) Ctree.Complete;
|
Walther@60611
|
312 |
"~~~~~ fun cappend_atomic , args:"; val (pt, p, ic_res, f, r, f', s) =
|
Walther@60611
|
313 |
(pt, p, (is, ctxt), f,
|
Walther@60611
|
314 |
(Tactic.Rewrite_Set_Inst (Subst.T_to_input ctxt subs', Rule_Set.id rls')), (f', asm), Ctree.Complete);
|
Walther@60611
|
315 |
Subst.T_to_input ctxt subs';
|
Walther@60558
|
316 |
|
Walther@60558
|
317 |
"~~~~~ from fun switch_specify_solve \<longrightarrow>fun Step.do_next \<longrightarrow>fun me , return:"; val (_, ts)
|
Walther@60558
|
318 |
= (LI.do_next (pt, input_pos));
|
Walther@60611
|
319 |
(*-------------------- stop step into do_next ------------------------------------------------*)
|
Walther@60706
|
320 |
(*\\------------------ step into do_next ---------------------------------------------------//*)
|
Walther@60706
|
321 |
(*\------------------- step into me Apply_Method --------------------------------------------/*)
|
Walther@60725
|
322 |
val (p_return_Apply_Method,_,f,nxt,_,pt) = return_Apply_Method;
|
Walther@60725
|
323 |
val Rewrite_Set_Inst (["(''bdv'', x)"], "isolate_bdv") = nxt;
|
wneuper@59578
|
324 |
|
Walther@60725
|
325 |
val (p,_,f,nxt,_,pt) = me nxt p_return_Apply_Method [] pt; val Rewrite_Set "Test_simplify" = nxt;
|
wneuper@59578
|
326 |
|
Walther@60611
|
327 |
(* final tests ... ---------------------------------------------------------------------------*)
|
Walther@60706
|
328 |
val ([3, 1], Frm) = p_return_Apply_Method;
|
Walther@60706
|
329 |
val "Rewrite_Set \"Test_simplify\"" = Tactic.input_to_string ctxt nxt;
|
Walther@60529
|
330 |
|
Walther@60706
|
331 |
(*p_frm BEFORE Apply_Method at Subproblem*)
|
Walther@60706
|
332 |
val p_frm = ([3], Frm);
|
Walther@60706
|
333 |
val ["precond_rootmet x"] = Ctree.get_assumptions pt p_frm |> map (UnparseC.term @{context});
|
Walther@60558
|
334 |
|
Walther@60706
|
335 |
(*assumptions<>[] before Apply_Method of Subproblem*)
|
Walther@60706
|
336 |
val ([3], Met) = p_return_Specify_Method;
|
Walther@60706
|
337 |
val [(*--- inserted by Apply_Method ---*)] = Ctree.get_assumptions pt p_return_Specify_Method;
|
Walther@60558
|
338 |
|
Walther@60706
|
339 |
(*FALSE: 2 assumptions recorded Apply_Method of Subproblem*)
|
Walther@60706
|
340 |
val ([3, 1], Frm) = p_return_Apply_Method;
|
Walther@60706
|
341 |
val ["matches (?a = ?b) (- 1 + x = 0)", "precond_rootmet x"] =
|
Walther@60706
|
342 |
Ctree.get_assumptions pt p_return_Apply_Method |> map (UnparseC.term @{context});
|
Walther@60558
|
343 |
|
Walther@60706
|
344 |
(*p_res AFTER Apply_Method at Subproblem*)
|
Walther@60706
|
345 |
val p_res = ([3], Res);
|
Walther@60706
|
346 |
val ["precond_rootmet x"] = Ctree.get_assumptions pt p_res |> map (UnparseC.term @{context});
|