| 
||||||||||
| 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.Variable
public class Variable
This class implements symbolic variables in Java. Like NamedSymbols, Variables are memory-unique objects, i.e. they are equal if and only if the handles are the same. This allows the creation of multiple variables with the same name that are not equal. It also allows for efficient equality testing. The unique index could also be used to compare variables.
| Field Summary | |
|---|---|
protected  java.lang.String | 
theName
 | 
protected  NamedSymbol | 
theType
 | 
| Constructor Summary | |
|---|---|
Variable(java.lang.String aName)
It is possible to create Variables directly with this constructor.  | 
|
| 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 this Variable to the given Set.  | 
 Variable | 
clone()
Cloning a Variable returns the this Variable.  | 
 Term | 
clone(Substitution s)
Cloning a Variable with a given Substitution returns a new Term which is determined by the given Substitution.  | 
 int | 
compareTo(Term other)
This function compares this Variable to the given Term.  | 
 int | 
compareTo(Variable other)
This function compares this Variable to the given Variable.  | 
 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.  | 
protected  long | 
getIndex()
This function returns the unique index of this Variable.  | 
 java.lang.String | 
getName()
This function returns the name of this Variable.  | 
 NamedSymbol | 
getType()
This function returns the Symbol that represents the type of this Variable.  | 
 int | 
hashCode()
The hashCode of a Variable is the unique index of this variable.  | 
 boolean | 
isGround()
This function tests whether this Term contains any Variables.  | 
 void | 
setType(NamedSymbol aSy)
This function sets the type of this Variable to the given NamedSymbol (or null).  | 
 java.lang.String | 
toString()
A Variable is printed as a question mark followed by the String that is its name and its index.  | 
 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 | 
|---|
equals, finalize, getClass, notify, notifyAll, wait, wait, wait | 
| Field Detail | 
|---|
protected final java.lang.String theName
protected NamedSymbol theType
| Constructor Detail | 
|---|
public Variable(java.lang.String aName)
It is possible to create Variables directly with this constructor. However, this new Variable will be different from other Variables with the same name!
aName - the name of the Variable| Method Detail | 
|---|
public Variable clone()
 Cloning a Variable returns the this Variable. To obtain a new Variable
 with the same name as this one, use clone(Substitution) with an
 appropriate Substitution.
 
clone in class Termpublic Term clone(Substitution s)
 Cloning a Variable with a given Substitution returns a new Term which is
 determined by the given Substitution. Thus, the returned Term is not
 necessarily a Variable. The function Substitution.getValue(ai.krr.fol.Variable) of the
 Substitution class is used to generate the returned Term. If this
 requires extending the Substitution, the Substitution used must support
 this functionality.
 
To generate a new Variable with the same name as this one, this function can be called with a Substitution that does not contain this Variable. This will result in a new Variable that will then be consistently repleced by the extended Substitution.
clone in class Terms - the Substitution that determines how to replace Variables
public final boolean isGround()
This function tests whether this Term contains any Variables. Variables always contain Variables.
isGround in class Termpublic final int getDepth()
This function returns the nesting depth of this Term. The depth of a Variable is defined to be 0.
getDepth in class Termpublic 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 Termdepth - 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 Constant containing a NamedSymbol which is an element of the Interpretation's domain.
evaluate in class Termipt - 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. A Variable can in principle be unified with any other kind of Term. Whether this succeeds depends entirely on whether the given Substitution can be extended accordingly.
unify in class Termother - the other Term this Variable is to be unified withs - the Substitution to be extended for the unification
public int compareTo(Term other)
This function compares this Variable to the given Term. Constants are considered to come before Variables and FunctionTerms come after Variables in the order defined here.
compareTo in interface java.lang.Comparable<Term>compareTo in class Termother - the Term to which this Variable is to be compared
public final java.lang.String getName()
This function returns the name of this Variable.
public void setType(NamedSymbol aSy)
This function sets the type of this Variable to the given NamedSymbol (or null). If the Variable already had a different type then this will be overwritten.
aSy - the (new) type of this Variable, including nullpublic NamedSymbol getType()
This function returns the Symbol that represents the type of this Variable. It may be null if the type was undefined.
public int compareTo(Variable other)
This function compares this Variable to the given Variable. Two Variables are compared first by name and second by index, which in turn is related to the time when they were created.
other - the Variable to which this Variable 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. Variables contain NamedSymbols only if they are typed.
addConstants in class Termsys - 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 Termsys - the Set that will contain all the function namesprotected final void addVariables(java.util.Set<Variable> vars)
This function adds this Variable to the given Set. If this Variable is already in the Set nothing is added.
addVariables in class Termvars - a Set of Variables that will be extended
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. Variables in the second given Set are bound and will not be added.
addFreeVariables in class Termfree - a Set of free Variables that will be extendedbound - a Set of bound Variables that will not be addedprotected final long getIndex()
This function returns the unique index of this Variable.
public java.lang.String toString()
 A Variable is printed as a question mark followed by the String that is
 its name and its index. Use getName() to get the String
 without the index.
 
toString in class java.lang.Objectpublic final int hashCode()
The hashCode of a Variable is the unique index of this variable.
hashCode in class java.lang.Object
  | 
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||