HOME

TheInfoList



OR:

In mathematics and
computer science Computer science is the study of computation, automation, and information. Computer science spans theoretical disciplines (such as algorithms, theory of computation, information theory, and automation) to practical disciplines (includi ...
in general, a '' fixed point'' of a function is a value that is mapped to itself by the function. In combinatory logic for
computer science Computer science is the study of computation, automation, and information. Computer science spans theoretical disciplines (such as algorithms, theory of computation, information theory, and automation) to practical disciplines (includi ...
, a fixed-point combinator (or fixpoint combinator) is a higher-order function \textsf that returns some fixed point of its argument function, if one exists. Formally, if the function ''f'' has one or more fixed points, then : \textsf\ f = f\ (\textsf\ f)\ , and hence, by repeated application, : \textsf\ f = f\ (f\ ( \ldots f\ (\textsf\ f) \ldots))\ .


Y combinator

In the classical untyped lambda calculus, every function has a fixed point. A particular implementation of fix is Curry's paradoxical combinator Y, represented by : \textsf = \lambda f. \ (\lambda x.f\ (x\ x))\ (\lambda x.f\ (x\ x))\ .Throughout this article, the syntax rules given in Lambda calculus#Notation are used, to save parentheses.For an arbitrary lambda term ''f'', the fixed-point property can be validated by beta reducing the left- and the right-hand side: where \equiv and \to denote syntactic equality by definition and beta reduction, respectively. Similarly to the first two steps, one obtains Since both terms \textsf\ f and f\ (\textsf\ f) could be reduced to the same term, they are equal. In
functional programming In computer science, functional programming is a programming paradigm where programs are constructed by applying and composing functions. It is a declarative programming paradigm in which function definitions are trees of expressions that ...
, the Y combinator can be used to formally define recursive functions in a programming language that does not support recursion. This combinator may be used in implementing
Curry's paradox Curry's paradox is a paradox in which an arbitrary claim ''F'' is proved from the mere existence of a sentence ''C'' that says of itself "If ''C'', then ''F''", requiring only a few apparently innocuous logical deduction rules. Since ''F'' is arbi ...
. The heart of Curry's paradox is that untyped lambda calculus is unsound as a deductive system, and the Y combinator demonstrates this by allowing an anonymous expression to represent zero, or even many values. This is inconsistent in mathematical logic. Applied to a function with one variable, the Y combinator usually does not terminate. More interesting results are obtained by applying the Y combinator to functions of two or more variables. The second variable may be used as a counter, or index. The resulting function behaves like a ''while'' or a ''for'' loop in an imperative language. Used in this way, the Y combinator implements simple recursion. In the lambda calculus it is not possible to refer to the definition of a function in a function body. Recursion may only be achieved by obtaining the function passed in as a parameter. The Y combinator demonstrates this style of programming. An example implementation of Y combinator in two languages in presented below. # Y Combinator in Python def Y(f): (lambda x: f(x(x)))(lambda x: f(x(x))) Y(Y) // Y Combinator in C++ int main()


Fixed-point combinator

The Y combinator is an implementation of a fixed-point combinator in lambda calculus. Fixed-point combinators may also be easily defined in other functional and imperative languages. The implementation in lambda calculus is more difficult due to limitations in lambda calculus. The fixed-point combinator may be used in a number of different areas: * General mathematics * Untyped lambda calculus *
Typed lambda calculus A typed lambda calculus is a typed formalism that uses the lambda-symbol (\lambda) to denote anonymous function abstraction. In this context, types are usually objects of a syntactic nature that are assigned to lambda terms; the exact nature of a ...
*
Functional programming In computer science, functional programming is a programming paradigm where programs are constructed by applying and composing functions. It is a declarative programming paradigm in which function definitions are trees of expressions that ...
*
Imperative programming In computer science, imperative programming is a programming paradigm of software that uses statements that change a program's state. In much the same way that the imperative mood in natural languages expresses commands, an imperative program ...
Fixed-point combinators may be applied to a range of different functions, but normally will not terminate unless there is an extra parameter. When the function to be fixed refers to its parameter, another call to the function is invoked, so the calculation never gets started. Instead, the extra parameter is used to trigger the start of the calculation. The type of the fixed point is the return type of the function being fixed. This may be a real or a function or any other type. In the untyped lambda calculus, the function to apply the fixed-point combinator to may be expressed using an encoding, like
Church encoding In mathematics, Church encoding is a means of representing data and operators in the lambda calculus. The Church numerals are a representation of the natural numbers using lambda notation. The method is named for Alonzo Church, who first encoded da ...
. In this case particular lambda terms (which define functions) are considered as values. "Running" (beta reducing) the fixed-point combinator on the encoding gives a lambda term for the result which may then be interpreted as fixed-point value. Alternately, a function may be considered as a lambda term defined purely in lambda calculus. These different approaches affect how a mathematician and a programmer may regard a fixed-point combinator. A lambda calculus mathematician may see the ''Y'' combinator applied to a function as being an expression satisfying the fixed-point equation, and therefore a solution. In contrast, a person only wanting to apply a fixed-point combinator to some general programming task may see it only as a means of implementing recursion.


Values and domains

Every expression has one value. This is true in general mathematics and it must be true in lambda calculus. This means that in lambda calculus, applying a fixed-point combinator to a function gives you an expression whose value is the fixed point of the function. However, this is a value in the lambda calculus domain, it may not correspond to any value in the domain of the function, so in a practical sense it is not necessarily a fixed point of the function, and only in the lambda calculus domain is it a fixed point of the equation. For example, consider : x^2 = -1 \Rightarrow x = \frac \Rightarrow f\ x = \frac \land \mathsf Y\ f = x
Division Division or divider may refer to: Mathematics *Division (mathematics), the inverse of multiplication *Division algorithm, a method for computing the result of mathematical division Military *Division (military), a formation typically consisting ...
of signed numbers may be implemented in the Church encoding, so ''f'' may be represented by a lambda term. This equation has no solution in the real numbers. But in the domain of the
complex number In mathematics, a complex number is an element of a number system that extends the real numbers with a specific element denoted , called the imaginary unit and satisfying the equation i^= -1; every complex number can be expressed in the fo ...
s ''i'' and -''i'' are solutions. This demonstrates that there may be solutions to an equation in another domain. However, the lambda term for the solution for the above equation is weirder than that. The lambda term \mathsf Y\ f represents the state where x could be either ''i'' or -''i'', as one value. The information distinguishing these two values has been lost, in the change of domain. Note that this may still be represented as a single value, if the logic is expanded to be
paraconsistent A paraconsistent logic is an attempt at a logical system to deal with contradictions in a discriminating way. Alternatively, paraconsistent logic is the subfield of logic that is concerned with studying and developing "inconsistency-tolerant" syste ...
. For the lambda calculus mathematician, this is a consequence of the definition of lambda calculus. For the programmer, it means that the beta reduction of the lambda term will loop forever, never reaching a normal form.


Function versus implementation

The fixed-point combinator may be defined in mathematics and then implemented in other languages. General mathematics defines a function based on its
extensional In any of several fields of study that treat the use of signs — for example, in linguistics Linguistics is the science, scientific study of human language. It is called a scientific study because it entails a comprehensive, systematic, obj ...
properties. That is, two functions are equal if they perform the same mapping. Lambda calculus and programming languages regard function identity as an intensional property. A function's identity is based on its implementation. A lambda calculus function (or term) is an implementation of a mathematical function. In the lambda calculus there are a number of combinators (implementations) that satisfy the mathematical definition of a fixed-point combinator.


Definition of the term "combinator"

Combinatory logic is a higher-order functions theory. A combinator is a ''closed'' lambda expression, meaning that it has no free variables. The combinators may be combined to direct values to their correct places in the expression without ever naming them as variables.


Usage in programming

Fixed-point combinators can be used to implement
recursive definition In mathematics and computer science, a recursive definition, or inductive definition, is used to define the elements in a set in terms of other elements in the set ( Aczel 1977:740ff). Some examples of recursively-definable objects include facto ...
of functions. However, they are rarely used in practical programming. Strongly normalizing
type system In computer programming, a type system is a logical system comprising a set of rules that assigns a property called a type to every "term" (a word, phrase, or other set of symbols). Usually the terms are various constructs of a computer progr ...
s such as the
simply typed lambda calculus The simply typed lambda calculus (\lambda^\to), a form of type theory, is a typed interpretation of the lambda calculus with only one type constructor (\to) that builds function types. It is the canonical and simplest example of a typed lambda c ...
disallow non-termination and hence fixed-point combinators often cannot be assigned a type or require complex type system features. Furthermore fixed-point combinators are often inefficient compared to other strategies for implementing recursion, as they require more function reductions and construct and take apart a tuple for each group of mutually recursive definitions.


The factorial function

The factorial function provides a good example of how the fixed-point combinator may be applied. The result demonstrates simple recursion, as would be implemented in a single loop in an imperative language. The definition of numbers used is explained in
Church encoding In mathematics, Church encoding is a means of representing data and operators in the lambda calculus. The Church numerals are a representation of the natural numbers using lambda notation. The method is named for Alonzo Church, who first encoded da ...
. The function taking itself as a parameter is : F\ f\ n = (\operatorname\ n)\ 1\ (\operatorname\ n\ (f\ (\operatorname\ n)))\ . This gives ''Y F n'' as : \begin \textsf\ F\ n &= F\ (\textsf\ F)\ n \\ &= (\operatorname\ n)\ 1\ (\operatorname\ n\ ((\textsf\ F)\ (\operatorname\ n)))\ .\end Setting \textsf\ F = \operatorname gives : \operatorname\ n = (\operatorname\ n)\ 1\ (\operatorname\ n\ (\operatorname\ (\operatorname\ n)))\ . This definition puts ''F'' in the role of the body of a loop to be iterated, and is equivalent to the mathematical definition of factorial: : \operatorname\ n = \begin 1 & \text ~ n = 0 \\ n \times \operatorname \ (n - 1) & \text \end


Fixed-point combinators in lambda calculus

The ''Y'' combinator, discovered by Haskell B. Curry, is defined as : Y = \lambda f.(\lambda x.f\ (x\ x)) \ (\lambda x.f\ (x\ x))\ .
Beta reduction Lambda calculus (also written as ''λ''-calculus) is a formal system in mathematical logic for expressing computation based on function abstraction and application using variable binding and substitution. It is a universal model of computation tha ...
of this gives: Repeatedly applying this equality gives: : Y\ g = g\ (Y\ g) = g\ (g\ (Y\ g)) = g\ (\ldots g\ (Y\ g) \ldots) (The equality above should be thought of as a sequence of multi-step β-reductions from left to right. The lambda term g\ (Y\ g) may not, in general, β-reduce to the term Y\ g. One can interpret the equality signs as β-equivalences instead of multi-step β-reductions to allow for going in both directions.)


Equivalent definition of a fixed-point combinator

This fixed-point combinator may be defined as ''y'', as in : x = f\ x \land y\ f = x An expression for y may be derived using rules from the definition of a let expression. Firstly, using the rule : (\exists x E \land F) \iff \operatorname x : E \operatorname F gives : \operatorname x = f\ x \operatorname y\ f = x\ . Also, using : x \not \in \operatorname(E) \land x \in \operatorname(F) \to \operatorname x : G \operatorname E\ F = E\ (\operatorname x : G \operatorname F) gives : y\ f = \operatorname x = f\ x \operatorname x\ . And then using the eta reduction rule, : f\ x = y \iff f = \lambda x.y\ , gives : y = \lambda f.\operatorname x = f\ x \operatorname x\ .


Derivation of the Y combinator

Curry's Y combinator may be readily obtained from the definition of ''y''. Starting with, : \lambda f.\operatorname x = f\ x \operatorname x\ , A lambda abstraction does not support reference to the variable name, in the applied expression, so ''x'' must be passed in as a parameter to ''x''. We can think of this as replacing ''x'' by ''x x'', but formally this is not correct. Instead defining ''y'' by \forall z, y\ z = x gives : \lambda f.\operatorname y\ z = f\ (y\ z) \operatorname y\ z\ . The let expression may be regarded as the definition of the function ''y'', where ''z'' is the parameter. Instantiation ''z'' as ''y'' in the call gives : \lambda f.\operatorname y\ z = f\ (y\ z) \operatorname y\ y\ . And, because the parameter ''z'' always passes the function ''y'', : \lambda f.\operatorname y\ z = f\ (z\ z) \operatorname y\ y\ . Using the eta reduction rule, : f\ x = y \equiv f = \lambda x.y\ , gives : \lambda f.\operatorname y = \lambda z.f\ (z\ z) \operatorname y\ y\ . A let expression may be expressed as a lambda abstraction; using : n \not \in FV(E) \to (\operatorname n = E \operatorname L \equiv (\lambda n.L)\ E) gives : \lambda f.(\lambda y.y\ y)\ (\lambda z.f\ (z\ z))\ . This is possibly the simplest implementation of a fixed-point combinator in lambda calculus. However, one beta reduction gives the more symmetrical form of Curry's Y combinator: : \lambda f.(\lambda z.f\ (z\ z))\ (\lambda z.f\ (z\ z))\ . See also Translating between let and lambda expressions.


Other fixed-point combinators

In untyped lambda calculus fixed-point combinators are not especially rare. In fact there are infinitely many of them. In 2005 Mayer Goldberg showed that the set of fixed-point combinators of untyped lambda calculus is
recursively enumerable In computability theory, a set ''S'' of natural numbers is called computably enumerable (c.e.), recursively enumerable (r.e.), semidecidable, partially decidable, listable, provable or Turing-recognizable if: *There is an algorithm such that the ...
.Goldberg, 2005 The ''Y'' combinator can be expressed in the SKI-calculus as : Y = S (K (S I I)) (S (S (K S) K) (K (S I I)))\ . The simplest fixed-point combinator in the SK-calculus, found by
John Tromp John Tromp is a Dutch computer scientist. He formerly worked for Dutch Centre for Mathematics and Computer Science. Tromp discovered the number of legal states of the board game Go (game), Go, and co-authored with Bill Taylor the Rules of Go#Basic ...
, is : Y' = S S K (S (K (S S (S (S S K)))) K)\ . although note that it is not in normal form, which is longer. This combinator corresponds to the lambda expression : Y' = (\lambda x y. x y x) (\lambda y x. y (x y x))\ . The following fixed-point combinator is simpler than the Y combinator, and β-reduces into the Y combinator; it is sometimes cited as the Y combinator itself: : X = \lambda f.(\lambda x.x x) (\lambda x.f (x x))\ . Another common fixed-point combinator is the Turing fixed-point combinator (named after its discoverer,
Alan Turing Alan Mathison Turing (; 23 June 1912 – 7 June 1954) was an English mathematician, computer scientist, logician, cryptanalyst, philosopher, and theoretical biologist. Turing was highly influential in the development of theoretical co ...
): : \Theta = (\lambda x y. y (x x y))\ (\lambda x y. y (x x y))\ . Its advantage over \textsf is that \Theta\ f beta-reduces to f\ (\Theta f), whereas \textsf\ f and f\ (\textsf f) only beta-reduce to a common term. \Theta also has a simple call-by-value form: : \Theta_ = (\lambda x y. y (\lambda z. x x y z))\ (\lambda x y. y (\lambda z. x x y z))\ . The analog for
mutual recursion In mathematics and computer science, mutual recursion is a form of recursion where two mathematical or computational objects, such as functions or datatypes, are defined in terms of each other. Mutual recursion is very common in functional progra ...
is a ''polyvariadic fix-point combinator'', which may be denoted Y*.


Strict fixed-point combinator

In a strict programming language the Y combinator will expand until stack overflow, or never halt in case of tail call optimization. The ''Z'' combinator will work in strict languages (also called eager languages, where applicative evaluation order is applied). The ''Z'' combinator has the next argument defined explicitly, preventing the expansion of ''Z'' g in the right-hand side of the definition: : Z g v = g (Z g) v\ . and in lambda calculus it is an eta-expansion of the ''Y'' combinator: : Z = \lambda f.(\lambda x.f (\lambda v.x x v)) \ (\lambda x.f (\lambda v.x x v))\ .


Non-standard fixed-point combinators

In untyped lambda calculus there are terms that have the same
Böhm tree In the study of denotational semantics of the lambda calculus, Böhm trees, Lévy-Longo trees, and Berarducci trees are (potentially infinite) tree-like mathematical objects that capture the "meaning" of a term up to some set of "meaningless" ter ...
as a fixed-point combinator, that is they have the same infinite extension λx.x (x (x ... )). These are called ''non-standard fixed-point combinators''. Any fixed-point combinator is also a non-standard one, but not all non-standard fixed-point combinators are fixed-point combinators because some of them fail to satisfy the equation that defines the "standard" ones. These strange combinators are called ''strictly non-standard fixed-point combinators''; an example is the following combinator: : N = B M (B (B M) B) where : B = \lambda x y z.x (y z) : M = \lambda x.x x\ . The set of non-standard fixed-point combinators is not recursively enumerable.


Implementation in other languages

(The Y combinator is a particular implementation of a fixed-point combinator in lambda calculus. Its structure is determined by the limitations of lambda calculus. It is not necessary or helpful to use this structure in implementing the fixed-point combinator in other languages.) Simple examples of fixed-point combinators implemented in some
programming paradigm Programming paradigms are a way to classify programming languages based on their features. Languages can be classified into multiple paradigms. Some paradigms are concerned mainly with implications for the execution model of the language, suc ...
s are given below.


Lazy functional implementation

In a language that supports
lazy evaluation In programming language theory, lazy evaluation, or call-by-need, is an evaluation strategy which delays the evaluation of an expression until its value is needed ( non-strict evaluation) and which also avoids repeated evaluations (sharing). The ...
, like in
Haskell Haskell () is a general-purpose, statically-typed, purely functional programming language with type inference and lazy evaluation. Designed for teaching, research and industrial applications, Haskell has pioneered a number of programming lan ...
, it is possible to define a fixed-point combinator using the defining equation of the fixed-point combinator which is conventionally named fix. Since Haskell has lazy datatypes, this combinator can also be used to define fixed points of data constructors (and not only to implement recursive functions). The definition is given here, followed by some usage examples. In Hackage, the original sample is: fix, fix' :: (a -> a) -> a fix f = let x = f x in x -- Lambda dropped. Sharing. -- Original definition in Data.Function. -- alternative: fix' f = f (fix' f) -- Lambda lifted. Non-sharing. fix (\x -> 9) -- this evaluates to 9 fix (\x -> 3:x) -- evaluates to the lazy infinite list ,3,3,... fact = fix fac -- evaluates to the factorial function where fac f 0 = 1 fac f x = x * f (x-1) fact 5 -- evaluates to 120


Strict functional implementation

In a strict functional language, the argument to ''f'' is expanded beforehand, yielding an infinite call sequence, : f\ (f ... (f\ (\mathsf\ f))... )\ x. This may be resolved by defining fix with an extra parameter. let rec fix f x = f (fix f) x (* note the extra x; here fix f = \x-> f (fix f) x *) let factabs fact = function (* factabs has extra level of lambda abstraction *) 0 -> 1 , x -> x * fact (x-1) let _ = (fix factabs) 5 (* evaluates to "120" *)


Imperative language implementation

This example is a slightly interpretive implementation of a fixed-point combinator. A class is used to contain the ''fix'' function, called ''fixer''. The function to be fixed is contained in a class that inherits from fixer. The ''fix'' function accesses the function to be fixed as a virtual function. As for the strict functional definition, ''fix'' is explicitly given an extra parameter ''x'', which means that lazy evaluation is not needed. template class fixer ; class fact : public fixer ; long result = fact().fix(5); In an imperative-functional language, such as Lisp, Scheme, or Racket, Landin (1963) suggests the use of a variable assignment to create a fixed-point combinator: (define Y! (lambda (f-maker) ((lambda (f) (set! f (f-maker (lambda (x) (f x)))) ;; assignment statement f) 'NONE))) Using a lambda calculus with axioms for assignment statements, it can be shown that Y! satisfies the same fixed-point law as the call-by-value Y combinator: : (\textsf_!\ \lambda x.e) e' = (\lambda x.e)\ (\textsf_!\ \lambda x.e) e'


Typing

In
System F System F (also polymorphic lambda calculus or second-order lambda calculus) is a typed lambda calculus that introduces, to simply typed lambda calculus, a mechanism of universal quantification over types. System F formalizes parametric polymorph ...
(polymorphic lambda calculus) a polymorphic fixed-point combinator has type; : ∀a.(a → a) → a where ''a'' is a type variable. That is, ''fix'' takes a function, which maps a → a and uses it to return a value of type a. In the simply typed lambda calculus extended with
recursive data type In computer programming languages, a recursive data type (also known as a recursively-defined, inductively-defined or inductive data type) is a data type for values that may contain other values of the same type. Data of recursive types are usuall ...
s, fixed-point operators can be written, but the type of a "useful" fixed-point operator (one whose application always returns) may be restricted. In the
simply typed lambda calculus The simply typed lambda calculus (\lambda^\to), a form of type theory, is a typed interpretation of the lambda calculus with only one type constructor (\to) that builds function types. It is the canonical and simplest example of a typed lambda c ...
, the fixed-point combinator Y cannot be assigned a type because at some point it would deal with the self-application sub-term x~x by the application rule: : \over where x has the infinite type t_1 = t_1\to t_2. No fixed-point combinator can in fact be typed; in those systems, any support for recursion must be explicitly added to the language.


Type for the Y combinator

In programming languages that support
recursive data type In computer programming languages, a recursive data type (also known as a recursively-defined, inductively-defined or inductive data type) is a data type for values that may contain other values of the same type. Data of recursive types are usuall ...
s, it is possible to type the Y combinator by appropriately accounting for the recursion at the type level. The need to self-apply the variable x can be managed using a type (Rec a), which is defined so as to be isomorphic to (Rec a -> a). For example, in the following Haskell code, we have In and out being the names of the two directions of the isomorphism, with types: In :: (Rec a -> a) -> Rec a out :: Rec a -> (Rec a -> a) which lets us write: newtype Rec a = In y :: (a -> a) -> a y = \f -> (\x -> f (out x x)) (In (\x -> f (out x x))) Or equivalently in OCaml: type 'a recc = In of ('a recc -> 'a) let out (In x) = x let y f = (fun x a -> f (out x x) a) (In (fun x a -> f (out x x) a)) Alternatively: let y f = (fun x -> f (fun z -> out x x z)) (In (fun x -> f (fun z -> out x x z)))


General information

Because fixed-point combinators can be used to implement recursion, it is possible to use them to describe specific types of recursive computations, such as those in
fixed-point iteration In numerical analysis, fixed-point iteration is a method of computing fixed points of a function. More specifically, given a function f defined on the real numbers with real values and given a point x_0 in the domain of f, the fixed-point itera ...
,
iterative method In computational mathematics, an iterative method is a mathematical procedure that uses an initial value to generate a sequence of improving approximate solutions for a class of problems, in which the ''n''-th approximation is derived from the pr ...
s,
recursive join The recursive join is an operation used in relational databases, also sometimes called a "fixed-point join". It is a compound operation that involves repeating the join operation, typically accumulating more records each time, until a repetition ma ...
in relational databases, data-flow analysis, FIRST and FOLLOW sets of non-terminals in a context-free grammar,
transitive closure In mathematics, the transitive closure of a binary relation on a set is the smallest relation on that contains and is transitive. For finite sets, "smallest" can be taken in its usual sense, of having the fewest related pairs; for infinite ...
, and other types of closure operations. A function for which ''every'' input is a fixed point is called an
identity function Graph of the identity function on the real numbers In mathematics, an identity function, also called an identity relation, identity map or identity transformation, is a function that always returns the value that was used as its argument, un ...
. Formally: : \forall x (f\ x = x) In contrast to universal quantification over all x, a fixed-point combinator constructs ''one'' value that is a fixed point of f. The remarkable property of a fixed-point combinator is that it constructs a fixed point for an ''arbitrary given'' function f. Other functions have the special property that, after being applied once, further applications don't have any effect. More formally: : \forall x (f\ (f\ x) = f\ x) Such functions are called
idempotent Idempotence (, ) is the property of certain operations in mathematics and computer science whereby they can be applied multiple times without changing the result beyond the initial application. The concept of idempotence arises in a number of pl ...
(see also
Projection (mathematics) In mathematics, a projection is a mapping of a set (or other mathematical structure) into a subset (or sub-structure), which is equal to its square for mapping composition, i.e., which is idempotent. The restriction to a subspace of a projecti ...
). An example of such a function is the function that returns ''0'' for all even integers, and ''1'' for all odd integers. In lambda calculus, from a computational point of view, applying a fixed-point combinator to an identity function or an idempotent function typically results in non-terminating computation. For example, we obtain : (Y \ \lambda x.x) = (\lambda x.(xx) \ \lambda x.(xx)) where the resulting term can only reduce to itself and represents an infinite loop. Fixed-point combinators do not necessarily exist in more restrictive models of computation. For instance, they do not exist in
simply typed lambda calculus The simply typed lambda calculus (\lambda^\to), a form of type theory, is a typed interpretation of the lambda calculus with only one type constructor (\to) that builds function types. It is the canonical and simplest example of a typed lambda c ...
. The Y combinator allows
recursion Recursion (adjective: ''recursive'') occurs when a thing is defined in terms of itself or of its type. Recursion is used in a variety of disciplines ranging from linguistics to logic. The most common application of recursion is in mathemati ...
to be defined as a set of rewrite rules, without requiring native recursion support in the language. "More generally, Y gives us a way to get recursion in a programming language that supports first-class functions but that doesn't have recursion built in to it." In programming languages that support anonymous functions, fixed-point combinators allow the definition and use of anonymous recursive functions, i.e. without having to
bind BIND () is a suite of software for interacting with the Domain Name System (DNS). Its most prominent component, named (pronounced ''name-dee'': , short for ''name daemon''), performs both of the main DNS server roles, acting as an authoritative ...
such functions to identifiers. In this setting, the use of fixed-point combinators is sometimes called ''
anonymous recursion In computer science, anonymous recursion is recursion which does not explicitly call a function by name. This can be done either explicitly, by using a higher-order function – passing in a function as an argument and calling it – or implicitly ...
''.This terminology appears to be largely
folklore Folklore is shared by a particular group of people; it encompasses the traditions common to that culture, subculture or group. This includes oral traditions such as tales, legends, proverbs and jokes. They include material culture, ranging ...
, but it does appear in the following: * Trey Nash, ''Accelerated C# 2008'', Apress, 2007, , p. 462—463. Derived substantially fro
Wes Dyer
s blog (see next item). * Wes Dye
Anonymous Recursion in C#
February 02, 2007, contains a substantially similar example found in the book above, but accompanied by more discussion.
The If Work
Deriving the Y combinator
January 10th, 2008


See also

* Anonymous function *
Fixed-point iteration In numerical analysis, fixed-point iteration is a method of computing fixed points of a function. More specifically, given a function f defined on the real numbers with real values and given a point x_0 in the domain of f, the fixed-point itera ...
* Lambda calculus#Recursion and fixed points *
Lambda lifting Lambda lifting is a meta-process that restructures a computer program so that functions are defined independently of each other in a global scope. An individual "lift" transforms a local function into a global function. It is a two step process ...
* Let expression


Notes


References

* Werner Kluge, ''Abstract computing machines: a lambda calculus perspective'', Springer, 2005, , pp. 73–77 * Mayer Goldberg, (2005)
On the Recursive Enumerability of Fixed-Point Combinators
', BRICS Report RS-05-1, University of Aarhus *
Matthias Felleisen Matthias Felleisen is a German-American computer science professor and author. He grew up in Germany and immigrated to the US when he was 21 years old. He received his PhD from Indiana University under the direction of Daniel P. Friedman. Afte ...

A Lecture on the ''Why'' of ''Y''


External links



Manfred von Thun, (2002 or earlier)
The Lambda Calculus - notes by Don Blaheta, October 12, 2000



"A Use of the Y Combinator in Ruby"



Rosetta code - Y combinator
{{DEFAULTSORT:Fixed Point Combinator Combinatory logic Fixed points (mathematics) Lambda calculus Mathematics of computing Recursion