一句话:提出有类型直接风格与 CPS 语言及其互译,证明类型保持、操作对应,并刻画互译复合的逆性质。
CPS 变换是显式处理控制结构、用于编译的经典工具,在类型化场景下还可视为经典逻辑到直觉主义逻辑的嵌入。本文追问是否存在逆向的直接风格变换;答案取决于 CPS 变换的定义与逆变换的定义域。一般地,将 CPS 程序转回直接风格需借助控制操作符来处理非平凡使用延续的情况。作者给出两个语言:一个直接风格、一个 CPS,二者均有类型系统与抽象机语义,并支持非平凡控制流。文中定义正向与逆向翻译,证明二者保持类型,并以操作对应精确保持语义;还研究翻译复合的行为,证明在整个语言上为语法单侧逆,在平凡控制流受限时则为完全语法逆。
Translating programs into continuation-passing style is a well-studied tool to explicitly deal with the control structure of programs. This is useful, for example, for compilation. In a typed setting, there also is a logical interpretation of such a translation as an embedding of classical logic into intuitionistic logic. A naturally arising question is whether there is an inverse translation back to direct style. The answer to this question depends on how the continuation-passing translation is defined and on the domain of the inverse translation. In general, translating programs from continuation-passing style back to direct style requires the use of control operators to account for the use of continuations in non-trivial ways. We present two languages, one in direct style and one in continuation-passing style. Both languages are typed and equipped with an abstract machine semantics. Moreover, both languages allow for non-trivial control flow. We further present a translation to continuation-passing style and a translation back to direct style. We show that both translations are type-preserving and also preserve semantics in a very precise way giving an operational correspondence between the two languages. Moreover, we show that the compositions of the translations are well-behaved. In particular, they are syntactic one-sided inverses on the full language and full syntactic inverses when restricted to trivial control flow.
@article{paperbot2031,
title = {Back to Direct Style: Typed and Tight},
author = {Marius Müller and Philipp Schuster and Jonathan Immanuel Brachthäuser and Klaus Ostermann},
journal = {Proceedings of the ACM on Programming Languages},
volume = {7},
number = {OOPSLA1},
year = {2023},
doi = {10.1145/3586056}
}