/** {@inheritDoc} */ public boolean proofStep(ResolutionState state) { Clause query = state.getCurrentClause(); // The query goals are placed onto the goal stack backwards so that their insertion order is reversed for an // intuitive left-to-right evaluation order. for (int i = query.getBody().length - 1; i >= 0; i--) { BuiltInFunctor newGoal = state.getBuiltInTransform().apply(query.getBody()[i]); state.getGoalStack().offer(newGoal); } return true; } }
if ((clause.getBody() != null)) for (int i = clause.getBody().length - 1; i >= 1; i--) Set<Variable> groupVariables = TermUtils.findFreeVariables(clause.getBody()[i]); if ((clause.getBody() != null) && (clause.getBody().length > 0)) Set<Variable> firstArgVariables = TermUtils.findFreeVariables(clause.getBody()[0]); firstGroupVariables.addAll(firstArgVariables); int[] permVarsRemainingCount = new int[(clause.getBody() != null) ? clause.getBody().length : 0]; symbolTable.put(clause.getBody()[i].getSymbolKey(), SymbolTableKeys.SYMKEY_PERM_VARS_REMAINING, permVarsRemaining); permVarsRemaining += permVarsRemainingCount[i];
/** * Examines all top-level functors within a clause, including any head and body, and determines which functor has * the highest number of arguments. * * @param clause The clause to determine the highest number of arguments within. * * @return The highest number of arguments within any top-level functor in the clause. */ private int findMaxArgumentsInClause(Clause clause) { int result = 0; Functor head = clause.getHead(); if (head != null) { result = head.getArity(); } Functor[] body = clause.getBody(); if (body != null) { for (int i = 0; i < body.length; i++) { int arity = body[i].getArity(); result = (arity > result) ? arity : result; } } return result; }
/** {@inheritDoc} */ public Iterator<Operator<Term>> traverse(Clause clause, boolean reverse) { /*log.fine("Traversing clause " + clause.toString());*/ Functor head = clause.getHead(); Functor[] body = clause.getBody(); Queue<Operator<Term>> queue = (!reverse) ? new StackQueue<Operator<Term>>() : new LinkedList<Operator<Term>>(); // For the head functor, set the top-level flag, set in head context. if (head != null) { head.setReversable(createHeadOperator(head, clause)); head.setTermTraverser(this); queue.offer(head); } // For the body functors, set the top-level flag, clear in head context. if (body != null) { for (int i = leftToRightClauseBodies ? 0 : (body.length - 1); leftToRightClauseBodies ? (i < body.length) : (i >= 0); i = i + (leftToRightClauseBodies ? 1 : -1)) { Functor bodyFunctor = body[i]; bodyFunctor.setReversable(createBodyOperator(bodyFunctor, i, body, clause)); bodyFunctor.setTermTraverser(this); queue.offer(bodyFunctor); } } return queue.iterator(); }
/** {@inheritDoc} */ public Iterator<Operator<Term>> traverse(Clause clause, boolean reverse) { /*log.fine("Traversing clause " + clause.toString());*/ Functor head = clause.getHead(); Functor[] body = clause.getBody(); Queue<Operator<Term>> queue = (!reverse) ? new StackQueue<Operator<Term>>() : new LinkedList<Operator<Term>>(); // For the head functor, set the top-level flag, set in head context. if (head != null) { head.setReversable(createHeadOperator(head, clause)); head.setTermTraverser(this); queue.offer(head); } // For the body functors, set the top-level flag, clear in head context. if (body != null) { for (int i = leftToRightClauseBodies ? 0 : (body.length - 1); leftToRightClauseBodies ? (i < body.length) : (i >= 0); i = i + (leftToRightClauseBodies ? 1 : -1)) { Functor bodyFunctor = body[i]; bodyFunctor.setReversable(createBodyOperator(bodyFunctor, i, body, clause)); bodyFunctor.setTermTraverser(this); queue.offer(bodyFunctor); } } return queue.iterator(); }
parentClause.getBody()[pos] = builtInFunctor;
Functor[] body = clause.getBody();
Functor[] body = clause.getBody();
PrologCompiledClause result = new PrologCompiledClause(clause.getHead(), clause.getBody());
Functor[] expressions = clause.getBody();
Functor[] body = state.getCurrentClause().getBody();