test/Tools/isac/Specify/i-model.sml
author wneuper <Walther.Neuper@jku.at>
Mon, 11 Dec 2023 09:24:02 +0100
changeset 60778 41abd196342a
parent 60777 df8636ffd6f8
child 60779 fabe6923e819
permissions -rw-r--r--
prepare 1: delete old code with I_Model.T (without Position.T)
walther@59957
     1
(* Title:  "Specify/i-model.sml"
walther@59957
     2
   Author: Walther Neuper
walther@59957
     3
   (c) due to copyright terms
walther@59957
     4
*)
walther@59957
     5
walther@59957
     6
"-----------------------------------------------------------------------------------------------";
walther@59957
     7
"table of contents -----------------------------------------------------------------------------";
walther@59957
     8
"-----------------------------------------------------------------------------------------------";
Walther@60763
     9
"----------- survey on handling of input terms -------------------------------------------------";
walther@59957
    10
"----------- investigate fun add_single in I_Model ---------------------------------------------";
Walther@60771
    11
"----------- build I_Model.init_POS -----------------------------------------------------------";
Walther@60705
    12
"----------- exercise preparing I_Model.is_complete --------------------------------------------";
Walther@60705
    13
"----------- build I_Model.is_complete_OLD -----------------------------------------------------";
Walther@60751
    14
"----------- build I_Model.s_make_complete -----------------------------------------------------";
Walther@60753
    15
"----------- check I_Model.s_make_complete for ([], [])-----------------------------------------";
Walther@60766
    16
"----------- fun item_to_add: Maximum-exammple -------------------------------------------------";
Walther@60766
    17
"----------- fun item_to_add: Biegelinie-example -----------------------------------------------";
walther@59957
    18
"-----------------------------------------------------------------------------------------------";
walther@59957
    19
"-----------------------------------------------------------------------------------------------";
walther@59957
    20
"-----------------------------------------------------------------------------------------------";
walther@59957
    21
walther@59957
    22
open I_Model;
Walther@60705
    23
open Test_Code;
Walther@60705
    24
open Tactic;
Walther@60753
    25
open Pos; 
Walther@60763
    26
open Ctree; 
Walther@60763
    27
open Pre_Conds; 
Walther@60763
    28
open Specify; 
Walther@60763
    29
val ctxt = Proof_Context.init_global @{theory Biegelinie};
Walther@60763
    30
Walther@60763
    31
"----------- survey on handling of input terms -------------------------------------------------";
Walther@60763
    32
"----------- survey on handling of input terms -------------------------------------------------";
Walther@60763
    33
"----------- survey on handling of input terms -------------------------------------------------";
Walther@60763
    34
