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