# A Dependently Typed Multi-Stage Calculus

**Authors:** Akira Kawata, Atsushi Igarashi

arXiv: 1908.02035 · 2021-08-18

## TL;DR

This paper introduces a dependently typed extension of a multi-stage programming language, enabling stronger invariants on generated code and addressing the complexities of stage-dependent types.

## Contribution

It develops $mbda^{MD}$, a dependently typed calculus for multi-stage programming, and proves key properties like preservation, confluence, and normalization.

## Key findings

- Proves preservation, confluence, and normalization of the calculus.
- Highlights the importance of cross-stage persistence in dependently typed programming.
- Establishes type equivalences beyond reduction rules.

## 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.

## Full text

_Full body text omitted from this summary view._ Fetch the complete paper as Markdown: https://tomesphere.com/paper/1908.02035/full.md

## Figures

13 figures with captions in the complete paper: https://tomesphere.com/paper/1908.02035/full.md

## References

34 references — full list in the complete paper: https://tomesphere.com/paper/1908.02035/full.md

---
Source: https://tomesphere.com/paper/1908.02035