Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is implicit recursion?

What is implicit recursion? How is it different from explicit recursion?

like image 928
StackUnderflow Avatar asked Mar 01 '23 16:03

StackUnderflow


2 Answers

I've not seen the term used often. A Google search revealed a usage in a book on the lambda calculus. That book is arguing as follows:

  1. An equation that claims to be a definition should not include the thing defined on the right-hand side. (I agree with this.)
  2. If such an equation, like

    FAC = \n. if n = 0 then 1 else n * FAC (n-1),
    

    does show up, we'll call it "implicit recursion" and say it's illegal. (I'm a bit dubious about this.)

I don't know why this term is considered useful; to me it's just another piece of terminology. The important thing is to distinguish a true mathematical definition from a recursion equation, which has to be solved. Not every recursion equation has a useful or interesting solution; for example, although the factorial function is a solution for FAC above, the only useful solution for

x = x + 1

is "bottom", which may stand for "wrong" or "undefined" or "divergence".

I think the line in the textbook is trying to distinguish between "implicit recursion" (which I would call a recursion equation or a recursive equation) and a mathematical definition that uses an explicit fixed-point operator like the Y combinator.

When it comes to practical programming languages, all this discussion is extremely academic. Programming languages are totally set up to support "implicit recursion", although explicit fixed-point combinators are also surprisingly useful.

like image 57
Norman Ramsey Avatar answered Mar 07 '23 10:03

Norman Ramsey


I've heard the terms explicit and implicit recursion to contrast recursive function definitions (explicit), eg:

sum (x:xs) = x + sum xs
sum [] = 0

With functions that use explicitly recursive functions like folds and map, (implicit), eg:

sum xs = foldr (+) 0 xs
like image 44
Zoey Hewll Avatar answered Mar 07 '23 12:03

Zoey Hewll