
In
mathematics
Mathematics is a field of study that discovers and organizes methods, Mathematical theory, theories and theorems that are developed and Mathematical proof, proved for the needs of empirical sciences and mathematics itself. There are many ar ...
, a Boolean function is a
function whose
arguments
An argument is a series of sentences, statements, or propositions some of which are called premises and one is the conclusion. The purpose of an argument is to give reasons for one's conclusion via justification, explanation, and/or persua ...
and result assume values from a two-element set (usually , or ). Alternative names are switching function, used especially in older
computer science
Computer science is the study of computation, information, and automation. Computer science spans Theoretical computer science, theoretical disciplines (such as algorithms, theory of computation, and information theory) to Applied science, ...
literature, and
truth function
In logic, a truth function is a function that accepts truth values as input and produces a unique truth value as output. In other words: the input and output of a truth function are all truth values; a truth function will always output exactly ...
(or logical function), used in
logic
Logic is the study of correct reasoning. It includes both formal and informal logic. Formal logic is the study of deductively valid inferences or logical truths. It examines how conclusions follow from premises based on the structure o ...
. Boolean functions are the subject of
Boolean algebra
In mathematics and mathematical logic, Boolean algebra is a branch of algebra. It differs from elementary algebra in two ways. First, the values of the variable (mathematics), variables are the truth values ''true'' and ''false'', usually denot ...
and
switching theory.
A Boolean function takes the form
, where
is known as the
Boolean domain
In mathematics and abstract algebra, a Boolean domain is a set consisting of exactly two elements whose interpretations include ''false'' and ''true''. In logic, mathematics and theoretical computer science, a Boolean domain is usually written ...
and
is a non-negative integer called the
arity
In logic, mathematics, and computer science, arity () is the number of arguments or operands taken by a function, operation or relation. In mathematics, arity may also be called rank, but this word can have many other meanings. In logic and ...
of the function. In the case where
, the function is a constant element of
. A Boolean function with multiple outputs,
with
is a vectorial or ''vector-valued'' Boolean function (an
S-box in symmetric
cryptography
Cryptography, or cryptology (from "hidden, secret"; and ''graphein'', "to write", or ''-logy, -logia'', "study", respectively), is the practice and study of techniques for secure communication in the presence of Adversary (cryptography), ...
).
There are
different Boolean functions with
arguments; equal to the number of different
truth table
A truth table is a mathematical table used in logic—specifically in connection with Boolean algebra, Boolean functions, and propositional calculus—which sets out the functional values of logical expressions on each of their functional arg ...
s with
entries.
Every
-ary Boolean function can be expressed as a
propositional formula in
variables
, and two propositional formulas are
logically equivalent if and only if they express the same Boolean function.
Examples

The rudimentary symmetric Boolean functions (
logical connective
In logic, a logical connective (also called a logical operator, sentential connective, or sentential operator) is a logical constant. Connectives can be used to connect logical formulas. For instance in the syntax of propositional logic, the ...
s or
logic gate
A logic gate is a device that performs a Boolean function, a logical operation performed on one or more binary inputs that produces a single binary output. Depending on the context, the term may refer to an ideal logic gate, one that has, for ...
s) are:
*
NOT,
negation
In logic, negation, also called the logical not or logical complement, is an operation (mathematics), operation that takes a Proposition (mathematics), proposition P to another proposition "not P", written \neg P, \mathord P, P^\prime or \over ...
or
complement - which receives one input and returns true when that input is false ("not")
*
AND or
conjunction - true when all inputs are true ("both")
*
OR or
disjunction
In logic, disjunction (also known as logical disjunction, logical or, logical addition, or inclusive disjunction) is a logical connective typically notated as \lor and read aloud as "or". For instance, the English language sentence "it is ...
- true when any input is true ("either")
*
XOR or
exclusive disjunction
Exclusive or, exclusive disjunction, exclusive alternation, logical non-equivalence, or Logical_equality#Inequality, logical inequality is a Logical connective, logical operator whose negation is the logical biconditional. With two inputs, X ...
- true when one of its inputs is true and the other is false ("not equal")
*
NAND or
Sheffer stroke
In Boolean functions and propositional calculus, the Sheffer stroke denotes a logical operation that is equivalent to the negation of the conjunction operation, expressed in ordinary language as "not both". It is also called non-conjunction, ...
- true when it is not the case that all inputs are true ("not both")
*
NOR or
logical nor
In Boolean logic, logical NOR, non-disjunction, or joint denial is a truth-functional operator which produces a result that is the negation of logical or. That is, a sentence of the form (''p'' NOR ''q'') is true precisely when neither ''p' ...
- true when none of the inputs are true ("neither")
*
XNOR or
logical equality - true when both inputs are the same ("equal")
An example of a more complicated function is the
majority function
In Boolean logic, the majority function (also called the median operator) is the Boolean function that evaluates to false when half or more arguments are false and true otherwise, i.e. the value of the function equals the value of the majority of t ...
(of an odd number of inputs).
Representation

