We study a dependently typed extension of a multi-stage programming language \`a la MetaOCaml, which supports quasi-quotation and cross-stage persistence for manipulation of code fragments as first-class values and an evaluation construct for execution of programs dynamically generated by this code manipulation. Dependent types are expected to bring to multi-stage programming enforcement of strong invariant -- beyond simple type safety -- on the behavior of dynamically generated code. An extension is, however, not trivial because such a type system would have to take stages of types -- roughly speaking, the number of surrounding quotations -- into account. To rigorously study properties of such an extension, we develop $\lambda^{MD}$, which is an extension of Hanada and Igarashi's typed calculus $\lambda^{\triangleright\%} $ with dependent types, and prove its properties including preservation, confluence, strong normalization for full reduction, and progress for staged reduction. Motivated by code generators that generate code whose type depends on a value from outside of the quotations, we argue the significance of cross-stage persistence in dependently typed multi-stage programming and certain type equivalences that are not directly derived from reduction rules.
翻译:我们研究多阶段编程语言“a la la MetaOCaml”的自发型扩展,它支持准引用和跨阶段持续操纵代码碎片,作为头等值进行操纵,并为执行这种代码操纵所动态产生的程序建立评价结构。 依赖型类型预计将给多阶段编程执行强变(超越简单类型安全)的动态生成代码的行为带来强烈变化。 但是,扩展并非微不足道,因为这种类型系统需要考虑到种类阶段 -- -- 大致而言,周围引言的数量 -- -- 来考虑。为了严格研究这种扩展的特性,我们开发了美元\lambda ⁇ MD}$,这是Hanada和Igarashashi用依赖型类型打字的微积分($\lambda ⁇ triangright ⁇ $)的延伸,并证明其特性,包括保护、影响、全面削减的高度正常化和分阶段削减的进展。受代码生成者的兴趣,其类型取决于引文的外值,因此,我们认为,跨阶段编程的持久性的意义不是从依赖的多级编程中直接转换成等式规则。