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.IntCChanged;
11 import isac.bridge.xml.IntCEvent;
12 import isac.bridge.xml.IntFormHead;
13 import isac.bridge.xml.IntFormulas;
14 import isac.bridge.xml.IntIntCompound;
15 import isac.bridge.xml.IntContext;
16 import isac.bridge.xml.IntPosition;
17 import isac.bridge.xml.IntTactic;
18 import isac.bridge.xml.IntTacticErrPats;
19 import isac.bridge.xml.IntTactics;
20 import isac.bridge.xml.IsaToJava;
21 import isac.bridge.xml.JavaToIsa;
22 import isac.interfaces.ICalcElement;
23 import isac.interfaces.ICalcIterator;
24 import isac.interfaces.IToCalc;
25 import isac.util.Formalization;
26 import isac.util.Message;
27 import isac.util.ResponseWrapper;
28 import isac.util.formulae.Assumptions;
29 import isac.util.formulae.CalcHead;
30 import isac.util.formulae.Context;
31 import isac.util.formulae.ContextMethod;
32 import isac.util.formulae.ContextProblem;
33 import isac.util.formulae.ContextTheory;
34 import isac.util.formulae.HierarchyKey;
35 import isac.util.formulae.CalcHeadSimpleID;
36 import isac.util.formulae.CalcFormula;
37 import isac.util.formulae.FormHeadsContainer;
38 import isac.util.formulae.Match;
39 import isac.util.formulae.MethodID;
40 import isac.util.formulae.Position;
41 import isac.util.formulae.ProblemID;
42 import isac.util.parser.XMLParserDigest;
43 import isac.util.tactics.SimpleTactic;
44 import isac.util.tactics.Tactic;
45 import isac.util.tactics.TacticsContainer;
46 import isac.wsdialog.IContextProvider.ContextType;
47 import edu.tum.cs.isabelle.japi.JSystem;
48 import edu.tum.cs.isabelle.japi.Operations;
50 import isabelle.XML.Tree;
52 import java.io.BufferedReader;
53 import java.io.IOException;
54 import java.io.InputStreamReader;
55 import java.io.PrintWriter;
56 import java.math.BigInteger;
57 import java.net.MalformedURLException;
58 import java.net.Socket;
59 import java.net.UnknownHostException;
60 import java.rmi.Naming;
61 import java.rmi.RMISecurityManager;
62 import java.rmi.RemoteException;
63 import java.rmi.registry.LocateRegistry;
64 import java.rmi.server.UnicastRemoteObject;
65 import java.util.HashMap;
66 import java.util.Iterator;
69 import java.util.Vector;
71 import scala.math.BigInt;
73 import org.apache.log4j.Logger;
76 * @author Richard Gradischnegg RG
78 * WN0422 here seems to be the key for simplifying the whole bridge.* drawbacks
79 * of the present implementation: # more complicated than necessary #
80 * JUnitTestCases require BridgeMain running # BridgeLogger cannot be made
81 * serializable, thus not accessible for writing by JUnitTestCases #
83 public class BridgeRMI extends UnicastRemoteObject implements IBridgeRMI {
85 static final long serialVersionUID = -3047706038036289437L;
86 private static final Logger logger = Logger.getLogger(BridgeRMI.class.getName());
88 private BridgeMain bridge_;
90 private XMLParserDigest xml_parser_digest_;
92 // Socket used to communicate with bridge
93 private Socket socket_ = null;
95 // Writer to write sml requests to the kernel
96 private PrintWriter out_ = null;
98 // Reader to read sml response from kernel
99 private BufferedReader in_ = null;
101 private String host_;
106 * Maps the Java calc(Tree)rmiID to the sml calc(Tree)rmiID. A mapping is
107 * nescessary because these ids are not (nescessary) the same: For example
108 * when restoring the kernel, the calcTree rmiID can change because of
109 * already finished CalcTrees no longer existing and their CalcId assigned
110 * to another CalcTree. key: Integer (javaCalcID) value: Integer (smlCalcID)
112 private Map java_calcid_to_smlcalcid_;
115 * This map stores user inputs which have already been answered by the
116 * kernel and the response being sent back to the user. These inputs are
117 * resent to the kernel in the case of a newstart of the kernel. key:
118 * Integer (javaCalcID) value: Vector (containing input strings)
121 private JSystem connection_to_kernel_;
123 public BridgeRMI(BridgeMain bridge, String host, int port, String dtdPath)
124 throws RemoteException {
125 if (logger.isDebugEnabled())
126 logger.debug("BridgeRMI obj.init: bridge=" + bridge + ", host=" + host
127 + ", port=" + port + ", dtdPath=" + dtdPath);
129 this.bridge_ = bridge;
130 this.connection_to_kernel_ = bridge.getConnectionToKernel();
132 * out = bridge.getSmlWriter(); in = bridge.getSmlReader();
134 in_ = bridge.getSmlReader();
136 socket_ = new Socket(host, port);
137 out_ = new PrintWriter(socket_.getOutputStream(), true);
138 in_ = new BufferedReader(new InputStreamReader(socket_
140 } catch (UnknownHostException e) {
141 System.out.println("Unknown host: " + host + "\n");
142 } catch (IOException e) {
143 System.out.println("No I/O\n");
146 xml_parser_digest_ = new XMLParserDigest(dtdPath);
147 //xml_parser_digest_.setValidating(true);
148 //...all XML-data should be tested in
149 //javatest.isac.util.parser.TestXMLParserDigest
150 inputs_ = new HashMap();
151 java_calcid_to_smlcalcid_ = new HashMap();
155 * Buffers input sent to the sml-Kernel (for later possible restart)
158 * calcTree this input belongs to
162 public void bufferInput(int javaCalcID, String input) {
163 Vector v = (Vector) inputs_.get(new Integer(javaCalcID));
166 inputs_.put(new Integer(javaCalcID), v);
171 // '@calcid@' is a placeholder for the CalcID
172 // this method replaces it with a real CalcID
173 private String insertCalcID(int id, String s) {
174 return s.replaceAll("@calcid@", String.valueOf(id));
177 // return smallest integer which is not yet
178 // used as a (java)CalcID
179 private int smallestFreeCalcID() {
180 Set set = java_calcid_to_smlcalcid_.keySet();
181 for (int i = 0; i < set.size(); i++) {
182 if (!set.contains(new Integer(i))) {
190 * Send a sml instruction to the kernel. restore == true, if the instruction
191 * is resent after the kernel crashed
193 private ResponseWrapper sendToKernel(String smlInstr, boolean restore) {
194 if (logger.isDebugEnabled())
195 logger.debug(" BR->KN: sendToKernel(" + smlInstr + ")");
196 ResponseWrapper wrapper = null;
197 //bridge.log(1,"---sendToKernel |
198 //bridge.isRestoring=="+bridge.isRestoring());
199 //bridge.log(1,"---sendToKernel | restoring=="+restore);
200 if (!bridge_.isRestoring() || restore) {
201 String xmlString = "";
203 out_.println(smlInstr);// send the sml Instruction to the sml Kernel
205 xmlString = in_.readLine();//read the response from the kernel
206 if (logger.isInfoEnabled())
207 logger.info(" BR<-KN: sendToKernel <- xml= " + xmlString);
208 } catch (IOException e) {
209 bridge_.log(1, "BridgeRMI.interpretSKN: IOException");
212 //if (!(restore) && bridge.isRestoring()) {
213 // this.restoreExistingCalcTrees();
216 bridge_.log( 1, xmlString );
217 wrapper = xml_parser_digest_.parse(xmlString);
223 * Send an instruction to the SML-Kernel and return the response
227 * @return response from SML-Kernel
229 private synchronized ResponseWrapper interpretSML(int javaCalcID,
230 String instr, boolean restore) {
233 Integer smlCalcInteger = (Integer) java_calcid_to_smlcalcid_.get(new Integer(javaCalcID));
234 if( smlCalcInteger == null ) {
235 bridge_.log(1, "smlCalcInteger is null for javaCalcID : " + javaCalcID );
239 smlCalcID = smlCalcInteger.intValue();
240 String smlInstr = insertCalcID(smlCalcID, instr);
241 bridge_.log(1, "JavaCalcID " + javaCalcID + " == SmlCalcID "
243 bridge_.log(1, "sent to bridge: " + smlInstr);
244 ResponseWrapper wrapper = this.sendToKernel(smlInstr, restore);
246 bufferInput(javaCalcID, smlInstr);
250 private void rmiBind() {
251 if (logger.isDebugEnabled())
252 logger.debug("rmiBind");
253 if (System.getSecurityManager() == null) {
254 System.setSecurityManager(new RMISecurityManager());
257 String name = "//" + host_ + "/BridgeRMI";
259 System.out.println("try to bind as " + name);
260 Naming.rebind(name, this);
261 System.out.println("Bridge RMI bound to " + name);
262 } catch (java.rmi.ConnectException e) {
263 System.err.println("failed to contact as " + name + " (creating RMI-Server on localhost: 1099)");
265 LocateRegistry.createRegistry(1099);
266 } catch (java.rmi.RemoteException exc2) {
267 System.err.println("can not create registry: " + exc2.getMessage());
271 } catch (RemoteException e) {
272 System.err.println("RemoteException");
273 System.err.println(e.getMessage());
274 System.err.println(e.getCause().getMessage());
275 System.err.println(e.getCause().getClass());
279 } catch (MalformedURLException e) {
280 System.err.println(e.getMessage());
284 } catch (Exception e) {
285 System.err.println("----------- Exception");
286 System.err.println(e.getClass().getName());
287 System.err.println(e.getMessage());
295 * Restore a saved calcTree.
298 * Vector containing strings
299 * @return Java CalcTreeID (not SML-ID)
301 public int loadCalcTree(Vector v) {
302 this.bridge_.log(1, "----------------begin loading------------");
303 int javaCalcID = smallestFreeCalcID();
304 this.bridge_.log(1, "-----smallest free = " + javaCalcID);
305 restoreToSML(javaCalcID, v);
306 this.bridge_.log(1, "----------------done loading-------------");
310 public int smlCalcIDtoJavaCalcID(int smlID) {
311 Iterator it = java_calcid_to_smlcalcid_.keySet().iterator();
312 while (it.hasNext()) {
313 Object key = it.next();
314 Integer value = (Integer) java_calcid_to_smlcalcid_.get(key);
315 if (value.intValue() == smlID) {
316 return ((Integer) key).intValue();
322 public Map getInputs() {
326 public int getRmiID() {
330 public void setRmiID(int i) {
331 if (logger.isDebugEnabled())
332 logger.debug("setRmiID: i=" + i);
337 * causes a CalcChanged event for the first line on the Worksheet
340 * for the CalcTree (unused)
341 * @return CalcChanged with Iterators pointing at the root of the CalcTree
343 public CChanged startCalculate(int id) {
344 Position p = new Position();
345 p.setKind("Pbl");// toSMLString --> ([],"Pbl")
346 CChanged cc = new CChanged();
347 cc.setLastUnchanged(p);
348 cc.setLastDeleted(p);
349 cc.setLastGenerated(p);
354 * Starts the specifying phase: fill the calcTree with the appropriate
355 * information. Once the calc_head_ is fully specified, the user can begin
356 * with the actual calculation.
359 * Formalization for this calculation (empty if user starts a
360 * complete new calculation)
363 public int getCalcTree(Formalization formalization) {
365 int javaCalcID = smallestFreeCalcID();
366 this.bridge_.log(1, "-----smallest free javaCalcID = " + javaCalcID);
367 int smlCalcID = newCalculation(javaCalcID,
368 "CalcTree " + formalization.toSMLString() + ";", formalization, false);
369 return_val = javaCalcID;
373 /***********************************************************************
374 * Below are all the methods in structure Math_Engine : MATH_ENGINE
375 * listed in the same order as in the signature.
376 * The previous order still reflected original development;
377 * method names reflect the original struggle at the
378 * interface Java <--> Isabelle/Isac: different names are made explicit.
381 /** MATH_ENGINE: val appendFormula : calcID -> cterm' -> XML.tree */
382 public CEvent appendFormula(int id, CalcFormula f) {
383 CEvent return_val = null;
384 int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(id));
385 /*---------------------------------------------------------------------------*/
386 //*TTY*/ResponseWrapper wrapper = null;
387 //*TTY*/wrapper = interpretSML(id, "appendFormula @calcid@ \"" + f.toSMLString() + "\";", false);
388 //*TTY*/if (wrapper == null) return null;
389 //*TTY*/return_val = (CEvent) wrapper.getResponse();
390 /*---------------------------------------------------------------------------*/
391 /*PIDE*/bridge_.log(1, "-->ISA: " + "appendFormula " + sml_id + " \"" + f.toSMLString() + "\";");
392 /*PIDE*/XML.Tree xml_in = JavaToIsa.append_form(new scala.math.BigInt(BigInteger.valueOf(sml_id)), f.getFormula());
393 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
394 /*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(Operations.APPEND_FORM, xml_in);
396 /*PIDE*/IntCEvent java_out = null;
397 /*PIDE*/if (!IsaToJava.is_message(xml_out)) java_out = IsaToJava.append_form_out(xml_out);
398 /*PIDE*/// else: no message handling by DialogGuide
399 /*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
400 /*PIDE*/return_val = java_out.getCEvent();
401 /*---------------------------------------------------------------------------*/
405 /** MATH_ENGINE: val autoCalculate : calcID -> auto -> XML.tree */
406 public CEvent autoCalculate(int id, int scope, int steps) {
407 if (logger.isDebugEnabled())
408 logger.debug("BridgeRMI#autoCalculate: id=" + id + ", scope" + scope + ", steps" + steps);
409 ResponseWrapper wrapper = null;
410 CEvent return_val = null;
411 int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(id));
413 /*---------------------------------------------------------------------------*/
414 //*TTY*/if ((scope == 3) && (steps == 0)) { //scope ==3 means IToCalc.SCOPE_CALCHEAD:
415 //*TTY*/ wrapper = interpretSML(id, "autoCalculate @calcid@ CompleteCalcHead;", false);
416 //*TTY*/} else if ((scope == IToCalc.SCOPE_CALCULATION) && (steps == 0)) {
417 //*TTY*/ wrapper = interpretSML(id, "autoCalculate @calcid@ CompleteCalc;", false);
418 //*TTY*/} else if ((scope == IToCalc.SCOPE_MODEL) && (steps == 0)) {
419 //*TTY*/ wrapper = interpretSML(id, "autoCalculate @calcid@ CompleteModel;", false);
420 //*TTY*/} else if ((scope == IToCalc.SCOPE_SUBCALCULATION) && (steps == 0)) {
421 //*TTY*/ wrapper = interpretSML(id, "autoCalculate @calcid@ CompleteToSubpbl;", false);
422 //*TTY*/} else if ((scope == IToCalc.SCOPE_SUBPROBLEM) && (steps == 0)) {
423 //*TTY*/ wrapper = interpretSML(id, "autoCalculate @calcid@ CompleteSubpbl;", false);
424 //*TTY*/} else { //FIXXXME040624: steps do not regard the scope
425 //*TTY*/ wrapper = interpretSML(id, "autoCalculate @calcid@ (Step " + steps + ");", false);
427 //*TTY*/if (wrapper == null) return_val = null;
428 //*TTY*/return_val = (CEvent) wrapper.getResponse();
429 //-----------------------------------------------------------------------------
430 /*PIDE*/String scope_str;
431 /*PIDE*/if ((scope == 3) && (steps == 0)) { //scope ==3 means IToCalc.SCOPE_CALCHEAD:
432 /*PIDE*/ scope_str = "CompleteCalcHead"; //FIXXXME.WN040624 steps == 0 hides mismatch in specifications
433 /*PIDE*/} else if ((scope == IToCalc.SCOPE_CALCULATION) && (steps == 0)) {
434 /*PIDE*/ scope_str = "CompleteCalc";
435 /*PIDE*/} else if ((scope == IToCalc.SCOPE_MODEL) && (steps == 0)) {
436 /*PIDE*/ scope_str = "CompleteModel";
437 /*PIDE*/} else if ((scope == IToCalc.SCOPE_SUBCALCULATION) && (steps == 0)) {
438 /*PIDE*/ scope_str = "CompleteToSubpbl";
439 /*PIDE*/} else if ((scope == IToCalc.SCOPE_SUBPROBLEM) && (steps == 0)) {
440 /*PIDE*/ scope_str = "CompleteSubpbl";
441 /*PIDE*/} else { //FIXXXME040624: steps do not regard the scope
442 /*PIDE*/ scope_str = "Step"; // steps > 0 according to impl.in "isabelle tty"
444 /*PIDE*/if (steps == 0) log_str = scope_str; else log_str = "(Step " + steps + ")";
445 /*PIDE*/bridge_.log(1, "-->ISA: " + "autoCalculate " + sml_id + " " + log_str + ";");
447 /*PIDE*/XML.Tree xml_in = JavaToIsa.auto_calculate(new scala.math.BigInt(BigInteger.valueOf(sml_id)),
448 /*PIDE*/ scope_str, new scala.math.BigInt(BigInteger.valueOf(steps)));
449 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
450 /*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(Operations.AUTO_CALC, xml_in);
452 /*PIDE*/IntCEvent java_out = null;
453 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
454 /*PIDE*/ java_out = IsaToJava.auto_calc_out(xml_out);
455 /*PIDE*/ return_val = java_out.getCEvent();
456 /*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
458 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: REVIEW!");
459 /*---------------------------------------------------------------------------*/
463 /** MATH_ENGINE: val applyTactic : calcID -> pos' -> tac -> XML.tree
464 * not implemented in Math_Engine.
465 * compare setNextTactic. */
468 * Starts a new calculation in the sml-Kernel: i.e. a new CalcTree with the
472 * "CalcTree" + Formalization in string Representation
474 * @return sml_calcid //WN150817 why return SML(?!) calcid to Java(?!)
476 * MATH_ENGINE: val CalcTree : fmz list -> XML.tree
478 private synchronized int newCalculation(int javaCalcID, String instr,
479 Formalization fmz, boolean restore) {
481 if (logger.isDebugEnabled())
482 logger.debug("newCalculation: javaCalcID=" + javaCalcID + ", instr" + instr + ", restore=" + restore);
485 /*---------------------------------------------------------------------------*/
486 //*TTY*/bridge_.log(1, "new calculation: " + instr);
487 //*TTY*/ResponseWrapper wrapper = sendToKernel(instr, restore);
488 //*TTY*/if (wrapper == null) return -1;
489 //*TTY*/sml_calcid = wrapper.getCalcID();
490 //*TTY*/sendToKernel("Iterator " + sml_calcid + ";", restore);//WN041209 no
491 //*TTY*/sendToKernel("moveActiveRoot " + sml_calcid + ";", restore);//WN041209
492 //*TTY*/if (!restore) bufferInput(javaCalcID, instr);
493 /*---------------------------------------------------------------------------*/
494 /*PIDE*/bridge_.log(1, "-->ISA: " + instr);
495 /*PIDE*/XML.Tree CALC_TREE_out = connection_to_kernel_.invoke(Operations.CALC_TREE,
496 /*PIDE*/ DataTypes.xml_of_Formalization(fmz));
497 /*PIDE*/bridge_.log(1, "<--ISA: " + CALC_TREE_out);
498 /*PIDE*/sml_calcid = (IsaToJava.calc_tree_out(CALC_TREE_out)).intValue();
500 /*PIDE*/bridge_.log(1, "-->ISA: " + "Iterator " + sml_calcid + ";");
501 /*PIDE*/XML.Tree ITERATOR_out = connection_to_kernel_.invoke(Operations.ITERATOR,
502 /*PIDE*/ new scala.math.BigInt(BigInteger.valueOf(sml_calcid)));
503 /*PIDE*/IntIntCompound int_int = IsaToJava.iterator_out(ITERATOR_out);
504 /*PIDE*/sml_calcid = int_int.getCalcId().intValue();
505 /*PIDE*/int userid = int_int.getUserId().intValue(); //WN150808 ununsed
506 /*PIDE*/bridge_.log(1, "<--ISA: " + ITERATOR_out);
508 /*PIDE*/bridge_.log(1, "-->ISA: " + "moveActiveRoot " + sml_calcid + ";");
509 /*PIDE*/XML.Tree MOVE_ACTIVE_ROOT_out = connection_to_kernel_.invoke(Operations.MOVE_ACTIVE_ROOT,
510 /*PIDE*/ new scala.math.BigInt(BigInteger.valueOf(sml_calcid)));
511 /*PIDE*/IntPosition calcid_pos = IsaToJava.move_active_root_out(MOVE_ACTIVE_ROOT_out);
512 /*PIDE*/return_val = calcid_pos.getCalcId();
513 /*PIDE*/Position pos = calcid_pos.getPosition(); //WN150808 unused
514 /*PIDE*/bridge_.log(1, "<--ISA: " + MOVE_ACTIVE_ROOT_out);
515 /*---------------------------------------------------------------------------*/
516 java_calcid_to_smlcalcid_.put(new Integer(javaCalcID), new Integer(sml_calcid));
517 return_val = sml_calcid; //WN150808 SML_caldid --> JAVA frontend ?!?
521 /** MATH_ENGINE: val checkContext : calcID -> pos' -> guh -> XML.tree */
522 public Context checkContext(int javaCalcID, Context context, Position pos) throws RemoteException {
523 Context return_val = null;
524 /*---------------------------------------------------------------------------*/
525 //*TTY*/ResponseWrapper wrapper = interpretSML(javaCalcID,
526 //*TTY*/ "checkContext @calcid@ " + pos.toSMLString() + " \"" + context.getKEStoreKey().toString() + "\";", false);
527 //*TTY*/if(wrapper == null) return null;
528 //*TTY*/return_val = (Context) wrapper.getResponse();
529 /*---------------------------------------------------------------------------*/
530 /*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(javaCalcID));
531 /*PIDE*/bridge_.log(1, "-->ISA: " + "checkContext " + sml_id + " " + pos.toSMLString() + " \"" + context.getKEStoreKey().toString() + "\";");
533 /*PIDE*/XML.Tree xml_in = JavaToIsa.check_ctxt(new scala.math.BigInt(BigInteger.valueOf(sml_id)),
534 /*PIDE*/ pos, context.getKEStoreKey().toString() + "\"");
535 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
536 /*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(Operations.CHECK_CTXT, xml_in);
538 /*PIDE*/ContextTheory java_out = null;
539 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
540 /*PIDE*/ java_out = IsaToJava.check_ctxt_out(xml_out);
541 /*PIDE*/ return_val = java_out;
542 /*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
544 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: REVIEW!");
545 /*---------------------------------------------------------------------------*/
549 /** MATH_ENGINE: val DEconstrCalcTree : calcID -> XML.tree */
550 public boolean destruct(int javaCalcID) {
552 /*---------------------------------------------------------------------------*/
553 //*TTY*/ResponseWrapper wrapper = interpretSML(javaCalcID,
554 //*TTY*/ "DEconstrCalcTree @calcid@;", false);
555 //*TTY*/if (wrapper == null) { return_val = false; }
556 //*TTY*/inputs_.remove(new Integer(javaCalcID));
557 //*TTY*/return_val = true;
558 /*---------------------------------------------------------------------------*/
559 /*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(javaCalcID));
560 /*PIDE*/bridge_.log(1, "-->ISA: " + "DEconstrCalcTree " + sml_id);
561 /*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(Operations.DEL_CALC,
562 /*PIDE*/ new scala.math.BigInt(BigInteger.valueOf(sml_id)));
564 /*PIDE*/Integer java_out = IsaToJava.del_calc_out(xml_out);
565 /*PIDE*/return_val = true;
566 /*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
567 /*---------------------------------------------------------------------------*/
568 java_calcid_to_smlcalcid_.remove(new Integer(javaCalcID));
572 /** MATH_ENGINE: val fetchApplicableTactics : calcID -> int -> pos' -> XML.tree */
573 public Vector<Tactic> getAppliableTactics(int id, int scope, Position pos) {
574 Vector<Tactic> return_val = null;
575 /*---------------------------------------------------------------------------*/
576 //*TTY*/ResponseWrapper wrapper = interpretSML(id,
577 //*TTY*/ "fetchApplicableTactics @calcid@ " + scope + pos.toSMLString() + ";", false);
578 //*TTY*/if (wrapper == null) return null;
579 //*TTY*/TacticsContainer tc = (TacticsContainer) wrapper.getResponse();
580 //*TTY*/if( tc == null ) return null;
581 //*TTY*/return_val = tc.getTactics();
582 /*---------------------------------------------------------------------------*/
583 /*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(id));
584 /*PIDE*/bridge_.log(1, "-->ISA: " + "fetchApplicableTactics " + sml_id + " " + scope + pos.toSMLString() + ";");
586 /*PIDE*/XML.Tree xml_in = JavaToIsa.fetch_applicable_tacs(new scala.math.BigInt(BigInteger.valueOf(sml_id)),
587 /*PIDE*/ new scala.math.BigInt(BigInteger.valueOf(scope)), pos);
588 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
589 /*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(Operations.FETCH_APPL_TACS, xml_in);
591 /*PIDE*/IntTactics java_out = null;
592 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
593 /*PIDE*/ java_out = IsaToJava.fetch_applicable_tacs_out(xml_out);
594 /*PIDE*/ return_val = java_out.getTactics();
595 /*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
597 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: REVIEW!");
598 /*---------------------------------------------------------------------------*/
602 /** MATH_ENGINE: val fetchProposedTactic : calcID -> XML.tree */
603 public Tactic fetchProposedTactic(int id) {
604 Tactic return_val = null;
605 /*---------------------------------------------------------------------------*/
606 //*TTY*/ResponseWrapper wrapper = interpretSML(id, "fetchProposedTactic @calcid@;", false);
607 //*TTY*/if (wrapper == null) { return null; }
608 //*TTY*/return_val = (Tactic) wrapper.getResponse();
609 /*---------------------------------------------------------------------------*/
610 /*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(id));
611 /*PIDE*/bridge_.log(1, "-->ISA: " + "fetchProposedTactic " + sml_id + ";");
613 /*PIDE*/XML.Tree xml_in = JavaToIsa.fetch_proposed_tac(new scala.math.BigInt(BigInteger.valueOf(sml_id)));
614 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
615 /*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(Operations.FETCH_PROP_TAC, xml_in);
617 /*PIDE*/IntTacticErrPats java_out = null;
618 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
619 /*PIDE*/ java_out = IsaToJava.fetch_proposed_tac_out(xml_out);
620 /*PIDE*/ return_val = java_out.getTactic();
621 /*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
623 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: REVIEW!");
624 /*---------------------------------------------------------------------------*/
628 /** MATH_ENGINE: val findFillpatterns : calcID -> errpatID -> XML.tree
629 * only implemented in Math_Engine */
632 * @see isac.bridge.IBridgeRMI#getAccumulatedAssumptions(int,
633 * isac.util.formulae.Position)
635 * ** MATH_ENGINE: val getAccumulatedAsms : calcID -> pos' -> XML.tree
637 public Assumptions getAccumulatedAssumptions(int calcTreeID, Position pos) throws RemoteException {
638 Assumptions return_val = null;
639 /*---------------------------------------------------------------------------*/
640 //*TTY*/ResponseWrapper wrapper = interpretSML(calcTreeID,
641 //*TTY*/ "getAccumulatedAsms @calcid@ " + pos.toSMLString() + ";", false);
642 //*TTY*/return_val = (Assumptions) wrapper.getResponse();
643 /*---------------------------------------------------------------------------*/
644 /*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(calcTreeID));
645 /*PIDE*/bridge_.log(1, "-->ISA: " + "getAccumulatedAsms " + sml_id + " " + pos.toSMLString() + ";");
647 /*PIDE*/XML.Tree xml_in = JavaToIsa.get_accumulated_asms(new scala.math.BigInt(BigInteger.valueOf(sml_id)), pos);
648 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
649 /*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(Operations.GET_ACC_ASMS, xml_in);
651 /*PIDE*/IntAssumptions java_out = null;
652 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
653 /*PIDE*/ java_out = IsaToJava.get_accumulated_asms_out(xml_out);
654 /*PIDE*/ return_val = java_out.getAssumptions();
655 /*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
657 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: REVIEW!");
658 /*---------------------------------------------------------------------------*/
662 /** MATH_ENGINE: val getActiveFormula : calcID -> XML.tree */
663 public Position getActiveFormula(int javaCalcID) {
664 Position return_val = null;
665 /*---------------------------------------------------------------------------*/
666 //*TTY*/ResponseWrapper wrapper = interpretSML(javaCalcID,
667 //*TTY*/ "getActiveFormula @calcid@ ;", false);
668 //*TTY*/return_val = moveSuccess(wrapper);
669 /*---------------------------------------------------------------------------*/
670 /*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(javaCalcID));
671 /*PIDE*/bridge_.log(1, "-->ISA: " + "getActiveFormula " + sml_id + " ;");
673 /*PIDE*/XML.Tree xml_in = JavaToIsa.get_active_form(new scala.math.BigInt(BigInteger.valueOf(sml_id)));
674 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
675 /*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(Operations.GET_ACTIVE_FORM, xml_in);
677 /*PIDE*/IntPosition java_out = null;
678 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
679 /*PIDE*/ java_out = IsaToJava.get_active_form_out(xml_out);
680 /*PIDE*/ return_val = java_out.getPosition();
681 /*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
683 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: REVIEW!");
684 /*---------------------------------------------------------------------------*/
689 * @see isac.bridge.IBridgeRMI#getAssumption(int, int)
691 * MATH_ENGINE: val getAssumptions : calcID -> pos' -> XML.tree
693 public Assumptions getAssumptions(int calcTreeID, Position pos) throws RemoteException {
694 Assumptions return_val = null;
695 /*---------------------------------------------------------------------------*/
696 //*TTY*/ResponseWrapper wrapper = interpretSML(calcTreeID,
697 //*TTY*/ "getAssumptions @calcid@ " + pos.toSMLString() + ";", false);
698 //*TTY*/return_val = (Assumptions) wrapper.getResponse();
699 /*---------------------------------------------------------------------------*/
700 /*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(calcTreeID));
701 /*PIDE*/bridge_.log(1, "-->ISA: " + "getAssumptions " + sml_id + " " + pos.toSMLString() + ";");
703 /*PIDE*/XML.Tree xml_in = JavaToIsa.get_asms(new scala.math.BigInt(BigInteger.valueOf(sml_id)), pos);
704 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
705 /*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(Operations.GET_ASMS, xml_in);
707 /*PIDE*/IntAssumptions java_out = null;
708 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
709 /*PIDE*/ java_out = IsaToJava.get_asms_out(xml_out);
710 /*PIDE*/ return_val = java_out.getAssumptions();
711 /*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
713 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: REVIEW!");
714 /*---------------------------------------------------------------------------*/
718 /** MATH_ENGINE: val getFormulaeFromTo : calcID -> pos' -> pos' -> int -> bool -> XML.tree */
719 public Vector getFormulaeFromTo(int id, ICalcIterator iterator_from,
720 ICalcIterator iterator_to, Integer level, boolean result_includes_tactics) {
721 XML.Tree xml_in = null;
722 ResponseWrapper wrapper = null;
723 Vector return_val = null;
724 /*---------------------------------------------------------------------------*/
725 //*TTY*/try { wrapper = interpretSML(id, "getFormulaeFromTo @calcid@ "
726 //*TTY*/ + iterator_from.toSMLString() + " " + iterator_to.toSMLString()
727 //*TTY*/ + " " + level + " " + result_includes_tactics + ";", false);
728 //*TTY*/} catch (RemoteException e) { e.printStackTrace(); }
729 //*TTY*/if (wrapper == null) return null;
730 //*TTY*/FormHeadsContainer con = (FormHeadsContainer) wrapper.getResponse();
731 //*TTY*/if (con != null) return_val = con.getElements();
732 //*TTY*/else return_val = null;
733 /*---------------------------------------------------------------------------*/
734 /*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(id));
736 /*PIDE*/ bridge_.log(1, "-->ISA: " + "getFormulaeFromTo " + sml_id + " "
737 /*PIDE*/ + iterator_from.toSMLString() + " " + iterator_to.toSMLString()
738 /*PIDE*/ + " " + level + " " + result_includes_tactics + ";");
739 /*PIDE*/} catch (RemoteException e2) { e2.printStackTrace(); }
742 /*PIDE*/ xml_in = JavaToIsa.get_formulae(new scala.math.BigInt(BigInteger.valueOf(sml_id)),
743 /*PIDE*/ iterator_from.getPosition(), iterator_to.getPosition(),
744 /*PIDE*/ new scala.math.BigInt(BigInteger.valueOf(level)), result_includes_tactics);
745 /*PIDE*/} catch (RemoteException e1) { e1.printStackTrace(); }
746 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
747 /*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(Operations.GET_FORMULAE, xml_in);
749 /*PIDE*/IntFormulas java_out = null;
750 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
751 /*PIDE*/ java_out = IsaToJava.get_formulae_out(xml_out);
752 /*PIDE*/ return_val = java_out.getCalcFormulas();
753 /*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
755 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: REVIEW!");
756 /*---------------------------------------------------------------------------*/
761 * @see isac.bridge.IBridgeRMI#getTactic(int, int)
763 * MATH_ENGINE: val getTactic : calcID -> pos' -> XML.tree
765 public Tactic getTactic(int calcTreeID, Position pos) throws RemoteException {
766 Tactic return_val = null;
767 /*---------------------------------------------------------------------------*/
768 //*TTY*/ResponseWrapper wrapper = interpretSML(calcTreeID,
769 //*TTY*/ "getTactic @calcid@ " + pos.toSMLString() + ";", false);
770 //*TTY*/return_val = (Tactic) wrapper.getResponse();
771 /*---------------------------------------------------------------------------*/
772 /*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(calcTreeID));
773 /*PIDE*/bridge_.log(1, "-->ISA: " + "getTactic " + sml_id + " " + pos.toSMLString() + ";");
775 /*PIDE*/XML.Tree xml_in = JavaToIsa.get_tac(new scala.math.BigInt(BigInteger.valueOf(sml_id)), pos);
776 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
777 /*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(Operations.GET_TAC, xml_in);
779 /*PIDE*/IntTactic java_out = null;
780 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
781 /*PIDE*/ java_out = IsaToJava.get_tac_out(xml_out);
782 /*PIDE*/ return_val = java_out.getTactic();
783 /*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
785 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: REVIEW!");
786 /*---------------------------------------------------------------------------*/
790 /** MATH_ENGINE: val initContext : calcID -> ketype -> pos' -> XML.tree
792 * This method is implemented in Isabelle/Isac, but seems to never have been completed in Java.
793 * See isac.bridge.TestContext#testContext.
795 public Context initContext(int javaCalcID, ContextType type, Position pos) throws RemoteException {
796 Context return_val = null;
797 /*---------------------------------------------------------------------------*/
798 //*TTY*/ResponseWrapper wrapper = interpretSML(javaCalcID,
799 //*TTY*/ "initContext @calcid@ " + type.toSMLString() + " " + pos.toSMLString() + ";", false);
800 //*TTY*/if(wrapper == null) return null;
801 //*TTY*/return_val = (Context) wrapper.getResponse();
802 /*---------------------------------------------------------------------------*/
803 /*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(javaCalcID));
804 /*PIDE*/bridge_.log(1, "-->ISA: " + "initContext " + sml_id + " " + type.toSMLString() + " " + pos.toSMLString() + ";");
806 /*PIDE*/XML.Tree xml_in = JavaToIsa.init_ctxt(new scala.math.BigInt(BigInteger.valueOf(sml_id)), type, pos);
807 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
808 /*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(Operations.INIT_CTXT, xml_in);
810 /*PIDE*/Context java_out = null; // front-end later distinguishes ContextTheory, ContextProblem, ..
811 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
812 /*PIDE*/ java_out = (Context) IsaToJava.init_ctxt_out(xml_out);
813 /*PIDE*/ return_val = java_out;
814 /*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
816 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: REVIEW!");
817 /*---------------------------------------------------------------------------*/
821 /** MATH_ENGINE: val inputFillFormula: calcID -> string -> XML.tree
822 * only implemented in Math_Engine */
824 /** MATH_ENGINE: val interSteps : calcID -> pos' -> XML.tree */
825 public CEvent intermediateSteps(int id, ICalcIterator ci) {
826 CEvent return_val = null;
827 /*---------------------------------------------------------------------------*/
828 //*TTY*/ResponseWrapper wrapper = null;
830 //*TTY*/ wrapper = interpretSML(id, "interSteps @calcid@ " + ci.toSMLString() + ";", false);
831 //*TTY*/} catch (RemoteException e) { e.printStackTrace(); }
832 //*TTY*/if (wrapper == null) return null;
833 //*TTY*/return_val = (CEvent) wrapper.getResponse();
834 /*---------------------------------------------------------------------------*/
835 /*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(id));
836 /*PIDE*/XML.Tree xml_in = null;
838 /*PIDE*/ bridge_.log(1, "-->ISA: " + "interSteps " + sml_id + " " + ci.toSMLString() + ";");
839 /*PIDE*/} catch (RemoteException e1) { e1.printStackTrace(); }
842 /*PIDE*/ xml_in = JavaToIsa.inter_steps(new scala.math.BigInt(BigInteger.valueOf(sml_id)), ci.getPosition());
843 /*PIDE*/} catch (Exception e1) { e1.printStackTrace();}
844 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
845 /*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(Operations.INTER_STEPS, xml_in);
847 /*PIDE*/IntCEvent java_out = null;
848 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
849 /*PIDE*/ java_out = IsaToJava.inter_steps_out(xml_out);
850 /*PIDE*/ return_val = java_out.getCEvent();
851 /*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
853 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: REVIEW!");
854 /*---------------------------------------------------------------------------*/
858 /** MATH_ENGINE: val Iterator : calcID -> XML.tree */
859 public int iterator(int id) {
860 if (logger.isDebugEnabled())
861 logger.debug("iterator: id=" + id);
862 int return_val = 4711;
863 /*---------------------------------------------------------------------------*/
864 //*TTY*/if (id == 1) {
865 //*TTY*/ ResponseWrapper wrapper = interpretSML(id, "Iterator @calcid@;", false);
866 //*TTY*/ if (wrapper == null) return_val = -1;
867 //*TTY*/ else return_val = Integer.parseInt(((CalcHeadSimpleID) wrapper .getResponse()).getID());
868 //*TTY*/} else return_val = 4711;//TODO.WN041208 drop CalcIterator.iteratorID_
869 /*---------------------------------------------------------------------------*/
870 /*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(id));
871 /*PIDE*/bridge_.log(1, "-->ISA: " + "Iterator " + sml_id + ";");
873 /*PIDE*/BigInt xml_in = new scala.math.BigInt(BigInteger.valueOf(sml_id));
874 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
875 /*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(Operations.ITERATOR, xml_in);
877 /*PIDE*/IntIntCompound java_out = null;
878 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
879 /*PIDE*/ java_out = IsaToJava.iterator_out(xml_out);
880 /*PIDE*/ return_val = java_out.getCalcId().intValue();
881 /*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
883 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: REVIEW!");
884 /*---------------------------------------------------------------------------*/
889 * @see isac.interfaces.IToCalc#modelProblem()
891 * MATH_ENGINE: val modelProblem : calcID -> XML.tree
893 public CalcHead modelProblem(int calc_tree_id) throws RemoteException {
894 CalcHead return_val = null;
895 /*---------------------------------------------------------------------------*/
896 //*TTY*/ResponseWrapper wrapper = interpretSML(calc_tree_id, "modelProblem @calcid@;", false);
897 //*TTY*/return_val = (CalcHead) wrapper.getResponse();
898 /*---------------------------------------------------------------------------*/
899 /*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(calc_tree_id));
900 /*PIDE*/bridge_.log(1, "-->ISA: " + "modelProblem " + sml_id + ";");
902 /*PIDE*/BigInt xml_in = new scala.math.BigInt(BigInteger.valueOf(sml_id));
903 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
904 /*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(Operations.MODEL_PBL, xml_in);
906 /*PIDE*/IntCalcHead java_out = null;
907 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
908 /*PIDE*/ java_out = IsaToJava.modify_calchead_out(xml_out);
909 /*PIDE*/ return_val = java_out.getCalcHead();
910 /*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
912 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: REVIEW!");
913 /*---------------------------------------------------------------------------*/
918 * @see isac.interfaces.IToCalc#checkCalcHead(isac.util.formulae.CalcHead)
920 * MATH_ENGINE: val modifyCalcHead : calcID -> icalhd -> XML.tree
922 public CalcHead checkCalcHead(int calc_tree_id, CalcHead calchead) throws RemoteException {
923 CalcHead return_val = null;
924 /*---------------------------------------------------------------------------*/
925 //*TTY*/ResponseWrapper wrapper = interpretSML(calc_tree_id,
926 //*TTY*/ "modifyCalcHead @calcid@ " + calchead.toSMLString() + ";", false);
927 //*TTY*/return_val = (CalcHead) wrapper.getResponse();
928 /*---------------------------------------------------------------------------*/
929 /*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(calc_tree_id));
930 /*PIDE*/bridge_.log(1, "-->ISA: " + "modelProblem " + sml_id + ";");
932 /*PIDE*/XML.Tree xml_in = JavaToIsa.modify_calchead(new scala.math.BigInt(BigInteger.valueOf(sml_id)), calchead);
933 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
934 /*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(Operations.MODIFY_CALCHEAD, xml_in);
936 /*PIDE*/IntCalcHead java_out = null;
937 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
938 /*PIDE*/ java_out = IsaToJava.modify_calchead_out(xml_out);
939 /*PIDE*/ return_val = java_out.getCalcHead();
940 /*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
942 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: REVIEW!");
943 /*---------------------------------------------------------------------------*/
947 /** MATH_ENGINE: val moveActiveCalcHead : calcID -> XML.tree */
948 public Position moveCalcHead(int javaCalcID, int iteratorID, Position p) {
949 Position return_val = null;
950 /*---------------------------------------------------------------------------*/
951 //*TTY*/ResponseWrapper wrapper = null;
952 //*TTY*/if (iteratorID == 1)
953 //*TTY*/ wrapper = interpretSML(javaCalcID, "moveActiveCalcHead @calcid@" + ";", false);
955 //*TTY*/ wrapper = interpretSML(javaCalcID, "moveCalcHead @calcid@ " + " " + p.toSMLString() + ";", false);
956 //*TTY*/return_val = moveSuccess(wrapper);
957 /*---------------------------------------------------------------------------*/
958 /*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(javaCalcID));
959 /*PIDE*/XML.Tree xml_in = null;
960 /*PIDE*/XML.Tree xml_out = null;
962 /*PIDE*/if (iteratorID == 1) {
963 /*PIDE*/bridge_.log(1, "-->ISA: " + "moveActiveCalcHead " + sml_id + "" + ";");
964 /*PIDE*/xml_in = JavaToIsa.move_active_calchead(new scala.math.BigInt(BigInteger.valueOf(sml_id)));
965 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
966 /*PIDE*/xml_out = connection_to_kernel_.invoke(Operations.MOVE_ACTIVE_FORM, xml_in);
968 /*PIDE*/IntPosition java_out = null;
969 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
970 /*PIDE*/ java_out = IsaToJava.move_active_calchead_out(xml_out);
971 /*PIDE*/ return_val = java_out.getPosition();
972 /*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
974 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: REVIEW!");
978 /*PIDE*/bridge_.log(1, "-->ISA: " + "moveCalcHead " + sml_id + " " + " " + p.toSMLString() + ";");
979 /*PIDE*/xml_in = JavaToIsa.move_calchead(new scala.math.BigInt(BigInteger.valueOf(sml_id)), null);
980 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
981 /*PIDE*/xml_out = connection_to_kernel_.invoke(Operations.MOVE_ACTIVE_FORM, xml_in);
983 /*PIDE*/IntPosition java_out = null;
984 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
985 /*PIDE*/ java_out = IsaToJava.move_calchead_out(xml_out);
986 /*PIDE*/ return_val = java_out.getPosition();
987 /*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
989 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: REVIEW!");
991 /*---------------------------------------------------------------------------*/
995 /** MATH_ENGINE: val moveActiveDown : calcID -> XML.tree */
996 public Position moveDown(int javaCalcID, int iteratorID, Position p) {
997 if (logger.isDebugEnabled())
998 logger.debug("moveDown: javaCalcID=" + javaCalcID + ", sml_pos=" + p.toSMLString());
999 Position return_val = null;
1000 /*---------------------------------------------------------------------------*/
1001 //*TTY*/ResponseWrapper wrapper = null;
1002 //*TTY*/if (iteratorID == 1)
1003 //*TTY*/ wrapper = interpretSML(javaCalcID, "moveActiveDown @calcid@" + ";", false);
1005 //*TTY*/ wrapper = interpretSML(javaCalcID, "moveDown @calcid@ " + p.toSMLString() + ";", false);
1006 //*TTY*/return_val = moveSuccess(wrapper);
1007 /*---------------------------------------------------------------------------*/
1008 /*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(javaCalcID));
1009 /*PIDE*/XML.Tree xml_in = null;
1010 /*PIDE*/XML.Tree xml_out = null;
1012 /*PIDE*/if (iteratorID == 1) {
1013 /*PIDE*/bridge_.log(1, "-->ISA: " + "moveActiveDown " + sml_id + "" + ";");
1014 /*PIDE*/xml_in = JavaToIsa.move_active_down(new scala.math.BigInt(BigInteger.valueOf(sml_id)));
1015 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
1016 /*PIDE*/xml_out = connection_to_kernel_.invoke(Operations.MOVE_ACTIVE_DOWN, xml_in);
1018 /*PIDE*/IntPosition java_out = null;
1019 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
1020 /*PIDE*/ java_out = IsaToJava.move_active_down_out(xml_out);
1021 /*PIDE*/ return_val = java_out.getPosition();
1022 /*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
1024 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: REVIEW!");
1028 /*PIDE*/bridge_.log(1, "-->ISA: " + "moveDown " + sml_id + " " + p.toSMLString() + ";");
1029 /*PIDE*/xml_in = JavaToIsa.move_down(new scala.math.BigInt(BigInteger.valueOf(sml_id)), p);
1030 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
1031 /*PIDE*/xml_out = connection_to_kernel_.invoke(Operations.MOVE_DOWN, xml_in);
1033 /*PIDE*/IntPosition java_out = null;
1034 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
1035 /*PIDE*/ java_out = IsaToJava.move_down_out(xml_out);
1036 /*PIDE*/ return_val = java_out.getPosition();
1037 /*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
1039 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: REVIEW!");
1041 /*---------------------------------------------------------------------------*/
1046 * returns Position for uniformity with move*; not required elsewhere
1048 * MATH_ENGINE: val moveActiveFormula : calcID -> pos' -> XML.tree
1050 public Position moveActiveFormula(int javaCalcID, Position p) {
1051 if (logger.isDebugEnabled())
1052 logger.debug("moveDown: javaCalcID=" + javaCalcID + ", sml_pos=" + p.toSMLString());
1053 Position return_val = null;
1054 /*---------------------------------------------------------------------------*/
1055 //*TTY*/ResponseWrapper wrapper = interpretSML(javaCalcID,
1056 //*TTY*/ "moveActiveFormula @calcid@ " + p.toSMLString() + ";", false);
1057 //*TTY*/return_val = moveSuccess(wrapper);
1058 /*---------------------------------------------------------------------------*/
1059 /*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(javaCalcID));
1060 /*PIDE*/bridge_.log(1, "-->ISA: " + "moveActiveFormula " + sml_id + " " + p.toSMLString() + ";");
1062 /*PIDE*/XML.Tree xml_in = JavaToIsa.move_active_form(new scala.math.BigInt(BigInteger.valueOf(sml_id)), p);
1063 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
1064 /*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(Operations.MOVE_ACTIVE_FORM, xml_in);
1066 /*PIDE*/IntPosition java_out = null;
1067 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
1068 /*PIDE*/ java_out = IsaToJava.move_active_form_out(xml_out);
1069 /*PIDE*/ return_val = java_out.getPosition();
1070 /*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
1072 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: REVIEW!");
1073 /*---------------------------------------------------------------------------*/
1077 /** MATH_ENGINE: val moveActiveLevelDown : calcID -> XML.tree */
1078 public Position moveLevelDown(int javaCalcID, int iteratorID, Position p) {
1079 Position return_val = null;
1080 /*---------------------------------------------------------------------------*/
1081 //*TTY*/ResponseWrapper wrapper = null;
1082 //*TTY*/if (iteratorID == 1)
1083 //*TTY*/ wrapper = interpretSML(javaCalcID, "moveActiveLevelDown @calcid@" + ";", false);
1085 //*TTY*/ wrapper = interpretSML(javaCalcID, "moveLevelDown @calcid@ " + " " + p.toSMLString() + ";", false);
1086 //*TTY*/return_val = moveSuccess(wrapper);
1087 /*---------------------------------------------------------------------------*/
1088 /*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(javaCalcID));
1089 /*PIDE*/XML.Tree xml_in = null;
1090 /*PIDE*/XML.Tree xml_out = null;
1092 /*PIDE*/if (iteratorID == 1) {
1093 /*PIDE*/bridge_.log(1, "-->ISA: " + "moveActiveLevelDown " + sml_id + "" + ";");
1094 /*PIDE*/xml_in = JavaToIsa.move_active_levdown(new scala.math.BigInt(BigInteger.valueOf(sml_id)));
1095 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
1096 /*PIDE*/xml_out = connection_to_kernel_.invoke(Operations.MOVE_ACTIVE_LEVDN, xml_in);
1098 /*PIDE*/IntPosition java_out = null;
1099 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
1100 /*PIDE*/ java_out = IsaToJava.move_active_levdown_out(xml_out);
1101 /*PIDE*/ return_val = java_out.getPosition();
1102 /*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
1104 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: REVIEW!");
1108 /*PIDE*/bridge_.log(1, "-->ISA: " + "moveLevelDown " + sml_id + " " + " " + p.toSMLString() + ";");
1109 /*PIDE*/xml_in = JavaToIsa.move_levdn(new scala.math.BigInt(BigInteger.valueOf(sml_id)), p);
1110 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
1111 /*PIDE*/xml_out = connection_to_kernel_.invoke(Operations.MOVE_LEVDN, xml_in);
1113 /*PIDE*/IntPosition java_out = null;
1114 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
1115 /*PIDE*/ java_out = IsaToJava.move_levdn_out(xml_out);
1116 /*PIDE*/ return_val = java_out.getPosition();
1117 /*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
1119 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: REVIEW!");
1121 /*---------------------------------------------------------------------------*/
1125 /** MATH_ENGINE: val moveActiveLevelUp : calcID -> XML.tree */
1126 public Position moveLevelUp(int javaCalcID, int iteratorID, Position p) {
1127 Position return_val = null;
1128 /*---------------------------------------------------------------------------*/
1129 //*TTY*/ResponseWrapper wrapper = null;
1130 //*TTY*/if (iteratorID == 1)
1131 //*TTY*/ wrapper = interpretSML(javaCalcID, "moveActiveLevelUp @calcid@" + ";", false);
1133 //*TTY*/ wrapper = interpretSML(javaCalcID, "moveLevelUp @calcid@ " + p.toSMLString() + ";", false);
1134 //*TTY*/return_val = moveSuccess(wrapper);
1135 /*---------------------------------------------------------------------------*/
1136 /*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(javaCalcID));
1137 /*PIDE*/XML.Tree xml_in = null;
1138 /*PIDE*/XML.Tree xml_out = null;
1140 /*PIDE*/if (iteratorID == 1) {
1141 /*PIDE*/bridge_.log(1, "-->ISA: " + "moveActiveLevelUp " + sml_id + "" + ";");
1142 /*PIDE*/xml_in = JavaToIsa.move_active_levup(new scala.math.BigInt(BigInteger.valueOf(sml_id)));
1143 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
1144 /*PIDE*/xml_out = connection_to_kernel_.invoke(Operations.MOVE_ACTIVE_LEVUP, xml_in);
1145 /*PIDE*/xml_out = connection_to_kernel_.invoke(Operations.MOVE_ACTIVE_FORM, xml_in);
1147 /*PIDE*/IntPosition java_out = null;
1148 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
1149 /*PIDE*/ java_out = IsaToJava.move_active_levup_out(xml_out);
1150 /*PIDE*/ return_val = java_out.getPosition();
1151 /*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
1153 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: REVIEW!");
1157 /*PIDE*/bridge_.log(1, "-->ISA: " + "moveLevelUp " + sml_id + " " + p.toSMLString() + ";");
1158 /*PIDE*/xml_in = JavaToIsa.move_levup(new scala.math.BigInt(BigInteger.valueOf(sml_id)), p);
1159 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
1160 /*PIDE*/xml_out = connection_to_kernel_.invoke(Operations.MOVE_LEVUP, xml_in);
1162 /*PIDE*/IntPosition java_out = null;
1163 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
1164 /*PIDE*/ java_out = IsaToJava.move_levup_out(xml_out);
1165 /*PIDE*/ return_val = java_out.getPosition();
1166 /*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
1168 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: REVIEW!");
1170 /*---------------------------------------------------------------------------*/
1174 /** MATH_ENGINE: val moveActiveRoot : calcID -> XML.tree */
1175 public Position moveRoot(int javaCalcID, int iteratorID) {
1176 if (logger.isDebugEnabled())
1177 logger.debug("moveRoot: javaCalcID=" + javaCalcID);
1178 Position return_val = null;
1179 /*---------------------------------------------------------------------------*/
1180 //*TTY*/ResponseWrapper wrapper = null;
1181 //*TTY*/if (iteratorID == 1)
1182 //*TTY*/ wrapper = interpretSML(javaCalcID, "moveActiveRoot @calcid@" + ";", false);
1184 //*TTY*/ wrapper = interpretSML(javaCalcID, "moveRoot @calcid@ " + ";", false);
1185 //*TTY*/return_val = moveSuccess(wrapper);
1186 /*---------------------------------------------------------------------------*/
1187 /*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(javaCalcID));
1188 /*PIDE*/scala.math.BigInt xml_in = null;
1189 /*PIDE*/XML.Tree xml_out = null;
1191 /*PIDE*/if (iteratorID == 1) {
1192 /*PIDE*/bridge_.log(1, "-->ISA: " + "moveActiveRoot " + sml_id + "" + ";");
1193 /*PIDE*/xml_in = new scala.math.BigInt(BigInteger.valueOf(sml_id));
1194 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
1195 /*PIDE*/xml_out = connection_to_kernel_.invoke(Operations.MOVE_ACTIVE_ROOT, xml_in);
1197 /*PIDE*/IntPosition java_out = null;
1198 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
1199 /*PIDE*/ java_out = IsaToJava.move_active_root_out(xml_out);
1200 /*PIDE*/ return_val = java_out.getPosition();
1201 /*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
1203 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: REVIEW!");
1207 /*PIDE*/bridge_.log(1, "-->ISA: " + "moveRoot " + sml_id + " " + ";");
1208 /*PIDE*/XML.Tree xml_in2 = JavaToIsa.move_root(new scala.math.BigInt(BigInteger.valueOf(sml_id)));
1209 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in2);
1210 /*PIDE*/xml_out = connection_to_kernel_.invoke(Operations.MOVE_ROOT, xml_in2);
1212 /*PIDE*/IntPosition java_out = null;
1213 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
1214 /*PIDE*/ java_out = IsaToJava.move_root_out(xml_out);
1215 /*PIDE*/ return_val = java_out.getPosition();
1216 /*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
1218 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: REVIEW!");
1220 /*---------------------------------------------------------------------------*/
1224 /** MATH_ENGINE: val moveActiveRootTEST : calcID -> XML.tree
1225 * used only internally in Math_Engine */
1227 /** MATH_ENGINE: val moveActiveUp : calcID -> XML.tree */
1228 public Position moveUp(int javaCalcID, int iteratorID, Position p) {
1229 Position return_val = null;
1230 /*---------------------------------------------------------------------------*/
1231 //*TTY*/ResponseWrapper wrapper = null;
1232 //*TTY*/if (iteratorID == 1)
1233 //*TTY*/ wrapper = interpretSML(javaCalcID, "moveActiveUp @calcid@" + ";", false);
1235 //*TTY*/ wrapper = interpretSML(javaCalcID, "moveUp @calcid@ " + p.toSMLString() + ";", false);
1236 //*TTY*/return_val = moveSuccess(wrapper);
1237 /*---------------------------------------------------------------------------*/
1238 /*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(javaCalcID));
1239 /*PIDE*/XML.Tree xml_in = null;
1240 /*PIDE*/XML.Tree xml_out = null;
1242 /*PIDE*/if (iteratorID == 1) {
1243 /*PIDE*/xml_in = JavaToIsa.move_active_up(new scala.math.BigInt(BigInteger.valueOf(sml_id)));
1244 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
1245 /*PIDE*/xml_out = connection_to_kernel_.invoke(Operations.MOVE_ACTIVE_UP, xml_in);
1247 /*PIDE*/IntPosition java_out = null;
1248 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
1249 /*PIDE*/ java_out = IsaToJava.move_active_calchead_out(xml_out);
1250 /*PIDE*/ return_val = java_out.getPosition();
1251 /*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
1253 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: REVIEW!");
1257 /*PIDE*/bridge_.log(1, "-->ISA: " + "moveUp " + sml_id + " " + p.toSMLString() + ";");
1258 /*PIDE*/xml_in = JavaToIsa.move_up(new scala.math.BigInt(BigInteger.valueOf(sml_id)), p);
1259 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
1260 /*PIDE*/xml_out = connection_to_kernel_.invoke(Operations.MOVE_UP, xml_in);
1262 /*PIDE*/IntPosition java_out = null;
1263 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
1264 /*PIDE*/ java_out = IsaToJava.move_calchead_out(xml_out);
1265 /*PIDE*/ return_val = java_out.getPosition();
1266 /*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
1268 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: REVIEW!");
1270 /*---------------------------------------------------------------------------*/
1274 // /----- these methods are designed for a visitor of the CalcTree ------------\
1275 // (with a iteratorID > 1), e.g. a teacher watching the student.
1276 /** MATH_ENGINE: val moveCalcHead : calcID -> pos' -> XML.tree
1277 * does not exist in isac-java, see val moveActiveCalcHead */
1279 /** MATH_ENGINE: val moveDown : calcID -> pos' -> XML.tree
1280 * does not exist in isac-java, see val moveActiveDown */
1282 /** MATH_ENGINE: val val moveLevelDown : calcID -> pos' -> XML.tree
1283 * does not exist in isac-java, see val moveActiveLevelDown */
1285 /** MATH_ENGINE: val moveLevelUp : calcID -> pos' -> XML.tree
1286 * does not exist in isac-java, see val moveActiveLevelUp */
1288 /** MATH_ENGINE: val moveRoot : calcID -> XML.tree
1289 * does not exist in isac-java, see val moveActiveRoot */
1291 /** MATH_ENGINE: val moveUp : calcID -> pos' -> XML.tree
1292 * does not exist in isac-java, see val moveActiveUp */
1293 // \----- these methods are designed for a visitor of the CalcTree ------------/
1296 * @see isac.bridge.IBridgeRMI#getElement(int, int)
1297 * MATH_ENGINE: val refFormula : calcID -> pos' -> XML.tree
1299 public ICalcElement getElement(int javaCalcID, Position p) {
1300 ICalcElement return_val = null;
1301 /*---------------------------------------------------------------------------*/
1302 //*TTY*/ResponseWrapper wrapper = interpretSML(javaCalcID,
1303 //*TTY*/ "(*getElement*)refFormula @calcid@ " + p.toSMLString() + ";", false);
1304 //*TTY*/if (wrapper == null) return_val = null;
1305 //*TTY*/return_val = (ICalcElement) wrapper.getResponse();
1306 /*---------------------------------------------------------------------------*/
1307 /*PIDE*/int sml_calcid = ((Integer) java_calcid_to_smlcalcid_.get(new Integer(javaCalcID))).intValue();
1308 /*PIDE*/bridge_.log(1, "-->ISA: " + "(*getElement*)refFormula " + sml_calcid
1309 /*PIDE*/ + " " + p.toSMLString() + ";");
1311 /*PIDE*/XML.Tree xml_in = JavaToIsa.ref_formula(new scala.math.BigInt(BigInteger.valueOf(sml_calcid)), p);
1312 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
1313 /*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(Operations.REF_FORMULA, xml_in);
1315 /*PIDE*/IntFormHead java_out = null;
1316 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
1317 /*PIDE*/ java_out = IsaToJava.ref_formula_out(xml_out);
1318 /*PIDE*/ return_val = (ICalcElement)java_out.getFormHead();
1319 /*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
1321 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: REVIEW!");
1322 /*---------------------------------------------------------------------------*/
1327 * @see isac.bridge.IBridgeRMI#getFormula(int, int)
1328 * @deprecated in favour of getElement.
1329 * ... WN150812: never used although it is in IBridgeRMI !!
1331 * MATH_ENGINE: val refFormula : calcID -> pos' -> XML.tree
1333 public ICalcElement getFormula(int calcTreeID, Position p) throws RemoteException {
1334 ICalcElement return_val = null;
1335 /*---------------------------------------------------------------------------*/
1336 //*TTY*/ResponseWrapper wrapper = interpretSML(calcTreeID,
1337 //*TTY*/ "(*getFormula*)refFormula @calcid@ " + p.toSMLString() + ";", false);
1338 //*TTY*/if (wrapper == null) return_val = null;
1339 //*TTY*/else return_val = (ICalcElement) wrapper.getResponse();
1340 /*---------------------------------------------------------------------------*/
1341 /*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(calcTreeID));
1342 /*PIDE*/bridge_.log(1, "-->ISA: " + "(*getFormula*)refFormula " + sml_id + " " + p.toSMLString() + ";");
1344 /*PIDE*/XML.Tree xml_in = JavaToIsa.ref_formula(new scala.math.BigInt(BigInteger.valueOf(sml_id)), p);
1345 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
1346 /*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(Operations.REF_FORMULA, xml_in);
1348 /*PIDE*/IntFormHead java_out = null;
1349 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
1350 /*PIDE*/ java_out = IsaToJava.ref_formula_out(xml_out);
1351 /*PIDE*/ return_val = (ICalcElement)java_out.getFormHead();
1352 /*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
1354 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: REVIEW!");
1355 /*---------------------------------------------------------------------------*/
1359 /** MATH_ENGINE: val refineProblem : calcID -> pos' -> guh -> XML.tree
1360 * see notes WN150824 */
1361 public Context refineProblem(int javaCalcID, Context context, Position pos) throws RemoteException {
1362 Context return_val = null;
1363 /*---------------------------------------------------------------------------*/
1364 //*TTY*/ResponseWrapper wrapper = interpretSML(javaCalcID,
1365 //*TTY*/ "refineProblem @calcid@ " + pos.toSMLString() + " \"" + context.getKEStoreKey().toString() + "\";", false);
1366 //*TTY*/if(wrapper == null) return null;
1367 //*TTY*/return_val = (Context) wrapper.getResponse();
1368 /*---------------------------------------------------------------------------*/
1369 /*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(javaCalcID));
1370 /*PIDE*/bridge_.log(1, "-->ISA: " + "refineProblem " + sml_id + " " + pos.toSMLString() + " \"" + context.getKEStoreKey().toString() + "\";");
1372 /*PIDE*/XML.Tree xml_in = JavaToIsa.refine_pbl(new scala.math.BigInt(BigInteger.valueOf(sml_id)),
1373 /*PIDE*/ pos, context.getKEStoreKey().toString() + "\"");
1374 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
1375 /*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(Operations.REFINE_PBL, xml_in);
1377 /*PIDE*/IntContext java_out = null;
1378 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
1379 /*PIDE*/ java_out = IsaToJava.refine_pbl_out(xml_out);
1380 /*PIDE*/ return_val = java_out.getContext();
1381 /*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
1383 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: REVIEW!");
1384 /*---------------------------------------------------------------------------*/
1388 /** MATH_ENGINE: val replaceFormula : calcID -> cterm' -> XML.tree */
1389 public CEvent replaceFormula(int id, CalcFormula f) {
1390 CEvent return_val = null;
1391 /*---------------------------------------------------------------------------*/
1392 //*TTY*/ResponseWrapper wrapper = null;
1393 //*TTY*/wrapper = interpretSML(id, "replaceFormula @calcid@ \"" + f.toSMLString() + "\";", false);
1394 //*TTY*/if (wrapper == null) return_val = null;
1395 //*TTY*/else return_val = (CEvent) wrapper.getResponse();
1396 /*---------------------------------------------------------------------------*/
1397 /*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(id));
1398 /*PIDE*/bridge_.log(1, "-->ISA: " + "replaceFormula " + sml_id + " \"" + f.toSMLString() + "\";");
1400 /*PIDE*/XML.Tree xml_in = JavaToIsa.replace_form(new scala.math.BigInt(BigInteger.valueOf(sml_id)), f.getFormula());
1401 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
1402 /*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(Operations.REPLACE_FORM, xml_in);
1404 /*PIDE*/IntCEvent java_out = null;
1405 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
1406 /*PIDE*/ java_out = IsaToJava.replace_form_out(xml_out);
1407 /*PIDE*/ return_val = java_out.getCEvent();
1408 /*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
1410 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: REVIEW!");
1411 /*---------------------------------------------------------------------------*/
1415 /** MATH_ENGINE: val requestFillformula : calcID -> errpatID * fillpatID -> XML.tree
1416 * only implemented in Math_Engine */
1418 /** MATH_ENGINE: val resetCalcHead : calcID -> XML.tree */
1420 * @see isac.interfaces.IToCalc#resetCalcHead()
1422 public CalcHead resetCalcHead(int calc_tree_id) throws RemoteException {
1423 CalcHead return_val = null;
1424 /*---------------------------------------------------------------------------*/
1425 //*TTY*/ResponseWrapper wrapper = interpretSML(calc_tree_id, "resetCalcHead @calcid@;", false);
1426 //*TTY*/return_val = (CalcHead) wrapper.getResponse();
1427 /*---------------------------------------------------------------------------*/
1428 /*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(calc_tree_id));
1429 /*PIDE*/bridge_.log(1, "-->ISA: " + "resetCalcHead " + sml_id + ";");
1431 /*PIDE*/XML.Tree xml_in = JavaToIsa.reset_calchead(new scala.math.BigInt(BigInteger.valueOf(sml_id)));
1432 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
1433 /*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(Operations.RESET_CALCHEAD, xml_in);
1435 /*PIDE*/IntCalcHead java_out = null;
1436 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
1437 /*PIDE*/ java_out = IsaToJava.reset_calchead_out(xml_out);
1438 /*PIDE*/ return_val = java_out.getCalcHead();
1439 /*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
1441 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: REVIEW!");
1442 /*---------------------------------------------------------------------------*/
1446 /** MATH_ENGINE: val setContext : calcID -> pos' -> guh -> XML.tree */
1447 /* The status of this method is unclear:
1449 ** There is no use-case and no test
1450 ** The code is NOT used when showing the contexts
1451 * of thy, pbl, met, exp for example Biegelinie.
1452 ** The code is not deleted, nevertheless, because there is
1453 * code in isabisac: interface#setContext
1455 * So the changes for "isabelle tty" --> libisabelle adapt to the XML
1456 * sent from isabisac interface#setContext > autocalculateOK2xml.
1458 public CChanged setContext(int javaCalcID, ContextTheory context, Position pos ) throws RemoteException {
1459 CChanged return_val = null;
1460 /*---------------------------------------------------------------------------*/
1461 //*TTY*/ResponseWrapper wrapper = interpretSML(javaCalcID,
1462 //*TTY*/ "setContext @calcid@ " + pos.toSMLString() + " \"" + context.getKEStoreKey().toString() + "\";", false);
1463 //*TTY*/if(wrapper == null) return_val = null;
1464 //*TTY*/else return_val = (CChanged) wrapper.getResponse();
1465 /*---------------------------------------------------------------------------*/
1466 /*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(javaCalcID));
1467 /*PIDE*/bridge_.log(1, "-->ISA: " + "setContext " + sml_id + " " + pos.toSMLString() + " \"" + context.getKEStoreKey().toString() + "\";");
1469 /*PIDE*/XML.Tree xml_in = JavaToIsa.set_ctxt(new scala.math.BigInt(BigInteger.valueOf(sml_id)),
1470 /*PIDE*/ pos, context.getKEStoreKey().toString() + "\"");
1471 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
1472 /*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(Operations.SET_CTXT, xml_in);
1474 /*PIDE*/IntCEvent java_out = null;
1475 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
1476 /*PIDE*/ java_out = IsaToJava.set_ctxt_out(xml_out);
1477 /*PIDE*/ return_val = (CChanged) java_out.getCEvent();
1478 /*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
1480 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: REVIEW!");
1481 /*---------------------------------------------------------------------------*/
1486 * @see isac.interfaces.IToCalc#setMethod()
1488 * MATH_ENGINE: val setMethod : calcID -> metID -> XML.tree
1490 public CalcHead setMethod(int calc_tree_id, MethodID id) throws RemoteException {
1491 CalcHead return_val = null;
1492 /*---------------------------------------------------------------------------*/
1493 //*TTY*/ResponseWrapper wrapper = interpretSML(calc_tree_id,
1494 //*TTY*/ "setMethod @calcid@ " + id.toSMLString() + ";", false);
1495 //*TTY*/return_val = (CalcHead) wrapper.getResponse();
1496 /*---------------------------------------------------------------------------*/
1497 /*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(calc_tree_id));
1498 /*PIDE*/bridge_.log(1, "-->ISA: " + "setMethod " + sml_id + " " + id.toSMLString() + ";");
1500 /*PIDE*/XML.Tree xml_in = JavaToIsa.set_met(new scala.math.BigInt(BigInteger.valueOf(sml_id)), id.getID());
1501 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
1502 /*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(Operations.SET_MET, xml_in);
1504 /*PIDE*/IntCalcHead java_out = null;
1505 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
1506 /*PIDE*/ java_out = IsaToJava.set_met_out(xml_out);
1507 /*PIDE*/ return_val = java_out.getCalcHead();
1508 /*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
1510 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: REVIEW!");
1511 /*---------------------------------------------------------------------------*/
1515 /** MATH_ENGINE: val setNextTactic : calcID -> tac -> XML.tree */
1516 public int setNextTactic(int id, Tactic tactic) {
1517 int return_val = 4711;
1518 /*---------------------------------------------------------------------------*/
1519 //*TTY*/ResponseWrapper wrapper = interpretSML(id,
1520 //*TTY*/ "setNextTactic @calcid@ (" + tactic.toSMLString() + ");", false);
1521 //*TTY*/if (wrapper == null) return_val = -1;//WN050223 response ... MESSAGE not parsed
1522 //*TTY*/if (wrapper.getResponse() == null) { return_val = 0; //Everything is ok
1523 //*TTY*/} else { return_val = -1; } //An Error occcured
1524 /*---------------------------------------------------------------------------*/
1525 /*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(id));
1526 /*PIDE*/bridge_.log(1, "-->ISA: " + "setNextTactic " + sml_id + " (" + tactic.toSMLString() + ");");
1528 /*PIDE*/XML.Tree xml_in = JavaToIsa.set_next_tac(new scala.math.BigInt(BigInteger.valueOf(sml_id)), tactic);
1529 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
1530 /*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(Operations.SET_NEXT_TAC, xml_in);
1532 /*PIDE*/Message java_out = null;
1533 /*PIDE*/if (!IsaToJava.is_syserror(xml_out)) {
1534 /*PIDE*/ java_out = IsaToJava.set_next_tac_out(xml_out); //DialogGuide handles no Messages, still WN150821
1535 /*PIDE*/ return_val = 0; //Everything is ok
1536 /*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
1538 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_syserror: REVIEW!");
1540 /*---------------------------------------------------------------------------*/
1545 * @see isac.interfaces.IToCalc#setProblem()
1547 * MATH_ENGINE: val setProblem : calcID -> pblID -> XML.tree
1549 public CalcHead setProblem(int calc_tree_id, ProblemID id) throws RemoteException {
1550 CalcHead return_val = null;
1551 /*---------------------------------------------------------------------------*/
1552 //*TTY*/ResponseWrapper wrapper = interpretSML(calc_tree_id,
1553 //*TTY*/ "setProblem @calcid@ " + id.toSMLString() + ";", false);
1554 //*TTY*/return_val = (CalcHead) wrapper.getResponse();
1555 /*---------------------------------------------------------------------------*/
1556 /*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(calc_tree_id));
1557 /*PIDE*/bridge_.log(1, "-->ISA: " + "setProblem " + sml_id + " " + id.toSMLString() + ";");
1559 /*PIDE*/XML.Tree xml_in = JavaToIsa.set_met(new scala.math.BigInt(BigInteger.valueOf(sml_id)), id.getID());
1560 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
1561 /*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(Operations.SET_PBL, xml_in);
1563 /*PIDE*/IntCalcHead java_out = null;
1564 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
1565 /*PIDE*/ java_out = IsaToJava.set_met_out(xml_out);
1566 /*PIDE*/ return_val = java_out.getCalcHead();
1567 /*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
1569 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: REVIEW!");
1570 /*---------------------------------------------------------------------------*/
1575 * @see isac.interfaces.IToCalc#setTheory()
1577 * TODO/WN150812: use implementation in Math_Engine.
1578 * MATH_ENGINE: val setTheory : calcID -> thyID -> XML.tree
1580 public CalcHead setTheory(int calc_tree_id, String thy_id)
1581 throws RemoteException {
1582 CalcHead return_val = null;
1583 Position pos = null;
1584 /*---------------------------------------------------------------------------*/
1585 //*TTY*///---FIXXXME.WN050809 hack until setTheory pushed into SML-kernel
1586 //*TTY*/ResponseWrapper wrapper = interpretSML(calc_tree_id,
1587 //*TTY*/ "(*setTheory*)setNextTactic @calcid@ (Specify_Theory \"" + thy_id + "\");", false);
1588 //*TTY*/wrapper = interpretSML(calc_tree_id,
1589 //*TTY*/ "(*setTheory*)autoCalculate @calcid@ (Step 1);", false);
1590 //*TTY*///drop the CalcChanged returned by autoCalculate
1591 //*TTY*/wrapper = interpretSML(calc_tree_id,
1592 //*TTY*/ "(*setTheory*)getActiveFormula @calcid@ ;", false);
1593 //*TTY*/pos = moveSuccess(wrapper);
1594 //*TTY*/wrapper = interpretSML(calc_tree_id,
1595 //*TTY*/ "(*setTheory*)refFormula @calcid@ " + pos.toSMLString() + ";", false);
1596 //*TTY*/return_val = (CalcHead) wrapper.getResponse();
1598 /*---------------------------------------------------------------------------*/
1599 //---FIXXXME.WN050809 hack until setTheory pushed into SML-kernel
1600 /*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(calc_tree_id));
1602 /*PIDE*/bridge_.log(1, "-->ISA: " + "(*setTheory*)setNextTactic " + sml_id + " (Specify_Theory \"" + thy_id + "\");");
1603 /*PIDE*/SimpleTactic tac = new SimpleTactic("Specify_Theory", thy_id + "\"");
1604 /*PIDE*/XML.Tree xml_in = JavaToIsa.set_next_tac(new scala.math.BigInt(BigInteger.valueOf(sml_id)), tac);
1605 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
1606 /*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(Operations.SET_NEXT_TAC, xml_in);
1607 /*PIDE*/bridge_.log(1, "<--ISA: message not sent to Dialog ... " + xml_out);
1609 /*PIDE*/bridge_.log(1, "-->ISA: " + "(*setTheory*)autoCalculate " + sml_id + " (Step 1);");
1610 /*PIDE*/xml_in = JavaToIsa.auto_calculate(new scala.math.BigInt(BigInteger.valueOf(sml_id)),
1611 /*PIDE*/ "Step", new scala.math.BigInt(BigInteger.valueOf(1)));
1612 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
1613 /*PIDE*/xml_out = connection_to_kernel_.invoke(Operations.AUTO_CALC, xml_in);
1614 /*PIDE*/bridge_.log(1, "<--ISA: CalcChanged not sent to Dialog ... " + xml_out);
1616 /*PIDE*/bridge_.log(1, "-->ISA: " + "(*setTheory*)getActiveFormula " + sml_id + ";");
1617 /*PIDE*/xml_in = JavaToIsa.get_active_form(new scala.math.BigInt(BigInteger.valueOf(sml_id)));
1618 /*PIDE*/xml_out = connection_to_kernel_.invoke(Operations.GET_ACTIVE_FORM, xml_in);
1619 /*PIDE*/IntPosition java_out = null;
1620 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
1621 /*PIDE*/ java_out = IsaToJava.get_active_form_out(xml_out);
1622 /*PIDE*/ pos = java_out.getPosition();
1623 /*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
1625 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: REVIEW!");
1627 /*PIDE*/bridge_.log(1, "-->ISA: " + "(*setTheory*)refFormula " + sml_id + " " + pos.toSMLString() + ";");
1628 /*PIDE*/xml_in = JavaToIsa.ref_formula(new scala.math.BigInt(BigInteger.valueOf(sml_id)), pos);//^^pos.setKind("DUMMY")
1629 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
1630 /*PIDE*/xml_out = connection_to_kernel_.invoke(Operations.REF_FORMULA, xml_in);
1632 /*PIDE*/IntFormHead java_out2 = null;
1633 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
1634 /*PIDE*/ java_out2 = IsaToJava.ref_formula_out(xml_out);
1635 /*PIDE*/ return_val = (CalcHead)java_out2.getFormHead();
1636 /*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
1638 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: REVIEW!");
1639 /*PIDE*///\---End hack
1640 /*---------------------------------------------------------------------------*/
1644 /***********************************************************************
1645 * Below are methods not contained in MATH_ENGINE, rather
1646 * they composed from other methods in Math_Engine.
1650 * @see isac.interfaces.IToCalc#completeCalcHead()
1652 public CalcHead completeCalcHead(int calc_tree_id) {
1653 CalcHead return_val = null;
1654 Position pos = null;
1655 /*---------------------------------------------------------------------------*/
1656 //*TTY*///---FIXXXME.WN050809 hack until setTheory pushed into SML-kernel
1657 //*TTY*/ResponseWrapper wrapper = interpretSML(calc_tree_id,
1658 //*TTY*/ "(*completeCalcHead*)autoCalculate @calcid@ CompleteCalcHead;", false);
1659 //*TTY*///drop the CalcChanged returned by autoCalculate
1660 //*TTY*/wrapper = interpretSML(calc_tree_id,
1661 //*TTY*/ "(*completeCalcHead*)getActiveFormula @calcid@ ;", false);
1662 //*TTY*/pos = moveSuccess(wrapper);
1663 //*TTY*/wrapper = interpretSML(calc_tree_id,
1664 //*TTY*/ "(*completeCalcHead*)refFormula @calcid@ " + pos.toSMLString() + ";", false);
1665 //*TTY*/return_val = (CalcHead) wrapper.getResponse();
1666 //*TTY*///\---End hack
1667 /*---------------------------------------------------------------------------*/
1668 //---FIXXXME.WN050809 hack until setTheory pushed into SML-kernel
1669 /*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(calc_tree_id));
1671 /*PIDE*/bridge_.log(1, "-->ISA: " + "(*completeCalcHead*)autoCalculate " + sml_id + "CompleteCalcHead;");
1672 /*PIDE*/XML.Tree xml_in = JavaToIsa.auto_calculate(new scala.math.BigInt(BigInteger.valueOf(sml_id)),
1673 /*PIDE*/ "CompleteCalcHead", new scala.math.BigInt(BigInteger.valueOf(0)));
1674 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
1675 /*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(Operations.AUTO_CALC, xml_in);
1677 /*PIDE*/IntCEvent java_out = null;
1678 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
1679 /*PIDE*/ java_out = IsaToJava.auto_calc_out(xml_out);
1680 /*PIDE*/// return_val = java_out.getCEvent();
1681 /*PIDE*/bridge_.log(1, "<--ISA: not sent to Dialog ... " + xml_out);
1683 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: REVIEW!");
1686 /*PIDE*/bridge_.log(1, "-->ISA: " + "(*completeCalcHead*)getActiveFormula " + sml_id + ";");
1687 /*PIDE*/xml_in = JavaToIsa.get_active_form(new scala.math.BigInt(BigInteger.valueOf(sml_id)));
1688 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
1689 /*PIDE*/xml_out = connection_to_kernel_.invoke(Operations.GET_ACTIVE_FORM, xml_in);
1691 /*PIDE*/IntPosition java_out2 = null;
1692 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
1693 /*PIDE*/ java_out2 = IsaToJava.get_active_form_out(xml_out);
1694 /*PIDE*/ pos = java_out2.getPosition();
1695 /*PIDE*/bridge_.log(1, "<--ISA: used locally ... " + xml_out);
1697 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: REVIEW!");
1700 /*PIDE*/bridge_.log(1, "-->ISA: " + "(*completeCalcHead*)refFormula " + sml_id + pos.toSMLString() + ";");
1701 /*PIDE*/xml_in = JavaToIsa.ref_formula(new scala.math.BigInt(BigInteger.valueOf(sml_id)), pos);
1702 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
1703 /*PIDE*/xml_out = connection_to_kernel_.invoke(Operations.REF_FORMULA, xml_in);
1705 /*PIDE*/IntFormHead java_out3 = null;
1706 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
1707 /*PIDE*/ java_out3 = IsaToJava.ref_formula_out(xml_out);
1708 /*PIDE*/ return_val = (CalcHead)java_out3.getFormHead();
1709 /*PIDE*/bridge_.log(1, "<--ISA: used locally ... " + xml_out);
1711 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: REVIEW!");
1712 /*PIDE*///\---End hack
1713 /*---------------------------------------------------------------------------*/
1718 * @see isac.interfaces.IToCalc#completeModel() WN050809 push this method
1719 * through to the SML-kernel
1721 public CalcHead completeModel(int calc_tree_id) throws RemoteException {
1722 CalcHead return_val = null;
1723 Position pos = null;
1724 /*---------------------------------------------------------------------------*/
1725 //*TTY*///---FIXXXME.WN050809 hack until setTheory pushed into SML-kernel
1726 //*TTY*/ResponseWrapper wrapper = interpretSML(calc_tree_id,
1727 //*TTY*/ "(*completeModel*)autoCalculate @calcid@ CompleteModel;", false);
1728 //*TTY*///drop the CalcChanged returned by autoCalculate
1729 //*TTY*/wrapper = interpretSML(calc_tree_id,
1730 //*TTY*/ "(*completeModel*)getActiveFormula @calcid@ ;", false);
1731 //*TTY*/pos = moveSuccess(wrapper);
1732 //*TTY*/wrapper = interpretSML(calc_tree_id,
1733 //*TTY*/ "(*completeModel*)refFormula @calcid@ " + pos.toSMLString() + ";", false);
1734 //*TTY*/return_val = (CalcHead) wrapper.getResponse();
1736 /*---------------------------------------------------------------------------*/
1737 //---FIXXXME.WN050809 hack until setTheory pushed into SML-kernel
1738 /*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(calc_tree_id));
1740 /*PIDE*/bridge_.log(1, "-->ISA: " + "(*completeModel*)autoCalculate " + sml_id + " CompleteModel;");
1741 /*PIDE*/XML.Tree xml_in = JavaToIsa.auto_calculate(new scala.math.BigInt(BigInteger.valueOf(sml_id)),
1742 /*PIDE*/ "CompleteModel", new scala.math.BigInt(BigInteger.valueOf(0)));
1743 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
1744 /*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(Operations.AUTO_CALC, xml_in);
1746 /*PIDE*/IntCalcHead java_out = null;
1747 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
1748 /*PIDE*/ java_out = IsaToJava.set_met_out(xml_out);
1749 /*PIDE*/bridge_.log(1, "<--ISA: not sent to Dialog = " + xml_out);
1751 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: REVIEW!");
1754 /*PIDE*/bridge_.log(1, "-->ISA: " + "(*completeModel*)getActiveFormula " + sml_id + ";");
1755 /*PIDE*/xml_in = JavaToIsa.get_active_form(new scala.math.BigInt(BigInteger.valueOf(sml_id)));
1756 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
1757 /*PIDE*/xml_out = connection_to_kernel_.invoke(Operations.GET_ACTIVE_FORM, xml_in);
1759 /*PIDE*/IntPosition java_out2 = null;
1760 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
1761 /*PIDE*/ java_out2 = IsaToJava.get_active_form_out(xml_out);
1762 /*PIDE*/ pos = java_out2.getPosition();
1763 /*PIDE*/bridge_.log(1, "<--ISA: used locally ... " + xml_out);
1765 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: REVIEW!");
1767 /*PIDE*/bridge_.log(1, "-->ISA: " + "(*completeModel*)refFormula " + sml_id + " " + pos.toSMLString() + ";");
1768 /*PIDE*/xml_in = JavaToIsa.ref_formula(new scala.math.BigInt(BigInteger.valueOf(sml_id)), pos);
1769 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
1770 /*PIDE*/xml_out = connection_to_kernel_.invoke(Operations.REF_FORMULA, xml_in);
1772 /*PIDE*/IntFormHead java_out3 = null;
1773 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
1774 /*PIDE*/ java_out3 = IsaToJava.ref_formula_out(xml_out);
1775 /*PIDE*/ return_val = (CalcHead)java_out3.getFormHead();
1776 /*PIDE*/bridge_.log(1, "<--ISA: used locally ... " + xml_out);
1778 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: REVIEW!");
1779 /*PIDE*///\---End hack
1780 /*---------------------------------------------------------------------------*/
1785 * @see isac.interfaces.IToCalc#nextSpecify() WN050809 push this method
1786 * through to the SML-kernel.
1788 public CalcHead nextSpecify(int calc_tree_id) throws RemoteException {
1789 CalcHead return_val = null;
1790 Position pos = null;
1791 /*---------------------------------------------------------------------------*/
1792 //*TTY*///---FIXXXME.WN050809 hack until setTheory pushed into SML-kernel
1793 //*TTY*/ResponseWrapper wrapper = interpretSML(calc_tree_id,
1794 //*TTY*/ "(*nextSpecify*)autoCalculate @calcid@ (Step 1);", false);
1795 //*TTY*///drop the CalcChanged returned by autoCalculate
1796 //*TTY*/wrapper = interpretSML(calc_tree_id,
1797 //*TTY*/ "(*nextSpecify*)getActiveFormula @calcid@ ;", false);
1798 //*TTY*/pos = moveSuccess(wrapper);
1799 //*TTY*/wrapper = interpretSML(calc_tree_id,
1800 //*TTY*/ "(*nextSpecify*)refFormula @calcid@ " + pos.toSMLString() + ";", false);
1801 //*TTY*/return_val = (CalcHead) wrapper.getResponse();
1802 //*TTY*///\---End hack
1803 /*---------------------------------------------------------------------------*/
1804 /*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(calc_tree_id));
1805 /*PIDE*///---FIXXXME.WN050809 hack until setTheory pushed into SML-kernel
1807 /*PIDE*/bridge_.log(1, "-->ISA: " + "(*nextSpecify*)autoCalculate " + sml_id + " (Step 1);");
1808 /*PIDE*/XML.Tree xml_in = JavaToIsa.auto_calculate(new scala.math.BigInt(BigInteger.valueOf(sml_id)),
1809 /*PIDE*/ "Step", new scala.math.BigInt(BigInteger.valueOf(1)));
1810 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
1811 /*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(Operations.AUTO_CALC, xml_in);
1813 /*PIDE*/IntCalcHead java_out = null;
1814 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
1815 /*PIDE*/ java_out = IsaToJava.set_met_out(xml_out);
1816 /*PIDE*/bridge_.log(1, "<--ISA: not sent to Dialog = " + xml_out);
1818 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: REVIEW!");
1821 /*PIDE*/bridge_.log(1, "-->ISA: " + "(*nextSpecify*)getActiveFormula " + sml_id + ";");
1822 /*PIDE*/xml_in = JavaToIsa.get_active_form(new scala.math.BigInt(BigInteger.valueOf(sml_id)));
1823 /*PIDE*/xml_out = connection_to_kernel_.invoke(Operations.GET_ACTIVE_FORM, xml_in);
1825 /*PIDE*/IntPosition java_out2 = null;
1826 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
1827 /*PIDE*/ java_out2 = IsaToJava.get_active_form_out(xml_out);
1828 /*PIDE*/ pos = java_out2.getPosition();
1829 /*PIDE*/bridge_.log(1, "<--ISA: used locally ... " + xml_out);
1831 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: REVIEW!");
1834 /*PIDE*/bridge_.log(1, "-->ISA: " + "(*nextSpecify*)refFormula " + sml_id + pos.toSMLString() + ";");
1835 /*PIDE*/xml_in = JavaToIsa.ref_formula(new scala.math.BigInt(BigInteger.valueOf(sml_id)), pos);//^^pos.setKind("DUMMY")
1836 /*PIDE*/bridge_.log(1, "-->ISA: " + xml_in);
1837 /*PIDE*/xml_out = connection_to_kernel_.invoke(Operations.REF_FORMULA, xml_in);
1839 /*PIDE*/IntFormHead java_out3 = null;
1840 /*PIDE*/if (!IsaToJava.is_message(xml_out)) {
1841 /*PIDE*/ java_out3 = IsaToJava.ref_formula_out(xml_out);
1842 /*PIDE*/ return_val = (CalcHead)java_out3.getFormHead();
1843 /*PIDE*/bridge_.log(1, "<--ISA: used locally ... " + xml_out);
1845 /*PIDE*/ bridge_.log(1, "<--ISA: IsaToJava.is_message: REVIEW!");
1846 /*PIDE*///\---End hack
1847 /*---------------------------------------------------------------------------*/
1851 /***********************************************************************
1852 * Below are methods not implemented in MATH_ENGINE at all,
1853 * or only very fragmentarily.
1854 * WN150812 here are also methods, where the status is not clarified.
1855 * Some methods seem to be replaced by similar ones.
1856 * TODO: review IBridgeRMI, MathEngine, etc.
1860 * @see isac.interfaces.ICalcIterator#tryMatchMethod(MethodID)
1861 * @deprecated WN150812: not impl. in Math_Engine.
1863 public Match initMatchMethod(int javaCalcID) throws RemoteException {
1864 ResponseWrapper wrapper = interpretSML(javaCalcID,
1865 "initMatchMethod @calcid@ ;", false);
1866 Object response = wrapper.getResponse();
1867 CalcHead ch = (CalcHead) response;
1868 Match m = new Match(ch.getSpecification().getProblem(), ch
1869 .getStatusString(), ch.getHeadLine(), ch.getModel());
1874 * @see isac.interfaces.ICalcIterator#tryMatchProblem(HierarchyKey)
1875 * @deprecated WN150812: not impl. in Math_Engine.
1877 public Match initMatchProblem(int javaCalcID) {
1878 ResponseWrapper wrapper = interpretSML(javaCalcID,
1879 "initMatchProblem @calcid@ ;", false);
1880 Object response = wrapper.getResponse();
1881 CalcHead ch = (CalcHead) response;
1882 Match m = new Match(ch.getSpecification().getProblem(), ch
1883 .getStatusString(), ch.getHeadLine(), ch.getModel());
1888 * @deprecated in favour of getFormula
1889 * WN150812: but used frequently ?!
1891 public boolean moveFormula(int javaCalcID, int iteratorID) {
1892 ResponseWrapper wrapper = interpretSML(javaCalcID,
1893 "moveFormula @calcid@ " + iteratorID + ";", false);
1894 return true;//WN041208 moveSuccess(wrapper);
1897 /** WN150812 unused ? */
1898 private Position moveSuccess(ResponseWrapper wrapper) {
1899 if (wrapper == null)
1902 Object r = wrapper.getResponse();
1903 if (r instanceof CMessage)
1904 return null;//TODO.WN041209 handle messages
1906 Position p = (Position) wrapper.getResponse();
1913 * @deprecated in favour of getTactic
1914 * WN150812: but used frequently ?!
1916 public boolean moveTactic(int javaCalcID, int iteratorID) {
1917 ResponseWrapper wrapper = interpretSML(javaCalcID,
1918 "moveTactic @calcid@ " + iteratorID + ";", false);
1919 return true;//WN041208 moveSuccess(wrapper);
1923 * @see isac.interfaces.ICalcIterator#tryMatchMethod(MethodID)
1924 * @deprecated is not impl. in math-engine !!!
1926 public Match tryMatchMethod(int javaCalcID, MethodID keStoreID)
1927 throws RemoteException {
1928 ResponseWrapper wrapper = interpretSML(javaCalcID,
1929 "tryMatchMethod @calcid@ " + keStoreID.toSMLString() + ";",
1931 Object response = wrapper.getResponse();
1932 CalcHead ch = (CalcHead) response;
1933 Match m = new Match(ch.getSpecification().getProblem(), ch
1934 .getStatusString(), ch.getHeadLine(), ch.getModel());
1938 /** enforced by IBridgeRMI, WN150812: exp-, met-, pbl-, thy-contexts all work --
1939 * -- see: CChanged setContext(int, ContextTheory, ... */
1941 public CalcHead setContext(int javaCalcID, ContextMethod context, Position pos) throws RemoteException {
1945 /** enforced by IBridgeRMI, WN150812: exp-, met-, pbl-, thy-contexts all work --
1946 * -- see: CChanged setContext(int, ContextTheory, ...
1947 * This method changed role with ^^^^^^^^^^^^^^^^ during "isabelle tty" --> libisabelle
1950 public CalcHead setContext(int javaCalcID, ContextProblem context, Position pos) throws RemoteException {
1955 * @see isac.interfaces.ICalcIterator#tryMatchProblem(HierarchyKey)
1957 * WN150812: tryMatchProblem, trymatch only partially implemented in Math_Engine
1959 public Match tryMatchProblem(int javaCalcID, ProblemID problemID) {
1960 ResponseWrapper wrapper = interpretSML(javaCalcID,
1961 "tryMatchProblem @calcid@ " + problemID.toSMLString() + ";",
1963 Object response = wrapper.getResponse();
1964 CalcHead ch = (CalcHead) response;
1965 Match m = new Match(ch.getSpecification().getProblem(), ch
1966 .getStatusString(), ch.getHeadLine(), ch.getModel());
1971 * @see isac.interfaces.ICalcIterator#tryRefineProblem(HierarchyKey)
1972 * @deprecated in favour of refineProblem.
1974 public Match tryRefineProblem(int javaCalcID, ProblemID problemID) {
1975 ResponseWrapper wrapper = interpretSML(javaCalcID,
1976 "tryRefineProblem @calcid@ " + problemID.toSMLString() + ";",
1978 Object response = wrapper.getResponse();
1979 CalcHead ch = (CalcHead) response;
1980 Match m = new Match(ch.getSpecification().getProblem(), ch
1981 .getStatusString(), ch.getHeadLine(), ch.getModel());
1985 /***********************************************************************
1986 * Below are methods for restoring Isabelle/Isac after a crash.
1987 * This never worked, is to be deleted and
1988 * to be reconsidered with introduction of libisabelle.
1992 * This method is used when the kernel crashes and the CalcTrees need to be
1993 * entered again to the kernel to restore the previous state. The
1994 * Java-CalcIDs stay the same
1996 public void restoreExistingCalcTrees() {
1997 bridge_.log(1, "---- entering restoreExistingCalcTrees");
1998 Iterator it = java_calcid_to_smlcalcid_.keySet().iterator();
1999 // keySet = javaCalcIDs
2000 int javaCalcID, newSmlCalcID;
2002 while (it.hasNext()) {
2003 //bridge.log(1, "1");
2004 //int i = ((Integer)it.next()).intValue();
2005 javaCalcID = ((Integer) it.next()).intValue();
2006 //bridge.log(1, "2");
2007 v = saveCalcTree(javaCalcID);
2008 //bridge.log(1, "3");
2009 this.restoreToSML(javaCalcID, v);
2011 bridge_.log(1, "---- done restoreExistingCalcTrees");
2014 private void restoreToSML(int javaCalcID, Vector v) {
2015 Iterator it = ((Vector) v.clone()).iterator();
2016 CalcTree result = null;
2017 String s = (String) it.next();
2018 int smlCalcID = newCalculation(javaCalcID, s, null/*never worked*/, true);
2019 //javaCalcIDtoSmlCalcID.put(new Integer(javaCalcID), new
2020 // Integer(smlCalcID));
2021 //int smlID = ((Integer)javaCalcIDtoSmlCalcID.get(new
2022 // Integer(calcID))).intValue();
2023 while (it.hasNext()) {
2024 s = (String) it.next();
2025 interpretSML(javaCalcID, s, true);
2030 * Save a calcTree for later restoring (probably to another SML Kernel)
2033 * the ID of the calcTree
2034 * @return a vector containing strings. This is representatation of the
2035 * status of the calcTree
2037 public Vector saveCalcTree(int calcTreeID) {
2038 this.bridge_.log(1, "----------------begin saving calcTree "
2039 + calcTreeID + "------------");
2040 return (Vector) inputs_.get(new Integer(calcTreeID));