Well-typed Programs Are not Wrong
Abstract
We consider prescriptive type systems for logic programs (as in
Gödel or Mercury). In such systems, the typing is static, but
it guarantees an operational property: if a program is ``well-typed'',
then all derivations starting in a ``well-typed'' goal are again
``well-typed''. This property has been called subject
reduction. We show that this property is actually also
declarative. This declarative view leads us to questioning a condition
which is usually considered necessary for subject reduction, namely
the head condition. It states that the head of each clause must
have a type which is a variant (and not a proper instance) of the
declared type. We provide a more general condition, thus
reestablishing a certain symmetry between heads and body atoms. The
condition ensures that in a derivation, the types of unifiable
atoms are also unifiable.