You are on page 1of 19

MA2002 Mathematical Project

An introduction to Martin-L
of type theory
Tor kland Barstad
Spring 2015

Supervisor: Richard Williamson

Contents
1 Introduction

2 MLTT as a formal system and as a programming language

3 What is a type theory?

4 Syntactics and semantics


4.1 Judgments . . . . . . . . . . . . .
4.2 Logic in MLTT . . . . . . . . . .
4.3 Rules . . . . . . . . . . . . . . . .
4.3.1 Formation rules . . . . . .
4.3.2 Introduction rules . . . .
4.3.3 Elimination rules . . . . .
4.3.4 Equality rules . . . . . . .
4.4 Sets vs types . . . . . . . . . . .
4.5 Contexts . . . . . . . . . . . . . .
4.6 The types of MLTT . . . . . . .
4.6.1 Function types . . . . . .
4.6.2 Binary product types . .
4.6.3 Binary sum types . . . . .
4.6.4 Dependent product types
4.6.5 Dependent sum types . .
4.6.6 Empty type . . . . . . . .
4.6.7 Identity types . . . . . . .

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

7
7
7
8
8
9
10
10
10
11
11
12
13
13
14
15
16
17

1 Introduction
This is a slightly modified version of a text I wrote for a university course where
I learned Martin-Lof type theory. It may be that my lack of depth/experience is
reflected in the text, but I hope that it regardless will serve as a good introduction.
Writing an introduction that is both less formal and takes better care to explain
things to people who are new to this kind of stuff, and is broader and more in-depth
and complete than this one, is on the list of things that I hope Ill have time to
do once I understand the material better myself. If you want to learn Martin-Lof
type theory this list of resources may be also be of help: http://tinyurl.com/
LearnDependentTypeTheory.
Martin-Lof type theory was developed in the 1970s and 1980s by Per Martin-Lof [2], and
has become one of the most important and influential approaches to the foundations
of mathematics outside of set theory, with a particular surge of interest in recent years
due to the emergence of homotopy type theory, which could be seen as interpretation
of Martin-L
of type theory [5]. Martin-Lof type theory has also been put to significant
uses outside of mathematics, especially in computer science, for instance in the field of
programme certification [1], but also for instance in linguistics [3].
In this text we give an introduction to Martin-L
of type theory, with a view towards how
it can be used to represent claims about the real world that usually are expressed in
natural language. Throughout this work, well abbreviate Martin-Lof type theory to
MLTT.
In type theory, various notations are commonly in use to denote the same types, and
terminology also differs. The choices of notation and terminology made here may differ
from what is found elsewhere. Also, MLTT does not refer to a single type theory, but
rather to various type theories which have certain fundamental aspects in common, and
thus there will be differences between what is presented here and other presentations of
MLTT.

2 MLTT as a formal system and as a


programming language
MLTT is a formal language. That is to say, it consists of rules for how various prescribed
symbols may be combined. Many of the formal systems used in traditional logic leave
things implicit, but MLTT aspires to be formal enough for there to not be any ambiguity.
It follows from this philosophy that we should be able to implement such a language on
a computer, and that we then should be able to know what an algorithm will do in all
situations by examining its formal specification.
Functional programming languages such as Haskell and OCaml can be thought of
implementations of a fragment of MLTT. The crucial difference between such programming
languages and an implementation of MLTT is that the former lack what are known
as dependent types, which we discuss in 3. Dependent types greatly increase the
expressibility of a type theory. Programming languages which implement full MLTT, or
a formal language similar to MLTT, include Coq (built upon OCaml), Agda (built upon
Haskell) and Idris (also built upon Haskell).
MLTT is used for formalisation of mathematical proofs, but is also used for formalisation
of proofs that computer algorithms are correctly implemented, without bugs. MLTT
can be used to construct algorithms that are in effect proofs that they are correctly
implemented. Another MLTT-based programming language, Grammatical Framework,
shows the potential of MLTT to be used for other things than formalisation of mathematics
[4]. Grammatical Framework is a language for working with the grammar of natural
languages. It enables precise translation between the latter and MLTT, and between
different languages with MLTT as an intermediary.
MLTT is highly extensible. Just about anything can be expressed in MLTT or extensions
of it, including other formal systems.

3 What is a type theory?


A broad range of formal systems can be considered to be type theories. Common among
these formal systems are the presence of two primitive notions: terms and types. Every
term has a specified type, and equality is defined only for terms of the same type.
An example of a type would be the type of natural numbers, often denoted by N. An
example of term of type N would be the natural number 42. To express that 42 is a term
of type N, we write 42 : N. A second example of a type would be the type of integers,
often denoted by Z. An example of term of type Z would be the integer 42. Since only
terms of the same type can be equal, there is a priori no relationship between 42 : N and
42 : Z.
That in type theory we can only speak of equality of terms of the same type is in
stark contrast to ZFC set theory, the most well-known formal system used to formalise
mathematics. In ZFC, everything is represented as a set, and thus it makes sense to
ask whether any two entities are equal, even when this is semantically non-sensical. For
instance, it makes sense in ZFC to ask whether the natural number 42 is equal to the
vector of real numbers (13, 37, 9), whereas this is not possible in MLTT in a natural way:
42 and (13, 37, 9) will be terms of different types.
MLTT is characterised among type theories by the ability to define types, known as
dependent types, which depend upon the terms of another type. An example of a
dependent type is the type of lists of natural numbers of arbitrary finite length, which
depends on a term of type N for the specification of the length of the list.
A second example of a dependent type is the type of days in a month, which depends
upon the month (different months have different number of days). Similarly, the type
of days in a month in a year would depend upon both the choice of month and year,
allowing for leap years.
To give a third example of a dependent type, we might capture friendship as a type
Friendship depending on a type of pairs of people. Given a term of the latter type, that is
to say a pair of people X and Y , we would then think of a term of type Friendship(X, Y )
as corresponding to the assertion: X and Y are friends.
We can think of a dependent type as a family of types, one type for each term of a fixed
type. The dependent type of lists of natural numbers of arbitrary finite length can, for
instance, be thought of as the family of types: lists of length 1, lists of length 2, and so
on.

On a different note, that different variables have different types, such as string, integer,
char, or more complicated gadgets, is common to many programming languages. There
are parallels between this and the notion of a type in MLTT, but there also large
differences. The most important of these is that MLTT allows for new types to be built
from others, and in this way highly complex types can be constructed in MLTT. These
types can be used to carry out much of what other formal systems implement by different
means.

4 Syntactics and semantics


4.1 Judgments
While there are many things that can be represented by MLTT through some correspondence, there are four kinds of judgments that are made within the system itself, described
in the table below.
Judgement

Reading

A : type
a:A
a=b:A
A=B

A is a type
a is a term of type A
a and b are equal terms of type A
A and B are equal types

Notice the convention of using small letters to refer to terms, and of using large letters
to refer to types.
Some versions of MLTT are hierarchical: there are types type, type1 , type2 , type3 , and
so on, such that type : type1 , type1 : type2 , and so on. Such types are often referred to
as universes. There will then be four forms of judgments for each universe type, type1 ,
type2 , and so on.
In other versions of MLTT, type, type1 , type2 , type3 , and so on, are instead denoted set,
set1 , set2 , set3 , and so on. In some implementations of MLTT, such as Coq, a universe
hierarchy is implicit, but the user is not permitted to explicitly make judgments A : typei
for i 2.

4.2 Logic in MLTT


The Curry-Howard correspondence, sometimes referred to by other names such as the
Curry-Howard isomorphism or the propositions-as-types correspondence, refers to the fact
that the judgement A : type can be read as A is a proposition, and the judgement a : A
can be read as a is a proof of A, or a is a witness for A. For instance, the judgement
N : type can be read as the proposition: there is a natural number. The judgement 2 : N
can be read as: 2 is a witness for the fact that there is a natural number, that is to say, 2
is a proof that there is a natural number.

As we will see later in this section, MLTT allows various ways to construct types from other
types. These type constructions correspond, under the reading of types as propositions, to
the ways to construct propositions from other propositions in predicate logic: implication,
conjunction, disjunction, universal quantification, existential quantification, and negation.
In this way, we can carry out first order logic in MLTT, with one significant caveat: a
proposition in MLTT is considered to be true if we can give a proof of it, and thus MLTT
corresponds to constructive predicate logic. Since we do not necessarily know for any
given proposition whether or not we can give a proof of it, we do not know whether it is
true. Thus, from this point of view, we must reject the law of excluded middle. However,
its entirely possible to disregard this reading of MLTT by expressing the law of excluded
middle within MLTT, and then taking as an axiom that it holds.
The following table gives an overview of the logical reading of the types which we will
introduce in this section:
Type

Logical reading

AB
AB
A+B
(x : A)B(x)
(x : A)B(x)
A

