test/Tools/isac/BridgeLibisabelle/use-cases.sml
author Walther Neuper <walther.neuper@jku.at>
Mon, 25 Nov 2019 16:39:52 +0100
changeset 59718 bc4b000caa39
parent 59694 2f86079ee85a
child 59719 568ea658e026
permissions -rw-r--r--
lucin: renaming in scanning the parse-tree
neuper@52113
     1
(* Title:  tests the interface of isac's SML-kernel in accordance to 
neuper@52113
     2
           java-tests/isac.bridge.
neuper@52113
     3
   Author: Walther Neuper
neuper@52113
     4
   (c) copyright due to lincense terms.
neuper@52113
     5
neuper@52113
     6
WN050707 ... if true, the test ist marked with a \label referring
neuper@52113
     7
to the same UC in isac-docu.tex as the JUnit testcase.
neuper@52113
     8
WN120210?not ME: added some labels, which are not among the above,
neuper@52113
     9
repaired lost \label (s).
wneuper@59127
    10
wneuper@59465
    11
theory Test_Some imports Isac.Build_Thydata begin 
wneuper@59127
    12
ML {* KEStore_Elems.set_ref_thy @{theory};
wneuper@59127
    13
  fun autoCalculate' cI auto = autoCalculate cI auto (*|> Future.join*) *}
wneuper@59127
    14
ML_file "Frontend/use-cases.sml"
neuper@52113
    15
*)
neuper@52113
    16
neuper@52113
    17
"--------------------------------------------------------";
neuper@52113
    18
"table of contents --------------------------------------";
neuper@52113
    19
"--------------------------------------------------------";
neuper@52113
    20
"within struct ------------------------------------------";
neuper@52113
    21
"--------------------------------------------------------";
neuper@52113
    22
"--------- encode ^ -> ^^^ ------------------------------";
neuper@52113
    23
"--------------------------------------------------------";
neuper@52113
    24
"exported from struct -----------------------------------";
neuper@52113
    25
"--------------------------------------------------------";
neuper@52113
    26
"--------- empty rootpbl --------------------------------";
neuper@52113
    27
"--------- solve_linear as rootpbl FE -------------------";
neuper@52113
    28
"--------- inspect the CalcTree No.1 with Iterator No.2 -";
neuper@52113
    29
"--------- miniscript with mini-subpbl ------------------";
neuper@52113
    30
"--------- mini-subpbl AUTOCALCULATE Step 1 -------------";
neuper@52113
    31
"--------- solve_linear as rootpbl AUTO CompleteCalc ----";
neuper@52113
    32
"--------- solve_linear as rootpbl AUTO CompleteHead/Calc ";
neuper@52113
    33
"--------- mini-subpbl AUTOCALCULATE CompleteCalc -------";
neuper@52113
    34
"--------- mini-subpbl AUTO CompleteCalcHead ------------";
neuper@52113
    35
"--------- solve_linear as rootpbl AUTO CompleteModel ---";
neuper@52113
    36
"--------- setContext..Thy ------------------------------";
neuper@52113
    37
"--------- mini-subpbl AUTOCALC CompleteToSubpbl --------";
neuper@52113
    38
"--------- rat-eq + subpbl: no_met, NO solution dropped -";
neuper@52113
    39
"--------- tryMatchProblem, tryRefineProblem ------------";
neuper@52113
    40
"--------- modifyCalcHead, resetCalcHead, modelProblem --";
neuper@52113
    41
"--------- maximum-example, UC: Modeling an example -----";
neuper@52113
    42
"--------- solve_linear from pbl-hierarchy --------------";
neuper@52113
    43
"--------- solve_linear as in an algebra system (CAS)----";
neuper@52113
    44
"--------- interSteps: on 'miniscript with mini-subpbl' -";
neuper@52113
    45
"--------- getTactic, fetchApplicableTactics ------------";
neuper@52113
    46
"--------- getAssumptions, getAccumulatedAsms -----------";
neuper@52113
    47
"--------- arbitrary combinations of steps --------------";
neuper@52113
    48
"--------- appendF label{SOLVE:MANUAL:FORMULA:enter}right";
neuper@52113
    49
"--------- appendF label{SOLVE:MANUAL:FORMULA:enter}other";
neuper@52113
    50
"--------- appendF label{SOLVE:MANUAL:FORMULA:enter}oth 2";
neuper@52113
    51
"--------- appendF label{SOLVE:MANUAL:FORMULA:enter}NOTok";
neuper@52113
    52
"--------- replaceFormula {SOL:MAN:FOR:replace} right----";
neuper@52113
    53
"--------- replaceFormula {SOL:MAN:FOR:replace} other----";
neuper@52113
    54
"--------- replaceFormula {SOL:MAN:FOR:replace} other 2--";
neuper@52113
    55
"--------- replaceFormula {SOL:MAN:FOR:replace} NOTok----";
neuper@52113
    56
"--------- UC errpat chain-rule-diff-both, fillpat by input ------";
neuper@52113
    57
"--------- UC errpat add-fraction, fillpat by input --------------";
neuper@52113
    58
"--------- UC errpat, fillpat step to Rewrite --------------------";
neuper@52113
    59
"--------- UC errpat, fillpat step to Rewrite_Set ----------------";
neuper@52113
    60
"--------------------------------------------------------";
neuper@52113
    61
neuper@52113
    62
"within struct ---------------------------------------------------";
neuper@52113
    63
"within struct ---------------------------------------------------";
neuper@52113
    64
"within struct ---------------------------------------------------";
neuper@52113
    65
(*==================================================================
neuper@52113
    66
neuper@52113
    67
neuper@52113
    68
"--------- encode ^ -> ^^^ ------------------------------";
neuper@52113
    69
"--------- encode ^ -> ^^^ ------------------------------";
neuper@52113
    70
"--------- encode ^ -> ^^^ ------------------------------";
neuper@52113
    71
if encode "a^2+b^2=c^2" = "a^^^2+b^^^2=c^^^2" then ()
neuper@52113
    72
else error "interface.sml: diff.behav. in encode ^ -> ^^^ ";
neuper@52113
    73
neuper@52113
    74
if (decode o encode) "a^2+b^2=c^2" = "a^2+b^2=c^2" then ()
neuper@52113
    75
else error "interface.sml: diff.behav. in de/encode ^ <-> ^^^ ";
neuper@52113
    76
neuper@52113
    77
==================================================================*)
neuper@52113
    78
"exported from struct --------------------------------------------";
neuper@52113
    79
"exported from struct --------------------------------------------";
neuper@52113
    80
"exported from struct --------------------------------------------";
neuper@52113
    81
neuper@52113
    82
neuper@52113
    83
(*------------ set at startup of the Kernel ----------------------*)
wneuper@59253
    84
reset_states ();  (*resets all state information in Kernel        *)
neuper@52113
    85
(*----------------------------------------------------------------*)
neuper@52113
    86
neuper@52113
    87
"--------- empty rootpbl --------------------------------";
neuper@52113
    88
"--------- empty rootpbl --------------------------------";
neuper@52113
    89
"--------- empty rootpbl --------------------------------";
neuper@52113
    90
 CalcTree [([], ("", [], []))];
neuper@52113
    91
 Iterator 1;
neuper@52113
    92
 moveActiveRoot 1;
neuper@52113
    93
 refFormula 1 (get_pos 1 1);
neuper@52113
    94
(*WN.040222: stoert das sehr, dass e_domID etc. statt leer kommt ???*)
neuper@52113
    95
DEconstrCalcTree 1;
neuper@52113
    96
neuper@52113
    97
"--------- solve_linear as rootpbl FE -------------------";
neuper@52113
    98
"--------- solve_linear as rootpbl FE -------------------";
neuper@52113
    99
"--------- solve_linear as rootpbl FE -------------------";
wneuper@59569
   100
reset_states ();
wneuper@59569
   101
neuper@52113
   102
 CalcTree      (*start of calculation, return No.1*)
neuper@52113
   103
     [(["equality (1+-1*2+x=(0::real))", "solveFor x","solutions L"],
neuper@52113
   104
       ("Test", 
neuper@55279
   105
	["LINEAR","univariate","equation","test"],
neuper@52113
   106
	["Test","solve_linear"]))];
neuper@52113
   107
 Iterator 1;     (*create an active Iterator on CalcTree No.1*)
neuper@52113
   108
 
neuper@52113
   109
 moveActiveRoot 1;(*sets the CalcIterator No.1 at the root of CalcTree No.1*);
neuper@52113
   110
 refFormula 1 (get_pos 1 1)  (*gets CalcHead; model is still empty*);
neuper@52113
   111
 
neuper@52113
   112
wneuper@59569
   113
(*1*) fetchProposedTactic 1 (*by using Iterator No.1*);
neuper@52113
   114
 setNextTactic 1 (Model_Problem); (*by using Iterator No.1*)
wneuper@59248
   115
 autoCalculate 1 (Step 1);
neuper@52113
   116
 refFormula 1 (get_pos 1 1)  (*model contains descriptions for all items*);
wneuper@59248
   117
 autoCalculate 1 (Step 1);
neuper@52113
   118
(*-----since Model_Problem + complete_mod_ in case cas of SOME-----*
wneuper@59569
   119
(*2*)  fetchProposedTactic 1;
neuper@52113
   120
 setNextTactic 1 (Add_Given "equality (1 + -1 * 2 + x = 0)");
wneuper@59248
   121
 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1); (*equality added*);
neuper@52113
   122
wneuper@59569
   123
(*3*)  fetchProposedTactic 1;
neuper@52113
   124
 setNextTactic 1 (Add_Given "solveFor x");
wneuper@59248
   125
 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
neuper@52113
   126
wneuper@59569
   127
(*4*)  fetchProposedTactic 1;
neuper@52113
   128
 setNextTactic 1 (Add_Find "solutions L");
wneuper@59248
   129
 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
neuper@52113
   130
wneuper@59569
   131
(*5*)  fetchProposedTactic 1;
neuper@52113
   132
 setNextTactic 1 (Specify_Theory "Test");
wneuper@59248
   133
 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
neuper@52113
   134
*-----since Model_Problem + complete_mod_ in case cas of SOME-----*)
neuper@52113
   135
wneuper@59569
   136
(*6*)  fetchProposedTactic 1;
neuper@55279
   137
 setNextTactic 1 (Specify_Problem ["LINEAR","univariate","equation","test"]);
wneuper@59248
   138
 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
neuper@52113
   139
(*-------------------------------------------------------------------------*)
wneuper@59569
   140
(*7*)  fetchProposedTactic 1;
neuper@52113
   141
 val (ptp as (pt,p), tacis) = get_calc 1; get_pos 1 1;
neuper@52113
   142
neuper@52113
   143
 setNextTactic 1 (Specify_Method ["Test","solve_linear"]);
neuper@52113
   144
 val (ptp as (pt,p), tacis) = get_calc 1; get_pos 1 1;
neuper@52113
   145
wneuper@59248
   146
 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
neuper@52113
   147
 val (ptp as (pt,p), tacis) = get_calc 1; get_pos 1 1;
neuper@52113
   148
neuper@52113
   149
(*-------------------------------------------------------------------------*)
wneuper@59569
   150
(*8*)  fetchProposedTactic 1;
neuper@52113
   151
 val (ptp as (pt,p), tacis) = get_calc 1; get_pos 1 1;
neuper@52113
   152
wneuper@59569
   153
(*8*)  setNextTactic 1 (Apply_Method ["Test","solve_linear"]);
neuper@52113
   154
   (*ERROR.110620 <SETNEXTTACTIC>..<MESSAGE> end-of-calculation*)
neuper@52113
   155
 val (ptp as (pt,p), tacis) = get_calc 1; get_pos 1 1;
neuper@52113
   156
 is_complete_mod ptp;
neuper@52113
   157
 is_complete_spec ptp;
neuper@52113
   158
wneuper@59569
   159
(*8*)  autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1); (*<---------------------- orig. test code*)
wneuper@59569
   160
wneuper@59569
   161
 val (ptp as (pt,p), tacis) = get_calc 1; get_pos 1 1; (*<---------------------- orig. test code*)
wneuper@59569
   162
(*+isa=REP*) if p = ([1], Frm) andalso term2str (get_obj g_form pt [1]) = "1 + -1 * 2 + x = 0"
wneuper@59569
   163
andalso istate2str (get_istate pt p)
walther@59718
   164
  = "Pstate ([\"\n(e_e, 1 + -1 * 2 + x = 0)\",\"\n(v_v, x)\"], [], e_rls, NONE, \n??.empty, ORundef, AppUndef_, true)"
wneuper@59569
   165
then () else error "refFormula =   1 + -1 * 2 + x = 0   changed";
neuper@52113
   166
(*-------------------------------------------------------------------------*)
neuper@52113
   167
wneuper@59569
   168
(*9*) fetchProposedTactic 1; (*<----------------------------------------------------- orig. test code*)
wneuper@59569
   169
