Interface PredicateFactory

All Known Subinterfaces:
UserDefinedPredicateFactory
All Known Implementing Classes:
AbstractPredicateFactory, AbstractSingleResultPredicate, AddArithmeticOperator, AddExpressionFactory, AddPredicateFactory, AddUserDefinedArithmeticOperator, AlterSpyPoint, Append, AppendListOfLists, Arg, Assert, AtomConcat, AtomicListConcat, BagOf, Between, BooleanConstraintPredicate, Call, CharType, Close, Compare, Conjunction, Consult, ConsultList, ConvertTime, CopyTerm, CurrentInput, CurrentOutput, CurrentPredicate, Cut, Debugging, Delete, Dif, Disjunction, Distinct, Dynamic, DynamicUserDefinedPredicateFactory, EnsureLoaded, Equal, Erase, ExtremumList, Fail, FindAll, Flag, Flatten, Fold, Functor, GetChar, GetCode, GetTime, IfThen, In, InsertRecord, Inspect, InterpretedTailRecursivePredicateFactory, Is, IsAtom, IsAtomic, IsCompound, IsFloat, IsInteger, IsList, IsNonVar, IsNumber, IsVar, KeySort, Last, Length, Limit, Listing, MapList, Member, MemberCheck, NewLine, NoDebug, Not, NoTrace, NotStrictEquality, NotUnifiable, Nth, NumberVars, NumericConstraintPredicate, NumericEquality, NumericGreaterThan, NumericGreaterThanOrEqual, NumericInequality, NumericLessThan, NumericLessThanOrEqual, Once, Op, Open, PairsElements, PredSort, PutChar, RandomPermutation, Read, Recorded, RepeatInfinitely, RepeatSetAmount, Resolve, RetractAll, Reverse, See, Seen, Select, SetInput, SetOf, SetOutput, Sort, SortAsSet, StaticUserDefinedPredicateFactory, StrictEquality, SubList, Subset, SubtractFromList, SumList, Tab, TabledUserDefinedPredicateFactory, Tabling, Tell, TermGreaterThan, TermGreaterThanOrEqual, TermLessThan, TermLessThanOrEqual, TermSplit, Throw, Told, Trace, True, UnifyWithOccursCheck, Univ, UnknownPredicate, Write, WriteCanonical, Writef

public interface PredicateFactory
Returns specialised implementations of Predicate.

There are two general types of predicates:

  • User defined predicates are defined by a mixture of rules and facts constructed from Prolog syntax consulted at runtime.
  • Built-in predicates are written in Java. Built-in predicates can provide facilities that would not be possible using pure Prolog syntax. The two predicates that are always available in Projog are pj_add_predicate/2 and pj_add_arithmetic_operator/2. The pj_add_predicate/2 predicate allows other predicates to be "plugged-in" to Projog.

Note: Rather than directly implementing PredicateFactory it is recommended to extend either AbstractSingleResultPredicate or AbstractPredicateFactory.

See Also:
  • Method Details

    • getPredicate

      Predicate getPredicate(Term term)
      Returns a Predicate to be used in the evaluation of a goal.
      Parameters:
      term - the term containing the arguments to use in the evaluation of the goal
      Returns:
      Predicate to be used in the evaluation of the goal
      See Also:
    • isRetryable

      boolean isRetryable()
      Should instances of this implementation be re-evaluated when backtracking?

      Some goals (e.g. X is 1) are only meant to be evaluated once (the statement is either true or false) while others (e.g. repeat(3)) are meant to be evaluated multiple times. For instances of Predicate that are designed to possibly have Predicate.evaluate() called on them multiple times for the same individual query this method should return true. For instances of Predicate that are designed to only be evaluated once per individual query this method should return false.

      Returns:
      true if an attempt should be made to re-evaluate instances of implementing classes when backtracking, false otherwise
    • isAlwaysCutOnBacktrack

      default boolean isAlwaysCutOnBacktrack()
      Will attempting to re-evaluate this implementation always result in a cut?
      Returns:
      true if a cut will always be encountered when attempting to re-evaluate, false otherwise
    • preprocess

      default PredicateFactory preprocess(Term term)