论文标题
用两级类型理论分阶段汇编
Staged Compilation with Two-Level Type Theory
论文作者
论文摘要
上演汇编的目的是以一种使我们保证代码输出良好的方式启用元编程,并且我们还可以以简洁且方便的方式将对象级别和元级代码混合在一起。在这项工作中,我们观察到,两级类型的理论(2LTT)是为开发合成同义理论而设计的系统,也是用于与依赖类型的上演汇编的系统。 2LTT在此用例中具有许多良好的属性:它具有简洁的规范,行为良好的模型理论,并且支持对象和元级别的各种语言特征。首先,我们概述了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.