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_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_Method' of Celem.metID * term option * Istate_Def.T * Proof.context
17 | Begin_Sequ' | Begin_Trans' of term
18 | Split_And' of term | Split_Or' of term | Split_Intersect' of term
19 | Conclude_And' of term | Conclude_Or' of term | Collect_Trues' of term
20 | End_Sequ' | End_Trans' of Selem.result
21 | End_Ruleset' of term | End_Intersect' of term | End_Proof''
24 | Calculate' of Rule.theory' * string * term * (term * Celem.thm')
25 | Check_Postcond' of Celem.pblID * term
26 | Check_elementwise' of term * Rule.cterm' * Selem.result
27 | Del_Find' of Rule.cterm' | Del_Given' of Rule.cterm' | Del_Relation' of Rule.cterm'
29 | Derive' of Rule_Set.T
30 | Detail_Set' of Rule.theory' * bool * Rule_Set.T * term * Selem.result
31 | Detail_Set_Inst' of Rule.theory' * bool * Rule.subst * Rule_Set.T * term * Selem.result
32 | End_Detail' of Selem.result
37 | Init_Proof' of Rule.cterm' list * Celem.spec
38 | Model_Problem' of Celem.pblID * Model.itm list * Model.itm list
39 | Or_to_List' of term * term
40 | Refine_Problem' of Celem.pblID * (Model.itm list * (bool * term) list)
41 | Refine_Tacitly' of Celem.pblID * Celem.pblID * Rule.domID * Celem.metID * Model.itm list
43 | Rewrite' of Rule.theory' * Rule_Def.rew_ord' * Rule_Set.T * bool * Celem.thm'' * term * Selem.result
44 | Rewrite_Inst' of Rule.theory' * Rule_Def.rew_ord' * Rule_Set.T * bool * Rule.subst * Celem.thm'' * term * Selem.result
45 | Rewrite_Set' of Rule.theory' * bool * Rule_Set.T * term * Selem.result
46 | Rewrite_Set_Inst' of Rule.theory' * bool * Rule.subst * Rule_Set.T * term * Selem.result
48 | Specify_Method' of Celem.metID * Model.ori list * Model.itm list
49 | Specify_Problem' of Celem.pblID * (bool * (Model.itm list * (bool * term) list))
50 | Specify_Theory' of Rule.domID
52 Celem.spec * Model.ori list *
53 term * (* CAScmd, e.g. "solve (-1 + x = 0, x)" *)
54 Selem.fmz_ * (* either input to root-probl. or derived from prog. in ??? *)
56 Proof.context * (* derived from prog. in ??? *)
57 term (* ?UNUSED, e.g."Subproblem\n (''Test'',\n ??.\<^const>String.char.Char ''LINEAR'' ''univariate'' ''equation''\n ''test'')" *)
58 | Substitute' of Rule_Def.rew_ord_ * Rule_Set.T * Selem.subte * term * term
59 | Tac_ of theory * string * string * string
61 val string_of: T -> string
64 Add_Find of Rule.cterm' | Add_Given of Rule.cterm' | Add_Relation of Rule.cterm'
65 | Apply_Assumption of Rule.cterm' list
66 | Apply_Method of Celem.metID
67 (*/--- TODO: re-design ? -----------------------------------------------------------------\*)
68 | Begin_Sequ | Begin_Trans
69 | Split_And | Split_Or | Split_Intersect
70 | Conclude_And | Conclude_Or | Collect_Trues
71 | End_Sequ | End_Trans
72 | End_Ruleset | End_Subproblem | End_Intersect | End_Proof'
73 (*\--- TODO: re-design ? -----------------------------------------------------------------/*)
74 | CAScmd of Rule.cterm'
76 | Check_Postcond of Celem.pblID
77 | Check_elementwise of Rule.cterm'
78 | Del_Find of Rule.cterm' | Del_Given of Rule.cterm' | Del_Relation of Rule.cterm'
80 | Derive of Rule_Set.identifier
81 | Detail_Set of Rule_Set.identifier
82 | Detail_Set_Inst of Selem.subs * Rule_Set.identifier
88 | Init_Proof of Rule.cterm' list * Celem.spec
91 | Refine_Problem of Celem.pblID
92 | Refine_Tacitly of Celem.pblID
94 | Rewrite of Celem.thm''
95 | Rewrite_Inst of Selem.subs * Celem.thm''
96 | Rewrite_Set of Rule_Set.identifier
97 | Rewrite_Set_Inst of Selem.subs * Rule_Set.identifier
99 | Specify_Method of Celem.metID
100 | Specify_Problem of Celem.pblID
101 | Specify_Theory of Rule.domID
102 | Subproblem of Rule.domID * Celem.pblID
104 | Substitute of Selem.sube
106 | Take of Rule.cterm' | Take_Inst of Rule.cterm'
107 val input_to_string : input -> string
108 val tac2IDstr : input -> string
109 val is_empty : input -> bool
111 val eq_tac : input * input -> bool
112 val is_rewtac : input -> bool
113 val is_rewset : input -> bool
114 val rls_of : input -> Rule_Set.identifier
115 val rule2tac : theory -> (term * term) list -> Rule.rule -> input
116 val input_from_T : T -> input
117 val result : T -> term
118 val creates_assms: T -> term list
119 val insert_assumptions: T -> Proof.context -> Proof.context
120 val for_specify: input -> bool
121 val for_specify': T -> bool
123 (* ---- for tests only: shifted from below to remove the Warning "unused" at fun.def. --------- *)
125 (*/-------------------------------------------------------- ! aktivate for Test_Isac BEGIN ---\* )
127 ( *\--- ! aktivate for Test_Isac END ----------------------------------------------------------/*)
129 (*----- unused code, kept as hints to design ideas ---------------------------------------------*)
134 structure Tactic(**): TACTIC(**) =
138 (* tactics for user at front-end.
139 input propagates the construction of the calc-tree;
141 (a) 'specsteps' for the specify-phase, and others for the solve-phase
142 (b) those of the solve-phase are 'initac's and others;
143 initacs start with a formula different from the preceding formula.
144 see 'type tac_' for the internal representation of tactics
147 Add_Find of Rule.cterm' | Add_Given of Rule.cterm' | Add_Relation of Rule.cterm'
148 | Apply_Assumption of Rule.cterm' list
149 | Apply_Method of Celem.metID
150 (* creates an "istate" in PblObj.env; in case of "implicit_take"
151 creates a formula at ((lev_on o lev_dn) p, Frm) and in this "ppobj.loc"
152 a "SOME istate" at fst of "loc".
153 As each step (in the solve-phase) has a resulting formula (at the front-end)
154 Apply_Method also does the 1st step in the script (an "initac") if there is no "implicit_take" *)
155 (*/--- TODO: re-design ? -----------------------------------------------------------------\*)
156 | Begin_Sequ | Begin_Trans
157 | Split_And | Split_Or | Split_Intersect
158 | Conclude_And | Conclude_Or | Collect_Trues
159 | End_Sequ | End_Trans
160 | End_Ruleset | End_Subproblem (* WN0509 drop *) | End_Intersect | End_Proof'
161 (*\--- TODO: re-design ? -----------------------------------------------------------------/*)
162 | CAScmd of Rule.cterm'
163 | Calculate of string
164 | Check_Postcond of Celem.pblID
165 | Check_elementwise of Rule.cterm'
166 | Del_Find of Rule.cterm' | Del_Given of Rule.cterm' | Del_Relation of Rule.cterm'
168 | Derive of Rule_Set.identifier (* WN0509 drop *)
169 | Detail_Set of Rule_Set.identifier (* WN0509 drop *)
170 | Detail_Set_Inst of Selem.subs * Rule_Set.identifier (* WN0509 drop *)
171 | End_Detail (* WN0509 drop *)
176 | Init_Proof of Rule.cterm' list * Celem.spec
179 | Refine_Problem of Celem.pblID
180 | Refine_Tacitly of Celem.pblID
182 (* rewrite-tactics can transport a (thmID, thm) to and (!) from the java-front-end
183 because there all the thms are present with both (thmID, thm)
184 (where user-views can show both or only one of (thmID, thm)),
185 and thm is created from ThmID by assoc_thm'' when entering isabisac *)
186 | Rewrite of Celem.thm''
187 | Rewrite_Inst of Selem.subs * Celem.thm''
188 | Rewrite_Set of Rule_Set.identifier
189 | Rewrite_Set_Inst of Selem.subs * Rule_Set.identifier
191 | Specify_Method of Celem.metID
192 | Specify_Problem of Celem.pblID
193 | Specify_Theory of Rule.domID
194 | Subproblem of Rule.domID * Celem.pblID (* WN0509 drop *)
196 | Substitute of Selem.sube
197 | Tac of string (* WN0509 drop *)
198 | Take of Rule.cterm' | Take_Inst of Rule.cterm'
200 fun input_to_string ma = case ma of
201 Init_Proof (ppc, spec) =>
202 "Init_Proof "^(pair2str (strs2str ppc, Celem.spec2str spec))
203 | Model_Problem => "Model_Problem "
204 | Refine_Tacitly pblID => "Refine_Tacitly " ^ strs2str pblID
205 | Refine_Problem pblID => "Refine_Problem " ^ strs2str pblID
206 | Add_Given cterm' => "Add_Given " ^ cterm'
207 | Del_Given cterm' => "Del_Given " ^ cterm'
208 | Add_Find cterm' => "Add_Find " ^ cterm'
209 | Del_Find cterm' => "Del_Find " ^ cterm'
210 | Add_Relation cterm' => "Add_Relation " ^ cterm'
211 | Del_Relation cterm' => "Del_Relation " ^ cterm'
213 | Specify_Theory domID => "Specify_Theory " ^ quote domID
214 | Specify_Problem pblID => "Specify_Problem " ^ strs2str pblID
215 | Specify_Method metID => "Specify_Method " ^ strs2str metID
216 | Apply_Method metID => "Apply_Method " ^ strs2str metID
217 | Check_Postcond pblID => "Check_Postcond " ^ strs2str pblID
218 | Free_Solve => "Free_Solve"
220 | Rewrite_Inst (subs, (id, thm)) =>
221 "Rewrite_Inst " ^ (pair2str (subs2str subs, spair2str (id, thm |> Thm.prop_of |> Rule.term2str)))
222 | Rewrite (id, thm) => "Rewrite " ^ 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 | _ => "input_to_string not impl. for ?!";
249 fun tac2IDstr ma = case ma of
250 Model_Problem => "Model_Problem"
251 | Refine_Tacitly _ => "Refine_Tacitly"
252 | Refine_Problem _ => "Refine_Problem"
253 | Add_Given _ => "Add_Given"
254 | Del_Given _ => "Del_Given"
255 | Add_Find _ => "Add_Find"
256 | Del_Find _ => "Del_Find"
257 | Add_Relation _ => "Add_Relation"
258 | Del_Relation _ => "Del_Relation"
260 | Specify_Theory _ => "Specify_Theory"
261 | Specify_Problem _ => "Specify_Problem"
262 | Specify_Method _ => "Specify_Method"
263 | Apply_Method _ => "Apply_Method"
264 | Check_Postcond _ => "Check_Postcond"
265 | Free_Solve => "Free_Solve"
267 | Rewrite_Inst _ => "Rewrite_Inst"
268 | Rewrite _ => "Rewrite"
269 | Rewrite_Set_Inst _ => "Rewrite_Set_Inst"
270 | Rewrite_Set _ => "Rewrite_Set"
271 | Detail_Set _ => "Detail_Set"
272 | Detail_Set_Inst _ => "Detail_Set_Inst"
273 | Derive _ => "Derive "
274 | Calculate _ => "Calculate "
275 | Substitute _ => "Substitute"
276 | Apply_Assumption _ => "Apply_Assumption"
279 | Take_Inst _ => "Take_Inst"
280 | Subproblem _ => "Subproblem"
281 | End_Subproblem => "End_Subproblem"
282 | CAScmd _ => "CAScmd"
284 | Check_elementwise _ => "Check_elementwise"
285 | Or_to_List => "Or_to_List "
286 | Collect_Trues => "Collect_Trues"
288 | Empty_Tac => "Empty_Tac"
290 | End_Proof' => "End_Proof'"
291 | _ => "input_to_string not impl. for ?!";
293 fun is_empty input = case input of Empty_Tac => true | _ => false
295 fun eq_tac (Rewrite (id1, _), Rewrite (id2, _)) = id1 = id2
296 | eq_tac (Rewrite_Inst (_, (id1, _)), Rewrite_Inst (_, (id2, _))) = id1 = id2
297 | eq_tac (Rewrite_Set id1, Rewrite_Set id2) = id1 = id2
298 | eq_tac (Rewrite_Set_Inst (_, id1), Rewrite_Set_Inst (_, id2)) = id1 = id2
299 | eq_tac (Calculate id1, Calculate id2) = id1 = id2
302 fun is_rewset (Rewrite_Set_Inst _) = true
303 | is_rewset (Rewrite_Set _) = true
304 | is_rewset _ = false;
305 fun is_rewtac (Rewrite _) = true
306 | is_rewtac (Rewrite_Inst _) = true
307 | is_rewtac input = is_rewset input;
310 fun rls_of (Rewrite_Set_Inst (_, rls)) = rls
311 | rls_of (Rewrite_Set rls) = rls
312 | rls_of input = error ("rls_of: called with input \"" ^ tac2IDstr input ^ "\"");
314 fun rule2tac thy _ (Rule.Num_Calc (opID, _)) = Calculate (assoc_calc thy opID)
315 | rule2tac _ [] (Rule.Thm thm'') = Rewrite thm''
316 | rule2tac _ subst (Rule.Thm thm'') =
317 Rewrite_Inst (Selem.subst2subs subst, thm'')
318 | rule2tac _ [] (Rule.Rls_ rls) = Rewrite_Set (Rule_Set.id_rls rls)
319 | rule2tac _ subst (Rule.Rls_ rls) =
320 Rewrite_Set_Inst (Selem.subst2subs subst, (Rule_Set.id_rls rls))
321 | rule2tac _ _ rule =
322 error ("rule2tac: called with \"" ^ Rule_Set.rule2str rule ^ "\"");
324 (* tactics for for internal use, compare "input" for user at the front-end.
325 tac_ contains results from check in 'fun applicable_in'.
326 This is useful for costly results, e.g. from rewriting;
327 however, these results might be changed by Scripts like
328 " eq = (Rewrite_Set ''ansatz_rls'' False) eql;" ^
329 " eq = (Rewrite_Set equival_trans False) eq;" ^
330 TODO.WN120106 ANALOGOUSLY TO Substitute':
331 So tac_ contains the term t the result was calculated from
332 in order to compare t with t' possibly changed by "Expr "
333 and re-calculate result if t<>t'
334 TODO.WN161219: replace *every* cterm' by term
337 Add_Find' of Rule.cterm' * Model.itm list | Add_Given' of Rule.cterm' * Model.itm list
338 | Add_Relation' of Rule.cterm' * Model.itm list
339 | Apply_Method' of (* creates the 1st step visible in a (sub-) comprising
340 * tactic Apply_Method metID
342 Celem.metID * (* key for KEStore *)
343 term option * (* the first formula of Calc.T. TODO: rm option *)
344 Istate_Def.T * (* for the newly started program *)
345 Proof.context (* for the newly started program *)
346 (*/--- TODO: re-design ? -----------------------------------------------------------------\*)
347 | Begin_Sequ' | Begin_Trans' of term
348 | Split_And' of term | Split_Or' of term | Split_Intersect' of term
349 | Conclude_And' of term | Conclude_Or' of term | Collect_Trues' of term
350 | End_Sequ' | End_Trans' of Selem.result
351 | End_Ruleset' of term | End_Intersect' of term | End_Proof''
352 (*\--- TODO: re-design ? -----------------------------------------------------------------/*)
354 | Calculate' of Rule.theory' * string * term * (term * Celem.thm')
355 | Check_Postcond' of Celem.pblID *
356 term (* returnvalue of program in solve *)
357 | Check_elementwise' of (* DEPRECATED, made idle for Calc.T in df00a2b5c4cc *)
358 term * (* (1) the current formula: [x=1,x=...] *)
359 string * (* (2) the pred from Check_elementwise *)
360 Selem.result (* (3) composed from (1) and (2): {x. pred} *)
361 | Del_Find' of Rule.cterm' | Del_Given' of Rule.cterm' | Del_Relation' of Rule.cterm'
363 | Derive' of Rule_Set.T
364 | Detail_Set' of Rule.theory' * bool * Rule_Set.T * term * Selem.result
365 | Detail_Set_Inst' of Rule.theory' * bool * Rule.subst * Rule_Set.T * term * Selem.result
366 | End_Detail' of Selem.result
371 | Init_Proof' of Rule.cterm' list * Celem.spec
372 | Model_Problem' of (* first step in specifying *)
373 Celem.pblID * (* key into KEStore *)
374 Model.itm list * (* the 'untouched' pbl *)
375 Model.itm list (* the casually completed met *)
376 | Or_to_List' of term * term
377 | Refine_Problem' of Celem.pblID * (Model.itm list * (bool * term) list)
379 Celem.pblID * (* input *)
380 Celem.pblID * (* the refined from applicable_in *)
381 Rule.domID * (* from new pbt?! filled in specify *)
382 Celem.metID * (* from new pbt?! filled in specify *)
383 Model.itm list (* drop ! 9.03: remains [] for Model_Problem recognizing its activation *)
384 | Rewrite' of Rule.theory' * Rule_Def.rew_ord' * Rule_Set.T * bool * Celem.thm'' * term * Selem.result
385 | Rewrite_Inst' of Rule.theory' * Rule_Def.rew_ord' * Rule_Set.T * bool * Rule.subst * Celem.thm'' * term * Selem.result
386 | Rewrite_Set' of Rule.theory' * bool * Rule_Set.T * term * Selem.result
387 | Rewrite_Set_Inst' of Rule.theory' * bool * Rule.subst * Rule_Set.T * term * Selem.result
389 | Specify_Method' of Celem.metID * Model.ori list * Model.itm list
390 | Specify_Problem' of Celem.pblID *
391 (bool * (* matches *)
392 (Model.itm list * (* ppc *)
393 (bool * term) list)) (* preconditions marked true/false *)
394 | Specify_Theory' of Rule.domID
397 (Model.ori list) * (* filled in associate Subproblem' *)
398 term * (* filled -"-, headline of calc-head *)
399 Selem.fmz_ * (* string list from arguments *)
400 Proof.context * (* for specify-phase *)
401 term (* Subproblem (thyID, pbl) OR cascmd *)
403 Rule_Def.rew_ord_ * (* for re-calculation *)
404 Rule_Set.T * (* for re-calculation *)
405 Selem.subte * (* the 'substitution': terms of type bool *)
406 term * (* to be substituted into *)
407 term (* resulting from the substitution *)
408 | Tac_ of theory * string * string * string
411 fun string_of ma = case ma of
412 Init_Proof' (ppc, spec) => "Init_Proof' " ^ pair2str (strs2str ppc, Celem.spec2str spec)
413 | Model_Problem' (pblID, _, _) => "Model_Problem' " ^ strs2str pblID
414 | Refine_Tacitly'(p, prefin, domID, metID, _) => "Refine_Tacitly' (" ^ strs2str p ^ ", " ^
415 strs2str prefin ^ ", " ^ domID ^ ", " ^ strs2str metID ^ ", pbl-itms)"
416 | Refine_Problem' _ => "Refine_Problem' (" ^ (*matchs2str ms*)"..." ^ ")"
417 | Add_Given' _ => "Add_Given' "(*^cterm'*)
418 | Del_Given' _ => "Del_Given' "(*^cterm'*)
419 | Add_Find' _ => "Add_Find' "(*^cterm'*)
420 | Del_Find' _ => "Del_Find' "(*^cterm'*)
421 | Add_Relation' _ => "Add_Relation' "(*^cterm'*)
422 | Del_Relation' _ => "Del_Relation' "(*^cterm'*)
424 | Specify_Theory' domID => "Specify_Theory' " ^ quote domID
425 | Specify_Problem' (pI, (ok, _)) => "Specify_Problem' " ^
426 spair2str (strs2str pI, spair2str (bool2str ok, spair2str ("itms2str_ itms", "items2str pre")))
427 | Specify_Method' (pI, oris, _) => "Specify_Method' (" ^
428 Celem.metID2str pI ^ ", " ^ Model.oris2str oris ^ ", )"
430 | Apply_Method' (metID, _, _, _) => "Apply_Method' " ^ strs2str metID
431 | Check_Postcond' (pblID, scval) => "Check_Postcond' " ^
432 (spair2str (strs2str pblID, Rule.term2str scval))
434 | Free_Solve' => "Free_Solve'"
436 | Rewrite_Inst' (*subs,thm'*) _ => "Rewrite_Inst' "(*^(pair2str (subs2str subs, spair2str thm'))*)
437 | Rewrite' _(*thm'*) => "Rewrite' "(*^(spair2str thm')*)
438 | Rewrite_Set_Inst' _(*subs,thm'*) => "Rewrite_Set_Inst' "(*^(pair2str (subs2str subs, quote rls))*)
439 | Rewrite_Set' (thy', pasm, rls', f, (f', asm)) => "Rewrite_Set' (" ^ thy' ^ "," ^ bool2str pasm ^
440 "," ^ Rule_Set.id_rls rls' ^ "," ^ Rule.term2str f ^ ",(" ^ Rule.term2str f' ^ "," ^ Rule.terms2str asm ^ "))"
441 | End_Detail' _ => "End_Detail' xxx"
442 | Detail_Set' _ => "Detail_Set' xxx"
443 | Detail_Set_Inst' _ => "Detail_Set_Inst' xxx"
445 | Derive' rls => "Derive' " ^ Rule_Set.id_rls rls
446 | Calculate' _ => "Calculate' "
447 | Substitute' _ => "Substitute' "(*^(subs2str subs)*)
449 | Take' _(*cterm'*) => "Take' "(*^(quote cterm' )*)
450 | Subproblem' _(*(spec, oris, _, _, _, pbl_form)*) =>
451 "Subproblem' "(*^(pair2str (domID, strs2str ,))*)
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_Set.id_rls rls)
472 | input_from_T (Detail_Set' (_, _, rls, _, _)) = Detail_Set (Rule_Set.id_rls rls)
474 | input_from_T (Rewrite_Set_Inst' (_, _, sub, rls, _, _)) =
475 Rewrite_Set_Inst (Selem.subst2subs sub, Rule_Set.id_rls rls)
476 | input_from_T (Detail_Set_Inst' (_, _, sub, rls, _, _)) =
477 Detail_Set_Inst (Selem.subst2subs sub, Rule_Set.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 = raise 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