# Analysis of Boolean functions

In mathematics and theoretical computer science, analysis of Boolean functions is the study of real-valued functions on $\{0,1\}^{n}$ or $\{-1,1\}^{n}$ (such functions are sometimes known as pseudo-Boolean functions) from a spectral perspective. The functions studied are often, but not always, Boolean-valued, making them Boolean functions. The area has found many applications in combinatorics, social choice theory, random graphs, and theoretical computer science, especially in hardness of approximation, property testing, and PAC learning.

## Basic concepts

We will mostly consider functions defined on the domain $\{-1,1\}^{n}$. Sometimes it is more convenient to work with the domain $\{0,1\}^{n}$ instead. If $f$ is defined on $\{-1,1\}^{n}$, then the corresponding function defined on $\{0,1\}^{n}$ is
    $f_{01}(x_{1},\ldots ,x_{n})=f((-1)^{x_{1}},\ldots ,(-1)^{x_{n}}).$
Similarly, for us a Boolean function is a $\{-1,1\}$-valued function, though often it is more convenient to consider $\{0,1\}$-valued functions instead.

### Fourier expansion

Every real-valued function $f\colon \{-1,1\}^{n}\to \mathbb {R}$ has a unique expansion as a multilinear polynomial:
    $f(x)=\sum _{S\subseteq [n]}{\hat {f}}(S)\chi _{S}(x),\quad \chi _{S}(x)=\prod _{i\in S}x_{i}.$
(Note that even if the function is 0-1 valued this is not a sum mod 2, but just an ordinary sum of real numbers.)
This is the Hadamard transform of the function $f$, which is the Fourier transform in the group $\mathbb {Z} _{2}^{n}$. The coefficients ${\hat {f}}(S)$ are known as Fourier coefficients, and the entire sum is known as the Fourier expansion of $f$. The functions $\chi _{S}$ are known as Fourier characters, and they form an orthonormal basis for the space of all functions over $\{-1,1\}^{n}$, with respect to the inner product $\langle f,g\rangle =2^{-n}\sum _{x\in \{-1,1\}^{n}}f(x)g(x)$.
The Fourier coefficients can be calculated using an inner product:
    ${\hat {f}}(S)=\langle f,\chi _{S}\rangle .$
In particular, this shows that ${\hat {f}}(\emptyset )=\operatorname {E} [f]$, where the expected value is taken with respect to the uniform distribution over $\{-1,1\}^{n}$. Parseval's identity states that
    $\|f\|^{2}=\operatorname {E} [f^{2}]=\sum _{S}{\hat {f}}(S)^{2}.$
If we skip $S=\emptyset$, then we get the variance of $f$:
    $\operatorname {Var} [f]=\sum _{S\neq \emptyset }{\hat {f}}(S)^{2}.$

### Fourier degree and Fourier levels

The degree of a function $f\colon \{-1,1\}^{n}\to \mathbb {R}$ is the maximum $d$ such that ${\hat {f}}(S)\neq 0$ for some set $S$ of size $d$. In other words, the degree of $f$ is its degree as a multilinear polynomial.
It is convenient to decompose the Fourier expansion into levels: the Fourier coefficient ${\hat {f}}(S)$ is on level $|S|$.
The degree $d$ part of $f$ is
    $f^{=d}=\sum _{|S|=d}{\hat {f}}(S)\chi _{S}.$
It is obtained from $f$ by zeroing out all Fourier coefficients not on level $d$.
We similarly define $f^{>d},f^{<d},f^{\geq d},f^{\leq d}$.

### Influence

The $i$'th influence of a function $f\colon \{-1,1\}^{n}\to \mathbb {R}$ can be defined in two equivalent ways:
    ${\begin{aligned}&\operatorname {Inf} _{i}[f]=\operatorname {E} \left[\left({\frac {f-f^{\oplus i}}{2}}\right)^{2}\right]=\sum _{S\ni i}{\hat {f}}(S)^{2},\\[5pt]&f^{\oplus i}(x_{1},\ldots ,x_{n})=f(x_{1},\ldots ,x_{i-1},-x_{i},x_{i+1},\ldots ,x_{n}).\end{aligned}}$
