Deriving Y combinator with beta reduction
I’m preparing a step-by-step beta reduction showing how the standard Y combinator satisfies Y f = f (Y f), illustrating its role as a fixed-point operator enabling recursion without named functions.
In the untyped λ–calculus, a fixed‐point combinator is a term Fix that, when applied to any function f, gives you a value Fix f such that
[
\text{Fix}, f ;\equiv; f\bigl(\text{Fix}, f\bigr).
]
One famous example is the Y combinator. Here is how you can derive it and check that it satisfies the desired equation.
Derivation of (Y)
We want a term (Y) with the property (Y,f = f,(Y,f)). This means (Y,f) is a fixed point of (f). In other words, we want to solve the equation
[
Y f = f (Y f)
]
inside the λ–calculus without giving a name to (Y f) itself.
A standard trick is to arrange that something “calls itself.” Consider the expression ((x,x)), where (x) is a parameter; if we define a function (W \equiv \lambda x., f,(x,x)), then the self‐application (W,W) becomes (f,(W,W)). That is exactly the shape of the equation we want. Now simply encapsulate this in a λ–expression that abstracts over (f):
[
\boxed{Y ;\equiv; \lambda f.;(\lambda x., f,(x,x)),(\lambda x., f,(x,x))}
]
Checking that (Y) satisfies (Y,f = f(Y,f))
We perform a straightforward β–reduction step by step:
-
Apply (Y) to an arbitrary function (f):
[
\begin{aligned}
Y,f
&= (\lambda f.,(\lambda x.,f(x,x))(\lambda x.,f(x,x))) , f
\end{aligned}
]
-
β–reduce the outermost application ((\lambda f., \dots) applied to (f)):
[
\to (\lambda x.,f(x,x))(\lambda x.,f(x,x))
]
-
Now we have a self‐application of (\lambda x.,f(x,x)), so reduce that:
[
\begin{aligned}
(\lambda x.,f(x,x))(\lambda x.,f(x,x))
&\to f\Bigl((\lambda x.,f(x,x))(\lambda x.,f(x,x))\Bigr)
\end{aligned}
]
Here, the body of (\lambda x.,f(x,x)) is (f(x,x)), so substituting (\lambda x.,f(x,x)) for (x) gives us exactly (f((\lambda x.,f(x,x))(\lambda x.,f(x,x)))).
-
Observe that the expression inside (f(\dots)) is exactly the same self‐application we started with, which by step 2 is (Y,f). Therefore,
[
(\lambda x.,f(x,x))(\lambda x.,f(x,x)) ;=; f\Bigl((\lambda x.,f(x,x))(\lambda x.,f(x,x))\Bigr)
;;=;; f\bigl(Y,f\bigr).
]
Combining these steps, we have shown:
[
Y,f ;=; (\lambda x.,f(x,x))(\lambda x.,f(x,x)) ;=; f\bigl(Y,f\bigr).
]
Hence (Y) is a fixed–point combinator: when applied to any (f), it returns a value that is a fixed point of (f).
How this enables recursion
Using (Y), you can define recursive functions without giving them explicit names. For example, you might write a “factorial” body
[
\text{FACT} ;\equiv; \lambda rec.,\lambda n.;\text{if }(n=0)\text{ then }1 \text{ else } n \times (rec,(n-1))
]
Then the fully recursive factorial is (Y(\text{FACT})). By the above property,
[
Y(\text{FACT}) = \text{FACT}\bigl(Y(\text{FACT})\bigr),
]
so inside the definition of FACT, any call to rec is really a call to FACT’s own fixed point. This is how (Y) encodes “self‐reference” purely with higher‐order functions, allowing recursion in the λ–calculus even though you cannot give a function a name directly.
In summary, the Y combinator
[
\lambda f.,(\lambda x.,f(x,x))(\lambda x.,f(x,x))
]
indeed satisfies (Y f = f (Y f)) by β–reduction, thereby providing recursion without any named function definitions.