test/Tools/isac/Minisubpbl/150a-add-given-Maximum.sml
author wneuper <Walther.Neuper@jku.at>
Fri, 24 Nov 2023 15:34:07 +0100
changeset 60766 2e0603ca18a4
parent 60763 2121f1a39a64
child 60767 466f0a5bfb73
permissions -rw-r--r--
followup 3: repair new fill_from_o, uncomment maximum of tests
     1 (* Title:  "Minisubpbl/150a-add-given-Maximum.sml"
     2    Author: Walther Neuper 1105
     3    (c) copyright due to lincense terms.
     4 
     5 COMPARE Specify/specify.sml --- specify-phase: low level functions ---
     6 
     7 ATTENTION: the file creates buffer overflow if copied in one piece !
     8 
     9 Note: This test --- steps into me --- more than once, to a somewhat extreme extent;
    10   in order not to get lost while working in Test_Some etc, 
    11   re-introduce  ML (*--- step into XXXXX ---*) and Co.
    12   and use Sidekick for orientation.
    13   Nesting is indicated by  /---   //--   ///-  at the left margin of the comments.
    14 *)
    15 
    16 open Model_Def
    17 open ME_Misc
    18 open Pre_Conds;
    19 
    20 val (_(*example text*),
    21   (model as ("Constants [r = (7::real)]" :: "Maximum A" :: "AdditionalValues [u, v]" :: 
    22      "Extremum (A = 2 * u * v - u \<up> 2)" :: 
    23      "SideConditions [((u::real) / 2) \<up> 2 + (2 / v) \<up> 2 = r \<up> 2]" :: 
    24      "SideConditions [((u::real) / 2) \<up> 2 + (2 / v) \<up> 2 = r \<up> 2]" :: 
    25      "SideConditions [(u::real) / 2 = r * sin \<alpha>, 2 / v = r * cos \<alpha>]" ::
    26 (*---------------------------------------------,(v::real) / 2 = r * cos \<alpha>]" --- ERROR in example*)
    27      "FunctionVariable a" :: "FunctionVariable b" :: "FunctionVariable \<alpha>" :: 
    28      "Domain {0 <..< r}" :: "Domain {0 <..< r}" :: "Domain {0 <..< \<pi> / 2}" ::
    29      "ErrorBound (\<epsilon> = (0::real))" :: []), 
    30    refs as ("Diff_App", 
    31      ["univariate_calculus", "Optimisation"],
    32      ["Optimisation", "by_univariate_calculus"])))
    33   = Store.get (Know_Store.get_expls @{theory}) ["Diff_App-No.123a"] ["Diff_App-No.123a"];
    34 
    35 val c = [];
    36 val return_init_calc = 
    37  Test_Code.init_calc @{context} [(model, refs)]; (*val Model_Problem = nxt;*)
    38 (*/------------------- step into init_calc -------------------------------------------------\\*)
    39 "~~~~~ fun init_calc , args:"; val (ctxt, [(model, refs as (thy_id, _, _))]) =
    40   (@{context}, [(model, refs)]);
    41     val thy = thy_id |> ThyC.get_theory ctxt
    42     val ((pt, p), tacis) = Step_Specify.initialise' thy (model, refs)
    43 	  val tac = case tacis of [] => Tactic.Empty_Tac | _ => (#1 o hd) tacis
    44 	  val f = 
    45            TESTg_form ctxt (pt,p);
    46 "~~~~~ fun TESTg_form , args:"; val (ctxt, ptp) = (ctxt, (pt,p));
    47     val (form, _, _) =
    48    ME_Misc.pt_extract ctxt ptp;
    49 "~~~~~ fun pt_extract , args:"; val (ctxt, (pt, (p, p_ as Pbl(*Frm,Pbl*)))) = (ctxt, ptp);
    50         val ppobj = Ctree.get_obj I pt p
    51         val f = if Ctree.is_pblobj ppobj then pt_model ppobj p_ else Ctree.get_obj pt_form pt p;
    52             (*if*) Ctree.is_pblobj ppobj (*then*);
    53            pt_model ppobj p_ ;
    54 "~~~~~ fun pt_model , args:"; val ((Ctree.PblObj {probl, spec, origin = (_, spec', hdl), ctxt, ...}), Pbl_) =
    55   (ppobj, p_);
    56       val (_, pI, _) = Ctree.get_somespec' spec spec';
    57 (*    val where_ = if pI = Problem.id_empty then []*)
    58                (*if*) pI = Problem.id_empty (*else*);
    59 	          val {where_rls, where_, model, ...} = Problem.from_store ctxt pI
    60 	          val (_, where_) = 
    61  Pre_Conds.check ctxt where_rls where_
    62               (model, I_Model.OLD_to_TEST probl);
    63 "~~~~~ fun check , args:"; val (ctxt, where_rls, pres, (model_patt, i_model)) =
    64   (ctxt, where_rls, where_, (model, I_Model.OLD_to_TEST probl));
    65       val (env_model, (env_subst, env_eval)) = 
    66            make_environments model_patt i_model;
    67 "~~~~~ fun make_environments , args:"; val (_, []) = (model_patt, i_model);
    68 (*\------------------- step into init_calc -------------------------------------------------//*)
    69 val (p,_,f,nxt,_,pt) = return_init_calc;   val Model_Problem = nxt
    70 val (p, _, f, nxt, _, pt) = me nxt p c pt; val Add_Given "Constants [r = 7]" = nxt
    71 val return_me_add_find_Constants =
    72            me nxt p c pt; val Add_Find "Maximum A" = #4 return_me_add_find_Constants;
    73 (*/------------------- step into me_add_find_Constants -------------------------------------\\*)
    74 "~~~~~ fun me , args:"; val (tac as Add_Given "Constants [r = 7]", p, _(*NEW remove*), pt) =
    75   (nxt, p, c, pt);
    76       val ctxt = Ctree.get_ctxt pt p
    77 (*+*)val PblObj {probl = (1, [1, 2, 3], false, "#Given", Inc 
    78     ((Const ("Input_Descript.Constants", _), []), _)) :: _, ...}  = get_obj I pt (fst p)
    79 (*-------------------------------------------^^--*)
    80 val return_step_by_tactic = (*case*) 
    81       Step.by_tactic tac (pt, p) (*of*);
    82 (*//------------------ step into Step.by_tactic --------------------------------------------\\*)
    83 "~~~~~ fun by_tactic , args:"; val (tac, (ptp as (pt, p))) = (tac, (pt, p));
    84 val Applicable.Yes tac' =
    85     (*case*) Specify_Step.check tac (pt, p) (*of*);
    86 	    (*if*) Tactic.for_specify' tac' (*then*);
    87 
    88 (** )val return_step_by_tactic =( **)
    89 (**)val return_step_specify_by_tactic =(**)
    90 Step_Specify.by_tactic tac' ptp;
    91 (*///----------------- step into Step_Specify.by_tactic ------------------------------------\\*)
    92 "~~~~~ fun by_tactic , args:"; val ((Tactic.Add_Given' (ct, _)), (pt, p)) = (tac', ptp);
    93 
    94 (** )val calling_code =( **)
    95 (**)val return_by_Add_ =(**)
    96    Specify.by_Add_ "#Given" ct (pt, p);
    97 (*////---------------- step by_Add_ --------------------------------------------------------\\*)
    98 "~~~~~ fun by_Add_ , args:"; val (m_field, ct, (pt, pos as (_, p_))) = ("#Given", ct, (pt, p));
    99     val (met, oris, (_, pI', mI'), pbl, (_, pI, mI), ctxt) = SpecificationC.get_data (pt, pos);
   100 
   101 val false =
   102        (*if*) p_ = Pos.Met (*else*);
   103 val (i_model, m_patt) =
   104          (pbl,
   105            (if pI = Problem.id_empty then pI' else pI) |> Problem.from_store ctxt |> #model)
   106 val I_Model.Add i_single =
   107       (*case*) I_Model.check_single ctxt m_field oris i_model m_patt ct (*of*);
   108 
   109 (** )val i_model' =( **)
   110 (**)val return_add_single =(**)
   111    I_Model.add_single (Proof_Context.theory_of ctxt) i_single i_model;
   112 (*/////--------------- step add_single -----------------------------------------------------\\*)
   113 "~~~~~ fun add_single , args:"; val (thy, itm, model) =
   114   ((Proof_Context.theory_of ctxt), i_single, i_model);
   115     fun eq_untouched d (0, _, _, _, itm_) = (d = I_Model.descriptor itm_)
   116       | eq_untouched _ _ = false
   117     val model' = case I_Model.seek_ppc (#1 itm) model of
   118       SOME _ => overwrite_ppc thy itm model (*itm updated in is_notyet_input WN.11.03*)
   119 (*\\\\\--------------- step add_single -----------------------------------------------------//*)
   120 (*|||||--------------- step by_Add_ ----------------------------------------------------------*)
   121             val i_model' = return_add_single
   122 (*+++*)val "[\n(1 ,[1, 2, 3] ,true ,#Given ,Cor Constants [r = 7] , pen2str), \n(2 ,[1, 2, 3] ,false ,#Find ,Inc Maximum , pen2str), \n(3 ,[1, 2, 3] ,false ,#Find ,Inc AdditionalValues [] , pen2str), \n(4 ,[1, 2, 3] ,false ,#Relate ,Inc Extremum , pen2str), \n(5 ,[1, 2] ,false ,#Relate ,Inc SideConditions [] , pen2str)]"
   123  = i_model' |> I_Model.to_string ctxt
   124             val tac' = I_Model.make_tactic m_field (ct, i_model')
   125 	          val  (_, _, _, pt') =  Specify_Step.add tac' (Istate_Def.Uistate, ctxt) (pt, pos)
   126 val return_by_Add_step =
   127             ("ok", ([(Tactic.input_from_T ctxt tac', tac', (pos, (Istate_Def.Uistate, ctxt)))],
   128               [], (pt', pos)))
   129 (*+++*)val {probl, ...} = Calc.specify_data (pt', pos);
   130 (*+++*)val "[\n(1 ,[1, 2, 3] ,true ,#Given ,Cor Constants [r = 7] , pen2str), \n(2 ,[1, 2, 3] ,false ,#Find ,Inc Maximum , pen2str), \n(3 ,[1, 2, 3] ,false ,#Find ,Inc AdditionalValues [] , pen2str), \n(4 ,[1, 2, 3] ,false ,#Relate ,Inc Extremum , pen2str), \n(5 ,[1, 2] ,false ,#Relate ,Inc SideConditions [] , pen2str)]"
   131  = probl |> I_Model.to_string ctxt
   132 (*\\\\---------------- step into by_Add_ ---------------------------------------------------//*)
   133 val return_by_tactic_step = return_by_Add_
   134 (*\\\----------------- step into Step_Specify.by_tactic ------------------------------------//*)
   135 (*vvv--- this means, the return value of *)
   136 val return_step_by_tactic_STEP = return_step_specify_by_tactic
   137 (*\\------------------ step into Step.by_tactic --------------------------------------------//*)
   138 val ("ok", (_, _, ptp)) = return_step_by_tactic;
   139 
   140 (*+++*)val (pt, p) = ptp
   141 (*+++*)val {probl, ...} = Calc.specify_data (pt, p);
   142 (*+++*)val "[\n(1 ,[1, 2, 3] ,true ,#Given ,Cor Constants [r = 7] , pen2str), \n(2 ,[1, 2, 3] ,false ,#Find ,Inc Maximum , pen2str), \n(3 ,[1, 2, 3] ,false ,#Find ,Inc AdditionalValues [] , pen2str), \n(4 ,[1, 2, 3] ,false ,#Relate ,Inc Extremum , pen2str), \n(5 ,[1, 2] ,false ,#Relate ,Inc SideConditions [] , pen2str)]"
   143  = probl |> I_Model.to_string ctxt;
   144 
   145       val (pt, p) = ptp; (*case*)
   146       Step.do_next p ((pt, Pos.e_pos'), []) (*of*);
   147 "~~~~~ fun do_next , args:"; val ((ip as (_, p_)), (ptp as (pt, p), tacis)) =
   148   (p, ((pt, Pos.e_pos'), []));
   149 val false =
   150   (*if*) Pos.on_calc_end ip (*else*);
   151       val (_, probl_id, _) = Calc.references (pt, p);
   152 val _ =
   153       (*case*) tacis (*of*);
   154 val false =
   155         (*if*) probl_id = Problem.id_empty (*else*);
   156 
   157 
   158 val ("ok", ([(Add_Find "Maximum A", _, _)], [], _)) =
   159            switch_specify_solve p_ (pt, ip);
   160 "~~~~~ fun switch_specify_solve , args:"; val (state_pos, (pt, input_pos)) = (p_, (pt, ip));
   161       (*if*) Pos.on_specification ([], state_pos) (*then*);
   162 
   163 val ("ok", ([(Add_Find "Maximum A", _, _)], [], _)) =
   164            specify_do_next (pt, input_pos);
   165 "~~~~~ fun specify_do_next , args:"; val (ptp as (pt, (p, p_))) = (pt, input_pos);
   166     val (_, (p_', tac)) =
   167    Specify.find_next_step ptp;
   168 "~~~~~ fun find_next_step , args:"; val (pt, pos as (_, p_)) = (ptp);
   169     val {meth = met, origin = origin as (oris, o_refs as (_, pI', mI'), _), probl = pbl,
   170       spec = refs, ...} = Calc.specify_data (pt, pos);
   171     val ctxt = Ctree.get_ctxt pt pos;
   172 (*+*)val "[\n(1 ,[1, 2, 3] ,true ,#Given ,Cor Constants [r = 7] , pen2str), \n(2 ,[1, 2, 3] ,false ,#Find ,Inc Maximum , pen2str), \n(3 ,[1, 2, 3] ,false ,#Find ,Inc AdditionalValues [] , pen2str), \n(4 ,[1, 2, 3] ,false ,#Relate ,Inc Extremum , pen2str), \n(5 ,[1, 2] ,false ,#Relate ,Inc SideConditions [] , pen2str)]"
   173  = pbl|> I_Model.to_string ctxt
   174 
   175 val false =
   176       (*if*) Ctree.just_created (pt, pos) andalso origin <> Ctree.e_origin (*else*); 
   177 val true =
   178         (*if*) p_ = Pos.Pbl (*then*); 
   179 
   180 (** )val ("dummy", (Pbl, Add_Find "Maximum A")) =( **)
   181 (**)val return_for_problem as ("dummy", (Pbl, Add_Find "Maximum A"))=(**)
   182            for_problem ctxt oris (o_refs, refs) (pbl, I_Model.OLD_to_TEST met);
   183 (*//------------------ step into for_problem -----------------------------------------------\\*)
   184 "~~~~~ fun for_problem , args:"; val (ctxt, oris, ((dI', pI', mI'), (dI, pI, mI)), (pbl, met)) =
   185   (ctxt, oris, (o_refs, refs), (pbl, met));
   186     val cpI = if pI = Problem.id_empty then pI' else pI;
   187     val cmI = if mI = MethodC.id_empty then mI' else mI;
   188     val {model = pbt, where_rls, where_, ...} = Problem.from_store ctxt cpI;
   189     val {model = mpc, ...} = MethodC.from_store ctxt cmI
   190 
   191 (** )val (preok, _) =( **)
   192 (**)val return_check =(**)
   193 Pre_Conds.check ctxt where_rls where_ (pbt, I_Model.OLD_to_TEST pbl);
   194 (*///----------------- step into Pre_Conds.check -------------------------------------------\\*)
   195 "~~~~~ fun check , args:"; val (ctxt, where_rls, pres, (model_patt, i_model)) =
   196   (ctxt, where_rls, where_, (pbt, I_Model.OLD_to_TEST pbl));
   197 
   198 (** )val (_, (env_subst, env_eval)) =( **)
   199 (**)val return_make_environments =(**)
   200 Pre_Conds.make_environments model_patt i_model;
   201 (*////---------------- step into make_environments -----------------------------------------\\*)
   202 "~~~~~ fun make_environments , args:"; val (model_patt, i_model) = (model_patt, i_model);
   203     val equal_descr_pairs = map (get_equal_descr i_model) model_patt
   204       |> flat
   205 
   206     val env_model = make_env_model equal_descr_pairs
   207 (** )val env_model =( **)
   208 (**)val return_make_env_model =(**)
   209   make_env_model equal_descr_pairs;
   210 (*/////--------------- step into make_env_model --------------------------------------------\\*)
   211 "~~~~~ fun make_env_model , args:"; val (equal_descr_pairs) = (equal_descr_pairs);
   212 val return_make_env_model_step =
   213   map (fn ((_, (_, id)), (_, _, _, _, (feedb, _)))
   214         => (mk_env_model id feedb)) equal_descr_pairs
   215   |> flat
   216 (*map:*)val ((_, (_, id)), (_, _, _, _, (feedb, _))) = (nth 2 equal_descr_pairs);
   217 
   218 (*///// /------------- step into mk_env_model ----------------------------------------------\\*)
   219 "~~~~~ fun mk_env_model , args:"; val (_, (Model_Def.Inc_TEST (_, []))) = (id, feedb);
   220 (*+*)val (patt, imod) = nth 2 equal_descr_pairs
   221 (*+*)val "(#Find, (Maximum, maxx))" = patt |> Model_Pattern.pat2str ctxt
   222 (*+*)val "(2, [1, 2, 3], false ,#Find, (Inc_TEST Maximum __, Position.T))" = imod |> I_Model.single_to_string_TEST ctxt
   223 
   224 val return_mk_env_model_2_step = []
   225 (*\\\\\ \------------- step into mk_env_model ----------------------------------------------//*)
   226 (*\\\\\--------------- step into make_env_model --------------------------------------------//*)
   227 val env_model = return_make_env_model;
   228 
   229 (*||||---------------- contine.. make_environments -------------------------------------------*)
   230     val equal_givens = filter (fn ((m_field, _), _) => m_field = "#Given") equal_descr_pairs
   231 
   232 (** )val subst_eval_list =( **)
   233 (**)val return_make_envs_preconds =(**)
   234   make_envs_preconds equal_givens;
   235 (*/////--------------- step into make_envs_preconds ----------------------------------------\\*)
   236 "~~~~~ fun make_envs_preconds , args:"; val (equal_givens) = (equal_givens);
   237 val return_make_envs_preconds_step = 
   238   map (fn ((_, (_, id)), (_, _, _, _, (feedb, _))) => discern_feedback id feedb) equal_givens
   239   |> flat
   240 
   241 
   242 val ((_, (_, id)), (_, _, _, _, (feedb, _))) = nth 1 equal_givens
   243 (*\\\\\--------------- step into make_envs_preconds ----------------------------------------//*)
   244     val subst_eval_list = return_make_envs_preconds;
   245     val (env_subst, env_eval) = split_list subst_eval_list
   246 
   247 val return_make_environments_step = (env_model, (env_subst, env_eval));
   248 (*+*)if return_make_environments_step = return_make_environments
   249   then () else error "return_make_environments_step <> return_make_environments";
   250 (*\\\\---------------- step into make_environments -----------------------------------------//*)
   251 (*|||----------------- contine.. Pre_Conds.check ---------------------------------------------*)
   252       val (env_model, (env_subst, env_eval)) = return_make_environments
   253       val pres_subst = map (TermC.subst_atomic_all env_subst) where_;
   254       val pres_subst_other = map (TermC.subst_atomic_all env_model) (map #2 pres_subst);
   255       val full_subst = if env_eval = [] then pres_subst_other
   256         else map (TermC.subst_atomic_all env_eval) (map #2 pres_subst_other)
   257       val evals = map (eval ctxt where_rls) full_subst
   258     (*in*)
   259 val return_make_environments_step = (foldl and_ (true, map fst evals), pres_subst_other)
   260 (*\\\----------------- step into Pre_Conds.check -------------------------------------------//*)
   261 (*||------------------ contine.. for_problem -------------------------------------------------*)
   262     val (preok, _) = return_check;
   263   (*in*)
   264 val false =
   265     (*if*) dI' = ThyC.id_empty andalso dI = ThyC.id_empty (*else*);
   266 val false =
   267       (*if*) pI' = Problem.id_empty andalso pI = Problem.id_empty (*else*);
   268 val NONE =
   269       (*case*) find_first (fn (_, _, _, _, feedb) => I_Model.is_error feedb) pbl (*of*);
   270 
   271 val SOME (fd, ct' as "Maximum A") = (*case*)
   272            item_to_add ctxt oris (I_Model.OLD_to_TEST pbl) (*of*);
   273 "~~~~~ fun item_to_add , args:"; val (ctxt, o_model, i_model) = (ctxt, oris, (I_Model.OLD_to_TEST pbl));
   274     val max_vnt = last_elem (*this decides, for which variant initially help is given*)
   275       (Model_Def.max_variants o_model i_model)
   276     val o_vnts = filter (fn (_, vnts, _, _, _) => member op= vnts max_vnt) o_model
   277     val i_to_select = i_model
   278       |> filter_out (fn (_, vnts, _, _, (I_Model.Cor_TEST _, _)) => member op= vnts max_vnt | _ => false)
   279       |> select_inc_lists
   280       |> hd
   281   (*in*)
   282 
   283 val SOME (_, _, _, m_field, (feedb, _)) = (*case*)
   284    I_Model.fill_from_o o_vnts i_to_select (*of*);
   285 (*+*)val "Cor_TEST Maximum A , pen2str" = feedb |> I_Model.feedback_TEST_to_string ctxt;
   286 
   287 "~~~~~ fun fill_from_o , args:"; val (o_model, (i, vnts, bool, m_field, (feedb, pos))) =
   288   (o_vnts, i_to_select);
   289     val (m_field, all_value as [Free ("A", _)]) =
   290       case find_first (fn (_, _, _, descr', _) => Pre_Conds.descriptor_exists descr' feedb) o_model of
   291         SOME (_, _, m_field, _, ts) =>  (m_field, ts)
   292     val descr = Pre_Conds.get_dscr'' feedb (*i_single has been filtered appropriately*)
   293   (*in*)
   294 val false =
   295     (*if*) Model_Def.is_list_descr descr (*else*);
   296 val return_fill_from_o_STEP = SOME (i, vnts, bool, m_field,
   297       (Inc_TEST (descr, all_value), pos))
   298 (*\------------------- step into me_add_find_Constants -------------------------------------//*)
   299 val (p,_,f,nxt,_,pt) = return_me_add_find_Constants;
   300                                       val Add_Find "Maximum A" = nxt
   301 
   302 (** )val (p,_,f,nxt,_,pt) =( **)
   303 (**)val return_me_Add_Find_Maximum =(**)
   304        me nxt p c pt;  val Add_Find "AdditionalValues [u]" = #4 return_me_Add_Find_Maximum;
   305 (*/------------------- step into me_Add_Find_Maximum ---------------------------------------\\*)
   306 "~~~~~ fun me , args:"; val (tac, p, _(*NEW remove*), pt) = (nxt, p, c, pt);
   307       val ctxt = Ctree.get_ctxt pt p
   308       val (pt, p) = 
   309   	    case Step.by_tactic tac (pt, p) of
   310   		    ("ok", (_, _, ptp)) => ptp;
   311 
   312       (*case*)
   313       Step.do_next p ((pt, Pos.e_pos'), []) (*of*);
   314 "~~~~~ fun do_next , args:"; val ((ip as (_, p_)), (ptp as (pt, p), tacis)) =
   315   (p, ((pt, Pos.e_pos'), []));
   316 val false =
   317   (*if*) Pos.on_calc_end ip (*else*);
   318       val (_, probl_id, _) = Calc.references (pt, p);
   319     (*in*)
   320 val [] =
   321       (*case*) tacis (*of*);
   322 val false =
   323         (*if*) probl_id = Problem.id_empty (*else*);
   324 
   325            switch_specify_solve p_ (pt, ip);
   326 "~~~~~ fun switch_specify_solve , args:"; val (state_pos, (pt, input_pos)) = (p_, (pt, ip));
   327 val true =
   328       (*if*) Pos.on_specification ([], state_pos) (*then*);
   329 
   330            specify_do_next (pt, input_pos);
   331 "~~~~~ fun specify_do_next , args:"; val (ptp as (pt, (p, p_))) = (pt, input_pos);
   332 
   333 (**)val (_, (p_', tac as Add_Find "AdditionalValues [u]")) =(**)
   334    Specify.find_next_step ptp;
   335 "~~~~~ fun find_next_step , args:"; val (pt, pos as (_, p_)) = (ptp);
   336     val {meth = met, origin = origin as (oris, o_refs as (_, pI', mI'), _), probl = pbl,
   337       spec = refs, ...} = Calc.specify_data (pt, pos);
   338     val ctxt = Ctree.get_ctxt pt pos
   339   (*in*)
   340 val false =
   341       (*if*) Ctree.just_created (pt, pos) andalso origin <> Ctree.e_origin (*else*);
   342 val true =
   343         (*if*) p_ = Pos.Pbl (*then*);
   344 
   345 (**)val return_find_next_step_STEP as ("dummy", (Pbl, Add_Find "AdditionalValues [u]")) =(**)
   346            for_problem ctxt oris (o_refs, refs) (pbl, I_Model.OLD_to_TEST met);
   347 "~~~~~ fun for_problem , args:"; val (ctxt, oris, ((dI', pI', mI'), (dI, pI, mI)), (pbl, met)) =
   348   (ctxt, oris, (o_refs, refs), (pbl, I_Model.OLD_to_TEST met));
   349     val cpI = if pI = Problem.id_empty then pI' else pI;
   350     val cmI = if mI = MethodC.id_empty then mI' else mI;
   351     val {model = pbt, where_rls, where_, ...} = Problem.from_store ctxt cpI;
   352     val {model = mpc, ...} = MethodC.from_store ctxt cmI
   353     val (preok, _) = Pre_Conds.check ctxt where_rls where_ (pbt, I_Model.OLD_to_TEST pbl);
   354   (*in*)
   355 val false =
   356     (*if*) dI' = ThyC.id_empty andalso dI = ThyC.id_empty (*else*);
   357 val false =
   358       (*if*) pI' = Problem.id_empty andalso pI = Problem.id_empty (*else*);
   359 val NONE =
   360       (*case*) find_first (fn (_, _, _, _, feedb) => I_Model.is_error feedb) pbl (*of*);
   361 
   362 (**)val SOME (fd, ct' as "AdditionalValues [u]") = (*case*)(**)
   363            item_to_add ctxt oris (I_Model.OLD_to_TEST pbl) (*of*);
   364 "~~~~~ fun item_to_add , args:"; val (ctxt, o_model, i_model) =
   365   (ctxt, oris, (I_Model.OLD_to_TEST pbl));
   366     val max_vnt = last_elem (*this decides, for which variant initially help is given*)
   367       (Model_Def.max_variants o_model i_model)
   368     val o_vnts = filter (fn (_, vnts, _, _, _) => member op= vnts max_vnt) o_model
   369     val i_to_select = i_model
   370       |> filter_out (fn (_, vnts, _, _, (I_Model.Cor_TEST _, _)) => member op= vnts max_vnt | _ => false)
   371       |> select_inc_lists
   372 (*ERROR*)val "[\n(3, [1, 2, 3], false ,#Find, (Inc_TEST AdditionalValues [] [__, __], Position.T)), \n(4, [1, 2, 3], false ,#Relate, (Inc_TEST Extremum (__=__), Position.T)), \n(5, [1, 2], false ,#Relate, (Inc_TEST SideConditions [] [__=__, __=__], Position.T))]"
   373  = i_to_select |> I_Model.to_string_TEST ctxt(*ERROR*)
   374   (*in*)
   375 val false =
   376     (*if*) i_to_select = []
   377 
   378 val SOME (_, _, _, m_field, (feedb, _)) = (*case*)
   379    I_Model.fill_from_o o_vnts (hd i_to_select) (*of*);
   380 "~~~~~ fun fill_from_o , args:";
   381 (*==================== see test/../i-model.sml --- fun item_to_add ===========================*)
   382 (*\------------------- step into me_Add_Find_Maximum ---------------------------------------//*)
   383 val (p,_,f,nxt,_,pt) = return_me_Add_Find_Maximum; 
   384                                       val Add_Find "AdditionalValues [u]" = nxt
   385 val (p,_,f,nxt,_,pt) = me nxt p c pt; val Add_Find "AdditionalValues [u, v]" = nxt;(*ERROR after repairing item_to_add, investigate in testcode above*)
   386 val (p,_,f,nxt,_,pt) = me nxt p c pt; val Add_Relation "Extremum (A = 2 * u * v - u \<up> 2)" = nxt;
   387 val (p,_,f,nxt,_,pt) = me nxt p c pt; val Add_Relation "SideConditions [(u / 2) \<up> 2 + (2 / v) \<up> 2 = r \<up> 2]" = nxt;
   388 
   389 val return_me_Add_Relation_SideConditions as (_, _, _, Specify_Theory "Diff_App", _, _)
   390                      = me nxt p c pt;
   391 (*/------------------- step into me Add_Relation_SideConditions ----------------------------\\*)
   392 "~~~~~ fun me , args:"; val (tac, p, _, pt) = (nxt, p, c, pt);
   393       val ctxt = Ctree.get_ctxt pt p;
   394 (**)  val (pt, p) = (**) 
   395   	    (**)case(**) Step.by_tactic tac (pt, p) (**)of(**)
   396 (**) 		    ("ok", (_, _, ptp)) => ptp (**) ;
   397 
   398    (*case*)
   399       Step.do_next p ((pt, Pos.e_pos'), []) (*of*);
   400 (*//------------------ step into do_next ---------------------------------------------------\\*)
   401 "~~~~~ fun do_next , args:"; val ((ip as (_, p_)), (ptp as (pt, p), tacis))
   402   = (p, ((pt, Pos.e_pos'), [])) (*of*);
   403   (*if*) Pos.on_calc_end ip (*else*);
   404       val (_, probl_id, _) = Calc.references (pt, p);
   405       (*case*) tacis (*of*);
   406         (*if*) probl_id = Problem.id_empty (*else*);
   407 
   408       Step.switch_specify_solve p_ (pt, ip);
   409 "~~~~~ fun switch_specify_solve , args:"; val (state_pos, (pt, input_pos)) = (p_, (pt, ip));
   410       (*if*) Pos.on_specification ([], state_pos) (*then*);
   411 
   412       Step.specify_do_next (pt, input_pos);
   413 "~~~~~ fun specify_do_next , args:"; val ((ptp as (pt, (p, p_)))) = (pt, input_pos);
   414     val (_, (p_', tac as Specify_Theory "Diff_App")) =
   415    Specify.find_next_step ptp;
   416 "~~~~~ fun find_next_step , args:"; val (pt, pos as (_, p_)) = (ptp);
   417     val {meth = met, origin = origin as (oris, o_refs as (_, pI', mI'), _), probl = pbl,
   418       spec = refs, ...} = Calc.specify_data (pt, pos);
   419     val ctxt = Ctree.get_ctxt pt pos;
   420       (*if*) Ctree.just_created (pt, pos) andalso origin <> Ctree.e_origin (*else*);
   421         (*if*) p_ = Pos.Pbl (*then*);
   422 
   423 (** )val ("dummy", (Pbl, tac as Specify_Theory "Diff_App")) =( **)
   424 (**)val return_for_problem =(**)
   425   for_problem ctxt oris (o_refs, refs) (pbl, I_Model.OLD_to_TEST met);
   426 (*///// /------------- step into for_problem -----------------------------------------------\\*)
   427 "~~~~~ fun for_problem , args:"; val (ctxt, oris, ((dI', pI', mI'), (dI, pI, mI)), (pbl, met)) =
   428   (ctxt, oris, (o_refs, refs), (pbl, met));
   429     val cpI = if pI = Problem.id_empty then pI' else pI;
   430     val cmI = if mI = MethodC.id_empty then mI' else mI;
   431     val {model = pbt, where_rls, where_, ...} = Problem.from_store ctxt cpI;
   432     val {model = mpc, ...} = MethodC.from_store ctxt cmI
   433 
   434 (*+*)val [Const ("Orderings.ord_class.less", _) $ Const ("Groups.zero_class.zero", _) $
   435   Free ("fixes", _)] = where_;
   436 
   437 (** )val (preok, _) =( **)
   438 (**)return_check =(**)
   439  Pre_Conds.check ctxt where_rls where_ (pbt, I_Model.OLD_to_TEST pbl);
   440 (*///// //------------ step into check -------------------------------------------------\\*)
   441 "~~~~~ fun check , args:"; val (ctxt, where_rls, pres, (model_patt, i_model)) =
   442   (ctxt, where_rls, where_, (pbt, I_Model.OLD_to_TEST pbl));
   443 (*+*)val "[0 < fixes]" = pres |> UnparseC.terms ctxt
   444 (*+*)val "[\"(#Given, (Constants, fixes))\", \"(#Find, (Maximum, maxx))\", \"(#Find, (AdditionalValues, vals))\", \"(#Relate, (Extremum, extr))\", \"(#Relate, (SideConditions, sideconds))\"]"
   445 (*+*)  = model_patt |> Model_Pattern.to_string ctxt
   446 (*+*)val "[\n(1, [1, 2, 3], true ,#Given, (Cor_TEST Constants [r = 7] , pen2str, Position.T)), \n(2, [1, 2, 3], true ,#Find, (Cor_TEST Maximum A , pen2str, Position.T)), \n(3, [1, 2, 3], true ,#Find, (Cor_TEST AdditionalValues [u, v] , pen2str, Position.T)), \n(4, [1, 2, 3], true ,#Relate, (Cor_TEST Extremum (A = 2 * u * v - u \<up> 2) , pen2str, Position.T)), \n(5, [1, 2], true ,#Relate, (Cor_TEST SideConditions [(u / 2) \<up> 2 + (2 / v) \<up> 2 = r \<up> 2] , pen2str, Position.T))]"
   447  = i_model |> I_Model.to_string_TEST ctxt
   448 
   449 val return_make_environments as (_, (env_subst, env_eval)) =
   450            Pre_Conds.make_environments model_patt i_model
   451 
   452 (*+*)val [(Free ("fixes", T1), Free ("r", T2))] = env_subst (*?!? Const*)
   453 (*+*)val Type ("Real.real", []) = T1
   454 (*+*)val Type ("Real.real", []) = T2
   455 
   456 (*+*)val [(Free ("r", T2), Const ("Num.numeral_class.numeral", _) $ _)] = env_eval
   457 (*+*)val Type ("Real.real", []) = T2
   458 
   459 val (_, (env_subst, env_eval)) = return_make_environments;
   460 (*|||----------------- contine check -----------------------------------------------------*)
   461       val pres_subst = map (TermC.subst_atomic_all env_subst) pres;
   462 (*+*)val [(true, Const ("Orderings.ord_class.less", _) $
   463   Const ("Groups.zero_class.zero", _) $ Free ("r", _))] = pres_subst
   464 
   465       val full_subst = map (fn (bool, t) => (bool, subst_atomic env_eval t)) pres_subst
   466 (*+*)val [(true,
   467      Const ("Orderings.ord_class.less", _) $ Const ("Groups.zero_class.zero", _) $
   468        (Const ("Num.numeral_class.numeral", _) $ _))] = full_subst
   469 
   470       val evals = map (eval ctxt where_rls) full_subst
   471 val return_check_STEP = (foldl and_ (true, map fst evals), pres_subst)
   472 (*\\\\\ \\------------ step into check -------------------------------------------------\\*)
   473     val (preok as true, _) = return_check
   474 
   475 (*||||| |------------- contine.. for_problem -------------------------------------------------*)
   476 val false =
   477     (*if*) dI' = ThyC.id_empty andalso dI = ThyC.id_empty (*else*);
   478 val false =
   479       (*if*) pI' = Problem.id_empty andalso pI = Problem.id_empty (*else*);
   480 val NONE =
   481       (*case*) find_first (fn (_, _, _, _, feedb) => I_Model.is_error feedb) pbl (*of*);
   482 
   483   (*case*) item_to_add ctxt oris (I_Model.OLD_to_TEST pbl) (*of*);
   484 "~~~~~ fun item_to_add , args:"; val (ctxt, o_model, i_model) = (ctxt, oris, (I_Model.OLD_to_TEST pbl));
   485 
   486 (*+*)val "[\n(1, [\"1\", \"2\", \"3\"], #Given, Constants, [\"[r = 7]\"]), \n(2, [\"1\", \"2\", \"3\"], #Find, Maximum, [\"A\"]), \n(3, [\"1\", \"2\", \"3\"], #Find, AdditionalValues, [\"[u]\", \"[v]\"]), \n(4, [\"1\", \"2\", \"3\"], #Relate, Extremum, [\"A = 2 * u * v - u \<up> 2\"]), \n(5, [\"1\", \"2\"], #Relate, SideConditions, [\"[(u / 2) \<up> 2 + (2 / v) \<up> 2 = r \<up> 2]\"]), \n(6, [\"3\"], #Relate, SideConditions, [\"[u / 2 = r * sin \<alpha>]\", \"[2 / v = r * cos \<alpha>]\"]), \n(7, [\"1\"], #undef, FunctionVariable, [\"a\"]), \n(8, [\"2\"], #undef, FunctionVariable, [\"b\"]), \n(9, [\"3\"], #undef, FunctionVariable, [\"\<alpha>\"]), \n(10, [\"1\", \"2\"], #undef, Input_Descript.Domain, [\"{0<..<r}\"]), \n(11, [\"3\"], #undef, Input_Descript.Domain, [\"{0<..<\<pi> / 2}\"]), \n(12, [\"1\", \"2\", \"3\"], #undef, ErrorBound, [\"\<epsilon> = 0\"])]"
   487  = o_model |> O_Model.to_string ctxt
   488 (*+*)val "[\n(1, [1, 2, 3], true ,#Given, (Cor_TEST Constants [r = 7] , pen2str, Position.T)), \n(2, [1, 2, 3], true ,#Find, (Cor_TEST Maximum A , pen2str, Position.T)), \n(3, [1, 2, 3], true ,#Find, (Cor_TEST AdditionalValues [u, v] , pen2str, Position.T)), \n(4, [1, 2, 3], true ,#Relate, (Cor_TEST Extremum (A = 2 * u * v - u \<up> 2) , pen2str, Position.T)), \n(5, [1, 2], true ,#Relate, (Cor_TEST SideConditions [(u / 2) \<up> 2 + (2 / v) \<up> 2 = r \<up> 2] , pen2str, Position.T))]"
   489  = i_model |> I_Model.to_string_TEST ctxt
   490 
   491     val max_vnt as 1= last_elem (*this decides, for which variant initially help is given*)
   492       (Model_Def.max_variants o_model i_model)
   493     val o_vnts = filter (fn (_, vnts, _, _, _) => member op= vnts max_vnt) o_model
   494 (*+*)val "[\n(1, [\"1\", \"2\", \"3\"], #Given, Constants, [\"[r = 7]\"]), \n(2, [\"1\", \"2\", \"3\"], #Find, Maximum, [\"A\"]), \n(3, [\"1\", \"2\", \"3\"], #Find, AdditionalValues, [\"[u]\", \"[v]\"]), \n(4, [\"1\", \"2\", \"3\"], #Relate, Extremum, [\"A = 2 * u * v - u \<up> 2\"]), \n(5, [\"1\", \"2\"], #Relate, SideConditions, [\"[(u / 2) \<up> 2 + (2 / v) \<up> 2 = r \<up> 2]\"]), \n(7, [\"1\"], #undef, FunctionVariable, [\"a\"]), \n(10, [\"1\", \"2\"], #undef, Input_Descript.Domain, [\"{0<..<r}\"]), \n(12, [\"1\", \"2\", \"3\"], #undef, ErrorBound, [\"\<epsilon> = 0\"])]"
   495  = o_vnts |> O_Model.to_string ctxt
   496 
   497     val i_to_select = i_model
   498       |> filter_out (fn (_, vnts, _, _, (I_Model.Cor_TEST _, _)) => member op= vnts max_vnt | _ => false)
   499       |> select_inc_lists
   500 val true =
   501     (*if*) i_to_select = [] (*then*);
   502 
   503 val return_for_problem_STEP = NONE
   504 (*\\\\\ \------------- step into for_problem -----------------------------------------------//*)
   505 val calling_code = return_for_problem;
   506 (*-------------------- stopped after ERROR found ---------------------------------------------*)
   507 
   508 (*\\------------------ step into do_next ---------------------------------------------------\\*)
   509 (*\------------------- step into me_Add_Relation_SideConditions ----------------------------//*)
   510 val (p, _, f, nxt, _, pt) = return_me_Add_Relation_SideConditions
   511                                       val Specify_Theory "Diff_App" = nxt;
   512 
   513 val return_me_Specify_Theory
   514                      = me nxt p c pt; val Specify_Problem ["univariate_calculus", "Optimisation"] = #4 return_me_Specify_Theory;
   515 (*/------------------- step into me_Specify_Theory -----------------------------------------\\*)
   516 "~~~~~ fun me , args:"; val (tac as Specify_Theory "Diff_App", p, _, pt) = (nxt, p, c, pt);
   517       val ctxt = Ctree.get_ctxt pt p;
   518 (*      val (pt, p) = *)
   519   	    (*case*) Step.by_tactic tac (pt, p) (*of*);
   520 (*		    ("ok", (_, _, ptp)) => ptp *)
   521 val return_Step_by_tactic =
   522       Step.by_tactic tac (pt, p);
   523 (*//------------------ step into Step_by_tactic --------------------------------------------\\*)
   524 "~~~~~ fun by_tactic , args:"; val (tac, (ptp as (pt, p))) = (tac, (pt, p));
   525     (*case*) Specify_Step.check tac (pt, p) (*of*);
   526 
   527 (*||------------------ contine Step_by_tactic ------------------------------------------------*)
   528 (*\\------------------ step into Step_by_tactic --------------------------------------------//*)
   529 
   530 val ("ok", (_, _, ptp)) = return_Step_by_tactic;
   531 (*|------------------- continue me Specify_Theory --------------------------------------------*)
   532 
   533 val ("ok", (ts as (_, _, _) :: _, _, _)) =
   534     (*case*)
   535       Step.do_next p ((pt, Pos.e_pos'), []) (*of*);
   536 (*//------------------ step into do_next ---------------------------------------------------\\*)
   537 "~~~~~ fun do_next , args:"; val ((ip as (_, p_)), (ptp as (pt, p), tacis))
   538   = (p, ((pt, Pos.e_pos'), [])) (*of*);
   539   (*if*) Pos.on_calc_end ip (*else*);
   540       val (_, probl_id, _) = Calc.references (pt, p);
   541 val _ =
   542       (*case*) tacis (*of*);
   543         (*if*) probl_id = Problem.id_empty (*else*);
   544 
   545       Step.switch_specify_solve p_ (pt, ip);
   546 "~~~~~ fun switch_specify_solve , args:"; val (state_pos, (pt, input_pos)) = (p_, (pt, ip));
   547       (*if*) Pos.on_specification ([], state_pos) (*then*);
   548 
   549       Step.specify_do_next (pt, input_pos);
   550 "~~~~~ fun specify_do_next , args:"; val ((ptp as (pt, (p, p_)))) = (pt, input_pos);
   551     val (_, (p_', tac)) = Specify.find_next_step ptp
   552     val ist_ctxt =  Ctree.get_loc pt (p, p_);
   553     (*case*) tac (*of*);
   554 
   555 Step_Specify.by_tactic_input tac (pt, (p, p_'));
   556 (*+*)val Specify_Theory "Diff_App" = tac;
   557 "~~~~~ fun by_tactic_input , args:"; val ((Tactic.Specify_Theory dI), (pt, pos as (_, Pbl)))
   558   = (tac, (pt, (p, p_')));
   559       val (oris, dI, dI', pI', probl, ctxt) = case get_obj I pt p of
   560         PblObj {origin = (oris, (dI,_,_),_), spec = (dI',pI',_), probl, ctxt, ...} =>
   561           (oris, dI, dI', pI', probl, ctxt)
   562 	    val thy = ThyC.get_theory ctxt (if dI' = ThyC.id_empty then dI else dI');
   563       val {model, where_, where_rls,...} = Problem.from_store (Ctree.get_ctxt pt pos) pI
   564 (*\\------------------ step into do_next ---------------------------------------------------//*)
   565 (*\------------------- step into me_Specify_Theory -----------------------------------------//*)
   566 val (p,_,f,nxt,_,pt) = return_me_Specify_Theory;
   567 
   568 val return_me_Specify_Problem (* keep for continuing me *)
   569                      = me nxt p c pt; val Specify_Method ["Optimisation", "by_univariate_calculus"] = #4 return_me_Specify_Problem;
   570 (*/------------------- step into me_Specify_Problem ----------------------------------------\\*)
   571 "~~~~~ fun me , args:"; val (tac, p, _, pt) = (nxt, p, c, pt);
   572       val ctxt = Ctree.get_ctxt pt p
   573 
   574 (** )  val ("ok", (_, _, ptp as (pt, p))) =( **)
   575 (**)    val return_by_tactic =(**) (*case*)
   576       Step.by_tactic tac (pt, p) (*of*);
   577 (*//------------------ step into by_tactic -------------------------------------------------\\*)
   578 "~~~~~ fun by_tactic , args:"; val (tac, (ptp as (pt, p))) = (tac, (pt, p));
   579 
   580     (*case*)
   581       Step.check tac (pt, p) (*of*);
   582 "~~~~~ fun check , args:"; val (tac, (ctree, pos)) = (tac, (pt, p));
   583   (*if*) Tactic.for_specify tac (*then*);
   584 
   585 Specify_Step.check tac (ctree, pos);
   586 "~~~~~ fun check , args:"; val ((Tactic.Specify_Problem pID), (pt, pos as (p, _)))
   587   = (tac, (ctree, pos));
   588 		    val (oris, dI, pI, dI', pI', itms) = case Ctree.get_obj I pt p of
   589 		      Ctree.PblObj {origin = (oris, (dI, pI, _), _), spec = (dI', pI', _), probl = itms, ...}
   590 		        => (oris, dI, pI, dI', pI', itms)
   591 	      val thy = ThyC.get_theory ctxt (if dI' = ThyC.id_empty then dI else dI');
   592 (*\\------------------ step into by_tactic -------------------------------------------------//*)
   593 val ("ok", (_, _, ptp as (pt, p))) = return_by_tactic (* kept for continuing me *);
   594 
   595       (*case*)
   596       Step.do_next p ((pt, Pos.e_pos'), []) (*of*);
   597 "~~~~~ fun do_next , args:"; val ((ip as (_, p_)), (ptp as (pt, p), tacis)) = (p, ((pt, Pos.e_pos'), []));
   598   (*if*) Pos.on_calc_end ip (*else*);
   599       val (_, probl_id, _) = Calc.references (pt, p);
   600 val _ =
   601       (*case*) tacis (*of*);
   602         (*if*) probl_id = Problem.id_empty (*else*);
   603 
   604       Step.switch_specify_solve p_ (pt, ip);
   605 "~~~~~ fun switch_specify_solve , args:"; val (state_pos, (pt, input_pos)) = (p_, (pt, ip));
   606       (*if*) Pos.on_specification ([], state_pos) (*then*);
   607 
   608       Step.specify_do_next (pt, input_pos);
   609 "~~~~~ fun specify_do_next , args:"; val ((ptp as (pt, (p, p_)))) = ((pt, input_pos));
   610     val (_, (p_', tac)) = Specify.find_next_step ptp
   611     val ist_ctxt =  Ctree.get_loc pt (p, p_)
   612 val _ =
   613     (*case*) tac (*of*);
   614 
   615 Step_Specify.by_tactic_input tac (pt, (p, p_'));
   616 "~~~~~ fun by_tactic_input , args:"; val ((Tactic.Specify_Method id), (pt, pos))
   617   = (tac, (pt, (p, p_')));
   618 
   619 (**)val return_complete_for =(**)
   620 (** )  val (o_model, ctxt, i_model) =( **)
   621 Specify_Step.complete_for id (pt, pos);
   622 (*//------------------ step into complete_for ----------------------------------------------\\*)
   623 "~~~~~ fun complete_for , args:"; val (mID, (ctree, pos)) = (id, (pt, pos));
   624 
   625 (*+*)val ["Optimisation", "by_univariate_calculus"] = mID
   626 (*OLD*  )
   627     val {origin = (o_model, _, _), probl = i_prob, ctxt,
   628        ...} = Calc.specify_data (ctree, pos);
   629     val {model = m_patt, where_, where_rls, ...} = MethodC.from_store ctxt mID
   630     val {origin = (root_model, _, _), ...} = Calc.specify_data (ctree, ([], Pos.Und))
   631     val (o_model', ctxt') = O_Model.complete_for m_patt root_model (o_model, ctxt)
   632 ( *---*)
   633     val {origin = (o_model, o_refs, _), spec = refs, probl = i_prob, meth = met_imod, ctxt,
   634        ...} = Calc.specify_data (ctree, pos);
   635     val ctxt = Ctree.get_ctxt ctree pos
   636     val (dI, _, _) = References.select_input o_refs refs;
   637     val {model = m_patt, where_, where_rls, ...} = MethodC.from_store ctxt mID
   638     val {origin = (root_model, _, _), ...} = Calc.specify_data (ctree, ([], Pos.Und))
   639     val (o_model', ctxt') = O_Model.complete_for m_patt root_model (o_model, ctxt)
   640 (*NEW*)
   641 
   642 (**)val return_match_itms_oris = (**)
   643 (** )val (_, (i_model, _)) = ( **)
   644 (*OLD* )
   645    M_Match.match_itms_oris ctxt i_prob (m_patt, where_, where_rls) o_model';
   646 ( *---*)
   647      M_Match.match_itms_oris ctxt o_model' (I_Model.OLD_to_TEST i_prob, I_Model.OLD_to_TEST i_prob)
   648               (m_patt, where_, where_rls);
   649 (*NEW*)
   650 (*//################## @ {context} within fun match_itms_oris -----------------------------\\*)
   651 (*///----------------- step into match_itms_oris -------------------------------------------\\*)
   652 "~~~~~ fun match_itms_oris, args:"; val (ctxt, o_model, (pbl_imod, met_imod), (m_patt, where_, where_rls)) =
   653   (ctxt, o_model', (I_Model.OLD_to_TEST i_prob, I_Model.OLD_to_TEST i_prob), (m_patt, where_, where_rls));
   654 
   655 (**)val return_fill_method =(**)
   656 (** )val met_imod =( **)
   657            fill_method o_model (pbl_imod, met_imod) m_patt;
   658 (*////--------------- step into fill_method -----------------------------------------------\\*)
   659 "~~~~~ fun fill_method , args:"; val (o_model, (pbl_imod, met_imod), met_patt) =
   660   (o_model, (pbl_imod, met_imod), m_patt);
   661 
   662 (*+*)val "[\n(1, [1, 2, 3], true ,#Given, (Cor_TEST Constants [r = 7] , pen2str, Position.T)), \n(2, [1, 2, 3], true ,#Find, (Cor_TEST Maximum A , pen2str, Position.T)), \n(3, [1, 2, 3], true ,#Find, (Cor_TEST AdditionalValues [u, v] , pen2str, Position.T)), \n(4, [1, 2, 3], true ,#Relate, (Cor_TEST Extremum (A = 2 * u * v - u \<up> 2) , pen2str, Position.T)), \n(5, [1, 2], true ,#Relate, (Cor_TEST SideConditions [(u / 2) \<up> 2 + (2 / v) \<up> 2 = r \<up> 2] , pen2str, Position.T))]"
   663  = pbl_imod |> I_Model.to_string_TEST ctxt
   664 (*+*)val "[\n(1, [1, 2, 3], true ,#Given, (Cor_TEST Constants [r = 7] , pen2str, Position.T)), \n(2, [1, 2, 3], true ,#Find, (Cor_TEST Maximum A , pen2str, Position.T)), \n(3, [1, 2, 3], true ,#Find, (Cor_TEST AdditionalValues [u, v] , pen2str, Position.T)), \n(4, [1, 2, 3], true ,#Relate, (Cor_TEST Extremum (A = 2 * u * v - u \<up> 2) , pen2str, Position.T)), \n(5, [1, 2], true ,#Relate, (Cor_TEST SideConditions [(u / 2) \<up> 2 + (2 / v) \<up> 2 = r \<up> 2] , pen2str, Position.T))]"
   665  = met_imod |> I_Model.to_string_TEST ctxt
   666 
   667 (**)val return_max_variants =(**)
   668 (** )val pbl_max_vnts as [2, 1] =( **)
   669  Model_Def.max_variants o_model pbl_imod;
   670 (*//------------------ step into max_variants ----------------------------------------------\\*)
   671 "~~~~~ fun max_variants , args:"; val (o_model, i_model) = (o_model, pbl_imod);
   672       val all_variants as [1, 2, 3] =
   673           map (fn (_, variants, _, _, _) => variants) i_model
   674           |> flat
   675           |> distinct op =
   676       val variants_separated = map (filter_variants' i_model) all_variants
   677 (*+*)val ["[\n(1, [1, 2, 3], true ,#Given, (Cor_TEST Constants [r = 7] , pen2str, Position.T)), \n(2, [1, 2, 3], true ,#Find, (Cor_TEST Maximum A , pen2str, Position.T)), \n(3, [1, 2, 3], true ,#Find, (Cor_TEST AdditionalValues [u, v] , pen2str, Position.T)), \n(4, [1, 2, 3], true ,#Relate, (Cor_TEST Extremum (A = 2 * u * v - u \<up> 2) , pen2str, Position.T)), \n(5, [1, 2], true ,#Relate, (Cor_TEST SideConditions [(u / 2) \<up> 2 + (2 / v) \<up> 2 = r \<up> 2] , pen2str, Position.T))]",
   678           "[\n(1, [1, 2, 3], true ,#Given, (Cor_TEST Constants [r = 7] , pen2str, Position.T)), \n(2, [1, 2, 3], true ,#Find, (Cor_TEST Maximum A , pen2str, Position.T)), \n(3, [1, 2, 3], true ,#Find, (Cor_TEST AdditionalValues [u, v] , pen2str, Position.T)), \n(4, [1, 2, 3], true ,#Relate, (Cor_TEST Extremum (A = 2 * u * v - u \<up> 2) , pen2str, Position.T)), \n(5, [1, 2], true ,#Relate, (Cor_TEST SideConditions [(u / 2) \<up> 2 + (2 / v) \<up> 2 = r \<up> 2] , pen2str, Position.T))]",
   679           "[\n(1, [1, 2, 3], true ,#Given, (Cor_TEST Constants [r = 7] , pen2str, Position.T)), \n(2, [1, 2, 3], true ,#Find, (Cor_TEST Maximum A , pen2str, Position.T)), \n(3, [1, 2, 3], true ,#Find, (Cor_TEST AdditionalValues [u, v] , pen2str, Position.T)), \n(4, [1, 2, 3], true ,#Relate, (Cor_TEST Extremum (A = 2 * u * v - u \<up> 2) , pen2str, Position.T))]"]
   680  = variants_separated |> map (I_Model.to_string_TEST ctxt)
   681 
   682       val sums_corr as [5, 5, 4] = map (cnt_corrects) variants_separated
   683       (*----------------#--#--#*)
   684       (*---------------------^-------^-------^*)
   685       val sum_variant_s as [(5, 1), (5, 2), (4, 3)] = arrange_args sums_corr (1, all_variants)
   686       val max_first as [(5, 2), (5, 1), (4, 3)] = rev (sort (fn ((i, _), (j, _)) => int_ord (i, j)) sum_variant_s)
   687       (*----------------##====--##====--//////---------^^^^*)
   688       (*------------^--^-#-------#*)
   689       val maxes as [2, 1] = filter (fn (cnt, _) => curry op = (fst (hd max_first)) cnt) max_first
   690         |> map snd
   691 val return_max_variants = maxes
   692 (*\\------------------ step into max_variants ----------------------------------------------//*)
   693 val pbl_max_vnts as [2, 1] = return_max_variants;
   694 
   695     (*probably pbl/met_imod = [], so take met_patt; if empty return Sup*)
   696     val i_from_met = map (fn (_, (descr, _)) => (*order from met_patt*)
   697       Pre_Conds.get_descr_vnt descr pbl_max_vnts met_imod) met_patt (*\<longrightarrow> right order for args*)
   698 (*+MET: Sup..*)val "[\n(1, [1, 2, 3], true ,#Given, (Cor_TEST Constants [r = 7] , pen2str, Position.T)), \n(2, [1, 2, 3], true ,#Find, (Cor_TEST Maximum A , pen2str, Position.T)), \n(4, [1, 2, 3], true ,#Relate, (Cor_TEST Extremum (A = 2 * u * v - u \<up> 2) , pen2str, Position.T)), \n(5, [1, 2], true ,#Relate, (Cor_TEST SideConditions [(u / 2) \<up> 2 + (2 / v) \<up> 2 = r \<up> 2] , pen2str, Position.T)), \n(0, [], false ,i_model_empty, (Sup_TEST FunctionVariable, Position.T)), \n(0, [], false ,i_model_empty, (Sup_TEST Input_Descript.Domain, Position.T)), \n(0, [], false ,i_model_empty, (Sup_TEST ErrorBound, Position.T)), \n(3, [1, 2, 3], true ,#Find, (Cor_TEST AdditionalValues [u, v] , pen2str, Position.T))]"
   699   = i_from_met |> I_Model.to_string_TEST ctxt
   700 
   701     val met_max_vnts as [2, 1] = Model_Def.max_variants o_model i_from_met;
   702     val max_vnt as 2 = hd (inter op= pbl_max_vnts met_max_vnts);
   703     (*add items from pbl_imod (without overwriting existing items in met_imod)*)
   704 
   705 val return_add_other = map (
   706            add_other max_vnt pbl_imod) i_from_met;
   707 (*+*)val "[\n(1, [1, 2, 3], true ,#Given, (Cor_TEST Constants [r = 7] , pen2str, Position.T)), \n(2, [1, 2, 3], true ,#Find, (Cor_TEST Maximum A , pen2str, Position.T)), \n(4, [1, 2, 3], true ,#Relate, (Cor_TEST Extremum (A = 2 * u * v - u \<up> 2) , pen2str, Position.T)), \n(5, [1, 2], true ,#Relate, (Cor_TEST SideConditions [(u / 2) \<up> 2 + (2 / v) \<up> 2 = r \<up> 2] , pen2str, Position.T)), \n(0, [2], false ,i_model_empty, (Sup_TEST FunctionVariable, Position.T)), \n(0, [2], false ,i_model_empty, (Sup_TEST Input_Descript.Domain, Position.T)), \n(0, [2], false ,i_model_empty, (Sup_TEST ErrorBound, Position.T)), \n(3, [1, 2, 3], true ,#Find, (Cor_TEST AdditionalValues [u, v] , pen2str, Position.T))]"
   708   = return_add_other |> I_Model.to_string_TEST ctxt;
   709 (*/////-------------- step into add_other -------------------------------------------------\\*)
   710 "~~~~~ fun add_other_5 , args:"; val (max_vnt, i1_model, (i2, _, bool2, m_field2, (Sup_TEST (descr2, ts2), pos2))) =
   711   (max_vnt, pbl_imod, nth 5 i_from_met);
   712 
   713 (*+*)val Const ("Input_Descript.FunctionVariable", _) = descr2;
   714 
   715 val (_, vnts1, _, _, (feedb1, _)) = (i2, [], bool2, m_field2, (Sup_TEST (descr2, ts2), pos2))
   716 val SOME (descr1 as (Const ("Input_Descript.FunctionVariable", _)) ) =
   717       get_dscr' feedb1
   718 val true =
   719         descr1 = descr2
   720 val true =
   721           Model_Def.member_vnt vnts1 max_vnt
   722 val NONE =
   723     find_first (fn (_, vnts1, _, _, (feedb1, _)) => case get_dscr' feedb1 of
   724           NONE => false
   725         | SOME descr1 => descr1 = descr2 andalso Model_Def.member_vnt vnts1 max_vnt) i1_model
   726 
   727 val return_add_other_1 = (i2, [max_vnt], bool2, m_field2, (Sup_TEST (descr2, ts2), pos2))
   728 val check as true = return_add_other_1 = nth 5 return_add_other
   729 (*\\\\\-------------- step into add_other -------------------------------------------------//*)
   730     val i_from_pbl = return_add_other
   731 (*\\\\---------------- step into fill_method -----------------------------------------------//*)
   732 val return_fill_method_step = filter (fn (_, vnts', _, _, _) => member op = vnts' max_vnt) i_from_met
   733 
   734 (*+MET: dropped ALL DUE TO is_empty_single_TEST*)val "[\n(1, [1, 2, 3], true ,#Given, (Cor_TEST Constants [r = 7] , pen2str, Position.T)), \n(2, [1, 2, 3], true ,#Find, (Cor_TEST Maximum A , pen2str, Position.T)), \n(4, [1, 2, 3], true ,#Relate, (Cor_TEST Extremum (A = 2 * u * v - u \<up> 2) , pen2str, Position.T)), \n(5, [1, 2], true ,#Relate, (Cor_TEST SideConditions [(u / 2) \<up> 2 + (2 / v) \<up> 2 = r \<up> 2] , pen2str, Position.T)), \n(3, [1, 2, 3], true ,#Find, (Cor_TEST AdditionalValues [u, v] , pen2str, Position.T))]" =
   735   return_fill_method_step |> I_Model.to_string_TEST ctxt
   736 (*+*)val                                             "[\n(1, [1, 2, 3], true ,#Given, (Cor_TEST Constants [r = 7] , pen2str, Position.T)), \n(2, [1, 2, 3], true ,#Find, (Cor_TEST Maximum A , pen2str, Position.T)), \n(4, [1, 2, 3], true ,#Relate, (Cor_TEST Extremum (A = 2 * u * v - u \<up> 2) , pen2str, Position.T)), \n(5, [1, 2], true ,#Relate, (Cor_TEST SideConditions [(u / 2) \<up> 2 + (2 / v) \<up> 2 = r \<up> 2] , pen2str, Position.T)), \n(0, [2], false ,i_model_empty, (Sup_TEST FunctionVariable, Position.T)), \n(0, [2], false ,i_model_empty, (Sup_TEST Input_Descript.Domain, Position.T)), \n(0, [2], false ,i_model_empty, (Sup_TEST ErrorBound, Position.T)), \n(3, [1, 2, 3], true ,#Find, (Cor_TEST AdditionalValues [u, v] , pen2str, Position.T))]"
   737  = return_fill_method |> I_Model.to_string_TEST ctxt;
   738 return_fill_method_step = return_fill_method; (*latter is correct, did not investigate further*)
   739 (*\\\----------------- step into match_itms_oris -------------------------------------------//*)
   740 (*\\################# @ {context} within fun match_itms_oris ------------------------------//*)
   741 val (_, (i_model, _)) = return_match_itms_oris;
   742 
   743 (*||------------------ continue. complete_for ------------------------------------------------*)
   744       val (o_model, ctxt, i_model) = return_complete_for
   745 (*+isa*)val "[\n(1, [1, 2, 3], true ,#Given, (Cor_TEST Constants [r = 7] , pen2str, Position.T)), \n(2, [1, 2, 3], true ,#Find, (Cor_TEST Maximum A , pen2str, Position.T)), \n(4, [1, 2, 3], true ,#Relate, (Cor_TEST Extremum (A = 2 * u * v - u \<up> 2) , pen2str, Position.T)), \n(5, [1, 2], true ,#Relate, (Cor_TEST SideConditions [(u / 2) \<up> 2 + (2 / v) \<up> 2 = r \<up> 2] , pen2str, Position.T)), \n(0, [2], false ,i_model_empty, (Sup_TEST FunctionVariable, Position.T)), \n(0, [2], false ,i_model_empty, (Sup_TEST Input_Descript.Domain, Position.T)), \n(0, [2], false ,i_model_empty, (Sup_TEST ErrorBound, Position.T)), \n(3, [1, 2, 3], true ,#Find, (Cor_TEST AdditionalValues [u, v] , pen2str, Position.T))]"
   746  = i_model |> I_Model.to_string_TEST ctxt(*+isa*)
   747 (*+isa2:MET.Mis* ) val "[\n(1 ,[1, 2, 3] ,true ,#Given ,Cor Constants [r = 7] , pen2str), \n(2 ,[1, 2, 3] ,true ,#Find ,Cor Maximum A , pen2str), \n(3 ,[1, 2, 3] ,true ,#Find ,Cor AdditionalValues [u, v] , pen2str), \n(4 ,[1, 2, 3] ,true ,#Relate ,Cor Extremum (A = 2 * u * v - u \<up> 2) , pen2str), \n(5 ,[1, 2] ,true ,#Relate ,Cor SideConditions [(u / 2) \<up> 2 + (2 / v) \<up> 2 = r \<up> 2] , pen2str), \n(7 ,[1] ,false ,#Given ,Mis FunctionVariable funvar), \n(10 ,[1, 2] ,false ,#Given ,Mis Input_Descript.Domain doma), \n(12 ,[1, 2, 3] ,false ,#Given ,Mis ErrorBound err)]" =
   748   i_model |> I_Model.to_string ctxt ( *+isa2*)
   749 (*\\------------------ step into complete_for ----------------------------------------------//*)
   750       val (o_model, ctxt, i_model) = return_complete_for
   751 
   752 (*|------------------- continue. complete_for ------------------------------------------------*)
   753 val return_complete_for_step = (o_model', ctxt', i_model)
   754 
   755 val (o_model'_step, i_model_step) = (#1 return_complete_for_step, #3 return_complete_for_step)
   756 val (o_model', i_model) = (#1 return_complete_for, #3 return_complete_for)
   757 ;
   758 (*+*)if (o_model'_step, i_model_step) = (o_model', i_model)
   759 (*+*)then () else error "return_complete_for_step <> return_complete_for";
   760 (*\------------------- step into me Specify_Problem ----------------------------------------//*)
   761 val (p,_,f,nxt,_,pt) = return_me_Specify_Problem
   762 
   763 val return_me_Specify_Method
   764                      = me nxt p c pt; val Add_Given "FunctionVariable a" = #4 return_me_Specify_Method;
   765 (*/------------------- step into me_Specify_Method -----------------------------------------\\*)
   766 "~~~~~ fun me , args:"; val (tac, p, _, pt) = (nxt, p, c, pt);
   767 
   768 (*+*)val "[]" =(*+*) get_obj g_met pt (fst p) |> I_Model.to_string ctxt
   769 
   770       val ctxt = Ctree.get_ctxt pt p
   771       val (pt, p) = 
   772   	    case Step.by_tactic tac (pt, p) of
   773   		    ("ok", (_, _, ptp)) => ptp;
   774 
   775 (*quick step into --> me_Specify_Method*)
   776 (*+*)val Specify_Method ["Optimisation", "by_univariate_calculus"] = tac;
   777 (*    Step.by_tactic*)
   778 "~~~~~ fun by_tactic , args:"; val () = ();
   779 (*    Step.check*)
   780 "~~~~~ fun check , args:"; val () = ();
   781 (*Specify_Step.check (Tactic.Specify_Method*)
   782 "~~~~~ fun check , args:"; val () = ();
   783 (*Specify_Step.complete_for*)
   784 "~~~~~ fun complete_for , args:"; val () = ();
   785 (* M_Match.match_itms_oris*)
   786 "~~~~~ fun match_itms_oris , args:"; val () = ();
   787 
   788 (*+isa*)val"[\n(1 ,[1, 2, 3] ,true ,#Given ,Cor Constants [r = 7] , pen2str), \n(2 ,[1, 2, 3] ,true ,#Find ,Cor Maximum A , pen2str), \n(4 ,[1, 2, 3] ,true ,#Relate ,Cor Extremum (A = 2 * u * v - u \<up> 2) , pen2str), \n(5 ,[1, 2] ,true ,#Relate ,Cor SideConditions [(u / 2) \<up> 2 + (2 / v) \<up> 2 = r \<up> 2] , pen2str), \n(0 ,[2] ,false ,i_model_empty ,Sup FunctionVariable), \n(0 ,[2] ,false ,i_model_empty ,Sup Input_Descript.Domain), \n(0 ,[2] ,false ,i_model_empty ,Sup ErrorBound), \n(3 ,[1, 2, 3] ,true ,#Find ,Cor AdditionalValues [u, v] , pen2str)]"
   789  = get_obj g_met pt (fst p) |> I_Model.to_string ctxt;
   790 
   791          (*case*)
   792       Step.do_next p ((pt, Pos.e_pos'), []) (*of*);
   793 (*//------------------ step into Step.do_next ----------------------------------------------\\*)
   794 "~~~~~ fun do_next , args:"; val ((ip as (_, p_)), (ptp as (pt, p), tacis)) = (p, ((pt, Pos.e_pos'), []));
   795   (*if*) Pos.on_calc_end ip (*else*);
   796       val (_, probl_id, _) = Calc.references (pt, p);
   797 val _ =
   798       (*case*) tacis (*of*);
   799         (*if*) probl_id = Problem.id_empty (*else*);
   800 
   801       Step.switch_specify_solve p_ (pt, ip);
   802 (*///----------------- step into Step.switch_specify_solve ---------------------------------\\*)
   803 "~~~~~ fun switch_specify_solve , args:"; val (state_pos, (pt, input_pos)) = (p_, (pt, ip));
   804       (*if*) Pos.on_specification ([], state_pos) (*then*);
   805 
   806       Step.specify_do_next (pt, input_pos);
   807 (*////---------------- step into Step.specify_do_next --------------------------------------\\*)
   808 "~~~~~ fun specify_do_next , args:"; val ((ptp as (pt, (p, p_)))) = (pt, input_pos);
   809 
   810     val (_, (p_', tac)) =
   811    Specify.find_next_step ptp;
   812 (*/////--------------- step into find_next_step --------------------------------------------\\*)
   813 "~~~~~ fun find_next_step , args:"; val ((pt, pos as (_, p_))) = (ptp);
   814     val {meth = met, origin = origin as (oris, o_refs as (_, pI', mI'), _), probl = pbl,
   815       spec = refs, ...} = Calc.specify_data (pt, pos);
   816     val ctxt = Ctree.get_ctxt pt pos;
   817       (*if*) Ctree.just_created (pt, pos) andalso origin <> Ctree.e_origin (*else*);
   818         (*if*) p_ = Pos.Pbl (*else*);
   819 
   820 (*+isa*)val     "[\n(1 ,[1, 2, 3] ,true ,#Given ,Cor Constants [r = 7] , pen2str), \n(2 ,[1, 2, 3] ,true ,#Find ,Cor Maximum A , pen2str), \n(4 ,[1, 2, 3] ,true ,#Relate ,Cor Extremum (A = 2 * u * v - u \<up> 2) , pen2str), \n(5 ,[1, 2] ,true ,#Relate ,Cor SideConditions [(u / 2) \<up> 2 + (2 / v) \<up> 2 = r \<up> 2] , pen2str), \n(0 ,[2] ,false ,i_model_empty ,Sup FunctionVariable), \n(0 ,[2] ,false ,i_model_empty ,Sup Input_Descript.Domain), \n(0 ,[2] ,false ,i_model_empty ,Sup ErrorBound), \n(3 ,[1, 2, 3] ,true ,#Find ,Cor AdditionalValues [u, v] , pen2str)]"
   821  = met |> I_Model.to_string ctxt;
   822 
   823 (**)val ("dummy", (Met, Add_Given "FunctionVariable a")) =(**)
   824    Specify.for_method ctxt oris (o_refs, refs) (pbl, met);
   825 (*///// /------------- step into Step.for_method -------------------------------------------\\*)
   826 "~~~~~ fun for_method , args:"; val (ctxt, oris, ((dI', pI', mI'), (dI, pI, mI)), (_, met))
   827   = (ctxt, oris, (o_refs, refs), (pbl, met));
   828     val cmI = if mI = MethodC.id_empty then mI' else mI;
   829     val {model, where_rls, where_, ...} = MethodC.from_store ctxt cmI;    (*..MethodC ?*)
   830     val (preok, _) = Pre_Conds.check ctxt where_rls where_ (model, I_Model.OLD_to_TEST met);
   831 val NONE =
   832     (*case*) find_first (I_Model.is_error o #5) met (*of*);
   833 
   834 (** )SOME (fd, ct') =( **)
   835 (**)val return_item_to_add =(**)
   836       (*case*)
   837    Specify.item_to_add  ctxt oris (I_Model.OLD_to_TEST met) (*of*);
   838 (*///// //------------ step into item_to_add -----------------------------------------------\\*)
   839 "~~~~~ fun item_to_add , args:"; val (ctxt, o_model, i_model) = (ctxt, oris, I_Model.OLD_to_TEST met);
   840 (*+*)val "[\n(1, [\"1\", \"2\", \"3\"], #Given, Constants, [\"[r = 7]\"]), \n(2, [\"1\", \"2\", \"3\"], #Given, Maximum, [\"A\"]), \n(3, [\"1\", \"2\", \"3\"], #Find, AdditionalValues, [\"[u]\", \"[v]\"]), \n(4, [\"1\", \"2\", \"3\"], #Given, Extremum, [\"A = 2 * u * v - u \<up> 2\"]), \n(5, [\"1\", \"2\"], #Given, SideConditions, [\"[(u / 2) \<up> 2 + (2 / v) \<up> 2 = r \<up> 2]\"]), \n(6, [\"3\"], #Given, SideConditions, [\"[u / 2 = r * sin \<alpha>]\", \"[2 / v = r * cos \<alpha>]\"]), \n(7, [\"1\"], #Given, FunctionVariable, [\"a\"]), \n(8, [\"2\"], #Given, FunctionVariable, [\"b\"]), \n(9, [\"3\"], #Given, FunctionVariable, [\"\<alpha>\"]), \n(10, [\"1\", \"2\"], #Given, Input_Descript.Domain, [\"{0<..<r}\"]), \n(11, [\"3\"], #Given, Input_Descript.Domain, [\"{0<..<\<pi> / 2}\"]), \n(12, [\"1\", \"2\", \"3\"], #Given, ErrorBound, [\"\<epsilon> = 0\"])]"
   841  = oris |> O_Model.to_string ctxt
   842 (*+*)val "[\n(1, [1, 2, 3], true ,#Given, (Cor_TEST Constants [r = 7] , pen2str, Position.T)), \n(2, [1, 2, 3], true ,#Find, (Cor_TEST Maximum A , pen2str, Position.T)), \n(4, [1, 2, 3], true ,#Relate, (Cor_TEST Extremum (A = 2 * u * v - u \<up> 2) , pen2str, Position.T)), \n(5, [1, 2], true ,#Relate, (Cor_TEST SideConditions [(u / 2) \<up> 2 + (2 / v) \<up> 2 = r \<up> 2] , pen2str, Position.T)), \n(0, [2], false ,i_model_empty, (Sup_TEST FunctionVariable, Position.T)), \n(0, [2], false ,i_model_empty, (Sup_TEST Input_Descript.Domain, Position.T)), \n(0, [2], false ,i_model_empty, (Sup_TEST ErrorBound, Position.T)), \n(3, [1, 2, 3], true ,#Find, (Cor_TEST AdditionalValues [u, v] , pen2str, Position.T))]"
   843  = i_model |> I_Model.to_string_TEST ctxt
   844 
   845     val max_vnt = last_elem (*this decides, for which variant initially help is given*)
   846       (Model_Def.max_variants o_model i_model)
   847     val o_vnts = filter (fn (_, vnts, _, _, _) => member op= vnts max_vnt) o_model
   848     val i_to_select = i_model
   849       |> filter_out (fn (_, vnts, _, _, (I_Model.Cor_TEST _, _)) => member op= vnts max_vnt | _ => false)
   850       |> select_inc_lists
   851 (*+*)val "[\n(0, [2], false ,i_model_empty, (Sup_TEST FunctionVariable, Position.T)), \n(0, [2], false ,i_model_empty, (Sup_TEST Input_Descript.Domain, Position.T)), \n(0, [2], false ,i_model_empty, (Sup_TEST ErrorBound, Position.T))]"
   852  = i_to_select |> I_Model.to_string_TEST ctxt
   853 
   854 val false =
   855     (*if*) i_to_select = [] (*else*);
   856 
   857 (** )val SOME (_, _, _, m_field, (feedb, _)) =( **)
   858 (**)val return_fill_from_o = (**)
   859       (*case*) I_Model.fill_from_o o_vnts (hd i_to_select) (*of*);
   860 (*///// ///----------- step into fill_from_o -----------------------------------------------\\*)
   861 "~~~~~ fun fill_from_o , args:"; val (o_model, (i, vnts, bool, _, (feedb, pos))) =
   862   (o_vnts, (hd i_to_select));
   863     val (m_field, all_value) =
   864       case find_first (fn (_, _, _, descr', _) => Pre_Conds.descriptor_exists descr' feedb) o_model of
   865         SOME (_, _, m_field, _, ts) =>  (m_field, ts)
   866     val descr = Pre_Conds.get_dscr'' feedb (*i_single has been filtered appropriately*)
   867 val false =
   868     (*if*) Model_Def.is_list_descr descr (*else*);
   869 val return_fill_from_o_STEP = SOME (i, vnts, bool, m_field, (Cor_TEST (descr, all_value), pos))
   870 (*-------------------- stopped after ERROR found ---------------------------------------------*)
   871 (*\\\\\ \\\----------- step into fill_from_o -----------------------------------------------//*)
   872 val SOME (_, _, _, m_field, (feedb, _)) = return_fill_from_o
   873 
   874 (*||||| ||------------ step into item_to_add -----------------------------------------------//*)
   875 (*\\\\\ \\\----------- step into item_to_add -----------------------------------------------//*)
   876 val return_item_to_add_STEP as SOME ("#Given", "FunctionVariable a") =
   877   SOME (m_field, feedb |> I_Model.feedb_args_to_string ctxt)
   878 (*\\\\\ \\------------ step into item_to_add -----------------------------------------------//*)
   879 val SOME (fd, ct') = return_item_to_add;
   880 (*||||| |------------- contine.. Step.for_method ---------------------------------------------*)
   881 val return_for_method_STEP = ("dummy", (Pos.Met, P_Model.mk_additem fd ct'))
   882 
   883 (*\\\\\ \------------- step into Step.for_method -------------------------------------------//*)
   884 (*\------------------- step into me_Specify_Method -----------------------------------------//*)
   885 
   886 val (p,_,f,nxt,_,pt) = return_me_Specify_Method;
   887                                       val Add_Given "FunctionVariable a" = nxt;
   888 val (p,_,f,nxt,_,pt) = me nxt p c pt; val Add_Given "Input_Descript.Domain {0<..<r}" = nxt
   889 val (p,_,f,nxt,_,pt) = me nxt p c pt; val Add_Given "ErrorBound (\<epsilon> = 0)" = nxt;
   890 (*ErRoR type_of: type mismatch in application, bool, bool list, (#) [r = 7] --> 200a-start-method
   891 val (p,_,f,nxt,_,pt) = me nxt p c pt; val Apply_Method xxx = nxt
   892 *)