(*+\\------------------------------------------ isa == REP -----------------------------------//* )
wneuper@59569
   170
(*+//========================================== isa <> REP (1) ===============================\\*)
wneuper@59569
   171
(*9*) setNextTactic 1 (Rewrite_Set_Inst (["(''bdv'',x)"], "isolate_bdv")); ( *<------- orig. test code*)
neuper@52113
   172
wneuper@59569
   173
"~~~~~ fun setNextTactic , args:"; val (cI, tac) = (1, (Rewrite_Set_Inst (["(''bdv'',x)"], "isolate_bdv")));
wneuper@59569
   174
    val ((pt'''''_', _), _) = get_calc cI
wneuper@59569
   175
    val ip'''''_' = get_pos cI 1;
wneuper@59569
   176
wneuper@59569
   177
    val xxxxx_x(*"ok", (tacis, _, _)*) = (*case*) Math_Engine.locatetac tac (pt'''''_', ip'''''_') (*of*);
wneuper@59569
   178
(*+isa+REP*)val ("ok", ( [ (Rewrite_Set_Inst (["(''bdv'', x)"], "isolate_bdv"),
wneuper@59569
   179
     Rewrite_Set_Inst' _, (pos', (istate, ctxt))) ] , _, cstate)) = xxxxx_x;
wneuper@59569
   180
wneuper@59569
   181
(*//******************* locatetac returns tac_ + istate + cstate *****************************\\*)
wneuper@59571
   182
locatetac : Tactic.input -> state -> string * (taci list * pos' list * state);
wneuper@59569
   183
if istate2str istate
walther@59718
   184
 = "Pstate ([\"\n(e_e, 1 + -1 * 2 + x = 0)\",\"\n(v_v, x)\"], [R,L,R,L,R,L,R], e_rls, SOMEe_e, \nx = 0 + -1 * (1 + -1 * 2), ORundef, AppUndef_, true)"
wneuper@59569
   185
then () else error "from locatetac return --- changed 1";
wneuper@59569
   186
wneuper@59569
   187
if istate2str (get_istate (fst cstate) (snd cstate))
walther@59718
   188
 = "Pstate ([\"\n(e_e, 1 + -1 * 2 + x = 0)\",\"\n(v_v, x)\"], [R,L,R,L,R,L,R], e_rls, SOMEe_e, \nx = 0 + -1 * (1 + -1 * 2), ORundef, AppUndef_, true)"
wneuper@59569
   189
then () else error "from locatetac return --- changed 2";
wneuper@59569
   190
(*\\******************* locatetac returns tac_ + istate + cstate *****************************//*)
wneuper@59569
   191
wneuper@59569
   192
"~~~~~ fun locatetac , args:"; val (tac, (ptp as (pt, p))) = (tac, (pt'''''_', ip'''''_'));
wneuper@59569
   193
      val (mI, m) = Solve.mk_tac'_ tac;
wneuper@59569
   194
      val Chead.Appl m = (*case*) Applicable.applicable_in p pt m (*of*);
wneuper@59569
   195
      (*if*) member op = Solve.specsteps mI; (*else*)
wneuper@59569
   196
wneuper@59569
   197
        (*val Updated (cs' as (_, _, (_, p'))) =*) loc_solve_ (mI,m) ptp;
wneuper@59569
   198
"~~~~~ fun loc_solve_ , args:"; val (m, (pt, pos)) = ((mI,m), ptp); 
wneuper@59569
   199
wneuper@59569
   200
"~~~~~ fun solve , args:"; val ((_, m), (pt, po as (p, p_))) = (m, (pt, pos));
wneuper@59569
   201
    (*if*) Celem.e_metID = get_obj g_metID pt (par_pblobj pt p); (*else*)
wneuper@59569
   202
	      val thy' = get_obj g_domID pt (par_pblobj pt p);
wneuper@59569
   203
	      val (srls, is, sc) = Lucin.from_pblobj_or_detail' thy' (p,p_) pt;
walther@59655
   204
        val Safe_Step (istate, _, tac) =
wneuper@59569
   205
          (*case*) LucinNEW.locate_input_tactic sc (pt, po) (fst is) (snd is) m (*of*);
wneuper@59569
   206
walther@59655
   207
(*+*)Safe_Step: Istate.T * Proof.context * T -> input_tactic_result;
wneuper@59569
   208
(********************* locate_input_tactic returns cstate * istate * Proof.context  *************)
wneuper@59569
   209
(*+*)if istate2str istate
walther@59718
   210
(*+isa*) = "Pstate ([\"\n(e_e, 1 + -1 * 2 + x = 0)\",\"\n(v_v, x)\"], [R,L,R,L,R,L,R], e_rls, SOMEe_e, \nx = 0 + -1 * (1 + -1 * 2), ORundef, AppUndef_, true)"
wneuper@59569
   211
then case m of Rewrite_Set_Inst' _ => ()
wneuper@59569
   212
else error "from locate_input_tactic return --- changed";
wneuper@59569
   213
wneuper@59569
   214
val ("ok", (tacis'''''_', _, _)) = xxxxx_x;
wneuper@59569
   215
"~~~~~ from TOPLEVEL to states return:"; upd_calc cI ((pt'''''_', ip'''''_'), tacis'''''_');
wneuper@59569
   216
(*\\=========================================== isa <> REP (1) ===============================//*)
wneuper@59569
   217
(*//=========================================== isa <> REP (2) ===============================\\*)
wneuper@59569
   218
(*9* ) autoCalculate 1 (Step 1); (*<-------------------------------------------------- orig. test code*)
wneuper@59569
   219
( *isa: <AUTOCALC><CALCID>1</CALCID><CALCCHANGED><UNCHANGED><INTLIST><INT>1</INT></INTLIST><POS>Frm</POS></UNCHANGED><DELETED><INTLIST><INT>1</INT></INTLIST><POS>Frm</POS></DELETED><GENERATED><INTLIST><INT>1</INT></INTLIST><POS>Res</POS></GENERATED></CALCCHANGED></AUTOCALC>*)
wneuper@59569
   220
wneuper@59569
   221
"~~~~~ fun autoCalculate , args:"; val (cI, auto) = (1, (Step 1));
wneuper@59569
   222
     val pold = get_pos cI 1;
wneuper@59569
   223
     val xxx = (get_calc cI);
wneuper@59569
   224
(*isa*) val (**)xxxx(**) (**) = (**) 
wneuper@59569
   225
       (*case*) Math_Engine.autocalc [] pold (xxx) auto (*of*);
wneuper@59569
   226
"~~~~~ fun autocalc , args:"; val (c, ip, cs, (Solve.Step s)) = ([], pold, (xxx), auto);
wneuper@59569
   227
    (*if*) s <= 1; (*then*)
wneuper@59569
   228
    (*val (str, (_, c', ptp)) =*) step ip cs;
wneuper@59569
   229
wneuper@59569
   230
"~~~~~ fun step , args:"; val ((ip as (_, p_)), (ptp as (pt,p), tacis)) = (ip, cs);
wneuper@59569
   231
wneuper@59569
   232
(*+isa==REP*)val [(Rewrite_Set_Inst (["(''bdv'', x)"], "isolate_bdv"),
wneuper@59569
   233
     Rewrite_Set_Inst' _, (pos', (istate, ctxt)))] = tacis;
wneuper@59569
   234
(*+*)if pos' = ([1], Res) andalso istate2str istate
walther@59718
   235
 = "Pstate ([\"\n(e_e, 1 + -1 * 2 + x = 0)\",\"\n(v_v, x)\"], [R,L,R,L,R,L,R], e_rls, SOMEe_e, \nx = 0 + -1 * (1 + -1 * 2), ORundef, AppUndef_, true)"
wneuper@59569
   236
then () else error "init. step 1 + -1 * 2 + x = 0 changed";
wneuper@59569
   237
wneuper@59569
   238
       val pIopt = get_pblID (pt,ip);
walther@59694
   239
       (*if*) ip = ([], Pos.Res);(*else*)
wneuper@59569
   240
         val (_::_) = (*case*) tacis (*of*);
wneuper@59569
   241
(*isa==REP*)    (*if*) ip = p;(*then*)
wneuper@59569
   242
           (*val (pt',c',p') =*) Generate.generate tacis (pt,[],p);
wneuper@59569
   243
(*//------------------------------------- final test -----------------------------------------\\*)
wneuper@59569
   244
val ("ok", [], ptp as (pt, p)) = xxxx;
walther@59680
   245
                                         
wneuper@59569
   246
if istate2str (get_istate pt p) (*                <>                 <>                 <>                 <>                     ^^^^^^^^^^^^^*)
walther@59718
   247
(*REP*) = "Pstate ([\"\n(e_e, 1 + -1 * 2 + x = 0)\",\"\n(v_v, x)\"], [R,L,R,L,R,L,R], e_rls, SOMEe_e, \nx = 0 + -1 * (1 + -1 * 2), ORundef, AppUndef_, true)"
wneuper@59569
   248
then () else error "REP autoCalculate on (e_e, 1 + -1 * 2 + x = 0) changed"
wneuper@59569
   249
wneuper@59569
   250
"~~~~~ from TOPLEVEL to states return:";  upd_calc cI (ptp, []); upd_ipos cI 1 p;
wneuper@59569
   251
(*\\=========================================== isa <> REP (2) ===============================//*)
wneuper@59569
   252
wneuper@59569
   253
(*10*)  fetchProposedTactic 1;
neuper@52113
   254
 setNextTactic 1 (Rewrite_Set "Test_simplify");
wneuper@59248
   255
 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
neuper@52113
   256
wneuper@59569
   257
(*11*)  fetchProposedTactic 1;
neuper@55279
   258
 setNextTactic 1 (Check_Postcond ["LINEAR","univariate","equation","test"]);
wneuper@59248
   259
 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
neuper@52113
   260
wneuper@59569
   261
(*======= final test ==================================================*)
neuper@52113
   262
 val ((pt,_),_) = get_calc 1;
neuper@52113
   263
 val ip = get_pos 1 1;
wneuper@59569
   264
neuper@52113
   265
 val (Form f, tac, asms) = pt_extract (pt, ip);
neuper@52113
   266
     (*exception just above means: 'ModSpec' has been returned: error anyway*)
wneuper@59569
   267
 if ip = ([], Res) andalso term2str f = "[x = 1]" then () else 
neuper@52113
   268
 error "FE-Kernel-interface.sml: diff.behav. in solve_linear as rootpbl";
neuper@52113
   269
wneuper@59569
   270
neuper@52113
   271
"--------- inspect the CalcTree No.1 with Iterator No.2 -";
neuper@52113
   272
"--------- inspect the CalcTree No.1 with Iterator No.2 -";
neuper@52113
   273
"--------- inspect the CalcTree No.1 with Iterator No.2 -";
neuper@52113
   274
(*WN041118: inspection shifted to Iterator No.1, because others need pos'*)
wneuper@59569
   275
(*-------- WN190723: doesnt work since changeset 59474	21d4d2868b83
neuper@52113
   276
 moveActiveRoot 1; 
neuper@52113
   277
 refFormula 1 ([],Pbl); getTactic 1 ([],Pbl);(*Error*)
neuper@52113
   278
 moveActiveDown 1; 
neuper@52113
   279
 refFormula 1 ([1],Frm); getTactic 1 ([1],Frm);(*Error*)
neuper@52113
   280
 moveActiveDown 1 ; 
neuper@52113
   281
 refFormula 1 ([1],Res); getTactic 1 ([1],Res);(*OK*) 
neuper@52113
   282
 (*getAssumption 1 ([1],Res); TODO.WN041217*)
neuper@52113
   283
 moveActiveDown 1 ; refFormula 1 ([2],Res);
neuper@52113
   284
 moveActiveCalcHead 1; refFormula 1 ([],Pbl);
neuper@52113
   285
 moveActiveDown 1;
neuper@52113
   286
 moveActiveDown 1;
neuper@52113
   287
 moveActiveDown 1;
neuper@52113
   288
 if get_pos 1 1 = ([2], Res) then () else 
neuper@52113
   289
 error "FE-interface.sml: diff.behav. in a inspect 1 with Iterator 2";
neuper@52113
   290
 moveActiveDown 1; refFormula 1 ([], Res);
neuper@52113
   291
 if get_pos 1 1 = ([], Res) then () else 
neuper@52113
   292
 error "FE-interface.sml: diff.behav. in b inspect 1 with Iterator 2";
neuper@52113
   293
 moveActiveCalcHead 1; refFormula 1 ([],Pbl);
neuper@52113
   294
DEconstrCalcTree 1;
wneuper@59569
   295
------------------------------------------------------------------------------------------------*)
neuper@52113
   296
neuper@52113
   297
"--------- miniscript with mini-subpbl ------------------";
neuper@52113
   298
"--------- miniscript with mini-subpbl ------------------";
neuper@52113
   299
"--------- miniscript with mini-subpbl ------------------";
neuper@52113
   300
(*WN120210?not ME:\label{SOLVE:MANUAL:TACTIC:enter} UC 30.3.2.1 p.175 !!!!!NOT IMPL IN FE*)
neuper@52113
   301
"=== this sequence of fun-calls resembles fun me ===";
neuper@52113
   302
 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"], 
neuper@52113
   303
   ("Test", ["sqroot-test","univariate","equation","test"],
neuper@52113
   304
    ["Test","squ-equ-test-subpbl1"]))];
neuper@52113
   305
 Iterator 1;
neuper@52113
   306
neuper@52113
   307
 moveActiveRoot 1; 
neuper@52113
   308
 refFormula 1 (get_pos 1 1);
neuper@52113
   309
 fetchProposedTactic 1;
neuper@52113
   310
 setNextTactic 1 (Model_Problem);
wneuper@59248
   311
 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*gets ModSpec;model is still empty*)
neuper@52113
   312
neuper@52113
   313
 fetchProposedTactic 1;
neuper@52113
   314
 setNextTactic 1 (Add_Given "equality (x + 1 = 2)");
wneuper@59248
   315
 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
neuper@52113
   316
neuper@52113
   317
 fetchProposedTactic 1;
neuper@52113
   318
 setNextTactic 1 (Add_Given "solveFor x");
wneuper@59248
   319
 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
neuper@52113
   320
neuper@52113
   321
 fetchProposedTactic 1;
neuper@52113
   322
 setNextTactic 1 (Add_Find "solutions L");
wneuper@59248
   323
 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
neuper@52113
   324
neuper@52113
   325
 fetchProposedTactic 1;
neuper@52113
   326
 setNextTactic 1 (Specify_Theory "Test");
wneuper@59248
   327
 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
neuper@52113
   328
neuper@52113
   329
 fetchProposedTactic 1;
neuper@52113
   330
 setNextTactic 1 (Specify_Problem 
neuper@52113
   331
		      ["sqroot-test","univariate","equation","test"]);
wneuper@59248
   332
 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
neuper@52113
   333
"1-----------------------------------------------------------------";
neuper@52113
   334
neuper@52113
   335
 fetchProposedTactic 1;
neuper@52113
   336
 setNextTactic 1 (Specify_Method ["Test","squ-equ-test-subpbl1"]);
wneuper@59248
   337
 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
neuper@52113
   338
neuper@52113
   339
 fetchProposedTactic 1;
neuper@52113
   340
 setNextTactic 1 (Apply_Method ["Test","squ-equ-test-subpbl1"]);
wneuper@59248
   341
 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
neuper@52113
   342
neuper@52113
   343
 fetchProposedTactic 1;
neuper@52113
   344
 setNextTactic 1 (Rewrite_Set "norm_equation");
wneuper@59248
   345
 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
neuper@52113
   346
neuper@52113
   347
 fetchProposedTactic 1;
neuper@52113
   348
 setNextTactic 1 (Rewrite_Set "Test_simplify");
wneuper@59248
   349
 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
neuper@52113
   350
neuper@52113
   351
 fetchProposedTactic 1;(*----------------Subproblem--------------------*);
neuper@52113
   352
 setNextTactic 1 (Subproblem ("Test",
neuper@55279
   353
			      ["LINEAR","univariate","equation","test"]));
wneuper@59248
   354
 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
neuper@52113
   355
neuper@52113
   356
 fetchProposedTactic 1;
neuper@52113
   357
 setNextTactic 1 (Model_Problem );
wneuper@59248
   358
 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
neuper@52113
   359
neuper@52113
   360
 fetchProposedTactic 1;
neuper@52113
   361
 setNextTactic 1 (Add_Given "equality (-1 + x = 0)");
wneuper@59248
   362
 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
neuper@52113
   363
neuper@52113
   364
 fetchProposedTactic 1;
neuper@52113
   365
 setNextTactic 1 (Add_Given "solveFor x");
wneuper@59248
   366
 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
neuper@52113
   367
neuper@52113
   368
 fetchProposedTactic 1;
neuper@52113
   369
 setNextTactic 1 (Add_Find "solutions x_i");
wneuper@59248
   370
 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
neuper@52113
   371
neuper@52113
   372
 fetchProposedTactic 1;
neuper@52113
   373
 setNextTactic 1 (Specify_Theory "Test");
wneuper@59248
   374
 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
neuper@52113
   375
neuper@52113
   376
 fetchProposedTactic 1;
neuper@55279
   377
 setNextTactic 1 (Specify_Problem ["LINEAR","univariate","equation","test"]);
wneuper@59248
   378
 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
neuper@52113
   379
"2-----------------------------------------------------------------";
neuper@52113
   380
neuper@52113
   381
 fetchProposedTactic 1;
neuper@52113
   382
 setNextTactic 1 (Specify_Method ["Test","solve_linear"]);
wneuper@59248
   383
 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
neuper@52113
   384
neuper@52113
   385
 fetchProposedTactic 1;
neuper@52113
   386
 setNextTactic 1 (Apply_Method ["Test","solve_linear"]);
wneuper@59248
   387
 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
neuper@52113
   388
neuper@52113
   389
 fetchProposedTactic 1;
wneuper@59497
   390
 setNextTactic 1 (Rewrite_Set_Inst (["(''bdv'',x)"], "isolate_bdv"));
wneuper@59248
   391
 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
neuper@52113
   392
neuper@52113
   393
 fetchProposedTactic 1;
neuper@52113
   394
 setNextTactic 1 (Rewrite_Set "Test_simplify");
wneuper@59248
   395
 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
neuper@52113
   396
neuper@52113
   397
 fetchProposedTactic 1;
neuper@55279
   398
 setNextTactic 1 (Check_Postcond ["LINEAR","univariate","equation","test"]);
wneuper@59248
   399
 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
neuper@52113
   400
neuper@52113
   401
 fetchProposedTactic 1;
neuper@52113
   402
 setNextTactic 1 (Check_elementwise "Assumptions");
wneuper@59248
   403
 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
neuper@52113
   404
neuper@52113
   405
 val xml = fetchProposedTactic 1;
neuper@52113
   406
 setNextTactic 1 (Check_Postcond 
neuper@52113
   407
		      ["sqroot-test","univariate","equation","test"]);
wneuper@59248
   408
 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
neuper@52113
   409
neuper@52113
   410
 val ((pt,_),_) = get_calc 1;
wneuper@59279
   411
 val str = pr_ctree pr_short pt;
neuper@52113
   412
 writeln str;
neuper@52113
   413
 val ip = get_pos 1 1;
neuper@52113
   414
 val (Form f, tac, asms) = pt_extract (pt, ip);
neuper@52113
   415
     (*exception just above means: 'ModSpec' has been returned: error anyway*)
neuper@52113
   416
 if term2str f = "[x = 1]" then () else 
neuper@52113
   417
 error "FE-interface.sml: diff.behav. in miniscript with mini-subpb";
neuper@52113
   418
 DEconstrCalcTree 1;
neuper@52113
   419
neuper@52113
   420
"--------- mini-subpbl AUTOCALCULATE Step 1 -------------";
neuper@52113
   421
"--------- mini-subpbl AUTOCALCULATE Step 1 -------------";
neuper@52113
   422
"--------- mini-subpbl AUTOCALCULATE Step 1 -------------";
neuper@52113
   423
(*WN120210?not ME:\label{SOLVE:AUTO:one} UC 30.3.3.2 p.176*)
neuper@52113
   424
 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"], 
neuper@52113
   425
   ("Test", ["sqroot-test","univariate","equation","test"],
neuper@52113
   426
    ["Test","squ-equ-test-subpbl1"]))];
neuper@52113
   427
 Iterator 1;
neuper@52113
   428
 moveActiveRoot 1;
wneuper@59248
   429
 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
wneuper@59248
   430
 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
wneuper@59248
   431
 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
wneuper@59248
   432
 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
wneuper@59248
   433
 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
wneuper@59248
   434
 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
wneuper@59248
   435
 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
wneuper@59248
   436
 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
neuper@52113
   437
 (*here the solve-phase starts*)
wneuper@59248
   438
 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
wneuper@59248
   439
 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
wneuper@59248
   440
 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
neuper@52113
   441
 (*------------------------------------*)
wneuper@59348
   442
(* (*default_print_depth 13*) get_calc 1;
neuper@52113
   443
   *)
wneuper@59248
   444
 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
neuper@52113
   445
 (*calc-head of subproblem*)
wneuper@59248
   446
 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
wneuper@59248
   447
 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
wneuper@59248
   448
 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
wneuper@59248
   449
 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
wneuper@59248
   450
 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
wneuper@59248
   451
 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
wneuper@59248
   452
 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
neuper@52113
   453
 (*solve-phase of the subproblem*)
wneuper@59248
   454
 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
wneuper@59248
   455
 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
wneuper@59248
   456
 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
wneuper@59248
   457
 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
neuper@52113
   458
 (*finish subproblem*)
wneuper@59248
   459
 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
neuper@52113
   460
 (*finish problem*)
wneuper@59248
   461
 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1); 
neuper@52113
   462
neuper@52113
   463
 (*this checks the test for correctness..*)
neuper@52113
   464
 val ((pt,_),_) = get_calc 1;
neuper@52113
   465
 val p = get_pos 1 1;
neuper@52113
   466
 val (Form f, tac, asms) = pt_extract (pt, p);
neuper@52113
   467
 if term2str f = "[x = 1]" andalso p = ([], Res) then () else 
neuper@52113
   468
 error "FE-interface.sml: diff.behav. in miniscript with mini-subpb";
neuper@52113
   469
 DEconstrCalcTree 1;
neuper@52113
   470
neuper@52113
   471
neuper@52113
   472
"--------- solve_linear as rootpbl AUTO CompleteCalc ----";
neuper@52113
   473
"--------- solve_linear as rootpbl AUTO CompleteCalc ----";
neuper@52113
   474
"--------- solve_linear as rootpbl AUTO CompleteCalc ----";
neuper@52113
   475
(*WN120210?not ME:\label{SPECIFY:START:auto} UC 30.2.4.2 p.174*)
neuper@52113
   476
 CalcTree
neuper@52113
   477
     [(["equality (1+-1*2+x=(0::real))", "solveFor x","solutions L"],
neuper@52113
   478
       ("Test", 
neuper@55279
   479
	["LINEAR","univariate","equation","test"],
neuper@52113
   480
	["Test","solve_linear"]))];
neuper@52113
   481
 Iterator 1;
neuper@52113
   482
 moveActiveRoot 1;
neuper@52113
   483
getFormulaeFromTo 1 ([],Pbl) ([],Pbl) 999 false;
neuper@52113
   484
wneuper@59248
   485
 autoCalculate 1 CompleteCalc; 
neuper@52113
   486
 val (unc, del, gen) = (([],Pbl), ([],Pbl), ([],Res));
neuper@52113
   487
 getFormulaeFromTo 1 unc gen 1 (*only level 1*) false;
neuper@52113
   488
neuper@52113
   489
 val ((pt,_),_) = get_calc 1;
neuper@52113
   490
 val p = get_pos 1 1;
neuper@52113
   491
 val (Form f, tac, asms) = pt_extract (pt, p);
neuper@52113
   492
 if term2str f = "[x = 1]" andalso p = ([], Res) then () else 
neuper@52113
   493
 error "FE-interface.sml: diff.behav. in solve_linear/rt AUTOCALCULATE ";
neuper@52113
   494
DEconstrCalcTree 1;
neuper@52113
   495
neuper@52113
   496
"--------- solve_linear as rootpbl AUTO CompleteHead/Calc ";
neuper@52113
   497
"--------- solve_linear as rootpbl AUTO CompleteHead/Calc ";
neuper@52113
   498
"--------- solve_linear as rootpbl AUTO CompleteHead/Calc ";
neuper@52113
   499
(* ERROR: error in kernel ?? *)
neuper@52113
   500
 CalcTree
neuper@52113
   501
     [(["equality (1+-1*2+x=(0::real))", "solveFor x","solutions L"],
neuper@52113
   502
       ("Test", 
neuper@55279
   503
	["LINEAR","univariate","equation","test"],
neuper@52113
   504
	["Test","solve_linear"]))];
neuper@52113
   505
 Iterator 1;
neuper@52113
   506
 moveActiveRoot 1;
neuper@52113
   507
wneuper@59248
   508
 autoCalculate 1 CompleteCalcHead;
neuper@52113
   509
 refFormula 1 (get_pos 1 1);
neuper@52113
   510
 val ((pt,p),_) = get_calc 1;
neuper@52113
   511
wneuper@59248
   512
 autoCalculate 1 CompleteCalc; 
neuper@52113
   513
 val ((pt,p),_) = get_calc 1;
neuper@52113
   514
 if p=([], Res) then () else 
neuper@52113
   515
 error "FE-interface.sml: diff.behav. in solve_linear AUTOC Head/Calc ";
neuper@52113
   516
DEconstrCalcTree 1;
neuper@52113
   517
neuper@52113
   518
"--------- mini-subpbl AUTOCALCULATE CompleteCalc -------";
neuper@52113
   519
"--------- mini-subpbl AUTOCALCULATE CompleteCalc -------";
neuper@52113
   520
"--------- mini-subpbl AUTOCALCULATE CompleteCalc -------";
neuper@52113
   521
(*WN120210?not ME:\label{SPECIFY:START:auto} UC 30.2.4.2 p.174*)
neuper@52113
   522
 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"], 
neuper@52113
   523
   ("Test", ["sqroot-test","univariate","equation","test"],
neuper@52113
   524
    ["Test","squ-equ-test-subpbl1"]))];
neuper@52113
   525
 Iterator 1;
neuper@52113
   526
 moveActiveRoot 1;
wneuper@59248
   527
 autoCalculate 1 CompleteCalc;
neuper@52113
   528
 val ((pt,p),_) = get_calc 1; show_pt pt;
neuper@52113
   529
(*
neuper@52113
   530
getTactic 1 ([1],Frm);
neuper@52113
   531
getTactic 1 ([1],Res);
neuper@52113
   532
initContext 1 Thy_ ([1],Res);
neuper@52113
   533
*)
neuper@52113
   534
 (*... returns calcChangedEvent with*)
neuper@52113
   535
 val (unc, del, gen) = (([],Pbl), ([],Pbl), ([],Res));
neuper@52113
   536
 getFormulaeFromTo 1 unc gen 0 (*only result*) false;
neuper@52113
   537
 getFormulaeFromTo 1 unc gen 1 (*only level 1*) false;
neuper@52113
   538
 getFormulaeFromTo 1 unc gen 99999 (*all levels*) false;
neuper@52113
   539
neuper@52113
   540
 val ((pt,_),_) = get_calc 1;
neuper@52113
   541
 val p = get_pos 1 1;
neuper@52113
   542
 val (Form f, tac, asms) = pt_extract (pt, p);
neuper@52113
   543
 if term2str f = "[x = 1]" andalso p = ([], Res) then () else 
neuper@52113
   544
 error "FE-interface.sml: diff.behav. in mini-subpbl AUTOCALCULATE 6";
wneuper@59253
   545
 DEconstrCalcTree 1;
neuper@52113
   546
neuper@52113
   547
"--------- mini-subpbl AUTO CompleteCalcHead ------------";
neuper@52113
   548
"--------- mini-subpbl AUTO CompleteCalcHead ------------";
neuper@52113
   549
"--------- mini-subpbl AUTO CompleteCalcHead ------------";
neuper@52113
   550
 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"], 
neuper@52113
   551
   ("Test", ["sqroot-test","univariate","equation","test"],
neuper@52113
   552
    ["Test","squ-equ-test-subpbl1"]))];
neuper@52113
   553
 Iterator 1;
neuper@52113
   554
 moveActiveRoot 1;
wneuper@59248
   555
 autoCalculate 1 CompleteCalcHead;
neuper@52113
   556
neuper@52113
   557
val ((Nd (PblObj {env = NONE, fmz = (fm, ("Test", pblID, metID)), loc = (SOME (env, ctxt1), NONE), 
neuper@52113
   558
      cell = NONE, ctxt = ctxt2, meth,
neuper@52113
   559
      spec = ("Test", ["sqroot-test", "univariate", "equation", "test"], 
neuper@52113
   560
        ["Test", "squ-equ-test-subpbl1"]), 
neuper@52113
   561
      probl, branch = TransitiveB, origin, ostate = Incomplete, result}, []),
neuper@52113
   562
   ([], Met)), []) = get_calc 1;
neuper@52113
   563
if length meth = 3 andalso length probl = 3 (*just some items tested*) then () 
neuper@52113
   564
else error "--- mini-subpbl AUTO CompleteCalcHead ---";
neuper@52113
   565
DEconstrCalcTree 1;
neuper@52113
   566
neuper@52113
   567
"--------- solve_linear as rootpbl AUTO CompleteModel ---";
neuper@52113
   568
"--------- solve_linear as rootpbl AUTO CompleteModel ---";
neuper@52113
   569
"--------- solve_linear as rootpbl AUTO CompleteModel ---";
neuper@52113
   570
 CalcTree
neuper@52113
   571
     [(["equality (1+-1*2+x=(0::real))", "solveFor x","solutions L"],
neuper@52113
   572
       ("Test", 
neuper@55279
   573
	["LINEAR","univariate","equation","test"],
neuper@52113
   574
	["Test","solve_linear"]))];
neuper@52113
   575
 Iterator 1;
neuper@52113
   576
 moveActiveRoot 1;
wneuper@59248
   577
 autoCalculate 1 CompleteModel;  
neuper@52113
   578
 refFormula 1 (get_pos 1 1);
neuper@52113
   579
neuper@55279
   580
setProblem 1 ["LINEAR","univariate","equation","test"];
neuper@52113
   581
val pos = get_pos 1 1;
neuper@55279
   582
setContext 1 pos (kestoreID2guh Pbl_["LINEAR","univariate","equation","test"]);
neuper@52113
   583
 refFormula 1 (get_pos 1 1);
neuper@52113
   584
neuper@52113
   585
setMethod 1 ["Test","solve_linear"];
neuper@52113
   586
setContext 1 pos (kestoreID2guh Met_ ["Test","solve_linear"]);
neuper@52113
   587
 refFormula 1 (get_pos 1 1);
neuper@52113
   588
 val ((pt,_),_) = get_calc 1;
neuper@52113
   589
 if get_obj g_spec pt [] = ("e_domID", 
neuper@55279
   590
			    ["LINEAR", "univariate","equation","test"],
neuper@52113
   591
			    ["Test","solve_linear"]) then ()
neuper@52113
   592
 else error "FE-interface.sml: diff.behav. in setProblem, setMethod";
neuper@52113
   593
wneuper@59248
   594
 autoCalculate 1 CompleteCalcHead;
neuper@52113
   595
 refFormula 1 (get_pos 1 1); 
wneuper@59248
   596
 autoCalculate 1 CompleteCalc; 
neuper@52113
   597
 moveActiveDown 1;
neuper@52113
   598
 moveActiveDown 1;
neuper@52113
   599
 moveActiveDown 1;
neuper@52113
   600
 refFormula 1 (get_pos 1 1); 
neuper@52113
   601
 val ((pt,_),_) = get_calc 1;
neuper@52113
   602
 val p = get_pos 1 1;
neuper@52113
   603
 val (Form f, tac, asms) = pt_extract (pt, p);
neuper@52113
   604
 if term2str f = "[x = 1]" andalso p = ([], Res) then () else 
neuper@52113
   605
 error "FE-interface.sml: diff.behav. in mini-subpbl AUTOCALCULATE 6";
wneuper@59253
   606
 DEconstrCalcTree 1;
neuper@52113
   607
neuper@52113
   608
"--------- setContext..Thy ------------------------------";
neuper@52113
   609
"--------- setContext..Thy ------------------------------";
neuper@52113
   610
"--------- setContext..Thy ------------------------------";
neuper@52113
   611
 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"], 
neuper@52113
   612
  ("Test", ["sqroot-test","univariate","equation","test"],
neuper@52113
   613
   ["Test","squ-equ-test-subpbl1"]))];
neuper@52113
   614
 Iterator 1; moveActiveRoot 1;
wneuper@59248
   615
 autoCalculate 1 CompleteCalcHead;
wneuper@59248
   616
 autoCalculate 1 (Step 1);
neuper@52113
   617
 val ((pt,p),_) = get_calc 1;  show_pt pt; (*2 lines, OK*)
neuper@52113
   618
 (*
neuper@52113
   619
 setNextTactic 1 (Rewrite_Set "Test_simplify"); (*--> "thy_isac_Test-rls-Test_simplify"*)
wneuper@59248
   620
 autoCalculate 1 (Step 1);
neuper@52113
   621
 val ((pt,p),_) = get_calc 1;  show_pt pt;
neuper@52113
   622
 *)
neuper@52113
   623
"-----^^^^^ and vvvvv do the same -----";
neuper@52113
   624
 setContext 1 p "thy_isac_Test-rls-Test_simplify";
neuper@52113
   625
 val ((pt,p),_) = get_calc 1;  show_pt pt; (*2 lines, OK*)
neuper@52113
   626
wneuper@59248
   627
 autoCalculate 1 (Step 1);
neuper@52113
   628
 setContext 1 p "thy_isac_Test-rls-Test_simplify";
neuper@52113
   629
 val (((pt,_),_), p) = (get_calc 1, get_pos 1 1);
neuper@52113
   630
 val (Form f, tac, asms) = pt_extract (pt, p);
neuper@52113
   631
 if p = ([1], Res) andalso term2str (get_obj g_res pt (fst p)) = "x + 1 + -1 * 2 = 0"
wneuper@59248
   632
 then () else error "--- setContext..Thy --- autoCalculate 1 (Step 1) #1";
neuper@52113
   633
wneuper@59248
   634
 autoCalculate 1 CompleteCalc;
neuper@52113
   635
 val (((pt,_),_), p) = (get_calc 1, get_pos 1 1);
neuper@52113
   636
 val (Form f, tac, asms) = pt_extract (pt, p);
neuper@52113
   637
neuper@52113
   638
 if term2str f = "[x = 1]" andalso p = ([], Res) then () 
wneuper@59248
   639
  else error "--- setContext..Thy --- autoCalculate CompleteCalc";
neuper@52113
   640
 DEconstrCalcTree 1;
neuper@52113
   641
neuper@52113
   642
"--------- mini-subpbl AUTOCALC CompleteToSubpbl --------";
neuper@52113
   643
"--------- mini-subpbl AUTOCALC CompleteToSubpbl --------";
neuper@52113
   644
"--------- mini-subpbl AUTOCALC CompleteToSubpbl --------";
neuper@52113
   645
 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"], 
neuper@52113
   646
   ("Test", ["sqroot-test","univariate","equation","test"],
neuper@52113
   647
    ["Test","squ-equ-test-subpbl1"]))];
neuper@52113
   648
 Iterator 1; moveActiveRoot 1;
wneuper@59248
   649
 autoCalculate 1 CompleteToSubpbl;
neuper@52113
   650
 refFormula 1 (get_pos 1 1); (*<ISA> -1 + x = 0 </ISA>*);
neuper@52113
   651
 val ((pt,_),_) = get_calc 1;
wneuper@59279
   652
 val str = pr_ctree pr_short pt;
neuper@52113
   653
 writeln str;
neuper@52113
   654
 if str = ".    ----- pblobj -----\n1.   x + 1 = 2\n2.   x + 1 + -1 * 2 = 0\n"
neuper@52113
   655
 then () else 
neuper@52113
   656
 error "FE-interface.sml: diff.behav. in mini-subpbl CompleteToSubpbl-1";
neuper@52113
   657
wneuper@59569
   658
 autoCalculate 1 (Step 1); (*proceeds only, if NOT 1 step before subplb*)
wneuper@59248
   659
 autoCalculate 1 CompleteToSubpbl;
neuper@52113
   660
 val ((pt,_),_) = get_calc 1;
wneuper@59279
   661
 val str = pr_ctree pr_short pt;
neuper@52113
   662
 writeln str;
wneuper@59248
   663
 autoCalculate 1 CompleteCalc; (*das geht ohnehin !*);
neuper@52113
   664
 val ((pt,_),_) = get_calc 1;
neuper@52113
   665
 val p = get_pos 1 1;
neuper@52113
   666
neuper@52113
   667
 val (Form f, tac, asms) = pt_extract (pt, p);
neuper@52113
   668
 if term2str f = "[x = 1]" andalso p = ([], Res) then () else 
neuper@52113
   669
 error "FE-interface.sml: diff.behav. in mini-subpbl CompleteToSubpbl 1";
wneuper@59253
   670
 DEconstrCalcTree 1;
neuper@52113
   671
neuper@52113
   672
"--------- rat-eq + subpbl: no_met, NO solution dropped -";
neuper@52113
   673
"--------- rat-eq + subpbl: no_met, NO solution dropped -";
neuper@52113
   674
"--------- rat-eq + subpbl: no_met, NO solution dropped -";
neuper@52113
   675
 CalcTree
neuper@52113
   676
 [(["equality ((5*x)/(x - 2) - x/(x+2)=(4::real))", "solveFor x","solutions L"],
neuper@52113
   677
   ("RatEq", ["univariate","equation"], ["no_met"]))];
neuper@52113
   678
 Iterator 1;
neuper@52113
   679
 moveActiveRoot 1; 
neuper@52113
   680
 fetchProposedTactic 1;
neuper@52113
   681
neuper@52113
   682
 setNextTactic 1 (Model_Problem);
wneuper@59248
   683
 autoCalculate 1 (Step 1); fetchProposedTactic 1;
neuper@52113
   684
neuper@52113
   685
 setNextTactic 1 (Specify_Theory "RatEq");
wneuper@59248
   686
 autoCalculate 1 (Step 1); fetchProposedTactic 1;
neuper@52113
   687
 setNextTactic 1 (Specify_Problem ["rational","univariate","equation"]);
wneuper@59248
   688
 autoCalculate 1 (Step 1); fetchProposedTactic 1;
neuper@52113
   689
 setNextTactic 1 (Specify_Method ["RatEq","solve_rat_equation"]);
wneuper@59248
   690
 autoCalculate 1 (Step 1); fetchProposedTactic 1;
neuper@52113
   691
 setNextTactic 1 (Apply_Method ["RatEq","solve_rat_equation"]);
wneuper@59248
   692
 autoCalculate 1 (Step 1); fetchProposedTactic 1;
neuper@52113
   693
 setNextTactic 1 (Rewrite_Set "RatEq_simplify");
wneuper@59248
   694
 autoCalculate 1 (Step 1); fetchProposedTactic 1;
neuper@52113
   695
 setNextTactic 1 (Rewrite_Set "norm_Rational");
wneuper@59248
   696
 autoCalculate 1 (Step 1); fetchProposedTactic 1;
neuper@52113
   697
 setNextTactic 1 (Rewrite_Set "RatEq_eliminate");
wneuper@59248
   698
 autoCalculate 1 (Step 1); fetchProposedTactic 1;
neuper@52113
   699
 (*               __________ for "12 * x + 4 * x ^^^ 2 = 4 * (-4 + x ^^^ 2)"*)
wneuper@59367
   700
 setNextTactic 1 (Subproblem ("PolyEq", ["normalise","polynomial",
neuper@52113
   701
					    "univariate","equation"]));
wneuper@59248
   702
 autoCalculate 1 (Step 1); fetchProposedTactic 1;
neuper@52113
   703
 setNextTactic 1 (Model_Problem );
wneuper@59248
   704
 autoCalculate 1 (Step 1); fetchProposedTactic 1;
neuper@52113
   705
 setNextTactic 1 (Specify_Theory "PolyEq");
wneuper@59248
   706
 autoCalculate 1 (Step 1); fetchProposedTactic 1;
wneuper@59367
   707
 setNextTactic 1 (Specify_Problem ["normalise","polynomial",
neuper@52113
   708
				   "univariate","equation"]);
wneuper@59248
   709
 autoCalculate 1 (Step 1); fetchProposedTactic 1;
wneuper@59370
   710
 setNextTactic 1 (Specify_Method ["PolyEq","normalise_poly"]);
wneuper@59248
   711
 autoCalculate 1 (Step 1); fetchProposedTactic 1;
wneuper@59370
   712
 setNextTactic 1 (Apply_Method ["PolyEq","normalise_poly"]);
wneuper@59248
   713
 autoCalculate 1 (Step 1); fetchProposedTactic 1;
wneuper@59254
   714
 setNextTactic 1 (Rewrite ("all_left", num_str @{thm all_left}));
wneuper@59248
   715
 autoCalculate 1 (Step 1); fetchProposedTactic 1;
wneuper@59497
   716
 setNextTactic 1 (Rewrite_Set_Inst (["(''bdv'',x)"], "make_ratpoly_in"));
wneuper@59248
   717
 autoCalculate 1 (Step 1); fetchProposedTactic 1;
neuper@52113
   718
 (*               __________ for "16 + 12 * x = 0"*)
neuper@52113
   719
 setNextTactic 1 (Subproblem ("PolyEq",
neuper@52113
   720
			 ["degree_1","polynomial","univariate","equation"]));
wneuper@59248
   721
 autoCalculate 1 (Step 1); fetchProposedTactic 1;
neuper@52113
   722
 setNextTactic 1 (Model_Problem );
wneuper@59248
   723
 autoCalculate 1 (Step 1); fetchProposedTactic 1;
neuper@52113
   724
 setNextTactic 1 (Specify_Theory "PolyEq");
neuper@52113
   725
 (*------------- some trials in the problem-hierarchy ---------------*)
neuper@55279
   726
 setNextTactic 1 (Specify_Problem ["LINEAR","univariate","equation"]);
wneuper@59248
   727
 autoCalculate 1 (Step 1); fetchProposedTactic 1; (*<ERROR> helpless </ERROR> !!!*)
neuper@52113
   728
 setNextTactic 1 (Refine_Problem ["univariate","equation"]);
neuper@52113
   729
 (*------------------------------------------------------------------*)
wneuper@59248
   730
 autoCalculate 1 (Step 1); fetchProposedTactic 1;
neuper@52113
   731
 setNextTactic 1 (Specify_Method ["PolyEq","solve_d1_polyeq_equation"]);
wneuper@59248
   732
 autoCalculate 1 (Step 1); fetchProposedTactic 1;
neuper@52113
   733
 setNextTactic 1 (Apply_Method ["PolyEq","solve_d1_polyeq_equation"]);
wneuper@59248
   734
 autoCalculate 1 (Step 1); fetchProposedTactic 1;
wneuper@59497
   735
 setNextTactic 1 (Rewrite_Set_Inst (["(''bdv'',x)"], "d1_polyeq_simplify"));
wneuper@59248
   736
 autoCalculate 1 (Step 1); fetchProposedTactic 1;
neuper@52113
   737
 setNextTactic 1 (Rewrite_Set "polyeq_simplify");
wneuper@59248
   738
 autoCalculate 1 (Step 1); fetchProposedTactic 1;
neuper@52113
   739
 setNextTactic 1 Or_to_List;
wneuper@59248
   740
 autoCalculate 1 (Step 1); fetchProposedTactic 1;
neuper@52113
   741
 setNextTactic 1 (Check_elementwise "Assumptions"); 
wneuper@59248
   742
 autoCalculate 1 (Step 1); fetchProposedTactic 1;
neuper@52113
   743
 setNextTactic 1 (Check_Postcond ["degree_1","polynomial",
neuper@52113
   744
				  "univariate","equation"]);
wneuper@59248
   745
 autoCalculate 1 (Step 1); fetchProposedTactic 1;
wneuper@59367
   746
 setNextTactic 1 (Check_Postcond ["normalise","polynomial",
neuper@52113
   747
				  "univariate","equation"]);
wneuper@59248
   748
 autoCalculate 1 (Step 1); fetchProposedTactic 1;
neuper@52113
   749
 setNextTactic 1 (Check_Postcond ["rational","univariate","equation"]);
neuper@52113
   750
 val (ptp,_) = get_calc 1;
neuper@52113
   751
 val (Form t,_,_) = pt_extract ptp;
neuper@52113
   752
 if get_pos 1 1 = ([], Res) andalso term2str t = "[x = -4 / 3]" then ()
neuper@52113
   753
 else writeln "FE-inteface.sml: diff.behav. in rat-eq + subpbl: no_met, NO ..";
wneuper@59253
   754
 DEconstrCalcTree 1;
neuper@52113
   755
neuper@52113
   756
"--------- tryMatchProblem, tryRefineProblem ------------";
neuper@52113
   757
"--------- tryMatchProblem, tryRefineProblem ------------";
neuper@52113
   758
"--------- tryMatchProblem, tryRefineProblem ------------";
neuper@52113
   759
(*{\bf\UC{Having \isac{} Refine the Problem
neuper@52113
   760
 * Automatically}\label{SPECIFY:refine-auto}\\} test match and refine with
neuper@52113
   761
 * x^^^2 + 4*x + 5 = 2
neuper@52113
   762
see isac.bridge.TestSpecify#testMatchRefine*)
neuper@52113
   763
 CalcTree
neuper@52113
   764
 [(["equality (x^2 + 4*x + 5 = (2::real))", "solveFor x","solutions L"],
wneuper@59592
   765
   ("Isac_Knowledge", 
neuper@52113
   766
    ["univariate","equation"],
neuper@52113
   767
    ["no_met"]))];
neuper@52113
   768
 Iterator 1;
neuper@52113
   769
 moveActiveRoot 1; 
neuper@52113
   770
neuper@52113
   771
 fetchProposedTactic 1;
neuper@52113
   772
 setNextTactic 1 (Model_Problem );
neuper@52113
   773
 (*..this tactic should be done 'tacitly', too !*)
neuper@52113
   774
neuper@52113
   775
(*
wneuper@59248
   776
autoCalculate 1 CompleteCalcHead; 
neuper@52113
   777
checkContext 1 ([],Pbl) "pbl_equ_univ";
neuper@52113
   778
checkContext 1 ([],Pbl) (kestoreID2guh Pbl_ ["univariate","equation"]);
neuper@52113
   779
*)
neuper@52113
   780
wneuper@59248
   781
 autoCalculate 1 (Step 1); 
neuper@52113
   782
neuper@52113
   783
 fetchProposedTactic 1;
neuper@52113
   784
 setNextTactic 1 (Add_Given "equality (x ^^^ 2 + 4 * x + 5 = (2::real))");
wneuper@59248
   785
 autoCalculate 1 (Step 1); 
neuper@52113
   786
neuper@52113
   787
 "--------- we go into the ProblemBrowser (_NO_ pblID selected) -";
neuper@52113
   788
initContext 1 Pbl_ ([],Pbl);
wneuper@59173
   789
(* this would break if a calculation would be inserted before: CALCID...
wneuper@59173
   790
   and pattern matching is not available in *.java.
wneuper@59173
   791
if cut_xml xml = "(CONTEXTPBL)\n. (CALCID)\n. . 1\n. (/CALCID)\n. (CONTEXTDATA)\n. . (GUH)\n. . . pbl_equ_univ\n. . (/GUH)\n. . (STATUS)\n. . . correct\n. . (/STATUS)\n. . (HEAD)\n. . . (MATHML)\n. . . . (ISA)\n. . . . . solve (x ^ 2 + 4 * x + 5 = 2, x)\n. . . . (/ISA)\n. . . (/MATHML)\n. . (/HEAD)\n. . (MODEL)\n. . . (GIVEN)\n. . . . (ITEM status=correct)\n. . . . . (MATHML)\n. . . . . . (ISA)\n. . . . . . . equality (x ^ 2 + 4 * x + 5 = 2)\n. . . . . . (/ISA)\n. . . . . (/MATHML)\n. . . . (/ITEM)\n. . . . (ITEM status=correct)\n. . . . . (MATHML)\n. . . . . . (ISA)\n. . . . . . . solveFor x\n. . . . . . (/ISA)\n. . . . . (/MATHML)\n. . . . (/ITEM)\n. . . (/GIVEN)\n. . . (WHERE)\n. . . . (ITEM status=correct)\n. . . . . (MATHML)\n. . . . . . (ISA)\n. . . . . . . matches (?a = ?b) (x ^ 2 + 4 * x + 5 = 2)\n. . . . . . (/ISA)\n. . . . . (/MATHML)\n. . . . (/ITEM)\n. . . (/WHERE)\n. . . (FIND)\n. . . . (ITEM status=correct)\n. . . . . (MATHML)\n. . . . . . (ISA)\n. . . . . . . solutions L\n. . . . . . (/ISA)\n. . . . . (/MATHML)\n. . . . (/ITEM)\n. . . (/FI"
wneuper@59173
   792
then () else error "--- tryMatchProblem, tryRefineProblem: initContext 1 Pbl_ ([],Pbl); CHANGED";
wneuper@59173
   793
*)
neuper@52113
   794
initContext 1 Met_ ([],Pbl);
wneuper@59173
   795
(*<SYSERROR><CALCID>1</CALCID><ERROR>error in kernel 33</ERROR></SYSERROR>*)
neuper@52113
   796
neuper@52113
   797
 "--------- this match will show some incomplete items: ---------";
neuper@52113
   798
neuper@52113
   799
checkContext 1 ([],Pbl) (kestoreID2guh Pbl_ ["univariate","equation"]);
neuper@52113
   800
checkContext 1 ([],Pbl) (kestoreID2guh Met_ ["LinEq", "solve_lineq_equation"]);
neuper@52113
   801
neuper@52113
   802
neuper@52113
   803
 fetchProposedTactic 1;
wneuper@59248
   804
 setNextTactic 1 (Add_Given "solveFor x"); autoCalculate 1 (Step 1);
neuper@52113
   805
neuper@52113
   806
 fetchProposedTactic 1;
wneuper@59248
   807
 setNextTactic 1 (Add_Find "solutions L"); autoCalculate 1 (Step 1);
neuper@52113
   808
neuper@52113
   809
 "--------- this is a matching model (all items correct): -------";
neuper@52113
   810
checkContext 1  ([],Pbl) (kestoreID2guh Pbl_ ["univariate","equation"]);
neuper@52113
   811
 "--------- this is a NOT matching model (some 'false': ---------";
neuper@55279
   812
checkContext 1  ([],Pbl)(kestoreID2guh Pbl_ ["LINEAR","univariate","equation"]);
neuper@52113
   813
neuper@52113
   814
 "--------- find out a matching problem: ------------------------";
neuper@52113
   815
 "--------- find out a matching problem (FAILING: no new pbl) ---";
neuper@55279
   816
 refineProblem 1([],Pbl)(pblID2guh ["LINEAR","univariate","equation"]);
neuper@52113
   817
neuper@52113
   818
 "--------- find out a matching problem (SUCCESSFUL) ------------";
neuper@52113
   819
 refineProblem 1 ([],Pbl) (pblID2guh ["univariate","equation"]);
neuper@52113
   820
neuper@52113
   821
 "--------- tryMatch, tryRefine did not change the calculation -";
neuper@52113
   822
 "--------- this is done by <TRANSFER> on the pbl-browser: ------";
wneuper@59367
   823
 setNextTactic 1 (Specify_Problem ["normalise","polynomial",
neuper@52113
   824
				 "univariate","equation"]);
wneuper@59248
   825
 autoCalculate 1 (Step 1);
wneuper@59367
   826
(*WN050904 fetchProposedTactic again --> Specify_Problem ["normalise",...
neuper@52113
   827
  and Specify_Theory skipped in comparison to below ---^^^-inserted      *)
neuper@52113
   828
(*------------vvv-inserted-----------------------------------------------*)
neuper@52113
   829
 fetchProposedTactic 1;
wneuper@59367
   830
 setNextTactic 1 (Specify_Problem ["normalise","polynomial",
neuper@52113
   831
				 "univariate","equation"]);
wneuper@59248
   832
 autoCalculate 1 (Step 1);
neuper@52113
   833
neuper@52113
   834
(*and Specify_Theory skipped by fetchProposedTactic ?!?*)
neuper@52113
   835
neuper@52113
   836
 fetchProposedTactic 1;
wneuper@59370
   837
 setNextTactic 1 (Specify_Method ["PolyEq","normalise_poly"]);
wneuper@59248
   838
 autoCalculate 1 (Step 1);
neuper@52113
   839
neuper@52113
   840
 fetchProposedTactic 1;
wneuper@59370
   841
 setNextTactic 1 (Apply_Method ["PolyEq","normalise_poly"]);
neuper@52113
   842
wneuper@59248
   843
 autoCalculate 1 CompleteCalc;
neuper@52113
   844
neuper@52113
   845
 val ((pt,_),_) = get_calc 1;
neuper@52113
   846
 show_pt pt;
neuper@52113
   847
 val p = get_pos 1 1;
neuper@52113
   848
 val (Form f, tac, asms) = pt_extract (pt, p);
neuper@52113
   849
 if term2str f = "[x = -1, x = -3]" andalso p = ([], Res) then () else 
neuper@52113
   850
 error "FE-interface.sml: diff.behav. in tryMatchProblem, tryRefine";
neuper@52113
   851
neuper@52113
   852
(*------------^^^-inserted-----------------------------------------------*)
neuper@52113
   853
(*WN050904 the fetchProposedTactic's below may not have worked like that
neuper@52113
   854
  before, too, because there was no check*)
neuper@52113
   855
 fetchProposedTactic 1;
neuper@52113
   856
 setNextTactic 1 (Specify_Theory "PolyEq");
wneuper@59248
   857
 autoCalculate 1 (Step 1);
neuper@52113
   858
neuper@52113
   859
 fetchProposedTactic 1;
wneuper@59370
   860
 setNextTactic 1 (Specify_Method ["PolyEq","normalise_poly"]);
wneuper@59248
   861
 autoCalculate 1 (Step 1);
neuper@52113
   862
neuper@52113
   863
 fetchProposedTactic 1;
neuper@52113
   864
 "--------- now the calc-header is ready for enter 'solving' ----";
wneuper@59248
   865
 autoCalculate 1 CompleteCalc;
neuper@52113
   866
neuper@52113
   867
 val ((pt,_),_) = get_calc 1;
neuper@52113
   868
 rootthy pt;
neuper@52113
   869
 show_pt pt;
neuper@52113
   870
 val p = get_pos 1 1;
neuper@52113
   871
 val (Form f, tac, asms) = pt_extract (pt, p);
neuper@52113
   872
 if term2str f = "[x = -1, x = -3]" andalso p = ([], Res) then () else 
neuper@52113
   873
 error "FE-interface.sml: diff.behav. in tryMatchProblem, tryRefine";
wneuper@59253
   874
 DEconstrCalcTree 1;
neuper@52113
   875
neuper@52113
   876
"--------- modifyCalcHead, resetCalcHead, modelProblem --";
neuper@52113
   877
"--------- modifyCalcHead, resetCalcHead, modelProblem --";
neuper@52113
   878
"--------- modifyCalcHead, resetCalcHead, modelProblem --";
neuper@52113
   879
 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"], 
neuper@52113
   880
   ("Test", ["sqroot-test","univariate","equation","test"],
neuper@52113
   881
    ["Test","squ-equ-test-subpbl1"]))];
neuper@52113
   882
 Iterator 1;
neuper@52113
   883
 moveActiveRoot 1; 
neuper@52113
   884
neuper@52113
   885
 modifyCalcHead 1 (([],Pbl),(*the position from refFormula*)
neuper@52113
   886
		  "solve (x+1=2, x)",(*the headline*)
neuper@52113
   887
		  [Given ["equality (x+1=(2::real))", "solveFor x"],
neuper@52113
   888
		   Find ["solutions L"](*,Relate []*)],
neuper@52113
   889
		  Pbl, 
neuper@52113
   890
		  ("Test", 
neuper@52113
   891
		   ["sqroot-test","univariate","equation","test"],
neuper@52113
   892
		   ["Test","squ-equ-test-subpbl1"]));
neuper@52113
   893
 
neuper@52113
   894
val ((Nd (PblObj {env = NONE,
neuper@52113
   895
                  fmz = (fm, tpm),
neuper@52113
   896
                  loc = (SOME scrst_ctxt, NONE),
neuper@52113
   897
                  ctxt,
neuper@52113
   898
                  cell = NONE,
neuper@52113
   899
                  meth,
neuper@52113
   900
                  spec = (thy,
neuper@52113
   901
                          ["sqroot-test", "univariate", "equation", "test"],
neuper@52113
   902
                          ["Test", "squ-equ-test-subpbl1"]),
neuper@52113
   903
                  probl,
neuper@52113
   904
                  branch = TransitiveB,
neuper@52113
   905
                  origin,
neuper@52113
   906
                  ostate = Incomplete,
neuper@52113
   907
                  result},
neuper@52113
   908
               []),
neuper@52113
   909
         ([], Pbl)),
neuper@52113
   910
      []) = get_calc 1;
neuper@52113
   911
(*WN110622: is the same as in 2002, but shouldn't be probl = [3 items?]*)
neuper@52113
   912
if length meth = 0 andalso length probl = 0 (*just some items tested*) then () 
neuper@52113
   913
else error "--- modifyCalcHead, resetCalcHead, modelProblem 1 --";
neuper@52113
   914
neuper@52113
   915
resetCalcHead 1;
neuper@52113
   916
modelProblem 1;
neuper@52113
   917
neuper@52113
   918
get_calc 1;
neuper@52113
   919
val ((Nd (PblObj {env = NONE,
neuper@52113
   920
                  fmz = (fm, tpm),
neuper@52113
   921
                  loc = (SOME scrst_ctxt, NONE),
neuper@52113
   922
                  ctxt,
neuper@52113
   923
                  cell = NONE,
neuper@52113
   924
                  meth,
neuper@52113
   925
                  spec = ("e_domID", ["e_pblID"], ["e_metID"]),
neuper@52113
   926
                  probl,
neuper@52113
   927
                  branch = TransitiveB,
neuper@52113
   928
                  origin,
neuper@52113
   929
                  ostate = Incomplete,
neuper@52113
   930
                  result},
neuper@52113
   931
               []),
neuper@52113
   932
         ([], Pbl)),
neuper@52113
   933
      []) = get_calc 1;
neuper@52113
   934
if length meth = 3 andalso length probl = 3 (*just some items tested*) then () 
neuper@52113
   935
else error "--- modifyCalcHead, resetCalcHead, modelProblem 2 --";
neuper@52113
   936
neuper@52113
   937
"--------- maximum-example, UC: Modeling an example -----";
neuper@52113
   938
"--------- maximum-example, UC: Modeling an example -----";
neuper@52113
   939
"--------- maximum-example, UC: Modeling an example -----";
neuper@52113
   940
(* {\bf\UC{Editing the Model}\label{SPECIFY:enter}\label{SPECIFY:check}\\}
neuper@52113
   941
see isac.bridge.TestModel#testEditItems
neuper@52113
   942
*)
neuper@52113
   943
 val elems = ["fixedValues [r=Arbfix]","maximum A","valuesFor [a,b]",
neuper@52113
   944
	      "relations [A=a*b, (a/2)^2 + (b/2)^2 = r^2]",
neuper@52113
   945
	      "relations [A=a*b, (a/2)^2 + (b/2)^2 = r^2]",
wneuper@59582
   946
        "relations [A=a*b, a/2=r*sin alpha, b/2=r*cos (alpha::real)]",
neuper@52113
   947
	      (*^^^ these are the elements for the root-problem (in variants)*)
neuper@52113
   948
              (*vvv these are elements required for subproblems*)
neuper@52113
   949
	      "boundVariable a","boundVariable b","boundVariable alpha",
neuper@52113
   950
	      "interval {x::real. 0 <= x & x <= 2*r}",
neuper@52113
   951
	      "interval {x::real. 0 <= x & x <= 2*r}",
neuper@52113
   952
	      "interval {x::real. 0 <= x & x <= pi}",
neuper@52113
   953
	      "errorBound (eps=(0::real))"]
neuper@52113
   954
 (*specifying is not interesting for this example*)
neuper@52113
   955
 val spec = ("DiffApp", ["maximum_of","function"], 
neuper@52113
   956
	     ["DiffApp","max_by_calculus"]);
neuper@52113
   957
 (*the empty model with descriptions for user-guidance by Model_Problem*)
neuper@52113
   958
 val empty_model = [Given ["fixedValues []"],
neuper@52113
   959
		    Find ["maximum", "valuesFor"],
neuper@52113
   960
		    Relate ["relations []"]]; 
neuper@52113
   961
 DEconstrCalcTree 1;
neuper@52113
   962
neuper@52113
   963
"#################################################################";
neuper@52113
   964
neuper@52113
   965
 CalcTree [(elems, spec)];
neuper@52113
   966
 Iterator 1;
neuper@52113
   967
 moveActiveRoot 1; 
neuper@52113
   968
 refFormula 1 (get_pos 1 1);
neuper@52113
   969
 (*this gives a completely empty model*) 
neuper@52113
   970
neuper@52113
   971
 fetchProposedTactic 1;
neuper@52113
   972
(*fill the CalcHead with Descriptions...*)
neuper@52113
   973
 setNextTactic 1 (Model_Problem );
wneuper@59248
   974
 autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
neuper@52113
   975
neuper@52113
   976
 (*user input is !!!!!EITHER!!!!! _some_ (at least one) items of the model 
neuper@52113
   977
 !!!!!OR!!!!! _one_ part of the specification !!!!!!!!!!!!!*)
neuper@52113
   978
 (*input of two items, 'fixedValues [r=Arbfix]' and 'maximum b'...*)
neuper@52113
   979
 modifyCalcHead 1 (([],Pbl) (*position, from previous refFormula*),
neuper@52113
   980
		  "Problem (DiffApp.thy, [maximum_of, function])",
neuper@52113
   981
		  (*the head-form ^^^ is not used for input here*)
neuper@52113
   982
		  [Given ["fixedValues [r=Arbfix]"(*new input*)],
neuper@52113
   983
		   Find ["maximum b"(*new input*), "valuesFor"], 
neuper@52113
   984
		   Relate ["relations"]],
neuper@52113
   985
		  (*input (Arbfix will dissappear soon)*)
neuper@52113
   986
		  Pbl (*belongsto*),
neuper@52113
   987
		  e_spec (*no input to the specification*));
neuper@52113
   988
neuper@52113
   989
 (*the user does not know, what 'superfluous' for 'maximum b' may mean
neuper@52113
   990
  and asks what to do next*)
neuper@52113
   991
 fetchProposedTactic 1;
neuper@52113
   992
 (*the student follows the advice*)
neuper@52113
   993
 setNextTactic 1 (Add_Find "maximum A"); (*FIXME.17.11.03: does not yet work*)
wneuper@59248
   994
  autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);
neuper@52113
   995
 
neuper@52113
   996
 (*this input completes the model*)
neuper@52113
   997
 modifyCalcHead 1 (([],Pbl), "not used here",
neuper@52113
   998
		  [Given ["fixedValues [r=Arbfix]"],
neuper@52113
   999
		   Find ["maximum A", "valuesFor [a,b]"(*new input*)], 
neuper@52113
  1000
		   Relate ["relations [A=a*b, \
neuper@52113
  1001
			   \(a/2)^2 + (b/2)^2 = r^2]"]], Pbl, e_spec);
neuper@52113
  1002
neuper@52113
  1003
 (*specification is not interesting and should be skipped by the dialogguide;
neuper@52113
  1004
   !!!!!!!!!!!!!!!!!!!! input of ONE part at a time !!!!!!!!!!!!!!!!!!!!!!*)
neuper@52113
  1005
 modifyCalcHead 1 (([],Pbl), "not used here",
neuper@52113
  1006
		  [Given ["fixedValues [r=Arbfix]"],
neuper@52113
  1007
		   Find ["maximum A", "valuesFor [a,b]"(*new input*)], 
neuper@52113
  1008
		   Relate ["relations [A=a*b, \
neuper@52113
  1009
			   \(a/2)^2 + (b/2)^2 = r^2]"]], Pbl, 
neuper@52113
  1010
		  ("DiffApp", ["e_pblID"], ["e_metID"]));
neuper@52113
  1011
 modifyCalcHead 1 (([],Pbl), "not used here",
neuper@52113
  1012
		  [Given ["fixedValues [r=Arbfix]"],
neuper@52113
  1013
		   Find ["maximum A", "valuesFor [a,b]"(*new input*)], 
neuper@52113
  1014
		   Relate ["relations [A=a*b, \
neuper@52113
  1015
			   \(a/2)^2 + (b/2)^2 = r^2]"]], Pbl, 
neuper@52113
  1016
		  ("DiffApp", ["maximum_of","function"], 
neuper@52113
  1017
		   ["e_metID"]));
neuper@52113
  1018
 modifyCalcHead 1 (([],Pbl), "not used here",
neuper@52113
  1019
		  [Given ["fixedValues [r=Arbfix]"],
neuper@52113
  1020
		   Find ["maximum A", "valuesFor [a,b]"(*new input*)], 
neuper@52113
  1021
		   Relate ["relations [A=a*b, \
neuper@52113
  1022
			   \(a/2)^2 + (b/2)^2 = r^2]"]], Pbl, 
neuper@52113
  1023
		  ("DiffApp", ["maximum_of","function"], 
neuper@52113
  1024
		   ["DiffApp","max_by_calculus"]));
neuper@52113
  1025
 (*this final calcHead now has STATUS 'complete' !*)
neuper@52113
  1026
 DEconstrCalcTree 1;
neuper@52113
  1027
neuper@52113
  1028
"--------- solve_linear from pbl-hierarchy --------------";
neuper@52113
  1029
"--------- solve_linear from pbl-hierarchy --------------";
neuper@52113
  1030
"--------- solve_linear from pbl-hierarchy --------------";
neuper@55279
  1031
 val (fmz, sp) = ([], ("", ["LINEAR","univariate","equation","test"], []));
neuper@52113
  1032
 CalcTree [(fmz, sp)];
neuper@52113
  1033
 Iterator 1; moveActiveRoot 1;
neuper@52113
  1034
 refFormula 1 (get_pos 1 1);
neuper@52113
  1035
 modifyCalcHead 1 (([],Pbl),"solve (1+-1*2+x=(0::real))",
neuper@52113
  1036
		  [Given ["equality (1+-1*2+x=(0::real))", "solveFor x"],
neuper@52113
  1037
		   Find ["solutions L"]],
neuper@52113
  1038
		  Pbl, 
neuper@55279
  1039
		  ("Test", ["LINEAR","univariate","equation","test"],
neuper@52113
  1040
		   ["Test","solve_linear"]));
wneuper@59248
  1041
 autoCalculate 1 CompleteCalc;
neuper@52113
  1042
 refFormula 1 (get_pos 1 1);
neuper@52113
  1043
 val ((pt,_),_) = get_calc 1;
neuper@52113
  1044
 val p = get_pos 1 1;
neuper@52113
  1045
 val (Form f, tac, asms) = pt_extract (pt, p);
neuper@52113
  1046
 if term2str f = "[x = 1]" andalso p = ([], Res) 
walther@59686
  1047
   andalso terms2str asms = "[]" then () 
neuper@52113
  1048
 else error "FE-interface.sml: diff.behav. in from pbl -hierarchy";
neuper@52113
  1049
 DEconstrCalcTree 1;
neuper@52113
  1050
neuper@52113
  1051
"--------- solve_linear as in an algebra system (CAS)----";
neuper@52113
  1052
"--------- solve_linear as in an algebra system (CAS)----";
neuper@52113
  1053
"--------- solve_linear as in an algebra system (CAS)----";
neuper@52113
  1054
(*WN120210?not ME:\label{UC:cas-input} UC 30.1.2.5 p.168*)
neuper@52113
  1055
 val (fmz, sp) = ([], ("", [], []));
neuper@52113
  1056
 CalcTree [(fmz, sp)];
neuper@52113
  1057
 Iterator 1; moveActiveRoot 1;
neuper@52113
  1058
 modifyCalcHead 1 (([],Pbl),"solveTest (1+-1*2+x=0,x)", [], Pbl, ("", [], []));
wneuper@59248
  1059
 autoCalculate 1 CompleteCalc;
neuper@52113
  1060
 refFormula 1 (get_pos 1 1);
neuper@52113
  1061
 val ((pt,_),_) = get_calc 1;
neuper@52113
  1062
 val p = get_pos 1 1;
neuper@52113
  1063
 val (Form f, tac, asms) = pt_extract (pt, p);
neuper@52113
  1064
 if term2str f = "[x = 1]" andalso p = ([], Res) 
walther@59686
  1065
   andalso terms2str asms = "[]" then () 
neuper@52113
  1066
 else error "FE-interface.sml: diff.behav. in from pbl -hierarchy";
neuper@52113
  1067
DEconstrCalcTree 1;
neuper@52113
  1068
neuper@52113
  1069
"--------- interSteps: on 'miniscript with mini-subpbl' -";
neuper@52113
  1070
"--------- interSteps: on 'miniscript with mini-subpbl' -";
neuper@52113
  1071
"--------- interSteps: on 'miniscript with mini-subpbl' -";
neuper@52113
  1072
 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"], 
neuper@52113
  1073
   ("Test", ["sqroot-test","univariate","equation","test"],
neuper@52113
  1074
    ["Test","squ-equ-test-subpbl1"]))];
neuper@52113
  1075
 Iterator 1;
neuper@52113
  1076
 moveActiveRoot 1;
wneuper@59248
  1077
 autoCalculate 1 CompleteCalc; 
neuper@52113
  1078
 val ((pt,_),_) = get_calc 1;
neuper@52113
  1079
 show_pt pt;
neuper@52113
  1080
neuper@52113
  1081
 (*UC\label{UC:inter-steps} UC 30.3.5.5 p.178*)
neuper@52113
  1082
 interSteps 1 ([2],Res);
neuper@52113
  1083
 val ((pt,_),_) = get_calc 1; show_pt pt (*new ([2,1],Frm)..([2,6],Res)*);
neuper@52113
  1084
 val (unc, del, gen) = (([1],Res),([1],Res),([2,6],Res));
neuper@52113
  1085
 getFormulaeFromTo 1 unc gen 1 false; 
neuper@52113
  1086
neuper@52113
  1087
 (*UC\label{UC:inter-steps} UC 30.3.5.5 p.178*)
neuper@52113
  1088
 interSteps 1 ([3,2],Res);
neuper@52113
  1089
 val ((pt,_),_) = get_calc 1; show_pt pt (*new ([3,2,1],Frm)..([3,2,2],Res)*);
neuper@52113
  1090
 val (unc, del, gen) = (([3,1],Res),([3,1],Res),([3,2,2],Res));
neuper@52113
  1091
 getFormulaeFromTo 1 unc gen 1 false; 
neuper@52113
  1092
neuper@52113
  1093
 (*UC\label{UC:inter-steps} UC 30.3.5.5 p.178*)
neuper@52113
  1094
 interSteps 1 ([3],Res)  (*no new steps in subproblems*);
neuper@52113
  1095
 val (unc, del, gen) = (([3],Pbl),([3],Pbl),([3,2],Res));
neuper@52113
  1096
 getFormulaeFromTo 1 unc gen 1 false; 
neuper@52113
  1097
neuper@52113
  1098
 (*UC\label{UC:inter-steps} UC 30.3.5.5 p.178*)
neuper@52113
  1099
 interSteps 1 ([],Res)  (*no new steps in subproblems*);
neuper@52113
  1100
 val (unc, del, gen) = (([],Pbl),([],Pbl),([4],Res));
neuper@52113
  1101
 getFormulaeFromTo 1 unc gen 1 false; 
neuper@52113
  1102
DEconstrCalcTree 1;
neuper@52113
  1103
neuper@52113
  1104
"--------- getTactic, fetchApplicableTactics ------------";
neuper@52113
  1105
"--------- getTactic, fetchApplicableTactics ------------";
neuper@52113
  1106
"--------- getTactic, fetchApplicableTactics ------------";
neuper@52113
  1107
(* compare test/../script.sml
neuper@52113
  1108
"----------- fun sel_rules ---------------------------------------";
neuper@52113
  1109
*)
neuper@52113
  1110
 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"], 
neuper@52113
  1111
   ("Test", ["sqroot-test","univariate","equation","test"],
neuper@52113
  1112
    ["Test","squ-equ-test-subpbl1"]))];
neuper@52113
  1113
 Iterator 1; moveActiveRoot 1;
wneuper@59248
  1114
 autoCalculate 1 CompleteCalc;
neuper@52113
  1115
 val ((pt,_),_) = get_calc 1;
neuper@52113
  1116
 show_pt pt;
neuper@52113
  1117
neuper@52113
  1118
 (*UC\label{SOLVE:HIDE:getTactic} \label{SOLVE:AUTO:tactic} UC 30.3.3.1 p.176
neuper@52113
  1119
WN120210 not impl. in FE*)
neuper@52113
  1120
 getTactic 1 ([],Pbl);
neuper@52113
  1121
 getTactic 1 ([1],Res);
neuper@52113
  1122
 getTactic 1 ([3],Pbl);
neuper@52113
  1123
 getTactic 1 ([3,1],Frm);
neuper@52113
  1124
 getTactic 1 ([3],Res);
neuper@52113
  1125
 getTactic 1 ([],Res);
neuper@52113
  1126
neuper@52113
  1127
(*UC\label{SOLVE:MANUAL:TACTIC:listall} UC 30.3.2.2 p.175*)
neuper@52113
  1128
 fetchApplicableTactics 1 99999 ([],Pbl);
neuper@52113
  1129
 fetchApplicableTactics 1 99999 ([1],Res);
neuper@52113
  1130
 fetchApplicableTactics 1 99999 ([3],Pbl);
neuper@52113
  1131
 fetchApplicableTactics 1 99999 ([3,1],Res);
neuper@52113
  1132
 fetchApplicableTactics 1 99999 ([3],Res);
neuper@52113
  1133
 fetchApplicableTactics 1 99999 ([],Res);
neuper@52113
  1134
DEconstrCalcTree 1;
neuper@52113
  1135
neuper@52113
  1136
"--------- getAssumptions, getAccumulatedAsms -----------";
neuper@52113
  1137
"--------- getAssumptions, getAccumulatedAsms -----------";
neuper@52113
  1138
"--------- getAssumptions, getAccumulatedAsms -----------";
neuper@52113
  1139
CalcTree
neuper@52113
  1140
[(["equality (x/(x^2 - 6*x+9) - 1/(x^2 - 3*x) =1/x)",
neuper@52113
  1141
	   "solveFor x","solutions L"], 
neuper@52113
  1142
  ("RatEq",["univariate","equation"],["no_met"]))];
neuper@52113
  1143
Iterator 1; moveActiveRoot 1;
wneuper@59248
  1144
autoCalculate 1 CompleteCalc; 
neuper@52113
  1145
val ((pt,_),_) = get_calc 1;
neuper@52113
  1146
val p = get_pos 1 1;
neuper@52113
  1147
val (Form f, tac, asms) = pt_extract (pt, p);
neuper@52113
  1148
(*============ inhibit exn WN120316 compare 2002--2011 ===========================
neuper@52113
  1149
if map term2str asms = 
neuper@52113
  1150
 ["True |\n~ lhs ((3 + -1 * x + x ^^^ 2) * x =\n" ^
neuper@52113
  1151
  "       1 * (9 * x + -6 * x ^^^ 2 + x ^^^ 3)) is_poly_in x", "-6 * x + 5 * x ^^^ 2 = 0", 
neuper@52113
  1152
  "lhs (-6 * x + 5 * x ^^^ 2 = 0) is_poly_in x",
neuper@52113
  1153
  "lhs (-6 * x + 5 * x ^^^ 2 = 0) has_degree_in x = 2", 
neuper@52113
  1154
  "9 * x + -6 * x ^^^ 2 + x ^^^ 3 ~= 0"] 
neuper@52113
  1155
andalso term2str f = "[-6 * x + 5 * x ^^^ 2 = 0]" andalso p = ([], Res) then ()
neuper@52113
  1156
else error "TODO compare 2002--2011"; (*...data during test --- x / (x ^ 2 - 6 * x + 9) - 1...*)
neuper@52113
  1157
============ inhibit exn WN120316 compare 2002--2011 ===========================*)
neuper@52113
  1158
if p = ([], Res) andalso term2str f = "[]" (*see WN120317.TODO dropped rateq*)
neuper@52113
  1159
andalso asms = [] (*STRANGE!, compare test --- x / (x ^ 2 - 6 * x + 9) - 1 / (x ^ 2 ...*)
neuper@52113
  1160
then () else error "rlang.sml: diff.behav. in  Schalk I s.87 Bsp 55b [x = 6 / 5]";
neuper@52113
  1161
neuper@52113
  1162
(*UC\label{SOLVE:HELP:assumptions} UC 30.3.5.1 p.178*)
neuper@52113
  1163
getAssumptions 1 ([3], Res);
neuper@52113
  1164
getAssumptions 1 ([5], Res);
neuper@52113
  1165
(*UC\label{SOLVE:HELP:assumptions-origin} UC 30.3.5.2 p.178
neuper@52113
  1166
  WN0502 still without positions*)
neuper@52113
  1167
getAccumulatedAsms 1 ([3], Res);
neuper@52113
  1168
getAccumulatedAsms 1 ([5], Res);
neuper@52113
  1169
DEconstrCalcTree 1;
neuper@52113
  1170
neuper@52113
  1171
"--------- arbitrary combinations of steps --------------";
neuper@52113
  1172
"--------- arbitrary combinations of steps --------------";
neuper@52113
  1173
"--------- arbitrary combinations of steps --------------";
neuper@52113
  1174
 CalcTree      (*start of calculation, return No.1*)
neuper@52113
  1175
     [(["equality (1+-1*2+x=(0::real))", "solveFor x","solutions L"],
neuper@52113
  1176
       ("Test", 
neuper@55279
  1177
	["LINEAR","univariate","equation","test"],
neuper@52113
  1178
	["Test","solve_linear"]))];
neuper@52113
  1179
 Iterator 1; moveActiveRoot 1;
neuper@52113
  1180
neuper@52113
  1181
 fetchProposedTactic 1;
neuper@52113
  1182
             (*ERROR get_calc 1 not existent*)
neuper@52113
  1183
 setNextTactic 1 (Model_Problem );
wneuper@59248
  1184
 autoCalculate 1 (Step 1); 
neuper@52113
  1185
 fetchProposedTactic 1;
neuper@52113
  1186
 fetchProposedTactic 1;
neuper@52113
  1187
neuper@52113
  1188
 setNextTactic 1 (Add_Find "solutions L");
neuper@52113
  1189
 setNextTactic 1 (Add_Find "solutions L");
neuper@52113
  1190
wneuper@59248
  1191
 autoCalculate 1 (Step 1); 
wneuper@59248
  1192
 autoCalculate 1 (Step 1); 
neuper@52113
  1193
neuper@52113
  1194
 setNextTactic 1 (Specify_Theory "Test");
neuper@52113
  1195
 fetchProposedTactic 1;
wneuper@59248
  1196
 autoCalculate 1 (Step 1); 
neuper@52113
  1197
wneuper@59248
  1198
 autoCalculate 1 (Step 1); 
wneuper@59248
  1199
 autoCalculate 1 (Step 1); 
wneuper@59248
  1200
 autoCalculate 1 (Step 1); 
wneuper@59248
  1201
 autoCalculate 1 (Step 1); 
neuper@52113
  1202
(*------------------------- end calc-head*)
neuper@52113
  1203
neuper@52113
  1204
 fetchProposedTactic 1;
wneuper@59497
  1205
 setNextTactic 1 (Rewrite_Set_Inst (["(''bdv'',x)"], "isolate_bdv"));
wneuper@59248
  1206
 autoCalculate 1 (Step 1); 
neuper@52113
  1207
neuper@52113
  1208
 setNextTactic 1 (Rewrite_Set "Test_simplify");
neuper@52113
  1209
 fetchProposedTactic 1;
wneuper@59248
  1210
 autoCalculate 1 (Step 1); 
neuper@52113
  1211
wneuper@59248
  1212
 autoCalculate 1 CompleteCalc; 
neuper@52113
  1213
 val ((pt,_),_) = get_calc 1;
neuper@52113
  1214
 val p = get_pos 1 1;
neuper@52113
  1215
 val (Form f, tac, asms) = pt_extract (pt, p);
neuper@52113
  1216
 if term2str f = "[x = 1]" andalso p = ([], Res) then () else 
neuper@52113
  1217
 error "FE-interface.sml: diff.behav. in combinations of steps";
neuper@52113
  1218
DEconstrCalcTree 1;
neuper@52113
  1219
neuper@52113
  1220
"--------- appendF label{SOLVE:MANUAL:FORMULA:enter}right"; (*UC 30.3.2.4 p.175*)
neuper@52113
  1221
"--------- appendF label{SOLVE:MANUAL:FORMULA:enter}right";
neuper@52113
  1222
"--------- appendF label{SOLVE:MANUAL:FORMULA:enter}right";
neuper@52113
  1223
 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"], 
neuper@52113
  1224
   ("Test", ["sqroot-test","univariate","equation","test"],
neuper@52113
  1225
    ["Test","squ-equ-test-subpbl1"]))];
neuper@52113
  1226
 Iterator 1;
neuper@52113
  1227
 moveActiveRoot 1;
wneuper@59248
  1228
 autoCalculate 1 CompleteCalcHead;
wneuper@59248
  1229
 autoCalculate 1 (Step 1);
wneuper@59248
  1230
 autoCalculate 1 (Step 1);
wneuper@59123
  1231
 appendFormula 1 "-1 + x = 0" (*|> Future.join*);
neuper@52113
  1232
 (*... returns calcChangedEvent with*)
neuper@52113
  1233
 val (unc, del, gen) = (([1],Res), ([1],Res), ([2],Res));
neuper@52113
  1234
 getFormulaeFromTo 1 unc gen 99999 (*all levels*) false;
neuper@52113
  1235
neuper@52113
  1236
 val ((pt,_),_) = get_calc 1;
neuper@52113
  1237
 val p = get_pos 1 1;
neuper@52113
  1238
 val (Form f, tac, asms) = pt_extract (pt, p);
neuper@52113
  1239
 if term2str f = "-1 + x = 0" andalso p = ([2], Res) then () else 
neuper@52113
  1240
 error "FE-interface.sml: diff.behav. in FORMULA:enter} right";
neuper@52113
  1241
DEconstrCalcTree 1;
neuper@52113
  1242
neuper@52113
  1243
"--------- appendF label{SOLVE:MANUAL:FORMULA:enter}other"; (*UC 30.3.2.4 p.175*)
neuper@52113
  1244
"--------- appendF label{SOLVE:MANUAL:FORMULA:enter}other";
neuper@52113
  1245
"--------- appendF label{SOLVE:MANUAL:FORMULA:enter}other";
neuper@52113
  1246
 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"], 
neuper@52113
  1247
   ("Test", ["sqroot-test","univariate","equation","test"],
neuper@52113
  1248
    ["Test","squ-equ-test-subpbl1"]))];
neuper@52113
  1249
 Iterator 1;
neuper@52113
  1250
 moveActiveRoot 1;
wneuper@59248
  1251
 autoCalculate 1 CompleteCalcHead;
wneuper@59248
  1252
 autoCalculate 1 (Step 1);
wneuper@59248
  1253
 autoCalculate 1 (Step 1);
wneuper@59123
  1254
 appendFormula 1 "x - 1 = 0" (*|> Future.join*);
neuper@52113
  1255
 val (unc, del, gen) = (([1],Res), ([1],Res), ([2],Res));
neuper@52113
  1256
 getFormulaeFromTo 1 unc gen 99999 (*all levels*) false;
neuper@52113
  1257
 (*11 elements !!!*)
neuper@52113
  1258
neuper@52113
  1259
 val ((pt,_),_) = get_calc 1;
neuper@52113
  1260
 val p = get_pos 1 1;
neuper@52113
  1261
 val (Form f, tac, asms) = pt_extract (pt, p);
neuper@52113
  1262
 if term2str f = "x - 1 = 0" andalso p = ([2], Res) then () else 
neuper@52113
  1263
 error "FE-interface.sml: diff.behav. in FORMULA:enter} other";
neuper@52113
  1264
DEconstrCalcTree 1;
neuper@52113
  1265
neuper@52113
  1266
"--------- appendF label{SOLVE:MANUAL:FORMULA:enter}oth 2"; (*UC 30.3.2.4 p.175*)
neuper@52113
  1267
"--------- appendF label{SOLVE:MANUAL:FORMULA:enter}oth 2";
neuper@52113
  1268
"--------- appendF label{SOLVE:MANUAL:FORMULA:enter}oth 2";
neuper@52113
  1269
 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"], 
neuper@52113
  1270
   ("Test", ["sqroot-test","univariate","equation","test"],
neuper@52113
  1271
    ["Test","squ-equ-test-subpbl1"]))];
