org.deri.iris.builtins
Class ArithmeticBuiltin
java.lang.Object
org.deri.iris.builtins.AbstractBuiltin
org.deri.iris.builtins.ArithmeticBuiltin
- All Implemented Interfaces:
- Comparable<IAtom>, IAtom, IBuiltinAtom
- Direct Known Subclasses:
- AddBuiltin, DivideBuiltin, EqualBuiltin, ExactEqualBuiltin, MaxBuiltin, ModulusBuiltin, MultiplyBuiltin, SubtractBuiltin
public abstract class ArithmeticBuiltin
- extends AbstractBuiltin
Base class of arithmetic built-in predicates.
This kind of built-in has:
a) can have any arity
b) can be evaluated with up to 1 unknown variable
c) the unknown variable can be at any position
d) if all terms are known at evaluation time, the result is checked to indicate true or false
ArithmeticBuiltin
public ArithmeticBuiltin(IPredicate predicate,
ITerm... terms)
- Constructor.
- Parameters:
predicate - The predicate that identifies this built-in.terms - The terms of the instance. Must be 3.
evaluateTerms
protected ITerm evaluateTerms(ITerm[] terms,
int[] variableIndexes)
throws EvaluationException
- Description copied from class:
AbstractBuiltin
- Evaluate the predicate once the terms and variable indexes have been found.
- Overrides:
evaluateTerms in class AbstractBuiltin
- Parameters:
terms - The array of all terms for this evaluation.variableIndexes - the indexes of the terms which should be
computed (starting at 0)
- Returns:
- The result of the evaluation.
- Throws:
EvaluationException
testForEquality
protected boolean testForEquality(ITerm t1,
ITerm t2)
computeMissingTerm
protected abstract ITerm computeMissingTerm(int missingTermIndex,
ITerm[] terms)
throws EvaluationException
- Compute the missing term when the other two are known.
- Parameters:
terms - The collection of all terms.
- Returns:
- The computed value.
- Throws:
EvaluationException
maxUnknownVariables
public int maxUnknownVariables()
- Description copied from interface:
IBuiltinAtom
- The maximum number of unknown variables allowed such that the
predicate can still be evaluated.
- Specified by:
maxUnknownVariables in interface IBuiltinAtom- Overrides:
maxUnknownVariables in class AbstractBuiltin
- Returns:
- The maximum number of unknown variables.