nLab
dependent sum 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-proposition, mere proposition
proofgeneralized elementprogram
cut rulecomposition of classifying morphisms / pullback of display mapssubstitution
cut elimination? for implicationcounit for hom-tensor adjunctionbeta reduction
introduction rule for implicationunit for hom-tensor adjunctioneta conversion
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, (idemponent) monadmodal type theory, monad (in computer science)
linear logic(symmetric, closed) monoidal categorylinear type theory/quantum computation
proof netstring diagramquantum circuit
(absence of) contraction rule(absence of) diagonalno-cloning theorem
synthetic mathematicsdomain specific embedded programming language

homotopy levels

semantics

Dependent sum types

Idea

In dependent type theory, a dependent sum type of a dependent type x:AB(x):Typex\colon A\vdash B(x)\colon Type is the type whose terms are ordered pairs (a,b)(a,b) with a:Aa\colon A and b:B(a)b\colon B(a).

In a model of the type theory in categorical semantics, this is a dependent sum (indexed disjoint union). It includes product types as the special case where BB is not dependent on AA.

Overview

type theorycategory theory
syntaxsemantics
natural deductionuniversal construction
dependent sum typedependent sum
type formationX:Typex:XA(x):Type( x:XA(x)):Type\frac{\vdash\: X \colon Type \;\;\;\;\; x \colon X \;\vdash\; A(x)\colon Type}{\vdash \; \left(\sum_{x \colon X} A\left(x\right)\right) \colon Type}
term introductionx:Xa:A(x)(x,a): x:XA(x)\frac{x \colon X \;\vdash\; a \colon A(x)}{\vdash (x,a) \colon \sum_{x' \colon X} A\left(x'\right) }
term eliminationt:( x:XA(x))p 1(t):Xp 2(t):A(p 1(t))\frac{\vdash\; t \colon \left(\sum_{x \colon X} A\left(x\right)\right)}{\vdash\; p_1(t) \colon X\;\;\;\;\; \vdash\; p_2(t) \colon A(p_1(t))}
computation rulep 1(x,a)=xp 2(x,a)=ap_1(x,a) = x\;\;\;\; p_2(x,a) = a

Definition

Like any type constructor in type theory, the 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 presentation of dependent sum type is almost exactly the same as that of product types, with the simple change that BB may depend on AA. In particular, they can be presented both as a negative type or as a positive type. In both cases, the rule for building the dependent sum type is the same:

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

but the constructors and eliminators may be different.

As a negative type

When presented negatively, primacy is given to the eliminators. We specify that there are two ways to eliminate a term of type x:AB(x)\sum_{x\colon A} B(x): by projecting out the first component, or by projecting out the second.

p: x:AB(x)π 1p:Ap: x:AB(x)π 2p:B(π 1p) \frac{p \colon \sum_{x\colon A} B(x)}{\pi_1 p\colon A} \qquad \frac{p\colon \sum_{x\colon A} B(x)}{\pi_2 p\colon B(\pi_1 p)}

This then determines the form of the constructors: in order to construct a term of type x:AB(x)\sum_{x\colon A} B(x), we have to specify what value that term should yield when all the eliminators are applied to it. In other words, we have to specify a pair of elements, one a:Aa\colon A (to be the value of π 1p\pi_1 p) and one b:B(a)b\colon B(a) (to be the value of π 2p\pi_2 p).

a:Ab:B(a)(a,b): x:AB(x) \frac{a\colon A \qquad b\colon B(a)}{(a,b)\colon \sum_{x\colon A} B(x)}

Finally, we have computation rules which say that the relationship between the constructors and the eliminators is as we hoped. We always have beta reduction rules

π 1(a,b) βaπ 2(a,b) βb \pi_1(a,b) \to_\beta a \qquad \pi_2(a,b) \to_\beta b

and we may or may not choose to have an eta reduction rule

(π 1p,π 2p) ηp (\pi_1 p, \pi_2 p) \to_\eta p

As a positive type

When presented positively, primacy is given to the constructors. We specify that the way to construct something of type x:AB(x)\sum_{x\colon A} B(x) is to give a term a:Aa\colon A and a term b:B(a)b\colon B(a):

a:Ab:B(a)(a,b): x:AB(x) \frac{a\colon A \qquad b\colon B(a)}{(a,b)\colon \sum_{x\colon A} B(x)}

Of course, this is the same as the constructor obtained from the negative presentation. However, the eliminator is different. Now, in order to say how to use something of type x:AB(x)\sum_{x\colon A} B(x), we have to specify how we should behave for all possible ways that it could have been constructed. In other words, we have to say, assuming that pp were of the form (a,b)(a,b), what we want to do. Thus we end up with the following rule:

z: x:AB(x)C(z):Typep: x:AB(x)x:A,y:B(x)c:C((x,y))let(x,y)=pinc:C(p) \frac{z\colon \sum_{x\colon A} B(x) \vdash C(z)\colon Type\qquad p\colon \sum_{x\colon A} B(x) \qquad x\colon A, y\colon B(x) \vdash c\colon C((x,y))}{let (x,y) = p in c \;\colon C(p)}

We need a term cc in the context of two variables of types AA and BB, and the destructor or match “binds those variables” to the two components of pp. Note that the “ordered pair” (x,y)(x,y) in the destructor is just a part of the syntax; it is not an instance of the constructor ordered pair.

Now we have the beta reduction rule:

let(x,y)=(a,b)inc βc[a/x,b/y] let (x,y) = (a,b) \,in c \;\to_\beta\; c[a/x, b/y]

In other words, if we build an ordered pair and then break it apart, what we get is just the things we put into it. (The notation c[a/x,b/y]c[a/x, b/y] means to substitute aa for xx and bb for yy in the term cc).

And (if we wish) the eta reduction rule, which is a little more subtle:

let(x,y)=pinc[(x,y)/z] ηc[p/z] let (x,y) = p in c[(x,y)/z] \;\to_\eta\; c[p/z]

This says that if we break something of type x:AB(x) \sum_{x\colon A} B(x) into its components, but then we only use those two components by way of putting them back together into an ordered pair, then we might as well just not have broken it down in the first place.

Positively defined dependent sum types are naturally expressed as inductive types. For instance, in Coq syntax we have

Inductive sig (A:Type) (B:A->Type) : Type :=
| exist : forall (x:A), B x -> sig A B.

(Coq then implements beta-reduction, but not eta-reduction. However, eta-equivalence is provable with the internally defined identity type, using the dependent eliminator mentioned above.)

Arguably, negatively defined products should be naturally expressed as coinductive types, but this is not exactly the case for the presentation of coinductive types used in Coq.

Positive versus negative

In ordinary “nonlinear” type theory, the positive and negative dependent sum types are equivalent, just as in the case of product types. They manifestly have the same constructor, while we can define the eliminators in terms of each other as follows:

π 1p let(x,y)=pinx π 2p let(x,y)=piny let(x,y)=pinc c[π 1p/x,π 2p/y] \begin{aligned} \pi_1 p &\;\coloneqq\; let (x,y) = p \,in\, x\\ \pi_2 p &\;\coloneqq\; let (x,y) = p \,in\, y\\ let (x,y) = p in c &\;\coloneqq\; c[\pi_1 p / x, \pi_2 p / y] \end{aligned}

The computation rules then also correspond, just as for product types.

Also just as for product types, in order to recover the important dependent eliminator for the positive product type from the eliminators for the negative product type, we need the latter to satisfy the η\eta-conversion rule so as to make the above definition well-typed. By inserting a transport, we can make do with a propositional η\eta-conversion, which is also provable from the dependent eliminator.

One might expect that in “dependent linear type theory” the positive and negative dependent sums would become different. However, the meaning of the quoted phrase is unclear.

Categorical interpretation

Under categorical semantics, a dependent type x:AB(x):Typex\colon A \vdash B(x)\colon Type corresponds to a fibration or display map BAB\to A. In this case, the dependent sum is just the object BB. This requires the dependent sum type to satisfy both β\beta- and η\eta-conversion.

Revised on December 10, 2013 00:32:44 by Urs Schreiber (89.204.138.69)