Package edu.tufts.hrilab.fol
Class Term
java.lang.Object
edu.tufts.hrilab.fol.Symbol
edu.tufts.hrilab.fol.Term
- All Implemented Interfaces:
Serializable
,Cloneable
- Direct Known Subclasses:
Predicate
Representation of term logical form.
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
Deprecated.protected void
applyBindingMap
(Map<Variable, ? extends Symbol> bindings) Protected helper method for copyWithNewBindings.protected void
applyVariableTypes
(Collection<Variable> typedVariables) Replaces variables' types with passed in variables' types.clone()
copyWithNewBindings
(List<? extends Map<Variable, ? extends Symbol>> bindings) copyWithNewBindings
(Map<Variable, ? extends Symbol> bindings) Similar to applyBindingMap, except this Term is not bound.copyWithNewVariableTypes
(Collection<Variable> typedVariables) Returns a clone with replaced variables' types with passed in variables' types.boolean
Check whether the given object is equal to this one.boolean
Compare without checking semantic type information.get
(int i) Returns the i-th argument, null if the i is out of range.getArgs()
Get arguments as a shallow copy.Gets arguments as a deep copy.Deprecated.getBindings
(Term other) Gets variable bindings from this Term to another.Get leaves in order in which they appear (depth first in cases of nested Terms).Get all Variable instances in the order in which they appear (depth first in cases of nested Terms).getVars()
Get all Variable instances contained in this Term.boolean
hasArgs()
Checks if this symbol has arguments.int
hashCode()
Calculate hash code for this Term.boolean
instanceOf
(Term template) Compares "instantiated" term to a template.boolean
Check if this Term is negated (i.e., functor name is "not").boolean
isTerm()
void
Deprecated.int
size()
Return the number of arguments.toString()
Constructs a String representation of the Term.Returns a FOL instance that is not negated (i.e., drops outer "not" if it exists).Constructs a String representation that does not include type information.Methods inherited from class edu.tufts.hrilab.fol.Symbol
getName, getType, hasType, isConstant, isPredicate, isVariable, setName
-
Field Details
-
args
-
-
Constructor Details
-
Term
-
Term
-
Term
-
Term
-
Term
-
Term
-
-
Method Details
-
add
Deprecated. -
get
Returns the i-th argument, null if the i is out of range.- Parameters:
i
-- Returns:
-
getArgs
Get arguments as a shallow copy.- Returns:
-
getArgsRef
Deprecated. -
getArgsCopy
Gets arguments as a deep copy.- Returns:
-
getVars
Get all Variable instances contained in this Term.- Returns:
-
getOrderedVars
Get all Variable instances in the order in which they appear (depth first in cases of nested Terms).- Returns:
-
getOrderedLeaves
Get leaves in order in which they appear (depth first in cases of nested Terms).- Returns:
-
getBindings
Gets variable bindings from this Term to another. Supports nested terms (and will return those bindings as well).- Parameters:
other
- Term providing the bindings for variables in this term- Returns:
- bindings map
-
instanceOf
Compares "instantiated" term to a template. TODO: FIXME: this is broken when a variable appears more than once in the template and different values are used for that variable- Parameters:
template
-- Returns:
- true if this predicate matches the template.
-
copyWithNewBindings
Similar to applyBindingMap, except this Term is not bound. Instead, a cloned version is bound and returned.- Parameters:
bindings
-
-
copyWithNewBindings
-
applyBindingMap
Protected helper method for copyWithNewBindings. Replaces Variables with Symbols from the bindings map. Note that not all Variables need to be bound.- Parameters:
bindings
-
-
copyWithNewVariableTypes
Returns a clone with replaced variables' types with passed in variables' types.- Parameters:
typedVariables
-- Returns:
-
applyVariableTypes
Replaces variables' types with passed in variables' types. -
set
Deprecated. -
size
public int size()Return the number of arguments.- Returns:
-
equalsIgnoreType
Compare without checking semantic type information.- Overrides:
equalsIgnoreType
in classSymbol
- Parameters:
o
-- Returns:
-
equals
Check whether the given object is equal to this one. Two Symbols are equal if they're of the same class, their names are the same, and their args are the same. -
hashCode
public int hashCode()Calculate hash code for this Term. -
toString
Constructs a String representation of the Term. If the term is negated, then it is wrapped in a not(). -
toUntypedString
Description copied from class:Symbol
Constructs a String representation that does not include type information.- Overrides:
toUntypedString
in classSymbol
- Returns:
- String of the form "name(arg0,..., argN)"
-
toUnnegatedForm
Description copied from class:Symbol
Returns a FOL instance that is not negated (i.e., drops outer "not" if it exists). This doesn't apply to the Symbol class which can't be negated, but is here as a convenience so that Term/Predicate instances passed as Symbols (e.g., via getArgs) don't need to be cast to Term/Predicate.- Overrides:
toUnnegatedForm
in classSymbol
- Returns:
- Un-negated form of this FOL class.
-
toNegatedForm
-
isNegated
public boolean isNegated()Check if this Term is negated (i.e., functor name is "not").- Returns:
-
clone
-
hasArgs
public boolean hasArgs()Checks if this symbol has arguments. -
isTerm
public boolean isTerm()
-