Types
Types
Like our operational semantics, the typing relation is defined using a set of
inference rules.
Another way to say it: the type relation is not total on terms.
Another way to say it: the type relation is not total on terms.
The typing relation for arithmetic expressions is the smallest binary relation
between terms and types satisfying all the typing rules given in the last two
figures.
A term t is well-typed if there is some T such that t : T
When talking about types, we will often make statements like:
If a term of the form succ t1 has any type at all, then it has type Nat.
There is a sort of information flow, up and down the AST, of typing
information.
The following inversion rules are immediately derivable from our typing rules:
Taken together, we can say that any well-typed term will eventually
evaluate to a well-typed value without getting stuck.
We can argue this inductively over evaluation derivations.
The canonical forms of a type are the values which have that type.
THEOREM : [Progress]
Suppose t : T . Then t is either a value, or else there is some t ′ such that
t → t ′.
T-If:
t = if t1 then t2 else t3 (9)
By inversion:
t1 : Bool t2 : T t3 : T
t : T ∧ t → t ′ =⇒ t ′ : T (10)