test/Tools/isac/Minisubpbl/200-start-method-NEXT_STEP.sml
author wneuper <Walther.Neuper@jku.at>
Wed, 25 Oct 2023 12:34:12 +0200
changeset 60760 3b173806efe2
parent 60758 5319a8dc84f5
child 60769 0df0759fed26
permissions -rw-r--r--
prepare 12: M_Model.match_itms_oris takes Position.T and new max_mariants

some tests are outcommented until <broken elementwise input to lists> is repaired alltogether
walther@59781
     1
(* Title:  "Minisubpbl/200-start-method-NEXT_STEP.sml"
walther@59781
     2
   Author: Walther Neuper 1105
walther@59781
     3
   (c) copyright due to lincense terms.
walther@59781
     4
*)
walther@59781
     5
Walther@60710
     6
open Ctree;
Walther@60596
     7
open Pos;
Walther@60596
     8
open TermC;
Walther@60710
     9
open Istate;
Walther@60710
    10
open Tactic;
Walther@60710
    11
open I_Model;
Walther@60710
    12
open Pre_Conds;
Walther@60710
    13
open Rewrite;
Walther@60710
    14
open Step;
Walther@60710
    15
open LItool;
Walther@60710
    16
open LI;
Walther@60596
    17
walther@59781
    18
"----------- Minisubplb/200-start-method-NEXT_STEP.sml ---------------------------------------";
walther@59781
    19
"----------- Minisubplb/200-start-method-NEXT_STEP.sml ---------------------------------------";
walther@59781
    20
"----------- Minisubplb/200-start-method-NEXT_STEP.sml ---------------------------------------";
Walther@60712
    21
tracing "--- Minisubplb/200-start-method-NEXT_STEP.sml ---------------------------------------";
walther@59997
    22
val fmz = ["equality (x+1=(2::real))", "solveFor x", "solutions L"];
walther@59781
    23
