test/Tools/isac/Interpret/calchead.sml
author Walther Neuper <wneuper@ist.tugraz.at>
Thu, 02 Feb 2017 06:50:47 +0100
changeset 59306 a2baef20c741
parent 59279 255c853ea2f0
child 59348 ddfabb53082c
permissions -rw-r--r--
remove warnings at the cost of opening structures

Notes:
# the only warnings to preliminiarily remain are those with handle _
# this changeset is messed up with work for the subsequent changeset.
akargl@42108
     1
  (* Title: tests on calchead.sml
neuper@38036
     2
   Author: Walther Neuper 051013,
neuper@37906
     3
   (c) due to copyright terms
neuper@37906
     4
neuper@38011
     5
12345678901234567890123456789012345678901234567890123456789012345678901234567890
neuper@38011
     6
        10        20        30        40        50        60        70        80
neuper@37906
     7
*)
neuper@37906
     8
neuper@38010
     9
"--------------------------------------------------------";
neuper@38010
    10
"table of contents --------------------------------------";
neuper@38010
    11
"--------------------------------------------------------";
neuper@38010
    12
"--------- get_interval after replace} other 2 ----------";
neuper@38010
    13
"--------- maximum example with 'specify' ---------------";
neuper@38010
    14
"--------- maximum example with 'specify', fmz <> [] ----";
neuper@38010
    15
"--------- maximum example with 'specify', fmz = [] -----";
neuper@38010
    16
"--------- match_ags, is_cp, cpy_nam +with EqSystem (!)--";
neuper@38010
    17
"--------- regression test fun is_copy_named ------------";
neuper@38011
    18
"--------- regr.test fun cpy_nam ------------------------";
neuper@38051
    19
"--------- check specify phase --------------------------";
neuper@42279
    20
"--------- check: fmz matches pbt -----------------------";
wneuper@59265
    21
"--------- fun typeless ---------------------------------";
wneuper@59265
    22
"--------- fun variants_in ------------------------------";
wneuper@59265
    23
"--------- fun has_list_type ----------------------------";
wneuper@59265
    24
"--------- fun tag_form ---------------------------------";
wneuper@59265
    25
"--------- fun foldr1, foldl1 ---------------------------";
neuper@38010
    26
"--------------------------------------------------------";
neuper@38010
    27
"--------------------------------------------------------";
neuper@38010
    28
"--------------------------------------------------------";
neuper@38009
    29
akargl@42108
    30
neuper@38011
    31
"--------- get_interval after replace} other 2 ----------";
neuper@38011
    32
"--------- get_interval after replace} other 2 ----------";
neuper@38011
    33
"--------- get_interval after replace} other 2 ----------";
s1210629013@55445
    34
reset_states ();
neuper@41970
    35
 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"], 
neuper@41970
    36
   ("Test", ["sqroot-test","univariate","equation","test"],
neuper@37906
    37
    ["Test","squ-equ-test-subpbl1"]))];
neuper@37906
    38
 Iterator 1;
neuper@37906
    39
 moveActiveRoot 1;
wneuper@59248
    40
 autoCalculate 1 CompleteCalc;
neuper@37906
    41
 moveActiveFormula 1 ([2],Res); (*there is "-1 + x = 0"*)
neuper@37906
    42
 replaceFormula 1 "x = 1"; 
neuper@37906
    43
 (*... returns calcChangedEvent with ...*)
neuper@37906
    44
 val (unc, del, gen) = (([1],Res), ([4],Res), ([3,2],Res));
neuper@37906
    45
 val ((pt,_),_) = get_calc 1;
neuper@37906
    46
wneuper@59111
    47
default_print_depth 99;map fst (get_interval ([],Pbl) ([],Res) 9999 pt);default_print_depth 3;
neuper@37906
    48
if map fst (get_interval ([],Pbl) ([],Res) 9999 pt) = 
neuper@37906
    49
    [([], Pbl), ([1], Frm),([1], Res), ([2], Res), ([3], Pbl), ([3, 1], Frm), 
neuper@37906
    50
     ([3, 1], Res), ([3, 2, 1], Frm), ([3, 2, 1], Res), ([3, 2, 2], Res),
neuper@37906
    51
      ([3, 2], Res)] then () else
neuper@38031
    52
error "calchead.sml: diff.behav. get_interval after replace} other 2 a";
neuper@37906
    53
wneuper@59111
    54
default_print_depth 99;map fst (get_interval ([3, 2, 1], Res) ([],Res) 9999 pt); default_print_depth 3;
neuper@37906
    55
if map fst (get_interval ([3, 2, 1], Res) ([],Res) 9999 pt) = 
neuper@37906
    56
    [([3, 2, 1], Res), ([3, 2, 2], Res), ([3, 2], Res)] then () else
neuper@38031
    57
error "modspec.sml: diff.behav. get_interval after replace} other 2 b";
neuper@37906
    58
neuper@37906
    59
"--------- maximum example with 'specify' ------------------------";
neuper@37906
    60
"--------- maximum example with 'specify' ------------------------";
neuper@37906
    61
"--------- maximum example with 'specify' ------------------------";
neuper@37906
    62
(*"              Specify_Problem (match_itms_oris)       ";*)
neuper@37906
    63
val fmz =
neuper@37906
    64
    ["fixedValues [r=Arbfix]","maximum A",
neuper@48894
    65
     "valuesFor [a,b::real]",
neuper@48894
    66
     "relations [A=a*(b::real), (a/2)^^^2 + (b/2)^^^2 = (r::real)^^^2]",
neuper@48894
    67
     "relations [A=a*(b::real), (a/2)^^^2 + (b/2)^^^2 = (r::real)^^^2]",
neuper@48894
    68
     "relations [A=a*(b::real), a/2=r*sin alpha, b/2 = (r::real)*cos alpha]",
neuper@37906
    69
neuper@37906
    70
     "boundVariable a","boundVariable b","boundVariable alpha",
neuper@37906
    71
     "interval {x::real. 0 <= x & x <= 2*r}",
neuper@37906
    72
     "interval {x::real. 0 <= x & x <= 2*r}",
neuper@37906
    73
     "interval {x::real. 0 <= x & x <= pi}",
neuper@37906
    74
     "errorBound (eps=(0::real))"];
neuper@37906
    75
