@Override
 public int execute(Interpreter interpreter, boolean backtrackMode, Term[] args)
     throws PrologException {
   RuleTransition transition = getTransition(args[0]);
   Term result = new JavaObjectTerm(transition.getProof());
   return interpreter.unify(args[1], result);
 }
 public List<Term> parseSentence(Term startCat, Term sentence) throws PrologException {
   Term resultsTerm = new VariableTerm("Results");
   Term goalTerm = new CompoundTerm("parse_all", new Term[] {startCat, sentence, resultsTerm});
   int rc = interpreter.runOnce(goalTerm);
   assert (rc == PrologCode.SUCCESS || rc == PrologCode.SUCCESS_LAST);
   Term results = resultsTerm.dereference();
   return collectResults(results);
 }
 @Override
 public int execute(Interpreter interpreter, boolean backtrackMode, Term[] args)
     throws PrologException {
   if (backtrackMode) {
     PrologCollectionIterator it = (PrologCollectionIterator) interpreter.popBacktrackInfo();
     interpreter.undo(it.getUndoPosition());
     return it.nextSolution(interpreter);
   } else {
     RuleEvent re = getRuleEvent(args[0]);
     HostGraph graph = (HostGraph) getGraph(args[1]);
     RuleEffect record = re.getEffect(graph);
     Iterable<HostEdge> createdEdges = record.getAddedEdges();
     if (createdEdges == null) {
       return FAIL;
     } else {
       PrologCollectionIterator it =
           new PrologCollectionIterator(createdEdges, args[2], interpreter.getUndoPosition());
       return it.nextSolution(interpreter);
     }
   }
 }