Fall 2001, CSE 520: Lectures 10 and 11

Properties of the type system of Curry

From the properties of FO unification, we have that:

Proposition For any term M, it is decidable whether M is typable or not, and in case it is, then it has a principal type.

This proposition is very important because it states that type inference/checking can be done effectively and without risk of looping.

Another important property is the following, which states that type inference/checking can be done once and for all at compile time, in the sense that if a program typechecks correctly then there is no risk of getting type errors at execution time.

Theorem (Subject reduction) If M : A and M ->> N then N : A.

Note that the converse (subject expansion) of this theorem does not hold. Namely, there are terms M and N such that M ->> N and N : A, but M is not typeable. Take for instance M = (\y x. x) Y and N = \x. x. Note that the reason why subject expansion does not hold is related to lazy evaluation.

Note also that reduction does not preserve the principal type. For instance, take M = \xy.[false](xy). Its principal type is T = (A -> B) -> A -> (C -> C). However M ->> \xyz.z, whose principal type is D -> A -> (C -> C), which is more general than T.

The system of Church and the Simply Typed Lambda Calculus

The system of Church is very similar to the system of Curry, the only difference is that each variable is explicitly typed (in the term) at the moment in which it is introduced. This philosophy (declare the type of every variable) is adopted in several programming languages, for instance C, C++, Java, Pascal, lambda Prolog, ... On the contrary, ML adopts the more liberal approach of the system of Curry.

The language of Simply Typed lambda terms is defined by the following grammar:

   Term ::= Var | (\Var : Type . Term) | (Term Term)
Type expressions are defined as usual:
   Type ::= TVar | (Type -> Type)
The rules are identical to those of Curry, the only difference is the abs rule, which is forced to introduce the argument type specified in the abstraction variable:
            G , x : A |- M : B
   (abs) -------------------------
          G |- (\x:A. M) : A -> B

Properties of the Simply Typed Lambda Calculus

The important properties of the Lambda Calculus and of the Curry system hold also for the Simply Typed Lambda Calculus and the Church system. In particular the following properties hold: Furthermore, in this system the type of a term is unique:


The property of uniqueness of type derives from the fact that we do not have the flexibility to choose the type of the abstraction variables.

Note also that the type variables are called "variables" only because they represent arbitrary types, but they are not meant to be substituted for some other type expressions. In other words, in the proof of a type statement, two type expressions are considered equal only if they are syntactically identical.


Also in the type system of Curry the type variables represent arbitrary types, but in the proof of a type statement we allow unification of type expressions. However, this is not because type variables are seen differently than in Church, but rather because we are trying to find a possible type for our term (type inference), and to do so we have the possibility of constructing the right types for the abstraction variables.

In conclusion: This symple type system of Church is not polymorphic. The type system of Curry has more "polymorphic flavor", in the sense that one term can have many types. However also the system of Curry is not completely satisfactory from this point of view. We will see that certain forms of polymorphism which are used, for instance, in ML, require an extension of the system of Curry (let-polymorphism).

Relation between the systems of Curry and of Church

Given a simply-typed lambda term M, let |M| denote the lambda term obtained from M by removing the type decorations. Then we have that if M is Church-typeable then |M| is Curry-typeable. Viceversa, if a lambda term N is Curry-typeable, then we can find suitable type for the bound variables of N, so to obtain a term typeable in Church. More precisely:


  1. If M : A in Church, then |M| : A in Curry. (Note that the viceversa does not hold. Also note that A is not necessarily the principal type of |M|.)
  2. If N : A in Curry, then there exists a simply-typed lambda term M such that M : A in Church and |M| = N.
Note that, as a consequence of this proposition, we have that a type is inhabited in Curry iff it is inhabited in Church.