**Theorem. ***Take a random walk on the integer lattice starting at the origin. If , the probability you return to the origin at some point on the future is 1; if the return probability is less than 1.*

A random walk on moves uniformly randomly along the gridlines of the integer lattice. For example, here’s a random walk on :

We want to prove that with probability 1 the walk will return to its start. Here’s the trick. Suppose instead of doing a random walk along the gridlines, we “make the coordinates independent”: at each time step we increment or decrement each coordinate indepently with probability . In this new walk we move uniformly randomly along red edges in the following picture:

Notice that **the red edges form a copy of the integer lattice**! Therefore the probability that this new walk returns to the origin is exactly the same as the probability that the gridline walk returns to the origin.

The key property of this new walk is independence of the coordinates. The walk returns to the origin iff each coordinate is 0 simultaneously at some time , and **these events are independent** so the probabilities simply multiply. Each coordinate looks like a one-dimensional random walk, so we have the equality

We have a very nice fact, but how to apply it? Exercise: the expected number of returns to the origin is infinite iff the probability of eventually returning is 1. So let’s compute the expected number of returns. By linearity of expectation,

We’ve reduced the problem to analyzing the one-dimensional random walk, and this case we can compute exactly. We’re summing independent ‘s and ‘s; the sum will be if there are the same number of ‘s and ‘s, so

$latex \text{Pr}[\text{walk on } \mathbb{Z} \text{ returns to origin at time } t] = \frac{\binom{t}{t/2}}{2^t}$

This is the famous central binomial coefficient, and by Stirling’s approximation it’s . Plugging this in, we arrive at a sum of reciprocals,

This is the harmonic series (up to a constant from the ), which is of course infinite, and this completes the proof of the case.

For dimensions, everything goes through. We get the equality

This sum is convergent say by the integral test for any and divergent for , and this exactly captures the theorem.

This proof is also explained at this Stack Exchange post.

]]>There are many equivalent definitions of the class of “computable functions” (cf. the Church-Turing thesis). The definition used in the Kleene recursion theorems, and in recursion theory in general, uses the mu minimization operator. In contrast, a “programmer-friendly” definition of computable functions says that computable functions are exactly the functions computed in one’s favorite programming language. Though they define the same class, “recursive” functions and “computable” functions have different definitions, and coupled with the fact that “recursion” is a common tool in computer programming, this has led to some confusion (see this excellent Stack Exchange answer for some discussion). The Kleene recursion theorem is a statement from the “recursion theory” perspective; on the way to it we’ll state it in the computability perspective, and we’ll start by talking about it from the mathematical perspective. I think the discussion of this theorem emphasizes the clarity that can be gained from keeping in mind real-world programming languages even when thinking about “mathematically friendly” objects like the μ-recursive functions.

Say we want a function that satisfies some recursive equalities,

It’s not a priori clear that such an exists. There is a slightly more primitive mathematical object that always exists, though, which is the *recursive operator* obtained by replacing recursive calls with calls to ,

Given , we can always define a new function in this way. Now, notice that the satisfying our recurrence are exactly fixed points of our recursive operator . Kleene’s first recursion theorem says that recursive operators always have fixed points. In this way, the theorem says that our recurrence equations do, in fact, always have solutions.

**Theorem (Kleene’s First Recursion Theorem, mathematical version)
**Every (mathematical) recursive operator has a fixed point.

**Proof:**

In the mathematical case, we require that every recursive operator only evaluate on smaller natural numbers. What this condition says is that our recurrences for a desired fixed point only use previous values of . In this case we can define by induction like a normal recursive definition.

Let’s now talk about recursive operators from the computability/programming language perspective. Say we’re writing a recursive function in our favorite language,

f(0) = 0 f(1) = 1 f(n) = f(n - 1) + f(n - 2)

As before we have a natural notion of “recursive operator” , which is just a higher-order function,

f(0) = 0 f(1) = 1 f(n) = g(n - 1) + g(n - 2)

**Theorem (Kleene’s First Recursion Theorem, programming language version)
**Every (programming language) recursive operator has a fixed point.

**Proof:**

This proof is rather different from the mathematical case, and it will be different from the full Kleene recursion theorem, but it is philosophically interesting. Compile the block of code

f(0) = 0 f(1) = 1 f(n) = f(n - 1) + f(n - 2)

