blog
Interface EvalContext

All Known Implementing Classes:
DefaultEvalContext, InstantiatingEvalContext, ParentRecEvalContext, SimpleInstEvalContext

public interface EvalContext

Interface for objects that encapsulate a partial world and an assignment of values to logical variables. To facilitate debugging, an EvalContext object also maintains a separate stack of objects being evaluated.


Method Summary
 void assign(LogicalVar var, java.lang.Object value)
          Assigns the given value to the given logical variable, overwriting any previous value.
 void assignTuple(LogicalVar[] vars, java.lang.Object[] values)
          Assigns values to a tuple of logical variables.
 java.lang.String getAssignmentStr()
          Returns a string describing the assignment of values to variables in this context.
 java.lang.Object getLogicalVarValue(LogicalVar var)
          Returns the value of the given logical variable in this context, or null if the given logical variable has no assigned value.
 java.util.Set getLogicalVarValues()
          Returns the set of objects that are the value of some logical variable in this context.
 NumberVar getPOPAppSatisfied(java.lang.Object obj)
          Returns the NumberVar (i.e., POP and generating objects) such that the given object satisfies that POP applied to those generating objects in this world.
 ObjectSet getSatisfiers(NumberVar popApp)
          Returns the set of objects that satisfy the given POP in this world.
 java.lang.Object getValue(BasicVar var)
          Returns the value of the given basic random variable in this partial world, or null if the given variable is not instantiated.
 java.lang.Boolean objectExists(java.lang.Object obj)
          Returns Boolean.TRUE if obj exists in all worlds consistent with this context's partial world.
 void popEvaluee()
          Pops the top object from the stack of objects being evaluated.
 void printEvalTrace(java.io.PrintStream s)
          Prints the sequence of objects being evaluated, in the order they were added to the stack, to the given stream.
 void pushEvaluee(java.lang.Object evaluee)
          Pushes the given object onto the stack of objects being evaluated.
 void unassign(LogicalVar var)
          Erases any value currently assigned to the given logical variable.
 void unassignTuple(LogicalVar[] vars)
          Erases any values currently assigned to any of the given logical variables.
 boolean usesIdentifiers(Type type)
          Returns true if the world that underlies this context uses object identifiers for the given type.
 

Method Detail

getValue

java.lang.Object getValue(BasicVar var)
Returns the value of the given basic random variable in this partial world, or null if the given variable is not instantiated.


getSatisfiers

ObjectSet getSatisfiers(NumberVar popApp)
Returns the set of objects that satisfy the given POP in this world. The objects may be represented as actual objects or identifiers, depending on the way the underlying PartialWorld implementation handles objects of the relevant type. A null return value indicates that the relevant number variable is not instantiated.

The set returned by this method will remain correct if new basic random variables are instantiated. It may not remain correct if new identifiers are added or already-instantiated random variables are changed.


getPOPAppSatisfied

NumberVar getPOPAppSatisfied(java.lang.Object obj)
Returns the NumberVar (i.e., POP and generating objects) such that the given object satisfies that POP applied to those generating objects in this world. Returns null if the given object does not satisfy any POP application.

Throws:
java.lang.IllegalArgumentException - if the given object does not exist in this world

usesIdentifiers

boolean usesIdentifiers(Type type)
Returns true if the world that underlies this context uses object identifiers for the given type.


objectExists

java.lang.Boolean objectExists(java.lang.Object obj)
Returns Boolean.TRUE if obj exists in all worlds consistent with this context's partial world. This is true if obj is a guaranteed object, a concrete non-guaranteed object whose number variable is instantiated to a sufficiently large value, or an object identifier. Returns Boolean.FALSE if obj is a concrete non-guaranteed object whose number variable is instantiated to a value that is too small. If neither of the above cases holds, then this method returns null.

Throws:
java.lang.IllegalArgumentException - if obj is an identifier that is not in the common ground of this context's world

getLogicalVarValue

java.lang.Object getLogicalVarValue(LogicalVar var)
Returns the value of the given logical variable in this context, or null if the given logical variable has no assigned value.


getLogicalVarValues

java.util.Set getLogicalVarValues()
Returns the set of objects that are the value of some logical variable in this context.

Returns:
unmodifiable Set of Object

getAssignmentStr

java.lang.String getAssignmentStr()
Returns a string describing the assignment of values to variables in this context.


assign

void assign(LogicalVar var,
            java.lang.Object value)
Assigns the given value to the given logical variable, overwriting any previous value.


assignTuple

void assignTuple(LogicalVar[] vars,
                 java.lang.Object[] values)
Assigns values to a tuple of logical variables.

Parameters:
vars - array of LogicalVar objects
values - array of Objects, in one-to-one correspondence with the elements of vars, representing values for those variables
Throws:
java.lang.IllegalStateException - if the assignment stack is empty

unassign

void unassign(LogicalVar var)
Erases any value currently assigned to the given logical variable.


unassignTuple

void unassignTuple(LogicalVar[] vars)
Erases any values currently assigned to any of the given logical variables.


pushEvaluee

void pushEvaluee(java.lang.Object evaluee)
Pushes the given object onto the stack of objects being evaluated. This stack is maintained purely so that the EvalContext can print more informative error messages.


popEvaluee

void popEvaluee()
Pops the top object from the stack of objects being evaluated.

Throws:
java.lang.IllegalStateException - if the stack of objects being evaluated is empty

printEvalTrace

void printEvalTrace(java.io.PrintStream s)
Prints the sequence of objects being evaluated, in the order they were added to the stack, to the given stream.