neuper@52113
  1272
 Iterator 1;
neuper@52113
  1273
 moveActiveRoot 1;
wneuper@59248
  1274
 autoCalculate 1 CompleteCalcHead;
wneuper@59248
  1275
 autoCalculate 1 (Step 1);
wneuper@59248
  1276
 autoCalculate 1 (Step 1);
wneuper@59123
  1277
 appendFormula 1 "x = 1" (*|> Future.join*);
neuper@52113
  1278
 (*... returns calcChangedEvent with*)
neuper@52113
  1279
 val (unc, del, gen) = (([1],Res), ([1],Res), ([3,2],Res));
neuper@52113
  1280
 getFormulaeFromTo 1 unc gen 99999 (*all levels*) false;
neuper@52113
  1281
 (*6 elements !!!*)
neuper@52113
  1282
neuper@52113
  1283
 val ((pt,_),_) = get_calc 1;
neuper@52113
  1284
 val p = get_pos 1 1;
neuper@52113
  1285
 val (Form f, tac, asms) = pt_extract (pt, p);
neuper@52113
  1286
 if term2str f = "x = 1" andalso p = ([3,2], Res) then () else 
neuper@52113
  1287
 error "FE-interface.sml: diff.behav. in FORMULA:enter} oth 2";
neuper@52113
  1288