If $f$ is Boolean then $\operatorname {Inf} _{i}[f]$ is the probability that flipping the $i$'th coordinate flips the value of the function:
    $\operatorname {Inf} _{i}[f]=\Pr[f(x)\neq f^{\oplus i}(x)].$
If $\operatorname {Inf} _{i}[f]=0$ then $f$ doesn't depend on the $i$'th coordinate.
The total influence of $f$ is the sum of all of its influences:
    $\operatorname {Inf} [f]=\sum _{i=1}^{n}\operatorname {Inf} _{i}[f]=\sum _{S}|S|{\hat {f}}(S)^{2}.$
The total influence of a Boolean function is also the average sensitivity of the function. The sensitivity of a Boolean function $f$ at a given point is the number of coordinates $i$ such that if we flip the $i$'th coordinate, the value of the function changes. The average value of this quantity is exactly the total influence.
The total influence can also be defined using the discrete Laplacian of the Hamming graph, suitably normalized: $\operatorname {Inf} [f]=\langle f,Lf\rangle$.
A generalized form of influence is the $\rho$-stable influence, defined by:
    $\operatorname {Inf} _{i}^{\,(\rho )}[f]=\operatorname {Stab} _{\rho }[\operatorname {D} _{i}f]=\sum _{S\ni i}\rho ^{|S|-1}{\hat {f}}(S)^{2}.$
The corresponding total influences is
    $\operatorname {I} ^{(\rho )}[f]={\frac {d}{d\rho }}\operatorname {Stab} _{\rho }[f]=\sum _{S}|S|\rho ^{|S|-1}{\hat {f}}(S)^{2}.$
One can prove that a function $f:\{-1,1\}^{n}\to \{-1,1\}$ has at most “constantly” many “stably-influential” coordinates: $|\{i\in [n]:\operatorname {Inf} _{i}^{\,(1-\delta )}[f]\geq \epsilon \}|\leq {\frac {1}{\delta \epsilon }}.$

### Noise stability

Given $-1\leq \rho \leq 1$, we say that two random vectors $x,y\in \{-1,1\}^{n}$ are $\rho$-correlated if the marginal distributions of $x,y$ are uniform, and $\operatorname {E} [x_{i}y_{i}]=\rho$. Concretely, we can generate a pair of $\rho$-correlated random variables by first choosing $x,z\in \{-1,1\}^{n}$ uniformly at random, and then choosing $y$ according to one of the following two equivalent rules, applied independently to each coordinate:
    $y_{i}={\begin{cases}x_{i}&{\text{w.p. }}\rho ,\\z_{i}&{\text{w.p. }}1-\rho .\end{cases}}\quad {\text{or}}\quad y_{i}={\begin{cases}x_{i}&{\text{w.p. }}{\frac {1+\rho }{2}},\\-x_{i}&{\text{w.p. }}{\frac {1-\rho }{2}}.\end{cases}}$
We denote this distribution by $y\sim N_{\rho }(x)$.
The noise stability of a function $f\colon \{-1,1\}^{n}\to \mathbb {R}$ at $\rho$ can be defined in two equivalent ways:
    $\operatorname {Stab} _{\rho }[f]=\operatorname {E} _{x;y\sim N_{\rho }(x)}[f(x)f(y)]=\sum _{S\subseteq [n]}\rho ^{|S|}{\hat {f}}(S)^{2}.$
For $0\leq \delta \leq 1$, the noise sensitivity of $f$ at $\delta$ is
    $\operatorname {NS} _{\delta }[f]={\frac {1}{2}}-{\frac {1}{2}}\operatorname {Stab} _{1-2\delta }[f].$
If $f$ is Boolean, then this is the probability that the value of $f$ changes if we flip each coordinate with probability $\delta$, independently.

### Noise operator

