一句话:提出完全同构递归类型,以可擦除 cast 编码等值递归类型,消除强制转换开销并简化等价推理。
同构递归类型与等值递归类型在表达力上等价,但 Abadi 和 Fiore 的编码需要显式强制转换,带来额外计算开销并使两种表述的等价性推理复杂化。本文提出完全同构递归类型,用计算无关的 cast 捕获所有类型变换,这些 cast 可在运行时擦除而不影响程序语义,从而无开销地编码等值递归类型程序。作者定义了扩展简单类型 λ 演算的 λF_iμ 演算,证明其类型可靠性,并证明其与等值递归类型演算表达力相同。文章还将结果扩展到子类型,表明等值递归子类型可用带 cast 算子的同构递归子类型表达。
There are two well-known formulations of recursive types: iso-recursive and equi-recursive types. Abadi and Fiore [LICS 1996] have shown that iso- and equi-recursive types have the same expressive power. However, their encoding of equi-recursive types in terms of iso-recursive types requires explicit coercions. These coercions come with significant additional computational overhead , and complicate reasoning about the equivalence of the two formulations of recursive types. This paper proposes a generalization of iso-recursive types called full iso-recursive types. Full iso-recursive types allow encoding all programs with equi-recursive types without computational overhead. Instead of explicit term coercions, all type transformations are captured by computationally irrelevant casts, which can be erased at runtime without affecting the semantics of the program. Consequently, reasoning about the equivalence between the two approaches can be greatly simplified. We present a calculus called λ F i μ , which extends the simply typed lambda calculus (STLC) with full iso-recursive types. The λ F i μ calculus is proved to be type sound, and shown to have the same expressive power as a calculus with equi-recursive types. We also extend our results to subtyping, and show that equi-recursive subtyping can be expressed in terms of iso-recursive subtyping with cast operators.
DOI 原文 · arXiv · PDF(开放获取) · DBLP
@article{abs-2407-00941,
title = {Full Iso-Recursive Types},
author = {Litao Zhou and Qianyong Wan and Bruno C. d. S. Oliveira},
journal = {Proceedings of the ACM on Programming Languages},
volume = {8},
number = {OOPSLA2},
year = {2024},
doi = {10.1145/3689718}
}