DEconstrCalcTree 1;
neuper@52113
  1289
neuper@52113
  1290
"--------- appendF label{SOLVE:MANUAL:FORMULA:enter}NOTok"; (*UC 30.3.2.4 p.175*)
neuper@52113
  1291
"--------- appendF label{SOLVE:MANUAL:FORMULA:enter}NOTok";
neuper@52113
  1292
"--------- appendF label{SOLVE:MANUAL:FORMULA:enter}NOTok";
neuper@52113
  1293
 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"], 
neuper@52113
  1294
   ("Test", ["sqroot-test","univariate","equation","test"],
neuper@52113
  1295
    ["Test","squ-equ-test-subpbl1"]))];
neuper@52113
  1296
 Iterator 1;
neuper@52113
  1297
 moveActiveRoot 1;
wneuper@59248
  1298
 autoCalculate 1 CompleteCalcHead;
wneuper@59248
  1299
 autoCalculate 1 (Step 1);
wneuper@59248
  1300
 autoCalculate 1 (Step 1);
wneuper@59123
  1301
 appendFormula 1 "x - 4711 = 0" (*|> Future.join*);
neuper@52113
  1302
 (*... returns <ERROR> no derivation found </ERROR>*)
neuper@52113
  1303
neuper@52113
  1304
 val ((pt,_),_) = get_calc 1;
neuper@52113
  1305
 val p = get_pos 1 1;
neuper@52113
  1306
 val (Form f, tac, asms) = pt_extract (pt, p);
neuper@52113
  1307
 if term2str f = "x + 1 + -1 * 2 = 0" andalso p = ([1], Res) then () else 
neuper@52113
  1308
 error "FE-interface.sml: diff.behav. in FORMULA:enter} NOTok";
neuper@52113
  1309
DEconstrCalcTree 1;
neuper@52113
  1310
neuper@52113
  1311
"--------- replaceFormula {SOL:MAN:FOR:replace} right----"; (*UC 30.3.2.5 p.176*)
neuper@52113
  1312
"--------- replaceFormula {SOL:MAN:FOR:replace} right----";
neuper@52113
  1313
"--------- replaceFormula {SOL:MAN:FOR:replace} right----";
neuper@52113
  1314
(*\label{SOLVE:MANUAL:FORMULA:replace}*)
neuper@52113
  1315
 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"], 
neuper@52113
  1316
   ("Test", ["sqroot-test","univariate","equation","test"],
neuper@52113
  1317
    ["Test","squ-equ-test-subpbl1"]))];
neuper@52113
  1318
 Iterator 1;
neuper@52113
  1319
 moveActiveRoot 1;
wneuper@59248
  1320
 autoCalculate 1 CompleteCalc;
