Class InterpretedTailRecursivePredicate

    • Field Detail

      • isSpyPointEnabled

        private final boolean isSpyPointEnabled
      • numArgs

        private final int numArgs
      • currentQueryArgs

        private final Term[] currentQueryArgs
      • isRetryable

        private final boolean isRetryable
      • firstClausePredicateFactories

        private final PredicateFactory[] firstClausePredicateFactories
      • firstClauseConsequentArgs

        private final Term[] firstClauseConsequentArgs
      • firstClauseOriginalTerms

        private final Term[] firstClauseOriginalTerms
      • secondClausePredicateFactories

        private final PredicateFactory[] secondClausePredicateFactories
      • secondClauseConsequentArgs

        private final Term[] secondClauseConsequentArgs
      • secondClauseOriginalTerms

        private final Term[] secondClauseOriginalTerms
    • Constructor Detail

      • InterpretedTailRecursivePredicate

        InterpretedTailRecursivePredicate​(SpyPoints.SpyPoint spyPoint,
                                          Term[] inputArgs,
                                          PredicateFactory[] firstClausePredicateFactories,
                                          Term[] firstClauseConsequentArgs,
                                          Term[] firstClauseOriginalTerms,
                                          PredicateFactory[] secondClausePredicateFactories,
                                          Term[] secondClauseConsequentArgs,
                                          Term[] secondClauseOriginalTerms,
                                          boolean isRetryable)
    • Method Detail

      • matchFirstRule

        protected boolean matchFirstRule()
        Description copied from class: TailRecursivePredicate
        Match the first rule of the tail recursive predicate.

        If the head of the first rule is matched then the rule has been successfully evaluated.

        Specified by:
        matchFirstRule in class TailRecursivePredicate
        Returns:
        true if the first rule is matched, else false
      • matchSecondRule

        protected boolean matchSecondRule()
        Description copied from class: TailRecursivePredicate
        Match the second rule of the tail recursive predicate.

        If the second rule is matched then the attempt at evaluating the rule continues for another level of recursion.

        Specified by:
        matchSecondRule in class TailRecursivePredicate
        Returns:
        true if the second rule is matched, else false
      • unify

        public static boolean unify​(Term[] inputArgs,
                                    Term[] consequentArgs)
        Unifies the arguments in the head (consequent) of a clause with a query.

        When Prolog attempts to answer a query it searches its knowledge base for all rules with the same functor and arity. For each rule founds it attempts to unify the arguments in the query with the arguments in the head (consequent) of the rule. Only if the query and rule's head can be unified can it attempt to evaluate the body (antecedent) of the rule to determine if the rule is true.

        Parameters:
        inputArgs - the arguments contained in the query
        consequentArgs - the arguments contained in the head (consequent) of the clause
        Returns:
        true if the attempt to unify the arguments was successful
        See Also:
        Term.unify(Term)
      • couldReevaluationSucceed

        public boolean couldReevaluationSucceed()
        Description copied from interface: Predicate
        Could the next re-evaluation of this instance succeed?

        Specifies whether a specific instance of a specific implementation of Predicate, that has already had Predicate.evaluate() called on it at least once, could possibly return true the next time Predicate.evaluate() is called on it. i.e. is it worth trying to continue to find solutions for the specific query this particular instance represents and has been evaluating?

        (Note: the difference between this method and PredicateFactory.isRetryable() is that PredicateFactory.isRetryable() deals with whether, in general, a specific implementation (rather than instance) of Predicate could ever produce multiple answers for an individual query.)

        Returns:
        true if an attempt to re-evaluate this instance could possible succeed, false otherwise