# Confusion when composing functions in Lambda expression

$$(\lambda x. x \text{ } x ) ( \lambda x . x \text{ } x )= (\lambda x. x \text{ } x) ( \lambda x . x \text{ } x)$$

Source

I am a bit confused on how this composition was done. When I do it, I get:

$$\lambda x. (\lambda x. x \text{ } x) (\lambda x . x \text{ } x)$$

On what basis do I drop the exterior most $$\lambda x.$$?

• It's not composition - it's application. Commented Feb 19, 2023 at 18:22
• the point is that when you write a $\lambda$-term $M \ N$ the "meaning" - which can be evaluated using $\beta$-reduction - is what might be written $M(N)$ in conventional function notation, not $M \circ N$ as you've interpreted it. Commented Feb 19, 2023 at 21:55
• All this might be a bit obscured by the overuse of variable name $x$. Perhaps there would be a bit less confusion if you wrote $(\lambda x. x x)(\lambda y. y y)$ instead?
– Stef
Commented Feb 20, 2023 at 12:30

You drop the $$\lambda x$$ because that's just how beta reduction is defined: $$(\lambda v.M)(N) \triangleright_\beta M[v/N]$$. In your example, $$v$$ is $$x$$, $$M$$ is $$xx$$, and $$N$$ is $$\lambda x. xx$$.
The intuition is that once you applied the function to an argument, then the slot is filled and no longer open for substitution with yet another argument ad infinitum. The "$$\lambda x.$$" is like the "$$f(x) =$$" in something like "$$f(x) = x^2$$". Once you apply the function, $$f(2)$$, the result is equivalent to $$4$$ (the part behind the equivalence sign with $$2$$ substituted for $$x$$), and not a new function of the form $$f(x)$$.
• Or "$x \mapsto$" in "$f : x \mapsto x^2$"