ubc.cs.JLog.Foundation
Class jRuleDefinitions

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

public class jRuleDefinitions
extends java.lang.Object
implements iNameArity

This class represents an ordered collection of jRules of the same name and arity. This is designed for statically defined rules that cannot change during a proof.

Author:
Glendon Holst

Field Summary
protected  boolean builtin
           
protected  java.lang.String library
           
protected  int rule_arity
           
protected  java.lang.String rule_name
           
protected  java.util.Vector rules
           
 
Constructor Summary
protected jRuleDefinitions()
          Constructor for use by sub-classes which set up the members themeselves.
  jRuleDefinitions(java.lang.String name, int arity)
           
 
Method Summary
 void addRule(jRule fn)
          Add a rule to the definitions.
 void addRuleFirst(jRule fn)
          Add a rule to the begining of the rule definitions.
 void addRuleLast(jRule fn)
          Add a rule to the end of the rule definitions.
 void clearRules()
           
 void consult(jKnowledgeBase kb)
           
 jPredicateGoal createGoal(jCompoundTerm t)
           
 java.util.Enumeration enumRules()
           
 int getArity()
          Returns the arity of this instance.
 java.lang.String getLibrary()
          Get the name of the library associated with this operator.
 java.lang.String getName()
          Returns the name of this instance.
 jRule getRuleAt(int n)
           
 boolean isBuiltin()
          Determine if rules are builtin predicates.
 boolean match(iNameArity fn)
          Determine if rules match the given name and arity.
 boolean prove(jPredicateGoal pg, iGoalStack goals)
           
 void removeRule(jRule fn)
          Remove a rule from the rule definitions.
 boolean retry(jPredicateGoal pg)
           
 boolean sameLibrary(java.lang.String lib)
           
 void setLibrary(java.lang.String lib)
          Set the name of the library associated with this rule definition.
 int size()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

rules

protected java.util.Vector rules

rule_name

protected java.lang.String rule_name

rule_arity

protected int rule_arity

library

protected java.lang.String library

builtin

protected boolean builtin
Constructor Detail

jRuleDefinitions

protected jRuleDefinitions()
Constructor for use by sub-classes which set up the members themeselves.


jRuleDefinitions

public jRuleDefinitions(java.lang.String name,
                        int arity)
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.

isBuiltin

public boolean isBuiltin()
Determine if rules are builtin predicates.

Returns:
true if these rules are builtin predicates, false otherwise.

setLibrary

public void setLibrary(java.lang.String lib)
Set the name of the library associated with this rule definition. Once an association is made it is an error to change it (throws InvalidLibraryEntryException in this case). The default is a null valued library.

Parameters:
lib - The name of the library.

getLibrary

public java.lang.String getLibrary()
Get the name of the library associated with this operator.

Returns:
The name of the library. May be null.

sameLibrary

public boolean sameLibrary(java.lang.String lib)

size

public int size()

getRuleAt

public jRule getRuleAt(int n)

match

public final boolean match(iNameArity fn)
Determine if rules match the given name and arity.

Parameters:
fn - The given name and arity.
Returns:
true if these rules have the same name and arity as the given argument, false otherwise.

addRule

public void addRule(jRule fn)
Add a rule to the definitions. No ordering is specified, and duplicate rules are permitted.

Parameters:
fn - The jRule to add.

addRuleFirst

public void addRuleFirst(jRule fn)
Add a rule to the begining of the rule definitions. Duplicate rules are permitted. Rules at the begining are evaluated first during the proof phase.

Parameters:
fn - The jRule to add.

addRuleLast

public void addRuleLast(jRule fn)
Add a rule to the end of the rule definitions. Duplicate rules are permitted. Rules at the end are evaluated last during the proof phase.

Parameters:
fn - The jRule to add.

removeRule

public void removeRule(jRule fn)
Remove a rule from the rule definitions. Removes on one instance of the rule, if duplicate rules exist.

Parameters:
fn - The jRule to remove.

clearRules

public void clearRules()

enumRules

public java.util.Enumeration enumRules()

createGoal

public jPredicateGoal createGoal(jCompoundTerm t)

consult

public void consult(jKnowledgeBase kb)

prove

public final boolean prove(jPredicateGoal pg,
                           iGoalStack goals)

retry

public boolean retry(jPredicateGoal pg)

toString

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