Skip to content

Lambda Syntax

Advanced Logic Notation

λ-calculus has a grammar small enough to fit on a stamp — but it reads nothing like school algebra at first. This page is the phrasebook.

The grammar, whole

term ::= x variable | λx.term abstraction (makes a function) | term term application (uses a function)

Every legal λ-term is one of those three things, built from smaller λ-terms. Nothing else exists.

Reading an abstraction

λx.x "take x, give x" — identity λx.42 "take x, give 42" — constant function λx.x x "take x, give (x applied to x)" — self-application

The λ ends at a dot: λx.M means the body is everything after the dot. So λx.x y is a function whose body is x y — it is not (λx.x) y.

The #1 misread λx.x y ≠ (λx.x) y. The first is a function (body x y). The second is the identity function applied to y — which reduces to just y. The parentheses move the whole meaning.

Application hugs left

When applications chain, they group to the left:

a b c means (a b) c never a (b c) f x y means (f x) y "f of x, then that result of y"

So λf.λx.f (f x) means: a function of f that gives a function of x that applies f twice — written with no extra ink.

Currying: functions that take one thing

λ-calculus has no multi-argument functions. It doesn't need them — a function can return a function:

λx.λy.x "take x, then (function that) takes y, give x" (λx.λy.x) a → λy.a a is captured inside (λx.λy.x) a b → (λy.a) b → a two applications, one at a time

This trick — one argument per function, nested λs for more — is called currying, after Haskell Curry. Two placeholders, one at a time.

See the structure

Every λ-term is a tree: λ nodes bind a variable, @ nodes apply, and leaves are variables. Here's (λx.λy.x) a b:

Free vs bound

Inside λx.M, every x in M is bound — owned by that λ. A variable with no λ owning it is free. In λx.x y: x is bound, y is free — it floats in from whoever wrote the term. Free variables are the inputs; bound variables are the machine's moving parts. This matters enormously on the next page, when substitution arrives.

Practice

λx.x y means…

f g h parses as…

In λx.x y, the variable y is…

Reduce by currying: (λx.λy.x) a b → ___