val (dI',pI',mI') =
walther@59997
    24
  ("Test", ["sqroot-test", "univariate", "equation", "test"],
walther@59997
    25
   ["Test", "squ-equ-test-subpbl1"]);
Walther@60571
    26
val (p,_,f,nxt,_,pt) = Test_Code.init_calc @{context} [(fmz, (dI',pI',mI'))];
Walther@60725
    27
(*[], Pbl*)val (_, ([(tac, _, _)], _, (pt, p))) = Step.do_next p ((pt, e_pos'), []); val Model_Problem = tac
Walther@60725
    28
(*[], Pbl*)val (_, ([(tac, _, _)], _, (pt, p))) = Step.do_next p ((pt, e_pos'), []); val Specify_Theory "Test" = tac
Walther@60725
    29
(*[], Pbl*)val (_, ([(tac, _, _)], _, (pt, p))) = Step.do_next p ((pt, e_pos'), []); val Specify_Problem ["sqroot-test", "univariate", "equation", "test"] = tac
Walther@60682
    30
Walther@60682
    31
(*[], Met*)val return_Step_do_next_Specify_Problem = Step.do_next p ((pt, e_pos'), []);(*Specify_Method ["Test", "squ-equ-test-subpbl1"]*)
Walther@60682
    32
(*/------------------- step into Step.do_next_Specify_Problem ------------------------------\\*)
Walther@60682
    33
"~~~~~ fun do_next , args:"; val ((ip as (_, p_)), (ptp as (pt, p), tacis)) =
Walther@60682
    34
  (p, ((pt, e_pos'), []));
Walther@60682
    35
  (*if*) Pos.on_calc_end ip (*else*);
Walther@60682
    36
      val (_, probl_id, _) = Calc.references (pt, p);
Walther@60682
    37
val _ =
Walther@60682
    38
      (*case*) tacis (*of*);
Walther@60682
    39
        (*if*) probl_id = Problem.id_empty (*else*);
Walther@60682
    40
Walther@60682
    41
      Step.switch_specify_solve p_ (pt, ip);
Walther@60682
    42
"~~~~~ fun switch_specify_solve , args:"; val (state_pos, (pt, input_pos)) = (p_, (pt, ip));
Walther@60682
    43
      (*if*) Pos.on_specification ([], state_pos) (*then*);
Walther@60682
    44
Walther@60682
    45
      Step.specify_do_next (pt, input_pos);
Walther@60682
    46
"~~~~~ fun specify_do_next , args:"; val ((ptp as (pt, (p, p_)))) = ((pt, input_pos));
Walther@60682
    47
    val (_, (p_', tac)) = Specify.find_next_step ptp
Walther@60682
    48
    val ist_ctxt =  Ctree.get_loc pt (p, p_)
Walther@60682
    49
val _ =
Walther@60682
    50
    (*case*) tac (*of*);
Walther@60682
    51
Walther@60682
    52
Step_Specify.by_tactic_input tac (pt, (p, p_'));
Walther@60682
    53
"~~~~~ fun by_tactic_input , args:"; val ((Tactic.Specify_Method id), (pt, pos)) =
Walther@60682
    54
  (tac, (pt, (p, p_')));
Walther@60682
    55
Walther@60682
    56
      val (o_model, ctxt, i_model) =
Walther@60682
    57
Specify_Step.complete_for id (pt, pos);
Walther@60682
    58
"~~~~~ fun complete_for , args:"; val (mID, (ctree, pos)) = (id, (pt, pos));
Walther@60760
    59
    val {origin = (o_model, o_refs, _), spec = refs, probl = i_prob, meth = met_imod, ctxt,
Walther@60682
    60
       ...} = Calc.specify_data (ctree, pos);
Walther@60760
    61
    val ctxt = Ctree.get_ctxt ctree pos
Walther@60760
    62
    val (dI, _, _) = References.select_input o_refs refs;
Walther@60682
    63
    val {model = m_patt, where_, where_rls, ...} = MethodC.from_store ctxt mID
Walther@60682
    64
    val {origin = (root_model, _, _), ...} = Calc.specify_data (ctree, ([], Pos.Und))
Walther@60682
    65
    val (o_model', ctxt') = O_Model.complete_for m_patt root_model (o_model, ctxt)
Walther@60682
    66
Walther@60760
    67
    val (_, (i_model, _)) = 
Walther@60760
    68
   M_Match.match_itms_oris ctxt o_model' (I_Model.OLD_to_TEST i_prob,
Walther@60760
    69
                            I_Model.OLD_to_TEST i_prob) (m_patt, where_, where_rls);
Walther@60682
    70
"~~~~~ fun match_itms_oris , args:"; val (ctxt, pbl, (pbt, where_, where_rls), oris) =
Walther@60682
    71
  (ctxt, i_prob, (m_patt, where_, where_rls), o_model');
Walther@60705
    72
 (*0*)val mv = Pre_Conds.max_variant pbl;
Walther@60682
    73
Walther@60682
    74
      fun eqdsc_pbt_itm ((_,(d,_))) (_, _, _, _, itm_) = d = I_Model.descriptor itm_;
Walther@60682
    75
      fun notmem pbl pbt1 = case find_first (eqdsc_pbt_itm pbt1) pbl of
Walther@60682
    76
				SOME _ => false | NONE => true;
Walther@60682
    77
 (*1*)val mis = (filter (notmem pbl)) pbt;
Walther@60730
    78
Walther@60682
    79
      fun eqdsc_ori (_,(d,_)) (_, _, _, d', _) = d = d';
Walther@60682
    80
      fun ori2itmMis (f, (d, pid)) (i, v, _, _, _) = (i, v, false, f, I_Model.Mis (d, pid));
Walther@60682
    81
 (*2*)fun oris2itms oris mis1 = ((map (ori2itmMis mis1)) o (filter (eqdsc_ori mis1))) oris;
Walther@60682
    82
      val news = (flat o (map (oris2itms oris))) mis;
Walther@60682
    83
 (*3*)fun mem_vat (_, vats, _, _, _) = member op = vats mv;
Walther@60682
    84
      val newitms = filter mem_vat news;
Walther@60682
    85
 (*4*)val itms' = pbl @ newitms;
Walther@60682
    86
Walther@60741
    87
      val (pb, where_') = Pre_Conds.check ctxt where_rls where_ 
Walther@60730
    88
        (pbt, I_Model.OLD_to_TEST itms');
Walther@60741
    89
"~~~~~ fun check , args:"; val (ctxt, where_rls, where_, (model_patt, i_model)) =
Walther@60730
    90
  (ctxt, where_rls, where_, (pbt, I_Model.OLD_to_TEST itms'));
Walther@60758
    91
      val (env_model, (env_subst, env_eval)) = make_environments model_patt i_model
Walther@60730
    92
      val pres_subst = map (TermC.subst_atomic_all env_subst) where_;
Walther@60730
    93
      val pres_subst_other = map (TermC.subst_atomic_all env_model) (map #2 pres_subst);
Walther@60730
    94
      val full_subst = if env_eval = [] then pres_subst_other
Walther@60730
    95
        else map (TermC.subst_atomic_all env_eval) (map #2 pres_subst_other)
Walther@60682
    96
Walther@60730
    97
(*+*)val "Test" = ctxt |> Proof_Context.theory_of |> ThyC.id_of
Walther@60682
    98
(*+*)val Rule_Set.Repeat {id = "prls_met_test_squ_sub", ...} = where_rls
Walther@60730
    99
(*+*)val [(true, tTEST as Const ("Test.precond_rootmet", _) $ Free ("x", xxx))] = full_subst
Walther@60682
   100
Walther@60682
   101
(*+*)val ctxt = Config.put rewrite_trace true ctxt;
Walther@60682
   102
      val evals = map (
Walther@60731
   103
 Pre_Conds.eval ctxt where_rls) full_subst;
Walther@60705
   104
(* (*declare [[rewrite_trace = true]]*)
Walther@60682
   105
@## rls: prls_met_test_squ_sub on: precond_rootmet x 
Walther@60682
   106
@### try calc: "Test.precond_rootmet" 
Walther@60682
   107
@#### eval asms: "(precond_rootmet x) = True" 
Walther@60682
   108
@### calc. to: True 
Walther@60682
   109
@### try calc: "Test.precond_rootmet" 
Walther@60682
   110
@### try calc: "Test.precond_rootmet" 
Walther@60682
   111
*)
Walther@60682
   112
(*+*)val ctxt = Config.put rewrite_trace false ctxt;
Walther@60682
   113
Walther@60682
   114
"~~~~~ fun eval_precond_rootmet , args:"; val ((thmid:string), _, (t as (Const (\<^const_name>\<open>Test.precond_rootmet\<close>, _) $ arg)), ctxt) =
Walther@60682
   115
  ("aaa", "bbb", tTEST, ctxt);
Walther@60682
   116
    SOME (TermC.mk_thmid thmid (UnparseC.term ctxt arg) "",
Walther@60682
   117
      HOLogic.Trueprop $ (TermC.mk_equality (t, @{term True})))
Walther@60682
   118
;
Walther@60682
   119
    (TermC.mk_thmid thmid (UnparseC.term ctxt arg)) "";
Walther@60682
   120
"~~~~~ fun mk_thmid , args:"; val (thmid, n1, n2) = (thmid, (UnparseC.term ctxt arg), "");
Walther@60682
   121
  thmid ^ (cut_longid n1) ^ "_" ^ (cut_longid n2);
Walther@60682
   122
Walther@60682
   123
      (cut_longid n2);
Walther@60682
   124
"~~~~~ fun cut_longid , args:"; val (dn) = (n2);
Walther@60682
   125
(*\------------------- step into Step.do_next_Specify_Problem ------------------------------//*)
Walther@60725
   126
val (_, ([(tac, _, _)], _, (pt, p))) = return_Step_do_next_Specify_Problem; val Specify_Method ["Test", "squ-equ-test-subpbl1"] = tac;
Walther@60710
   127
Walther@60710
   128
(*[1], Frm*)val return_Step_do_next_Specify_Method = Step.do_next p ((pt, e_pos'), []);(*Apply_Method ["Test", "squ-equ-test-subpbl1"]*)
Walther@60710
   129
(*/------------------- step into Specify_Method --------------------------------------------\\*)
Walther@60710
   130
"~~~~~ fun do_next , args:"; val ((ip as (_, p_)), (ptp as (pt, p), tacis)) =
Walther@60710
   131
  (p, ((pt, e_pos'), []));
Walther@60710
   132
  (*if*) Pos.on_calc_end ip (*else*);
Walther@60710
   133
      val (_, probl_id, _) = Calc.references (pt, p);
Walther@60710
   134
val _ =
Walther@60710
   135
      (*case*) tacis (*of*);
Walther@60710
   136
        (*if*) probl_id = Problem.id_empty (*else*);
Walther@60710
   137
Walther@60710
   138
           switch_specify_solve p_ (pt, ip);
Walther@60710
   139
"~~~~~ fun switch_specify_solve , args:"; val (state_pos, (pt, input_pos)) = (p_, (pt, ip));
Walther@60710
   140
      (*if*) Pos.on_specification ([], state_pos) (*then*);
Walther@60710
   141
Walther@60710
   142
           specify_do_next (pt, input_pos);
Walther@60710
   143
"~~~~~ fun specify_do_next , args:"; val (ptp as (pt, (p, p_))) = (pt, input_pos);
Walther@60710
   144
    val (_, (p_', tac)) = Specify.find_next_step ptp
Walther@60710
   145
    val ist_ctxt =  Ctree.get_loc pt (p, p_)
Walther@60710
   146
(*+*)val Tactic.Apply_Method mI =
Walther@60710
   147
    (*case*) tac (*of*);
Walther@60710
   148
Walther@60710
   149
  	    LI.by_tactic (Tactic.Apply_Method' (mI, NONE, Istate.empty, ContextC.empty))
Walther@60710
   150
  	      ist_ctxt (pt, (p, p_'));
Walther@60710
   151
"~~~~~ fun by_tactic , args:"; val ((Tactic.Apply_Method' (mI, _, _, _)), (_, ctxt), (pt, pos as (p, _))) =
Walther@60710
   152
  ((Tactic.Apply_Method' (mI, NONE, Istate.empty, ContextC.empty)),
Walther@60710
   153
  	      ist_ctxt, (pt, (p, p_')));
Walther@60754
   154
      val (itms, oris, probl, o_spec, spec) = case get_obj I pt p of
Walther@60754
   155
         PblObj {meth = itms, origin = (oris, o_spec, _), probl, spec, ...}
Walther@60754
   156
         => (itms, oris, probl, o_spec, spec)
Walther@60754
   157
      | _ => raise ERROR ""
Walther@60754
   158
      val (_, pI', _) = References.select_input o_spec spec
Walther@60757
   159
      val (_, itms) = I_Model.s_make_complete ctxt oris
Walther@60757
   160
        (I_Model.OLD_to_TEST probl, I_Model.OLD_to_TEST itms) (pI', mI)
Walther@60710
   161
Walther@60710
   162
         val (is, env, ctxt, prog) = case
Walther@60754
   163
           LItool.init_pstate ctxt itms mI of
Walther@60710
   164
             (is as Pstate {env, ...}, ctxt, program) => (is, env, ctxt, program)
Walther@60710
   165
val return_init_pstate = (is, env, ctxt, prog)
Walther@60710
   166
(*#------------------- un-hide local of init_pstate -----------------------------------------\*)
Walther@60710
   167
fun msg_miss ctxt sc metID caller f formals actuals =
Walther@60710
   168
  "ERROR in creating the environment from formal args. of partial_function \"" ^ fst (Program.get_fun_id sc) ^ "\"\n" ^
Walther@60710
   169
	"and the actual args., ie. items of the guard of \"" ^ MethodC.id_to_string metID ^ "\" by \"" ^ caller ^ "\":\n" ^
Walther@60710
   170
	"formal arg \"" ^ UnparseC.term ctxt f ^ "\" doesn't match any actual arg.\n" ^
Walther@60710
   171
	"with:\n" ^
Walther@60710
   172
	(string_of_int o length) formals ^ " formal args: " ^ UnparseC.terms ctxt formals ^ "\n" ^
Walther@60710
   173
	(string_of_int o length) actuals ^ " actual args: " ^ UnparseC.terms ctxt actuals
Walther@60710
   174
fun msg_miss_type ctxt sc metID f formals actuals =
Walther@60710
   175
  "ERROR in creating the environment from formal args. of partial_function \"" ^ fst (Program.get_fun_id sc) ^ "\"\n" ^
Walther@60710
   176
	"and the actual args., ie. items of the guard of \"" ^ MethodC.id_to_string metID ^ "\" by \"assoc_by_type\":\n" ^
Walther@60710
   177
	"formal arg \"" ^ UnparseC.term ctxt f ^ "\" of type \"" ^ UnparseC.typ ctxt (type_of f) ^
Walther@60710
   178
  "\" doesn't mach any actual arg.\nwith:\n" ^
Walther@60710
   179
	(string_of_int o length) formals ^ " formal args: " ^ UnparseC.terms ctxt formals ^ "\n" ^
Walther@60710
   180
	(string_of_int o length) actuals ^ " actual args: " ^ UnparseC.terms ctxt actuals ^ "\n" ^
Walther@60710
   181
  "   with types: " ^ (strs2str o (map ((UnparseC.typ ctxt) o type_of))) actuals
Walther@60710
   182
fun msg_ambiguous ctxt sc metID f aas formals actuals =
Walther@60710
   183
  "AMBIGUITY in creating the environment from formal args. of partial_function \"" ^ fst (Program.get_fun_id sc) ^ "\"\n" ^
Walther@60710
   184
	"and the actual args., ie. items of the guard of \"" ^ MethodC.id_to_string metID ^ "\" by \"assoc_by_type\":\n" ^
Walther@60710
   185
  "formal arg. \"" ^ UnparseC.term ctxt f ^ "\" type-matches with several..."  ^
Walther@60710
   186
  "actual args. \"" ^ UnparseC.terms ctxt aas ^ "\"\n" ^
Walther@60710
   187
  "selected \"" ^ UnparseC.term ctxt (hd aas) ^ "\"\n" ^
Walther@60710
   188
	"with\n" ^
Walther@60710
   189
	"formals: " ^ UnparseC.terms ctxt formals ^ "\n" ^
Walther@60710
   190
	"actuals: " ^ UnparseC.terms ctxt actuals
Walther@60710
   191
fun trace_init ctxt metID =
Walther@60710
   192
  if Config.get ctxt LI_trace
Walther@60710
   193
  then tracing("@@@ program \"" ^ strs2str metID ^ "\"")
Walther@60710
   194
  else ();
Walther@60710
   195
Walther@60710
   196
fun assoc_by_type ctxt f aa prog met_id formals actuals =
Walther@60710
   197
  case filter (curry (fn (f, a) => type_of f = type_of a) f) aa of
Walther@60710
   198
    [] => raise ERROR (msg_miss_type ctxt prog met_id f formals actuals)
Walther@60710
   199
  | [a] => (f, a)
Walther@60710
   200
  | aas as (a :: _) => (writeln (msg_ambiguous ctxt prog met_id f aas formals actuals); (f, a));
Walther@60710
   201
(*
Walther@60710
   202
  fun assoc_formals_actuals: at "PIDE turn 11" ONLY syntax revised, NOT semantics
Walther@60710
   203
  Env.T ->         (* [] for building return Env.T         *)
Walther@60710
   204
  term list ->     (* changed during building return Env.T *)
Walther@60710
   205
  term list ->     (* changed during building return Env.T *)
Walther@60710
   206
  Proof.context -> (*                                      *)
Walther@60710
   207
  term ->          (* program code                         *)
Walther@60710
   208
  MethodC.id ->    (* for error msg                        *)
Walther@60710
   209
  term list ->     (* original value, unchanged            *)
Walther@60710
   210
  term list ->     (* original value, unchanged            *)
Walther@60710
   211
  Env.T            (* return Env.T                         *)
Walther@60710
   212
*)
Walther@60710
   213
fun relate_args _ (f::_) [] ctxt prog met_id formals actuals =
Walther@60710
   214
    raise ERROR (msg_miss ctxt prog met_id "relate_args" f formals actuals)
Walther@60710
   215
  | relate_args env [] _ _ _ _ _ _ = env (*may drop Find?*)
Walther@60710
   216
  | relate_args env (f::ff) (aas as (a::aa)) ctxt prog met_id formals actuals = 
Walther@60710
   217
    if type_of f = type_of a 
Walther@60710
   218
    then relate_args (env @ [(f, a)]) ff aa ctxt prog met_id formals actuals
Walther@60710
   219
    else
Walther@60710
   220
      let val (f, a) = assoc_by_type ctxt f aas prog met_id formals actuals
Walther@60710
   221
      in relate_args (env @ [(f, a)]) ff (remove op = a aas) ctxt prog met_id formals actuals end
Walther@60710
   222
;
Walther@60710
   223
(*+*)relate_args: Env.T -> term list -> term list -> Proof.context -> term -> MethodC.id ->
Walther@60710
   224
    term list -> term list -> Env.T;
Walther@60710
   225
(*#------------------- un-hide local of init_pstate -----------------------------------------/*)
Walther@60710
   226
Walther@60710
   227
(*//------------------ step into init_pstate NEW -------------------------------------------\\*)
Walther@60710
   228
val (_, ctxt, i_model, met_id) = (prog_rls, ctxt, itms, mI);
Walther@60710
   229
"~~~~~ fun init_pstate , args:"; val (ctxt, i_model, met_id) =
Walther@60754
   230
    (ctxt, i_model, met_id);
Walther@60710
   231
    val (model_patt, program, prog, prog_rls, where_, where_rls) =
Walther@60710
   232
      case MethodC.from_store ctxt met_id of
Walther@60710
   233
        {model = model_patt, program = program as Rule.Prog prog, prog_rls, where_, where_rls,...} =>
Walther@60710
   234
          (model_patt, program, prog, prog_rls, where_, where_rls)
Walther@60710
   235
      | _ => raise ERROR ("init_pstate with " ^ MethodC.id_to_string met_id)
Walther@60710
   236
Walther@60758
   237
    val (env_model, (env_subst, env_eval)) = make_environments model_patt i_model;
Walther@60729
   238
    val actuals = map snd env_model
Walther@60710
   239
(*+*)val "[x + 1 = 2, x, L]" = actuals |> UnparseC.terms @{context}
Walther@60710
   240
Walther@60729
   241
    val formals = Program.formal_args prog    
Walther@60710
   242
(*+*)val "[e_e, v_v]" = (formals |> UnparseC.terms @{context})
Walther@60710
   243
Walther@60710
   244
(*+*)val "minisubpbl e_e v_v =\n(let e_ea =\n       (Try (Rewrite_Set ''norm_equation'') #>\n        Try (Rewrite_Set ''Test_simplify''))\n        e_e;\n     L_La =\n       SubProblem\n        (''Test'', [''LINEAR'', ''univariate'', ''equation'', ''test''],\n         [''Test'', ''solve_linear''])\n        [BOOL e_e, REAL v_v]\n in Check_elementwise L_L {v_v. Assumptions})" =
Walther@60710
   245
  (prog |> UnparseC.term @{context})
Walther@60710
   246
Walther@60741
   247
    val preconds = Pre_Conds.check_envs ctxt where_rls where_ (env_model, (env_subst, env_eval))
Walther@60710
   248
Walther@60710
   249
(*||------------------ continue init_pstate NEW --------------------------------------------\\*)
Walther@60710
   250
    val ctxt = ctxt |> ContextC.insert_assumptions (map snd (snd preconds));
Walther@60710
   251
    val ist = Istate.e_pstate
Walther@60710
   252
      |> Istate.set_eval prog_rls
Walther@60710
   253
      |> Istate.set_env_true (relate_args [] formals actuals ctxt prog met_id formals actuals);
Walther@60710
   254
(*+*)                        (relate_args [] formals actuals ctxt prog met_id formals actuals);
Walther@60710
   255
(*+*)val "[\"\n(e_e, x + 1 = 2)\", \"\n(v_v, x)\"]" =
Walther@60710
   256
                             (relate_args [] formals actuals ctxt prog met_id formals actuals)
Walther@60710
   257
       |> Subst.to_string @{context}
Walther@60710
   258
Walther@60710
   259
val return_init_pstate_steps = (* = return_init_pstate*)
Walther@60710
   260
    (Istate.Pstate ist, ctxt, program)
Walther@60710
   261
(*\\------------------ step into init_pstate NEW -------------------------------------------//*)
Walther@60710
   262
val (is, env, ctxt, prog) = return_init_pstate;
Walther@60710
   263
Walther@60710
   264
(*|------------------- continuing Specify_Method ---------------------------------------------*)
Walther@60710
   265
(*\------------------- step into Specify_Method --------------------------------------------//*)
Walther@60725
   266
val (_, ([(tac, _, _)], _, (pt, p))) = return_Step_do_next_Specify_Method; val Apply_Method ["Test", "squ-equ-test-subpbl1"] = tac;
Walther@60682
   267
Walther@60725
   268
(*[1], Frm*)val (_, ([(tac, _, _)], _, (pt, p))) = Step.do_next p ((pt, e_pos'), []); val Rewrite_Set "norm_equation" = tac
walther@60324
   269
Walther@60725
   270
(*[1], Res*)val return_Step_do_next_Rewrite_Set = Step.do_next p ((pt, e_pos'), []);
Walther@60682
   271
(*/------------------- step into Apply_Method ----------------------------------------------\\*)
Walther@60710
   272
"~~~~~ fun do_next , args:"; val ((ip as (_, p_)), (ptp as (pt, p), tacis)) =
Walther@60710
   273
  (p ,((pt, e_pos'), []));
Walther@60596
   274
  (*if*) Pos.on_calc_end ip (*else*);
Walther@60596
   275
      val (_, probl_id, _) = Calc.references (pt, p);
Walther@60596
   276
val _ =
Walther@60596
   277
      (*case*) tacis (*of*);
Walther@60596
   278
        (*if*) probl_id = Problem.id_empty (*else*);
walther@60324
   279
Walther@60596
   280
      Step.switch_specify_solve p_ (pt, ip);
Walther@60596
   281
"~~~~~ fun switch_specify_solve , args:"; val (state_pos, (pt, input_pos))
Walther@60596
   282
  = (p_, (pt, ip));
Walther@60596
   283
      (*if*) Pos.on_specification ([], state_pos) (*else*);
walther@60324
   284
Walther@60596
   285
        LI.do_next (pt, input_pos);
Walther@60596
   286
"~~~~~ and do_next , args:"; val (ptp as (pt, pos as (p, p_))) = (pt, input_pos);
Walther@60596
   287
    (*if*) MethodC.id_empty = get_obj g_metID pt (par_pblobj pt p) (*else*);
Walther@60596
   288
	      val ((ist, ctxt), sc) = LItool.resume_prog (p,p_) pt;
Walther@60682
   289
Walther@60682
   290
val return_LI_find_next_step = (*case*)
Walther@60682
   291
        LI.find_next_step sc (pt, pos) ist ctxt (*of*);
Walther@60682
   292
(*//------------------ step into LI.find_next_step -----------------------------------------\\*)
Walther@60682
   293
"~~~~~ fun find_next_step , args:"; val ((Rule.Prog prog), (ptp as (pt, pos as (p, _))), (Istate.Pstate ist), ctxt) =
Walther@60682
   294
  (sc, (pt, pos), ist, ctxt);
Walther@60682
   295
(*.. this showed that we have ContextC.empty*)
Walther@60710
   296
(*\\------------------ step into LI.find_next_step -----------------------------------------//*)
Walther@60682
   297
val LI.Next_Step (ist, ctxt, tac) = return_LI_find_next_step;
walther@60324
   298
Walther@60596
   299
        LI.by_tactic tac (ist, Tactic.insert_assumptions tac ctxt) ptp;
Walther@60596
   300
"~~~~~ fun by_tactic , args:"; val (tac_, ic, (pt, pos))
Walther@60596
   301
  = (tac, (ist, Tactic.insert_assumptions tac ctxt), ptp);
Walther@60596
   302
      val pos = next_in_prog' pos
walther@60324
   303
Walther@60596
   304
 	    val (pos', c, _, pt) =
Walther@60596
   305
Solve_Step.add_general tac_ ic (pt, pos);
Walther@60596
   306
"~~~~~ fun add_general , args:"; val (tac, ic, cs)
Walther@60596
   307
  = (tac_, ic, (pt, pos));
Walther@60596
   308
 (*if*) Tactic.for_specify' tac (*else*);
walther@60324
   309
Walther@60596
   310
Solve_Step.add tac ic cs;
Walther@60596
   311
"~~~~~ fun add , args:"; val ((Tactic.Rewrite_Set' (_, _, rls', f, (f', asm))), (is, ctxt), (pt, (p, _)))
Walther@60596
   312
  = (tac, ic, cs);
Walther@60596
   313
      val (pt, c) = Ctree.cappend_atomic pt p (is, ctxt) f 
Walther@60596
   314
        (Tactic.Rewrite_Set (Rule_Set.id rls')) (f', asm) Ctree.Complete
Walther@60596
   315
      val pt = Ctree.update_branch pt p Ctree.TransitiveB
walther@59851
   316
Walther@60596
   317
val return =
Walther@60675
   318
      ((p, Pos.Res), c, Test_Out.FormKF (UnparseC.term ctxt f'), pt)
Walther@60682
   319
(*\------------------- step into Apply_Method ----------------------------------------------//*)
Walther@60710
   320
val (_, ([(tac, _, _)], _, (pt, p))) = return_Step_do_next_Rewrite_Set
Walther@60529
   321
Walther@60596
   322
(* final test ... ----------------------------------------------------------------------------*)
Walther@60682
   323
(*+*)val ([2], Res) = p;
Walther@60682
   324
Test_Tool.show_pt_tac pt; (*[
Walther@60596
   325
([], Frm), solve (x + 1 = 2, x)
Walther@60596
   326
. . . . . . . . . . Apply_Method ["Test", "squ-equ-test-subpbl1"], 
Walther@60596
   327
([1], Frm), x + 1 = 2
Walther@60596
   328
. . . . . . . . . . Rewrite_Set "norm_equation", 
Walther@60596
   329
([1], Res), x + 1 + - 1 * 2 = 0
Walther@60596
   330
. . . . . . . . . . Rewrite_Set "Test_simplify", 
Walther@60596
   331
([2], Res), - 1 + x = 0
Walther@60596
   332
. . . . . . . . . . Check_Postcond ["sqroot-test", "univariate", "equation", "test"]]   ..INCORRECT
Walther@60730
   333
*)