test/Tools/isac/Minisubpbl/150a-add-given-Maximum.sml
author wneuper <Walther.Neuper@jku.at>
Mon, 31 Oct 2022 18:28:36 +0100
changeset 60585 b7071d1dd263
parent 60578 baf06b1b2aaa
child 60586 007ef64dbb08
permissions -rw-r--r--
rename fields in Probl_Def.T
Walther@60578
     1
(* Title:  "Minisubpbl/150a-add-given-Maximum.sml"
Walther@60578
     2
   Author: Walther Neuper 1105
Walther@60578
     3
   (c) copyright due to lincense terms.
Walther@60578
     4
Walther@60578
     5
Note: This test --- steps into me --- more than once;
Walther@60578
     6
  in order not to get lost while working in Test_Some etc, 
Walther@60578
     7
  re-introduce  ML (*--- step into XXXXX ---*) and Co.
Walther@60578
     8
  and use Sidekick for orientation.
Walther@60578
     9
*)
Walther@60578
    10
Walther@60578
    11
open Test_Code
Walther@60578
    12
open Pos
Walther@60578
    13
open Ctree
Walther@60578
    14
open Tactic
Walther@60578
    15
Walther@60578
    16
val (_(*example text*),
Walther@60578
    17
  (model as ("Constants [r = (7::real)]" :: "Maximum A" :: "AdditionalValues [u, v]" :: 
Walther@60578
    18
     "Extremum (A = 2 * u * v - u \<up> 2)" :: 
Walther@60578
    19
     "SideConditions [((u::real) / 2) \<up> 2 + (2 / v) \<up> 2 = r \<up> 2]" :: 
Walther@60578
    20
     "SideConditions [((u::real) / 2) \<up> 2 + (2 / v) \<up> 2 = r \<up> 2]" :: 
Walther@60578
    21
     "SideConditions [(u::real) / 2 = r * sin \<alpha>, 2 / v = r * cos \<alpha>]" :: 
Walther@60578
    22
     "FunctionVariable a" :: "FunctionVariable b" :: "FunctionVariable \<alpha>" :: 
Walther@60578
    23
     "Domain {0 <..< r}" :: "Domain {0 <..< r}" :: "Domain {0 <..< \<pi> / 2}" ::
Walther@60578
    24
     "ErrorBound (\<epsilon> = (0::real))" :: []), 
Walther@60578
    25
   refs as ("Diff_App", 
Walther@60578
    26
     ["univariate_calculus", "Optimisation"],
Walther@60578
    27
     ["Optimisation", "by_univariate_calculus"])))
Walther@60578
    28
  = Store.get (KEStore_Elems.get_expls @{theory}) ["Diff_App-No.123a"] ["Diff_App-No.123a"];
Walther@60578
    29
Walther@60578
    30
val (p,_,f,nxt,_,pt) = Test_Code.init_calc @{context} [(model, refs)]; val Model_Problem = nxt;
Walther@60578
    31
val c = [];
Walther@60578
    32
Walther@60578
    33
val (p''', _, f''', nxt''', _, pt''') = me nxt p c pt; val Add_Given "Constants [r = 7]" = nxt''';
Walther@60578
    34
Walther@60578
    35
(*//------------------ step into me Model_Problem ------------------------------------------\\*)
Walther@60578
    36
"~~~~~ fun me , args:"; val (tac, (p:Pos.pos'), (_:Test_Code.NEW), (pt:Ctree.ctree)) = (nxt, p, c, pt);
Walther@60578
    37
    val (pt, p) = 
Walther@60578
    38
      (*ERROR Specify.item_to_add: types or dsc DO NOT MATCH BETWEEN fmz --- pbt ... see 100-init-rootpbl.sml*)
Walther@60578
    39
	    case Step.by_tactic tac (pt,p) of
Walther@60578
    40
		    ("ok", (_, _, ptp)) => ptp;
Walther@60578
    41
Walther@60578
    42
val    ("ok", (ts as (_, _, _) :: _, _, _)) =
Walther@60578
    43
    (*case*)
Walther@60578
    44
      Step.do_next p ((pt, Pos.e_pos'), []) (*of*);
Walther@60578
    45
(*//------------------ step into do_next ---------------------------------------------------\\*)
Walther@60578
    46
val (ts'''', (pt'''', p'''')) = (ts, (pt, p)); (* keep for continuing me Model_Problem *)
Walther@60578
    47
