blog
Class Term

java.lang.Object
  extended by blog.ArgSpec
      extended by blog.Term
Direct Known Subclasses:
FuncAppTerm, LogicalVar, SymbolTerm

public abstract class Term
extends ArgSpec

Represents a Bayesian atom. All specific kinds of terms are expected to implement this interface.


Field Summary
 
Fields inherited from class blog.ArgSpec
location
 
Constructor Summary
Term()
           
 
Method Summary
 boolean containsTerm(Term target)
          Returns true if the given term occurs in this term (or if the given term is equal to this term).
abstract  Term getCanonicalVersion()
          Returns a version of this term that uses canonical terms as much as possible.
 java.util.Set getGenFuncsApplied(Term subject)
          Returns the set of generating functions that are applied to the term subject by this term or any of its subterms.
 Term getTermInScope(Model model, java.util.Map scope)
          Returns an object representing this term in the given scope.
abstract  Type getType()
          Returns the type of this term.
 boolean isConstantNull()
          Returns true if this term is the constant term that always denotes Model.NULL.
 boolean isNumeric()
          Returns true if the value of this ArgSpec is always an instance of Number (regardless of scope).
 Substitution makeOverlapSubst(Term t)
          Function for computing a substitution that will make the two terms overlap.
abstract  boolean makeOverlapSubst(Term t, Substitution theta)
          Function for computing a substitution that will make the two terms overlap.
 
Methods inherited from class blog.ArgSpec
checkTypesAndScope, compile, containsRandomSymbol, evaluate, evaluate, evaluate, getFreeVars, getLocation, getSubExprs, getSubstResult, getSubstResult, getValueIfNonRandom, getVariable, isDetermined, setLocation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Term

public Term()
Method Detail

getTermInScope

public Term getTermInScope(Model model,
                           java.util.Map scope)
Returns an object representing this term in the given scope. This method exists to handle cases where a term's class depends on the scope where it occurs, such as when a term consists of a single symbol that may be either a logical variable or a function symbol. If calling checkTypesAndScope on this term would return false, then this method returns null.

The default implementation simply returns this object if checkTypesAndScope returns true, and null otherwise.

Parameters:
model - a BLOG model
scope - a map from String to LogicalVar

getType

public abstract Type getType()
Returns the type of this term. Throws an IllegalStateException if this term has not been compiled successfully (e.g., if this term is a variable that is not in scope).


containsTerm

public boolean containsTerm(Term target)
Returns true if the given term occurs in this term (or if the given term is equal to this term).


getGenFuncsApplied

public java.util.Set getGenFuncsApplied(Term subject)
Returns the set of generating functions that are applied to the term subject by this term or any of its subterms.

The default implementation returns the union of the generating functions applied in this term's sub-expressions. This is overridden by FuncAppTerm.

Returns:
unmodifiable set of OriginFunc

isNumeric

public boolean isNumeric()
Description copied from class: ArgSpec
Returns true if the value of this ArgSpec is always an instance of Number (regardless of scope). The default implementation returns false.

Overrides:
isNumeric in class ArgSpec

isConstantNull

public boolean isConstantNull()
Returns true if this term is the constant term that always denotes Model.NULL. The default implementation returns false.


makeOverlapSubst

public Substitution makeOverlapSubst(Term t)
Function for computing a substitution that will make the two terms overlap. Returns null if there is no such substitution.


makeOverlapSubst

public abstract boolean makeOverlapSubst(Term t,
                                         Substitution theta)
Function for computing a substitution that will make the two terms overlap. The necessary mappings are added to the given substitution theta. If there is no extension of theta that makes this term and t overlap, this method returns false.


getCanonicalVersion

public abstract Term getCanonicalVersion()
Returns a version of this term that uses canonical terms as much as possible. The canonical term for a guaranteed object 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.