The compiler *automatically makes this a valid definition of the function .* Note that we didn’t need the restriction we had in the mathematical case, that recursive calls are only made on smaller natural numbers. Consequently the output of compilation might be a partial function (undefined, , on some inputs), but it’s a well-defined mathematical object.

In recursion theory we have a different definition of recursive functions via the mu minimization operator. Let be the set of μ-recursive functions. This calls for a new definition of a recursive operator. This seems like a hard task: we don’t have any “code” to speak of, a recursive operator should be a special case of a function . We can extract one key mathematical property of programming language recursive operators to be our guide: we require that a recursive operator allows to be computed from finitely many values of (notice that every programming language recursive operator i.e. higher order function has this property). More discussion of recursive operators is at the end of this post; the intuition here suffices to understand the proof of Kleene’s first recursion theorem,

**Theorem (Kleene’s First Recursion Theorem)
**Every (recursion theory) recursive operator has a fixed point. Furthermore, there is a least fixed point i.e. a function such that , and for any function satisfying , .

The notation (pronounced “ is more defined than “) says that implies . Notice that the function defined nowhere (denoted ) satisfies for every .

**Proof
**The proof can be thought of as “making recursive calls until termination”. Say we want to know what value we should assign to . If we want , this means we want to know the value of . tells us a finite list of values of that, if we define those, will define ; this is our recurrence for computing . By repeatedly asking for and evaluating those values, either all recursive calls for will terminate at base cases, or they won’t; if it ever terminates, we have ‘s value, otherwise is undefined. To use our running example of the Fibonacci recurrence, tells us that in order to define , it suffices to define and , which in turn require and , and so on until we meet the base cases and , which don’t require any other values of .

A bit more formally, start with the function that loops on every input, . Define functions that terminate after recursive calls by and . Finally, let i.e. if an input terminates in any finite number of recursive calls, it is defined.

It’s not too hard to see that this is least: any satisfying the recursion must have carried out any finite number of recursive calls.

Ultimately, the proof is nothing more than “compiling our recursive operator,” in the same way the compiler in the programming language perspective “automatically” defines a function that terminates if all recursive calls terminate, or is undefined if there’s an infinite loop.

Finally, we should mention the idea behind the definition of recursive operators. As seen in the proof, and as holds true when thinking of programming language recursion, the key idea is that computing some value should only require finitely many values of . This can be formalized by saying that is a continuous function on .

We define the *positive information topology* on . Let be those functions that are defined on only finitely many inputs, and are elsewhere. We think of functions in as specifying finitely many values of functions in . A basis of open sets of the positive information topology is , for , defined by

That is, is exactly those functions that meet the specified (finitely many) output values of . A continuous function has that the preimage of every basis set contains a basis set . Taking to be a singleton function, and so is exactly those functions with a specified single output, continuity says that defining the finitely many values in ensures that the single output is fixed.

A recursive operator is necessarily a continuous function on this space. A “coherence condition” is also necessary to pin down the proper definition, but continuity suffices for intuition. For full definitions, see Cutman’s book on computability theory, Chapter 10.

]]>

For the standard Fourier transform on , one produces some interesting functions, most interestingly any Gaussian, and in general the Hermite functions. Mysteriously, *why* the Gaussian is an eigenfunction remains “a minor miracle”.

For the Boolean Fourier transform, which takes a function to its transform , I don’t see how exciting the eigenfunctions are. But here they are:

- There are eigenfunctions to . Indexed by the even parity bit strings , they are

where and represents the Hamming weight of the bitwise XOR of and .

- There are eigenfunctions to . Indexed by the odd parity bit strings , they use the same formula.

(This is using the textbook CS definition of the Boolean Fourier transform; if it’s instead normalized to be unitary the eigenvalues will be .)

Let’s prove this. The Boolean Fourier transform is implemented by the Hadamard matrix, itself defined by the recurrence , where

The eigenvectors of this matrix are

using as before.

Inductively, the eigenvectors of the tensor product recurrence are tensored to produce the eigenvectors we listed above.

It seems that computing the eigenfunctions of the Fourier transform over gets quite a bit messier. This is the question of computing an orthogonal eigenbasis for the DFT matrix

A canonical set of eigenvectors can be generated computationally as the solutions to a simpler matrix equation using this seminal work, but it seems that in general there isn’t a simple description of the eigenvectors themselves.