Walther@60578
    48
"~~~~~ fun do_next , args:"; val (((ip as (_,p_)):pos'), ((ptp as (pt,p), tacis):Calc.state_pre)) =
Walther@60578
    49
  (p, ((pt, e_pos'),[]));
Walther@60578
    50
    val pIopt = get_pblID (pt,ip);
Walther@60578
    51
    (*if*) ip = ([],Res); (* = false*)
Walther@60578
    52
      val _ = (*case*) tacis (*of*);
Walther@60578
    53
      val SOME _ = (*case*) pIopt (*of*);
Walther@60578
    54
Walther@60578
    55
    val ("ok", ([(Add_Given "Constants [r = 7]", _, _)], [], _)) =
Walther@60578
    56
      Step.switch_specify_solve p_ (pt, ip);
Walther@60578
    57
"~~~~~ fun switch_specify_solve , args:"; val (state_pos, (pt, input_pos)) = (p_, (pt, ip));
Walther@60578
    58
      (*if*) Pos.on_specification ([], state_pos) (*then*);
Walther@60578
    59
Walther@60578
    60
    val ("ok", ([(Add_Given "Constants [r = 7]", _, _)], [], _)) =
Walther@60578
    61
      Step.specify_do_next (pt, input_pos);
Walther@60578
    62
"~~~~~ fun specify_do_next , args:"; val (ptp as (pt, (p, p_))) = (pt, input_pos);
Walther@60578
    63
Walther@60578
    64
    val (_, (p_', tac)) =
Walther@60578
    65
   Specify.find_next_step ptp;
Walther@60578
    66
"~~~~~ fun find_next_step , args:"; val ((pt, pos as (_, p_))) = (ptp);
Walther@60578
    67
    val {meth = met, origin = origin as (oris, o_refs as (_, pI', mI'), _), probl = pbl,
Walther@60578
    68
      spec = refs, ...} = Calc.specify_data (pt, pos);
Walther@60578
    69
    val ctxt = Ctree.get_ctxt pt pos;
Walther@60578
    70
      (*if*) Ctree.just_created (pt, pos) andalso origin <> Ctree.e_origin (*else*);
Walther@60578
    71
        (*if*) p_ = Pos.Pbl (*then*);
Walther@60578
    72
Walther@60578
    73
   Specify.for_problem ctxt oris (o_refs, refs) (pbl, met);
Walther@60578
    74
"~~~~~ fun for_problem , args:"; val (ctxt, oris, ((dI', pI', mI'), (dI, pI, mI)), (pbl, met))
Walther@60578
    75
  = (ctxt, oris, (o_refs, refs), (pbl, met));
Walther@60578
    76
    val cdI = if dI = ThyC.id_empty then dI' else dI;
Walther@60578
    77
    val cpI = if pI = Problem.id_empty then pI' else pI;
Walther@60578
    78
    val cmI = if mI = MethodC.id_empty then mI' else mI;
Walther@60585
    79
    val {model = pbt, where_rls, where_, ...} = Problem.from_store ctxt cpI;
Walther@60578
    80
    val {ppc = mpc, ...} = MethodC.from_store ctxt cmI
Walther@60585
    81
    val (preok, _) = Pre_Conds.check where_rls where_ pbl 0;
Walther@60578
    82
    (*if*) dI' = ThyC.id_empty andalso dI = ThyC.id_empty (*else*);
Walther@60578
    83
      (*if*) pI' = Problem.id_empty andalso pI = Problem.id_empty (*else*);
Walther@60578
    84
      (*case*) find_first (I_Model.is_error o #5) pbl (*of*);
Walther@60578
    85
Walther@60578
    86
        (*case*)
Walther@60578
    87
   Specify.item_to_add (ThyC.get_theory_PIDE ctxt
Walther@60578
    88
            (if dI = ThyC.id_empty then dI' else dI)) oris pbt pbl (*of*);
Walther@60578
    89
"~~~~~ fun item_to_add , args:"; val (thy, oris, _, itms)
Walther@60578
    90
  = ((ThyC.get_theory_PIDE ctxt (if dI = ThyC.id_empty then dI' else dI)), oris, pbt, pbl);
Walther@60578
    91
      fun testr_vt v ori = member op= (#2 (ori : O_Model.single)) v andalso (#3 ori) <> "#undef"
Walther@60578
    92
      fun testi_vt v itm = member op= (#2 (itm : I_Model.single)) v
Walther@60578
    93
      fun test_id ids r = member op= ids (#1 (r : O_Model.single))
Walther@60578
    94
      fun test_subset itm (_, _, _, d, ts) = 
Walther@60578
    95
        (I_Model.descriptor (#5 (itm: I_Model.single))) = d andalso subset op = (I_Model.o_model_values (#5 itm), ts)
Walther@60578
    96
      fun false_and_not_Sup (_, _, false, _, I_Model.Sup _) = false
Walther@60578
    97
        | false_and_not_Sup (_, _, false, _, _) = true
Walther@60578
    98
        | false_and_not_Sup _ = false
Walther@60578
    99
      val v = if itms = [] then 1 else I_Model.max_variant itms
Walther@60578
   100
      val vors = if v = 0 then oris else filter (testr_vt v) oris
Walther@60578
   101
      val vits =
Walther@60578
   102
        if v = 0
Walther@60578
   103
        then itms                                 (* because of dsc without dat *)
Walther@60578
   104
  	    else filter (testi_vt v) itms;                             (* itms..vat *)
Walther@60578
   105
      val icl = filter false_and_not_Sup vits;                    (* incomplete *)
Walther@60578
   106
      (*if*) icl = [] (*else*);
Walther@60578
   107
val SOME ori =
Walther@60578
   108
        (*case*) find_first (test_subset (hd icl)) vors (*of*);
Walther@60578
   109
(*-------------------- stop step into do_next ------------------------------------------------*)
Walther@60578
   110
(*\\------------------ step into into do_next ----------------------------------------------//*)
Walther@60578
   111
Walther@60578
   112
(*-------------------- continue with me Model_Problem ----------------------------------------*)
Walther@60578
   113
"~~~~~ continue fun me Model_Problem";  val (ts, (p, pt)) = (ts'''', (p'''', pt''''));
Walther@60578
   114
val tacis as (_::_) =
Walther@60578
   115
        (*case*) ts (*of*);
Walther@60578
   116
          val (tac, _, _) = last_elem tacis
Walther@60578
   117
Walther@60578
   118
val return = (p, [] : NEW,
Walther@60578
   119
           TESTg_form ctxt (pt, p), tac, Celem.Sundef, pt);
Walther@60578
   120
"~~~~~ fun TESTg_form , args:"; val (ctxt, ptp) = (ctxt, (pt, p));
Walther@60578
   121
    val (form, _, _) = ME_Misc.pt_extract ctxt ptp
Walther@60578
   122
val Ctree.ModSpec (_, p_, _, gfr, pre, _) =
Walther@60578
   123
    (*case*) form (*of*);
Walther@60578
   124
Walther@60578
   125
(*+*)val Pos.Pbl = p_;
Walther@60578
   126
    Test_Out.PpcKF (  (Test_Out.Problem [],
Walther@60578
   127
 			P_Model.from (Proof_Context.theory_of ctxt) gfr pre));
Walther@60578
   128
Walther@60578
   129
   P_Model.from (Proof_Context.theory_of ctxt) gfr pre;
Walther@60578
   130
"~~~~~ fun from , args:"; val (thy, itms, pre) = ((Proof_Context.theory_of ctxt), gfr, pre);
Walther@60578
   131
    fun coll ppc [] = ppc
Walther@60578
   132
      | coll ppc ((_, _, _, field, itm_) :: itms) =
Walther@60578
   133
        coll (add_sel_ppc thy field ppc (item_from_feedback thy itm_)) itms;
Walther@60578
   134
Walther@60578
   135
 val gfr = coll P_Model.empty itms;
Walther@60578
   136
"~~~~~ fun coll , args:"; val (ppc, ((aaa, bbb_,ccc_, field, itm_) :: itms))
Walther@60578
   137
  = (P_Model.empty, itms);
Walther@60578
   138
Walther@60578
   139
(*+*)val 4 = length itms;
Walther@60578
   140
(*+*)val itm = nth 1 itms;
Walther@60578
   141
Walther@60578
   142
           coll P_Model.empty [itm];
Walther@60578
   143
"~~~~~ fun coll , iterate:"; val (ppc, ((aaa, bbb_,ccc_, field, itm_) :: []))
Walther@60578
   144
  = (P_Model.empty, [itm]);
Walther@60578
   145
Walther@60578
   146
          (add_sel_ppc thy field ppc (item_from_feedback thy itm_));
Walther@60578
   147
"~~~~~ fun add_sel_ppc , args:"; val ((_: theory), sel, {Given = gi, Where = wh, Find = fi, With = wi, Relate = re}, x )
Walther@60578
   148
  = (thy, field, ppc, (item_from_feedback thy itm_));
Walther@60578
   149
Walther@60578
   150
   P_Model.item_from_feedback thy itm_;
Walther@60578
   151
"~~~~~ fun item_from_feedback , args:"; val (thy, (I_Model.Inc ((d, ts), _))) = (thy, itm_);
Walther@60578
   152
  P_Model.Incompl (UnparseC.term_in_thy thy (Input_Descript.join (d, ts)));
Walther@60578
   153
(*-------------------- stop step into me Model_Problem ---------------------------------------*)
Walther@60578
   154
(*\\------------------ step into into me Model_Problem -------------------------------------//*)
Walther@60578
   155
Walther@60578
   156
val (p,_,f,nxt,_,pt) = me nxt''' p''' c pt'''; val Add_Find "Maximum A" = nxt;
Walther@60578
   157
val (p,_,f,nxt,_,pt) = me nxt p c pt; val Add_Find "AdditionalValues [u]" = nxt;
Walther@60578
   158
val (p,_,f,nxt,_,pt) = me nxt p c pt; val Add_Find "AdditionalValues [v]" = nxt;
Walther@60578
   159
val (p,_,f,nxt,_,pt) = me nxt p c pt; val Add_Relation "Extremum (A = 2 * u * v - u \<up> 2)" = nxt;
Walther@60578
   160
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;
Walther@60578
   161
val (p,_,f,nxt,_,pt) = me nxt p c pt; val Specify_Theory "Diff_App" = nxt;
Walther@60578
   162
Walther@60578
   163
val (p''',_,f,nxt''',_,pt''') = me nxt p [1] pt; val Specify_Problem ["univariate_calculus", "Optimisation"] = nxt''';
Walther@60578
   164
Walther@60578
   165
(*//------------------ step into me Specify_Theory -----------------------------------------\\*)
Walther@60578
   166
"~~~~~ fun me , args:"; val (tac, p, _, pt) = (nxt, p, c, pt);
Walther@60578
   167
      val ctxt = Ctree.get_ctxt pt p
Walther@60578
   168
      val (pt, p) = 
Walther@60578
   169
  	    case Step.by_tactic tac (pt, p) of
Walther@60578
   170
  		    ("ok", (_, _, ptp)) => ptp
Walther@60578
   171
Walther@60578
   172
val ("ok", (ts as (_, _, _) :: _, _, _)) =
Walther@60578
   173
    (*case*)
Walther@60578
   174
      Step.do_next p ((pt, Pos.e_pos'), []) (*of*);
Walther@60578
   175
(*//------------------ step into do_next ---------------------------------------------------\\*)
Walther@60578
   176
"~~~~~ fun do_next , args:"; val ((ip as (_, p_)), (ptp as (pt, p), tacis))
Walther@60578
   177
  = (p, ((pt, Pos.e_pos'), [])) (*of*);
Walther@60578
   178
  (*if*) Pos.on_calc_end ip (*else*);
Walther@60578
   179
      val (_, probl_id, _) = Calc.references (pt, p);
Walther@60578
   180
val _ =
Walther@60578
   181
      (*case*) tacis (*of*);
Walther@60578
   182
        (*if*) probl_id = Problem.id_empty (*else*);
Walther@60578
   183
Walther@60578
   184
      Step.switch_specify_solve p_ (pt, ip);
Walther@60578
   185
"~~~~~ fun switch_specify_solve , args:"; val (state_pos, (pt, input_pos)) = (p_, (pt, ip));
Walther@60578
   186
      (*if*) Pos.on_specification ([], state_pos) (*then*);
Walther@60578
   187
Walther@60578
   188
      Step.specify_do_next (pt, input_pos);
Walther@60578
   189
"~~~~~ fun specify_do_next , args:"; val ((ptp as (pt, (p, p_)))) = (pt, input_pos);
Walther@60578
   190
    val (_, (p_', tac)) = Specify.find_next_step ptp
Walther@60578
   191
    val ist_ctxt =  Ctree.get_loc pt (p, p_);
Walther@60578
   192
    (*case*) tac (*of*);
Walther@60578
   193
Walther@60578
   194
Step_Specify.by_tactic_input  tac (pt, (p, p_'));
Walther@60578
   195
"~~~~~ fun by_tactic_input , args:"; val ((Tactic.Specify_Problem pI), (pt, pos as (p, _)))
Walther@60578
   196
  = (tac, (pt, (p, p_')));
Walther@60578
   197
      val (oris, dI, dI', pI', probl, ctxt) = case get_obj I pt p of
Walther@60578
   198
        PblObj {origin = (oris, (dI,_,_),_), spec = (dI',pI',_), probl, ctxt, ...} =>
Walther@60578
   199
          (oris, dI, dI', pI', probl, ctxt)
Walther@60578
   200
	    val thy = ThyC.get_theory_PIDE ctxt (if dI' = ThyC.id_empty then dI else dI');
Walther@60585
   201
      val {model, where_, where_rls,...} = Problem.from_store (Ctree.get_ctxt pt pos) pI
Walther@60578
   202
(*-------------------- stop step into me Specify_Theory --------------------------------------*)
Walther@60578
   203
(*\\------------------ step into me Specify_Theory -----------------------------------------//*)
Walther@60578
   204
Walther@60578
   205
val (p'''',_,f'''',nxt'''',_,pt'''') = me nxt''' p''' c pt'''; val Specify_Method ["Optimisation", "by_univariate_calculus"] = nxt'''';
Walther@60578
   206
Walther@60578
   207
(*//------------------ step into me Specify_Problem ----------------------------------------\\*)
Walther@60578
   208
"~~~~~ fun me , args:"; val (tac, p, _, pt) = (nxt''', p''', c, pt''');
Walther@60578
   209
      val ctxt = Ctree.get_ctxt pt p
Walther@60578
   210
Walther@60578
   211
      val ("ok", (_, _, ptp as (pt''''', p'''''))) =
Walther@60578
   212
  	    (*case*)
Walther@60578
   213
      Step.by_tactic tac (pt, p) (*of*);
Walther@60578
   214
"~~~~~ fun by_tactic , args:"; val (tac, (ptp as (pt, p))) = (tac, (pt, p));
Walther@60578
   215
Walther@60578
   216
    (*case*)
Walther@60578
   217
      Step.check tac (pt, p) (*of*);
Walther@60578
   218
"~~~~~ fun check , args:"; val (tac, (ctree, pos)) = (tac, (pt, p));
Walther@60578
   219
  (*if*) Tactic.for_specify tac (*then*);
Walther@60578
   220
Walther@60578
   221
Specify_Step.check tac (ctree, pos);
Walther@60578
   222
"~~~~~ fun check , args:"; val ((Tactic.Specify_Problem pID), (pt, pos as (p, _)))
Walther@60578
   223
  = (tac, (ctree, pos));
Walther@60578
   224
		    val (oris, dI, pI, dI', pI', itms) = case Ctree.get_obj I pt p of
Walther@60578
   225
		      Ctree.PblObj {origin = (oris, (dI, pI, _), _), spec = (dI', pI', _), probl = itms, ...}
Walther@60578
   226
		        => (oris, dI, pI, dI', pI', itms)
Walther@60578
   227
	      val thy = ThyC.get_theory_PIDE ctxt (if dI' = ThyC.id_empty then dI else dI');
Walther@60578
   228
(*-------------------- stop step into Step.do_next -------------------------------------------*)
Walther@60578
   229
(*-------------------- stop step into me Specify_Problem -------------------------------------*)
Walther@60578
   230
Walther@60578
   231
val (p, pt, nxt) = (p''''', pt''''', nxt'''); (* kept for continuing me *)
Walther@60578
   232
Walther@60578
   233
      (*case*)
Walther@60578
   234
      Step.do_next p ((pt, Pos.e_pos'), []) (*of*);
Walther@60578
   235
"~~~~~ fun do_next , args:"; val ((ip as (_, p_)), (ptp as (pt, p), tacis)) = (p, ((pt, Pos.e_pos'), []));
Walther@60578
   236
  (*if*) Pos.on_calc_end ip (*else*);
Walther@60578
   237
      val (_, probl_id, _) = Calc.references (pt, p);
Walther@60578
   238
val _ =
Walther@60578
   239
      (*case*) tacis (*of*);
Walther@60578
   240
        (*if*) probl_id = Problem.id_empty (*else*);
Walther@60578
   241
Walther@60578
   242
      Step.switch_specify_solve p_ (pt, ip);
Walther@60578
   243
"~~~~~ fun switch_specify_solve , args:"; val (state_pos, (pt, input_pos)) = (p_, (pt, ip));
Walther@60578
   244
      (*if*) Pos.on_specification ([], state_pos) (*then*);
Walther@60578
   245
Walther@60578
   246
      Step.specify_do_next (pt, input_pos);
Walther@60578
   247
"~~~~~ fun specify_do_next , args:"; val ((ptp as (pt, (p, p_)))) = ((pt, input_pos));
Walther@60578
   248
    val (_, (p_', tac)) = Specify.find_next_step ptp
Walther@60578
   249
    val ist_ctxt =  Ctree.get_loc pt (p, p_)
Walther@60578
   250
val _ =
Walther@60578
   251
    (*case*) tac (*of*);
Walther@60578
   252
Walther@60578
   253
Step_Specify.by_tactic_input tac (pt, (p, p_'));
Walther@60578
   254
"~~~~~ fun by_tactic_input , args:"; val ((Tactic.Specify_Method id), (pt, pos))
Walther@60578
   255
  = (tac, (pt, (p, p_')));
Walther@60578
   256
Walther@60578
   257
      val (o_model, ctxt, i_model) =
Walther@60578
   258
Specify_Step.complete_for id (pt, pos);
Walther@60578
   259
"~~~~~ fun complete_for , args:"; val (mID, (ctree, pos)) = (id, (pt, pos));
Walther@60578
   260
    val {origin = (o_model, o_refs, _), spec = refs, probl = i_prob, ctxt,
Walther@60578
   261
       ...} = Calc.specify_data (ctree, pos);
Walther@60578
   262
    val ctxt = Ctree.get_ctxt ctree pos
Walther@60578
   263
    val (dI, _, _) = References.select_input o_refs refs;
Walther@60578
   264
    val {ppc = m_patt, pre, prls, ...} = MethodC.from_store ctxt mID
Walther@60578
   265
    val {origin = (root_model, _, _), ...} = Calc.specify_data (ctree, ([], Pos.Und))
Walther@60578
   266
    val (o_model', ctxt') = O_Model.complete_for m_patt root_model (o_model, ctxt)
Walther@60578
   267
    val thy = ThyC.get_theory_PIDE ctxt dI
Walther@60578
   268
    val (_, (i_model, _)) = M_Match.match_itms_oris thy i_prob (m_patt, pre, prls) o_model';
Walther@60578
   269
(*-------------------- stop step into me Specify_Problem -------------------------------------*)
Walther@60578
   270
(*\\------------------ step into me Specify_Problem ----------------------------------------//*)
Walther@60578
   271
Walther@60578
   272
val (p''',_,f,nxt''',_,pt''') = me nxt'''' p'''' c pt''''; val Add_Given "FunctionVariable a" = nxt''';
Walther@60578
   273
(*//------------------ step into me Specify_Method -----------------------------------------\\*)
Walther@60578
   274
"~~~~~ fun me , args:"; val (tac, p, _, pt) = (nxt'''', p'''', c, pt'''');
Walther@60578
   275
      val ctxt = Ctree.get_ctxt pt p
Walther@60578
   276
      val (pt, p) = 
Walther@60578
   277
  	    (*Step.by_tactic is here for testing by me; do_next would suffice in me*)
Walther@60578
   278
  	    case Step.by_tactic tac (pt, p) of
Walther@60578
   279
  		    ("ok", (_, _, ptp)) => ptp;
Walther@60578
   280
Walther@60578
   281
         (*case*)
Walther@60578
   282
      Step.do_next p ((pt, Pos.e_pos'), []) (*of*);
Walther@60578
   283
"~~~~~ fun do_next , args:"; val ((ip as (_, p_)), (ptp as (pt, p), tacis)) = (p, ((pt, Pos.e_pos'), []));
Walther@60578
   284
  (*if*) Pos.on_calc_end ip (*else*);
Walther@60578
   285
      val (_, probl_id, _) = Calc.references (pt, p);
Walther@60578
   286
val _ =
Walther@60578
   287
      (*case*) tacis (*of*);
Walther@60578
   288
        (*if*) probl_id = Problem.id_empty (*else*);
Walther@60578
   289
Walther@60578
   290
      Step.switch_specify_solve p_ (pt, ip);
Walther@60578
   291
"~~~~~ fun switch_specify_solve , args:"; val (state_pos, (pt, input_pos)) = (p_, (pt, ip));
Walther@60578
   292
      (*if*) Pos.on_specification ([], state_pos) (*then*);
Walther@60578
   293
Walther@60578
   294
      Step.specify_do_next (pt, input_pos);
Walther@60578
   295
"~~~~~ fun specify_do_next , args:"; val ((ptp as (pt, (p, p_)))) = (pt, input_pos);
Walther@60578
   296
Walther@60578
   297
    val (_, (p_', tac)) =
Walther@60578
   298
   Specify.find_next_step ptp;
Walther@60578
   299
"~~~~~ fun find_next_step , args:"; val ((pt, pos as (_, p_))) = (ptp);
Walther@60578
   300
    val {meth = met, origin = origin as (oris, o_refs as (_, pI', mI'), _), probl = pbl,
Walther@60578
   301
      spec = refs, ...} = Calc.specify_data (pt, pos);
Walther@60578
   302
    val ctxt = Ctree.get_ctxt pt pos;
Walther@60578
   303
      (*if*) Ctree.just_created (pt, pos) andalso origin <> Ctree.e_origin (*else*);
Walther@60578
   304
        (*if*) p_ = Pos.Pbl (*else*);
Walther@60578
   305
Walther@60578
   306
   Specify.for_method ctxt oris (o_refs, refs) (pbl, met);
Walther@60578
   307
"~~~~~ fun for_method , args:"; val (ctxt, oris, ((dI', pI', mI'), (dI, pI, mI)), (pbl, met))
Walther@60578
   308
  = (ctxt, oris, (o_refs, refs), (pbl, met));
Walther@60578
   309
    val cmI = if mI = MethodC.id_empty then mI' else mI;
Walther@60578
   310
    val {ppc = mpc, prls, pre, ...} = MethodC.from_store ctxt cmI;    (*..MethodC ?*)
Walther@60578
   311
    val (preok, _) = Pre_Conds.check prls pre pbl 0;
Walther@60578
   312
val NONE =
Walther@60578
   313
    (*case*) find_first (I_Model.is_error o #5) met (*of*);
Walther@60578
   314
Walther@60578
   315
      (*case*)
Walther@60578
   316
   Specify.item_to_add (ThyC.get_theory_PIDE ctxt 
Walther@60578
   317
     (if dI = ThyC.id_empty then dI' else dI)) oris mpc met (*of*);
Walther@60578
   318
"~~~~~ fun item_to_add , args:"; val (thy, oris, _, itms)
Walther@60578
   319
  = ((ThyC.get_theory_PIDE ctxt (if dI = ThyC.id_empty then dI' else dI)), oris, mpc, met);
Walther@60578
   320
(*-------------------- stop step into me Specify_Method --------------------------------------*)
Walther@60578
   321
(*\\------------------ step into me Specify_Method -----------------------------------------//*)
Walther@60578
   322
Walther@60578
   323
val (p,_,f,nxt,_,pt) = me nxt''' p''' c pt'''; val Add_Given "Input_Descript.Domain {0<..<r}" = nxt;
Walther@60578
   324
val (p,_,f,nxt,_,pt) = me nxt p c pt; val Add_Given "ErrorBound (\<epsilon> = 0)" = nxt;
Walther@60578
   325
(*
Walther@60578
   326
  nxt would be Tactic.Apply_Method, which tries to determine a next step in the ***Program***,
Walther@60578
   327
  but the Program is not yet perfectly implemented.
Walther@60578
   328
val (p,_,f,nxt,_,pt) = me nxt p c pt;
Walther@60578
   329
*)