We investigate a simply typed modal $\lambda$-calculus, $\lambda^{\to\square}$, due to Pfenning, Wong and Davies, where we define a well-typed term with respect to a context stack that captures the possible world semantics in a syntactic way. It provides logical foundation for multi-staged meta-programming. Our main contribution in this paper is a normalization by evaluation (NbE) algorithm for $\lambda^{\to\square}$ which we prove sound and complete. The NbE algorithm is a moderate extension to the standard presheaf model of simply typed $\lambda$-calculus. However, central to the model construction and the NbE algorithm is the observation of Kripke-style substitutions on context stacks which brings together two previously separate concepts, structural modal transformations on context stacks and substitutions for individual assumptions. Moreover, Kripke-style substitutions allow us to give a formulation for contextual types, which can represent open code in a meta-programming setting. Our work lays the foundation for extending the logical foundation by Pfenning, Wong, and Davies towards building a practical, dependently typed foundation for meta-programming.
翻译:本文研究Pfenning、Wong和Davies提出的简单类型模态λ-演算λ^{→□}。在该演算中,我们针对上下文栈定义良类型项,以句法方式捕捉可能世界语义,为多阶段元编程提供逻辑基础。本文主要贡献在于提出λ^{→□}的依值求值归约(NbE)算法,并证明其可靠性与完备性。该NbE算法是对简单类型λ-演算标准预层模型的适度扩展。然而,模型构造和NbE算法的核心在于对上下文栈上克里普克风格替换的观察——这融合了两个此前独立的概念:上下文栈的结构模态变换与个体假设的替换。此外,克里普克风格替换使我们能够为上下文类型提供形式化描述,从而在元编程环境中表示开放代码。本研究为扩展Pfenning、Wong和Davies提出的逻辑基础,构建实用的依值类型元编程框架奠定基础。