neuper@52113
  1321
 moveActiveFormula 1 ([2],Res);
neuper@52113
  1322
 replaceFormula 1 "-1 + x = 0" (*i.e. repeats input*);
neuper@52113
  1323
 (*... returns <ERROR> formula not changed </ERROR>*)
neuper@52113
  1324
neuper@52113
  1325
 val ((pt,_),_) = get_calc 1;
neuper@52113
  1326
 val p = get_pos 1 1;
neuper@52113
  1327
 val (Form f, tac, asms) = pt_extract (pt, p);
neuper@52113
  1328
 if term2str f = "-1 + x = 0" andalso p = ([2], Res) then () else 
neuper@52113
  1329
 error "FE-interface.sml: diff.behav. in FORMULA:replace} right 1";
wneuper@59520
  1330
 if map fst3 (get_interval ([2],Res) ([],Res) 9999 pt) = 
neuper@52113
  1331
    [([2], Res), ([3], Pbl), ([3, 1], Frm), ([3, 1], Res), ([3, 2], Res),
neuper@52113
  1332
     ([3], Res), ([4], Res), ([], Res)] then () (*nothing deleted!*) else
neuper@52113
  1333
 error "FE-interface.sml: diff.behav. in FORMULA:replace} right 2";
neuper@52113
  1334