The noise operator $T_{\rho }$ is an operator taking a function $f\colon \{-1,1\}^{n}\to \mathbb {R}$ and returning another function $T_{\rho }f\colon \{-1,1\}^{n}\to \mathbb {R}$ given by
    $(T_{\rho }f)(x)=\operatorname {E} _{y\sim N_{\rho }(x)}[f(y)]=\sum _{S\subseteq [n]}\rho ^{|S|}{\hat {f}}(S)\chi _{S}.$
When $\rho >0$, the noise operator can also be defined using a continuous-time Markov chain in which each bit is flipped independently with rate 1. The operator $T_{\rho }$ corresponds to running this Markov chain for ${\frac {1}{2}}\log {\frac {1}{\rho }}$ steps starting at $x$, and taking the average value of $f$ at the final state. This Markov chain is generated by the Laplacian of the Hamming graph, and this relates total influence to the noise operator.
Noise stability can be defined in terms of the noise operator: $\operatorname {Stab} _{\rho }[f]=\langle f,T_{\rho }f\rangle$.

### Hypercontractivity

For $1\leq q<\infty$, the $L_{q}$-norm of a function $f\colon \{-1,1\}^{n}\to \mathbb {R}$ is defined by
    $\|f\|_{q}={\sqrt[{q}]{\operatorname {E} [|f|^{q}]}}.$
We also define $\|f\|_{\infty }=\max _{x\in \{-1,1\}^{n}}|f(x)|.$
The hypercontractivity theorem states that for all $p>q>1$, if $|\rho |\leq {\sqrt {\frac {q-1}{p-1}}}$ then
    $\|T_{\rho }f\|_{p}\leq \|f\|_{q}.$
Hypercontractivity is closely related to the logarithmic Sobolev inequalities of functional analysis.
A similar result for $1>p>q$ is known as reverse hypercontractivity. It states that if $|\rho |\leq {\sqrt {\frac {1-p}{1-q}}}$ then
    $\|T_{\rho }f\|_{q}\geq \|f\|_{p}.$

### p-Biased analysis

In many situations the input to the function is not uniformly distributed over $\{-1,1\}^{n}$, but instead has a bias toward $-1$ or $1$. In these situations it is customary to consider functions over the domain $\{0,1\}^{n}$. For $0<p<1$, the p-biased measure $\mu _{p}$ is given by
    $\mu _{p}(x)=p^{\sum _{i}x_{i}}(1-p)^{\sum _{i}(1-x_{i})}.$
This measure can be generated by choosing each coordinate independently to be 1 with probability $p$ and 0 with probability $1-p$.
The classical Fourier characters are no longer orthogonal with respect to this measure. Instead, we use the following characters:
    $\omega _{S}(x)=\left({\sqrt {\frac {p}{1-p}}}\right)^{|\{i\in S:x_{i}=0\}|}\left(-{\sqrt {\frac {1-p}{p}}}\right)^{|\{i\in S:x_{i}=1\}|}.$
The p-biased Fourier expansion of $f$ is the expansion of $f$ as a linear combination of p-biased characters:
    $f=\sum _{S\subseteq [n]}{\hat {f}}(S)\omega _{S}.$
We can extend the definitions of influence and the noise operator to the p-biased setting by using their spectral definitions.

#### Influence

The $i$'s influence is given by
    $\operatorname {Inf} _{i}[f]=\sum _{S\ni i}{\hat {f}}(S)^{2}=p(1-p)\operatorname {E} [(f-f^{\oplus i})^{2}].$
The total influence is the sum of the individual influences:
    $\operatorname {Inf} [f]=\sum _{i=1}^{n}\operatorname {Inf} _{i}[f]=\sum _{S}|S|{\hat {f}}(S)^{2}.$

#### Noise operator

A pair of $\rho$-correlated random variables can be obtained by choosing $x,z\sim \mu _{p}$ independently and $y\sim N_{\rho }(x)$, where $N_{\rho }$ is given by
    $y_{i}={\begin{cases}x_{i}&{\text{w.p. }}\rho ,\\z_{i}&{\text{w.p. }}1-\rho .\end{cases}}$
The noise operator is then given by
    $(T_{\rho }f)(x)=\sum _{S\subseteq [n]}\rho ^{|S|}{\hat {f}}(S)\omega _{S}(x)=\operatorname {E} _{y\sim N_{\rho }(x)}[f(y)].$
