test/Tools/isac/ME/inform.sml
author Walther Neuper <neuper@ist.tugraz.at>
Wed, 18 Aug 2010 13:40:09 +0200
branchisac-update-Isa09-2
changeset 37924 6c53fe2519e5
parent 37906 e2b23ba9df13
child 37926 e6fc98fbcb85
permissions -rw-r--r--
established thy-ctxt strategy (1..2) for ME/mstools.sml

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