arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 1907.13227cs.LOcs.PL
收藏

用经典连接词进行编译

Compiling With Classical Connectives

Paul Downen, Zena M. Ariola

AI总结:

本文通过扩展极性概念并引入共享机制,将经典连接词用于编译,支持按需调用,实现对偶性,并统一参数多态与抽象数据类型。

摘要:

对计算中极性(polarity)的研究揭示了一种“理想”的编程语言应同时结合按值调用(call-by-value)和按名调用(call-by-name)两种求值方式;这两种调用约定分别对编程语言中一半的类型是理想的。但这种二元选择忽略了按需调用(call-by-need),而按需调用在实践中用于实现像 Haskell 这样的惰性默认(lazy-by-default)语言。我们展示了如何将极性的概念扩展到值/名二分法之外,通过增加一种共享(sharing)机制来包含按需调用,该机制足以编译一个带有用户定义类型的类似 Haskell 的函数式语言。在这种混合求值设置中捕获共享的关键是推广通常的极性“转换(shifts)”概念:不是只有两个转换(在正极和负极之间),而是有一族四个对偶转换。我们扩展了这一逻辑对偶性思想——“与”对偶于“或”;证明对偶于反驳——用于编译各种类型。基于数据和余数据(codata)的一般概念,我们展示了如何使用经典连接词来编码广泛的内置和用户定义类型。与对应于纯函数式编程的直觉主义逻辑相比,这些经典连接词将经典逻辑的更多令人愉快的对称性带到了计算相关、构造性的设置中。特别是,一对对合(involution)的否定连接了编程语言中广泛存在的参数多态(parametric polymorphism)和抽象数据类型(abstract data types)之间的鸿沟。为了完成编译中对偶性的研究,我们还考虑了按需调用求值的对偶,它共享程序控制流中的计算,而不是信息流中的计算。

英文摘要:

The study of polarity in computation has revealed that an "ideal" programming language combines both call-by-value and call-by-name evaluation; the two calling conventions are each ideal for half the types in a programming language. But this binary choice leaves out call-by-need which is used in practice to implement lazy-by-default languages like Haskell. We show how the notion of polarity can be extended beyond the value/name dichotomy to include call-by-need by adding a mechanism for sharing which is enough to compile a Haskell-like functional language with user-defined types. The key to capturing sharing in this mixed-evaluation setting is to generalize the usual notion of polarity "shifts:" rather than just two shifts (between positive and negative) we have a family of four dual shifts. We expand on this idea of logical duality -- "and" is dual to "or;" proof is dual to refutation -- for the purpose of compiling a variety of types. Based on a general notion of data and codata, we show how classical connectives can be used to encode a wide range of built-in and user-defined types. In contrast with an intuitionistic logic corresponding to pure functional programming, these classical connectives bring more of the pleasant symmetries of classical logic to the computationally-relevant, constructive setting. In particular, an involutive pair of negations bridges the gulf between the wide-spread notions of parametric polymorphism and abstract data types in programming languages. To complete the study of duality in compilation, we also consider the dual to call-by-need evaluation, which shares the computation within the control flow of a program instead of computation within the information flow.

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

↑