paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Elaborating dependent (co)pattern matching: No pattern left behind

依赖(余)模式匹配的加工:不遗漏任何模式
JFP vol.302020匹配度 2/10 · 论文研究依赖类型语言中(余)模式匹配到 case tree 的 elaboration,属于类型系统与语言设计/实现,未涉及静态分析在 ML/Agent 程序中的应用,也未使用 LLM/Agent 改进静态分析或形式化验证,与用户画像的核心交叉方向无关。引用 1 inbox
JESPER COCKX, ANDREAS ABEL
crossref: 2026-09-10

AI 速览

一句话:提出将依赖(余)模式匹配定义加工为核心语言 case tree 的算法,证明其保持首匹配语义并改进 Agda 实现。

在依赖类型语言中,程序与证明会被类型检查器加工成底层核心语言,但用户定义的依赖余模式匹配如何正确翻译为 case tree 长期缺乏形式化说明。本文针对这一“第一步”,提出将依赖余模式匹配定义加工为含归纳数据类型、余归纳记录类型、同一性类型和良类型 case tree 常量的核心语言的算法。作者证明该加工保持用户子句的首匹配语义,并用该理论重新实现 Agda 检查模式匹配左侧的算法。新实现更通用、更简单,并修复旧版若干错误与可用性问题,向实用依赖类型语言的形式验证实现迈进一步。

问题
依赖类型语言的核心语言难以被用户理解,而依赖(余)模式匹配定义如何从用户子句正确加工为 case tree 并保持语义,此前尚未得到充分形式化。
方法
定义将依赖余模式匹配加工为核心语言中良类型 case tree 的算法,并证明该加工保持用户子句的首匹配语义;基于此理论重新实现 Agda 的模式匹配左侧检查器。
评估
通过形式化证明保证语义保持,并以 Agda 实现重写作为实践评估,表明新实现比旧版更通用、更简单,且修复了若干错误和可用性问题。
原文摘要(Abstract)

Abstract In a dependently typed language, we can guarantee correctness of our programmes by providing formal proofs. To check them, the typechecker elaborates these programs and proofs into a low-level core language. However, this core language is by nature hard to understand by mere humans, so how can we know we proved the right thing? This question occurs in particular for dependent copattern matching, a powerful language construct for writing programmes and proofs by dependent case analysis and mixed induction/coinduction. A definition by copattern matching consists of a list of clauses that are elaborated to a case tree , which can be further translated to primitive eliminators . In previous work this second step has received a lot of attention, but the first step has been mostly ignored so far. We present an algorithm elaborating definitions by dependent copattern matching to a core language with inductive data types, coinductive record types, an identity type, and constants defined by well-typed case trees. To ensure correctness, we prove that elaboration preserves the first-match semantics of the user clauses. Based on this theoretical work, we reimplement the algorithm used by Agda to check left-hand sides of definitions by pattern matching. The new implementation is at the same time more general and less complex, and fixes a number of bugs and usability issues with the old version. Thus, we take another step towards the formally verified implementation of a practical dependently typed language.

链接与引用

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

BibTeX
@article{paperbot963,
  title = {Elaborating dependent (co)pattern matching: No pattern left behind},
  author = {JESPER COCKX and ANDREAS ABEL},
  journal = {Journal of Functional Programming},
  volume = {30},
  year = {2020},
  doi = {10.1017/s0956796819000182}
}