What seems to make these mathematically weird is that we’re working with maps between a space and its dual. These spaces are not typically isomorphic, and in these cases we can’t even talk about eigenvectors. In the cases where they are (canonically) isomorphic, the eigenfunctions feel like a spontaneous beast.

Perhaps this will be the subject of a blog post in the future.

If you know of any further interpretations of the eigenfunctions (in either the real or finite abelian case), leave a comment!

]]>A coupling of two distributions and on is a joint distribution on such that the two marginal distributions are and respectively. We write for the joint random variable, with the marginal in the first coordinate, and the marginal in the second coordinate. We say that and are “coupled”, with the coupling defining the interaction, or dependence, between them.

One of the basic facts about couplings compares the statistical distance between and to the probability the coupled variables agree. For any coupling of and , we have

Furthermore, there is a coupling that achieves this bound. The above inequality is typically used to upper bound the statistical distance between and by constructing a coupling that’s likely to agree e.g. in the proof of convergence of an ergodic Markov chain to its limiting distribution.

In this post we’ll prove this inequality (and its tightness!) using an LP duality argument.

A coupling is specified by a set of linear constraints: for , let be the probability of seeing the pair . The constraints are

This defines a polytope in , called a transportation polytope. In fact, the last constraint is redundant, as summing the constraints with over all ‘s will also give . Over this polytope, the linear constraint to minimize is the probability and disagree,

Ok, now that we have the LP, its dual (whose computation is explained e.g. here… or perhaps in a future blog post) is

By the duality theorems, is always at least as large as the solution to the dual, and furthermore, for some the two solutions agree. To finish our argument, we’ll show that the value of the dual LP is the statistical distance between and . The definition of the statistical distance we’ll use is the “optimization” version: the maximum difference in probabilities of events in ,

First we argue that the optimum is -valued. The dual problem’s matrix is totally unimodular (Prop. 3.2) and the right-hand sides of the constraints are integral, hence the LP is integral. Fix an optimal solution . From the constraints we see only one of the sets and can contain positive values. WLOG these are the variables for . By optimality and looking at the largest (resp. smallest) of the (resp. ), the are within of one another, and the are their negations. Now we can shift the solution to be -valued without changing the value.

Now we are in a position to compare the -optimum with . As noted above, the set of variables for exactly one of is positive, which gives the sign in the absolute value. The -valued variables indicate the event to take. This shows the value of the dual is exactly . As explained, this finishes the proof that

We finish with a few extra details on transportation polytopes.

Fixing in mind and , the collection of possible couplings forms a convex polytope in from a very special class of polytopes, the transportation polytopes. The name comes from the following “transportation” problem in optimization: suppose you have factories producing a good, such as lawn mowers, which produce quantities . You want to distribute the lawn mowers among stores in quantities . The question is, how many lawn mowers should factory send to store ? A solution that achieves the desired stocking quantity is exactly a matrix (a.k.a joint probability distribution) with the given marginals.

Vertices of a transportation polytope can be enumerated and checked algorithmically. Furthermore, when the marginals and are uniform, the corresponding transportation polytope is exactly the set of doubly stochastic matrices. By the classical Birkhoff-Von Neumann theorem, the vertices of this polytope are exactly the permutation matrices i.e. doubly stochastic matrices are exactly convex combinations of permutation matrices (along with the zero matrix).

]]>How is distributed?

Typically the answer is the central limit theorem (CLT) amplified with the Berry-Esséen theorem, “a sum of independent variables is approximately normally distributed”. This post explains two symbolic translations of that sentence which I find easier to write down at a moment’s notice. The first takes the viewpoint of “asymptotic approximation of “,

Here is the mean of and is the standard deviation of . The second is

where the are i.i.d Gaussian random variables with the same mean and variance as the , . This can be thought of as an “invariance principle” or “replacement lemma” (and this is the viewpoint taken by Lindeburg in his proof of the CLT). The invariance principle is now a tool used in Boolean fourier analysis.

**Crucial remark:** Unfortunately, the equality of these “syntactic forms” is NOT any convergence in distribution. We’ve “blown up” errors by a factor of from the convergence guaranteed by the CLT. Dividing both sides by normalizes both sides to have finite variance and gives convergence in probability (or the stronger convergence guaranteed by an appropriate CLT).

