当前位置: X-MOL 学术J. Funct. Program. › 论文详情
Our official English website, www.x-mol.net, welcomes your feedback! (Note: you will need to create a separate account there.)
Gradual type theory
Journal of Functional Programming ( IF 1.1 ) Pub Date : 2021-10-14 , DOI: 10.1017/s0956796821000125
MAX S. NEW 1 , DANIEL R. LICATA 2 , AMAL AHMED 3
Affiliation  

Gradually typed languages are designed to support both dynamically typed and statically typed programming styles while preserving the benefits of each. Sound gradually typed languages dynamically check types at runtime at the boundary between statically typed and dynamically typed modules. However, there is much disagreement in the gradual typing literature over how to enforce complex types such as tuples, lists, functions and objects. In this paper, we propose a new perspective on the design of runtime gradual type enforcement: runtime type casts exist precisely to ensure the correctness of certain type-based refactorings and optimizations. For instance, for simple types, a language designer might desire that beta-eta equality is valid. We show that this perspective is useful by demonstrating that a cast semantics can be derived from beta-eta equality. We do this by providing an axiomatic account program equivalence in a gradual cast calculus in a logic we call gradual type theory (GTT). Based on Levy’s call-by-push-value, GTT allows us to axiomatize both call-by-value and call-by-name gradual languages. We then show that we can derive the behavior of casts for simple types from the corresponding eta equality principle and the assumption that the language satisfies a property called graduality, also known as the dynamic gradual guarantee. Since we can derive the semantics from the assumption of eta equality, we also receive a useful contrapositive: any observably different cast semantics that satisfies graduality must violate the eta equality. We show the consistency and applicability of our axiomatic theory by proving that a contract-based implementation using the lazy cast semantics gives a logical relations model of our type theory, where equivalence in GTT implies contextual equivalence of the programs. Since GTT also axiomatizes the dynamic gradual guarantee, our model also establishes this central theorem of gradual typing. The model is parameterized by the implementation of the dynamic types, and so gives a family of implementations that validate type-based optimization and the gradual guarantee.

中文翻译:

渐进型理论

渐进类型语言旨在支持动态类型和静态类型的编程风格,同时保留每种风格的优点。健全的渐进类型语言在运行时动态检查静态类型和动态类型模块之间的类型。然而,渐进式类型化文献对于如何强制执行复杂类型(如元组、列表、函数和对象)存在很大分歧。在本文中,我们提出了一个关于运行时渐进类型强制设计的新观点:运行时类型转换的存在正是为了确保某些基于类型的重构和优化的正确性。例如,对于简单类型,语言设计者可能希望 beta-eta 相等是有效的。我们通过证明转换语义可以从 beta-eta 等式派生来证明这种观点是有用的。我们通过在我们称之为逻辑的渐进演算中提供一个公理化的帐户程序等价性来做到这一点渐进型理论(GTT)。基于 Levy 的 call-by-push-value,GTT 允许我们公理化 call-by-value 和 call-by-name 渐进式语言。然后,我们证明我们可以从相应的 eta 相等原则和语言满足称为的属性的假设中推导出简单类型的强制转换行为渐进性,又称动态渐进保证。由于我们可以从 eta 相等的假设中推导出语义,我们还得到了一个有用的反证:任何满足渐进性的明显不同的转换语义必须违反 eta 等式。我们通过证明使用惰性转换语义的基于契约的实现给出了我们的类型理论的逻辑关系模型,证明了我们的公理理论的一致性和适用性,其中 GTT 中的等价意味着程序的上下文等价。由于 GTT 也公理化了动态渐进保证,我们的模型也建立了渐进类型的中心定理。该模型通过动态类型的实现进行参数化,因此提供了一系列实现,以验证基于类型的优化和逐步保证。
更新日期:2021-10-14
down
wechat
bug