(*//------------------ survey on handling of input terms in specify-phase ------------------\\*)
Walther@60763
    35
(*        * ---------- handling of lists -----------------------------------------------------*)
Walther@60763
    36
(*         ** ---------- current situation ---------------------------------------------------*)
Walther@60763
    37
(** )(*---- from tests -------------------------------------------vvvvvvv *);
Walther@60763
    38
val o_single as (3, [1, 2, 3], "#Find", descr, [t1, t2]) = (nth 3 o_model)
Walther@60763
    39
val "(3, [\"1\", \"2\", \"3\"], #Find, AdditionalValues, [\"[u]\", \"[v]\"])"
Walther@60763
    40
  = O_Model.single_to_string ctxt o_single
Walther@60763
    41
val "[u]" = UnparseC.term ctxt t1
Walther@60763
    42
val "[v]" = UnparseC.term ctxt t2
Walther@60763
    43
( **)
Walther@60763
    44
val t as (descr $ vals_term) = @{term "AdditionalValues [u, v]"}
Walther@60766
    45
val true = (*if*)Model_Def.is_list_descr descr(*else*);
Walther@60763
    46
Walther@60763
    47
val values = vals_term |> TermC.isalist2list |> map TermC.single_to_list
Walther@60771
    48
val feedb = Cor_POS (descr, values)
Walther@60763
    49
Walther@60771
    50
val "Cor_POS AdditionalValues [u, v] , pen2str" = feedb |> feedback_POS_to_string ctxt
Walther@60763
    51
Walther@60763
    52
(*get values out of feedback:*)
Walther@60763
    53
val [Free ("u", _), Free ("v", _)] = (values |> map TermC.isalist2list  |> flat): term list
Walther@60763
    54
Walther@60763
    55
(*         ** ---------- wanted situation ----------------------------------------------------*)
Walther@60763
    56
val t as (descr $ vals_term) = @{term "AdditionalValues [u, v]"}
Walther@60766
    57
val true = (*if*)Model_Def.is_list_descr descr(*else*);
Walther@60763
    58
Walther@60763
    59
val values = [vals_term]
Walther@60771
    60
val feedb = Cor_POS (descr, values)
Walther@60763
    61
Walther@60771
    62
val "Cor_POS AdditionalValues [u, v] , pen2str" = feedb |> feedback_POS_to_string ctxt (*OK*)
Walther@60763
    63
Walther@60763
    64
(*get values out of feedback:*)
Walther@60763
    65
val "[u, v]" = values |> map (UnparseC.term ctxt) |> hd
Walther@60763
    66
Walther@60763
    67
(*        * ---------- handling of NON-lists -------------------------------------------------*)
Walther@60763
    68
(*         ** ---------- current situation ---------------------------------------------------*)
Walther@60763
    69
(** )(*---- from tests -------------------------------------------vvvvvvv *);
Walther@60763
    70
val o_single as (2, [1, 2, 3], "#Find", Const ("Input_Descript.Maximum", _), [Free ("A", _)])
Walther@60763
    71
  = (nth 2 o_model) 
Walther@60763
    72
( **)
Walther@60763
    73
val t as (descr $ vals_term) = @{term "Maximum A"}
Walther@60766
    74
val false = (*if*)Model_Def.is_list_descr descr(*then*);
Walther@60763
    75
Walther@60763
    76
val values = [vals_term]
Walther@60771
    77
val feedb = Cor_POS (descr, values)
Walther@60763
    78
Walther@60771
    79
val "Cor_POS Maximum A , pen2str" = feedb |> feedback_POS_to_string ctxt (*OK*)
Walther@60763
    80
Walther@60763
    81
(*get values out of feedback:*)
Walther@60763
    82
val "A" = values |> map (UnparseC.term ctxt) |> hd
Walther@60763
    83
Walther@60763
    84
(*         ** ---------- wanted situation ----------------------------------------------------*)
Walther@60763
    85
val t as (descr $ vals_term) = @{term "Maximum A"}
Walther@60766
    86
val false = (*if*)Model_Def.is_list_descr descr(*then*);
Walther@60763
    87
Walther@60763
    88
val values = [vals_term]
Walther@60771
    89
val feedb = Cor_POS (descr, values)
Walther@60763
    90
Walther@60771
    91
val "Cor_POS Maximum A , pen2str" = feedb |> feedback_POS_to_string ctxt (*OK*)
Walther@60763
    92
Walther@60763
    93
(*get values out of feedback:*)
Walther@60763
    94
val "A" = values |> map (UnparseC.term ctxt) |> hd;
Walther@60763
    95
(*\\------------------ survey on handling of input terms in specify-phase ------------------//*)
Walther@60763
    96
Walther@60729
    97
walther@59957
    98
"----------- investigate fun add_single in I_Model -------------------------------------------";
walther@59957
    99
"----------- investigate fun add_single in I_Model -------------------------------------------";
walther@59957
   100
"----------- investigate fun add_single in I_Model -------------------------------------------";
walther@59997
   101
val f_model = ["Traegerlaenge L", "Streckenlast q_0", "Biegelinie y",
walther@59957
   102
	"Randbedingungen [y 0 = (0::real), y L = 0, M_b 0 = 0, M_b L = 0]",
walther@59957
   103
	"FunktionsVariable x", "GleichungsVariablen [c, c_2, c_3, c_4]",
walther@59957
   104
  "AbleitungBiegelinie dy"];
walther@59957
   105
val f_spec = ("Biegelinie", ["Biegelinien"], ["IntegrierenUndKonstanteBestimmen2"]);
Walther@60571
   106
(*[], Pbl*)val (p,_,f,nxt,_,pt) = Test_Code.init_calc @{context} [(f_model, f_spec)]; (*\<rightarrow>Model_Problem*)
walther@59957
   107
(*[], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*\<rightarrow>Add_Given "Traegerlaenge L"*)
walther@59957
   108
(*[], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Add_Given "Streckenlast q_0"*)
walther@59957
   109
Walther@60676
   110
(*[], Pbl*)val return_me_Add_Given =
Walther@60676
   111
           me nxt p [] pt; (*\<rightarrow>Add_Find "Biegelinie y"*)
Walther@60676
   112
(*/------------------- step into me Add_Given ----------------------------------------------\\*)
walther@59957
   113
"~~~~~ fun me , args:"; val (tac, p, _(*NEW remove*), pt) = (nxt, p, [], pt);
walther@59957
   114
Walther@60676
   115
val ("ok", (_, _, ptp)) = (*case*)
walther@59957
   116
      Step.by_tactic tac (pt, p) (*of*);
walther@59957
   117
"~~~~~ fun by_tactic , args:"; val (tac, (ptp as (pt, p))) = (tac, (pt, p));
Walther@60676
   118
walther@59957
   119
  val Applicable.Yes tac' = (*case*)
walther@59957
   120
      Step.check tac (pt, p) (*of*);
walther@59957
   121
	    (*if*) Tactic.for_specify' tac' (*then*);
walther@59957
   122
walther@59957
   123
Step_Specify.by_tactic tac' ptp;
walther@59957
   124
"~~~~~ fun by_tactic , args:"; val ((Tactic.Add_Given' (ct, _)), (pt, p)) = (tac', ptp);
walther@59957
   125
Walther@60676
   126
val ("ok", ([(Add_Given "Streckenlast q_0", _, _)], [], _)) = (*case*)
walther@60016
   127
   Specify.by_Add_ "#Given" ct (pt, p);
Walther@60676
   128
"~~~~~ fun by_Add_ , args:"; val (m_field, ct, (pt, pos as (_, p_))) =
walther@59957
   129
  ("#Given", ct, (pt, p));
Walther@60676
   130
    val (met, oris, (_, pI', mI'), pbl, (_, pI, mI), ctxt) = SpecificationC.get_data (pt, pos)
Walther@60676
   131
    val (i_model, m_patt) =
Walther@60676
   132
       if p_ = Pos.Met then
Walther@60676
   133
         (met,
Walther@60676
   134
           (if mI = MethodC.id_empty then mI' else mI) |> MethodC.from_store ctxt |> #model)
Walther@60676
   135
       else
Walther@60676
   136
         (pbl,
Walther@60676
   137
           (if pI = Problem.id_empty then pI' else pI) |> Problem.from_store ctxt |> #model)
Walther@60676
   138
;
Walther@60655
   139
(*+*)if O_Model.to_string @{context} oris = "[\n" ^
walther@59997
   140
  "(1, [\"1\"], #Given, Traegerlaenge, [\"L\"]), \n" ^
walther@59997
   141
  "(2, [\"1\"], #Given, Streckenlast, [\"q_0\"]), \n" ^
walther@59997
   142
  "(3, [\"1\"], #Find, Biegelinie, [\"y\"]), \n" ^
walther@59997
   143
  "(4, [\"1\"], #Relate, Randbedingungen, [\"[y 0 = 0]\", \"[y L = 0]\", \"[M_b 0 = 0]\", \"[M_b L = 0]\"]), \n" ^
walther@59997
   144
  "(5, [\"1\"], #undef, FunktionsVariable, [\"x\"]), \n" ^
walther@59997
   145
  "(6, [\"1\"], #undef, GleichungsVariablen, [\"[c]\", \"[c_2]\", \"[c_3]\", \"[c_4]\"]), \n" ^
walther@59997
   146
  "(7, [\"1\"], #undef, AbleitungBiegelinie, [\"dy\"])]"
walther@59957
   147
(*+*)then () else error "INITIAL O_Model CHANGED";
Walther@60773
   148
(*+*)val "[\n(1, [1], true ,#Given, (Cor_POS Traegerlaenge L , pen2str, Position.T)), \n(2, [1], false ,#Given, (Inc_POS Streckenlast __, Position.T)), \n(3, [1], false ,#Find, (Inc_POS Biegelinie __, Position.T)), \n(4, [1], false ,#Relate, (Inc_POS Randbedingungen [] [__=__, __=__], Position.T))]"
Walther@60773
   149
 = pbl |> I_Model.to_string_POS ctxt
walther@59957
   150
Walther@60676
   151
val return_check_single = (*case*)
Walther@60778
   152
   I_Model.check_single ctxt m_field oris i_model m_patt ct (*of*);
Walther@60676
   153
(*//------------------ step into check_single ----------------------------------------------\\*)
Walther@60676
   154
"~~~~~ fun check_single , args <>[]:"; val (ctxt, m_field, o_model, i_model, m_patt, str)
Walther@60773
   155
  = (ctxt, m_field, oris, (I_Model.TEST_to_OLD i_model), m_patt, ct);
Walther@60676
   156
      val (t as (descriptor $ _)) = Syntax.read_term ctxt str
Walther@60676
   157
        handle ERROR msg => error (msg (*^ Position.here pp*))
Walther@60773
   158
Walther@60676
   159
val SOME m_field' =
Walther@60773
   160
        (*case*) Model_Pattern.get_field descriptor m_patt;
Walther@60773
   161
val false =
Walther@60676
   162
          (*if*) m_field <> m_field' (*else*);
Walther@60773
   163
        val ("", ori', all) =(**)
Walther@60469
   164
          (*case*) O_Model.contains ctxt m_field o_model t (*of*);
walther@59957
   165
Walther@60655
   166
(*+*)O_Model.single_to_string @{context} ori';
walther@59957
   167
(*+*)val [Free ("q_0", _)] = all;
walther@59957
   168
walther@59957
   169
(**)val ("", itm) =(**)
Walther@60772
   170
 (*case*) is_notyet_input ctxt (OLD_to_POS i_model) all ori' m_patt (*of*);
walther@59957
   171
Walther@60772
   172
(*+*)val (2, [1], true, "#Given", (Cor_POS (Const (\<^const_name>\<open>Streckenlast\<close>, _), [Free ("q_0", _)]), _)) = itm
Walther@60676
   173
(*\\------------------ step into check_single ----------------------------------------------//*)
Walther@60773
   174
val I_Model.Add i_single = return_check_single
walther@59957
   175
Walther@60676
   176
	          val  (_, _, _, pt') =  Specify_Step.add tac' (Istate_Def.Uistate, ctxt) (pt, pos)
walther@59957
   177
Walther@60676
   178
val return_by_Add_ = ("ok", ([(Tactic.input_from_T ctxt tac', tac', (pos, (Istate_Def.Uistate, ctxt)))],
Walther@60676
   179
              [], (pt', pos)));
Walther@60676
   180
(*-------------------- stop into me Add_Given ------------------------------------------------*)
Walther@60676
   181
(*\------------------- step into me Add_Given ----------------------------------------------//*)
Walther@60763
   182
                                val (p,_,f,nxt,_,pt) = return_me_Add_Given;
walther@59957
   183
Walther@60763
   184
(*ErRoR Clash of types "_ \<Rightarrow> _" and "_ list", Randbedingungen :: bool list \<Rightarrow> una, y :: real \<Rightarrow> real* )
Walther@60676
   185
(*[], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*\<rightarrow>Add_Relation "Randbedingungen [y 0 = 0]"*)
walther@59957
   186
Walther@60729
   187
(* final test ... BEFORE BREAKING ELEMENTWISE INPUT TO LISTS* )
walther@59957
   188
if p = ([], Pbl) then
Walther@60729
   189
  case nxt of Add_Relation "Randbedingungen [y 0 = 0]" => () | _
Walther@60729
   190
    => error "investigate fun add_single CHANGED 1"
Walther@60729
   191
else error "investigate fun add_single CHANGED 2"
Walther@60729
   192
( * final test ... AFTER BREAKING ELEMENTWISE INPUT TO LISTS*)
Walther@60729
   193
if p = ([], Pbl) then
Walther@60729
   194
  case nxt of Add_Relation "Randbedingungen [y 0 = 0, y L = 0, M_b 0 = 0, M_b L = 0]" => () | _
Walther@60729
   195
    => error "investigate fun add_single CHANGED 1"
walther@59957
   196
else error "investigate fun add_single CHANGED 2"
Walther@60763
   197
( *ErRoR Clash of types "_ \<Rightarrow> _" and "_ list", Randbedingungen :: bool list \<Rightarrow> una, y :: real \<Rightarrow> real*)
Walther@60763
   198
Walther@60690
   199
Walther@60771
   200
"----------- build I_Model.init_POS -----------------------------------------------------------";
Walther@60771
   201
"----------- build I_Model.init_POS -----------------------------------------------------------";
Walther@60771
   202
"----------- build I_Model.init_POS -----------------------------------------------------------";
Walther@60690
   203
(*/---------------------------------------- mimic input from PIDE -----------------------------\*)
Walther@60690
   204
Walther@60690
   205
(* Test_Example "Diff_App-No.123a" (*complete Model, empty References*) *)
Walther@60690
   206
val in_refs as (thy_id, probl_id, meth_id) = ("__", "__/__", "__/__")
Walther@60690
   207
val thy = @{theory}
Walther@60690
   208
val model_input = (*type Position.T is hidden, thus redefinition*)
Walther@60690
   209
 [("#Given", [("Constants [r = 7]", Position.none)]),
Walther@60690
   210
  ("#Where", [("0 < r", Position.none)]),
Walther@60690
   211
  ("#Find",
Walther@60690
   212
   [("Maximum A", Position.none), ("AdditionalValues [u, v]", Position.none)]),
Walther@60690
   213
  ("#Relate",
Walther@60690
   214
   [("Extremum (A = 2 * u * v - u \<up> 2)", Position.none),
Walther@60690
   215
    ("SideConditions [(u / 2) \<up> 2 + (2 / v) \<up> 2 = r \<up> 2]", Position.none)])]
Walther@60690
   216
: (Model_Pattern.m_field * (string * Position.T) list) list
Walther@60690
   217
val example_id = "Diff_App-No.123a";
Walther@60690
   218
(*----------------------------------------- init state -----------------------------------------*)
Walther@60771
   219
set_data CTbasic_POS.EmptyPtree @{theory Calculation};
Walther@60690
   220
(*\---------------------------------------- mimic input from PIDE -----------------------------/*)
Walther@60690
   221
Walther@60771
   222
val CTbasic_POS.EmptyPtree =
Walther@60694
   223
              (*case*) the_data @{theory Calculation} (*of*);
Walther@60690
   224
Walther@60690
   225
(* Calculation..*)
Walther@60704
   226
"~~~~~ fun init_ctree , args:"; val (thy, example_id) = (thy, example_id);
Walther@60690
   227
      val example_id' = References_Def.explode_id example_id
Walther@60690
   228
      val (_, (formalise as (model, refs as (thy_id, probl_id, meth_id)))) =
Walther@60690
   229
        Store.get (Know_Store.get_expls @{theory}) example_id' example_id' 
Walther@60690
   230
      val {model = model_patt, ...} = Problem.from_store (Proof_Context.init_global thy) probl_id
Walther@60690
   231
      val (o_model, ctxt) = O_Model.init thy model model_patt
Walther@60690
   232
;
Walther@60690
   233
(*+*)o_model: O_Model.T; (* |> O_Model.to_string @{context}*)
Walther@60690
   234
(*+*)val ("Diff_App", ["univariate_calculus", "Optimisation"], ["Optimisation", "by_univariate_calculus"]) =
Walther@60695
   235
(*+*)  refs       
Walther@60690
   236
Walther@60694
   237
      val empty_i_model =
Walther@60771
   238
   I_Model.init_POS ctxt o_model model_patt;
Walther@60771
   239
"~~~~~ fun init_POS , args:"; val (ctxt, model_patt) = (ctxt, model_patt);
Walther@60694
   240
;
Walther@60771
   241
(*+*)val "[\n(1, [1, 2, 3], false ,#Given, (Inc_POS Constants [] [__=__, __=__], Position.T)), \n(2, [1, 2, 3], false ,#Find, (Inc_POS Maximum __, Position.T)), \n(3, [1, 2, 3], false ,#Find, (Inc_POS AdditionalValues [] [__, __], Position.T)), \n(4, [1, 2, 3], false ,#Relate, (Inc_POS Extremum (__=__), Position.T)), \n(5, [1, 2], false ,#Relate, (Inc_POS SideConditions [] [__=__, __=__], Position.T))]"
Walther@60771
   242
 = I_Model.to_string_POS @{context} empty_i_model;
Walther@60705
   243
Walther@60705
   244
Walther@60705
   245
"----------- exercise preparing I_Model.is_complete --------------------------------------------";
Walther@60705
   246
"----------- exercise preparing I_Model.is_complete --------------------------------------------";
Walther@60705
   247
"----------- exercise preparing I_Model.is_complete --------------------------------------------";
Walther@60705
   248
fun check str = if str = "true" then true else false
Walther@60705
   249
fun complete str = if str = "true" then true else false
Walther@60705
   250
Walther@60705
   251
val i_model_envs_v = [("i_model_envs-1", 11), ("i_model_envs-2", 12), ("i_model_envs-3", 13)]
Walther@60705
   252
Walther@60705
   253
val result_all_variants =
Walther@60705
   254
  map (fn (a, variant) => if check a andalso complete a then SOME [variant] else NONE) i_model_envs_v;
Walther@60705
   255
(*----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*)
Walther@60705
   256
;
Walther@60705
   257
val [NONE, NONE, NONE] = result_all_variants: int list option list
Walther@60705
   258
Walther@60705
   259
(*+*)val true = forall is_none result_all_variants
Walther@60705
   260
Walther@60705
   261
val variants_complete =
Walther@60705
   262
  if forall is_none result_all_variants
Walther@60705
   263
  then NONE
Walther@60705
   264
  else SOME (map (fn x => if is_some x then [the x] else []) result_all_variants |> flat |> flat)
Walther@60705
   265
;
Walther@60705
   266
val NONE = variants_complete: int list option
Walther@60705
   267
Walther@60705
   268
Walther@60705
   269
(*more significant result ..*)
Walther@60705
   270
val result_all_variants = [SOME [11], NONE, SOME [13]]: int list option list
Walther@60705
   271
(*
Walther@60705
   272
in case the result is null, no I_Model is_complete,
Walther@60705
   273
in case the result contains more than 1 variant, this might determine the decision for MethodC.
Walther@60705
   274
*)
Walther@60705
   275
val variants_complete =
Walther@60705
   276
  if forall is_none result_all_variants
Walther@60705
   277
  then NONE
Walther@60705
   278
  else SOME (map (fn x => if is_some x then [the x] else []) result_all_variants |> flat |> flat)
Walther@60705
   279
;
Walther@60705
   280
val SOME [11, 13] = variants_complete: int list option;
Walther@60705
   281
Walther@60714
   282
(*/----- reactivate with CS "remove sep_variants_envs"-----\* )
Walther@60705
   283
"----------- build I_Model.is_complete_OLD -----------------------------------------------------";
Walther@60705
   284
"----------- build I_Model.is_complete_OLD -----------------------------------------------------";
Walther@60705
   285
"----------- build I_Model.is_complete_OLD -----------------------------------------------------";
Walther@60705
   286
(*see Outer_Syntax:    val (model, where_) = Model_Pattern.parse_pos_empty ctxt model_input*)
Walther@60705
   287
open I_Model
Walther@60705
   288
open Pre_Conds;
Walther@60705
   289
(*//------------------ test data setup -----------------------------------------------------\\*)
Walther@60705
   290
(*
Walther@60705
   291
*****************************************************************************************
Walther@60705
   292
***** WE FIRST MAINTAIN THE ERROR, THAT ITEMS WITH TYPE list ARE STORED AS isalist, *****
Walther@60705
   293
***** NOT AS term list (NECESSARY TO DETECT INCOMPLETE INPUT OF lists)              *****
Walther@60705
   294
*****************************************************************************************
Walther@60705
   295
  The ERROR occurred somewhere since introducing structure or since transition to PIDE.
Walther@60705
   296
*****************************************************************************************
Walther@60771
   297
  We complete the two single_POS "1" and "5" below and replace them in  empty_input;
Walther@60705
   298
  we add "6" as variant of "5" to the empty input.
Walther@60705
   299
  later we shall replace empty_input by partial input "AdditionalValues [v]" (u missing).
Walther@60771
   300
  The test intermediatly pairs (feedback_POS, Position.T) in I_Model.T_POS 
Walther@60705
   301
  and leaves the rest as is.
Walther@60705
   302
Walther@60705
   303
I_Model.is_complete_OLD: because PIDE gets instantiated Pre_Conds by Template.show,
Walther@60771
   304
  I_Model.is_complete_POS NO instantiation (done in Template.show):
Walther@60705
   305
  it serves to maintain the OLD test/*
Walther@60705
   306
*)
Walther@60705
   307
val thy = @{theory Calculation}
Walther@60705
   308
Walther@60705
   309
            val state =
Walther@60705
   310
              case the_data thy of
Walther@60771
   311
                  CTbasic_POS.EmptyPtree => Preliminary.init_ctree thy example_id
Walther@60705
   312
                | _(*state (*FOR TEST*)*) => (**)the_data thy(**)
Walther@60705
   313
                  (*let*)
Walther@60705
   314
                    val {origin = (o_model, o_ref, _), spec = spec_ref, probl, meth, ctxt, ...} =
Walther@60771
   315
                      CTbasic_POS.get_obj I state [(*Pos will become variable*)] |> CTbasic_POS.rep_specify_data
Walther@60705
   316
;
Walther@60771
   317
probl: Model_Def.i_model_POS 
Walther@60771
   318
(*[(1, [1, 2, 3], false, "#Given", (Inp_POS (Const ("Input_Descript.Constants", "bool list \<Rightarrow> nam"), "[__=__, __=__]"), {})),
Walther@60771
   319
   (2, [1, 2, 3], false, "#Find", (Inp_POS (Const ("Input_Descript.Maximum", "real \<Rightarrow> toreal"), "__"), {})),
Walther@60771
   320
   (3, [1, 2, 3], false, "#Find", (Inp_POS (Const ("Input_Descript.AdditionalValues", "real list \<Rightarrow> toreall"), "[__, __]"), {})),
Walther@60771
   321
   (4, [1, 2, 3], false, "#Relate", (Inp_POS (Const ("Input_Descript.Extremum", "bool \<Rightarrow> toreal"), "(__=__)"), {})),
Walther@60771
   322
   (5, [1, 2], false, "#Relate", (Inp_POS (Const ("Input_Descript.SideConditions", "bool list \<Rightarrow> una"), "[__=__, __=__]"), {}))]*)
Walther@60705
   323
;
Walther@60705
   324
val probl_POS = (*from above, #1 and #5,6 replaced by complete items for building code.test*)
Walther@60705
   325
  (1, [1,2,3], true, "#Given",
Walther@60771
   326
    (Cor_POS ((@{term "Constants"}, [@{term "[r = (7::real)]"(*should be "r = (7::real)"*)}]),
Walther@60705
   327
      (@{term "fixes::bool list"}, [@{term "[r = (7::real)]"}])), Position.none )) ::
Walther@60705
   328
  nth 2 probl :: nth 3 probl :: nth 4 probl ::
Walther@60705
   329
  (5, [1,2], true, "#Relate",
Walther@60771
   330
    (Cor_POS ((@{term "SideConditions"}, [@{term "[(u / 2) \<up> 2 + (2 / v) \<up> 2 = r \<up> 2]"}]),
Walther@60705
   331
      (@{term "sideconds::bool list"}, [TermC.empty])), Position.none )) ::
Walther@60705
   332
  (6, [3], true, "#Relate",
Walther@60771
   333
    (Cor_POS ((@{term "SideConditions"}, [@{term "[2 * u = r * sin \<alpha>, 2 * v = r * cos \<alpha>]"}]),
Walther@60705
   334
      (@{term "sideconds::bool list"}, [TermC.empty])), Position.none ))
Walther@60705
   335
  :: [];
Walther@60705
   336
Walther@60705
   337
val {model = model_patt, where_rls, where_ = where_OLD, ...} = (*from_store without Position.T-vv*)
Walther@60705
   338
  Problem.from_store ctxt (References.explode_id "univariate_calculus/Optimisation")
Walther@60705
   339
;
Walther@60705
   340
val [Const ("Orderings.ord_class.less", _(*"real \<Rightarrow> real \<Rightarrow> bool"*)) $
Walther@60705
   341
  Const ("Groups.zero_class.zero", _(*"real"*)) $ Free ("fixes", _(*"real"*))] = where_OLD
Walther@60705
   342
(*design-ERROR: "fixes" is used twice, as variable ------^^^^^^^^^^^^^^^^^^^^^^^^^^^ in pre-condition
Walther@60705
   343
  AND as "id" in Subst.T [("fixes", [0 < x])] *);
Walther@60705
   344
(model_patt |> Model_Pattern.to_string ctxt) =
Walther@60705
   345
 "[\"(#Given, (Constants, fixes))\", " ^
Walther@60705
   346
  "\"(#Find, (Maximum, maxx))\", " ^
Walther@60705
   347
  "\"(#Find, (AdditionalValues, vals))\", " ^
Walther@60705
   348
  "\"(#Relate, (Extremum, extr))\", " ^
Walther@60705
   349
  "\"(#Relate, (SideConditions, sideconds))\"]";
Walther@60705
   350
val "[0 < fixes]" = (where_OLD |> UnparseC.terms @{context})
Walther@60705
   351
(*\\------------------ test data setup -----------------------------------------------------//*)
Walther@60705
   352
Walther@60771
   353
(*/------------------- test on OLD algorithm (with I_Model.T_POS) --------------------------\*)
Walther@60771
   354
(*\------------------- test on OLD algorithm (with I_Model.T_POS) --------------------------/*)
Walther@60714
   355
( *\----- reactivate with CS "remove sep_variants_envs"-----/*)
Walther@60751
   356
Walther@60751
   357
Walther@60751
   358
"----------- build I_Model.s_make_complete -----------------------------------------------------";
Walther@60751
   359
"----------- build I_Model.s_make_complete -----------------------------------------------------";
Walther@60751
   360
"----------- build I_Model.s_make_complete -----------------------------------------------------";
Walther@60751
   361
val (_(*example text*),
Walther@60751
   362
  (model as ("Constants [r = (7::real)]" :: "Maximum A" :: "AdditionalValues [u, v]" :: 
Walther@60751
   363
     "Extremum (A = 2 * u * v - u \<up> 2)" :: 
Walther@60751
   364
     "SideConditions [((u::real) / 2) \<up> 2 + (2 / v) \<up> 2 = r \<up> 2]" :: 
Walther@60751
   365
     "SideConditions [((u::real) / 2) \<up> 2 + (2 / v) \<up> 2 = r \<up> 2]" :: 
Walther@60751
   366
     "SideConditions [(u::real) / 2 = r * sin \<alpha>, 2 / v = r * cos \<alpha>]" :: (*INCORRECT 2 / v*)
Walther@60751
   367
(*---------------------------------------------,(v::real) / 2 = r * cos \<alpha>]" --- ERROR in example*)
Walther@60751
   368
     "FunctionVariable a" :: "FunctionVariable b" :: "FunctionVariable \<alpha>" :: 
Walther@60751
   369
     "Domain {0 <..< r}" :: "Domain {0 <..< r}" :: "Domain {0 <..< \<pi> / 2}" ::
Walther@60751
   370
     "ErrorBound (\<epsilon> = (0::real))" :: []), 
Walther@60751
   371
   refs as ("Diff_App", 
Walther@60751
   372
     ["univariate_calculus", "Optimisation"],
Walther@60751
   373
     ["Optimisation", "by_univariate_calculus"])))
Walther@60751
   374
  = Store.get (Know_Store.get_expls @{theory}) ["Diff_App-No.123a"] ["Diff_App-No.123a"];
Walther@60751
   375
Walther@60751
   376
val c = [];
Walther@60751
   377
val (p,_,f,nxt,_,pt) = 
Walther@60751
   378
 Test_Code.init_calc @{context} [(model, refs)]; val Model_Problem = nxt;
Walther@60751
   379
val (p,_,f,nxt,_,pt) = me nxt p c pt;
Walther@60751
   380
Walther@60751
   381
(*//------------------ setup test data for I_Model.s_make_complete -------------------------\\*)
Walther@60751
   382
val (o_model, (pbl_imod, met_imod), (pI, mI)) = case get_obj I pt (fst p) of
Walther@60751
   383
   PblObj {meth = met_imod, origin = (o_model, (_, pI, mI), _), probl = pbl_imod, ...}
Walther@60751
   384
      => (o_model, (pbl_imod, met_imod), (pI, mI))
Walther@60751
   385
       | _ => raise ERROR ""
Walther@60751
   386
Walther@60751
   387
val pbl_imod = [ (*2 items for creating code ---> variants [1, 2]*)
Walther@60771
   388
  (1, [1, 2, 3], true, "#undef", (Cor_POS (@{term Constants},
Walther@60751
   389
    [@{term "[r = (7::real)]"}]), Position.none)),
Walther@60771
   390
  (1, [1, 2], true, "#undef", (Cor_POS (@{term SideConditions},
Walther@60751
   391
    [@{term "[(u / 2) \<up> 2 + (2 / v) \<up> 2 = r \<up> 2]"}]), Position.none))]
Walther@60751
   392
Walther@60751
   393
val met_imod = [ (*1 item for creating code*)
Walther@60771
   394
(8, [2], true, "#undef", (Cor_POS (@{term FunctionVariable}, [@{term "b::real"}]), Position.none))]
Walther@60751
   395
;
Walther@60751
   396
(*+*)if (o_model |> O_Model.to_string @{context}) = "[\n" ^
Walther@60751
   397
(*+*)  "(1, [\"1\", \"2\", \"3\"], #Given, Constants, [\"[r = 7]\"]), \n" ^
Walther@60751
   398
(*+*)  "(2, [\"1\", \"2\", \"3\"], #Find, Maximum, [\"A\"]), \n" ^
Walther@60751
   399
(*+*)  "(3, [\"1\", \"2\", \"3\"], #Find, AdditionalValues, [\"[u]\", \"[v]\"]), \n" ^
Walther@60751
   400
(*+*)  "(4, [\"1\", \"2\", \"3\"], #Relate, Extremum, [\"A = 2 * u * v - u \<up> 2\"]), \n" ^
Walther@60751
   401
(*+*)  "(5, [\"1\", \"2\"], #Relate, SideConditions, [\"[(u / 2) \<up> 2 + (2 / v) \<up> 2 = r \<up> 2]\"]), \n" ^
Walther@60751
   402
(*+*)  "(6, [\"3\"], #Relate, SideConditions, [\"[u / 2 = r * sin \<alpha>]\", \"[2 / v = r * cos \<alpha>]\"]), \n" ^
Walther@60751
   403
(*+*)  "(7, [\"1\"], #undef, FunctionVariable, [\"a\"]), \n" ^
Walther@60751
   404
(*+*)  "(8, [\"2\"], #undef, FunctionVariable, [\"b\"]), \n" ^
Walther@60751
   405
(*+*)  "(9, [\"3\"], #undef, FunctionVariable, [\"\<alpha>\"]), \n" ^
Walther@60751
   406
(*+*)  "(10, [\"1\", \"2\"], #undef, Input_Descript.Domain, [\"{0<..<r}\"]), \n" ^
Walther@60751
   407
(*+*)  "(11, [\"3\"], #undef, Input_Descript.Domain, [\"{0<..<\<pi> / 2}\"]), \n" ^
Walther@60751
   408
(*+*)  "(12, [\"1\", \"2\", \"3\"], #undef, ErrorBound, [\"\<epsilon> = 0\"])]"
Walther@60751
   409
then () else error "setup test data for I_Model.s_make_complete CHANGED";
Walther@60751
   410
(*\\------------------ setup test data for I_Model.s_make_complete -------------------------//*)
Walther@60751
   411
Walther@60751
   412
val return_s_make_complete =
Walther@60757
   413
           s_make_complete ctxt o_model (pbl_imod, met_imod) (pI, mI);
Walther@60751
   414
(*/------------------- step into s_make_complete -------------------------------------------\\*)
Walther@60757
   415
"~~~~~ fun s_make_complete , args:"; val (o_model, (pbl_imod, met_imod), (pI, mI)) =
Walther@60757
   416
  (o_model, (pbl_imod, met_imod), (pI, mI));
Walther@60757
   417
    val {model = pbl_patt, ...} = Problem.from_store ctxt pI;
Walther@60757
   418
    val {model = met_patt, ...} = MethodC.from_store ctxt mI;
Walther@60752
   419
    val pbl_max_vnts = Model_Def.max_variants o_model pbl_imod;
Walther@60751
   420
    val i_from_pbl = map (fn (_, (descr, _)) =>
Walther@60751
   421
      Pre_Conds.get_descr_vnt descr pbl_max_vnts pbl_imod) pbl_patt;
Walther@60751
   422
Walther@60751
   423
(*//------------------ step into get_descr_vnt ---------------------------------------------\\*)
Walther@60751
   424
"~~~~~ fun get_descr_vnt , args:"; val (descr, vnts, i_model) =
Walther@60751
   425
  (@{term Constants}, pbl_max_vnts, pbl_imod);
Walther@60767
   426
    val equal_descr = filter (fn (_, _, _, _, (feedb, _)) => case get_dscr_opt feedb of NONE => false
Walther@60751
   427
      | SOME descr' => if descr = descr' then true else false) i_model 
Walther@60751
   428
;
Walther@60771
   429
(*+*)filter (fn (_, vnts', _, _, _) => inter op= vnts' vnts <> []) equal_descr: I_Model.T_POS
Walther@60751
   430
;
Walther@60751
   431
val return_get_descr_vnt_1 =
Walther@60751
   432
    case filter (fn (_, vnts', _, _, _) => inter op= vnts' vnts <> []) equal_descr of
Walther@60771
   433
      [] => (0, [], false, "i_model_empty", (Sup_POS (descr, []), Position.none))
Walther@60751
   434
    | items => Library.the_single items (*only applied to model_patt, which has each descr once*)
Walther@60751
   435
(*\\------------------ step into get_descr_vnt ---------------------------------------------//*)
Walther@60751
   436
Walther@60751
   437
(*|------------------- continue s_make_complete ----------------------------------------------*)
Walther@60751
   438
    val pbl_from_o_model = map ((fn i_single as (_, _, _, _, (feedb, _)) =>
Walther@60771
   439
      if is_empty_single_POS i_single
Walther@60751
   440
      then
Walther@60751
   441
        case get_descr_vnt' feedb pbl_max_vnts o_model of
Walther@60751
   442
(*-----------^^^^^^^^^^^^^^-----------------------------*)
Walther@60751
   443
            [] => raise ERROR (msg pbl_max_vnts feedb)
Walther@60751
   444
          | o_singles => map transfer_terms o_singles
Walther@60751
   445
      else [i_single (*fetched before from pbl_imod*)])) i_from_pbl |> flat
Walther@60751
   446
Walther@60751
   447
(*+*)val [2, 1] = vnts;
Walther@60771
   448
(*+*)if (pbl_from_o_model |> I_Model.to_string_POS @{context}) = "[\n" ^
Walther@60771
   449
  "(1, [1, 2, 3], true ,#undef, (Cor_POS Constants [r = 7] , pen2str, Position.T)), \n" ^
Walther@60771
   450
  "(2, [1, 2, 3], true ,#Find, (Cor_POS Maximum A , pen2str, Position.T)), \n" ^
Walther@60771
   451
  "(3, [1, 2, 3], true ,#Find, (Cor_POS AdditionalValues [u, v] , pen2str, Position.T)), \n" ^
Walther@60771
   452
  "(4, [1, 2, 3], true ,#Relate, (Cor_POS Extremum (A = 2 * u * v - u \<up> 2) , pen2str, Position.T)), \n" ^
Walther@60771
   453
  "(1, [1, 2], true ,#undef, (Cor_POS SideConditions [(u / 2) \<up> 2 + (2 / v) \<up> 2 = r \<up> 2] , pen2str, Position.T))]"
Walther@60757
   454
then () else error "pbl_from_o_model CHANGED 1"
Walther@60751
   455
Walther@60751
   456
(*//------------------ step into map ((fn i_single -----------------------------------------\\*)
Walther@60751
   457
"~~~~~ fun map ((fn i_single , args:"; val (i_single as (_, _, _, _, (feedb, _))) = (nth 1 i_from_pbl);
Walther@60771
   458
      (*if*) is_empty_single_POS i_single (*else*);
Walther@60751
   459
             get_descr_vnt' feedb pbl_max_vnts o_model;
Walther@60751
   460
Walther@60751
   461
    val pbl_from_o_model = map ((fn i_single as (_, _, _, _, (feedb, _)) =>
Walther@60771
   462
      if is_empty_single_POS i_single
Walther@60751
   463
      then
Walther@60751
   464
        case get_descr_vnt' feedb pbl_max_vnts o_model of
Walther@60751
   465
(*---------- ^^^^^^^^^^^^^^ ----------------------------*)
Walther@60751
   466
            [] => raise ERROR (msg pbl_max_vnts feedb)
Walther@60751
   467
          | o_singles => map transfer_terms o_singles
Walther@60751
   468
      else [i_single (*fetched before from pbl_imod*)])) i_from_pbl |> flat
Walther@60751
   469
(*\\------------------ step into map ((fn i_single -----------------------------------------//*)
Walther@60751
   470
Walther@60751
   471
(*|------------------- continue s_make_complete ----------------------------------------------*)
Walther@60751
   472
    val i_from_met = map (fn (_, (descr, _)) =>
Walther@60753
   473
      Pre_Conds.get_descr_vnt descr pbl_max_vnts met_imod) met_patt
Walther@60751
   474
;
Walther@60771
   475
(*+*)if (i_from_met |> I_Model.to_string_POS @{context}) = "[\n" ^
Walther@60771
   476
  "(0, [], false ,i_model_empty, (Sup_POS Constants [], Position.T)), \n" ^
Walther@60771
   477
  "(0, [], false ,i_model_empty, (Sup_POS Maximum, Position.T)), \n" ^
Walther@60771
   478
  "(0, [], false ,i_model_empty, (Sup_POS Extremum, Position.T)), \n" ^
Walther@60771
   479
  "(0, [], false ,i_model_empty, (Sup_POS SideConditions [], Position.T)), \n" ^
Walther@60771
   480
  "(8, [2], true ,#undef, (Cor_POS FunctionVariable b , pen2str, Position.T)), \n" ^
Walther@60751
   481
(*---there is 1 item already input -^^^^^^^^^^^^^^^^^^*)
Walther@60771
   482
  "(0, [], false ,i_model_empty, (Sup_POS Input_Descript.Domain, Position.T)), \n" ^
Walther@60771
   483
  "(0, [], false ,i_model_empty, (Sup_POS ErrorBound, Position.T)), \n" ^
Walther@60771
   484
  "(0, [], false ,i_model_empty, (Sup_POS AdditionalValues [], Position.T))]"
Walther@60751
   485
(*+*)then () else error "s_make_complete: from_met CHANGED";
Walther@60751
   486
;
Walther@60752
   487
    val met_max_vnts = Model_Def.max_variants o_model i_from_met;
Walther@60751
   488
(*+*)val [2] = met_max_vnts
Walther@60751
   489
Walther@60751
   490
    val met_max_vnt = hd met_max_vnts (*need only one for solve-phase*)
Walther@60751
   491
    val met_from_pbl = map ((fn i_single as (_, _, _, _, (feedb, _)) =>
Walther@60771
   492
      if is_empty_single_POS i_single
Walther@60751
   493
      then
Walther@60751
   494
        case get_descr_vnt' feedb [met_max_vnt] o_model of
Walther@60751
   495
            [] => raise ERROR (msg [met_max_vnt] feedb)
Walther@60751
   496
          | o_singles => map transfer_terms o_singles
Walther@60751
   497
      else [i_single (*fetched before from met_imod*)])) i_from_met |> flat
Walther@60751
   498
;
Walther@60771
   499
(*+*)if (met_from_pbl |> I_Model.to_string_POS @{context}) = "[\n" ^
Walther@60771
   500
  "(1, [1, 2, 3], true ,#Given, (Cor_POS Constants [r = 7] , pen2str, Position.T)), \n" ^
Walther@60771
   501
  "(2, [1, 2, 3], true ,#Find, (Cor_POS Maximum A , pen2str, Position.T)), \n" ^
Walther@60771
   502
  "(4, [1, 2, 3], true ,#Relate, (Cor_POS Extremum (A = 2 * u * v - u \<up> 2) , pen2str, Position.T)), \n" ^
Walther@60771
   503
  "(5, [1, 2], true ,#Relate, (Cor_POS SideConditions [(u / 2) \<up> 2 + (2 / v) \<up> 2 = r \<up> 2] , pen2str, Position.T)), \n" ^
Walther@60771
   504
  "(8, [2], true ,#undef, (Cor_POS FunctionVariable b , pen2str, Position.T)), \n" ^
Walther@60771
   505
  "(10, [1, 2], true ,#undef, (Cor_POS Input_Descript.Domain {0<..<r} , pen2str, Position.T)), \n" ^
Walther@60771
   506
  "(12, [1, 2, 3], true ,#undef, (Cor_POS ErrorBound (\<epsilon> = 0) , pen2str, Position.T)), \n" ^
Walther@60771
   507
  "(3, [1, 2, 3], true ,#Find, (Cor_POS AdditionalValues [u, v] , pen2str, Position.T))]"
Walther@60751
   508
(*+*)then () else error "s_make_complete: met_from_pbl CHANGED";
Walther@60751
   509
;
Walther@60751
   510
val return_s_make_complete_step = (pbl_from_o_model, met_from_pbl)
Walther@60751
   511
(*\------------------- step into s_make_complete -------------------------------------------//*)
Walther@60751
   512
;
Walther@60751
   513
if return_s_make_complete = return_s_make_complete_step
Walther@60751
   514
then () else error "s_make_complete: stewise construction <> value of fun"
Walther@60753
   515
Walther@60753
   516
Walther@60753
   517
"----------- check I_Model.s_make_complete for ([], [])-----------------------------------------";
Walther@60753
   518
"----------- check I_Model.s_make_complete for ([], [])-----------------------------------------";
Walther@60753
   519
"----------- check I_Model.s_make_complete for ([], [])-----------------------------------------";
Walther@60753
   520
val (_(*example text*),
Walther@60753
   521
  (model as ("Constants [r = (7::real)]" :: "Maximum A" :: "AdditionalValues [u, v]" :: 
Walther@60753
   522
     "Extremum (A = 2 * u * v - u \<up> 2)" :: 
Walther@60753
   523
     "SideConditions [((u::real) / 2) \<up> 2 + (2 / v) \<up> 2 = r \<up> 2]" :: 
Walther@60753
   524
     "SideConditions [((u::real) / 2) \<up> 2 + (2 / v) \<up> 2 = r \<up> 2]" :: 
Walther@60753
   525
     "SideConditions [(u::real) / 2 = r * sin \<alpha>, 2 / v = r * cos \<alpha>]" :: (*INCORRECT 2 / v*)
Walther@60753
   526
(*---------------------------------------------,(v::real) / 2 = r * cos \<alpha>]" --- ERROR in example*)
Walther@60753
   527
     "FunctionVariable a" :: "FunctionVariable b" :: "FunctionVariable \<alpha>" :: 
Walther@60753
   528
     "Domain {0 <..< r}" :: "Domain {0 <..< r}" :: "Domain {0 <..< \<pi> / 2}" ::
Walther@60753
   529
     "ErrorBound (\<epsilon> = (0::real))" :: []), 
Walther@60753
   530
   refs as ("Diff_App", 
Walther@60753
   531
     ["univariate_calculus", "Optimisation"],
Walther@60753
   532
     ["Optimisation", "by_univariate_calculus"])))
Walther@60753
   533
  = Store.get (Know_Store.get_expls @{theory}) ["Diff_App-No.123a"] ["Diff_App-No.123a"];
Walther@60753
   534
Walther@60753
   535
val c = [];
Walther@60753
   536
val (p,_,f,nxt,_,pt) = 
Walther@60753
   537
 Test_Code.init_calc @{context} [(model, refs)]; val Model_Problem = nxt;
Walther@60753
   538
val (p,_,f,nxt,_,pt) = me nxt p c pt;
Walther@60753
   539
Walther@60753
   540
(*//------------------ setup test data for I_Model.s_make_complete -------------------------\\*)
Walther@60753
   541
val (o_model, (pI, mI)) = case get_obj I pt (fst p) of
Walther@60753
   542
   PblObj {origin = (o_model, (_, pI, mI), _), ...}
Walther@60753
   543
      => (o_model, (pI, mI))
Walther@60753
   544
       | _ => raise ERROR ""
Walther@60753
   545
Walther@60753
   546
val pbl_imod = []
Walther@60753
   547
val met_imod = []
Walther@60753
   548
;
Walther@60753
   549
(*+*)if (o_model |> O_Model.to_string @{context}) = "[\n" ^
Walther@60753
   550
(*+*)  "(1, [\"1\", \"2\", \"3\"], #Given, Constants, [\"[r = 7]\"]), \n" ^
Walther@60753
   551
(*+*)  "(2, [\"1\", \"2\", \"3\"], #Find, Maximum, [\"A\"]), \n" ^
Walther@60753
   552
(*+*)  "(3, [\"1\", \"2\", \"3\"], #Find, AdditionalValues, [\"[u]\", \"[v]\"]), \n" ^
Walther@60753
   553
(*+*)  "(4, [\"1\", \"2\", \"3\"], #Relate, Extremum, [\"A = 2 * u * v - u \<up> 2\"]), \n" ^
Walther@60753
   554
(*+*)  "(5, [\"1\", \"2\"], #Relate, SideConditions, [\"[(u / 2) \<up> 2 + (2 / v) \<up> 2 = r \<up> 2]\"]), \n" ^
Walther@60753
   555
(*+*)  "(6, [\"3\"], #Relate, SideConditions, [\"[u / 2 = r * sin \<alpha>]\", \"[2 / v = r * cos \<alpha>]\"]), \n" ^
Walther@60753
   556
(*+*)  "(7, [\"1\"], #undef, FunctionVariable, [\"a\"]), \n" ^
Walther@60753
   557
(*+*)  "(8, [\"2\"], #undef, FunctionVariable, [\"b\"]), \n" ^
Walther@60753
   558
(*+*)  "(9, [\"3\"], #undef, FunctionVariable, [\"\<alpha>\"]), \n" ^
Walther@60753
   559
(*+*)  "(10, [\"1\", \"2\"], #undef, Input_Descript.Domain, [\"{0<..<r}\"]), \n" ^
Walther@60753
   560
(*+*)  "(11, [\"3\"], #undef, Input_Descript.Domain, [\"{0<..<\<pi> / 2}\"]), \n" ^
Walther@60753
   561
(*+*)  "(12, [\"1\", \"2\", \"3\"], #undef, ErrorBound, [\"\<epsilon> = 0\"])]"
Walther@60753
   562
then () else error "setup test data for I_Model.s_make_complete CHANGED";
Walther@60753
   563
(*\\------------------ setup test data for I_Model.s_make_complete -------------------------//*)
Walther@60753
   564
Walther@60753
   565
val return_s_make_complete =
Walther@60757
   566
           s_make_complete ctxt o_model (pbl_imod, met_imod) (pI, mI);
Walther@60753
   567
(*/------------------- step into s_make_complete -------------------------------------------\\*)
Walther@60753
   568
"~~~~~ fun s_make_complete , args:"; val (o_model, (pbl_imod, met_imod), (pbl_patt, met_patt)) =
Walther@60753
   569
  (o_model, (pbl_imod, met_imod), (pbl_patt, met_patt));
Walther@60753
   570
    val pbl_max_vnts = Model_Def.max_variants o_model pbl_imod;
Walther@60753
   571
Walther@60753
   572
    val i_from_pbl = map (fn (_, (descr, _)) =>
Walther@60753
   573
      Pre_Conds.get_descr_vnt descr pbl_max_vnts pbl_imod) pbl_patt;
Walther@60753
   574
(*//------------------ step into get_descr_vnt ---------------------------------------------\\*)
Walther@60753
   575
"~~~~~ fun get_descr_vnt , args:"; val (descr, vnts, i_model) =
Walther@60753
   576
  (@{term Constants}, pbl_max_vnts, pbl_imod);
Walther@60771
   577
    val equal_descr(*for (*+*)filter (fn (_, vnts',..*): I_Model.T_POS =
Walther@60767
   578
                      filter (fn (_, _, _, _, (feedb, _)) => case get_dscr_opt feedb of NONE => false
Walther@60753
   579
      | SOME descr' => if descr = descr' then true else false) i_model 
Walther@60753
   580
;
Walther@60771
   581
(*+*)filter (fn (_, vnts', _, _, _) => inter op= vnts' vnts <> []) (equal_descr: I_Model.T_POS)
Walther@60771
   582
(*+*): I_Model.T_POS
Walther@60753
   583
;
Walther@60753
   584
val return_get_descr_vnt_1 =
Walther@60753
   585
    case filter (fn (_, vnts', _, _, _) => inter op= vnts' vnts <> []) equal_descr of
Walther@60771
   586
      [] => (0, [], false, "i_model_empty", (Sup_POS (descr, []), Position.none))
Walther@60753
   587
    | items => Library.the_single items (*only applied to model_patt, which has each descr once*)
Walther@60753
   588
(*\\------------------ step into get_descr_vnt ---------------------------------------------//*)
Walther@60753
   589
;
Walther@60753
   590
(*+*)if return_get_descr_vnt_1 = nth 1 i_from_pbl
Walther@60753
   591
(*+*)then () else error "return_get_descr_vnt_1 <> nth 1 i_from_pbl";
Walther@60771
   592
(*+*)if (i_from_pbl |> I_Model.to_string_POS @{context}) = "[\n" ^
Walther@60771
   593
  "(0, [], false ,i_model_empty, (Sup_POS Constants [], Position.T)), \n" ^
Walther@60771
   594
  "(0, [], false ,i_model_empty, (Sup_POS Maximum, Position.T)), \n" ^
Walther@60771
   595
  "(0, [], false ,i_model_empty, (Sup_POS AdditionalValues [], Position.T)), \n" ^
Walther@60771
   596
  "(0, [], false ,i_model_empty, (Sup_POS Extremum, Position.T)), \n" ^
Walther@60771
   597
  "(0, [], false ,i_model_empty, (Sup_POS SideConditions [], Position.T))]"
Walther@60753
   598
(*+*)then () else error "I_Model.s_make_complete > i_from_pbl CHANGED";
Walther@60753
   599
Walther@60753
   600
(*|------------------- continue s_make_complete ----------------------------------------------*)
Walther@60753
   601
    val pbl_from_o_model = map ((fn i_single as (_, _, _, _, (feedb, _)) =>
Walther@60771
   602
      if is_empty_single_POS i_single
Walther@60753
   603
      then
Walther@60753
   604
        case get_descr_vnt' feedb pbl_max_vnts o_model of
Walther@60753
   605
(*-----------^^^^^^^^^^^^^^-----------------------------*)
Walther@60753
   606
            [] => raise ERROR (msg pbl_max_vnts feedb)
Walther@60753
   607
          | o_singles => map transfer_terms o_singles
Walther@60753
   608
      else [i_single (*fetched before from pbl_imod*)])) i_from_pbl |> flat
Walther@60753
   609
Walther@60753
   610
(*+*)val [1, 2, 3] = vnts;
Walther@60771
   611
(*+*)if (pbl_from_o_model |> I_Model.to_string_POS @{context}) = "[\n" ^
Walther@60771
   612
  "(1, [1, 2, 3], true ,#Given, (Cor_POS Constants [r = 7] , pen2str, Position.T)), \n" ^
Walther@60771
   613
  "(2, [1, 2, 3], true ,#Find, (Cor_POS Maximum A , pen2str, Position.T)), \n" ^
Walther@60771
   614
  "(3, [1, 2, 3], true ,#Find, (Cor_POS AdditionalValues [u, v] , pen2str, Position.T)), \n" ^
Walther@60771
   615
  "(4, [1, 2, 3], true ,#Relate, (Cor_POS Extremum (A = 2 * u * v - u \<up> 2) , pen2str, Position.T)), \n" ^
Walther@60771
   616
  "(5, [1, 2], true ,#Relate, (Cor_POS SideConditions [(u / 2) \<up> 2 + (2 / v) \<up> 2 = r \<up> 2] , pen2str, Position.T)), \n" ^
Walther@60771
   617
  "(6, [3], true ,#Relate, (Cor_POS SideConditions [u / 2 = r * sin \<alpha>, 2 / v = r * cos \<alpha>] , pen2str, Position.T))]"
Walther@60757
   618
then () else error "pbl_from_o_model CHANGED 2"
Walther@60753
   619
Walther@60753
   620
(*//------------------ step into map ((fn i_single -----------------------------------------\\*)
Walther@60753
   621
"~~~~~ fun map nth 1 ((fn i_single , args:"; val (i_single as (_, _, _, _, (feedb, _))) =
Walther@60753
   622
  (nth 1 i_from_pbl);
Walther@60771
   623
      (*if*) is_empty_single_POS i_single (*then*);
Walther@60753
   624
  (*case*) get_descr_vnt' feedb pbl_max_vnts o_model;
Walther@60753
   625
Walther@60771
   626
(*+*)val (0, [], false, "i_model_empty", (Sup_POS (Const ("Input_Descript.Constants", _), []), _))
Walther@60753
   627
  = i_single
Walther@60771
   628
(*+*)val true = is_empty_single_POS i_single
Walther@60753
   629
Walther@60753
   630
val return_get_descr_vnt'= (*case*)
Walther@60753
   631
           get_descr_vnt' feedb pbl_max_vnts o_model (*of*);
Walther@60753
   632
(*\\------------------ step into map ((fn i_single -----------------------------------------//*)
Walther@60753
   633
Walther@60753
   634
(*|------------------- continue s_make_complete ----------------------------------------------*)
Walther@60753
   635
    val i_from_met = map (fn (_, (descr, _)) =>
Walther@60753
   636
      Pre_Conds.get_descr_vnt descr pbl_max_vnts met_imod) met_patt
Walther@60753
   637
Walther@60753
   638
(*+*)val [1, 2, 3] = pbl_max_vnts (*..? ? GOON*);
Walther@60771
   639
(*+*)if (i_from_met |> I_Model.to_string_POS @{context}) = "[\n" ^
Walther@60771
   640
  "(0, [], false ,i_model_empty, (Sup_POS Constants [], Position.T)), \n" ^
Walther@60771
   641
  "(0, [], false ,i_model_empty, (Sup_POS Maximum, Position.T)), \n" ^
Walther@60771
   642
  "(0, [], false ,i_model_empty, (Sup_POS Extremum, Position.T)), \n" ^
Walther@60771
   643
  "(0, [], false ,i_model_empty, (Sup_POS SideConditions [], Position.T)), \n" ^
Walther@60771
   644
  "(0, [], false ,i_model_empty, (Sup_POS FunctionVariable, Position.T)), \n" ^
Walther@60771
   645
  "(0, [], false ,i_model_empty, (Sup_POS Input_Descript.Domain, Position.T)), \n" ^
Walther@60771
   646
  "(0, [], false ,i_model_empty, (Sup_POS ErrorBound, Position.T)), \n" ^
Walther@60771
   647
  "(0, [], false ,i_model_empty, (Sup_POS AdditionalValues [], Position.T))]"
Walther@60753
   648
(*+*)then () else error "s_make_complete: i_from_met CHANGED";
Walther@60753
   649
Walther@60753
   650
    val met_max_vnts = Model_Def.max_variants o_model i_from_met;
Walther@60753
   651
(*+*)val [1, 2, 3]: variant list = met_max_vnts
Walther@60753
   652
Walther@60753
   653
    val max_vnt = hd met_max_vnts (*need only one for solve-phase*)
Walther@60753
   654
    val met_from_pbl = map ((fn i_single as (_, _, _, _, (feedb, _)) =>
Walther@60771
   655
      if is_empty_single_POS i_single
Walther@60753
   656
      then
Walther@60753
   657
        case get_descr_vnt' feedb [max_vnt] o_model of
Walther@60753
   658
            [] => raise ERROR (msg [max_vnt] feedb)
Walther@60753
   659
          | o_singles => map transfer_terms o_singles
Walther@60753
   660
      else [i_single (*fetched before from met_imod*)])) i_from_met |> flat
Walther@60753
   661
Walther@60753
   662
(*+*)val 1 = max_vnt;
Walther@60771
   663
(*+*)if (met_from_pbl |> I_Model.to_string_POS @{context}) = "[\n" ^
Walther@60771
   664
  "(1, [1, 2, 3], true ,#Given, (Cor_POS Constants [r = 7] , pen2str, Position.T)), \n" ^
Walther@60771
   665
  "(2, [1, 2, 3], true ,#Find, (Cor_POS Maximum A , pen2str, Position.T)), \n" ^
Walther@60771
   666
  "(4, [1, 2, 3], true ,#Relate, (Cor_POS Extremum (A = 2 * u * v - u \<up> 2) , pen2str, Position.T)), \n" ^
Walther@60771
   667
  "(5, [1, 2], true ,#Relate, (Cor_POS SideConditions [(u / 2) \<up> 2 + (2 / v) \<up> 2 = r \<up> 2] , pen2str, Position.T)), \n" ^
Walther@60771
   668
  "(7, [1], true ,#undef, (Cor_POS FunctionVariable a , pen2str, Position.T)), \n" ^
Walther@60771
   669
  "(10, [1, 2], true ,#undef, (Cor_POS Input_Descript.Domain {0<..<r} , pen2str, Position.T)), \n" ^
Walther@60771
   670
  "(12, [1, 2, 3], true ,#undef, (Cor_POS ErrorBound (\<epsilon> = 0) , pen2str, Position.T)), \n" ^
Walther@60771
   671
  "(3, [1, 2, 3], true ,#Find, (Cor_POS AdditionalValues [u, v] , pen2str, Position.T))]"
Walther@60753
   672
(*+*)then () else error "s_make_complete: met_from_pbl CHANGED";
Walther@60753
   673
Walther@60753
   674
val return_s_make_complete_step as (pbl_imod_step, met_imod_step)=
Walther@60753
   675
    (filter (fn (_, vnts', _, _, _) => member op = vnts' max_vnt) pbl_from_o_model,
Walther@60753
   676
      met_from_pbl);
Walther@60753
   677
(*\------------------- step into s_make_complete -------------------------------------------//*)
Walther@60753
   678
if return_s_make_complete = return_s_make_complete_step
Walther@60753
   679
then () else error "s_make_complete: stewise construction <> value of fun"
Walther@60753
   680
;
Walther@60753
   681
(* final test ... ----------------------------------------------------------------------------*)
Walther@60771
   682
val "[\n(1, [1, 2, 3], true ,#Given, (Cor_POS Constants [r = 7] , pen2str, Position.T)), \n(2, [1, 2, 3], true ,#Find, (Cor_POS Maximum A , pen2str, Position.T)), \n(3, [1, 2, 3], true ,#Find, (Cor_POS AdditionalValues [u, v] , pen2str, Position.T)), \n(4, [1, 2, 3], true ,#Relate, (Cor_POS Extremum (A = 2 * u * v - u \<up> 2) , pen2str, Position.T)), \n(5, [1, 2], true ,#Relate, (Cor_POS SideConditions [(u / 2) \<up> 2 + (2 / v) \<up> 2 = r \<up> 2] , pen2str, Position.T))]"
Walther@60771
   683
 = pbl_imod_step |> I_Model.to_string_POS @{context}
Walther@60771
   684
val "[\n(1, [1, 2, 3], true ,#Given, (Cor_POS Constants [r = 7] , pen2str, Position.T)), \n(2, [1, 2, 3], true ,#Find, (Cor_POS Maximum A , pen2str, Position.T)), \n(4, [1, 2, 3], true ,#Relate, (Cor_POS Extremum (A = 2 * u * v - u \<up> 2) , pen2str, Position.T)), \n(5, [1, 2], true ,#Relate, (Cor_POS SideConditions [(u / 2) \<up> 2 + (2 / v) \<up> 2 = r \<up> 2] , pen2str, Position.T)), \n(7, [1], true ,#undef, (Cor_POS FunctionVariable a , pen2str, Position.T)), \n(10, [1, 2], true ,#undef, (Cor_POS Input_Descript.Domain {0<..<r} , pen2str, Position.T)), \n(12, [1, 2, 3], true ,#undef, (Cor_POS ErrorBound (\<epsilon> = 0) , pen2str, Position.T)), \n(3, [1, 2, 3], true ,#Find, (Cor_POS AdditionalValues [u, v] , pen2str, Position.T))]"
Walther@60771
   685
 = met_imod_step |> I_Model.to_string_POS @{context};
Walther@60763
   686
Walther@60766
   687
Walther@60766
   688
Walther@60766
   689
(*** fun item_to_add: Maximum-example ====================================================== ***);
Walther@60766
   690
"----------- fun item_to_add: Maximum-example --------------------------------------------------";
Walther@60766
   691
"----------- fun item_to_add: Maximum-example --------------------------------------------------";
Walther@60763
   692
(*//------------------ setup test data for item_to_add Maximum-exammple --------------------\\*)
Walther@60763
   693
(*
Walther@60763
   694
(*+*)val "[\n
Walther@60763
   695
  (1, [\"1\", \"2\", \"3\"], #Given, Constants, [\"[r = 7]\"]), \n
Walther@60763
   696
  (2, [\"1\", \"2\", \"3\"], #Find, Maximum, [\"A\"]), \n
Walther@60763
   697
  (3, [\"1\", \"2\", \"3\"], #Find, AdditionalValues, [\"[u]\", \"[v]\"]), \n
Walther@60763
   698
  (4, [\"1\", \"2\", \"3\"], #Relate, Extremum, [\"A = 2 * u * v - u \<up> 2\"]), \n
Walther@60763
   699
  (5, [\"1\", \"2\"], #Relate, SideConditions, [\"[(u / 2) \<up> 2 + (2 / v) \<up> 2 = r \<up> 2]\"]), \n
Walther@60763
   700
  (7, [\"1\"], #undef, FunctionVariable, [\"a\"]), \n
Walther@60763
   701
  (10, [\"1\", \"2\"], #undef, Input_Descript.Domain, [\"{0<..<r}\"]), \n
Walther@60763
   702
  (12, [\"1\", \"2\", \"3\"], #undef, ErrorBound, [\"\<epsilon> = 0\"])]"
Walther@60763
   703
 = o_model |> O_Model.to_string ctxt
Walther@60763
   704
Walther@60763
   705
val true = o_model_test = o_model
Walther@60763
   706
*)
Walther@60763
   707
val ctxt = @{context}
Walther@60763
   708
Walther@60763
   709
val o_model_test = [
Walther@60763
   710
  (1, [1, 2, 3], "#Given",  @{term Constants},        [@{term "[r = (7::real)]"}]),
Walther@60763
   711
  (2, [1, 2, 3], "#Find",   @{term Maximum},          [@{term "A::real"}            ]),
Walther@60763
   712
  (3, [1, 2, 3], "#Find",   @{term AdditionalValues}, [@{term "[u::real]"}, @{term "[v::real]"}]),
Walther@60763
   713
  (4, [1, 2, 3], "#Relate", @{term Extremum},         [@{term "A = 2 * u * v - u \<up> 2"}]),
Walther@60763
   714
  (5, [1, 2],    "#Relate", @{term SideConditions},   [@{term "[(u / 2) \<up> 2 + (2 / v) \<up> 2 = r \<up> 2]"}]),
Walther@60763
   715
  (7, [1],       "#undef",  @{term FunctionVariable}, [@{term "a::real"}]),
Walther@60763
   716
  (10,[1, 2],    "#undef",  @{term Domain},           [@{term "{0<..<(r::real)}"}]),
Walther@60763
   717
  (12,[1, 2, 3], "#undef",  @{term ErrorBound},       [@{term "\<epsilon> = (0::real)"}]),
Walther@60763
   718
  (0, [1],       "#Find",   @{term solutions},        [@{term "L::real list"}])
Walther@60763
   719
];
Walther@60763
   720
(*\\------------------ setup test data for item_to_add Maximum-exammple --------------------//*)
Walther@60763
   721
Walther@60766
   722
(** fun item_to_add: Constants [r = (7::real)] ============================================== **);
Walther@60771
   723
val i_single : I_Model.single_POS =
Walther@60771
   724
((3, [1, 2, 3], false, "from o_model", (Inc_POS (@{term Constants}, []) , Position.none)))
Walther@60763
   725
val SOME ("#Given", "Constants [r = 7]") = item_to_add ctxt o_model_test [i_single];
Walther@60763
   726
Walther@60766
   727
(** fun item_to_add: Maximum A ============================================================== **);
Walther@60771
   728
val i_single : I_Model.single_POS =
Walther@60771
   729
((3, [1, 2, 3], false, "from o_model", (Inc_POS (@{term Maximum}, []) , Position.none)))
Walther@60763
   730
val SOME ("#Find", "Maximum A") = item_to_add ctxt o_model_test [i_single];
Walther@60763
   731
Walther@60766
   732
(** fun item_to_add: AdditionalValues [u] =================================================== **);
Walther@60771
   733
val i_single : I_Model.single_POS =
Walther@60771
   734
((3, [1, 2, 3], false, "from o_model", (Inc_POS (@{term AdditionalValues}, []) , Position.none)))
Walther@60763
   735
val SOME ("#Find", "AdditionalValues [u]") = item_to_add ctxt o_model_test [i_single];
Walther@60763
   736
Walther@60766
   737
(** fun item_to_add: AdditionalValues [u, v] ================================================ **);
Walther@60771
   738
val i_single : I_Model.single_POS =
Walther@60771
   739
((3, [1, 2, 3], false, "from o_model", (Inc_POS (@{term AdditionalValues}, [@{term "[u::real]"}]) , Position.none)))
Walther@60763
   740
(**)val SOME ("#Find", "AdditionalValues [u, v]") = item_to_add ctxt o_model_test [i_single];
Walther@60763
   741
Walther@60766
   742
(** fun item_to_add: AdditionalValues [v, u] ================================================ **);
Walther@60763
   743
(*/------------------- fun item_to_add: AdditionalValues [v, u] ----------------------------\\*)
Walther@60771
   744
val i_single : I_Model.single_POS =
Walther@60763
   745
(*present [v, u] (reverse order), because second element has been input first ------vvvvvvvvvv*)
Walther@60771
   746
((3, [1, 2, 3], false, "from o_model", (Inc_POS (@{term AdditionalValues}, [@{term "[v::real]"}]) , Position.none)))
Walther@60763
   747
Walther@60763
   748
(**)val return_item_to_add as SOME ("#Find", "AdditionalValues [v, u]") = (**)
Walther@60763
   749
(** )val calling_code as SOME ("#Find", "AdditionalValues [v, u]") =( **)
Walther@60763
   750
           item_to_add ctxt o_model_test [i_single];
Walther@60763
   751
(*//------------------ step into item_to_add -----------------------------------------------\\*)
Walther@60763
   752
"~~~~~ fun item_to_add , args:"; val (ctxt, o_model, i_model) = (ctxt, o_model_test, [i_single]);
Walther@60766
   753
    val max_vnt as 1 = last_elem (*this decides, for which variant initially help is given*)
Walther@60763
   754
      (Model_Def.max_variants o_model i_model)
Walther@60763
   755
    val o_vnts = filter (fn (_, vnts, _, _, _) => member op= vnts max_vnt) o_model
Walther@60763
   756
    val i_to_select = i_model
Walther@60771
   757
      |> filter_out (fn (_, vnts, _, _, (I_Model.Cor_POS _, _)) => member op= vnts max_vnt | _ => false)
Walther@60763
   758
      |> select_inc_lists
Walther@60766
   759
    (*in*)
Walther@60771
   760
(*+*)val "[\n(3, [1, 2, 3], false ,from o_model, (Inc_POS AdditionalValues [v] , pen2str, Position.T))]"
Walther@60771
   761
 = i_to_select |> I_Model.to_string_POS ctxt
Walther@60771
   762
(*+*)val [(_, _, _, _, (Inc_POS (_, [Const ("List.list.Cons", _) $ Free ("v", _) $ _]), _))]
Walther@60766
   763
 = i_to_select
Walther@60763
   764
Walther@60763
   765
val false =
Walther@60763
   766
    (*if*) i_to_select = []
Walther@60763
   767
Walther@60766
   768
(** )val return_item_to_add =( **)
Walther@60766
   769
(**)val return_fill_from_o as
Walther@60771
   770
      SOME (_, _, _, _, (Cor_POS (Const ("Input_Descript.AdditionalValues", _), xxx), _)) =(**)
Walther@60763
   771
(*I_Model.*)fill_from_o o_vnts (hd i_to_select) (*of*);
Walther@60763
   772
(*///----------------- step into fill_from_o -----------------------------------------------\\*)
Walther@60763
   773
"~~~~~ fun fill_from_o , args:"; val (o_model, (i, vnts, bool, _, (feedb, pos))) =
Walther@60763
   774
  (o_vnts, (hd i_to_select));
Walther@60763
   775
    val (m_field, all_value) =
Walther@60767
   776
      case find_first (fn (_, _, _, descr', _) => Model_Def.descriptor_exists descr' feedb) o_model of
Walther@60763
   777
        SOME (_, _, m_field, _, ts) =>  (m_field, ts)
Walther@60763
   778
      | NONE => raise ERROR "I_Model.fill_from_o does NOT find a descriptor in O_Model"
Walther@60767
   779
    val descr = Model_Def.get_descr feedb (*i_single has been filtered appropriately*)
Walther@60763
   780
(*+*)val "[[u], [v]]" = all_value |> UnparseC.terms ctxt
Walther@60766
   781
    (*in*)
Walther@60766
   782
val true =
Walther@60766
   783
    (*if*) Model_Def.is_list_descr descr
Walther@60777
   784
        val already_input as [Const ("List.list.Cons", _) $ Free ("v", _) $ _] = feedb |> feedb_values
Walther@60763
   785
Walther@60766
   786
        val miss = subtract op= already_input all_value
Walther@60766
   787
(*+*)val "[[u]]" = miss |> UnparseC.terms ctxt
Walther@60766
   788
Walther@60766
   789
        val ts = already_input @ [hd miss]
Walther@60766
   790
val "[[v], [u]]" = ts |> UnparseC.terms ctxt
Walther@60766
   791
    (*in*)
Walther@60763
   792
val true =
Walther@60766
   793
        (*if*) length all_value = length ts
Walther@60771
   794
val return_fill_from_o_STEP = SOME (i, vnts, bool, m_field, (Cor_POS (descr, [values_to_present ts]), pos))
Walther@60763
   795
(*\\\----------------- step into fill_from_o -----------------------------------------------//*)
Walther@60763
   796
        val SOME (_, _, _, m_field, (feedb, _)) = return_fill_from_o
Walther@60771
   797
(*+*)val Cor_POS (Const ("Input_Descript.AdditionalValues", _), xxx) = feedb;
Walther@60766
   798
(*+*)val xxx = xxx |> UnparseC.terms ctxt;
Walther@60763
   799
Walther@60763
   800
(*||------------------ contiue.. item_to_add -------------------------------------------------*)
Walther@60763
   801
(** )val return_item_to_add = ( **)
Walther@60763
   802
  SOME (m_field, feedb |> 
Walther@60766
   803
   (*I_Model.*)feedb_args_to_string ctxt);
Walther@60763
   804
(*///----------------- step into feedb_args_to_string --------------------------------------\\*)
Walther@60771
   805
"~~~~~ fun feedb_args_to_string , args:"; val (ctxt, Cor_POS (descr, values)) = (ctxt, feedb);
Walther@60763
   806
(** )val return_feedb_args_to_string =( **)
Walther@60766
   807
val return_feedb_args_to_string_STEP =
Walther@60769
   808
    UnparseC.term ctxt (descr $ values_to_present values);
Walther@60763
   809
(*\\\----------------- step into feedb_args_to_string --------------------------------------//*)
Walther@60763
   810
(*\\------------------ step into item_to_add -----------------------------------------------//*)
Walther@60763
   811
val calling_code as SOME ("#Find", "AdditionalValues [v, u]") = return_item_to_add;
Walther@60763
   812
(*\------------------- fun item_to_add: AdditionalValues [v, u] ----------------------------//*)
Walther@60763
   813
Walther@60766
   814
Walther@60766
   815
(** fun item_to_add: Constants Extremum (A = 2 * u * v - u \<up> 2) ============================= **);
Walther@60771
   816
val i_single : I_Model.single_POS =
Walther@60771
   817
((3, [1, 2, 3], false, "from o_model", (Inc_POS (@{term Extremum}, []) , Position.none)))
Walther@60763
   818
val SOME ("#Relate", "Extremum (A = 2 * u * v - u \<up> 2)")
Walther@60763
   819
  = item_to_add ctxt o_model_test [i_single];
Walther@60763
   820
Walther@60766
   821
(** fun item_to_add: Constants SideConditions [(u / 2) \<up> 2 + (2 / v) \<up> 2 = r \<up> 2] ============ **);
Walther@60771
   822
val i_single : I_Model.single_POS =
Walther@60771
   823
((3, [1, 2, 3], false, "from o_model", (Inc_POS (@{term SideConditions}, []) , Position.none)))
Walther@60763
   824
val SOME ("#Relate", "SideConditions [(u / 2) \<up> 2 + (2 / v) \<up> 2 = r \<up> 2]")
Walther@60763
   825
  = item_to_add ctxt o_model_test [i_single];
Walther@60763
   826
Walther@60766
   827
(** fun item_to_add: Solutions L ============================================================ **);
Walther@60771
   828
val i_single : I_Model.single_POS =
Walther@60771
   829
(3, [1, 2, 3], false, "from o_model", (Inc_POS (@{term solutions}, []) , Position.none))
Walther@60763
   830
val SOME ("#Find", "solutions L") = item_to_add ctxt o_model_test [i_single];
Walther@60766
   831
Walther@60766
   832
Walther@60766
   833
(*** fun item_to_add Biegelinie-exammple =================================================== ***);
Walther@60766
   834
"----------- fun item_to_add: Biegelinie-exammple ----------------------------------------------";
Walther@60766
   835
"----------- fun item_to_add: Biegelinie-exammple ----------------------------------------------";
Walther@60766
   836
Walther@60766
   837
(** fun item_to_add: solveForVars [c] ======================================================= **);
Walther@60766
   838
val (descr $ t) = @{term "solveForVars [c, c_2, c_3, c_4]"}
Walther@60766
   839
val [Const ("List.list.Cons", _) $ Free ("c",   _) $ Const ("List.list.Nil", _),
Walther@60766
   840
     Const ("List.list.Cons", _) $ Free ("c_2", _) $ Const ("List.list.Nil", _),
Walther@60766
   841
     Const ("List.list.Cons", _) $ Free ("c_3", _) $ Const ("List.list.Nil", _),
Walther@60766
   842
     Const ("List.list.Cons", _) $ Free ("c_4", _) $ Const ("List.list.Nil", _)]
Walther@60766
   843
  = make_values (descr, t)
Walther@60766
   844
Walther@60766
   845
val o_model_test : O_Model.T = [(0, [1], "#Given", descr, make_values (descr, t))]
Walther@60771
   846
val i_model_test : I_Model.T_POS = [
Walther@60771
   847
  (0, [1], false, "get-from-o_model", (Inc_POS (descr, []) , Position.none))]
Walther@60766
   848
val SOME ("#Given", "solveForVars [c]") = item_to_add ctxt o_model_test i_model_test;
Walther@60766
   849
Walther@60766
   850
(** fun item_to_add: solveForVars [c, c_2] ================================================== **);
Walther@60771
   851
val i_model_test : I_Model.T_POS = [
Walther@60771
   852
  (0, [1], false, "get-from-o_model", (Inc_POS (descr,
Walther@60766
   853
    [nth 1 (make_values (descr, t))]) , Position.none))]
Walther@60766
   854
val SOME ("#Given", "solveForVars [c, c_2]") = item_to_add ctxt o_model_test i_model_test;
Walther@60766
   855
Walther@60766
   856
(** fun item_to_add: solveForVars [c, c_2, c_3] ============================================= **);
Walther@60771
   857
val i_model_test : I_Model.T_POS = [
Walther@60771
   858
  (0, [1], false, "get-from-o_model", (Inc_POS (descr,
Walther@60766
   859
    (nth 1 (make_values (descr, t))) :: (nth 2 (make_values (descr, t))) :: []) , Position.none))]
Walther@60766
   860
val SOME ("#Given", "solveForVars [c, c_2, c_3]") = item_to_add ctxt o_model_test i_model_test;