The law of large numbers says that, if is finite, “the sample mean converges to the true mean”, i.e.

In our notation, this is a “linear approximation to “,

The central limit theorem refines this by saying that, in fact, the sample mean is about away from the true mean. If and are finite,

In our notation, this is a “ approximation to “,

The Berry-Esséen theorem strengthens the convergence to the normal distribution. If denotes (an upper bound on) the third moment of the distribution , which we assume to be finite,

In our notation, this is an improvement up to a constant to the asymptotic distribution of ,

It should be noted that the Berry-Esséen theorem is tight up to the big-Oh. The binomial distribution achieves this rate of convergence; see the end of these lecture notes for a proof.

The previous analysis ends with the distribution . We can incorporate everything into one Gaussian to produce the equivalent distribution . Interestingly, because the sum of independent Gaussians is again Gaussian, this distribution has the same PDF as

for independent Gaussian random variables . This leads us to the equality

in which we’ve simply replaced each by a Gaussian random variable with the same mean and variance.

As noted in Remark 29 here, one can improve the constant term by changing the replacement variables. In particular, it can be made if the first, second, **and third** moments of the agree with the .

The idea of “replacement invariance” surfaces in theoretical CS in the context of Boolean fourier analysis. Here we generalize the summation of Boolean (-valued) variables to an arbitrary Boolean function

The invariance principle states that the random variable for uniformly drawn from is close in probability to the random variable

for (assuming we normalize both sides to have variance ). In this case the “closeness” is determined by the maximum influence of a variable on the value of , as well as the complexity of (its degree as a multilinear polynomial); see the previously linked lecture notes for an exact quantitative statement.

]]>The Ackermann function is variously defined, but the most popular these days is the Ackermann-Péter function:

One way to build up to the Ackermann function is through hyperoperation. We’ll show that is pretty much for the -th hyperoperator : in fact .

Fixing the first argument of yields a function based on the -th hyperoperator, which is why we often think of the Ackermann function as a family of functions parameterized by the first argument. In retrospect, maybe the better definition for the Ackermann function is the simpler , so that the ubiquitous exercise to compute the first few functions becomes just a little bit less of an exercise.

Interpret multiplication as repeated addition: add to itself, times. Interpret exponentiation as repeated multiplication: multiply with itself, times. Going one step further, interpret tetration as repeated exponentiation: exponentiate with itself, times. For example,

Going infinitely many steps further, we can define the -th hyperoperation to “recursively apply the previous hyperoperation on with itself, times” (this of course stops being commutative at and beyond exponentiation, though the first hyperoperators constructed were actually commutative). To actually implement this we should use the recursion “compute hyperoperated with itself times, then apply one more time”:

Notice we fold right here i.e. compute rather than .

We also need a trio of base cases for what happens when you “apply to itself times” in order to align with the normal arithmetic operations:

for

Finally, we set , to capture that addition, , arises as the iterated successor function, our . After making all these definitions, we have our hyperoperators. These extend the normal arithmetic operators in the following way:

The point of defining these hyperoperations is to note that the Ackermann function is itself a specific case: . The proof of this isn’t too exciting, but let’s prove it by induction. Check the base case ,

For the base case , we need key properties of using instead of a different constant:

for

for

Now we have

And the primary recurrence for and :

Substituting for by induction, we see they are in fact the same recursion.

]]>

where is the binary entropy function i.e. the entropy of a coin flipped with bias . Maybe more properly the proof is just counting in two ways?

By a tiny tweak to our entropy argument as done here, one can get a better bound

This is what’s typically used in practice to bound e.g. the sum of the first of the binomial coefficients by . The proof here gives all the essential ideas for that proof. With Stirling’s approximation used to give error bounds, both approximations are tight when ,

**The experiment:** Let the random variable denote the result of flipping fair coins i.e. is binomially distributed. Now suppose we know has exactly Heads.

**The question:** How much entropy is in the conditional distribution of given Heads? I.e. what is ?

**The left side: **The conditional distribution of is uniform over possible results. The entropy of the uniform distribution on objects is , therefore

.

**The right side: **On the other hand, is specified by its bits , so

By subaddivitity of entropy,

This expression is easy to compute: when flipping Heads of flips, each looks like a coin with bias , therefore its entropy is . So

