paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Coherence of type class resolution

类型类解析的连贯性
ICFP 3(ICFP)2019匹配度 2/10 · 该论文属于纯编程语言理论中的类型类解析与连贯性形式证明,虽涉及形式语义与类型系统,但与用户核心方向 PL↔AI、静态分析、浮点程序分析、贝叶斯程序分析及 LLM/Agent 交叉均无直接关联。引用 10 inbox
Gert-Jan Bottu, Ningning Xie, Koar Marntirosian, Tom Schrijvers
crossref: 2026-09-10

AI 速览

一句话:首次为基于 elaboration 的类型类解析在超类与灵活上下文等非确定性下建立连贯性的形式证明。

Haskell、Mercury、PureScript 等语言采用基于 elaboration 的类型类解析,它本质上是非确定性的:同一 wanted constraint 可由多个全局实例与局部约束共同满足。连贯性(coherence)是保证程序行为可预测的关键性质,但此前尚未在 superclasses、flexible contexts 等非确定性来源存在时得到形式证明。本文填补这一空白。受 full abstraction 启发,作者提出两步策略:先将源语言非确定地 elaboration 到一个保持 contextual equivalence 的中间语言,再从该中间语言确定地 elaboration 到目标语言。利用 logical relations,论文证明了第一步的 contextual equivalence,从而建立连贯性;第二步的确定性则直接保持该性质。

问题
基于 elaboration 的类型类解析通常非确定,可能存在多个解析方式;论文要证明在 superclasses、flexible contexts 等非确定性存在时该解析仍满足 coherence。
方法
采用受 full abstraction 启发的两步 elaboration:先非确定地落到保持 contextual equivalence 的中间语言,再确定地落到目标语言;并用 logical relations 证明第一步的 contextual equivalence。
评估
以形式化证明和逻辑关系论证完成,不依赖实现或实验;结果是在上述非确定性下建立 coherence,并说明第二步确定性保持该性质。
原文摘要(Abstract)

Elaboration-based type class resolution, as found in languages like Haskell, Mercury and PureScript, is generally nondeterministic: there can be multiple ways to satisfy a wanted constraint in terms of global instances and locally given constraints. Coherence is the key property that keeps this sane; it guarantees that, despite the nondeterminism, programs still behave predictably. Even though elaboration-based resolution is generally assumed coherent, as far as we know, there is no formal proof of this property in the presence of sources of nondeterminism, like superclasses and flexible contexts. This paper provides a formal proof to remedy the situation. The proof is non-trivial because the semantics elaborates resolution into a target language where different elaborations can be distinguished by contexts that do not have a source language counterpart. Inspired by the notion of full abstraction, we present a two-step strategy that first elaborates nondeterministically into an intermediate language that preserves contextual equivalence, and then deterministically elaborates from there into the target language. We use an approach based on logical relations to establish contextual equivalence and thus coherence for the first step of elaboration, while the second step’s determinism straightforwardly preserves this coherence property.

链接与引用

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

BibTeX
@article{paperbot584,
  title = {Coherence of type class resolution},
  author = {Gert-Jan Bottu and Ningning Xie and Koar Marntirosian and Tom Schrijvers},
  journal = {Proceedings of the ACM on Programming Languages},
  volume = {3},
  number = {ICFP},
  year = {2019},
  doi = {10.1145/3341695}
}