test/Tools/isac/Specify/specify.sml
author wneuper <Walther.Neuper@jku.at>
Mon, 02 Oct 2023 15:39:22 +0200
changeset 60757 9f4d7a352426
parent 60756 b1ae5a019fa1
child 60766 2e0603ca18a4
permissions -rw-r--r--
prepare 11: clean up new code 1
walther@59763
     1
(* Title:  "Specify/specify.sml"
walther@59763
     2
   Author: Walther Neuper
walther@59763
     3
   (c) due to copyright terms
walther@59763
     4
*)
walther@59763
     5
walther@59763
     6
"-----------------------------------------------------------------------------------------------";
walther@59763
     7
"table of contents -----------------------------------------------------------------------------";
walther@59763
     8
"-----------------------------------------------------------------------------------------------";
walther@59763
     9
"-----------------------------------------------------------------------------------------------";
walther@59996
    10
"----------- maximum-example: Specify.finish_phase ---------------------------------------------";
Walther@60654
    11
"----------- revise Specify.do_all -------------------------------------------------------------";
walther@60014
    12
"----------- specify-phase: low level functions ------------------------------------------------";
walther@59763
    13
"-----------------------------------------------------------------------------------------------";
walther@59763
    14
"-----------------------------------------------------------------------------------------------";
walther@59763
    15
"-----------------------------------------------------------------------------------------------";
Walther@60736
    16
open Pos;
Walther@60736
    17
open Ctree;
Walther@60736
    18
open Test_Code;
Walther@60736
    19
open Tactic;
Walther@60736
    20
open Specify;
Walther@60736
    21
open Step;
Walther@60736
    22
Walther@60736
    23
open O_Model;
Walther@60736
    24
open I_Model;
Walther@60736
    25
open P_Model;
Walther@60736
    26
open Specify_Step;
Walther@60736
    27
open Test_Code;
walther@59763
    28
Walther@60459
    29
