|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectai.krr.fol.Term
ai.krr.fol.Constant
public class Constant
The most basic Term is a Constant that is represented by a Symbol. ConstantTerms or constants are usually used in logic to represent named individuals or concepts.
Symbol
Field Summary | |
---|---|
protected Symbol |
theSy
the Symbol contained in this Constant |
Constructor Summary | |
---|---|
Constant(Symbol aSy)
This constructor just takes the Symbol that is this Term. |
Method Summary | |
---|---|
protected void |
addConstants(java.util.Set<Symbol> sys)
This function adds all the constant Symbols used in this Term to the given Set. |
protected void |
addFreeVariables(java.util.Set<Variable> free,
java.util.Set<Variable> bound)
This function adds the free Variables in this Term to the first given Set. |
protected void |
addFunctions(java.util.Map<Symbol,java.lang.Integer> sys)
This function adds all the function Symbols used in this Term to the given Set. |
protected void |
addVariables(java.util.Set<Variable> vars)
This function adds the Variables in this Term to the given Set. |
Constant |
clone()
Cloning a Constant returns this Constant (containing the same Symbol). |
Constant |
clone(Substitution s)
Cloning a Constant under a given Substitution returns this Constant. |
int |
compareTo(Constant other)
This function compares this Constant to the given Constant. |
int |
compareTo(Term other)
This function compares this Constant to the given Term. |
boolean |
equals(Constant other)
A Constant is equal to any other Constant that holds an equal Symbol. |
boolean |
equals(java.lang.Object other)
A Constant can only be equal to any other Constant. |
java.lang.Object |
evaluate(Interpretation ipt,
Substitution s)
This function evaluates this Term under the given Interpretation and Substitution for Variables. |
boolean |
exceedsDepth(int depth)
This function tests whether this Term exceeds the given depth which should be a non-negative integer. |
int |
getDepth()
This function returns the nesting depth of this Term. |
Symbol |
getSymbol()
This function can be used to extract the Symbol contained in this Constant. |
int |
hashCode()
This function returns the hash code of this Constant which is the hash code of the contained symbol. |
boolean |
isGround()
This function tests whether this Term contains any Variables. |
java.lang.String |
toString()
A Constant is printed as the Symbol it holds. |
boolean |
unify(Term other,
Substitution s)
This function attempts to extend the given Substitution so that this Term and the given Term are unified. |
Methods inherited from class ai.krr.fol.Term |
---|
getVariables |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected final Symbol theSy
Constructor Detail |
---|
public Constant(Symbol aSy)
This constructor just takes the Symbol that is this Term. Note that there is only one NamedSymbol (in memory) with this name, but there may well be several Constants containing the same Symbol. The given Symbol can be any type of Symbol, except a BooleanSymbol.
aSy
- the Symbol that is this TermMethod Detail |
---|
public Constant clone()
Cloning a Constant returns this Constant (containing the same Symbol).
clone
in class Term
public Constant clone(Substitution s)
Cloning a Constant under a given Substitution returns this Constant. Since a Constant cannot contain Variables the Substitution will be ignored.
clone
in class Term
s
- a Substitution (will be ignored)
public final boolean isGround()
This function tests whether this Term contains any Variables. Constants never contain Variables.
isGround
in class Term
public final int getDepth()
This function returns the nesting depth of this Term. The depth of a Constant is defined to be 0.
getDepth
in class Term
public final boolean exceedsDepth(int depth)
This function tests whether this Term exceeds the given depth which should be a non-negative integer.
exceedsDepth
in class Term
depth
- the depth value that is tested for
public java.lang.Object evaluate(Interpretation ipt, Substitution s)
This function evaluates this Term under the given Interpretation and Substitution for Variables. If all sub-Terms occurring in the Term have a value assigned by the Interpretation the result will be a Object from the Interpretation's domain.
evaluate
in class Term
ipt
- the Interpretation giving values for Termss
- the Substitution for Variables occurring in this Term
public boolean unify(Term other, Substitution s)
This function attempts to extend the given Substitution so that this Term and the given Term are unified. It returns true if and only if this is possible. If the other Term is a Constant then unification succeeds only if the two contained Symbols are equal. If the other Term is a Variable then unification succeeds only if the given Substitution can be extended accordingly. FunctionTerms can never be unified with Constants.
unify
in class Term
other
- the other Term this Constant is to be unified withs
- the Substitution to be extended for the unification
public int compareTo(Term other)
This function compares this Constant to the given Term. Variables and FunctionTerms are both considered to come after Constants in the order defined here.
compareTo
in interface java.lang.Comparable<Term>
compareTo
in class Term
other
- the Term to which this Constant is to be compared
public final Symbol getSymbol()
This function can be used to extract the Symbol contained in this Constant.
public int compareTo(Constant other)
This function compares this Constant to the given Constant. The order between Constants is defined by the order of the Symbols they contain.
other
- the Constant to which this Constant is to be compared
protected void addConstants(java.util.Set<Symbol> sys)
This function adds all the constant Symbols used in this Term to the given Set.
addConstants
in class Term
sys
- the Set that will contain all the Constantsprotected final void addFunctions(java.util.Map<Symbol,java.lang.Integer> sys)
This function adds all the function Symbols used in this Term to the given Set.
addFunctions
in class Term
sys
- the Set that will contain all the function namesprotected final void addVariables(java.util.Set<Variable> vars)
This function adds the Variables in this Term to the given Set. However, since Constants do not contain Variables this function effectively does nothing.
addVariables
in class Term
vars
- a Set of Variables (will be ignored)protected final void addFreeVariables(java.util.Set<Variable> free, java.util.Set<Variable> bound)
This function adds the free Variables in this Term to the first given Set. Variables in the second given Set are bound and will not be added.
addFreeVariables
in class Term
free
- a Set of free Variables that will be extendedbound
- a Set of bound Variables that will not be addedpublic java.lang.String toString()
A Constant is printed as the Symbol it holds.
toString
in class java.lang.Object
public boolean equals(java.lang.Object other)
A Constant can only be equal to any other Constant. It never equals a Variable or any other kind of Term.
equals
in class java.lang.Object
other
- the Object this Constant is compared to
public boolean equals(Constant other)
A Constant is equal to any other Constant that holds an equal Symbol.
other
- the Constant this Constant is compared to
public final int hashCode()
This function returns the hash code of this Constant which is the hash code of the contained symbol.
hashCode
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |