1.6 Dependent pair types

1.6 Dependent pair types

Just as we generalized function types (§1.2 (

http://planetmath.org/12functiontypes

)) to dependent function types (§1.4 (

http://planetmath.org/14dependentfunctiontypes

)), it is often useful to generalize the product types from §1.5 (

http://planetmath.org/15producttypes

) to allow the type of
the second

component

of a pair to vary depending on the choice of the first
component. This is called a

dependent pair type

, or

Σ

-type

, because in

set theory

it
corresponds to an indexed sum (in the sense of coproduct or

disjoint union

) over a given type.

Given a type

A

:

𝒰

and a family

B

:

A

→

𝒰

, the dependent
pair type is written as

∑

(

x

:

A

)

B

⁢

(

x

)

:

𝒰

.
Alternative notations are

∑

(

x

:

A

)

B

(

x

)

∑

(

x

:

A

)

B

(

x

)

∑

(

x

:

A

)

,

B

(

x

)

.

Like other binding constructs such as

λ

-abstractions and

Π

s,

Σ

s automatically scope over the rest of the expression unless delimited, so e.g.

∑

(

x

:

A

)

B

⁢

(

x

)

×

C

⁢

(

x

)

means

∑

(

x

:

A

)

(

B

⁢

(

x

)

×

C

⁢

(

x

)

)

.

The way to construct elements of a dependent pair type is by

pairing

: we have

(

a

,

b

)

:

∑

(

x

:

A

)

B

⁢

(

x

)

given

a

:

A

and

b

:

B

⁢

(

a

)

.
If

B

is

constant

, then the dependent pair type is the
ordinary

cartesian product

type:

(

∑

(

x

:

A

)

B

)

≡

(

A

×

B

)

.

All the constructions on

Σ

-types arise as straightforward

generalizations

of the ones for product types, with dependent

functions

often replacing non-dependent ones.

For

instance

, the

recursion

principle
says that to define a non-dependent function out of a

Σ

-type

f

:

(

∑

(

x

:

A

)

B

⁢

(

x

)

)

→

C

, we provide a function

g

:

∏

(

x

:

A

)

B

⁢

(

x

)

→

C

, and then we can define

f

via the defining
equation

f

⁢

(

(

a

,

b

)

)

⁢

Ü

⁢



≡

g

⁢

(

a

)

⁢

(

b

)

.

For instance, we can derive the first

projection

from a

Σ

-type:

𝗉𝗋

1

:

(

∑

(

x

:

A

)

B

⁢

(

x

)

)

→

A

.

by the defining equation

𝗉𝗋

1

⁢

(

(

a

,

b

)

)

⁢

Ü

⁢



≡

a

.

However, since the type of the second component of a pair

(

a

,

b

)

:

∑

(

x

:

A

)

B

⁢

(

x

)

is

B

⁢

(

a

)

, the second projection must be a

dependent

function, whose type involves the first projection function:

𝗉𝗋

2

:

∏

(

p

:

∑

(

x

:

A

)

B

(

x

)

)

B

⁢

(

𝗉𝗋

1

⁢

(

p

)

)

.

Thus we need the

induction

principle
for

Σ

-types (the “dependent eliminator”).
This says that to construct a dependent function out of a

Σ

-type into a family

C

:

(

∑

(

x

:

A

)

B

⁢

(

x

)

)

→

𝒰

, we need a function

g

:

∏

(

a

:

A

)

b

:

B

⁢

(

a

)

⁢

C

⁢

(

(

a

,

b

)

)

.

We can then derive a function

f

:

∏

(

p

:

∑

(

x

:

A

)

B

(

x

)

)

C

⁢

(

p

)

with defining equation

f

⁢

(

(

a

,

b

)

)

⁢

Ü

⁢



≡

g

⁢

(

a

)

⁢

(

b

)

.

Applying this with

C

⁢

(

p

)

⁢

Ü

⁢



≡

B

⁢

(

𝗉𝗋

1

⁢

(

p

)

)

, we can define

𝗉𝗋

2

:

∏

(

p

:

∑

(

x

:

A

)

B

(

x

)

)

B

⁢

(

𝗉𝗋

1

⁢

(

p

)

)

with the obvious equation

𝗉𝗋

2

⁢

(

(

a

,

b

)

)

⁢

Ü

⁢



≡

b

.

To convince ourselves that this is correct, we note that

