Modifier and Type | Field and Description |
---|---|
static java.lang.String |
COMMA |
static java.lang.String |
LEFT_PAR |
static java.lang.String |
RIGHT_PAR |
Constructor and Description |
---|
NonVariableTerm(OperationSymbol opSym,
java.util.List<Term> children) |
Modifier and Type | Method and Description |
---|---|
int |
depth()
The depth of the term tree.
|
boolean |
equals(java.lang.Object obj) |
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.Set<OperationSymbol> |
getOperationSymbols()
The set of operation symbols or null for a variable.
|
java.util.List<Variable> |
getVariableList()
The list of variables in the order they appear in the term.
|
int |
hashCode() |
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<Variable,java.lang.Integer> 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.
|
static Term |
makeConstantTerm(OperationSymbol sym)
A static method to make a constant term from an operation symbol.
|
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.
|
public static final java.lang.String LEFT_PAR
public static final java.lang.String RIGHT_PAR
public static final java.lang.String COMMA
public NonVariableTerm(OperationSymbol opSym, java.util.List<Term> children)
public static Term makeConstantTerm(OperationSymbol sym)
sym
- public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public boolean isaVariable()
isaVariable
in interface Term
public OperationSymbol leadingOperationSymbol()
leadingOperationSymbol
in interface Term
public java.util.List<Term> getChildren()
getChildren
in interface Term
public java.lang.Object eval(Algebra alg, java.util.Map map)
public int intEval(Algebra alg, java.util.Map<Variable,java.lang.Integer> map)
Term
map
as
the variable assignment.public Operation interpretation(SmallAlgebra alg, java.util.List<Variable> varlist, boolean useAll)
Term
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.
(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.interpretation
in interface Term
alg
- the Algebravarlist
- the list of variablesuseAll
- if true, use all the variables in varlistpublic TermOperation interpretation(SmallAlgebra alg)
Term
(z*y)*z
.
The result will be a 2 place operation with z
as the first
variable and y
as the second.interpretation
in interface Term
alg
- the Algebra#interpretation(Algebra,List,boolean)
public java.util.List<Variable> getVariableList()
Term
getVariableList
in interface Term
public java.util.Set<OperationSymbol> getOperationSymbols()
Term
getOperationSymbols
in interface Term
public int length()
Term
public int depth()
Term
public Term substitute(java.util.Map<Variable,Term> map)
Term
substitute
in interface Term
map
- a map for the substitutionpublic java.lang.String toString()
Term
public java.lang.StringBuffer writeStringBuffer(java.lang.StringBuffer sb)
Term
writeStringBuffer
in interface Term
Copyright 2003 Ralph Freese. All Rights Reserved.