You are on page 1of 94

Type systems:

revisited

Curry-Howard
Martin-Löf’s Type Theory correspondence

Martin-Löf’s type
theory

Bas van Gijzel

October 6, 2010

1
Outline

Type systems:
revisited

Curry-Howard
Type systems: revisited correspondence

Martin-Löf’s type
theory

Curry-Howard correspondence

Martin-Löf’s type theory

2
Outline

Type systems:
revisited

Curry-Howard
Type systems: revisited correspondence

Martin-Löf’s type
theory

Curry-Howard correspondence

Martin-Löf’s type theory

3
Why type systems?

Type systems:
revisited

Curry-Howard
correspondence

Martin-Löf’s type
theory

4
Why type systems?

“A type system is a tractable syntactic method for Type systems:


revisited
proving the absence of certain program behaviors
Curry-Howard
by classifying phrases according to the kinds of correspondence

values they compute.” (Pierce2002) Martin-Löf’s type


theory

4
Why type systems?

“A type system is a tractable syntactic method for Type systems:


revisited
proving the absence of certain program behaviors
Curry-Howard
by classifying phrases according to the kinds of correspondence

values they compute.” (Pierce2002) Martin-Löf’s type


theory

I Normally about programs, but too narrow for us.

4
Why type systems?

“A type system is a tractable syntactic method for Type systems:


revisited
proving the absence of certain program behaviors
Curry-Howard
by classifying phrases according to the kinds of correspondence

values they compute.” (Pierce2002) Martin-Löf’s type


theory

I Normally about programs, but too narrow for us.


I Tractable, trade-off between manual type annotation
and automatic type inference.

4
Why type systems?

“A type system is a tractable syntactic method for Type systems:


revisited
proving the absence of certain program behaviors
Curry-Howard
by classifying phrases according to the kinds of correspondence

values they compute.” (Pierce2002) Martin-Löf’s type


theory

I Normally about programs, but too narrow for us.


I Tractable, trade-off between manual type annotation
and automatic type inference.
I Syntactic, by classification of terms. Static.

4
Why type systems?

“A type system is a tractable syntactic method for Type systems:


revisited
proving the absence of certain program behaviors
Curry-Howard
by classifying phrases according to the kinds of correspondence

values they compute.” (Pierce2002) Martin-Löf’s type


theory

I Normally about programs, but too narrow for us.


I Tractable, trade-off between manual type annotation
and automatic type inference.
I Syntactic, by classification of terms. Static.
I Absence, only categorical absence of bad behaviour
can be proved. (rejecting legal programs)

4
Type checking

Type systems:
revisited

Curry-Howard
I Type checking of terms is done automatically by the correspondence

compiler. Martin-Löf’s type


theory

5
Type checking

Type systems:
revisited

Curry-Howard
I Type checking of terms is done automatically by the correspondence

compiler. Martin-Löf’s type


theory

Two options: Type annotations versus type inference.


I Annotations are easy to check, but harder to write.
I Inference is easy for the programmer but hard for the
compiler.
I Tractability of type inference for dependent types?

5
Types and terms

Type systems:
revisited

Curry-Howard
correspondence

In a typed programming language we want to be able to Martin-Löf’s type


theory
construct terms and types.

6
Types and terms

Type systems:
revisited

Curry-Howard
correspondence

In a typed programming language we want to be able to Martin-Löf’s type


theory
construct terms and types.

Furthermore, we want to make a connection between both,


using a so called typing relation.

6
Terms

Terms of an example arithmetic language: Type systems:


revisited

t : : = true Curry-Howard
correspondence
false Martin-Löf’s type
i f t then t e l s e t theory

0
succ t
pred t
t + t
iszero t

7
Terms

Terms of an example arithmetic language: Type systems:


revisited

t : : = true Curry-Howard
correspondence
false Martin-Löf’s type
i f t then t e l s e t theory

0
succ t
pred t
t + t
iszero t
And we want to be able to use a set of variables: {x, y, x1 , ...}
representing arbitrary terms.

7
Types

