paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Elaborating dependent (co)pattern matching

精化依赖(共)模式匹配
ICFP 2(ICFP)2018匹配度 2/10 · 该论文属于依赖类型论中的模式匹配精化与Agda实现,是纯PL/类型系统工作,与用户关注的LLM/Agent和静态分析/形式化验证的交叉、浮点程序分析、贝叶斯程序分析等核心方向均无直接关联。虽然涉及形式化验证,但未结合LLM或用户列出的具体问题。引用 18 inbox
Jesper Cockx, Andreas Abel
crossref: 2026-09-10

AI 速览

一句话:提出依赖(共)模式匹配到良类型 case tree 核心语言的精化算法,并证明其保持用户子句的首匹配语义。

依赖类型语言中,类型检查器需将程序与证明精化到低层核心语言,但核心语言难以理解,尤其依赖共模式匹配定义的精化步骤此前被忽视。本文提出算法,把依赖(共)模式匹配定义精化为含归纳数据类型、余归纳记录类型、identity type 与良类型 case tree 常量的核心语言,并证明该精化保持用户子句的首匹配语义。作者据此重新实现 Agda 检查模式匹配左侧的算法;新实现更通用、更简单,修复旧版缺陷与可用性问题,是迈向实用依赖类型语言形式验证实现的一步。

问题
依赖类型语言的核心语言难以人工理解,尤其依赖共模式匹配定义如何被精化为 case tree 这一第一步此前研究不足。
方法
提出精化算法,将依赖(共)模式匹配定义翻译为含归纳数据类型、余归纳记录类型、identity type 和良类型 case tree 常量的核心语言,并证明精化保持用户子句的首匹配语义。
评估
基于该算法重新实现 Agda 的模式匹配左侧检查器,并说明新实现比旧版更通用、更简单,且修复了若干缺陷与可用性问题。
原文摘要(Abstract)

In a dependently typed language, we can guarantee correctness of our programs 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 programs 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 datatypes, 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{paperbot281,
  title = {Elaborating dependent (co)pattern matching},
  author = {Jesper Cockx and Andreas Abel},
  journal = {Proceedings of the ACM on Programming Languages},
  volume = {2},
  number = {ICFP},
  year = {2018},
  doi = {10.1145/3236770}
}