23

I am reading the wikipedia page on ackermann's function, http://en.wikipedia.org/wiki/Ackermann_function

And I am having trouble understanding WHY ackermann's function is an example of a function which is not primitive recursive.

I understand that the ackermann function terminates, and thus is a total function. So why is it not primitive recursive? The only information that i can find on the wikipedia page is

[Ackermann's function] grows faster than any primitive recursive function and is therefore not primitive recursive

Which isn't a good example of why it is not primitive recursive.

Could anyone explain to me how exactly ackermann's function is NOT primitive recursive please?

Simply Beautiful Art
  • 71,916
  • 11
  • 112
  • 250
AlanFoster
  • 333
  • 1
  • 2
  • 6
  • 2
    I don't quite understand your question. It's not primitively recursive because it can't be defined using the primitively recursive operations. If you're asking for a proof of that, I don't think there's a simple one that does not use its rate of growth to proof this. – sepp2k Jan 04 '12 at 01:07
  • 2
    Alan, could you please explain why you feel that the fact that Ackermann's function "grows faster than any primitive recursive function" is not a good answer? Also, what do you mean by a "good example"? (Explaining these two things may help us figure out what kind of explanation you would find most satisfactory.) – Andrés E. Caicedo Jan 04 '12 at 23:09
  • 1
    Just saying: "it grows faster" without constraining that statement to a numeric value (like: it grows X times faster than the fastest primitive recursive function which never runs faster than Z) is a pretty vague (useless) statement – Luxspes Dec 26 '14 at 20:39

4 Answers4

19

You seem to be conflating primitive recursive functions with total recursive functions. Actually, primitive recursive are a subset of total recursive functions. The hierarchy can be described informally as follows:

  • Partial recursive functions are defined by an algorithm which only works on some inputs.
  • Total recursive functions are defined by an algorithm which works on all inputs but can take an arbitrarily long time to compute.
  • Primitive recursive functions are defined by an algorithm that completes in a knowable time (“not too long” for some theoretic definition of long).

More precisely (though I'll refer you to Wikipedia or some other reference for a complete definition), a primitive recursive function can be computed by a sequence of elementary computations where there is a way to bound the running time at every step. The only form of recursion allowed in the definition is primitive recursion, where a function calls itself on a smaller argument. All primitive recursions can be reduced to giving definitions for $f(0)$ (not involving $f$) and $f(n+1)$ as a function of $f(n)$ only.

General recursive definitions allow an extra operation: looking for the smallest $n$ that makes some property come true. In general, it's impossible to know how far you'll have to go to find such an $n$.

The definition of the Ackermann function contains the clause $A(m+1,n+1) = A(m, A(m+1, n))$. The “next” value of the function (going from $n$ to $n+1$) depends on calls with larger parameters (starting with $A(m+1,n)$). So the definition is not in primitive recursive form. It takes some work which I am not going to reproduce here, but you can show that there is no alternate presentation of the Ackermann function that uses only primitive recursion. Yet the function is well-defined, because computing $A(?,n)$ only requires computations of $A(?,n')$ with $n' < n$.

If you prefer a programming approach, recursive functions can be computed with dynamic memory allocation and while loops. Primitive recursive functions can be computed with only for loops, where the loop bound may be computed at run time but must be known when the loop starts.

7

Here's a proof showing why Ackermann's function is not primitive recursive.

The key to showing that A is not primitive recursive, is to find a properties shared by all primitive recursive functions, but not by A . One such property is in showing that A in some way ``grows'' faster than any primitive recursive function

Also, here's a proof showing that Ackermann's function is both a total function and a recursive function.

hardmath
  • 35,235
  • 19
  • 69
  • 133
Óscar López
  • 171
  • 3
  • 6
  • 1
    Just saying: "it grows faster" without constraining that statement to a numeric value (like: it grows X times faster than the fastest primitive recursive function which never runs faster than Z) is a pretty vague (useless) statement – Luxspes Dec 26 '14 at 20:35
  • @Luxspes: How is it useless? If $f(0)=0$ and $f(n)=2^{f(n-1)}$, how would you compare the growth rate of $f$ compared to $g(n)=n$? Now make $F(n)$ to be the composition of $f$ with itself $n$ times on the input $n$. How much faster does $F$ grow compared to $g$? Can you even give a number to it? Does it even matter? – Asaf Karagila Jun 13 '15 at 09:34
  • @Karagila it is useless because it is meaningless. Imagine that I defined a set of numbers (like the naturals or the irrationals) as: Those numbers that represent the difference in "growth speed" between the fastest primitive function and the slowest non primitive one... Would you be able to demonstrate anyone could find the same concrete elements inside that set? – Luxspes Jun 13 '15 at 17:09
  • 1
    @Luxspes If you read the proof linked, it's pretty clear: If $g$ is any primitive recursive function with inputs $n_1, \dotsc, n_k$ with $n = \max\{n_1, \dotsc, n_k\}$, then the Ackermann function is such that there is an $m$ large enough that for every $n$, $A(m,n)>g$. Therefore if $A$ were primitive recursive, we would have some $m$ for which $A(m,n)>A(k,n)$ for every $k$, a contradiction. This isn't a matter of a linear scaling factor: we can always double the growth rate of a primitive recursive function, so no, you cannot attach a numerical value in the way you suggest. – Morgan Rogers Oct 11 '16 at 22:47
  • 1
    @hardmath looks good, please edit it, thanks for your attention to detail! – Óscar López Feb 05 '22 at 23:52
3

The intuitive reason for why it is not primitive recursive is that it is recursing on more than one parameters, the primitive recursive functions are defined by functions recursing on only one parameter.

It is more complicated to show that a function is not a primitive recursive because we have to prove than no primitive recursive function will compute the same function, i.e. the fact that the definition of Ackermann function is not explicitly primitive recursive doesn't mean that there is no primitive recursive way of computing the same function. And the easiest way to show this cannot happen (AFAIK) is to show that it grows faster than any primitive recursive function so it cannot be one of them.

There is a hierarchy for recursive functions using recursion similar to primitive recursion but with more parameters. IIRC, Ackermann function is in the second level (taking primitive recursive functions to be the first level), i.e. can be computed by recursion on two parameters.

Kaveh
  • 3,424
  • 24
  • 37
  • The first paragraph is wrong. You can map $\mathbb{N}^k$ bijectively and primitive recursively (in both directions) to $\mathbb{N}$ so the number of parameters is not at all the point. Besides, primitive recursion is (usually) explicitly defined on arbitrarily many parameters. – Raphael Jan 15 '12 at 10:07
  • @Raphael No, both of the statements are wrong. The mapping doesn't help. If you are interested check the second chapter of the first volume of "Classical Recursion Theory". – Kaveh Jan 16 '12 at 04:31
  • 1
    I see what you mean. I did not see that you wrote "is recursing on more than one parameter". Still, I think this is not a separating criterion. 1) Primitive recursion says $g(x,y) = h(x,y,g(x,y-1))$ for any primitive recursive $h$. In particular, $h$ may recurse over any of the $x_i$; that would make $g$ recurse on multiple parameters, wouldn't it? 2) Every (partial) recursive function can be written using only on $\mu$-operator. By your reasoning, would that not imply that partial recursive functions can only recurse on one parameter, too? – Raphael Jan 16 '12 at 13:46
  • @Raphael, no, it cannot do all recursions on mutiple parameters. The well-ordering type of such recursion will be different. No, This doesn't apply for the $\mu$ operator. – Kaveh Jan 16 '12 at 20:06
  • 2
    You keep stating this, but you don't explain. After talking to others, I think what you mean is that, in my notation, $h$ may not depend on $g$, so $g$ itself does not *really* recurse over multiple parameters. Note, though, that Ackerman is "special" in that it increases recursed-over parameters; primitive recursion can never do that. So what you say is not necessarily wrong, but I claim it is not helpful in this context as it is *not* likely to help somebody struggling to understand primitive recursion. – Raphael Jan 17 '12 at 12:50
  • @Raphael, I think my answer is a reasonable answer and states that although A looks like PR it is not because it is recursive on more than one variable. The reference I mentioned explains these if you wanted to understand more. If you consider the order representing dependence of value of the function on an input on values of the function on other inputs you can see that the order-types you can get from recursion on more inputs give more order-types. These order-types are inherently related to the hierarchies of functions that I have mentioned in the answer. – Kaveh Jan 17 '12 at 23:50
  • You have made incorrect statements and I guess you are also the same user who have down-voted my answer, I replied to your comment and also give you a reference so you can look up, but it seems you didn't and in place made more incorrect statements, and now you are claiming that my answer is not useful in place of accepting that you didn't understand and your comment were incorrect. But all that is fine, I don't answer questions for votes. :) – Kaveh Jan 17 '12 at 23:54
  • You assume, and wrongly. I actually did pick up the book and skimmed the sections that seemed relevant. I could, however, not find any mention of the number of parameters a function recursed on. So maybe your reference is imprecise, or you refer to a non-trivial result, or I did not look close enough. Besides, the factual statements I made are correct but do not relate to your answer as I misunderstood it. I think I do now, as written above, and now I think your answer is (at best) not helpful for beginners (that's subjective, of course). – Raphael Jan 18 '12 at 09:49
  • By the way, you don't have to answer for votes but not considering the feedback votes give you is arrogant. The fact that you received only one upvote while another did get considerably more may signal that your answer is not as helpful as you think, which you might want to reflect upon. – Raphael Jan 18 '12 at 09:51
  • "although A looks like PR" -- I don't think it does. It does look nothing like the scheme of PR (as e.g. given in "Classical Recursion Theory"). – Raphael Jan 18 '12 at 09:52
  • @Raphael, apologies. Since the down-vote occurred around the time of your comment I thought that it was you. Sorry for the incorrect reference, you are right. It is not there. It is in the second volume, see section VIII.8, e.g. Corollary VIII.8.11. Also section VIII.9.1. ps: I do value feedback but it doesn't mean I should agree with all of them, and when I disagree it doesn't matter if I get a down-vote because of it. – Kaveh Jan 18 '12 at 19:13
  • Oh, the down-vote *was* me, although you could only have guessed. ;) Thanks for the updated reference; I will check it out (and adapt my vote if appropriate). ad ps: agreed. – Raphael Jan 18 '12 at 21:49
  • I see what you refer to now; even so, I think your first paragraph is misleading. The property you say is "intuitive" is in fact not obvious from typical definitions. That aside, I think Odifreddi committed a fallacy there. In definition VIII.9.1, he suggests that $P_1$ is proven to be equal to the set of primitive recursive functions by means of VIII.8.11. That theorem, however, only proves that not *all* functions that recurse on two parameters in a nested way are primitive recursive; in particular, it does *not* show that *no* such function is primitive recursive. Did I misunderstand? – Raphael Jan 19 '12 at 08:53
  • I checked my thoughts again and I think I reached the bottom of our misunderstanding. I read your first paragraph as "Whenever a function uses (nested) recursion on two parameters it is not primitive recursive". This is not true. True is: "Whenever a function can not be represented without (nested) recursion on two parameters it is not primitive recursive". Unfortunately, this is no good as a rule-of-thumb as you can not see very easily wether a suspicious function *can* be implemented primitive recursively. – Raphael Jan 19 '12 at 14:16
0

It seems to me that you miss to see how 'growing faster' implies 'not to be a primitive recursive'.

Let us assume that the "Ackermann's function [A] grows faster than any primitive recursive [p.r.] function". We need to prove that (therefore) A is not p.r.. Say instead it is a p.r. function, i.e. for some p.r. F: A=F (for all numbers N,M: A(N,M) = F(N,M)). Now, by assumption, for some numbers K,J, for all M>K,N>J A(M,N)>F(M,N) (this means to grow faster). So A is not F, for all p.r. F.

To conclude that there are computable function which are not p.r. you need to prove that A grows faster than any p.r. function. This I let up to you.

(note: there are a couple of nuances about what we mean by to be a primitive recursive function)

mario
  • 158
  • 6