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

数据-余数据对称性及其与评价序的相互作用

Data-Codata Symmetry and its Interaction with Evaluation Order

David Binder, Julian Jabs, Ingo Skupin, Klaus Ostermann

摘要:

数据类型和共同数据类型,顾名思义,通常被视为彼此的区别。然而,大多数程序设计语言并不完全支持这两种类型,或者即使它们支持,它们仍然被视为具有单独定义的类型检查,编译等的不同结构。然而,在以前的作品中,codata和data仍然被视为单独定义的语言结构,去功能化和重新功能化被定义为类似但独立的算法。这些工作也掩盖了上述转换和评估顺序之间的相互作用,这导致了理想的$η$扩展等式的损失。我们认为,完全对称的失败是由于作为语言设计逻辑基础的自然演绎的内在不对称性。自然演绎是不对称的,因为它的重点是类型的生产者(证明),而消费者(上下文,延续,反驳)具有二等地位。受现有的基于顺序演算的语言设计的启发,我们提出了第一种完全对称的语言设计,其中极性(数据类型与codata类型)和求值顺序(按值调用与按名称调用)的问题被解开,并成为单一形式的类型声明的独立属性。两个属性,极性和评估顺序,可以单独改变一个算法。特别地,去功能化和重新功能化现在是一种算法。可以为每种类型单独定义和更改评估顺序,与极性无关。通过仅允许求值顺序和极性的某些组合,可以恢复上述$η$定律。

英文摘要:

Data types and codata types are, as the names suggest, often seen as duals of each other. However, most programming languages do not support both of them in their full generality, or if they do, they are still seen as distinct constructs with separately defined type-checking, compilation, etc. Rendel et al. were the first to propose variants of two standard program transformations, de- and refunctionalization, as a test to gauge and improve the symmetry between data and codata types. However, in previous works, codata and data were still seen as separately defined language constructs, with de- and refunctionalization being defined as similar but separate algorithms. These works also glossed over interactions between the aforementioned transformations and evaluation order, which leads to a loss of desirable $η$ expansion equalities. We argue that the failure of complete symmetry is due to the inherent asymmetry of natural deduction as the logical foundation of the language design. Natural deduction is asymmetric in that its focus is on producers (proofs) of types, whereas consumers (contexts, continuations, refutations) have a second-class status. Inspired by existing sequent-calculus-based language designs, we present the first language design that is fully symmetric in that the issues of polarity (data type vs codata types) and evaluation order (call-by-value vs call-by-name) are untangled and become independent attributes of a single form of type declaration. Both attributes, polarity and evaluation order, can be changed independently by one algorithm each. In particular, defunctionalization and refunctionalization are now one algorithm. Evaluation order can be defined and changed individually for each type, independently from polarity. By allowing only certain combinations of evaluation order and polarity, the aforementioned $η$ laws can be restored.

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

↑