BooleanFunction¶
BooleanFunction[k, n] is the k-th Boolean function of n variables. The
index is read as a truth table: bit v of k is the value for the assignment
v, written as a binary number with the first variable most significant and
True as 1. Index 7 of two variables is therefore Nand, index 1 is Nor and
index 6 is Xor.
The bare form is an opaque object carrying the function's reduced ordered binary decision diagram:
The leading ±n is the variable count, negative when the root edge is
complemented, and each following triple is a node {var, then, else} in the
order a then-branch-first walk from the root first reaches them. A branch
refers to the |v|-th such node, negated when v is negative, except that
±1 is the True/False terminal. A constant function is just the signed count:
Applied to Boolean arguments it answers directly, and integer 1/0 count as
True/False:
Some arguments literal and some symbolic restricts the function to the rest —
Nand[a, True] is Not[a], the one-variable function of index 1:
Symbolic arguments alone leave the application as it stands; BooleanConvert
writes it out:
Given a list of variables instead of a count, BooleanFunction writes the
expression out directly, in minimal sum-of-products form:
The index is taken two's-complement, so index -1 is the constant True: