BooleanCountingFunction—Wolfram Documentation

BooleanCountingFunction[spec,{a1,a2,}]

gives the Boolean expression in variables ai corresponding to the Boolean counting function specified by spec.

Details

Examples

open all close all

Basic Examples  (1)

At most two conditions are true:

Convert to a disjunctive normal form:

Scope  (6)

Specify that f is true when at most 2 arguments are true:

Exactly 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:

Constant arguments are reduced:

Extreme cases are automatically converted to formulas:

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:

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:

Find the mean time to failure for a system that needs two out of three components to work:

Properties & Relations  (6)

Neat Examples  (1)

Wolfram Research (2008), BooleanCountingFunction, Wolfram Language function, https://reference.wolfram.com/language/ref/BooleanCountingFunction.html.

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: 22-February-2026]}

BibLaTeX

@online{reference.wolfram_2025_booleancountingfunction, organization={Wolfram Research}, title={BooleanCountingFunction}, year={2008}, url={https://reference.wolfram.com/language/ref/BooleanCountingFunction.html}, note=[Accessed: 22-February-2026]}