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