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 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
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).