BooleanCountingFunction
BooleanCountingFunction[kmax,n]
represents a Boolean function of n variables that gives True if at most kmax variables are True.
BooleanCountingFunction[{k},n]
represents a function of n variables that gives True if exactly k variables are True.
BooleanCountingFunction[{kmin,kmax},n]
represents a function that gives True if between kmin and kmax variables are True.
BooleanCountingFunction[{{k1,k2,…}},n]
represents a function that gives True if exactly ki variables are True.
BooleanCountingFunction[spec,{a1,a2,…}]
gives the Boolean expression in variables ai corresponding to the Boolean counting function specified by spec.
BooleanCountingFunction[spec,{a1,a2,…},form]
gives the Boolean expression in the form specified by form.
Details
- BooleanCountingFunction[spec] gives a Boolean function object that works like Function.
- BooleanCountingFunction[spec][a1,a2,…] gives an implicit representation equivalent to the explicit Boolean expression BooleanCountingFunction[spec,{a1,a2,…}].
- BooleanConvert converts BooleanCountingFunction[spec][vars] to an explicit Boolean expression.
- BooleanCountingFunction[{kmin,kmax,s},…] represents a function that gives True if kmin, kmin+s, …, kmax variables are True.
- Any symmetric Boolean function can be represented uniquely using BooleanCountingFunction.
- In BooleanCountingFunction[spec,{a1,a2,…},form], the possible forms are as given for BooleanConvert.
- BooleanCountingFunction[spec,{a1,a2,…}] by default gives an expression in disjunctive normal form (DNF).
Examples
open allclose allScope (6)
Specify that f is true when at most 2 arguments are true:
Between 2 and 3 arguments are true:
1, 3, or 5 arguments are true:
Specify that f is true when exactly 1, 4, or 5 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:
Applications (4)
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:
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:
Define a Boolean function that sorts a list of truth values:
The resulting list is always in sorted order:
Find the mean time to failure for a system that needs two out of three components to work:
Properties & Relations (6)
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:
Nand:
Nor:
Xor:
Xnor:
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:
Neat Examples (1)
BooleanCountingFunction for when exactly i variables are true has disjoint truth sets:
Text
Wolfram Research (2008), BooleanCountingFunction, Wolfram Language function, https://reference.wolfram.com/language/ref/BooleanCountingFunction.html.
CMS
Wolfram Language. 2008. "BooleanCountingFunction." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/BooleanCountingFunction.html.
APA
Wolfram Language. (2008). BooleanCountingFunction. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/BooleanCountingFunction.html