[Paper Review] Implicit Polarized F: local type inference for impredicativity
This paper introduces Implicit Polarized F, a novel type inference system for impredicative polymorphism in System F that leverages call-by-push-value duality to enable local type inference without unification. By reformulating System F with explicit polarity shifts, the approach achieves decidable, declarative type inference that naturally explains existing heuristics and supports full impredicativity with minimal complexity.
System F, the polymorphic lambda calculus, features the principle of impredicativity: polymorphic types may be (explicitly) instantiated at other types, enabling many powerful idioms such as Church encoding and data abstraction. Unfortunately, type applications need to be implicit for a language to be human-usable, and the problem of inferring all type applications in System F is undecidable. As a result, language designers have historically avoided impredicative type inference. We reformulate System F in terms of call-by-push-value, and study type inference for it. Surprisingly, this new perspective yields a novel type inference algorithm which is extremely simple to implement (not even requiring unification), infers many types, and has a simple declarative specification. Furthermore, our approach offers type theoretic explanations of how many of the heuristics used in existing algorithms for impredicative polymorphism arise.
Motivation & Objective
- To address the undecidability of full type inference in System F, where explicit type applications are required for impredicative instantiation.
- To develop a practical, human-readable type inference system that supports full impredicative polymorphism without requiring explicit type annotations.
- To provide a clear, declarative specification of type inference that explains the origins of heuristic techniques used in existing systems.
- To demonstrate that polarity shifts in call-by-push-value naturally capture the structure of argument lists and enable local inference.
- To show that function type contravariance need not be sacrificed for decidability, as long as polarity boundaries are properly controlled.
Proposed method
- Reformulates System F using call-by-push-value duality, introducing explicit shifts to mark polarity boundaries.
- Introduces a local type inference algorithm that infers type applications by analyzing the structure of shifts and polarity changes.
- Uses a declarative subtyping relation that respects the specialization order of universal types, with rules for ∀L and ∀R that reflect instantiation semantics.
- Employs a bidirectional typechecking style where synthesis and checking judgments are separated, but types are inferred locally without unification.
- Represents type instantiations through the presence of shifts, which constrain where impredicative instantiation can occur.
- Provides a non-algorithmic specification of inference that explains why certain heuristics—like instantiating quantifiers at first encountered constraints—arise naturally from type-theoretic structure.
Experimental results
Research questions
- RQ1How can impredicative type inference be made decidable and practical without sacrificing full polymorphism?
- RQ2Why do existing heuristic approaches to impredicative inference (e.g., instantiating at first constraint) work, and what is their theoretical basis?
- RQ3Can the structure of argument lists in impredicative functions be given a principled type-theoretic explanation?
- RQ4Does function type contravariance need to be abandoned to achieve decidable inference, or can it be preserved?
- RQ5Can a declarative specification of type inference be given that explains the behavior of complex inference algorithms?
Key findings
- The proposed system achieves full impredicative polymorphism with a type inference algorithm that requires no unification and is extremely simple to implement.
- The algorithm is declaratively specified and correctly infers types in all cases where the standard undecidable specification would succeed.
- The presence of explicit shifts in the syntax naturally explains why argument lists are essential for inference, as they mark polarity boundaries.
- The approach clarifies that the need to restrict function type contravariance in prior systems arises not from the contravariance itself, but from uncontrolled crossing of polarity boundaries.
- Heuristic strategies such as instantiating quantifiers at the first encountered constraint are shown to be grounded in the type-theoretic structure of shifts and polarity.
- The system provides a principled explanation for the behavior of boxy types and HMF, showing that their design choices emerge naturally from polarized type theory.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.