Implication: if A is true, then B is true


Conjunction: both A and B are true
Disjunction: either A is true or B is true
Universal quantification: for all x, B(x) is true
Existential quantification: for some x, B(x) is true
Negation: A is not true

4.3 Rules
We have rules that prescribe new judgments which can be made given that we have
already made other judgments. Typically these are rules are written as follows (but this
notation is only one of several possibilities).
Some judgement
Some other judgement
Name of rule
Judgment thats true if the two judgments above are true
Under the Curry-Howard correspondence, this can be read as: if some proposition is
true, and some other proposition is true, then a third proposition is true. In this way,
rules can be thought of as functions on true propositions, where the premises are the
input and the conclusion is the output.

4.3.1 Formation rules


Formation rules concern how types themselves are introduced, specifying which terms
and types they depend upon. For example, the formation rule for a function type, which
we will explore in more detail later, looks as follows:

A : type
B : type
A B : type
It depends upoon two types, A and B. We do not, though, usually refer to A B as a
dependent type, because it does not depend upon the terms of any type.
Formation rules need not depend upon any types. For instance, the formation rule for
the type of natural numbers is as follows:
N : type
Given that we have a type A and a type B, well see that there are rules which allow
us to form new types such as A B, A B, and A + B. Iterated applications of type
formation rules allow us to construct ever more complex types, like for instance the one
bellow:
(A A B B) A + B.

4.3.2 Introduction rules


Introduction rules prescribe the canonical terms of a type. Here are the introduction
rules for the natural numbers:
0:N
a:N
successor(a) : N
The first rule establishes the existence of the natural number 0. The second rule
establishes that, if a is a natural number, then we can construct another natural number
successor(a).
We distinguish between canonical and non-canonical terms. The canonical expression of
the natural number 1 is successor(0), the canonical expression of 2 is
successor(successor(0)),
and so on. Thus 4, defined in this way as
successor(successor(successor(successor(0))))
is a canonical term of type N, while 3+1 and 22 are non-canonical terms of type N.
Introduction rules dont have to be inductive. For some types, there will simply be one
introduction rule for each canonical term. For example, if we were to define a type of
months in a year, we could add rules similar to the following one for each of the 12
months:
January : M onths
To give a different example, the type Boolean would have the following introduction
rules:

true : Boolean
f alse : Boolean

4.3.3 Elimination rules


While introduction rules prescribe the terms of a type, elimination rules prescribe what
can be done with them. As a rule of thumb, introduction rules of a type have the
canonical terms of that type as their output/conclusion, while the elimination rules of a
type have one or more terms of that type as their input/assumptions.
For example, the following is one of the elimination rules for the type A B, which we
will explore in more detail later:
p:AB
f irst(p) : A

4.3.4 Equality rules


Equality rules prescribe when terms of a type are equal. For example, the following is an
equality rule for the type of natural numbers:
a=b:N
successor(a) = successor(b) : N
The task of finding a canonical term equal to a non-canonical term, for instance of finding
a term of type N which is equal to 1 + 1, is often referred to as computation. Equality
rules allow such computations to be carried out.
In practise, equality rules typically behave in exactly the same way in all cases. Thus
they are typically omitted.

4.4 Sets vs types


The judgement A : type can also be read as A is a set, and the judgement a : A can
be read as a is an element of A. As we will discuss later in this section, the type
constructions of MLTT can be read as corresponding to various constructions of set
theory: sets of functions, products, and disjoint unions. However, as discussed in 3, this
reading, at least if sets are thought of in the ZFC sense, obscures much of the essential
nature of MLTT.
In ZFC, two sets are equal if their elements are equal. In other words, a set is entirely
determined by its elements. This is known as an extensional notion of a set. However, the
same two sets can arise in very different ways. A notion of set that takes into account how
the set is defined when considering equality is called intensional. To give an example, the

10

set of all numbers between 10 and 14 which are divisible by 3, and the set of all numbers
between 10 and 14 which are divisible by 6, are extensionally equal, but intensionally
distinct.
Equality of types in MLTT is an intensional notion: it cannot be reduced to checking
equalities of terms, unless this is forced as an additional rule.

4.5 Contexts
In MLTT, judgments are often made in context. That is to say, relying upon other
judgments having been made. For instance, the judgment a = b : A only makes sense if
A is a type, and if a and b are of type A. In other words, when we make the judgment
a = b : A, we presuppose the judgments, A : type, a : A, and b : A. We say that a = b : A
is a judgment in the context of the latter three judgments, and write:
A : type, a : A, b : A ` a = b : A.
Thus the judgment we are making, a = b : A in this case, is written to the right of the
symbol `, and the judgments which we are supposing to have been made are written
to the left of the symbol `, separated by commas. The order in which the presupposed
judgments are written, from left to right, is significant: judgments may presuppose those
to their left. For instance, the judgment a : A presupposes the judgment A : type:
A : type ` a : A.
Another notation that sometimes is used for the contexts is the following:
a : A[A : type]
In this notation the context is put inside the parenthesis.
Greek letters such as and are often used to represent contexts. In MLTT notation,
all or some of the context is often omitted when whats left out can be inferred without
ambiguity from the judgment being made.

4.6 The types of MLTT


We now introduce the fundamental ways to build types out of other types that already
have been established. We will mention some rules, but only those that are particularly
relevant to our discussion.

11

4.6.1 Function types


We have the following formation, introduction, and elimination rules.
A : type
B : type
Formation
A B : type
a : A ` f (a) : B
Introduction
f :AB
a:A

f :AB
Elimination
f (a) : B

We think of the terms of A B as functions from A to B. Under the set theoretic


reading of MLTT discussed in 4.4, the type A B corresponds to the set of functions
from the set A to the set B.
The term f : A B in the introduction rule is often denoted by a.f (a) : A B. The
latter notation originates in the -calculus, one of the most significant influences on
MLTT from a historical point of view. However, it has no meaning in our setting beyond
being a collection of symbols: any other notation could be used instead, even one which
does not refer to a or f . The introduction rule simply asserts that given an assignment
of a term f (a) of B to each term a of type A, we can construct a term of type A B.
With reference to 4.4, it is important to note that, unlike in set theory, equality of
functions, that is, of terms of A B, is intensional. Given two functions f and g, and
given that a : A ` f (a) = g(a) : B, we cannot conclude that f = g. An axiom, known as
functional extensionality, is often added to MLTT to allow this conclusion to be made.
Under the logical reading of MLTT discussed in 4.2, A B is thought of as the
proposition A B, or as we could say in natural language: if A is true, then B is true.
The introduction and elimination rules for A B correspond to asserting that to give a
proof of A B it is necessary and sufficient to explain how to construct a proof of B
given a proof of A.
Applying the formation rule several times, we can construct types such as A (B
(C D)). Implicit brackets were included here, to make it clear that a term of this
type would return a term of type (B (C D)) when applied to a term of type A.
Normally we simply write A B C D. For simplicity we often denote the term
thats obtained by repeated application of elimination rules (until whats left is a term of
type D) as f abc : D, or f (a, b, c) : D.
Function types often play an important role in organising the syntactics of MLTT.
Suppose for instance that we have a rule as follows.
a : A ` b(a) : B
c:C
In computer implementations of MLTT, such a rule will typically be encoded as asserting
that there is a term of type

12

A B C.
On a different note, a dependent type x : A ` B(x) : type can be viewed as a term of type
A type (assuming that there is a type type1 such that type : type1 ). This is typically
how dependent types are encoded in a computer implementation of MLTT.

4.6.2 Binary product types


We have the following formation, introduction, and elimination rules.
A : type
B : type
Formation
A B : type
a:A
b:B
Introduction
(a, b) : A B
p:AB
Elimination I
f irst(p) : A
p:AB
Elimination II
second(p) : B
In other words, a term of A B can be thought of as pair (a, b) of a term a of A, and a
term b of B. Under the set theoretic reading of MLTT discussed in 4.4, the type A B
corresponds to the set that is the binary product of the set A and the set B.
The denotations (a, b), f irst(p), and second(p) are arbitrary. Any other denotations
could have been used instead, even ones not referring to a, b, or p. All that is important
is that, in the case of the introduction rule for instance, we can construct a term of type
A B given a : A and b : B.
Under the logical reading of MLTT, A B is thought of as the proposition A B, or as
we would say in natural language: A and B are true. The introduction and elimination
rules for A B correspond to asserting that, to give a proof of A B, it is necessary and
sufficient to give a proof of A and to give a proof of B.

4.6.3 Binary sum types


We have the following formation and introduction rules.
A : type
B : type
Formation
A + B : type
a:A
Introduction I
i(a) : A + B
b:B
Introduction II
j(b) : A + B

13

