A Dependently Typed Multi-Stage Calculus
Preprint
Abstract
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.
Keywords
All Related Versions
This publication has 8 references indexed in Scilit:
- Reconciling Abstraction with High Performance: A MetaOCaml approachFoundations and Trends® in Programming Languages, 2018
- A metaprogramming framework for formal verificationProceedings of the ACM on Programming Languages, 2017
- Program Logics for Homogeneous Generative Run-Time Meta-ProgrammingLogical Methods in Computer Science, 2015
- A Logical Foundation for Environment Classifiers2009
- Staged computation with names and necessityJournal of Functional Programming, 2005
- A modal analysis of staged computationJournal of the ACM, 2001
- MetaML and multi-stage programming with explicit annotationsTheoretical Computer Science, 2000
- A theory of type polymorphism in programmingJournal of Computer and System Sciences, 1978