test/Tools/isac/Interpret/inform.sml
author Walther Neuper <neuper@ist.tugraz.at>
Wed, 16 May 2012 08:59:09 +0200
changeset 42423 89afb340571c
parent 42209 a12b724f1d37
child 42426 fc042a668d7a
permissions -rw-r--r--
added fun check_err_patt

type errpat =
errpatID (* one identifier for a list of patterns *)
* term list (* error patterns *)
* thm list (* thms related to error patterns;
note that respective lhs do not match
(which reflects student's error) *)
     1 (* Title: tests on inform.sml
     2    Author: Walther Neuper 060225,
     3    (c) due to copyright terms 
     4 
     5 use"../smltest/ME/inform.sml";
     6 use"inform.sml";
     7 *)
     8 
     9 "-----------------------------------------------------------------";
    10 "table of contents -----------------------------------------------";
    11 "-----------------------------------------------------------------";
    12 "appendForm with miniscript with mini-subpbl:";
    13 "--------- appendFormula: on Res + equ_nrls ----------------------";
    14 "--------- appendFormula: on Frm + equ_nrls ----------------------";
    15 "--------- appendFormula: on Res + NO deriv ----------------------";
    16 "--------- appendFormula: on Res + late deriv --------------------";
    17 "--------- appendFormula: on Res + late deriv [x = 3 + -2]---///--";
    18 "replaceForm with miniscript with mini-subpbl:";
    19 "--------- replaceFormula: on Res + = ----------------------------";
    20 "--------- replaceFormula: on Res + = 1st Nd ---------------------";
    21 "--------- replaceFormula: on Frm + = 1st Nd ---------------------";
    22 "--------- replaceFormula: cut calculation -----------------------";
    23 "--------- replaceFormula: cut calculation -----------------------";
    24 (* 040307 copied from informtest.sml ... old versions
    25 "--------- maximum-example, UC: Modeling / modifyCalcHead --------";*)
    26 "--------- syntax error ------------------------------------------";
    27 "CAS-command:";
    28 "--------- CAS-command on ([],Pbl) -------------------------------";
    29 "--------- CAS-command on ([],Pbl) FE-interface ------------------";
    30 "--------- inform [rational,simplification] ----------------------";
    31 "--------- Take as 1st tac, start with <NEW> (CAS input) ---------";
    32 "--------- Take as 1st tac, start from exp -----------------------";
    33 "--------- init_form, start with <NEW> (CAS input) ---------------";
    34 "--------- build fun check_err_patt ------------------------------";
    35 "-----------------------------------------------------------------";
    36 "-----------------------------------------------------------------";
    37 "-----------------------------------------------------------------";
    38 
    39 
    40 
    41 
    42 
    43 
    44 "--------- appendFormula: on Res + equ_nrls ----------------------";
    45 "--------- appendFormula: on Res + equ_nrls ----------------------";
    46 "--------- appendFormula: on Res + equ_nrls ----------------------";
    47 
    48  val Script sc = (#scr o get_met) ["Test","squ-equ-test-subpbl1"];
    49  (writeln o term2str) sc;
    50  val Script sc = (#scr o get_met) ["Test","solve_linear"];
    51  (writeln o term2str) sc;
    52 
    53  states:=[];
    54  CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"], 
    55 	    ("Test", ["sqroot-test","univariate","equation","test"],
    56 	     ["Test","squ-equ-test-subpbl1"]))];
    57  Iterator 1; moveActiveRoot 1;
    58  autoCalculate 1 CompleteCalcHead;
    59  autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
    60  autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
    61 
    62  appendFormula 1 "-2 * 1 + (1 + x) = 0"; refFormula 1 (get_pos 1 1);
    63  val ((pt,_),_) = get_calc 1;
    64  val str = pr_ptree pr_short pt;
    65 
    66  writeln str;
    67 (*============ inhibit exn AK110726 ==============================================
    68 (* 2nd string should be the same as 1st one *)
    69 ".    ----- pblobj -----\n1.   x + 1 = 2\n2.   x + 1 + -1 * 2 = 0\n2.1.   x + 1 + -1 * 2 = 0\n2.2.   1 + x + -1 * 2 = 0\n2.3.   1 + (x + -1 * 2) = 0\n2.4.   1 + (x + -2) = 0\n2.5.   1 + (x + -2 * 1) = 0\n2.6.   1 + x + -2 * 1 = 0\n";
    70 ".    ----- pblobj -----\n1.   x + 1 = 2\n2.   x + 1 + -1 * 2 = 0\n2.1.   x + 1 + -1 * 2 = 0\n2.2.   -1 * 2 + (x + 1) = 0\n2.3.   -1 * 2 + (1 + x) = 0\n2.4.   1 + (-1 * 2 + x) = 0\n2.5.   1 + (-2 + x) = 0\n2.6.   1 + (-2 * 1 + x) = 0\n";
    71  if str = ".    ----- pblobj -----\n1.   x + 1 = 2\n2.   x + 1 + -1 * 2 = 0\n2.1.   x + 1 + -1 * 2 = 0\n2.2.   -1 * 2 + (x + 1) = 0\n2.3.   -1 * 2 + (1 + x) = 0\n2.4.   1 + (-1 * 2 + x) = 0\n2.5.   1 + (-2 + x) = 0\n2.6.   1 + (-2 * 1 + x) = 0\n" then ()
    72    else error "inform.sml: diff.behav.appendFormula: on Res + equ 1";
    73 ============ inhibit exn AK110726 ==============================================*)
    74 
    75  moveDown 1 ([ ],Pbl); refFormula 1 ([1],Frm); (*x + 1 = 2*)
    76  moveDown 1 ([1],Frm); refFormula 1 ([1],Res); (*x + 1 + -1 * 2 = 0*)
    77 
    78  (*the seven steps of detailed derivation*)
    79  moveDown 1 ([1  ],Res); refFormula 1 ([2,1],Frm); 
    80  moveDown 1 ([2,1],Frm); refFormula 1 ([2,1],Res);
    81  moveDown 1 ([2,1],Res); refFormula 1 ([2,2],Res);
    82  moveDown 1 ([2,2],Res); refFormula 1 ([2,3],Res); 
    83  moveDown 1 ([2,3],Res); refFormula 1 ([2,4],Res);
    84  moveDown 1 ([2,4],Res); refFormula 1 ([2,5],Res);
    85  moveDown 1 ([2,5],Res); refFormula 1 ([2,6],Res);
    86  val ((pt,_),_) = get_calc 1;
    87  if "-2 * 1 + (1 + x) = 0" = term2str (fst (get_obj g_result pt [2,6])) then()
    88  else error "inform.sml: diff.behav.appendFormula: on Res + equ 2";
    89 
    90  fetchProposedTactic 1; (*takes Iterator 1 _1_*)
    91 
    92 (*============ inhibit exn AK110725 ==============================================
    93 (* ERROR: exception Bind raised *)
    94  val (_,(tac,_,_)::_) = get_calc 1;
    95  if tac = Rewrite_Set "Test_simplify" then ()
    96  else error "inform.sml: diff.behav.appendFormula: on Res + equ 3";
    97 ============ inhibit exn AK110725 ==============================================*)
    98 
    99  autoCalculate 1 CompleteCalc;
   100  val ((pt,_),_) = get_calc 1;
   101  if "[x = 1]" = term2str (fst (get_obj g_result pt [])) then ()
   102  else error "inform.sml: diff.behav.appendFormula: on Res + equ 4";
   103  (* autoCalculate 1 CompleteCalc;
   104    val ((pt,p),_) = get_calc 1;
   105    (writeln o istates2str) (get_obj g_loc pt [ ]);  
   106    (writeln o istates2str) (get_obj g_loc pt [1]);  
   107    (writeln o istates2str) (get_obj g_loc pt [2]);  
   108    (writeln o istates2str) (get_obj g_loc pt [3]);  
   109    (writeln o istates2str) (get_obj g_loc pt [3,1]);  
   110    (writeln o istates2str) (get_obj g_loc pt [3,2]);  
   111    (writeln o istates2str) (get_obj g_loc pt [4]);  
   112 
   113    *)
   114 "----------------------------------------------------------";
   115 
   116  val fod = make_deriv (@{theory "Isac"}) Atools_erls 
   117 		       ((#rules o rep_rls) Test_simplify)
   118 		       (sqrt_right false (@{theory "Pure"})) NONE 
   119 		       (str2term "x + 1 + -1 * 2 = 0");
   120  (writeln o trtas2str) fod;
   121 
   122  val ifod = make_deriv (@{theory "Isac"}) Atools_erls 
   123 		       ((#rules o rep_rls) Test_simplify)
   124 		       (sqrt_right false (@{theory "Pure"})) NONE 
   125 		       (str2term "-2 * 1 + (1 + x) = 0");
   126  (writeln o trtas2str) ifod;
   127  fun equal (_,_,(t1, _)) (_,_,(t2, _)) = t1 = t2;
   128  val (fod', rifod') = dropwhile' equal (rev fod) (rev ifod);
   129  val der = fod' @ (map rev_deriv' rifod');
   130  (writeln o trtas2str) der;
   131  "----------------------------------------------------------";
   132 
   133 
   134 "--------- appendFormula: on Frm + equ_nrls ----------------------";
   135 "--------- appendFormula: on Frm + equ_nrls ----------------------";
   136 "--------- appendFormula: on Frm + equ_nrls ----------------------";
   137  states:=[];
   138  CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"], 
   139 	    ("Test", ["sqroot-test","univariate","equation","test"],
   140 	     ["Test","squ-equ-test-subpbl1"]))];
   141  Iterator 1; moveActiveRoot 1;
   142  autoCalculate 1 CompleteCalcHead;
   143  autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1) (*x + 1 = 2*);
   144  appendFormula 1 "2+ -1 + x = 2"; refFormula 1 (get_pos 1 1);
   145 
   146  moveDown 1 ([],Pbl); refFormula 1 ([1],Frm) (*x + 1 = 2*);
   147 
   148  moveDown 1 ([1  ],Frm); refFormula 1 ([1,1],Frm); 
   149  moveDown 1 ([1,1],Frm); refFormula 1 ([1,1],Res); 
   150  moveDown 1 ([1,1],Res); refFormula 1 ([1,2],Res); 
   151  moveDown 1 ([1,2],Res); refFormula 1 ([1,3],Res); 
   152  moveDown 1 ([1,3],Res); refFormula 1 ([1,4],Res); 
   153  moveDown 1 ([1,4],Res); refFormula 1 ([1,5],Res); 
   154  moveDown 1 ([1,5],Res); refFormula 1 ([1,6],Res); 
   155  val ((pt,_),_) = get_calc 1;
   156  if "2 + -1 + x = 2" = term2str (fst (get_obj g_result pt [1,6])) then()
   157  else error "inform.sml: diff.behav.appendFormula: on Frm + equ 1";
   158 
   159  fetchProposedTactic 1; (*takes Iterator 1 _1_*)
   160  val (_,(tac,_,_)::_) = get_calc 1;
   161  if tac = Rewrite_Set "norm_equation" then ()
   162  else error "inform.sml: diff.behav.appendFormula: on Frm + equ 2";
   163  autoCalculate 1 CompleteCalc;
   164  val ((pt,_),_) = get_calc 1;
   165  if "[x = 1]" = term2str (fst (get_obj g_result pt [])) then ()
   166  else error "inform.sml: diff.behav.appendFormula: on Frm + equ 3";
   167 
   168 
   169 "--------- appendFormula: on Res + NO deriv ----------------------";
   170 "--------- appendFormula: on Res + NO deriv ----------------------";
   171 "--------- appendFormula: on Res + NO deriv ----------------------";
   172  states:=[];
   173  CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"], 
   174 	    ("Test", ["sqroot-test","univariate","equation","test"],
   175 	     ["Test","squ-equ-test-subpbl1"]))];
   176  Iterator 1; moveActiveRoot 1;
   177  autoCalculate 1 CompleteCalcHead;
   178  autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
   179  autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
   180 
   181  appendFormula 1 "x = 2";
   182  val ((pt,p),_) = get_calc 1;
   183  val str = pr_ptree pr_short pt;
   184  writeln str;
   185  if str = ".    ----- pblobj -----\n1.   x + 1 = 2\n" andalso p = ([1], Res)
   186  then ()
   187  else error "inform.sml: diff.behav.appendFormula: Res + NOder 1";
   188 
   189  fetchProposedTactic 1;
   190  val (_,(tac,_,_)::_) = get_calc 1;
   191  if tac = Rewrite_Set "Test_simplify" then ()
   192  else error "inform.sml: diff.behav.appendFormula: Res + NOder 2";
   193  autoCalculate 1 CompleteCalc;
   194  val ((pt,_),_) = get_calc 1;
   195  if "[x = 1]" = term2str (fst (get_obj g_result pt [])) then ()
   196  else error "inform.sml: diff.behav.appendFormula: on Frm + equ 3";
   197 
   198 
   199 "--------- appendFormula: on Res + late deriv --------------------";
   200 "--------- appendFormula: on Res + late deriv --------------------";
   201 "--------- appendFormula: on Res + late deriv --------------------";
   202  states:=[];
   203  CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"], 
   204 	    ("Test", ["sqroot-test","univariate","equation","test"],
   205 	     ["Test","squ-equ-test-subpbl1"]))];
   206  Iterator 1; moveActiveRoot 1;
   207  autoCalculate 1 CompleteCalcHead;
   208  autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
   209  autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
   210 
   211  appendFormula 1 "x = 1";
   212  val ((pt,p),_) = get_calc 1;
   213  val str = pr_ptree pr_short pt;
   214  writeln str;
   215  if str = ".    ----- pblobj -----\n1.   x + 1 = 2\n2.   x + 1 + -1 * 2 = 0\n3.    ----- pblobj -----\n3.1.   -1 + x = 0\n3.2.   x = 0 + -1 * -1\n3.2.1.   x = 0 + -1 * -1\n3.2.2.   x = 0 + 1\n" andalso p = ([3,2], Res)
   216  then () (*finds 1 step too early: ([3,2], Res) "x = 1" also by script !!!*)
   217  else error "inform.sml: diff.behav.appendFormula: Res + late d 1";
   218 
   219  fetchProposedTactic 1;
   220  val (_,(tac,_,_)::_) = get_calc 1;
   221  if tac = Check_Postcond ["linear", "univariate", "equation", "test"] then ()
   222  else error "inform.sml: diff.behav.appendFormula: Res + late d 2";
   223  autoCalculate 1 CompleteCalc;
   224  val ((pt,_),_) = get_calc 1;
   225  if "[x = 1]" = term2str (fst (get_obj g_result pt [])) then ()
   226  else error "inform.sml: diff.behav.appendFormula: Res + late d 3";
   227 
   228 
   229 "--------- appendFormula: on Res + late deriv [x = 3 + -2]---///--";
   230 "--------- appendFormula: on Res + late deriv [x = 3 + -2]---///--";
   231 "--------- appendFormula: on Res + late deriv [x = 3 + -2]---///--";
   232  states:=[];
   233  CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"], 
   234 	    ("Test", ["sqroot-test","univariate","equation","test"],
   235 	     ["Test","squ-equ-test-subpbl1"]))];
   236  Iterator 1; moveActiveRoot 1;
   237  autoCalculate 1 CompleteCalcHead;
   238  autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
   239  autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
   240  appendFormula 1 "[x = 3 + -2*1]";
   241  val ((pt,p),_) = get_calc 1;
   242  val str = pr_ptree pr_short pt;
   243  writeln str;
   244  if str=".    ----- pblobj -----\n1.   x + 1 = 2\n2.   x + 1 + -1 * 2 = 0\n3.    ----- pblobj -----\n3.1.   -1 + x = 0\n3.2.   x = 0 + -1 * -1\n4.   [x = 1]\n4.1.   [x = 1]\n4.2.   [x = -2 + 3]\n4.3.   [x = 3 + -2]\n" then ()
   245  else error "inform.sml: diff.behav.appendFormula: Res + latEE 1";
   246  autoCalculate 1 CompleteCalc;
   247  val ((pt,p),_) = get_calc 1;
   248  if "[x = 3 + -2 * 1]" = term2str (fst (get_obj g_result pt [])) then ()
   249  (*       ~~~~~~~~~~ simplify as last step in any script ?!*)
   250  else error "inform.sml: diff.behav.appendFormula: Res + latEE 2";
   251 
   252 
   253 
   254 "--------- replaceFormula: on Res + = ----------------------------";
   255 "--------- replaceFormula: on Res + = ----------------------------";
   256 "--------- replaceFormula: on Res + = ----------------------------";
   257  states:=[];
   258  CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"], 
   259 	    ("Test", ["sqroot-test","univariate","equation","test"],
   260 	     ["Test","squ-equ-test-subpbl1"]))];
   261  Iterator 1; moveActiveRoot 1;
   262  autoCalculate 1 CompleteCalcHead;
   263  autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
   264  autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
   265  autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*-1 + x*);
   266 
   267  replaceFormula 1 "-2 * 1 + (1 + x) = 0"; refFormula 1 (get_pos 1 1);
   268  val ((pt,_),_) = get_calc 1;
   269  val str = pr_ptree pr_short pt;
   270  writeln str;
   271 
   272 (*============ inhibit exn AK110725 ==============================================
   273 (* 2nd string should be the same as 1st one *)
   274 ".    ----- pblobj -----\n1.   x + 1 = 2\n2.   x + 1 + -1 * 2 = 0\n2.1.   x + 1 + -1 * 2 = 0\n2.2.   1 + x + -1 * 2 = 0\n2.3.   1 + (x + -1 * 2) = 0\n2.4.   1 + (x + -2) = 0\n2.5.   1 + (x + -2 * 1) = 0\n2.6.   1 + x + -2 * 1 = 0\n";
   275 ".    ----- pblobj -----\n1.   x + 1 = 2\n2.   x + 1 + -1 * 2 = 0\n2.1.   x + 1 + -1 * 2 = 0\n2.2.   -1 * 2 + (x + 1) = 0\n2.3.   -1 * 2 + (1 + x) = 0\n2.4.   1 + (-1 * 2 + x) = 0\n2.5.   1 + (-2 + x) = 0\n2.6.   1 + (-2 * 1 + x) = 0\n";
   276  if str = ".    ----- pblobj -----\n1.   x + 1 = 2\n2.   x + 1 + -1 * 2 = 0\n2.1.   x + 1 + -1 * 2 = 0\n2.2.   -1 * 2 + (x + 1) = 0\n2.3.   -1 * 2 + (1 + x) = 0\n2.4.   1 + (-1 * 2 + x) = 0\n2.5.   1 + (-2 + x) = 0\n2.6.   1 + (-2 * 1 + x) = 0\n" then()
   277  else error "inform.sml: diff.behav.replaceFormula: on Res += 1";
   278 ============ inhibit exn AK110725 ==============================================*)
   279 
   280  autoCalculate 1 CompleteCalc;
   281  val ((pt,pos as (p,_)),_) = get_calc 1;
   282  if pos = ([],Res) andalso "[x = 1]" = (term2str o fst) (get_obj g_result pt p) then()
   283  else error "inform.sml: diff.behav.replaceFormula: on Res + = 2";
   284  
   285 
   286 "--------- replaceFormula: on Res + = 1st Nd ---------------------";
   287 "--------- replaceFormula: on Res + = 1st Nd ---------------------";
   288 "--------- replaceFormula: on Res + = 1st Nd ---------------------";
   289  states:=[];
   290  CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"], 
   291 	    ("Test", ["sqroot-test","univariate","equation","test"],
   292 	     ["Test","squ-equ-test-subpbl1"]))];
   293  Iterator 1; moveActiveRoot 1;
   294  autoCalculate 1 CompleteCalcHead;
   295  autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
   296  autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
   297 
   298  replaceFormula 1 "x + 1 = 4 + -2"; refFormula 1 (get_pos 1 1);
   299  val ((pt,_),_) = get_calc 1;
   300  val str = pr_ptree pr_short pt;
   301  writeln str;
   302  if str= ".    ----- pblobj -----\n1.   x + 1 = 2\n1.1.   x + 1 = 2\n1.2.   1 + x = 2\n1.3.   1 + x = -2 + 4\n1.4.   x + 1 = -2 + 4\n" then ()
   303  else error "inform.sml: diff.behav.replaceFormula: on Res 1 + = 1";
   304  autoCalculate 1 CompleteCalc;
   305  val ((pt,pos as (p,_)),_) = get_calc 1;
   306  if pos = ([],Res) andalso "[x = 1]" = (term2str o fst)(get_obj g_result pt p) then()
   307  else error "inform.sml: diff.behav.replaceFormula: on Res + = 2";
   308 
   309 
   310 "--------- replaceFormula: on Frm + = 1st Nd ---------------------";
   311 "--------- replaceFormula: on Frm + = 1st Nd ---------------------";
   312 "--------- replaceFormula: on Frm + = 1st Nd ---------------------";
   313  states:=[];
   314  CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"], 
   315 	    ("Test", ["sqroot-test","univariate","equation","test"],
   316 	     ["Test","squ-equ-test-subpbl1"]))];
   317  Iterator 1; moveActiveRoot 1;
   318  autoCalculate 1 CompleteCalcHead;
   319  autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
   320 
   321  replaceFormula 1 "x + 1 = 4 + -2"; refFormula 1 (get_pos 1 1);
   322  val ((pt,_),_) = get_calc 1;
   323  val str = pr_ptree pr_short pt;
   324  writeln str;
   325  if str= ".    ----- pblobj -----\n1.   x + 1 = 2\n1.1.   x + 1 = 2\n1.2.   1 + x = 2\n1.3.   1 + x = -2 + 4\n1.4.   x + 1 = -2 + 4\n" then ()
   326  else error "inform.sml: diff.behav.replaceFormula: on Frm 1 + = 1";
   327  autoCalculate 1 CompleteCalc;
   328  val ((pt,pos as (p,_)),_) = get_calc 1;
   329  if pos = ([],Res) andalso "[x = 1]" = (term2str o fst)(get_obj g_result pt p) then()
   330  else error "inform.sml: diff.behav.replaceFormula: on Frm 1 + = 2";
   331 
   332 
   333 "--------- replaceFormula: cut calculation -----------------------";
   334 "--------- replaceFormula: cut calculation -----------------------";
   335 "--------- replaceFormula: cut calculation -----------------------";
   336  states:=[];
   337  CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"], 
   338 	    ("Test", ["sqroot-test","univariate","equation","test"],
   339 	     ["Test","squ-equ-test-subpbl1"]))];
   340  Iterator 1; moveActiveRoot 1;
   341  autoCalculate 1 CompleteCalc;
   342  moveActiveRoot 1; moveActiveDown 1;
   343  if get_pos 1 1 = ([1], Frm) then ()
   344  else error "inform.sml: diff.behav. cut calculation 1";
   345 
   346  replaceFormula 1 "x + 1 = 4 + -2"; refFormula 1 (get_pos 1 1);
   347  val ((pt,p),_) = get_calc 1;
   348  val str = pr_ptree pr_short pt;
   349  writeln str;
   350  if p = ([1], Res) then ()
   351  else error "inform.sml: diff.behav. cut calculation 2";
   352 
   353 
   354 (* 040307 copied from informtest.sml; ... old version 
   355  "---------------- maximum-example, UC: Modeling / modifyCalcHead -";
   356  "---------------- maximum-example, UC: Modeling / modifyCalcHead -";
   357  "---------------- maximum-example, UC: Modeling / modifyCalcHead -";
   358 
   359  val p = ([],Pbl);
   360  val elems = ["fixedValues [r=Arbfix]","maximum A","valuesFor [a,b]",
   361 	      "relations [A=a*b, (a/2)^^^2 + (b/2)^^^2 = r^^^2]",
   362 	      "relations [A=a*b, (a/2)^^^2 + (b/2)^^^2 = r^^^2]",
   363 	      "relations [A=a*b, a/2=r*sin alpha, b/2=r*cos alpha]",
   364 	      (*^^^ these are the elements for the root-problem (in variants)*)
   365               (*vvv these are elements required for subproblems*)
   366 	      "boundVariable a","boundVariable b","boundVariable alpha",
   367 	      "interval {x::real. 0 <= x & x <= 2*r}",
   368 	      "interval {x::real. 0 <= x & x <= 2*r}",
   369 	      "interval {x::real. 0 <= x & x <= pi}",
   370 	      "errorBound (eps=(0::real))"]
   371  (*specifying is not interesting for this example*)
   372  val spec = ("DiffApp", ["maximum_of","function"], 
   373 	     ["DiffApp","max_by_calculus"]);
   374  (*the empty model with descriptions for user-guidance by Model_Problem*)
   375  val empty_model = [Given ["fixedValues []"],
   376 		    Find ["maximum", "valuesFor"],
   377 		    Relate ["relations []"]];
   378 
   379 
   380  (*!!!!!!!!!!!!!!!!! DON'T USE me FOR FINDING nxt !!!!!!!!!!!!!!!!!!*)
   381  val (p,_,f,nxt,_,pt) = CalcTreeTEST [(elems, spec)];
   382  (*val nxt = ("Model_Problem", ...*)
   383  val pbl = get_obj g_pbl pt (fst p); (writeln o (itms2str_ ctxt)) pbl; 
   384 
   385  val (p,_,f,nxt,_,pt) = me nxt p c pt;
   386  (*nxt = Add_Given "fixedValues [r = Arbfix]"*)
   387  val pbl = get_obj g_pbl pt (fst p); (writeln o (itms2str_ ctxt)) pbl; 
   388 (*[
   389 (0 ,[] ,false ,#Given ,Inc fixedValues [] ,(??.empty, [])),
   390 (0 ,[] ,false ,#Find ,Inc maximum ,(??.empty, [])),
   391 (0 ,[] ,false ,#Find ,Inc valuesFor ,(??.empty, [])),
   392 (0 ,[] ,false ,#Relate ,Inc relations [] ,(??.empty, []))]*)
   393 
   394  (*the empty CalcHead is checked w.r.t the model and re-established as such*)
   395  val (b,pt,ocalhd) = input_icalhd pt (p,"", empty_model, Pbl, e_spec);
   396  val pbl = get_obj g_pbl pt (fst p); (writeln o (itms2str_ ctxt)) pbl; 
   397  if ocalhd2str ocalhd = "(Pbl, ??.empty, [\n(0 ,[] ,false ,#Given ,Inc fixedValues [] ,(??.empty, [])),\n(0 ,[] ,false ,#Find ,Inc maximum ,(??.empty, [])),\n(0 ,[] ,false ,#Find ,Inc valuesFor ,(??.empty, [])),\n(0 ,[] ,false ,#Relate ,Inc relations [] ,(??.empty, []))], [], \n(\"e_domID\", [\"e_pblID\"], [\"e_metID\"]) )" then () else error "informtest.sml: diff.behav. max 1";
   398 
   399  (*there is one input to the model (could be more)*)
   400  val (b,pt,ocalhd) = 
   401      input_icalhd pt (p,"", [Given ["fixedValues [r=Arbfix]"],
   402 			     Find ["maximum", "valuesFor"],
   403 			     Relate ["relations"]], Pbl, e_spec);
   404  val pbl = get_obj g_pbl pt (fst p); (writeln o (itms2str_ ctxt)) pbl; 
   405  if ocalhd2str ocalhd = "(Pbl, ??.empty, [\n(1 ,[1,2,3] ,true ,#Given ,Cor fixedValues [r = Arbfix] ,(fix_, [[r = Arbfix]])),\n(0 ,[] ,false ,#Find ,Inc maximum ,(??.empty, [])),\n(0 ,[] ,false ,#Find ,Inc valuesFor ,(??.empty, [])),\n(0 ,[] ,false ,#Relate ,Inc relations [] ,(??.empty, []))], [], \n(\"e_domID\", [\"e_pblID\"], [\"e_metID\"]) )" then () 
   406  else error "informtest.sml: diff.behav. max 2";
   407 
   408  (*this input is complete in variant 3, but the ME doesn't recognize FIXXXXME
   409  val (b,pt''''',ocalhd) = 
   410      input_icalhd pt (p,"", [Given ["fixedValues [r=Arbfix]"],
   411 			     Find ["maximum A", "valuesFor [a,b]"],
   412 			     Relate ["relations [A=a*b, a/2=r*sin alpha, \
   413 				     \b/2=r*cos alpha]"]], Pbl, e_spec);
   414  val pbl = get_obj g_pbl pt''''' (fst p); (writeln o (itms2str_ ctxt)) pbl; 
   415  if ocalhd2str ocalhd = ------------^^^^^^^^^^ missing !!!*)
   416 
   417  (*this input is complete in variant 1 (variant 3 does not work yet)*)
   418  val (b,pt''''',ocalhd) = 
   419      input_icalhd pt (p,"", [Given ["fixedValues [r=Arbfix]"],
   420 			     Find ["maximum A", "valuesFor [a,b]"],
   421 			     Relate ["relations [A=a*b, \
   422 				     \(a/2)^^^2 + (b/2)^^^2 = r^^^2]"]], 
   423 		      Pbl, e_spec);
   424  val pbl = get_obj g_pbl pt''''' (fst p); (writeln o (itms2str_ ctxt)) pbl; 
   425 
   426  modifycalcheadOK2xml 111 (bool2str b) ocalhd;
   427 *)
   428 
   429 "--------- syntax error ------------------------------------------";
   430 "--------- syntax error ------------------------------------------";
   431 "--------- syntax error ------------------------------------------";
   432  states:=[];
   433  CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"], 
   434 	    ("Test", ["sqroot-test","univariate","equation","test"],
   435 	     ["Test","squ-equ-test-subpbl1"]))];
   436  Iterator 1; moveActiveRoot 1;
   437  autoCalculate 1 CompleteCalcHead;
   438  autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
   439  autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
   440 
   441  appendFormula 1 " x - "; (*<ERROR> syntax error in ' x - ' </ERROR>*)
   442  val ((pt,_),_) = get_calc 1;
   443  val str = pr_ptree pr_short pt;
   444  writeln str;
   445  if str = ".    ----- pblobj -----\n1.   x + 1 = 2\n" then ()
   446  else error "inform.sml: diff.behav.appendFormula: syntax error";
   447 
   448 
   449 "--------- CAS-command on ([],Pbl) -------------------------------";
   450 "--------- CAS-command on ([],Pbl) -------------------------------";
   451 "--------- CAS-command on ([],Pbl) -------------------------------";
   452 val (p,_,f,nxt,_,pt) = 
   453     CalcTreeTEST [([], ("e_domID", ["e_pblID"], ["e_metID"]))];
   454 val ifo = "solve(x+1=2,x)";
   455 val (_,(_,c,(pt,p))) = inform ([],[],(pt,p)) "solve(x+1=2,x)";
   456 show_pt pt;
   457 val nxt = ("Apply_Method",Apply_Method ["Test","squ-equ-test-subpbl1"]);
   458 val (p,_,f,nxt,_,pt) = me nxt p [] pt;
   459 if p = ([1], Frm) andalso f2str f = "x + 1 = 2" then ()
   460 else error "inform.sml: diff.behav. CAScmd ([],Pbl)";
   461 
   462 
   463 "--------- CAS-command on ([],Pbl) FE-interface ------------------";
   464 "--------- CAS-command on ([],Pbl) FE-interface ------------------";
   465 "--------- CAS-command on ([],Pbl) FE-interface ------------------";
   466 states:=[];
   467 CalcTree [([], ("e_domID", ["e_pblID"], ["e_metID"]))];
   468 Iterator 1;
   469 moveActiveRoot 1;
   470 replaceFormula 1 "solve(x+1=2,x)";
   471 autoCalculate 1 CompleteCalc;
   472 val ((pt,p),_) = get_calc 1;
   473 show_pt pt;
   474 if p = ([], Res) then ()
   475 else error "inform.sml: diff.behav. CAScmd ([],Pbl) FE-interface";
   476 
   477 
   478 "--------- inform [rational,simplification] ----------------------";
   479 "--------- inform [rational,simplification] ----------------------";
   480 "--------- inform [rational,simplification] ----------------------";
   481 states:=[];
   482 CalcTree [(["Term (4/x - 3/y - 1)", "normalform N"],
   483 	   ("Rational",["rational","simplification"],
   484 	    ["simplification","of_rationals"]))];
   485 Iterator 1; moveActiveRoot 1;
   486 autoCalculate 1 CompleteCalcHead;
   487 autoCalculate 1 (Step 1);
   488 autoCalculate 1 (Step 1);
   489 autoCalculate 1 (Step 1);
   490 autoCalculate 1 (Step 1);
   491 "--- input the next formula that _should_ be presented by mat-engine";
   492 appendFormula 1 "(4 * y + -3 * x) / (x * y) + -1";
   493 val ((pt,p),_) = get_calc 1;
   494 if p = ([4], Res) andalso (length o children o (get_nd pt)) (fst p) = 2 then ()
   495 else error ("inform.sml: [rational,simplification] 1");
   496 
   497 "--- input the next formula that would be presented by mat-engine";
   498 (*autoCalculate 1 (Step 1);*)
   499 appendFormula 1 "(4 * y + -3 * x + -1 * (x * y)) / (x * y)";
   500 val ((pt,p),_) = get_calc 1;
   501 if p = ([5], Res) andalso (length o children o (get_nd pt)) (fst p) = 0 then ()
   502 else error ("inform.sml: [rational,simplification] 2");
   503 
   504 "--- input the exact final result";(*TODO: Exception- LIST "last_elem" raised*)
   505 appendFormula 1 "(-3 * x + 4 * y + -1 * x * y) / (x * y)";
   506 val ((pt,p),_) = get_calc 1;
   507 if p = ([6], Res) andalso (length o children o (get_nd pt)) (fst p) = 2 then ()
   508 else error ("inform.sml: [rational,simplification] 3");
   509 show_pt pt;
   510 
   511 "--------- Take as 1st tac, start with <NEW> (CAS input) ---------";
   512 "--------- Take as 1st tac, start with <NEW> (CAS input) ---------";
   513 "--------- Take as 1st tac, start with <NEW> (CAS input) ---------";
   514 val t = str2term "Diff (x^^^2 + x + 1, x)";
   515 case t of Const ("Diff.Diff", _) $ _ => ()
   516 	| _ => raise 
   517 	      error "diff.sml behav.changed for CAS Diff (..., x)";
   518 atomty t;
   519 "-----------------------------------------------------------------";
   520 (*1>*)states:=[];
   521 (*2>*)CalcTree [([], ("e_domID", ["e_pblID"], ["e_metID"]))];
   522 (*3>*)Iterator 1;moveActiveRoot 1;
   523 "----- here the Headline has been finished";
   524 (*4>*)moveActiveFormula 1 ([],Pbl);
   525 (*5>*)replaceFormula 1 "Diff (x^2 + x + 1, x)";
   526 val ((pt,_),_) = get_calc 1;
   527 val PblObj {probl, meth, spec, fmz, env, loc, ...} = get_obj I pt [];
   528 val NONE = env;
   529 val (SOME istate, NONE) = loc;
   530 print_depth 5;
   531 writeln"-----------------------------------------------------------";
   532 spec;
   533 writeln (itms2str_ ctxt probl);
   534 writeln (itms2str_ ctxt meth);
   535 
   536 (*============ inhibit exn AK110725 ==============================================
   537 (* ERROR: Argument: istate : istate * Proof.context Reason: 
   538         Can't unify istate to istate * Proof.context *)
   539 writeln (istate2str istate);
   540 ============ inhibit exn AK110725 ==============================================*)
   541 
   542 print_depth 3;
   543 
   544 refFormula 1 ([],Pbl) (*--> correct CalcHead*);
   545  (*081016 NOT necessary (but leave it in Java):*)
   546 (*6>*)(*completeCalcHead*)autoCalculate 1 CompleteCalcHead;
   547 "----- here the CalcHead has been completed --- ONCE MORE ?????";
   548 
   549 (***difference II***)
   550 val ((pt,p),_) = get_calc 1;
   551 (*val p = ([], Pbl)*)
   552 val PblObj {probl, meth, spec, fmz, env, loc, ...} = get_obj I pt [];
   553 val NONE = env;
   554 val (SOME istate, NONE) = loc;
   555 (*============ inhibit exn AK110725 ==============================================
   556 (* ERROR: Argument: istate : istate * Proof.context Reason: Can't unify istate to istate * Proof.context *)
   557 print_depth 5; writeln (istate2str istate);  print_depth 3;
   558 ============ inhibit exn AK110725 ==============================================*)
   559 (*ScrState ([],
   560  [], NONE,
   561  ??.empty, Sundef, false)*)
   562 print_depth 5; spec; print_depth 3;
   563 (*("Isac",
   564       ["derivative_of", "function"],
   565       ["diff", "differentiate_on_R"]) : spec*)
   566 writeln (itms2str_ ctxt probl);
   567 (*[
   568 (1 ,[1] ,true ,#Given ,Cor functionTerm (x ^^^ 2 + x + 1) ,(f_, [x ^^^ 2 + x + 1])),
   569 (2 ,[1] ,true ,#Given ,Cor differentiateFor x ,(v_, [x])),
   570 (3 ,[1] ,true ,#Find ,Cor derivative f_'_f ,(f_'_f, [f_'_f]))]*)
   571 writeln (itms2str_ ctxt meth);
   572 (*[
   573 (1 ,[1] ,true ,#Given ,Cor functionTerm (x ^^^ 2 + x + 1) ,(f_, [x ^^^ 2 + x + 1])),
   574 (2 ,[1] ,true ,#Given ,Cor differentiateFor x ,(v_, [x])),
   575 (3 ,[1] ,true ,#Find ,Cor derivative f_'_f ,(f_'_f, [f_'_f]))]*)
   576 writeln"-----------------------------------------------------------";
   577 (*7>*)fetchProposedTactic 1 (*--> Apply_Method*);
   578 (*WN081028 fixed <ERROR> helpless </ERROR> by inform returning ...(.,Met)*)
   579 autoCalculate 1 CompleteCalc;
   580 val ((pt,p),_) = get_calc 1;
   581 val Form res = (#1 o pt_extract) (pt, ([],Res));
   582 show_pt pt;
   583 if p = ([], Res) andalso term2str res = "1 + 2 * x" then ()
   584 else error "diff.sml behav.changed for Diff (x^2 + x + 1, x)";
   585 
   586 
   587 "--------- Take as 1st tac, start from exp -----------------------";
   588 "--------- Take as 1st tac, start from exp -----------------------";
   589 "--------- Take as 1st tac, start from exp -----------------------";
   590 (*the following input is copied from BridgeLog Java <==> SML,
   591   omitting unnecessary inputs*)
   592 (*1>*)states:=[];
   593 (*2>*)CalcTree [(["functionTerm (x^2 + x + 1)", "differentiateFor x", "derivative f_'_f"],("Isac",["derivative_of","function"],["diff","differentiate_on_R"]))];
   594 (*3>*)Iterator 1; moveActiveRoot 1;
   595 
   596 (*6>*)(*completeCalcHead*)autoCalculate 1 CompleteCalcHead;
   597 (***difference II***)
   598 val ((pt,_),_) = get_calc 1;
   599 val PblObj {probl, meth, spec, fmz, env, loc, ...} = get_obj I pt [];
   600 val NONE = env;
   601 val (SOME istate, NONE) = loc;
   602 (*============ inhibit exn AK110725 ==============================================
   603 (* ERROR: Argument: istate : istate * Proof.context Reason: Can't unify istate to istate * Proof.context *)
   604 print_depth 5; writeln (istate2str istate);  print_depth 3;
   605 ============ inhibit exn AK110725 ==============================================*)
   606 (*ScrState ([],
   607  [], NONE,
   608  ??.empty, Sundef, false)*)
   609 print_depth 5; spec; print_depth 3;
   610 (*("Isac",
   611       ["derivative_of", "function"],
   612       ["diff", "differentiate_on_R"]) : spec*)
   613 writeln (itms2str_ ctxt probl);
   614 (*[
   615 (1 ,[1] ,true ,#Given ,Cor functionTerm (x ^^^ 2 + x + 1) ,(f_, [x ^^^ 2 + x + 1])),
   616 (2 ,[1] ,true ,#Given ,Cor differentiateFor x ,(v_, [x])),
   617 (3 ,[1] ,true ,#Find ,Cor derivative f_'_f ,(f_'_f, [f_'_f]))]*)
   618 writeln (itms2str_ ctxt meth);
   619 (*[
   620 (1 ,[1] ,true ,#Given ,Cor functionTerm (x ^^^ 2 + x + 1) ,(f_, [x ^^^ 2 + x + 1])),
   621 (2 ,[1] ,true ,#Given ,Cor differentiateFor x ,(v_, [x])),
   622 (3 ,[1] ,true ,#Find ,Cor derivative f_'_f ,(f_'_f, [f_'_f]))]*)
   623 writeln"-----------------------------------------------------------";
   624 (*7>*)fetchProposedTactic 1 (*--> Apply_Method*);
   625 autoCalculate 1 (Step 1);
   626 val ((pt,p),_) = get_calc 1;
   627 val Form res = (#1 o pt_extract) (pt, p);
   628 if term2str res = "d_d x (x ^^^ 2 + x + 1)" then ()
   629 else error "diff.sml Diff (x^2 + x + 1, x) from exp";
   630 
   631 
   632 "--------- init_form, start with <NEW> (CAS input) ---------------";
   633 "--------- init_form, start with <NEW> (CAS input) ---------------";
   634 "--------- init_form, start with <NEW> (CAS input) ---------------";
   635 states:=[];
   636 CalcTree [([], ("e_domID", ["e_pblID"], ["e_metID"]))];
   637 (*[[from sml: > @@@@@begin@@@@@
   638 [[from sml:  1 
   639 [[from sml: <CALCTREE>
   640 [[from sml:    <CALCID> 1 </CALCID>
   641 [[from sml: </CALCTREE>
   642 [[from sml: @@@@@end@@@@@*)
   643 Iterator 1;
   644 (*[[from sml: > @@@@@begin@@@@@
   645 [[from sml:  1 
   646 [[from sml: <ADDUSER>
   647 [[from sml:   <CALCID> 1 </CALCID>
   648 [[from sml:   <USERID> 1 </USERID>
   649 [[from sml: </ADDUSER>
   650 [[from sml: @@@@@end@@@@@*)
   651 moveActiveRoot 1;
   652 (*[[from sml: > @@@@@begin@@@@@
   653 [[from sml:  1 
   654 [[from sml: <CALCITERATOR>
   655 [[from sml:   <CALCID> 1 </CALCID>
   656 [[from sml:   <POSITION>
   657 [[from sml:     <INTLIST>
   658 [[from sml:     </INTLIST>
   659 [[from sml:     <POS> Pbl </POS>
   660 [[from sml:   </POSITION>
   661 [[from sml: </CALCITERATOR>
   662 [[from sml: @@@@@end@@@@@*)
   663 getFormulaeFromTo 1 ([],Pbl) ([],Pbl) 0 false;
   664 (*[[from sml: > @@@@@begin@@@@@                STILL CORRECT
   665 [[from sml:  1 
   666 [[from sml: <GETELEMENTSFROMTO>
   667 [[from sml:   <CALCID> 1 </CALCID>
   668 [[from sml:   <FORMHEADS>
   669 [[from sml:     <CALCFORMULA>
   670 [[from sml:       <POSITION>
   671 [[from sml:         <INTLIST>
   672 [[from sml:         </INTLIST>
   673 [[from sml:         <POS> Pbl </POS>
   674 [[from sml:       </POSITION>
   675 [[from sml:       <FORMULA>
   676 [[from sml:         <MATHML>
   677 [[from sml:           <ISA> ________________________________________________ </ISA>
   678 [[from sml:         </MATHML>
   679 [[from sml: 
   680 [[from sml:       </FORMULA>
   681 [[from sml:     </CALCFORMULA>
   682 [[from sml:   </FORMHEADS>
   683 [[from sml: </GETELEMENTSFROMTO>
   684 [[from sml: @@@@@end@@@@@*)
   685 refFormula 1 ([],Pbl);
   686 (*[[from sml: > @@@@@begin@@@@@                STILL CORRECT
   687 [[from sml:  1 
   688 [[from sml: <REFFORMULA>
   689 [[from sml:   <CALCID> 1 </CALCID>
   690 [[from sml:   <CALCHEAD status = "incorrect">
   691 [[from sml:     <POSITION>
   692 [[from sml:       <INTLIST>
   693 [[from sml:       </INTLIST>
   694 [[from sml:       <POS> Pbl </POS>
   695 [[from sml:     </POSITION>
   696 [[from sml:     <HEAD>
   697 [[from sml:       <MATHML>
   698 [[from sml:         <ISA> Problem (e_domID, [e_pblID]) </ISA>
   699 [[from sml:       </MATHML>
   700 [[from sml:     </HEAD>
   701 [[from sml:     <MODEL>
   702 [[from sml:       <GIVEN>  </GIVEN>
   703 [[from sml:       <WHERE>  </WHERE>
   704 [[from sml:       <FIND>  </FIND>
   705 [[from sml:       <RELATE>  </RELATE>
   706 [[from sml:     </MODEL>
   707 [[from sml:     <BELONGSTO> Pbl </BELONGSTO>
   708 [[from sml:     <SPECIFICATION>
   709 [[from sml:       <THEORYID> e_domID </THEORYID>
   710 [[from sml:       <PROBLEMID>
   711 [[from sml:         <STRINGLIST>
   712 [[from sml:           <STRING> e_pblID </STRING>
   713 [[from sml:         </STRINGLIST>
   714 [[from sml:       </PROBLEMID>
   715 [[from sml:       <METHODID>
   716 [[from sml:         <STRINGLIST>
   717 [[from sml:           <STRING> e_metID </STRING>
   718 [[from sml:         </STRINGLIST>
   719 [[from sml:       </METHODID>
   720 [[from sml:     </SPECIFICATION>
   721 [[from sml:   </CALCHEAD>
   722 [[from sml: </REFFORMULA>
   723 [[from sml: @@@@@end@@@@@*)
   724 moveActiveFormula 1 ([],Pbl);
   725 (*[[from sml: > @@@@@begin@@@@@
   726 [[from sml:  1 
   727 [[from sml: <CALCITERATOR>
   728 [[from sml:   <CALCID> 1 </CALCID>
   729 [[from sml:   <POSITION>
   730 [[from sml:     <INTLIST>
   731 [[from sml:     </INTLIST>
   732 [[from sml:     <POS> Pbl </POS>
   733 [[from sml:   </POSITION>
   734 [[from sml: </CALCITERATOR>
   735 [[from sml: @@@@@end@@@@@*)
   736 replaceFormula 1 "Simplify (1+2)";
   737 (*[[from sml: > @@@@@begin@@@@@
   738 [[from sml:  1 
   739 [[from sml: <REPLACEFORMULA>
   740 [[from sml:   <CALCID> 1 </CALCID>
   741 [[from sml:   <CALCCHANGED>
   742 [[from sml:     <UNCHANGED>
   743 [[from sml:       <INTLIST>
   744 [[from sml:       </INTLIST>
   745 [[from sml:       <POS> Pbl </POS>
   746 [[from sml:     </UNCHANGED>
   747 [[from sml:     <DELETED>
   748 [[from sml:       <INTLIST>
   749 [[from sml:       </INTLIST>
   750 [[from sml:       <POS> Pbl </POS>
   751 [[from sml:     </DELETED>
   752 [[from sml:     <GENERATED>
   753 [[from sml:       <INTLIST>
   754 [[from sml:       </INTLIST>
   755 [[from sml:       <POS> Met </POS>                           DIFFERENCE: Pbl
   756 [[from sml:     </GENERATED>
   757 [[from sml:   </CALCCHANGED>
   758 [[from sml: </REPLACEFORMULA>
   759 [[from sml: @@@@@end@@@@@*)
   760 getFormulaeFromTo 1 ([],Pbl) ([],Pbl) 0 false(*              DIFFERENCE: Pbl*);
   761 (*@@@@@begin@@@@@
   762  1
   763 <GETELEMENTSFROMTO>
   764   <CALCID> 1 </CALCID>
   765   <FORMHEADS>
   766     <CALCFORMULA>
   767       <POSITION>
   768         <INTLIST>
   769         </INTLIST>
   770         <POS> Pbl </POS>
   771       </POSITION>
   772       <FORMULA>
   773         <MATHML>
   774           <ISA> Simplify (1 + 2) </ISA>                      WORKS !!!!!
   775         </MATHML>
   776       </FORMULA>
   777     </CALCFORMULA>
   778   </FORMHEADS>
   779 </GETELEMENTSFROMTO>
   780 @@@@@end@@@@@*)
   781 getFormulaeFromTo 1 ([],Pbl) ([],Met) 0 false;
   782 (*[[from sml: > @@@@@begin@@@@@
   783 [[from sml:  1 
   784 [[from sml: <SYSERROR>
   785 [[from sml:   <CALCID> 1 </CALCID>
   786 [[from sml:   <ERROR> error in getFormulaeFromTo </ERROR>
   787 [[from sml: </SYSERROR>
   788 [[from sml: @@@@@end@@@@@*)
   789 (*step into getFormulaeFromTo --- bug corrected...*)
   790 
   791 "--------- build fun check_err_patt ------------------------------";
   792 "--------- build fun check_err_patt ------------------------------";
   793 "--------- build fun check_err_patt ------------------------------";
   794 val rls = norm_Rational
   795 val pat = parse_patt @{theory} "(?a + ?b)/(?b + ?c) = ?a / ?c";
   796 val (res, inf) = (str2term "(2 + 3)/(3 + 4)", str2term "2 / 4");
   797 val (res, inf) = (str2term "(2 + 3)/(3 + 4)", str2term "1 / 2");
   798 
   799 val (res', _, _, rewritten) =
   800   rew_sub thy 1 [] e_rew_ord e_rls false [] (Trueprop $ pat) res;
   801 if rewritten then NONE else SOME "e_errpatID";
   802 
   803 val norm_res = case rewrite_set_ (Isac()) false rls res' of
   804   NONE => res'
   805 | SOME (norm_res, _) => norm_res
   806 
   807 val norm_inf = case rewrite_set_ (Isac()) false rls inf of
   808   NONE => inf
   809 | SOME (norm_inf, _) => norm_inf;
   810 
   811 res' = inf;
   812 norm_res = norm_inf;
   813 
   814 val pat = parse_patt @{theory} "(?a + ?b)/?a = ?b";
   815 val (res, inf) = (str2term "(2 + 3)/2", str2term "3");
   816 if check_err_patt (res, inf) ("errpatID", pat) rls = SOME "errpatID"
   817 then () else error "error patt example1 changed";
   818 
   819 val pat = parse_patt @{theory} "(?a + ?b)/(?a + ?c) = ?b / ?c";
   820 val (res, inf) = (str2term "(2 + 3)/(2 + 4)", str2term "3 / 4");
   821 if check_err_patt (res, inf) ("errpatID", pat) rls = SOME "errpatID"
   822 then () else error "error patt example2 changed";
   823 
   824 val pat = parse_patt @{theory} "(?a + ?b)/(?b + ?c) = ?a / ?c";
   825 val (res, inf) = (str2term "(2 + 3)/(3 + 4)", str2term "2 / 4");
   826 if check_err_patt (res, inf) ("errpatID", pat) rls = SOME "errpatID"
   827 then () else error "error patt example3 changed";
   828 
   829 val inf =  str2term "1 / 2";
   830 if check_err_patt (res, inf) ("errpatID", pat) rls = SOME "errpatID"
   831 then () else error "error patt example3 changed";
   832 
   833