Whilst we remarked in 4.6.2 that a term of type A B can be thought of as a pair (a, b)
of a term a of type A and a term b of type B, a term of type A + B can be thought of as
a term of either A or of B.
Under the set theoretic reading of MLTT discussed in 4.4, the type A + B corresponds
to the set that is the disjoint union of the set A and the set B. Under the logical reading
of MLTT, A + B is thought of as the proposition A B, or as we could say in natural
language: A or B are true. The introduction rule for A + B corresponds to asserting
that, to give a proof of A B, it is necessary and sufficient to either give a proof of A or
a proof of B.

4.6.4 Dependent product types


We have the following formation, introduction and elimination rules.
A : type
a : A ` B(a) : type
Formation
(a : A)B(a) : type
a : A ` f (a) : B(a)
Introduction
f : (a : A)B(a)
a:A
f : (a : A)B(a)
Elimination
a : A ` f (a) : B(a)
A term of type (a : A)B(a) can be thought of as a term of type B(a) for each a : A.
Under the set theoretic reading of MLTT discussed in 4.4, the type (a : A)B(a)
corresponds to the set that is the product aA B(a) of the sets B(a) for a A.
Dependent product types are a generalization of the function types of 4.6.1, which are a
special case of the dependent product type where we take B(a) to be B for each a : A.
A B is the same as (a : A)
Under the logical reading of MLTT, (a : A)B(a) is thought of as the proposition
a A B(a), or as we could say in natural language: B(a) is true for all a in A. The
introduction and elimination rules for (a : A)B(a) correspond to asserting that, to give
a proof of B(a) for all a in A, it is necessary and sufficient to explain how to construct a
proof of B(a) given an a A. This is subtly different from asserting that, for each term
a : A, we explain how to construct a proof of B(a).
It is not natural in type theory to speak of each term, or all terms of a given type. In
type theory, the emphasis is rather upon the fact that any given term of a certain type
A has an intensional meaning, specified by the definition of A, and it is this intensional
meaning that we make use of when working with terms of type A, so that it typically
does not matter which particular term we look at.
To give an example of the use of dependent products types when working with natural
languages, suppose that we have a dependent type x : P erson ` M ortal(x) of mortal

14

people. We would then express everyone is mortal, or, more precisely, every person is
mortal, by the type
(x : P erson)M ortal(x).
As a second example, making use of dependent types
x1 : P erson, x2 : P erson ` Enmity(x1 , x2 )
and
x1 : P erson, x2 : P erson ` F riendship(x1 , x2 )
expressing enmity and friendship.
We can express that two people with a common enemy are friends, or, more precisely,
every pair of people with a common enemy are friends, by the following type:



x1 : P erson x2 : P erson x3 : P erson


