一句话:揭示扩展 System F 因类型变量失去词法作用域而产生 universal type,并用类型世界修正参数性、否证两个猜想。
System F 的参数性刻画了多态与抽象数据类型的核心性质。当它被扩展以支持无类型代码、渐进类型、动态 sealing、运行时类型分析(typecase)与类型生成时,参数性的标准表述需借助 step-indexing、Kripke world 或双正交等方法调整,但这些表述的相对能力及扩展语言的表达力仍不清楚。本文指出,这些设置共同不强制或保持类型变量的词法作用域,从而产生 universal type(不同于全称量化类型);作者解释标准参数性为何与其不相容,并说明类型世界如何修正参数性。基于此,作者否定文献中的两个开放猜想,并指出现有 System F 与渐进类型结合方案的一个缺陷。
The formal calculus System F models the essence of polymorphism and abstract data types, features that exist in many programming languages. The calculus’ core property is parametricity: a theorem expressing the language’s abstractions and validating important principles like information hiding and modularity. When System F is combined with features like recursive types, mutable state, continuations or exceptions, the formulation of parametricity needs to be adapted to follow suit, for example using techniques like step-indexing, Kripke world-indexing or biorthogonality. However, it is less clear how this formulation should change when System F is combined with untyped languages, gradual types, dynamic sealing and runtime type analysis (typecase) alongside type generation. Extensions of System F with these features have been proven to satisfy forms of parametricity (with Kripke worlds carrying semantic interpretations of types). However, the relative power of the modified formulations of parametricity with respect to others and the relative expressiveness of System F with and without these extensions are unknown. In this paper, we explain that the aforementioned different settings have a common characteristic: they do not enforce or preserve the lexical scope of System F’s type variables. Formally, this results in the existence of a universal type (note: this is not the same as a universally-quantified type). We explain why standard parametricity is incompatible with such a type and how type worlds resolve this. Building on these insights, we answer two open conjectures from the literature, negatively, and we point out a deficiency in current proposals for combining System F with gradual types.
@article{paperbot1604,
title = {Two Parametricities Versus Three Universal Types},
author = {Dominique Devriese and Marco Patrignani and Frank Piessens},
journal = {ACM Transactions on Programming Languages and Systems},
volume = {44},
number = {4},
year = {2022},
doi = {10.1145/3539657}
}