test/Tools/isac/Knowledge/diff-app.sml
author wneuper <Walther.Neuper@jku.at>
Sun, 09 Oct 2022 07:44:22 +0200
changeset 60565 f92963a33fe3
parent 60549 c0a775618258
child 60571 19a172de0bb5
permissions -rw-r--r--
eliminate term2str in test/*
Walther@60458
     1
(* tests for IsacKnowledge/Diff_App
neuper@37906
     2
   author Walther Neuper 000301
neuper@37906
     3
   (c) due to copyright terms
neuper@37906
     4
neuper@37906
     5
   use"../smltest/IsacKnowledge/diffapp.sml";
neuper@37906
     6
   use"diffapp.sml";
neuper@37906
     7
*)
neuper@37906
     8
neuper@37906
     9
"Contents----------------------------------------------";
neuper@37906
    10
"              Specify_Problem (match_itms_oris)       ";
neuper@37906
    11
"              test specify, fmz <> []                  ";
neuper@37906
    12
"              test specify, fmz = []                  ";
neuper@37906
    13
"          problemtypes + formalizations               ";
wneuper@59279
    14
"-------------------- ctree of {(a,b). is-max ... ----------------";
neuper@37906
    15
"--------- me .. scripts for maximum-example ---------------------";
neuper@37906
    16
"--------- autoCalc .. scripts for maximum-example ---------------";
neuper@37906
    17
walther@59801
    18
"--------------------- 30.4.03: maximum .. rewrite_set_ prog_expr ---------";
neuper@37906
    19
"---------------------- 1.5.03: Make_fun_by_explicit ---------------------";
neuper@37906
    20
"---------------------- 2.5.03: Make_fun_by_new_variable -----------------";
neuper@37906
    21
neuper@37906
    22
neuper@37906
    23
neuper@37906
    24
neuper@37906
    25
neuper@37906
    26
" #################################################### ";
neuper@37906
    27
"          problemtypes + formalizations               ";
neuper@37906
    28
" #################################################### ";
neuper@37906
    29
" -------------- [maximum_of,function] --------------- ";
neuper@37906
    30
val pbt = 
walther@59997
    31
    ["fixedValues f_ix", "maximum m_m", "valuesFor v_s", "relations r_s"];
t@42195
    32
(*=== inhibit exn 110722=============================================================
neuper@37906
    33
map (the o (parseold thy)) pbt;
t@42195
    34
=== inhibit exn 110722=============================================================*)
neuper@37906
    35
val fmz =
walther@59997
    36
    ["fixedValues [r=Arbfix]", "maximum A",
neuper@37906
    37
     "valuesFor [a,b]",
walther@60242
    38
     "relations [A=a*b, (a/2) \<up> 2 + (b/2) \<up> 2 = r \<up> 2]",
walther@60242
    39
     "relations [A=a*b, (a/2) \<up> 2 + (b/2) \<up> 2 = r \<up> 2]",
wneuper@59582
    40
     "relations [A=a*b, a/2=r*sin alpha, b/2=r*cos (alpha::real)]",
neuper@37906
    41
walther@59997
    42
     "boundVariable a", "boundVariable b", "boundVariable alpha",
neuper@37906
    43
     "interval {x::real. 0 <= x & x <= 2*r}",
neuper@37906
    44
     "interval {x::real. 0 <= x & x <= 2*r}",
neuper@37906
    45
     "interval {x::real. 0 <= x & x <= pi}",
neuper@37906
    46
     "errorBound (eps=(0::real))"];
t@42195
    47
(*=== inhibit exn 110722=============================================================
neuper@37906
    48
map (the o (parseold thy)) fmz;
neuper@37906
    49
" -------------- [make,function] -------------- ";
t@42195
    50
=== inhibit exn 110722=============================================================*)
neuper@37906
    51
val pbt = 
walther@59997
    52
    ["functionOf f_f", "boundVariable v_v", "equalities eqs",
t@42195
    53
     "functionTerm f_0_0"];
t@42195
    54
(*=== inhibit exn 110722=============================================================
neuper@37906
    55
map (the o (parseold thy)) pbt;
neuper@37906
    56
val fmz12 =
walther@59997
    57
    ["functionOf A", "boundVariable a", "boundVariable b",
walther@60242
    58
     "equalities [A=a*b, (a/2) \<up> 2 + (b/2) \<up> 2 = r \<up> 2]",
neuper@37906
    59
     (*28.11.00: "functionTerm (A_0=Undef)"*)"functionTerm (Undef)"];
neuper@37906
    60
map (the o (parseold thy)) fmz12;
neuper@37906
    61
val fmz3 =
walther@59997
    62
    ["functionOf A", "boundVariable a", "boundVariable b",
neuper@37906
    63
     "equalities [A=a*b, a/2=r*sin alpha, b/2=r*cos alpha]",
neuper@37906
    64
     (*28.11.00: "functionTerm (A_0=Undef)"*)"functionTerm (Undef)"];
neuper@37906
    65
map (the o (parseold thy)) fmz3;
neuper@37906
    66
" --------- [univar,equation] --------- ";
neuper@37906
    67
val pbt = 
walther@59997
    68
    ["equality e_e", "solveFor v_v", "solutions v_i_i"];
neuper@37906
    69
map (the o (parseold thy)) pbt;
neuper@37906
    70
val fmz =
walther@60242
    71
    ["equality ((a/2) \<up> 2 + (b/2) \<up> 2 = r \<up> 2)",
walther@59997
    72
     "solveFor b", "solutions b_i"];
neuper@37906
    73
map (the o (parseold thy)) fmz;
neuper@37906
    74
" ---- [on_interval,maximum_of,function] ---- ";
neuper@37906
    75
val pbt = 
walther@59997
    76
    ["functionTerm t_t", "boundVariable v_v", "interval itv_v",
walther@59997
    77
     "errorBound err_r", "maxArgument v_0"];
neuper@37906
    78
map (the o (parseold thy)) pbt;
neuper@37906
    79
val fmz12 =
walther@60242
    80
    [(*28.11.00: "functionTerm (A_0 = a*sqrt(#4*r \<up> #2 - a \<up> #2))",*)
walther@60242
    81
     "functionTerm (a*sqrt(4*r \<up> 2 - a \<up> 2))",
walther@60242
    82
     (*28.11.00: "functionTerm (A_0 = b*sqrt(#4*r \<up> #2 - b \<up> #2))",*)
walther@60242
    83
     "functionTerm (b*sqrt(4*r \<up> 2 - b \<up> 2))",
walther@59997
    84
     "boundVariable a", "boundVariable b",
neuper@37906
    85
     "interval {x::real. 0 <= x & x <= 2*r}",
walther@59997
    86
     "errorBound (eps=0)", "maxArgument (a_0=Undef)"];
neuper@37906
    87
map (the o (parseold thy)) fmz12;
neuper@37906
    88
val fmz3 =
neuper@37906
    89
    [(*28.11.00: "functionTerm (A_0 = (#2*r*sin alpha)*(#2*r*cos alpha))",*)
neuper@37906
    90
     "functionTerm ((2*r*sin alpha)*(2*r*cos alpha))",
neuper@37906
    91
     "boundVariable alpha",
neuper@37906
    92
     "interval {x::real. 0 <= x & x <= pi}",
walther@59997
    93
     "errorBound (eps=0)", "maxArgument (a_0=Undef)"];
neuper@37906
    94
map (the o (parseold thy)) fmz3;
neuper@37906
    95
" --------- [derivative_of,function] --------- ";
neuper@37906
    96
val pbt = 
walther@59997
    97
    ["functionTerm f_f", "boundVariable v_v", "derivative f_f'"];
neuper@37906
    98
map (the o (parseold thy)) pbt;
neuper@37906
    99
val fmz =
walther@60242
   100
    [(*28.11.00: "functionTerm (A_0=a*#2*sqrt r \<up> #2 - (a//#2) \<up> #2)",*)
walther@60242
   101
     "functionTerm (a*2*sqrt r \<up> 2 - (a/2) \<up> 2)",
neuper@37906
   102
     "boundVariable a",
neuper@37906
   103
     (*28.11.00: "derivative (A_0'=Undef)"*)"derivative (Undef)"];
neuper@37906
   104
map (the o (parseold thy)) fmz;
neuper@37906
   105
" --------- [find_values,tool] --------- ";
neuper@37906
   106
val pbt = 
walther@59997
   107
    ["maxArgument ma_a", "functionTerm f_f", "boundVariable v_v",
walther@59997
   108
     "valuesFor vls_s", "additionalRels r_s"];
neuper@37906
   109
map (the o (parseold thy)) pbt;
neuper@37906
   110
val fmz1 =
neuper@37906
   111
    ["maxArgument (a_0=(srqt 2)*r)",
walther@60242
   112
     (*28.11.00: "functionTerm (A_0=a*#2*sqrt r \<up> #2 - (a//#2) \<up> #2)",*)
walther@60242
   113
     "functionTerm (a*2*sqrt r \<up> 2 - (a/2) \<up> 2)",
neuper@37906
   114
     "boundVariable a",
walther@59997
   115
     "valuesFor [a,b]", "maximum A",
walther@60242
   116
     "additionalRels [(a/2) \<up> 2 + (b/2) \<up> 2 = r \<up> 2]"];
neuper@37906
   117
map (the o (parseold thy)) fmz1;
neuper@37906
   118
t@42166
   119
=== inhibit exn 110722=============================================================*)
neuper@37906
   120
neuper@37906
   121
wneuper@59279
   122
"-------------------- ctree of {(a,b). is-max ... --------------------------";
wneuper@59279
   123
"-------------------- ctree of {(a,b). is-max ... --------------------------";
wneuper@59279
   124
"-------------------- ctree of {(a,b). is-max ... --------------------------";
neuper@37906
   125
neuper@37906
   126
(* --vvv-- ausgeliehen von test-root-equ/sml *)
walther@59846
   127
val loc = Istate.empty;
neuper@37906
   128
val (dI',pI',mI') =
walther@59997
   129
  ("Program",["sqroot-test", "univariate", "equation"],
walther@59997
   130
   ["Program", "squ-equ-test2"]);
neuper@37906
   131
val fmz = ["equality (sqrt(9+4*x)=sqrt x + sqrt(5+x))",
walther@59997
   132
	   "solveFor x", "errorBound (eps=0)",
neuper@37906
   133
	   "solutions L"];
neuper@37906
   134
(*
neuper@37906
   135
val (mI,m) = ("Init_Proof",Init_Proof (fmz, (dI',pI',mI')));
walther@59926
   136
val ((p,p_),_,_,_,_,(_,pt,_)) = CalcTreeTEST [fmz, (dI',pI',mI')))];
walther@60242
   137
 -- \<up> -- ausgeliehen von test-root-equ/sml *)
neuper@37906
   138
(*-------------- 9.6.03 --- cappend_ ... term -------irreparabler test
neuper@37906
   139
val (pt,_) = 
walther@59819
   140
  cappend_problem EmptyPtree [] loc ([],(dI',pI',mI'), .....);
neuper@37906
   141
val pos = (lev_on o lev_dn) [];
neuper@37906
   142
(* val pos = ([1]) *)
neuper@37906
   143
val (pt,_) = cappend_parent pt pos loc "{(a,b). is-max ..." 
neuper@37906
   144
    Empty_Tac TransitiveB;
neuper@37906
   145
val pos = (lev_on o lev_dn) pos;
neuper@37906
   146
(*val pos = ([1,1])*)
neuper@37906
   147
val (pt,_) = cappend_atomic pt pos loc "{(a,b). is-max ..." 
neuper@37906
   148
    Empty_Tac ("[1,1]:{(a,b). is-extremum ...",[]) Complete;
neuper@37906
   149
val pos = lev_on pos;
neuper@37906
   150
(*val pos = ([1,2])*)
neuper@37906
   151
val (pt,_) = cappend_atomic pt pos loc "{(a,b). is-extremum ..." 
neuper@37906
   152
    Empty_Tac ("[1,2]:{(a,b). f_x(a,b) ...",[]) Complete;
neuper@37906
   153
val pos = lev_up pos;
neuper@37906
   154
(*val pos = ([1])*)
walther@59846
   155
val (pt,_) = append_result pt pos Istate.empty ("[1#]:{(a,b). f_x(a,b) ...",[])
neuper@37906
   156
    Complete;
neuper@37906
   157
neuper@37906
   158
val pos = lev_on pos;
neuper@37906
   159
(*val pos = ([2]) *)
neuper@37906
   160
val (pt,_) = cappend_atomic pt pos loc "{(a,b). f_x(a,b) ..." 
neuper@37906
   161
    Empty_Tac ("[2]:{(a,b). f_x & f_xx &...",[]) Complete;
neuper@37906
   162
val pos = lev_on pos;
neuper@37906
   163
(*al pos = [3] : pos*)
neuper@37906
   164
val (pt,_) = cappend_parent pt pos loc "{(a,b). f_x & f_xx &..." 
neuper@37906
   165
    Empty_Tac TransitiveB;
neuper@37906
   166
val pos = (lev_on o lev_dn) pos;
neuper@37906
   167
(*pos = ([3,1]) *)
neuper@37906
   168
val (pt,_) = cappend_atomic pt pos loc "{(a,b). f_x & f_xx & ..." 
neuper@37906
   169
    Empty_Tac ("[3,1]:{(a,b). f_x & f_xx } cup ...",[]) Complete;
neuper@37906
   170
val pos = lev_on pos;
neuper@37906
   171
(*pos = ([3,2]) *)
neuper@37906
   172
val (pt,_) = cappend_atomic pt pos loc "{(a,b). f_x & f_xx } cup.."
neuper@37906
   173
    Empty_Tac ("[3,2]:{(a,b). f_x ..} cup ...",[]) Complete;
neuper@37906
   174
neuper@37906
   175
val pos = lev_up pos;
neuper@37906
   176
(*pos = ([3]) *)
walther@59846
   177
val (pt,_) = append_result pt pos Istate.empty ("[3#]:{(a,b). f_x ..} cup..",[])
neuper@37906
   178
    Complete;
neuper@37906
   179
val pos = lev_on pos;
neuper@37906
   180
(*val pos = [4] : pos *)
neuper@37906
   181
val (pt,_) = cappend_parent pt pos loc "{(a,b). f_x ..} cup ..." 
neuper@37906
   182
    Empty_Tac IntersectB;
neuper@37906
   183
val pos = (lev_on o lev_dn) pos;
neuper@37906
   184
(*val pos = ([4,1]) *)
neuper@37906
   185
val (pt,_) = cappend_parent pt pos loc "set_1 = ..." 
neuper@37906
   186
    Empty_Tac SequenceB;
neuper@37906
   187
neuper@37906
   188
neuper@37906
   189
val pos = (lev_on o lev_dn) pos;
neuper@37906
   190
(*val pos = ([4,1,1]) *)
walther@60242
   191
val (pt,_) = cappend_parent(*pbl*) pt pos loc"f_x = d/dx x \<up> 3 ..."
neuper@37906
   192
    Empty_Tac TransitiveB;
neuper@37906
   193
val pos = (lev_on o lev_dn) pos;
neuper@37906
   194
(*val pos = ([4,1,1,1]) *)
walther@60242
   195
val (pt,_) = cappend_parent pt pos loc "d/dx x \<up> 3 ..." 
neuper@37906
   196
    Empty_Tac TransitiveB;
neuper@37906
   197
val pos = (lev_on o lev_dn) pos;
neuper@37906
   198
(*val pos = ([4,1,1,1,1]) *)
walther@60242
   199
val (pt,_) = cappend_atomic pt pos loc "d/dx x \<up> 3 ..." 
walther@60242
   200
    Empty_Tac ("[4,1,1,1,1]:3x \<up> 2 + d/dx ...",[]) Complete;
neuper@37906
   201
val pos = lev_on pos;
neuper@37906
   202
(*val pos = ([4,1,1,1,2]) *)
walther@60242
   203
val (pt,_) = cappend_atomic pt pos loc "3x \<up> 2 + d/dx ..." 
walther@60242
   204
    Empty_Tac ("[4,1,1,1,2]:3x \<up> 2 + 0 + d/dx ...",[]) Complete;
neuper@37906
   205
val pos = lev_on pos;
neuper@37906
   206
(*pos = ([4,1,1,1,3]) *)
walther@60242
   207
val (pt,_) = cappend_atomic pt pos loc "3x \<up> 2 + 0 + d/dx ..." 
walther@60242
   208
    Empty_Tac ("[4,1,1,1,3]:3x \<up> 2 + 0 -3 ...",[]) Complete;
neuper@37906
   209
"--- 1 ---";
neuper@37906
   210
val pos = lev_up pos;
neuper@37906
   211
(*pos = ([4,1,1,1]) *)
walther@60242
   212
val (pt,_) = append_result pt pos Istate.empty ("[4,1,1,1#]:3x \<up> 2 -3.",[])Complete;
neuper@37906
   213
"--- 2 ---";
neuper@37906
   214
val pos = lev_up pos;
neuper@37906
   215
(*val pos = ([4,1,1]) *)
walther@60242
   216
val (pt,_) = append_result pt pos Istate.empty ("[4,1,1#]:found 3x \<up> 2 -3 ...",[])
neuper@37906
   217
    Complete;
neuper@37906
   218
"--- 3 ---";
neuper@37906
   219
val pos = lev_on pos;
neuper@37906
   220
(*val pos = ([4,1,2]+) *)
walther@60242
   221
val (pt,_) = cappend_parent(*pbl*) pt pos loc "f_y = d/dy x \<up> 3 ..."
neuper@37906
   222
    Empty_Tac TransitiveB;
neuper@37906
   223
"--- 4 ---";
wneuper@59279
   224
writeln (pr_ctree pr_short pt);
neuper@37906
   225
neuper@37906
   226
(*
neuper@37906
   227
.    ----- pblobj -----
neuper@37906
   228
1.   {(a,b). is-max ...
neuper@37906
   229
1.1.   {(a,b). is-max ...
neuper@37906
   230
1.2.   {(a,b). is-extremum ...
neuper@37906
   231
2.   {(a,b). f_x(a,b) ...
neuper@37906
   232
3.   {(a,b). f_x & f_xx &...
neuper@37906
   233
3.1.   {(a,b). f_x & f_xx & ...
neuper@37906
   234
3.2.   {(a,b). f_x & f_xx } cup..
neuper@37906
   235
4.   {(a,b). f_x ..} cup ...
neuper@37906
   236
4.1.   set_1 = ...
walther@60242
   237
4.1.1.   f_x = d/dx x \<up> 3 ...
walther@60242
   238
4.1.1.1.   d/dx x \<up> 3 ...
walther@60242
   239
4.1.1.1.1.   d/dx x \<up> 3 ...
walther@60242
   240
4.1.1.1.2.   3x \<up> 2 + d/dx ...
walther@60242
   241
4.1.1.1.3.   3x \<up> 2 + 0 + d/dx ...
walther@60242
   242
4.1.2.   f_y = d/dy x \<up> 3 ...
neuper@37906
   243
  
neuper@37906
   244
 use"test-max-surf1.sml";
neuper@37906
   245
   *)
neuper@37906
   246
-------------- 9.6.03 --- cappend_ ... term -------irreparabler test---*)
neuper@37906
   247
neuper@37906
   248
neuper@37906
   249
"--------- me .. scripts for maximum-example ---------------------";
neuper@37906
   250
"--------- me .. scripts for maximum-example ---------------------";
neuper@37906
   251
"--------- me .. scripts for maximum-example ---------------------";
neuper@37906
   252
neuper@37906
   253
val fmz =
walther@59997
   254
    ["fixedValues [r=Arbfix]", "maximum A",
neuper@37906
   255
     "valuesFor [a,b]",
walther@60242
   256
     "relations [A=a*b, (a/2) \<up> 2 + (b/2) \<up> 2 = r \<up> 2]",
walther@60242
   257
     "relations [A=a*b, (a/2) \<up> 2 + (b/2) \<up> 2 = r \<up> 2]",
wneuper@59582
   258
     "relations [A=a*b, a/2=r*sin alpha, b/2=r*cos (alpha::real)]",
neuper@37906
   259
walther@59997
   260
     "boundVariable a", "boundVariable b", "boundVariable alpha",
neuper@37906
   261
     "interval {x::real. 0 <= x & x <= 2*r}",
neuper@37906
   262
     "interval {x::real. 0 <= x & x <= 2*r}",
neuper@37906
   263
     "interval {x::real. 0 <= x & x <= pi}",
neuper@37906
   264
     "errorBound (eps=(0::real))"];
neuper@37906
   265
val (dI',pI',mI') =
Walther@60458
   266
  ("Diff_App",["maximum_of", "function"],
Walther@60458
   267
   ["Diff_App", "max_by_calculus"]);
neuper@37906
   268
neuper@37906
   269
val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
t@42166
   270
(*=== inhibit exn 110722=============================================================
neuper@37906
   271
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37906
   272
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37906
   273
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37906
   274
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@38043
   275
val (p,_,f,nxt,_,pt) = (me nxt p c pt) handle e => OldGoals.print_exn e;
neuper@37906
   276
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37906
   277
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37906
   278
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37906
   279
val (p,_,f,nxt,_,pt) = me nxt p c pt;
Walther@60458
   280
case nxt of (_, Specify_Method ["Diff_App", "max_by_calculus"]) => ()
neuper@38031
   281
	  | _ => error "diffapp.sml: max-exp me, nxt = Specify_Method";
neuper@37906
   282
walther@59940
   283
val oris = fst3 (get_obj g_origin pt (fst p)); writeln(O_Model.to_string oris);
walther@59942
   284
val pits = get_obj g_pbl pt (fst p); writeln(I_Model.to_string ctxt pits);
neuper@37906
   285
neuper@37906
   286
val (p,_,f,nxt,_,pt) = me nxt p c pt;
walther@59942
   287
val mits = get_obj g_met pt (fst p); writeln(I_Model.to_string ctxt mits);
neuper@37906
   288
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37906
   289
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37906
   290
val (p,_,f,nxt,_,pt) = me nxt p c pt;
Walther@60458
   291
case nxt of (_,Apply_Method ["Diff_App", "max_by_calculus"] ) => ()
neuper@38031
   292
	  | _ => error "diffapp.sml: max-exp me, nxt = Apply_Method";
neuper@37906
   293
val (p,_,f,nxt,_,pt) = me nxt p c pt;
t@42166
   294
=== inhibit exn 110722=============================================================*)
neuper@37906
   295
walther@59845
   296
(*since 0508 Apply_Method does the 1st step, if NONE implicit_take -------------
Walther@60458
   297
(*val nxt = ("Subproblem",Subproblem ("Diff_App",["make", "function"]))*)
neuper@37906
   298
val (p,_,f,nxt,_,pt) = (me nxt p c pt) handle e => print_exn_G e;
walther@59997
   299
(*val nxt = ("Refine_Tacitly",Refine_Tacitly ["make", "function"])*)
neuper@37906
   300
val (p,_,f,nxt,_,pt) = me nxt p c pt;
walther@59997
   301
(*val nxt = ("Model_Problem",Model_Problem ["by_explicit", "make", "function"])*)
neuper@37906
   302
----------------------------------------------------------------------------*)
walther@59749
   303
case nxt of (Model_Problem(*["by_explicit", "make", "function"]*)) => ()
neuper@38031
   304
	  | _ => error "diffapp.sml: max-exp me, nxt = Model_Problem";
neuper@37906
   305
t@42166
   306
(*=== inhibit exn 110722=============================================================
neuper@37906
   307
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37906
   308
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37906
   309
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37906
   310
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37906
   311
val (p,_,f,nxt,_,pt) = me nxt p c pt;
t@42166
   312
=== inhibit exn 110722=============================================================*)
neuper@37906
   313
walther@59940
   314
val oris = fst3 (get_obj g_origin pt (fst p));writeln(O_Model.to_string oris);
walther@59942
   315
val pits = get_obj g_pbl pt (fst p);writeln(I_Model.to_string ctxt pits);
neuper@37906
   316
t@42166
   317
(*=== inhibit exn 110722=============================================================
neuper@37906
   318
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37906
   319
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37906
   320
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37906
   321
val (p,_,f,nxt,_,pt) = me nxt p c pt;
Walther@60458
   322
case nxt of (_, Apply_Method ["Diff_App", "make_fun_by_explicit"]) => ()
neuper@38031
   323
	  | _ => error "diffapp.sml: max-exp Apply_Method ([1], Met) ";
t@42166
   324
=== inhibit exn 110722=============================================================*)
neuper@37906
   325
walther@59990
   326
(*----since WN050901 (ie. corr. mathengine#nxt_specify_ ..Specify.find_next_step' Pbl->p_
neuper@37906
   327
we get at ...
neuper@37906
   328
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37906
   329
...
walther@59844
   330
### associate: Not_Associated m= Subproblem'  ,
neuper@37906
   331
 stac= Substitute
neuper@37906
   332
 [(b, (rhs o hd)
wneuper@59370
   333
       (Subproblem (thy, [normalise, polynomial, univariate, equation])))]
walther@60242
   334
 (hd (filterVar A [A = a * b, (a / 2) \<up> 2 + (b / 2) \<up> 2 = r \<up> 2]))
walther@59825
   335
*** tac_from_prog TODO: no match for Substitute
neuper@37906
   336
***  [(b, (rhs o hd)
wneuper@59370
   337
***        (Subproblem (thy, [normalise, polynomial, univariate, equation])))]
walther@60242
   338
***  (hd (filterVar A [A = a * b, (a / 2) \<up> 2 + (b / 2) \<up> 2 = r \<up> 2]))
neuper@37906
   339
Exception- ERROR raised
neuper@37906
   340
neuper@37906
   341
############################################################################
neuper@37906
   342
# presumerably didnt work before either, but not detected due to Emtpy_Tac #
neuper@37906
   343
############################################################################
neuper@37906
   344
Walther@60458
   345
(*val nxt = Subproblem ("Diff_App",["univariate", "equation"]))   *)
neuper@37906
   346
val (p,_,f,nxt,_,pt) = me nxt p c pt;
walther@59997
   347
(*val nxt = Refine_Tacitly ["univariate", "equation"])*)
neuper@37906
   348
walther@59940
   349
val oris = fst3 (get_obj g_origin pt (fst p));writeln(O_Model.to_string oris);
walther@59942
   350
val pits = get_obj g_pbl pt (fst p);writeln(I_Model.to_string ctxt pits);
neuper@37906
   351
neuper@37906
   352
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37906
   353
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37906
   354
val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37906
   355
val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37906
   356
val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
walther@59997
   357
(*val nxt = ("Apply_Method",Apply_Method ["PolyEq", "normalise_poly"])*)
neuper@37906
   358
neuper@37906
   359
val (p,_,f,nxt,_,pt) = me nxt p c pt;
walther@59959
   360
(*val f = Form' (Test_Out.FormKF (~1,EdUndef,3,Nundef,"A = a * b"))*)
neuper@37906
   361
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37906
   362
val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37906
   363
val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37906
   364
val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37906
   365
val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37906
   366
val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37906
   367
val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37906
   368
val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
walther@59959
   369
(*val f = Form' (Test_Out.FormKF (~1,EdUndef,4,Nundef,"[b = A / a]"))*)
neuper@37906
   370
neuper@37906
   371
------------------------------------------------------------------------*)
neuper@37906
   372
neuper@37906
   373
(*val f =
neuper@37906
   374
Error' (Error_ "Refine_Tacitly [\"univariate\",\"equation\"] not applicable")*)
neuper@37906
   375
neuper@37906
   376
t@42166
   377
(*----postponed.15.5.03 run scripts for maximum-example: univariate equation*)
t@42166
   378
(*=== inhibit exn 110722=============================================================
neuper@37906
   379
neuper@38043
   380
val (p,_,f,nxt,_,pt) = (me nxt p c pt) handle e => OldGoals.print_exn e; 
t@42166
   381
=== inhibit exn 110722=============================================================*)
neuper@37906
   382
walther@59940
   383
val oris = fst3 (get_obj g_origin pt (fst p));writeln(O_Model.to_string oris);
neuper@37906
   384
walther@59942
   385
val pits = get_obj g_pbl pt (fst p);writeln(I_Model.to_string ctxt pits);
walther@59942
   386
val pits = get_obj g_pbl pt [];writeln(I_Model.to_string ctxt pits);
neuper@37906
   387
walther@59942
   388
val mits = get_obj g_met pt (fst p);writeln(I_Model.to_string ctxt mits);
walther@59942
   389
val mits = get_obj g_met pt [];writeln(I_Model.to_string ctxt mits);
neuper@37906
   390
t@42166
   391
(*=== inhibit exn 110722=============================================================
Walther@60458
   392
arguments_from_model ["Diff_App", "max_by_calculus"] mits;
neuper@37906
   393
neuper@37906
   394
val (p,_,f,nxt,_,pt) = me nxt p c pt;
t@42166
   395
=== inhibit exn 110722=============================================================*)
neuper@37906
   396
t@42166
   397
(*---*)
neuper@37906
   398
neuper@37906
   399
"--------- autoCalc .. scripts for maximum-example ---------------";
neuper@37906
   400
"--------- autoCalc .. scripts for maximum-example ---------------";
neuper@37906
   401
"--------- autoCalc .. scripts for maximum-example ---------------";
walther@59988
   402
(*++++++++ see systest/inform.sml 'I_Model.complete' ++++++++*)
Walther@60549
   403
 States.reset ();
neuper@37906
   404
val fmz =
walther@59997
   405
    ["fixedValues [r=Arbfix]", "maximum A",
neuper@37906
   406
     "valuesFor [a,b]",
walther@60242
   407
     "relations [A=a*b, (a/2) \<up> 2 + (b/2) \<up> 2 = r \<up> 2]",
walther@60242
   408
     "relations [A=a*b, (a/2) \<up> 2 + (b/2) \<up> 2 = r \<up> 2]",
wneuper@59582
   409
     "relations [A=a*b, a/2=r*sin alpha, b/2=r*cos (alpha::real)]",
neuper@37906
   410
walther@59997
   411
     "boundVariable a", "boundVariable b", "boundVariable alpha",
neuper@37906
   412
     "interval {x::real. 0 <= x & x <= 2*r}",
neuper@37906
   413
     "interval {x::real. 0 <= x & x <= 2*r}",
neuper@37906
   414
     "interval {x::real. 0 <= x & x <= pi}",
neuper@37906
   415
     "errorBound (eps=(0::real))"];
neuper@37906
   416
val (dI',pI',mI') =
Walther@60458
   417
  ("Diff_App",["maximum_of", "function"],
Walther@60458
   418
   ["Diff_App", "max_by_calculus"]);
neuper@37906
   419
neuper@37906
   420
 CalcTree [(fmz, (dI',pI',mI'))];
neuper@37906
   421
 Iterator 1; moveActiveRoot 1;
wneuper@59248
   422
 autoCalculate 1 CompleteCalcHead;
Walther@60549
   423
 refFormula 1 (States.get_pos 1 1); 
neuper@37906
   424
neuper@37906
   425
 fetchProposedTactic 1;
walther@60262
   426
(*autoCalculate 1 (Steps 1);
walther@60262
   427
    broken in child of.1790e1073acc : eliminate "handle _ => ..." from Rewrite.rewrite
walther@60262
   428
    this test is not up to date
walther@60262
   429
    ERROR exception TERM raised (line 359 of "term.ML"): fastype_of: Bound B.0*)
neuper@37906
   430
neuper@37906
   431
 fetchProposedTactic 1;
walther@60262
   432
(*autoCalculate 1 (Steps 1);
walther@60262
   433
    broken in child of.1790e1073acc : eliminate "handle _ => ..." from Rewrite.rewrite
walther@60262
   434
    this test is not up to date
walther@60262
   435
    ERROR exception TERM raised (line 359 of "term.ML"): fastype_of: Bound B.0*)
neuper@37906
   436
 (*Subproblem on_interval maximum_of function*)
wneuper@59248
   437
 autoCalculate 1 CompleteCalcHead;
neuper@37906
   438
neuper@37906
   439
 fetchProposedTactic 1;
Walther@60549
   440
 val ((pt,p),_) = States.get_calc 1;
neuper@37906
   441
 val mits = get_obj g_met pt (fst p);
walther@59942
   442
 writeln (I_Model.to_string ctxt mits);
neuper@37906
   443
(*
walther@59942
   444
 if I_Model.to_string ctxt mits = "[\n(1 ,[1] ,true ,#Given ,Cor functionEq (hd r_s) ,(t_, [hd r_s])),\n(2 ,[1] ,true ,#Given ,Cor boundVariable v_v ,(v_, [v_])),\n(3 ,[1] ,true ,#Given ,Cor interval itv_ ,(itv_, [itv_])),\n(4 ,[1] ,true ,#Find ,Cor maxArgument v__0 ,(v_0, [v__0]))]" then ()
neuper@38031
   445
 else error "diffapp.sml: diff.behav. in autoCalc .. scripts for max 1";
neuper@37906
   446
*)
neuper@37906
   447
 (*FIXME: the environments contain identifers, and NOT values ?!?!?*)
neuper@37906
   448
(* WN051209 while extending 'fun step' for initac, this became better ...
walther@60242
   449
 if I_Model.to_string ctxt mits = "[\n(1 ,[1,2,3] ,true ,#Given ,Cor fixedValues [r = Arbfix] ,(f_ix, [[r = Arbfix]])),\n(2 ,[1,2,3] ,true ,#Find ,Cor maximum A ,(m_, [A])),\n(3 ,[1,2,3] ,true ,#Find ,Cor valuesFor [a, b] ,(v_s, [[a],[b]])),\n(4 ,[1,2] ,true ,#Relate ,Cor relations [A = a * b, (a / 2) \<up> 2 + (b / 2) \<up> 2 = r \<up> 2] ,(r_s, [[A = a * b],[(a / 2) \<up> 2 + (b / 2) \<up> 2 = r \<up> 2]])),\n(6 ,[1] ,true ,#undef ,Cor boundVariable a ,(v_, [a])),\n(9 ,[1,2] ,true ,#undef ,Cor interval {x. 0 <= x & x <= 2 * r} ,(itv_, [{x. 0 <= x & x <= 2 * r}])),\n(11 ,[1,2,3] ,true ,#undef ,Cor errorBound (eps = 0) ,(err_, [eps = 0]))]" then ()
neuper@38031
   450
 else error "diffapp.sml: diff.behav. in autoCalc .. scripts for max 1";
neuper@37906
   451
*)
neuper@37906
   452
neuper@37906
   453
neuper@37906
   454
walther@59801
   455
"--------------------- 30.4.03: maximum .. rewrite_set_ prog_expr ---------";
walther@59801
   456
"--------------------- 30.4.03: maximum .. rewrite_set_ prog_expr ---------";
walther@59801
   457
"--------------------- 30.4.03: maximum .. rewrite_set_ prog_expr ---------";
Walther@60565
   458
TermC.parse_test @{context}
wneuper@59585
   459
  "Program Maximum_value(f_ix::bool list)(m_m::real) (r_s::bool list)\
t@42203
   460
   \      (v_v::real) (itv_v::real set) (err_r::bool) =          \ 
t@42203
   461
   \ (let e_e = (hd o (filterVar m_m)) r_s;              \
t@42203
   462
   \      t_t = (if 1 < length_h r_s                            \
t@42203
   463
   \           then (SubProblem (Reals_s,[make,function],[no_met])\
t@42203
   464
   \                     [REAL m_m, REAL v_v, BOOL_LIST r_s])\
neuper@37995
   465
   \           else (hd r_s));                                \
t@42203
   466
   \      (mx_x::real) = SubProblem (Reals_s,[on_interval,max_of,function], \
neuper@37906
   467
   \                                [Isac,maximum_on_interval])\
t@42203
   468
   \                               [BOOL t_t, REAL v_v, REAL_SET itv_v]\
t@42203
   469
   \ in ((SubProblem (Reals_s,[find_values,tool],[Isac,find_values])   \
t@42203
   470
   \      [REAL mx_x, REAL (Rhs t_t), REAL v_v, REAL m_m,     \
neuper@37995
   471
   \       BOOL_LIST (dropWhile (ident e_e) r_s)])::bool list))";
neuper@37906
   472
Walther@60565
   473
val f_ix = (TermC.parse_test @{context} "f_ix::bool list", 
Walther@60565
   474
	    TermC.parse_test @{context} "[r=Arbfix]");
Walther@60565
   475
val m_m   = (TermC.parse_test @{context} "m_m::real", 
Walther@60565
   476
	    TermC.parse_test @{context} "A");
Walther@60565
   477
val r_s  = (TermC.parse_test @{context} "rs_s::bool list", 
Walther@60565
   478
	    TermC.parse_test @{context} "[A = a*b, (a/2) \<up> 2 + (b/2) \<up> 2 = r \<up> 2]");
Walther@60565
   479
val v_v   = (TermC.parse_test @{context} "v_v::real", 
Walther@60565
   480
	    TermC.parse_test @{context} "b");
Walther@60565
   481
val itv_v = (TermC.parse_test @{context} "itv_v::real set", 
Walther@60565
   482
	    TermC.parse_test @{context} "{x::real. 0 <= x & x <= 2*r}");
Walther@60565
   483
val err_r = (TermC.parse_test @{context} "err_r::bool", 
Walther@60565
   484
	    TermC.parse_test @{context} "eps=0");
t@42204
   485
val env = [f_ix, m_m, r_s ,v_v, itv_v, err_r];
neuper@37906
   486
neuper@37906
   487
(*--- 1.line in script ---*)
Walther@60565
   488
val t = TermC.parse_test @{context} "(hd o (filterVar m_m)) (r_s::bool list)";
neuper@37906
   489
val s = subst_atomic env t;
walther@59868
   490
UnparseC.term s;
walther@60242
   491
"(hd o filterVar A) [A = a * b, (a / 2) \<up> 2 + (b / 2) \<up> 2 = r \<up> 2]";
t@42204
   492
(*=== inhibit exn 110726=============================================================
walther@59801
   493
val SOME (s',_) = rewrite_set_ thy false prog_expr s;
walther@59868
   494
val s'' = UnparseC.term s';
walther@59801
   495
if s''="A = a * b" then () else error "new behaviour with prog_expr 1.1.";
t@42204
   496
=== inhibit exn 110726=============================================================*)
Walther@60565
   497
val env = env @ [(TermC.parse_test @{context} "e_e::bool",TermC.parse_test @{context} "A = a * b")];
neuper@37906
   498
neuper@37906
   499
(*--- 2.line: condition alone ---*)
Walther@60565
   500
val t = TermC.parse_test @{context} "1 < length_h (r_s::bool list)";
neuper@37906
   501
val s = subst_atomic env t;
walther@59868
   502
UnparseC.term s;
walther@60242
   503
"1 < length_h [A = a * b, (a / 2) \<up> 2 + (b / 2) \<up> 2 = r \<up> 2]";
t@42204
   504
(*=== inhibit exn 110726=============================================================
walther@59801
   505
val SOME (s',_) = rewrite_set_ thy false prog_expr s;
walther@59868
   506
val s'' = UnparseC.term s';
wenzelm@60309
   507
if s''=\<^const_name>\<open>True\<close> then () else error "new behaviour with prog_expr 1.2.";
t@42204
   508
=== inhibit exn 110726=============================================================*)
neuper@37906
   509
neuper@37906
   510
(*--- 2.line in script ---*)
Walther@60565
   511
val t = TermC.parse_test @{context} 
t@42204
   512
	    "(if 1 < length_h r_s                            \
t@42204
   513
   \           then (SubProblem (Reals_s,[make,function],[no_met])\
t@42204
   514
   \                     [REAL m_m, REAL v_v, BOOL_LIST r_s])\
neuper@37995
   515
   \           else (hd r_s))";
neuper@37906
   516
val s = subst_atomic env t;
walther@59868
   517
UnparseC.term s;
walther@60242
   518
"if 1 < length_h [A = a * b, (a / 2) \<up> 2 + (b / 2) \<up> 2 = r \<up> 2]\
t@42204
   519
\then SubProblem (Reals_s, [make, function], [no_met])\
neuper@37984
   520
\      [REAL A, REAL b,\
walther@60242
   521
\       BOOL_LIST [A = a * b, (a / 2) \<up> 2 + (b / 2) \<up> 2 = r \<up> 2]]\
walther@60242
   522
\else hd [A = a * b, (a / 2) \<up> 2 + (b / 2) \<up> 2 = r \<up> 2]";
t@42204
   523
(*=== inhibit exn 110726=============================================================
walther@59801
   524
val SOME (s',_) = rewrite_set_ thy false prog_expr s;
walther@59868
   525
val s'' = UnparseC.term s';
neuper@37906
   526
if s'' = 
t@42204
   527
"SubProblem (Reals_s, [make, function], [no_met])\n\
neuper@37984
   528
\ [REAL A, REAL b,\n\
walther@60242
   529
\  BOOL_LIST [A = a * b, (a / 2) \<up> 2 + (b / 2) \<up> 2 = r \<up> 2]]" then ()
walther@59801
   530
else error "new behaviour with prog_expr 1.3.";
t@42204
   531
=== inhibit exn 110726=============================================================*)
Walther@60565
   532
val env = env @ [(TermC.parse_test @{context} "t_t::bool",
Walther@60565
   533
		  TermC.parse_test @{context} "A = (2*sqrt(r \<up> 2-(b/2) \<up> 2)) * b")];
neuper@37906
   534
neuper@37906
   535
neuper@37906
   536
neuper@37906
   537
"---------------------- 1.5.03: Make_fun_by_explicit ---------------------";
neuper@37906
   538
"---------------------- 1.5.03: Make_fun_by_explicit ---------------------";
neuper@37906
   539
"---------------------- 1.5.03: Make_fun_by_explicit ---------------------";
Walther@60565
   540
TermC.parse_test @{context}
wneuper@59585
   541
   "Program Make_fun_by_explicit (f_f::real) (v_v::real)         \
neuper@37994
   542
   \      (eqs::bool list) =                                 \
t@42204
   543
   \ (let h_h  = (hd o (filterVar f_f)) eqs;                   \
t@42204
   544
   \      e_1 = hd (dropWhile (ident h_h) eqs);               \
t@42204
   545
   \      v_s = dropWhile (ident f_f) (Vars h_h);                \
neuper@37995
   546
   \      v_1 = hd (dropWhile (ident v_v) v_s);                \
t@42204
   547
   \      (s_1::bool list)=(SubProblem(Reals_s,[univar,equation],[no_met])\
neuper@37984
   548
   \                          [BOOL e_1, REAL v_1])\
t@42204
   549
   \ in Substitute [(v_1 = (rhs o hd) s_1)] h_h)";
Walther@60565
   550
val f_f = (TermC.parse_test @{context} "f_f::real", 
Walther@60565
   551
	  TermC.parse_test @{context} "A");
Walther@60565
   552
val v_v = (TermC.parse_test @{context} "v_v::real", 
Walther@60565
   553
	  TermC.parse_test @{context} "b");
Walther@60565
   554
val eqs=(TermC.parse_test @{context} "eqs::bool list", 
Walther@60565
   555
	  TermC.parse_test @{context} "[A = a * b, (a / 2) \<up> 2 + (b / 2) \<up> 2 = r \<up> 2]");
neuper@37994
   556
val env = [f_f, v_v, eqs];
neuper@37906
   557
neuper@37906
   558
(*--- 1.line in script ---*)
Walther@60565
   559
val t = TermC.parse_test @{context} "(hd o (filterVar v_v)) (eqs::bool list)";
neuper@37906
   560
val s = subst_atomic env t;
walther@59868
   561
UnparseC.term s;
Walther@60565
   562
val t = TermC.parse_test @{context} 
walther@60242
   563
     "(hd o filterVar b) [A = a * b, (a / 2) \<up> 2 + (b / 2) \<up> 2 = r \<up> 2]";
Walther@60500
   564
val SOME (t',_) = rewrite_set_ ctxt false prog_expr t;
walther@59868
   565
val s' = UnparseC.term t';
t@42204
   566
(*=== inhibit exn 110726=============================================================
walther@59801
   567
if s' = "A = a * b" then () else error "new behaviour with prog_expr 2.1";
t@42204
   568
=== inhibit exn 110726=============================================================*)
Walther@60565
   569
val env = env @ [(TermC.parse_test @{context} "h_h::bool", TermC.parse_test @{context} s')];
neuper@37906
   570
neuper@37906
   571
(*--- 2.line in script ---*)
Walther@60565
   572
val t = TermC.parse_test @{context} "hd (dropWhile (ident h_h) (eqs::bool list))";
neuper@37906
   573
val s = subst_atomic env t;
walther@59868
   574
UnparseC.term s;
Walther@60565
   575
val t = TermC.parse_test @{context} 
neuper@37906
   576
	    "hd (dropWhile (ident (A = a * b))\
walther@60242
   577
	    \     [A = a * b, (a / 2) \<up> 2 + (b / 2) \<up> 2 = r \<up> 2])";
t@42204
   578
(*=== inhibit exn 110726=============================================================
walther@59801
   579
mem_rls "dropWhile_Cons" prog_expr;
walther@59801
   580
mem_rls "Prog_Expr.ident" prog_expr;
walther@59801
   581
val SOME (t',_) = rewrite_set_ thy false prog_expr t;
walther@59868
   582
val s' = UnparseC.term t';
walther@60242
   583
if s' = "(a / 2) \<up> 2 + (b / 2) \<up> 2 = r \<up> 2" then () 
walther@59801
   584
else error "new behaviour with prog_expr 2.2";
t@42204
   585
=== inhibit exn 110726=============================================================*)
Walther@60565
   586
val env = env @ [(TermC.parse_test @{context} "e_1::bool", TermC.parse_test @{context} s')];
neuper@37906
   587
neuper@37906
   588
(*--- 3.line in script ---*)
Walther@60565
   589
val t = TermC.parse_test @{context} "dropWhile (ident f_f) (Vars (h_h::bool))";
neuper@37906
   590
val s = subst_atomic env t;
walther@59868
   591
UnparseC.term s;
Walther@60565
   592
val t = TermC.parse_test @{context} "dropWhile (ident A) (Vars (A = a * b))";
t@42204
   593
(*=== inhibit exn 110726=============================================================
walther@59801
   594
val SOME (t',_) = rewrite_set_ thy false prog_expr t;
walther@59868
   595
val s' = UnparseC.term t';
walther@59801
   596
if s' = "[a, b]" then () else error "new behaviour with prog_expr 2.3";
t@42204
   597
=== inhibit exn 110726=============================================================*)
Walther@60565
   598
val env = env @ [(TermC.parse_test @{context} "vs_s::real list", TermC.parse_test @{context} s')];
neuper@37906
   599
neuper@37906
   600
(*--- 4.line in script ---*)
Walther@60565
   601
val t = TermC.parse_test @{context} "hd (dropWhile (ident v_v) v_s)";
neuper@37906
   602
val s = subst_atomic env t;
walther@59868
   603
UnparseC.term s;
Walther@60565
   604
val t = TermC.parse_test @{context} "hd (dropWhile (ident b) [a, b])";
t@42204
   605
(*=== inhibit exn 110726=============================================================
walther@59801
   606
val SOME (t',_) = rewrite_set_ thy false prog_expr t;
walther@59868
   607
val s' = UnparseC.term t';
walther@59801
   608
if s' = "a" then () else error "new behaviour with prog_expr 2.4.";
t@42204
   609
=== inhibit exn 110726=============================================================*)
Walther@60565
   610
val env = env @ [(TermC.parse_test @{context} "v_1::real", TermC.parse_test @{context} s')];
neuper@37906
   611
neuper@37906
   612
(*--- 5.line in script ---*)
Walther@60565
   613
val t = TermC.parse_test @{context} "(SubProblem(Reals_s,[univar,equation],[no_met])\
neuper@37984
   614
		 \           [BOOL e_1, REAL v_1])";
neuper@37906
   615
val s = subst_atomic env t;
walther@59868
   616
UnparseC.term s;
t@42204
   617
"SubProblem (Reals_s, [univar, equation], [no_met])\n\
walther@60242
   618
\ [BOOL ((a / 2) \<up> 2 + (b / 2) \<up> 2 = r \<up> 2), REAL a]";
Walther@60565
   619
val env = env @ [(TermC.parse_test @{context} "s_1::bool list", 
Walther@60565
   620
		  TermC.parse_test @{context} "[a = 2 * sqrt (r \<up> 2 - (b/2) \<up> 2)]")];
neuper@37906
   621
neuper@37906
   622
(*--- 6.line in script ---*)
Walther@60565
   623
val t = TermC.parse_test @{context} "Substitute [(v_1 = (rhs o hd) (s_1::bool list))] (h_h::bool)";
neuper@37906
   624
val s = subst_atomic env t;
walther@59868
   625
UnparseC.term s;
Walther@60565
   626
val t = TermC.parse_test @{context} 
walther@60242
   627
"Substitute [(a = (rhs o hd) [a = 2 * sqrt (r \<up> 2 - (b / 2) \<up> 2)])]\n\
neuper@37906
   628
\ (A = a * b)";
t@42204
   629
(*=== inhibit exn 110726=============================================================
walther@59801
   630
mem_rls "Prog_Expr.rhs" prog_expr;
walther@59801
   631
val SOME (t',_) = rewrite_set_ thy false prog_expr t;
walther@59868
   632
val s' = UnparseC.term t';
walther@60242
   633
if s' = "Substitute [a = 2 * sqrt (r \<up> 2 - (b / 2) \<up> 2)] (A = a * b)" 
walther@59801
   634
then () else error "new behaviour with prog_expr 2.6.";
t@42204
   635
=== inhibit exn 110726=============================================================*)
neuper@37906
   636
neuper@37906
   637
neuper@37906
   638
"---------------------- 2.5.03: Make_fun_by_new_variable -----------------";
neuper@37906
   639
"---------------------- 2.5.03: Make_fun_by_new_variable -----------------";
neuper@37906
   640
"---------------------- 2.5.03: Make_fun_by_new_variable -----------------";
Walther@60565
   641
TermC.parse_test @{context}
wneuper@59585
   642
  "Program Make_fun_by_new_variable (f_f::real) (v_v::real)     \
neuper@37994
   643
   \      (eqs::bool list) =                                 \
t@42204
   644
   \(let h_h = (hd o (filterVar f_f)) eqs;             \
t@42204
   645
   \     es_s = dropWhile (ident h_h) eqs;                    \
t@42204
   646
   \     v_s = dropWhile (ident f_f) (Vars h_h);                \
t@42204
   647
   \     v_1 = nth_h 1 v_s;                                   \
t@42204
   648
   \     v_2 = nth_h 2 v_s;                                   \
t@42204
   649
   \     e_1 = (hd o (filterVar v_1)) es_s;            \
t@42204
   650
   \     e_2 = (hd o (filterVar v_2)) es_s;            \
t@42204
   651
   \  (s_1::bool list) = (SubProblem (Reals_s,[univar,equation],[no_met])\
neuper@37984
   652
   \                    [BOOL e_1, REAL v_1]);\
t@42204
   653
   \  (s_2::bool list) = (SubProblem (Reals_s,[univar,equation],[no_met])\
neuper@37984
   654
   \                    [BOOL e_2, REAL v_2])\
t@42204
   655
   \in Substitute [(v_1 = (rhs o hd) s_1),(v_2 = (rhs o hd) s_2)] h_h)";
Walther@60565
   656
val f_ = (TermC.parse_test @{context} "f_f::real", 
Walther@60565
   657
	  TermC.parse_test @{context} "A");
Walther@60565
   658
val v_v = (TermC.parse_test @{context} "v_v::real", 
Walther@60565
   659
	  TermC.parse_test @{context} "alpha");
Walther@60565
   660
val eqs=(TermC.parse_test @{context} "eqs::bool list", 
Walther@60565
   661
	  TermC.parse_test @{context} "[A=a*b, a/2=r*sin alpha, b/2=r*cos (alpha::real)]");
neuper@37994
   662
val env = [f_f, v_v, eqs];
neuper@37906
   663
neuper@37906
   664
(*--- 1.line in script ---*)
Walther@60565
   665
val t = TermC.parse_test @{context} "(hd o (filterVar (f_f::real))) (eqs::bool list)";
neuper@37906
   666
val s = subst_atomic env t;
walther@59868
   667
UnparseC.term s;
Walther@60565
   668
val t = TermC.parse_test @{context} 
neuper@37906
   669
"(hd o filterVar A) [A = a * b, a / 2 = r * sin alpha, b / 2 = r * cos alpha]";
Walther@60500
   670
val SOME (t',_) = rewrite_set_ ctxt false prog_expr t;
walther@59868
   671
val s' = UnparseC.term t';
t@42204
   672
(*=== inhibit exn 110726=============================================================
walther@59801
   673
if s' = "A = a * b" then() else error "new behaviour with prog_expr 3.1.";
Walther@60565
   674
val env = env @ [(TermC.parse_test @{context} "h_h::bool", TermC.parse_test @{context} s')];
t@42204
   675
=== inhibit exn 110726=============================================================*)
neuper@37906
   676
neuper@37906
   677
(*--- 2.line in script ---*)
Walther@60565
   678
val t = TermC.parse_test @{context} "dropWhile (ident (h_h::bool)) (eqs::bool list)";
neuper@37906
   679
val s = subst_atomic env t;
walther@59868
   680
UnparseC.term s;
Walther@60565
   681
val t = TermC.parse_test @{context} 
neuper@37906
   682
"dropWhile (ident (A = a * b))\
neuper@37906
   683
\ [A = a * b, a / 2 = r * sin alpha, b / 2 = r * cos alpha]";
t@42204
   684
(*=== inhibit exn 110726=============================================================
walther@59801
   685
val SOME (t',_) = rewrite_set_ thy false prog_expr t;
walther@59868
   686
val s' = UnparseC.term t';
neuper@37906
   687
if s' = "[a / 2 = r * sin alpha, b / 2 = r * cos alpha]" 
walther@59801
   688
then () else error "new behaviour with prog_expr 3.2.";
t@42204
   689
=== inhibit exn 110726=============================================================*)
Walther@60565
   690
val env = env @ [(TermC.parse_test @{context} "es_s::bool list", TermC.parse_test @{context} s')];
neuper@37906
   691
neuper@37906
   692
(*--- 3.line in script ---*)
Walther@60565
   693
val t = TermC.parse_test @{context} "dropWhile (ident (f_f::real)) (Vars (h_h::bool))";
neuper@37906
   694
val s = subst_atomic env t;
walther@59868
   695
UnparseC.term s;
Walther@60565
   696
val t = TermC.parse_test @{context} "dropWhile (ident A) (Vars (A = a * b))";
t@42204
   697
(*=== inhibit exn 110726=============================================================
walther@59801
   698
val SOME (t',_) = rewrite_set_ thy false prog_expr t;
walther@59868
   699
val s' = UnparseC.term t';
walther@59801
   700
if s' = "[a, b]" then () else error "new behaviour with prog_expr 3.3.";
t@42204
   701
=== inhibit exn 110726=============================================================*)
Walther@60565
   702
val env = env @ [(TermC.parse_test @{context} "vs_s::real list", TermC.parse_test @{context} s')];
neuper@37906
   703
neuper@37906
   704
(*--- 4.line in script ---*)
Walther@60565
   705
val t = TermC.parse_test @{context} "nth_h 1 v_s";
neuper@37906
   706
val s = subst_atomic env t;
walther@59868
   707
UnparseC.term s;
Walther@60565
   708
val t = TermC.parse_test @{context} "nth_h 1 [a, b]";
t@42204
   709
(*=== inhibit exn 110726=============================================================
walther@59801
   710
val SOME (t',_) = rewrite_set_ thy false prog_expr t;
walther@59868
   711
val s' = UnparseC.term t';
walther@59801
   712
if s' = "a" then () else error "new behaviour with prog_expr 3.4.";
t@42204
   713
=== inhibit exn 110726=============================================================*)
Walther@60565
   714
val env = env @ [(TermC.parse_test @{context} "v_1", TermC.parse_test @{context} s')];
neuper@37906
   715
neuper@37906
   716
(*--- 5.line in script ---*)
Walther@60565
   717
val t = TermC.parse_test @{context} "nth_h 2 v_s";
neuper@37906
   718
val s = subst_atomic env t;
walther@59868
   719
UnparseC.term s;
Walther@60565
   720
val t = TermC.parse_test @{context} "nth_h 2 [a, b]";
t@42204
   721
(*=== inhibit exn 110726=============================================================
walther@59801
   722
val SOME (t',_) = rewrite_set_ thy false prog_expr t;
walther@59868
   723
val s' = UnparseC.term t';
walther@59801
   724
if s' = "b" then () else error "new behaviour with prog_expr 3.5.";
t@42204
   725
=== inhibit exn 110726=============================================================*)
Walther@60565
   726
val env = env @ [(TermC.parse_test @{context} "v_2", TermC.parse_test @{context} s')];
neuper@37906
   727
neuper@37906
   728
(*--- 6.line in script ---*)
Walther@60565
   729
val t = TermC.parse_test @{context} "(hd o (filterVar v_1)) (es_s::bool list)";
neuper@37906
   730
val s = subst_atomic env t;
walther@59868
   731
UnparseC.term s;
Walther@60565
   732
val t = TermC.parse_test @{context} 
neuper@37906
   733
	   "(hd o filterVar a) [a / 2 = r * sin alpha, b / 2 = r * cos alpha]";
Walther@60500
   734
val SOME (t',_) = rewrite_set_ ctxt false prog_expr t;
walther@59868
   735
val s' = UnparseC.term t';
t@42204
   736
(*=== inhibit exn 110726=============================================================
neuper@37906
   737
if s' = "a / 2 = r * sin alpha" then () 
walther@59801
   738
else error "new behaviour with prog_expr 3.6.";
t@42204
   739
=== inhibit exn 110726=============================================================*)
Walther@60565
   740
val e_1 = TermC.parse_test @{context} "e_1::bool";
Walther@60565
   741
val env = env @ [(e_1, TermC.parse_test @{context} s')];
neuper@37906
   742
neuper@37906
   743
(*--- 7.line in script ---*)
Walther@60565
   744
val t = TermC.parse_test @{context} "(hd o (filterVar v_2)) (es_s::bool list)";
neuper@37906
   745
val s = subst_atomic env t;
walther@59868
   746
UnparseC.term s;
Walther@60565
   747
val t = TermC.parse_test @{context} 
neuper@37906
   748
	  "(hd o filterVar b) [a / 2 = r * sin alpha, b / 2 = r * cos alpha]";
Walther@60500
   749
val SOME (t',_) = rewrite_set_ ctxt false prog_expr t;
walther@59868
   750
val s' = UnparseC.term t';
t@42204
   751
(*=== inhibit exn 110726=============================================================
neuper@37906
   752
if s' = "b / 2 = r * cos alpha" then () 
walther@59801
   753
else error "new behaviour with prog_expr 3.7.";
t@42204
   754
=== inhibit exn 110726=============================================================*)
Walther@60565
   755
val env = env @ [(TermC.parse_test @{context} "e_2::bool", TermC.parse_test @{context} s')];
neuper@37906
   756
neuper@37906
   757
(*--- 8.line in script ---*)
Walther@60565
   758
val t = TermC.parse_test @{context} "(SubProblem (Reals_s,[univar,equation],[no_met])\
neuper@37984
   759
		 \            [BOOL e_1, REAL v_1])";
neuper@37906
   760
val s = subst_atomic env t;
walther@59868
   761
UnparseC.term s;
t@42204
   762
"SubProblem (Reals_s, [univar, equation], [no_met])\
neuper@37984
   763
	    \ [BOOL (a / 2 = r * sin alpha), REAL a]";
Walther@60565
   764
val s_1 = TermC.parse_test @{context} "[a = 2*r*sin alpha]";
Walther@60565
   765
val env = env @ [(TermC.parse_test @{context} "s_1::bool list", s_1)];
neuper@37906
   766
neuper@37906
   767
(*--- 9.line in script ---*)
Walther@60565
   768
val t = TermC.parse_test @{context} "(SubProblem (Reals_s,[univar,equation],[no_met])\
neuper@37984
   769
   \                    [BOOL e_2, REAL v_2])";
neuper@37906
   770
val s = subst_atomic env t;
walther@59868
   771
UnparseC.term s;
wneuper@59476
   772
"SubProblem (Reals_s, [univar, equation], [no_met])\
neuper@37984
   773
	    \ [BOOL (b / 2 = r * cos alpha), REAL b]";
Walther@60565
   774
val s_2 = TermC.parse_test @{context} "[b = 2*r*cos alpha]";
Walther@60565
   775
val env = env @ [(TermC.parse_test @{context} "s_2::bool list", s_2)];
neuper@37906
   776
neuper@37906
   777
(*--- 10.line in script ---*)
Walther@60565
   778
val t = TermC.parse_test @{context} 
t@42204
   779
"Substitute [(v_1 = (rhs o hd) s_1),(v_2 = (rhs o hd) s_2)] (h_h::bool)";
neuper@37906
   780
val s = subst_atomic env t;
walther@59868
   781
UnparseC.term s;
neuper@37906
   782
"Substitute\n [(a = (rhs o hd) [a = 2 * r * sin alpha]),\
neuper@37906
   783
\              (b = (rhs o hd) [b = 2 * r * cos alpha])] (A = a * b)";
Walther@60500
   784
val SOME (s',_) = rewrite_set_ ctxt false prog_expr s;
walther@59868
   785
val s'' = UnparseC.term s';
t@42204
   786
(*=== inhibit exn 110726=============================================================
neuper@37906
   787
if s'' = 
neuper@37906
   788
"Substitute [a = 2 * r * sin alpha, b = 2 * r * cos alpha] (A = a * b)"
walther@59801
   789
then () else error "new behaviour with prog_expr 3.10.";
t@42166
   790
===== inhibit exn 110722===========================================================*)
t@42195
   791