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
-
Substitution()
- The constructor just initializes the Substituiton as empty.
-
clone()
- This function returns a copy of this Substitution that will be identical
to this Substitution.
-
getTerm(Variable)
- This function returns the Term associated with this Variable in this
Substitution or null if there is no such Term.
-
getValue(Variable)
- This function returns the Term the given Variable is mapped to.
-
getVars()
-
This function returns a Vector of all the Variables that are unified in
this Substitution.
-
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.
-
toString()
- This function renders this Substitution printable.
-
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.
-
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.
Substitution
public Substitution()
- The constructor just initializes the Substituiton as empty. In an empty
Substitution no Variables are mapped to anything.
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
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:
- the Variable was not instantiated before and association with the
given Term does not introduce a circle into the substitution, or
- the variable was instantiated before and old and new term are
unifiable without causing circles.
- 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.
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:
- both Variables have not been mapped to Terms in this Substitution
previously, or
- only one of the two given Variables has been mapped to a Term by
this Substitution previously and this Term does not contain the other
Variable or any other Variable associated with it, or
- both Variables had Terms associated with them and these Terms are
unifyable without causing circles in this Substitution.
- 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.
getValue
public Term getValue(Variable aVar) throws IllegalArgumentException
- This function returns the Term the given Variable is mapped to. More
specifically, it returns:
- a new VarTerm with a new Variable iff the Variable is not part
of the Substitution or has no Term associated with it; the new
VarTerm will be retained for future consistency;
- a Term that is the instantiation of the associated Term under
this Substitution iff there is an associated term;
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.
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.
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.
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
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