The -Calculus is a system for manipulating strings of symbol, similar to algebra or logic. It serves as a model of computation, and is the foundation for functional programming.

The strings are composed of parenthesis, variables, and operators.
Every computable function can be expressed in -calculus using only these three constructs:

Variables (names):
Function definitions (-abstractions):

Function calls (application): means “apply to

can be any variable or expression (abstraction or application). Random examples: , , ,

-reduction

When a function is applied to an argument, we substitute the argument for the bound variable:

“Replace all free occurrences of in with

- reduction

is the bound variable
occurrences get replaced
stays unchanged (it’s not bound by this λ)
is substituted for each

From algebra to λ-calculus

Starting with a familiar function:

Applying it to 5:

Transforming it to -calculus form:

The -reduction substitutes for every occurrence of in the function body.

Currying

Transforming a function that takes multiple arguments into a sequence of functions that each take a single argument. In -calculus, all functions technically take only one argument, so multi-argument functions are achieved through currying.

Currying in action

Let’s curry a function that adds :

Partial application

Currying enables partial application - we can apply arguments one at a time:

This creates a new function “add 5 after multiplying by 5”

Shorthand notation

Instead of writing nested lambdas, we often use shorthand:
Full form:
Shorthand:

Similarly for application:
Full form:
Shorthand:

Booleans are selectors.

In -calculus, booleans are functions that select between two options:

Or in shorthand notation:

The boolean itself acts as the conditional:

If : returns , if : returns

Example

When we apply TRUE or FALSE to two values and :

Not

Here, is expected to be a “church-encoded” boolean, and acts as a selector of the opposite argument.


And

are expected to be booleans… “if then else

Or

are expected to be booleans… “if then else