(y : Enmity(x1 , x2 ) z : Enmity(x3 , x2 ) F riendship(x1 , x3 )

4.6.5 Dependent sum types


We have the following formation, introduction, and elimination rules.
A : type
a : A ` B(a) : type
Formation
(a : A)B(a) : type
a : A ` b : B(a)
Introduction
(a, b) : (a : A)B(a)
p : (a : A)B(a)
Elimination I
f irst(p) : A
p : (a : A)B(a)

 Elimination II
second(p) : B f irst(p)
Dependent sum types are a generalisation of the binary product types of 4.6.2. A B
is really a special case of (a : A)B(a) where we take B(a) to be B for each a : A. A
term of type (a : A)B(a) can be thought of as a pair (a, b), where a is of type A, and b
is of type B(a). Under the set theoretic reading of MLTT discussed
in 4.4, the type
F
(a : A)B(a) corresponds to the set that is the disjoint union aA B(a) of the sets B(a)
for a A.
Under the logical reading of MLTT, (a : A)B(a) is thought of as the proposition
a A B(a), or as we would say in natural language: B(a) is true for some a. The
introduction and elimination rules for (a : A)B(a) correspond to asserting that, to give
a proof of a A, B(a), it is necessary and sufficient to give a proof of B(a) for some
a : A.

15

A natural language example of a dependent sum type would one that expresses the
proposition that friendships exist, or more precisely: There exists a person who is Bills
friend. Such a dependent sum type could look as follows:
(x : P erson)F riendship(x, Bill)
To give an example of a dependent product type that references a and dependent sum
type, we can express the proposition everybody has a friend by the following type:
(x : P erson)(y : P erson)F riendship(x, y).
To give an example of how the introduction and elimination rules of dependent types
can be made use of in practise, the following expresses type theoretically the following
argument: Socrates is a person; all people are mortal; hence there is a mortal person.
f : (x : P erson)M ortal(x)
Socrates : P erson
Socrates : P erson
f (Socrates) : M ortal(Socrates)
(Intro )

Socrates, f (Socrates) : (x : P erson)M ortal(x)

(Elim )

In a proof tree such as this, rules are applied sequentially from the top down. The
judgments below a line are can be made as a consequence of a rule which depends upon
the judgments above this line. The rules are indicated to the right of the line. Here
Elim is the elimination rule for dependent products, and Intro is the introduction
rule for dependent sums.

4.6.6 Empty type


We have the following formation and elimination rules:
: type

Formation

c:
A : type
Elimination
abort(c) : A
There is no introduction rule, that is to say, the type has no canonical terms. Under
the set theoretic reading of MLTT discussed in 4.4, the type corresponds to the empty
set.
Under the logical reading of MLTT, is thought of as falsity, . The elimination rule
for corresponds to the logical principle known as ex falso quodlibet. That is, given a
proof of falsity, one can give a proof of any proposition.
In constructive logic, negation of a proposition A (A is false ) is typically defined to be
the proposition A . Giving a proof of A is to demonstrate that a proof of A
implies a proof of falsity, which is to say that the negation of a proposition is true when
the truth of that proposition leads to a contradiction. Thus, when viewing a type A as
a proposition under the Curry-Howard correspondence, we think of the type A as
corresponding to the negation of A.

16

4.6.7 Identity types


We have seen that, under the Curry-Howard correspondence the connectives of predicate
logic correspond to certain type constructions. In addition to the logical connectives,
propositions asserting that two entities are equal is fundamental to predicate logic.
Identity types allow for an extension of the Curry-Howard correspondence to capture
propositional equality. Together with the use of dependent products and dependent sums
to extend the Curry-Howard correspondence to universal and existential quantification,
identity types are one of the major innovations of MLTT.
We have the following formation and introduction rules:
A : type
a:A
b:A
Formation
I(A, a, b) : type
a:A
Introduction
r(a) : I(A, a, a)
Under the logical reading of MLTT, I(A, a, b) is thought of as the proposition that a
and b are equal terms of type A. The terms of I(A, a, b) can be thought of as proofs
that a and b are equal terms of type A. The introduction rule can then be thought of as
corresponding to the fact that a = a for any a : A .
If I(A, a, b) has a proof, that is to say we can make the judgement a : A , b : A ` p :
I(A, a, b), we say, as we have already suggested, that a and b are propositionally equal. If
we can make the judgement a : A, b : A ` a = b : A, we say that a and b are definitionally
equal or judgementally equal. The term definitionally equal is sometimes reserved to
denote equality which just arises from giving the same term two different names or
notations, allowing for syntactic sugar, but its also commonly used in the way we have
described.
Under the set theoretic reading of MLTT, the type Id(A, a, b) corresponds either empty
set or to a set with one element, depending upon whether or not a and b are equal
elements of A. The following rule is sometimes added to MLTT, which ensures that this
is the case within MLTT too:
a : A, b : A ` p : I(A, a, b)
a=b:A
It asserts that if a : A and b : A are propositionally equal, then they are definitionally
equal. The resulting variant of MLTT is known as extensional MLTT, because the
intensional significance of the terms of type I(A, a, b), that is to say how a and b can be
proven to be equal (many proofs could be possible), is lost. It can be demonstrated that
in extensional MLTT, all terms of type I(A, a, b) become definitionally equal, that is to
say, extensional MLTT sees only one possible proof that a = b.
To give an example of a use of identity types in combination with various other types
which we have discussed, we can express the proposition a and b are equal terms of type

17

A, or b and c are not equal terms of type A by the type



I(A, a, b) + (I(A, b, c) .

18

Bibliography
[1] A. Chlipala, Certified programming with dependent types, 2011.
f, Intuitionistic Type Theory: Notes by Giovanni Sambin of a series
[2] P. Martin-Lo
of lectures given in Padova, June 1980, 1984.
[3] A. Ranta, Type-theoretical grammar, (1994).
, Grammatical framework, Journal of Functional Programming, 14 (2004), pp. 145

[4]
189.

[5] The Univalent Foundations Program, Homotopy Type Theory: Univalent


Foundations of Mathematics, http://homotopytypetheory.org/book, Institute for
Advanced Study, 2013.

19

You might also like