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算法的核心在于对上下文栈的Kripke式替换的观察——这融合了两个先前分离的概念:上下文栈上的结构模态变换与单个假设的替换。进一步地,Kripke式替换使我们能够为上下文类型给出公式化表示,从而在元编程设定中表达开放代码。本工作为将Pfenning、Wong和Davies的逻辑基础扩展为构建实用的、基于依赖类型的元编程基础奠定了基石。