Type systems:
revisited

Curry-Howard
correspondence

Martin-Löf’s type
Types of this example arithmetic language: theory

T : : = Bool
Nat

8
Typing simple expressions

Type systems:
revisited

Curry-Howard
So now we can already type most of our expressions. For correspondence

Martin-Löf’s type
example: theory

9
Typing simple expressions

Type systems:
revisited

Curry-Howard
So now we can already type most of our expressions. For correspondence

Martin-Löf’s type
example: theory

3 : Nat

9
Typing simple expressions

Type systems:
revisited

Curry-Howard
So now we can already type most of our expressions. For correspondence

Martin-Löf’s type
example: theory

3 : Nat
(if true then 4 else 5) : Nat.

9
Typing simple expressions

Type systems:
revisited

Curry-Howard
So now we can already type most of our expressions. For correspondence

Martin-Löf’s type
example: theory

3 : Nat
(if true then 4 else 5) : Nat.
succ true will not be correctly typed.

9
Environments (contexts) (1)

Type systems:
But before we’re able to fully construct a typing relation we revisited

Curry-Howard
would need to be able to type expression like these: correspondence

Martin-Löf’s type
theory

10
Environments (contexts) (1)

Type systems:
But before we’re able to fully construct a typing relation we revisited

Curry-Howard
would need to be able to type expression like these: correspondence

Martin-Löf’s type
x + 3, theory

if x then 3 else 5,
etc.

10
Environments (contexts) (1)

Type systems:
But before we’re able to fully construct a typing relation we revisited

Curry-Howard
would need to be able to type expression like these: correspondence

Martin-Löf’s type
x + 3, theory

if x then 3 else 5,
etc.

I We will need to know the type of variables.


I This type depends on a current context/typing
environment.

10
Environments (contexts) (2)

Type systems:
revisited

Curry-Howard
correspondence
An environment can be build up by starting with the empty Martin-Löf’s type
theory
environment and by adding bindings.

11
Environments (contexts) (2)

Type systems:
revisited

Curry-Howard
correspondence
An environment can be build up by starting with the empty Martin-Löf’s type
theory
environment and by adding bindings.

Γ ::= 
| Γ ,x : T

11
Typing relation

We know have the elements needed to construct a typing Type systems:


revisited
relation for a given environment. Curry-Howard
correspondence

Martin-Löf’s type
theory

12
Typing relation

We know have the elements needed to construct a typing Type systems:


revisited
relation for a given environment. Curry-Howard
correspondence

Γ `t :T Martin-Löf’s type
theory

12
Typing relation

We know have the elements needed to construct a typing Type systems:


revisited
relation for a given environment. Curry-Howard
correspondence

Γ `t :T Martin-Löf’s type
theory

I This statement can be read as:


in environment Γ , the term t has type T .

12
Typing relation

We know have the elements needed to construct a typing Type systems:


revisited
relation for a given environment. Curry-Howard
correspondence

Γ `t :T Martin-Löf’s type
theory

I This statement can be read as:


in environment Γ , the term t has type T .
I The statement “t has type T (given context Γ )” is a type
of judgement.
I For this simply arithmetic language this is the only type
of judgement.

12
Type rules

Type systems:
revisited
I To construct the typing relation we use type rules in Curry-Howard
Gentzen style natural deduction. correspondence

Martin-Löf’s type
I Inference rules come in two forms, with and without theory

assumptions.

13
Type rules

Type systems:
revisited
I To construct the typing relation we use type rules in Curry-Howard
Gentzen style natural deduction. correspondence

Martin-Löf’s type
I Inference rules come in two forms, with and without theory

assumptions.

Γ ,x:Nat,Γ 0 `x:Nat (axiom)

