test/Tools/isac/Interpret/calchead.sml
author Walther Neuper <wneuper@ist.tugraz.at>
Thu, 20 Oct 2016 10:26:29 +0200
changeset 59253 f0bb15a046ae
parent 59248 5eba5e6d5266
child 59265 ee68ccda7977
permissions -rw-r--r--
simplify handling of theorems

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