Proofs about a folklore let-polymorphic type inference algorithm

The Hindley/Milner let-polymorphic type inference system has two different algorithms: one is the <italic>de facto</italic>standard Algorithm <inline-equation> <f><sc>W</sc></f></inline-equation> that is bottom-up (or context-insensitive), and the other is a “folklore” algorithm that is top-down (or context-sensitive). Because the latter algorithm has not been formally presented with its soundness and completeness proofs, and its relation with the <inline-equation> <f><sc>W</sc></f></inline-equation> algorithm has not been rigorously investigated, its use in place of (or in combination with) <inline-equation> <f><sc>W</sc></f></inline-equation> is not well founded. In this article, we formally define the context-sensitive, top-down type inference algorithm (named “<inline-equation> <f><sc>M</sc></f></inline-equation>”), prove its soundness and completeness, and show a distinguishing property that <inline-equation> <f><sc>M</sc></f></inline-equation> always stops earlier than <inline-equation> <f><sc>W</sc></f></inline-equation> if the input program is ill typed. Our proofs can be seen as theoretical justifications for various type-checking strategies being used in practice.