Using this we can define the noise stability and the noise sensitivity, as before.

#### Russo–Margulis formula

The Russo–Margulis formula (also called the Margulis–Russo formula) states that for monotone Boolean functions $f\colon \{0,1\}^{n}\to \{0,1\}$,
    ${\frac {d}{dp}}\operatorname {E} _{x\sim \mu _{p}}[f(x)]={\frac {\operatorname {Inf} [f]}{p(1-p)}}=\sum _{i=1}^{n}\Pr[f\neq f^{\oplus i}].$
Both the influence and the probabilities are taken with respect to $\mu _{p}$, and on the right-hand side we have the average sensitivity of $f$. If we think of $f$ as a property, then the formula states that as $p$ varies, the derivative of the probability that $f$ occurs at $p$ equals the average sensitivity at $p$.
The Russo–Margulis formula is key for proving sharp threshold theorems such as Friedgut's.

### Gaussian space

One of the deepest results in the area, the invariance principle, connects the distribution of functions on the Boolean cube $\{-1,1\}^{n}$ to their distribution on Gaussian space, which is the space $\mathbb {R} ^{n}$ endowed with the standard $n$-dimensional Gaussian measure.
Many of the basic concepts of Fourier analysis on the Boolean cube have counterparts in Gaussian space:
* The counterpart of the Fourier expansion in Gaussian space is the Hermite expansion, which is an expansion to an infinite sum (converging in $L^{2}$) of multivariate Hermite polynomials.
* The counterpart of total influence or average sensitivity for the indicator function of a set is Gaussian surface area, which is the Minkowski content of the boundary of the set.
* The counterpart of the noise operator is the Ornstein–Uhlenbeck operator (related to the Mehler transform), given by $(U_{\rho }f)(x)=\operatorname {E} _{z\sim N(0,1)}[f(\rho x+{\sqrt {1-\rho ^{2}}}z)]$, or alternatively by $(U_{\rho }f)(x)=\operatorname {E} [f(y)]$, where $x,y$ is a pair of $\rho$-correlated standard Gaussians.
* Hypercontractivity holds (with appropriate parameters) in Gaussian space as well.
Gaussian space is more symmetric than the Boolean cube (for example, it is rotation invariant), and supports continuous arguments which may be harder to get through in the discrete setting of the Boolean cube. The invariance principle links the two settings, and allows deducing results on the Boolean cube from results on Gaussian space.

## Basic results
### Friedgut–Kalai–Naor theorem

If $f\colon \{-1,1\}^{n}\to \{-1,1\}$ has degree at most 1, then $f$ is either constant, equal to a coordinate, or equal to the negation of a coordinate. In particular, $f$ is a dictatorship: a function depending on at most one coordinate.
The Friedgut–Kalai–Naor theorem, also known as the FKN theorem, states that if $f$ almost has degree 1 then it is close to a dictatorship. Quantitatively, if $f\colon \{-1,1\}^{n}\to \{-1,1\}$ and $\|f^{>1}\|^{2}<\varepsilon$, then $f$ is $O(\varepsilon )$-close to a dictatorship, that is, $\|f-g\|^{2}=O(\varepsilon )$ for some Boolean dictatorship $g$, or equivalently, $\Pr[f\neq g]=O(\varepsilon )$ for some Boolean dictatorship $g$.
Similarly, a Boolean function of degree at most $d$ depends on at most $C_{W}2^{d}$ coordinates, making it a junta (a function depending on a constant number of coordinates), where $C_{W}$ is an absolute constant equal to at least 1.5, and at most 4.41, as shown by Wellens. The Kindler–Safra theorem generalizes the Friedgut–Kalai–Naor theorem to this setting. It states that if $f\colon \{-1,1\}^{n}\to \{-1,1\}$ satisfies $\|f^{>d}\|^{2}<\varepsilon$ then $f$ is $O(\varepsilon )$-close to a Boolean function of degree at most $d$.

### Kahn–Kalai–Linial theorem

