Jump to content

User:WillNess/Fixed-point combinator

From Wikipedia, the free encyclopedia

In combinatory logic for computer science, a fixed-point combinator (or fixpoint combinator),[1]: p.26  is a higher-order function (i.e. a function which takes a function as argument) that returns some fixed point (a value that is mapped to itself) of its argument function, if one exists.

Formally, if is a fixed-point combinator and the function has one or more fixed points, then is one of these fixed points, i.e.

Fixed-point combinators can be defined in the lambda calculus and in functional programming languages and provide a means to allow for recursive definitions, when recursion is seen as a computational step repeated an indefinite number of times – with the above equation seen as definition.

For example, a recursive definition of factorial can be seen as a repetition of the computational step performing the decision whether the received argument is a base case, where a final result is to be returned. Or it is not a base case, whereas the whole process should be repeated anew with an updated argument.

And because the argument can not be known in advance, this means that the computational step must be able to be repeated an indefinite number of times.

Y combinator in lambda calculus

[edit]

In the classical untyped lambda calculus, every function has a fixed point. A particular implementation of is Haskell Curry's paradoxical combinator Y, given by[2]: 131 [note 1][note 2]

(Here we use the standard notations and conventions of lambda calculus: Y is a function that takes one argument f and returns the entire expression following the first period; the expression denotes a function that takes one argument x, thought of as a function, and returns the expression , where denotes x applied to itself. Juxtaposition of expressions denotes function application, is left-associative, and has higher precedence than the period.)

In combinators notation, this is

                                 

Now, if

expresses a "computational step" expecting to express "the rest of computation", which decides whether to "return" right away or to perform the rest of the computation with the "updated argument value" , then in

the rest of the computation is the same as itself, which is the definition of recursion, as a process which might use itself to perform the rest of computation with an updated argument, after considering whether to stop with some base case.

And , when "called", will become , re-doing the same "function" again, with the same and the updated as arguments. Thus the fixed point for the given computational step function is the recursive function which uses itself to perform the rest of the computation, if so chooses.

  1. ^ Peyton Jones, Simon L. (1987). The Implementation of Functional Programming (PDF). Prentice Hall International.
  2. ^ Henk Barendregt (1985). The Lambda Calculus – Its Syntax and Semantics. Studies in Logic and the Foundations of Mathematics. Vol. 103. Amsterdam: North-Holland. ISBN 0444867481.


Cite error: There are <ref group=note> tags on this page, but the references will not show without a {{reflist|group=note}} template (see the help page).