test/Tools/isac/Interpret/calchead.sml
author Walther Neuper <neuper@ist.tugraz.at>
Thu, 11 Jul 2013 16:58:31 +0200
changeset 48895 35751d90365e
parent 48894 1920135f13c9
child 52101 c3f399ce32af
permissions -rw-r--r--
end of improving tests for isac on Isabelle2012

improvements:
# reactivated tests for error patterns, fill patterns
# reasons for outcommented test are given as much as possible,
see subsubsection {* State of tests *} in Test_Isac.thy
# detailed "Plans for updating isac from Isabelle2011 to Isabelle2012 and Isabelle2013"
in Build_Thydata.thy

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