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