Γ `M :Nat Γ `N :Nat
Γ `M +N :Nat (inference rule)

13
Outline

Type systems:
revisited

Curry-Howard
Type systems: revisited correspondence

Martin-Löf’s type
theory

Curry-Howard correspondence

Martin-Löf’s type theory

14
Lambda calculus and natural deduction(1)

Type systems:
Assuming a simply-typed lambda calculus, some standard revisited

Curry-Howard
type (inference) rules would be: correspondence

Martin-Löf’s type
theory

15
Lambda calculus and natural deduction(1)

Type systems:
Assuming a simply-typed lambda calculus, some standard revisited

Curry-Howard
type (inference) rules would be: correspondence

Martin-Löf’s type
Γ ,x:α`t:β theory
Γ1 ,x:α,Γ2 `x:α (axiom) Γ `λx.t:α→β (function abstraction)

Γ `t:α→β Γ `u:α
Γ `t u:β (function application)

15
Lambda calculus and natural deduction(1)

Type systems:
Assuming a simply-typed lambda calculus, some standard revisited

Curry-Howard
type (inference) rules would be: correspondence

Martin-Löf’s type
Γ ,x:α`t:β theory
Γ1 ,x:α,Γ2 `x:α (axiom) Γ `λx.t:α→β (function abstraction)

Γ `t:α→β Γ `u:α
Γ `t u:β (function application)

I Expanding on Curry, Howard noticed a syntactic


correspondence between simply-typed lambda calculus
and natural deduction.

15
Lambda calculus and natural deduction(2)

I Lambda calculus:
Type systems:
revisited
Γ ,x:α`t:β
Γ1 ,x:α,Γ2 `x:α (axiom) Γ `λx.t:α→β (function abstraction)
Curry-Howard
correspondence

Martin-Löf’s type
theory
Γ `t:α→β Γ `u:α
Γ `t u:β (function application)

16
Lambda calculus and natural deduction(2)

I Lambda calculus:
Type systems:
revisited
Γ ,x:α`t:β
Γ1 ,x:α,Γ2 `x:α (axiom) Γ `λx.t:α→β (function abstraction)
Curry-Howard
correspondence

Martin-Löf’s type
theory
Γ `t:α→β Γ `u:α
Γ `t u:β (function application)

I (Intuitionistic implicational) natural deduction:

Γ ,α`β
Γ1 ,α,Γ2 `α (axiom) Γ `α→β (→ introduction)

Γ `α→β Γ `α
Γ `β (→ elimination)

16
Curry-Howard correspondence (1)

Type systems:
revisited

Curry-Howard
correspondence
The Curry-Howard correspondence is a correspondence
Martin-Löf’s type
between propositions and types, and proofs and programs. theory

17
Curry-Howard correspondence (1)

Type systems:
revisited

Curry-Howard
correspondence
The Curry-Howard correspondence is a correspondence
Martin-Löf’s type
between propositions and types, and proofs and programs. theory

I The type of a function corresponds to a logical


proposition.

17
Curry-Howard correspondence (1)

Type systems:
revisited

Curry-Howard
correspondence
The Curry-Howard correspondence is a correspondence
Martin-Löf’s type
between propositions and types, and proofs and programs. theory

I The type of a function corresponds to a logical


proposition.
I The program (function) implementing that type
corresponds to a proof of that logical proposition.

17
Curry-Howard correspondence (2) (exercise)

Type systems:
revisited

Curry-Howard
Given: correspondence

Martin-Löf’s type
Γ ,α`β theory
Γ1 ,α,Γ2 `α (axiom) Γ `α→β (→ introduction)

Γ `α→β Γ `α
Γ `β (→ elimination)

18
Curry-Howard correspondence (2) (exercise)

Type systems:
revisited

Curry-Howard
Given: correspondence

Martin-Löf’s type
Γ ,α`β theory
Γ1 ,α,Γ2 `α (axiom) Γ `α→β (→ introduction)

Γ `α→β Γ `α
Γ `β (→ elimination)

Try proving ` α → (β → α)!

18
Outline

Type systems:
revisited

Curry-Howard
Type systems: revisited correspondence

Martin-Löf’s type
theory

Curry-Howard correspondence

Martin-Löf’s type theory

19
Type theory: a programming language

