|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object blog.ArgSpec blog.Term blog.LogicalVar
public class LogicalVar
A logical variable. Specifically, a single LogicalVar object is used for the introduction of a logical variable in a particular scope, and for all uses of the variable in that scope. Unlike other terms, LogicalVar objects can be compared safely using ==.
Note that some LogicalVar objects are not created directly by the
parser, but are returned by the getTermInScope
method on
SymbolTerm. This is because, in some contexts, the parser cannot
distinguish a logical variable from a constant symbol based on local
syntax alone.
Field Summary |
---|
Fields inherited from class blog.ArgSpec |
---|
location |
Constructor Summary | |
---|---|
LogicalVar(java.lang.String name,
Type type)
Creates a new LogicalVar with the given name and type. |
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). |
static LogicalVar |
createVar(Type type)
|
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. |
java.lang.String |
getName()
Returns the name of this variable. |
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 . |
Type |
getType()
Returns the type of this variable. |
BayesNetVar |
getVariable()
Returns the (basic or derived) random variable that this argument specification corresponds to. |
LogicalVar |
makeNew()
|
boolean |
makeOverlapSubst(Term t,
Substitution theta)
Function for computing a substitution that will make the two terms overlap. |
java.lang.String |
toString()
Returns the name of this variable. |
Methods inherited from class blog.Term |
---|
containsTerm, getGenFuncsApplied, getTermInScope, isConstantNull, isNumeric, makeOverlapSubst |
Methods inherited from class blog.ArgSpec |
---|
evaluate, evaluate, getLocation, getSubExprs, getSubstResult, getValueIfNonRandom, isDetermined, setLocation |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public LogicalVar(java.lang.String name, Type type)
Method Detail |
---|
public java.lang.String getName()
public boolean checkTypesAndScope(Model model, java.util.Map scope)
ArgSpec
checkTypesAndScope
in class ArgSpec
scope
- a Map from variable names (Strings) to LogicalVar objectspublic 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()
getType
in class Term
public java.lang.Object evaluate(EvalContext context)
ArgSpec
evaluate
in class ArgSpec
public BayesNetVar getVariable()
ArgSpec
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 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 LogicalVar makeNew()
public java.lang.String toString()
toString
in class java.lang.Object
public static LogicalVar createVar(Type type)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |