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

继承演算

A Calculus of Inheritance

Figure AI Inc.(Figure AI公司)

Bo Yang

AI总结:

本文提出继承演算,通过记录、定义和继承三个原语统一声明式编程,将继承建模为集合并,从而消除多重继承线性化问题,并证明其语义具有一阶、指称和可计算性,且比λ演算更具表达力。

摘要:

正如λ演算使用三个原语(抽象、应用、变量)作为函数式编程的基础,继承演算使用三个原语(记录、定义、继承)作为声明式编程的基础。通过将模块、类、对象、方法、字段和局部变量统一在单个记录抽象下,该演算将继承简单建模为集合并。因此,组合本质上是可交换、幂等和结合的,从而在结构上消除了多重继承线性化问题。其语义是一阶、指称的,并且可以通过制表计算,即使对于循环继承层次结构也是如此。这三个性质扩展到λ演算,因为Böhm树等价对于继承演算子语言的一阶迭代近似是完全抽象的。作为推论,这建立了共享相同λ语法的λ演算之间的收敛层次:急切⊊惰性⊊不动点。继承演算源自MIXINv2,这是一个实际实现,其中相同的代码充当不同的函数颜色;普通算术产生逻辑编程的关系语义;this解析到多个目标;并且程序在表达式问题的意义下对不可扩展性免疫。这使得继承演算在常识和Felleisen的意义上都比λ演算严格更具表达力。

英文摘要:

Just as the $λ$-calculus is a pure functional programming language built from three primitives (abstraction, application, variable), we present inheritance-calculus, a pure declarative programming language built from three primitives (mixin, definition, reference). We introduce multi-target $\mathtt{this}$ to solve the problem that inheritance conflicts with modularity, and thereby unify object-oriented and configuration constructs: modules, classes, objects, methods, fields, and locals become a single mixin abstraction, and inheritance becomes simply set union, the deep merge of configuration languages. Consequently, composition is commutative, idempotent, and associative, structurally eliminating the multiple-inheritance linearization problem; the inheritance relation has substitutability; every path of every program can be inherited and extended; every subtree can be split into parts that, inherited together, behave as the whole; and programs have no side effects and cover every input. We call these properties modularity by construction. The calculus has no functions, yet it macro-expresses the lazy $λ$-calculus and is more macro-expressive than it in Felleisen's sense. Its semantics is first-order, denotational, and evaluated by tabling, even for cyclic inheritance hierarchies. Inheritance-calculus is distilled from MIXINv2, an implementation in which the same code acts as different function colors and ordinary arithmetic agrees with the relational semantics of logic programming.

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

↑