|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object blog.ArgSpec blog.Term blog.SymbolTerm
public class SymbolTerm
A term consisting of a single symbol. This may be either a zero-ary function application or a use of a logical variable. SymbolTerms occur in the abstract syntax tree for a model only before checkTypesAndScope is called on the expressions in the model. After that point, a SymbolTerm is replaced with a LogicalVar if its symbol is the name of a logical variable in the current scope; otherwise it's replaced with a zero-argument FuncAppTerm.
If you're creating a term or formula programmatically, you should not use SymbolTerm; you should use either LogicalVar or FuncAppTerm.
Field Summary |
---|
Fields inherited from class blog.ArgSpec |
---|
location |
Constructor Summary | |
---|---|
SymbolTerm(java.lang.String symbol)
Creates a new SymbolTerm with the given symbol. |
Method Summary | |
---|---|
boolean |
checkTypesAndScope(Model model,
java.util.Map scope)
Returns true if, within the given scope, all the variables used in this ArgSpec are in scope and all type constraints are satisfied. |
int |
compile(java.util.LinkedHashSet callStack)
Does compilation steps that can only be done correctly once the model is complete. |
boolean |
containsRandomSymbol()
Returns true if this ArgSpec contains any random function symbols or any type symbols (any type might have a number statement, and thus could be random). |
boolean |
equals(java.lang.Object o)
|
java.lang.Object |
evaluate(EvalContext context)
Returns the value of this argument specification in the given context. |
Term |
getCanonicalVersion()
Returns a version of this term that uses canonical terms as much as possible. |
java.util.Set |
getFreeVars()
Returns the logical variables that occur free in this expression. |
Function |
getFunc()
Returns the zero-ary function used in this SymbolTerm, or null if this is an occurrence of a logical variable. |
LogicalVar |
getLogicalVar()
Returns the logical variable used in this SymbolTerm, or null if this is a zero-ary function application. |
ArgSpec |
getSubstResult(Substitution subst,
java.util.Set<LogicalVar> boundVars)
Returns the result of applying the substitution subst to this expression, excluding the logical
variables in boundVars . |
Term |
getTermInScope(Model model,
java.util.Map scope)
Returns an object representing this term in the given scope. |
Type |
getType()
Returns the type of this term. |
BayesNetVar |
getVariable()
Returns the random variable that this term corresponds to. |
int |
hashCode()
|
boolean |
isConstantNull()
Returns true if this term is the constant term that always denotes Model.NULL. |
boolean |
isLogicalVar()
Returns true if this SymbolTerm is an occurrence of a logical variable. |
boolean |
makeOverlapSubst(Term t,
Substitution theta)
Function for computing a substitution that will make the two terms overlap. |
java.lang.String |
toString()
|
Methods inherited from class blog.Term |
---|
containsTerm, getGenFuncsApplied, isNumeric, makeOverlapSubst |
Methods inherited from class blog.ArgSpec |
---|
evaluate, evaluate, getLocation, getSubExprs, getSubstResult, getValueIfNonRandom, isDetermined, setLocation |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public SymbolTerm(java.lang.String symbol)
checkTypesAndScope
method will determine if this
is a zero-ary function or a logical variable.
Method Detail |
---|
public boolean isLogicalVar()
public LogicalVar getLogicalVar()
public Function getFunc()
public boolean checkTypesAndScope(Model model, java.util.Map scope)
ArgSpec
checkTypesAndScope
in class ArgSpec
scope
- a Map from variable names (Strings) to LogicalVar objectspublic Term getTermInScope(Model model, java.util.Map scope)
Term
The default implementation simply returns this object if checkTypesAndScope returns true, and null otherwise.
getTermInScope
in class Term
model
- a BLOG modelscope
- a map from String to LogicalVarpublic int compile(java.util.LinkedHashSet callStack)
ArgSpec
This default implementation just returns 0.
compile
in class ArgSpec
callStack
- Set of objects whose compile methods are parents
of this method invocation. Ordered by invocation
order. Used to detect cycles.public Type getType()
Term
getType
in class Term
public java.lang.Object evaluate(EvalContext context)
ArgSpec
evaluate
in class ArgSpec
public BayesNetVar getVariable()
getVariable
in class ArgSpec
public boolean containsRandomSymbol()
ArgSpec
containsRandomSymbol
in class ArgSpec
public java.util.Set getFreeVars()
ArgSpec
checkTypesAndScope
, which
converts SymbolTerms to LogicalVars.
The default implementation returns the union of the sets of free variables in this expression's sub-expressions.
getFreeVars
in class ArgSpec
public ArgSpec getSubstResult(Substitution subst, java.util.Set<LogicalVar> boundVars)
ArgSpec
subst
to this expression, excluding the logical
variables in boundVars
. This method is used for
recursive calls. The set boundVars
should contain
those variables that are bound in the syntax tree between this
sub-expression and the top-level expression to which the
substitution is being applied.
getSubstResult
in class ArgSpec
public boolean isConstantNull()
Term
isConstantNull
in class Term
public boolean makeOverlapSubst(Term t, Substitution theta)
Term
theta
. If there is no extension of
theta
that makes this term and t
overlap,
this method returns false.
makeOverlapSubst
in class Term
public Term getCanonicalVersion()
Term
obj
of type type
is returned by
type.getCanonicalTerm(obj)
. A term can be
converted to canonical form only if it is non-random and has no
free variables (note that if the term is non-random, its value
must be a guaranteed object). This method returns a canonical
version of this term if possible; otherwise, it returns a
version where the subterms have been converted to canonical
form as much as possible.
getCanonicalVersion
in class Term
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |