4

Ackermann's function is total but not primitive recursive. Can one define Ackermann's function in Type Theory,

ie:

Can you define functions which are not primitive recursive, yet total, in Type Theory?

[this post was closed] due to being "not specific enough", however this question is very specific, to the point. It is exactly what I need to know, and no more can be asked. What exactly is meant by being more specific here?

RFV
  • 140
  • 2
    What type theory are you asking about? – Zhen Lin Nov 26 '21 at 11:59
  • Any, even simply typed lambda calculus. From my understanding type theory restricts the language to functions which must terminate and I read a lot about recursion and mathematical induction, but there are terminating functions which are not primitive recursive. Can the be expressed in ANY type theory? – RFV Nov 26 '21 at 16:37
  • I think you will have to be more specific if you want a satisfactory answer. For example, I can extend simply typed lambda calculus by adding a type $\mathbb{N}$ and a term $\textrm{ack} : \mathbb{N} \to \mathbb{N}$ and declare that the intended interpretation is that $\mathbb{N}$ is the type of natural numbers and $\textrm{ack}$ is the Ackermann function. In what sense have I defined the Ackermann function in type theory? Not a very good sense, I think. – Zhen Lin Nov 26 '21 at 23:13

1 Answers1

4

$\newcommand{\suc}{\mathsf{suc}\ }$ $\newcommand{\iter}{\mathsf{iter}}$ $\newcommand{\ack}{\mathsf{ack}}$ The Ackermann function can be defined in e.g. Martin-löf type theory. The reason is that the notion of 'primitive recursion' that you are able to use is much stronger due to the presence of higher-order functions. Here is how you might go about figuring out how.

The specification is:

$$ \begin{align} &\ack\ 0\ n = n + 1 \\ &\ack\ (\suc m)\ 0 = \ack\ m\ 1 \\ &\ack\ (\suc m)\ (\suc n) = \ack\ m\ (\ack\ (\suc m)\ n) \end{align} $$

The thing to notice is that $\ack\ (\suc m)\ n$ is the (n+1)-fold composition of $\ack\ m$ applied to $1$, and $\ack\ 0$ is $\mathsf{suc}$. So, if we define:

$$ \begin{align} &\iter : ℕ → (A → A) → A → A \\ &\iter\ 0\ f = f \\ &\iter\ (\suc n)\ f = f \circ \iter\ n\ f \end{align} $$

which is a recursive definition of the (n+1)-fold composition. Then we can define:

$$ \begin{align} &\ack : ℕ → (ℕ → ℕ) \\ &\ack\ 0 = \suc \\ &\ack\ (\suc m) = λ n → \iter\ n\ (\ack\ m)\ 1 \end{align} $$

which is also acceptable recursion on $ℕ$.

These definitions aren't allowed under the traditional rules of primitive recursion, because a primitive recursive definition must be of a first-order function, with type like $ℕ × ... × ℕ → ℕ$. But, a theory that lets you define higher-order functions 'by primitive recursion' will let you go beyond this.

Dan Doel
  • 4,608
  • Can all total functions be defined in higher, and higher order type theories. ie once you "hit a ceiling" in say simple typed, you go to a higher order? – RFV Nov 27 '21 at 22:44
  • No, every tractable, consistent theory is going to have a limit on what which total functions it is able to define/prove total, which will leave out some 'actual' total functions. For type theories, the typical example is the function that takes a representation of a closed term in the theory as a natural number, and outputs a natural number representing the normal form of the input term. This won't work for reasons similar to the second incompleteness theorem, or the halting problem. – Dan Doel Nov 27 '21 at 23:18
  • I understand, but if one wishes to express this function (in said theory), then one would create an even higher order theory to express it (and the bigger set/class of functions expressible in this new theory/language)? This higher order theory in turn would have it's own Godel statement (halting problem/second incompleteness theorem statement). Ahh and therfor you would need an infinite hierarchy of higher order theories to express ALL total functions. Is this correct? – RFV Nov 28 '21 at 11:32
  • What do you mean with "tractable"?. Tractability has to do with complexity/feasibility, not undesidability. Do you mean "complete"? – RFV Nov 28 '21 at 11:47
  • But since you can always create an even higher order "theory", one could assume that one could find the n-th higher order theory sufficient to express ANY Total function and therefor ALL total function would have some finite higher order theory to express it. Are all type theories (higher order theories) not just Type Theory point? – RFV Nov 28 '21 at 12:03
  • The point of 'tractable' was to rule out 'theories' with situations like, "for every actual/meta total function $f$, there is an object function $[f] : ℕ → ℕ$ ..." Things like that are studied, but they aren't realistic unless you already have a more tractable methodology of talking about what the 'total functions' are and how you write them down, and that is going to have its limitations. – Dan Doel Nov 28 '21 at 16:35
  • Martin-löf type theory (for example) is already "higher order," meaning it has functions of all orders. The function space is just another type, so given any type of functions $A → B$, you can specify higher order functions $(A → B) → C$. So, in order to define a function that it cannot, the theory would have to be strengthened in some other way. You could always just add whatever single total function you want, like Zhen Lin suggested. However, I think it's possible for even something like that to render a system inconsistent. – Dan Doel Nov 28 '21 at 16:41