BooleanFunction

BooleanFunction[k,n]

represents the k^(th) Boolean function in n variables.

BooleanFunction[values]

represents the Boolean function corresponding to the specified vector of truth values.

BooleanFunction[{{i11,i12,}o1,}]

represents the Boolean function defined by the specified mapping from inputs to outputs.

BooleanFunction[spec,{a1,a2,}]

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

BooleanFunction[spec,{a1,a2,},form]

gives the Boolean expression in the form specified by form.

Details

Examples

open allclose all

Basic Examples  (3)

Generate the 30^(th) Boolean function of 3 variables:

Use f like any other Boolean operator:

Convert to a DNF expression:

Generate the formula directly:

Specify a Boolean function based on a table of truth rules:

Use an incompletely specified truth table:

Convert a Boolean expression to a BooleanFunction:

Test that they represent the same function:

Scope  (14)

Basic Uses  (3)

Create a BooleanFunction with two arguments by indexing:

Compute its value for particular arguments:

The function remains unevaluated for symbolic arguments:

BooleanFunction can be used just like any other Boolean operator:

Any Boolean expression can be converted to a BooleanFunction expression:

Including combinations of BooleanFunction expressions:

A BooleanFunction expression that is equivalent to True or False automatically simplifies:

BooleanFunction is a canonical representation, and equivalence can be tested using SameQ:

Working with Truth Tables  (7)

Create a truth table in standard order:

Create an equivalent BooleanFunction expression:

Show that they are equivalent:

Alternatively, show that the resulting truth tables are the same:

Create a complete list of truth rules:

Create the corresponding BooleanFunction expression:

The ordering of truth rules for complete lists has no effect:

Use _ to indicate "don't cares" in a truth table:

Create a BooleanFunction:

The resulting truth table matches the original specification:

Use _ and __ to indicate "don't cares" in truth rules:

Create a BooleanFunction:

The original rules completely specify the function and the resulting truth tables are identical:

Use lists of lists to indicate a vector-valued truth table:

Create a BooleanFunction:

The resulting output matches the original specification:

Use vector-valued truth rules:

Create a BooleanFunction:

The resulting truth rules match the original specification:

Truth tables can also be given using 0 in place of False and 1 in place of True:

The resulting truth tables are identical:

Working with Other Representations  (4)

Convert any Boolean expression to a BooleanFunction expression:

Show that they are equivalent:

Convert expressions involving any Boolean operators:

Show that they are equivalent:

Convert a BooleanFunction expression to other standard forms:

A number of different standard forms:

As well as a truth table:

Or truth rules:

Specify BooleanFunction using CellularAutomaton:

Applications  (4)

Enumerating Boolean Functions  (2)

Enumerate all 2-variable Boolean functions:

All 3-variable Boolean functions:

Randomly sample 50 functions of 4 variables:

Compare the sizes of Boolean functions in their standard and minimized forms:

Three variables:

Four variables, the first 1000 functions:

Creating New Primitives  (1)

Create new Boolean primitives corresponding to , , <, and >:

These are closely related:

Implies is equivalent to x<=y:

Define a relation for Boolean functions fg iff f[u]g[u]:

Here you have xxy as reflected in the truth tables:

Using standard inequalities:

For all Boolean functions f and g, fgffg:

This proves that fg iff fgf:

And similarly fg iff fgg:

Or that fg and gh implies fh:

Cellular Automata  (1)

Generate the rule 30 elementary cellular automaton rule:

Simulate it:

Compare to the standard encoding:

Properties & Relations  (7)

BooleanFunction displays in an elided form indicating the number of arguments:

It is an atomic object:

The InputForm gives an encoding that can be used to reconstruct the object:

Use the encoding to construct a BooleanFunction:

The result is identical to the original:

The order of values for BooleanFunction is the same as BooleanTable:

The corresponding BooleanFunction has an identical truth table:

The ordering is consistent with Tuples:

Indexing of BooleanFunction is consistent with IntegerDigits:

Convert from a BooleanFunction to its index:

Convert from any Boolean expression to its index:

Show that it is equivalent with the indexed BooleanFunction expression:

The indexing of Boolean functions agrees with the indexing of cellular automata:

More generally, for CellularAutomaton[{k,2,r}] with integer and , the relation reads:

CellularAutomaton satisfying the preceding properties can be used to specify BooleanFunction:

BooleanMinterms can also represent any BooleanFunction:

The mapping from minterms to index:

The mapping from index to minterms:

Using bit vectors:

Use BooleanConvert to convert to BooleanFunction from other forms:

Also use BooleanConvert to convert from BooleanFunction to other forms:

Show that they are all equivalent:

Use BooleanTable to convert BooleanFunction to truth tables:

Or convert to truth rules:

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

Text

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

CMS

Wolfram Language. 2008. "BooleanFunction." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/BooleanFunction.html.

APA

Wolfram Language. (2008). BooleanFunction. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/BooleanFunction.html

BibTeX

@misc{reference.wolfram_2024_booleanfunction, author="Wolfram Research", title="{BooleanFunction}", year="2008", howpublished="\url{https://reference.wolfram.com/language/ref/BooleanFunction.html}", note=[Accessed: 22-December-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_booleanfunction, organization={Wolfram Research}, title={BooleanFunction}, year={2008}, url={https://reference.wolfram.com/language/ref/BooleanFunction.html}, note=[Accessed: 22-December-2024 ]}