2 * Created on Oct 13, 2003
3 * @author Richard Gradischnegg RG
7 import isac.bridge.xml.DataTypes;
8 import isac.bridge.xml.IntAssumptions;
9 import isac.bridge.xml.IntCalcHead;
10 import isac.bridge.xml.IntCEvent;
11 import isac.bridge.xml.IntFormHead;
12 import isac.bridge.xml.IntFormulas;
13 import isac.bridge.xml.IntIntCompound;
14 import isac.bridge.xml.IntContext;
15 import isac.bridge.xml.IntPosition;
16 import isac.bridge.xml.IntTactic;
17 import isac.bridge.xml.IntTacticErrPats;
18 import isac.bridge.xml.IntTactics;
19 import isac.bridge.xml.IsaToJava;
20 import isac.bridge.xml.JavaToIsa;
21 import isac.interfaces.ICalcElement;
22 import isac.interfaces.ICalcIterator;
23 import isac.interfaces.IToCalc;
24 import isac.util.Formalization;
25 import isac.util.ResponseWrapper;
26 import isac.util.formulae.Assumptions;
27 import isac.util.formulae.CalcHead;
28 import isac.util.formulae.Context;
29 import isac.util.formulae.ContextMethod;
30 import isac.util.formulae.ContextProblem;
31 import isac.util.formulae.ContextTheory;
32 import isac.util.formulae.HierarchyKey;
33 import isac.util.formulae.CalcFormula;
34 import isac.util.formulae.Match;
35 import isac.util.formulae.MethodID;
36 import isac.util.formulae.Position;
37 import isac.util.formulae.ProblemID;
38 import isac.util.parser.XMLParserDigest;
39 import isac.util.tactics.SimpleTactic;
40 import isac.util.tactics.Tactic;
41 import isac.wsdialog.IContextProvider.ContextType;
42 import edu.tum.cs.isabelle.api.XML;
43 import edu.tum.cs.isabelle.japi.JSystem;
45 import java.io.BufferedReader;
46 import java.io.IOException;
47 import java.io.InputStreamReader;
48 import java.io.PrintWriter;
49 import java.math.BigInteger;
50 import java.net.MalformedURLException;
51 import java.net.Socket;
52 import java.net.UnknownHostException;
53 import java.rmi.Naming;
54 import java.rmi.RMISecurityManager;
55 import java.rmi.RemoteException;
56 import java.rmi.registry.LocateRegistry;
57 import java.rmi.server.UnicastRemoteObject;
58 import java.util.HashMap;
59 import java.util.Iterator;
62 import java.util.Vector;
64 import scala.math.BigInt;
66 import org.apache.log4j.Logger;
69 * @author Richard Gradischnegg RG
71 * WN0422 here seems to be the key for simplifying the whole bridge.* drawbacks
72 * of the present implementation: # more complicated than necessary #
73 * JUnitTestCases require BridgeMain running # BridgeLogger cannot be made
74 * serializable, thus not accessible for writing by JUnitTestCases #
76 @SuppressWarnings("deprecation") // RMISecurityManager : RMI reform will come
77 public class BridgeRMI extends UnicastRemoteObject implements IBridgeRMI {
79 static final long serialVersionUID = -3047706038036289437L;
80 private static final Logger logger = Logger.getLogger(BridgeRMI.class.getName());
82 private BridgeMain bridge_;
84 private XMLParserDigest xml_parser_digest_;
86 // Socket used to communicate with bridge
87 private Socket socket_ = null;
89 // Writer to write sml requests to the kernel
90 private PrintWriter out_ = null;
92 // Reader to read sml response from kernel
93 private BufferedReader in_ = null;
100 * Maps the Java calc(Tree)rmiID to the sml calc(Tree)rmiID. A mapping is
101 * nescessary because these ids are not (nescessary) the same: For example
102 * when restoring the kernel, the calcTree rmiID can change because of
103 * already finished CalcTrees no longer existing and their CalcId assigned
104 * to another CalcTree. key: Integer (javaCalcID) value: Integer (smlCalcID)
106 private Map<Integer, Integer> java_calcid_to_smlcalcid_;
109 * This map stores user inputs which have already been answered by the
110 * kernel and the response being sent back to the user. These inputs are
111 * resent to the kernel in the case of a newstart of the kernel. key:
112 * Integer (javaCalcID) value: Vector (containing input strings)
114 private Map<Integer, Vector<String>> inputs_;
115 private JSystem connection_to_kernel_;
117 public BridgeRMI(BridgeMain bridge, String host, int port, String dtdPath)
118 throws RemoteException {
119 if (logger.isDebugEnabled())
120 logger.debug("BridgeRMI obj.init: bridge=" + bridge + ", host=" + host
121 + ", port=" + port + ", dtdPath=" + dtdPath);
123 this.bridge_ = bridge;
124 this.connection_to_kernel_ = bridge.getConnectionToKernel();
125 in_ = bridge.getSmlReader();
127 socket_ = new Socket(host, port);
128 out_ = new PrintWriter(socket_.getOutputStream(), true);
129 in_ = new BufferedReader(new InputStreamReader(socket_
131 } catch (UnknownHostException e) {
132 System.out.println("Unknown host: " + host + "\n");
133 } catch (IOException e) {
134 System.out.println("probably just a remainder of 'bridge-internal RMI'");
137 xml_parser_digest_ = new XMLParserDigest(dtdPath);
138 //xml_parser_digest_.setValidating(true);
139 //...all XML-data should be tested in
140 //javatest.isac.util.parser.TestXMLParserDigest
141 inputs_ = new HashMap<Integer, Vector<String>>();
142 java_calcid_to_smlcalcid_ = new HashMap<>();
146 * Buffers input sent to the sml-Kernel (for later possible restart)
149 * calcTree this input belongs to
153 public void bufferInput(int javaCalcID, String input) {
154 Vector<String> v = (Vector<String>) inputs_.get(new Integer(javaCalcID));
157 inputs_.put(new Integer(javaCalcID), v);
162 // '@calcid@' is a placeholder for the CalcID
163 // this method replaces it with a real CalcID
164 private String insertCalcID(int id, String s) {
165 return s.replaceAll("@calcid@", String.valueOf(id));
168 // return smallest integer which is not yet
169 // used as a (java)CalcID
170 private int smallestFreeCalcID() {
171 Set<?> set = java_calcid_to_smlcalcid_.keySet();
172 for (int i = 0; i < set.size(); i++) {
173 if (!set.contains(new Integer(i))) {
181 * Send a sml instruction to the kernel. restore == true, if the instruction
182 * is resent after the kernel crashed
184 private ResponseWrapper sendToKernel(String smlInstr, boolean restore) {
185 if (logger.isDebugEnabled())
186 logger.debug(" BR->KN: sendToKernel(" + smlInstr + ")");
187 ResponseWrapper wrapper = null;
188 //bridge.log(1,"---sendToKernel |
189 //bridge.isRestoring=="+bridge.isRestoring());
190 //bridge.log(1,"---sendToKernel | restoring=="+restore);
191 if (!bridge_.isRestoring() || restore) {
192 String xmlString = "";
194 out_.println(smlInstr);// send the sml Instruction to the sml Kernel
196 xmlString = in_.readLine();//read the response from the kernel
197 if (logger.isInfoEnabled())
198 logger.info(" BR<-KN: sendToKernel <- xml= " + xmlString);
199 } catch (IOException e) {
200 bridge_.log(1, "BridgeRMI.interpretSKN: IOException");
203 //if (!(restore) && bridge.isRestoring()) {
204 // this.restoreExistingCalcTrees();
207 bridge_.log( 1, xmlString );
208 wrapper = xml_parser_digest_.parse(xmlString);
214 * Send an instruction to the SML-Kernel and return the response
218 * @return response from SML-Kernel
220 private synchronized ResponseWrapper interpretSML(int javaCalcID,
221 String instr, boolean restore) {
224 Integer smlCalcInteger = (Integer) java_calcid_to_smlcalcid_.get(new Integer(javaCalcID));
225 if( smlCalcInteger == null ) {
226 bridge_.log(1, "smlCalcInteger is null for javaCalcID : " + javaCalcID );
230 smlCalcID = smlCalcInteger.intValue();
231 String smlInstr = insertCalcID(smlCalcID, instr);
232 bridge_.log(1, "JavaCalcID " + javaCalcID + " == SmlCalcID "
234 bridge_.log(1, "sent to bridge: " + smlInstr);
235 ResponseWrapper wrapper = this.sendToKernel(smlInstr, restore);
237 bufferInput(javaCalcID, smlInstr);
241 private void rmiBind() {
242 if (logger.isDebugEnabled())
243 logger.debug("rmiBind");
244 if (System.getSecurityManager() == null) {
245 System.setSecurityManager(new RMISecurityManager());
248 String name = "//" + host_ + "/BridgeRMI";
250 System.out.println("try to bind as " + name);
251 Naming.rebind(name, this);
252 System.out.println("Bridge RMI bound to " + name);
253 } catch (java.rmi.ConnectException e) {
254 System.err.println("failed to contact as " + name + " (creating RMI-Server on localhost: 1099)");
256 LocateRegistry.createRegistry(1097);
257 // LocateRegistry.createRegistry(1099);
258 } catch (java.rmi.RemoteException exc2) {
259 System.err.println("can not create registry: " + exc2.getMessage());
263 } catch (RemoteException e) {
264 System.err.println("RemoteException");
265 System.err.println(e.getMessage());
266 System.err.println(e.getCause().getMessage());
267 System.err.println(e.getCause().getClass());
271 } catch (MalformedURLException e) {
272 System.err.println(e.getMessage());
276 } catch (Exception e) {
277 System.err.println("----------- Exception");
278 System.err.println(e.getClass().getName());
279 System.err.println(e.getMessage());
287 * Restore a saved calcTree.
290 * Vector containing strings
291 * @return Java CalcTreeID (not SML-ID)
293 public int loadCalcTree(Vector v) {
294 this.bridge_.log(1, "----------------begin loading------------");
295 int javaCalcID = smallestFreeCalcID();
296 this.bridge_.log(1, "-----smallest free = " + javaCalcID);
297 restoreToSML(javaCalcID, v);
298 this.bridge_.log(1, "----------------done loading-------------");
302 public int smlCalcIDtoJavaCalcID(int smlID) {
303 Iterator<?> it = java_calcid_to_smlcalcid_.keySet().iterator();
304 while (it.hasNext()) {
305 Object key = it.next();
306 Integer value = (Integer) java_calcid_to_smlcalcid_.get(key);
307 if (value.intValue() == smlID) {
308 return ((Integer) key).intValue();
314 public Map<?, Vector<String>> getInputs() {
318 public int getRmiID() {
322 public void setRmiID(int i) {
323 if (logger.isDebugEnabled())
324 logger.debug("setRmiID: i=" + i);
329 * causes a CalcChanged event for the first line on the Worksheet
332 * for the CalcTree (unused)
333 * @return CalcChanged with Iterators pointing at the root of the CalcTree
335 public CChanged startCalculate(int id) {
336 Position p = new Position();
337 p.setKind("Pbl");// toSMLString --> ([],"Pbl")
338 CChanged cc = new CChanged();
339 cc.setLastUnchanged(p);
340 cc.setLastDeleted(p);
341 cc.setLastGenerated(p);
346 * Starts the specifying phase: fill the calcTree with the appropriate
347 * information. Once the calc_head_ is fully specified, the user can begin
348 * with the actual calculation.
351 * Formalization for this calculation (empty if user starts a
352 * complete new calculation)
355 public int getCalcTree(Formalization formalization) {
357 int javaCalcID = smallestFreeCalcID();
358 this.bridge_.log(1, "-----smallest free javaCalcID = " + javaCalcID);
359 newCalculation(javaCalcID,
360 "CalcTree " + formalization.toSMLString() + ";", formalization, false);
361 return_val = javaCalcID;
365 /***********************************************************************
366 * Below are all the methods in structure Math_Engine : MATH_ENGINE
367 * listed in the same order as in the signature.
368 * The previous order still reflected original development;
369 * method names reflect the original struggle at the
370 * interface Java <--> Isabelle/Isac: different names are made explicit.
373 /** MATH_ENGINE: val appendFormula : calcID -> cterm' -> XML.tree */
374 public CEvent appendFormula(int id, CalcFormula f) {
375 CEvent return_val = null;
376 int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(id));
377 /*---------------------------------------------------------------------------*/
378 //*TTY*/ResponseWrapper wrapper = null;
379 //*TTY*/wrapper = interpretSML(id, "appendFormula @calcid@ \"" + f.toSMLString() + "\";", false);
380 //*TTY*/if (wrapper == null) return null;
381 //*TTY*/return_val = (CEvent) wrapper.getResponse();
382 /*---------------------------------------------------------------------------*/
383 /*PIDE*/bridge_.log(1, "-->ISA: " + "appendFormula " + sml_id + " \"" + f.toSMLString() + "\";");
384 /*PIDE*/XML.Tree xml_in = JavaToIsa.append_form(new scala.math.BigInt(BigInteger.valueOf(sml_id)), f.getFormula());
385 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
386 /*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(IsacOperations.APPEND_FORM, xml_in);
388 /*PIDE*/IntCEvent java_out = null;
389 /*PIDE*/if (!IsaToJava.is_message(xml_out)) java_out = IsaToJava.append_form_out(xml_out);
390 /*PIDE*/// else: no message handling by DialogGuide
391 /*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
392 /*PIDE*/return_val = java_out.getCEvent();
393 /*---------------------------------------------------------------------------*/
397 /** MATH_ENGINE: val autoCalculate : calcID -> auto -> XML.tree */
398 public CEvent autoCalculate(int id, int scope, int steps) {
399 if (logger.isDebugEnabled())
400 logger.debug("BridgeRMI#autoCalculate: id=" + id + ", scope" + scope + ", steps" + steps);
401 CEvent return_val = null;
402 int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(id));
404 /*---------------------------------------------------------------------------*/
405 //*TTY*/if ((scope == 3) && (steps == 0)) { //scope ==3 means IToCalc.SCOPE_CALCHEAD:
406 //*TTY*/ wrapper = interpretSML(id, "autoCalculate @calcid@ CompleteCalcHead;", false);
407 //*TTY*/} else if ((scope == IToCalc.SCOPE_CALCULATION) && (steps == 0)) {
408 //*TTY*/ wrapper = interpretSML(id, "autoCalculate @calcid@ CompleteCalc;", false);
409 //*TTY*/} else if ((scope == IToCalc.SCOPE_MODEL) && (steps == 0)) {
410 //*TTY*/ wrapper = interpretSML(id, "autoCalculate @calcid@ CompleteModel;", false);
411 //*TTY*/} else if ((scope == IToCalc.SCOPE_SUBCALCULATION) && (steps == 0)) {
412 //*TTY*/ wrapper = interpretSML(id, "autoCalculate @calcid@ CompleteToSubpbl;", false);
413 //*TTY*/} else if ((scope == IToCalc.SCOPE_SUBPROBLEM) && (steps == 0)) {
414 //*TTY*/ wrapper = interpretSML(id, "autoCalculate @calcid@ CompleteSubpbl;", false);
415 //*TTY*/} else { //FIXXXME040624: steps do not regard the scope
416 //*TTY*/ wrapper = interpretSML(id, "autoCalculate @calcid@ (Step " + steps + ");", false);
418 //*TTY*/if (wrapper == null) return_val = null;
419 //*TTY*/return_val = (CEvent) wrapper.getResponse();
420 //-----------------------------------------------------------------------------
421 /*PIDE*/String scope_str;
422 /*PIDE*/if ((scope == 3) && (steps == 0)) { //scope ==3 means IToCalc.SCOPE_CALCHEAD:
423 /*PIDE*/ scope_str = "CompleteCalcHead"; //FIXXXME.WN040624 steps == 0 hides mismatch in specifications
424 /*PIDE*/} else if ((scope == IToCalc.SCOPE_CALCULATION) && (steps == 0)) {
425 /*PIDE*/ scope_str = "CompleteCalc";
426 /*PIDE*/} else if ((scope == IToCalc.SCOPE_MODEL) && (steps == 0)) {
427 /*PIDE*/ scope_str = "CompleteModel";
428 /*PIDE*/} else if ((scope == IToCalc.SCOPE_SUBCALCULATION) && (steps == 0)) {
429 /*PIDE*/ scope_str = "CompleteToSubpbl";
430 /*PIDE*/} else if ((scope == IToCalc.SCOPE_SUBPROBLEM) && (steps == 0)) {
431 /*PIDE*/ scope_str = "CompleteSubpbl";
432 /*PIDE*/} else { //FIXXXME040624: steps do not regard the scope
433 /*PIDE*/ scope_str = "Step"; // steps > 0 according to impl.in "isabelle tty"
435 /*PIDE*/if (steps == 0) log_str = scope_str; else log_str = "(Step " + steps + ")";
436 /*PIDE*/bridge_.log(1, "-->ISA: " + "autoCalculate " + sml_id + " " + log_str + ";");
438 /*PIDE*/XML.Tree xml_in = JavaToIsa.auto_calculate(new scala.math.BigInt(BigInteger.valueOf(sml_id)),
439 /*PIDE*/ scope_str, new scala.math.BigInt(BigInteger.valueOf(steps)));
440 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
441 /*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(IsacOperations.AUTO_CALC, xml_in);
443 /*PIDE*/IntCEvent java_out = null;
444 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
445 /*PIDE*/ java_out = IsaToJava.auto_calc_out(xml_out);
446 /*PIDE*/ return_val = java_out.getCEvent();
447 /*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
449 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);
450 /*---------------------------------------------------------------------------*/
454 /** MATH_ENGINE: val applyTactic : calcID -> pos' -> tac -> XML.tree
455 * not implemented in Math_Engine.
456 * compare setNextTactic. */
459 * Starts a new calculation in the sml-Kernel: i.e. a new CalcTree with the
463 * "CalcTree" + Formalization in string Representation
465 * @return sml_calcid //WN150817 why return SML(?!) calcid to Java(?!)
467 * MATH_ENGINE: val CalcTree : fmz list -> XML.tree
469 private synchronized int newCalculation(int javaCalcID, String instr,
470 Formalization fmz, boolean restore) {
472 if (logger.isDebugEnabled())
473 logger.debug("newCalculation: javaCalcID=" + javaCalcID + ", instr" + instr + ", restore=" + restore);
476 /*---------------------------------------------------------------------------*/
477 //*TTY*/bridge_.log(1, "new calculation: " + instr);
478 //*TTY*/ResponseWrapper wrapper = sendToKernel(instr, restore);
479 //*TTY*/if (wrapper == null) return -1;
480 //*TTY*/sml_calcid = wrapper.getCalcID();
481 //*TTY*/sendToKernel("Iterator " + sml_calcid + ";", restore);//WN041209 no
482 //*TTY*/sendToKernel("moveActiveRoot " + sml_calcid + ";", restore);//WN041209
483 //*TTY*/if (!restore) bufferInput(javaCalcID, instr);
484 /*---------------------------------------------------------------------------*/
485 /*PIDE*/bridge_.log(1, "-->ISA: " + instr);
486 /*PIDE*/bridge_.log(1, "-->ISA: " + DataTypes.xml_of_Formalization(fmz));
487 /*PIDE*/XML.Tree CALC_TREE_out = connection_to_kernel_.invoke(IsacOperations.CALC_TREE,
488 /*PIDE*/ DataTypes.xml_of_Formalization(fmz));
489 /*PIDE*/bridge_.log(1, "<--ISA: " + CALC_TREE_out);
490 /*PIDE*/sml_calcid = (IsaToJava.calc_tree_out(CALC_TREE_out)).intValue();
492 /*PIDE*/bridge_.log(1, "-->ISA: " + "Iterator " + sml_calcid + ";");
493 /*PIDE*/XML.Tree ITERATOR_out = connection_to_kernel_.invoke(IsacOperations.ITERATOR,
494 /*PIDE*/ new scala.math.BigInt(BigInteger.valueOf(sml_calcid)));
495 /*PIDE*/IntIntCompound int_int = IsaToJava.iterator_out(ITERATOR_out);
496 /*PIDE*/sml_calcid = int_int.getCalcId().intValue();
497 int_int.getUserId().intValue();
498 /*PIDE*/bridge_.log(1, "<--ISA: " + ITERATOR_out);
500 /*PIDE*/bridge_.log(1, "-->ISA: " + "moveActiveRoot " + sml_calcid + ";");
501 /*PIDE*/XML.Tree MOVE_ACTIVE_ROOT_out = connection_to_kernel_.invoke(IsacOperations.MOVE_ACTIVE_ROOT,
502 /*PIDE*/ new scala.math.BigInt(BigInteger.valueOf(sml_calcid)));
503 /*PIDE*/IntPosition calcid_pos = IsaToJava.move_active_root_out(MOVE_ACTIVE_ROOT_out);
504 /*PIDE*/return_val = calcid_pos.getCalcId();
505 calcid_pos.getPosition();
506 /*PIDE*/bridge_.log(1, "<--ISA: " + MOVE_ACTIVE_ROOT_out);
507 /*---------------------------------------------------------------------------*/
508 java_calcid_to_smlcalcid_.put(new Integer(javaCalcID), new Integer(sml_calcid));
509 return_val = sml_calcid; //WN150808 SML_caldid --> JAVA frontend ?!?
513 /** MATH_ENGINE: val checkContext : calcID -> pos' -> guh -> XML.tree */
514 public Context checkContext(int javaCalcID, Context context, Position pos) throws RemoteException {
515 Context return_val = null;
516 /*---------------------------------------------------------------------------*/
517 //*TTY*/ResponseWrapper wrapper = interpretSML(javaCalcID,
518 //*TTY*/ "checkContext @calcid@ " + pos.toSMLString() + " \"" + context.getKEStoreKey().toString() + "\";", false);
519 //*TTY*/if(wrapper == null) return null;
520 //*TTY*/return_val = (Context) wrapper.getResponse();
521 /*---------------------------------------------------------------------------*/
522 /*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(javaCalcID));
523 /*PIDE*/bridge_.log(1, "-->ISA: " + "checkContext " + sml_id + " " + pos.toSMLString() + " \"" + context.getKEStoreKey().toString() + "\";");
525 /*PIDE*/XML.Tree xml_in = JavaToIsa.check_ctxt(new scala.math.BigInt(BigInteger.valueOf(sml_id)),
526 /*PIDE*/ pos, context.getKEStoreKey().toString() + "\"");
527 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
528 /*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(IsacOperations.CHECK_CTXT, xml_in);
530 /*PIDE*/ContextTheory java_out = null;
531 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
532 /*PIDE*/ java_out = IsaToJava.check_ctxt_out(xml_out);
533 /*PIDE*/ return_val = java_out;
534 /*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
536 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);
537 /*---------------------------------------------------------------------------*/
541 /** MATH_ENGINE: val DEconstrCalcTree : calcID -> XML.tree */
542 public boolean destruct(int javaCalcID) {
544 /*---------------------------------------------------------------------------*/
545 //*TTY*/ResponseWrapper wrapper = interpretSML(javaCalcID,
546 //*TTY*/ "DEconstrCalcTree @calcid@;", false);
547 //*TTY*/if (wrapper == null) { return_val = false; }
548 //*TTY*/inputs_.remove(new Integer(javaCalcID));
549 //*TTY*/return_val = true;
550 /*---------------------------------------------------------------------------*/
551 /*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(javaCalcID));
552 /*PIDE*/bridge_.log(1, "-->ISA: " + "DEconstrCalcTree " + sml_id);
553 /*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(IsacOperations.DEL_CALC,
554 /*PIDE*/ new scala.math.BigInt(BigInteger.valueOf(sml_id)));
556 IsaToJava.del_calc_out(xml_out);
557 /*PIDE*/return_val = true;
558 /*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
559 /*---------------------------------------------------------------------------*/
560 java_calcid_to_smlcalcid_.remove(new Integer(javaCalcID));
564 /** MATH_ENGINE: val fetchApplicableTactics : calcID -> int -> pos' -> XML.tree */
565 public Vector<Tactic> getAppliableTactics(int id, int scope, Position pos) {
566 Vector<Tactic> return_val = null;
567 /*---------------------------------------------------------------------------*/
568 //*TTY*/ResponseWrapper wrapper = interpretSML(id,
569 //*TTY*/ "fetchApplicableTactics @calcid@ " + scope + pos.toSMLString() + ";", false);
570 //*TTY*/if (wrapper == null) return null;
571 //*TTY*/TacticsContainer tc = (TacticsContainer) wrapper.getResponse();
572 //*TTY*/if( tc == null ) return null;
573 //*TTY*/return_val = tc.getTactics();
574 /*---------------------------------------------------------------------------*/
575 /*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(id));
576 /*PIDE*/bridge_.log(1, "-->ISA: " + "fetchApplicableTactics " + sml_id + " " + scope + pos.toSMLString() + ";");
578 /*PIDE*/XML.Tree xml_in = JavaToIsa.fetch_applicable_tacs(new scala.math.BigInt(BigInteger.valueOf(sml_id)),
579 /*PIDE*/ new scala.math.BigInt(BigInteger.valueOf(scope)), pos);
580 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
581 /*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(IsacOperations.FETCH_APPL_TACS, xml_in);
583 /*PIDE*/IntTactics java_out = null;
584 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
585 /*PIDE*/ java_out = IsaToJava.fetch_applicable_tacs_out(xml_out);
586 /*PIDE*/ return_val = java_out.getTactics();
587 /*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
589 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);
590 /*---------------------------------------------------------------------------*/
594 /** MATH_ENGINE: val fetchProposedTactic : calcID -> XML.tree */
595 public Tactic fetchProposedTactic(int id) {
596 Tactic return_val = null;
597 /*---------------------------------------------------------------------------*/
598 //*TTY*/ResponseWrapper wrapper = interpretSML(id, "fetchProposedTactic @calcid@;", false);
599 //*TTY*/if (wrapper == null) { return null; }
600 //*TTY*/return_val = (Tactic) wrapper.getResponse();
601 /*---------------------------------------------------------------------------*/
602 /*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(id));
603 /*PIDE*/bridge_.log(1, "-->ISA: " + "fetchProposedTactic " + sml_id + ";");
605 /*PIDE*/XML.Tree xml_in = JavaToIsa.fetch_proposed_tac(new scala.math.BigInt(BigInteger.valueOf(sml_id)));
606 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
607 /*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(IsacOperations.FETCH_PROP_TAC, xml_in);
609 /*PIDE*/IntTacticErrPats java_out = null;
610 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
611 /*PIDE*/ java_out = IsaToJava.fetch_proposed_tac_out(xml_out);
612 /*PIDE*/ return_val = java_out.getTactic();
613 /*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
615 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);
616 /*---------------------------------------------------------------------------*/
620 /** MATH_ENGINE: val findFillpatterns : calcID -> errpatID -> XML.tree
621 * only implemented in Math_Engine */
624 * @see isac.bridge.IBridgeRMI#getAccumulatedAssumptions(int,
625 * isac.util.formulae.Position)
627 * ** MATH_ENGINE: val getAccumulatedAsms : calcID -> pos' -> XML.tree
629 public Assumptions getAccumulatedAssumptions(int calcTreeID, Position pos) throws RemoteException {
630 Assumptions return_val = null;
631 /*---------------------------------------------------------------------------*/
632 //*TTY*/ResponseWrapper wrapper = interpretSML(calcTreeID,
633 //*TTY*/ "getAccumulatedAsms @calcid@ " + pos.toSMLString() + ";", false);
634 //*TTY*/return_val = (Assumptions) wrapper.getResponse();
635 /*---------------------------------------------------------------------------*/
636 /*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(calcTreeID));
637 /*PIDE*/bridge_.log(1, "-->ISA: " + "getAccumulatedAsms " + sml_id + " " + pos.toSMLString() + ";");
639 /*PIDE*/XML.Tree xml_in = JavaToIsa.get_accumulated_asms(new scala.math.BigInt(BigInteger.valueOf(sml_id)), pos);
640 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
641 /*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(IsacOperations.GET_ACC_ASMS, xml_in);
643 /*PIDE*/IntAssumptions java_out = null;
644 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
645 /*PIDE*/ java_out = IsaToJava.get_accumulated_asms_out(xml_out);
646 /*PIDE*/ return_val = java_out.getAssumptions();
647 /*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
649 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);
650 /*---------------------------------------------------------------------------*/
654 /** MATH_ENGINE: val getActiveFormula : calcID -> XML.tree */
655 public Position getActiveFormula(int javaCalcID) {
656 Position return_val = null;
657 /*---------------------------------------------------------------------------*/
658 //*TTY*/ResponseWrapper wrapper = interpretSML(javaCalcID,
659 //*TTY*/ "getActiveFormula @calcid@ ;", false);
660 //*TTY*/return_val = moveSuccess(wrapper);
661 /*---------------------------------------------------------------------------*/
662 /*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(javaCalcID));
663 /*PIDE*/bridge_.log(1, "-->ISA: " + "getActiveFormula " + sml_id + " ;");
665 /*PIDE*/XML.Tree xml_in = JavaToIsa.get_active_form(new scala.math.BigInt(BigInteger.valueOf(sml_id)));
666 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
667 /*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(IsacOperations.GET_ACTIVE_FORM, xml_in);
669 /*PIDE*/IntPosition java_out = null;
670 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
671 /*PIDE*/ java_out = IsaToJava.get_active_form_out(xml_out);
672 /*PIDE*/ return_val = java_out.getPosition();
673 /*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
675 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);
676 /*---------------------------------------------------------------------------*/
681 * @see isac.bridge.IBridgeRMI#getAssumption(int, int)
683 * MATH_ENGINE: val getAssumptions : calcID -> pos' -> XML.tree
685 public Assumptions getAssumptions(int calcTreeID, Position pos) throws RemoteException {
686 Assumptions return_val = null;
687 /*---------------------------------------------------------------------------*/
688 //*TTY*/ResponseWrapper wrapper = interpretSML(calcTreeID,
689 //*TTY*/ "getAssumptions @calcid@ " + pos.toSMLString() + ";", false);
690 //*TTY*/return_val = (Assumptions) wrapper.getResponse();
691 /*---------------------------------------------------------------------------*/
692 /*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(calcTreeID));
693 /*PIDE*/bridge_.log(1, "-->ISA: " + "getAssumptions " + sml_id + " " + pos.toSMLString() + ";");
695 /*PIDE*/XML.Tree xml_in = JavaToIsa.get_asms(new scala.math.BigInt(BigInteger.valueOf(sml_id)), pos);
696 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
697 /*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(IsacOperations.GET_ASMS, xml_in);
699 /*PIDE*/IntAssumptions java_out = null;
700 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
701 /*PIDE*/ java_out = IsaToJava.get_asms_out(xml_out);
702 /*PIDE*/ return_val = java_out.getAssumptions();
703 /*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
705 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);
706 /*---------------------------------------------------------------------------*/
710 /** MATH_ENGINE: val getFormulaeFromTo : calcID -> pos' -> pos' -> int -> bool -> XML.tree */
711 public Vector<CalcFormula> getFormulaeFromTo(int id, ICalcIterator iterator_from,
712 ICalcIterator iterator_to, Integer level, boolean result_includes_tactics) {
713 XML.Tree xml_in = null;
714 Vector<CalcFormula> return_val = null;
715 /*---------------------------------------------------------------------------*/
716 //*TTY*/try { wrapper = interpretSML(id, "getFormulaeFromTo @calcid@ "
717 //*TTY*/ + iterator_from.toSMLString() + " " + iterator_to.toSMLString()
718 //*TTY*/ + " " + level + " " + result_includes_tactics + ";", false);
719 //*TTY*/} catch (RemoteException e) { e.printStackTrace(); }
720 //*TTY*/if (wrapper == null) return null;
721 //*TTY*/FormHeadsContainer con = (FormHeadsContainer) wrapper.getResponse();
722 //*TTY*/if (con != null) return_val = con.getElements();
723 //*TTY*/else return_val = null;
724 /*---------------------------------------------------------------------------*/
725 /*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(id));
727 /*PIDE*/ bridge_.log(1, "-->ISA: " + "getFormulaeFromTo " + sml_id + " "
728 /*PIDE*/ + iterator_from.toSMLString() + " " + iterator_to.toSMLString()
729 /*PIDE*/ + " " + level + " " + result_includes_tactics + ";");
730 /*PIDE*/} catch (RemoteException e2) { e2.printStackTrace(); }
733 /*PIDE*/ xml_in = JavaToIsa.get_formulae(new scala.math.BigInt(BigInteger.valueOf(sml_id)),
734 /*PIDE*/ iterator_from.getPosition(), iterator_to.getPosition(),
735 /*PIDE*/ new scala.math.BigInt(BigInteger.valueOf(level)), result_includes_tactics);
736 /*PIDE*/} catch (RemoteException e1) { e1.printStackTrace(); }
737 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
738 /*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(IsacOperations.GET_FORMULAE, xml_in);
740 /*PIDE*/IntFormulas java_out = null;
741 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
742 /*PIDE*/ java_out = IsaToJava.get_formulae_out(xml_out);
743 /*PIDE*/ return_val = java_out.getCalcFormulas();
744 /*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
746 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);
747 /*---------------------------------------------------------------------------*/
752 * @see isac.bridge.IBridgeRMI#getTactic(int, int)
754 * MATH_ENGINE: val getTactic : calcID -> pos' -> XML.tree
756 public Tactic getTactic(int calcTreeID, Position pos) throws RemoteException {
757 Tactic return_val = null;
758 /*---------------------------------------------------------------------------*/
759 //*TTY*/ResponseWrapper wrapper = interpretSML(calcTreeID,
760 //*TTY*/ "getTactic @calcid@ " + pos.toSMLString() + ";", false);
761 //*TTY*/return_val = (Tactic) wrapper.getResponse();
762 /*---------------------------------------------------------------------------*/
763 /*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(calcTreeID));
764 /*PIDE*/bridge_.log(1, "-->ISA: " + "getTactic " + sml_id + " " + pos.toSMLString() + ";");
766 /*PIDE*/XML.Tree xml_in = JavaToIsa.get_tac(new scala.math.BigInt(BigInteger.valueOf(sml_id)), pos);
767 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
768 /*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(IsacOperations.GET_TAC, xml_in);
770 /*PIDE*/IntTactic java_out = null;
771 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
772 /*PIDE*/ java_out = IsaToJava.get_tac_out(xml_out);
773 /*PIDE*/ return_val = java_out.getTactic();
774 /*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
776 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);
777 /*---------------------------------------------------------------------------*/
781 /** MATH_ENGINE: val initContext : calcID -> ketype -> pos' -> XML.tree
783 * This method is implemented in Isabelle/Isac, but seems to never have been completed in Java.
784 * See isac.bridge.TestContext#testContext.
786 public Context initContext(int javaCalcID, ContextType type, Position pos) throws RemoteException {
787 Context return_val = null;
788 /*---------------------------------------------------------------------------*/
789 //*TTY*/ResponseWrapper wrapper = interpretSML(javaCalcID,
790 //*TTY*/ "initContext @calcid@ " + type.toSMLString() + " " + pos.toSMLString() + ";", false);
791 //*TTY*/if(wrapper == null) return null;
792 //*TTY*/return_val = (Context) wrapper.getResponse();
793 /*---------------------------------------------------------------------------*/
794 /*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(javaCalcID));
795 /*PIDE*/bridge_.log(1, "-->ISA: " + "initContext " + sml_id + " " + type.toSMLString() + " " + pos.toSMLString() + ";");
797 /*PIDE*/XML.Tree xml_in = JavaToIsa.init_ctxt(new scala.math.BigInt(BigInteger.valueOf(sml_id)), type, pos);
798 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
799 /*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(IsacOperations.INIT_CTXT, xml_in);
801 /*PIDE*/Context java_out = null; // front-end later distinguishes ContextTheory, ContextProblem, ..
802 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
803 /*PIDE*/ java_out = (Context) IsaToJava.init_ctxt_out(xml_out);
804 /*PIDE*/ return_val = java_out;
805 /*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
807 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);
808 /*---------------------------------------------------------------------------*/
812 /** MATH_ENGINE: val inputFillFormula: calcID -> string -> XML.tree
813 * only implemented in Math_Engine */
815 /** MATH_ENGINE: val interSteps : calcID -> pos' -> XML.tree */
816 public CEvent intermediateSteps(int id, ICalcIterator ci) {
817 CEvent return_val = null;
818 /*---------------------------------------------------------------------------*/
819 //*TTY*/ResponseWrapper wrapper = null;
821 //*TTY*/ wrapper = interpretSML(id, "interSteps @calcid@ " + ci.toSMLString() + ";", false);
822 //*TTY*/} catch (RemoteException e) { e.printStackTrace(); }
823 //*TTY*/if (wrapper == null) return null;
824 //*TTY*/return_val = (CEvent) wrapper.getResponse();
825 /*---------------------------------------------------------------------------*/
826 /*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(id));
827 /*PIDE*/XML.Tree xml_in = null;
829 /*PIDE*/ bridge_.log(1, "-->ISA: " + "interSteps " + sml_id + " " + ci.toSMLString() + ";");
830 /*PIDE*/} catch (RemoteException e1) { e1.printStackTrace(); }
833 /*PIDE*/ xml_in = JavaToIsa.inter_steps(new scala.math.BigInt(BigInteger.valueOf(sml_id)), ci.getPosition());
834 /*PIDE*/} catch (Exception e1) { e1.printStackTrace();}
835 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
836 /*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(IsacOperations.INTER_STEPS, xml_in);
838 /*PIDE*/IntCEvent java_out = null;
839 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
840 /*PIDE*/ java_out = IsaToJava.inter_steps_out(xml_out);
841 /*PIDE*/ return_val = java_out.getCEvent();
842 /*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
844 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);
845 /*---------------------------------------------------------------------------*/
849 /** MATH_ENGINE: val Iterator : calcID -> XML.tree */
850 public int iterator(int id) {
851 if (logger.isDebugEnabled())
852 logger.debug("iterator: id=" + id);
853 int return_val = 4711;
854 /*---------------------------------------------------------------------------*/
855 //*TTY*/if (id == 1) {
856 //*TTY*/ ResponseWrapper wrapper = interpretSML(id, "Iterator @calcid@;", false);
857 //*TTY*/ if (wrapper == null) return_val = -1;
858 //*TTY*/ else return_val = Integer.parseInt(((CalcHeadSimpleID) wrapper .getResponse()).getID());
859 //*TTY*/} else return_val = 4711;//TODO.WN041208 drop CalcIterator.iteratorID_
860 /*---------------------------------------------------------------------------*/
861 /*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(id));
862 /*PIDE*/bridge_.log(1, "-->ISA: " + "Iterator " + sml_id + ";");
864 /*PIDE*/BigInt xml_in = new scala.math.BigInt(BigInteger.valueOf(sml_id));
865 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
866 /*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(IsacOperations.ITERATOR, xml_in);
868 /*PIDE*/IntIntCompound java_out = null;
869 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
870 /*PIDE*/ java_out = IsaToJava.iterator_out(xml_out);
871 /*PIDE*/ return_val = java_out.getCalcId().intValue();
872 /*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
874 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);
875 /*---------------------------------------------------------------------------*/
880 * @see isac.interfaces.IToCalc#modelProblem()
882 * MATH_ENGINE: val modelProblem : calcID -> XML.tree
884 public CalcHead modelProblem(int calc_tree_id) throws RemoteException {
885 CalcHead return_val = null;
886 /*---------------------------------------------------------------------------*/
887 //*TTY*/ResponseWrapper wrapper = interpretSML(calc_tree_id, "modelProblem @calcid@;", false);
888 //*TTY*/return_val = (CalcHead) wrapper.getResponse();
889 /*---------------------------------------------------------------------------*/
890 /*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(calc_tree_id));
891 /*PIDE*/bridge_.log(1, "-->ISA: " + "modelProblem " + sml_id + ";");
893 /*PIDE*/BigInt xml_in = new scala.math.BigInt(BigInteger.valueOf(sml_id));
894 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
895 /*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(IsacOperations.MODEL_PBL, xml_in);
897 /*PIDE*/IntCalcHead java_out = null;
898 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
899 /*PIDE*/ java_out = IsaToJava.modify_calchead_out(xml_out);
900 /*PIDE*/ return_val = java_out.getCalcHead();
901 /*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
903 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);
904 /*---------------------------------------------------------------------------*/
909 * @see isac.interfaces.IToCalc#checkCalcHead(isac.util.formulae.CalcHead)
911 * MATH_ENGINE: val modifyCalcHead : calcID -> icalhd -> XML.tree
913 public CalcHead checkCalcHead(int calc_tree_id, CalcHead calchead) throws RemoteException {
914 CalcHead return_val = null;
915 /*---------------------------------------------------------------------------*/
916 //*TTY*/ResponseWrapper wrapper = interpretSML(calc_tree_id,
917 //*TTY*/ "modifyCalcHead @calcid@ " + calchead.toSMLString() + ";", false);
918 //*TTY*/return_val = (CalcHead) wrapper.getResponse();
919 /*---------------------------------------------------------------------------*/
920 /*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(calc_tree_id));
921 /*PIDE*/bridge_.log(1, "-->ISA: " + "modelProblem " + sml_id + ";");
923 /*PIDE*/XML.Tree xml_in = JavaToIsa.modify_calchead(new scala.math.BigInt(BigInteger.valueOf(sml_id)), calchead);
924 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
925 /*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(IsacOperations.MODIFY_CALCHEAD, xml_in);
927 /*PIDE*/IntCalcHead java_out = null;
928 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
929 /*PIDE*/ java_out = IsaToJava.modify_calchead_out(xml_out);
930 /*PIDE*/ return_val = java_out.getCalcHead();
931 /*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
933 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);
934 /*---------------------------------------------------------------------------*/
938 /** MATH_ENGINE: val moveActiveCalcHead : calcID -> XML.tree */
939 public Position moveCalcHead(int javaCalcID, int iteratorID, Position p) {
940 Position return_val = null;
941 /*---------------------------------------------------------------------------*/
942 //*TTY*/ResponseWrapper wrapper = null;
943 //*TTY*/if (iteratorID == 1)
944 //*TTY*/ wrapper = interpretSML(javaCalcID, "moveActiveCalcHead @calcid@" + ";", false);
946 //*TTY*/ wrapper = interpretSML(javaCalcID, "moveCalcHead @calcid@ " + " " + p.toSMLString() + ";", false);
947 //*TTY*/return_val = moveSuccess(wrapper);
948 /*---------------------------------------------------------------------------*/
949 /*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(javaCalcID));
950 /*PIDE*/XML.Tree xml_in = null;
951 /*PIDE*/XML.Tree xml_out = null;
953 /*PIDE*/if (iteratorID == 1) {
954 /*PIDE*/bridge_.log(1, "-->ISA: " + "moveActiveCalcHead " + sml_id + "" + ";");
955 /*PIDE*/xml_in = JavaToIsa.move_active_calchead(new scala.math.BigInt(BigInteger.valueOf(sml_id)));
956 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
957 /*PIDE*/xml_out = connection_to_kernel_.invoke(IsacOperations.MOVE_ACTIVE_FORM, xml_in);
959 /*PIDE*/IntPosition java_out = null;
960 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
961 /*PIDE*/ java_out = IsaToJava.move_active_calchead_out(xml_out);
962 /*PIDE*/ return_val = java_out.getPosition();
963 /*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
965 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);
969 /*PIDE*/bridge_.log(1, "-->ISA: " + "moveCalcHead " + sml_id + " " + " " + p.toSMLString() + ";");
970 /*PIDE*/xml_in = JavaToIsa.move_calchead(new scala.math.BigInt(BigInteger.valueOf(sml_id)), null);
971 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
972 /*PIDE*/xml_out = connection_to_kernel_.invoke(IsacOperations.MOVE_ACTIVE_FORM, xml_in);
974 /*PIDE*/IntPosition java_out = null;
975 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
976 /*PIDE*/ java_out = IsaToJava.move_calchead_out(xml_out);
977 /*PIDE*/ return_val = java_out.getPosition();
978 /*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
980 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);
982 /*---------------------------------------------------------------------------*/
986 /** MATH_ENGINE: val moveActiveDown : calcID -> XML.tree */
987 public Position moveDown(int javaCalcID, int iteratorID, Position p) {
988 if (logger.isDebugEnabled())
989 logger.debug("moveDown: javaCalcID=" + javaCalcID + ", sml_pos=" + p.toSMLString());
990 Position return_val = null;
991 /*---------------------------------------------------------------------------*/
992 //*TTY*/ResponseWrapper wrapper = null;
993 //*TTY*/if (iteratorID == 1)
994 //*TTY*/ wrapper = interpretSML(javaCalcID, "moveActiveDown @calcid@" + ";", false);
996 //*TTY*/ wrapper = interpretSML(javaCalcID, "moveDown @calcid@ " + p.toSMLString() + ";", false);
997 //*TTY*/return_val = moveSuccess(wrapper);
998 /*---------------------------------------------------------------------------*/
999 /*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(javaCalcID));
1000 /*PIDE*/XML.Tree xml_in = null;
1001 /*PIDE*/XML.Tree xml_out = null;
1003 /*PIDE*/if (iteratorID == 1) {
1004 /*PIDE*/bridge_.log(1, "-->ISA: " + "moveActiveDown " + sml_id + "" + ";");
1005 /*PIDE*/xml_in = JavaToIsa.move_active_down(new scala.math.BigInt(BigInteger.valueOf(sml_id)));
1006 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
1007 /*PIDE*/xml_out = connection_to_kernel_.invoke(IsacOperations.MOVE_ACTIVE_DOWN, xml_in);
1009 /*PIDE*/IntPosition java_out = null;
1010 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
1011 /*PIDE*/ java_out = IsaToJava.move_active_down_out(xml_out);
1012 /*PIDE*/ return_val = java_out.getPosition();
1013 /*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
1015 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);
1019 /*PIDE*/bridge_.log(1, "-->ISA: " + "moveDown " + sml_id + " " + p.toSMLString() + ";");
1020 /*PIDE*/xml_in = JavaToIsa.move_down(new scala.math.BigInt(BigInteger.valueOf(sml_id)), p);
1021 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
1022 /*PIDE*/xml_out = connection_to_kernel_.invoke(IsacOperations.MOVE_DOWN, xml_in);
1024 /*PIDE*/IntPosition java_out = null;
1025 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
1026 /*PIDE*/ java_out = IsaToJava.move_down_out(xml_out);
1027 /*PIDE*/ return_val = java_out.getPosition();
1028 /*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
1030 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);
1032 /*---------------------------------------------------------------------------*/
1037 * returns Position for uniformity with move*; not required elsewhere
1039 * MATH_ENGINE: val moveActiveFormula : calcID -> pos' -> XML.tree
1041 public Position moveActiveFormula(int javaCalcID, Position p) {
1042 if (logger.isDebugEnabled())
1043 logger.debug("moveDown: javaCalcID=" + javaCalcID + ", sml_pos=" + p.toSMLString());
1044 Position return_val = null;
1045 /*---------------------------------------------------------------------------*/
1046 //*TTY*/ResponseWrapper wrapper = interpretSML(javaCalcID,
1047 //*TTY*/ "moveActiveFormula @calcid@ " + p.toSMLString() + ";", false);
1048 //*TTY*/return_val = moveSuccess(wrapper);
1049 /*---------------------------------------------------------------------------*/
1050 /*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(javaCalcID));
1051 /*PIDE*/bridge_.log(1, "-->ISA: " + "moveActiveFormula " + sml_id + " " + p.toSMLString() + ";");
1053 /*PIDE*/XML.Tree xml_in = JavaToIsa.move_active_form(new scala.math.BigInt(BigInteger.valueOf(sml_id)), p);
1054 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
1055 /*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(IsacOperations.MOVE_ACTIVE_FORM, xml_in);
1057 /*PIDE*/IntPosition java_out = null;
1058 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
1059 /*PIDE*/ java_out = IsaToJava.move_active_form_out(xml_out);
1060 /*PIDE*/ return_val = java_out.getPosition();
1061 /*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
1063 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);
1064 /*---------------------------------------------------------------------------*/
1068 /** MATH_ENGINE: val moveActiveLevelDown : calcID -> XML.tree */
1069 public Position moveLevelDown(int javaCalcID, int iteratorID, Position p) {
1070 Position return_val = null;
1071 /*---------------------------------------------------------------------------*/
1072 //*TTY*/ResponseWrapper wrapper = null;
1073 //*TTY*/if (iteratorID == 1)
1074 //*TTY*/ wrapper = interpretSML(javaCalcID, "moveActiveLevelDown @calcid@" + ";", false);
1076 //*TTY*/ wrapper = interpretSML(javaCalcID, "moveLevelDown @calcid@ " + " " + p.toSMLString() + ";", false);
1077 //*TTY*/return_val = moveSuccess(wrapper);
1078 /*---------------------------------------------------------------------------*/
1079 /*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(javaCalcID));
1080 /*PIDE*/XML.Tree xml_in = null;
1081 /*PIDE*/XML.Tree xml_out = null;
1083 /*PIDE*/if (iteratorID == 1) {
1084 /*PIDE*/bridge_.log(1, "-->ISA: " + "moveActiveLevelDown " + sml_id + "" + ";");
1085 /*PIDE*/xml_in = JavaToIsa.move_active_levdown(new scala.math.BigInt(BigInteger.valueOf(sml_id)));
1086 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
1087 /*PIDE*/xml_out = connection_to_kernel_.invoke(IsacOperations.MOVE_ACTIVE_LEVDN, xml_in);
1089 /*PIDE*/IntPosition java_out = null;
1090 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
1091 /*PIDE*/ java_out = IsaToJava.move_active_levdown_out(xml_out);
1092 /*PIDE*/ return_val = java_out.getPosition();
1093 /*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
1095 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);
1099 /*PIDE*/bridge_.log(1, "-->ISA: " + "moveLevelDown " + sml_id + " " + " " + p.toSMLString() + ";");
1100 /*PIDE*/xml_in = JavaToIsa.move_levdn(new scala.math.BigInt(BigInteger.valueOf(sml_id)), p);
1101 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
1102 /*PIDE*/xml_out = connection_to_kernel_.invoke(IsacOperations.MOVE_LEVDN, xml_in);
1104 /*PIDE*/IntPosition java_out = null;
1105 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
1106 /*PIDE*/ java_out = IsaToJava.move_levdn_out(xml_out);
1107 /*PIDE*/ return_val = java_out.getPosition();
1108 /*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
1110 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);
1112 /*---------------------------------------------------------------------------*/
1116 /** MATH_ENGINE: val moveActiveLevelUp : calcID -> XML.tree */
1117 public Position moveLevelUp(int javaCalcID, int iteratorID, Position p) {
1118 Position return_val = null;
1119 /*---------------------------------------------------------------------------*/
1120 //*TTY*/ResponseWrapper wrapper = null;
1121 //*TTY*/if (iteratorID == 1)
1122 //*TTY*/ wrapper = interpretSML(javaCalcID, "moveActiveLevelUp @calcid@" + ";", false);
1124 //*TTY*/ wrapper = interpretSML(javaCalcID, "moveLevelUp @calcid@ " + p.toSMLString() + ";", false);
1125 //*TTY*/return_val = moveSuccess(wrapper);
1126 /*---------------------------------------------------------------------------*/
1127 /*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(javaCalcID));
1128 /*PIDE*/XML.Tree xml_in = null;
1129 /*PIDE*/XML.Tree xml_out = null;
1131 /*PIDE*/if (iteratorID == 1) {
1132 /*PIDE*/bridge_.log(1, "-->ISA: " + "moveActiveLevelUp " + sml_id + "" + ";");
1133 /*PIDE*/xml_in = JavaToIsa.move_active_levup(new scala.math.BigInt(BigInteger.valueOf(sml_id)));
1134 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
1135 /*PIDE*/xml_out = connection_to_kernel_.invoke(IsacOperations.MOVE_ACTIVE_LEVUP, xml_in);
1136 /*PIDE*/xml_out = connection_to_kernel_.invoke(IsacOperations.MOVE_ACTIVE_FORM, xml_in);
1138 /*PIDE*/IntPosition java_out = null;
1139 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
1140 /*PIDE*/ java_out = IsaToJava.move_active_levup_out(xml_out);
1141 /*PIDE*/ return_val = java_out.getPosition();
1142 /*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
1144 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);
1148 /*PIDE*/bridge_.log(1, "-->ISA: " + "moveLevelUp " + sml_id + " " + p.toSMLString() + ";");
1149 /*PIDE*/xml_in = JavaToIsa.move_levup(new scala.math.BigInt(BigInteger.valueOf(sml_id)), p);
1150 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
1151 /*PIDE*/xml_out = connection_to_kernel_.invoke(IsacOperations.MOVE_LEVUP, xml_in);
1153 /*PIDE*/IntPosition java_out = null;
1154 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
1155 /*PIDE*/ java_out = IsaToJava.move_levup_out(xml_out);
1156 /*PIDE*/ return_val = java_out.getPosition();
1157 /*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
1159 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);
1161 /*---------------------------------------------------------------------------*/
1165 /** MATH_ENGINE: val moveActiveRoot : calcID -> XML.tree */
1166 public Position moveRoot(int javaCalcID, int iteratorID) {
1167 if (logger.isDebugEnabled())
1168 logger.debug("moveRoot: javaCalcID=" + javaCalcID);
1169 Position return_val = null;
1170 /*---------------------------------------------------------------------------*/
1171 //*TTY*/ResponseWrapper wrapper = null;
1172 //*TTY*/if (iteratorID == 1)
1173 //*TTY*/ wrapper = interpretSML(javaCalcID, "moveActiveRoot @calcid@" + ";", false);
1175 //*TTY*/ wrapper = interpretSML(javaCalcID, "moveRoot @calcid@ " + ";", false);
1176 //*TTY*/return_val = moveSuccess(wrapper);
1177 /*---------------------------------------------------------------------------*/
1178 /*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(javaCalcID));
1179 /*PIDE*/scala.math.BigInt xml_in = null;
1180 /*PIDE*/XML.Tree xml_out = null;
1182 /*PIDE*/if (iteratorID == 1) {
1183 /*PIDE*/bridge_.log(1, "-->ISA: " + "moveActiveRoot " + sml_id + "" + ";");
1184 /*PIDE*/xml_in = new scala.math.BigInt(BigInteger.valueOf(sml_id));
1185 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
1186 /*PIDE*/xml_out = connection_to_kernel_.invoke(IsacOperations.MOVE_ACTIVE_ROOT, xml_in);
1188 /*PIDE*/IntPosition java_out = null;
1189 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
1190 /*PIDE*/ java_out = IsaToJava.move_active_root_out(xml_out);
1191 /*PIDE*/ return_val = java_out.getPosition();
1192 /*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
1194 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);
1198 /*PIDE*/bridge_.log(1, "-->ISA: " + "moveRoot " + sml_id + " " + ";");
1199 /*PIDE*/XML.Tree xml_in2 = JavaToIsa.move_root(new scala.math.BigInt(BigInteger.valueOf(sml_id)));
1200 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in2);
1201 /*PIDE*/xml_out = connection_to_kernel_.invoke(IsacOperations.MOVE_ROOT, xml_in2);
1203 /*PIDE*/IntPosition java_out = null;
1204 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
1205 /*PIDE*/ java_out = IsaToJava.move_root_out(xml_out);
1206 /*PIDE*/ return_val = java_out.getPosition();
1207 /*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
1209 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);
1211 /*---------------------------------------------------------------------------*/
1215 /** MATH_ENGINE: val moveActiveRootTEST : calcID -> XML.tree
1216 * used only internally in Math_Engine */
1218 /** MATH_ENGINE: val moveActiveUp : calcID -> XML.tree */
1219 public Position moveUp(int javaCalcID, int iteratorID, Position p) {
1220 Position return_val = null;
1221 /*---------------------------------------------------------------------------*/
1222 //*TTY*/ResponseWrapper wrapper = null;
1223 //*TTY*/if (iteratorID == 1)
1224 //*TTY*/ wrapper = interpretSML(javaCalcID, "moveActiveUp @calcid@" + ";", false);
1226 //*TTY*/ wrapper = interpretSML(javaCalcID, "moveUp @calcid@ " + p.toSMLString() + ";", false);
1227 //*TTY*/return_val = moveSuccess(wrapper);
1228 /*---------------------------------------------------------------------------*/
1229 /*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(javaCalcID));
1230 /*PIDE*/XML.Tree xml_in = null;
1231 /*PIDE*/XML.Tree xml_out = null;
1233 /*PIDE*/if (iteratorID == 1) {
1234 /*PIDE*/xml_in = JavaToIsa.move_active_up(new scala.math.BigInt(BigInteger.valueOf(sml_id)));
1235 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
1236 /*PIDE*/xml_out = connection_to_kernel_.invoke(IsacOperations.MOVE_ACTIVE_UP, xml_in);
1238 /*PIDE*/IntPosition java_out = null;
1239 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
1240 /*PIDE*/ java_out = IsaToJava.move_active_calchead_out(xml_out);
1241 /*PIDE*/ return_val = java_out.getPosition();
1242 /*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
1244 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);
1248 /*PIDE*/bridge_.log(1, "-->ISA: " + "moveUp " + sml_id + " " + p.toSMLString() + ";");
1249 /*PIDE*/xml_in = JavaToIsa.move_up(new scala.math.BigInt(BigInteger.valueOf(sml_id)), p);
1250 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
1251 /*PIDE*/xml_out = connection_to_kernel_.invoke(IsacOperations.MOVE_UP, xml_in);
1253 /*PIDE*/IntPosition java_out = null;
1254 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
1255 /*PIDE*/ java_out = IsaToJava.move_calchead_out(xml_out);
1256 /*PIDE*/ return_val = java_out.getPosition();
1257 /*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
1259 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);
1261 /*---------------------------------------------------------------------------*/
1265 // /----- these methods are designed for a visitor of the CalcTree ------------\
1266 // (with a iteratorID > 1), e.g. a teacher watching the student.
1267 /** MATH_ENGINE: val moveCalcHead : calcID -> pos' -> XML.tree
1268 * does not exist in isac-java, see val moveActiveCalcHead */
1270 /** MATH_ENGINE: val moveDown : calcID -> pos' -> XML.tree
1271 * does not exist in isac-java, see val moveActiveDown */
1273 /** MATH_ENGINE: val val moveLevelDown : calcID -> pos' -> XML.tree
1274 * does not exist in isac-java, see val moveActiveLevelDown */
1276 /** MATH_ENGINE: val moveLevelUp : calcID -> pos' -> XML.tree
1277 * does not exist in isac-java, see val moveActiveLevelUp */
1279 /** MATH_ENGINE: val moveRoot : calcID -> XML.tree
1280 * does not exist in isac-java, see val moveActiveRoot */
1282 /** MATH_ENGINE: val moveUp : calcID -> pos' -> XML.tree
1283 * does not exist in isac-java, see val moveActiveUp */
1284 // \----- these methods are designed for a visitor of the CalcTree ------------/
1287 * @see isac.bridge.IBridgeRMI#getElement(int, int)
1288 * MATH_ENGINE: val refFormula : calcID -> pos' -> XML.tree
1290 public ICalcElement getElement(int javaCalcID, Position p) {
1291 ICalcElement return_val = null;
1292 /*---------------------------------------------------------------------------*/
1293 //*TTY*/ResponseWrapper wrapper = interpretSML(javaCalcID,
1294 //*TTY*/ "(*getElement*)refFormula @calcid@ " + p.toSMLString() + ";", false);
1295 //*TTY*/if (wrapper == null) return_val = null;
1296 //*TTY*/return_val = (ICalcElement) wrapper.getResponse();
1297 /*---------------------------------------------------------------------------*/
1298 /*PIDE*/int sml_calcid = ((Integer) java_calcid_to_smlcalcid_.get(new Integer(javaCalcID))).intValue();
1299 /*PIDE*/bridge_.log(1, "-->ISA: " + "(*getElement*)refFormula " + sml_calcid
1300 /*PIDE*/ + " " + p.toSMLString() + ";");
1302 /*PIDE*/XML.Tree xml_in = JavaToIsa.ref_formula(new scala.math.BigInt(BigInteger.valueOf(sml_calcid)), p);
1303 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
1304 /*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(IsacOperations.REF_FORMULA, xml_in);
1306 /*PIDE*/IntFormHead java_out = null;
1307 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
1308 /*PIDE*/ java_out = IsaToJava.ref_formula_out(xml_out);
1309 /*PIDE*/ return_val = (ICalcElement)java_out.getFormHead();
1310 /*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
1312 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);
1313 /*---------------------------------------------------------------------------*/
1317 /** MATH_ENGINE: val refineProblem : calcID -> pos' -> guh -> XML.tree
1318 * see notes WN150824 */
1319 public Context refineProblem(int javaCalcID, Context context, Position pos) throws RemoteException {
1320 Context return_val = null;
1321 /*---------------------------------------------------------------------------*/
1322 //*TTY*/ResponseWrapper wrapper = interpretSML(javaCalcID,
1323 //*TTY*/ "refineProblem @calcid@ " + pos.toSMLString() + " \"" + context.getKEStoreKey().toString() + "\";", false);
1324 //*TTY*/if(wrapper == null) return null;
1325 //*TTY*/return_val = (Context) wrapper.getResponse();
1326 /*---------------------------------------------------------------------------*/
1327 /*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(javaCalcID));
1328 /*PIDE*/bridge_.log(1, "-->ISA: " + "refineProblem " + sml_id + " " + pos.toSMLString() + " \"" + context.getKEStoreKey().toString() + "\";");
1330 /*PIDE*/XML.Tree xml_in = JavaToIsa.refine_pbl(new scala.math.BigInt(BigInteger.valueOf(sml_id)),
1331 /*PIDE*/ pos, context.getKEStoreKey().toString() + "\"");
1332 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
1333 /*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(IsacOperations.REFINE_PBL, xml_in);
1335 /*PIDE*/IntContext java_out = null;
1336 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
1337 /*PIDE*/ java_out = IsaToJava.refine_pbl_out(xml_out);
1338 /*PIDE*/ return_val = java_out.getContext();
1339 /*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
1341 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);
1342 /*---------------------------------------------------------------------------*/
1346 /** MATH_ENGINE: val replaceFormula : calcID -> cterm' -> XML.tree */
1347 public CEvent replaceFormula(int id, CalcFormula f) {
1348 CEvent return_val = null;
1349 /*---------------------------------------------------------------------------*/
1350 //*TTY*/ResponseWrapper wrapper = null;
1351 //*TTY*/wrapper = interpretSML(id, "replaceFormula @calcid@ \"" + f.toSMLString() + "\";", false);
1352 //*TTY*/if (wrapper == null) return_val = null;
1353 //*TTY*/else return_val = (CEvent) wrapper.getResponse();
1354 /*---------------------------------------------------------------------------*/
1355 /*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(id));
1356 /*PIDE*/bridge_.log(1, "-->ISA: " + "replaceFormula " + sml_id + " \"" + f.toSMLString() + "\";");
1358 /*PIDE*/XML.Tree xml_in = JavaToIsa.replace_form(new scala.math.BigInt(BigInteger.valueOf(sml_id)), f.getFormula());
1359 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
1360 /*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(IsacOperations.REPLACE_FORM, xml_in);
1362 /*PIDE*/IntCEvent java_out = null;
1363 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
1364 /*PIDE*/ java_out = IsaToJava.replace_form_out(xml_out);
1365 /*PIDE*/ return_val = java_out.getCEvent();
1366 /*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
1368 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);
1369 /*---------------------------------------------------------------------------*/
1373 /** MATH_ENGINE: val requestFillformula : calcID -> errpatID * fillpatID -> XML.tree
1374 * only implemented in Math_Engine */
1376 /** MATH_ENGINE: val resetCalcHead : calcID -> XML.tree */
1378 * @see isac.interfaces.IToCalc#resetCalcHead()
1380 public CalcHead resetCalcHead(int calc_tree_id) throws RemoteException {
1381 CalcHead return_val = null;
1382 /*---------------------------------------------------------------------------*/
1383 //*TTY*/ResponseWrapper wrapper = interpretSML(calc_tree_id, "resetCalcHead @calcid@;", false);
1384 //*TTY*/return_val = (CalcHead) wrapper.getResponse();
1385 /*---------------------------------------------------------------------------*/
1386 /*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(calc_tree_id));
1387 /*PIDE*/bridge_.log(1, "-->ISA: " + "resetCalcHead " + sml_id + ";");
1389 /*PIDE*/XML.Tree xml_in = JavaToIsa.reset_calchead(new scala.math.BigInt(BigInteger.valueOf(sml_id)));
1390 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
1391 /*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(IsacOperations.RESET_CALCHEAD, xml_in);
1393 /*PIDE*/IntCalcHead java_out = null;
1394 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
1395 /*PIDE*/ java_out = IsaToJava.reset_calchead_out(xml_out);
1396 /*PIDE*/ return_val = java_out.getCalcHead();
1397 /*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
1399 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);
1400 /*---------------------------------------------------------------------------*/
1404 /** MATH_ENGINE: val setContext : calcID -> pos' -> guh -> XML.tree */
1405 /* The status of this method is unclear:
1407 ** There is no use-case and no test
1408 ** The code is NOT used when showing the contexts
1409 * of thy, pbl, met, exp for example Biegelinie.
1410 ** The code is not deleted, nevertheless, because there is
1411 * code in isabisac: interface#setContext
1413 * So the changes for "isabelle tty" --> libisabelle adapt to the XML
1414 * sent from isabisac interface#setContext > autocalculateOK2xml.
1416 public CChanged setContext(int javaCalcID, ContextTheory context, Position pos ) throws RemoteException {
1417 CChanged return_val = null;
1418 /*---------------------------------------------------------------------------*/
1419 //*TTY*/ResponseWrapper wrapper = interpretSML(javaCalcID,
1420 //*TTY*/ "setContext @calcid@ " + pos.toSMLString() + " \"" + context.getKEStoreKey().toString() + "\";", false);
1421 //*TTY*/if(wrapper == null) return_val = null;
1422 //*TTY*/else return_val = (CChanged) wrapper.getResponse();
1423 /*---------------------------------------------------------------------------*/
1424 /*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(javaCalcID));
1425 /*PIDE*/bridge_.log(1, "-->ISA: " + "setContext " + sml_id + " " + pos.toSMLString() + " \"" + context.getKEStoreKey().toString() + "\";");
1427 /*PIDE*/XML.Tree xml_in = JavaToIsa.set_ctxt(new scala.math.BigInt(BigInteger.valueOf(sml_id)),
1428 /*PIDE*/ pos, context.getKEStoreKey().toString() + "\"");
1429 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
1430 /*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(IsacOperations.SET_CTXT, xml_in);
1432 /*PIDE*/IntCEvent java_out = null;
1433 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
1434 /*PIDE*/ java_out = IsaToJava.set_ctxt_out(xml_out);
1435 /*PIDE*/ return_val = (CChanged) java_out.getCEvent();
1436 /*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
1438 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);
1439 /*---------------------------------------------------------------------------*/
1444 * @see isac.interfaces.IToCalc#setMethod()
1446 * MATH_ENGINE: val setMethod : calcID -> metID -> XML.tree
1448 public CalcHead setMethod(int calc_tree_id, MethodID id) throws RemoteException {
1449 CalcHead return_val = null;
1450 /*---------------------------------------------------------------------------*/
1451 //*TTY*/ResponseWrapper wrapper = interpretSML(calc_tree_id,
1452 //*TTY*/ "setMethod @calcid@ " + id.toSMLString() + ";", false);
1453 //*TTY*/return_val = (CalcHead) wrapper.getResponse();
1454 /*---------------------------------------------------------------------------*/
1455 /*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(calc_tree_id));
1456 /*PIDE*/bridge_.log(1, "-->ISA: " + "setMethod " + sml_id + " " + id.toSMLString() + ";");
1458 /*PIDE*/XML.Tree xml_in = JavaToIsa.set_met(new scala.math.BigInt(BigInteger.valueOf(sml_id)), id.getID());
1459 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
1460 /*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(IsacOperations.SET_MET, xml_in);
1462 /*PIDE*/IntCalcHead java_out = null;
1463 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
1464 /*PIDE*/ java_out = IsaToJava.set_met_out(xml_out);
1465 /*PIDE*/ return_val = java_out.getCalcHead();
1466 /*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
1468 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);
1469 /*---------------------------------------------------------------------------*/
1473 /** MATH_ENGINE: val setNextTactic : calcID -> tac -> XML.tree */
1474 public int setNextTactic(int id, Tactic tactic) {
1475 int return_val = 4711;
1476 /*---------------------------------------------------------------------------*/
1477 //*TTY*/ResponseWrapper wrapper = interpretSML(id,
1478 //*TTY*/ "setNextTactic @calcid@ (" + tactic.toSMLString() + ");", false);
1479 //*TTY*/if (wrapper == null) return_val = -1;//WN050223 response ... MESSAGE not parsed
1480 //*TTY*/if (wrapper.getResponse() == null) { return_val = 0; //Everything is ok
1481 //*TTY*/} else { return_val = -1; } //An Error occcured
1482 /*---------------------------------------------------------------------------*/
1483 /*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(id));
1484 /*PIDE*/bridge_.log(1, "-->ISA: " + "setNextTactic " + sml_id + " (" + tactic.toSMLString() + ");");
1486 /*PIDE*/XML.Tree xml_in = JavaToIsa.set_next_tac(new scala.math.BigInt(BigInteger.valueOf(sml_id)), tactic);
1487 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
1488 /*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(IsacOperations.SET_NEXT_TAC, xml_in);
1490 /*PIDE*/if (!IsaToJava.is_syserror(xml_out)) {
1491 IsaToJava.set_next_tac_out(xml_out);
1492 /*PIDE*/ return_val = 0; //Everything is ok
1493 /*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
1495 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_syserror: " + xml_out);
1497 /*---------------------------------------------------------------------------*/
1502 * @see isac.interfaces.IToCalc#setProblem()
1504 * MATH_ENGINE: val setProblem : calcID -> pblID -> XML.tree
1506 public CalcHead setProblem(int calc_tree_id, ProblemID id) throws RemoteException {
1507 CalcHead return_val = null;
1508 /*---------------------------------------------------------------------------*/
1509 //*TTY*/ResponseWrapper wrapper = interpretSML(calc_tree_id,
1510 //*TTY*/ "setProblem @calcid@ " + id.toSMLString() + ";", false);
1511 //*TTY*/return_val = (CalcHead) wrapper.getResponse();
1512 /*---------------------------------------------------------------------------*/
1513 /*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(calc_tree_id));
1514 /*PIDE*/bridge_.log(1, "-->ISA: " + "setProblem " + sml_id + " " + id.toSMLString() + ";");
1516 /*PIDE*/XML.Tree xml_in = JavaToIsa.set_met(new scala.math.BigInt(BigInteger.valueOf(sml_id)), id.getID());
1517 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
1518 /*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(IsacOperations.SET_PBL, xml_in);
1520 /*PIDE*/IntCalcHead java_out = null;
1521 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
1522 /*PIDE*/ java_out = IsaToJava.set_met_out(xml_out);
1523 /*PIDE*/ return_val = java_out.getCalcHead();
1524 /*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
1526 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);
1527 /*---------------------------------------------------------------------------*/
1532 * @see isac.interfaces.IToCalc#setTheory()
1534 * TODO/WN150812: use implementation in Math_Engine.
1535 * MATH_ENGINE: val setTheory : calcID -> thyID -> XML.tree
1537 public CalcHead setTheory(int calc_tree_id, String thy_id)
1538 throws RemoteException {
1539 CalcHead return_val = null;
1540 Position pos = null;
1541 /*---------------------------------------------------------------------------*/
1542 //*TTY*///---FIXXXME.WN050809 hack until setTheory pushed into SML-kernel
1543 //*TTY*/ResponseWrapper wrapper = interpretSML(calc_tree_id,
1544 //*TTY*/ "(*setTheory*)setNextTactic @calcid@ (Specify_Theory \"" + thy_id + "\");", false);
1545 //*TTY*/wrapper = interpretSML(calc_tree_id,
1546 //*TTY*/ "(*setTheory*)autoCalculate @calcid@ (Step 1);", false);
1547 //*TTY*///drop the CalcChanged returned by autoCalculate
1548 //*TTY*/wrapper = interpretSML(calc_tree_id,
1549 //*TTY*/ "(*setTheory*)getActiveFormula @calcid@ ;", false);
1550 //*TTY*/pos = moveSuccess(wrapper);
1551 //*TTY*/wrapper = interpretSML(calc_tree_id,
1552 //*TTY*/ "(*setTheory*)refFormula @calcid@ " + pos.toSMLString() + ";", false);
1553 //*TTY*/return_val = (CalcHead) wrapper.getResponse();
1555 /*---------------------------------------------------------------------------*/
1556 //---FIXXXME.WN050809 hack until setTheory pushed into SML-kernel
1557 /*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(calc_tree_id));
1559 /*PIDE*/bridge_.log(1, "-->ISA: " + "(*setTheory*)setNextTactic " + sml_id + " (Specify_Theory \"" + thy_id + "\");");
1560 /*PIDE*/SimpleTactic tac = new SimpleTactic("Specify_Theory", thy_id + "\"");
1561 /*PIDE*/XML.Tree xml_in = JavaToIsa.set_next_tac(new scala.math.BigInt(BigInteger.valueOf(sml_id)), tac);
1562 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
1563 /*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(IsacOperations.SET_NEXT_TAC, xml_in);
1564 /*PIDE*/bridge_.log(1, "<--ISA: message not sent to Dialog ... " + xml_out);
1566 /*PIDE*/bridge_.log(1, "-->ISA: " + "(*setTheory*)autoCalculate " + sml_id + " (Step 1);");
1567 /*PIDE*/xml_in = JavaToIsa.auto_calculate(new scala.math.BigInt(BigInteger.valueOf(sml_id)),
1568 /*PIDE*/ "Step", new scala.math.BigInt(BigInteger.valueOf(1)));
1569 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
1570 /*PIDE*/xml_out = connection_to_kernel_.invoke(IsacOperations.AUTO_CALC, xml_in);
1571 /*PIDE*/bridge_.log(1, "<--ISA: CalcChanged not sent to Dialog ... " + xml_out);
1573 /*PIDE*/bridge_.log(1, "-->ISA: " + "(*setTheory*)getActiveFormula " + sml_id + ";");
1574 /*PIDE*/xml_in = JavaToIsa.get_active_form(new scala.math.BigInt(BigInteger.valueOf(sml_id)));
1575 /*PIDE*/xml_out = connection_to_kernel_.invoke(IsacOperations.GET_ACTIVE_FORM, xml_in);
1576 /*PIDE*/IntPosition java_out = null;
1577 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
1578 /*PIDE*/ java_out = IsaToJava.get_active_form_out(xml_out);
1579 /*PIDE*/ pos = java_out.getPosition();
1580 /*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
1582 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);
1584 /*PIDE*/bridge_.log(1, "-->ISA: " + "(*setTheory*)refFormula " + sml_id + " " + pos.toSMLString() + ";");
1585 /*PIDE*/xml_in = JavaToIsa.ref_formula(new scala.math.BigInt(BigInteger.valueOf(sml_id)), pos);//^^pos.setKind("DUMMY")
1586 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
1587 /*PIDE*/xml_out = connection_to_kernel_.invoke(IsacOperations.REF_FORMULA, xml_in);
1589 /*PIDE*/IntFormHead java_out2 = null;
1590 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
1591 /*PIDE*/ java_out2 = IsaToJava.ref_formula_out(xml_out);
1592 /*PIDE*/ return_val = (CalcHead)java_out2.getFormHead();
1593 /*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
1595 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);
1596 /*PIDE*///\---End hack
1597 /*---------------------------------------------------------------------------*/
1601 /***********************************************************************
1602 * Below are methods not contained in MATH_ENGINE, rather
1603 * they composed from other methods in Math_Engine.
1607 * @see isac.interfaces.IToCalc#completeCalcHead()
1609 public CalcHead completeCalcHead(int calc_tree_id) {
1610 CalcHead return_val = null;
1611 Position pos = null;
1612 /*---------------------------------------------------------------------------*/
1613 //*TTY*///---FIXXXME.WN050809 hack until setTheory pushed into SML-kernel
1614 //*TTY*/ResponseWrapper wrapper = interpretSML(calc_tree_id,
1615 //*TTY*/ "(*completeCalcHead*)autoCalculate @calcid@ CompleteCalcHead;", false);
1616 //*TTY*///drop the CalcChanged returned by autoCalculate
1617 //*TTY*/wrapper = interpretSML(calc_tree_id,
1618 //*TTY*/ "(*completeCalcHead*)getActiveFormula @calcid@ ;", false);
1619 //*TTY*/pos = moveSuccess(wrapper);
1620 //*TTY*/wrapper = interpretSML(calc_tree_id,
1621 //*TTY*/ "(*completeCalcHead*)refFormula @calcid@ " + pos.toSMLString() + ";", false);
1622 //*TTY*/return_val = (CalcHead) wrapper.getResponse();
1623 //*TTY*///\---End hack
1624 /*---------------------------------------------------------------------------*/
1625 //---FIXXXME.WN050809 hack until setTheory pushed into SML-kernel
1626 /*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(calc_tree_id));
1628 /*PIDE*/bridge_.log(1, "-->ISA: " + "(*completeCalcHead*)autoCalculate " + sml_id + "CompleteCalcHead;");
1629 /*PIDE*/XML.Tree xml_in = JavaToIsa.auto_calculate(new scala.math.BigInt(BigInteger.valueOf(sml_id)),
1630 /*PIDE*/ "CompleteCalcHead", new scala.math.BigInt(BigInteger.valueOf(0)));
1631 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
1632 /*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(IsacOperations.AUTO_CALC, xml_in);
1634 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
1635 IsaToJava.auto_calc_out(xml_out);
1636 /*PIDE*/// return_val = java_out.getCEvent();
1637 /*PIDE*/bridge_.log(1, "<--ISA: not sent to Dialog ... " + xml_out);
1639 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);
1642 /*PIDE*/bridge_.log(1, "-->ISA: " + "(*completeCalcHead*)getActiveFormula " + sml_id + ";");
1643 /*PIDE*/xml_in = JavaToIsa.get_active_form(new scala.math.BigInt(BigInteger.valueOf(sml_id)));
1644 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
1645 /*PIDE*/xml_out = connection_to_kernel_.invoke(IsacOperations.GET_ACTIVE_FORM, xml_in);
1647 /*PIDE*/IntPosition java_out2 = null;
1648 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
1649 /*PIDE*/ java_out2 = IsaToJava.get_active_form_out(xml_out);
1650 /*PIDE*/ pos = java_out2.getPosition();
1651 /*PIDE*/bridge_.log(1, "<--ISA: used locally ... " + xml_out);
1653 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);
1656 /*PIDE*/bridge_.log(1, "-->ISA: " + "(*completeCalcHead*)refFormula " + sml_id + pos.toSMLString() + ";");
1657 /*PIDE*/xml_in = JavaToIsa.ref_formula(new scala.math.BigInt(BigInteger.valueOf(sml_id)), pos);
1658 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
1659 /*PIDE*/xml_out = connection_to_kernel_.invoke(IsacOperations.REF_FORMULA, xml_in);
1661 /*PIDE*/IntFormHead java_out3 = null;
1662 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
1663 /*PIDE*/ java_out3 = IsaToJava.ref_formula_out(xml_out);
1664 /*PIDE*/ return_val = (CalcHead)java_out3.getFormHead();
1665 /*PIDE*/bridge_.log(1, "<--ISA: used locally ... " + xml_out);
1667 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);
1668 /*PIDE*///\---End hack
1669 /*---------------------------------------------------------------------------*/
1674 * @see isac.interfaces.IToCalc#completeModel() WN050809 push this method
1675 * through to the SML-kernel
1677 public CalcHead completeModel(int calc_tree_id) throws RemoteException {
1678 CalcHead return_val = null;
1679 Position pos = null;
1680 /*---------------------------------------------------------------------------*/
1681 //*TTY*///---FIXXXME.WN050809 hack until setTheory pushed into SML-kernel
1682 //*TTY*/ResponseWrapper wrapper = interpretSML(calc_tree_id,
1683 //*TTY*/ "(*completeModel*)autoCalculate @calcid@ CompleteModel;", false);
1684 //*TTY*///drop the CalcChanged returned by autoCalculate
1685 //*TTY*/wrapper = interpretSML(calc_tree_id,
1686 //*TTY*/ "(*completeModel*)getActiveFormula @calcid@ ;", false);
1687 //*TTY*/pos = moveSuccess(wrapper);
1688 //*TTY*/wrapper = interpretSML(calc_tree_id,
1689 //*TTY*/ "(*completeModel*)refFormula @calcid@ " + pos.toSMLString() + ";", false);
1690 //*TTY*/return_val = (CalcHead) wrapper.getResponse();
1692 /*---------------------------------------------------------------------------*/
1693 //---FIXXXME.WN050809 hack until setTheory pushed into SML-kernel
1694 /*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(calc_tree_id));
1696 /*PIDE*/bridge_.log(1, "-->ISA: " + "(*completeModel*)autoCalculate " + sml_id + " CompleteModel;");
1697 /*PIDE*/XML.Tree xml_in = JavaToIsa.auto_calculate(new scala.math.BigInt(BigInteger.valueOf(sml_id)),
1698 /*PIDE*/ "CompleteModel", new scala.math.BigInt(BigInteger.valueOf(0)));
1699 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
1700 /*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(IsacOperations.AUTO_CALC, xml_in);
1702 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
1703 IsaToJava.set_met_out(xml_out);
1704 /*PIDE*/bridge_.log(1, "<--ISA: not sent to Dialog = " + xml_out);
1706 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);
1709 /*PIDE*/bridge_.log(1, "-->ISA: " + "(*completeModel*)getActiveFormula " + sml_id + ";");
1710 /*PIDE*/xml_in = JavaToIsa.get_active_form(new scala.math.BigInt(BigInteger.valueOf(sml_id)));
1711 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
1712 /*PIDE*/xml_out = connection_to_kernel_.invoke(IsacOperations.GET_ACTIVE_FORM, xml_in);
1714 /*PIDE*/IntPosition java_out2 = null;
1715 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
1716 /*PIDE*/ java_out2 = IsaToJava.get_active_form_out(xml_out);
1717 /*PIDE*/ pos = java_out2.getPosition();
1718 /*PIDE*/bridge_.log(1, "<--ISA: used locally ... " + xml_out);
1720 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);
1722 /*PIDE*/bridge_.log(1, "-->ISA: " + "(*completeModel*)refFormula " + sml_id + " " + pos.toSMLString() + ";");
1723 /*PIDE*/xml_in = JavaToIsa.ref_formula(new scala.math.BigInt(BigInteger.valueOf(sml_id)), pos);
1724 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
1725 /*PIDE*/xml_out = connection_to_kernel_.invoke(IsacOperations.REF_FORMULA, xml_in);
1727 /*PIDE*/IntFormHead java_out3 = null;
1728 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
1729 /*PIDE*/ java_out3 = IsaToJava.ref_formula_out(xml_out);
1730 /*PIDE*/ return_val = (CalcHead)java_out3.getFormHead();
1731 /*PIDE*/bridge_.log(1, "<--ISA: used locally ... " + xml_out);
1733 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);
1734 /*PIDE*///\---End hack
1735 /*---------------------------------------------------------------------------*/
1740 * @see isac.interfaces.IToCalc#nextSpecify() WN050809 push this method
1741 * through to the SML-kernel.
1743 public CalcHead nextSpecify(int calc_tree_id) throws RemoteException {
1744 CalcHead return_val = null;
1745 Position pos = null;
1746 /*---------------------------------------------------------------------------*/
1747 //*TTY*///---FIXXXME.WN050809 hack until setTheory pushed into SML-kernel
1748 //*TTY*/ResponseWrapper wrapper = interpretSML(calc_tree_id,
1749 //*TTY*/ "(*nextSpecify*)autoCalculate @calcid@ (Step 1);", false);
1750 //*TTY*///drop the CalcChanged returned by autoCalculate
1751 //*TTY*/wrapper = interpretSML(calc_tree_id,
1752 //*TTY*/ "(*nextSpecify*)getActiveFormula @calcid@ ;", false);
1753 //*TTY*/pos = moveSuccess(wrapper);
1754 //*TTY*/wrapper = interpretSML(calc_tree_id,
1755 //*TTY*/ "(*nextSpecify*)refFormula @calcid@ " + pos.toSMLString() + ";", false);
1756 //*TTY*/return_val = (CalcHead) wrapper.getResponse();
1757 //*TTY*///\---End hack
1758 /*---------------------------------------------------------------------------*/
1759 /*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(calc_tree_id));
1760 /*PIDE*///---FIXXXME.WN050809 hack until setTheory pushed into SML-kernel
1762 /*PIDE*/bridge_.log(1, "-->ISA: " + "(*nextSpecify*)autoCalculate " + sml_id + " (Step 1);");
1763 /*PIDE*/XML.Tree xml_in = JavaToIsa.auto_calculate(new scala.math.BigInt(BigInteger.valueOf(sml_id)),
1764 /*PIDE*/ "Step", new scala.math.BigInt(BigInteger.valueOf(1)));
1765 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
1766 /*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(IsacOperations.AUTO_CALC, xml_in);
1768 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
1769 IsaToJava.set_met_out(xml_out);
1770 /*PIDE*/bridge_.log(1, "<--ISA: not sent to Dialog = " + xml_out);
1772 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);
1775 /*PIDE*/bridge_.log(1, "-->ISA: " + "(*nextSpecify*)getActiveFormula " + sml_id + ";");
1776 /*PIDE*/xml_in = JavaToIsa.get_active_form(new scala.math.BigInt(BigInteger.valueOf(sml_id)));
1777 /*PIDE*/xml_out = connection_to_kernel_.invoke(IsacOperations.GET_ACTIVE_FORM, xml_in);
1779 /*PIDE*/IntPosition java_out2 = null;
1780 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
1781 /*PIDE*/ java_out2 = IsaToJava.get_active_form_out(xml_out);
1782 /*PIDE*/ pos = java_out2.getPosition();
1783 /*PIDE*/bridge_.log(1, "<--ISA: used locally ... " + xml_out);
1785 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);
1788 /*PIDE*/bridge_.log(1, "-->ISA: " + "(*nextSpecify*)refFormula " + sml_id + pos.toSMLString() + ";");
1789 /*PIDE*/xml_in = JavaToIsa.ref_formula(new scala.math.BigInt(BigInteger.valueOf(sml_id)), pos);//^^pos.setKind("DUMMY")
1790 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
1791 /*PIDE*/xml_out = connection_to_kernel_.invoke(IsacOperations.REF_FORMULA, xml_in);
1793 /*PIDE*/IntFormHead java_out3 = null;
1794 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
1795 /*PIDE*/ java_out3 = IsaToJava.ref_formula_out(xml_out);
1796 /*PIDE*/ return_val = (CalcHead)java_out3.getFormHead();
1797 /*PIDE*/bridge_.log(1, "<--ISA: used locally ... " + xml_out);
1799 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: " + xml_out);
1800 /*PIDE*///\---End hack
1801 /*---------------------------------------------------------------------------*/
1805 /***********************************************************************
1806 * Below are methods not implemented in MATH_ENGINE at all,
1807 * or only very fragmentarily.
1808 * WN150812 here are also methods, where the status is not clarified.
1809 * Some methods seem to be replaced by similar ones.
1810 * TODO: review IBridgeRMI, MathEngine, etc.
1814 * <b>Do not use:</b><br></br> not impl. in Math_Engine
1815 * @see isac.interfaces.ICalcIterator#tryMatchMethod(MethodID)
1817 public Match initMatchMethod(int javaCalcID) throws RemoteException {
1818 ResponseWrapper wrapper = interpretSML(javaCalcID,
1819 "initMatchMethod @calcid@ ;", false);
1820 Object response = wrapper.getResponse();
1821 CalcHead ch = (CalcHead) response;
1822 Match m = new Match(ch.getSpecification().getProblem(), ch
1823 .getStatusString(), ch.getHeadLine(), ch.getModel());
1828 * <b>Do not use:</b><br></br> not impl. in Math_Engine
1829 * @see isac.interfaces.ICalcIterator#tryMatchMethod(MethodID)
1831 public Match initMatchProblem(int javaCalcID) {
1832 ResponseWrapper wrapper = interpretSML(javaCalcID,
1833 "initMatchProblem @calcid@ ;", false);
1834 Object response = wrapper.getResponse();
1835 CalcHead ch = (CalcHead) response;
1836 Match m = new Match(ch.getSpecification().getProblem(), ch
1837 .getStatusString(), ch.getHeadLine(), ch.getModel());
1842 * <b>Do not use:</b><br></br> not impl. in Math_Engine
1843 * @see isac.interfaces.ICalcIterator#tryMatchMethod(MethodID)
1845 public Match tryMatchMethod(int javaCalcID, MethodID keStoreID)
1846 throws RemoteException {
1847 ResponseWrapper wrapper = interpretSML(javaCalcID,
1848 "tryMatchMethod @calcid@ " + keStoreID.toSMLString() + ";",
1850 Object response = wrapper.getResponse();
1851 CalcHead ch = (CalcHead) response;
1852 Match m = new Match(ch.getSpecification().getProblem(), ch
1853 .getStatusString(), ch.getHeadLine(), ch.getModel());
1857 /** enforced by IBridgeRMI, WN150812: exp-, met-, pbl-, thy-contexts all work --
1858 * -- see: CChanged setContext(int, ContextTheory, ... */
1860 public CalcHead setContext(int javaCalcID, ContextMethod context, Position pos) throws RemoteException {
1864 /** enforced by IBridgeRMI, WN150812: exp-, met-, pbl-, thy-contexts all work --
1865 * -- see: CChanged setContext(int, ContextTheory, ...
1866 * This method changed role with ^^^^^^^^^^^^^^^^ during "isabelle tty" --> libisabelle
1869 public CalcHead setContext(int javaCalcID, ContextProblem context, Position pos) throws RemoteException {
1874 * @see isac.interfaces.ICalcIterator#tryMatchProblem(HierarchyKey)
1876 * WN150812: tryMatchProblem, trymatch only partially implemented in Math_Engine
1878 public Match tryMatchProblem(int javaCalcID, ProblemID problemID) {
1879 ResponseWrapper wrapper = interpretSML(javaCalcID,
1880 "tryMatchProblem @calcid@ " + problemID.toSMLString() + ";",
1882 Object response = wrapper.getResponse();
1883 CalcHead ch = (CalcHead) response;
1884 Match m = new Match(ch.getSpecification().getProblem(), ch
1885 .getStatusString(), ch.getHeadLine(), ch.getModel());
1890 * <b>Do not use:</b><br></br> not impl. in Math_Engine
1891 * @see isac.interfaces.ICalcIterator#tryRefineProblem(HierarchyKey)
1893 public Match tryRefineProblem(int javaCalcID, ProblemID problemID) {
1894 ResponseWrapper wrapper = interpretSML(javaCalcID,
1895 "tryRefineProblem @calcid@ " + problemID.toSMLString() + ";",
1897 Object response = wrapper.getResponse();
1898 CalcHead ch = (CalcHead) response;
1899 Match m = new Match(ch.getSpecification().getProblem(), ch
1900 .getStatusString(), ch.getHeadLine(), ch.getModel());
1904 /***********************************************************************
1905 * Below are methods for restoring Isabelle/Isac after a crash.
1906 * This never worked, is to be deleted and
1907 * to be reconsidered with introduction of libisabelle.
1911 * This method is used when the kernel crashes and the CalcTrees need to be
1912 * entered again to the kernel to restore the previous state. The
1913 * Java-CalcIDs stay the same
1915 public void restoreExistingCalcTrees() {
1916 bridge_.log(1, "---- entering restoreExistingCalcTrees");
1917 Iterator<?> it = java_calcid_to_smlcalcid_.keySet().iterator();
1918 // keySet = javaCalcIDs
1921 while (it.hasNext()) {
1922 //bridge.log(1, "1");
1923 //int i = ((Integer)it.next()).intValue();
1924 javaCalcID = ((Integer) it.next()).intValue();
1925 //bridge.log(1, "2");
1926 v = saveCalcTree(javaCalcID);
1927 //bridge.log(1, "3");
1928 this.restoreToSML(javaCalcID, v);
1930 bridge_.log(1, "---- done restoreExistingCalcTrees");
1933 private void restoreToSML(int javaCalcID, Vector<String> v) {
1934 Iterator<String> it = new Vector<String>(v).iterator();
1935 String s = (String) it.next();
1936 newCalculation(javaCalcID, s, null/*never worked*/, true);
1937 //javaCalcIDtoSmlCalcID.put(new Integer(javaCalcID), new
1938 // Integer(smlCalcID));
1939 //int smlID = ((Integer)javaCalcIDtoSmlCalcID.get(new
1940 // Integer(calcID))).intValue();
1941 while (it.hasNext()) {
1942 s = (String) it.next();
1943 interpretSML(javaCalcID, s, true);
1948 * Save a calcTree for later restoring (probably to another SML Kernel)
1951 * the ID of the calcTree
1952 * @return a vector containing strings. This is representatation of the
1953 * status of the calcTree
1955 public Vector<String> saveCalcTree(int calcTreeID) {
1956 this.bridge_.log(1, "----------------begin saving calcTree "
1957 + calcTreeID + "------------");
1958 return (Vector<String>) inputs_.get(new Integer(calcTreeID));