一句话:提出带声明子类型的 iso 递归类型核心演算,无需平方级膨胀即可表达互递归与高阶/混合种类子类型,并给出可高效检查的片段。
iso 递归类型常被用作编程语言中类型递归(如类与代数数据类型)的类型论模型,比 equi 递归更简单、类型检查更廉价。但标准 iso 递归难以高效表达互递归与非一致递归:高阶编码在与子类型结合时失效,经典 Amber 规则太弱,只能退化为平方规模的编码。本文提出带声明子类型的 iso 递归类型核心演算,可无膨胀表达递归间与递归内子类型,涵盖高阶与混合种类的构造子。作者进一步刻画一个语法片段,用高阶 iso 递归类型充当守卫以阻止多余的 β 归约,实现无需深层替换的高效类型检查;该片段类似 nominal 子类型系统但无需 nominal 语义,并已成为 WebAssembly 递归类型扩展提案的基础。
Iso-recursive types are often taken as a type-theoretic model for type recursion as present in many programming languages, e.g., classes in object-oriented languages or algebraic datatypes in functional languages. Their main advantage over an equi-recursive semantics is that they are simpler and algorithmically less expensive, which is an important consideration when the cost of type checking matters, such as for intermediate or low-level code representations, virtual machines, or runtime casts. However, a closer look reveals that iso-recursion cannot, in its standard form, efficiently express essential type system features like mutual recursion or non-uniform recursion. While it has been folklore that mutual recursion and non-uniform type parameterisation can nicely be handled by generalising to higher kinds, this encoding breaks down when combined with subtyping: the classic “Amber” rule for subtyping iso-recursive types is too weak to express mutual recursion without falling back to encodings of quadratic size.We present a foundational core calculus of iso-recursive types withdeclaredsubtyping that can express both inter- and intra-recursion subtyping without such blowup, including subtyping between constructors of higher or mixed kind. In a second step, we identify a syntactic fragment of this general calculus that allows for more efficient type checking without “deep” substitutions, by observing that higher-kinded iso-recursive types can be inserted to “guard” against unwanted β-reductions. This fragment closely resembles the structure of typical nominal subtype systems, but without requiring nominal semantics. It has been used as the basis for a proposed extension of WebAssembly with recursive types.