Type Inference Logics
Type inference is essential for statically-typed languages such as OCaml and Haskell. It can be decomposed into two (possibly interleaved) phases: a generator converts programs to constraints; a solver decides whether a constraint is satisfiable. Elaboration, the task of decorating a program with explicit type annotations, can also be structured in this way. Unfortunately, most machine-checked implementations of type inference do not follow this phase-separated, constraint-based approach. Those that do are rarely executable, lack effectful abstractions, and do not include elaboration. To close the gap between common practice in real-world implementations and mechanizations inside proof assistants, we propose an approach that enables modular reasoning about monadic constraint generation in the presence of elaboration. Our approach includes a domain-specific base logic for reasoning about metavariables and a program logic that allows us to reason abstractly about the meaning of constraints. To evaluate it, we report on a machine-checked implementation of our techniques inside the Coq proof assistant. As a case study, we verify both soundness and completeness for three elaborating type inferencers for the simply typed <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" display="inline"> <mml:mi>λ</mml:mi> </mml:math> -calculus with Booleans. Our results are the first demonstration that type inference algorithms can be verified in the same form as they are implemented in practice: in an imperative style, modularly decomposed into constraint generation and solving, and delivering elaborated terms to the remainder of the compiler chain.
Authors
- François Pottier (ORCID: https://orcid.org/0000-0002-4069-1235)
- Steven Keuchel (ORCID: https://orcid.org/0000-0001-6411-438X)
- Denis Carnier (ORCID: https://orcid.org/0000-0003-2148-5193)
Institutions
- Institut national de recherche en sciences et technologies du numérique (FR)
- Vrije Universiteit Brussel (BE)
- KU Leuven (BE)
Publication Details
- Journal
- Proceedings of the ACM on Programming Languages
- Published
- 2024-10-08
- DOI
- https://doi.org/10.1145/3689786
- Citations
- 3
- Primary Topic
- Logic, programming, and type systems
- Type
- article
- Field-Weighted Citation Impact
- 1.04
Funders
- European Commission
- KU Leuven
- Vlaamse regering