(**** maximum-example: Specify.finish_phase  ############################################# ****)
walther@59996
    30
"----------- maximum-example: Specify.finish_phase ---------------------------------------------";
walther@59996
    31
"----------- maximum-example: Specify.finish_phase ---------------------------------------------";
walther@59800
    32
(*//-------- WAS OUT OF Test UNTIL 200209, ERROR PROBABLY FROM INTRO. OF Isabelle's funpack --\\* )
walther@59800
    33
 val (p,_,f,nxt,_,pt) = 
Walther@60571
    34
     Test_Code.init_calc @{context} 
walther@59997
    35
     [(["fixedValues [r=Arbfix]", "maximum A",
walther@59800
    36
	"valuesFor [a,b]",
walther@60242
    37
	"relations [A=a*b, (a/2) \<up> 2 + (b/2) \<up> 2 = r \<up> 2]",
walther@60242
    38
	"relations [A=a*b, (a/2) \<up> 2 + (b/2) \<up> 2 = r \<up> 2]",
walther@59800
    39
	"relations [A=a*b, a/2=r*sin alpha, b/2=r*cos alpha]",
walther@59800
    40
	
walther@59997
    41
	"boundVariable a", "boundVariable b", "boundVariable alpha",
walther@59800
    42
	"interval {x::real. 0 <= x & x <= 2*r}",
walther@59800
    43
	"interval {x::real. 0 <= x & x <= 2*r}",
walther@59800
    44
	"interval {x::real. 0 <= x & x <= pi}",
walther@59800
    45
	"errorBound (eps=(0::real))"],
Walther@60458
    46
       ("Diff_App",["maximum_of", "function"],["Diff_App", "max_by_calculus"])
walther@59800
    47
       )];
walther@59800
    48
 val (p,_,f,nxt,_,pt) = me nxt p c pt;
walther@59800
    49
 val (p,_,f,nxt,_,pt) = me nxt p c pt;
walther@59800
    50
 val (p,_,f,nxt,_,pt) = me nxt p c pt;
walther@59800
    51
 (*nxt = nxt = Add_Find "valuesFor [a]" FIXME.12.03 +handle Inc !*)
walther@59800
    52
 val pits = get_obj g_pbl pt (fst p);
walther@59942
    53
 writeln (I_Model.to_string ctxt pits);
walther@59800
    54
(*[
walther@59800
    55
(0 ,[] ,false ,#Find ,Inc valuesFor ,(??.empty, [])),
walther@59800
    56
(0 ,[] ,false ,#Relate ,Inc relations [] ,(??.empty, [])),
walther@59800
    57
(1 ,[1,2,3] ,true,#Given,Cor fixedValues [r = Arbfix] ,(fix_, [[r = Arbfix]])),
walther@59800
    58
(2 ,[1,2,3] ,true ,#Find ,Cor maximum A ,(m_, [A]))]*) 
walther@59990
    59
 val (pt,p) = Specify.finish_phase (pt,p);
walther@59800
    60
 val pits = get_obj g_pbl pt (fst p);
walther@60242
    61
 if I_Model.to_string ctxt pits = "[\n(1 ,[1,2,3] ,true ,#Given ,Cor fixedValues [r = Arbfix] ,(fix_, [[r = Arbfix]])),\n(2 ,[1,2,3] ,true ,#Find ,Cor maximum A ,(m_, [A])),\n(3 ,[1,2,3] ,true ,#Find ,Cor valuesFor [a, b] ,(vs_, [[a],[b]])),\n(4 ,[1,2] ,true ,#Relate ,Cor relations [A = a * b, (a / 2) \<up> 2 + (b / 2) \<up> 2 = r \<up> 2] ,(rs_, [[A = a * b],[(a / 2) \<up> 2 + (b / 2) \<up> 2 = r \<up> 2]]))]" 
walther@59990
    62
 then () else error "completetest.sml: new behav. in Specify.finish_phase 3";
walther@59942
    63
 writeln (I_Model.to_string ctxt pits);
walther@59800
    64
(*[
walther@59800
    65
(1 ,[1,2,3] ,true,#Given,Cor fixedValues [r = Arbfix] ,(fix_, [[r = Arbfix]])),
walther@59800
    66
(2 ,[1,2,3] ,true ,#Find ,Cor maximum A ,(m_, [A])),
walther@59800
    67
(3 ,[1,2,3] ,true ,#Find ,Cor valuesFor [a, b] ,(valuesFor, [[a],[b]])),
walther@60242
    68
(4 ,[1,2] ,true ,#Relate ,Cor relations [A = a * b, (a / 2) \<up> 2 + (b / 2)  \<up> 
walther@60242
    69
2 = r \<up> 2] ,(relations, [[A = a * b],[(a / 2) \<up> 2 + (b / 2) \<up> 2 = r \<up> 2]]))]*)
walther@59800
    70
 val mits = get_obj g_met pt (fst p);
walther@60242
    71
 if I_Model.to_string ctxt mits = "[\n(1 ,[1,2,3] ,true ,#Given ,Cor fixedValues [r = Arbfix] ,(fix_, [[r = Arbfix]])),\n(2 ,[1,2,3] ,true ,#Find ,Cor maximum A ,(m_, [A])),\n(3 ,[1,2,3] ,true ,#Find ,Cor valuesFor [a, b] ,(vs_, [[a],[b]])),\n(4 ,[1,2] ,true ,#Relate ,Cor relations [A = a * b, (a / 2) \<up> 2 + (b / 2) \<up> 2 = r \<up> 2] ,(rs_, [[A = a * b],[(a / 2) \<up> 2 + (b / 2) \<up> 2 = r \<up> 2]])),\n(6 ,[1] ,true ,#undef ,Cor boundVariable a ,(v_, [a])),\n(9 ,[1,2] ,true ,#undef ,Cor interval {x. 0 <= x & x <= 2 * r} ,(itv_, [{x. 0 <= x & x <= 2 * r}])),\n(11 ,[1,2,3] ,true ,#undef ,Cor errorBound (eps = 0) ,(err_, [eps = 0]))]" 
walther@59990
    72
 then () else error "completetest.sml: new behav. in Specify.finish_phase 3";
walther@59942
    73
 writeln (I_Model.to_string ctxt mits);
walther@59800
    74
(*[
walther@59800
    75
(1 ,[1,2,3] ,true ,#Given ,Cor fixedValues [r = Arbfix] ,(fix_, [[r = Arbfix]])),
walther@59800
    76
(2 ,[1,2,3] ,true ,#Find ,Cor maximum A ,(m_, [A])),
walther@59800
    77
(3 ,[1,2,3] ,true ,#Find ,Cor valuesFor [a, b] ,(valuesFor, [[a],[b]])),
walther@60242
    78
(4 ,[1,2] ,true ,#Relate ,Cor relations [A = a * b, (a / 2) \<up> 2 + (b / 2)  \<up> 
walther@60242
    79
2 = r \<up> 2] ,(relations, [[A = a * b],[(a / 2) \<up> 2 + (b / 2) \<up> 2 = r \<up> 2]])),
walther@59800
    80
(6 ,[1] ,true ,#undef ,Cor boundVariable a ,(boundVariable, [a])),
walther@59800
    81
(9 ,[1,2] ,true ,#undef ,Cor interval {x. 0 <= x & x <= 2 * r} ,(interval, [{x.
walther@59800
    82
0 <= x & x <= 2 * r}])),
walther@59800
    83
(11 ,[1,2,3] ,true ,#undef ,Cor errorBound (eps = 0) ,(errorBound, [eps = 0]))]*)
walther@59800
    84
( *\\-------- WAS OUT OF Test UNTIL 200209, ERROR PROBABLY FROM INTRO. OF Isabelle's funpack --//*)
walther@59800
    85
Walther@60459
    86
Walther@60746
    87
(**** revise Specify.do_all ############################################################## ****);
Walther@60654
    88
"----------- revise Specify.do_all -------------------------------------------------------------";
Walther@60654
    89
"----------- revise Specify.do_all -------------------------------------------------------------";
Walther@60654
    90
(* from Minisubplb/100-init-rootpbl.sml:
Walther@60654
    91
val (_(*example text*), 
Walther@60654
    92
  (model as ("Constants [r = (7::real)]" :: "Maximum A" :: "AdditionalValues [u, v]" :: 
Walther@60654
    93
     "Extremum (A = 2 * u * v - u \<up> 2)" :: 
Walther@60654
    94
     "SideConditions [((u::real) / 2) \<up> 2 + (2 / v) \<up> 2 = r \<up> 2]" :: 
Walther@60654
    95
     "SideConditions [((u::real) / 2) \<up> 2 + (2 / v) \<up> 2 = r \<up> 2]" :: 
Walther@60654
    96
     "SideConditions [(u::real) / 2 = r * sin \<alpha>, 2 / v = r * cos \<alpha>]" :: 
Walther@60654
    97
     "FunctionVariable a" :: "FunctionVariable b" :: "FunctionVariable \<alpha>" :: 
Walther@60654
    98
     "Domain {0 <..< r}" :: "Domain {0 <..< r}" :: "Domain {0 <..< \<pi> / 2}" ::
Walther@60654
    99
     "ErrorBound (\<epsilon> = (0::real))" :: []), 
Walther@60654
   100
   refs as ("Diff_App", 
Walther@60654
   101
     ["univariate_calculus", "Optimisation"],
Walther@60654
   102
     ["Optimisation", "by_univariate_calculus"])))
Walther@60654
   103
  = Store.get (Know_Store.get_expls @ {theory Know_Store}) ["Diff_App-No.123a"] ["Diff_App-No.123a"];
Walther@60654
   104
*)
Walther@60654
   105
val model = ("Constants [r = (7::real)]" :: "Maximum A" :: "AdditionalValues [u, v]" :: 
Walther@60654
   106
     "Extremum (A = 2 * u * v - u \<up> 2)" :: 
Walther@60654
   107
     "SideConditions [((u::real) / 2) \<up> 2 + (2 / v) \<up> 2 = r \<up> 2]" :: 
Walther@60654
   108
     "SideConditions [((u::real) / 2) \<up> 2 + (2 / v) \<up> 2 = r \<up> 2]" :: 
Walther@60654
   109
     "SideConditions [(u::real) / 2 = r * sin \<alpha>, 2 / v = r * cos \<alpha>]" :: 
Walther@60654
   110
     "FunctionVariable a" :: "FunctionVariable b" :: "FunctionVariable \<alpha>" :: 
Walther@60654
   111
     "Domain {0 <..< r}" :: "Domain {0 <..< r}" :: "Domain {0 <..< \<pi> / 2}" ::
Walther@60654
   112
     "ErrorBound (\<epsilon> = (0::real))" :: [])
Walther@60654
   113
val refs = ("Diff_App", 
Walther@60654
   114
     ["univariate_calculus", "Optimisation"],
Walther@60654
   115
     ["Optimisation", "by_univariate_calculus"])
Walther@60654
   116
Walther@60654
   117
val (p,_,f,nxt,_,pt) =
Walther@60654
   118
 Test_Code.init_calc @{context} [(model, refs)];
Walther@60654
   119
"~~~~~ fun init_calc , args:"; val (ctxt, [(model, refs as (thy_id, _, _))])
Walther@60654
   120
  = (@{context}, [(model, refs)]);
Walther@60654
   121
Walther@60654
   122
   Specify.do_all (pt, p);
Walther@60654
   123
(*//------------------ step into do_all ----------------------------------------------------\\*)
Walther@60654
   124
"~~~~~ fun do_all , args:"; val (pt, (*old* )pos as( *old*) (p, _)) = (pt, p);
Walther@60755
   125
    val (itms, oris, probl, o_refs, spec, ctxt) = case Ctree.get_obj I pt p of
Walther@60755
   126
      Ctree.PblObj {meth = itms, origin = (oris, o_spec, _), probl, spec, ctxt, ...}
Walther@60755
   127
        => (itms, oris, probl, o_spec, spec, ctxt)
Walther@60755
   128
    | _ => raise ERROR "LI.by_tactic: no PblObj"
Walther@60755
   129
    val (_, pbl_id', met_id') = References.select_input o_refs spec
Walther@60757
   130
    val (pbl_imod, met_imod) = I_Model.s_make_complete ctxt oris
Walther@60757
   131
      (I_Model.OLD_to_TEST probl, I_Model.OLD_to_TEST itms) (pbl_id', met_id')
Walther@60755
   132
;
Walther@60654
   133
(*-------------------- stop step into do_all -------------------------------------------------*)
Walther@60654
   134
(*/------------------- check result of I_Model.complete' ------------------------------------\*)
Walther@60757
   135
(*+*)if Model_Pattern.to_string @{context} (#model (MethodC.from_store ctxt met_id')) = "[\"" ^
Walther@60654
   136
  "(#Given, (Constants, fixes))\", \"" ^
Walther@60654
   137
  "(#Given, (Maximum, maxx))\", \"" ^
Walther@60654
   138
  "(#Given, (Extremum, extr))\", \"" ^
Walther@60654
   139
  "(#Given, (SideConditions, sideconds))\", \"" ^
Walther@60654
   140
  "(#Given, (FunctionVariable, funvar))\", \"" ^
Walther@60654
   141
  "(#Given, (Input_Descript.Domain, doma))\", \"" ^
Walther@60654
   142
  "(#Given, (ErrorBound, err))\", \"" ^
Walther@60755
   143
  "(#Find, (AdditionalValues, vals))\"]"
Walther@60755
   144
(*+*)then () else error "mod_pat CHANGED";
Walther@60755
   145
(*+*)if I_Model.to_string_TEST @{context} met_imod = "[\n" ^
Walther@60755
   146
  "(1, [1, 2, 3], true ,#Given, (Cor_TEST Constants [r = 7] , pen2str, Position.T)), \n" ^
Walther@60755
   147
  "(2, [1, 2, 3], true ,#Find, (Cor_TEST Maximum A , pen2str, Position.T)), \n" ^
Walther@60755
   148
  "(4, [1, 2, 3], true ,#Relate, (Cor_TEST Extremum (A = 2 * u * v - u \<up> 2) , pen2str, Position.T)), \n" ^
Walther@60755
   149
  "(5, [1, 2], true ,#Relate, (Cor_TEST SideConditions [(u / 2) \<up> 2 + (2 / v) \<up> 2 = r \<up> 2] , pen2str, Position.T)), \n" ^
Walther@60755
   150
  "(7, [1], true ,#undef, (Cor_TEST FunctionVariable a , pen2str, Position.T)), \n" ^
Walther@60755
   151
  "(10, [1, 2], true ,#undef, (Cor_TEST Input_Descript.Domain {0<..<r} , pen2str, Position.T)), \n" ^
Walther@60755
   152
  "(12, [1, 2, 3], true ,#undef, (Cor_TEST ErrorBound (\<epsilon> = 0) , pen2str, Position.T)), \n" ^
Walther@60755
   153
  "(3, [1, 2, 3], true ,#Find, (Cor_TEST AdditionalValues [u, v] , pen2str, Position.T))]"
Walther@60755
   154
(*+*)then () else error "met_imod CHANGED";
Walther@60654
   155
(*\------------------- check result of I_Model.complete' ------------------------------------/*)
Walther@60654
   156
(*\\------------------ step into do_all ----------------------------------------------------//*)
Walther@60654
   157
Walther@60654
   158
(*-------------------- continuing do_all -----------------------------------------------------*)
Walther@60755
   159
    val (pt, _) = Ctree.cupdate_problem pt p
Walther@60755
   160
      (o_refs, I_Model.TEST_to_OLD pbl_imod, I_Model.TEST_to_OLD met_imod, ctxt)
Walther@60755
   161
;
Walther@60654
   162
Walther@60654
   163
Walther@60459
   164
(**** specify-phase: low level functions ################################################# ****)
Walther@60459
   165
"----------- specify-phase: low level functions -----------------------------------------";
Walther@60459
   166
"----------- specify-phase: low level functions -----------------------------------------";
Walther@60736
   167
open Pos;
Walther@60736
   168
open Ctree;
Walther@60736
   169
open Test_Code;
Walther@60736
   170
open Tactic;
Walther@60736
   171
open Specify;
Walther@60736
   172
open Step;
Walther@60736
   173
walther@60010
   174
open O_Model;
walther@60010
   175
open I_Model;
Walther@60736
   176
open P_Model;
walther@60010
   177
open Specify_Step;
Walther@60736
   178
walther@60010
   179
val formalise = ["Traegerlaenge L", "Streckenlast q_0", "Biegelinie y",
Walther@60736
   180
	    "Randbedingungen [y 0 = (0::real), y L = 0, M_b 0 = 0, M_b L = 0]",
Walther@60736
   181
(*
Walther@60736
   182
  Now follow items for ALL SubProblems,
Walther@60736
   183
  since ROOT MethodC must provide values for "actuals" of ALL SubProblems.
Walther@60736
   184
  See Biegelinie.thy subsection \<open>Survey on Methods\<close>.
Walther@60736
   185
*)
Walther@60736
   186
(*
Walther@60736
   187
  Items for MethodC "IntegrierenUndKonstanteBestimmen2"
Walther@60736
   188
*)
Walther@60736
   189
	    "FunktionsVariable x",
Walther@60736
   190
    (*"Biegelinie y",          ..already input for Problem above*)
Walther@60736
   191
      "AbleitungBiegelinie dy",
Walther@60736
   192
      "Biegemoment M_b",
Walther@60736
   193
      "Querkraft Q",
Walther@60736
   194
(*
Walther@60736
   195
  Item for Problem "LINEAR/system", which by [''no_met''] involves refinement
Walther@60736
   196
*)
Walther@60736
   197
      "GleichungsVariablen [c, c_2, c_3, c_4]"
Walther@60736
   198
];
Walther@60736
   199
(*
Walther@60736
   200
  Note: the above sequence of items follows the sequence of formal arguments (and of model items)
Walther@60736
   201
  of MethodC "IntegrierenUndKonstanteBestimmen2"
Walther@60736
   202
*)
walther@60010
   203
val references = ("Biegelinie", ["Biegelinien"], ["IntegrierenUndKonstanteBestimmen2"]);
walther@60010
   204
val p = e_pos'; val c = [];
Walther@60571
   205
(*[], Pbl*)val (p,_,f,nxt,_,pt) = Test_Code.init_calc @{context} [(formalise, references)]; (*nxt = Model_Problem*)
walther@59800
   206
Walther@60571
   207
(*/------------------- check result of Test_Code.init_calc @{context} ----------------------------------------\*)
walther@60010
   208
(*+*)val (o_model, ("Biegelinie", ["Biegelinien"], ["IntegrierenUndKonstanteBestimmen2"]), _) =
walther@60010
   209
  get_obj g_origin pt (fst p);
Walther@60655
   210
(*+*)if O_Model.to_string @{context} o_model = "[\n" ^
walther@60010
   211
  "(1, [\"1\"], #Given, Traegerlaenge, [\"L\"]), \n" ^
walther@60010
   212
  "(2, [\"1\"], #Given, Streckenlast, [\"q_0\"]), \n" ^
walther@60010
   213
  "(3, [\"1\"], #Find, Biegelinie, [\"y\"]), \n" ^
walther@60010
   214
  "(4, [\"1\"], #Relate, Randbedingungen, [\"[y 0 = 0]\", \"[y L = 0]\", \"[M_b 0 = 0]\", \"[M_b L = 0]\"]), \n" ^
walther@60010
   215
  "(5, [\"1\"], #undef, FunktionsVariable, [\"x\"]), \n" ^
Walther@60736
   216
  "(6, [\"1\"], #undef, AbleitungBiegelinie, [\"dy\"]), \n" ^
Walther@60736
   217
  "(7, [\"1\"], #undef, Biegemoment, [\"M_b\"]), \n" ^
Walther@60736
   218
  "(8, [\"1\"], #undef, Querkraft, [\"Q\"]), \n" ^
Walther@60736
   219
  "(9, [\"1\"], #undef, GleichungsVariablen, [\"[c]\", \"[c_2]\", \"[c_3]\", \"[c_4]\"])]"
walther@60010
   220
then () else error "[IntegrierenUndKonstanteBestimmen2] O_Model CHANGED";
Walther@60571
   221
(*\------------------- check result of Test_Code.init_calc @{context} ----------------------------------------/*)
walther@60010
   222
Walther@60736
   223
(*[], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p c pt; val Add_Given "Traegerlaenge L" = nxt
Walther@60736
   224
(*[], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p c pt; val Add_Given "Streckenlast q_0" = nxt
Walther@60736
   225
(*[], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p c pt; val Add_Find "Biegelinie y" = nxt
Walther@60736
   226
(*[], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p c pt; val Add_Relation "Randbedingungen [y 0 = 0, y L = 0, M_b 0 = 0, M_b L = 0]" = nxt
Walther@60729
   227
(*/---broken elementwise input to lists---\* )
walther@60010
   228
(*[], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p c pt; (*\<rightarrow>Add_Relation "Randbedingungen [y L = 0, M_b 0 = 0, M_b L = 0]"*)
Walther@60729
   229
( *\---broken elementwise input to lists---/*)
walther@60010
   230
Walther@60736
   231
val return_me_Add_Relation_Randbedingungen = me nxt p c pt; (*\<rightarrow>Specify_Problem ["Biegelinien"]*)
Walther@60736
   232
(*/------------------- step into me_Add_Relation_Randbedingungen ---------------------------\\*)
Walther@60736
   233
"~~~~~ fun me , args:"; val (tac, p, _(*NEW remove*), pt) = (nxt, p, c, pt);
Walther@60736
   234
      val ctxt = Ctree.get_ctxt pt p
Walther@60736
   235
      val (pt, p) = 
Walther@60736
   236
  	    (*Step.by_tactic is here for testing by me; do_next would suffice in me*)
Walther@60736
   237
  	    case Step.by_tactic tac (pt, p) of
Walther@60736
   238
  		    ("ok", (_, _, ptp)) => ptp
Walther@60736
   239
Walther@60736
   240
val ("ok", ([(Specify_Theory "Biegelinie", _, _)], _, _)) =
Walther@60736
   241
      (*case*)
Walther@60736
   242
      Step.do_next p ((pt, Pos.e_pos'), []) (*of*);
Walther@60736
   243
"~~~~~ fun do_next , args:"; val ((ip as (_, p_)), (ptp as (pt, p), tacis)) =
Walther@60736
   244
  (p, ((pt, Pos.e_pos'), []));
Walther@60736
   245
  (*if*) Pos.on_calc_end ip (*else*);
Walther@60736
   246
      val (_, probl_id, _) = Calc.references (pt, p);
Walther@60736
   247
val _ =
Walther@60736
   248
      (*case*) tacis (*of*);
Walther@60736
   249
        (*if*) probl_id = Problem.id_empty (*else*);
Walther@60736
   250
Walther@60736
   251
           switch_specify_solve p_ (pt, ip);
Walther@60736
   252
"~~~~~ fun switch_specify_solve , args:"; val (state_pos, (pt, input_pos)) = (p_, (pt, ip));
Walther@60736
   253
      (*if*) Pos.on_specification ([], state_pos) (*then*);
Walther@60736
   254
Walther@60736
   255
           specify_do_next (pt, input_pos);
Walther@60736
   256
"~~~~~ fun specify_do_next , args:"; val ((ptp as (pt, (p, p_)))) = ((pt, input_pos));
Walther@60736
   257
    val (_, (p_', tac)) = Specify.find_next_step ptp
Walther@60736
   258
    val ist_ctxt =  Ctree.get_loc pt (p, p_)
Walther@60736
   259
val Specify_Theory "Biegelinie" =
Walther@60736
   260
          (*case*) tac (*of*);
Walther@60736
   261
Walther@60736
   262
Step_Specify.by_tactic_input tac (pt, (p, p_'));
Walther@60736
   263
Walther@60736
   264
(*|------------------- contine me_Add_Relation_Randbedingungen -------------------------------*)
Walther@60736
   265
(*\------------------- step into me_Add_Relation_Randbedingungen ---------------------------//*)
Walther@60736
   266
(*[], Pbl*)val (p,_,f,nxt,_,pt) = return_me_Add_Relation_Randbedingungen;
Walther@60736
   267
                                                 val Specify_Theory "Biegelinie" = nxt
Walther@60736
   268
(*[], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p c pt; val Specify_Problem ["Biegelinien"] = nxt
Walther@60736
   269
(*[], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p c pt; val Specify_Method ["IntegrierenUndKonstanteBestimmen2"] = nxt
Walther@60736
   270
Walther@60736
   271
(*[], Met*)val return_me_Specify_Method_IntegrierenUndKonstanteBestimmen2
Walther@60736
   272
                                = me nxt p c pt; (*\<rightarrow>Add_Given "FunktionsVariable x"*)
Walther@60736
   273
(*/------------------- step into me_Specify_Method_IntegrierenUndKonstanteBestimmen2--------\*)
walther@60010
   274
walther@60010
   275
(*/------------------- initial check for whole me ------------------------------------------\*)
walther@60010
   276
(*+*)val Specify_Method ["IntegrierenUndKonstanteBestimmen2"] = nxt;
walther@60010
   277
walther@60010
   278
(*+*)val {origin = (o_model, o_refs, _), probl = i_pbl, meth = i_met, spec, ...} =
walther@60010
   279
  Calc.specify_data (pt, p);
walther@60010
   280
(*+*)if o_refs = ("Biegelinie", ["Biegelinien"], ["IntegrierenUndKonstanteBestimmen2"])
walther@60010
   281
(*+*)then () else error "initial o_refs CHANGED";
Walther@60655
   282
(*+*)if O_Model.to_string @{context} o_model = "[\n" ^
walther@60010
   283
  "(1, [\"1\"], #Given, Traegerlaenge, [\"L\"]), \n" ^
walther@60010
   284
  "(2, [\"1\"], #Given, Streckenlast, [\"q_0\"]), \n" ^
walther@60010
   285
  "(3, [\"1\"], #Find, Biegelinie, [\"y\"]), \n" ^
walther@60010
   286
  "(4, [\"1\"], #Relate, Randbedingungen, [\"[y 0 = 0]\", \"[y L = 0]\", \"[M_b 0 = 0]\", \"[M_b L = 0]\"]), \n" ^
walther@60010
   287
  "(5, [\"1\"], #undef, FunktionsVariable, [\"x\"]), \n" ^
Walther@60736
   288
  "(6, [\"1\"], #undef, AbleitungBiegelinie, [\"dy\"]), \n" ^
Walther@60736
   289
  "(7, [\"1\"], #undef, Biegemoment, [\"M_b\"]), \n" ^
Walther@60736
   290
  "(8, [\"1\"], #undef, Querkraft, [\"Q\"]), \n" ^
Walther@60736
   291
  "(9, [\"1\"], #undef, GleichungsVariablen, [\"[c]\", \"[c_2]\", \"[c_3]\", \"[c_4]\"])]"
walther@60010
   292
(*+*)then () else error "initial o_model CHANGED";
walther@60010
   293
(*+*)if I_Model.to_string @{context} i_pbl = "[\n" ^
Walther@60739
   294
  "(1 ,[1] ,true ,#Given ,Cor Traegerlaenge L , pen2str), \n" ^
Walther@60739
   295
  "(2 ,[1] ,true ,#Given ,Cor Streckenlast q_0 , pen2str), \n" ^
Walther@60739
   296
  "(3 ,[1] ,true ,#Find ,Cor Biegelinie y , pen2str), \n" ^
Walther@60739
   297
  "(4 ,[1] ,true ,#Relate ,Cor Randbedingungen [y 0 = 0, y L = 0, M_b 0 = 0, M_b L = 0] , pen2str)]"
walther@60010
   298
(*+*)then () else error "initial i_pbl CHANGED";
walther@60010
   299
(*+*)if I_Model.to_string @{context} i_met = "[]"
walther@60010
   300
(*+*)then () else error "initial i_met CHANGED";
walther@60010
   301
(*+*)val (_, ["Biegelinien"], _) = spec;
walther@60010
   302
(*\------------------- initial check for whole me ------------------------------------------/*)
walther@60010
   303
walther@60010
   304
"~ fun me , args:"; val (tac, p, _(*NEW remove*), pt) = (nxt, p, c, pt);
walther@60010
   305
(*/------------------- step into Step.by_tactic \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*)
walther@60010
   306
      val (pt'''''_', p'''''_') = case
walther@60010
   307
walther@60010
   308
      Step.by_tactic tac (pt, p) of ("ok", (_, _, ptp)) => ptp;
walther@60010
   309
(*/------------------- check for entry to Step.by_tactic -----------------------------------\*)
walther@60010
   310
(*+*)val Specify_Method ["IntegrierenUndKonstanteBestimmen2"] = tac;
walther@60010
   311
(*+*)val {origin = (o_model, _, _), ...} = Calc.specify_data (pt, p);
Walther@60655
   312
(*+*)if O_Model.to_string @{context} o_model = "[\n" ^
walther@60010
   313
  "(1, [\"1\"], #Given, Traegerlaenge, [\"L\"]), \n" ^
walther@60010
   314
  "(2, [\"1\"], #Given, Streckenlast, [\"q_0\"]), \n" ^
walther@60010
   315
  "(3, [\"1\"], #Find, Biegelinie, [\"y\"]), \n" ^
walther@60010
   316
  "(4, [\"1\"], #Relate, Randbedingungen, [\"[y 0 = 0]\", \"[y L = 0]\", \"[M_b 0 = 0]\", \"[M_b L = 0]\"]), \n" ^
walther@60010
   317
  "(5, [\"1\"], #undef, FunktionsVariable, [\"x\"]), \n" ^
Walther@60736
   318
  "(6, [\"1\"], #undef, AbleitungBiegelinie, [\"dy\"]), \n" ^
Walther@60736
   319
  "(7, [\"1\"], #undef, Biegemoment, [\"M_b\"]), \n" ^
Walther@60736
   320
  "(8, [\"1\"], #undef, Querkraft, [\"Q\"]), \n" ^
Walther@60736
   321
  "(9, [\"1\"], #undef, GleichungsVariablen, [\"[c]\", \"[c_2]\", \"[c_3]\", \"[c_4]\"])]"
walther@60010
   322
(*+*)then () else error "o_model AFTER Specify_Method NOTok CHANGED";
walther@60010
   323
(*\------------------- check for Step.by_tactic --------------------------------------------/*)
walther@60010
   324
"~~~~~ fun by_tactic , args:"; val (tac, (ptp as (pt, p))) = (tac, (pt, p));
walther@60010
   325
  val Applicable.Yes tac' = (*case*)
walther@60010
   326
walther@60010
   327
      Step.check tac (pt, p) (*of*);
walther@60010
   328
"~~~~~ fun check , args:"; val (tac, (ctree, pos)) = (tac, (pt, p));
walther@60010
   329
  (*if*) Tactic.for_specify tac (*then*);
walther@60010
   330
walther@60010
   331
Specify_Step.check tac (ctree, pos);
walther@60010
   332
"~~~~~ fun check , args:"; val ((Tactic.Specify_Method mID), (ctree, pos)) = (tac, (ctree, pos));
walther@60010
   333
walther@60010
   334
        val (o_model''''', _, i_model''''') =
walther@60014
   335
           Specify_Step.complete_for mID (ctree, pos);
walther@60014
   336
"~~~~~ fun complete_for , args:"; val (mID, (ctree, pos)) = (mID, (ctree, pos));
walther@60010
   337
    val {origin = (o_model, o_refs, _), spec = refs, probl = i_prob, ctxt,
walther@60010
   338
       ...} = Calc.specify_data (ctree, pos);
Walther@60494
   339
    val (dI, _, _) = References.select_input o_refs refs;
Walther@60586
   340
    val {model = m_patt, where_, where_rls, ...} = MethodC.from_store ctxt mID
walther@60010
   341
    val {origin = (root_model, _, _), ...} = Calc.specify_data (ctree, ([], Pos.Und))
walther@60010
   342
    val (o_model', ctxt') =
walther@60010
   343
walther@60010
   344
   O_Model.complete_for m_patt root_model (o_model, ctxt);
walther@60014
   345
(*/------------------- check entry to O_Model.complete_for -----------------------------------------\*)
Walther@60655
   346
(*+*)Model_Pattern.to_string @{context}  m_patt = "[\"" ^
walther@60010
   347
  "(#Given, (Traegerlaenge, l))\", \"" ^
walther@60010
   348
  "(#Given, (Streckenlast, q))\", \"" ^
walther@60010
   349
  "(#Given, (FunktionsVariable, v))\", \"" ^
walther@60010
   350
  "(#Given, (GleichungsVariablen, vs))\", \"" ^
walther@60010
   351
  "(#Given, (AbleitungBiegelinie, id_abl))\", \"" ^
walther@60010
   352
  "(#Find, (Biegelinie, b))\", \"" ^
walther@60010
   353
  "(#Relate, (Randbedingungen, s))\"]";
Walther@60736
   354
(*+*) O_Model.to_string @{context} root_model;
walther@60014
   355
(*\------------------- check entry to O_Model.complete_for -----------------------------------------/*)
walther@60010
   356
"~~~~~ fun complete_for , args:"; val (m_patt, root_model, (o_model, ctxt)) = (m_patt, root_model, (o_model, ctxt));
walther@60010
   357
    val  missing = m_patt |> filter_out
walther@60017
   358
      (fn (_, (descriptor, _)) => (member op = (map #4 o_model) descriptor));
walther@60010
   359
    val add = (root_model
walther@60010
   360
      |> filter
walther@60017
   361
        (fn (_, _, _, descriptor, _) => (member op = (map (fst o snd) missing)) descriptor))
walther@60010
   362
;
walther@60010
   363
    ((o_model @ add)
walther@60010
   364
      |> map (fn (a, b, _, descr, e) => (a, b, the (Model_Pattern.get_field descr m_patt), descr, e))
walther@60010
   365
      |> map (fn (_, b, c, d, e) => (b, c, d, e))      (* for correct enumeration *)
Walther@60472
   366
      |> add_enumerate                                        (* for correct enumeration *)
walther@60010
   367
      |> map (fn (a, (b, c, d, e)) => (a, b, c, d, e)), (* for correct enumeration *)
walther@60014
   368
    ctxt |> ContextC.add_constraints (add |> values |> TermC.vars')) (*return from O_Model.complete_for*);
walther@60014
   369
"~~~~~ fun complete_for \<longrightarrow>fun Specify_Step.complete_for , return:"; val (o_model', ctxt') =
walther@60010
   370
    ((o_model @ add)
walther@60010
   371
      |> map (fn (a, b, _, descr, e) => (a, b, the (Model_Pattern.get_field descr m_patt), descr, e))
walther@60010
   372
      |> map (fn (_, b, c, d, e) => (b, c, d, e))      (* for correct enumeration *)
Walther@60472
   373
      |> add_enumerate                                        (* for correct enumeration *)
walther@60010
   374
      |> map (fn (a, (b, c, d, e)) => (a, b, c, d, e)), (* for correct enumeration *)
walther@60010
   375
    ctxt |> ContextC.add_constraints (add |> values |> TermC.vars'));
walther@60010
   376
walther@60014
   377
(*/------------------- check of result from O_Model.complete_for -----------------------------------\*)
Walther@60736
   378
(*+*) O_Model.to_string @{context} o_model'; "O_Model.complete_for: result o_model CHANGED";
walther@60014
   379
(*\------------------- check of result from O_Model.complete_for -----------------------------------/*)
walther@60010
   380
Walther@60676
   381
    val thy = ThyC.get_theory @{context} dI
Walther@60590
   382
    val (_, (i_model, _)) = M_Match.match_itms_oris ctxt i_prob (m_patt, where_, where_rls) o_model';
walther@60010
   383
walther@60014
   384
  (o_model', ctxt', i_model) (*return from Specify_Step.complete_for*);
walther@60010
   385
walther@60014
   386
"~~~~~ fun complete_for \<longrightarrow>fun Specify_Step.check , return:"; val (o_model, _, i_model) =
walther@60010
   387
  (o_model', ctxt', i_model);
walther@60010
   388
walther@60010
   389
   Applicable.Yes (Tactic.Specify_Method' (mID, o_model, i_model)) (*return from Specify_Step.check*);
walther@60010
   390
"~~~~~ fun Specify_Step.check \<longrightarrow>fun Step.check \<longrightarrow>fun Step.by_tactic , return:"; val (Applicable.Yes tac') =
walther@60010
   391
  (Applicable.Yes (Tactic.Specify_Method' (mID, o_model, i_model)));
walther@60010
   392
	    (*if*) Tactic.for_specify' tac' (*then*);
walther@60010
   393
  val ("ok", ([], [], (_, _))) =
walther@60010
   394
walther@60010
   395
Step_Specify.by_tactic tac' ptp;
walther@60010
   396
"~~~~~ fun by_tactic , args:"; val ((Tactic.Specify_Method' (mID, _, _)), (pt,pos as (p, _))) =
walther@60010
   397
  (tac', ptp);
walther@60010
   398
(*NEW*) val {origin = (o_model, o_refs, _), spec = refs, probl = i_prob, ctxt,
walther@60010
   399
(*NEW*)    ...} = Calc.specify_data (pt, pos);
Walther@60494
   400
(*NEW*) val (dI, _, mID) = References.select_input o_refs refs;
Walther@60586
   401
(*NEW*) val {model = m_patt, where_, where_rls, ...} = MethodC.from_store ctxt mID
walther@60010
   402
(*NEW*) val {origin = (root_model, _, _), ...} = Calc.specify_data (pt, ([], Und))
walther@60010
   403
(*NEW*) val (o_model', ctxt') = O_Model.complete_for m_patt root_model (o_model, ctxt)
Walther@60676
   404
(*NEW*) val thy = ThyC.get_theory @{context} dI
Walther@60590
   405
(*NEW*) val (_, (i_model, _)) = M_Match.match_itms_oris ctxt i_prob (m_patt, where_, where_rls) o_model';
walther@60010
   406
(*NEW*) val (pos, _, _, pt) = Specify_Step.add (Tactic.Specify_Method' (mID, o_model', i_model))
walther@60010
   407
(*NEW*)   (Istate_Def.Uistate, ctxt') (pt, pos)
walther@60010
   408
walther@60010
   409
(*/------------------- check result of Step_Specify.by_tactic ------------------------------\*)
walther@60010
   410
(*+*)val {origin = (o_model, _, _), meth, ...} = Calc.specify_data (pt, pos);
Walther@60736
   411
(*+*)O_Model.to_string @{context} o_model;
walther@60010
   412
(*+*)if I_Model.to_string @{context} meth = "[\n" ^
Walther@60739
   413
  "(1 ,[1] ,true ,#Given ,Cor Traegerlaenge L , pen2str), \n" ^
Walther@60739
   414
  "(2 ,[1] ,true ,#Given ,Cor Streckenlast q_0 , pen2str), \n" ^
Walther@60739
   415
  "(3 ,[1] ,true ,#Find ,Cor Biegelinie y , pen2str), \n" ^
Walther@60739
   416
  "(4 ,[1] ,true ,#Relate ,Cor Randbedingungen [y 0 = 0, y L = 0, M_b 0 = 0, M_b L = 0] , pen2str), \n" ^
walther@60023
   417
  "(5 ,[1] ,false ,#Given ,Mis FunktionsVariable fun_var), \n" ^
Walther@60736
   418
  "(6 ,[1] ,false ,#Given ,Mis AbleitungBiegelinie id_der), \n" ^
Walther@60736
   419
  "(7 ,[1] ,false ,#Given ,Mis Biegemoment id_momentum), \n" ^
Walther@60736
   420
  "(8 ,[1] ,false ,#Given ,Mis Querkraft id_lat_force), \n" ^
Walther@60736
   421
  "(9 ,[1] ,false ,#Given ,Mis GleichungsVariablen vs)]"
walther@60010
   422
(*+*)then () else error "result of Step_Specify.by_tactic o_model CHANGED";
walther@60010
   423
(*\------------------- check result of Step_Specify.by_tactic ------------------------------/*)
walther@60010
   424
(*\------------------- step into Step.by_tactic /////////////////////////////////////////////*)
walther@60010
   425
walther@60010
   426
walther@60020
   427
val (_, ([(Add_Given "FunktionsVariable x", _, _)], _, _)) =
walther@60010
   428
   Step.do_next p'''''_' ((pt'''''_', Pos.e_pos'), []) (*of*);
walther@60010
   429
(*/------------------- step into Step.do_next \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*)
walther@60010
   430
"~~ fun do_next , args:"; val ((ip as (_, p_)), (ptp as (pt, p), tacis)) =
walther@60010
   431
  (p'''''_', ((pt'''''_', Pos.e_pos'), []));
walther@60010
   432
  (*if*) Pos.on_calc_end ip (*else*);
walther@60010
   433
     val (_, probl_id, _) = Calc.references (pt, p);
walther@60010
   434
     val _ = (*case*) tacis (*of*);
walther@60010
   435
       (*if*) probl_id = Problem.id_empty (*else*);
walther@60010
   436
walther@60020
   437
val (_, ([(Add_Given "FunktionsVariable x", _, _)], _, _)) =
walther@60010
   438
         switch_specify_solve p_ (pt, ip);
walther@60010
   439
"~~~ fun switch_specify_solve , args:"; val (state_pos, (pt, input_pos)) = (p_, (pt, ip));
walther@60010
   440
      (*if*) Pos.on_specification ([], state_pos) (*then*);
walther@60010
   441
walther@60020
   442
val ("ok", ([(Add_Given "FunktionsVariable x", _, _)], [], (pt'''''_'', p'''''_''))) =
Walther@60556
   443
      Step.specify_do_next (pt, input_pos);
walther@60010
   444
(*/------------------- check result of specify_do_next -------------------------------------\*)
walther@60010
   445
(*+*)val {origin = (ooo_mod, _, _), meth, ...} =  Calc.specify_data (pt'''''_'', p'''''_'');
Walther@60736
   446
(*+*) O_Model.to_string @{context} ooo_mod; "result of Step_Specify.by_tactic o_model CHANGED";
walther@60010
   447
(*+*)if I_Model.to_string @{context} meth = "[\n" ^
Walther@60739
   448
  "(1 ,[1] ,true ,#Given ,Cor Traegerlaenge L , pen2str), \n" ^
Walther@60739
   449
  "(2 ,[1] ,true ,#Given ,Cor Streckenlast q_0 , pen2str), \n" ^
Walther@60739
   450
  "(3 ,[1] ,true ,#Find ,Cor Biegelinie y , pen2str), \n" ^
Walther@60739
   451
  "(4 ,[1] ,true ,#Relate ,Cor Randbedingungen [y 0 = 0, y L = 0, M_b 0 = 0, M_b L = 0] , pen2str), \n" ^
Walther@60739
   452
  "(5 ,[1] ,true ,#Given ,Cor FunktionsVariable x , pen2str), \n" ^
Walther@60736
   453
  "(6 ,[1] ,false ,#Given ,Mis AbleitungBiegelinie id_der), \n" ^
Walther@60736
   454
  "(7 ,[1] ,false ,#Given ,Mis Biegemoment id_momentum), \n" ^
Walther@60736
   455
  "(8 ,[1] ,false ,#Given ,Mis Querkraft id_lat_force), \n" ^
Walther@60736
   456
  "(9 ,[1] ,false ,#Given ,Mis GleichungsVariablen vs)]"
walther@60010
   457
(*+*)then () else error "result of Step_Specify.by_tactic i_model CHANGED";
walther@60010
   458
(*\------------------- check result of specify_do_next -------------------------------------/*)
walther@60010
   459
"~~~~ fun specify_do_next , args:"; val (ptp as (pt, (p, p_))) = (pt, input_pos);
walther@60010
   460
walther@60010
   461
(**)val (_, (p_', Add_Given "FunktionsVariable x")) =(**)
walther@60010
   462
   Specify.find_next_step ptp;
Walther@60556
   463
"~~~~~ fun find_next_step , args:"; val (pt, pos as (_, p_)) = (ptp);
Walther@60556
   464
    val {meth = met, origin = origin as (oris, o_refs as (_, pI', mI'), _), probl = pbl,
Walther@60556
   465
      spec = refs, ...} = Calc.specify_data (pt, pos);
Walther@60556
   466
    val ctxt = Ctree.get_ctxt pt pos;
Walther@60556
   467
    (*if*) Ctree.just_created (pt, (p, p_)) andalso origin <> Ctree.e_origin (*else*);
Walther@60556
   468
      (*if*) p_ = Pos.Pbl (*else*);
Walther@60736
   469
Walther@60575
   470
val return = for_problem ctxt oris (o_refs, refs) (pbl, met);
Walther@60556
   471
"~~~~~ fun for_method , args:"; val (oris, ((dI', pI', mI'), (dI, pI, mI)), (pbl, met)) = 
Walther@60556
   472
  (oris, (o_refs, refs), (pbl, met));
Walther@60556
   473
    val cmI = if mI = MethodC.id_empty then mI' else mI;
Walther@60730
   474
    val {model = mpc, where_rls, where_, ...} = MethodC.from_store ctxt cmI;
Walther@60741
   475
    val (preok, _) = Pre_Conds.check ctxt where_rls where_ (mpc, I_Model.OLD_to_TEST met);
Walther@60556
   476
"~~~~~ from fun find_next_step \<longrightarrow>fun specify_do_next , return:"; val (_, (p_', tac)) = (return);
walther@60010
   477
(*/------------------- check within find_next_step -----------------------------------------\*)
Walther@60655
   478
(*+*)Model_Pattern.to_string @{context} (MethodC.from_store ctxt mI' |> #model) = "[\"" ^
walther@60010
   479
  "(#Given, (Traegerlaenge, l))\", \"" ^
walther@60010
   480
  "(#Given, (Streckenlast, q))\", \"" ^
walther@60010
   481
  "(#Given, (FunktionsVariable, v))\", \"" ^   (* <---------- take m_field from here !!!*)
walther@60010
   482
  "(#Given, (GleichungsVariablen, vs))\", \"" ^
walther@60010
   483
  "(#Given, (AbleitungBiegelinie, id_abl))\", \"" ^
walther@60010
   484
  "(#Find, (Biegelinie, b))\", \"" ^
walther@60010
   485
  "(#Relate, (Randbedingungen, s))\"]";
walther@60010
   486
(*\------------------- check within find_next_step -----------------------------------------/*)
walther@60010
   487
Walther@60676
   488
    (*case*) item_to_add (ThyC.get_theory @{context} (if dI = ThyC.id_empty then dI' else dI)) oris mpc met (*of*);
walther@60010
   489
"~~~~~ ~ fun item_to_add , args:"; val (thy, oris, _, itms) =
Walther@60676
   490
  ((ThyC.get_theory @{context} (if dI = ThyC.id_empty then dI' else dI)), oris, mpc, met);
walther@60017
   491
(*OLD*)fun testr_vt v ori = member op= (#2 (ori : O_Model.single)) v (**)andalso (#3 ori) <> "#undef"(**)
walther@60017
   492
      fun testi_vt v itm = member op= (#2 (itm : I_Model.single)) v
walther@60017
   493
      fun test_id ids r = member op= ids (#1 (r : O_Model.single))
walther@60010
   494
      fun test_subset itm (_, _, _, d, ts) = 
Walther@60477
   495
        (I_Model.descriptor (#5 (itm: I_Model.single))) = d andalso subset op = (I_Model.o_model_values (#5 itm), ts)
walther@60010
   496
      fun false_and_not_Sup (_, _, false, _, I_Model.Sup _) = false
walther@60010
   497
        | false_and_not_Sup (_, _, false, _, _) = true
walther@60010
   498
        | false_and_not_Sup _ = false
Walther@60705
   499
      val v = if itms = [] then 1 else Pre_Conds.max_variant itms
walther@60010
   500
      val vors = if v = 0 then oris else filter (testr_vt v) oris  (* oris..vat *)
walther@60010
   501
      val vits =
walther@60010
   502
        if v = 0
walther@60010
   503
        then itms                                 (* because of dsc without dat *)
walther@60010
   504
  	    else filter (testi_vt v) itms;                             (* itms..vat *)
walther@60010
   505
      val icl = filter false_and_not_Sup vits;                    (* incomplete *)
walther@60010
   506
walther@60010
   507
(*/------------------- check within item_to_add --------------------------------------------\*)
Walther@60736
   508
(*+*)if I_Model.to_string @{context} icl = "[\n" ^                 (*.. values, not formals*)
Walther@60736
   509
  "(5 ,[1] ,false ,#Given ,Mis FunktionsVariable fun_var), \n" ^   (*.. values, not formals*)
Walther@60736
   510
  "(6 ,[1] ,false ,#Given ,Mis AbleitungBiegelinie id_der), \n" ^  (*.. values, not formals*)
Walther@60736
   511
  "(7 ,[1] ,false ,#Given ,Mis Biegemoment id_momentum), \n" ^     (*.. values, not formals*)
Walther@60736
   512
  "(8 ,[1] ,false ,#Given ,Mis Querkraft id_lat_force), \n" ^      (*.. values, not formals*)
Walther@60736
   513
  "(9 ,[1] ,false ,#Given ,Mis GleichungsVariablen vs)]"
walther@60010
   514
(*+*)then () else error "icl within item_to_add CHANGED";
Walther@60736
   515
(*+*) O_Model.to_string @{context} vors; "vors within item_to_add CHANGED";
walther@60010
   516
(*+*)if I_Model.to_string @{context} itms = "[\n" ^
Walther@60739
   517
  "(1 ,[1] ,true ,#Given ,Cor Traegerlaenge L , pen2str), \n" ^
Walther@60739
   518
  "(2 ,[1] ,true ,#Given ,Cor Streckenlast q_0 , pen2str), \n" ^
Walther@60739
   519
  "(3 ,[1] ,true ,#Find ,Cor Biegelinie y , pen2str), \n" ^
Walther@60739
   520
  "(4 ,[1] ,true ,#Relate ,Cor Randbedingungen [y 0 = 0, y L = 0, M_b 0 = 0, M_b L = 0] , pen2str), \n" ^
Walther@60736
   521
  "(5 ,[1] ,false ,#Given ,Mis FunktionsVariable fun_var), \n" ^
Walther@60736
   522
  "(6 ,[1] ,false ,#Given ,Mis AbleitungBiegelinie id_der), \n" ^
Walther@60736
   523
  "(7 ,[1] ,false ,#Given ,Mis Biegemoment id_momentum), \n" ^
Walther@60736
   524
  "(8 ,[1] ,false ,#Given ,Mis Querkraft id_lat_force), \n" ^
Walther@60736
   525
  "(9 ,[1] ,false ,#Given ,Mis GleichungsVariablen vs)]"
walther@60010
   526
(*+*)then () else error "i_model  within item_to_add CHANGED";
walther@60010
   527
(*\------------------- check within item_to_add --------------------------------------------/*)
walther@60010
   528
walther@60010
   529
      (*if*) icl = [] (*else*);
walther@60010
   530
        val SOME ori =(*case*) find_first (test_subset (hd icl)) vors (*of*);
walther@60010
   531
walther@60336
   532
(*+*)val (5, [1], "#Given", Const (\<^const_name>\<open>FunktionsVariable\<close>, _), [Free ("x", _)]) = ori
walther@60010
   533
(*+*)val SOME ("#Given", "FunktionsVariable x") =
walther@60010
   534
walther@60010
   535
        SOME
Walther@60477
   536
     (I_Model.get_field_term thy ori (hd icl)) (*return from item_to_add*);
Walther@60477
   537
"~~~~~ ~~ fun get_field_term , args:"; val (thy, (_, _, _, d, ts), (_, _, _, fd, itm_)) = (thy, ori, (hd icl));
walther@60010
   538
walther@60010
   539
val rrrrr =
walther@60010
   540
  (fd, ((UnparseC.term_in_thy thy) o Input_Descript.join)
Walther@60477
   541
    (d, subtract op = (o_model_values itm_) ts)) (*return from get_field_term*);
Walther@60477
   542
"~~~~~ ~~ from fun get_field_term \<longrightarrow>fun item_to_add \<longrightarrow>fun find_next_step , return:"; val (SOME (fd, ct')) =
walther@60010
   543
    (SOME rrrrr);
walther@60010
   544
  ("dummy", (Pos.Met, P_Model.mk_additem fd ct')) (*return from find_next_step*);
walther@60010
   545
walther@60010
   546
(*+*)val Add_Given "FunktionsVariable x" = P_Model.mk_additem fd ct';
walther@60010
   547
walther@60010
   548
"~~~~~ from fun find_next_step \<longrightarrow>fun specify_do_next , return:"; val (_, (p_', tac)) =
walther@60010
   549
  ("dummy", (Pos.Met, P_Model.mk_additem fd ct'));
walther@60010
   550
    val ist_ctxt =  Ctree.get_loc pt (p, p_)
walther@60010
   551
    val _ = (*case*) tac (*of*);
walther@60010
   552
walther@60010
   553
      ("dummy",
walther@60010
   554
Step_Specify.by_tactic_input tac (pt, (p, p_'))) (*return from specify_do_next*);
walther@60010
   555
"~~~~~ fun by_tactic_input , args:"; val ((Tactic.Add_Given ct), ptp) =
walther@60010
   556
  (tac, (pt, (p, p_')));
walther@60010
   557
walther@60021
   558
  val ("ok", ([(Add_Given "FunktionsVariable x", _, _)], _, _)) =
walther@60021
   559
     Specify.by_Add_ "#Given" ct ptp (*return from by_tactic_input*);
walther@60021
   560
"~~~~~ ~ fun by_Add_ , args:"; val (m_field, ct, (pt, pos as (_, p_))) = ("#Given", ct, ptp);
walther@60097
   561
    val (met, oris, (_, pI', mI'), pbl, (_, pI, mI), ctxt) = SpecificationC.get_data (pt, pos);
walther@60021
   562
       (*if*) p_ = Pos.Met (*then*);
walther@60021
   563
    val (i_model, m_patt) = (met,
Walther@60586
   564
           (if mI = MethodC.id_empty then mI' else mI) |> MethodC.from_store ctxt |> #model)
walther@60010
   565
walther@60336
   566
val Add (5, [1], true, "#Given", Cor ((Const (\<^const_name>\<open>FunktionsVariable\<close>, _), [Free ("x", _)]), (Free ("fun_var", _), [Free ("x", _)]))) =
walther@60010
   567
      (*case*)
walther@60021
   568
   I_Model.check_single ctxt m_field oris i_model m_patt ct (*of*);
walther@60010
   569
"~~~~~ ~~ fun check_single , args:"; val (ctxt, m_field, o_model, i_model, m_patt, str) =
walther@60021
   570
  (ctxt, m_field, oris, i_model, m_patt, ct);
Walther@60663
   571
(*.NEW*)      val SOME (t as (descriptor $ _)) = (*case*) ParseC.term_opt ctxt str (*of*);
walther@60010
   572
(*.NEW*)   val SOME m_field = (*case*) Model_Pattern.get_field descriptor m_patt (*of*);
walther@60010
   573
walther@60336
   574
val ("", (5, [1], "#Given", Const (\<^const_name>\<open>FunktionsVariable\<close>, _), [Free ("x", _)]), [Free ("x", _)]) =
walther@60010
   575
          (*case*)
Walther@60471
   576
       O_Model.contains ctxt m_field o_model t (*of*);
Walther@60471
   577
"~~~~~ ~~~ fun contains , args:"; val (ctxt, sel, ori, t) = (ctxt, m_field, o_model, t);
walther@60017
   578
    val ots = ((distinct op =) o flat o (map #5)) ori
walther@60017
   579
    val oids = ((map (fst o dest_Free)) o (distinct op =) o flat o (map TermC.vars)) ots
walther@60010
   580
    val (d, ts) = Input_Descript.split t
walther@60017
   581
    val ids = map (fst o dest_Free) (((distinct op =) o (flat o (map TermC.vars))) ts);
walther@60010
   582
    (*if*) (subtract op = oids ids) <> [] (*else*);
walther@60010
   583
	    (*if*) d = TermC.empty (*else*);
walther@60017
   584
	      (*if*) member op = (map #4 ori) d (*then*);
walther@60010
   585
Walther@60471
   586
                associate_input ctxt sel (d, ts) ori;
Walther@60471
   587
"~~~~~ ~~~~ fun associate_input , args:"; val (ctxt, m_field, (descript, vals), ((id, vat, m_field', descript', vals') :: oris)) =
walther@60010
   588
  (ctxt, sel, (d, ts), ori);
walther@60010
   589
Walther@60469
   590
(*/------------------- check within associate_input ------------------------------------------\*)
walther@60010
   591
(*+*)val Add_Given "FunktionsVariable x" = tac;
walther@60010
   592
(*+*)m_field = "#Given";
walther@60336
   593
(*+*)val Const (\<^const_name>\<open>FunktionsVariable\<close>, _) = descript;
walther@60010
   594
(*+*)val [Free ("x", _)] = vals;
Walther@60655
   595
(*+*)O_Model.to_string @{context} ori = "[\n" ^
walther@60010
   596
  "(1, [\"1\"], #Given, Traegerlaenge, [\"L\"]), \n" ^
walther@60010
   597
  "(2, [\"1\"], #Given, Streckenlast, [\"q_0\"]), \n" ^
walther@60010
   598
  "(3, [\"1\"], #Find, Biegelinie, [\"y\"]), \n" ^
walther@60010
   599
  "(4, [\"1\"], #Relate, Randbedingungen, [\"[y 0 = 0]\", \"[y L = 0]\", \"[M_b 0 = 0]\", \"[M_b L = 0]\"]), \n" ^
walther@60010
   600
  "(5, [\"1\"], #undef, FunktionsVariable, [\"x\"]), \n" ^
walther@60010
   601
  "(6, [\"1\"], #undef, GleichungsVariablen, [\"[c]\", \"[c_2]\", \"[c_3]\", \"[c_4]\"]), \n" ^
walther@60010
   602
  "(7, [\"1\"], #undef, AbleitungBiegelinie, [\"dy\"])]";
walther@60010
   603
(*+*)val (id, vat, m_field', descript', vals') = nth 5 ori
walther@60336
   604
(*+*)val (5, [1], "#Given", Const (\<^const_name>\<open>FunktionsVariable\<close>, _), [Free ("x", _)]) =
walther@60010
   605
  (id, vat, m_field', descript', vals')
Walther@60469
   606
(*\------------------- check within associate_input ----------------------------------------/*)
Walther@60736
   607
(*\------------------- step into me_Specify_Method_IntegrierenUndKonstanteBestimmen2--------*)
Walther@60736
   608
(*[], Met*)val (p,_,f,nxt,_,pt) = return_me_Specify_Method_IntegrierenUndKonstanteBestimmen2
Walther@60736
   609
                                                 val Add_Given "FunktionsVariable x" =  nxt;
walther@60010
   610
Walther@60736
   611
(*[], Met*)val (p,_,f,nxt,_,pt) = me nxt p c pt; val Add_Given "AbleitungBiegelinie dy" = nxt
Walther@60736
   612
(*[], Met*)val (p,_,f,nxt,_,pt) = me nxt p c pt; val Add_Given "Biegemoment M_b" = nxt
Walther@60736
   613
(*[], Met*)val (p,_,f,nxt,_,pt) = me nxt p c pt; val Add_Given "Querkraft Q" = nxt
Walther@60736
   614
(*[], Met*)val (p,_,f,nxt,_,pt) = me nxt p c pt; val Add_Given "GleichungsVariablen [c, c_2, c_3, c_4]" = nxt
Walther@60736
   615
(*[], Met*)val (p,_,f,nxt,_,pt) = me nxt p c pt; val Apply_Method ["IntegrierenUndKonstanteBestimmen2"] = nxt
walther@60010
   616
Walther@60736
   617
(*[1], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p c pt; val Model_Problem = nxt
walther@60010
   618
(*/------------------- check entry to me Model_Problem -------------------------------------\*)
walther@60010
   619
(*+*)val ([1], Pbl) = p;
walther@60010
   620
(*+*)val (o_model, ("Biegelinie", ["vonBelastungZu", "Biegelinien"], ["Biegelinien", "ausBelastung"]), _) =
walther@60010
   621
  get_obj g_origin pt (fst p);
Walther@60655
   622
(*+*)if O_Model.to_string @{context} o_model = "[\n" ^
walther@60010
   623
  "(1, [\"1\"], #Given, Streckenlast, [\"q_0\"]), \n" ^
walther@60010
   624
  "(2, [\"1\"], #Given, FunktionsVariable, [\"x\"]), \n" ^
walther@60010
   625
  "(3, [\"1\"], #Find, Funktionen, [\"funs'''\"])]"
walther@60010
   626
(*
walther@60154
   627
.. here the O_Model does NOT know, which MethodC will be chosen,
Walther@60710
   628
so "belastung_zu_biegelinie q__q v_v b_b id_abl" is NOT known,
Walther@60710
   629
"b_b" and "id_abl" are NOT missing.
walther@60010
   630
*)
walther@60010
   631
then () else error "[Biegelinien, ausBelastung] initial O_Model CHANGED";
walther@60010
   632
(*\------------------- check entry to me Model_Problem -------------------------------------/*)
walther@60010
   633
walther@60010
   634
(*[1], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p c pt; (*\<rightarrow>Add_Given "Streckenlast q_0"*)
walther@60010
   635
(*[1], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p c pt; (*\<rightarrow>Add_Given "FunktionsVariable x"*)
walther@60010
   636
(*[1], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p c pt; (*\<rightarrow>Add_Find "Funktionen funs'''":*)
walther@60010
   637
(*[1], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p c pt; (*\<rightarrow>Specify_Theory "Biegelinie"*)
walther@60010
   638
(*[1], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p c pt; (*\<rightarrow>Specify_Problem ["vonBelastungZu", "Biegelinien"]*)
walther@60010
   639
(*[1], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p c pt; (*\<rightarrow>Specify_Method ["Biegelinien", "ausBelastung"]*)
walther@60010
   640
Walther@60736
   641
(*[1], Met*)val return_me_Specify_Method_ausBelastung = me nxt p c pt; (*\<rightarrow>Add_Given "Biegelinie y"*)
Walther@60736
   642
(*//------------------ step into me_Specify_Method_ausBelastung ----------------------------\\*)
walther@60010
   643
(*+*)val Specify_Method ["Biegelinien", "ausBelastung"] = nxt;
Walther@60710
   644
(*+*)(* by \<up> \<up> \<up> \<up>   "b_b" and "id_abl" must be requested: PUT THEM INTO O_Model*)
walther@60010
   645
walther@60010
   646
"~ fun me , args:"; val (tac, p, _(*NEW remove*), pt) = (nxt, p, c, pt);
walther@60010
   647
walther@60010
   648
  val ("ok", ([], [], (_, _))) = (*case*)
walther@60010
   649
      Step.by_tactic tac (pt, p) (*of*);
walther@60010
   650
"~~ fun by_tactic , args:"; val (tac, (ptp as (pt, p))) = (tac, (pt, p));
walther@60010
   651
  val Applicable.Yes tac' = (*case*) check tac (pt, p) (*of*);
walther@60010
   652
	    (*if*) Tactic.for_specify' tac' (*then*);
walther@60010
   653
walther@60010
   654
  val ("ok", ([], [], (_, _))) =
walther@60010
   655
Step_Specify.by_tactic tac' ptp;
walther@60010
   656
(*/------------------- initial check for Step_Specify.by_tactic ----------------------------\*)
walther@60010
   657
(*+*)val (o_model, ("Biegelinie", ["vonBelastungZu", "Biegelinien"], ["Biegelinien", "ausBelastung"]), _) =
walther@60010
   658
  get_obj g_origin pt (fst p);
Walther@60655
   659
(*+*)if O_Model.to_string @{context} o_model = "[\n" ^                                         
walther@60010
   660
  "(1, [\"1\"], #Given, Streckenlast, [\"q_0\"]), \n" ^
walther@60010
   661
  "(2, [\"1\"], #Given, FunktionsVariable, [\"x\"]), \n" ^
walther@60010
   662
  "(3, [\"1\"], #Find, Funktionen, [\"funs'''\"])]"
walther@60010
   663
(*
walther@60154
   664
.. here the MethodC has been determined by the user,
Walther@60710
   665
so "belastung_zu_biegelinie q__q v_v b_b id_abl" IS KNOWN and,
Walther@60710
   666
"b_b" and "id_abl" WOULD BE missing (added by O_Model.).
walther@60010
   667
*)
walther@60154
   668
then () else error "[Biegelinien, ausBelastung] O_Model NOT EXTENDED BY MethodC";
walther@60010
   669
(*\------------------- initial check for Step_Specify.by_tactic ----------------------------/*)
walther@60010
   670
"~~~ fun by_tactic , args:"; val ((Tactic.Specify_Method' (mID, _, _)), (pt, pos as (p, _))) =
walther@60010
   671
  (tac', ptp);
walther@60010
   672
(*.NEW*) val {origin = (o_model, o_refs, _), spec = refs, probl = i_prob, meth = i_meth, ctxt,
walther@60010
   673
(*.NEW*)    ...} =Calc.specify_data (pt, pos);
Walther@60494
   674
(*.NEW*) val (dI, _, mID) = References.select_input o_refs refs;
Walther@60586
   675
(*.NEW*) val {model = m_patt, where_, where_rls, ...} = MethodC.from_store ctxt mID
walther@60010
   676
(*.NEW*) val {origin = (root_model, _, _), ...} = Calc.specify_data (pt, ([], Und))
walther@60010
   677
(*.NEW*) val (o_model', ctxt') = O_Model.complete_for m_patt root_model (o_model, ctxt);
walther@60010
   678
walther@60010
   679
(*/------------------- check for entry to O_Model.complete_for -----------------------------\*)
walther@60010
   680
(*+*)if mID = ["Biegelinien", "ausBelastung"]
walther@60154
   681
(*+*)then () else error "MethodC [Biegelinien, ausBelastung] CHANGED";
Walther@60655
   682
(*+*)if Model_Pattern.to_string @{context} m_patt = "[\"" ^
walther@60010
   683
  "(#Given, (Streckenlast, q__q))\", \"" ^
walther@60010
   684
  "(#Given, (FunktionsVariable, v_v))\", \"" ^
Walther@60736
   685
  "(#Given, (Biegelinie, b_b))\", \"" ^
Walther@60736
   686
  "(#Given, (AbleitungBiegelinie, id_der))\", \"" ^
Walther@60736
   687
  "(#Given, (Biegemoment, id_momentum))\", \"" ^
Walther@60736
   688
  "(#Given, (Querkraft, id_lat_force))\", \"" ^
walther@60010
   689
  "(#Find, (Funktionen, fun_s))\"]"
walther@60010
   690
(*+*)then () else error "[Biegelinien, ausBelastung] Model_Pattern CHANGED";
Walther@60655
   691
(*+*)if O_Model.to_string @{context} o_model = "[\n" ^
walther@60010
   692
  "(1, [\"1\"], #Given, Streckenlast, [\"q_0\"]), \n" ^
walther@60010
   693
  "(2, [\"1\"], #Given, FunktionsVariable, [\"x\"]), \n" ^
walther@60010
   694
  "(3, [\"1\"], #Find, Funktionen, [\"funs'''\"])]" 
walther@60154
   695
(*+*)then () else error "[Biegelinien, ausBelastung] O_Model NOT EXTENDED BY MethodC CHANGED";
Walther@60736
   696
(*+*) O_Model.to_string @{context} root_model;
Walther@60736
   697
(*+*) O_Model.to_string @{context} o_model';
Walther@60736
   698
  "[Biegelinien, ausBelastung] O_Model EXTENDED BY MethodC CHANGED";
walther@60010
   699
(*\------------------- check for entry to O_Model.complete_for -----------------------------/*)
walther@60010
   700
walther@60010
   701
  O_Model.complete_for m_patt root_model (o_model, ctxt);
walther@60010
   702
"~~~~ fun complete_for , args:"; val (m_patt, root_model, (o_model, ctxt)) =
walther@60010
   703
  (m_patt, root_model, (o_model, ctxt));
walther@60010
   704
    val  missing = m_patt |> filter_out
walther@60017
   705
      (fn (_, (descriptor, _)) => (member op = (map #4 o_model) descriptor))
walther@60010
   706
;
walther@60010
   707
    val add = root_model
walther@60010
   708
      |> filter
walther@60017
   709
        (fn (_, _, _, descriptor, _) => (member op = (map (fst o snd) missing)) descriptor)
walther@60010
   710
;
walther@60010
   711
    (o_model @ add
walther@60010
   712
(*NEW*)|> map (fn (a, b, _, descr, e) => (a, b, the (Model_Pattern.get_field descr m_patt), descr, e))
walther@60010
   713
(*NEW*)
walther@60010
   714
      |> map (fn (_, b, c, d, e) => (b, c, d, e))     
Walther@60472
   715
      |> add_enumerate                                       
walther@60010
   716
      |> map (fn (a, (b, c, d, e)) => (a, b, c, d, e)),
walther@60014
   717
    ctxt |> ContextC.add_constraints (add |> O_Model.values |> TermC.vars')) (*return from O_Model.complete_for*);
walther@60014
   718
"~~~~ from fun O_Model.complete_for \<longrightarrow>Step_Specify.by_tactic , return:"; val (o_model', ctxt') =
walther@60010
   719
  ((o_model @ add)
walther@60010
   720
(*NEW*)|> map (fn (a, b, _, descr, e) => (a, b, the (Model_Pattern.get_field descr m_patt), descr, e))
walther@60010
   721
(*NEW*)
walther@60010
   722
      |> map (fn (_, b, c, d, e) => (b, c, d, e))     
Walther@60472
   723
      |> add_enumerate                                       
walther@60010
   724
      |> map (fn (a, (b, c, d, e)) => (a, b, c, d, e)),
walther@60010
   725
    ctxt |> ContextC.add_constraints (add |> O_Model.values |> TermC.vars'));
walther@60010
   726
walther@60014
   727
(*/------------------- check within O_Model.complete_for -------------------------------------------\*)
Walther@60736
   728
(*+*) O_Model.to_string @{context} o_model';
Walther@60736
   729
  "[Biegelinien, ausBelastung] O_Model EXTENDED BY MethodC CHANGED";
walther@60014
   730
(*\------------------- check within O_Model.complete_for -------------------------------------------/*)
walther@60010
   731
Walther@60676
   732
(*.NEW*) val thy = ThyC.get_theory @{context} dI
Walther@60590
   733
(*.NEW*) val (_, (i_model, _)) = M_Match.match_itms_oris ctxt i_prob (m_patt, where_, where_rls) o_model';
walther@60010
   734
(*.NEW*) val (pos, _, _, pt) = Specify_Step.add (Tactic.Specify_Method' (mID, o_model', i_model))
walther@60010
   735
(*.NEW*)   (Istate_Def.Uistate, ctxt') (pt, pos)
walther@60010
   736
;
Walther@60736
   737
(*+*) I_Model.to_string @{context} i_model; "[Biegelinien, ausBelastung] I_Model CHANGED 1";
walther@60010
   738
(*+*)val {origin = (o_model, o_refs, _), spec = refs, probl = i_prob, meth = i_meth, ctxt, ...} =
walther@60010
   739
(*+*)  Calc.specify_data (pt, pos);
walther@60010
   740
(*+*)pos = ([1], Met);
walther@60010
   741
walther@60010
   742
         ("ok", ([], [], (pt, pos)))  (*return from Step_Specify.by_tactic*);
walther@60010
   743
"~~~ from Step_Specify.by_tactic \<longrightarrow>Step.by_tactic \<longrightarrow>fun me , return:"; val ("ok", (_, _, (pt, p))) =
walther@60010
   744
         ("ok", ([], [], (pt, pos)));
walther@60010
   745
(*  val ("helpless", ([(xxxxx, _, _)], _, _)) =  (*case*)*)
walther@60242
   746
  (*  SHOULD BE    \<up> \<up> \<up> \<up> \<up> \<up> \<up> \<up> \<up> Add_Given "Biegelinie y" | Add_Given "AbleitungBiegelinie dy"*)
walther@60010
   747
walther@60020
   748
val ("ok", ([( Add_Given "Biegelinie y", _, _)], [], _)) =
walther@60010
   749
   Step.do_next p ((pt, Pos.e_pos'), []) (*of*);
walther@60010
   750
"~~ fun do_next , args:"; val ((ip as (_, p_)), (ptp as (pt, p), tacis)) = (p, ((pt, Pos.e_pos'), []));
walther@60010
   751
(*.NEW*)(*if*) on_calc_end ip (*else*);
walther@60010
   752
(*.NEW*)    val (_, probl_id, _) = Calc.references (pt, p);
walther@60010
   753
(*-"-*)    val _ = (*case*)  tacis (*of*);
walther@60010
   754
(*.NEW*)      (*if*) probl_id = Problem.id_empty (*else*);
walther@60010
   755
walther@60020
   756
(*.NEW*)val ("ok", ([(Add_Given "Biegelinie y", _, _)], _, _)) =
walther@60010
   757
         switch_specify_solve p_ (pt, ip);
walther@60010
   758
"~~~ fun switch_specify_solve , args:"; val (state_pos, (pt, input_pos)) = (p_, (pt, ip));
walther@60010
   759
      (*if*) Pos.on_specification ([], state_pos) (*then*);
walther@60010
   760
walther@60020
   761
  val ("ok", ([(Add_Given "Biegelinie y", _, _)], _, _)) =
Walther@60556
   762
          specify_do_next (pt, input_pos);
walther@60010
   763
"~~~~ fun specify_do_next , args:"; val (ptp as (pt, (p, p_))) = (pt, input_pos);
walther@60010
   764
walther@60010
   765
    val (_, (p_', tac)) =
walther@60010
   766
   Specify.find_next_step ptp;
Walther@60556
   767
"~~~~~ fun find_next_step , args:"; val (pt, pos as (_, p_)) = (ptp);
Walther@60556
   768
    val {meth = met, origin = origin as (oris, o_refs as (_, pI', mI'), _), probl = pbl,
Walther@60556
   769
      spec = refs, ...} = Calc.specify_data (pt, pos);
Walther@60556
   770
    val ctxt = Ctree.get_ctxt pt pos
walther@60010
   771
;
Walther@60655
   772
(*+*)O_Model.to_string @{context} oris = "[\n" ^
walther@60010
   773
  "(1, [\"1\"], #Given, Streckenlast, [\"q_0\"]), \n" ^
walther@60010
   774
  "(2, [\"1\"], #Given, FunktionsVariable, [\"x\"]), \n" ^
walther@60010
   775
  "(3, [\"1\"], #Find, Funktionen, [\"funs'''\"]), \n" ^
walther@60010
   776
  "(4, [\"1\"], #Find, Biegelinie, [\"y\"]), \n" ^
walther@60010
   777
  "(5, [\"1\"], #Given, AbleitungBiegelinie, [\"dy\"])]";
Walther@60756
   778
(*+*)val (true, []) = Pre_Conds.check_internal ctxt (I_Model.OLD_to_TEST pbl) (Pos.Met, mI');
walther@60010
   779
(*+*)I_Model.to_string @{context} met = "[\n" ^
walther@60010
   780
  "(1 ,[1] ,true ,#Given ,Cor Streckenlast q_0 ,(q_q, [q_0])), \n" ^
walther@60010
   781
  "(2 ,[1] ,true ,#Given ,Cor FunktionsVariable x ,(v_v, [x])), \n" ^
walther@60010
   782
  "(3 ,[1] ,true ,#Find ,Cor Funktionen funs''' ,(funs''', [funs'''])), \n" ^
Walther@60710
   783
  "(4 ,[1] ,false ,#Given ,Mis Biegelinie b_b), \n" ^
walther@60010
   784
  "(5 ,[1] ,false ,#Given ,Mis AbleitungBiegelinie id_abl)]";
walther@60010
   785
Walther@60556
   786
    (*if*) Ctree.just_created (pt, pos) andalso origin <> Ctree.e_origin (*else*);
Walther@60556
   787
      (*if*) p_ = Pos.Pbl (*else*);
Walther@60575
   788
val return = for_method ctxt oris (o_refs, refs) (pbl, met);
Walther@60556
   789
"~~~~~ from fun find_next_step \<longrightarrow>fun specify_do_next , return:"; val (_, (p_', tac)) = (return);
walther@60010
   790
Walther@60556
   791
    val ist_ctxt =  Ctree.get_loc pt (p, p_)
Walther@60556
   792
    val Add_Given "Biegelinie y" = (*case*) tac (*of*);
Walther@60556
   793
val return = Step_Specify.by_tactic_input tac (pt, (p, p_'));
walther@60010
   794
(*+*)val Add_Given "Biegelinie y" = tac;
walther@60010
   795
    val ist_ctxt =  Ctree.get_loc pt (p, p_)
walther@60010
   796
    val _ = (*case*) tac (*of*); 
walther@60010
   797
walther@60020
   798
  val (_, ([(Add_Given "Biegelinie y", _, _)], _, (p'''''_'', ([1], Met)))) =
walther@60010
   799
Step_Specify.by_tactic_input tac (pt, (p, p_'))
walther@60010
   800
(*/------------------- check result of Step_Specify.by_tactic_input ------------------------\*)
walther@60010
   801
(*+*)val {meth, ...} = Calc.specify_data (p'''''_'', ([1], Met));
walther@60010
   802
(*+*)I_Model.to_string @{context} meth = "[\n" ^ (* result does NOT show Add_Given "Biegelinie y" *)
walther@60010
   803
  "(1 ,[1] ,true ,#Given ,Cor Streckenlast q_0 ,(q_q, [q_0])), \n" ^
walther@60010
   804
  "(2 ,[1] ,true ,#Given ,Cor FunktionsVariable x ,(v_v, [x])), \n" ^
walther@60010
   805
  "(3 ,[1] ,true ,#Find ,Cor Funktionen funs''' ,(funs''', [funs'''])), \n" ^
Walther@60710
   806
  "(4 ,[1] ,false ,#Given ,Mis Biegelinie b_b), \n" ^
walther@60010
   807
  "(5 ,[1] ,false ,#Given ,Mis AbleitungBiegelinie id_abl)]";
walther@60010
   808
(*\------------------- check result of Step_Specify.by_tactic_input ------------------------/*)
walther@60010
   809
"~~~~ fun by_tactic_input , args:"; val ((Tactic.Add_Given ct), ptp) =   (tac, (pt, (p, p_')));
walther@60010
   810
walther@60021
   811
   Specify.by_Add_ "#Given" ct ptp;
walther@60021
   812
"~~~~~ fun by_Add_ , args:"; val (m_field, ct, (pt, pos as (_, p_))) = ("#Given", ct, ptp);
walther@60097
   813
    val (met, oris, (_, pI', mI'), pbl, (_, pI, mI), ctxt) = SpecificationC.get_data (pt, pos);
walther@60021
   814
       (*if*) p_ = Pos.Met (*then*);
walther@60021
   815
    val (i_model, m_patt) = (met,
Walther@60586
   816
           (if mI = MethodC.id_empty then mI' else mI) |> MethodC.from_store ctxt |> #model)
walther@60010
   817
Walther@60710
   818
val Add (4, [1], true, "#Given", Cor ((Const (\<^const_name>\<open>Biegelinie\<close>, _), [Free ("y", _)]), (Free ("b_b", _), [Free ("y", _)]))) =
walther@60010
   819
      (*case*)
walther@60021
   820
   check_single ctxt m_field oris i_model m_patt ct (*of*);
walther@60010
   821
walther@60010
   822
(*/------------------- check for entry to check_single -------------------------------------\*)
Walther@60736
   823
(*+*) O_Model.to_string @{context} oris; "[Biegelinien, ausBelastung] O_Model CHANGED for entry";
Walther@60736
   824
(*+*) I_Model.to_string ctxt met; "[Biegelinien, ausBelastung] I_Model CHANGED for entry";
walther@60010
   825
(*\------------------- check for entry to check_single -------------------------------------/*)
walther@60010
   826
walther@60010
   827
"~~~~~ ~ fun check_single , args:"; val (ctxt, m_field, o_model, i_model, m_patt, str) =
Walther@60586
   828
  (ctxt, sel, oris, met, ((#model o MethodC.from_store ctxt) cmI), ct);
Walther@60663
   829
      val SOME t = (*case*) ParseC.term_opt ctxt str (*of*);
walther@60010
   830
walther@60336
   831
(*+*)val Const (\<^const_name>\<open>Biegelinie\<close>, _) $ Free ("y", _) = t;
walther@60010
   832
Walther@60471
   833
(*("associate_input: input ('Biegelinie y') not found in oris (typed)", (0, [], "#Given", Const (\<^const_name>\<open>Biegelinie\<close>, "(real \<Rightarrow> real) \<Rightarrow> una"), [Free ("y", "real \<Rightarrow> real")]), [])*)
walther@60010
   834
          (*case*)
Walther@60471
   835
   contains ctxt m_field o_model t (*of*);
Walther@60471
   836
"~~~~~ ~~ fun contains , args:"; val (ctxt, sel, ori, t) = (ctxt, m_field, o_model, t);
walther@60017
   837
    val ots = ((distinct op =) o flat o (map #5)) ori
walther@60017
   838
    val oids = ((map (fst o dest_Free)) o (distinct op =) o flat o (map TermC.vars)) ots
walther@60010
   839
    val (d, ts) = Input_Descript.split t
walther@60017
   840
    val ids = map (fst o dest_Free) (((distinct op =) o (flat o (map TermC.vars))) ts);
walther@60010
   841
    (*if*) (subtract op = oids ids) <> [] (*else*);
walther@60010
   842
	    (*if*) d = TermC.empty (*else*);
Walther@60471
   843
	      (*if*) not (subset op = (map make_typeless ts, map make_typeless ots)) (*else*);
walther@60010
   844
Walther@60471
   845
  (*case*) O_Model.associate_input' ctxt sel ts ori (*of*);
Walther@60471
   846
"~~~~~ ~~~ fun associate_input' , args:"; val (ctxt, sel, ts, ((id, vat, sel', d, ts') :: oris)) = (ctxt, sel, ts, ori);
walther@60010
   847
Walther@60471
   848
(*+/---------------- bypass recursion of associate_input' ----------------\*)
Walther@60655
   849
(*+*)O_Model.to_string @{context} oris = "[\n" ^
walther@60010
   850
  "(2, [\"1\"], #Given, FunktionsVariable, [\"x\"]), \n" ^
walther@60010
   851
  "(3, [\"1\"], #Find, Funktionen, [\"funs'''\"]), \n" ^
walther@60010
   852
  "(4, [\"1\"], #Find, Biegelinie, [\"y\"]), \n" ^
walther@60010
   853
  "(5, [\"1\"], #Given, AbleitungBiegelinie, [\"dy\"])]";
walther@60010
   854
(*+*)val (id, vat, sel', d, ts') = nth 3 oris; (* 3rd iteration *)
Walther@60471
   855
(*+\---------------- bypass recursion of associate_input' ----------------/*)
walther@60010
   856
walther@60010
   857
    (*if*) sel = sel' andalso (inter op = ts ts') <> [] (*else*);
walther@60010
   858
Walther@60471
   859
(*/------------------- check within associate_input' -------------------------------\*)
walther@60010
   860
(*+*)if sel = "#Given" andalso sel' = "#Given"
Walther@60471
   861
(*+*)then () else error "associate_input' Model_Pattern CHANGED";
walther@60154
   862
(*BUT: m_field can change from root-Problem to sub-MethodC --------------------vvv*)
walther@60010
   863
(* sub-vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*)
Walther@60655
   864
(*+*)if (Problem.from_store ctxt ["vonBelastungZu", "Biegelinien"] |> #model |> Model_Pattern.to_string @{context}) = "[\"" ^
walther@60010
   865
  "(#Given, (Streckenlast, q_q))\", \"" ^
walther@60010
   866
  "(#Given, (FunktionsVariable, v_v))\", \"" ^
walther@60010
   867
  "(#Find, (Funktionen, funs'''))\"]"
Walther@60471
   868
(*+*)then () else error "associate_input' Model_Pattern of Subproblem CHANGED";
Walther@60746
   869
(* root-vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv ------------------------------------- \<up>*)
Walther@60655
   870
(*+*)if (Problem.from_store ctxt ["Biegelinien"] |> #model |> Model_Pattern.to_string @{context}) = "[\"" ^
walther@60010
   871
  "(#Given, (Traegerlaenge, l_l))\", \"" ^
walther@60010
   872
  "(#Given, (Streckenlast, q_q))\", \"" ^
walther@60242
   873
  "(#Find, (Biegelinie, b_b))\", \"" ^ (*------------------------------------- \<up> *)
walther@60010
   874
  "(#Relate, (Randbedingungen, r_b))\"]"
Walther@60471
   875
(*+*)then () else error "associate_input' Model_Pattern root-problem CHANGED";
walther@60010
   876
(* sub-vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*)
Walther@60655
   877
(*+*)if (MethodC.from_store ctxt ["Biegelinien", "ausBelastung"] |> #model |> Model_Pattern.to_string @{context}) = "[\"" ^
walther@60010
   878
  "(#Given, (Streckenlast, q__q))\", \"" ^
walther@60010
   879
  "(#Given, (FunktionsVariable, v_v))\", \"" ^
Walther@60736
   880
  "(#Given, (Biegelinie, b_b))\", \"" ^
walther@60023
   881
  "(#Given, (AbleitungBiegelinie, id_der))\", \"" ^
Walther@60736
   882
  "(#Given, (Biegemoment, id_momentum))\", \"" ^
Walther@60736
   883
  "(#Given, (Querkraft, id_lat_force))\", \"" ^
walther@60010
   884
  "(#Find, (Funktionen, fun_s))\"]"
Walther@60471
   885
(*+*)then () else error "associate_input' Model_Pattern CHANGED";
Walther@60675
   886
(*+*)if UnparseC.term @{context} d = "Biegelinie" andalso UnparseC.terms @{context} ts = "[y]"
Walther@60675
   887
(*+*)  andalso UnparseC.terms @{context} ts' = "[y]"
walther@60010
   888
(*+*)then
walther@60010
   889
(*+*)  (case (inter op = ts ts') of [Free ("y", _(*"real \<Rightarrow> real"*))] => () 
Walther@60471
   890
(*+*)  | _ => error "check within associate_input' CHANGED 1")
Walther@60471
   891
(*+*)else error "check within associate_input' CHANGED 2";
Walther@60471
   892
(*\------------------- check within associate_input' -------------------------------/*)
walther@60010
   893
Walther@60736
   894
(*|------------------- contine me_Specify_Method_ausBelastung --------------------------------*)
Walther@60736
   895
(*\------------------- step into me_Specify_Method_ausBelastung ----------------------------//*)
Walther@60736
   896
(*[1], Met*)val (p,_,f,nxt,_,pt) = return_me_Specify_Method_ausBelastung;
Walther@60736
   897
                                                     val Add_Given "Biegelinie y" = nxt
Walther@60736
   898
Walther@60736
   899
(*[1], Met*)val (p,_,f,nxt,_,pt) = me nxt p c pt; val Add_Given "AbleitungBiegelinie dy"= nxt
Walther@60736
   900
(*[1], Met*)val (p,_,f,nxt,_,pt) = me nxt p c pt; val Add_Given "Biegemoment M_b" = nxt
Walther@60736
   901
(*[1], Met*)val (p,_,f,nxt,_,pt) = me nxt p c pt; val Add_Given "Querkraft Q" = nxt
Walther@60736
   902
(*[1], Met*)val (p,_,f,nxt,_,pt) = me nxt p c pt; val Apply_Method ["Biegelinien", "ausBelastung"] = nxt
Walther@60736
   903
Walther@60729
   904
(*[1, 1], Frm*)val (p,_,f,nxt,_,pt) = me nxt p c pt; val Rewrite ("sym_neg_equal_iff_equal", _)= nxt
Walther@60729
   905
(*[1, 1], Res*)val (p,_,f,nxt,_,pt) = me nxt p c pt; val Rewrite ("Belastung_Querkraft", _)= nxt
Walther@60729
   906
(*[1, 2], Res*)val (p,_,f,nxt,_,pt) = me nxt p c pt; val Subproblem ("Biegelinie", ["named", "integrate", "function"])= nxt
Walther@60729
   907
(*[1, 3], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; val Model_Problem= nxt
Walther@60729
   908
(*[1, 3], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; val Add_Given "functionTerm (- q_0)"= nxt
Walther@60729
   909
(*[1, 3], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; val Add_Given "integrateBy x"= nxt
Walther@60729
   910
;
walther@60010
   911
(*/------------------- check result of Add_Given "functionTerm (- q_0)" --------------------\*)
walther@60010
   912
if p = ([1, 3], Pbl) andalso
walther@60010
   913
  f = Test_Out.PpcKF (Test_Out.Problem [], {Find = [Incompl "antiDerivativeName"],
Walther@60729
   914
    Given = [Correct "functionTerm (- q_0)", Incompl "integrateBy"], 
walther@60010
   915
    Relate = [], Where = [], With = []})
walther@60010
   916
then
walther@60010
   917
  (case nxt of Add_Given "integrateBy x" => () | _ => error "specify-phase: low level CHANGED 1")
walther@60010
   918
else error "specify-phase: low level CHANGED 2";
walther@60010
   919
(*\------------------- check result of Add_Given "functionTerm (- q_0)" --------------------/*)
walther@60010
   920