Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

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?

share|improve this question

migrated from stackoverflow.com Jan 4 '12 at 22:37

This question came from our site for professional and enthusiast programmers.

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 4 '12 at 1: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.) –  Andres Caicedo Jan 4 '12 at 23:09
add comment

3 Answers 3

up vote 9 down vote accepted

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.

share|improve this answer
add comment

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.

share|improve this answer
add comment

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.

share|improve this answer
    
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 4: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
show 9 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.