arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2501.18087cs.PL
收藏

依值模式匹配的覆盖语义

Coverage Semantics for Dependent Pattern Matching

Joseph Eremondi, Ohad Kammar

AI总结:

本文通过层论提出了一种不精化为消除器的依值模式匹配直接范畴语义,利用规范覆盖和层论饱和条件为多种复杂模式提供了合理模型,弥合了理论与实践的差距。

摘要:

依值模式匹配是依值类型编程中的一个关键特性。然而,理论与实践存在脱节:尽管许多证明助手将模式匹配作为原语实现,但理论表述通过将其精化为消除器来给出模式匹配的语义。虽然理论上很方便,但消除器可能显得笨拙且冗长,特别是对于模式的复杂组合。本工作旨在通过为模式匹配提供直接的范畴语义来弥合理论与实践的差距,该语义不精化为消除器。这是通过使用层论来描述何时可以将箭头(项)集合合并为单个箭头来实现的。我们提出了一种具有顶层依值模式匹配的语言,而不指定哪些模式集合被视为匹配的覆盖。然后,我们给出了哪些模式集允许合理模型的充分准则:模式应位于上下文范畴的规范覆盖中。最后,我们使用层论饱和条件来设计一些允许的模式集。我们能够表达并超越现状,为数据类型构造函数、嵌套模式、荒谬模式、命题相等和点模式提供语义。

英文摘要:

Dependent pattern matching is a key feature in dependently typed programming. However, there is a theory-practice disconnect: while many proof assistants implement pattern matching as primitive, theoretical presentations give semantics to pattern matching by elaborating to eliminators. Though theoretically convenient, eliminators can be awkward and verbose, particularly for complex combinations of patterns. This work aims to bridge the theory-practice gap by presenting a direct categorical semantics for pattern matching, which does not elaborate to eliminators. This is achieved using sheaf theory to describe when sets of arrows (terms) can be amalgamated into a single arrow. We present a language with top-level dependent pattern matching, without specifying which sets of patterns are considered covering for a match. Then, we give a sufficient criterion for which pattern-sets admit a sound model: patterns should be in the canonical coverage for the category of contexts. Finally, we use sheaf-theoretic saturation conditions to devise some allowable sets of patterns. We are able to express and exceed the status quo, giving semantics for datatype constructors, nested patterns, absurd patterns, propositional equality, and dot patterns.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