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