All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class JavaAgent.resource.fopl.Substitution

java.lang.Object
   |
   +----JavaAgent.resource.fopl.Substitution

public class Substitution
extends Object
A Substitution maps a set of Variables to a set of Terms. Each Variable belongs to a set of Variables in the Substitution. Each set of Variables might have a Term associated with it. Substitutions are mainly used for unification of Terms or instantiation of Terms.

See Also:
Variable, Term, UnificationException

Constructor Index

 o Substitution()
The constructor just initializes the Substituiton as empty.

Method Index

 o clone()
This function returns a copy of this Substitution that will be identical to this Substitution.
 o getTerm(Variable)
This function returns the Term associated with this Variable in this Substitution or null if there is no such Term.
 o getValue(Variable)
This function returns the Term the given Variable is mapped to.
 o getVars()
This function returns a Vector of all the Variables that are unified in this Substitution.
 o lockVariable(Variable)
This function can be used to make sure that a Variable that is not already mapped to a Term by this Substitution will not be touched.
 o toString()
This function renders this Substitution printable.
 o unify(Variable, Term)
This function attempts to extend this Substitution such that the given Variable and the given Term are unified and returns whether this succeeded.
 o unify(Variable, Variable)
This function attempts to extend this Substitution such that the given Variables will be unified and returns true if this was possible.

Constructors

 o Substitution
 public Substitution()
The constructor just initializes the Substituiton as empty. In an empty Substitution no Variables are mapped to anything.

Methods

 o clone
 public Object clone()
This function returns a copy of this Substitution that will be identical to this Substitution. Hoeever, modification to the new Substitution will not affect the original.

Overrides:
clone in class Object
 o unify
 public boolean unify(Variable aVar,
                      Term aTerm) throws IllegalArgumentException, UnificationException
This function attempts to extend this Substitution such that the given Variable and the given Term are unified and returns whether this succeeded. Basically, this will succeed if:

Parameters:
aVar - the Variable the given Term is to be unified with
aTerm - the Term the given Variable will be mapped to
Returns:
whether successful extension of this Substitution was possible
Throws: IllegalArgumentException
An exception will occor if the given Variable or Term are null.
Throws: UnificationException
An exception will occor if this Substitution has already been finished.
 o unify
 public boolean unify(Variable var1,
                      Variable var2) throws IllegalArgumentException, UnificationException
This function attempts to extend this Substitution such that the given Variables will be unified and returns true if this was possible. This will be the case if:

Parameters:
var1 - a Variable to be associated with the other given Variable
var2 - a Variable to be associated with the other given Variable
Returns:
whether successful extension of this Substitution was possible
Throws: IllegalArgumentException
An exception will occor if either of the given Variables is null.
Throws: UnificationException
An exception will occor if this Substitution has already been finished.
 o getValue
 public Term getValue(Variable aVar) throws IllegalArgumentException
This function returns the Term the given Variable is mapped to. More specifically, it returns:

Once this function has been called this Substitution can no longer be modified with calls to unify(...) above.

Parameters:
aVar - the Variable the Term is being seeked for
Returns:
the instantiated Term the given Variable is mapped to
Throws: IllegalArgumentException
An exception will occor if the given Variable is null.
 o lockVariable
 public void lockVariable(Variable aVar) throws UnificationException
This function can be used to make sure that a Variable that is not already mapped to a Term by this Substitution will not be touched.

Parameters:
aVar - the Variable to be locked
Throws: UnificationException
An exception will occur if the given Variable is already part of this Substitution.
 o getTerm
 protected Term getTerm(Variable v) throws IllegalArgumentException
This function returns the Term associated with this Variable in this Substitution or null if there is no such Term. The returned Term will be instantiated under this Substitution. Variables in the returned Term are not replaced by other Terms in the Substitution. Use getValue(Variable) (above) to get an instantiatied version of the Term associated with the given Variable.

Parameters:
v - the Variable the Term is being seeked for
Returns:
the uninstantiated Term the given Variable is mapped to
Throws: IllegalArgumentException
An exception will occor if the given Variable is null.
 o getVars
 public Vector getVars()
This function returns a Vector of all the Variables that are unified in this Substitution. It will not include new Variables old ones are being mapped to.

Returns:
a Vector of all the Variables that are unified in this Substitution
 o toString
 public String toString()
This function renders this Substitution printable.

Returns:
the String representing this Substitution
Overrides:
toString in class Object

All Packages  Class Hierarchy  This Package  Previous  Next  Index