test/Tools/isac/Interpret/mathengine.sml
author Walther Neuper <neuper@ist.tugraz.at>
Wed, 03 Nov 2010 09:45:59 +0100
branchisac-update-Isa09-2
changeset 38065 6e57bce5b515
parent 38058 ad0485155c0e
child 38066 db99b0b8f955
permissions -rw-r--r--
check 'autoCalculate 1 CompleteCalc': works for test/../integrate.sml

seem to have chased a phantom, but found:
# new calcstate created very differently in
(1) me > locatetac (step here only used for next tac)
(2) autocalc > step
# DIFFERENCE (1)..(2) by encode_*, e.g. '^^^' instead '^'
# 'autoCalculate 1 (Step 1) == autocalc work, but seem to skip modelling
TODO: where do these steps come from with <Next> in the GUI ?
neuper@37906
     1
(* test for sml/ME/mathengine.sml
neuper@37906
     2
   authors: Walther Neuper 2000, 2006
neuper@37906
     3
   (c) due to copyright terms
neuper@37906
     4
*)
neuper@37906
     5
neuper@38065
     6
"--------------------------------------------------------";
neuper@38065
     7
"table of contents --------------------------------------";
neuper@38065
     8
"--------------------------------------------------------";
neuper@38065
     9
"----------- debugging setContext..pbl_ -----------------";
neuper@38065
    10
"----------- tryrefine ----------------------------------";
neuper@38065
    11
"----------- fun step -----------------------------------";
neuper@38065
    12
"----------- fun autocalc -------------------------------";
neuper@38065
    13
"----------- fun autoCalculate --------------------------";
neuper@38065
    14
"--------------------------------------------------------";
neuper@38065
    15
"--------------------------------------------------------";
neuper@38065
    16
"--------------------------------------------------------";
neuper@37906
    17
neuper@38065
    18
(*=== inhibit exn ?=============================================================
neuper@37906
    19
neuper@38065
    20
"----------- debugging setContext..pbl_ -----------------";
neuper@38065
    21
"----------- debugging setContext..pbl_ -----------------";
neuper@38065
    22
"----------- debugging setContext..pbl_ -----------------";
neuper@37906
    23
states:=[];
neuper@37906
    24
CalcTree
neuper@37906
    25
[(["equality (x+1=2)", "solveFor x","solutions L"], 
neuper@38058
    26
  ("Test", 
neuper@37906
    27
   ["sqroot-test","univariate","equation","test"],
neuper@37906
    28
   ["Test","squ-equ-test-subpbl1"]))];
neuper@37906
    29
Iterator 1;
neuper@37906
    30
moveActiveRoot 1; modelProblem 1;
neuper@37906
    31
neuper@37906
    32
val pos as (p,_) = ([],Pbl);
neuper@37906
    33
val guh = "pbl_equ_univ";
neuper@37906
    34
checkContext 1 pos guh;
neuper@37906
    35
val ((pt,_),_) = get_calc 1;
neuper@37906
    36
val pp = par_pblobj pt p;
neuper@37906
    37
val keID = guh2kestoreID guh;
neuper@37906
    38
case context_pbl keID pt pp of (true,["univariate", "equation"],_,_,_)=>()
neuper@38031
    39
| _ => error "mathengine.sml: context_pbl .. pbl_equ_univ checked";
neuper@37906
    40
neuper@37906
    41
case get_obj g_spec pt p of (_, ["e_pblID"], _) => ()
neuper@38031
    42
| _ => error "mathengine.sml: context_pbl .. pbl still empty";
neuper@37906
    43
setContext 1 pos guh;
neuper@37906
    44
val ((pt,_),_) = get_calc 1;
neuper@37906
    45
case get_obj g_spec pt p of (_, ["univariate", "equation"], _) => ()
neuper@38031
    46
| _ => error "mathengine.sml: context_pbl .. pbl set";
neuper@37906
    47
neuper@37906
    48
neuper@37906
    49
setContext 1 pos "met_eq_lin";
neuper@37906
    50
val ((pt,_),_) = get_calc 1;
neuper@37906
    51
case get_obj g_spec pt p of (_,  _, ["LinEq", "solve_lineq_equation"]) => ()
neuper@38031
    52
| _ => error "mathengine.sml: context_pbl .. pbl set";
neuper@37906
    53
neuper@37906
    54
neuper@38065
    55
"----------- tryrefine ----------------------------------";
neuper@38065
    56
"----------- tryrefine ----------------------------------";
neuper@38065
    57
"----------- tryrefine ----------------------------------";
neuper@37906
    58
states:=[];
neuper@37906
    59
CalcTree [(["equality (x/(x^2 - 6*x+9) - 1/(x^2 - 3*x) =1/x)", 
neuper@37906
    60
	    "solveFor x", "solutions L"],
neuper@38058
    61
	   ("RatEq",["univariate","equation"],["no_met"]))];
neuper@37906
    62
Iterator 1;
neuper@37906
    63
moveActiveRoot 1; autoCalculate 1 CompleteCalc;
neuper@37906
    64
neuper@37906
    65
refineProblem 1 ([1],Res) "pbl_equ_univ" 
neuper@37906
    66
(*gives "pbl_equ_univ_rat" correct*);
neuper@37906
    67
neuper@37906
    68
refineProblem 1 ([1],Res) (pblID2guh ["linear","univariate","equation"])
neuper@38065
    69
(*gives "pbl_equ_univ_lin" incorrect*);
neuper@38065
    70
neuper@38065
    71
===== inhibit exn ?===========================================================*)
neuper@38065
    72