B

⁢

(

𝗉𝗋

1

⁢

(

(

a

,

b

)

)

)

≡

B

⁢

(

a

)

, using the defining equation for

𝗉𝗋

1

, and
indeed

b

:

B

⁢

(

a

)

.

We can package the recursion and induction principles into the recursor for

Σ

:

𝗋𝖾𝖼

∑

(

x

:

A

)

B

⁢

(

x

)

:

∏

(

C

:

𝒰

)

(

∏

(

x

:

A

)

B

(

x

)

→

C

)

→

(

∑

(

x

:

A

)

B

(

x

)

)

→

C

with the defining equation

𝗋𝖾𝖼

∑

(

x

:

A

)

B

⁢

(

x

)

⁢

(

C

,

g

,

(

a

,

b

)

)

⁢

Ü

⁢



≡

g

⁢

(

a

)

⁢

(

b

)

and the corresponding induction

operator

:

𝗂𝗇𝖽

∑

(

x

:

A

)

B

⁢

(

x

)

:

∏

(

C

:

(

∑

(

x

:

A

)

B

(

x

)

)

→

𝒰

)

(

∏

(

a

:

A

)

b

:

B

(

a

)

C

(

(

a

,

b

)

)

)

→

∏

(

p

:

∑

(

x

:

A

)

B

(

x

)

)

C

(

p

)

with the defining equation

𝗂𝗇𝖽

∑

(

x

:

A

)

B

⁢

(

x

)

⁢

(

C

,

g

,

(

a

,

b

)

)

⁢

Ü

⁢



≡

g

⁢

(

a

)

⁢

(

b

)

.

As before, the recursor is the special case of induction
when the family

C

is constant.

As a further example, consider the following principle, where

A

and

B

are types and

R

:

A

→

B

→

𝒰

.

𝖺𝖼

:

(

∏

(

x

:

A

)

∑

(

y

:

B

)

R

⁢

(

x

,

y

)

)

→

(

∑

(

f

:

A

→

B

)

∏

(

x

:

A

)

R

⁢

(

x

,

f

⁢

(

x

)

)

)

We may regard

R

as a “proof-relevant

relation

”
between

A

and

B

, with

R

⁢

(

a

,

b

)

the type of witnesses for relatedness of

a

:

A

and

b

:

B

.
Then

𝖺𝖼

says intuitively that if we have a dependent function

g

assigning to every

a

:

A

a dependent pair

(

b

,

r

)

where

b

:

B

and

r

:

R

⁢

(

a

,

b

)

, then we have a function

f

:

A

→

B

and a dependent function assigning to every

a

:

A

a witness that

R

⁢

(

a

,

f

⁢

(

a

)

)

.
Our intuition tells us that we can just split up the values of

g

into their components.
Indeed, using the projections we have just defined, we can define:

𝖺𝖼

(

g

)

Ü



≡

(

λ

x

.

𝗉𝗋

1

(

g

(

x

)

)

,

λ

x

.

𝗉𝗋

2

(

g

(

x

)

)

)

.

To verify that this is well-typed, note that if

g

:

∏

(

x

:

A

)

∑

(

y

:

B

)

R

⁢

(

x

,

y

)

, we have

λ

⁢

x

.

𝗉𝗋

1

⁢

(

g

⁢

(

x

)

)

:

A

→

B

,

λ

⁢

x

.

𝗉𝗋

2

⁢

(

g

⁢

(

x

)

)

:

∏

(

x

:

A

)

R

⁢

(

x

,

𝗉𝗋

1

⁢

(

g

⁢

(

x

)

)

)

.

Moreover, the type

∏

(

x

:

A

)

R

⁢

(

x

,

𝗉𝗋

1

⁢

(

g

⁢

(

x

)

)

)

is the result of substituting the function

λ

⁢

x

.

𝗉𝗋

1

⁢

(

g

⁢

(

x

)

)

for

f

in the family being summed over in the codomain of

𝖺𝖼

:

∏

(

x

:

A

)

R

(

x

,

𝗉𝗋

1

(

g

(

x

)

)

)

≡

(

λ

f

.

∏

(

x

:

A

)

R

(

x

,

f

(

x

)

)

)

(

λ

x

.

𝗉𝗋

1

(

g

(

x

)

)

)

.

Thus, we have

