Beta. Content is under active construction and has not been peer-reviewed. Report errors on GitHub.Disclaimer

Foundations

Dependent Type Theory

Types that depend on values. Pi types generalize function types; Sigma types generalize pairs. The Curry-Howard correspondence extends to full logic: propositions are types, proofs are programs. This is the foundation of proof assistants like Lean and Coq.

AdvancedTier 3Current~65 min

Prerequisites

0

Why This Matters

In simply typed lambda calculus, types and values live in separate worlds: the type NN\mathbb{N} \to \mathbb{N} does not know which natural number you pass in. Dependent type theory erases this boundary. A type can mention a value: Vec(R,n)\text{Vec}(\mathbb{R}, n) is the type of real-valued vectors of length nn, where nn is a natural number.

This fusion of types and values has a profound consequence: propositions become types, and proofs become terms. The statement "for all nn, n+0=nn + 0 = n" becomes a dependent function type n:N(n+0=Nn)\prod_{n : \mathbb{N}} (n + 0 =_\mathbb{N} n), and a proof of this statement is a term of that type. This is why Lean, Coq, and Agda use dependent type theory: mathematical assertions and their proofs live in the same language.

Prerequisites

This page assumes familiarity with lambda calculus, specifically simply typed lambda calculus and the basic Curry-Howard correspondence (types as propositions, terms as proofs, function types as implications).

Core Definitions

Definition

Dependent Function Type (Pi Type)

The Pi type x:AB(x)\prod_{x:A} B(x) is the type of functions that take an input xx of type AA and return an output of type B(x)B(x), where the output type depends on the input value.

A term f:x:AB(x)f : \prod_{x:A} B(x) is a function such that for each a:Aa : A, we have f(a):B(a)f(a) : B(a).

When BB does not depend on xx, this reduces to the ordinary function type ABA \to B.

Definition

Dependent Pair Type (Sigma Type)

The Sigma type x:AB(x)\sum_{x:A} B(x) is the type of pairs (a,b)(a, b) where a:Aa : A and b:B(a)b : B(a). The type of the second component depends on the value of the first.

When BB does not depend on xx, this reduces to the ordinary product type A×BA \times B.

Definition

Propositions as Types (Curry-Howard for Dependent Types)

In dependent type theory, logical connectives correspond to type formers:

LogicType theory
xA.P(x)\forall x \in A.\, P(x)x:AP(x)\prod_{x:A} P(x)
xA.P(x)\exists x \in A.\, P(x)x:AP(x)\sum_{x:A} P(x)
P    QP \implies QPQP \to Q
PQP \land QP×QP \times Q
PQP \lor QP+QP + Q (sum type)
TrueUnit type 1\mathbf{1}
FalseEmpty type 0\mathbf{0}

A proposition is "true" if its corresponding type is inhabited (has a term). A proof of x.P(x)\forall x.\, P(x) is a function that takes any xx and produces a proof of P(x)P(x).

Definition

Identity Type (Propositional Equality)

The identity type a=Aba =_A b is the type of proofs that aa and bb are equal as elements of type AA. It is inhabited if and only if aa and bb are (propositionally) equal. The canonical constructor is refla:a=Aa\text{refl}_a : a =_A a.

Main Theorems

Theorem

Curry-Howard Correspondence (Dependent Version)

Statement

There is a precise correspondence between:

  1. Propositions in constructive predicate logic and types in dependent type theory.
  2. Proofs and terms (programs): a proposition PP is provable if and only if the type PP is inhabited.
  3. Proof simplification (cut-elimination) and program evaluation (beta-reduction).

In particular, type-checking a term verifies that a proof is correct. The problem of theorem proving reduces to the problem of term construction.

Intuition

Writing a proof and writing a program are the same activity. When you prove "for all natural numbers nn, n+0=nn + 0 = n" in Lean, you construct a function that takes n:Nn : \mathbb{N} and returns a term of type n+0=Nnn + 0 =_\mathbb{N} n. The type-checker verifies correctness.

Proof Sketch

The correspondence is structural, not a single theorem to prove. For each logical rule (introduction and elimination of connectives), there is a corresponding typing rule for lambda terms. Universal quantification introduction corresponds to lambda abstraction for Pi types. Existential quantification introduction corresponds to pair formation for Sigma types. Modus ponens corresponds to function application. The meta-theorem is that derivations in constructive logic biject with well-typed terms.

Why It Matters

This correspondence is the reason proof assistants work. Lean's kernel is a type-checker: it does not search for proofs, it verifies that a proposed term has the claimed type. The entire trust base of a proof assistant is a type-checker, which can be small and auditable. This is a much smaller trusted computing base than a general-purpose automated theorem prover.

Failure Mode

