arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2209.09729cs.PLcs.LO
收藏

两层次类型论的分期编译

Staged Compilation with Two-Level Type Theory

András Kovács

摘要:

分段编译的目的是以一种方式启用元编程,这样我们就可以保证代码输出的格式良好,并且我们还可以以简洁方便的方式将对象级和元级代码混合在一起。在这项工作中,我们观察到,两级类型论(2LTT),一个系统最初设计的目的是发展合成同伦理论,也作为一个系统,分阶段编译依赖类型。2LTT在这个用例中有许多好的特性:它有一个简洁的规范,行为良好的模型理论,并且它在对象和Meta级别上支持广泛的语言功能。首先,我们概述了2LTT的特点和在分期中的应用。然后,我们提出了一个分期算法,并证明了它的正确性。我们的算法是“分期评估”,类似于规范化评估的技术,在分期是由语义域中的2LTT语法的评估。分期算法及其正确性证明了2LLT相对于对象理论的强保守性。据我们所知,这是第一次描述支持完全依赖类型和类型的无限制分级的分级编译。

英文摘要:

The aim of staged compilation is to enable metaprogramming in a way such that we have guarantees about the well-formedness of code output, and we can also mix together object-level and meta-level code in a concise and convenient manner. In this work, we observe that two-level type theory (2LTT), a system originally devised for the purpose of developing synthetic homotopy theory, also serves as a system for staged compilation with dependent types. 2LTT has numerous good properties for this use case: it has a concise specification, well-behaved model theory, and it supports a wide range of language features both at the object and the meta level. First, we give an overview of 2LTT's features and applications in staging. Then, we present a staging algorithm and prove its correctness. Our algorithm is "staging-by-evaluation", analogously to the technique of normalization-by-evaluation, in that staging is given by the evaluation of 2LTT syntax in a semantic domain. The staging algorithm together with its correctness constitutes a proof of strong conservativity of 2LLT over the object theory. To our knowledge, this is the first description of staged compilation which supports full dependent types and unrestricted staging for types.

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

↑