arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 1907.07283cs.PLcs.LO
收藏

使用Comonads和功能恢复纯度

Recovering Purity with Comonads and Capabilities

Vikraman Choudhury, Neel Krishnaswami

摘要:

在本文中,我们采用了一种普遍有效的(ML风格的)类型λ演算,并展示了如何扩展它以允许捕获具有类型的纯表达式。我们的关键观察是,正如纯简单类型的λ演算可以扩展到支持一元类型规则的效果,不纯类型的λ演算可以扩展到支持一元类型规则的纯度。我们通过一个简单的指称模型来建立我们的类型系统的正确性,我们称之为能力空间模型。我们的模型形式化的直觉常见的系统程序员,执行效果的能力应该通过访问权限或能力进行控制,一个程序是能力安全的,如果它没有执行效果,它没有一个运行时的能力。然后,我们确定的公理范畴结构的能力空间模型验证,并使用这些公理给我们的comonadic类型系统的范畴语义。然后,我们给出了一个等式理论(替代和调用的值$β$和$η$法律)的命令λ演算,并显示其可靠性相对于此语义。最后,我们给出了一个翻译的纯简单类型的λ演算到我们的共同命令演算,并表明,任何两个条款是$βη$ -平等的STLC是平等的共同命令演算的方程理论,建立纯程序可以映射到我们的命令演算在一个方程保持的方式。

英文摘要:

In this paper, we take a pervasively effectful (in the style of ML) typed lambda calculus, and show how to extend it to permit capturing pure expressions with types. Our key observation is that, just as the pure simply-typed lambda calculus can be extended to support effects with a monadic type discipline, an impure typed lambda calculus can be extended to support purity with a comonadic type discipline. We establish the correctness of our type system via a simple denotational model, which we call the capability space model. Our model formalizes the intuition common to systems programmers that the ability to perform effects should be controlled via access to a permission or capability, and that a program is capability-safe if it performs no effects that it does not have a runtime capability for. We then identify the axiomatic categorical structure that the capability space model validates, and use these axioms to give a categorical semantics for our comonadic type system. We then give an equational theory (substitution and the call-by-value $β$ and $η$ laws) for the imperative lambda calculus, and show its soundness relative to this semantics. Finally, we give a translation of the pure simply-typed lambda calculus into our comonadic imperative calculus, and show that any two terms which are $βη$-equal in the STLC are equal in the equational theory of the comonadic calculus, establishing that pure programs can be mapped in an equation-preserving way into our imperative calculus.

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

↑