A Boolean function may be specified in a variety of ways:
*
Truth table
A truth table is a mathematical table used in logic—specifically in connection with Boolean algebra, Boolean functions, and propositional calculus—which sets out the functional values of logical expressions on each of their functional arg ...
: explicitly listing its value for all possible values of the arguments
**Marquand diagram: truth table values arranged in a two-dimensional grid (used in a
Karnaugh map
A Karnaugh map (KM or K-map) is a diagram that can be used to simplify a Boolean algebra expression. Maurice Karnaugh introduced the technique in 1953 as a refinement of Edward W. Veitch's 1952 Veitch chart, which itself was a rediscovery of ...
)
**
Binary decision diagram, listing the truth table values at the bottom of a binary tree
**
Venn diagram
A Venn diagram is a widely used diagram style that shows the logical relation between set (mathematics), sets, popularized by John Venn (1834–1923) in the 1880s. The diagrams are used to teach elementary set theory, and to illustrate simple ...
, depicting the truth table values as a colouring of regions of the plane
Algebraically, as a
propositional formula using rudimentary Boolean functions:
*
Negation normal form, an arbitrary mix of AND and ORs of the arguments and their complements
*
Disjunctive normal form, as an OR of ANDs of the arguments and their complements
*
Conjunctive normal form, as an AND of ORs of the arguments and their complements
*
Canonical normal form, a standardized formula which uniquely identifies the function:
**
Algebraic normal form or
Zhegalkin polynomial, as a XOR of ANDs of the arguments (no complements allowed)
**''Full'' (canonical)
disjunctive normal form, an OR of ANDs each containing every argument or complement (
minterms
In Boolean algebra, any Boolean function can be expressed in the canonical disjunctive normal form ( CDNF), minterm canonical form, or Sum of Products (SoP or SOP) as a disjunction (OR) of minterms. The De Morgan dual is the canonical conjunc ...
)
**''Full'' (canonical)
conjunctive normal form, an AND of ORs each containing every argument or complement (
maxterms)
**
Blake canonical form, the OR of all the
prime implicants of the function
Boolean formulas can also be displayed as a graph:
*
Propositional directed acyclic graph
**
Digital circuit
In theoretical computer science, a circuit is a model of computation in which input values proceed through a sequence of gates, each of which computes a function. Circuits of this kind provide a generalization of Boolean circuits and a mathematica ...
diagram of
logic gate
A logic gate is a device that performs a Boolean function, a logical operation performed on one or more binary inputs that produces a single binary output. Depending on the context, the term may refer to an ideal logic gate, one that has, for ...
s, a
Boolean circuit
In computational complexity theory and circuit complexity, a Boolean circuit is a mathematical model for combinational digital logic circuits. A formal language can be decided by a family of Boolean circuits, one circuit for each possible inpu ...
**
And-inverter graph, using only AND and NOT
In order to optimize electronic circuits, Boolean formulas can be
minimized using the
Quine–McCluskey algorithm
The Quine–McCluskey algorithm (QMC), also known as the method of prime implicants, is a method used for minimization of Boolean functions that was developed by Willard V. Quine in 1952 and extended by Edward J. McCluskey in 1956. As a gener ...
or
Karnaugh map
A Karnaugh map (KM or K-map) is a diagram that can be used to simplify a Boolean algebra expression. Maurice Karnaugh introduced the technique in 1953 as a refinement of Edward W. Veitch's 1952 Veitch chart, which itself was a rediscovery of ...
.
Analysis
Properties
A Boolean function can have a variety of properties:
*
Constant: Is always true or always false regardless of its arguments.
*
Monotone: for every combination of argument values, changing an argument from false to true can only cause the output to switch from false to true and not from true to false. A function is said to be
unate in a certain variable if it is monotone with respect to changes in that variable.
*
Linear
In mathematics, the term ''linear'' is used in two distinct senses for two different properties:
* linearity of a '' function'' (or '' mapping'');
* linearity of a '' polynomial''.
An example of a linear function is the function defined by f(x) ...
: for each variable, flipping the value of the variable either always makes a difference in the truth value or never makes a difference (a
parity function).
*
Symmetric
Symmetry () in everyday life refers to a sense of harmonious and beautiful proportion and balance. In mathematics, the term has a more precise definition and is usually used to refer to an object that is invariant under some transformations ...
: the value does not depend on the order of its arguments.
*
Read-once: Can be expressed with
conjunction,
disjunction
In logic, disjunction (also known as logical disjunction, logical or, logical addition, or inclusive disjunction) is a logical connective typically notated as \lor and read aloud as "or". For instance, the English language sentence "it is ...
, and
negation
In logic, negation, also called the logical not or logical complement, is an operation (mathematics), operation that takes a Proposition (mathematics), proposition P to another proposition "not P", written \neg P, \mathord P, P^\prime or \over ...
with a single instance of each variable.
*
Balanced: if its
truth table
A truth table is a mathematical table used in logic—specifically in connection with Boolean algebra, Boolean functions, and propositional calculus—which sets out the functional values of logical expressions on each of their functional arg ...
contains an equal number of zeros and ones. The
Hamming weight
The Hamming weight of a string (computer science), string is the number of symbols that are different from the zero-symbol of the alphabet used. It is thus equivalent to the Hamming distance from the all-zero string of the same length. For the mo ...
of the function is the number of ones in the truth table.
*
Bent: its derivatives are all balanced (the autocorrelation spectrum is zero)
*
Correlation immune to ''m''th order: if the output is uncorrelated with all (linear) combinations of at most ''m'' arguments
*
Evasive: if evaluation of the function always requires the value of all arguments
*A Boolean function is a ''Sheffer function'' if it can be used to create (by composition) any arbitrary Boolean function (see
functional completeness
In Mathematical logic, logic, a functionally complete set of logical connectives or Boolean function, Boolean operators is one that can be used to express all possible truth tables by combining members of the Set (mathematics), set into a Boolean ...
)
*The ''algebraic degree'' of a function is the order of the highest order monomial in its
algebraic normal form
Circuit complexity
In theoretical computer science, circuit complexity is a branch of computational complexity theory in which Boolean functions are classified according to the size or depth of the Boolean circuits that compute them. A related notion is the circui ...
attempts to classify Boolean functions with respect to the size or depth of circuits that can compute them.
Derived functions
A Boolean function may be decomposed using
Boole's expansion theorem in positive and negative ''Shannon'' ''cofactors'' (
Shannon expansion), which are the (''k''−1)-ary functions resulting from fixing one of the arguments (to 0 or 1). The general ''k''-ary functions obtained by imposing a linear constraint on a set of inputs (a linear subspace) are known as ''subfunctions''.
The ''
Boolean derivative'' of the function to one of the arguments is a (''k''−1)-ary function that is true when the output of the function is sensitive to the chosen input variable; it is the XOR of the two corresponding cofactors. A derivative and a cofactor are used in a
Reed–Muller expansion. The concept can be generalized as a ''k''-ary derivative in the direction dx, obtained as the difference (XOR) of the function at x and x + dx.
The ''
Möbius transform'' (or ''Boole–Möbius transform'') of a Boolean function is the set of coefficients of its
polynomial
In mathematics, a polynomial is a Expression (mathematics), mathematical expression consisting of indeterminate (variable), indeterminates (also called variable (mathematics), variables) and coefficients, that involves only the operations of addit ...
(
algebraic normal form), as a function of the monomial exponent vectors. It is a
self-inverse transform. It can be calculated efficiently using a
butterfly algorithm ("''Fast Möbius Transform''"), analogous to the
fast Fourier transform
A fast Fourier transform (FFT) is an algorithm that computes the discrete Fourier transform (DFT) of a sequence, or its inverse (IDFT). A Fourier transform converts a signal from its original domain (often time or space) to a representation in ...
. ''Coincident'' Boolean functions are equal to their Möbius transform, i.e. their truth table (minterm) values equal their algebraic (monomial) coefficients. There are 2^2^(''k''−1) coincident functions of ''k'' arguments.
Cryptographic analysis
The ''
Walsh transform'' of a Boolean function is a k-ary integer-valued function giving the coefficients of a decomposition into
linear functions (
Walsh functions), analogous to the decomposition of real-valued functions into
harmonic
In physics, acoustics, and telecommunications, a harmonic is a sinusoidal wave with a frequency that is a positive integer multiple of the ''fundamental frequency'' of a periodic signal. The fundamental frequency is also called the ''1st har ...
s by the
Fourier transform
In mathematics, the Fourier transform (FT) is an integral transform that takes a function as input then outputs another function that describes the extent to which various frequencies are present in the original function. The output of the tr ...
. Its square is the ''power spectrum'' or ''Walsh spectrum''. The Walsh coefficient of a single bit vector is a measure for the correlation of that bit with the output of the Boolean function. The maximum (in absolute value) Walsh coefficient is known as the ''linearity'' of the function.
The highest number of bits (order) for which all Walsh coefficients are 0 (i.e. the subfunctions are balanced) is known as ''resiliency'', and the function is said to be
correlation immune to that order.
The Walsh coefficients play a key role in
linear cryptanalysis
In cryptography, linear cryptanalysis is a general form of cryptanalysis based on finding affine
Affine may describe any of various topics concerned with connections or affinities.
It may refer to:
* Affine, a Affinity_(law)#Terminology, relat ...
.
The ''
autocorrelation
Autocorrelation, sometimes known as serial correlation in the discrete time case, measures the correlation of a signal with a delayed copy of itself. Essentially, it quantifies the similarity between observations of a random variable at differe ...
'' of a Boolean function is a k-ary integer-valued function giving the correlation between a certain set of changes in the inputs and the function output. For a given bit vector it is related to the Hamming weight of the derivative in that direction. The maximal autocorrelation coefficient (in absolute value) is known as the ''absolute indicator''.
If all autocorrelation coefficients are 0 (i.e. the derivatives are balanced) for a certain number of bits then the function is said to satisfy the ''propagation criterion'' to that order; if they are all zero then the function is a
bent function. The autocorrelation coefficients play a key role in
differential cryptanalysis
Differential cryptanalysis is a general form of cryptanalysis applicable primarily to block ciphers, but also to stream ciphers and cryptographic hash functions. In the broadest sense, it is the study of how differences in information input can a ...
.
The Walsh coefficients of a Boolean function and its autocorrelation coefficients are related by the equivalent of the
Wiener–Khinchin theorem, which states that the autocorrelation and the power spectrum are a Walsh transform pair.
Linear approximation table
These concepts can be extended naturally to ''vectorial'' Boolean functions by considering their output bits (''coordinates'') individually, or more thoroughly, by looking at the set of all linear functions of output bits, known as its ''components''.
The set of Walsh transforms of the components is known as a linear approximation table (LAT)
or ''correlation matrix''; it describes the correlation between different linear combinations of input and output bits. The set of autocorrelation coefficients of the components is the ''autocorrelation table'',
related by a Walsh transform of the components
to the more widely used ''difference distribution table'' (DDT)
which lists the correlations between differences in input and output bits (see also:
S-box).
Real polynomial form
On the unit hypercube
Any Boolean function
can be uniquely extended (interpolated) to the
real domain by a
multilinear polynomial in
, constructed by summing the truth table values multiplied by
indicator polynomials:
For example, the extension of the binary XOR function
is
which equals
Some other examples are negation (
), AND (
) and OR (
). When all operands are independent (share no variables) a function's polynomial form can be found by repeatedly applying the polynomials of the operators in a Boolean formula. When the coefficients are calculated
modulo 2 one obtains the
algebraic normal form (
Zhegalkin polynomial).
Direct expressions for the coefficients of the polynomial can be derived by taking an appropriate derivative:
this generalizes as the
Möbius inversion of the
partially ordered set
In mathematics, especially order theory, a partial order on a Set (mathematics), set is an arrangement such that, for certain pairs of elements, one precedes the other. The word ''partial'' is used to indicate that not every pair of elements need ...
of bit vectors:
where
denotes the weight of the bit vector
. Taken modulo 2, this is the
Boolean ''Möbius transform'', giving the
algebraic normal form coefficients:
In both cases, the sum is taken over all bit-vectors ''a'' covered by ''m'', i.e. the "one" bits of ''a'' form a subset of the one bits of ''m''.
When the domain is restricted to the n-dimensional
hypercube
In geometry, a hypercube is an ''n''-dimensional analogue of a square ( ) and a cube ( ); the special case for is known as a ''tesseract''. It is a closed, compact, convex figure whose 1- skeleton consists of groups of opposite parallel l ...
, the polynomial