This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)

BooleanFunction

BooleanFunction
represents the k^(th) Boolean function in n variables.
BooleanFunction[values]
represents the Boolean function corresponding to the specified vector of truth values.
BooleanFunction
represents the Boolean function defined by the specified mapping from inputs to outputs.
BooleanFunction
gives the Boolean expression in variables corresponding to the Boolean function specified by spec.
BooleanFunction
gives the Boolean expression in the form specified by form.
  • In BooleanFunction[values], the values are specified in binary order starting with , ....
  • In BooleanFunction[values], each value can be a list, representing a vector-valued Boolean function.
  • In BooleanFunction the can be lists, representing vector-valued Boolean functions.
  • Elements of both inputs and outputs can be specified either as True and False or as and .
  • Elements of inputs and outputs can also include any number of , representing "don't cares".
  • They can also include up to one , representing a sequence of "don't cares".
  • BooleanFunction[k] gives the k^(th) Boolean function in n variables, where n has the smallest value for which .
  • BooleanFunction objects can be applied to variables just like other Boolean functions such as And, Or, etc.
  • In StandardForm and related formats, BooleanFunction objects are printed in elided form, with only their number of variables displayed.
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:
Generate the 30^(th) Boolean function of 3 variables:
In[1]:=
Click for copyable input
Out[1]=
Use f like any other Boolean operator:
In[2]:=
Click for copyable input
Out[2]=
Convert to a DNF expression:
In[3]:=
Click for copyable input
Out[3]=
Generate the formula directly:
In[4]:=
Click for copyable input
Out[4]=
 
Specify a Boolean function based on a table of truth rules:
In[1]:=
Click for copyable input
Out[1]=
Use an incompletely specified truth table:
In[2]:=
Click for copyable input
Out[2]=
 
Convert a Boolean expression to a BooleanFunction:
In[1]:=
Click for copyable input
Out[1]=
Test that they represent the same function:
In[2]:=
Click for copyable input
Out[2]=
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:
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 in place of False and in place of True:
The resulting truth tables are identical:
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:
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 functions:
Create new Boolean primitives corresponding to , , , and :
These are closely related:
Implies is equivalent to :
Define a relation for Boolean functions iff :
Here you have as reflected in the truth tables:
Using standard inequalities:
For all Boolean functions f and g, :
This proves that iff :
And similarly iff :
Or that and implies :
Generate the rule 30 elementary cellular automaton rule:
Simulate it:
Compare to the standard encoding:
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:
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:
New in 7