ncatlab.org

dependent type in nLab

Contents

Context

Type theory

natural deduction metalanguage, practical foundations

  1. type formation rule
  2. term introduction rule
  3. term elimination rule
  4. computation rule

type theory (dependent, intensional, observational type theory, homotopy type theory)

syntax object language

homotopy levels

semantics

Contents

Idea

In type theory, a dependent type or type in context is a family or bundle of types which vary over the elements (terms) of some other type. It can be regarded as a formalization of the notion of “indexed family,” providing a structural account of families (in contrast to the material approach which requires sets to be able to contain other sets as elements).

Type theory with the notion of dependent types is called dependent type theory.

In the categorical semantics of type theory, a dependent type

x:A⊢B(x):type x:A \; \vdash \;B(x): \;\mathrm{type}

is represented by a particular morphism p:B→Ap\colon B\to A, the intended meaning being that each type B(x)B(x) is the fiber of pp over x∈Ax\in A. The morphism in a category that may represent dependent types in this way are sometimes called display morphisms (especially when not every morphism is a display morphism).

Dependent types can be thought of as fibrations (Serre fibrations) in classical homotopy theory. The base space is XX, the total space is ∑ (x:X)P(x)\sum_{(x:X)}P(x) and the fiber P(⋆ X)P(\star_X). This gives the fibration:

P(⋆ X)→∑ x:XP(x)→XP(\star_X)\to \sum_{x:X}P(x) \to X

Relation to families of elements.

One may understand AA-dependent types a:A⊢B(a)a \colon A \;\vdash\; B(a) equivalently as functions B→AB \to A with codomain AA, i.e. as “type-bundles” (in the general, not in locally trivial sense of fiber bundles, though) or “type-fibrations” (in a rather accurate sense):

The domain BB — i.e. the “total space” of these bundles — is identified with the dependent sum of the “fibers” B(a)B(a), and conversely these fibers are indeed recovered from any such bundle as the fiber types.

Under the categorical semantics of dependent type theory (cf. categorical model of dependent types and relation between type theory and category theory) it is exactly these associated “type bundles” which are identified with actual fibrations (“display maps”) in the given semantic category.

We now say this in more detail, first

and then as

Syntactically

Given a family of types, x:A⊢B(x)x:A \vdash B(x), one can construct a family of elements z:∑ x:AB(x)⊢π 1(z):Az:\sum_{x:A} B(x) \vdash \pi_1(z):A via the elimination rules for negative dependent sum types:

Γ⊢AtypeΓ,x:A⊢B(x)typeΓ,z:∑ x:AB(x)⊢π 1(z):A\frac{\Gamma \vdash A \; \mathrm{type} \quad \Gamma, x:A \vdash B(x) \; \mathrm{type}}{\Gamma, z:\sum_{x:A} B(x) \vdash \pi_1(z):A}

Conversely, given a family of elements x:A⊢f(x):Bx:A \vdash f(x):B one can construct a family of types y:B⊢∑ x:Af(x)= Byy:B \vdash \sum_{x:A} f(x) =_B y as the family of fiber types of x:A⊢f(x):Bx:A \vdash f(x):B, via the formation rules for identity types and dependent sum types:

Γ⊢AtypeΓ⊢AtypeΓ⊢BtypeΓ,x:A⊢f(x):BΓ,x:A,y:B⊢f(x)= BytypeΓ,y:B⊢∑ x:Af(x)= Bytype\frac{\Gamma \vdash A \; \mathrm{type} \quad \frac{\Gamma \vdash A \; \mathrm{type} \quad \Gamma \vdash B \; \mathrm{type} \quad \Gamma, x:A \vdash f(x):B}{\Gamma, x:A, y:B \vdash f(x) =_B y \; \mathrm{type}}}{\Gamma, y:B \vdash \sum_{x:A} f(x) =_B y \; \mathrm{type}}

This corresponds to the relation between type theory and category theory: there are two ways to interpret a morphism f:Hom C(A,B)f:\mathrm{Hom}_C(A, B) in a category CC

  • as a family of elements x:A⊢f(x):Bx:A \vdash f(x):B
  • as a family of types y:B⊢A(y)y:B \vdash A(y)

If the type theory has function types, then the above notions are also interderivable with an element of a function type f:A→Bf:A \to B, which correspond to the internal hom of a category CC.

One can additionally derive the following equivalences of types:

p:A≃∑ y:B∑ x:A(f(x)= By) p \;\;\;\; \colon \;\;\;\; A \;\; \simeq \; \sum_{y:B} \sum_{x:A} \big( f(x) =_B y \big)

y:B⊢q(y):A(y)≃∑ z:∑ x:BA(x)(π 1(z)= Ay) y \colon B \;\;\;\; \vdash \;\;\;\; q(y) \;\;\; \colon \;\;\; A(y) \;\simeq\; \sum_{ \mathclap{ z \colon \sum_{x:B} A(x) } } \big( \pi_1(z) =_A y \big)

Reflected in the type universe

Assuming the univalence-axiom, the analogous statement holds reflected within a type universe TypeType: Given X:TypeX \,\colon\, Type, the type X→TypeX \to Type of XX-dependent types is equivalent to the type (X:Type)×(Y→X)(X \colon Type) \times (Y \to X) of functions with codomain XX, via forming fiber types and dependent sum-types, respectively [UFP13, Thm. 4.8.3]

X:Type⊢(Y:Type)×(Y→X)≃(X→Type). X \colon Type \;\;\;\; \vdash \;\;\;\; (Y \colon Type) \times (Y \to X) \;\; \simeq \;\; \big( X \to Type \big) \,.

Under the categorical semantics of homotopy type theory in ∞ \infty -toposes, this characterizes the type universe as (interpreted by) the (small) object classifier in an ∞ \infty -topos.

Examples

When the theory of a category is phrased in dependent type theory then there is one type “objobj” of objects and a type homhom of morphisms, which is dependent on two terms of type objobj, so that for any x,y:objx,y:obj there is a type hom(x,y)hom(x,y) of arrows from xx to yy. This dependency is usually written as x,y:obj⊢hom(x,y):Typex,y:obj \vdash hom(x,y):Type. In some theories, it makes sense to say that the type of “homhom” itself is obj,obj→Typeobj, obj\to Type (usually understood as obj→(obj→Type)obj \to (obj \to Type) or (obj×obj)→Type(\obj \times \obj) \to Type), i.e. a function from pairs of elements of AA to the universe TypeType of types.

References

See the references at dependent type theory.

Exposition:

In Coq:

  • Yves Bertot?, Introduction to dependent types in Coq [pdf]

The relation between dependent types and bundles (functions of given codomain)

Last revised on January 22, 2024 at 05:47:12. See the history of this page for a list of all contributions to it.