nLab
dependent product type

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

computational trinitarianism = propositions as types +programs as proofs +relation type theory/category theory

logiccategory theorytype theory
trueterminal object/(-2)-truncated objecth-level 0-type/unit type
falseinitial objectempty type
proposition(-1)-truncated objecth-level 1-type/h-prop
proofgeneralized elementprogram
conjunctionproductproduct type
disjunctioncoproduct ((-1)-truncation of)sum type (bracket type of)
implicationinternal homfunction type
negationinternal hom into initial objectfunction type into empty type
universal quantificationdependent productdependent product type
existential quantificationdependent sum ((-1)-truncation of)dependent sum type (bracket type of)
equivalencepath space objectidentity type
equivalence classquotientquotient type
inductioncolimitinductive type, W-type, M-type
higher inductionhigher colimithigher inductive type
completely presented setdiscrete object/0-truncated objecth-level 2-type/preset/h-set
setinternal 0-groupoidBishop set/setoid
universeobject classifiertype of types
modalityclosure operator monadmodal type theory, monad (in computer science)

homotopy levels

semantics

Dependent product types

Idea

In dependent type theory, a dependent product type x:AB(x), for a dependent type x:AB(x):Type is the type of “dependently typed functions” assigning to each x:A an element of B(x).

In a model of the type theory in categorical semantics, this is a dependent product. In set theory, it is an element of an indexed product.

It includes function types as the special case when B is not dependent on A. Note that a binary product type is rather different, being actually a special case of a dependent sum type.

Overview

type theorycategory theory
syntaxsemantics
natural deductionuniversal construction
dependent product typedependent product
type formationX:Typex:XA(x):Type( x:XA(x)):Type
term introductionx:Xa(x):A(x)(xa(x)): x:XA(x)
term eliminationf:( x:XA(x))x:Xx:Xf(x):A(x)
computation rule(ya(y))(x)=a(x)

Definition

Like any type constructor in type theory, a dependent product type is specified by rules saying when we can introduce it as a type, how to construct terms of that type, how to use or “eliminate” terms of that type, and how to compute when we combine the constructors with the eliminators.

The type formation rule for dependent product type is:

A:Typex:AB(x):Type x:AB(x):Type\frac{A\colon Type \qquad x\colon A \vdash B(x) \colon Type}{\prod_{x\colon A} B(x)\colon Type}

As a negative type

Dependent product types are almost always defined as negative types. In this presentation, primacy is given to the eliminators. The natural eliminator of a dependent product type says that we can apply it to any input:

f: x:AB(x)a:Af(a):B(a)\frac{f\colon \prod_{x\colon A} B(x) \qquad a\colon A}{f(a) \colon B(a)}

The constructor is then determined as usual for a negative type: to construct a term of x:AB(x), we have to specify how it behaves when applied to any input. In other words, we should have a term of type B(x) containing a free variable x:A. This yields the usual ”λ-abstraction” constructor:

x:Ab:B(x)λx.b: x:AB(x)\frac{x\colon A\vdash b\colon B(x)}{\lambda x.b\colon \prod_{x\colon A} B(x)}

The β-reduction rule is the obvious one, saying that when we evaluate a λ-abstraction, we do it by substituting for the bound variable.

(λx.b)(a) βb[a/x](\lambda x.b)(a) \;\to_\beta\; b[a/x]

If we want an η-conversion rule, the natural one says that every dependently typed function is a λ-abstraction:

λx.f(x) ηf\lambda x.f(x) \;\to_\eta\; f

As a positive type

It is also possible to present dependent product types as a positive type. However, this requires a stronger metatheory, such as a logical framework. We use the same constructor (λ-abstraction), but now the eliminator says that to define an operation using a function, it suffices to say what to do in the case that that function is a lambda abstraction.

(x:Ab:B(x))c:Cf: x:AB(x)funsplit(c,f):C\frac{(x\colon A \vdash b\colon B(x)) \vdash c\colon C \qquad f\colon \prod_{x\colon A} B(x)}{funsplit(c,f)\colon C}

This rule cannot be formulated in the usual presentation of type theory, since it involves a “higher-order judgment”: the context of the term c:C involves a “term of type B(x) containing a free variable x:A”. However, it is possible to make sense of it. In dependent type theory, we need additionally to allow C to depend on x:AB(x).

The natural β-reduction rule for this eliminator is

funsplit(c,λx.g) βc[g/b]funsplit(c, \lambda x.g) \;\to_\beta c[g/b]

and its η-conversion rule looks something like

funsplit(c[λx.b/g],f) ηc[f/g].funsplit(c[\lambda x.b / g], f) \;\to_\eta\; c[f/g].

Here g: x:AB(x)c:C is a term containing a free variable of type x:AB(x). By substituting λx.b for g, we obtain a term of type C which depends on “a term b:B(x) containing a free variable x:A”. We then apply the positive eliminator at f: x:AB(x), and the η-rule says that this can be computed by just substituting f for g in c.

Positive versus negative

As usual, the positive and negative formulations are equivalent in a suitable sense. They have the same constructor, while we can formulate the eliminators in terms of each other:

f(a) funsplit(b[a/x],f) funsplit(c,f) c[f(x)/b]\begin{aligned} f(a) &\coloneqq funsplit(b[a/x], f)\\ funsplit(c, f) &\coloneqq c[f(x)/b] \end{aligned}

The conversion rules also correspond.

In dependent type theory, this definition of funsplit only gives us a properly typed dependent eliminator if the negative dependent product type satisfies η-conversion. As usual, if it satisfies propositional eta-conversion then we can transport along that instead—and conversely, the dependent eliminator allows us to prove propositional η-conversion. This is the content of Propositions 3.5, 3.6, and 3.7 in (Garner).

References

The standard rules for type-formation, term introduction/elimination and computation of dependent product type are listed for instance in part I of

See also

  • Richard Garner, On the strength of dependent products in the type theory of Martin-Löf, arXiv.

Revised on October 2, 2012 22:22:50 by Urs Schreiber (82.169.65.155)