|
||||||||||
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.FunctionTerm
public class FunctionTerm
This class allows to build structured Terms that consist of a function symbol and a number of arguments. There must be at least one argument, otherwise this FunctionTerm is a Constant and should be represented as such.
Field Summary | |
---|---|
protected Term[] |
arguments
|
protected Symbol |
function
|
Constructor Summary | |
---|---|
FunctionTerm(Symbol fSymbol,
java.util.List<Term> someTerms)
This constructor for a FunctionTerm takes a function Symbol and a List of argument Terms. |
|
FunctionTerm(Symbol fSymbol,
Term... someTerms)
This constructor for a FunctionTerm takes a function Symbol and a number of argument Terms; at least one. |
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 FunctionTerm to the given Set. |
FunctionTerm |
clone()
Returns a shallow copy of this FunctionTerm. |
FunctionTerm |
clone(Substitution s)
Returns a deep copy of this FunctionTerm with Variables replaced according to the given Substitution. |
int |
compareTo(FunctionTerm other)
This function compares this FunctionTerm to the given FunctionTerm. |
int |
compareTo(Term other)
This function compares this FunctionTerm to the given Term. |
boolean |
equals(FunctionTerm other)
A FunctionTerm is equal to any other FunctionTerm that consists of an equal function symbol followed by an equal number of equal Terms. |
boolean |
equals(java.lang.Object obj)
A FunctionTerm is only equal to another FunctionTerm. |
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. |
Term[] |
getArguments()
This function returns the arguments of this FunctionTerm. |
int |
getDepth()
This function returns the nesting depth of this Term. |
Symbol |
getFunction()
This function returns the function symbol used in this FunctionTerm which is a NamedSymbol. |
int |
hashCode()
This function returns the hash code of this FunctionTerm. |
boolean |
isGround()
This function tests whether this Term contains any Variables. |
java.lang.String |
toString()
A FunctionTerm is printed as <function> ( <term>+ ). |
boolean |
unify(Term other,
Substitution s)
This function attempts to extend the given Substitution so that this FunctionTerm 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 function
protected final Term[] arguments
Constructor Detail |
---|
public FunctionTerm(Symbol fSymbol, java.util.List<Term> someTerms)
This constructor for a FunctionTerm takes a function Symbol and a List of argument Terms. Note that the given List must contain at least one Term.
fSymbol
- the function symbolsomeTerms
- the List of argument Termspublic FunctionTerm(Symbol fSymbol, Term... someTerms)
This constructor for a FunctionTerm takes a function Symbol and a number of argument Terms; at least one.
fSymbol
- the function symbolsomeTerms
- the argument TermsMethod Detail |
---|
public FunctionTerm clone()
Returns a shallow copy of this FunctionTerm. Argument Terms in the copy will be the same as the original ones.
clone
in class Term
public FunctionTerm clone(Substitution s)
Returns a deep copy of this FunctionTerm with Variables replaced
according to the given Substitution. Symbols in the copy will be the same
as the original ones but Variables will be replaced by the respective
Terms in the given Substitution. The function uses
Term.clone(Substitution)
again to generate the copies of all the
argument Terms in this FunctionTerm.
clone
in class Term
s
- the Substitution that tells us how to replace Variables
public boolean isGround()
This function tests whether this Term contains any Variables. This is true only if one of the arguments contains a Variable.
isGround
in class Term
public int getDepth()
This function returns the nesting depth of this Term. The depth of a FunctionTerm is the maximum depth of the sub-Term plus 1.
getDepth
in class Term
public 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 an Object which is an element of 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 FunctionTerm and the given Term are unified. It returns true if and only if this is possible. If the other Term is a FunctionTerm then unification succeeds only if the two function symbols are equal and the Substitution can be extended to unify all arguments. If the other Term is a Variable then unification succeeds only if the given Substitution can be extended accordingly.
unify
in class Term
other
- the other Term this FunctionTerm is to be unified withs
- the Substitution to be extended for the unification
public int compareTo(Term other)
This function compares this FunctionTerm to the given Term. Variables and Constants are both considered to come before FunctionTerms in the order defined here.
compareTo
in interface java.lang.Comparable<Term>
compareTo
in class Term
other
- the Term to which this FunctionTerm is to be compared
public final Symbol getFunction()
This function returns the function symbol used in this FunctionTerm which is a NamedSymbol.
public final Term[] getArguments()
This function returns the arguments of this FunctionTerm.
public int compareTo(FunctionTerm other)
This function compares this FunctionTerm to the given FunctionTerm. The order between FunctionTerms is defined by the order of the function symbols and the sub-Terms they contain. First the function symbols are compared. Next, the first sub-Terms are compared and if they are equal the second sub-Terms are compared etc. It is like an alphabetical sorting.
other
- the FunctionTerm to which this FunctionTerm 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 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 void addVariables(java.util.Set<Variable> vars)
This function adds the Variables in this FunctionTerm to the given Set.
addVariables
in class Term
vars
- a Set of Variables that will be extendedprotected 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 FunctionTerm is printed as <function> ( <term>+ ).
toString
in class java.lang.Object
public boolean equals(java.lang.Object obj)
A FunctionTerm is only equal to another FunctionTerm.
equals
in class java.lang.Object
obj
- the Object this FunctionTerm is compared to
public boolean equals(FunctionTerm other)
A FunctionTerm is equal to any other FunctionTerm that consists of an equal function symbol followed by an equal number of equal Terms.
other
- the Object this FunctionTerm is compared to
public int hashCode()
This function returns the hash code of this FunctionTerm.
hashCode
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |