code.term
Class Term

java.lang.Object
  extended by code.term.Term

public class Term
extends java.lang.Object

This class implements a term. There is an overloaded constructor for each kind of term:

Since the root of an algebraic type is an int, the second argument of an algebraic type term is an array of terms, the arguments. This array has zero length for a nullary symbol term.

Since:
June 17, 2003
Author:
Sergio Antoy

Field Summary
static Term[] noArgs
          Terms made up by a nullary symbol must still use the binary constructor to discriminate with the constructor that construct integer constants.
(package private)  TermImpl representation
          The implementation of this term.
 
Constructor Summary
Term(char value)
           
Term(float value)
           
Term(int value)
           
Term(int root, Term[] argument)
           
Term(java.lang.String value)
           
Term(Term referee)
           
Term(TermImpl representation)
           
Term(Variable variable)
           
 
Method Summary
 Term cloneWithReplace(Term out, Term in)
           
 Term cloneWithSubst(Subst subst)
           
 Term eqBool(Term right)
           
 Term eqSuccess(Term right)
           
 Term[] getArgument()
          Returns the list of arguments for this term.
 Term getArgument(byte number)
          Returns the number-th argument of this term.
 Instruction[] getCode()
          Returns the bytecode represented with objects for rewritting this term.
 byte getKind()
          Returns the kind of this term.
 TermImpl getRepresentation()
           
 int getRoot()
          Returns the root id of this term.
 java.lang.String getRootSymbol()
          Returns the root symbol of this term
 boolean isHNF()
          Returns true if this term is in head normal form.
 boolean isNF()
          Returns true if this term is in normal form.
 java.lang.String toString()
          Returns a String representation of this term.
 java.lang.String toString(Subst substitution)
          Returns a String representation of this term.
 void update(Term replacement)
          Replaces the representation of this term with the replacement.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

representation

TermImpl representation
The implementation of this term.


noArgs

public static final Term[] noArgs
Terms made up by a nullary symbol must still use the binary constructor to discriminate with the constructor that construct integer constants. Therefore, an array of zero arguments.

Constructor Detail

Term

public Term(int root,
            Term[] argument)

Term

public Term(Variable variable)

Term

public Term(int value)

Term

public Term(float value)

Term

public Term(char value)

Term

public Term(java.lang.String value)

Term

public Term(TermImpl representation)

Term

public Term(Term referee)
Method Detail

getRepresentation

public TermImpl getRepresentation()

getRoot

public int getRoot()
Returns the root id of this term.

Returns:
The root value

getRootSymbol

public java.lang.String getRootSymbol()
Returns the root symbol of this term

Returns:
String

getArgument

public Term[] getArgument()
Returns the list of arguments for this term.

Returns:
The argument value

getArgument

public Term getArgument(byte number)
Returns the number-th argument of this term.

Parameters:
number -
Returns:
Term

getKind

public byte getKind()
Returns the kind of this term.

Returns:
The kind value

isHNF

public boolean isHNF()
Returns true if this term is in head normal form.

Returns:
boolean

isNF

public boolean isNF()
Returns true if this term is in normal form.

Returns:
boolean

getCode

public Instruction[] getCode()
Returns the bytecode represented with objects for rewritting this term.

Returns:
The code value

update

public void update(Term replacement)
Replaces the representation of this term with the replacement.

Parameters:
replacement - The replacement

toString

public java.lang.String toString()
Returns a String representation of this term. This method should be called on terms that have no occurrences of bound variables. Generally these terms are the normal form results of computations.

Overrides:
toString in class java.lang.Object
Returns:
String The printable representation of this term.

toString

public java.lang.String toString(Subst substitution)
Returns a String representation of this term. This method should be called on terms that have occurrences of bound variables. Generally these terms are the images of variables of the computed answer of a computation.

Returns:
String The printable representation of this term.

eqSuccess

public Term eqSuccess(Term right)

eqBool

public Term eqBool(Term right)

cloneWithSubst

public Term cloneWithSubst(Subst subst)

cloneWithReplace

public Term cloneWithReplace(Term out,
                             Term in)