ubc.cs.JLog.Foundation
Class jRule

java.lang.Object
  extended by ubc.cs.JLog.Foundation.jRule
All Implemented Interfaces:
iConsultable, iName, iNameArity
Direct Known Subclasses:
jBuiltinRule

public class jRule
extends java.lang.Object
implements iNameArity, iConsultable

This class represents a rule of the form Head :- Base, where Head is a predicate and Base is a term of predicates.

Author:
Glendon Holst

Field Summary
protected  boolean all_variables
           
protected  jPredicateTerms base
           
protected  jPredicate head
           
protected  jVariableVector variables
           
 
Constructor Summary
jRule(jPredicate h, jPredicateTerms b)
           
 
Method Summary
 void consult(jKnowledgeBase kb)
          Consult the given jKnowledgeBase and cache any invariant values (those which would not change until the next time the jKnowledgeBase changes).
 void consultReset()
          Called when the jKnowledgeBase changes.
 java.util.Enumeration enumBase()
           
 int getArity()
          Returns the arity of this instance.
 jPredicateTerms getBase()
           
 jPredicate getHead()
           
 java.lang.String getName()
          Returns the name of this instance.
 jTerm getUnifiedBase(jCompoundTerm input_goal, jUnifiedVector unified)
          Test if rule head will unify.
 boolean isConsultNeeded()
          Determine if cached values already exist and hence if consulting is required.
 java.lang.String toString()
           
 boolean unify(jPredicateGoal pg, iGoalStack goals)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

head

protected jPredicate head

base

protected jPredicateTerms base

variables

protected jVariableVector variables

all_variables

protected boolean all_variables
Constructor Detail

jRule

public jRule(jPredicate h,
             jPredicateTerms b)
Method Detail

getName

public java.lang.String getName()
Description copied from interface: iName
Returns the name of this instance.

Specified by:
getName in interface iName
Returns:
String containing name of this instance.

getArity

public int getArity()
Description copied from interface: iNameArity
Returns the arity of this instance.

Specified by:
getArity in interface iNameArity
Returns:
int whose value is the arity of this instance.

getHead

public jPredicate getHead()

getBase

public jPredicateTerms getBase()

unify

public boolean unify(jPredicateGoal pg,
                     iGoalStack goals)

getUnifiedBase

public jTerm getUnifiedBase(jCompoundTerm input_goal,
                            jUnifiedVector unified)
Test if rule head will unify. Assumes predicate name and arity already match.

Returns:
The duplicated base jTerm if it head unifies, null otherwise.

consult

public void consult(jKnowledgeBase kb)
Description copied from interface: iConsultable
Consult the given jKnowledgeBase and cache any invariant values (those which would not change until the next time the jKnowledgeBase changes). Where possible, consultable objects should minimize computation and assume that any cached values are still accurate.

Specified by:
consult in interface iConsultable
Parameters:
kb - the knowledge base which attempted proofs are based upon.

consultReset

public void consultReset()
Description copied from interface: iConsultable
Called when the jKnowledgeBase changes. Should set all cached values to dirty so that a following call to consult would perform a full lookup as required.

Specified by:
consultReset in interface iConsultable

isConsultNeeded

public boolean isConsultNeeded()
Description copied from interface: iConsultable
Determine if cached values already exist and hence if consulting is required. If object does not knowimmediatly whether consulting is needed, then assuming it is required.

Specified by:
isConsultNeeded in interface iConsultable
Returns:
false if cached values are valid, true otherwise, if consult should be called.

enumBase

public java.util.Enumeration enumBase()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object