|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectai.krr.fol.Term
public abstract class Term
A Term represents an object in a conceptualisation of some domain. Terms are mostly used in logical expressions. Currently, there are three kinds of Term implemented: Constant, Variable, and FunctionTerm.
Constructor Summary | |
---|---|
Term()
|
Method Summary | |
---|---|
protected abstract void |
addConstants(java.util.Set<Symbol> sys)
This function adds all the constant Symbols used in this Term to the given Set. |
protected abstract 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 abstract 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 abstract void |
addVariables(java.util.Set<Variable> vars)
This function adds all the Variables in this Term to the given Set. |
abstract Term |
clone()
Returns a copy of this Term. |
abstract Term |
clone(Substitution s)
Returns a copy of this Term with Variables replaced according to the given Substitution. |
abstract int |
compareTo(Term term)
This function compares this Term to the given Term. |
abstract java.lang.Object |
evaluate(Interpretation i,
Substitution s)
This function evaluates this Term under the given Interpretation and Substitution for Variables. |
abstract boolean |
exceedsDepth(int depth)
This function tests whether this Term exceeds the given depth which should be a non-negative integer. |
abstract int |
getDepth()
This function returns the nesting depth of this Term. |
java.util.Set<Variable> |
getVariables()
This function adds all the Variables in this Term to the returned Set. |
abstract boolean |
isGround()
This function tests whether this Term contains any Variables. |
abstract 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 java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Term()
Method Detail |
---|
public abstract Term clone()
Returns a copy of this Term. Variables and Symbols in the copy will be the same as the original ones.
clone
in class java.lang.Object
public abstract Term clone(Substitution s)
Returns a copy of this Term 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. A Variable not occurring in the Substitution will be replaced by a new (different) Variable with the same name. The given Substitution will be extended to include the mappings of old Variables to new ones (if the Substitution allows for this).
This function can be used to generate a copy of this Term that contains a new set of Variables. The given Substitution should be a new, empty Substitution in this case. Otherwise cloning can be seen as instantiating the Term.
s
- the Substitution that determines how to replace Variables
public abstract boolean isGround()
This function tests whether this Term contains any Variables.
public abstract int getDepth()
This function returns the nesting depth of this Term. The depth of a Constant or Variable is defined to be 0. The depth of a FunctionTerm is the maximum depth of the sub-Term plus 1.
public abstract boolean exceedsDepth(int depth)
This function tests whether this Term exceeds the given depth which should be a non-negative integer.
depth
- the depth value that is tested for
public abstract java.lang.Object evaluate(Interpretation i, 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.
i
- the Interpretation giving values for Termss
- the Substitution for Variables occurring in this Term
public abstract 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. For example, if t1 and t2 are Terms then:
Substitution subst = new Substitution(); boolean unif = t1.unify(t2, subst); Term uniTerm = t1.clone(subst);
will firstly create a new, empty Substitution subst. This will be modified in the call to unify. If unification was possible unif will contain the value true and subst will be the unifying Substitution. Otherwise it will have an undefined value. In the latter case the last line should not be executed. If unification was successful though it is safe and will set uniTerm to the expected value.
other
- the other Term this one is to be unified withs
- the Substitution to be extended for the unification
public abstract int compareTo(Term term)
This function compares this Term to the given Term. The order between different kinds of Term is arbitrarily defined as (ascending): Constant, Variable, FunctionTerm.
compareTo
in interface java.lang.Comparable<Term>
term
- the Term to which this Term is to be compared
public java.util.Set<Variable> getVariables()
This function adds all the Variables in this Term to the returned Set.
protected abstract void addConstants(java.util.Set<Symbol> sys)
This function adds all the constant Symbols used in this Term to the given Set.
sys
- the Set that will contain all the Constantsprotected abstract 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.
sys
- the Set that will contain all the function namesprotected abstract void addVariables(java.util.Set<Variable> vars)
This function adds all the Variables in this Term to the given Set.
vars
- a Set of Variables that will be extendedprotected abstract 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.
free
- a Set of free Variables that will be extendedbound
- a Set of bound Variables that will not be added
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |