org.uacalc.terms
Interface Term

All Known Subinterfaces:
Variable
All Known Implementing Classes:
NonVariableTerm, VariableImp

public interface Term


Method Summary
 int depth()
          The depth of the term tree.
 java.lang.Object eval(Algebra alg, java.util.Map map)
          The evaluation of this term in an algebra using map as the variable assignment.
 java.util.List<Term> getChildren()
          A list of terms which are the immediate children.
 java.util.List<Variable> getVariableList()
          The list of variables in the order they appear in the term.
 TermOperation interpretation(SmallAlgebra alg)
          The operation obtained from this term using the variables in the order they occur.
 Operation interpretation(SmallAlgebra alg, java.util.List<Variable> varlist, boolean useAll)
          The interpretation of this term in an algebra; that is, the operation on alg corresponding to this term.
 int intEval(Algebra alg, java.util.Map map)
          The int evaluation of this term in an algebra using map as the variable assignment.
 boolean isaVariable()
           
 OperationSymbol leadingOperationSymbol()
          The leading operation symbol or null if this term is a variable.
 int length()
          The length of the term.
 Term substitute(java.util.Map<Variable,Term> map)
          Replace some of the variables with terms.
 java.lang.String toString()
          A reasonably good printout of the term.
 java.lang.StringBuffer writeStringBuffer(java.lang.StringBuffer sb)
          This is really an efficiency helper for toString.
 

Method Detail

isaVariable

boolean isaVariable()

leadingOperationSymbol

OperationSymbol leadingOperationSymbol()
The leading operation symbol or null if this term is a variable.


getChildren

java.util.List<Term> getChildren()
A list of terms which are the immediate children. If the term is a variable this return null; it is a constant this returns the empty list.


eval

java.lang.Object eval(Algebra alg,
                      java.util.Map map)
The evaluation of this term in an algebra using map as the variable assignment.


intEval

int intEval(Algebra alg,
            java.util.Map map)
The int evaluation of this term in an algebra using map as the variable assignment.


interpretation

Operation interpretation(SmallAlgebra alg,
                         java.util.List<Variable> varlist,
                         boolean useAll)
The interpretation of this term in an algebra; that is, the operation on alg corresponding to this term. The varlist, a list of Variable's, specifies the order. If useAll is true, variables that are not explicit in this term are still used.
For example, suppose the term is (z*y)*z, and varlist is (x, y, z). If useAll is true, the resulting operation will have arity 3 and be independent of its first variable. Otherwise it will be a 2 place operation with y as the first variable and z as the second.

Parameters:
alg - the Algebra
varlist - the list of variables
useAll - if true, use all the variables in varlist
Returns:
the term operation

interpretation

TermOperation interpretation(SmallAlgebra alg)
The operation obtained from this term using the variables in the order they occur.
For example, suppose the term is (z*y)*z. The result will be a 2 place operation with z as the first variable and y as the second.

Parameters:
alg - the Algebra
Returns:
the term operation
See Also:
#interpretation(Algebra,List,boolean)

depth

int depth()
The depth of the term tree. A variable has depth 0.


length

int length()
The length of the term. A variable has length 1.


getVariableList

java.util.List<Variable> getVariableList()
The list of variables in the order they appear in the term.


substitute

Term substitute(java.util.Map<Variable,Term> map)
Replace some of the variables with terms.

Parameters:
map - a map for the substitution
Returns:

toString

java.lang.String toString()
A reasonably good printout of the term.

Overrides:
toString in class java.lang.Object

writeStringBuffer

java.lang.StringBuffer writeStringBuffer(java.lang.StringBuffer sb)
This is really an efficiency helper for toString. It returns the StringBuffer as a convenience.



Copyright 2003 Ralph Freese. All Rights Reserved.