The correspondence holds for constructive logic, not classical logic. Classical principles like the law of excluded middle (P¬PP \lor \neg P) and double negation elimination (¬¬P    P\neg\neg P \implies P) do not have computational content in the standard sense. They can be added as axioms, but the resulting "proofs" are not programs that compute witnesses. Lean and Coq allow classical reasoning by adding these axioms, at the cost of losing computational extraction for classical proofs.

Calculus of Inductive Constructions

Coq (now Rocq) and Lean are based on the Calculus of Inductive Constructions (CIC), which extends dependent type theory with:

  1. Inductive types: datatypes defined by their constructors. Natural numbers are defined by zero:N\text{zero} : \mathbb{N} and succ:NN\text{succ} : \mathbb{N} \to \mathbb{N}. Lists, trees, and other data structures are similarly defined.

  2. Pattern matching and recursion: functions on inductive types are defined by matching on constructors and recursing on structurally smaller arguments. Structural recursion guarantees termination.

  3. A universe hierarchy: types themselves have types. N:Type0\mathbb{N} : \text{Type}_0, Type0:Type1\text{Type}_0 : \text{Type}_1, etc. This avoids Girard's paradox (the type-theoretic analogue of Russell's paradox).

The key property of CIC is strong normalization: every well-typed term reduces to a normal form in finite steps. This means that type-checking is decidable (the type-checker always terminates), and proofs cannot loop forever.

What Lean Looks Like

In Lean 4, a proof that addition is commutative looks like a function definition:

theorem add_comm : forall (n m : Nat), n + m = m + n := by
  intro n m
  induction n with
  | zero => simp
  | succ n ih => simp [Nat.succ_add]; exact ih

The by keyword enters tactic mode, where tactics construct the proof term incrementally. The kernel then verifies the resulting term has the correct type.

Why This Matters for ML

Dependent types are not directly used in most ML systems today. The connection is indirect:

  1. Formal verification of ML systems: Projects like VeriML and verified neural network properties use dependent types to state and prove properties about ML algorithms.

  2. Proof assistants for mathematical ML theory: The Lean Mathematics Library (Mathlib) formalizes significant portions of analysis, measure theory, and probability. The long-term goal is to formalize all of ML theory.

  3. Neuro-symbolic integration: Systems that combine neural networks with symbolic reasoning increasingly use type-theoretic frameworks to ensure that the symbolic component is correct by construction.

Common Confusions

Watch Out

Dependent types are not just generics

In Java or Python, generic types like List<T> are parameterized by types. Dependent types are parameterized by values: Vec(n) depends on the number nn. You cannot express "a function that takes a number nn and returns a vector of length nn" with generics alone. You need n:NVec(R,n)\prod_{n:\mathbb{N}} \text{Vec}(\mathbb{R}, n).

Watch Out

Constructive does not mean weak

Constructive logic rejects the law of excluded middle as an axiom. This does not mean constructive proofs are weaker in practice. A constructive proof of x.P(x)\exists x.\, P(x) actually produces a witness xx, which is computationally more informative than a classical existence proof by contradiction. Most theorems in analysis and algebra have constructive proofs, though some require more work.

Watch Out

Lean and Coq allow classical reasoning

Although their foundations are constructive, both Lean and Coq allow you to assume classical axioms (excluded middle, choice). When you do, you lose the ability to extract programs from proofs of existence statements, but you gain the full power of classical mathematics. Most formalization projects freely use classical reasoning.

Exercises

ExerciseCore

Problem

Write the type (in dependent type theory notation) corresponding to the logical statement: "for every natural number nn, there exists a natural number mm such that m>nm > n."

ExerciseAdvanced

Problem

Explain why Girard's paradox (Type : Type) makes a type theory inconsistent, and how the universe hierarchy Type0:Type1:Type2:\text{Type}_0 : \text{Type}_1 : \text{Type}_2 : \cdots avoids it.

ExerciseAdvanced

Problem

In the Curry-Howard correspondence, what does beta-reduction of a lambda term correspond to in logic? What does the Church-Rosser theorem (confluence) mean for proofs?

References

Canonical:

  • Martin-Lof, Intuitionistic Type Theory (1984)
  • The Univalent Foundations Program, Homotopy Type Theory (2013), Chapters 1-2

Practical:

  • Avigad, Theorem Proving in Lean 4 (2023)
  • Coquand & Huet, "The Calculus of Constructions" (1988)

Accessible:

  • Pierce, Types and Programming Languages (2002), Chapters 23, 29-30

Next Topics

The main extensions of dependent type theory:

  • Formal verification of ML: applying these ideas to prove properties of ML systems
  • Proof theory and cut-elimination: the structural theory underlying the Curry-Howard correspondence

Last reviewed: April 2026

Prerequisites

Foundations this topic depends on.