src/Tools/isac/MathEngBasic/tactic.sml
author Walther Neuper <walther.neuper@jku.at>
Thu, 14 Nov 2019 12:08:05 +0100
changeset 59702 501a4ae08275
parent 59701 24273e0a6739
child 59704 178869f0f4ba
permissions -rw-r--r--
tuned
     1 (* Title:  Tactics; tac_ for interaction with frontend, input for internal use.
     2    Author: Walther Neuper 170121
     3    (c) due to copyright terms
     4 
     5 regular expression for search:
     6 
     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
     8 
     9 *)
    10 signature TACTIC =
    11 sig
    12   datatype T =
    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.T * Proof.context
    17 
    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''
    23 
    24   | CAScmd' of term
    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'
    29 
    30   | Derive' of Rule.rls
    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
    34 
    35   | Empty_Tac_
    36   | Free_Solve'
    37 
    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
    43 
    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
    49 
    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 tac_2str : T -> string
    58 
    59   datatype input =
    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'
    71   | Calculate of string
    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'
    75 
    76   | Derive of Rule.rls'
    77   | Detail_Set of Rule.rls'
    78   | Detail_Set_Inst of Selem.subs * Rule.rls'
    79   | End_Detail
    80 
    81   | Empty_Tac
    82   | Free_Solve
    83 
    84   | Init_Proof of Rule.cterm' list * Celem.spec
    85   | Model_Problem
    86   | Or_to_List
    87   | Refine_Problem of Celem.pblID
    88   | Refine_Tacitly of Celem.pblID
    89 
    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'
    95 
    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
   100 
   101   | Substitute of Selem.sube
   102   | Tac of string
   103   | Take of Rule.cterm' | Take_Inst of Rule.cterm'
   104   val tac2str : input -> string
   105 
   106   val eq_tac : input * input -> bool                                              (* for script.sml *)
   107   val is_empty_tac : input -> bool                                              (* also for tests *)
   108   val is_rewtac : input -> bool                                              (* for interface.sml *)
   109   val is_rewset : input -> bool                                             (* for mathengine.sml *)
   110   val rls_of : input -> Rule.rls'                                               (* for solve.sml *)
   111   val tac2IDstr : input -> string
   112   val rule2tac : theory -> (term * term) list ->  Rule.rule -> input         (* for rewtools.sml *)
   113 (* ---- for tests only: shifted from below to remove the Warning "unused" at fun.def. --------- *)
   114   (* NONE *)
   115 (*/-------------------------------------------------------- ! aktivate for Test_Isac BEGIN ---\* )
   116   (* NONE *)
   117 ( *\--- ! aktivate for Test_Isac END ----------------------------------------------------------/*)
   118 
   119 (*----- unused code, kept as hints to design ideas ---------------------------------------------*)
   120   (* NONE *)
   121 end
   122 
   123 structure Tactic(**): TACTIC(**) =
   124 struct
   125 
   126 (* tactics for user at front-end.
   127    input propagates the construction of the calc-tree;
   128    there are
   129    (a) 'specsteps' for the specify-phase, and others for the solve-phase
   130    (b) those of the solve-phase are 'initac's and others;
   131        initacs start with a formula different from the preceding formula.
   132    see 'type tac_' for the internal representation of tactics
   133 *)
   134 datatype input =
   135     Add_Find of Rule.cterm' | Add_Given of Rule.cterm' | Add_Relation of Rule.cterm'
   136   | Apply_Assumption of Rule.cterm' list
   137   | Apply_Method of Celem.metID
   138     (* creates an "istate" in PblObj.env; in case of "init_form" 
   139       creates a formula at ((lev_on o lev_dn) p, Frm) and in this "ppobj.loc"
   140       a "SOME istate" at fst of "loc".
   141       As each step (in the solve-phase) has a resulting formula (at the front-end)
   142       Apply_Method also does the 1st step in the script (an "initac") if there is no "init_form" *)  
   143   (*/--- TODO: re-design ? -----------------------------------------------------------------\*)
   144   | Begin_Sequ | Begin_Trans
   145   | Split_And | Split_Or | Split_Intersect
   146   | Conclude_And | Conclude_Or | Collect_Trues
   147   | End_Sequ | End_Trans
   148   | End_Ruleset | End_Subproblem (* WN0509 drop *) | End_Intersect | End_Proof'
   149   (*\--- TODO: re-design ? -----------------------------------------------------------------/*)
   150   | CAScmd of Rule.cterm'
   151   | Calculate of string
   152   | Check_Postcond of Celem.pblID
   153   | Check_elementwise of Rule.cterm'
   154   | Del_Find of Rule.cterm' | Del_Given of Rule.cterm' | Del_Relation of Rule.cterm'
   155 
   156   | Derive of Rule.rls'                 (* WN0509 drop *)
   157   | Detail_Set of Rule.rls'             (* WN0509 drop *)
   158   | Detail_Set_Inst of Selem.subs * Rule.rls' (* WN0509 drop *)
   159   | End_Detail                     (* WN0509 drop *)
   160 
   161   | Empty_Tac
   162   | Free_Solve
   163 
   164   | Init_Proof of Rule.cterm' list * Celem.spec
   165   | Model_Problem
   166   | Or_to_List
   167   | Refine_Problem of Celem.pblID
   168   | Refine_Tacitly of Celem.pblID
   169 
   170    (* rewrite-tactics can transport a (thmID, thm) to and (!) from the java-front-end
   171      because there all the thms are present with both (thmID, thm)
   172      (where user-views can show both or only one of (thmID, thm)),
   173      and thm is created from ThmID by assoc_thm'' when entering isabisac *)
   174   | Rewrite of Celem.thm''
   175   | Rewrite_Asm of Celem.thm''
   176   | Rewrite_Inst of Selem.subs * Celem.thm''
   177   | Rewrite_Set of Rule.rls'
   178   | Rewrite_Set_Inst of Selem.subs * Rule.rls'
   179 
   180   | Specify_Method of Celem.metID
   181   | Specify_Problem of Celem.pblID
   182   | Specify_Theory of Rule.domID
   183   | Subproblem of Rule.domID * Celem.pblID (* WN0509 drop *)
   184 
   185   | Substitute of Selem.sube
   186   | Tac of string               (* WN0509 drop *)
   187   | Take of Rule.cterm' | Take_Inst of Rule.cterm'
   188 
   189 fun tac2str ma = case ma of
   190     Init_Proof (ppc, spec)  => 
   191       "Init_Proof "^(pair2str (strs2str ppc, Celem.spec2str spec))
   192   | Model_Problem           => "Model_Problem "
   193   | Refine_Tacitly pblID    => "Refine_Tacitly " ^ strs2str pblID 
   194   | Refine_Problem pblID    => "Refine_Problem " ^ strs2str pblID 
   195   | Add_Given cterm'        => "Add_Given " ^ cterm'
   196   | Del_Given cterm'        => "Del_Given " ^ cterm'
   197   | Add_Find cterm'         => "Add_Find " ^ cterm'
   198   | Del_Find cterm'         => "Del_Find " ^ cterm'
   199   | Add_Relation cterm'     => "Add_Relation " ^ cterm'
   200   | Del_Relation cterm'     => "Del_Relation " ^ cterm'
   201 
   202   | Specify_Theory domID    => "Specify_Theory " ^ quote domID
   203   | Specify_Problem pblID   => "Specify_Problem " ^ strs2str pblID
   204   | Specify_Method metID    => "Specify_Method " ^ strs2str metID
   205   | Apply_Method metID      => "Apply_Method " ^ strs2str metID
   206   | Check_Postcond pblID    => "Check_Postcond " ^ strs2str pblID
   207   | Free_Solve              => "Free_Solve"
   208 
   209   | Rewrite_Inst (subs, (id, thm)) =>
   210     "Rewrite_Inst " ^ (pair2str (subs2str subs, spair2str (id, thm |> Thm.prop_of |> Rule.term2str)))
   211   | Rewrite (id, thm) => "Rewrite " ^ spair2str (id, thm |> Thm.prop_of |> Rule.term2str)
   212   | Rewrite_Asm (id, thm) => "Rewrite_Asm " ^ spair2str (id, thm |> Thm.prop_of |> Rule.term2str)
   213   | Rewrite_Set_Inst (subs, rls) => 
   214     "Rewrite_Set_Inst " ^ pair2str (subs2str subs, quote rls)
   215   | Rewrite_Set rls         => "Rewrite_Set " ^ quote rls
   216   | Detail_Set rls          => "Detail_Set " ^ quote rls
   217   | Detail_Set_Inst (subs, rls) =>  "Detail_Set_Inst " ^ pair2str (subs2str subs, quote rls)
   218   | End_Detail              => "End_Detail"
   219   | Derive rls'             => "Derive " ^ rls' 
   220   | Calculate op_           => "Calculate " ^ op_ 
   221   | Substitute sube         => "Substitute " ^ Selem.sube2str sube	     
   222   | Apply_Assumption ct's   => "Apply_Assumption " ^ strs2str ct's
   223 
   224   | Take cterm'             => "Take " ^ quote cterm'
   225   | Take_Inst cterm'        => "Take_Inst " ^ quote cterm'
   226   | Subproblem (domID, pblID) => "Subproblem " ^ pair2str (domID, strs2str pblID)
   227   | End_Subproblem          => "End_Subproblem"
   228   | CAScmd cterm'           => "CAScmd " ^ quote cterm'
   229 
   230   | Check_elementwise cterm'=> "Check_elementwise " ^ quote cterm'
   231   | Or_to_List              => "Or_to_List "
   232   | Collect_Trues           => "Collect_Trues"
   233 
   234   | Empty_Tac               => "Empty_Tac"
   235   | Tac string              => "Tac " ^ string
   236   | End_Proof'              => "input End_Proof'"
   237   | _                       => "tac2str not impl. for ?!";
   238 
   239 fun is_empty_tac input = case input of Empty_Tac => true | _ => false
   240 
   241 fun eq_tac (Rewrite (id1, _), Rewrite (id2, _)) = id1 = id2
   242   | eq_tac (Rewrite_Inst (_, (id1, _)), Rewrite_Inst (_, (id2, _))) = id1 = id2
   243   | eq_tac (Rewrite_Set id1, Rewrite_Set id2) = id1 = id2
   244   | eq_tac (Rewrite_Set_Inst (_, id1), Rewrite_Set_Inst (_, id2)) = id1 = id2
   245   | eq_tac (Calculate id1, Calculate id2) = id1 = id2
   246   | eq_tac _ = false
   247 
   248 fun is_rewset (Rewrite_Set_Inst _) = true
   249   | is_rewset (Rewrite_Set _) = true 
   250   | is_rewset _ = false;
   251 fun is_rewtac (Rewrite _) = true
   252   | is_rewtac (Rewrite_Inst _) = true
   253   | is_rewtac (Rewrite_Asm _) = true
   254   | is_rewtac input = is_rewset input;
   255 
   256 fun tac2IDstr ma = case ma of
   257     Model_Problem => "Model_Problem"
   258   | Refine_Tacitly _ => "Refine_Tacitly"
   259   | Refine_Problem _ => "Refine_Problem"
   260   | Add_Given _ => "Add_Given"
   261   | Del_Given _ => "Del_Given"
   262   | Add_Find _ => "Add_Find"
   263   | Del_Find _ => "Del_Find"
   264   | Add_Relation _ => "Add_Relation"
   265   | Del_Relation _ => "Del_Relation"
   266 
   267   | Specify_Theory _ => "Specify_Theory"
   268   | Specify_Problem _ => "Specify_Problem"
   269   | Specify_Method _ => "Specify_Method"
   270   | Apply_Method _ => "Apply_Method"
   271   | Check_Postcond _ => "Check_Postcond"
   272   | Free_Solve => "Free_Solve"
   273 
   274   | Rewrite_Inst _ => "Rewrite_Inst"
   275   | Rewrite _ => "Rewrite"
   276   | Rewrite_Asm _ => "Rewrite_Asm"
   277   | Rewrite_Set_Inst _ => "Rewrite_Set_Inst"
   278   | Rewrite_Set _ => "Rewrite_Set"
   279   | Detail_Set _ => "Detail_Set"
   280   | Detail_Set_Inst _ => "Detail_Set_Inst"
   281   | Derive _ => "Derive "
   282   | Calculate _ => "Calculate "
   283   | Substitute _ => "Substitute" 
   284   | Apply_Assumption _ => "Apply_Assumption"
   285 
   286   | Take _ => "Take"
   287   | Take_Inst _ => "Take_Inst"
   288   | Subproblem _ => "Subproblem"
   289   | End_Subproblem => "End_Subproblem"
   290   | CAScmd _ => "CAScmd"
   291 
   292   | Check_elementwise _ => "Check_elementwise"
   293   | Or_to_List => "Or_to_List "
   294   | Collect_Trues => "Collect_Trues"
   295 
   296   | Empty_Tac => "Empty_Tac"
   297   | Tac _ => "Tac "
   298   | End_Proof' => "End_Proof'"
   299   | _ => "tac2str not impl. for ?!";
   300 
   301 fun rls_of (Rewrite_Set_Inst (_, rls)) = rls
   302   | rls_of (Rewrite_Set rls) = rls
   303   | rls_of input = error ("rls_of: called with input \"" ^ tac2IDstr input ^ "\"");
   304 
   305 fun rule2tac thy _ (Rule.Calc (opID, _)) = Calculate (assoc_calc thy opID)
   306   | rule2tac _ [] (Rule.Thm thm'') = Rewrite thm''
   307   | rule2tac _ subst (Rule.Thm thm'') = 
   308     Rewrite_Inst (Selem.subst2subs subst, thm'')
   309   | rule2tac _ [] (Rule.Rls_ rls) = Rewrite_Set (Rule.id_rls rls)
   310   | rule2tac _ subst (Rule.Rls_ rls) = 
   311     Rewrite_Set_Inst (Selem.subst2subs subst, (Rule.id_rls rls))
   312   | rule2tac _ _ rule = 
   313     error ("rule2tac: called with \"" ^ Rule.rule2str rule ^ "\"");
   314 
   315 (* tactics for for internal use, compare "input" for user at the front-end.
   316   tac_ contains results from check in 'fun applicable_in'.
   317   This is useful for costly results, e.g. from rewriting;
   318   however, these results might be changed by Scripts like
   319       "      eq = (Rewrite_Set ''ansatz_rls'' False) eql;" ^
   320       "      eq = (Rewrite_Set equival_trans False) eq;" ^
   321   TODO.WN120106 ANALOGOUSLY TO Substitute':
   322   So tac_ contains the term t the result was calculated from
   323   in order to compare t with t' possibly changed by "Expr "
   324   and re-calculate result if t<>t'
   325   TODO.WN161219: replace *every* cterm' by term
   326 *)
   327   datatype T =
   328     Add_Find' of Rule.cterm' * Model.itm list | Add_Given' of Rule.cterm' * Model.itm list 
   329   | Add_Relation' of Rule.cterm' * Model.itm list
   330   | Apply_Assumption' of term list * term
   331   | Apply_Method' of Celem.metID * term option * Istate.T * Proof.context
   332   (*/--- TODO: re-design ? -----------------------------------------------------------------\*)
   333   | Begin_Sequ' | Begin_Trans' of term
   334   | Split_And' of term | Split_Or' of term | Split_Intersect' of term
   335   | Conclude_And' of term | Conclude_Or' of term | Collect_Trues' of term
   336   | End_Sequ' | End_Trans' of Selem.result
   337   | End_Ruleset' of term | End_Subproblem' of term | End_Intersect' of term | End_Proof''
   338   (*\--- TODO: re-design ? -----------------------------------------------------------------/*)
   339   | CAScmd' of term
   340   | Calculate' of Rule.theory' * string * term * (term * Celem.thm')
   341   | Check_Postcond' of Celem.pblID *
   342     Selem.result (* returnvalue of script in solve *)
   343   | Check_elementwise' of (*special case:*)
   344     term *       (* (1) the current formula: [x=1,x=...]     *)
   345     string *     (* (2) the pred from Check_elementwise      *)
   346     Selem.result (* (3) composed from (1) and (2): {x. pred} *)
   347   | Del_Find' of Rule.cterm' | Del_Given' of Rule.cterm' | Del_Relation' of Rule.cterm'
   348 
   349   | Derive' of Rule.rls
   350   | Detail_Set' of Rule.theory' * bool * Rule.rls * term * Selem.result
   351   | Detail_Set_Inst' of Rule.theory' * bool * Rule.subst * Rule.rls * term * Selem.result
   352   | End_Detail' of Selem.result
   353 
   354   | Empty_Tac_
   355   | Free_Solve'
   356 
   357   | Init_Proof' of Rule.cterm' list * Celem.spec
   358   | Model_Problem' of Celem.pblID * 
   359     Model.itm list *  (* the 'untouched' pbl        *)
   360     Model.itm list    (* the casually completed met *)
   361   | Or_to_List' of term * term
   362   | Refine_Problem' of Celem.pblID * (Model.itm list * (bool * term) list)
   363   | Refine_Tacitly' of
   364     Celem.pblID *     (* input*)
   365     Celem.pblID *     (* the refined from applicable_in                                       *)
   366     Rule.domID *     (* from new pbt?! filled in specify                                     *)
   367     Celem.metID *     (* from new pbt?! filled in specify                                     *)
   368     Model.itm list    (* drop ! 9.03: remains [] for Model_Problem recognizing its activation *)
   369   | Rewrite' of Rule.theory' * Rule.rew_ord' * Rule.rls * bool * Celem.thm'' * term * Selem.result
   370   | Rewrite_Asm' of Rule.theory' * Rule.rew_ord' * Rule.rls * bool * Celem.thm'' * term * Selem.result
   371   | Rewrite_Inst' of Rule.theory' * Rule.rew_ord' * Rule.rls * bool * Rule.subst * Celem.thm'' * term * Selem.result
   372   | Rewrite_Set' of Rule.theory' * bool * Rule.rls * term * Selem.result
   373   | Rewrite_Set_Inst' of Rule.theory' * bool * Rule.subst * Rule.rls * term * Selem.result
   374 
   375   | Specify_Method' of Celem.metID * Model.ori list * Model.itm list
   376   | Specify_Problem' of Celem.pblID * 
   377     (bool *                  (* matches	                                  *)
   378       (Model.itm list *      (* ppc	                                      *)
   379         (bool * term) list)) (* preconditions                             *)
   380   | Specify_Theory' of Rule.domID
   381   | Subproblem' of
   382     Celem.spec * 
   383 		(Model.ori list) *       (* filled in associate Subproblem'           *)
   384 		term *                   (* filled -"-, headline of calc-head         *)
   385 		Selem.fmz_ *             
   386     Proof.context *          (* DEPRECATED shifted into loc for all ppobj *)
   387 		term                     (* Subproblem (thyID, pbl) OR cascmd         *)  
   388   | Substitute' of           
   389     Rule.rew_ord_ *          (* for re-calculation                        *)
   390     Rule.rls *               (* for re-calculation                        *)
   391     Selem.subte *            (* the 'substitution': terms of type bool    *)
   392     term *                   (* to be substituted into                    *)
   393     term                     (* resulting from the substitution           *)
   394   | Tac_ of theory * string * string * string
   395   | Take' of term | Take_Inst' of term
   396 
   397 fun tac_2str ma = case ma of
   398     Init_Proof' (ppc, spec)  => "Init_Proof' " ^ pair2str (strs2str ppc, Celem.spec2str spec)
   399   | Model_Problem' (pblID, _, _) => "Model_Problem' " ^ strs2str pblID
   400   | Refine_Tacitly'(p, prefin, domID, metID, _) => "Refine_Tacitly' (" ^ strs2str p ^ ", " ^
   401     strs2str prefin ^ ", " ^ domID ^ ", " ^ strs2str metID ^ ", pbl-itms)"
   402   | Refine_Problem' _ => "Refine_Problem' (" ^ (*matchs2str ms*)"..." ^ ")"
   403   | Add_Given' _ => "Add_Given' "(*^cterm'*)
   404   | Del_Given' _ => "Del_Given' "(*^cterm'*)
   405   | Add_Find' _ => "Add_Find' "(*^cterm'*)
   406   | Del_Find' _ => "Del_Find' "(*^cterm'*)
   407   | Add_Relation' _ => "Add_Relation' "(*^cterm'*)
   408   | Del_Relation' _ => "Del_Relation' "(*^cterm'*)
   409 
   410   | Specify_Theory' domID => "Specify_Theory' " ^ quote domID
   411   | Specify_Problem' (pI, (ok, _)) =>  "Specify_Problem' " ^ 
   412     spair2str (strs2str pI, spair2str (bool2str ok, spair2str ("itms2str_ itms", "items2str pre")))
   413   | Specify_Method' (pI, oris, _) => "Specify_Method' (" ^ 
   414     Celem.metID2str pI ^ ", " ^ Model.oris2str oris ^ ", )"
   415 
   416   | Apply_Method' (metID, _, _, _) => "Apply_Method' " ^ strs2str metID
   417   | Check_Postcond' (pblID, (scval, asm)) => "Check_Postcond' " ^
   418       (spair2str (strs2str pblID, spair2str (Rule.term2str scval, Rule.terms2str asm)))
   419 
   420   | Free_Solve' => "Free_Solve'"
   421 
   422   | Rewrite_Inst' (*subs,thm'*) _ => "Rewrite_Inst' "(*^(pair2str (subs2str subs, spair2str thm'))*)
   423   | Rewrite' _(*thm'*) => "Rewrite' "(*^(spair2str thm')*)
   424   | Rewrite_Asm' _(*thm'*) => "Rewrite_Asm' "(*^(spair2str thm')*)
   425   | Rewrite_Set_Inst' _(*subs,thm'*) => "Rewrite_Set_Inst' "(*^(pair2str (subs2str subs, quote rls))*)
   426   | Rewrite_Set' (thy', pasm, rls', f, (f', asm)) => "Rewrite_Set' (" ^ thy' ^ "," ^ bool2str pasm ^
   427     "," ^ Rule.id_rls rls' ^ "," ^ Rule.term2str f ^ ",(" ^ Rule.term2str f' ^ "," ^ Rule.terms2str asm ^ "))"
   428   | End_Detail' _ => "End_Detail' xxx"
   429   | Detail_Set' _ => "Detail_Set' xxx"
   430   | Detail_Set_Inst' _ => "Detail_Set_Inst' xxx"
   431 
   432   | Derive' rls => "Derive' " ^ Rule.id_rls rls
   433   | Calculate'  _ => "Calculate' "
   434   | Substitute' _ => "Substitute' "(*^(subs2str subs)*)    
   435   | Apply_Assumption' _(* ct's*) => "Apply_Assumption' "(*^(strs2str ct's)*)
   436 
   437   | Take' _(*cterm'*) => "Take' "(*^(quote cterm'	)*)
   438   | Take_Inst' _(*cterm'*) => "Take_Inst' "(*^(quote cterm' )*)
   439   | Subproblem' _(*(spec, oris, _, _, _, pbl_form)*) => 
   440     "Subproblem' "(*^(pair2str (domID, strs2str ,))*)
   441   | End_Subproblem' _ => "End_Subproblem'"
   442   | CAScmd' _(*cterm'*) => "CAScmd' "(*^(quote cterm')*)
   443 
   444   | Empty_Tac_ => "Empty_Tac_"
   445   | Tac_ (_, form, id, result) => "Tac_ (thy," ^ form ^ "," ^ id ^ "," ^ result ^ ")"
   446   | _  => "tac_2str not impl. for arg";
   447 
   448 end