Type systems:
revisited
I Per Martin-Löf developed a formalism for constructive
Curry-Howard
mathematics, the intuitionistic theory of types. correspondence

Martin-Löf’s type
theory

20
Type theory: a programming language

Type systems:
revisited
I Per Martin-Löf developed a formalism for constructive
Curry-Howard
mathematics, the intuitionistic theory of types. correspondence

Martin-Löf’s type
I By C-H, this formalism can also be used for program theory

construction and is actually well-suited for it.


I So both specifications and programs are easily made in
the same formalism.

20
Type theory: a programming language

Type systems:
revisited
I Per Martin-Löf developed a formalism for constructive
Curry-Howard
mathematics, the intuitionistic theory of types. correspondence

Martin-Löf’s type
I By C-H, this formalism can also be used for program theory

construction and is actually well-suited for it.


I So both specifications and programs are easily made in
the same formalism.
I Constructing a program means proving it correct and
reversely.

20
Type theory: a programming language

Type systems:
revisited
I Per Martin-Löf developed a formalism for constructive
Curry-Howard
mathematics, the intuitionistic theory of types. correspondence

Martin-Löf’s type
I By C-H, this formalism can also be used for program theory

construction and is actually well-suited for it.


I So both specifications and programs are easily made in
the same formalism.
I Constructing a program means proving it correct and
reversely.
I So: a type theory as programming language.

20
Constructive mathematics

Type systems:
I Proofs should be constructive! revisited
• Classical logic uses rules such as “excluded middle” Curry-Howard
correspondence
(tertium non datur) and reductio ad absurdum (RAA).
Martin-Löf’s type
theory

21
Constructive mathematics

Type systems:
I Proofs should be constructive! revisited
• Classical logic uses rules such as “excluded middle” Curry-Howard
correspondence
(tertium non datur) and reductio ad absurdum (RAA).
Martin-Löf’s type
theory
I However, we’re not able to prove Γ ` α ∨ ¬α from
nothing. This would amount to having a proof, and thus
a program, of either one of these propositions.

21
Constructive mathematics

Type systems:
I Proofs should be constructive! revisited
• Classical logic uses rules such as “excluded middle” Curry-Howard
correspondence
(tertium non datur) and reductio ad absurdum (RAA).
Martin-Löf’s type
theory
I However, we’re not able to prove Γ ` α ∨ ¬α from
nothing. This would amount to having a proof, and thus
a program, of either one of these propositions.
I We would need either a proof for α or a proof for ¬α
and then construct the disjunction from that.

21
Constructive mathematics

