    All Packages  Class Hierarchy  This Package  Previous  Next  Index

# Class JavaAgent.resource.fopl.Term

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

public abstract class Term
extends Object
implements Parsable

A Term represents an object in a conceptualization of some domain. Terms are mostly used in logical expressions. Currently, there are several kinds of Terms implemented.

See Also:
  ConstTerm, VarTerm, FunctTerm, Substitution

##

Term()

##

clone()
  Returns a copy of this Term.
clone(Substitution)
  Returns a copy of this Term with Variables replaced according to the given Substitution.
clone(Substitution, Term, Term)
  Returns a copy of this Term with Variables replaced according to the given Substitution and the first given Term replaced by the second.
contains(Vector, Substitution)
  This function tests whether one of the Variables in the given set of Variables occurs in this Term taking the given Substitution into account.
contains(Vector, Substitution, Vector)
  Like `contains(Vector, Substitution)`, this function tests whether one of the variables in the first given Vector occurs in this Term taking the given Substitution into account.
equals(Object)
  Tests whether this Term is equal to the given Object.
getVars(Vector)
  This function adds the Variables in this Term to the given Vector.
parse(String)
  This function can be used to parse a given String that represents a Term.
unify(Term, Substitution)
  This function attempts to extend the given Substitution so that this Term and the given Term are unified.

##

Term

     public Term()

##

clone

     public abstract Object clone()

  Returns a copy of this Term. Variables and Symbols in the copy will be the same as the original ones.

  Returns:
    an equal copy of this Term
  Overrides:
    clone in class Object

clone

     public abstract Term clone(Substitution s) throws IllegalArgumentException

  Returns a copy of this Term with Variables replaced according to the given Substitution. Symbols in the copy will be the same as the original ones but Variables will be repalced by the respective Terms in the given Substitution. A Variable not occurring in the Substitution will be replaced by a new (different) Variable with the same name. The given Substitution will be extended to include the mappings of old Variables to new ones.

  This function can also be used to generate a copy of this Term that contains a new set of Variables. The given Substitution should be a new, empty Substitution in this case. Otherwise cloning can be seen as instantiating the Term.

  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 be 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.

clone

     protected abstract Term clone(Substitution s,
                                   Term t,
                                   Term rTerm) throws IllegalArgumentException

  Returns a copy of this Term with Variables replaced according to the given Substitution and the first given Term replaced by the second. This function works just like `clone(Substitution)` except that it also replaces a Term. Notice that the replacement Term will be an instance of the second Term under the given Substitution.

  Parameters:
    s - the Substitution that tells us how to replace Variables
    t - the Term to be replaced
    rTerm - the replacement Term
  Returns:
    a new Term that is an instance of this Term with the replaced sub-Term; the Substitution `s` will be extended with any new Variable replacements introduced
  Throws: IllegalArgumentException
    An exception can occur if the given Substitution or one of the given Terms is null.

getVars

     public abstract void getVars(Vector vars) throws IllegalArgumentException

  This function adds the Variables in this Term to the given Vector. No Variable is added twice though.

  Parameters:
    vars - a Vector of Variables that will be extended
  Throws: IllegalArgumentException
    An exception can occur if the given Vector is null.

unify

     public abstract 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. For example, if `t1` and `t2` are Terms then:

  `Substitution subst = new Substitution();`
  `boolean unif = t1.unify(t2, subst);`
  `Term uniTerm = t1.clone(subst);`

  will firstly create a new, empty Substitution `subst`. This will be modified in the call to `unify`. If unification was possible `unif` will contain the value `true` and `subst` will be the unifying Substitution. Otherwise it will have an undefined value. In the latter case the last line should not be executed. If unification was successful though it is save and will set `uniTerm` to the expected value.

  Parameters:
    other - the other Term this one 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 can occur if the given Substitution was already finshed.

contains

     public boolean contains(Vector theVars,
                             Substitution s) throws IllegalArgumentException

  This function tests whether one of the Variables in the given set of Variables occurs in this Term taking the given Substitution into account.

  Parameters:
    theVars - the Variables to be tested whether they occur in this Term
    s - the Substitution under which the test takes place
  Returns:
    `true` if and only if a Variable in the given Vector is contained in this Term under the given Substitution
  Throws: IllegalArgumentException
    An exception can occur if the given Vector or the given Substitution are null.

contains

     protected abstract 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 Term taking the given Substitution into account. Normally, the public version of `contains` (above) should be used. The difference is the third argument which must be a Vector of Variables in this Term that have already been tested for occurance. Variables in this Term that do not contain any Variable from the first set are added to the latter set.

  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

equals

     public abstract boolean equals(Object otherTerm)

  Tests whether this Term is equal to the given Object. This is only true if the structure as well as all of the components of this Term are equal to the given Term.

  Parameters:
    otherTerm - the Object this Term is compared to
  Returns:
    whether the given Object equals this Term
  Overrides:
    equals in class Object

parse

     public static Term parse(String s) throws IllegalArgumentException, ParseException

  This function can be used to parse a given String that represents a Term. The syntax in BNF is as follows:

       <term>       ::= <constant> | <variable> |
                        ( <constant> <term>+ ) |
       <variable>   ::= ?<name>
       <constant>   ::= <name>

  Throws: IllegalArgumentException
    An exception will occur if the supplied String is empty or null.
  Throws: ParseException
    An exception can occur if parsing failed. Potential reasons include a syntax error or an I/O problem.

    All Packages  Class Hierarchy  This Package  Previous  Next  Index