arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2307.15463cs.PL
收藏

答案细化修改:代数效应与处理器的细化类型系统

Answer Refinement Modification: Refinement Type System for Algebraic Effects and Handlers

Fuga Kawamata, Hiroshi Unno, Taro Sekiyama, Tachio Terauchi

AI总结:

本文提出一种针对代数效应与处理器的细化类型系统,引入答案细化修改(ARM)概念以精确追踪效应发生及其顺序,并证明其可靠性,在OCaml 5子集上实现并评估,同时提出双向类型保持的CPS转换。

摘要:

代数效应与处理器是一种以模块化方式构造具有计算效应的程序结构的机制。它们最近越来越受欢迎,并被应用于实用语言中,如OCaml。与此同时,通过细化类型系统进行程序验证方面取得了实质性进展。然而,迄今为止,对于代数效应与处理器,还没有一个令人满意的细化类型系统。在本文中,我们通过提出一种新颖的代数效应与处理器的细化类型系统来填补这一空白。代数效应与处理器的表达力和实用性来自于它们操作定界延续的能力,但定界延续也使得程序的控制流复杂化,并使其验证更加困难。为了解决这一复杂性,我们引入了一个新颖的概念,称为答案细化修改(简称ARM),它允许细化类型系统精确跟踪程序执行时发生哪些效应以及以何种顺序发生,并将这些信息反映为对定界延续类型中细化的修改。我们形式化了支持ARM(以及答案类型修改,即ATM)的类型系统,并证明了其可靠性。此外,作为概念验证,我们为OCaml 5的一个子集实现了相应的类型检查和推断算法,并在多个基准程序上进行了评估。评估表明,ARM在概念上简单且实用。最后,直接推理具有定界延续的程序的自然替代方案是应用延续传递风格(CPS)转换,将程序转换为纯程序。我们研究了这一替代方案,并通过提出一种新颖的代数效应与处理器的CPS转换,证明了该方法是可行的,该转换具有双向(细化)类型保持性。

英文摘要:

Algebraic effects and handlers are a mechanism to structure programs with computational effects in a modular way. They are recently gaining popularity and being adopted in practical languages, such as OCaml. Meanwhile, there has been substantial progress in program verification via refinement type systems. However, thus far there has not been a satisfactory refinement type system for algebraic effects and handlers. In this paper, we fill the void by proposing a novel refinement type system for algebraic effects and handlers. The expressivity and usefulness of algebraic effects and handlers come from their ability to manipulate delimited continuations, but delimited continuations also complicate programs' control flow and make their verification harder. To address the complexity, we introduce a novel concept that we call answer refinement modification (ARM for short), which allows the refinement type system to precisely track what effects occur and in what order when a program is executed, and reflect such information as modifications to the refinements in the types of delimited continuations. We formalize our type system that supports ARM (as well as answer type modification, or ATM) and prove its soundness. Additionally, as a proof of concept, we have implemented a corresponding type checking and inference algorithm for a subset of OCaml 5, and evaluated it on a number of benchmark programs. The evaluation demonstrates that ARM is conceptually simple and practically useful. Finally, a natural alternative to directly reasoning about a program with delimited continuations is to apply a continuation passing style (CPS) transformation that transforms the program to a pure program. We investigate this alternative, and show that the approach is indeed possible by proposing a novel CPS transformation for algebraic effects and handlers that enjoys bidirectional (refinement-)type-preservation.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