paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Extensional equality preservation and verified generic programming

外延相等保持与已验证泛型编程
JFP vol.312021匹配度 3/10 · 论文属于内涵类型论与已验证泛型编程的形式化方法,关注外延相等保持和 monadic laws 的泛型证明;未涉及 LLM/Agent、静态分析、浮点程序分析或贝叶斯程序分析等核心方向,仅与形式化验证有较弱的领域关联。引用 5 inbox
NICOLA BOTTA, NURIA BREDE, PATRIK JANSSON, TIM RICHTER
crossref: 2026-09-10

AI 速览

一句话:提出外延相等保持原则,在内涵类型论中无需扩展理论或完整 setoid 即可进行已验证泛型编程。

已验证泛型编程需要在抽象数据类型之上推理,无法依赖具体数据类型结构。函子与单子是函数式编程的核心,但许多重要单子的函子映射保持外延相等:若 f 与 g 外延相等,则 map f 与 map g 也外延相等。本文探索将这一性质作为已验证泛型编程的基本原则。作者采用极简方法,在 Martin-Löf 内涵类型论中处理外延相等的缺失,不扩展理论,也不使用完整的 setoid。结果表明,这一极简方法非常有用:既能给出单子律的简单泛型证明,也能在动力系统与控制理论中获得已验证的泛型结果,从而避免繁琐的代码重复与专门证明。该工作推动了实用化的已验证泛型编程。

问题
已验证泛型编程难以利用具体数据类型结构,需要合适的抽象数据类型与规约来推理函子和单子等结构;外延相等在内涵类型论中无法直接获得。
方法
采用极简方法,在 Martin-Löf 内涵类型论中直接处理外延相等保持,不扩展类型论或引入完整 setoid,并基于抽象数据类型构造泛型证明。
评估
通过推导单子律的泛型证明,以及在动力系统与控制理论中形式化已验证的泛型结果,展示该方法的有效性并避免代码重复与专门证明。
原文摘要(Abstract)

Abstract In verified generic programming, one cannot exploit the structure of concrete data types but has to rely on well chosen sets of specifications or abstract data types (ADTs). Functors and monads are at the core of many applications of functional programming. This raises the question of what useful ADTs for verified functors and monads could look like. The functorial map of many important monads preserves extensional equality. For instance, if $$f,g \, : \, A \, \to \, B$$ are extensionally equal, that is, $$\forall x \in A$$ , $$f \, x = g \, x$$ , then $$map \, f \, : \, List \, A \to List \, B$$ and $$map \, g$$ are also extensionally equal. This suggests that preservation of extensional equality could be a useful principle in verified generic programming. We explore this possibility with a minimalist approach: we deal with (the lack of) extensional equality in Martin-Löf’s intensional type theories without extending the theories or using full-fledged setoids. Perhaps surprisingly, this minimal approach turns out to be extremely useful. It allows one to derive simple generic proofs of monadic laws but also verified, generic results in dynamical systems and control theory. In turn, these results avoid tedious code duplication and ad-hoc proofs. Thus, our work is a contribution toward pragmatic, verified generic programming.

链接与引用

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

BibTeX
@article{paperbot1241,
  title = {Extensional equality preservation and verified generic programming},
  author = {NICOLA BOTTA and NURIA BREDE and PATRIK JANSSON and TIM RICHTER},
  journal = {Journal of Functional Programming},
  volume = {31},
  year = {2021},
  doi = {10.1017/s0956796821000204}
}