|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectubc.cs.JLog.Foundation.jType
ubc.cs.JLog.Terms.jTerm
ubc.cs.JLog.Terms.iPredicate
ubc.cs.JLog.Terms.jPredicate
public class jPredicate
This is the base class for Prolog predicates.
| Field Summary | |
|---|---|
protected jCompoundTerm |
arguments
|
protected int |
arity
|
protected jRuleDefinitions |
cached_ruledefs
|
protected String |
name
|
| Fields inherited from class ubc.cs.JLog.Foundation.jType |
|---|
type |
| Fields inherited from interface ubc.cs.JLog.Terms.iTerm |
|---|
EQUAL, GREATER_THAN, LESS_THAN |
| Fields inherited from interface ubc.cs.JLog.Foundation.iType |
|---|
TYPE_ARITHMETIC, TYPE_ATOM, TYPE_BUILTINPREDICATE, TYPE_COMMAND, TYPE_COMPARE, TYPE_COMPOUND, TYPE_CONS, TYPE_IF, TYPE_INTEGER, TYPE_LIST, TYPE_NULLLIST, TYPE_NUMERICCOMPARE, TYPE_OBJECT, TYPE_OPERATOR, TYPE_OR, TYPE_ORPREDICATE, TYPE_PREDICATE, TYPE_PREDICATETERMS, TYPE_REAL, TYPE_TYPE, TYPE_UNARYARITHMETIC, TYPE_UNARYOPERATOR, TYPE_UNDEFINED, TYPE_VARIABLE |
| Constructor Summary | |
|---|---|
|
jPredicate(jAtom a)
Copy constructor to convert jAtom to predicate/0 |
protected |
jPredicate(String n)
Constructor for subclasses which must set arguments and arity themselves. |
|
jPredicate(String n,
jCompoundTerm args)
jPredicate constructor. |
protected |
jPredicate(String n,
jCompoundTerm args,
int ar,
jRuleDefinitions crds)
|
| Method Summary | |
|---|---|
void |
addGoals(jGoal g,
iGoalStack goals)
Adds goal to prove this predicate onto goal stack. |
void |
addGoals(jGoal g,
jVariable[] vars,
iGoalStack goals)
Adds goal to prove this predicate onto goal stack. |
void |
addTerm(jTerm t)
|
protected int |
compareArguments(iPredicate ipred,
boolean first_call,
boolean var_equal)
Compares the arguments for predicates. |
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. |
jTerm |
copy(jVariableRegistry vars)
Internal member function which creates a copy of this term. |
jTerm |
duplicate(jVariable[] vars)
Creates a complete and entirely independant duplicate of this term. |
jCompoundTerm |
duplicateArguments(jVariable[] vars)
|
void |
enumerateVariables(jVariableVector v,
boolean all)
Adds variables belonging to this term (or belonging to any sub-part of this term) to the jVariableVector |
boolean |
equivalence(jTerm term,
jEquivalenceMapping v)
The public interface for evaluating term equivalence (i.e., structural similarity). |
boolean |
equivalenceArguments(jCompoundTerm term,
jEquivalenceMapping v)
|
jCompoundTerm |
getArguments()
Accessor for the arguments for this predicate. |
int |
getArity()
Returns the arity of this instance. |
jRuleDefinitions |
getCachedRuleDefinitions()
|
String |
getName()
Returns the name of this instance. |
boolean |
isConsultNeeded()
Determine if cached values already exist and hence if consulting is required. |
protected boolean |
lookup_predicate()
|
void |
registerUnboundVariables(jUnifiedVector v)
Adds any unbound variables belonging to this term (or belonging to any sub-part of this term) to the jUnifiedVector |
void |
registerVariables(jVariableVector v)
Adds all variables belonging to this term (or belonging to any sub-part of this term) to the jUnifiedVector
Should be called during the consultation phase by rules for their owned terms
both head and base. |
void |
removeTerm(jTerm t)
|
String |
toString(boolean usename)
Produces a string identifying this term, suitable for display to the console. |
boolean |
unify(jTerm term,
jUnifiedVector v)
Determines if this instance and term unify. |
boolean |
unifyArguments(jCompoundTerm term,
jUnifiedVector v)
|
| Methods inherited from class ubc.cs.JLog.Terms.iPredicate |
|---|
compare |
| Methods inherited from class ubc.cs.JLog.Terms.jTerm |
|---|
compare, copy, getTerm, getValue, requiresCompleteVariableState, toString |
| Methods inherited from class ubc.cs.JLog.Foundation.jType |
|---|
getType, objectToString |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected String name
protected int arity
protected jCompoundTerm arguments
protected jRuleDefinitions cached_ruledefs
| Constructor Detail |
|---|
public jPredicate(String n,
jCompoundTerm args)
jPredicate constructor.
n - The predicates name.args - The arguments for the predicate.public jPredicate(jAtom a)
jAtom to predicate/0
a - The jAtom.protected jPredicate(String n)
n - The predicates name.
protected jPredicate(String n,
jCompoundTerm args,
int ar,
jRuleDefinitions crds)
| Method Detail |
|---|
public final String getName()
iName
getName in interface iNamegetName in interface iTermgetName in class jTermString containing name of this instance.public final int getArity()
iNameArity
int whose value is the arity of this instance.
protected int compareArguments(iPredicate ipred,
boolean first_call,
boolean var_equal)
iPredicatecompare except that name
and arity must be equal.
compareArguments in class iPredicateipred - the iPredicate to compare with this instance of
iPredicate.first_call - true if just invoked by public
compare member function.
false otherwise.var_equal - if var_equal is true, then unbound
variables are considered equal.
var_equal = false is standard prolog
behavior.
LESS_THAN if this instance is less than
term,
EQUAL if the two terms are equal, and
GREATER_THAN if
this instance is greater than term.public jRuleDefinitions getCachedRuleDefinitions()
public void consult(jKnowledgeBase kb)
iConsultablejKnowledgeBase 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.
consult in interface iConsultableconsult in interface iTermconsult in class jTermkb - the knowledge base which attempted proofs are based upon.public void consultReset()
iConsultablejKnowledgeBase changes. Should set all cached values to
dirty so that a following call to consult would perform a full lookup
as required.
consultReset in interface iConsultableconsultReset in interface iTermconsultReset in class jTermpublic boolean isConsultNeeded()
iConsultable
isConsultNeeded in interface iConsultableisConsultNeeded in interface iTermisConsultNeeded in class jTermfalse if cached values are valid,
true otherwise, if consult should be
called.
public void addGoals(jGoal g,
jVariable[] vars,
iGoalStack goals)
iPredicate
addGoals in class iPredicateg - The super-goal jGoal for the sub-goal that this
function will add.vars - The vector of duplicate variables produced
from the previous call to registerVariables.
Needed for call to duplicate.goals - The iGoalStack to add the goal to.
public void addGoals(jGoal g,
iGoalStack goals)
iPredicate
addGoals in class iPredicateg - The super-goal jGoal for the sub-goal that this
function will add.goals - The iGoalStack to add the goal to.public void registerUnboundVariables(jUnifiedVector v)
jTermjUnifiedVector
registerUnboundVariables in interface iTermregisterUnboundVariables in class jTermv - The jUnifiedVector where unbound variables are
added to. This parameter is used to as output to the caller, not as input.
public boolean equivalence(jTerm term,
jEquivalenceMapping v)
iTerm
equivalence in interface iTermequivalence in class jTermterm - the jTerm to compare with this instance of
jTerm.v - v is the collection of equivalent variable pairs found.
It should be empty when first calling this function.
true if this instance is equivalent to term,
false otherwise.
public boolean unify(jTerm term,
jUnifiedVector v)
iUnifiableterm unify.
Every variable which was previously unbound, but which becomes bound during
the unification must register itself with the jUnifiedVector. It
is the callers responsibility to deal with the unified vector.
unify in interface iUnifiableunify in interface iTermunify in class jTermterm - the term to unify with this instance.v - the vector of variables bound during unification. Even if
unification fails, this vector may contain recently
bound vectors. This parameter is used to as output to the
caller, not as input for unify.
true if unification succeeded,
false otherwise.
public final boolean equivalenceArguments(jCompoundTerm term,
jEquivalenceMapping v)
public final boolean unifyArguments(jCompoundTerm term,
jUnifiedVector v)
public void registerVariables(jVariableVector v)
jTermjUnifiedVector
Should be called during the consultation phase by rules for their owned terms
both head and base. all variables encountered should be unbound.
After call, this term should not be modified in any way.
registerVariables in interface iTermregisterVariables in class jTermv - The jUnifiedVector where variables are
added to. This parameter is used to as output to the
caller, not as input.
public void enumerateVariables(jVariableVector v,
boolean all)
jTermjVariableVector
enumerateVariables in interface iTermenumerateVariables in class jTermv - The jVariabeVector where variables are
added to. This parameter is used to as output to the
caller, not as input.all - If true, then all variables should register,
otherwise only add non-existentially qualified variables.public jTerm duplicate(jVariable[] vars)
jTermregisterVariables has already been
invoked.
Within duplicate, any other calls to duplicate should pass along
the same vars array produced by registerVariables
since the same duplication path previously taken by registerVariables
should be taken by duplicate. This call is designed only for terms
which belong to rules and are templates for instantiation. Any variables in the
term should be unbound. As implied by the modification restrictions on
registerVariables, terms and their children cannot change
(especially during call!)
duplicate in interface iTermduplicate in class jTermvars - The user passes in a duplicate of the variable vector produced
from the previous call to registerVariables.
vars is produced from the
jVariableVector by creating a single duplicate
variable for each variable. Since this is created in the same
order as the registerVariables, it is now
efficient for jVariables to return their
unique duplicate.
jTerm which is an instantiated duplicate of this
term.public jTerm copy(jVariableRegistry vars)
jTermduplicate function. Should only be invoked by copy()
or other copy(vars). Should only invoke other
copy(vars) functions.
Bound variables should return a copy of the bound term.
copy in interface iTermcopy in class jTermvars - The registry of variables and their duplicates. Initially this
is empty. As variables generate copies, they add themselves
and their copy to the jVariableRegistry, and this
is output from the function call. Any further calls with the
same vars ensures that the same variable
(in a different term) returns the same copy.
jTerm which is an instantiated copy of this
term.public final jCompoundTerm getArguments()
iPredicate
getArguments in class iPredicatepublic void addTerm(jTerm t)
public void removeTerm(jTerm t)
public jCompoundTerm duplicateArguments(jVariable[] vars)
public String toString(boolean usename)
jTermfalse is the default for displaying the term,
true for displaying this term in a user query.
toString in interface iTermtoString in class jTermString which is a textual representation of this
term.protected boolean lookup_predicate()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||