JTP API Documentation

jtp.fol
Interface Unifyable

All Known Implementing Classes:
ListenerTemplate, ReasoningStep, UnifyableList, Variable

public interface Unifyable

This interface represents non-elementary objects that can change depending on interpretation and/or variable assignment, or objects that reference such objects.


Method Summary
 boolean contains(Variable v)
          Checks if this Unifyable contains a given Variable (in that case, they cannot be unified).
 Object deReferenceVariables()
          Replaces all the variables in this Unifyable by their values.
 Collection getVariables(Collection target)
          Retrieves the variables in this Unifyable and places them into a provided target collection.
 boolean unify(Object o, List stack)
          Attempts to unify with another object, that is find a variable assignment that will make the two objects equal.
 

Method Detail

contains

public boolean contains(Variable v)
Checks if this Unifyable contains a given Variable (in that case, they cannot be unified). The simplest (if not always the most efficient) implementation is to delegate u.contains(v) to u.getVariables(null).contains(v).

Parameters:
v - the variable to look for
Returns:
true if the variable was found in this Unifyable.

getVariables

public Collection getVariables(Collection target)
Retrieves the variables in this Unifyable and places them into a provided target collection.

Parameters:
target - the collection to which the variables are added. If null, and this Unifyable contains variables, a new collection is created.
Returns:
the target collection. If target is null, and there are no variables, null is returned; if a new collection is created, it has to be modifyable.

deReferenceVariables

public Object deReferenceVariables()
Replaces all the variables in this Unifyable by their values. If a value is, in its turn, a variable, the process is repeated.

Returns:
the copy of this Unifyable with all variables de-referenced. In many subclass implementations, this is returned if no variables needed to be dereferenced.
See Also:
Variable

unify

public boolean unify(Object o,
                     List stack)
Attempts to unify with another object, that is find a variable assignment that will make the two objects equal. If the unification is sucessful, the state of the participating variables is changed, i.e. they receive values. These variables are added to the variable stack. If the function returned true, but the stack didn't grow, then the two objects were probably equal to begin with.

Parameters:
o - the object to unify with.
stack - the variable stack
Returns:
true if successful

JTP API Documentation