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