(

λ

x

.

𝗉𝗋

1

(

g

(

x

)

)

,

λ

x

.

𝗉𝗋

2

(

g

(

x

)

)

)

:

∑

(

f

:

A

→

B

)

∏

(

x

:

A

)

R

(

x

,

f

(

x

)

)

as required.

If we read

Π

as “for all” and

Σ

as “there exists”, then the type of the function

𝖺𝖼

expresses:

if for all

x

:

A

there is a

y

:

B

such that

R

⁢

(

x

,

y

)

, then there is a function

f

:

A

→

B

such that for all

x

:

A

we have

R

⁢

(

x

,

f

⁢

(

x

)

)

.
Since this sounds like a version of the

axiom of choice

, the function

𝖺𝖼

has traditionally been called the

type-theoretic axiom of choice

, and as we have just shown, it can be proved directly from the rules of

type theory

, rather than having to be taken as an axiom.
However, note that no choice is actually involved, since the choices have already been given to us in the

premise

: all we have to do is take it apart into two functions: one representing the choice and the other its correctness.
In

\autoref

sec:axiom-choice we will give another formulation of an “axiom of choice” which is closer to the usual one.

Dependent pair types are often used to define types of mathematical structures, which commonly consist of several dependent pieces of data.
To take a simple example, suppose we want to define a

magma

to be a type

A

together with a

binary operation

m

:

A

→

A

→

A

.
The precise meaning of the phrase “together with” (and the synonymous “equipped with”) is that “a magma” is a

pair

(

A

,

m

)

consisting of a type

A

:

𝒰

and an

operation

m

:

A

→

A

→

A

.
Since the type

A

→

A

→

A

of the second component

m

of this pair depends on its first component

A

, such pairs belong to a dependent pair type.
Thus, the definition “a magma is a type

A

together with a binary operation

m

:

A

→

A

→

A

” should be read as defining

the type of magmas

to be

𝖬𝖺𝗀𝗆𝖺

Ü



≡

∑

(

A

:

𝒰

)

(

A

→

A

→

A

)

.

Given a magma, we extract its underlying type (its “

carrier

”) with the first projection

𝗉𝗋

1

, and its operation with the second projection

𝗉𝗋

2

.
Of course,

structures

built from more than two pieces of data require iterated pair types, which may be only partially dependent; for instance the type of pointed magmas (magmas

(

A

,

m

)

equipped with a

basepoint

e

:

A

) is

𝖯𝗈𝗂𝗇𝗍𝖾𝖽𝖬𝖺𝗀𝗆𝖺

Ü



≡

∑

(

A

:

𝒰

)

(

A

→

A

→

A

)

×

A

.

We generally also want to impose axioms on such a structure, e.g. to make a pointed magma into a monoid or a group.
This can also be done using

Σ

-types; see

\autoref

sec:pat.

In the rest of the book, we will sometimes make definitions of this sort explicit, but eventually we trust the reader to

translate

them from English into

Σ

-types.
We also generally follow the common mathematical practice of using the same letter for a structure of this sort and for its carrier (which amounts to leaving the appropriate projection function implicit in the notation): that is, we will speak of a magma

A

with its operation

m

:

A

→

A

→

A

.

Note that the canonical elements of

𝖯𝗈𝗂𝗇𝗍𝖾𝖽𝖬𝖺𝗀𝗆𝖺

are of the form

(

A

,

(

m

,

e

)

)

where

A

:

𝒰

,

m

:

A

→

A

→

A

, and

e

:

A

.
Because of the frequency with which iterated

Σ

-types of this sort arise, we use the usual notation of ordered triples, quadruples and so on to stand for nested pairs (possibly dependent) associating to the right.
That is, we have

(

x

,

y

,

z

)

⁢

Ü

⁢



≡

(

x

,

(

y

,

z

)

)

and

(

x

,

y

,

z

,

w

)

⁢

Ü

⁢



≡

(

x

,

(

y

,

(

z

,

w

)

)

)

, etc.

Title

1.6 Dependent pair types

Canonical name

16DependentPairTypes

Date of creation

2013-11-13 18:01:54

Last modified on

2013-11-13 18:01:54

Owner

PMBookProject (1000683)

Last modified by

rspuzio (6075)

Numerical id

22

Author

PMBookProject (6075)

Entry type

Definition

Classification

msc 03B15

Generated on Thu Feb 8 19:32:33 2018 by

LaTeXML