val (dI',pI',mI') =
neuper@38058
    76
  ("DiffApp",["maximum_of","function"],
neuper@37906
    77
   ["DiffApp","max_by_calculus"]);
neuper@37906
    78
val c = []:cid;
neuper@37906
    79
neuper@37906
    80
val (p,_,f,(_,nxt),_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
neuper@37906
    81
val nxt = tac2tac_ pt p nxt; 
wneuper@59267
    82
val(p,_, PpcKF ppc, nxt,_,pt) = specify nxt p [] pt;
neuper@37906
    83
(*val nxt = Add_Given "fixedValues [(r::real) = Arbfix]" : tac*)
neuper@37906
    84
neuper@37906
    85
val nxt = tac2tac_ pt p nxt; 
wneuper@59267
    86
val(p,_, PpcKF ppc, nxt,_,pt) = specify nxt p [] pt;
neuper@37906
    87
(**)
neuper@37906
    88
neuper@37906
    89
val nxt = tac2tac_ pt p (Add_Find "valuesFor [(a::real)]"); 
wneuper@59267
    90
val(p,_, PpcKF ppc, nxt,_,pt) = specify nxt p [] pt;
neuper@37906
    91
if ppc<>(Problem [],  
neuper@37906
    92
         {Find=[Incompl "maximum",Incompl "valuesFor [a]"],
neuper@37906
    93
	  Given=[Correct "fixedValues [r = Arbfix]"],
neuper@48894
    94
	  Relate=[Incompl "relations"], Where=[],With=[]})
neuper@38031
    95
then error "test-maximum.sml: model stepwise - different behaviour" 
neuper@48894
    96
else ();
neuper@37906
    97
neuper@48894
    98
val nxt = tac2tac_ pt p (Add_Given "boundVariable (a::real)"); 
neuper@48894
    99
(* WN1130630 THE maximum example WORKS IN isabisac09-2; 
neuper@48894
   100
  MOST LIKELY IT IS BROKEN BY INTRODUCING  ctxt. 
neuper@48894
   101
  Some tests have been broken much earlier, 
neuper@48894
   102
  see test/../calchead.sml "inhibit exn 010830". *)
neuper@48894
   103
(*========== inhibit exn WN1130630 maximum example broken =========================
wneuper@59267
   104
val(p,_, PpcKF ppc, nxt,_,pt) = specify nxt p [] pt;
neuper@48894
   105
============ inhibit exn WN1130630 maximum example broken =======================*)
neuper@48894
   106
neuper@48894
   107
val nxt = tac2tac_ pt p (Add_Given "boundVariable a+"); 
neuper@48894
   108
(*========== inhibit exn WN1130630 maximum example broken =========================
akargl@42181
   109
(* ERROR: Exception Bind raised *)
wneuper@59267
   110
val(p,_, PpcKF ppc, nxt,_,pt) = specify nxt p [] pt;
neuper@48894
   111
============ inhibit exn WN1130630 maximum example broken =======================*)
neuper@37906
   112
neuper@37906
   113
val m = Specify_Problem ["maximum_of","function"];
neuper@37906
   114
val nxt = tac2tac_ pt p m; 
wneuper@59267
   115
val(p,_, PpcKF ppc, nxt,_,pt) = specify nxt p [] pt;
neuper@48894
   116
(*========== inhibit exn WN1130630 maximum example broken =========================
neuper@37906
   117
if ppc<>(Problem ["maximum_of","function"],  
neuper@37906
   118
         {Find=[Incompl "maximum",Incompl "valuesFor"],
neuper@37906
   119
	  Given=[Correct "fixedValues [r = Arbfix]"],
neuper@37906
   120
	  Relate=[Incompl "relations []"], Where=[],With=[]})
neuper@38031
   121
then error "diffappl.sml: Specify_Problem different behaviour" 
neuper@37906
   122
else ();
neuper@37906
   123
(* WN.3.9.03 (#391) Model_Specify did init_pbl newly 
neuper@37906
   124
if ppc<>(Problem ["maximum_of","function"],
neuper@37906
   125
   {Find=[Missing "maximum m_",Missing "valuesFor vs_"],
neuper@37906
   126
    Given=[Correct "fixedValues [r = Arbfix]"],
neuper@37906
   127
    Relate=[Missing "relations rs_"],Where=[],With=[]})
neuper@38031
   128
then error "diffappl.sml: Specify_Problem different behaviour" 
neuper@37906
   129
else ();*)
neuper@48894
   130
============ inhibit exn WN1130630 maximum example broken =======================*)
neuper@37906
   131
neuper@37906
   132
val nxt = tac2tac_ pt p(Specify_Method ["DiffApp","max_by_calculus"]);
wneuper@59267
   133
val(p,_, PpcKF ppc, nxt,_,pt) = specify nxt p [] pt;
neuper@48894
   134
(*========== inhibit exn WN1130630 maximum example broken =========================
neuper@37906
   135
if ppc<>(Method ["DiffApp","max_by_calculus"],
neuper@37906
   136
	 {Find=[Incompl "maximum",Incompl "valuesFor"],
neuper@37981
   137
	  Given=[Correct "fixedValues [r = Arbfix]",Missing "boundVariable v_v",
neuper@37906
   138
		 Missing "interval itv_",Missing "errorBound err_"],
neuper@37906
   139
	  Relate=[Incompl "relations []"],Where=[],With=[]})
neuper@38031
   140
then error "diffappl.sml: Specify_Method different behaviour" 
neuper@37906
   141
else ();
neuper@37906
   142
(* WN.3.9.03 (#391) Model_Specify did init_pbl newly 
neuper@37906
   143
if ppc<>(Method ["DiffApp","max_by_calculus"],
neuper@37906
   144
   {Find=[Missing "maximum m_",Missing "valuesFor vs_"],
neuper@37981
   145
    Given=[Correct "fixedValues [r = Arbfix]",Missing "boundVariable v_v",
neuper@37906
   146
           Missing "interval itv_",Missing "errorBound err_"],
neuper@37906
   147
    Relate=[Missing "relations rs_"],Where=[],With=[]})
neuper@38031
   148
then error "diffappl.sml: Specify_Method different behaviour" 
neuper@37906
   149
else ();*)
neuper@48894
   150
============ inhibit exn WN1130630 maximum example broken =======================*)
neuper@37906
   151
neuper@37906
   152
"--------- maximum example with 'specify', fmz <> [] -------------";
neuper@37906
   153
"--------- maximum example with 'specify', fmz <> [] -------------";
neuper@37906
   154
"--------- maximum example with 'specify', fmz <> [] -------------";
neuper@37906
   155
val fmz =
neuper@37906
   156
    ["fixedValues [r=Arbfix]","maximum A",
neuper@37906
   157
     "valuesFor [a,b]",
neuper@37906
   158
     "relations [A=a*b, (a/2)^^^2 + (b/2)^^^2 = r^^^2]",
neuper@37906
   159
     "relations [A=a*b, (a/2)^^^2 + (b/2)^^^2 = r^^^2]",
neuper@37906
   160
     "relations [A=a*b, a/2=r*sin alpha, b/2=r*cos alpha]",
neuper@37906
   161
neuper@37906
   162
     "boundVariable a","boundVariable b","boundVariable alpha",
neuper@37906
   163
     "interval {x::real. 0 <= x & x <= 2*r}",
neuper@37906
   164
     "interval {x::real. 0 <= x & x <= 2*r}",
neuper@37906
   165
     "interval {x::real. 0 <= x & x <= pi}",
neuper@37906
   166
     "errorBound (eps=(0::real))"];
neuper@37906
   167
val (dI',pI',mI') =
neuper@38058
   168
  ("DiffApp",["maximum_of","function"],
neuper@37906
   169
   ["DiffApp","max_by_calculus"]);
neuper@37906
   170
val c = []:cid;
neuper@37906
   171
(*val nxt = Init_Proof' (fmz,(dI',pI',mI'));*)
neuper@37906
   172
val (p,_,f,(_,nxt),_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
neuper@37906
   173
neuper@37906
   174
val nxt = tac2tac_ pt p nxt; 
wneuper@59267
   175
val(p,_, PpcKF ppc, nxt,_,pt) = specify nxt e_pos' [] pt;
neuper@37906
   176
val nxt = tac2tac_ pt p nxt; 
wneuper@59267
   177
val(p,_, PpcKF ppc, nxt,_,pt) = specify nxt p [] pt;
neuper@37906
   178
(*val nxt = Add_Given "fixedValues [(r::real) = Arbfix]" : tac*)
neuper@37906
   179
neuper@37906
   180
val nxt = tac2tac_ pt p nxt; 
wneuper@59267
   181
val(p,_, PpcKF ppc, nxt,_,pt) = specify nxt p [] pt;
neuper@37906
   182
(*val nxt = Add_Find "maximum (A::bool)" : tac*)
neuper@37906
   183
neuper@37906
   184
val nxt = tac2tac_ pt p nxt; 
wneuper@59267
   185
val(p,_, PpcKF ppc, nxt,_,pt) = specify nxt p [] pt;
neuper@37906
   186
(*val nxt = Add_Find "valuesFor [(a::real)]" : tac*)
neuper@37906
   187
neuper@37906
   188
val nxt = tac2tac_ pt p nxt; 
wneuper@59267
   189
val(p,_, PpcKF ppc, nxt,_,pt) = specify nxt p [] pt;
neuper@37906
   190
(*val nxt = Add_Find "valuesFor [(b::real)]" : tac*)
neuper@37906
   191
neuper@37906
   192
val nxt = tac2tac_ pt p nxt; 
wneuper@59267
   193
val(p,_, PpcKF ppc, nxt,_,pt) = specify nxt p [] pt;
neuper@37906
   194
(*val nxt = Add_Relation "relations [A = a * b]" *)
neuper@37906
   195
neuper@37906
   196
val nxt = tac2tac_ pt p nxt; 
wneuper@59267
   197
val(p,_, PpcKF ppc, nxt,_,pt) = specify nxt p [] pt;
neuper@37906
   198
(*Add_Relation "relations\n [((a::real) // (#2::real)) ..."*)
neuper@37906
   199
neuper@37906
   200
(*---------------------------- FIXXXXME.meNEW !!! partial Add-Relation !!!
neuper@37906
   201
  nxt_specif <> specify ?!
neuper@37906
   202
neuper@37906
   203
if nxt<>(Add_Relation 
neuper@37906
   204
 "relations [(a / 2) ^^^ 2 + (b / 2) ^^^ 2 = r ^^^ 2]")
neuper@38031
   205
then error "test specify, fmz <> []: nxt <> Add_Relation (a/2)^2.." else (); (*different with show_types !!!*)
neuper@37906
   206
neuper@37906
   207
val nxt = tac2tac_ pt p nxt; 
wneuper@59267
   208
val(p,_, PpcKF ppc, nxt,_,pt) = specify nxt p [] pt;
neuper@37906
   209
------------------------------ FIXXXXME.meNEW !!! ---*)
neuper@37906
   210
neuper@38058
   211
(*val nxt = Specify_Theory "DiffApp" : tac*)
neuper@37906
   212
neuper@37924
   213
val itms = get_obj g_pbl pt (fst p);writeln(itms2str_ ctxt itms);
neuper@37906
   214
neuper@37906
   215
val nxt = tac2tac_ pt p nxt; 
wneuper@59267
   216
val(p,_, PpcKF ppc, nxt,_,pt) = specify nxt p [] pt;
neuper@37906
   217
(*val nxt = Specify_Problem ["maximum_of","function"]*)
neuper@37906
   218
neuper@37906
   219
val nxt = tac2tac_ pt p nxt; 
wneuper@59267
   220
val(p,_, PpcKF ppc, nxt,_,pt) = specify nxt p [] pt;
neuper@38058
   221
(*val nxt = Specify_Method ("DiffApp","max_by_calculus")*)
neuper@37906
   222
neuper@37906
   223
val nxt = tac2tac_ pt p nxt; 
wneuper@59267
   224
val(p,_, PpcKF ppc, nxt,_,pt) = specify nxt p [] pt;
neuper@37906
   225
(*val nxt = Add_Given "boundVariable a" : tac*)
neuper@37906
   226
neuper@37906
   227
val nxt = tac2tac_ pt p nxt; 
wneuper@59267
   228
val(p,_, PpcKF ppc, nxt,_,pt) = specify nxt p [] pt;
neuper@37906
   229
(*val nxt = Add_Given "interval {x. #0 <= x & x <= #2 * r}" : *)
neuper@37906
   230
neuper@37906
   231
val nxt = tac2tac_ pt p nxt; 
wneuper@59267
   232
val(p,_, PpcKF ppc, nxt,_,pt) = specify nxt p [] pt;
neuper@37906
   233
(*val nxt = Add_Given "errorBound (eps = #0)" : tac*)
neuper@37906
   234
neuper@37906
   235
val nxt = tac2tac_ pt p nxt; 
wneuper@59267
   236
val(p,_, PpcKF ppc, nxt,_,pt) = specify nxt p [] pt;
neuper@38058
   237
(*val nxt = Apply_Method ("DiffApp","max_by_calculus") *)
wneuper@59253
   238
case nxt of (Apply_Method ["DiffApp","max_by_calculus"]) => ()
wneuper@59253
   239
| _ => error "test specify, fmz <> []: nxt <> Apply_Method max_by_calculus";
neuper@37906
   240
neuper@37906
   241
neuper@37906
   242
"--------- maximum example with 'specify', fmz = [] --------------";
neuper@37906
   243
"--------- maximum example with 'specify', fmz = [] --------------";
neuper@37906
   244
"--------- maximum example with 'specify', fmz = [] --------------";
neuper@37906
   245
val fmz = [];
neuper@37906
   246
val (dI',pI',mI') = empty_spec;
neuper@37906
   247
val c = []:cid;
neuper@37906
   248
neuper@37906
   249
val nxt = Init_Proof' (fmz,(dI',pI',mI'));(*!!!!!!!!*)
neuper@37906
   250
(*val (p,_,f,(_,nxt),_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))]; !!!*)
wneuper@59267
   251
val(p,_, PpcKF ppc, nxt,_,pt) = specify nxt e_pos' [] 
neuper@37906
   252
  EmptyPtree;
neuper@37906
   253
val nxt = tac2tac_ pt p nxt; 
wneuper@59267
   254
val(p,_, PpcKF ppc, nxt,_,pt) = specify nxt p [] pt;
neuper@37906
   255
(*val nxt = Specify_Theory "e_domID" : tac*)
neuper@37906
   256
neuper@38058
   257
val nxt = Specify_Theory "DiffApp";
neuper@37906
   258
val nxt = tac2tac_ pt p nxt; 
wneuper@59267
   259
val(p,_, PpcKF ppc, nxt,_,pt) = specify nxt p [] pt;
neuper@37906
   260
(*val nxt = Specify_Problem ["e_pblID"] : tac*)
neuper@37906
   261
neuper@37906
   262
val nxt = Specify_Problem ["maximum_of","function"];
neuper@37906
   263
val nxt = tac2tac_ pt p nxt; 
wneuper@59267
   264
val(p,_, PpcKF ppc, nxt,_,pt) = specify nxt p [] pt;
neuper@37906
   265
(*val nxt = Add_Given "fixedValues" : tac*)
neuper@37906
   266
neuper@37906
   267
val nxt = Add_Given "fixedValues [r=Arbfix]";
neuper@37906
   268
val nxt = tac2tac_ pt p nxt; 
wneuper@59267
   269
val(p,_, PpcKF ppc, nxt,_,pt) = specify nxt p [] pt;
neuper@37906
   270
(*val nxt = Add_Find "maximum" : tac*)
neuper@37906
   271
neuper@37906
   272
val nxt = Add_Find "maximum A";
neuper@37906
   273
val nxt = tac2tac_ pt p nxt; 
neuper@37906
   274
neuper@37906
   275
wneuper@59267
   276
val(p,_, PpcKF ppc, nxt,_,pt) = specify nxt p [] pt;
neuper@37906
   277
(*val nxt = Add_Find "valuesFor" : tac*)
neuper@37906
   278
neuper@37906
   279
val nxt = Add_Find "valuesFor [a]";
neuper@37906
   280
val nxt = tac2tac_ pt p nxt; 
wneuper@59267
   281
val(p,_, PpcKF ppc, nxt,_,pt) = specify nxt p [] pt;
neuper@37906
   282
(*val nxt = Add_Relation "relations" --- 
neuper@37906
   283
  --- [b=Arbfix] KANN NICHT VERLANGT WERDEN !!!!*)
neuper@37906
   284
akargl@42181
   285
(*========== inhibit exn 010830 =======================================================*)
neuper@37906
   286
(*30.8.01 ... funktioniert nicht mehr nach Einfuehrung env ....
neuper@37906
   287
if nxt<>(Add_Relation "relations []")
neuper@38031
   288
then error "test specify, fmz <> []: nxt <> Add_Relation.." 
neuper@37906
   289
else (); (*different with show_types !!!*)
neuper@37906
   290
*)
akargl@42181
   291
(*========== inhibit exn 010830 =======================================================*)
neuper@37906
   292
neuper@37906
   293
val nxt = Add_Relation "relations [(A=a+b)]";
neuper@37906
   294
val nxt = tac2tac_ pt p nxt; 
wneuper@59267
   295
val(p,_, PpcKF ppc, nxt,_,pt) = specify nxt p [] pt;
neuper@37906
   296
(*val nxt = Specify_Method ("e_domID","e_metID") : tac*)
neuper@37906
   297
neuper@37906
   298
val nxt = Specify_Method ["DiffApp","max_by_calculus"];
neuper@37906
   299
val nxt = tac2tac_ pt p nxt; 
wneuper@59267
   300
val(p,_, PpcKF ppc, nxt,_,pt) = specify nxt p [] pt;
neuper@37906
   301
(*val nxt = Add_Given "boundVariable" : tac*)
neuper@37906
   302
neuper@37906
   303
val nxt = Add_Given "boundVariable alpha";
neuper@37906
   304
val nxt = tac2tac_ pt p nxt; 
wneuper@59267
   305
val(p,_, PpcKF ppc, nxt,_,pt) = specify nxt p [] pt;
neuper@37906
   306
(*val nxt = Add_Given "interval" : tac*)
neuper@37906
   307
neuper@37906
   308
val nxt = Add_Given "interval {x. 2 <= x & x <= 3}";
neuper@37906
   309
val nxt = tac2tac_ pt p nxt; 
wneuper@59267
   310
val(p,_, PpcKF ppc, nxt,_,pt) = specify nxt p [] pt;
neuper@37906
   311
(*val nxt = Add_Given "errorBound" : tac*)
neuper@37906
   312
neuper@37906
   313
val nxt = Add_Given "errorBound (eps=999)";
neuper@37906
   314
val nxt = tac2tac_ pt p nxt; 
wneuper@59267
   315
val(p,_, PpcKF ppc, nxt,_,pt) = specify nxt p [] pt;
neuper@37906
   316
(*val nxt = Apply_Method ("DiffApp","max_by_calculus") *)
akargl@42108
   317
neuper@37906
   318
(*30.8.01 ... funktioniert nicht mehr nach Einfuehrung env ....
neuper@38058
   319
if nxt<>(Apply_Method ("DiffApp","max_by_calculus"))
neuper@38031
   320
then error "test specify, fmz <> []: nxt <> Add_Relation.." 
neuper@37906
   321
else ();
neuper@37906
   322
*)
neuper@37906
   323
(* 2.4.00 nach Transfer specify -> hard_gen
neuper@38058
   324
val nxt = Apply_Method ("DiffApp","max_by_calculus");
wneuper@59267
   325
val(p,_, PpcKF ppc, nxt,_,pt) = specify nxt p [] pt; *)
neuper@37906
   326
(*val nxt = Empty_Tac : tac*)
neuper@38051
   327
neuper@38011
   328
"--------- match_ags, is_cp, cpy_nam +with EqSystem (!)--";
neuper@38011
   329
"--------- match_ags, is_cp, cpy_nam +with EqSystem (!)--";
neuper@38011
   330
"--------- match_ags, is_cp, cpy_nam +with EqSystem (!)--";
neuper@37906
   331
val Const ("Script.SubProblem",_) $
neuper@41972
   332
	  (Const ("Product_Type.Pair",_) $
neuper@37906
   333
		 Free (dI',_) $ 
neuper@41972
   334
		 (Const ("Product_Type.Pair",_) $ pI' $ mI')) $ ags' =
neuper@37906
   335
    (*...copied from stac2tac_*)
neuper@38011
   336
    str2term (
neuper@55279
   337
	"SubProblem (EqSystem', [LINEAR, system], [no_met])         " ^
neuper@38011
   338
        "     [BOOL_LIST [c_2 = 0, L * c + c_2 = q_0 * L ^^^ 2 / 2]," ^
neuper@38011
   339
        "      REAL_LIST [c, c_2]]");
neuper@37906
   340
val ags = isalist2list ags';
neuper@55279
   341
val pI = ["LINEAR","system"];
neuper@37906
   342
val pats = (#ppc o get_pbt) pI;
neuper@38011
   343
"-a1-----------------------------------------------------";
neuper@38011
   344
(*match_ags = fn : theory -> pat list -> term list -> ori list*)
neuper@48894
   345
val xxx = match_ags @{theory "EqSystem"} pats ags;
neuper@38011
   346
"-a2-----------------------------------------------------";
neuper@48894
   347
case match_ags @{theory  "Isac"} pats ags of 
neuper@37906
   348
    [(1, [1], "#Given", Const ("Descript.equalities", _), _),
neuper@37906
   349
     (2, [1], "#Given", Const ("EqSystem.solveForVars", _),
neuper@37906
   350
      [ _ $ Free ("c", _) $ _, _ $ Free ("c_2", _) $ _]),
neuper@38011
   351
     (3, [1], "#Find", Const ("EqSystem.solution", _), [Free ("ss'''", _)])] 
neuper@37906
   352
    =>()
neuper@38031
   353
  | _ => error "calchead.sml match_ags 2 args Nok ----------------";
neuper@37906
   354
neuper@38011
   355
"-b------------------------------------------------------";
neuper@37906
   356
val Const ("Script.SubProblem",_) $
neuper@41972
   357
	  (Const ("Product_Type.Pair",_) $
neuper@37906
   358
		 Free (dI',_) $ 
neuper@41972
   359
		 (Const ("Product_Type.Pair",_) $ pI' $ mI')) $ ags' =
neuper@37906
   360
    (*...copied from stac2tac_*)
neuper@38011
   361
    str2term (
neuper@55279
   362
	"SubProblem (EqSystem', [LINEAR, system], [no_met])         " ^
neuper@38011
   363
        "     [BOOL_LIST [c_2 = 0, L * c + c_2 = q_0 * L ^^^ 2 / 2]," ^
neuper@38011
   364
        "      REAL_LIST [c, c_2], BOOL_LIST ss''']");
neuper@37906
   365
val ags = isalist2list ags';
neuper@55279
   366
val pI = ["LINEAR","system"];
neuper@37906
   367
val pats = (#ppc o get_pbt) pI;
neuper@38011
   368
"-b1-----------------------------------------------------";
neuper@48894
   369
val xxx = match_ags @{theory  "Isac"} pats ags;
neuper@38011
   370
"-b2-----------------------------------------------------";
neuper@48894
   371
case match_ags @{theory "EqSystem"} pats ags of 
neuper@37906
   372
    [(1, [1], "#Given", Const ("Descript.equalities", _), _),
neuper@37906
   373
     (2, [1], "#Given", Const ("EqSystem.solveForVars", _),
neuper@37906
   374
         [_ $ Free ("c", _) $ _,
neuper@37906
   375
          _ $ Free ("c_2", _) $ _]),
neuper@38011
   376
     (3, [1], "#Find", Const ("EqSystem.solution", _), [Free ("ss'''", _)])]
neuper@38011
   377
    (*         type of Find:            [Free ("ss'''", "bool List.list")]*)
neuper@37906
   378
    =>()
neuper@38031
   379
  | _ => error "calchead.sml match_ags copy-named dropped --------";
neuper@37906
   380
neuper@38011
   381
"-c---ERROR case: stac is missing #Given equalities e_s--";
neuper@37906
   382
val stac as Const ("Script.SubProblem",_) $
neuper@41972
   383
	 (Const ("Product_Type.Pair",_) $
neuper@37906
   384
		Free (dI',_) $ 
neuper@41972
   385
		(Const ("Product_Type.Pair",_) $ pI' $ mI')) $ ags' =
neuper@37906
   386
    (*...copied from stac2tac_*)
neuper@38011
   387
    str2term (
neuper@55279
   388
	"SubProblem (EqSystem', [LINEAR, system], [no_met]) " ^
neuper@38011
   389
        "     [REAL_LIST [c, c_2]]");
neuper@38011
   390
val ags = isalist2list ags'; 
neuper@55279
   391
val pI = ["LINEAR","system"];
neuper@37906
   392
val pats = (#ppc o get_pbt) pI;
neuper@48895
   393
(*============ inhibit exn AK110726 ==============================================
neuper@38051
   394
val xxx - match_ags (theory "EqSystem") pats ags;
neuper@48895
   395
============ inhibit exn AK110726 ==============================================*)
neuper@38011
   396
"-c1-----------------------------------------------------";
neuper@38011
   397
"--------------------------step through code match_ags---";
neuper@48894
   398
val (thy, pbt:pat list, ags) = (@{theory "EqSystem"}, pats, ags);
neuper@38011
   399
fun flattup (i,(var,bool,str,itm_)) = (i,var,bool,str,itm_);
neuper@38011
   400
	val pbt' = filter_out is_copy_named pbt; (*=equalities, solveForVars*)
neuper@38011
   401
	val cy = filter is_copy_named pbt;       (*=solution*)
neuper@48895
   402
(*============ inhibit exn AK110726 ==============================================
neuper@38051
   403
	val oris' - matc thy pbt' ags [];
neuper@48895
   404
============ inhibit exn AK110726 ==============================================*)
neuper@38011
   405
"-------------------------------step through code matc---";
neuper@38011
   406
val (thy, (p as (s,(d,t)))::pbt, a::ags, oris) = (thy, pbt', ags, []);
neuper@38011
   407
(is_copy_named_idstr o free2str) t;
neuper@38011
   408
"---if False:...";
neuper@48895
   409
(*============ inhibit exn AK110726 ==============================================
neuper@38051
   410
val opt - mtc thy p a;
neuper@48895
   411
============ inhibit exn AK110726 ==============================================*)
neuper@38011
   412
"--------------------------------step through code mtc---";
neuper@48894
   413
val (thy, (str, (dsc, _)):pat, ty $ var) = (thy, p, a);
wneuper@59188
   414
Thm.global_cterm_of;
neuper@48894
   415
val ttt = (dsc $ var);
neuper@48895
   416
(*============ inhibit exn AK110726 ==============================================
wneuper@59188
   417
Thm.global_cterm_of thy (dsc $ var);
neuper@48895
   418
============ inhibit exn AK110726 ==============================================*)
neuper@48894
   419
neuper@48894
   420
"-------------------------------------step through end---";
neuper@48894
   421
"--------- match_ags, is_cp, cpy_nam +with EqSystem (!)--";
neuper@48894
   422
val Const ("Script.SubProblem",_) $
neuper@48894
   423
	  (Const ("Product_Type.Pair",_) $
neuper@48894
   424
		 Free (dI',_) $ 
neuper@48894
   425
		 (Const ("Product_Type.Pair",_) $ pI' $ mI')) $ ags' =
neuper@48894
   426
    (*...copied from stac2tac_*)
neuper@48894
   427
    str2term (
neuper@55279
   428
	"SubProblem (EqSystem', [LINEAR, system], [no_met])         " ^
neuper@48894
   429
        "     [BOOL_LIST [c_2 = 0, L * c + c_2 = q_0 * L ^^^ 2 / 2]," ^
neuper@48894
   430
        "      REAL_LIST [c, c_2]]");
neuper@48894
   431
val ags = isalist2list ags';
neuper@55279
   432
val pI = ["LINEAR","system"];
neuper@48894
   433
val pats = (#ppc o get_pbt) pI;
neuper@48894
   434
"-a1-----------------------------------------------------";
neuper@48894
   435
(*match_ags = fn : theory -> pat list -> term list -> ori list*)
neuper@48894
   436
val xxx = match_ags @{theory "EqSystem"} pats ags;
neuper@48894
   437
"-a2-----------------------------------------------------";
neuper@48894
   438
case match_ags @{theory  "Isac"} pats ags of 
neuper@48894
   439
    [(1, [1], "#Given", Const ("Descript.equalities", _), _),
neuper@48894
   440
     (2, [1], "#Given", Const ("EqSystem.solveForVars", _),
neuper@48894
   441
      [ _ $ Free ("c", _) $ _, _ $ Free ("c_2", _) $ _]),
neuper@48894
   442
     (3, [1], "#Find", Const ("EqSystem.solution", _), [Free ("ss'''", _)])] 
neuper@48894
   443
    =>()
neuper@48894
   444
  | _ => error "calchead.sml match_ags 2 args Nok ----------------";
neuper@48894
   445
neuper@48894
   446
"-b------------------------------------------------------";
neuper@48894
   447
val Const ("Script.SubProblem",_) $
neuper@48894
   448
	  (Const ("Product_Type.Pair",_) $
neuper@48894
   449
		 Free (dI',_) $ 
neuper@48894
   450
		 (Const ("Product_Type.Pair",_) $ pI' $ mI')) $ ags' =
neuper@48894
   451
    (*...copied from stac2tac_*)
neuper@48894
   452
    str2term (
neuper@55279
   453
	"SubProblem (EqSystem', [LINEAR, system], [no_met])         " ^
neuper@48894
   454
        "     [BOOL_LIST [c_2 = 0, L * c + c_2 = q_0 * L ^^^ 2 / 2]," ^
neuper@48894
   455
        "      REAL_LIST [c, c_2], BOOL_LIST ss''']");
neuper@48894
   456
val ags = isalist2list ags';
neuper@55279
   457
val pI = ["LINEAR","system"];
neuper@48894
   458
val pats = (#ppc o get_pbt) pI;
neuper@48894
   459
"-b1-----------------------------------------------------";
neuper@48894
   460
val xxx = match_ags @{theory  "Isac"} pats ags;
neuper@48894
   461
"-b2-----------------------------------------------------";
neuper@48894
   462
case match_ags @{theory "EqSystem"} pats ags of 
neuper@48894
   463
    [(1, [1], "#Given", Const ("Descript.equalities", _), _),
neuper@48894
   464
     (2, [1], "#Given", Const ("EqSystem.solveForVars", _),
neuper@48894
   465
         [_ $ Free ("c", _) $ _,
neuper@48894
   466
          _ $ Free ("c_2", _) $ _]),
neuper@48894
   467
     (3, [1], "#Find", Const ("EqSystem.solution", _), [Free ("ss'''", _)])]
neuper@48894
   468
    (*         type of Find:            [Free ("ss'''", "bool List.list")]*)
neuper@48894
   469
    =>()
neuper@48894
   470
  | _ => error "calchead.sml match_ags copy-named dropped --------";
neuper@48894
   471
neuper@48894
   472
"-c---ERROR case: stac is missing #Given equalities e_s--";
neuper@48894
   473
val stac as Const ("Script.SubProblem",_) $
neuper@48894
   474
	 (Const ("Product_Type.Pair",_) $
neuper@48894
   475
		Free (dI',_) $ 
neuper@48894
   476
		(Const ("Product_Type.Pair",_) $ pI' $ mI')) $ ags' =
neuper@48894
   477
    (*...copied from stac2tac_*)
neuper@48894
   478
    str2term (
neuper@55279
   479
	"SubProblem (EqSystem', [LINEAR, system], [no_met]) " ^
neuper@48894
   480
        "     [REAL_LIST [c, c_2]]");
neuper@48894
   481
val ags = isalist2list ags'; 
neuper@55279
   482
val pI = ["LINEAR","system"];
neuper@48894
   483
val pats = (#ppc o get_pbt) pI;
neuper@48895
   484
(*============ inhibit exn AK110726 ==============================================
neuper@48894
   485
val xxx - match_ags (theory "EqSystem") pats ags;
neuper@48894
   486
-------------------------------------------------------------------*)
neuper@48894
   487
"-c1-----------------------------------------------------";
neuper@48894
   488
"--------------------------step through code match_ags---";
neuper@48894
   489
val (thy, pbt:pat list, ags) = (@{theory "EqSystem"}, pats, ags);
neuper@48894
   490
fun flattup (i,(var,bool,str,itm_)) = (i,var,bool,str,itm_);
neuper@48894
   491
	val pbt' = filter_out is_copy_named pbt; (*=equalities, solveForVars*)
neuper@48894
   492
	val cy = filter is_copy_named pbt;       (*=solution*)
neuper@48895
   493
(*============ inhibit exn AK110726 ==============================================
neuper@48894
   494
	val oris' - matc thy pbt' ags [];
neuper@48894
   495
-------------------------------------------------------------------*)
neuper@48894
   496
"-------------------------------step through code matc---";
neuper@48894
   497
val (thy, (p as (s,(d,t)))::pbt, a::ags, oris) = (thy, pbt', ags, []);
neuper@48894
   498
(is_copy_named_idstr o free2str) t;
neuper@48894
   499
"---if False:...";
neuper@48895
   500
(*============ inhibit exn AK110726 ==============================================
neuper@48894
   501
val opt - mtc thy p a;
neuper@48894
   502
-------------------------------------------------------------------*)
neuper@48894
   503
"--------------------------------step through code mtc---";
neuper@48894
   504
val (thy, (str, (dsc, _)):pat, ty $ var) = (thy, p, a);
wneuper@59188
   505
Thm.global_cterm_of;
neuper@48894
   506
val ttt = (dsc $ var);
neuper@48895
   507
(*============ inhibit exn AK110726 ==============================================
wneuper@59188
   508
Thm.global_cterm_of thy (dsc $ var);
neuper@38051
   509
-------------------------------------------------------------------*)
neuper@38011
   510
"-------------------------------------step through end---";
neuper@38011
   511
neuper@48894
   512
case ((match_ags @{theory "EqSystem"} pats ags)
neuper@38011
   513
      handle ERROR _ => []) of (*why not TYPE ?WN100920*)
neuper@37906
   514
    [] => match_ags_msg pI stac ags
neuper@38031
   515
  | _ => error "calchead.sml match_ags 1st arg missing --------";
neuper@37906
   516
neuper@48894
   517
"-d------------------------------------------------------";
neuper@48894
   518
val stac as Const ("Script.SubProblem",_) $
neuper@48894
   519
	 (Const ("Product_Type.Pair",_) $
neuper@48894
   520
		Free (dI',_) $ 
neuper@48894
   521
		(Const ("Product_Type.Pair",_) $ pI' $ mI')) $ ags' =
neuper@48894
   522
    (*...copied from stac2tac_*)
neuper@48894
   523
    str2term (
neuper@48894
   524
	"SubProblem (Test',[univariate,equation,test]," ^
neuper@48894
   525
        "             [no_met]) [BOOL (x+1=2), REAL x]");
neuper@48894
   526
val AGS = isalist2list ags';
neuper@48894
   527
val pI = ["univariate","equation","test"];
neuper@48894
   528
neuper@48894
   529
neuper@48894
   530
case ((match_ags @{theory "EqSystem"} pats ags)
neuper@48894
   531
      handle ERROR _ => []) of (*why not TYPE ?WN100920*)
neuper@48894
   532
    [] => match_ags_msg pI stac ags
neuper@48894
   533
  | _ => error "calchead.sml match_ags 1st arg missing --------";
neuper@37906
   534
neuper@38011
   535
"-d------------------------------------------------------";
neuper@37906
   536
val stac as Const ("Script.SubProblem",_) $
neuper@41972
   537
	 (Const ("Product_Type.Pair",_) $
neuper@37906
   538
		Free (dI',_) $ 
neuper@41972
   539
		(Const ("Product_Type.Pair",_) $ pI' $ mI')) $ ags' =
neuper@37906
   540
    (*...copied from stac2tac_*)
neuper@38011
   541
    str2term (
neuper@38011
   542
	"SubProblem (Test',[univariate,equation,test]," ^
neuper@38011
   543
        "             [no_met]) [BOOL (x+1=2), REAL x]");
neuper@38011
   544
val AGS = isalist2list ags';
neuper@37906
   545
val pI = ["univariate","equation","test"];
neuper@38011
   546
val PATS = (#ppc o get_pbt) pI;
neuper@38011
   547
"-d1-----------------------------------------------------";
neuper@38011
   548
"--------------------------step through code match_ags---";
neuper@48894
   549
val (thy, pbt:pat list, ags) = (@{theory "Test"}, PATS, AGS);
neuper@38011
   550
fun flattup (i,(var,bool,str,itm_)) = (i,var,bool,str,itm_);
neuper@38011
   551
	val pbt' = filter_out is_copy_named pbt; 
neuper@38011
   552
	val cy = filter is_copy_named pbt;       
neuper@38011
   553
	val oris' = matc thy pbt' ags [];
neuper@38011
   554
"-------------------------------step through code matc---";
neuper@38011
   555
val (thy, (p as (s,(d,t)))::pbt, a::ags, oris) = (thy, pbt', ags, []);
neuper@38011
   556
(is_copy_named_idstr o free2str) t;
neuper@38011
   557
"---if False:...";
neuper@38011
   558
val opt = mtc thy p a;
neuper@38011
   559
"--------------------------------step through code mtc---";
neuper@38011
   560
val (thy, (str, (dsc, _)):pat, ty $ var) = (thy, p, a);
neuper@38011
   561
val ttt = (dsc $ var);
wneuper@59188
   562
Thm.global_cterm_of thy (dsc $ var);
neuper@38011
   563
val ori = ((([1], str, dsc, (*[var]*) split_dts' (dsc, var))): preori);
neuper@38011
   564
neuper@38011
   565
"-d2-----------------------------------------------------";
neuper@38011
   566
pbt = [];  (*false*)
neuper@38011
   567
"-------------------------------step through code matc---";
neuper@38011
   568
val (thy, (p as (s,(d,t)))::pbt, a::ags, oris) = (thy, pbt, ags, oris @ [ori]);
neuper@38011
   569
(is_copy_named_idstr o free2str) t;
neuper@38011
   570
"---if False:...";
neuper@38011
   571
val opt = mtc thy p a;
neuper@38011
   572
"--------------------------------step through code mtc---";
neuper@38011
   573
val (thy, (str, (dsc, _)):pat, ty $ var) = (thy, p, a);
neuper@38011
   574
val ttt = (dsc $ var);
wneuper@59188
   575
Thm.global_cterm_of thy (dsc $ var);
neuper@38011
   576
val ori = ((([1], str, dsc, (*[var]*) split_dts' (dsc, var))): preori);
neuper@38011
   577
"-d3-----------------------------------------------------";
neuper@38011
   578
pbt = [];  (*true, base case*)
neuper@38011
   579
"-----------------continue step through code match_ags---";
neuper@38011
   580
	val oris' = oris @ [ori]; (*result 2 oris, cpy_nam added later*)
neuper@38011
   581
"--------------------------------step through cpy_nam----";
neuper@38011
   582
val (pbt, oris, p as (field, (dsc, t)):pat) = (pbt', oris', hd cy);
neuper@38011
   583
(*t = "v_v'i'" : term             OLD: t = "v_i_"*)
neuper@38011
   584
"--------------------------------------------------------";
neuper@38011
   585
fun is_copy_named_generating_idstr str =
neuper@38011
   586
    if is_copy_named_idstr str
neuper@48894
   587
    then case (rev o Symbol.explode) str of
neuper@38011
   588
      (*"_"::"_"::"_"::_ => false*)
neuper@38011
   589
	"'"::"'"::"'"::_ => false
neuper@38011
   590
      | _ => true
neuper@38011
   591
    else false;
neuper@38011
   592
fun is_copy_named_generating (_, (_, t)) = 
neuper@38011
   593
    (is_copy_named_generating_idstr o free2str) t;
neuper@38011
   594
"--------------------------------------------------------";
neuper@38011
   595
is_copy_named_generating p (*true*);
neuper@38011
   596
           fun sel (_,_,d,ts) = comp_ts (d, ts);
neuper@48894
   597
	   val cy' = (implode o (drop_last_n 3) o Symbol.explode o free2str) t;
neuper@38011
   598
               (*"v_v"             OLD: "v_"*)
neuper@48894
   599
	   val ext = (last_elem o drop_last o Symbol.explode o free2str) t;
neuper@38011
   600
               (*"i"               OLD: "i"*)
neuper@38011
   601
	   val vars' = map (free2str o snd o snd) pbt(*cpy-nam filtered_out*);
neuper@38011
   602
               (*["e_e", "v_v"]    OLD: ["e_", "v_"]*)
neuper@38011
   603
	   val vals = map sel oris;
neuper@38011
   604
               (*[x+1=2, x]        OLD: [x+1=2, x] : term list*)
neuper@38011
   605
vars' ~~ vals;
neuper@38011
   606
(*[("e_e", [x+1=2), ("v_v", x)]    OLD: [("e_", [x+1=2), ("v_", x)]*)
neuper@38011
   607
(assoc (vars'~~vals, cy'));
neuper@55279
   608
(*SOME (Free ("x", "Real.real")) : term option*)
neuper@38011
   609
	   val cy_ext = (free2str o the) (assoc (vars'~~vals, cy'))^"_"^ext;
neuper@38011
   610
               (*x_i*)
neuper@38011
   611
"-----------------continue step through code match_ags---";
neuper@38011
   612
	val cy' = map (cpy_nam pbt' oris') cy;
neuper@38011
   613
               (*[([1], "#Find", "solutions, [x_i"] (*as terms*) )]*)
neuper@38011
   614
"-------------------------------------step through end---";
neuper@38011
   615
neuper@38011
   616
case match_ags thy PATS AGS of
neuper@38011
   617
[(1, [1], "#Given", Const ("Descript.equality", _),
neuper@41922
   618
  [Const ("HOL.eq", _) $ (Const ("Groups.plus_class.plus", _) $
neuper@38011
   619
		Free ("x", _) $ Free ("1", _)) $ Free ("2", _)]),
neuper@38011
   620
 (2, [1], "#Given", Const ("Descript.solveFor", _), [Free ("x", _)]),
neuper@38011
   621
 (3, [1], "#Find", Const ("Descript.solutions", _), [Free ("x_i", _)])]
neuper@37906
   622
    => ()
neuper@38031
   623
  | _ => error "calchead.sml match_ags [univariate,equation,test]--";
neuper@38009
   624
neuper@38010
   625
"--------- regression test fun is_copy_named ------------";
neuper@38010
   626
"--------- regression test fun is_copy_named ------------";
neuper@38010
   627
"--------- regression test fun is_copy_named ------------";
neuper@38010
   628
val trm = (1, (2, @{term "v'i'"}));
neuper@38031
   629
if is_copy_named trm then () else error "regr. is_copy_named 1";
neuper@38010
   630
val trm = (1, (2, @{term "e_e"}));
neuper@38031
   631
if is_copy_named trm then error "regr. is_copy_named 2" else ();
neuper@38010
   632
val trm = (1, (2, @{term "L'''"}));
neuper@38031
   633
if is_copy_named trm then () else error "regr. is_copy_named 3";
neuper@38010
   634
neuper@38010
   635
(* out-comment 'structure CalcHead'...
neuper@38010
   636
val trm = (1, (2, @{term "v'i'"}));
neuper@38031
   637
if is_copy_named_generating trm then () else error "regr. is_copy_named";
neuper@38010
   638
val trm = (1, (2, @{term "L'''"}));
neuper@38031
   639
if is_copy_named_generating trm then error "regr. is_copy_named" else ();
neuper@38010
   640
*)
neuper@38011
   641
neuper@38011
   642
"--------- regr.test fun cpy_nam ------------------------";
neuper@38011
   643
"--------- regr.test fun cpy_nam ------------------------";
neuper@38011
   644
"--------- regr.test fun cpy_nam ------------------------";
neuper@38011
   645
(*data from above - match_ags, is_cp, cpy_nam +with EqSystem (!)-:*)
neuper@38011
   646
(*the model-pattern, is_copy_named are filter_out*)
neuper@38011
   647
pbt = [("#Given", (@{term "equality"}, @{term "e_e :: bool"})),
neuper@38011
   648
       ("#Given", (@{term "solveFor"}, @{term "v_v :: real"} ))];
neuper@38011
   649
(*the model specific for an example*)
neuper@38011
   650
oris = [([1], "#Given", @{term "equality"} , [str2term "x+1= 2"]),
neuper@38011
   651
	([1], "#Given", @{term "solveFor"} , [@{term "x :: real"} ])];
neuper@38011
   652
cy = [("#Find", (@{term "solutions"}, @{term "v_v'i' :: bool list"}))];
neuper@38011
   653
(*...all must be true*)
neuper@38011
   654
neuper@38011
   655
case cpy_nam pbt oris (hd cy) of 
neuper@38011
   656
    ([1], "#Find", Const ("Descript.solutions", _), [Free ("x_i", _)]) => ()
neuper@38031
   657
  | _ => error "calchead.sml regr.test cpy_nam-1-";
neuper@38011
   658
neuper@38011
   659
(*new data: cpy_nam without changing the name*)
neuper@38011
   660
@{term "equalities"}; type_of @{term "[x_1+1=2,x_2=0]"};
neuper@38011
   661
@{term "solveForVars"}; type_of @{term "[x_1,x_2]::real list"};
neuper@38011
   662
@{term "solution"}; type_of @{term "ss''' :: bool list"};
neuper@55279
   663
(*the model-pattern for ["LINEAR", "system"], is_copy_named are filter_out*)
neuper@38011
   664
val pbt = [("#Given", (@{term "equalities"}, @{term "e_s :: bool list"})),
neuper@38011
   665
       ("#Given", (@{term "solveForVars v_s"}, @{term "v_s :: bool list"} ))];
neuper@38011
   666
(*the model specific for an example*)
neuper@38011
   667
val oris = [([1], "#Given", @{term "equalities"} ,[str2term "[x_1+1=2,x_2=0]"]),
neuper@38011
   668
    ([1], "#Given", @{term "solveForVars"} , [@{term "[x_1,x_2]::real list"}])];
neuper@38011
   669
val cy = [("#Find", (@{term "solution"}, @{term "ss''' :: bool list"}))
neuper@38011
   670
        (*could be more than 1*)];
neuper@38011
   671
neuper@38011
   672
case cpy_nam pbt oris (hd cy) of
neuper@38011
   673
    ([1], "#Find", Const ("EqSystem.solution", _), [Free ("ss'''", _)]) => ()
neuper@38031
   674
  | _ => error "calchead.sml regr.test cpy_nam-2-";
neuper@38051
   675
neuper@38051
   676
"--------- check specify phase --------------------------";
neuper@38051
   677
"--------- check specify phase --------------------------";
neuper@38051
   678
"--------- check specify phase --------------------------";
neuper@38051
   679
(*val fmz = ["functionTerm (x^^^2 + 1)",*)
neuper@38051
   680
val fmz = ["functionTerm (x + 1)", 
neuper@38051
   681
	   "integrateBy x","antiDerivative FF"];
neuper@38051
   682
val (dI',pI',mI') =
neuper@38051
   683
  ("Integrate",["integrate","function"],
neuper@38051
   684
   ["diff","integration"]);
neuper@38051
   685
val p = e_pos'; val c = [];
neuper@38051
   686
"--- step 1 --";
neuper@38051
   687
val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
neuper@38051
   688
(*> val it = "--- step 1 --" : string
neuper@38051
   689
val f =
neuper@38051
   690
  Form'
neuper@38051
   691
   (PpcKF
neuper@38051
   692
    (0, EdUndef, 0, Nundef,
neuper@38051
   693
     (Problem [],
neuper@38051
   694
	      {Find = [], With = [], Given = [], Where = [], Relate = []})))
neuper@38051
   695
: mout
neuper@38051
   696
val nxt = ("Model_Problem", Model_Problem) : string * tac
neuper@38051
   697
val p = ([], Pbl) : pos'
neuper@38051
   698
val pt =
neuper@38051
   699
   Nd (PblObj
neuper@38051
   700
       {env = None, fmz =
neuper@38051
   701
       (["functionTerm (x^^^2 + 1)", "integrateBy x",
neuper@38051
   702
	 "antiDerivative FF"],
neuper@38058
   703
	("Integrate", ["integrate", "function"],
neuper@38051
   704
	 ["diff", "integration"])),
neuper@38051
   705
       loc =
neuper@38051
   706
       (Some (ScrState ([], [], None, Const ("empty", "'a"), Sundef, false)),
neuper@38051
   707
	None),
neuper@38051
   708
       cell = None, meth = [], spec = ("e_domID", ["e_pblID"], ["e_metID"]),
neuper@38051
   709
       probl = [], branch = TransitiveB,
neuper@38051
   710
       origin =
neuper@38051
   711
       ([(1, [1], "#Given",
neuper@55279
   712
	     Const ("Descript.functionTerm", "Real.real => Tools.una"),
neuper@38051
   713
	     [Const ("op +", 
neuper@55279
   714
		     "["Real.real, "Real.real] => "Real.real") $
neuper@38051
   715
		     (Const ("Atools.pow",
neuper@55279
   716
			     "["Real.real, "Real.real] => "Real.real") $
neuper@55279
   717
		     Free ("x", "Real.real") $ Free ("2", "Real.real")) $
neuper@55279
   718
		     Free ("1", "Real.real")]),
neuper@38051
   719
	 (2, [1], "#Given",
neuper@55279
   720
	     Const ("Integrate.integrateBy", "Real.real => Tools.una"),
neuper@55279
   721
	     [Free ("x", "Real.real")]),
neuper@38051
   722
	 (3, [1], "#Find",
neuper@55279
   723
	     Const ("Integrate.antiDerivative", "Real.real => Tools.una"),
neuper@55279
   724
	     [Free ("FF", "Real.real")])],
neuper@38058
   725
	("Integrate", ["integrate", "function"], ["diff", "integration"]),
neuper@38051
   726
	Const ("Integrate.Integrate",
neuper@55279
   727
	       "("Real.real, "Real.real) * => "Real.real") $
neuper@41972
   728
	       (Const ("Product_Type.Pair",
neuper@55279
   729
		       "["Real.real, "Real.real]
neuper@55279
   730
                                  => ("Real.real, "Real.real) *") $
neuper@38051
   731
		 (Const ("op +",
neuper@55279
   732
			 "["Real.real, "Real.real] => "Real.real") $
neuper@38051
   733
		     (Const ("Atools.pow",
neuper@55279
   734
			     "["Real.real, "Real.real] => "Real.real") $
neuper@55279
   735
		      Free ("x", "Real.real") $ Free ("2", "Real.real")) $
neuper@55279
   736
		     Free ("1", "Real.real")) $
neuper@55279
   737
		    Free ("x", "Real.real"))),
neuper@38051
   738
       ostate = Incomplete, result = (Const ("empty", "'a"), [])},
wneuper@59279
   739
       []) : ctree*)
neuper@38051
   740
"----- WN101007 worked until here (checked same as isac2002) ---";
wneuper@59253
   741
case nxt of ("Model_Problem", Model_Problem) => ()
wneuper@59253
   742
| _ => error "clchead.sml: check specify phase step 1";
neuper@38051
   743
"--- step 2 --";
neuper@38051
   744
val (p,_,f,nxt,_,pt) = me nxt p c pt; (*Florian: see response buffer, top*)
neuper@38051
   745
(*val it = "--- step 2 --" : string
neuper@38051
   746
val p = ([], Pbl) : pos'
neuper@38051
   747
val f =
neuper@38051
   748
   Form'
neuper@38051
   749
      (PpcKF
neuper@38051
   750
         (0, EdUndef, 0, Nundef,
neuper@38051
   751
            (Problem [],
neuper@38051
   752
               {Find = [Incompl "Integrate.antiDerivative"],
neuper@38051
   753
                  With = [],
neuper@38051
   754
                  Given = [Incompl "functionTerm", Incompl "integrateBy"],
neuper@38051
   755
                  Where = [],
neuper@38051
   756
                  Relate = []}))) : mout
neuper@38051
   757
val nxt = ("Add_Given", Add_Given "functionTerm (x ^^^ 2 + 1)") : tac'_
neuper@38051
   758
val pt =
neuper@38051
   759
   Nd (PblObj
neuper@38051
   760
       {env = None, fmz =
neuper@38051
   761
       (["functionTerm (x^^^2 + 1)", "integrateBy x",
neuper@38051
   762
	 "antiDerivative FF"],
neuper@38058
   763
	("Integrate", ["integrate", "function"],
neuper@38051
   764
	 ["diff", "integration"])),
neuper@38051
   765
       loc =
neuper@38051
   766
       (Some
neuper@38051
   767
	(ScrState ([], [], None, Const ("empty", "'a"), Sundef, false)),
neuper@38051
   768
	None),
neuper@38051
   769
       cell = None, meth = [], spec = 
neuper@38051
   770
       ("e_domID", ["e_pblID"], ["e_metID"]), probl =
neuper@38051
   771
       [(0, [], false, "#Given",
neuper@38051
   772
	    Inc ((Const ("Descript.functionTerm",
neuper@55279
   773
			 "Real.real => Tools.una"),[]),
neuper@38051
   774
		 (Const ("empty", "'a"), []))),
neuper@38051
   775
	(0, [], false, "#Given",
neuper@38051
   776
	    Inc ((Const ("Integrate.integrateBy",
neuper@55279
   777
			 "Real.real => Tools.una"),[]),
neuper@38051
   778
		 (Const ("empty", "'a"), []))),
neuper@38051
   779
	(0, [], false, "#Find",
neuper@38051
   780
	    Inc ((Const ("Integrate.antiDerivative",
neuper@55279
   781
			 "Real.real => Tools.una"),[]),
neuper@38051
   782
		 (Const ("empty", "'a"), [])))],
neuper@38051
   783
       branch = TransitiveB, origin =
neuper@38051
   784
       ([(1, [1], "#Given",
neuper@55279
   785
	     Const ("Descript.functionTerm", "Real.real => Tools.una"),
neuper@38051
   786
	     [Const ("op +",
neuper@55279
   787
		     "["Real.real, "Real.real] => "Real.real") $
neuper@38051
   788
	       (Const ("Atools.pow",
neuper@55279
   789
		       "["Real.real, "Real.real] => "Real.real") $
neuper@55279
   790
		      Free ("x", "Real.real") $ Free ("2", "Real.real")) $
neuper@55279
   791
		     Free ("1", "Real.real")]),
neuper@38051
   792
	 (2, [1], "#Given",
neuper@55279
   793
	     Const ("Integrate.integrateBy", "Real.real => Tools.una"),
neuper@55279
   794
	     [Free ("x", "Real.real")]),
neuper@38051
   795
	 (3, [1], "#Find",
neuper@55279
   796
	     Const ("Integrate.antiDerivative", "Real.real => Tools.una"),
neuper@55279
   797
	     [Free ("FF", "Real.real")])],
neuper@38058
   798
	("Integrate", ["integrate", "function"], ["diff", "integration"]),
neuper@38051
   799
	Const ("Integrate.Integrate",
neuper@55279
   800
	       "("Real.real, "Real.real) * => "Real.real") $
neuper@41972
   801
	   (Const ("Product_Type.Pair",
neuper@55279
   802
		   "["Real.real, "Real.real]
neuper@55279
   803
                         => ("Real.real, "Real.real) *") $
neuper@38051
   804
	     (Const ("op +",
neuper@55279
   805
		     "["Real.real, "Real.real] => "Real.real") $
neuper@38051
   806
		     (Const ("Atools.pow",
neuper@55279
   807
			     "["Real.real, "Real.real] => "Real.real") $
neuper@55279
   808
		     Free ("x", "Real.real") $ Free ("2", "Real.real")) $
neuper@55279
   809
		   Free ("1", "Real.real")) $
neuper@55279
   810
                        Free ("x", "Real.real"))),
neuper@38051
   811
       ostate = Incomplete, result = (Const ("empty", "'a"), [])},
wneuper@59279
   812
       []) : ctree*)
wneuper@59279
   813
"----- WN101007 ctree checked same as isac2002, diff. in nxt --- REPAIRED";
wneuper@59253
   814
case nxt of ("Add_Given", Add_Given "functionTerm (x + 1)") => ()
wneuper@59253
   815
| _ => error "clchead.sml: check specify phase step 2";
neuper@38051
   816
"--- step 3 --";
neuper@38051
   817
val (p,_,f,nxt,_,pt) = me nxt p c pt;
wneuper@59279
   818
"----- WN101008 ctree checked same as isac2002, diff. in nxt --- REPAIRED";
wneuper@59253
   819
case nxt of ("Add_Given", Add_Given "integrateBy x") => ()
wneuper@59253
   820
| _ => error "clchead.sml: check specify phase step 2";
neuper@42279
   821
neuper@42279
   822
"--------- check: fmz matches pbt -----------------------";
neuper@42279
   823
"--------- check: fmz matches pbt -----------------------";
neuper@42279
   824
"--------- check: fmz matches pbt -----------------------";
neuper@42279
   825
"101230 error *** nxt_add: EX itm. not(dat(itm)<=dat(ori))";
neuper@42279
   826
"the following fmz caused the above error";
neuper@42279
   827
val fmz = ["TERM (5*e + 6*f - 8*g - 9 - 7*e - 4*f + 10*g + 12)","normalform N"];
neuper@42279
   828
val pI = ["plus_minus","polynom","vereinfachen"];
neuper@42279
   829
neuper@42279
   830
"----- this fmz is transformed to this internal format (TERM --> Pure.term):";
neuper@42279
   831
val ([(1, [1], "#undef", _, [Const ("Pure.term", _ (*"'a \<Rightarrow> prop"*)) $ _]),
neuper@42279
   832
      (*#############################^^^^^^^^^ defined by Isabelle*)
neuper@55279
   833
      (2, [1], "#Find", Const ("Simplify.normalform", _ (*"Real.real \<Rightarrow> Tools.una"*)),
neuper@55279
   834
                            [Free ("N", _ (*"Real.real"*))])],
neuper@42279
   835
     _ ) = prep_ori fmz thy ((#ppc o get_pbt) pI);
neuper@42279
   836
"#undef means: the element with description TERM in fmz did not match ";
neuper@42279
   837
"with any element of pbl (fetched by pI), because there we have Simplify.Term";
neuper@42279
   838
"defined in Simplify.thy";
neuper@42279
   839
neuper@42279
   840
"So we try out how to create Simplify.Term:";
neuper@42279
   841
"----- trial 1";
neuper@42279
   842
val Const ("Pure.term", _) $ Free ("ttt", _) = str2term "TERM ttt";
neuper@42279
   843
"           ^^^^^^^^^ see above";
neuper@42279
   844
atomwy t;
neuper@42279
   845
neuper@42279
   846
"----- trial 2";
neuper@42279
   847
val Free ("term", _) $ Free ("ttt", _) = str2term "term ttt";
neuper@42279
   848
"   ^^^^^^^^^^^ means, that no appropriate Const has be found (descriptions are all Const !)";
neuper@42279
   849
atomwy t;
neuper@42279
   850
neuper@42279
   851
"----- trial 3";
neuper@42279
   852
val Const ("Simplify.Term", _) $ Free ("ttt", _) = str2term "Term ttt";
neuper@42279
   853
"           ^^^^^^^^^^^^^^ this is what in Simplify.thy has been defined ";
neuper@42279
   854
"                          and unsed in pbl [plus_minus,polynom,vereinfachen]";
neuper@42279
   855
atomwy t;
neuper@42279
   856
neuper@42279
   857
"----- so this is the correct fmz:";
neuper@42279
   858
val fmz = ["Term (5*e + 6*f - 8*g - 9 - 7*e - 4*f + 10*g + 12)","normalform N"];
neuper@42279
   859
val ([(1, [1], "#Given", Const ("Simplify.Term", _), [Const ("Groups.plus_class.plus", _) $ _ $ _]),
neuper@42279
   860
      (*########################^^^^^^^^^ defined in Simplify.thy*)
neuper@42279
   861
      (2, [1], "#Find", Const ("Simplify.normalform", _ ),
neuper@42279
   862
                            [Free ("N", _ )])],
neuper@42279
   863
     _ ) = prep_ori fmz thy ((#ppc o get_pbt) pI);
neuper@42279
   864
neuper@42279
   865
"----- we could have checked the pbl at the very beginning and compare with (internal) fmz:";
neuper@42279
   866
val [("#Given", (Const ("Simplify.Term", _), Free ("t_t", _))),
neuper@42279
   867
     ("#Find", (Const ("Simplify.normalform", _), Free ("n_n", _)))] = (#ppc o get_pbt) pI;
neuper@42279
   868
wneuper@59265
   869
"--------- fun typeless ---------------------------------";
wneuper@59265
   870
"--------- fun typeless ---------------------------------";
wneuper@59265
   871
"--------- fun typeless ---------------------------------";
wneuper@59265
   872
(*
wneuper@59265
   873
> val (SOME ct) = parse thy "max_relation (A=#2*a*b - a^^^#2)";
wneuper@59265
   874
> val (_,t1) = split_dsc_t hs (Thm.term_of ct);
wneuper@59265
   875
> val (SOME ct) = parse thy "A=#2*a*b - a^^^#2";
wneuper@59265
   876
> val (_,t2) = split_dsc_t hs (Thm.term_of ct);
wneuper@59265
   877
> typeless t1 = typeless t2;
wneuper@59265
   878
val it = true : bool
wneuper@59265
   879
*)
wneuper@59265
   880
"--------- fun variants_in ------------------------------";
wneuper@59265
   881
"--------- fun variants_in ------------------------------";
wneuper@59265
   882
"--------- fun variants_in ------------------------------";
wneuper@59265
   883
(*
wneuper@59265
   884
> cnt (op=) [2,2,2,4,5,5,5,5,5] 2 0;
wneuper@59265
   885
val it = ([3],[4,5,5,5,5,5]) : int list * int list
wneuper@59265
   886
> coll (op=) [] [1,2,2,2,4,5,5,5,5,5];
wneuper@59265
   887
val it = [1,3,1,5] : int list
wneuper@59265
   888
*)
wneuper@59265
   889
"--------- fun tag_form ---------------------------------";
wneuper@59265
   890
"--------- fun tag_form ---------------------------------";
wneuper@59265
   891
"--------- fun tag_form ---------------------------------";
wneuper@59265
   892
(* val formal = (the o (parse thy)) "[R::real]";
wneuper@59265
   893
> val given = (the o (parse thy)) "fixed_values (cs::real list)";
wneuper@59265
   894
> tag_form thy (formal, given);
wneuper@59265
   895
val it = "fixed_values [R]" : cterm
wneuper@59265
   896
*)
wneuper@59265
   897
"--------- fun foldr1, foldl1 ---------------------------";
wneuper@59265
   898
"--------- fun foldr1, foldl1 ---------------------------";
wneuper@59265
   899
"--------- fun foldr1, foldl1 ---------------------------";
wneuper@59265
   900
(*
wneuper@59265
   901
> val (SOME ct) = parse thy "[a=b,c=d,e=f]";
wneuper@59265
   902
> val ces = map (Thm.global_cterm_of thy) (isalist2list (Thm.term_of ct));
wneuper@59265
   903
> val conj = foldr1 HOLogic.mk_conj (isalist2list (Thm.term_of ct));
wneuper@59265
   904
> Thm.global_cterm_of thy conj;
wneuper@59265
   905
val it = "(a = b & c = d) & e = f" : cterm
wneuper@59265
   906
*)
wneuper@59265
   907
(*
wneuper@59265
   908
> val (SOME ct) = parse thy "[a=b,c=d,e=f,g=h]";
wneuper@59265
   909
> val ces = map (Thm.global_cterm_of thy) (isalist2list (Thm.term_of ct));
wneuper@59265
   910
> val conj = foldl1 HOLogic.mk_conj (isalist2list (Thm.term_of ct));
wneuper@59265
   911
> Thm.global_cterm_of thy conj;
wneuper@59265
   912
val it = "a = b & c = d & e = f & g = h" : cterm
wneuper@59265
   913
*)