1 (* Title: Tactics; tac_ for interaction with frontend, input for internal use.
2 Author: Walther Neuper 170121
3 (c) due to copyright terms
5 regular expression for search:
7 Add_Find|Add_Given|Add_Relation|Apply_Assumption|Apply_Method|Begin_Sequ|Begin_Trans|Split_And|Split_Or|Split_Intersect|Conclude_And|Conclude_Or|Collect_Trues|End_Sequ|End_Trans|End_Ruleset|End_Subproblem|End_Intersect|End_Proof|CAScmd|Calculate|Check_Postcond|Check_elementwise|Del_Find|Del_Given|Del_Relation|Derive|Detail_Set|Detail_Set_Inst|End_Detail|Empty_Tac|Free_Solve|Init_Proof|Model_Problem Or_to_List|Refine_Problem|Refine_Tacitly| Rewrite|Rewrite_Asm|Rewrite_Inst|Rewrite_Set|Rewrite_Set_Inst|Specify_Method|Specify_Problem|Specify_Theory|Subproblem|Substitute|Tac|Take|Take_Inst
13 Add_Find' of Rule.cterm' * Model.itm list | Add_Given' of Rule.cterm' * Model.itm list
14 | Add_Relation' of Rule.cterm' * Model.itm list
15 | Apply_Assumption' of term list * term
16 | Apply_Method' of Celem.metID * term option * Istate_Def.T * Proof.context
18 | Begin_Sequ' | Begin_Trans' of term
19 | Split_And' of term | Split_Or' of term | Split_Intersect' of term
20 | Conclude_And' of term | Conclude_Or' of term | Collect_Trues' of term
21 | End_Sequ' | End_Trans' of Selem.result
22 | End_Ruleset' of term | End_Subproblem' of term | End_Intersect' of term | End_Proof''
25 | Calculate' of Rule.theory' * string * term * (term * Celem.thm')
26 | Check_Postcond' of Celem.pblID * Selem.result
27 | Check_elementwise' of term * Rule.cterm' * Selem.result
28 | Del_Find' of Rule.cterm' | Del_Given' of Rule.cterm' | Del_Relation' of Rule.cterm'
31 | Detail_Set' of Rule.theory' * bool * Rule.rls * term * Selem.result
32 | Detail_Set_Inst' of Rule.theory' * bool * Rule.subst * Rule.rls * term * Selem.result
33 | End_Detail' of Selem.result
38 | Init_Proof' of Rule.cterm' list * Celem.spec
39 | Model_Problem' of Celem.pblID * Model.itm list * Model.itm list
40 | Or_to_List' of term * term
41 | Refine_Problem' of Celem.pblID * (Model.itm list * (bool * term) list)
42 | Refine_Tacitly' of Celem.pblID * Celem.pblID * Rule.domID * Celem.metID * Model.itm list
44 | Rewrite' of Rule.theory' * Rule.rew_ord' * Rule.rls * bool * Celem.thm'' * term * Selem.result
45 | Rewrite_Asm' of Rule.theory' * Rule.rew_ord' * Rule.rls * bool * Celem.thm'' * term * Selem.result
46 | Rewrite_Inst' of Rule.theory' * Rule.rew_ord' * Rule.rls * bool * Rule.subst * Celem.thm'' * term * Selem.result
47 | Rewrite_Set' of Rule.theory' * bool * Rule.rls * term * Selem.result
48 | Rewrite_Set_Inst' of Rule.theory' * bool * Rule.subst * Rule.rls * term * Selem.result
50 | Specify_Method' of Celem.metID * Model.ori list * Model.itm list
51 | Specify_Problem' of Celem.pblID * (bool * (Model.itm list * (bool * term) list))
52 | Specify_Theory' of Rule.domID
53 | Subproblem' of Celem.spec * Model.ori list * term * Selem.fmz_ * Proof.context * term
54 | Substitute' of Rule.rew_ord_ * Rule.rls * Selem.subte * term * term
55 | Tac_ of theory * string * string * string
56 | Take' of term | Take_Inst' of term
57 val string_of : T -> string
60 Add_Find of Rule.cterm' | Add_Given of Rule.cterm' | Add_Relation of Rule.cterm'
61 | Apply_Assumption of Rule.cterm' list
62 | Apply_Method of Celem.metID
63 (*/--- TODO: re-design ? -----------------------------------------------------------------\*)
64 | Begin_Sequ | Begin_Trans
65 | Split_And | Split_Or | Split_Intersect
66 | Conclude_And | Conclude_Or | Collect_Trues
67 | End_Sequ | End_Trans
68 | End_Ruleset | End_Subproblem | End_Intersect | End_Proof'
69 (*\--- TODO: re-design ? -----------------------------------------------------------------/*)
70 | CAScmd of Rule.cterm'
72 | Check_Postcond of Celem.pblID
73 | Check_elementwise of Rule.cterm'
74 | Del_Find of Rule.cterm' | Del_Given of Rule.cterm' | Del_Relation of Rule.cterm'
77 | Detail_Set of Rule.rls'
78 | Detail_Set_Inst of Selem.subs * Rule.rls'
84 | Init_Proof of Rule.cterm' list * Celem.spec
87 | Refine_Problem of Celem.pblID
88 | Refine_Tacitly of Celem.pblID
90 | Rewrite of Celem.thm''
91 | Rewrite_Asm of Celem.thm''
92 | Rewrite_Inst of Selem.subs * Celem.thm''
93 | Rewrite_Set of Rule.rls'
94 | Rewrite_Set_Inst of Selem.subs * Rule.rls'
96 | Specify_Method of Celem.metID
97 | Specify_Problem of Celem.pblID
98 | Specify_Theory of Rule.domID
99 | Subproblem of Rule.domID * Celem.pblID
101 | Substitute of Selem.sube
103 | Take of Rule.cterm' | Take_Inst of Rule.cterm'
104 val tac2str : input -> string
105 val is_empty_tac : input -> bool
107 (*//-------------------------------------------------------------- only AFTER ctree.sml required *)
108 val eq_tac : input * input -> bool
109 val is_rewtac : input -> bool
110 val is_rewset : input -> bool
111 val rls_of : input -> Rule.rls'
112 val tac2IDstr : input -> string
113 val rule2tac : theory -> (term * term) list -> Rule.rule -> input
114 val input_from_T : T -> input
115 val result : T -> term
116 val creates_assms: T -> term list
117 val insert_assumptions: T -> Proof.context -> Proof.context
118 val for_specify: input -> bool
119 val for_specify': T -> bool
121 (* ---- for tests only: shifted from below to remove the Warning "unused" at fun.def. --------- *)
123 (*/-------------------------------------------------------- ! aktivate for Test_Isac BEGIN ---\* )
125 ( *\--- ! aktivate for Test_Isac END ----------------------------------------------------------/*)
127 (*----- unused code, kept as hints to design ideas ---------------------------------------------*)
132 structure Tactic(**): TACTIC(**) =
136 (* tactics for user at front-end.
137 input propagates the construction of the calc-tree;
139 (a) 'specsteps' for the specify-phase, and others for the solve-phase
140 (b) those of the solve-phase are 'initac's and others;
141 initacs start with a formula different from the preceding formula.
142 see 'type tac_' for the internal representation of tactics
145 Add_Find of Rule.cterm' | Add_Given of Rule.cterm' | Add_Relation of Rule.cterm'
146 | Apply_Assumption of Rule.cterm' list
147 | Apply_Method of Celem.metID
148 (* creates an "istate" in PblObj.env; in case of "init_form"
149 creates a formula at ((lev_on o lev_dn) p, Frm) and in this "ppobj.loc"
150 a "SOME istate" at fst of "loc".
151 As each step (in the solve-phase) has a resulting formula (at the front-end)
152 Apply_Method also does the 1st step in the script (an "initac") if there is no "init_form" *)
153 (*/--- TODO: re-design ? -----------------------------------------------------------------\*)
154 | Begin_Sequ | Begin_Trans
155 | Split_And | Split_Or | Split_Intersect
156 | Conclude_And | Conclude_Or | Collect_Trues
157 | End_Sequ | End_Trans
158 | End_Ruleset | End_Subproblem (* WN0509 drop *) | End_Intersect | End_Proof'
159 (*\--- TODO: re-design ? -----------------------------------------------------------------/*)
160 | CAScmd of Rule.cterm'
161 | Calculate of string
162 | Check_Postcond of Celem.pblID
163 | Check_elementwise of Rule.cterm'
164 | Del_Find of Rule.cterm' | Del_Given of Rule.cterm' | Del_Relation of Rule.cterm'
166 | Derive of Rule.rls' (* WN0509 drop *)
167 | Detail_Set of Rule.rls' (* WN0509 drop *)
168 | Detail_Set_Inst of Selem.subs * Rule.rls' (* WN0509 drop *)
169 | End_Detail (* WN0509 drop *)
174 | Init_Proof of Rule.cterm' list * Celem.spec
177 | Refine_Problem of Celem.pblID
178 | Refine_Tacitly of Celem.pblID
180 (* rewrite-tactics can transport a (thmID, thm) to and (!) from the java-front-end
181 because there all the thms are present with both (thmID, thm)
182 (where user-views can show both or only one of (thmID, thm)),
183 and thm is created from ThmID by assoc_thm'' when entering isabisac *)
184 | Rewrite of Celem.thm''
185 | Rewrite_Asm of Celem.thm''
186 | Rewrite_Inst of Selem.subs * Celem.thm''
187 | Rewrite_Set of Rule.rls'
188 | Rewrite_Set_Inst of Selem.subs * Rule.rls'
190 | Specify_Method of Celem.metID
191 | Specify_Problem of Celem.pblID
192 | Specify_Theory of Rule.domID
193 | Subproblem of Rule.domID * Celem.pblID (* WN0509 drop *)
195 | Substitute of Selem.sube
196 | Tac of string (* WN0509 drop *)
197 | Take of Rule.cterm' | Take_Inst of Rule.cterm'
199 fun tac2str ma = case ma of
200 Init_Proof (ppc, spec) =>
201 "Init_Proof "^(pair2str (strs2str ppc, Celem.spec2str spec))
202 | Model_Problem => "Model_Problem "
203 | Refine_Tacitly pblID => "Refine_Tacitly " ^ strs2str pblID
204 | Refine_Problem pblID => "Refine_Problem " ^ strs2str pblID
205 | Add_Given cterm' => "Add_Given " ^ cterm'
206 | Del_Given cterm' => "Del_Given " ^ cterm'
207 | Add_Find cterm' => "Add_Find " ^ cterm'
208 | Del_Find cterm' => "Del_Find " ^ cterm'
209 | Add_Relation cterm' => "Add_Relation " ^ cterm'
210 | Del_Relation cterm' => "Del_Relation " ^ cterm'
212 | Specify_Theory domID => "Specify_Theory " ^ quote domID
213 | Specify_Problem pblID => "Specify_Problem " ^ strs2str pblID
214 | Specify_Method metID => "Specify_Method " ^ strs2str metID
215 | Apply_Method metID => "Apply_Method " ^ strs2str metID
216 | Check_Postcond pblID => "Check_Postcond " ^ strs2str pblID
217 | Free_Solve => "Free_Solve"
219 | Rewrite_Inst (subs, (id, thm)) =>
220 "Rewrite_Inst " ^ (pair2str (subs2str subs, spair2str (id, thm |> Thm.prop_of |> Rule.term2str)))
221 | Rewrite (id, thm) => "Rewrite " ^ spair2str (id, thm |> Thm.prop_of |> Rule.term2str)
222 | Rewrite_Asm (id, thm) => "Rewrite_Asm " ^ spair2str (id, thm |> Thm.prop_of |> Rule.term2str)
223 | Rewrite_Set_Inst (subs, rls) =>
224 "Rewrite_Set_Inst " ^ pair2str (subs2str subs, quote rls)
225 | Rewrite_Set rls => "Rewrite_Set " ^ quote rls
226 | Detail_Set rls => "Detail_Set " ^ quote rls
227 | Detail_Set_Inst (subs, rls) => "Detail_Set_Inst " ^ pair2str (subs2str subs, quote rls)
228 | End_Detail => "End_Detail"
229 | Derive rls' => "Derive " ^ rls'
230 | Calculate op_ => "Calculate " ^ op_
231 | Substitute sube => "Substitute " ^ Selem.sube2str sube
232 | Apply_Assumption ct's => "Apply_Assumption " ^ strs2str ct's
234 | Take cterm' => "Take " ^ quote cterm'
235 | Take_Inst cterm' => "Take_Inst " ^ quote cterm'
236 | Subproblem (domID, pblID) => "Subproblem " ^ pair2str (domID, strs2str pblID)
237 | End_Subproblem => "End_Subproblem"
238 | CAScmd cterm' => "CAScmd " ^ quote cterm'
240 | Check_elementwise cterm'=> "Check_elementwise " ^ quote cterm'
241 | Or_to_List => "Or_to_List "
242 | Collect_Trues => "Collect_Trues"
244 | Empty_Tac => "Empty_Tac"
245 | Tac string => "Tac " ^ string
246 | End_Proof' => "input End_Proof'"
247 | _ => "tac2str not impl. for ?!";
249 fun is_empty_tac input = case input of Empty_Tac => true | _ => false
251 fun eq_tac (Rewrite (id1, _), Rewrite (id2, _)) = id1 = id2
252 | eq_tac (Rewrite_Inst (_, (id1, _)), Rewrite_Inst (_, (id2, _))) = id1 = id2
253 | eq_tac (Rewrite_Set id1, Rewrite_Set id2) = id1 = id2
254 | eq_tac (Rewrite_Set_Inst (_, id1), Rewrite_Set_Inst (_, id2)) = id1 = id2
255 | eq_tac (Calculate id1, Calculate id2) = id1 = id2
258 fun is_rewset (Rewrite_Set_Inst _) = true
259 | is_rewset (Rewrite_Set _) = true
260 | is_rewset _ = false;
261 fun is_rewtac (Rewrite _) = true
262 | is_rewtac (Rewrite_Inst _) = true
263 | is_rewtac (Rewrite_Asm _) = true
264 | is_rewtac input = is_rewset input;
266 fun tac2IDstr ma = case ma of
267 Model_Problem => "Model_Problem"
268 | Refine_Tacitly _ => "Refine_Tacitly"
269 | Refine_Problem _ => "Refine_Problem"
270 | Add_Given _ => "Add_Given"
271 | Del_Given _ => "Del_Given"
272 | Add_Find _ => "Add_Find"
273 | Del_Find _ => "Del_Find"
274 | Add_Relation _ => "Add_Relation"
275 | Del_Relation _ => "Del_Relation"
277 | Specify_Theory _ => "Specify_Theory"
278 | Specify_Problem _ => "Specify_Problem"
279 | Specify_Method _ => "Specify_Method"
280 | Apply_Method _ => "Apply_Method"
281 | Check_Postcond _ => "Check_Postcond"
282 | Free_Solve => "Free_Solve"
284 | Rewrite_Inst _ => "Rewrite_Inst"
285 | Rewrite _ => "Rewrite"
286 | Rewrite_Asm _ => "Rewrite_Asm"
287 | Rewrite_Set_Inst _ => "Rewrite_Set_Inst"
288 | Rewrite_Set _ => "Rewrite_Set"
289 | Detail_Set _ => "Detail_Set"
290 | Detail_Set_Inst _ => "Detail_Set_Inst"
291 | Derive _ => "Derive "
292 | Calculate _ => "Calculate "
293 | Substitute _ => "Substitute"
294 | Apply_Assumption _ => "Apply_Assumption"
297 | Take_Inst _ => "Take_Inst"
298 | Subproblem _ => "Subproblem"
299 | End_Subproblem => "End_Subproblem"
300 | CAScmd _ => "CAScmd"
302 | Check_elementwise _ => "Check_elementwise"
303 | Or_to_List => "Or_to_List "
304 | Collect_Trues => "Collect_Trues"
306 | Empty_Tac => "Empty_Tac"
308 | End_Proof' => "End_Proof'"
309 | _ => "tac2str not impl. for ?!";
311 fun rls_of (Rewrite_Set_Inst (_, rls)) = rls
312 | rls_of (Rewrite_Set rls) = rls
313 | rls_of input = error ("rls_of: called with input \"" ^ tac2IDstr input ^ "\"");
315 fun rule2tac thy _ (Rule.Num_Calc (opID, _)) = Calculate (assoc_calc thy opID)
316 | rule2tac _ [] (Rule.Thm thm'') = Rewrite thm''
317 | rule2tac _ subst (Rule.Thm thm'') =
318 Rewrite_Inst (Selem.subst2subs subst, thm'')
319 | rule2tac _ [] (Rule.Rls_ rls) = Rewrite_Set (Rule.id_rls rls)
320 | rule2tac _ subst (Rule.Rls_ rls) =
321 Rewrite_Set_Inst (Selem.subst2subs subst, (Rule.id_rls rls))
322 | rule2tac _ _ rule =
323 error ("rule2tac: called with \"" ^ Rule.rule2str rule ^ "\"");
325 (* tactics for for internal use, compare "input" for user at the front-end.
326 tac_ contains results from check in 'fun applicable_in'.
327 This is useful for costly results, e.g. from rewriting;
328 however, these results might be changed by Scripts like
329 " eq = (Rewrite_Set ''ansatz_rls'' False) eql;" ^
330 " eq = (Rewrite_Set equival_trans False) eq;" ^
331 TODO.WN120106 ANALOGOUSLY TO Substitute':
332 So tac_ contains the term t the result was calculated from
333 in order to compare t with t' possibly changed by "Expr "
334 and re-calculate result if t<>t'
335 TODO.WN161219: replace *every* cterm' by term
338 Add_Find' of Rule.cterm' * Model.itm list | Add_Given' of Rule.cterm' * Model.itm list
339 | Add_Relation' of Rule.cterm' * Model.itm list
340 | Apply_Assumption' of term list * term
341 | Apply_Method' of Celem.metID * term option * Istate_Def.T * Proof.context
342 (*/--- TODO: re-design ? -----------------------------------------------------------------\*)
343 | Begin_Sequ' | Begin_Trans' of term
344 | Split_And' of term | Split_Or' of term | Split_Intersect' of term
345 | Conclude_And' of term | Conclude_Or' of term | Collect_Trues' of term
346 | End_Sequ' | End_Trans' of Selem.result
347 | End_Ruleset' of term | End_Subproblem' of term | End_Intersect' of term | End_Proof''
348 (*\--- TODO: re-design ? -----------------------------------------------------------------/*)
350 | Calculate' of Rule.theory' * string * term * (term * Celem.thm')
351 | Check_Postcond' of Celem.pblID *
352 Selem.result (* returnvalue of script in solve *)
353 | Check_elementwise' of (*special case:*)
354 term * (* (1) the current formula: [x=1,x=...] *)
355 string * (* (2) the pred from Check_elementwise *)
356 Selem.result (* (3) composed from (1) and (2): {x. pred} *)
357 | Del_Find' of Rule.cterm' | Del_Given' of Rule.cterm' | Del_Relation' of Rule.cterm'
359 | Derive' of Rule.rls
360 | Detail_Set' of Rule.theory' * bool * Rule.rls * term * Selem.result
361 | Detail_Set_Inst' of Rule.theory' * bool * Rule.subst * Rule.rls * term * Selem.result
362 | End_Detail' of Selem.result
367 | Init_Proof' of Rule.cterm' list * Celem.spec
368 | Model_Problem' of Celem.pblID *
369 Model.itm list * (* the 'untouched' pbl *)
370 Model.itm list (* the casually completed met *)
371 | Or_to_List' of term * term
372 | Refine_Problem' of Celem.pblID * (Model.itm list * (bool * term) list)
374 Celem.pblID * (* input*)
375 Celem.pblID * (* the refined from applicable_in *)
376 Rule.domID * (* from new pbt?! filled in specify *)
377 Celem.metID * (* from new pbt?! filled in specify *)
378 Model.itm list (* drop ! 9.03: remains [] for Model_Problem recognizing its activation *)
379 | Rewrite' of Rule.theory' * Rule.rew_ord' * Rule.rls * bool * Celem.thm'' * term * Selem.result
380 | Rewrite_Asm' of Rule.theory' * Rule.rew_ord' * Rule.rls * bool * Celem.thm'' * term * Selem.result
381 | Rewrite_Inst' of Rule.theory' * Rule.rew_ord' * Rule.rls * bool * Rule.subst * Celem.thm'' * term * Selem.result
382 | Rewrite_Set' of Rule.theory' * bool * Rule.rls * term * Selem.result
383 | Rewrite_Set_Inst' of Rule.theory' * bool * Rule.subst * Rule.rls * term * Selem.result
385 | Specify_Method' of Celem.metID * Model.ori list * Model.itm list
386 | Specify_Problem' of Celem.pblID *
387 (bool * (* matches *)
388 (Model.itm list * (* ppc *)
389 (bool * term) list)) (* preconditions *)
390 | Specify_Theory' of Rule.domID
393 (Model.ori list) * (* filled in associate Subproblem' *)
394 term * (* filled -"-, headline of calc-head *)
396 Proof.context * (* DEPRECATED shifted into loc for all ppobj *)
397 term (* Subproblem (thyID, pbl) OR cascmd *)
399 Rule.rew_ord_ * (* for re-calculation *)
400 Rule.rls * (* for re-calculation *)
401 Selem.subte * (* the 'substitution': terms of type bool *)
402 term * (* to be substituted into *)
403 term (* resulting from the substitution *)
404 | Tac_ of theory * string * string * string
405 | Take' of term | Take_Inst' of term
407 fun string_of ma = case ma of
408 Init_Proof' (ppc, spec) => "Init_Proof' " ^ pair2str (strs2str ppc, Celem.spec2str spec)
409 | Model_Problem' (pblID, _, _) => "Model_Problem' " ^ strs2str pblID
410 | Refine_Tacitly'(p, prefin, domID, metID, _) => "Refine_Tacitly' (" ^ strs2str p ^ ", " ^
411 strs2str prefin ^ ", " ^ domID ^ ", " ^ strs2str metID ^ ", pbl-itms)"
412 | Refine_Problem' _ => "Refine_Problem' (" ^ (*matchs2str ms*)"..." ^ ")"
413 | Add_Given' _ => "Add_Given' "(*^cterm'*)
414 | Del_Given' _ => "Del_Given' "(*^cterm'*)
415 | Add_Find' _ => "Add_Find' "(*^cterm'*)
416 | Del_Find' _ => "Del_Find' "(*^cterm'*)
417 | Add_Relation' _ => "Add_Relation' "(*^cterm'*)
418 | Del_Relation' _ => "Del_Relation' "(*^cterm'*)
420 | Specify_Theory' domID => "Specify_Theory' " ^ quote domID
421 | Specify_Problem' (pI, (ok, _)) => "Specify_Problem' " ^
422 spair2str (strs2str pI, spair2str (bool2str ok, spair2str ("itms2str_ itms", "items2str pre")))
423 | Specify_Method' (pI, oris, _) => "Specify_Method' (" ^
424 Celem.metID2str pI ^ ", " ^ Model.oris2str oris ^ ", )"
426 | Apply_Method' (metID, _, _, _) => "Apply_Method' " ^ strs2str metID
427 | Check_Postcond' (pblID, (scval, asm)) => "Check_Postcond' " ^
428 (spair2str (strs2str pblID, spair2str (Rule.term2str scval, Rule.terms2str asm)))
430 | Free_Solve' => "Free_Solve'"
432 | Rewrite_Inst' (*subs,thm'*) _ => "Rewrite_Inst' "(*^(pair2str (subs2str subs, spair2str thm'))*)
433 | Rewrite' _(*thm'*) => "Rewrite' "(*^(spair2str thm')*)
434 | Rewrite_Asm' _(*thm'*) => "Rewrite_Asm' "(*^(spair2str thm')*)
435 | Rewrite_Set_Inst' _(*subs,thm'*) => "Rewrite_Set_Inst' "(*^(pair2str (subs2str subs, quote rls))*)
436 | Rewrite_Set' (thy', pasm, rls', f, (f', asm)) => "Rewrite_Set' (" ^ thy' ^ "," ^ bool2str pasm ^
437 "," ^ Rule.id_rls rls' ^ "," ^ Rule.term2str f ^ ",(" ^ Rule.term2str f' ^ "," ^ Rule.terms2str asm ^ "))"
438 | End_Detail' _ => "End_Detail' xxx"
439 | Detail_Set' _ => "Detail_Set' xxx"
440 | Detail_Set_Inst' _ => "Detail_Set_Inst' xxx"
442 | Derive' rls => "Derive' " ^ Rule.id_rls rls
443 | Calculate' _ => "Calculate' "
444 | Substitute' _ => "Substitute' "(*^(subs2str subs)*)
445 | Apply_Assumption' _(* ct's*) => "Apply_Assumption' "(*^(strs2str ct's)*)
447 | Take' _(*cterm'*) => "Take' "(*^(quote cterm' )*)
448 | Take_Inst' _(*cterm'*) => "Take_Inst' "(*^(quote cterm' )*)
449 | Subproblem' _(*(spec, oris, _, _, _, pbl_form)*) =>
450 "Subproblem' "(*^(pair2str (domID, strs2str ,))*)
451 | End_Subproblem' _ => "End_Subproblem'"
452 | CAScmd' _(*cterm'*) => "CAScmd' "(*^(quote cterm')*)
454 | Empty_Tac_ => "Empty_Tac_"
455 | Tac_ (_, form, id, result) => "Tac_ (thy," ^ form ^ "," ^ id ^ "," ^ result ^ ")"
456 | _ => "string_of not impl. for arg";
458 fun input_from_T (Refine_Tacitly' (pI, _, _, _, _)) = Refine_Tacitly pI
459 | input_from_T (Model_Problem' (_, _, _)) = Model_Problem
460 | input_from_T (Add_Given' (t, _)) = Add_Given t
461 | input_from_T (Add_Find' (t, _)) = Add_Find t
462 | input_from_T (Add_Relation' (t, _)) = Add_Relation t
464 | input_from_T (Specify_Theory' dI) = Specify_Theory dI
465 | input_from_T (Specify_Problem' (dI, _)) = Specify_Problem dI
466 | input_from_T (Specify_Method' (dI, _, _)) = Specify_Method dI
468 | input_from_T (Rewrite' (_, _, _, _, thm, _, _)) = Rewrite thm
469 | input_from_T (Rewrite_Inst' (_, _, _, _, sub, thm, _, _)) = Rewrite_Inst (Selem.subst2subs sub, thm)
471 | input_from_T (Rewrite_Set' (_, _, rls, _, _)) = Rewrite_Set (Rule.id_rls rls)
472 | input_from_T (Detail_Set' (_, _, rls, _, _)) = Detail_Set (Rule.id_rls rls)
474 | input_from_T (Rewrite_Set_Inst' (_, _, sub, rls, _, _)) =
475 Rewrite_Set_Inst (Selem.subst2subs sub, Rule.id_rls rls)
476 | input_from_T (Detail_Set_Inst' (_, _, sub, rls, _, _)) =
477 Detail_Set_Inst (Selem.subst2subs sub, Rule.id_rls rls)
479 | input_from_T (Calculate' (_, op_, _, _)) = Calculate (op_)
480 | input_from_T (Check_elementwise' (_, pred, _)) = Check_elementwise pred
482 | input_from_T (Or_to_List' _) = Or_to_List
483 | input_from_T (Take' term) = Take (Rule.term2str term)
484 | input_from_T (Substitute' (_, _, subte, _, _)) = Substitute (Selem.subte2sube subte)
485 | input_from_T (Tac_ (_, _, id, _)) = Tac id
487 | input_from_T (Subproblem' ((domID, pblID, _), _, _, _,_ ,_)) = Subproblem (domID, pblID)
488 | input_from_T (Check_Postcond' (pblID, _)) = Check_Postcond pblID
489 | input_from_T Empty_Tac_ = Empty_Tac
490 | input_from_T m = error (": not impl. for "^(string_of m));
492 fun res (Rewrite_Inst' (_ , _, _, _, _, _, _, res)) = res
493 | res (Rewrite' (_, _, _, _, _, _, res)) = res
494 | res (Rewrite_Set_Inst' (_, _, _, _, _, res)) = res
495 | res (Rewrite_Set' (_, _, _, _, res)) = res
496 | res (Calculate' (_, _, _, (t, _))) = (t, [])
497 | res (Check_elementwise' (_, _, res)) = res
498 | res (Subproblem' (_, _, _, _, _, t)) = (t, [])
499 | res (Take' t) = (t, [])
500 | res (Substitute' (_, _, _, _, t)) = (t, [])
501 | res (Or_to_List' (_, t)) = (t, [])
502 | res m = raise ERROR ("result: not impl.for " ^ string_of m)
504 (*fun result m = (fst o res) m; TODO*)
505 fun result tac = (fst o res) tac;
506 fun creates_assms tac = (snd o res) tac;
508 fun insert_assumptions tac ctxt = ContextC.insert_assumptions (creates_assms tac) ctxt
510 fun for_specify (Init_Proof _) = true
511 | for_specify Model_Problem = true
512 | for_specify (Refine_Tacitly _) = true
513 | for_specify (Refine_Problem _) = true
514 | for_specify (Add_Given _) = true
515 | for_specify (Del_Given _) = true
516 | for_specify (Add_Find _) = true
517 | for_specify (Del_Find _) = true
518 | for_specify (Add_Relation _) = true
519 | for_specify (Del_Relation _) = true
520 | for_specify (Specify_Theory _) = true
521 | for_specify (Specify_Problem _) = true
522 | for_specify (Specify_Method _) = true
523 | for_specify _ = false
524 fun for_specify' (Init_Proof' _) = true
525 | for_specify' (Model_Problem' _) = true
526 | for_specify' (Refine_Tacitly' _) = true
527 | for_specify' (Refine_Problem' _) = true
528 | for_specify' (Add_Given' _) = true
529 | for_specify' (Del_Given' _) = true
530 | for_specify' (Add_Find' _) = true
531 | for_specify' (Del_Find' _) = true
532 | for_specify' (Add_Relation' _) = true
533 | for_specify' (Del_Relation' _) = true
534 | for_specify' (Specify_Theory' _) = true
535 | for_specify' (Specify_Problem' _) = true
536 | for_specify' (Specify_Method' _) = true
537 | for_specify' _ = false