Dependent Type Theory

Dependent types let a type express a property of a value. The introduction and elimination rules distinguish what a program constructs from what the type checker computes.

Source
Anbloq
Language
English
Created
Updated
Chapters
3
Reading time
2 min
In this article3 chapters
  1. Judgments with a dependency
  2. Vector concatenation as a typed invariant
  3. Universes and conversion govern what can run

Judgments with a dependency

In a typing judgment \(\Gamma\vdash t:A\), the context records the variables available to the term and its type. A dependent product \(\prod_{x:A}B(x)\) contains functions whose result lies in a family indexed by the input. A dependent sum \(\sum_{x:A}B(x)\) contains a pair of a witness and an element of the corresponding fiber. Its second projection has a type mentioning the first. Under Curry–Howard, the product expresses a universal statement and the sum can carry constructive existence data.

The ordinary function interpretation of implication starts with natural deduction. Dependent results additionally require capture-avoiding substitution into the type of the result.

Vector concatenation as a typed invariant

Write \(\mathrm{Vec}(A,n)\) for vectors with a length index. Concatenation can receive a type that describes how lengths combine.

\[ \mathrm{append}:\prod_{m,n:\mathbb N} \mathrm{Vec}(A,m)\to\mathrm{Vec}(A,n)\to\mathrm{Vec}(A,m+n). \]

In a recursion on the first vector, the empty branch returns the second vector. If addition reduces on its first argument, the required length reduces to that of the second input. In the nonempty branch, the constructor adds one to the length delivered by the inductive call. If an arithmetic identity is propositional rather than definitional under the chosen definitions, explicit transport along a proof reconciles the types.

Universes and conversion govern what can run

A predicative hierarchy places \(\mathcal U_i\) in \(\mathcal U_{i+1}\). The rules specify where dependent products live and whether a smaller type can be used at a higher level. Judgmental equality is the conversion relation used during checking. An inhabitant of an identity type is an additional mathematical term that can be used by elimination. This distinction matters for cubical type theory, for automated proof elaboration and unification, and for the computational behavior of language semantics.[1][2]

References

  1. Per Martin-Löf, Intuitionistic Type Theory ↩
  2. The Univalent Foundations Program, Homotopy Type Theory ↩