1

I'm rather confused by the recursion theory.

From the link, the recursion theory was formed by Dedekind, Gödel and some other famous mathematicians. There are the following types of recursion. But where is tail recursion? can this concept parallel to these concepts? what else concept goes parallel to tail recursion?

 1.1 The Initial Functions
 1.2 Iteration
 1.3 Primitive recursion
 1.4 Primitive recursion with parameters
 1.5 Course-of-value recursion
 1.6 Double recursion
 1.7 Minimization (least search)
user3329081
  • 111
  • 1

2 Answers2

3

We need to distinguish two things:

  • Tail-calls are calls to functions that are made in tail position. Tail-recursion is a recursive tail-call.
  • Tail-call optimization is the process by which tail-calls are turned into loops or GOTOs in compilers.

The second, as others have stated, is an implementation detail that falls in the theory of compilers, and isn't really recursion theory.

However, it is absolutely possible to study tail calls in the context of computability. In particular, there is something called Continuation Passing Style.

There exist CPS-transformations which can turn any lambda-function into one in continuation passing style. So the set of languages computed using only tail-calls is equivalent to the set of recursively-enumerable languages.

CPS has many applications in the theory of programming languages, and the concept of tail recursion is useful for more than just the tail-call optimization.

Joey Eremondi
  • 30,277
  • 5
  • 67
  • 122
0

Tail recursion is a specific implementation detail. Mathematical functions are not algorithmic implementations, so the concept does not make sense.

To be precise, tail recursion is a specific optimization in which the epilogue of the caller and the prologue of the callee are ignored, by virtue of a direct transfer of execution. This is possible because the two deal with the management of the internal state of the function, and in a recursive call the caller and callee are the same function so their state will be similar. If the final state of the caller and the initial state of the callee can be linked by a relatively simple transform, such a direct transfer of execution may be more efficient than a regular function call. This is of course dependent on the execution architecture, but it is a common occurrence.

MSalters
  • 927
  • 4
  • 12