neuper@38065
    73
(*-.-.-.-.-.-isolate response.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
neuper@38065
    74
neuper@38065
    75
"----------- fun step -----------------------------------";
neuper@38065
    76
"----------- fun step -----------------------------------";
neuper@38065
    77
"----------- fun step -----------------------------------";
neuper@38065
    78
val p = e_pos'; val c = []; 
neuper@38065
    79
val (p,_,f,nxt,_,pt) = 
neuper@38065
    80
    CalcTreeTEST 
neuper@38065
    81
        [(["functionTerm (x^^^2 + 1)", "integrateBy x", "antiDerivative FF"], 
neuper@38065
    82
          ("Integrate", ["integrate","function"], ["diff","integration"]))];
neuper@38065
    83
"----- step 1: returns tac = Model_Problem ---";
neuper@38065
    84
val (str, ([(tac, _, _)], _, (pt, p))) = step p ((pt, e_pos'), []);
neuper@38065
    85
"----- step 2: returns tac =  ---";
neuper@38065
    86
val (str, ([(tac, _, _)], _, (pt, p))) = step p ((pt, e_pos'), []);
neuper@38065
    87
"----- step 3: returns tac =  ---";
neuper@38065
    88
val (str, ([(tac, _, _)], _, (pt, p))) = step p ((pt, e_pos'), []);
neuper@38065
    89
"----- step 4: returns tac =  ---";
neuper@38065
    90
val (str, ([(tac, _, _)], _, (pt, p))) = step p ((pt, e_pos'), []);
neuper@38065
    91
"----- step 5: returns tac =  ---";
neuper@38065
    92
neuper@38065
    93
(*========== inhibit exn =======================================================
neuper@38065
    94
(*oldNB stops here as well*)
neuper@38065
    95
val (str, ([(tac, _, _)], _, (pt, p))) = step p ((pt, e_pos'), []);
neuper@38065
    96
"----- step 6: returns tac =  ---";
neuper@38065
    97
val (str, ([(tac, _, _)], _, (pt, p))) = step p ((pt, e_pos'), []);
neuper@38065
    98
"----- step 7: returns tac =  ---";
neuper@38065
    99
val (str, ([(tac, _, _)], _, (pt, p))) = step p ((pt, e_pos'), []);
neuper@38065
   100
"----- step 8: returns tac =  ---";
neuper@38065
   101
val (str, ([(tac, _, _)], _, (pt, p))) = step p ((pt, e_pos'), []);
neuper@38065
   102
============ inhibit exn =====================================================*)
neuper@38065
   103
neuper@38065
   104
neuper@38065
   105
"----------- fun autocalc -------------------------------";
neuper@38065
   106
"----------- fun autocalc -------------------------------";
neuper@38065
   107
"----------- fun autocalc -------------------------------";
neuper@38065
   108
val p = e_pos'; val c = []; 
neuper@38065
   109
val (p,_,f,nxt,_,pt) = 
neuper@38065
   110
    CalcTreeTEST 
neuper@38065
   111
        [(["functionTerm (x^^^2 + 1)", "integrateBy x", "antiDerivative FF"], 
neuper@38065
   112
          ("Integrate",["integrate","function"], ["diff","integration"]))];
neuper@38065
   113
tracing "----- step 1 ---";
neuper@38065
   114
val (str, cut, (pt, p)) = autocalc [] p ((pt, e_pos'),[]) (Step 1); show_pt pt;
neuper@38065
   115
tracing "----- step 2 ---";
neuper@38065
   116
val (str, cut, (pt, p)) = autocalc [] p ((pt, e_pos'),[]) (Step 1); show_pt pt;
neuper@38065
   117
tracing "----- step 3 ---";
neuper@38065
   118
val (str, cut, (pt, p)) = autocalc [] p ((pt, e_pos'),[]) (Step 1); show_pt pt;
neuper@38065
   119
tracing "----- step 4 ---";
neuper@38065
   120
val (str, cut, (pt, p)) = autocalc [] p ((pt, e_pos'),[]) (Step 1); show_pt pt;
neuper@38065
   121
tracing "----- step 5 ---";
neuper@38065
   122
val (str, cut, (pt, p)) = autocalc [] p ((pt, e_pos'),[]) (Step 1); show_pt pt;
neuper@38065
   123
tracing "----- step 6 ---";
neuper@38065
   124
val (str, cut, (pt, p)) = autocalc [] p ((pt, e_pos'),[]) (Step 1); show_pt pt;
neuper@38065
   125
tracing "----- step 7 ---";
neuper@38065
   126
val (str, cut, (pt, p)) = autocalc [] p ((pt, e_pos'),[]) (Step 1); show_pt pt;
neuper@38065
   127
tracing "----- step 8 ---";
neuper@38065
   128
val (str, cut, (pt, p)) = autocalc [] p ((pt, e_pos'),[]) (Step 1); show_pt pt;
neuper@38065
   129
if str = "end-of-calculation" then ()
neuper@38065
   130
else error "mathengine.sml -- fun autocalc -- end";
neuper@38065
   131
-.-.-.-.-.-.-isolate response.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.*)
neuper@38065
   132
neuper@38065
   133
neuper@38065
   134
"----------- fun autoCalculate -----------------------------------";
neuper@38065
   135
"----------- fun autoCalculate -----------------------------------";
neuper@38065
   136
"----------- fun autoCalculate -----------------------------------";
neuper@38065
   137
states := [];
neuper@38065
   138
CalcTree (*ATTENTION: encode_fmz ... unlike CalcTreeTEST*)
neuper@38065
   139
    [(["functionTerm (x^2 + 1)", "integrateBy x", "antiDerivative FF"],
neuper@38065
   140
      ("Integrate", ["integrate", "function"], ["diff", "integration"]))];
neuper@38065
   141
Iterator 1;
neuper@38065
   142
moveActiveRoot 1;
neuper@38065
   143
autoCalculate 1 (Step 1); 
neuper@38065
   144
"----- step 1 ---";
neuper@38065
   145
autoCalculate 1 (Step 1);
neuper@38065
   146
"----- step 2 ---";
neuper@38065
   147
autoCalculate 1 (Step 1);
neuper@38065
   148
"----- step 3 ---";
neuper@38065
   149
autoCalculate 1 (Step 1);
neuper@38065
   150
"----- step 4 ---";
neuper@38065
   151
autoCalculate 1 (Step 1);
neuper@38065
   152
"----- step 5 ---";
neuper@38065
   153
autoCalculate 1 (Step 1);
neuper@38065
   154
"----- step 6 ---";
neuper@38065
   155
autoCalculate 1 (Step 1);
neuper@38065
   156
"----- step 7 ---";
neuper@38065
   157
autoCalculate 1 (Step 1);
neuper@38065
   158
"----- step 8 ---";
neuper@38065
   159
autoCalculate 1 (Step 1);
neuper@38065
   160
val (ptp as (_, p), _) = get_calc 1;
neuper@38065
   161
val (Form t,_,_) = pt_extract ptp;
neuper@38065
   162
if term2str t = "c + x + 1 / 3 * x ^^^ 3" andalso p = ([], Res) then ()
neuper@38065
   163
else error "mathengine.sml -- fun autoCalculate -- end";
neuper@38065
   164
neuper@38065
   165
(*-.-.-.-.-.-isolate response.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
neuper@38065
   166
-.-.-.-.-.-.-isolate response.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.*)