Suppose we are given a function . We would like to know whether it is linear, meaning that it has the form
, where the coefficients
belong to
. All additions here are modulo two. There is another way to describe linearity, without referring to the coefficients: a function is linear precisely when
for every pair . This is easy to see in one direction, since a linear expression preserves addition. Conversely, if the identity holds for every pair, then
, and by writing
in terms of the standard basis vectors, we obtain
. The first description is global: it says that one choice of
coefficients determines the function everywhere. The second is local: it gives a simple relation involving only three values of the function.
Now suppose the local identity holds for most pairs , but not necessarily all of them. Does it follow that the function is close to some linear function? More importantly, can we tell whether a function is close to linear by checking only a few randomly chosen values, rather than examining its entire truth table of size
? This is the question behind the BLR linearity test, introduced by Blum, Luby and Rubinfeld. The test is remarkably simple.
BLR linearity test: Choose independently and uniformly at random, query
, and accept exactly when
.
If is linear, every test passes. The interesting question is what happens when
is not linear. A function could violate some of these identities without being very far from linear. What we want is a quantitative relationship between the fraction of identities that fail and the fraction of values we would need to change to make the function linear. Let
be the distance from
to the nearest linear function, and let
be the probability that the BLR test rejects:
We will prove the following bounds:
The second inequality is fairly easy: if the function differs from a linear function at only a few points, a random test is unlikely to encounter one of those points. The first is more interesting. It says that if a random local test almost always passes, then there really is a single linear function agreeing with on almost the entire space. We will first prove this using Fourier analysis, which gives the stronger constant. Then we will give a second proof based on decoding: using the local identities themselves to reconstruct a linear function. The two arguments explain different aspects of why the test works.
The Fourier proof
The first question is how to express the acceptance probability in a form that Fourier analysis can handle. Since takes values in
, it is convenient to change to the sign representation
Now
is always
or
, and addition modulo two becomes multiplication of signs. In particular,
If the test accepts, this product is ; if it rejects, the product is
. So its expectation is the acceptance probability minus the rejection probability, or
. Equivalently,
This is a good reason for using the sign representation. The condition originally involved addition modulo two, but we have converted it into an ordinary product of three real numbers. We now expand in the Fourier basis. For
, let
be the corresponding character. Then
Substituting the expansion into the expectation gives
At first this is a triple sum, but the characters make nearly every term vanish. Since characters are multiplicative with respect to addition, . Thus the expectation in the sum becomes
A nontrivial character has average zero. Consequently, this product vanishes unless and
, which in characteristic two means
. Only the terms with three identical frequencies survive. We obtain the central identity of the proof:
This cubic expression is not accidental. The BLR test examines three points satisfying one additive relation. When we expand their Fourier characters, orthogonality forces all three frequencies to be equal. There is a useful parallel with the Fourier proof of Roth’s theorem over . There too, a three-variable configuration gives a sum of cubes of Fourier coefficients. The underlying mechanism is the same: an additive relation among the sampled points becomes a relation among frequencies, and character orthogonality removes almost the entire expansion.
We have expressed the acceptance probability using Fourier coefficients. But our theorem concerns the distance from to a linear function. How are these related? Fix
and consider the linear function
. By definition,
The expression inside the expectation is when
, and
when they disagree. Therefore
So the Fourier coefficient at frequency measures how well
agrees with the linear function
. For example, if they agree everywhere, the coefficient is
. If they disagree at ten percent of the points, the coefficient is
. If they agree at exactly half the points, it is zero. A negative coefficient means they disagree more often than they agree. Since
is the smallest possible disagreement over all linear functions, we have
This is the main reason Fourier analysis is so well suited to the problem. The linear functions we are trying to find are exactly the functions appearing in the Fourier basis. Finding a linear function close to is the same as finding a large positive Fourier coefficient of
. We now have everything we need. Parseval’s identity gives
since is always a sign. Let
. Every Fourier coefficient is real and at most
. Multiplying this inequality by the nonnegative quantity
, we obtain
. Summing over all frequencies,
Substituting into the expression for the acceptance probability,
Hence
This proves the difficult direction of the theorem. It is worth noticing how little we needed once the Fourier identity was established. Parseval tells us that the Fourier coefficients have total squared mass one. The cubic sum cannot exceed the largest coefficient times that squared mass. But the largest coefficient tells us exactly how close the function is to a linear function. We can also read the argument backward. If the test accepts with probability , then the cubic Fourier sum equals
. Since this sum cannot exceed the largest Fourier coefficient, some frequency satisfies
. The corresponding linear function
agrees with
on at least a
fraction of the inputs. Thus a large acceptance probability is not merely evidence that the function is approximately linear. It guarantees the existence of a particular linear function that explains most of its values.
The other direction is much simpler and does not need Fourier analysis. Let be a closest linear function, and suppose
differs from
on an
fraction of the inputs. Call these inputs errors. The BLR test queries the three points
. If
agrees with
at all three points, the test certainly accepts, because
is linear. Thus a rejection is possible only if at least one of the three queried values is an error. Each of
is uniformly distributed in
, so each is an error with probability
. By the union bound,
Combining this with the Fourier argument gives the desired theorem:
The upper bound shows that the test does not reject too often when the function is close to linear. The lower bound shows that it cannot accept too often when the function is far from every linear function. The two directions are quite different. The upper bound follows by comparing with a known nearby linear function. The lower bound is an inverse statement: from the fact that many local identities hold, we must prove that some nearby linear function exists.
It is also useful to consider what different acceptance probabilities tell us. If the BLR test accepts almost always, then the function must be close to linear: for example, 99% acceptance means that some linear function agrees with on at least 99% of the inputs. Interestingly, the opposite extreme also tells us something. If the test accepts only 1% of the time, then
must be within 1% of a function of the form
, where
is linear. Indeed, replacing
by
interchanges acceptance and rejection. What happens around 50% acceptance? Here we cannot conclude that the function is close to either type of function. A random Boolean function typically passes about half the tests, but even simple nonlinear functions, such as quadratic polynomials, can have acceptance probabilities very close to 50%. In fact, if the acceptance probability is exactly 50%, the function must be at least
away from every linear function and every function of the form
, although it may be much farther away. Thus the test is most informative near the two extremes: acceptance near 100% detects linearity, acceptance near 0% detects linearity with the constant term flipped, and acceptance near 50% gives much less information about the function.
The estimate comes from a union bound, but we can understand the rejection probability more precisely. Write
, where
is a closest linear function and
is the error indicator. Thus
exactly when
, and
. Since
is linear, its contribution cancels in the BLR condition. The test rejects exactly when
This gives a slightly surprising observation. The test does not reject whenever it sees an error. It rejects when it sees an odd number of errors among its three queried values. In particular, two errors can cancel each other. This is why the union bound is not an exact formula. There is a simple way to calculate the rejection probability from these possibilities. For bits , the indicator that
is odd equals
. Apply this with
,
, and
. Each individual error has probability
. More importantly, every pair among
is independent and uniformly distributed, even though all three points are not independent. For instance, the map
is a bijection of the product space. Therefore each pair of error indicators has expectation
. Let
. Taking expectations gives the exact formula
The quantity measures how often all three points of a randomly chosen additive triple lie in the error set. It depends on the additive structure of that set, not merely on its size. Since
, we obtain the more precise bounds
Together with the Fourier lower bound, this tells us
For small , the two quadratic bounds are very close. In fact,
. So when the function differs from a linear function on only a tiny fraction of inputs, the test rejects with probability approximately three times that fraction. This makes sense. For a very small error set, a random test usually encounters no errors. The main way it can fail is to encounter exactly one, and there are three queried positions at which that error might occur. Events involving two or three errors have probability of order
.
The refined identity also shows why the exact rejection probability cannot depend only on . Two error sets of the same size may have different additive structure and therefore different values of
. For example, let the error set be a subspace
of density
, and take
. For
, the zero function is a closest linear function. If
, then
, so
. The rejection probability is therefore
. Now take the error set to be a nonzero coset
of a subspace of codimension at least two. Again the zero function is a closest linear function, with distance
. But if
, then
, not in
. Thus
, giving
. The two functions have the same distance to linearity, but their error sets behave differently under addition. These examples attain the two quadratic bounds for such densities.
Consider on
. The function is zero at three of the four inputs and equals one at
. It has distance
from the zero linear function, and no linear function agrees with it at all four points. Its sign function
has four Fourier coefficients: three equal to
and one equal to
. Therefore
so the test rejects with probability
Thus a function at distance from linearity is rejected with probability
. This example is worth remembering because it is the simplest quadratic Boolean function. The BLR test was designed to distinguish linear functions from nonlinear ones, and the first nonlinear polynomial already gives a concrete instance of its behaviour.
Another Proof – Self Correction
The Fourier proof gives the stronger quantitative result, but it does not immediately tell us how to recover a nearby linear function from queries to . There is another argument that does exactly this. Suppose first that
is close to some linear function
. We want to recover
at a particular point
, possibly even when
itself is wrong. The linearity identity suggests a way to do this:
The important thing is that this holds for every . We can therefore choose a random
and use the two values
to guess
. Define the vote
If , every vote equals
. If
differs from
on an
fraction of the inputs, the vote can be incorrect only if at least one of
is incorrect. By the union bound,
Notice that this holds for every fixed . The point
itself need not be good. We have replaced the potentially incorrect value
by two randomly chosen values whose sum is supposed to equal the correct answer. If
, the right side is greater than one-half. Thus a majority of the votes agree with
, and repeated random votes can recover its value with high probability. This is called local self-correction. We do not have to reconstruct the entire truth table of
before computing its value at one point. We use the linearity identity to move the query to random locations where the function is likely to be correct. But this argument assumed that a nearby linear function already exists. Can we go in the opposite direction? If the BLR test rarely rejects, can we define a function from these majority votes and prove that it is linear? That is the decoding version of the soundness proof.
Let be the rejection probability of the BLR test. For every
, define
to be the majority value of the votes
, as
ranges uniformly over the space. If there is a tie, choose either value. We would like to prove that these majority values form a linear function. The difficulty is that the test rejects with probability
only on average over
. At a particular point
, we do not yet know that most votes agree with
. Some values of
may be badly corrupted. What we can prove is that, for each fixed
, most votes
agree with one another. The reason comes from comparing two votes. Take independent random
. Their votes are
and
. Put
. Since we are working over
, we have
, and hence
Each parenthesis is the expression tested by BLR for a pair of inputs. The first is the test on ; the second is the test on
. Both pairs are uniformly distributed when
are uniform and independent. Therefore, if the two votes disagree, at least one of these two BLR checks must fail. By the union bound,
The key point is that this estimate holds for every fixed . We have used the overlapping additive relations to turn an average statement about the test into a uniform statement about the consistency of the votes. Now suppose a binary random variable takes its minority value with probability
. Two independent samples disagree with probability
, which is at least
. Thus the probability that a vote disagrees with its majority value is at most the probability that two independent votes disagree. Applying this to
, we obtain
So the majority vote is reliable at every point, even though the original function may be unreliable at some points. We now want to prove . Fix any
and choose a random
. Consider the three identities
Each is a statement that one vote agrees with the majority value at its corresponding point. By the preceding estimate, each fails with probability at most . By the union bound, all three identities hold simultaneously with probability at least
. In particular, if
, there must exist some
for which all three are true. For this
, add the first two identities. The two occurrences of
cancel modulo two, leaving
Since were arbitrary,
is linear. This is the central step in the decoding proof. We did not begin with a linear function and check that it explains the data. We defined
from the data by taking majority votes, and then proved that these votes necessarily fit together into a linear function. Why does this work? Because the three expressions used to vote for
are not unrelated. They share values of
, and when the three votes are correct, their algebraic relation forces the desired linearity identity.
It remains to show that agrees with
on most inputs. Recall that
. The BLR test rejects on the pair
exactly when
. Thus
If , then
is not the majority value of the votes
. Consequently, at least half the votes disagree with
. Averaging over
gives
Therefore
We have proved that if the BLR test rejects with probability less than , then the majority-vote function
is linear and differs from
on at most a
fraction of inputs. This is weaker than the Fourier theorem, which guarantees distance at most
without assuming
. But the decoding proof gives something the Fourier proof does not directly provide: a concrete way of defining the corrected function at any point, using values of
at randomly chosen nearby pairs. The condition
appears because we needed three majority-vote identities to hold simultaneously, and each had failure probability at most
. It is a sufficient condition for this particular argument, not a threshold at which the BLR test suddenly stops working. The sharper Fourier guarantee holds for every function.
Bounds
We have proved . Could the constants be improved? For very small
, the exact counting formula from above shows that
. So the factor three in a universal linear upper bound cannot be replaced by a smaller constant. A function that differs from a linear one on a very small number of points is rejected approximately three times as often as its error rate. The factor one in the lower bound is also the best possible universal linear constant, although this is easiest to see for functions whose distance to linearity is close to one-half. Consider the quadratic function on
variables
For a single pair of variables, the sign function has four Fourier coefficients, each of absolute value
. For
independent pairs, the Fourier coefficients are products of these coefficients, so all have absolute value
, and some are positive. It follows that the distance to the closest linear function is
We can also calculate the rejection probability directly. The BLR error expression for each pair is . Its sign has expectation
, and the contributions from the different pairs are independent. Thus the full acceptance-minus-rejection bias is
, giving
Consequently,
As , this ratio tends to one. So even though the rejection probability is almost three times the distance when the distance is very small, it can be barely larger than the distance when the function is far from linear. These examples explain why the two constants in the theorem are both natural. Near a linear function, an isolated error can be detected through any of the three queried positions, producing the factor three. Far from linearity, the Fourier spectrum can be spread over many frequencies, and the rejection probability can be close to the distance itself. The exact relationship between distance and rejection probability is therefore more interesting than a single linear inequality. It depends not only on how many errors the function has relative to its closest linear approximation, but also on how those errors are arranged under addition. This was studied in greater detail by Bellare, Coppersmith, Håstad, Kiwi and Sudan in their 1996 work on linearity testing in characteristic two.
It is useful to compare the two proofs, because they suggest different ways to think about the problem. In the Fourier proof, we first change the function from bits to signs. That makes the local equation multiplicative. Expanding the product in characters is then natural, because characters themselves preserve the addition operation. Orthogonality leaves a sum of cubes. The rest follows from a simple inequality: a cubic Fourier sum is bounded by the largest Fourier coefficient times the total squared Fourier mass. The decisive observation is that the largest positive Fourier coefficient is not some unrelated analytic quantity. It measures the agreement with the best linear function. Thus the Fourier representation is exactly adapted to the property we are testing.
The decoding proof begins from a different question. If the function is supposed to be linear, how would we repair a value that might be incorrect? The equation suggests asking random pairs of points to vote for the value at
. The problem is then to show that different votes are consistent. That consistency comes from the overlapping additive relations. Two votes for the same point can disagree only if at least one of two BLR checks fails. This gives a reliable majority value for every point. To prove that the majority values are linear, we use three carefully chosen votes whose intermediate function values cancel. So the same identities that define the test also provide a way to reconstruct a global linear function. In this sense, the BLR test is doing more than checking a collection of unrelated equations. The local constraints overlap so heavily that their values cannot behave independently. If almost all constraints hold, the values at different points are forced to fit together into one global linear rule.
There is also a coding-theoretic interpretation. The truth table of each linear function is a codeword of the Hadamard code. These codewords have length , but the BLR test examines only three locations. The Fourier theorem says that the probability of rejecting a truth table is at least its relative distance from the closest codeword. The decoding argument shows how, when the corruption is sufficiently small, individual codeword symbols can be recovered from random pairs of received symbols. This is why linearity testing is useful in probabilistically checkable proofs. A verifier may be given an enormous table claiming to describe a linear function. It cannot afford to inspect the entire table, but it can sample a few local constraints. A truly linear table always passes, while a table far from every linear function is caught with probability proportional to its distance.
The main result can be stated quite simply. If the BLR test rejects with probability , then there is some linear function differing from
on at most a
fraction of inputs. Conversely, if the nearest linear function differs from
on an
fraction, then the rejection probability is at most
, and in fact is approximately
when
is small. The important point is the passage from local to global: knowing that most additive identities hold is enough to guarantee that one linear function explains most of the values. Fourier analysis proves this through the concentration of a cubic sum, while majority decoding proves it by showing that the local equations give consistent ways of reconstructing the same function.