Type systems:
I Proofs should be constructive! revisited
• Classical logic uses rules such as “excluded middle” Curry-Howard
correspondence
(tertium non datur) and reductio ad absurdum (RAA).
Martin-Löf’s type
theory
I However, we’re not able to prove Γ ` α ∨ ¬α from
nothing. This would amount to having a proof, and thus
a program, of either one of these propositions.
I We would need either a proof for α or a proof for ¬α
and then construct the disjunction from that.
I Also important, because we want total correctness, the
programming language will also need to be total.

21
Haskell and the Curry-Howard correspondence

Type systems:
revisited

Curry-Howard
correspondence

Martin-Löf’s type
theory
Question:
Why do we need totality? (Think of Haskell or fix.)

22
Formalising constructive mathematics

Type systems:
One of the main issues of formalising constructive revisited
mathematics was to fully make the mathematics explicit. Curry-Howard
correspondence

Martin-Löf’s type
theory

23
Formalising constructive mathematics

Type systems:
One of the main issues of formalising constructive revisited
mathematics was to fully make the mathematics explicit. Curry-Howard
correspondence
This is in contrast to normal natural deduction rules:
Martin-Löf’s type
theory
A
A ∨B

23
Formalising constructive mathematics

Type systems:
One of the main issues of formalising constructive revisited
mathematics was to fully make the mathematics explicit. Curry-Howard
correspondence
This is in contrast to normal natural deduction rules:
Martin-Löf’s type
theory
A
A ∨B

Here it is implicit that A and B are formulas and how they


are constructed.

23
Formalising constructive mathematics

Type systems:
One of the main issues of formalising constructive revisited
mathematics was to fully make the mathematics explicit. Curry-Howard
correspondence
This is in contrast to normal natural deduction rules:
Martin-Löf’s type
theory
A
A ∨B

Here it is implicit that A and B are formulas and how they


are constructed.
I So instead:
A prop. B prop. A true
A ∨ B true

23
Proposition as sets

Type systems:
revisited
I In Martin-Löf’s type theory propositions are interpreted Curry-Howard
correspondence
as sets whose elements represent the proofs of the
Martin-Löf’s type
proposition. theory

24
Proposition as sets

Type systems:
revisited
I In Martin-Löf’s type theory propositions are interpreted Curry-Howard
correspondence
as sets whose elements represent the proofs of the
Martin-Löf’s type
proposition. theory

I The following correspondences hold:

24
Proposition as sets

Type systems:
revisited
I In Martin-Löf’s type theory propositions are interpreted Curry-Howard
correspondence
as sets whose elements represent the proofs of the
Martin-Löf’s type
proposition. theory

I The following correspondences hold:


• a ∈ A.

24
Proposition as sets

Type systems:
revisited
I In Martin-Löf’s type theory propositions are interpreted Curry-Howard
correspondence
as sets whose elements represent the proofs of the
Martin-Löf’s type
proposition. theory

I The following correspondences hold:


• a ∈ A.
• a is a proof of the proposition A .

24
Proposition as sets

Type systems:
revisited
I In Martin-Löf’s type theory propositions are interpreted Curry-Howard
correspondence
as sets whose elements represent the proofs of the
Martin-Löf’s type
proposition. theory

I The following correspondences hold:


• a ∈ A.
• a is a proof of the proposition A .
• a is an object in the type A .

24
Proposition as sets

Type systems:
revisited
I In Martin-Löf’s type theory propositions are interpreted Curry-Howard
correspondence
as sets whose elements represent the proofs of the
Martin-Löf’s type
proposition. theory

I The following correspondences hold:


• a ∈ A.
• a is a proof of the proposition A .
• a is an object in the type A .
• a is a program with the specification A .

24
Proposition as sets

Type systems:
revisited
I In Martin-Löf’s type theory propositions are interpreted Curry-Howard
correspondence
as sets whose elements represent the proofs of the
Martin-Löf’s type
proposition. theory

I The following correspondences hold:


• a ∈ A.
• a is a proof of the proposition A .
• a is an object in the type A .
• a is a program with the specification A .
• a is a solution to the problem A .

24
Judgements

Type systems:
Four (or five) types of judgements: revisited

Curry-Howard
1. A is a set. (proposition) correspondence

Martin-Löf’s type
theory

25
Judgements

Type systems:
Four (or five) types of judgements: revisited

Curry-Howard
1. A is a set. (proposition) correspondence

Martin-Löf’s type
2. A1 and A2 are equal sets. (equal propositions) theory

25
Judgements

Type systems:
Four (or five) types of judgements: revisited

Curry-Howard
1. A is a set. (proposition) correspondence

Martin-Löf’s type
2. A1 and A2 are equal sets. (equal propositions) theory

3. α is an element in the set A . (α is a proof for


proposition A )

25
Judgements

Type systems:
Four (or five) types of judgements: revisited

Curry-Howard
1. A is a set. (proposition) correspondence

Martin-Löf’s type
2. A1 and A2 are equal sets. (equal propositions) theory

3. α is an element in the set A . (α is a proof for


proposition A )
4. α1 and α2 are equal elements in the set A . (α1 and α2
equal proofs for proposition A .)

25
Judgements

Type systems:
Four (or five) types of judgements: revisited

Curry-Howard
1. A is a set. (proposition) correspondence

Martin-Löf’s type
2. A1 and A2 are equal sets. (equal propositions) theory

3. α is an element in the set A . (α is a proof for


proposition A )
4. α1 and α2 are equal elements in the set A . (α1 and α2
equal proofs for proposition A .)
5. A is non-empty. (proposition A is true. This can be seen
as 3. without naming a)

25
Sets, constructively (1)

Type systems:
revisited

Continuing to make concepts explicit, we need to make the Curry-Howard


correspondence
semantics of our judgements explicit. Martin-Löf’s type
theory

26
Sets, constructively (1)

Type systems:
revisited

Continuing to make concepts explicit, we need to make the Curry-Howard


correspondence
semantics of our judgements explicit. Martin-Löf’s type
theory
I What does the judgement “A is a set” mean?
I What is a set?

26
Sets, constructively (1)

Type systems:
revisited

Continuing to make concepts explicit, we need to make the Curry-Howard


correspondence
semantics of our judgements explicit. Martin-Löf’s type
theory
I What does the judgement “A is a set” mean?
I What is a set?
Characterise its members:
a∈N
0∈N a 0 ∈N

26
Sets, constructively (2)

Type systems:
revisited

Curry-Howard
correspondence
Characterise its members:
Martin-Löf’s type
theory
a∈N
0∈N a 0 ∈N

27
Sets, constructively (2)

Type systems:
revisited

Curry-Howard
correspondence
Characterise its members:
Martin-Löf’s type
theory
a∈N
0∈N a 0 ∈N

I What about 2010 ?

27
Sets, constructively (2)

Type systems:
revisited

Curry-Howard
correspondence
Characterise its members:
Martin-Löf’s type
theory
a∈N
0∈N a 0 ∈N

I What about 2010 ?


I We need to know when two elements are equal.

27
Canonical expressions

Type systems:
To be able to define equality we first need the notion of revisited

canonical expression. Curry-Howard


correspondence

Martin-Löf’s type
theory

28
Canonical expressions

Type systems:
To be able to define equality we first need the notion of revisited

canonical expression. This notion is equivalent to the Curry-Howard


correspondence
weak-head normal form in a lazy language such as Haskell.
Martin-Löf’s type
theory

28
Canonical expressions

Type systems:
To be able to define equality we first need the notion of revisited

canonical expression. This notion is equivalent to the Curry-Howard


correspondence
weak-head normal form in a lazy language such as Haskell.
Martin-Löf’s type
theory
I For equality on expressions, we need equality of
canonical expressions.

28
Canonical expressions

Type systems:
To be able to define equality we first need the notion of revisited

canonical expression. This notion is equivalent to the Curry-Howard


correspondence
weak-head normal form in a lazy language such as Haskell.
Martin-Löf’s type
theory
I For equality on expressions, we need equality of
canonical expressions.
I Similar to before, we need this to be explicit.

28
Canonical expressions

Type systems:
To be able to define equality we first need the notion of revisited

canonical expression. This notion is equivalent to the Curry-Howard


correspondence
weak-head normal form in a lazy language such as Haskell.
Martin-Löf’s type
theory
I For equality on expressions, we need equality of
canonical expressions.
I Similar to before, we need this to be explicit.
I This is reflected in another type of judgement, “α1 and
α2 are equal elements in the set A ”.

28
Canonical expressions

Type systems:
To be able to define equality we first need the notion of revisited

canonical expression. This notion is equivalent to the Curry-Howard


correspondence
weak-head normal form in a lazy language such as Haskell.
Martin-Löf’s type
theory
I For equality on expressions, we need equality of
canonical expressions.
I Similar to before, we need this to be explicit.
I This is reflected in another type of judgement, “α1 and
α2 are equal elements in the set A ”.
I Equality between canonical expressions should be
reflexive, transitive and symmetric.

28
Definition of a set

The definition of a set (Nordström(1990)): Type systems:


revisited
“To know that A is a set is to know how to form the Curry-Howard
canonical elements in the set and under what correspondence

Martin-Löf’s type
conditions two canonical elements are equal.” theory

29
Definition of a set

The definition of a set (Nordström(1990)): Type systems:


revisited
“To know that A is a set is to know how to form the Curry-Howard
canonical elements in the set and under what correspondence

Martin-Löf’s type
conditions two canonical elements are equal.” theory

To construct a set (Nordström(1990)):


I “Give a prescription of how to form (construct) the
canonical elements, i.e. define the syntax of the
canonical expressions and the premises for forming
them.”
I “Give the premises for forming two equal canonical
elements.”

29
Example of a set

Type systems:
revisited

Curry-Howard
Again: correspondence

Martin-Löf’s type
a∈N theory

0∈N a 0 ∈N

30
Example of a set

Type systems:
revisited

Curry-Howard
Again: correspondence

Martin-Löf’s type
a∈N theory

0∈N a 0 ∈N
And now also:
a = b ∈N
0=0 a 0 = b 0 ∈N

30
General rules of equality

Type systems:
revisited

Curry-Howard
correspondence
Some rules for equality: Martin-Löf’s type
theory
a∈A A type
a=a∈A A =A (Reflexivity)
a=b ∈A b =c∈A A =B B =C
a=c∈A A =C (Transitivity)

31
Definitions of other judgements etc.

Type systems:
revisited

Curry-Howard
correspondence

Martin-Löf’s type
theory
Similar to the concepts of sets we need to define semantics
of judgements under assumptions, etc.

32
Definitions of other judgements etc.

Type systems:
revisited

Curry-Howard
correspondence

Martin-Löf’s type
theory
Similar to the concepts of sets we need to define semantics
of judgements under assumptions, etc.
(See Nordström(1990) or Per Martin-Löf (1984b).)

32
Martin Löf and dependent types

Type systems:
I Similar to the general rules for equality and union, revisited

Martin Löf’s type theory also has constructors for Curry-Howard


correspondence
products. Martin-Löf’s type
theory

33
Martin Löf and dependent types

Type systems:
I Similar to the general rules for equality and union, revisited

Martin Löf’s type theory also has constructors for Curry-Howard


correspondence
products. Martin-Löf’s type
theory
I The argument of the products can be dependent
however.

33
Martin Löf and dependent types

Type systems:
I Similar to the general rules for equality and union, revisited

Martin Löf’s type theory also has constructors for Curry-Howard


correspondence
products. Martin-Löf’s type
theory
I The argument of the products can be dependent
however.

(x ∈ A )
A type B (x) type
Π(A ,B ) type

33
Martin Löf and dependent types

Type systems:
I Similar to the general rules for equality and union, revisited

Martin Löf’s type theory also has constructors for Curry-Howard


correspondence
products. Martin-Löf’s type
theory
I The argument of the products can be dependent
however.

(x ∈ A )
A type B (x) type
Π(A ,B ) type

For example take for A : N, and for B (n):BoolVectors taking


a natural number as length argument.

33
Agda and the Curry-Howard correspondence

I “Agda is essentially an extension of intensional Type systems:


revisited
Martin-Löf type theory based on a logical framework.”
Curry-Howard
(Agda wiki) correspondence

Martin-Löf’s type
I Agda is total and we can easily see the correspondence theory

with Martin-Löf.
data > : Set where (True proposition)
tt : >
data ⊥ : Set where (False proposition)

data _ ] _ (A B : Set) where (Disjunction)


inj1 : A → A ] B
inj2 : B → A ] B

34
References

I Gilles Barthe and Thierry Coquand. An Introduction to


Dependent Type Theory. Type systems:
revisited
I Per Martin-Löf (1984a). Constructive Mathematics and Curry-Howard
correspondence
Computer Programming. Martin-Löf’s type
theory
I Per Martin-Löf (1984b). Intuitionistic Type Theory.
Bibliopolis.
I Bengt Nordström, Kent Petersson, Jan M. Smith (1990).
Programming in Martin-Löf’s type theory. Oxford
University Press.
I Benjamin Pierce (2002). Types and Programming
Languages. MIT Press.
I Simon Thompson (1999). Type Theory & Functional
Programming.

35
Questions

Type systems:
revisited

Curry-Howard
correspondence

Martin-Löf’s type
theory

36

You might also like