jtp.fol
Class UnifyableList
java.lang.Object
|
+--java.util.AbstractCollection
|
+--java.util.AbstractList
|
+--jtp.fol.SubstitutableList
|
+--jtp.fol.UnifyableList
- All Implemented Interfaces:
- Collection, List, Serializable, Substitutable, Unifyable
- public class UnifyableList
- extends SubstitutableList
- implements Unifyable
A List that implements the Unifyable interface. That is, it has
elements that can be unified. UnifyableLists are often used to
represent function terms.
- See Also:
- Serialized Form
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 bindings)
Attempts to unify with another object, that is find a variable assignment
that will make the two objects equal. |
Methods inherited from class java.util.AbstractList |
add, add, addAll, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, removeRange, set, subList |
getVariables
public Collection getVariables(Collection target)
- Description copied from interface:
Unifyable
- Retrieves the variables in this Unifyable and places them into a provided target collection.
- Specified by:
getVariables
in interface Unifyable
- 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()
- Description copied from interface:
Unifyable
- Replaces all the variables in this Unifyable by their values. If a value is,
in its turn, a variable, the process is repeated.
- Specified by:
deReferenceVariables
in interface Unifyable
- 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
contains
public boolean contains(Variable v)
- Description copied from interface:
Unifyable
- 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).
- Specified by:
contains
in interface Unifyable
- Parameters:
v
- the variable to look for
- Returns:
- true if the variable was found in this Unifyable.
unify
public boolean unify(Object o,
List bindings)
- Description copied from interface:
Unifyable
- 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.
- Specified by:
unify
in interface Unifyable
- Parameters:
o
- the object to unify with.bindings
- the variable stack
- Returns:
- true if successful