public abstract class BooleanFactory extends Object
comparisonDepth: int // the depth to which circuits should be checked for equalityintEncoding: Options.IntEncoding // the encoding used for generating integers (integer(int)bitwidth: int // the bitwidth used for integer computationscomponents: set BooleanValueBooleanConstant in componentsno f1, f2: BooleanFactory | f1 != f2 => f1.components & f2.components = BooleanConstantlet formulas = (components & BooleanFormula) - NotGate |
min(formulas.label) = 1 && max(formulas.label) = #formulas| Modifier and Type | Method and Description |
|---|---|
BooleanValue |
accumulate(BooleanAccumulator g)
Converts the given accumulator into an immutable boolean value and adds it to this.components.
|
void |
addVariables(int numVars)
Adds the specified number of fresh variables to
this.components. |
BooleanValue |
and(BooleanValue v0,
BooleanValue v1)
Returns a boolean value whose meaning is the conjunction of the input components.
|
int |
bitwidth()
Returns the bitwidth used for integer representation.
|
BooleanValue |
carry(BooleanValue v0,
BooleanValue v1,
BooleanValue cin)
Returns a boolean value whose meaning is the carry out bit of a full binary adder.
|
int |
comparisonDepth()
Returns the depth (from the root) to which components are checked for
semantic equality during gate construction.
|
static BooleanFactory |
constantFactory(Options options)
Returns a BooleanFactory with no variables; the returned factory
can manipulate only constants.
|
boolean |
contains(BooleanValue v)
Returns true if v is in this.components.
|
static BooleanFactory |
factory(int numVars,
Options options)
Returns a boolean factory, initialized to contain the given number
of boolean variables.
|
BooleanValue |
iff(BooleanValue v0,
BooleanValue v1)
Returns a boolean value whose meaning is [[v0]] <=> [[v1]].
|
BooleanValue |
implies(BooleanValue v0,
BooleanValue v1)
Returns a boolean value whose meaning is [[v0]] => [[v1]].
|
abstract Int |
integer(int number)
Returns an Int that represents the given number using this.intEncoding.
|
abstract Int |
integer(int number,
BooleanValue bit)
Returns an Int that represents 0 or the given number, depending on the value of the given bit.
|
abstract Options.IntEncoding |
intEncoding()
Returns the encoding used by this factory to represent integers.
|
BooleanValue |
ite(BooleanValue i,
BooleanValue t,
BooleanValue e)
Returns a boolean value whose meaning is [[i]] ? [[t]] : [[e]].
|
BooleanMatrix |
matrix(Dimensions d)
Returns a BooleanMatrix with the given dimensions and this
as the factory for its non-FALSE components.
|
BooleanMatrix |
matrix(Dimensions d,
IntSet allIndices,
IntSet trueIndices)
Returns a BooleanMatrix m with the given dimensions, this
as its factory, and the indices from the set trueIndices initialized
to TRUE.
|
int |
maxFormula()
Returns the maximum label of a
formula in this.components. |
int |
maxVariable()
Returns the maximum label of a
variable in this.components. |
BooleanValue |
not(BooleanValue v)
Returns the negation of the given boolean value.
|
int |
numberOfVariables()
Returns the number of variables in this factory.
|
BooleanValue |
or(BooleanValue v0,
BooleanValue v1)
Returns a boolean value whose meaning is the disjunction of the input components.
|
void |
setComparisonDepth(int newDepth)
Sets the comparison depth to the given value.
|
BooleanValue |
sum(BooleanValue v0,
BooleanValue v1,
BooleanValue cin)
Returns a boolean value whose meaning is the sum bit of a full binary adder.
|
Int |
sum(Collection<BooleanValue> bits)
Returns an Int that represents the sum of all values in the given collection.
|
BooleanVariable |
variable(int label)
Returns the variable with the given label.
|
BooleanValue |
xor(BooleanValue v0,
BooleanValue v1)
Returns a boolean value whose meaning is [[v0]] ^ [[v1]].
|
public final BooleanValue accumulate(BooleanAccumulator g)
g.components in this.componentsthis.components' = this.components + g'public final void addVariables(int numVars)
this.components.numVars >= 0let diff = this.components' - this.components |
diff in BooleanVariable && #diff = numVars &&
diff.label = { i: int | this.maxFormula() < i <= this.maxFormula() + numVars }public final BooleanValue and(BooleanValue v0, BooleanValue v1)
v0 + v1 in this.componentsthis.components' = this.components + vNullPointerException - any of the arguments are nullpublic final int bitwidth()
public final BooleanValue carry(BooleanValue v0, BooleanValue v1, BooleanValue cin)
v0 + v1 + cin in this.componentsthis.components' = this.components + vNullPointerException - any of the arguments are nullpublic final int comparisonDepth()
public static BooleanFactory constantFactory(Options options)
NullPointerException - options = nullpublic final boolean contains(BooleanValue v)
NullPointerException - v = nullpublic static BooleanFactory factory(int numVars, Options options)
Gates are checked for semantic equality down to the depth given by options.sharing when checking for cached values. In general, setting the comparison depth to a higher value will result in more subcomponents being shared. However, it will also slow down gate construction.
Integers are created/manipulated according to the specifications in the given Options object.
IllegalArgumentException - numVars < 0 || numVars = Integer.MAX_VALUENullPointerException - options = nullpublic final BooleanValue iff(BooleanValue v0, BooleanValue v1)
v0 + v1 in this.componentsthis.components' = this.components + vNullPointerException - any of the arguments are nullpublic final BooleanValue implies(BooleanValue v0, BooleanValue v1)
v0 + v1 in this.componentsthis.components' = this.components + vNullPointerException - any of the arguments are nullpublic abstract Int integer(int number)
IllegalArgumentException - the number cannot be represented using
the specified encodingpublic abstract Int integer(int number, BooleanValue bit)
public abstract Options.IntEncoding intEncoding()
public final BooleanValue ite(BooleanValue i, BooleanValue t, BooleanValue e)
i + t + e in this.componentsthis.components' = this.components + vNullPointerException - any of the arguments are nullpublic final BooleanMatrix matrix(Dimensions d)
NullPointerException - d = nullpublic final BooleanMatrix matrix(Dimensions d, IntSet allIndices, IntSet trueIndices)
BooleanMatrix.set(int, BooleanValue) is called on m with an index
not contained in allIndices. If allIndices.equals(trueIndices),
m may be a constant matrix; that is, an IllegalArgumentException may be
thrown if BooleanMatrix.set(int, BooleanValue) is called on m with
a non-constant value. Finally, if cloning trueIndices results in an immutable
set, then m.set(int, BooleanValue) may throw
an UnsupportedOperationException when called with a member of trueIndices.allIndices.containsAll(trueIndices)IllegalArgumentException - allIndices !in [0..d.capacity())IllegalArgumentException - one of the input sets is not cloneableNullPointerException - d = null || allIndices = null || trueIndices = nullpublic final int maxFormula()
formula in this.components.
Note that maxFormula() >= maxVariable() since variables themselves are formulas.public final int maxVariable()
variable in this.components.public final BooleanValue not(BooleanValue v)
(components.v).components' = (components.v).components + nNullPointerException - v = nullpublic final int numberOfVariables()
public final BooleanValue or(BooleanValue v0, BooleanValue v1)
v0 + v1 in this.componentsthis.components' = this.components + vNullPointerException - any of the arguments are nullIllegalArgumentException - v0 + v1 !in this.componentspublic final void setComparisonDepth(int newDepth)
this.comparisonDepth' = newDepthIllegalArgumentException - newDepth < 1public final BooleanValue sum(BooleanValue v0, BooleanValue v1, BooleanValue cin)
v0 + v1 + cin in this.componentsthis.components' = this.components + vNullPointerException - any of the arguments are nullpublic final Int sum(Collection<BooleanValue> bits)
public final BooleanVariable variable(int label)
0 < label <= numberOfVariables()public final BooleanValue xor(BooleanValue v0, BooleanValue v1)
v0 + v1 in this.componentsthis.components' = this.components + vNullPointerException - any of the arguments are null
© Emina Torlak 2005-2012