blog.distrib
Class TabularInterp

java.lang.Object
  extended by blog.AbstractFunctionInterp
      extended by blog.distrib.TabularInterp
All Implemented Interfaces:
FunctionInterp

public class TabularInterp
extends AbstractFunctionInterp

An interpretation for a function symbol, specified by listing argument tuples and the value that the function returns on each tuple. The first parameter to TabularInterp is the number of arguments to the function. If the number of arguments is k, the remaining parameters are interpreted in groups of k+1, as a tuple of k arguments followed by the function value on those arguments. If an argument tuple is not listed, then the function returns Model.NULL on that tuple.


Constructor Summary
TabularInterp(int arity)
          Creates a new TabularInterp with an empty argument-value mapping.
TabularInterp(java.util.List params)
          Creates a new TabularInterp object with a specified argument-value mapping.
 
Method Summary
 java.util.Set getInverseTuples(java.lang.Object value)
          Returns the set of argument tuples that yield the given value, if this set is finite and can be computed easily.
 java.lang.Object getValue(java.util.List args)
          Returns the value of this function on the given tuple of arguments.
 void put(java.util.List args, java.lang.Object value)
          Adds the given argument-value mapping to this interpretation.
 
Methods inherited from class blog.AbstractFunctionInterp
getInverseArgs
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TabularInterp

public TabularInterp(int arity)
Creates a new TabularInterp with an empty argument-value mapping.


TabularInterp

public TabularInterp(java.util.List params)
Creates a new TabularInterp object with a specified argument-value mapping.

Parameters:
params - List whose first element is an Integer k, and whose remaining elements are interpreted in groups of k+1 as a tuple of arguments and a function value.
Throws:
java.lang.IllegalArgumentException - if params includes more than one value for the same argument tuple
Method Detail

put

public void put(java.util.List args,
                java.lang.Object value)
Adds the given argument-value mapping to this interpretation. Replaces any existing value for the given arguments.

Throws:
java.lang.IllegalArgumentException - if the length of args is not equal to the arity specified in this object's constructor

getValue

public java.lang.Object getValue(java.util.List args)
Description copied from interface: FunctionInterp
Returns the value of this function on the given tuple of arguments. Implementations can assume that the arguments are of the expected types and are not Model.NULL.


getInverseTuples

public java.util.Set getInverseTuples(java.lang.Object value)
Description copied from class: AbstractFunctionInterp
Returns the set of argument tuples that yield the given value, if this set is finite and can be computed easily. Otherwise returns null.

This default implementation just returns null.

Specified by:
getInverseTuples in interface FunctionInterp
Overrides:
getInverseTuples in class AbstractFunctionInterp
Returns:
Set of List of objects