org.jscience.computing.ai.planning
Class Predicate

java.lang.Object
  extended by org.jscience.computing.ai.planning.CompileTimeObject
      extended by org.jscience.computing.ai.planning.Predicate

public class Predicate
extends CompileTimeObject

Each predicate, both at compile time and at run time, is an instance of this class.


Constructor Summary
Predicate(int varIdxIn, int varCountIn)
          To initialize this predicate when it is not a real predicate but a variable symbol.
Predicate(int headIn, int varCountIn, Term paramIn)
          To initialize this predicate.
 
Method Summary
 Predicate applySubstitution(Term[] bindings)
          To apply a binding to this predicate.
 boolean equals(Term t)
          Whether or not the argument list of another predicate is equal to the the argument list of this predicate.
 Term[] findUnifier(Term t)
          To find a unifier that unifies the argument list of another predicate with the argument list of this predicate.
 int getHead()
          To get the head of this predicate.
 Term getParam()
          To get the parameter list of this predicate.
 int getVarCount()
          To get the number of variables for this predicate.
 boolean isGround()
          To check if this predicate is ground (i.e., has no variables).
 boolean isVar()
          To check if this predicate is a variable symbol or a real predicate.
 void print()
          This function is used to print this predicate.
 void print(java.lang.String[] constants)
          This function is used to print this predicate.
 void setVarCount(int varCountIn)
          To set the number of variables for this predicate.
 java.lang.String toCode()
          This function produces Java code to create this predicate.
 java.lang.String toString()
          This function returns a printable String representation of this predicate.
 java.lang.String toString(java.lang.String[] constants)
          This function returns a printable String representation of this predicate.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Predicate

public Predicate(int headIn,
                 int varCountIn,
                 Term paramIn)
To initialize this predicate.

Parameters:
headIn - the head of the predicate.
varCountIn - number of the variables of the predicate.
paramIn - the argument list of the predicate.

Predicate

public Predicate(int varIdxIn,
                 int varCountIn)
To initialize this predicate when it is not a real predicate but a variable symbol.

Parameters:
varIdxIn - the index of the variable symbol that represents this predicate.
varCountIn - number of the variables of the predicate.
Method Detail

applySubstitution

public Predicate applySubstitution(Term[] bindings)
To apply a binding to this predicate.

Parameters:
bindings - the binding to be applied.
Returns:
the resulting predicate.

equals

public boolean equals(Term t)
Whether or not the argument list of another predicate is equal to the the argument list of this predicate.

Parameters:
t - the argument list of the other predicate.
Returns:
true if the two argument lists are equal, false otherwise.

findUnifier

public Term[] findUnifier(Term t)
To find a unifier that unifies the argument list of another predicate with the argument list of this predicate.

Parameters:
t - the argument list of the other predicate.
Returns:
the binding that unifies the two argument lists in case they are unifiable, null otherwise.

getHead

public int getHead()
To get the head of this predicate.

Returns:
the head of this predicate.

getParam

public Term getParam()
To get the parameter list of this predicate.

Returns:
the parameter list of this predicate.

getVarCount

public int getVarCount()
To get the number of variables for this predicate.

Returns:
the number of variables for this predicate.

isGround

public boolean isGround()
To check if this predicate is ground (i.e., has no variables).

Returns:
true if this predicate is ground, false otherwise.

isVar

public boolean isVar()
To check if this predicate is a variable symbol or a real predicate.

Returns:
true if this predicate is a variable symbol, false if it is a real predicate.

print

public void print()
This function is used to print this predicate.


print

public void print(java.lang.String[] constants)
This function is used to print this predicate.

Parameters:
constants - what String should each constant symbol be mapped to.

setVarCount

public void setVarCount(int varCountIn)
To set the number of variables for this predicate.

Parameters:
varCountIn - the number of variables for this predicate.

toCode

public java.lang.String toCode()
This function produces Java code to create this predicate.

Specified by:
toCode in class CompileTimeObject
Returns:
DOCUMENT ME!

toString

public java.lang.String toString()
This function returns a printable String representation of this predicate. This function is used to print the predicates known to be logical atoms, because the indexes in this predicate representing constant symbols are mapped back by default to String representations of the constant symbols in logical atoms.

Overrides:
toString in class java.lang.Object
Returns:
the String representation of this predicate.

toString

public java.lang.String toString(java.lang.String[] constants)
This function returns a printable String representation of this predicate. This function is used to print predicates other than logical atoms (such as task atoms).

Parameters:
constants - what String should each constant symbol be mapped to.
Returns:
the String representation of this predicate.