neuper@52113
  1335
(*WN050211 replaceFormula didn't work on second ctree: thus now tested...*)
neuper@52113
  1336
 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"], 
neuper@52113
  1337
   ("Test", ["sqroot-test","univariate","equation","test"],
neuper@52113
  1338
    ["Test","squ-equ-test-subpbl1"]))];
neuper@52113
  1339
 Iterator 2;
neuper@52113
  1340
 moveActiveRoot 2;
wneuper@59248
  1341
 autoCalculate 2 CompleteCalc;
neuper@52113
  1342
 moveActiveFormula 2 ([2],Res);
neuper@52113
  1343
 replaceFormula 2 "-1 + x = 0" (*i.e. repeats input*);
neuper@52113
  1344
 (*... returns <ERROR> formula not changed </ERROR>*)
neuper@52113
  1345
neuper@52113
  1346
 val ((pt,_),_) = get_calc 2;
neuper@52113
  1347
 val p = get_pos 2 1;
neuper@52113
  1348
 val (Form f, tac, asms) = pt_extract (pt, p);
neuper@52113
  1349
 if term2str f = "-1 + x = 0" andalso p = ([2], Res) then () else 
neuper@52113
  1350
 error "FE-interface.sml: diff.behav. in FORMULA:replace} right 1";
wneuper@59520
  1351
 if map fst3 (get_interval ([2],Res) ([],Res) 9999 pt) = 
neuper@52113
  1352
    [([2], Res), ([3], Pbl), ([3, 1], Frm), ([3, 1], Res), ([3, 2], Res),
neuper@52113
  1353
     ([3], Res), ([4], Res), ([], Res)] then () (*nothing deleted!*) else
neuper@52113
  1354
 error "FE-interface.sml: diff.behav. in FORMULA:replace} right 2b";
neuper@52113
  1355
DEconstrCalcTree 1;
neuper@52113
  1356
neuper@52113
  1357
"--------- replaceFormula {SOL:MAN:FOR:replace} other----"; (*UC 30.3.2.5 p.176*)
neuper@52113
  1358
"--------- replaceFormula {SOL:MAN:FOR:replace} other----";
neuper@52113
  1359
"--------- replaceFormula {SOL:MAN:FOR:replace} other----";
neuper@52113
  1360
(*\label{SOLVE:MANUAL:FORMULA:replace}*)
neuper@52113
  1361
 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"], 
neuper@52113
  1362
   ("Test", ["sqroot-test","univariate","equation","test"],
neuper@52113
  1363
    ["Test","squ-equ-test-subpbl1"]))];
neuper@52113
  1364
 Iterator 1;
neuper@52113
  1365
 moveActiveRoot 1;
wneuper@59248
  1366
 autoCalculate 1 CompleteCalc;
neuper@52113
  1367
 moveActiveFormula 1 ([2],Res); (*there is "-1 + x = 0"*)
neuper@52113
  1368
 replaceFormula 1 "x - 1 = 0"; (*<-------------------------------------*)
neuper@52113
  1369
 (*... returns calcChangedEvent with*)
neuper@52113
  1370
 val (unc, del, gen) = (([1],Res), ([4],Res), ([2],Res));
neuper@52113
  1371
 getFormulaeFromTo 1 unc gen 99999 (*all levels*) false;
neuper@52113
  1372
neuper@52113
  1373
 val ((pt,_),_) = get_calc 1;
neuper@52113
  1374
 show_pt pt;
neuper@52113
  1375
 val p = get_pos 1 1;
neuper@52113
  1376
 val (Form f, tac, asms) = pt_extract (pt, p);
neuper@52113
  1377
 if term2str f = "x - 1 = 0" andalso p = ([2], Res) then () else 
neuper@52113
  1378
 error "FE-interface.sml: diff.behav. in FORMULA:replace} other 1";
neuper@52113
  1379
(* for getting the list in whole length ...
wneuper@59348
  1380
(*default_print_depth 99*) map fst (get_interval ([1],Res) ([],Res) 9999 pt); (*default_print_depth 3*)
neuper@52113
  1381
   *)
wneuper@59520
  1382
 if map fst3 (get_interval ([1],Res) ([],Res) 9999 pt) = 
neuper@52113
  1383
    [([1], Res), ([2, 1], Frm), ([2, 1], Res), ([2, 2], Res), ([2, 3], Res),
neuper@52113
  1384
      ([2, 4], Res), ([2, 5], Res), ([2, 6], Res), ([2, 7], Res),
wneuper@59283
  1385
      ([2, 8], Res), ([2, 9], Res), ([2], Res)] then () else
neuper@52113
  1386
 error "FE-interface.sml: diff.behav. in FORMULA:replace} other 2";
neuper@52113
  1387
DEconstrCalcTree 1;
neuper@52113
  1388
neuper@52113
  1389
"--------- replaceFormula {SOL:MAN:FOR:replace} other 2--"; (*UC 30.3.2.5 p.176*)
neuper@52113
  1390
"--------- replaceFormula {SOL:MAN:FOR:replace} other 2--";
neuper@52113
  1391
"--------- replaceFormula {SOL:MAN:FOR:replace} other 2--";
neuper@52113
  1392
(*\label{SOLVE:MANUAL:FORMULA:replace}*)
neuper@52113
  1393
 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"], 
neuper@52113
  1394
   ("Test", ["sqroot-test","univariate","equation","test"],
neuper@52113
  1395
    ["Test","squ-equ-test-subpbl1"]))];
neuper@52113
  1396
 Iterator 1;
neuper@52113
  1397
 moveActiveRoot 1;
wneuper@59248
  1398
 autoCalculate 1 CompleteCalc;
neuper@52113
  1399
 moveActiveFormula 1 ([2],Res); (*there is "-1 + x = 0"*)
neuper@52113
  1400
 replaceFormula 1 "x = 1"; (*<-------------------------------------*)
neuper@52113
  1401
 (*... returns calcChangedEvent with ...*)
neuper@52113
  1402
 val (unc, del, gen) = (([1],Res), ([4],Res), ([3,2],Res));
neuper@52113
  1403
 getFormulaeFromTo 1 unc gen 99999 (*all levels*) false;
neuper@52113
  1404
 (*9 elements !!!*)
neuper@52113
  1405
neuper@52113
  1406
 val ((pt,_),_) = get_calc 1;
neuper@52113
  1407
 show_pt pt; (*error: ...get_interval drops ([3,2],Res) ...*)
neuper@52113
  1408
 val (t,_) = get_obj g_result pt [3,2]; term2str t;
wneuper@59520
  1409
  if map fst3 (get_interval ([1],Res) ([],Res) 9999 pt) = 
neuper@52113
  1410
    [([1], Res), ([2], Res), ([3], Pbl), ([3, 1], Frm), ([3, 1], Res),
neuper@52113
  1411
      ([3, 2, 1], Frm), ([3, 2, 1], Res), ([3, 2, 2], Res), 
neuper@52113
  1412
      ([3,2],Res)] then () else
neuper@52113
  1413
 error "FE-interface.sml: diff.behav. in FORMULA:replace} oth2 1";
neuper@52113
  1414
neuper@52113
  1415
 val p = get_pos 1 1;
neuper@52113
  1416
 val (Form f, tac, asms) = pt_extract (pt, p);