giving the right-hand side.

We can naturally generalize the above argument to provide an approximation for multinomial coefficients. Fix natural numbers with . Let be a distribution over taking with probability . Then

The proof generalizes perfectly: the underlying set is (place a letter from at each of indices), and we consider the entropy of a uniform choice of a string constrained to have the fixed letter histogram . This is exactly the left-hand side, and subadditivity yields the right-hand side.

Moreover, by Stirling again the approximation is tight when .

]]>and approximates it as

Imagine if are “bad events” that occur with some tiny probability . The union bound says

If the events were fully independent, we would have the equality

Now when . So we have

This is equal to the bound spit out by the application of the union bound! In the case of fully independent events with small probabilities, we see the union bound is essentially tight. Full independence is rare, but in applications where low-probability events are slightly correlated, the union bound is also a good approximation.

]]>To make sure we’re all on the same page, the wreath product for an arbitrary group and a permutation group is the semidirect product , where each is an automorphism of by permuting the coordinates.

That is, we fix some number and some group of permutations on , . The group we construct takes disjoint and independent versions of , , but also allows you to make “limited rearrangements according to “. There are two distinct ideas going on here; it’s the semidirect product that, if you tell it how two groups should interact, joins those two ideas into a single group.

There are two “trivial” wreath products, (where denotes the trivial group) and . is disjoint and independent versions of , with **no** interdependencies introduced by ; this is just .

Let be a graph with automorphism group . Claim: if you stick disjoint copies of next to each other, this new graph has automorphism group . To see this, of course some automorphisms apply elements “in parallel” to the different copies of . These automorphisms correspond to . But any rearrangement of the copies of is also an automorphism. All copies are isomorphic, so rearranging can be done without restriction by .

The previous paragraph shows that, if acts on a set , the wreath product acts naturally on . This is called the **sum action** (or “imprimitive action”, because it’s nearly always an imprimitive group action) of the wreath product. There is another natural action, called the **product action **(or “primitive action”). Here the domain is the set , and the action is defined by (1) applying elements of coordinate-wise and (2) permuting the coordinates with .

I think of this like a “simultaneous tracking” version of the sum action. In the sum action, we kept track of one point/vertex across copies of our graphs, and looked at where that point went when hit with a group element. In the product action, we track one point from each of the graphs simultaneously, and look at how as a whole those elements move.

It would be remiss to mention wreath products without mentioning the Kaluzhnin-Krasner theorem (English version). We say that the group is an extension of by if there is an exact sequence

**Theorem (Kaluzhnin-Krasner, 1951)** If is an extension of by , then is isomorphic to a subgroup of .

That is, is a group that’s big enough to contain all extensions of the two groups. In a sense that can probably be made more formal through order theory, is an “upper bound” on joining and together. Not bad!

]]>The most common form of the Chernoff bound is the following: suppose you have independent and identically distributed coin flips , say the result of repeatedly flipping a coin that comes up Heads with probability . The number of Heads is by definition a Binomial distribution; let denote this random variable. Then with all but exponentially small probability, is within of its mean:

The Central Limit Theorem (CLT) tells us that as , the distribution approaches a standard normal distribution. Philosophically, approaches a normal distribution with the parameters you would expect: mean and variance (though the “scaled up” distributions may not necessarily converge from the CLT alone).

In our case, and . The PDF of the “Gaussian you would expect” is

for an appropriate normalizing constant . Let’s rewrite that with :

This is (up to the factor of ) the expression appearing in the Chernoff bound! Thus we can think of the Chernoff bound as expressing an “even when is small” version of the CLT, with a little bit of loss from to in the multiplicative factor.

We lost some credibility at one point in the technique above: we actually should have been looking at the cumulative probability

Instead we noticed that the Chernoff bound can be remembered by looking at the PDF (and ignoring a nonconstant factor)

But using the CDF instead of the PDF actually gives the same expression, and with a truly constant factor. Let’s compute:

If we break up the integral into little size pieces from to , the integral on a piece looks like

The exponent increases faster than linearly, and it is the only thing that changes in , so this contribution to the integral goes to 0 faster than geometrically. Therefore the integral is bounded by an infinite geometric series with initial term proportional to . Therefore the cumulative probability is (up to a constant) the expression in the Chernoff bound

and this time the constant is actually constant!

]]>