The Poincaré inequality for the Boolean cube (which follows from formulas appearing above) states that for a function $f\colon \{-1,1\}^{n}\to \mathbb {R}$,
    $\operatorname {Var} [f]\leq \operatorname {Inf} [f]\leq \deg f\cdot \operatorname {Var} [f].$
This implies that $\max _{i}\operatorname {Inf} _{i}[f]\geq {\frac {\operatorname {Var} [f]}{n}}$.
The Kahn–Kalai–Linial theorem, also known as the KKL theorem, states that if $f$ is Boolean then $\max _{i}\operatorname {Inf} _{i}[f]=\Omega \left({\frac {\log n}{n}}\right)$.
The bound given by the Kahn–Kalai–Linial theorem is tight, and is achieved by the Tribes function of Ben-Or and Linial:
    $(x_{1,1}\land \cdots \land x_{1,w})\lor \cdots \lor (x_{2^{w},1}\land \cdots \land x_{2^{w},w}).$
The Kahn–Kalai–Linial theorem was one of the first results in the area, and was the one introducing hypercontractivity into the context of Boolean functions.

### Friedgut's junta theorem

If $f\colon \{-1,1\}^{n}\to \{-1,1\}$ is an $M$-junta (a function depending on at most $M$ coordinates) then $\operatorname {Inf} [f]\leq M$ according to the Poincaré inequality.
Friedgut's theorem is a converse to this result. It states that for any $\varepsilon >0$, the function $f$ is $\varepsilon$-close to a Boolean junta depending on $\exp(\operatorname {Inf} [f]/\varepsilon )$ coordinates.
Combined with the Russo–Margulis lemma, Friedgut's junta theorem implies that for every $p$, every monotone function is close to a junta with respect to $\mu _{q}$ for some $q\approx p$.

### Invariance principle

The invariance principle generalizes the Berry–Esseen theorem to non-linear functions.
The Berry–Esseen theorem states (among else) that if $f=\sum _{i=1}^{n}c_{i}x_{i}$ and no $c_{i}$ is too large compared to the rest, then the distribution of $f$ over $\{-1,1\}^{n}$ is close to a normal distribution with the same mean and variance.
The invariance principle (in a special case) informally states that if $f$ is a multilinear polynomial of bounded degree over $x_{1},\ldots ,x_{n}$ and all influences of $f$ are small, then the distribution of $f$ under the uniform measure over $\{-1,1\}^{n}$ is close to its distribution in Gaussian space.
More formally, let $\psi$ be a univariate Lipschitz function, let $f=\sum _{S\subseteq [n]}{\hat {f}}(S)\chi _{S}$, let $k=\deg f$, and let $\varepsilon =\max _{i}\sum _{S\ni i}{\hat {f}}(S)^{2}$. Suppose that $\sum _{S\neq \emptyset }{\hat {f}}(S)^{2}\leq 1$. Then
    $\left|\operatorname {E} _{x\sim \{-1,1\}^{n}}[\psi (f(x))]-\operatorname {E} _{g\sim N(0,I)}[\psi (f(g))]\right|=O(k9^{k}\varepsilon ).$
By choosing appropriate $\psi$, this implies that the distributions of $f$ under both measures are close in CDF distance, which is given by $\sup _{t}|\Pr[f(x)<t]-\Pr[f(g)<t]|$.
The invariance principle was the key ingredient in the original proof of the Majority is Stablest theorem.

## Some applications
### Linearity testing

A Boolean function $f\colon \{-1,1\}^{n}\to \{-1,1\}$ is linear if it satisfies $f(xy)=f(x)f(y)$, where $xy=(x_{1}y_{1},\ldots ,x_{n}y_{n})$. It is not hard to show that the Boolean linear functions are exactly the characters $\chi _{S}$.
In property testing we want to test whether a given function is linear. It is natural to try the following test: choose $x,y\in \{-1,1\}^{n}$ uniformly at random, and check that $f(xy)=f(x)f(y)$. If $f$ is linear then it always passes the test. Blum, Luby and Rubinfeld showed that if the test passes with probability $1-\varepsilon$ then $f$ is $O(\varepsilon )$-close to a Fourier character. Their proof was combinatorial.
Bellare et al. gave an extremely simple Fourier-analytic proof, that also shows that if the test succeeds with probability $1/2+\varepsilon$, then $f$ is correlated with a Fourier character. Their proof relies on the following formula for the success probability of the test:
    ${\frac {1}{2}}+{\frac {1}{2}}\sum _{S\subseteq [n]}{\hat {f}}(S)^{3}.$

