Lambda Calculus Fundamentals
Lambda Calculus: Functions, Computation, Types, and Logic
The basic idea
The lambda calculus is a formal system for describing functions and computation. It uses a very small set of syntactic forms and one central computation rule, yet it can express any computation that can be performed by a Turing machine. This makes it a foundational model for studying programming languages and computation mathematically.
The basic forms of an untyped lambda calculus are:
Variables, such as x or y.
Lambda abstractions, which define functions.
Applications, which apply a function to an argument.
The calculus has no built-in numbers, booleans, loops, or data structures. Instead, these can be represented using functions.
The lambda calculus is a minimal language of functions: its simplicity makes it useful for reasoning about what computation is, even though writing practical programs directly in it can be cumbersome.
Functions and variables
A function can be understood as a mapping from inputs to outputs. For example, a function that squares its input maps 2 to 4, 3 to 9, and so on. Instead of listing every input and its output, the function can be described using an arbitrary variable:
Here, x stands for any input. The specific symbol chosen for the variable does not change the function. These expressions describe the same function:
The variable is a placeholder for the function’s input.
Alpha equivalence and alpha conversion
Two lambda expressions are alpha equivalent when they differ only in the name of a bound input variable. For example, the functions that square x, y, or another variable are alpha equivalent, provided the variable is renamed consistently within the function.
The process of changing a bound variable’s name is called alpha conversion. Renaming must preserve which occurrences refer to the function’s input. It changes notation, not behavior.
Lambda abstractions
Lambda calculus uses a compact notation to define functions. A function that takes input x and produces output m is written:
The symbol λ marks the beginning of a function definition.
The variable immediately after it, x, is the function’s input.
The dot separates the input variable from the function’s body, m.
The body describes the result produced by the function.
For example, a function that adds 1 to its input is:
A function written this way is called a lambda abstraction. Its body can contain the input variable, other variables, or other lambda expressions.
Function application and beta reduction
A function becomes useful when it is applied to an argument. Application is written by placing the argument to the right of the function:
Applying the function means substituting the argument 3 for the input variable x wherever x occurs in the function’s body. This produces 3+1, which evaluates to 4.
The general computation rule is:
Here, m[x:=n] means “the expression m with n substituted for x.” The arrow labeled β indicates that a beta reduction has taken place.
For example:
Beta reduction is the central computation rule of the lambda calculus: applying a function substitutes its argument into the function’s body.
Higher-order functions and multiple inputs
Lambda abstractions take one input at a time. This does not prevent the calculus from representing functions that behave as though they take multiple inputs. The key is that a function can return another function.
A higher-order function is a function that can take functions as inputs, return functions as outputs, or both. This ability is central to the expressive power of the lambda calculus.
Currying
Consider a function that first takes x and returns a new function. The new function takes y and produces x+y:
Applying this function to 1 gives a function that adds 1 to its next input:
Applying the result to 2 gives:
The two arguments are supplied sequentially. More generally, applying λx.λy.m to a and then b substitutes a for x and b for y:
Representing a multi-input function as a chain of one-input functions is called currying, named after the logician Haskell Curry. In a curried function, supplying the first argument produces a function that is still waiting for the next argument.
Representing booleans and conditionals
Because the basic calculus has no built-in boolean values, truth and falsity can be represented by functions.
Define true to select its first argument:
Define false to select its second argument:
A conditional can then be represented as:
This function takes three inputs:
A boolean b.
A result to use when the boolean is true, x.
A result to use when the boolean is false, y.
The boolean chooses between the two possible results.
Evaluating a conditional with true
Applying the conditional to true, m, and n gives:
The true encoding selects its first argument, so the result is m.
Evaluating a conditional with false
Applying the conditional to false, m, and n gives:
The false encoding selects its second argument, so the result is n.
The representations may look unlike ordinary boolean values, but their behavior gives them the role of truth values. A function such as logical negation can be written in terms of the encoded concepts:
It swaps true and false.
Expressiveness and the Church–Turing thesis
The untyped lambda calculus has only variables, abstractions, applications, and beta reduction. Despite this, it can represent computation as powerful as that of a Turing machine. This is one form of the connection associated with the Church–Turing thesis: the lambda calculus and Turing machines capture the same broad class of effectively computable procedures.
This does not mean that every practical programming feature appears as a built-in construct. Rather, features such as numbers, booleans, conditionals, recursion, and data structures can be encoded from the calculus’s basic forms. The calculus is therefore computationally powerful but often inconvenient for direct, everyday programming.
Encodings and abstraction
Once a feature has been defined as an encoding, it can be treated as a meaningful object without repeatedly expanding its low-level definition. For instance, after defining booleans and conditionals, a programmer can reason about an expression as an if statement rather than tracing every beta reduction that implements it.
This separation between a feature’s representation and its use is an important programming idea: an implementation can be detailed while the interface presented to the programmer remains simple.
Types and the simply typed lambda calculus
In the untyped calculus, any expression can be applied to any other expression, even if the result is meaningless. For example, applying a boolean operation to a number may produce an expression that has no sensible interpretation.
A type system attaches labels to expressions to describe what kinds of values they represent and restricts how those expressions can be used. The simply typed lambda calculus commonly begins with basic types such as:
bool for boolean values.
num for numeric values.
A type is written after an expression with a colon. For example:
This says that the encoded value true has boolean type.
Function types
If a function takes an input of type A and returns an output of type B, its type is written:
For example, a function that takes a boolean and returns a boolean has type:
The type of a lambda abstraction includes the type of its input. A typed function can be written with the input type beside its variable, as in:
This function takes a boolean and returns a boolean, so it has type bool→bool.
Type checking prevents invalid applications
A typed function can be applied only to an argument with the input type it requires. Since the not function expects a boolean, applying it to a number is rejected:
The input type required by
notis bool.The type of a numeric input is num.
Since these types do not match, the application is not allowed.
Type checking prevents many nonsensical expressions from being formed. It does not make every program meaningful or correct, but it rules out classes of errors before evaluation.
The simply typed lambda calculus is the lambda calculus equipped with this basic type discipline. Its explicit types resemble those in statically typed languages such as C or Java. The underlying lambda calculus was developed by Alonzo Church in the 1930s and 1940s, before programming languages and computer science had been formally established as modern disciplines.
The Curry–Howard correspondence: types as propositions
Types can be interpreted not only as classifications of program values but also as propositions—statements that may be provable. Under this interpretation:
A type represents a proposition.
A term of that type represents a proof of the proposition.
Constructing a term of a type corresponds to constructing a proof of the associated statement.
For example, if A is a type interpreted as a proposition, then a term of type A can be understood as evidence that A is true. If no term can be constructed, then the proposition has no proof in the system. This means “unprovable in the system,” not necessarily false in every possible interpretation.
Function types correspond to implication
The function type A→B corresponds to the logical proposition “if A, then B,” written A⇒B.
A function of type A→B can be viewed as a method for transforming evidence of A into evidence of B. If a proof of A is supplied to that function, its output is a proof of B.
For example, let:
A mean “it is raining.”
B mean “the ground is wet.”
Then A⇒B means “if it is raining, then the ground is wet.” A proof of this implication can be represented by a function that takes evidence that it is raining and returns evidence that the ground is wet.
Function application corresponds to modus ponens
In logic, modus ponens is the rule that from A and A⇒B, one may conclude B.
The typed lambda calculus represents this directly:
Suppose there is a term n of type A.
Suppose there is a function f of type A→B.
Applying f to n produces a term of type B.
Thus, applying a function to an argument mirrors using an implication together with its premise to derive a conclusion.
The relationship between types and propositions, and between programs and proofs, is called the Curry–Howard correspondence.
Proof assistants and formal verification
A programming language designed around the Curry–Howard correspondence can be used to express mathematical propositions and construct proofs as programs. A proof assistant checks whether the constructed term has the required type. If it does, the proof satisfies the system’s formal rules.
A proof assistant is software that supports the creation and checking of formal proofs. In this approach:
A theorem is represented by a type.
A proof is represented by a term of that type.
Type checking verifies that the term is a valid proof according to the formal system.
This provides a way to verify mathematical arguments and computational constructions rigorously. A proof assistant can confirm that a proof is well-formed within its logic, though the result still depends on the correctness of the system and its foundations.
Why the lambda calculus matters
The lambda calculus is not generally convenient as a standalone language for ordinary software development. Simple features often require elaborate encodings. Its importance lies instead in what its simplicity makes possible:
It provides a precise mathematical account of functions and computation.
It shows how rich computational behavior can arise from a small number of rules.
It offers a framework for reasoning about programs and programming-language design.
With types, it connects program construction to logical proof construction.
It underlies ideas used in functional programming and formal verification.
The lambda calculus demonstrates that a compact formal system can serve both as a model of computation and as a bridge between programming languages and mathematical logic.

Ask anything
We've read this whole study set, so questions about it get the best answers.