isac-java/src/java/isac/bridge/BridgeRMI.java
author Walther Neuper <walther.neuper@jku.at>
Fri, 26 Mar 2021 10:45:05 +0100
changeset 5239 b4e3883d7b66
parent 5229 6bf0e95981e3
child 5240 0b946345a015
permissions -rw-r--r--
reset mathematics-engine to Isabelle2015

note: for this version libisabelle was available,
which connects front-end (Java) and back-end (Isabelle/ML)
     1 /**
     2  * Created on Oct 13, 2003
     3  * @author Richard Gradischnegg RG
     4  */
     5 package isac.bridge;
     6 
     7 import isac.bridge.xml.DataTypes;
     8 import isac.bridge.xml.IntAssumptions;
     9 import isac.bridge.xml.IntCalcHead;
    10 import isac.bridge.xml.IntCEvent;
    11 import isac.bridge.xml.IntFormHead;
    12 import isac.bridge.xml.IntFormulas;
    13 import isac.bridge.xml.IntIntCompound;
    14 import isac.bridge.xml.IntContext;
    15 import isac.bridge.xml.IntPosition;
    16 import isac.bridge.xml.IntTactic;
    17 import isac.bridge.xml.IntTacticErrPats;
    18 import isac.bridge.xml.IntTactics;
    19 import isac.bridge.xml.IsaToJava;
    20 import isac.bridge.xml.JavaToIsa;
    21 import isac.interfaces.ICalcElement;
    22 import isac.interfaces.ICalcIterator;
    23 import isac.interfaces.IToCalc;
    24 import isac.util.Formalization;
    25 import isac.util.ResponseWrapper;
    26 import isac.util.formulae.Assumptions;
    27 import isac.util.formulae.CalcHead;
    28 import isac.util.formulae.Context;
    29 import isac.util.formulae.ContextMethod;
    30 import isac.util.formulae.ContextProblem;
    31 import isac.util.formulae.ContextTheory;
    32 import isac.util.formulae.HierarchyKey;
    33 import isac.util.formulae.CalcFormula;
    34 import isac.util.formulae.Match;
    35 import isac.util.formulae.MethodID;
    36 import isac.util.formulae.Position;
    37 import isac.util.formulae.ProblemID;
    38 import isac.util.parser.XMLParserDigest;
    39 import isac.util.tactics.SimpleTactic;
    40 import isac.util.tactics.Tactic;
    41 import isac.wsdialog.IContextProvider.ContextType;
    42 import edu.tum.cs.isabelle.api.XML;
    43 import edu.tum.cs.isabelle.japi.JSystem;
    44 
    45 import java.io.BufferedReader;
    46 import java.io.IOException;
    47 import java.io.InputStreamReader;
    48 import java.io.PrintWriter;
    49 import java.math.BigInteger;
    50 import java.net.MalformedURLException;
    51 import java.net.Socket;
    52 import java.net.UnknownHostException;
    53 import java.rmi.Naming;
    54 import java.rmi.RMISecurityManager;
    55 import java.rmi.RemoteException;
    56 import java.rmi.registry.LocateRegistry;
    57 import java.rmi.server.UnicastRemoteObject;
    58 import java.util.HashMap;
    59 import java.util.Iterator;
    60 import java.util.Map;
    61 import java.util.Set;
    62 import java.util.Vector;
    63 
    64 import scala.math.BigInt;
    65 
    66 import org.apache.log4j.Logger;
    67 
    68 /**
    69  * @author Richard Gradischnegg RG
    70  * 
    71  * WN0422 here seems to be the key for simplifying the whole bridge.* drawbacks
    72  * of the present implementation: # more complicated than necessary #
    73  * JUnitTestCases require BridgeMain running # BridgeLogger cannot be made
    74  * serializable, thus not accessible for writing by JUnitTestCases #
    75  */
    76 @SuppressWarnings("deprecation") // RMISecurityManager : RMI reform will come
    77 public class BridgeRMI extends UnicastRemoteObject implements IBridgeRMI {
    78 
    79     static final long serialVersionUID = -3047706038036289437L;
    80     private static final Logger logger = Logger.getLogger(BridgeRMI.class.getName());
    81 
    82 	private BridgeMain bridge_;
    83 
    84     private XMLParserDigest xml_parser_digest_;
    85 
    86     // Socket used to communicate with bridge
    87     private Socket socket_ = null;
    88 
    89     // Writer to write sml requests to the kernel
    90     private PrintWriter out_ = null;
    91 
    92     // Reader to read sml response from kernel
    93     private BufferedReader in_ = null;
    94 
    95     private String host_;
    96 
    97     private int rmiid_;
    98 
    99     /**
   100      * Maps the Java calc(Tree)rmiID to the sml calc(Tree)rmiID. A mapping is
   101      * nescessary because these ids are not (nescessary) the same: For example
   102      * when restoring the kernel, the calcTree rmiID can change because of
   103      * already finished CalcTrees no longer existing and their CalcId assigned
   104      * to another CalcTree. key: Integer (javaCalcID) value: Integer (smlCalcID)
   105      */
   106     private Map<Integer, Integer> java_calcid_to_smlcalcid_;
   107 
   108     /**
   109      * This map stores user inputs which have already been answered by the
   110      * kernel and the response being sent back to the user. These inputs are
   111      * resent to the kernel in the case of a newstart of the kernel. key:
   112      * Integer (javaCalcID) value: Vector (containing input strings)
   113      */
   114     private Map<Integer, Vector<String>> inputs_;
   115 	private JSystem connection_to_kernel_;
   116 
   117     public BridgeRMI(BridgeMain bridge, String host, int port, String dtdPath)
   118             throws RemoteException {
   119         if (logger.isDebugEnabled())
   120             logger.debug("BridgeRMI obj.init: bridge=" + bridge + ", host=" + host
   121                 + ", port=" + port + ", dtdPath=" + dtdPath);
   122         this.host_ = host;
   123         this.bridge_ = bridge;
   124         this.connection_to_kernel_ = bridge.getConnectionToKernel();
   125         in_ = bridge.getSmlReader();
   126         try {
   127             socket_ = new Socket(host, port);
   128             out_ = new PrintWriter(socket_.getOutputStream(), true);
   129             in_ = new BufferedReader(new InputStreamReader(socket_
   130                     .getInputStream()));
   131         } catch (UnknownHostException e) {
   132             System.out.println("Unknown host: " + host + "\n");
   133         } catch (IOException e) {
   134             System.out.println("probably just a remainder of 'bridge-internal RMI'");
   135         }
   136         rmiBind();
   137         xml_parser_digest_ = new XMLParserDigest(dtdPath);
   138         //xml_parser_digest_.setValidating(true);
   139         //...all XML-data should be tested in
   140         //javatest.isac.util.parser.TestXMLParserDigest
   141         inputs_ = new HashMap<Integer, Vector<String>>();
   142         java_calcid_to_smlcalcid_ = new HashMap<>();
   143     }
   144 
   145     /**
   146      * Buffers input sent to the sml-Kernel (for later possible restart)
   147      * 
   148      * @param javaCalcID
   149      *            calcTree this input belongs to
   150      * @param input
   151      *            to be buffered
   152      */
   153     public void bufferInput(int javaCalcID, String input) {
   154         Vector<String> v = (Vector<String>) inputs_.get(new Integer(javaCalcID));
   155         if (v == null) {
   156             v = new Vector<>();
   157             inputs_.put(new Integer(javaCalcID), v);
   158         }
   159         v.add(input);
   160     }
   161 
   162     // '@calcid@' is a placeholder for the CalcID
   163     // this method replaces it with a real CalcID
   164     private String insertCalcID(int id, String s) {
   165         return s.replaceAll("@calcid@", String.valueOf(id));
   166     }
   167 
   168     // return smallest integer which is not yet
   169     // used as a (java)CalcID
   170     private int smallestFreeCalcID() {
   171         Set<?> set = java_calcid_to_smlcalcid_.keySet();
   172         for (int i = 0; i < set.size(); i++) {
   173             if (!set.contains(new Integer(i))) {
   174                 return i;
   175             }
   176         }
   177         return set.size();
   178     }
   179 
   180     /*
   181      * Send a sml instruction to the kernel. restore == true, if the instruction
   182      * is resent after the kernel crashed
   183      */
   184     private ResponseWrapper sendToKernel(String smlInstr, boolean restore) {
   185         if (logger.isDebugEnabled())
   186             logger.debug("   BR->KN: sendToKernel(" + smlInstr + ")");
   187         ResponseWrapper wrapper = null;
   188         //bridge.log(1,"---sendToKernel |
   189         //bridge.isRestoring=="+bridge.isRestoring());
   190         //bridge.log(1,"---sendToKernel | restoring=="+restore);
   191         if (!bridge_.isRestoring() || restore) {
   192             String xmlString = "";
   193 
   194             out_.println(smlInstr);// send the sml Instruction to the sml Kernel
   195             try {
   196                 xmlString = in_.readLine();//read the response from the kernel
   197                 if (logger.isInfoEnabled())
   198                     logger.info("   BR<-KN: sendToKernel <- xml= " + xmlString);
   199             } catch (IOException e) {
   200                 bridge_.log(1, "BridgeRMI.interpretSKN: IOException");
   201                 e.printStackTrace();
   202             }
   203             //if (!(restore) && bridge.isRestoring()) {
   204             //	this.restoreExistingCalcTrees();
   205             //}
   206             
   207             bridge_.log( 1, xmlString );
   208             wrapper = xml_parser_digest_.parse(xmlString);
   209         }
   210         return wrapper;
   211     }
   212 
   213     /**
   214      * Send an instruction to the SML-Kernel and return the response
   215      * 
   216      * @param smlInstr
   217      *            Instruction
   218      * @return response from SML-Kernel
   219      */
   220     private synchronized ResponseWrapper interpretSML(int javaCalcID,
   221             String instr, boolean restore) {
   222         int smlCalcID;
   223         
   224         Integer smlCalcInteger = (Integer) java_calcid_to_smlcalcid_.get(new Integer(javaCalcID));
   225         if( smlCalcInteger == null ) {
   226         	bridge_.log(1, "smlCalcInteger is null for javaCalcID : " + javaCalcID );
   227         	return null;
   228         }
   229         
   230         smlCalcID = smlCalcInteger.intValue();
   231         String smlInstr = insertCalcID(smlCalcID, instr);
   232         bridge_.log(1, "JavaCalcID " + javaCalcID + " == SmlCalcID "
   233                 + smlCalcID);
   234         bridge_.log(1, "sent to bridge: " + smlInstr);
   235         ResponseWrapper wrapper = this.sendToKernel(smlInstr, restore); 
   236         if (!restore)
   237             bufferInput(javaCalcID, smlInstr);
   238         return wrapper;
   239     }
   240 
   241 	private void rmiBind() {
   242         if (logger.isDebugEnabled())
   243             logger.debug("rmiBind");
   244         if (System.getSecurityManager() == null) {
   245             System.setSecurityManager(new RMISecurityManager());
   246         }
   247         
   248         String name = "//" + host_ + "/BridgeRMI";
   249         try {
   250             System.out.println("try to bind as " + name);
   251             Naming.rebind(name, this);
   252             System.out.println("Bridge RMI bound to " + name);
   253         } catch (java.rmi.ConnectException e) {
   254             System.err.println("failed to contact as " + name + " (creating RMI-Server on localhost: 1099)");
   255             try {
   256                 LocateRegistry.createRegistry(1099);
   257             } catch (java.rmi.RemoteException exc2) {
   258                 System.err.println("can not create registry: " + exc2.getMessage());
   259                 System.exit(1);
   260             }
   261             rmiBind();
   262         } catch (RemoteException e) {
   263         	System.err.println("RemoteException");
   264         	System.err.println(e.getMessage());
   265         	System.err.println(e.getCause().getMessage());
   266         	System.err.println(e.getCause().getClass());
   267         	e.printStackTrace();
   268         	System.exit(1);
   269 
   270         } catch (MalformedURLException e) {
   271         	System.err.println(e.getMessage());
   272         	e.printStackTrace();
   273         	System.exit(1);
   274 
   275         } catch (Exception e) {
   276         	System.err.println("----------- Exception");
   277         	System.err.println(e.getClass().getName());
   278         	System.err.println(e.getMessage());
   279         	e.printStackTrace();
   280         	System.exit(1);
   281         	
   282         }
   283     }
   284 
   285     /**
   286      * Restore a saved calcTree.
   287      * 
   288      * @param v
   289      *            Vector containing strings
   290      * @return Java CalcTreeID (not SML-ID)
   291      */
   292     public int loadCalcTree(Vector v) {
   293         this.bridge_.log(1, "----------------begin loading------------");
   294         int javaCalcID = smallestFreeCalcID();
   295         this.bridge_.log(1, "-----smallest free  = " + javaCalcID);
   296         restoreToSML(javaCalcID, v);
   297         this.bridge_.log(1, "----------------done loading-------------");
   298         return javaCalcID;
   299     }
   300 
   301     public int smlCalcIDtoJavaCalcID(int smlID) {
   302         Iterator<?> it = java_calcid_to_smlcalcid_.keySet().iterator();
   303         while (it.hasNext()) {
   304             Object key = it.next();
   305             Integer value = (Integer) java_calcid_to_smlcalcid_.get(key);
   306             if (value.intValue() == smlID) {
   307                 return ((Integer) key).intValue();
   308             }
   309         }
   310         return -1;
   311     }
   312 
   313     public Map<?, Vector<String>> getInputs() {
   314         return inputs_;
   315     }
   316 
   317     public int getRmiID() {
   318         return rmiid_;
   319     }
   320 
   321     public void setRmiID(int i) {
   322         if (logger.isDebugEnabled())
   323             logger.debug("setRmiID: i=" + i);
   324         rmiid_ = i;
   325     }
   326 
   327     /**
   328      * causes a CalcChanged event for the first line on the Worksheet
   329      * 
   330      * @param id
   331      *            for the CalcTree (unused)
   332      * @return CalcChanged with Iterators pointing at the root of the CalcTree
   333      */
   334     public CChanged startCalculate(int id) {
   335         Position p = new Position();
   336         p.setKind("Pbl");// toSMLString --> ([],"Pbl")
   337         CChanged cc = new CChanged();
   338         cc.setLastUnchanged(p);
   339         cc.setLastDeleted(p);
   340         cc.setLastGenerated(p);
   341         return cc;
   342     }
   343 
   344     /**
   345      * Starts the specifying phase: fill the calcTree with the appropriate
   346      * information. Once the calc_head_ is fully specified, the user can begin
   347      * with the actual calculation.
   348      * 
   349      * @param f
   350      *            Formalization for this calculation (empty if user starts a
   351      *            complete new calculation)
   352      * @return javaCalcID
   353      */
   354     public int getCalcTree(Formalization formalization) {
   355     	int return_val;
   356     	int javaCalcID = smallestFreeCalcID();
   357     	this.bridge_.log(1, "-----smallest free javaCalcID = " + javaCalcID);
   358     	newCalculation(javaCalcID, 
   359     	  "CalcTree " + formalization.toSMLString() + ";", formalization, false);
   360     	return_val = javaCalcID;
   361         return return_val;
   362     }
   363 
   364     /***********************************************************************
   365      * Below are all the methods in structure Math_Engine : MATH_ENGINE
   366      * listed in the same order as in the signature.
   367      * The previous order still reflected original development;
   368      * method names reflect the original struggle at the 
   369      * interface Java <--> Isabelle/Isac: different names are made explicit.
   370      */
   371     
   372     /** MATH_ENGINE: val appendFormula : calcID -> cterm' -> XML.tree */
   373     public CEvent appendFormula(int id, CalcFormula f) {
   374     	CEvent return_val = null;
   375     	int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(id));
   376         /*---------------------------------------------------------------------------*/
   377     	//*TTY*/ResponseWrapper wrapper = null;
   378     	//*TTY*/wrapper = interpretSML(id, "appendFormula @calcid@ \"" + f.toSMLString() + "\";", false);
   379     	//*TTY*/if (wrapper == null) return null;
   380     	//*TTY*/return_val = (CEvent) wrapper.getResponse();
   381         /*---------------------------------------------------------------------------*/
   382     	/*PIDE*/bridge_.log(1, "-->ISA: " + "appendFormula " + sml_id + " \"" + f.toSMLString() + "\";");
   383     	/*PIDE*/XML.Tree xml_in = JavaToIsa.append_form(new scala.math.BigInt(BigInteger.valueOf(sml_id)), f.getFormula());    	
   384     	/*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);    	
   385     	/*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(IsacOperations.APPEND_FORM, xml_in);
   386 
   387     	/*PIDE*/IntCEvent java_out = null;
   388     	/*PIDE*/if (!IsaToJava.is_message(xml_out)) java_out = IsaToJava.append_form_out(xml_out);
   389     	/*PIDE*/// else: no message handling by DialogGuide
   390     	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
   391     	/*PIDE*/return_val = java_out.getCEvent();
   392         /*---------------------------------------------------------------------------*/
   393         return return_val;   
   394     }
   395 
   396     /** MATH_ENGINE: val autoCalculate : calcID -> auto -> XML.tree */
   397     public CEvent autoCalculate(int id, int scope, int steps) {
   398         if (logger.isDebugEnabled())
   399             logger.debug("BridgeRMI#autoCalculate: id=" + id + ", scope" + scope + ", steps" + steps);
   400         CEvent return_val = null;
   401     	int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(id));
   402     	String log_str;
   403         /*---------------------------------------------------------------------------*/
   404     	//*TTY*/if ((scope == 3) && (steps == 0)) { //scope ==3 means IToCalc.SCOPE_CALCHEAD:
   405     	//*TTY*/    wrapper = interpretSML(id, "autoCalculate @calcid@ CompleteCalcHead;", false);
   406     	//*TTY*/} else if ((scope == IToCalc.SCOPE_CALCULATION) && (steps == 0)) {
   407     	//*TTY*/    wrapper = interpretSML(id, "autoCalculate @calcid@ CompleteCalc;", false);
   408         //*TTY*/} else if ((scope == IToCalc.SCOPE_MODEL) && (steps == 0)) {
   409         //*TTY*/    wrapper = interpretSML(id, "autoCalculate @calcid@ CompleteModel;", false);
   410         //*TTY*/} else if ((scope == IToCalc.SCOPE_SUBCALCULATION) && (steps == 0)) {
   411         //*TTY*/    wrapper = interpretSML(id, "autoCalculate @calcid@ CompleteToSubpbl;", false);
   412         //*TTY*/} else if ((scope == IToCalc.SCOPE_SUBPROBLEM) && (steps == 0)) {
   413         //*TTY*/    wrapper = interpretSML(id, "autoCalculate @calcid@ CompleteSubpbl;", false);
   414         //*TTY*/} else { //FIXXXME040624: steps do not regard the scope
   415         //*TTY*/    wrapper = interpretSML(id, "autoCalculate @calcid@ (Step " + steps + ");", false);
   416         //*TTY*/}
   417         //*TTY*/if (wrapper == null) return_val =  null;
   418         //*TTY*/return_val = (CEvent) wrapper.getResponse();
   419         //-----------------------------------------------------------------------------
   420     	/*PIDE*/String scope_str;
   421     	/*PIDE*/if ((scope == 3) && (steps == 0)) { //scope ==3 means IToCalc.SCOPE_CALCHEAD:
   422     	/*PIDE*/	scope_str = "CompleteCalcHead"; //FIXXXME.WN040624 steps == 0 hides mismatch in specifications
   423     	/*PIDE*/} else if ((scope == IToCalc.SCOPE_CALCULATION) && (steps == 0)) {
   424     	/*PIDE*/	scope_str = "CompleteCalc";
   425     	/*PIDE*/} else if ((scope == IToCalc.SCOPE_MODEL) && (steps == 0)) {
   426     	/*PIDE*/	scope_str = "CompleteModel";
   427     	/*PIDE*/} else if ((scope == IToCalc.SCOPE_SUBCALCULATION) && (steps == 0)) {
   428     	/*PIDE*/	scope_str = "CompleteToSubpbl";
   429     	/*PIDE*/} else if ((scope == IToCalc.SCOPE_SUBPROBLEM) && (steps == 0)) {
   430     	/*PIDE*/	scope_str = "CompleteSubpbl";
   431     	/*PIDE*/} else { //FIXXXME040624: steps do not regard the scope
   432     	/*PIDE*/	scope_str = "Step"; // steps > 0 according to impl.in "isabelle tty"
   433     	/*PIDE*/}
   434     	/*PIDE*/if (steps == 0) log_str = scope_str; else log_str = "(Step " + steps + ")";
   435     	/*PIDE*/bridge_.log(1, "-->ISA: " + "autoCalculate " + sml_id + " " + log_str + ";");
   436     	
   437     	/*PIDE*/XML.Tree xml_in = JavaToIsa.auto_calculate(new scala.math.BigInt(BigInteger.valueOf(sml_id)), 
   438     	/*PIDE*/  scope_str, new scala.math.BigInt(BigInteger.valueOf(steps)));
   439     	/*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
   440     	/*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(IsacOperations.AUTO_CALC, xml_in);
   441 
   442     	/*PIDE*/IntCEvent java_out = null;
   443     	/*PIDE*/if (!IsaToJava.is_message(xml_out)) {
   444     	/*PIDE*/  java_out = IsaToJava.auto_calc_out(xml_out);
   445     	/*PIDE*/  return_val = java_out.getCEvent();
   446     	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);    	
   447     	/*PIDE*/} else
   448         /*PIDE*/  bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);    	
   449         /*---------------------------------------------------------------------------*/
   450         return return_val;
   451     }
   452 
   453     /** MATH_ENGINE: val applyTactic : calcID -> pos' -> tac -> XML.tree 
   454      * not implemented in Math_Engine.
   455      * compare setNextTactic. */
   456     
   457     /**
   458      * Starts a new calculation in the sml-Kernel: i.e. a new CalcTree with the
   459      * initial hot_spot_
   460      * 
   461      * @param instr
   462      *            "CalcTree" + Formalization in string Representation
   463      * @param fmz 
   464      * @return sml_calcid //WN150817 why return SML(?!) calcid to Java(?!)
   465      * 
   466      * MATH_ENGINE: val CalcTree : fmz list -> XML.tree
   467      */
   468     private synchronized int newCalculation(int javaCalcID, String instr,
   469             Formalization fmz, boolean restore) {
   470 
   471         if (logger.isDebugEnabled())
   472             logger.debug("newCalculation: javaCalcID=" + javaCalcID + ", instr" + instr + ", restore=" + restore);
   473         int sml_calcid;
   474         int return_val;
   475         /*---------------------------------------------------------------------------*/
   476         //*TTY*/bridge_.log(1, "new calculation: " + instr);
   477         //*TTY*/ResponseWrapper wrapper = sendToKernel(instr, restore);
   478         //*TTY*/if (wrapper == null) return -1;
   479         //*TTY*/sml_calcid = wrapper.getCalcID();
   480         //*TTY*/sendToKernel("Iterator " + sml_calcid + ";", restore);//WN041209 no
   481         //*TTY*/sendToKernel("moveActiveRoot " + sml_calcid + ";", restore);//WN041209
   482         //*TTY*/if (!restore) bufferInput(javaCalcID, instr);
   483         /*---------------------------------------------------------------------------*/
   484         /*PIDE*/bridge_.log(1, "-->ISA: " + instr);
   485         /*PIDE*/bridge_.log(1, "-->ISA: " + DataTypes.xml_of_Formalization(fmz));
   486         /*PIDE*/XML.Tree CALC_TREE_out = connection_to_kernel_.invoke(IsacOperations.CALC_TREE,
   487         /*PIDE*/  DataTypes.xml_of_Formalization(fmz));
   488         /*PIDE*/bridge_.log(1, "<--ISA: " + CALC_TREE_out);
   489         /*PIDE*/sml_calcid = (IsaToJava.calc_tree_out(CALC_TREE_out)).intValue();
   490 
   491         /*PIDE*/bridge_.log(1, "-->ISA: " + "Iterator " + sml_calcid + ";");
   492         /*PIDE*/XML.Tree ITERATOR_out = connection_to_kernel_.invoke(IsacOperations.ITERATOR,
   493         /*PIDE*/  new scala.math.BigInt(BigInteger.valueOf(sml_calcid)));
   494         /*PIDE*/IntIntCompound int_int = IsaToJava.iterator_out(ITERATOR_out);
   495         /*PIDE*/sml_calcid = int_int.getCalcId().intValue();
   496         int_int.getUserId().intValue();
   497         /*PIDE*/bridge_.log(1, "<--ISA: " + ITERATOR_out);
   498 
   499         /*PIDE*/bridge_.log(1, "-->ISA: " + "moveActiveRoot " + sml_calcid + ";");
   500         /*PIDE*/XML.Tree MOVE_ACTIVE_ROOT_out = connection_to_kernel_.invoke(IsacOperations.MOVE_ACTIVE_ROOT,
   501         /*PIDE*/  new scala.math.BigInt(BigInteger.valueOf(sml_calcid)));
   502         /*PIDE*/IntPosition calcid_pos = IsaToJava.move_active_root_out(MOVE_ACTIVE_ROOT_out);
   503         /*PIDE*/return_val = calcid_pos.getCalcId();
   504         calcid_pos.getPosition();
   505         /*PIDE*/bridge_.log(1, "<--ISA: " + MOVE_ACTIVE_ROOT_out);
   506         /*---------------------------------------------------------------------------*/
   507         java_calcid_to_smlcalcid_.put(new Integer(javaCalcID), new Integer(sml_calcid));
   508         return_val = sml_calcid; //WN150808 SML_caldid --> JAVA frontend ?!?
   509         return return_val;
   510     }
   511 
   512     /** MATH_ENGINE: val checkContext : calcID -> pos' -> guh -> XML.tree */
   513     public Context checkContext(int javaCalcID, Context context, Position pos) throws RemoteException {
   514     	Context return_val = null;
   515         /*---------------------------------------------------------------------------*/
   516     	//*TTY*/ResponseWrapper wrapper = interpretSML(javaCalcID,
   517     	//*TTY*/  "checkContext @calcid@ " + pos.toSMLString() + " \"" + context.getKEStoreKey().toString() + "\";", false);
   518     	//*TTY*/if(wrapper == null) return null;
   519     	//*TTY*/return_val = (Context) wrapper.getResponse();
   520         /*---------------------------------------------------------------------------*/
   521     	/*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(javaCalcID));
   522     	/*PIDE*/bridge_.log(1, "-->ISA: " + "checkContext " + sml_id + " " + pos.toSMLString() + " \"" + context.getKEStoreKey().toString() + "\";");
   523 
   524     	/*PIDE*/XML.Tree xml_in = JavaToIsa.check_ctxt(new scala.math.BigInt(BigInteger.valueOf(sml_id)), 
   525     	/*PIDE*/  pos, context.getKEStoreKey().toString() + "\"");
   526     	/*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);    	
   527     	/*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(IsacOperations.CHECK_CTXT, xml_in);
   528 
   529     	/*PIDE*/ContextTheory java_out = null;
   530     	/*PIDE*/if (!IsaToJava.is_message(xml_out)) {
   531     	/*PIDE*/  java_out = IsaToJava.check_ctxt_out(xml_out);
   532     	/*PIDE*/  return_val = java_out;
   533     	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);    	
   534     	/*PIDE*/} else
   535         /*PIDE*/  bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);    	
   536         /*---------------------------------------------------------------------------*/
   537         return return_val;
   538     }    
   539     
   540     /** MATH_ENGINE: val DEconstrCalcTree : calcID -> XML.tree */
   541     public boolean destruct(int javaCalcID) {
   542     	boolean return_val;
   543         /*---------------------------------------------------------------------------*/
   544     	//*TTY*/ResponseWrapper wrapper = interpretSML(javaCalcID,
   545     	//*TTY*/  "DEconstrCalcTree @calcid@;", false);
   546     	//*TTY*/if (wrapper == null) { return_val = false; }
   547     	//*TTY*/inputs_.remove(new Integer(javaCalcID));
   548     	//*TTY*/return_val = true;
   549     	/*---------------------------------------------------------------------------*/
   550     	/*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(javaCalcID));
   551     	/*PIDE*/bridge_.log(1, "-->ISA: " + "DEconstrCalcTree " + sml_id);
   552     	/*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(IsacOperations.DEL_CALC,
   553     	/*PIDE*/  new scala.math.BigInt(BigInteger.valueOf(sml_id)));
   554 
   555     	IsaToJava.del_calc_out(xml_out);
   556     	/*PIDE*/return_val = true;
   557     	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);    	
   558     	/*---------------------------------------------------------------------------*/
   559     	java_calcid_to_smlcalcid_.remove(new Integer(javaCalcID));
   560     	return return_val;
   561     }
   562 
   563     /** MATH_ENGINE: val fetchApplicableTactics : calcID -> int -> pos' -> XML.tree */
   564     public Vector<Tactic> getAppliableTactics(int id, int scope, Position pos) {
   565     	Vector<Tactic> return_val = null;
   566     	/*---------------------------------------------------------------------------*/
   567     	//*TTY*/ResponseWrapper wrapper = interpretSML(id,
   568     	//*TTY*/  "fetchApplicableTactics @calcid@ " + scope + pos.toSMLString() + ";", false);
   569     	//*TTY*/if (wrapper == null) return null;
   570     	//*TTY*/TacticsContainer tc = (TacticsContainer) wrapper.getResponse();
   571     	//*TTY*/if( tc == null ) return null;
   572     	//*TTY*/return_val = tc.getTactics();
   573     	/*---------------------------------------------------------------------------*/
   574     	/*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(id));
   575     	/*PIDE*/bridge_.log(1, "-->ISA: " + "fetchApplicableTactics " + sml_id + " " + scope + pos.toSMLString() + ";");
   576     	
   577     	/*PIDE*/XML.Tree xml_in = JavaToIsa.fetch_applicable_tacs(new scala.math.BigInt(BigInteger.valueOf(sml_id)), 
   578     	/*PIDE*/  new scala.math.BigInt(BigInteger.valueOf(scope)), pos);    	
   579     	/*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
   580     	/*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(IsacOperations.FETCH_APPL_TACS, xml_in);
   581     	
   582     	/*PIDE*/IntTactics java_out = null;
   583     	/*PIDE*/if (!IsaToJava.is_message(xml_out)) {
   584     	/*PIDE*/  java_out = IsaToJava.fetch_applicable_tacs_out(xml_out);
   585     	/*PIDE*/  return_val = java_out.getTactics();
   586     	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);    	
   587     	/*PIDE*/} else
   588         /*PIDE*/  bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);    	
   589     	/*---------------------------------------------------------------------------*/
   590        return return_val;
   591     }
   592 
   593     /** MATH_ENGINE: val fetchProposedTactic : calcID -> XML.tree */
   594     public Tactic fetchProposedTactic(int id) {
   595     	Tactic return_val = null;
   596     	/*---------------------------------------------------------------------------*/
   597     	//*TTY*/ResponseWrapper wrapper = interpretSML(id, "fetchProposedTactic @calcid@;", false);
   598         //*TTY*/if (wrapper == null) { return null; }
   599         //*TTY*/return_val = (Tactic) wrapper.getResponse();
   600     	/*---------------------------------------------------------------------------*/
   601     	/*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(id));
   602     	/*PIDE*/bridge_.log(1, "-->ISA: " + "fetchProposedTactic " + sml_id + ";");
   603     	
   604     	/*PIDE*/XML.Tree xml_in = JavaToIsa.fetch_proposed_tac(new scala.math.BigInt(BigInteger.valueOf(sml_id)));    	
   605     	/*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
   606     	/*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(IsacOperations.FETCH_PROP_TAC, xml_in);
   607 
   608     	/*PIDE*/IntTacticErrPats java_out = null;
   609     	/*PIDE*/if (!IsaToJava.is_message(xml_out)) {
   610     	/*PIDE*/  java_out = IsaToJava.fetch_proposed_tac_out(xml_out);
   611     	/*PIDE*/  return_val = java_out.getTactic();
   612     	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);    	
   613     	/*PIDE*/} else
   614         /*PIDE*/  bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);    	
   615     	/*---------------------------------------------------------------------------*/
   616         return return_val;
   617     }
   618 
   619     /** MATH_ENGINE: val findFillpatterns : calcID -> errpatID -> XML.tree 
   620      * only implemented in Math_Engine */
   621     
   622     /**
   623      * @see isac.bridge.IBridgeRMI#getAccumulatedAssumptions(int,
   624      *      isac.util.formulae.Position)
   625      *      
   626      * ** MATH_ENGINE: val getAccumulatedAsms : calcID -> pos' -> XML.tree
   627      */
   628     public Assumptions getAccumulatedAssumptions(int calcTreeID, Position pos) throws RemoteException {
   629     	Assumptions return_val = null;
   630     	/*---------------------------------------------------------------------------*/
   631     	//*TTY*/ResponseWrapper wrapper = interpretSML(calcTreeID,
   632     	//*TTY*/  "getAccumulatedAsms @calcid@ " + pos.toSMLString() + ";", false);
   633     	//*TTY*/return_val = (Assumptions) wrapper.getResponse();
   634     	/*---------------------------------------------------------------------------*/
   635     	/*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(calcTreeID));
   636     	/*PIDE*/bridge_.log(1, "-->ISA: " + "getAccumulatedAsms " + sml_id + " " + pos.toSMLString() + ";");
   637     	
   638     	/*PIDE*/XML.Tree xml_in = JavaToIsa.get_accumulated_asms(new scala.math.BigInt(BigInteger.valueOf(sml_id)), pos);    	
   639     	/*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
   640     	/*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(IsacOperations.GET_ACC_ASMS, xml_in);
   641 
   642     	/*PIDE*/IntAssumptions java_out = null;
   643     	/*PIDE*/if (!IsaToJava.is_message(xml_out)) {
   644     	/*PIDE*/  java_out = IsaToJava.get_accumulated_asms_out(xml_out);
   645     	/*PIDE*/  return_val = java_out.getAssumptions();
   646     	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);    	
   647     	/*PIDE*/} else
   648         /*PIDE*/  bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);    	
   649     	/*---------------------------------------------------------------------------*/
   650         return return_val;
   651     }
   652     
   653     /** MATH_ENGINE: val getActiveFormula : calcID -> XML.tree */
   654     public Position getActiveFormula(int javaCalcID) {
   655     	Position return_val = null;
   656     	/*---------------------------------------------------------------------------*/
   657     	//*TTY*/ResponseWrapper wrapper = interpretSML(javaCalcID,
   658     	//*TTY*/  "getActiveFormula @calcid@ ;", false);
   659     	//*TTY*/return_val = moveSuccess(wrapper);
   660     	/*---------------------------------------------------------------------------*/
   661     	/*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(javaCalcID));
   662     	/*PIDE*/bridge_.log(1, "-->ISA: " + "getActiveFormula " + sml_id + " ;");
   663     	
   664     	/*PIDE*/XML.Tree xml_in = JavaToIsa.get_active_form(new scala.math.BigInt(BigInteger.valueOf(sml_id)));
   665     	/*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
   666     	/*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(IsacOperations.GET_ACTIVE_FORM, xml_in);
   667 
   668     	/*PIDE*/IntPosition java_out = null;
   669     	/*PIDE*/if (!IsaToJava.is_message(xml_out)) {
   670     	/*PIDE*/  java_out = IsaToJava.get_active_form_out(xml_out);
   671     	/*PIDE*/  return_val = java_out.getPosition();
   672     	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);    	
   673     	/*PIDE*/} else
   674         /*PIDE*/  bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);    	
   675     	/*---------------------------------------------------------------------------*/
   676         return return_val;
   677     }
   678 
   679     /**
   680      * @see isac.bridge.IBridgeRMI#getAssumption(int, int)
   681      * 
   682      * MATH_ENGINE: val getAssumptions : calcID -> pos' -> XML.tree
   683      */
   684     public Assumptions getAssumptions(int calcTreeID, Position pos) throws RemoteException {
   685     	Assumptions return_val = null;
   686     	/*---------------------------------------------------------------------------*/
   687     	//*TTY*/ResponseWrapper wrapper = interpretSML(calcTreeID,
   688     	//*TTY*/  "getAssumptions @calcid@ " + pos.toSMLString() + ";", false);
   689     	//*TTY*/return_val = (Assumptions) wrapper.getResponse();
   690     	/*---------------------------------------------------------------------------*/
   691     	/*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(calcTreeID));
   692     	/*PIDE*/bridge_.log(1, "-->ISA: " + "getAssumptions " + sml_id + " " + pos.toSMLString() + ";");
   693     	
   694     	/*PIDE*/XML.Tree xml_in = JavaToIsa.get_asms(new scala.math.BigInt(BigInteger.valueOf(sml_id)), pos);    	
   695     	/*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
   696     	/*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(IsacOperations.GET_ASMS, xml_in);
   697 
   698     	/*PIDE*/IntAssumptions java_out = null;
   699     	/*PIDE*/if (!IsaToJava.is_message(xml_out)) {
   700     	/*PIDE*/  java_out = IsaToJava.get_asms_out(xml_out);
   701     	/*PIDE*/  return_val = java_out.getAssumptions();
   702     	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);    	
   703     	/*PIDE*/} else
   704         /*PIDE*/  bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);    	
   705     	/*---------------------------------------------------------------------------*/
   706         return return_val;
   707     }
   708 
   709     /** MATH_ENGINE: val getFormulaeFromTo : calcID -> pos' -> pos' -> int -> bool -> XML.tree */
   710     public Vector<CalcFormula> getFormulaeFromTo(int id, ICalcIterator iterator_from,
   711             ICalcIterator iterator_to, Integer level, boolean result_includes_tactics) {
   712         XML.Tree xml_in = null;
   713     	Vector<CalcFormula> return_val = null;      
   714     	/*---------------------------------------------------------------------------*/
   715         //*TTY*/try { wrapper = interpretSML(id, "getFormulaeFromTo @calcid@ "
   716         //*TTY*/    + iterator_from.toSMLString() + " " + iterator_to.toSMLString()
   717         //*TTY*/    + " " + level + " " + result_includes_tactics + ";", false);
   718         //*TTY*/} catch (RemoteException e) { e.printStackTrace(); }
   719         //*TTY*/if (wrapper == null) return null;
   720         //*TTY*/FormHeadsContainer con = (FormHeadsContainer) wrapper.getResponse();
   721         //*TTY*/if (con != null) return_val = con.getElements();
   722         //*TTY*/else return_val = null;
   723     	/*---------------------------------------------------------------------------*/
   724         /*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(id));
   725         /*PIDE*/try {
   726         /*PIDE*/  bridge_.log(1, "-->ISA: " + "getFormulaeFromTo " + sml_id + " "
   727         /*PIDE*/    + iterator_from.toSMLString() + " " + iterator_to.toSMLString()
   728 		/*PIDE*/    + " " + level + " " + result_includes_tactics + ";");
   729 		/*PIDE*/} catch (RemoteException e2) { e2.printStackTrace(); }
   730         
   731         /*PIDE*/try {
   732         /*PIDE*/  xml_in = JavaToIsa.get_formulae(new scala.math.BigInt(BigInteger.valueOf(sml_id)),
   733 		/*PIDE*/    iterator_from.getPosition(), iterator_to.getPosition(), 
   734 		/*PIDE*/    new scala.math.BigInt(BigInteger.valueOf(level)), result_includes_tactics);
   735         /*PIDE*/} catch (RemoteException e1) { e1.printStackTrace(); }
   736     	/*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
   737     	/*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(IsacOperations.GET_FORMULAE, xml_in);
   738 
   739     	/*PIDE*/IntFormulas java_out = null;
   740     	/*PIDE*/if (!IsaToJava.is_message(xml_out)) {
   741     	/*PIDE*/  java_out = IsaToJava.get_formulae_out(xml_out);
   742     	/*PIDE*/  return_val = java_out.getCalcFormulas();
   743     	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);    	
   744     	/*PIDE*/} else
   745         /*PIDE*/  bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);    	
   746         /*---------------------------------------------------------------------------*/
   747         return return_val;
   748     }
   749 
   750     /*
   751      * @see isac.bridge.IBridgeRMI#getTactic(int, int)
   752      * 
   753      * MATH_ENGINE: val getTactic : calcID -> pos' -> XML.tree
   754      */
   755     public Tactic getTactic(int calcTreeID, Position pos) throws RemoteException {
   756     	Tactic return_val = null;
   757     	/*---------------------------------------------------------------------------*/
   758     	//*TTY*/ResponseWrapper wrapper = interpretSML(calcTreeID,
   759     	//*TTY*/  "getTactic @calcid@ " + pos.toSMLString() + ";", false);
   760     	//*TTY*/return_val = (Tactic) wrapper.getResponse();
   761     	/*---------------------------------------------------------------------------*/
   762     	/*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(calcTreeID));
   763     	/*PIDE*/bridge_.log(1, "-->ISA: " + "getTactic " + sml_id + " " + pos.toSMLString() + ";");
   764     	
   765     	/*PIDE*/XML.Tree xml_in = JavaToIsa.get_tac(new scala.math.BigInt(BigInteger.valueOf(sml_id)), pos);    	
   766     	/*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
   767     	/*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(IsacOperations.GET_TAC, xml_in);
   768 
   769     	/*PIDE*/IntTactic java_out = null;
   770     	/*PIDE*/if (!IsaToJava.is_message(xml_out)) {
   771     	/*PIDE*/  java_out = IsaToJava.get_tac_out(xml_out);
   772     	/*PIDE*/  return_val = java_out.getTactic();
   773     	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);    	
   774     	/*PIDE*/} else
   775         /*PIDE*/  bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);    	
   776     	/*---------------------------------------------------------------------------*/
   777         return return_val;
   778     }
   779 
   780     /** MATH_ENGINE: val initContext : calcID -> ketype -> pos' -> XML.tree 
   781      *
   782      * This method is implemented in Isabelle/Isac, but seems to never have been completed in Java.
   783      * See isac.bridge.TestContext#testContext.
   784      */
   785     public Context initContext(int javaCalcID, ContextType type, Position pos) throws RemoteException {
   786     	Context return_val = null;
   787     	/*---------------------------------------------------------------------------*/
   788     	//*TTY*/ResponseWrapper wrapper = interpretSML(javaCalcID,
   789     	//*TTY*/  "initContext @calcid@ " + type.toSMLString() + " " + pos.toSMLString() + ";", false);
   790     	//*TTY*/if(wrapper == null) return null;
   791     	//*TTY*/return_val = (Context) wrapper.getResponse();
   792     	/*---------------------------------------------------------------------------*/
   793     	/*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(javaCalcID));
   794     	/*PIDE*/bridge_.log(1, "-->ISA: " + "initContext " + sml_id + " " + type.toSMLString() + " " + pos.toSMLString() + ";");
   795     	
   796     	/*PIDE*/XML.Tree xml_in = JavaToIsa.init_ctxt(new scala.math.BigInt(BigInteger.valueOf(sml_id)), type, pos);    	
   797     	/*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
   798     	/*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(IsacOperations.INIT_CTXT, xml_in);
   799 
   800     	/*PIDE*/Context java_out = null; // front-end later distinguishes ContextTheory, ContextProblem, ..
   801     	/*PIDE*/if (!IsaToJava.is_message(xml_out)) {
   802     	/*PIDE*/  java_out = (Context) IsaToJava.init_ctxt_out(xml_out);
   803     	/*PIDE*/  return_val = java_out;
   804     	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);    	
   805     	/*PIDE*/} else
   806         /*PIDE*/  bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);    	
   807     	/*---------------------------------------------------------------------------*/
   808         return return_val;
   809     }
   810 
   811     /** MATH_ENGINE: val inputFillFormula: calcID -> string -> XML.tree 
   812      * only implemented in Math_Engine */
   813 
   814     /** MATH_ENGINE: val interSteps : calcID -> pos' -> XML.tree */
   815     public CEvent intermediateSteps(int id, ICalcIterator ci) {
   816     	CEvent return_val = null;
   817     	/*---------------------------------------------------------------------------*/
   818     	//*TTY*/ResponseWrapper wrapper = null;
   819         //*TTY*/try {
   820         //*TTY*/    wrapper = interpretSML(id, "interSteps @calcid@ " + ci.toSMLString() + ";", false);
   821         //*TTY*/} catch (RemoteException e) { e.printStackTrace(); }
   822         //*TTY*/if (wrapper == null) return null;
   823         //*TTY*/return_val = (CEvent) wrapper.getResponse();
   824     	/*---------------------------------------------------------------------------*/
   825     	/*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(id));
   826     	/*PIDE*/XML.Tree xml_in = null;
   827     	/*PIDE*/try {
   828     	/*PIDE*/	bridge_.log(1, "-->ISA: " + "interSteps " + sml_id + " " + ci.toSMLString() + ";");
   829     	/*PIDE*/} catch (RemoteException e1) { e1.printStackTrace(); }
   830     	
   831     	/*PIDE*/try {
   832     	/*PIDE*/  xml_in = JavaToIsa.inter_steps(new scala.math.BigInt(BigInteger.valueOf(sml_id)), ci.getPosition());
   833     	/*PIDE*/} catch (Exception e1) { e1.printStackTrace();}    	
   834     	/*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
   835     	/*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(IsacOperations.INTER_STEPS, xml_in);
   836     	
   837     	/*PIDE*/IntCEvent java_out = null;
   838     	/*PIDE*/if (!IsaToJava.is_message(xml_out)) {
   839     	/*PIDE*/  java_out = IsaToJava.inter_steps_out(xml_out);
   840     	/*PIDE*/  return_val = java_out.getCEvent();
   841     	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);    	
   842     	/*PIDE*/} else
   843         /*PIDE*/  bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);    	
   844     	/*---------------------------------------------------------------------------*/
   845         return return_val;
   846     }
   847 
   848     /** MATH_ENGINE: val Iterator : calcID -> XML.tree */
   849     public int iterator(int id) {
   850         if (logger.isDebugEnabled())
   851           logger.debug("iterator: id=" + id);
   852         int return_val = 4711;
   853     	/*---------------------------------------------------------------------------*/
   854         //*TTY*/if (id == 1) {
   855         //*TTY*/    ResponseWrapper wrapper = interpretSML(id, "Iterator @calcid@;", false);
   856         //*TTY*/    if (wrapper == null) return_val = -1;
   857         //*TTY*/    else return_val = Integer.parseInt(((CalcHeadSimpleID) wrapper .getResponse()).getID());
   858         //*TTY*/} else return_val = 4711;//TODO.WN041208 drop CalcIterator.iteratorID_
   859     	/*---------------------------------------------------------------------------*/
   860     	/*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(id));
   861     	/*PIDE*/bridge_.log(1, "-->ISA: " + "Iterator " + sml_id + ";");
   862     	
   863     	/*PIDE*/BigInt xml_in = new scala.math.BigInt(BigInteger.valueOf(sml_id));    	
   864     	/*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
   865     	/*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(IsacOperations.ITERATOR, xml_in);
   866 
   867     	/*PIDE*/IntIntCompound java_out = null;
   868     	/*PIDE*/if (!IsaToJava.is_message(xml_out)) {
   869     	/*PIDE*/  java_out = IsaToJava.iterator_out(xml_out);
   870     	/*PIDE*/  return_val = java_out.getCalcId().intValue();
   871     	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);    	
   872     	/*PIDE*/} else
   873         /*PIDE*/  bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);    	
   874     	/*---------------------------------------------------------------------------*/
   875         return return_val;
   876     }
   877 
   878     /**
   879      * @see isac.interfaces.IToCalc#modelProblem()
   880      * 
   881      * MATH_ENGINE: val modelProblem : calcID -> XML.tree
   882      */
   883     public CalcHead modelProblem(int calc_tree_id) throws RemoteException {
   884     	CalcHead return_val = null;
   885     	/*---------------------------------------------------------------------------*/
   886     	//*TTY*/ResponseWrapper wrapper = interpretSML(calc_tree_id, "modelProblem @calcid@;", false);
   887     	//*TTY*/return_val = (CalcHead) wrapper.getResponse();
   888     	/*---------------------------------------------------------------------------*/
   889     	/*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(calc_tree_id));
   890     	/*PIDE*/bridge_.log(1, "-->ISA: " + "modelProblem " + sml_id + ";");
   891     	
   892     	/*PIDE*/BigInt xml_in = new scala.math.BigInt(BigInteger.valueOf(sml_id));    	
   893     	/*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
   894     	/*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(IsacOperations.MODEL_PBL, xml_in);
   895 
   896     	/*PIDE*/IntCalcHead java_out = null;
   897     	/*PIDE*/if (!IsaToJava.is_message(xml_out)) {
   898     	/*PIDE*/  java_out = IsaToJava.modify_calchead_out(xml_out);
   899     	/*PIDE*/  return_val = java_out.getCalcHead();
   900     	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);    	
   901     	/*PIDE*/} else
   902         /*PIDE*/  bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);    	
   903     	/*---------------------------------------------------------------------------*/
   904         return return_val;
   905     }
   906     
   907     /**
   908      * @see isac.interfaces.IToCalc#checkCalcHead(isac.util.formulae.CalcHead)
   909      * 
   910      * MATH_ENGINE: val modifyCalcHead : calcID -> icalhd -> XML.tree
   911      */
   912     public CalcHead checkCalcHead(int calc_tree_id, CalcHead calchead) throws RemoteException {
   913     	CalcHead return_val = null;
   914     	/*---------------------------------------------------------------------------*/
   915     	//*TTY*/ResponseWrapper wrapper = interpretSML(calc_tree_id,
   916     	//*TTY*/  "modifyCalcHead @calcid@ " + calchead.toSMLString() + ";", false);
   917     	//*TTY*/return_val = (CalcHead) wrapper.getResponse();
   918     	/*---------------------------------------------------------------------------*/
   919     	/*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(calc_tree_id));
   920     	/*PIDE*/bridge_.log(1, "-->ISA: " + "modelProblem " + sml_id + ";");
   921     	
   922     	/*PIDE*/XML.Tree xml_in = JavaToIsa.modify_calchead(new scala.math.BigInt(BigInteger.valueOf(sml_id)), calchead);    	
   923     	/*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
   924     	/*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(IsacOperations.MODIFY_CALCHEAD, xml_in);
   925 
   926     	/*PIDE*/IntCalcHead java_out = null;
   927     	/*PIDE*/if (!IsaToJava.is_message(xml_out)) {
   928     	/*PIDE*/  java_out = IsaToJava.modify_calchead_out(xml_out);
   929     	/*PIDE*/  return_val = java_out.getCalcHead();
   930     	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);    	
   931     	/*PIDE*/} else
   932         /*PIDE*/  bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);    	
   933     	/*---------------------------------------------------------------------------*/
   934         return return_val;
   935     }
   936 
   937     /** MATH_ENGINE: val moveActiveCalcHead : calcID -> XML.tree */
   938     public Position moveCalcHead(int javaCalcID, int iteratorID, Position p) {
   939     	Position return_val = null;
   940     	/*---------------------------------------------------------------------------*/
   941     	//*TTY*/ResponseWrapper wrapper = null;
   942     	//*TTY*/if (iteratorID == 1)
   943     	//*TTY*/  wrapper = interpretSML(javaCalcID, "moveActiveCalcHead @calcid@" + ";", false);
   944     	//*TTY*/else
   945     	//*TTY*/  wrapper = interpretSML(javaCalcID, "moveCalcHead @calcid@ " + " " + p.toSMLString() + ";", false);
   946     	//*TTY*/return_val = moveSuccess(wrapper);
   947     	/*---------------------------------------------------------------------------*/
   948     	/*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(javaCalcID));
   949     	/*PIDE*/XML.Tree xml_in = null;
   950     	/*PIDE*/XML.Tree xml_out = null;
   951 
   952     	/*PIDE*/if (iteratorID == 1) {
   953     	/*PIDE*/bridge_.log(1, "-->ISA: " + "moveActiveCalcHead " + sml_id + "" + ";");    	
   954     	/*PIDE*/xml_in = JavaToIsa.move_active_calchead(new scala.math.BigInt(BigInteger.valueOf(sml_id)));    	
   955     	/*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
   956     	/*PIDE*/xml_out = connection_to_kernel_.invoke(IsacOperations.MOVE_ACTIVE_FORM, xml_in);
   957 
   958     	/*PIDE*/IntPosition java_out = null;
   959     	/*PIDE*/if (!IsaToJava.is_message(xml_out)) {
   960     	/*PIDE*/  java_out = IsaToJava.move_active_calchead_out(xml_out);
   961     	/*PIDE*/  return_val = java_out.getPosition();
   962     	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);    	
   963     	/*PIDE*/} else
   964         /*PIDE*/  bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);    	
   965 
   966     	/*PIDE*/} else {
   967     		
   968     	/*PIDE*/bridge_.log(1, "-->ISA: " + "moveCalcHead " + sml_id + " " + " " + p.toSMLString() + ";");
   969     	/*PIDE*/xml_in = JavaToIsa.move_calchead(new scala.math.BigInt(BigInteger.valueOf(sml_id)), null);    	
   970     	/*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
   971     	/*PIDE*/xml_out = connection_to_kernel_.invoke(IsacOperations.MOVE_ACTIVE_FORM, xml_in);
   972 
   973     	/*PIDE*/IntPosition java_out = null;
   974     	/*PIDE*/if (!IsaToJava.is_message(xml_out)) {
   975     	/*PIDE*/  java_out = IsaToJava.move_calchead_out(xml_out);
   976     	/*PIDE*/  return_val = java_out.getPosition();
   977     	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);    	
   978     	/*PIDE*/} else
   979         /*PIDE*/  bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);    	
   980     	/*PIDE*/}
   981     	/*---------------------------------------------------------------------------*/
   982         return return_val;
   983     }
   984 
   985     /** MATH_ENGINE: val moveActiveDown : calcID -> XML.tree */
   986     public Position moveDown(int javaCalcID, int iteratorID, Position p) {
   987         if (logger.isDebugEnabled())
   988             logger.debug("moveDown: javaCalcID=" + javaCalcID + ", sml_pos=" + p.toSMLString());
   989         Position return_val = null;
   990     	/*---------------------------------------------------------------------------*/
   991     	//*TTY*/ResponseWrapper wrapper = null;
   992     	//*TTY*/if (iteratorID == 1)
   993     	//*TTY*/    wrapper = interpretSML(javaCalcID, "moveActiveDown @calcid@" + ";", false);
   994     	//*TTY*/else
   995     	//*TTY*/    wrapper = interpretSML(javaCalcID, "moveDown @calcid@ " + p.toSMLString() + ";", false);
   996     	//*TTY*/return_val = moveSuccess(wrapper);
   997     	/*---------------------------------------------------------------------------*/
   998     	/*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(javaCalcID));
   999     	/*PIDE*/XML.Tree xml_in = null;
  1000     	/*PIDE*/XML.Tree xml_out = null;
  1001 
  1002     	/*PIDE*/if (iteratorID == 1) {
  1003     	/*PIDE*/bridge_.log(1, "-->ISA: " + "moveActiveDown " + sml_id + "" + ";");
  1004     	/*PIDE*/xml_in = JavaToIsa.move_active_down(new scala.math.BigInt(BigInteger.valueOf(sml_id)));    	
  1005     	/*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
  1006     	/*PIDE*/xml_out = connection_to_kernel_.invoke(IsacOperations.MOVE_ACTIVE_DOWN, xml_in);
  1007 
  1008     	/*PIDE*/IntPosition java_out = null;
  1009     	/*PIDE*/if (!IsaToJava.is_message(xml_out)) {
  1010     	/*PIDE*/  java_out = IsaToJava.move_active_down_out(xml_out);
  1011     	/*PIDE*/  return_val = java_out.getPosition();
  1012     	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);    	
  1013     	/*PIDE*/} else
  1014         /*PIDE*/  bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);    	
  1015 
  1016     	/*PIDE*/} else {
  1017     		
  1018     	/*PIDE*/bridge_.log(1, "-->ISA: " + "moveDown " + sml_id + " " + p.toSMLString() + ";");
  1019     	/*PIDE*/xml_in = JavaToIsa.move_down(new scala.math.BigInt(BigInteger.valueOf(sml_id)), p);    	
  1020     	/*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
  1021     	/*PIDE*/xml_out = connection_to_kernel_.invoke(IsacOperations.MOVE_DOWN, xml_in);
  1022 
  1023     	/*PIDE*/IntPosition java_out = null;
  1024     	/*PIDE*/if (!IsaToJava.is_message(xml_out)) {
  1025     	/*PIDE*/  java_out = IsaToJava.move_down_out(xml_out);
  1026     	/*PIDE*/  return_val = java_out.getPosition();
  1027     	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);    	
  1028     	/*PIDE*/} else
  1029         /*PIDE*/  bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);    	
  1030     	/*PIDE*/}
  1031     	/*---------------------------------------------------------------------------*/
  1032         return return_val;
  1033     }
  1034 
  1035     /** 
  1036      * returns Position for uniformity with move*; not required elsewhere
  1037      * 
  1038      * MATH_ENGINE: val moveActiveFormula : calcID -> pos' -> XML.tree 
  1039      */
  1040     public Position moveActiveFormula(int javaCalcID, Position p) {
  1041         if (logger.isDebugEnabled())
  1042             logger.debug("moveDown: javaCalcID=" + javaCalcID + ", sml_pos=" + p.toSMLString());
  1043     	Position return_val = null;
  1044     	/*---------------------------------------------------------------------------*/
  1045     	//*TTY*/ResponseWrapper wrapper = interpretSML(javaCalcID,
  1046     	//*TTY*/  "moveActiveFormula @calcid@ " + p.toSMLString() + ";", false);
  1047     	//*TTY*/return_val = moveSuccess(wrapper);
  1048     	/*---------------------------------------------------------------------------*/
  1049     	/*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(javaCalcID));
  1050     	/*PIDE*/bridge_.log(1, "-->ISA: " + "moveActiveFormula " + sml_id + " " + p.toSMLString() + ";");
  1051     	
  1052     	/*PIDE*/XML.Tree xml_in = JavaToIsa.move_active_form(new scala.math.BigInt(BigInteger.valueOf(sml_id)), p);    	
  1053     	/*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
  1054     	/*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(IsacOperations.MOVE_ACTIVE_FORM, xml_in);
  1055 
  1056     	/*PIDE*/IntPosition java_out = null;
  1057     	/*PIDE*/if (!IsaToJava.is_message(xml_out)) {
  1058     	/*PIDE*/  java_out = IsaToJava.move_active_form_out(xml_out);
  1059     	/*PIDE*/  return_val = java_out.getPosition();
  1060     	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);    	
  1061     	/*PIDE*/} else
  1062         /*PIDE*/  bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);    	
  1063     	/*---------------------------------------------------------------------------*/
  1064         return return_val;
  1065     }
  1066 
  1067     /** MATH_ENGINE: val moveActiveLevelDown : calcID -> XML.tree */
  1068     public Position moveLevelDown(int javaCalcID, int iteratorID, Position p) {
  1069     	Position return_val = null;
  1070     	/*---------------------------------------------------------------------------*/
  1071     	//*TTY*/ResponseWrapper wrapper = null;
  1072     	//*TTY*/if (iteratorID == 1)
  1073     	//*TTY*/    wrapper = interpretSML(javaCalcID, "moveActiveLevelDown @calcid@" + ";", false);
  1074     	//*TTY*/else
  1075     	//*TTY*/    wrapper = interpretSML(javaCalcID, "moveLevelDown @calcid@ " + " " + p.toSMLString() + ";", false);
  1076     	//*TTY*/return_val = moveSuccess(wrapper);
  1077     	/*---------------------------------------------------------------------------*/
  1078     	/*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(javaCalcID));
  1079     	/*PIDE*/XML.Tree xml_in = null;
  1080     	/*PIDE*/XML.Tree xml_out = null;
  1081 
  1082     	/*PIDE*/if (iteratorID == 1) {
  1083     	/*PIDE*/bridge_.log(1, "-->ISA: " + "moveActiveLevelDown " + sml_id + "" + ";");    	
  1084     	/*PIDE*/xml_in = JavaToIsa.move_active_levdown(new scala.math.BigInt(BigInteger.valueOf(sml_id)));    	
  1085     	/*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
  1086     	/*PIDE*/xml_out = connection_to_kernel_.invoke(IsacOperations.MOVE_ACTIVE_LEVDN, xml_in);
  1087 
  1088     	/*PIDE*/IntPosition java_out = null;
  1089     	/*PIDE*/if (!IsaToJava.is_message(xml_out)) {
  1090     	/*PIDE*/  java_out = IsaToJava.move_active_levdown_out(xml_out);
  1091     	/*PIDE*/  return_val = java_out.getPosition();
  1092     	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);    	
  1093     	/*PIDE*/} else
  1094         /*PIDE*/  bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);    	
  1095 
  1096     	/*PIDE*/} else {
  1097     		
  1098     	/*PIDE*/bridge_.log(1, "-->ISA: " + "moveLevelDown " + sml_id + " " + " " + p.toSMLString() + ";");
  1099     	/*PIDE*/xml_in = JavaToIsa.move_levdn(new scala.math.BigInt(BigInteger.valueOf(sml_id)), p);    	
  1100     	/*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
  1101     	/*PIDE*/xml_out = connection_to_kernel_.invoke(IsacOperations.MOVE_LEVDN, xml_in);
  1102 
  1103     	/*PIDE*/IntPosition java_out = null;
  1104     	/*PIDE*/if (!IsaToJava.is_message(xml_out)) {
  1105     	/*PIDE*/  java_out = IsaToJava.move_levdn_out(xml_out);
  1106     	/*PIDE*/  return_val = java_out.getPosition();
  1107     	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);    	
  1108     	/*PIDE*/} else
  1109         /*PIDE*/  bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);    	
  1110     	/*PIDE*/}
  1111     	/*---------------------------------------------------------------------------*/
  1112         return return_val;
  1113     }
  1114 
  1115     /** MATH_ENGINE: val moveActiveLevelUp : calcID -> XML.tree */
  1116     public Position moveLevelUp(int javaCalcID, int iteratorID, Position p) {
  1117     	Position return_val = null;
  1118     	/*---------------------------------------------------------------------------*/
  1119     	//*TTY*/ResponseWrapper wrapper = null;
  1120     	//*TTY*/if (iteratorID == 1)
  1121     	//*TTY*/    wrapper = interpretSML(javaCalcID, "moveActiveLevelUp @calcid@" + ";", false);
  1122     	//*TTY*/else
  1123     	//*TTY*/    wrapper = interpretSML(javaCalcID, "moveLevelUp @calcid@ " + p.toSMLString() + ";", false);
  1124     	//*TTY*/return_val = moveSuccess(wrapper);
  1125     	/*---------------------------------------------------------------------------*/
  1126     	/*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(javaCalcID));
  1127     	/*PIDE*/XML.Tree xml_in = null;
  1128     	/*PIDE*/XML.Tree xml_out = null;
  1129 
  1130     	/*PIDE*/if (iteratorID == 1) {
  1131     	/*PIDE*/bridge_.log(1, "-->ISA: " + "moveActiveLevelUp " + sml_id + "" + ";");
  1132     	/*PIDE*/xml_in = JavaToIsa.move_active_levup(new scala.math.BigInt(BigInteger.valueOf(sml_id)));    	
  1133     	/*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
  1134     	/*PIDE*/xml_out = connection_to_kernel_.invoke(IsacOperations.MOVE_ACTIVE_LEVUP, xml_in);
  1135     	/*PIDE*/xml_out = connection_to_kernel_.invoke(IsacOperations.MOVE_ACTIVE_FORM, xml_in);
  1136 
  1137     	/*PIDE*/IntPosition java_out = null;
  1138     	/*PIDE*/if (!IsaToJava.is_message(xml_out)) {
  1139     	/*PIDE*/  java_out = IsaToJava.move_active_levup_out(xml_out);
  1140     	/*PIDE*/  return_val = java_out.getPosition();
  1141     	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);    	
  1142     	/*PIDE*/} else
  1143         /*PIDE*/  bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);    	
  1144 
  1145     	/*PIDE*/} else {
  1146     		
  1147     	/*PIDE*/bridge_.log(1, "-->ISA: " + "moveLevelUp " + sml_id + " " + p.toSMLString() + ";");
  1148     	/*PIDE*/xml_in = JavaToIsa.move_levup(new scala.math.BigInt(BigInteger.valueOf(sml_id)), p);    	
  1149     	/*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
  1150     	/*PIDE*/xml_out = connection_to_kernel_.invoke(IsacOperations.MOVE_LEVUP, xml_in);
  1151 
  1152     	/*PIDE*/IntPosition java_out = null;
  1153     	/*PIDE*/if (!IsaToJava.is_message(xml_out)) {
  1154     	/*PIDE*/  java_out = IsaToJava.move_levup_out(xml_out);
  1155     	/*PIDE*/  return_val = java_out.getPosition();
  1156     	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);    	
  1157     	/*PIDE*/} else
  1158         /*PIDE*/  bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);    	
  1159     	/*PIDE*/}
  1160     	/*---------------------------------------------------------------------------*/
  1161         return return_val;
  1162     }
  1163 
  1164     /** MATH_ENGINE: val moveActiveRoot : calcID -> XML.tree */
  1165     public Position moveRoot(int javaCalcID, int iteratorID) {
  1166         if (logger.isDebugEnabled())
  1167             logger.debug("moveRoot: javaCalcID=" + javaCalcID);
  1168     	Position return_val = null;
  1169     	/*---------------------------------------------------------------------------*/
  1170     	//*TTY*/ResponseWrapper wrapper = null;
  1171     	//*TTY*/if (iteratorID == 1)
  1172     	//*TTY*/    wrapper = interpretSML(javaCalcID, "moveActiveRoot @calcid@" + ";", false);
  1173     	//*TTY*/else
  1174     	//*TTY*/    wrapper = interpretSML(javaCalcID, "moveRoot @calcid@ " + ";", false);
  1175     	//*TTY*/return_val = moveSuccess(wrapper);
  1176     	/*---------------------------------------------------------------------------*/
  1177     	/*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(javaCalcID));
  1178     	/*PIDE*/scala.math.BigInt xml_in = null;
  1179     	/*PIDE*/XML.Tree xml_out = null;
  1180 
  1181     	/*PIDE*/if (iteratorID == 1) {
  1182     	/*PIDE*/bridge_.log(1, "-->ISA: " + "moveActiveRoot " + sml_id + "" + ";");
  1183     	/*PIDE*/xml_in = new scala.math.BigInt(BigInteger.valueOf(sml_id));    	
  1184     	/*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
  1185     	/*PIDE*/xml_out = connection_to_kernel_.invoke(IsacOperations.MOVE_ACTIVE_ROOT, xml_in);
  1186 
  1187     	/*PIDE*/IntPosition java_out = null;
  1188     	/*PIDE*/if (!IsaToJava.is_message(xml_out)) {
  1189     	/*PIDE*/  java_out = IsaToJava.move_active_root_out(xml_out);
  1190     	/*PIDE*/  return_val = java_out.getPosition();
  1191     	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);    	
  1192     	/*PIDE*/} else
  1193         /*PIDE*/  bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);    	
  1194 
  1195     	/*PIDE*/} else {
  1196     		
  1197     	/*PIDE*/bridge_.log(1, "-->ISA: " + "moveRoot " + sml_id + " " + ";");
  1198     	/*PIDE*/XML.Tree xml_in2 = JavaToIsa.move_root(new scala.math.BigInt(BigInteger.valueOf(sml_id)));    	
  1199     	/*PIDE*/bridge_.log(1, "-->ISA: " + xml_in2);
  1200     	/*PIDE*/xml_out = connection_to_kernel_.invoke(IsacOperations.MOVE_ROOT, xml_in2);
  1201 
  1202     	/*PIDE*/IntPosition java_out = null;
  1203     	/*PIDE*/if (!IsaToJava.is_message(xml_out)) {
  1204     	/*PIDE*/  java_out = IsaToJava.move_root_out(xml_out);
  1205     	/*PIDE*/  return_val = java_out.getPosition();
  1206     	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);    	
  1207     	/*PIDE*/} else
  1208         /*PIDE*/  bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);    	
  1209     	/*PIDE*/}
  1210     	/*---------------------------------------------------------------------------*/
  1211         return return_val;
  1212     }
  1213 
  1214     /** MATH_ENGINE: val moveActiveRootTEST : calcID -> XML.tree 
  1215      *  used only internally in Math_Engine */
  1216 
  1217     /** MATH_ENGINE: val moveActiveUp : calcID -> XML.tree */
  1218     public Position moveUp(int javaCalcID, int iteratorID, Position p) {
  1219     	Position return_val = null;
  1220     	/*---------------------------------------------------------------------------*/
  1221     	//*TTY*/ResponseWrapper wrapper = null;
  1222     	//*TTY*/if (iteratorID == 1)
  1223     	//*TTY*/    wrapper = interpretSML(javaCalcID, "moveActiveUp @calcid@" + ";", false);
  1224     	//*TTY*/else
  1225     	//*TTY*/    wrapper = interpretSML(javaCalcID, "moveUp @calcid@ " + p.toSMLString() + ";", false);
  1226     	//*TTY*/return_val = moveSuccess(wrapper);
  1227     	/*---------------------------------------------------------------------------*/
  1228     	/*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(javaCalcID));
  1229     	/*PIDE*/XML.Tree xml_in = null;
  1230     	/*PIDE*/XML.Tree xml_out = null;
  1231 
  1232     	/*PIDE*/if (iteratorID == 1) {
  1233     	/*PIDE*/xml_in = JavaToIsa.move_active_up(new scala.math.BigInt(BigInteger.valueOf(sml_id)));    	
  1234     	/*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
  1235     	/*PIDE*/xml_out = connection_to_kernel_.invoke(IsacOperations.MOVE_ACTIVE_UP, xml_in);
  1236 
  1237     	/*PIDE*/IntPosition java_out = null;
  1238     	/*PIDE*/if (!IsaToJava.is_message(xml_out)) {
  1239     	/*PIDE*/  java_out = IsaToJava.move_active_calchead_out(xml_out);
  1240     	/*PIDE*/  return_val = java_out.getPosition();
  1241     	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);    	
  1242     	/*PIDE*/} else
  1243         /*PIDE*/  bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);    	
  1244 
  1245     	/*PIDE*/} else {
  1246     		
  1247     	/*PIDE*/bridge_.log(1, "-->ISA: " + "moveUp " + sml_id + " " + p.toSMLString() + ";");
  1248     	/*PIDE*/xml_in = JavaToIsa.move_up(new scala.math.BigInt(BigInteger.valueOf(sml_id)), p);    	
  1249     	/*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
  1250     	/*PIDE*/xml_out = connection_to_kernel_.invoke(IsacOperations.MOVE_UP, xml_in);
  1251 
  1252     	/*PIDE*/IntPosition java_out = null;
  1253     	/*PIDE*/if (!IsaToJava.is_message(xml_out)) {
  1254     	/*PIDE*/  java_out = IsaToJava.move_calchead_out(xml_out);
  1255     	/*PIDE*/  return_val = java_out.getPosition();
  1256     	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);    	
  1257     	/*PIDE*/} else
  1258         /*PIDE*/  bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);    	
  1259     	/*PIDE*/}
  1260     	/*---------------------------------------------------------------------------*/
  1261         return return_val;
  1262     }
  1263 
  1264     // /----- these methods are designed for a visitor of the CalcTree ------------\
  1265     //        (with a iteratorID > 1), e.g. a teacher watching the student.
  1266     /** MATH_ENGINE: val moveCalcHead : calcID -> pos' -> XML.tree 
  1267      *  does not exist in isac-java, see val moveActiveCalcHead */
  1268 
  1269     /** MATH_ENGINE: val moveDown : calcID -> pos' -> XML.tree 
  1270      *  does not exist in isac-java, see val moveActiveDown */
  1271     
  1272     /** MATH_ENGINE: val val moveLevelDown : calcID -> pos' -> XML.tree 
  1273      *  does not exist in isac-java, see val moveActiveLevelDown */
  1274 
  1275     /** MATH_ENGINE: val moveLevelUp : calcID -> pos' -> XML.tree 
  1276      *  does not exist in isac-java, see val moveActiveLevelUp */
  1277 
  1278     /** MATH_ENGINE: val moveRoot : calcID -> XML.tree
  1279      *  does not exist in isac-java, see val moveActiveRoot */
  1280     
  1281     /** MATH_ENGINE: val moveUp : calcID -> pos' -> XML.tree
  1282      *  does not exist in isac-java, see val moveActiveUp */
  1283     // \----- these methods are designed for a visitor of the CalcTree ------------/
  1284 
  1285     /**
  1286      * @see isac.bridge.IBridgeRMI#getElement(int, int)
  1287      * MATH_ENGINE: val refFormula : calcID -> pos' -> XML.tree
  1288      */
  1289     public ICalcElement getElement(int javaCalcID, Position p) {
  1290     	ICalcElement return_val = null;
  1291     	/*---------------------------------------------------------------------------*/
  1292     	//*TTY*/ResponseWrapper wrapper = interpretSML(javaCalcID,
  1293     	//*TTY*/        "(*getElement*)refFormula @calcid@ " + p.toSMLString() + ";", false);
  1294     	//*TTY*/if (wrapper == null) return_val =  null;
  1295     	//*TTY*/return_val =  (ICalcElement) wrapper.getResponse();
  1296     	/*---------------------------------------------------------------------------*/
  1297     	/*PIDE*/int sml_calcid = ((Integer) java_calcid_to_smlcalcid_.get(new Integer(javaCalcID))).intValue();
  1298     	/*PIDE*/bridge_.log(1, "-->ISA: " + "(*getElement*)refFormula " + sml_calcid
  1299     	/*PIDE*/  + " " + p.toSMLString() + ";");
  1300 
  1301     	/*PIDE*/XML.Tree xml_in = JavaToIsa.ref_formula(new scala.math.BigInt(BigInteger.valueOf(sml_calcid)), p);
  1302     	/*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
  1303     	/*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(IsacOperations.REF_FORMULA, xml_in);
  1304 
  1305     	/*PIDE*/IntFormHead java_out = null;
  1306     	/*PIDE*/if (!IsaToJava.is_message(xml_out)) {
  1307     	/*PIDE*/  java_out = IsaToJava.ref_formula_out(xml_out);
  1308     	/*PIDE*/  return_val = (ICalcElement)java_out.getFormHead();
  1309     	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);    	
  1310     	/*PIDE*/} else
  1311         /*PIDE*/  bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);    	
  1312     	/*---------------------------------------------------------------------------*/
  1313     	return return_val;
  1314     }
  1315     
  1316     /** MATH_ENGINE: val refineProblem : calcID -> pos' -> guh -> XML.tree 
  1317      *  see notes WN150824 */
  1318     public Context refineProblem(int javaCalcID, Context context, Position pos) throws RemoteException {
  1319     	Context return_val = null;
  1320     	/*---------------------------------------------------------------------------*/
  1321     	//*TTY*/ResponseWrapper wrapper = interpretSML(javaCalcID,
  1322     	//*TTY*/  "refineProblem @calcid@ " + pos.toSMLString() + " \"" + context.getKEStoreKey().toString() + "\";", false); 
  1323     	//*TTY*/if(wrapper == null) return null;
  1324     	//*TTY*/return_val = (Context) wrapper.getResponse();
  1325     	/*---------------------------------------------------------------------------*/
  1326     	/*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(javaCalcID));
  1327     	/*PIDE*/bridge_.log(1, "-->ISA: " + "refineProblem " + sml_id + " " + pos.toSMLString() + " \"" + context.getKEStoreKey().toString() + "\";");
  1328 
  1329     	/*PIDE*/XML.Tree xml_in = JavaToIsa.refine_pbl(new scala.math.BigInt(BigInteger.valueOf(sml_id)), 
  1330     	/*PIDE*/  pos, context.getKEStoreKey().toString() + "\"");
  1331     	/*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
  1332     	/*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(IsacOperations.REFINE_PBL, xml_in);
  1333 
  1334     	/*PIDE*/IntContext java_out = null;
  1335     	/*PIDE*/if (!IsaToJava.is_message(xml_out)) {
  1336     	/*PIDE*/  java_out = IsaToJava.refine_pbl_out(xml_out);
  1337     	/*PIDE*/  return_val = java_out.getContext();
  1338     	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);    	
  1339     	/*PIDE*/} else
  1340         /*PIDE*/  bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);    	
  1341     	/*---------------------------------------------------------------------------*/
  1342         return return_val;
  1343     }
  1344     
  1345     /** MATH_ENGINE: val replaceFormula : calcID -> cterm' -> XML.tree */
  1346     public CEvent replaceFormula(int id, CalcFormula f) {
  1347     	CEvent return_val = null;
  1348     	/*---------------------------------------------------------------------------*/
  1349     	//*TTY*/ResponseWrapper wrapper = null;
  1350     	//*TTY*/wrapper = interpretSML(id, "replaceFormula @calcid@ \"" + f.toSMLString() + "\";", false);
  1351     	//*TTY*/if (wrapper == null) return_val = null;
  1352     	//*TTY*/else return_val = (CEvent) wrapper.getResponse();
  1353     	/*---------------------------------------------------------------------------*/
  1354     	/*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(id));
  1355     	/*PIDE*/bridge_.log(1, "-->ISA: " + "replaceFormula " + sml_id + " \"" + f.toSMLString() + "\";");
  1356     	
  1357     	/*PIDE*/XML.Tree xml_in = JavaToIsa.replace_form(new scala.math.BigInt(BigInteger.valueOf(sml_id)), f.getFormula());    	
  1358     	/*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
  1359     	/*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(IsacOperations.REPLACE_FORM, xml_in);
  1360 
  1361     	/*PIDE*/IntCEvent java_out = null;
  1362     	/*PIDE*/if (!IsaToJava.is_message(xml_out)) {
  1363     	/*PIDE*/  java_out = IsaToJava.replace_form_out(xml_out);
  1364     	/*PIDE*/  return_val = java_out.getCEvent();
  1365     	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);    	
  1366     	/*PIDE*/} else
  1367         /*PIDE*/  bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);    	
  1368     	/*---------------------------------------------------------------------------*/
  1369         return return_val;
  1370     }
  1371 
  1372     /** MATH_ENGINE: val requestFillformula : calcID -> errpatID * fillpatID -> XML.tree 
  1373      * only implemented in Math_Engine */
  1374 
  1375     /** MATH_ENGINE: val resetCalcHead : calcID -> XML.tree */
  1376     /**
  1377      * @see isac.interfaces.IToCalc#resetCalcHead()
  1378      */
  1379     public CalcHead resetCalcHead(int calc_tree_id) throws RemoteException {
  1380     	CalcHead return_val = null;
  1381     	/*---------------------------------------------------------------------------*/
  1382     	//*TTY*/ResponseWrapper wrapper = interpretSML(calc_tree_id, "resetCalcHead @calcid@;", false);
  1383     	//*TTY*/return_val = (CalcHead) wrapper.getResponse();
  1384     	/*---------------------------------------------------------------------------*/
  1385     	/*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(calc_tree_id));
  1386     	/*PIDE*/bridge_.log(1, "-->ISA: " + "resetCalcHead " + sml_id + ";");
  1387     	
  1388     	/*PIDE*/XML.Tree xml_in = JavaToIsa.reset_calchead(new scala.math.BigInt(BigInteger.valueOf(sml_id)));    	
  1389     	/*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
  1390     	/*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(IsacOperations.RESET_CALCHEAD, xml_in);
  1391 
  1392     	/*PIDE*/IntCalcHead java_out = null;
  1393     	/*PIDE*/if (!IsaToJava.is_message(xml_out)) {
  1394     	/*PIDE*/  java_out = IsaToJava.reset_calchead_out(xml_out);
  1395     	/*PIDE*/  return_val = java_out.getCalcHead();
  1396     	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);    	
  1397     	/*PIDE*/} else
  1398         /*PIDE*/  bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);    	
  1399     	/*---------------------------------------------------------------------------*/
  1400         return return_val;
  1401     }
  1402 
  1403     /** MATH_ENGINE: val setContext : calcID -> pos' -> guh -> XML.tree */
  1404     /* The status of this method is unclear:
  1405      * 
  1406      ** There is no use-case and no test
  1407      ** The code is NOT used when showing the contexts
  1408      *    of thy, pbl, met, exp for example Biegelinie.
  1409      ** The code is not deleted, nevertheless, because there is
  1410      *    code in isabisac: interface#setContext
  1411      *    
  1412      *  So the changes for "isabelle tty" --> libisabelle adapt to the XML 
  1413      *  sent from isabisac interface#setContext > autocalculateOK2xml.
  1414      */
  1415     public CChanged setContext(int javaCalcID, ContextTheory context, Position pos ) throws RemoteException {
  1416     	CChanged return_val = null;
  1417     	/*---------------------------------------------------------------------------*/
  1418     	//*TTY*/ResponseWrapper wrapper =  interpretSML(javaCalcID,
  1419     	//*TTY*/  "setContext @calcid@ " + pos.toSMLString() + " \"" + context.getKEStoreKey().toString() + "\";", false);
  1420     	//*TTY*/if(wrapper == null) return_val = null;
  1421     	//*TTY*/else return_val = (CChanged) wrapper.getResponse();
  1422     	/*---------------------------------------------------------------------------*/
  1423     	/*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(javaCalcID));
  1424     	/*PIDE*/bridge_.log(1, "-->ISA: " + "setContext " + sml_id + " " + pos.toSMLString() + " \"" + context.getKEStoreKey().toString() + "\";");
  1425     	
  1426     	/*PIDE*/XML.Tree xml_in = JavaToIsa.set_ctxt(new scala.math.BigInt(BigInteger.valueOf(sml_id)), 
  1427     	/*PIDE*/  pos, context.getKEStoreKey().toString() + "\"");
  1428     	/*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
  1429     	/*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(IsacOperations.SET_CTXT, xml_in);
  1430 
  1431     	/*PIDE*/IntCEvent java_out = null;
  1432     	/*PIDE*/if (!IsaToJava.is_message(xml_out)) {
  1433     	/*PIDE*/  java_out = IsaToJava.set_ctxt_out(xml_out);
  1434     	/*PIDE*/  return_val = (CChanged) java_out.getCEvent();
  1435     	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);    	
  1436     	/*PIDE*/} else
  1437         /*PIDE*/  bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);    	
  1438     	/*---------------------------------------------------------------------------*/
  1439         return return_val;
  1440     }   
  1441 
  1442     /**
  1443      * @see isac.interfaces.IToCalc#setMethod()
  1444      * 
  1445      * MATH_ENGINE: val setMethod : calcID -> metID -> XML.tree
  1446      */
  1447     public CalcHead setMethod(int calc_tree_id, MethodID id) throws RemoteException {
  1448     	CalcHead return_val = null;
  1449     	/*---------------------------------------------------------------------------*/
  1450     	//*TTY*/ResponseWrapper wrapper = interpretSML(calc_tree_id,
  1451     	//*TTY*/  "setMethod @calcid@ " + id.toSMLString() + ";", false);
  1452     	//*TTY*/return_val = (CalcHead) wrapper.getResponse();
  1453     	/*---------------------------------------------------------------------------*/
  1454     	/*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(calc_tree_id));
  1455     	/*PIDE*/bridge_.log(1, "-->ISA: " + "setMethod " + sml_id + " " + id.toSMLString() + ";");
  1456     	
  1457     	/*PIDE*/XML.Tree xml_in = JavaToIsa.set_met(new scala.math.BigInt(BigInteger.valueOf(sml_id)), id.getID());    	
  1458     	/*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
  1459     	/*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(IsacOperations.SET_MET, xml_in);
  1460 
  1461     	/*PIDE*/IntCalcHead java_out = null;
  1462     	/*PIDE*/if (!IsaToJava.is_message(xml_out)) {
  1463     	/*PIDE*/  java_out = IsaToJava.set_met_out(xml_out);
  1464     	/*PIDE*/  return_val = java_out.getCalcHead();
  1465     	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);    	
  1466     	/*PIDE*/} else
  1467         /*PIDE*/  bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);    	
  1468     	/*---------------------------------------------------------------------------*/
  1469         return return_val;
  1470     }
  1471 
  1472     /** MATH_ENGINE: val setNextTactic : calcID -> tac -> XML.tree */
  1473     public int setNextTactic(int id, Tactic tactic) {
  1474     	int return_val = 4711;
  1475     	/*---------------------------------------------------------------------------*/
  1476     	//*TTY*/ResponseWrapper wrapper = interpretSML(id, 
  1477     	//*TTY*/  "setNextTactic @calcid@ (" + tactic.toSMLString() + ");", false);
  1478     	//*TTY*/if (wrapper == null) return_val = -1;//WN050223 response ... MESSAGE not parsed
  1479     	//*TTY*/if (wrapper.getResponse() == null) { return_val = 0; //Everything is ok
  1480     	//*TTY*/} else { return_val = -1; } //An Error occcured
  1481     	/*---------------------------------------------------------------------------*/
  1482     	/*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(id));
  1483     	/*PIDE*/bridge_.log(1, "-->ISA: " + "setNextTactic " + sml_id + " (" + tactic.toSMLString() + ");");    	
  1484 
  1485     	/*PIDE*/XML.Tree xml_in = JavaToIsa.set_next_tac(new scala.math.BigInt(BigInteger.valueOf(sml_id)), tactic);    	
  1486     	/*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
  1487     	/*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(IsacOperations.SET_NEXT_TAC, xml_in);
  1488 
  1489     	/*PIDE*/if (!IsaToJava.is_syserror(xml_out)) {
  1490     	IsaToJava.set_next_tac_out(xml_out);
  1491     	/*PIDE*/  return_val = 0; //Everything is ok
  1492     	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);    	
  1493     	/*PIDE*/} else {
  1494     	/*PIDE*/  bridge_.log(1, "<--ISA: IsaToJava.is_syserror: " + xml_out); 
  1495     	/*PIDE*/}
  1496     	/*---------------------------------------------------------------------------*/
  1497         return return_val;
  1498     }
  1499     
  1500     /**
  1501      * @see isac.interfaces.IToCalc#setProblem()
  1502      * 
  1503      * MATH_ENGINE: val setProblem : calcID -> pblID -> XML.tree
  1504      */
  1505     public CalcHead setProblem(int calc_tree_id, ProblemID id) throws RemoteException {
  1506     	CalcHead return_val = null;
  1507     	/*---------------------------------------------------------------------------*/
  1508     	//*TTY*/ResponseWrapper wrapper = interpretSML(calc_tree_id,
  1509     	//*TTY*/  "setProblem @calcid@ " + id.toSMLString() + ";", false);
  1510     	//*TTY*/return_val = (CalcHead) wrapper.getResponse();
  1511     	/*---------------------------------------------------------------------------*/
  1512     	/*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(calc_tree_id));
  1513     	/*PIDE*/bridge_.log(1, "-->ISA: " + "setProblem " + sml_id + " " + id.toSMLString() + ";");
  1514     	
  1515     	/*PIDE*/XML.Tree xml_in = JavaToIsa.set_met(new scala.math.BigInt(BigInteger.valueOf(sml_id)), id.getID());    	
  1516     	/*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
  1517     	/*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(IsacOperations.SET_PBL, xml_in);
  1518 
  1519     	/*PIDE*/IntCalcHead java_out = null;
  1520     	/*PIDE*/if (!IsaToJava.is_message(xml_out)) {
  1521     	/*PIDE*/  java_out = IsaToJava.set_met_out(xml_out);
  1522     	/*PIDE*/  return_val = java_out.getCalcHead();
  1523     	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);    	
  1524     	/*PIDE*/} else
  1525         /*PIDE*/  bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);    	
  1526     	/*---------------------------------------------------------------------------*/
  1527         return return_val;
  1528     }
  1529 
  1530     /**
  1531      * @see isac.interfaces.IToCalc#setTheory()
  1532      * 
  1533      * TODO/WN150812: use implementation in Math_Engine.
  1534      * MATH_ENGINE: val setTheory : calcID -> thyID -> XML.tree
  1535      */
  1536     public CalcHead setTheory(int calc_tree_id, String thy_id)
  1537             throws RemoteException {
  1538     	CalcHead return_val = null;
  1539     	Position pos = null;
  1540     	/*---------------------------------------------------------------------------*/
  1541        	//*TTY*///---FIXXXME.WN050809 hack until setTheory pushed into SML-kernel
  1542     	//*TTY*/ResponseWrapper wrapper = interpretSML(calc_tree_id,
  1543     	//*TTY*/  "(*setTheory*)setNextTactic @calcid@ (Specify_Theory \"" + thy_id + "\");", false);
  1544     	//*TTY*/wrapper = interpretSML(calc_tree_id,
  1545     	//*TTY*/  "(*setTheory*)autoCalculate @calcid@ (Step 1);", false);
  1546     	//*TTY*///drop the CalcChanged returned by autoCalculate
  1547     	//*TTY*/wrapper = interpretSML(calc_tree_id, 
  1548     	//*TTY*/  "(*setTheory*)getActiveFormula @calcid@ ;", false);
  1549     	//*TTY*/pos = moveSuccess(wrapper);
  1550     	//*TTY*/wrapper = interpretSML(calc_tree_id,
  1551     	//*TTY*/  "(*setTheory*)refFormula @calcid@ " + pos.toSMLString() + ";", false);
  1552     	//*TTY*/return_val = (CalcHead) wrapper.getResponse();
  1553         //\---End hack
  1554     	/*---------------------------------------------------------------------------*/
  1555         //---FIXXXME.WN050809 hack until setTheory pushed into SML-kernel
  1556     	/*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(calc_tree_id));
  1557 
  1558     	/*PIDE*/bridge_.log(1, "-->ISA: " + "(*setTheory*)setNextTactic " + sml_id + " (Specify_Theory \"" + thy_id + "\");");    	
  1559     	/*PIDE*/SimpleTactic tac = new SimpleTactic("Specify_Theory", thy_id + "\"");
  1560     	/*PIDE*/XML.Tree xml_in = JavaToIsa.set_next_tac(new scala.math.BigInt(BigInteger.valueOf(sml_id)), tac);    	
  1561     	/*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
  1562     	/*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(IsacOperations.SET_NEXT_TAC, xml_in);
  1563     	/*PIDE*/bridge_.log(1, "<--ISA: message not sent to Dialog ... " + xml_out);
  1564 
  1565     	/*PIDE*/bridge_.log(1, "-->ISA: " + "(*setTheory*)autoCalculate " + sml_id + " (Step 1);");   	
  1566     	/*PIDE*/xml_in = JavaToIsa.auto_calculate(new scala.math.BigInt(BigInteger.valueOf(sml_id)), 
  1567     	/*PIDE*/  "Step", new scala.math.BigInt(BigInteger.valueOf(1)));
  1568     	/*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
  1569     	/*PIDE*/xml_out = connection_to_kernel_.invoke(IsacOperations.AUTO_CALC, xml_in);
  1570     	/*PIDE*/bridge_.log(1, "<--ISA: CalcChanged not sent to Dialog ... " + xml_out);
  1571 
  1572     	/*PIDE*/bridge_.log(1, "-->ISA: " + "(*setTheory*)getActiveFormula " + sml_id + ";");   	
  1573     	/*PIDE*/xml_in = JavaToIsa.get_active_form(new scala.math.BigInt(BigInteger.valueOf(sml_id)));    	
  1574     	/*PIDE*/xml_out = connection_to_kernel_.invoke(IsacOperations.GET_ACTIVE_FORM, xml_in);
  1575     	/*PIDE*/IntPosition java_out = null;
  1576     	/*PIDE*/if (!IsaToJava.is_message(xml_out)) {
  1577     	/*PIDE*/  java_out = IsaToJava.get_active_form_out(xml_out);
  1578     	/*PIDE*/  pos = java_out.getPosition();
  1579     	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);    	
  1580     	/*PIDE*/} else
  1581         /*PIDE*/  bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);    	
  1582 
  1583     	/*PIDE*/bridge_.log(1, "-->ISA: " + "(*setTheory*)refFormula " + sml_id + " " + pos.toSMLString() + ";");
  1584     	/*PIDE*/xml_in = JavaToIsa.ref_formula(new scala.math.BigInt(BigInteger.valueOf(sml_id)), pos);//^^pos.setKind("DUMMY")
  1585     	/*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
  1586     	/*PIDE*/xml_out = connection_to_kernel_.invoke(IsacOperations.REF_FORMULA, xml_in);
  1587 
  1588     	/*PIDE*/IntFormHead java_out2 = null;
  1589     	/*PIDE*/if (!IsaToJava.is_message(xml_out)) {
  1590     	/*PIDE*/  java_out2 = IsaToJava.ref_formula_out(xml_out);
  1591     	/*PIDE*/  return_val = (CalcHead)java_out2.getFormHead();
  1592     	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);    	
  1593     	/*PIDE*/} else
  1594         /*PIDE*/  bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);    	
  1595        	/*PIDE*///\---End hack
  1596     	/*---------------------------------------------------------------------------*/
  1597         return return_val;
  1598     }
  1599 
  1600     /***********************************************************************
  1601      * Below are methods not contained in MATH_ENGINE, rather
  1602      * they composed from other methods in Math_Engine. 
  1603      */
  1604 
  1605     /**
  1606      * @see isac.interfaces.IToCalc#completeCalcHead()
  1607      */
  1608     public CalcHead completeCalcHead(int calc_tree_id) {
  1609     	CalcHead return_val = null;
  1610     	Position pos = null;
  1611     	/*---------------------------------------------------------------------------*/
  1612        	//*TTY*///---FIXXXME.WN050809 hack until setTheory pushed into SML-kernel
  1613     	//*TTY*/ResponseWrapper wrapper = interpretSML(calc_tree_id,
  1614     	//*TTY*/  "(*completeCalcHead*)autoCalculate @calcid@ CompleteCalcHead;", false);
  1615     	//*TTY*///drop the CalcChanged returned by autoCalculate
  1616     	//*TTY*/wrapper = interpretSML(calc_tree_id,
  1617     	//*TTY*/  "(*completeCalcHead*)getActiveFormula @calcid@ ;", false);
  1618     	//*TTY*/pos = moveSuccess(wrapper);
  1619     	//*TTY*/wrapper = interpretSML(calc_tree_id,
  1620     	//*TTY*/  "(*completeCalcHead*)refFormula @calcid@ " + pos.toSMLString() + ";", false);
  1621     	//*TTY*/return_val = (CalcHead) wrapper.getResponse();
  1622     	//*TTY*///\---End hack
  1623     	/*---------------------------------------------------------------------------*/
  1624         //---FIXXXME.WN050809 hack until setTheory pushed into SML-kernel
  1625     	/*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(calc_tree_id));
  1626 
  1627     	/*PIDE*/bridge_.log(1, "-->ISA: " + "(*completeCalcHead*)autoCalculate " + sml_id + "CompleteCalcHead;");
  1628     	/*PIDE*/XML.Tree xml_in = JavaToIsa.auto_calculate(new scala.math.BigInt(BigInteger.valueOf(sml_id)), 
  1629     	/*PIDE*/  "CompleteCalcHead", new scala.math.BigInt(BigInteger.valueOf(0)));
  1630     	/*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
  1631     	/*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(IsacOperations.AUTO_CALC, xml_in);
  1632 
  1633     	/*PIDE*/if (!IsaToJava.is_message(xml_out)) {
  1634     	IsaToJava.auto_calc_out(xml_out);
  1635     	/*PIDE*///  return_val = java_out.getCEvent();
  1636     	/*PIDE*/bridge_.log(1, "<--ISA: not sent to Dialog ... " + xml_out);    	
  1637     	/*PIDE*/} else
  1638         /*PIDE*/  bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);    	
  1639     	
  1640 
  1641     	/*PIDE*/bridge_.log(1, "-->ISA: " + "(*completeCalcHead*)getActiveFormula " + sml_id + ";");
  1642     	/*PIDE*/xml_in = JavaToIsa.get_active_form(new scala.math.BigInt(BigInteger.valueOf(sml_id)));    	
  1643     	/*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
  1644     	/*PIDE*/xml_out = connection_to_kernel_.invoke(IsacOperations.GET_ACTIVE_FORM, xml_in);
  1645 
  1646     	/*PIDE*/IntPosition java_out2 = null;
  1647     	/*PIDE*/if (!IsaToJava.is_message(xml_out)) {
  1648     	/*PIDE*/  java_out2 = IsaToJava.get_active_form_out(xml_out);
  1649     	/*PIDE*/ pos = java_out2.getPosition();
  1650     	/*PIDE*/bridge_.log(1, "<--ISA: used locally ... " + xml_out);    	
  1651     	/*PIDE*/} else
  1652         /*PIDE*/  bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);    	
  1653     	
  1654     	
  1655     	/*PIDE*/bridge_.log(1, "-->ISA: " + "(*completeCalcHead*)refFormula " + sml_id + pos.toSMLString() + ";");
  1656     	/*PIDE*/xml_in = JavaToIsa.ref_formula(new scala.math.BigInt(BigInteger.valueOf(sml_id)), pos);    	
  1657     	/*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
  1658     	/*PIDE*/xml_out = connection_to_kernel_.invoke(IsacOperations.REF_FORMULA, xml_in);
  1659 
  1660     	/*PIDE*/IntFormHead java_out3 = null;
  1661     	/*PIDE*/if (!IsaToJava.is_message(xml_out)) {
  1662     	/*PIDE*/  java_out3 = IsaToJava.ref_formula_out(xml_out);
  1663     	/*PIDE*/ return_val = (CalcHead)java_out3.getFormHead();
  1664     	/*PIDE*/bridge_.log(1, "<--ISA: used locally ... " + xml_out);    	
  1665     	/*PIDE*/} else
  1666         /*PIDE*/  bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);    	   	
  1667        	/*PIDE*///\---End hack
  1668     	/*---------------------------------------------------------------------------*/
  1669         return return_val;
  1670     }
  1671 
  1672     /**
  1673      * @see isac.interfaces.IToCalc#completeModel() WN050809 push this method
  1674      *      through to the SML-kernel
  1675      */
  1676     public CalcHead completeModel(int calc_tree_id) throws RemoteException {
  1677        	CalcHead return_val = null;
  1678     	Position pos = null;
  1679     	/*---------------------------------------------------------------------------*/
  1680         //*TTY*///---FIXXXME.WN050809 hack until setTheory pushed into SML-kernel
  1681        	//*TTY*/ResponseWrapper wrapper = interpretSML(calc_tree_id,
  1682        	//*TTY*/  "(*completeModel*)autoCalculate @calcid@ CompleteModel;", false);
  1683        	//*TTY*///drop the CalcChanged returned by autoCalculate
  1684        	//*TTY*/wrapper = interpretSML(calc_tree_id,
  1685        	//*TTY*/  "(*completeModel*)getActiveFormula @calcid@ ;", false);
  1686        	//*TTY*/pos = moveSuccess(wrapper);
  1687        	//*TTY*/wrapper = interpretSML(calc_tree_id,
  1688        	//*TTY*/  "(*completeModel*)refFormula @calcid@ " + pos.toSMLString() + ";", false);
  1689     	//*TTY*/return_val = (CalcHead) wrapper.getResponse();
  1690         //\---End hack
  1691     	/*---------------------------------------------------------------------------*/
  1692         //---FIXXXME.WN050809 hack until setTheory pushed into SML-kernel
  1693     	/*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(calc_tree_id));
  1694 
  1695     	/*PIDE*/bridge_.log(1, "-->ISA: " + "(*completeModel*)autoCalculate " + sml_id + " CompleteModel;");
  1696     	/*PIDE*/XML.Tree xml_in = JavaToIsa.auto_calculate(new scala.math.BigInt(BigInteger.valueOf(sml_id)), 
  1697     	/*PIDE*/  "CompleteModel", new scala.math.BigInt(BigInteger.valueOf(0)));
  1698     	/*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
  1699     	/*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(IsacOperations.AUTO_CALC, xml_in);
  1700 
  1701     	/*PIDE*/if (!IsaToJava.is_message(xml_out)) {
  1702     	IsaToJava.set_met_out(xml_out);
  1703     	/*PIDE*/bridge_.log(1, "<--ISA: not sent to Dialog = " + xml_out);    	
  1704     	/*PIDE*/} else
  1705         /*PIDE*/  bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);    	
  1706 
  1707     	
  1708     	/*PIDE*/bridge_.log(1, "-->ISA: " + "(*completeModel*)getActiveFormula " + sml_id + ";");
  1709     	/*PIDE*/xml_in = JavaToIsa.get_active_form(new scala.math.BigInt(BigInteger.valueOf(sml_id)));    	
  1710     	/*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
  1711     	/*PIDE*/xml_out = connection_to_kernel_.invoke(IsacOperations.GET_ACTIVE_FORM, xml_in);
  1712 
  1713     	/*PIDE*/IntPosition java_out2 = null;
  1714     	/*PIDE*/if (!IsaToJava.is_message(xml_out)) {
  1715     	/*PIDE*/  java_out2 = IsaToJava.get_active_form_out(xml_out);
  1716     	/*PIDE*/ pos = java_out2.getPosition();
  1717     	/*PIDE*/bridge_.log(1, "<--ISA: used locally ... " + xml_out);    	
  1718     	/*PIDE*/} else
  1719         /*PIDE*/  bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);    	
  1720     	
  1721     	/*PIDE*/bridge_.log(1, "-->ISA: " + "(*completeModel*)refFormula " + sml_id + " " + pos.toSMLString() + ";");
  1722     	/*PIDE*/xml_in = JavaToIsa.ref_formula(new scala.math.BigInt(BigInteger.valueOf(sml_id)), pos);    	
  1723     	/*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
  1724     	/*PIDE*/xml_out = connection_to_kernel_.invoke(IsacOperations.REF_FORMULA, xml_in);
  1725 
  1726     	/*PIDE*/IntFormHead java_out3 = null;
  1727     	/*PIDE*/if (!IsaToJava.is_message(xml_out)) {
  1728     	/*PIDE*/  java_out3 = IsaToJava.ref_formula_out(xml_out);
  1729     	/*PIDE*/ return_val = (CalcHead)java_out3.getFormHead();
  1730     	/*PIDE*/bridge_.log(1, "<--ISA: used locally ... " + xml_out);    	
  1731     	/*PIDE*/} else
  1732         /*PIDE*/  bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);    	   	
  1733        	/*PIDE*///\---End hack
  1734     	/*---------------------------------------------------------------------------*/
  1735         return return_val;
  1736     }
  1737 
  1738     /**
  1739      * @see isac.interfaces.IToCalc#nextSpecify() WN050809 push this method
  1740      *      through to the SML-kernel.
  1741      */
  1742     public CalcHead nextSpecify(int calc_tree_id) throws RemoteException {
  1743        	CalcHead return_val = null;
  1744     	Position pos = null;
  1745     	/*---------------------------------------------------------------------------*/
  1746        	//*TTY*///---FIXXXME.WN050809 hack until setTheory pushed into SML-kernel
  1747        	//*TTY*/ResponseWrapper wrapper = interpretSML(calc_tree_id,
  1748        	//*TTY*/  "(*nextSpecify*)autoCalculate @calcid@ (Step 1);", false);
  1749        	//*TTY*///drop the CalcChanged returned by autoCalculate
  1750        	//*TTY*/wrapper = interpretSML(calc_tree_id,
  1751        	//*TTY*/  "(*nextSpecify*)getActiveFormula @calcid@ ;", false);
  1752        	//*TTY*/pos = moveSuccess(wrapper);
  1753        	//*TTY*/wrapper = interpretSML(calc_tree_id,
  1754        	//*TTY*/  "(*nextSpecify*)refFormula @calcid@ " + pos.toSMLString() + ";", false);
  1755        	//*TTY*/return_val = (CalcHead) wrapper.getResponse();
  1756        	//*TTY*///\---End hack
  1757     	/*---------------------------------------------------------------------------*/
  1758     	/*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(calc_tree_id));
  1759        	/*PIDE*///---FIXXXME.WN050809 hack until setTheory pushed into SML-kernel
  1760 
  1761     	/*PIDE*/bridge_.log(1, "-->ISA: " + "(*nextSpecify*)autoCalculate " + sml_id + " (Step 1);");
  1762     	/*PIDE*/XML.Tree xml_in = JavaToIsa.auto_calculate(new scala.math.BigInt(BigInteger.valueOf(sml_id)), 
  1763     	/*PIDE*/  "Step", new scala.math.BigInt(BigInteger.valueOf(1)));
  1764     	/*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
  1765     	/*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(IsacOperations.AUTO_CALC, xml_in);
  1766 
  1767     	/*PIDE*/if (!IsaToJava.is_message(xml_out)) {
  1768     	IsaToJava.set_met_out(xml_out);
  1769     	/*PIDE*/bridge_.log(1, "<--ISA: not sent to Dialog = " + xml_out);    	
  1770     	/*PIDE*/} else
  1771         /*PIDE*/  bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);    	
  1772 
  1773     	
  1774     	/*PIDE*/bridge_.log(1, "-->ISA: " + "(*nextSpecify*)getActiveFormula " + sml_id + ";");
  1775     	/*PIDE*/xml_in = JavaToIsa.get_active_form(new scala.math.BigInt(BigInteger.valueOf(sml_id)));    	
  1776     	/*PIDE*/xml_out = connection_to_kernel_.invoke(IsacOperations.GET_ACTIVE_FORM, xml_in);
  1777 
  1778     	/*PIDE*/IntPosition java_out2 = null;
  1779     	/*PIDE*/if (!IsaToJava.is_message(xml_out)) {
  1780     	/*PIDE*/  java_out2 = IsaToJava.get_active_form_out(xml_out);
  1781     	/*PIDE*/ pos = java_out2.getPosition();
  1782     	/*PIDE*/bridge_.log(1, "<--ISA: used locally ... " + xml_out);    	
  1783     	/*PIDE*/} else
  1784         /*PIDE*/  bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);    	
  1785     	
  1786     	
  1787     	/*PIDE*/bridge_.log(1, "-->ISA: " + "(*nextSpecify*)refFormula " + sml_id + pos.toSMLString() + ";");
  1788     	/*PIDE*/xml_in = JavaToIsa.ref_formula(new scala.math.BigInt(BigInteger.valueOf(sml_id)), pos);//^^pos.setKind("DUMMY")
  1789     	/*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
  1790     	/*PIDE*/xml_out = connection_to_kernel_.invoke(IsacOperations.REF_FORMULA, xml_in);
  1791 
  1792     	/*PIDE*/IntFormHead java_out3 = null;
  1793     	/*PIDE*/if (!IsaToJava.is_message(xml_out)) {
  1794     	/*PIDE*/  java_out3 = IsaToJava.ref_formula_out(xml_out);
  1795     	/*PIDE*/ return_val = (CalcHead)java_out3.getFormHead();
  1796     	/*PIDE*/bridge_.log(1, "<--ISA: used locally ... " + xml_out);    	
  1797     	/*PIDE*/} else
  1798         /*PIDE*/  bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);    	   	
  1799        	/*PIDE*///\---End hack
  1800     	/*---------------------------------------------------------------------------*/
  1801         return return_val;
  1802     }
  1803 
  1804     /***********************************************************************
  1805      * Below are methods not implemented in MATH_ENGINE at all,
  1806      * or only very fragmentarily.
  1807      * WN150812 here are also methods, where the status is not clarified. 
  1808      * Some methods seem to be replaced by similar ones.
  1809      * TODO: review IBridgeRMI, MathEngine, etc.
  1810      */
  1811 
  1812     /**
  1813      * <b>Do not use:</b><br></br> not impl. in Math_Engine
  1814      * @see isac.interfaces.ICalcIterator#tryMatchMethod(MethodID)
  1815      */
  1816     public Match initMatchMethod(int javaCalcID) throws RemoteException {
  1817         ResponseWrapper wrapper = interpretSML(javaCalcID,
  1818           "initMatchMethod @calcid@ ;", false);
  1819         Object response = wrapper.getResponse();
  1820         CalcHead ch = (CalcHead) response;
  1821         Match m = new Match(ch.getSpecification().getProblem(), ch
  1822                 .getStatusString(), ch.getHeadLine(), ch.getModel());
  1823         return m;
  1824     }
  1825     
  1826     /**
  1827      * <b>Do not use:</b><br></br> not impl. in Math_Engine
  1828      * @see isac.interfaces.ICalcIterator#tryMatchMethod(MethodID)
  1829      */
  1830     public Match initMatchProblem(int javaCalcID) {
  1831         ResponseWrapper wrapper = interpretSML(javaCalcID,
  1832           "initMatchProblem @calcid@ ;", false);
  1833         Object response = wrapper.getResponse();
  1834         CalcHead ch = (CalcHead) response;
  1835         Match m = new Match(ch.getSpecification().getProblem(), ch
  1836                 .getStatusString(), ch.getHeadLine(), ch.getModel());
  1837         return m;
  1838     }
  1839 
  1840     /**
  1841      * <b>Do not use:</b><br></br> not impl. in Math_Engine
  1842      * @see isac.interfaces.ICalcIterator#tryMatchMethod(MethodID)
  1843      */
  1844     public Match tryMatchMethod(int javaCalcID, MethodID keStoreID)
  1845             throws RemoteException {
  1846         ResponseWrapper wrapper = interpretSML(javaCalcID,
  1847                 "tryMatchMethod @calcid@ " + keStoreID.toSMLString() + ";",
  1848                 false);
  1849         Object response = wrapper.getResponse();
  1850         CalcHead ch = (CalcHead) response;
  1851         Match m = new Match(ch.getSpecification().getProblem(), ch
  1852                 .getStatusString(), ch.getHeadLine(), ch.getModel());
  1853         return m;
  1854     }
  1855 
  1856     /** enforced by IBridgeRMI, WN150812: exp-, met-, pbl-, thy-contexts all work --
  1857      * -- see: CChanged setContext(int, ContextTheory, ... */
  1858 	@Override
  1859 	public CalcHead setContext(int javaCalcID, ContextMethod context, Position pos) throws RemoteException {
  1860 		return null;
  1861 	}
  1862 
  1863     /** enforced by IBridgeRMI, WN150812: exp-, met-, pbl-, thy-contexts all work --
  1864      * -- see: CChanged setContext(int, ContextTheory, ... 
  1865      * This method changed role with ^^^^^^^^^^^^^^^^ during "isabelle tty" --> libisabelle
  1866      */
  1867 	@Override
  1868 	public CalcHead setContext(int javaCalcID, ContextProblem context, Position pos) throws RemoteException {
  1869 		return null;
  1870 	}
  1871     
  1872     /**
  1873      * @see isac.interfaces.ICalcIterator#tryMatchProblem(HierarchyKey)
  1874      * 
  1875      * WN150812: tryMatchProblem, trymatch only partially implemented in Math_Engine
  1876      */
  1877     public Match tryMatchProblem(int javaCalcID, ProblemID problemID) {
  1878         ResponseWrapper wrapper = interpretSML(javaCalcID,
  1879                 "tryMatchProblem @calcid@ " + problemID.toSMLString() + ";",
  1880                 false);
  1881         Object response = wrapper.getResponse();
  1882         CalcHead ch = (CalcHead) response;
  1883         Match m = new Match(ch.getSpecification().getProblem(), ch
  1884                 .getStatusString(), ch.getHeadLine(), ch.getModel());
  1885         return m;
  1886     }
  1887 
  1888     /**
  1889      * <b>Do not use:</b><br></br> not impl. in Math_Engine
  1890      * @see isac.interfaces.ICalcIterator#tryRefineProblem(HierarchyKey)
  1891      */
  1892     public Match tryRefineProblem(int javaCalcID, ProblemID problemID) {
  1893         ResponseWrapper wrapper = interpretSML(javaCalcID,
  1894                 "tryRefineProblem @calcid@ " + problemID.toSMLString() + ";",
  1895                 false);
  1896         Object response = wrapper.getResponse();
  1897         CalcHead ch = (CalcHead) response;
  1898         Match m = new Match(ch.getSpecification().getProblem(), ch
  1899                 .getStatusString(), ch.getHeadLine(), ch.getModel());
  1900         return m;
  1901     }
  1902 
  1903     /***********************************************************************
  1904      * Below are methods for restoring Isabelle/Isac after a crash.
  1905      * This never worked, is to be deleted and 
  1906      * to be reconsidered with introduction of libisabelle.
  1907      */
  1908 
  1909     /**
  1910      * This method is used when the kernel crashes and the CalcTrees need to be
  1911      * entered again to the kernel to restore the previous state. The
  1912      * Java-CalcIDs stay the same
  1913      */
  1914     public void restoreExistingCalcTrees() {
  1915         bridge_.log(1, "---- entering restoreExistingCalcTrees");
  1916         Iterator<?> it = java_calcid_to_smlcalcid_.keySet().iterator();
  1917         // keySet = javaCalcIDs
  1918         int javaCalcID;
  1919         Vector<String> v;
  1920         while (it.hasNext()) {
  1921             //bridge.log(1, "1");
  1922             //int i = ((Integer)it.next()).intValue();
  1923             javaCalcID = ((Integer) it.next()).intValue();
  1924             //bridge.log(1, "2");
  1925             v = saveCalcTree(javaCalcID);
  1926             //bridge.log(1, "3");
  1927             this.restoreToSML(javaCalcID, v);
  1928         }
  1929         bridge_.log(1, "---- done restoreExistingCalcTrees");
  1930     }
  1931 
  1932     private void restoreToSML(int javaCalcID, Vector<String> v) {
  1933         Iterator<String> it = new Vector<String>(v).iterator();
  1934         String s = (String) it.next();
  1935         newCalculation(javaCalcID, s, null/*never worked*/, true);
  1936         //javaCalcIDtoSmlCalcID.put(new Integer(javaCalcID), new
  1937         // Integer(smlCalcID));
  1938         //int smlID = ((Integer)javaCalcIDtoSmlCalcID.get(new
  1939         // Integer(calcID))).intValue();
  1940         while (it.hasNext()) {
  1941             s = (String) it.next();
  1942             interpretSML(javaCalcID, s, true);
  1943         }
  1944     }
  1945 
  1946     /**
  1947      * Save a calcTree for later restoring (probably to another SML Kernel)
  1948      * 
  1949      * @param calcTreeID
  1950      *            the ID of the calcTree
  1951      * @return a vector containing strings. This is representatation of the
  1952      *         status of the calcTree
  1953      */
  1954 	public Vector<String> saveCalcTree(int calcTreeID) {
  1955         this.bridge_.log(1, "----------------begin saving calcTree "
  1956                 + calcTreeID + "------------");
  1957         return (Vector<String>) inputs_.get(new Integer(calcTreeID));
  1958     }
  1959 
  1960     
  1961 }