org.jscience.computing.ai.planning
Class Term

java.lang.Object
  extended by org.jscience.computing.ai.planning.CompileTimeObject
      extended by org.jscience.computing.ai.planning.Term
Direct Known Subclasses:
TermCall, TermConstant, TermList, TermNumber, TermVariable

public abstract class Term
extends CompileTimeObject

Each term, both at compile time and at run time, is an instance of a class derived from this abstract class.


Constructor Summary
Term()
           
 
Method Summary
abstract  Term bind(Term[] binding)
          To apply a given binding to this term.
abstract  boolean equals(Term t)
          Whether or not another term is equivalent to this term.
abstract  boolean findUnifier(Term t, Term[] binding)
          To find a unifier that binds this term to another given term.
abstract  boolean isGround()
          Is this term ground (i.e., has no variables)?
 boolean isNil()
          Is this a NIL term?
static Term[] merge(Term[][] inp, int howMany)
          This function is used to merge an arbitrary number of bindings.
static void merge(Term[] inp1, Term[] inp2)
          This function is used to merge two bindings.
 void print()
          This function is used to print the value of this term.
abstract  java.lang.String toString()
          This function is used to produce a printable String showing the value of this term.
 
Methods inherited from class org.jscience.computing.ai.planning.CompileTimeObject
toCode
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Term

public Term()
Method Detail

bind

public abstract Term bind(Term[] binding)
To apply a given binding to this term.

Parameters:
binding - an array of terms, indexed by the integers associated with variable symbols.
Returns:
the result of binding.

equals

public abstract boolean equals(Term t)
Whether or not another term is equivalent to this term.

Parameters:
t - the term being compared to this term.
Returns:
true if the two terms are equal, false otherwise.

findUnifier

public abstract boolean findUnifier(Term t,
                                    Term[] binding)
To find a unifier that binds this term to another given term.

Parameters:
t - the term with which we are finding a unifier.
binding - the unifier to be returned.
Returns:
false if the two terms can not be unified, true otherwise.

isGround

public abstract boolean isGround()
Is this term ground (i.e., has no variables)?

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

isNil

public boolean isNil()
Is this a NIL term?

Returns:
true if this is a NIL term, false otherwise.

merge

public static void merge(Term[] inp1,
                         Term[] inp2)
This function is used to merge two bindings. Bindings are represented as an array of terms, each element showing what its corresponding variable should be mapped to.

Parameters:
inp1 - the first binding, also the result of merging.
inp2 - the second binding.

merge

public static Term[] merge(Term[][] inp,
                           int howMany)
This function is used to merge an arbitrary number of bindings.

Parameters:
inp - the bindings to be merged. This is a two dimensional array, the first dimension indexes the different bindings, and the second dimension indexes variables within each binding.
howMany - how many of available bindings we want to merge. Bindings indexed 0 to howMany-1 are merged.
Returns:
the result of merging.

print

public void print()
This function is used to print the value of this term.


toString

public abstract java.lang.String toString()
This function is used to produce a printable String showing the value of this term.

Overrides:
toString in class java.lang.Object
Returns:
the printable String that shows the value of this term.