This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.

# BooleanCountingFunction

 BooleanCountingFunctionrepresents a Boolean function of n variables that gives True if at most variables are True. BooleanCountingFunctionrepresents a function of n variables that gives True if exactly k variables are True. BooleanCountingFunctionrepresents a function that gives True if between and variables are True. BooleanCountingFunctionrepresents a function that gives True if exactly variables are True. BooleanCountingFunctiongives the Boolean expression in variables corresponding to the Boolean counting function specified by spec. BooleanCountingFunctiongives the Boolean expression in the form specified by form.
At most two conditions are true:
Convert to a disjunctive normal form:
At most two conditions are true:
 Out[1]=
Convert to a disjunctive normal form:
 Out[2]=
 Scope   (6)
Specify that f is true when at most arguments are true:
Exactly arguments are true:
Between and arguments are true:
, , or arguments are true:
Specify that f is true when exactly , , or arguments are true:
BooleanCountingFunction is by default preserved in function form:
Use BooleanConvert to convert to other forms:
BooleanCountingFunction is automatically converted when given an explicit list of variables:
The expanded forms can be large when the number of variables grows:
The performance gain in evaluating the function form can be substantial:
Constant arguments are reduced:
Extreme cases are automatically converted to formulas:
 Applications   (3)
Create new primitives that are true when at most, at least, or exactly k arguments are true:
Create a number of disk regions along the unit circle:
Show the newly combined regions:
Integrate over these regions:
Define a Boolean function that is true when the number of true arguments is k modulo m:
When k=0 and m=2 you get Xnor:
When k=1 and m=2 you get Xor:
For other values of k and m you get new functionality:
The 2D truth table:
Define a Boolean function that sorts a list of truth values:
The resulting list is always in sorted order:
BooleanCountingFunction is symmetric in its arguments:
Logical combinations of BooleanCountingFunction correspond to set operations on indices:
The basic specification can equivalently be specified using Range:
Many primitives can be expressed in terms of BooleanCountingFunction:
And:
Or:
Nor:
Xor:
The size of the truth set for BooleanCountingFunction is the length of Subsets:
The size of the truth set for BooleanCountingFunction can be given by a combinatorial sum:
BooleanCountingFunction for when exactly i variables are true has disjoint truth sets:
New in 7