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