### Arrow's theorem

Arrow's impossibility theorem states that for three and more candidates, the only unanimous voting rule for which there is always a Condorcet winner is a dictatorship.
The usual proof of Arrow's theorem is combinatorial. Kalai gave an alternative proof of this result in the case of three candidates using Fourier analysis. If $f\colon \{-1,1\}^{n}\to \{-1,1\}$ is the rule that assigns a winner among two candidates given their relative orders in the votes, then the probability that there is a Condorcet winner given a uniformly random vote is ${\frac {3}{4}}-{\frac {3}{4}}\operatorname {Stab} _{-1/3}[f]$, from which the theorem easily follows.
The FKN theorem implies that if $f$ is a rule for which there is almost always a Condorcet winner, then $f$ is close to a dictatorship.

### Sharp thresholds

A classical result in the theory of random graphs states that the probability that a $G(n,p)$ random graph is connected tends to $e^{-e^{-c}}$ if $p\sim {\frac {\log n+c}{n}}$. This is an example of a sharp threshold: the width of the "threshold window", which is $O(1/n)$, is asymptotically smaller than the threshold itself, which is roughly ${\frac {\log n}{n}}$. In contrast, the probability that a $G(n,p)$ graph contains a triangle tends to $e^{-c^{3}/6}$ when $p\sim {\frac {c}{n}}$. Here both the threshold window and the threshold itself are $\Theta (1/n)$, and so this is a coarse threshold.
Friedgut's sharp threshold theorem states, roughly speaking, that a monotone graph property (a graph property is a property which doesn't depend on the names of the vertices) has a sharp threshold unless it is correlated with the appearance of small subgraphs. This theorem has been widely applied to analyze random graphs and percolation.
On a related note, the KKL theorem implies that the width of threshold window is always at most $O(1/\log n)$.

### Majority is stablest

Let $\operatorname {Maj} _{n}\colon \{-1,1\}^{n}\to \{-1,1\}$ denote the majority function on $n$ coordinates. Sheppard's formula gives the asymptotic noise stability of majority:
    $\operatorname {Stab} _{\rho }[\operatorname {Maj} _{n}]\longrightarrow 1-{\frac {2}{\pi }}\arccos \rho .$
This is related to the probability that if we choose $x\in \{-1,1\}^{n}$ uniformly at random and form $y\in \{-1,1\}^{n}$ by flipping each bit of $x$ with probability ${\frac {1-\rho }{2}}$, then the majority stays the same:
    $\operatorname {Stab} _{\rho }[\operatorname {Maj} _{n}]=2\Pr[\operatorname {Maj} _{n}(x)=\operatorname {Maj} _{n}(y)]-1$.
There are Boolean functions with larger noise stability. For example, a dictatorship $x_{i}$ has noise stability $\rho$.
The Majority is Stablest theorem states, informally, then the only functions having noise stability larger than majority have influential coordinates. Formally, for every $\varepsilon >0$ there exists $\tau >0$ such that if $f\colon \{-1,1\}^{n}\to \{-1,1\}$ has expectation zero and $\max _{i}\operatorname {Inf} _{i}[f]\leq \tau$, then $\operatorname {Stab} _{\rho }[f]\leq 1-{\frac {2}{\pi }}\arccos \rho +\varepsilon$.
The first proof of this theorem used the invariance principle in conjunction with an isoperimetric theorem of Borell in Gaussian space; since then more direct proofs were devised.
Majority is Stablest implies that the Goemans–Williamson approximation algorithm for MAX-CUT is optimal, assuming the unique games conjecture. This implication, due to Khot et al., was the impetus behind proving the theorem.