BooleanCountingFunction[kmax,n]
represents a Boolean function ofn variables that givesTrue if at mostkmax variables areTrue.
BooleanCountingFunction[{k},n]
represents a function ofn variables that givesTrue if exactlyk variables areTrue.
BooleanCountingFunction[{kmin,kmax},n]
represents a function that givesTrue if betweenkmin andkmax variables areTrue.
BooleanCountingFunction[{{k1,k2,…}},n]
represents a function that givesTrue if exactlyki variables areTrue.
BooleanCountingFunction[spec,{a1,a2,…}]
gives the Boolean expression in variablesai corresponding to the Boolean counting function specified byspec.
BooleanCountingFunction[spec,{a1,a2,…},form]
gives the Boolean expression in the form specified byform.


BooleanCountingFunction
BooleanCountingFunction[kmax,n]
represents a Boolean function ofn variables that givesTrue if at mostkmax variables areTrue.
BooleanCountingFunction[{k},n]
represents a function ofn variables that givesTrue if exactlyk variables areTrue.
BooleanCountingFunction[{kmin,kmax},n]
represents a function that givesTrue if betweenkmin andkmax variables areTrue.
BooleanCountingFunction[{{k1,k2,…}},n]
represents a function that givesTrue if exactlyki variables areTrue.
BooleanCountingFunction[spec,{a1,a2,…}]
gives the Boolean expression in variablesai corresponding to the Boolean counting function specified byspec.
BooleanCountingFunction[spec,{a1,a2,…},form]
gives the Boolean expression in the form specified byform.
Details

- BooleanCountingFunction[spec] gives a Boolean function object that works likeFunction.
- BooleanCountingFunction[spec][a1,a2,…] gives an implicit representation equivalent to the explicit Boolean expressionBooleanCountingFunction[spec,{a1,a2,…}].
- BooleanConvert convertsBooleanCountingFunction[spec][vars] to an explicit Boolean expression.
- BooleanCountingFunction[{kmin,kmax,s},…] represents a function that givesTrue ifkmin,kmin+s,…,kmax variables areTrue.
- Any symmetric Boolean function can be represented uniquely usingBooleanCountingFunction.
- InBooleanCountingFunction[spec,{a1,a2,…},form], the possible forms are as given forBooleanConvert.
- BooleanCountingFunction[spec,{a1,a2,…}] by default gives an expression in disjunctive normal form (DNF).
Examples
open allclose allScope (6)
Specify thatf is true when at most2 arguments are true:
Between2 and3 arguments are true:
Specify thatf is true when exactly1,4, or5 arguments are true:
BooleanCountingFunction is by default preserved in function form:
UseBooleanConvert 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 exactlyk 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 isk modulom:
Whenk=0 andm=2, you getXnor:
Whenk=1 andm=2, you getXor:
For other values ofk andm, 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 ofBooleanCountingFunction correspond to set operations on indices:
The basic specification can equivalently be specified usingRange:
Many primitives can be expressed in terms ofBooleanCountingFunction:
And:
Or:
Nand:
Nor:
Xor:
Xnor:
The size of the truth set forBooleanCountingFunction is the length ofSubsets:
The size of the truth set forBooleanCountingFunction can be given by a combinatorial sum:
Neat Examples (1)
BooleanCountingFunction for when exactlyi variables are true has disjoint truth sets:
Related Guides
History
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
BibTeX
@misc{reference.wolfram_2025_booleancountingfunction, author="Wolfram Research", title="{BooleanCountingFunction}", year="2008", howpublished="\url{https://reference.wolfram.com/language/ref/BooleanCountingFunction.html}", note=[Accessed: 29-November-2025]}
BibLaTeX
@online{reference.wolfram_2025_booleancountingfunction, organization={Wolfram Research}, title={BooleanCountingFunction}, year={2008}, url={https://reference.wolfram.com/language/ref/BooleanCountingFunction.html}, note=[Accessed: 29-November-2025]}
[8]ページ先頭