paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Parametricity for Nested Types and GADTs

嵌套类型与 GADT 的参数性
LMCS vol.Volume 17, Issue 42021匹配度 2/10 · 这篇论文属于纯类型论与形式语义,研究嵌套类型和 GADT 的参数性与自由定理,不涉及静态分析、LLM/Agent、浮点程序分析或贝叶斯程序分析。仅与形式化验证/PL 理论有较间接的联系,与用户当前聚焦的交叉方向匹配度低。引用 1 inbox
Patricia Johann, Enrico Ghiorzi
crossref: 2026-09-10

AI 速览

一句话:为直接以不动点构造的嵌套类型建立参数模型,推导自由定理,并揭示 GADT 扩展的局限。

本文研究嵌套数据类型(包括真正嵌套类型)的参数性及由其导出的自由定理。不同于通过高阶或依赖类型 System F 的 Church 编码表示嵌套类型,作者从函数式编程视角设计一种 Hindley-Milner 风格演算,以原语直接构造嵌套类型的不动点,并在项层支持模式匹配、map 与 fold。核心贡献是为该演算构造参数模型:为获得解释嵌套类型的语义不动点并建立 Identity Extension Lemma,类型系统显式追踪类型的函子性,模型构造中亦需贯穿余连续条件。作者证明模型满足相应的 Abstraction Theorem,并验证嵌套原语下参数性的标准推论,给出自由定理与 shortcut fusion 示例;最后论证将结果推广到 GADT 的困难,指出基于左 Kan 扩张的函子解释无法保持参数性。

问题
如何为嵌套类型(包括真正嵌套类型)建立参数性语义并导出自由定理,以及该框架能否推广到 GADT。
方法
设计带嵌套类型原语的 Hindley-Milner 风格演算,支持模式匹配、map 与 fold;构造参数模型,类型系统追踪函子性,并在模型中使用余连续条件保证语义不动点与 Identity Extension Lemma。
评估
证明 Abstraction Theorem 和参数性标准推论,给出自由定理及 shortcut fusion 示例,并论证 GADT 无法通过左 Kan 扩张获得保持参数性的函子解释。
原文摘要(Abstract)

This paper considers parametricity and its consequent free theorems for nested data types. Rather than representing nested types via their Church encodings in a higher-kinded or dependently typed extension of System F, we adopt a functional programming perspective and design a Hindley-Milner-style calculus with primitives for constructing nested types directly as fixpoints. Our calculus can express all nested types appearing in the literature, including truly nested types. At the level of terms, it supports primitive pattern matching, map functions, and fold combinators for nested types. Our main contribution is the construction of a parametric model for our calculus. This is both delicate and challenging. In particular, to ensure the existence of semantic fixpoints interpreting nested types, and thus to establish a suitable Identity Extension Lemma for our calculus, our type system must explicitly track functoriality of types, and cocontinuity conditions on the functors interpreting them must be appropriately threaded throughout the model construction. We also prove that our model satisfies an appropriate Abstraction Theorem, as well as that it verifies all standard consequences of parametricity in the presence of primitive nested types. We give several concrete examples illustrating how our model can be used to derive useful free theorems, including a short cut fusion transformation, for programs over nested types. Finally, we consider generalizing our results to GADTs, and argue that no extension of our parametric model for nested types can give a functorial interpretation of GADTs in terms of left Kan extensions and still be parametric.

链接与引用

DOI 原文 · PDF(开放获取) ·

BibTeX
@article{paperbot1250,
  title = {Parametricity for Nested Types and GADTs},
  author = {Patricia Johann and Enrico Ghiorzi},
  journal = {Logical Methods in Computer Science},
  volume = {Volume 17, Issue 4},
  year = {2021},
  doi = {10.46298/lmcs-17(4:23)2021}
}