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

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