Package org.projog.core.predicate
Interface PredicateFactory
-
- All Known Subinterfaces:
PreprocessablePredicateFactory,UserDefinedPredicateFactory
- All Known Implementing Classes:
AbstractNumericComparisonPredicate,AbstractPredicateFactory,AbstractSingleResultPredicate,AddArithmeticOperator,AddExpressionFactory,AddPredicateFactory,AddUserDefinedArithmeticOperator,AlterSpyPoint,Append,AppendListOfLists,Arg,Assert,AtomConcat,AtomicListConcat,BagOf,BagOf.PreprocessedBagOf,Between,BooleanConstraintPredicate,Call,CharType,Close,Compare,Conjunction,Conjunction.OptimisedRetryableConjuction,Conjunction.OptimisedSingletonConjuction,Consult,ConsultList,ConvertTime,CopyTerm,CurrentInput,CurrentOutput,CurrentPredicate,Cut,Debugging,Delete,Dif,Disjunction,Disjunction.OptimisedDisjunction,Disjunction.OptimisedIfThenElse,Distinct,Dynamic,DynamicUserDefinedPredicateFactory,EnsureLoaded,Equal,Erase,ExtremumList,Fail,FindAll,FindAll.PreprocessedFindAll,Flag,Flatten,Fold,Fold.OptimisedFold,Functor,GetChar,GetCode,GetTime,IfThen,IfThen.OptimisedIfThen,In,InsertRecord,Inspect,InterpretedTailRecursivePredicateFactory,Is,Is.PreprocessedIs,Is.Unify,IsAtom,IsAtomic,IsCompound,IsFloat,IsInteger,IsList,IsNonVar,IsNumber,IsVar,KeySort,Last,Length,Limit,Limit.OptimisedLimit,Listing,MapList,MapList.PreprocessedMapList,Member,MemberCheck,MemberCheck.PreprocessedMemberCheck,NeverSucceedsPredicateFactory,NewLine,NoDebug,Not,Not.OptimisedNot,NoTrace,NotStrictEquality,NotUnifiable,Nth,NumberVars,NumericConstraintPredicate,NumericEquality,NumericGreaterThan,NumericGreaterThanOrEqual,NumericInequality,NumericLessThan,NumericLessThanOrEqual,Once,Once.OptimisedOnce,Op,Open,PairsElements,PredSort,PredSort.PreprocessedPredSort,PutChar,Read,Recorded,RepeatInfinitely,RepeatSetAmount,Resolve,RetractAll,Reverse,See,Seen,Select,SetInput,SetOf,SetOf.PreprocessedSetOf,SetOutput,SingleNonRetryableRulePredicateFactory,SingleRetryableRulePredicateFactory,Sort,SortAsSet,StaticUserDefinedPredicateFactory,StaticUserDefinedPredicateFactory.IndexablePredicateFactory,StaticUserDefinedPredicateFactory.LinkedHashMapPredicateFactory,StaticUserDefinedPredicateFactory.NotIndexablePredicateFactory,StaticUserDefinedPredicateFactory.SingleIndexPredicateFactory,StrictEquality,SubList,SubList.PreprocessedSubList,Subset,SubtractFromList,Tab,Tell,TermGreaterThan,TermGreaterThanOrEqual,TermLessThan,TermLessThanOrEqual,TermSplit,Throw,Told,Trace,True,UnifyWithOccursCheck,Univ,UnknownPredicate,Write,WriteCanonical,Writef
public interface PredicateFactoryReturns specialised implementations ofPredicate.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/2andpj_add_arithmetic_operator/2. Thepj_add_predicate/2predicate allows other predicates to be "plugged-in" to Projog.
Note: Rather than directly implementing
PredicateFactoryit is recommended to extend eitherAbstractSingleResultPredicateorAbstractPredicateFactory.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description PredicategetPredicate(Term[] args)Returns aPredicateto be used in the evaluation of a goal.default booleanisAlwaysCutOnBacktrack()Will attempting to re-evaluate this implementation always result in a cut?booleanisRetryable()Should instances of this implementation be re-evaluated when backtracking?
-
-
-
Method Detail
-
getPredicate
Predicate getPredicate(Term[] args)
Returns aPredicateto be used in the evaluation of a goal.- Parameters:
args- the arguments to use in the evaluation of the goal- Returns:
- Predicate to be used in the evaluation of the goal
- See Also:
Predicate.evaluate()
-
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 ofPredicatethat are designed to possibly havePredicate.evaluate()called on them multiple times for the same individual query this method should returntrue. For instances ofPredicatethat are designed to only be evaluated once per individual query this method should returnfalse.- Returns:
trueif an attempt should be made to re-evaluate instances of implementing classes when backtracking,falseotherwise
-
isAlwaysCutOnBacktrack
default boolean isAlwaysCutOnBacktrack()
Will attempting to re-evaluate this implementation always result in a cut?- Returns:
trueif a cut will always be encountered when attempting to re-evaluate,falseotherwise
-
-