All Packages Class Hierarchy This Package Previous Next Index
Class JavaAgent.resource.fopl.VarTerm
java.lang.Object
|
+----JavaAgent.resource.fopl.Term
|
+----JavaAgent.resource.fopl.VarTerm
- public class VarTerm
- extends Term
This kind of Term represents a symbolic Variable (as opposed to a Java
variable). Variables again can be mapped to other Terms by a Substitution.
Note that several differnent VarTerms can share a Variable.
- See Also:
- Substitution, Variable
-
VarTerm(String)
-
This constructor takes a String that is interpreted as the name of a
Variable.
-
VarTerm(Variable)
- This constructor just takes a Variable that is this Term.
-
clone()
- Cloning a VarTerm returns a new VarTerm with the same Variable.
-
clone(Substitution)
- Cloning a VarTerm with a given Substitution returns a new Term which
is determined by the given Substitution.
-
clone(Substitution, Term, Term)
- Cloning a VarTerm with a given Substitution and Term replacements
returns a new Term which is either an instantiation of the Variable
under the given Substitution or an instance of the replacement Term.
-
contains(Vector, Substitution, Vector)
- Like contains(Vector, Substitution), this function tests whether
one of the variables in the first given Vector occurs in this VarTerm
taking the given Substitution into account.
-
equals(Object)
-
A VarTerm is equal to any other VarTermthat holds
the same Variable.
-
getVar()
- This function can be used to extract the Variable contained in this
VarTerm.
-
getVars(Vector)
- This function adds the Variable in this VarTerm to the given Vector.
-
toString()
- A VarTerm is printed as the Variable it holds.
-
unify(Term, Substitution)
- This function attempts to extend the given Substitution so that this
Term and the given Term are unified.
VarTerm
public VarTerm(Variable aVar) throws IllegalArgumentException
- This constructor just takes a Variable that is this Term. Note that
several VarTerms may share a Variable, but other VarTerms
might contain a different Variable with the same name.
- Parameters:
- aVar - the Variable that is this Term
- Throws: IllegalArgumentException
- An exception will occur if the
given Variable is null.
VarTerm
public VarTerm(String aName) throws IllegalArgumentException
- This constructor takes a String that is interpreted as the name of a
Variable. This constructor will not check whether the given name is a
legal Variable name (e.g. does not contain spaces). It it uses the
static function get of the class Variable to get the Variable
in this VarTerm.
- Parameters:
- aName - the name of the Variable that is this Term
- Throws: IllegalArgumentException
- An exception will occur if the
supplied String is empty or null.
clone
public Object clone()
- Cloning a VarTerm returns a new VarTerm with the same Variable. Use
clone(Substitution) with an appropriate Substitution to
to get a copy with VarTerms replaced by other Terms.
- Returns:
- a VarTerm containing the same Variable as this one
- Overrides:
- clone in class Term
clone
public Term clone(Substitution s) throws IllegalArgumentException
- Cloning a VarTerm with a given Substitution returns a new Term which
is determined by the given Substitution. Thus, the returned Term is
not necessarily a VarTerm. The function getValue(Variable) of
the Substitution class is used to generate the returned Term. A
Variable not occurring in the Substitution will be replaced by a new
(different) Variable with the same name. The given Susbtitution will
be extended to include the mappings of old Variables to new ones.
To generate a new VarTerm with a new Variable with the same name
as this one (unlike clone()) this function can be called with
an empty Substitution.
- Parameters:
- s - the Substitution that tells us how to replace Variables
- Returns:
- a new Term that is an instance of this Term; the Substitution
s will extended with any new Variable replacements introduced
- Throws: IllegalArgumentException
- An exception can occur if the given
Substitution is null. In this case clone() (above) should be
used.
- Overrides:
- clone in class Term
clone
protected Term clone(Substitution s,
Term t,
Term rTerm) throws IllegalArgumentException
- Cloning a VarTerm with a given Substitution and Term replacements
returns a new Term which is either an instantiation of the Variable
under the given Substitution or an instance of the replacement Term.
If this Term is the first given Term the result will be an instance of
the second given Term. Otherwise the function
getValue(Variable) of the Substitution class is used to
generate the returned Term. A Variable not occurring in the Substitution
will be replaced by a new (different) Variable with the same name. The
given Susbtitution will be extended to include the mappings of old
Variables to new ones.
- Parameters:
- s - the Substitution that tells us how to replace Variables
- t - the sub-Term to be replaced
- rTerm - the (uninstantiated) replacement Term
- Returns:
- a new Term that is, apart from the replaced Term, an instance
of this Term; the Substitution s will extended with any new
Variable replacements introduced
- Throws: IllegalArgumentException
- An exception can occur if the given
Substitution is null.
- Overrides:
- clone in class Term
getVars
public void getVars(Vector vars) throws IllegalArgumentException
- This function adds the Variable in this VarTerm to the given Vector. If
the Variable in this VarTerm is already in the Vector nothing is added.
- Parameters:
- vars - a Vector of Variables that will be extended
- Throws: IllegalArgumentException
- An exception can occur if the given
Vector is null.
- Overrides:
- getVars in class Term
unify
public boolean unify(Term other,
Substitution s) throws IllegalArgumentException, UnificationException
- This function attempts to extend the given Substitution so that this
Term and the given Term are unified. It returns true if and
only if this is possible. A VarTerm can in principle be unified with
any other kind of Term. Whether this succeeds depends entirely on
whether the given Substitution can be extended accordingly.
- Parameters:
- other - the other Term this VarTerm is to be unified with
- s - the Substitution to be extended for the unification
- Returns:
- whether a unifying extension of the given Substitution was
possible
- Throws: IllegalArgumentException
- An exception will occur if the given
Term or the given Substitution are null.
- Throws: UnificationException
- An exception will occur if the given
Substitution was already finshed.
- Overrides:
- unify in class Term
contains
protected boolean contains(Vector theVars,
Substitution s,
Vector okVars)
- Like contains(Vector, Substitution), this function tests whether
one of the variables in the first given Vector occurs in this VarTerm
taking the given Substitution into account. Normally, the public version
of contains (in class Term) should be used. The difference is
the third argument which must be a Vector of Variables that have
already been tested for occurance, i.e. if the Variable in this VarTerm
is in the latter Vector it has been tested before.
- Parameters:
- theVars - the Variables to be tested whether they occur in this Term
- s - the Substitution under which the test takes place
- okVars - some Variables in this Term that have already been tested
- Returns:
- true if and only if a Variable in the given Vector is
contained in this Term under the given Substitution
- Overrides:
- contains in class Term
toString
public String toString()
- A VarTerm is printed as the Variable it holds. Note that this can be
changed in the class Variable.
- Returns:
- the String that represents the contained Variable
- Overrides:
- toString in class Object
equals
public boolean equals(Object otherTerm)
- A VarTerm is equal to any other VarTermthat holds
the same Variable. It never equals ConstTerm or any other kind
of Term.
- Parameters:
- otherTerm - the Object this Term is compared to
- Returns:
- whether the given Object equals this VarTerm
- Overrides:
- equals in class Term
getVar
public Variable getVar()
- This function can be used to extract the Variable contained in this
VarTerm.
- Returns:
- the Variable contained in this VarTerm
All Packages Class Hierarchy This Package Previous Next Index