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

语言互操作的语义合理性

Semantic Soundness for Language Interoperability

Daniel Patterson, Noble Mushtak, Andrew Wagner, Amal Ahmed

摘要:

程序很少用一种语言实现,因此类型可靠性的问题不仅要解决单一语言的语义,还要解决它如何与其他语言交互。即使在类型安全的语言之间,不同的特性也会阻碍互操作性,因为一种语言的不变量很容易在另一种语言中被违反。在他们2007年的开创性论文中,Matthews和Findler提出了一种多语言结构,它通过一对边界来增强互操作语言,允许一种语言的代码嵌入另一种语言。虽然该技术已被广泛应用,但它们的语法源代码级互操作性并不能反映实际的实现,其中交互行为是在编译到公共目标之后定义的,并且任何安全性都必须由目标不变量或插入的目标级“粘合代码”来确保。“在本文中,我们提出了一个框架的设计和验证的声音语言的互操作性,遵循互操作后编译策略。语言设计器指定哪些数据可以通过关系$τ_A \sim τ_B$在语言类型之间转换,并指定实现转换的目标粘合代码。然后,通过给出源类型的语义模型作为目标术语的集合,我们可以建立转换的可靠性:即,每当$τ_A \sim τ_B$时,对应的转换对将表现为$τ_A$的目标项转换为表现为$τ_B$的目标项,反之亦然。然后我们可以证明整个系统的语义类型可靠性。我们通过一系列的案例研究来说明我们的框架,这些案例研究展示了我们的语义互操作编译后的方法如何使我们既可以考虑语言语义中的复杂差异,又可以根据编译器或目标的特殊性进行效率权衡。

英文摘要:

Programs are rarely implemented in a single language, and thus questions of type soundness should address not only the semantics of a single language, but how it interacts with others. Even between type-safe languages, disparate features frustrate interoperability, as invariants from one language can easily be violated in the other. In their seminal 2007 paper, Matthews and Findler proposed a multi-language construction that augments the interoperating languages with a pair of boundaries that allow code from one language to be embedded in the other. While the technique has been widely applied, their syntactic source-level interoperability doesn't reflect practical implementations, where behavior of interaction is defined after compilation to a common target, and any safety must be ensured by target invariants or inserted target-level "glue code." In this paper, we present a framework for the design and verification of sound language interoperability that follows an interoperation-after-compilation strategy. Language designers specify what data can be converted between types of the languages via a relation $τ_A \sim τ_B$ and specify target glue code implementing conversions. Then, by giving a semantic model of source types as sets of target terms, we can establish soundness of conversions: i.e., whenever $τ_A \sim τ_B$, the corresponding pair of conversions convert target terms that behave as $τ_A$ to target terms that behave as $τ_B$, and vice versa. We can then prove semantic type soundness for the entire system. We illustrate our framework via a series of case studies that demonstrate how our semantic interoperation-after-compilation approach allows us both to account for complex differences in language semantics and make efficiency trade-offs based on particularities of compilers or targets.

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

↑