# Realizability theory: difference in power between Lambda calculus and Turing Machines

I have three related subquestions, which are highlighted by bullet points below (no, they could not be split, if you are wondering). Andrej Bauer wrote, here, that some functions are realizable through a Turing machine, but not through lambda-calculus. A key step of his reasoning is:

However, if we use the lambda calculus, then [the program] c is supposed to compute a numeral representing a Turing machine out of a lambda term representing a function f. This cannot be done (I can explain why, if you ask it as a separate question).

• I would like to see an explanation/informal proof proof.

I don't see how to apply Rice's theorem here; it would apply to the problem "are this turing machine T and this lambda-term L equivalent?", because applying this predicate to equivalent terms gives the same result. However, the required function might compute different, but equivalent, TMs for different, but equivalent, lambda-terms.

• Moreover, if the problem is with introspection of a lambda-term, I think that passing a Gödel encoding of a lambda-term would be also acceptable, wouldn't it?

On the one hand, given that his example involves computing, in the lambda calculus, the number of steps needed by a Turing Machine to complete a given task, I'm not very surprised.

• But since here lambda-calculus can't solve a Turing-machine-related problem, I wonder whether one can define a similar problem for lambda-calculus and prove it unsolvable for Turing machines, or there is actually a difference in power in favor of Turing Machines (which would surprise me).
-

John Longley has a very extensive survey article discussing the issues involved, "Notions of Computability at Higher Type".

The basic idea is that the Church-Turing thesis is only about functions from $\mathbb{N} \to \mathbb{N}$ -- and there's more to computation than that! In particular, when we write programs, we make use of functions of higher type (such as $(\mathbb{N} \to \mathbb{N}) \to \mathbb{N}$).

In order to fully define a model of higher type computation, we need to specify the calling convention for functions, in order to allow one function to call another function it receives as an argument. In lambda calculus, the standard calling convention is that we represent functions by lambda-terms, and the only thing you can do with a lambda in the lambda calculus is to apply it. In typical encodings with Turing machines, we pass functions as arguments by fixing a particular Godel encoding, and then strings representing the index of the machine you want to pass as an argument.

The difference in encoding means that you can analyze the syntax of the argument with a TM-style encoding, and you cannot with a standard lambda-calculus representation. So if you receive a lambda-term for a function of type $\mathbb{N} \to \mathbb{N}$, you can only test its behavior by passing it particular $n$'s -- you can't analyze the structure of the term in any way. This is just not enough information to figure out the code of the lambda term.

One thing worth noting is that with higher types, if a language is less expressive at one order, it is more expressive one order up, because functions are contravariant. So similarly there are functions you can write in LC that you can't with a TM-style encoding (because they rely on the fact that you can pass functional arguments and know that the receiver can't look inside the function you give it).

-
this is an excellent survey. thanks for the link ! –  Suresh Venkat Sep 9 '10 at 21:56
I just realized I had forgot to accept an answer, though I meant to accept yours. Sorry! –  Blaisorblade Oct 5 '13 at 21:02

What Neel said, and also the following.

I would like to emphasize (again, again and again) that representation of input and output matters. If we are allowed to change representations, we can achieve just about anything (for example, make any given function computable). So, passing from a representation of functions $\mathbb{N} \to \mathbb{N}$ by $\lambda$-terms to a representation by Gödel numbers is not acceptable if our model of computation is $\lambda$-calculus (because then the currying operation becomes uncomputable by $\lambda$-calculus).

A statement which is realizable in the $\lambda$-term model but not in the Turing machine model is "not every function $\mathbb{N} \to \mathbb{N}$ has a Gödel code", which is kind of silly. I will try to come up with a better one and edit this answer.

Edit on 2013-10-07: Here is what I meant by "currying becomes uncomputable". Suppose we use the untyped $\lambda$-calculus as our computational model, but then we decide that we should represent maps $\mathbb{N} \to \mathbb{N}$ with Gödel codes (of Turing machines, encoded as Church numerals). Sounds harmless, right? After all we believe the mantra "Turing machines and $\lambda$-calculus are equivalent".

Well, for this new representation to actually be a valid representation of $\mathbb{N} \to \mathbb{N}$, we need also to realize application and currying (because to "represent functions" means the same thing as "to represent an exponential object"). Specifically, we need a $\lambda$-term $\mathtt{app}$ such that, whenever the Church numeral $\overline{n}$ represents $f : \mathbb{N} \to \mathbb{N}$ then $f(k)$ is represented by $\mathtt{app} \; \overline{n} \; \overline{k}$. (Here I write $\overline{n}$ for the Church numeral representing the number $n$.) Such an $\mathtt{app}$ is readily available because it amounts to an interpreter for Turing machines, implemented in the $\lambda$-calculus.

But how about currying? For that we need the following. Suppose $X$ is a represented set. Given any map $f : X \times \mathbb{N} \to \mathbb{N}$ computed by a $\lambda$-term $t$, we need to show that the transposition $\tilde{f} : X \to (\mathbb{N} \to \mathbb{N})$ is also computed by some $\lambda$-term $s$. But consider the example where $X$ is the set o fmaps $\mathbb{N} \to \mathbb{N}$ represented by $\lambda$-terms, and $f$ is application. Then $\tilde{f}$ would be a map which acts as identity on $\mathbb{N} \to \mathbb{N}$, but its realizer is a $\lambda$-term that converts $\lambda$-terms representing maps $\mathbb{N} \to \mathbb{N}$ to corresponding Gödel codes. Such a $\lambda$-term does not exist (for example because it would be discontinuous in a topological semantic model).

You may attempt to object that I should not have used the specific represented set $X$ of maps $\mathbb{N} \to \mathbb{N}$ represented by $\lambda$-terms, because we "agreed" that those should be represented by Gödel codes. But you would be wrong. First of all, I could have used a different $X$ with a more complicated proof which would elude you but still accomplish the same result. Second of all, $X$ is there in the category and the definition of exponential requires that currying work with respect to all objects. You have to respect the category. You cannot just randomly butcher it and take some objects out (well, you can but then you are a butcher).

-
still waiting for that better example... –  Jacques Carette Mar 10 '11 at 0:52
Well, I can think of many statements which are realizable with Turing machines but not with $\lambda$-terms. I suppose you want the opposite. Hmmm. –  Andrej Bauer Mar 12 '11 at 21:54
I don't get how currying can become incomputable. You should be able to reuse the s-m-n theorem, since its proof constructs a function on first-order data (naturals). By the Church-Turing thesis, this behavior on naturals can be implemented as a lambda term (which uses native functions internally, but I don't see how that's forbidden). One can similarly prove the u-t-m theorem, so according to your post we should be done. What am I missing? –  Blaisorblade Oct 5 '13 at 23:31
I explained in the answer what it means that currying becomes uncomputable, namely that the suggested object is not an exponential in the category of represented sets. –  Andrej Bauer Oct 7 '13 at 7:52
Thanks for the explanation! Unfortunately I can't upvote again. I can follow most technical details; I am not familiar with topological models, but I'm anyway familiar with "you can't inspect functions in functional programming/λ-calculus". Your last paragraph also explains why I can't go through s-m-n, because the currying given by s-m-n produces Gödel codes again, not standard functions as you require. I'll be meditating over that paragraph. –  Blaisorblade Nov 20 '13 at 20:34