neuper@52113
  1417
 if term2str f = "x = 1" andalso p = ([3,2], Res) then () else 
neuper@52113
  1418
 error "FE-interface.sml: diff.behav. in FORMULA:replace} oth2 2";
neuper@52113
  1419
DEconstrCalcTree 1;
neuper@52113
  1420
neuper@52113
  1421
"--------- replaceFormula {SOL:MAN:FOR:replace} NOTok----"; (*UC 30.3.2.5 p.176*)
neuper@52113
  1422
"--------- replaceFormula {SOL:MAN:FOR:replace} NOTok----";
neuper@52113
  1423
"--------- replaceFormula {SOL:MAN:FOR:replace} NOTok----";
neuper@52113
  1424
(*\label{SOLVE:MANUAL:FORMULA:replace}*)
neuper@52113
  1425
 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"], 
neuper@52113
  1426
   ("Test", ["sqroot-test","univariate","equation","test"],
neuper@52113
  1427
    ["Test","squ-equ-test-subpbl1"]))];
neuper@52113
  1428
 Iterator 1;
neuper@52113
  1429
 moveActiveRoot 1;
wneuper@59248
  1430
 autoCalculate 1 CompleteCalc;
neuper@52113
  1431
 moveActiveFormula 1 ([2],Res); (*there is "-1 + x = 0"*)
neuper@52113
  1432
 replaceFormula 1 "x - 4711 = 0"; 
neuper@52113
  1433
 (*... returns <ERROR> no derivation found </ERROR>*)
neuper@52113
  1434
neuper@52113
  1435
 val ((pt,_),_) = get_calc 1;
neuper@52113
  1436
 show_pt pt;
neuper@52113
  1437
 val p = get_pos 1 1;
neuper@52113
  1438
 val (Form f, tac, asms) = pt_extract (pt, p);
neuper@52113
  1439
 if term2str f = "-1 + x = 0" andalso p = ([2], Res) then () else 
neuper@52113
  1440
 error "FE-interface.sml: diff.behav. in FORMULA:replace} NOTok";
wneuper@59254
  1441
 DEconstrCalcTree 1;
neuper@52113
  1442
neuper@52113
  1443
"--------- UC errpat chain-rule-diff-both, fillpat by input ------";
neuper@52113
  1444
"--------- UC errpat chain-rule-diff-both, fillpat by input ------";
neuper@52113
  1445
"--------- UC errpat chain-rule-diff-both, fillpat by input ------";
neuper@52113
  1446
CalcTree
neuper@52113
  1447
[(["functionTerm (x ^ 2 + sin (x ^ 4))", "differentiateFor x", "derivative f_f'"], 
wneuper@59592
  1448
  ("Isac_Knowledge", ["derivative_of","function"], ["diff","differentiate_on_R"]))];
neuper@52113
  1449
Iterator 1;
neuper@52113
  1450
moveActiveRoot 1;
wneuper@59248
  1451
autoCalculate 1 CompleteCalcHead;
wneuper@59248
  1452
autoCalculate 1 (Step 1);
wneuper@59248
  1453
autoCalculate 1 (Step 1);(*([1], Res), d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))*)
wneuper@59123
  1454
appendFormula 1 "d_d x (x ^ 2) + cos (4 * x ^ 3)" (*|> Future.join*); (*<<<<<<<=========================*)
neuper@52113
  1455
(* the check for errpat is maximally liberal (whole term modulo "nrls" from "type met"),
neuper@52113
  1456
  would recognize "cos (4 * x ^ (4 - 1)) + 2 * x" as well.
neuper@52113
  1457
  results in <CALCMESSAGE> error pattern #chain-rule-diff-both# </CALCMESSAGE>
neuper@52113
  1458
  instead of <CALCMESSAGE> no derivation found </CALCMESSAGE> *)
neuper@52113
  1459
  val ((pt,pos), _) = get_calc 1;
neuper@52113
  1460
  val p = get_pos 1 1;
neuper@52113
  1461
  val (Form f, _, asms) = pt_extract (pt, p);
neuper@52113
  1462
wneuper@59254
  1463
  if p = ([1], Res) andalso term2str f = "d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))"
wneuper@59497
  1464
  then case get_obj g_tac pt (fst p) of Rewrite_Inst (["(''bdv'', x)"],
wneuper@59253
  1465
      ("diff_sum", thm)) => () | _ => error "embed fun get_fillform changed 0"
wneuper@59253
  1466
  | _ => error "embed fun get_fillform changed 1"
wneuper@59253
  1467
else error "embed fun get_fillform changed 2";
neuper@52113
  1468
neuper@52113
  1469
(*========== inhibit exn WN1130621 Isabelle2012-->13 !thehier! ====================
neuper@52113
  1470
findFillpatterns 1 "chain-rule-diff-both"; (*<<<<<<<=================================*)
neuper@52113
  1471
(*<CALCMESSAGE> fill patterns #fill-d_d-arg#d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4)) =
neuper@52113
  1472
  d_d x (x ^^^ 2) + cos (x ^^^ 4) * d_d x ?_dummy_1#fill-both-args#...#...#... *)
neuper@52113
  1473
  val ((pt,pos),_) = get_calc 1;
neuper@52113
  1474
  val p = get_pos 1 1;
neuper@52113
  1475
neuper@52113
  1476
  val (Form f, _, asms) = pt_extract (pt, p);
neuper@52113
  1477
  if p = ([1], Res) andalso term2str f = "d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))" andalso
wneuper@59497
  1478
    get_obj g_tac pt (fst p) = Rewrite_Inst (["(''bdv'', x)"], ("diff_sum", "Diff.diff_sum"(*?!?*)))
neuper@52113
  1479
  then ()
neuper@52113
  1480
  else error "embed fun get_fillform changed 2";
neuper@52113
  1481
neuper@52113
  1482
(* if we assume, that the fill-patterns are ordered such that the 1st has large gaps
neuper@52113
  1483
   and the last has no gaps, then the number of fill-patterns would suffice
neuper@52113
  1484
   for the DialogGuide to select appropriately. *)
neuper@52113
  1485
requestFillformula 1 ("chain-rule-diff-both", "fill-both-args");(*<<<<<<<============*)
neuper@52113
  1486
  (*<AUTOCALC> ([1], Res) ([2], Res) ([2], Res) </AUTOCALC>*)
neuper@52113
  1487
  val ((pt,pos),_) = get_calc 1;
neuper@52113
  1488
  val p = get_pos 1 1;
neuper@52113
  1489
  val (Form f, _, asms) = pt_extract (pt, p);
neuper@52113
  1490
  if p = ([1], Res) andalso existpt [2] pt andalso
neuper@52113
  1491
    term2str f = "d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))" andalso
wneuper@59497
  1492
    get_obj g_tac pt (fst p) = Rewrite_Inst (["(''bdv'', x)"], ("diff_sum", "Diff.diff_sum"))
neuper@52113
  1493
  then () else error "embed fun get_fillform changed 3";
neuper@52113
  1494
neuper@52113
  1495
inputFillFormula 1 "d_d x (x ^^^ 2) + cos (x ^^^ 4) * d_d x (x ^^^ 4)";(*<<<<<<<=====*)
neuper@52113
  1496
  val ((pt, _),_) = get_calc 1;
neuper@52113
  1497
  val p = get_pos 1 1;
neuper@52113
  1498
  val (Form f, _, asms) = pt_extract (pt, p);
neuper@52113
  1499
  if p = ([2], Res) andalso
neuper@52113
  1500
    term2str f = "d_d x (x ^^^ 2) + cos (x ^^^ 4) * d_d x (x ^^^ 4)" andalso
wneuper@59497
  1501
    get_obj g_tac pt (fst p) = Rewrite_Inst (["(''bdv'', x)"], ("diff_sin_chain", ""))
neuper@52113
  1502
  then () else error "inputFillFormula changed 11";
neuper@52113
  1503
wneuper@59248
  1504
autoCalculate 1 CompleteCalc;
neuper@52113
  1505
neuper@52113
  1506
"~~~~~ final check: the input formula is inserted as it would have been correct from beginning";
neuper@52113
  1507
val ((pt, _),_) = get_calc 1;
neuper@52113
  1508
val p = get_pos 1 1;
neuper@52113
  1509
val (Form f, _, asms) = pt_extract (pt, p);
neuper@52113
  1510
if p = ([], Res) andalso term2str f = "2 * x + cos (x ^^^ 4) * 4 * x ^^^ 3"
neuper@52113
  1511
then () else error "inputFillFormula changed 12";
neuper@52113
  1512
show_pt pt;
neuper@52113
  1513
(*[
neuper@52113
  1514
(([], Frm), Diff (x ^^^ 2 + sin (x ^^^ 4), x)),
neuper@52113
  1515
(([1], Frm), d_d x (x ^^^ 2 + sin (x ^^^ 4))),
neuper@52113
  1516
(([1], Res), d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))),
neuper@52113
  1517
(([2], Res), d_d x (x ^^^ 2) + cos (x ^^^ 4) * d_d x (x ^^^ 4)),       (*<<<<<<<=====*)
neuper@52113
  1518
(([3], Res), d_d x (x ^^^ 2) + cos (x ^^^ 4) * (4 * x ^^^ (4 - 1))),
neuper@52113
  1519
(([4], Res), 2 * x ^^^ (2 - 1) + cos (x ^^^ 4) * (4 * x ^^^ (4 - 1))),
neuper@52113
  1520
(([5], Res), 2 * x + cos (x ^^^ 4) * 4 * x ^^^ 3),
neuper@52113
  1521
(([], Res), 2 * x + cos (x ^^^ 4) * 4 * x ^^^ 3)] *)
neuper@52113
  1522
============ inhibit exn WN1130621 Isabelle2012-->13 !thehier! ==================*)
wneuper@59253
  1523
DEconstrCalcTree 1;
neuper@52113
  1524
neuper@52113
  1525
"--------- UC errpat add-fraction, fillpat by input --------------";
neuper@52113
  1526
"--------- UC errpat add-fraction, fillpat by input --------------";
neuper@52113
  1527
"--------- UC errpat add-fraction, fillpat by input --------------";
neuper@52113
  1528
(*cp from BridgeLog Java <=> SML*)
wneuper@59254
  1529
CalcTree [([], ("e_domID", ["e_pblID"], ["e_metID"]))];
neuper@52113
  1530
Iterator 1;
neuper@52113
  1531
moveActiveRoot 1;
neuper@52113
  1532
moveActiveFormula 1 ([],Pbl);
neuper@52113
  1533
replaceFormula 1 "Simplify (5 * x / (4 * y) + 3 * x / (4 * y))";
wneuper@59248
  1534
autoCalculate 1 CompleteCalcHead;
wneuper@59248
  1535
autoCalculate 1 (Step 1);
wneuper@59123
  1536
appendFormula 1 "8 * x / (8 * y)" (*|> Future.join*);
neuper@52113
  1537
(*<CALCMESSAGE> no derivation found </CALCMESSAGE> 
neuper@52113
  1538
--- but in BridgeLog Java <=> SML:
neuper@52113
  1539
<CALCMESSAGE> error pattern #addition-of-fractions# </CALCMESSAGE>*)
wneuper@59253
  1540
DEconstrCalcTree 1;
neuper@52113
  1541
neuper@52113
  1542
"--------- UC errpat, fillpat step to Rewrite --------------------";
neuper@52113
  1543
"--------- UC errpat, fillpat step to Rewrite --------------------";
neuper@52113
  1544
"--------- UC errpat, fillpat step to Rewrite --------------------";
neuper@52113
  1545
(*TODO*)
wneuper@59254
  1546
CalcTree
neuper@52113
  1547
[(["functionTerm ((x ^ 2) ^ 3 + sin (x ^ 4))",
neuper@52113
  1548
   "differentiateFor x", "derivative f_f'"], 
wneuper@59592
  1549
  ("Isac_Knowledge", ["derivative_of","function"],
neuper@52113
  1550
  ["diff","differentiate_on_R"]))]; (*<<<======= EP is directly in script*)
neuper@52113
  1551
Iterator 1;
neuper@52113
  1552
moveActiveRoot 1;
wneuper@59248
  1553
autoCalculate 1 CompleteCalc;
neuper@52113
  1554
val ((pt,p),_) = get_calc 1; show_pt pt;
wneuper@59253
  1555
DEconstrCalcTree 1;
neuper@52113
  1556
neuper@52113
  1557
"--------- UC errpat, fillpat step to Rewrite_Set ----------------";
neuper@52113
  1558
"--------- UC errpat, fillpat step to Rewrite_Set ----------------";
neuper@52113
  1559
"--------- UC errpat, fillpat step to Rewrite_Set ----------------";
neuper@52113
  1560
CalcTree
neuper@52113
  1561
[(["functionTerm ((x ^ 2) ^ 3 + sin (x ^ 4))",
neuper@52113
  1562
   "differentiateFor x", "derivative f_f'"], 
wneuper@59592
  1563
  ("Isac_Knowledge", ["derivative_of","function"],
neuper@52113
  1564
  ["diff","after_simplification"]))]; (*<<<======= EP is in a ruleset*)
neuper@52113
  1565
Iterator 1;
neuper@52113
  1566
moveActiveRoot 1;
wneuper@59248
  1567
autoCalculate 1 CompleteCalcHead;
wneuper@59248
  1568
autoCalculate 1 (Step 1); fetchProposedTactic 1;
wneuper@59248
  1569
autoCalculate 1 (Step 1); fetchProposedTactic 1;
neuper@52113
  1570
(*
neuper@52113
  1571
<NEXTTAC>
neuper@52113
  1572
  <CALCID> 1 </CALCID>
neuper@52113
  1573
  <TACTICERRORPATTERNS>
neuper@52113
  1574
    <STRINGLIST>
neuper@52113
  1575
      <STRING> chain-rule-diff-both </STRING>
neuper@52113
  1576
      <STRING> cancel </STRING>
neuper@52113
  1577
    </STRINGLIST>
neuper@52113
  1578
    <REWRITESETINSTTACTIC name="Rewrite_Set_Inst">
neuper@52113
  1579
      <RULESET> norm_diff </RULESET>
neuper@52113
  1580
      <SUBSTITUTION>
neuper@52113
  1581
        <PAIR>
neuper@52113
  1582
          <VARIABLE>
neuper@52113
  1583
            <MATHML>
neuper@52113
  1584
              <ISA> bdv </ISA>
neuper@52113
  1585
            </MATHML>
neuper@52113
  1586
          </VARIABLE>
neuper@52113
  1587
          <VALUE>
neuper@52113
  1588
            <MATHML>
neuper@52113
  1589
              <ISA> x </ISA>
neuper@52113
  1590
            </MATHML>
neuper@52113
  1591
          </VALUE>
neuper@52113
  1592
        </PAIR>
neuper@52113
  1593
      </SUBSTITUTION>
neuper@52113
  1594
    </REWRITESETINSTTACTIC>
neuper@52113
  1595
  </TACTICERRORPATTERNS>
neuper@52113
  1596
</NEXTTAC>
neuper@52113
  1597
neuper@52113
  1598
neuper@52113
  1599
(*WN1208 postponed due to efforts required for stepToErrorPatterns (NEW rewrite_set_)*)
neuper@52113
  1600
stepToErrorPatterns 1; (*--> calcChanged, rule immediately calls... *)
neuper@52113
  1601
stepOnErrorPatterns 1; (*--> calcChanged, rule calls getTactic and displays it *)
neuper@52113
  1602
(* then --- UC errpat, fillpat by input ---*)
neuper@52113
  1603
*)
wneuper@59248
  1604
autoCalculate 1 CompleteCalc;
neuper@52113
  1605
val ((pt,p),_) = get_calc 1; show_pt pt;
neuper@52113
  1606
(*WN1208 postponed due to efforts required for stepToErrorPatterns (NEW rewrite_set_)*)
wneuper@59253
  1607
DEconstrCalcTree 1;
neuper@52113
  1608