S and K Turing-completeness proof

Many esoteric programming languages in the functional paradigm use the S and K combinators to demonstrate that they are Turing-complete. This page outlines a proof that the S and K combinators are Turing-complete, by showing that any expression in Lambda calculus can be converted into these combinators.

Currently missing is an argument that the conversion preserves the respective reduction/evaluation semantics of the computation models.

Conversion
We begin by observing the following equivalences:


 * Ky = (&lambda; x.y)
 * (SKK) = (&lambda; x.x)
 * (S(&lambda; x.f)(&lambda; x.g)) = (&lambda; x.fg)
 * y = (&lambda;x.yx) (Eta conversion)

We can apply these in reverse to convert a lambda expression into combinators. Note that the final rule can convert longer expressions - for example, &lambda; x.abcdeg can be converted by setting f = abcde. This will eventually terminate as the third rule reduces the number of applications, so that eventally one of the other rules will take effect and remove the lambdas.

Example
Consider the following lambda expression, which raises one Church numeral to the power of a second:

&lambda; mn.nm

Recall that this is short-hand for:

&lambda; m.(&lambda; n.nm)

Which by the third rule becomes:

&lambda; m.S(&lambda; n.n)(&lambda; n.m)

Which by the first and second rules becomes:

&lambda; m.S(SKK)(Km)

Which by the third rule becomes:

S(&lambda; m.S(SKK))(&lambda; m.Km)

Then by the fourth rule, the last statement becomes K:

S(&lambda; m.S(SKK))K

Then by the first rule, the statement becomes:

S(K(S(SKK)))K

Which is the combinator form of (&lambda;mn.nm).

External resources

 * SKI combinator calculus
 * David Madore's original description of the Unlambda language
 * Raymond Smullyan, To Mock a Mockingbird