##
*Fall 2001, CSE 520:
Lecture 7*

# The Symply Typed Lambda Calculus

The typed lambda calculus provides foundations for the concept of type,
which is used in all modern high-level programming languages.
Some of the advantages of having a notion of type are;
- Readability
- Static correctness
- Efficiency of implementation
- Modularity (interfaces of modules, inheritance,...)

There are two main type systems for the simply typed
Lambda Calculus: The system of Curry (1934) and the system of Church (1940).

The system of Curry is the basis of typed languages like ML, where
variables do not require explicit type annotation.
The type system of Church is the basis of languages like Pascal and C,
where the type of every variable must be declared.

## The Type System of Curry

Hystorical note: Haskell Curry lived in State College and worked at the
Mathematical Department of Penn State! See the dedication to him at the
entrance of the Math building.
In this system, the syntax of Lambda terms is the same as in the
untyped version.

The types are defined by the following grammar:

`Type ::=
TVar
`(type variable)

` | (Type -> Type)
`(function)

Convention: In order to eliminate some parentheses,
we assume` -> `to be right associative.
So` (A`_{1} -> (A_{2} -> (A_{3} -> ... (A_{n-1} -> A_{n}) ... ))) will be
written simply as` A`_{1} -> A_{2} -> A_{3} -> ... A_{n-1} -> A_{n}.

The system allows to derive statements of the following form:

G |- M : A

meaning: under the assumptions G
(asociations between lambda variables and types),
the lambda term M
has type A.
The rules for the Type System are the following:

(var) --------------- if x : A is in G
G |- x : A
G |- M : A -> B G |- N : A
(app) ----------------------------------
G |- M N : B
G , x : A |- M : B
(abs) ------------------------
G |- \x. M : A -> B

In the following, the statement "`M` has type `A`"
(or equivalently, "`A` is a type of `M`"),
notation `|- M : A ` or simply `M : A`, stands for
"the statement `{} |- M : A` has a proof in the type system of Curry".
Note that the set of assumptions must be empty.