paperbot · PL 论文追踪

全部论文 待读 收藏

P2 A Bargain for Mergesorts: How to Prove Your Mergesort Correct and Stable, Almost for Free

归并排序的便宜买卖:如何几乎免费地证明归并排序正确且稳定
ICFP 9(ICFP)2025匹配度 2/10 · 该论文属于形式化验证与证明工程,研究归并排序正确性与稳定性的机械化证明,但未涉及用户核心关注的 LLM/Agent 与静态分析/形式化验证的交叉,也与浮点程序分析、贝叶斯程序分析无关。引用 0 inbox
Cyril Cohen, Kazuhiko Sakaguchi
crossref: 2026-09-10

AI 速览

一句话:用关系参数性刻画稳定归并排序,使多种实现的正确性与稳定性证明在 Rocq 中近乎免费。

本文提出一种基于关系参数性(relational parametricity)的稳定归并排序函数刻画,并证明该刻画蕴含归并排序的函数正确性。由此,对某一归并排序变体只需证明其满足该特征性质,便可推出其正确性。作者利用该刻画与参数性翻译,在 Rocq Prover(原 Coq)中推导了多种列表归并排序实现的正确性与稳定性,包括自顶向下、自底向上、尾递归与非尾递归、平滑与非平滑以及高度优化的实现。该方法将正确性证明转化为对统一特征性质的验证,从而显著降低证明负担,实现“几乎免费”地证明归并排序正确且稳定。

问题
如何低成本地证明多种归并排序实现的函数正确性,并同时保证其稳定性?
方法
用关系参数性给出稳定归并排序的特征性质,并借助参数性翻译将各具体实现归约到该性质的证明。
评估
在 Rocq Prover(原 Coq)中验证多种列表归并排序实现,包括自顶向下、自底向上、尾递归、非尾递归、平滑、非平滑及高度优化版本,并推出其正确性与稳定性。
原文摘要(Abstract)

We present a novel characterization of stable mergesort functions using relational parametricity, and show that it implies the functional correctness of mergesort. As a result, one can prove the correctness of several variations of mergesort ( e.g ., top-down, bottom-up, tail-recursive, non-tail-recursive, smooth, and non-smooth mergesorts) by proving the characteristic property for each variation. Thanks to our characterization and the parametricity translation, we deduced the correctness results, including stability, of various implementations of mergesort for lists, including highly optimized ones, in the Rocq Prover (formerly the Coq Proof Assistant).

链接与引用

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

BibTeX
@article{paperbot3029,
  title = {A Bargain for Mergesorts: How to Prove Your Mergesort Correct and Stable, Almost for Free},
  author = {Cyril Cohen and Kazuhiko Sakaguchi},
  journal = {Proceedings of the ACM on Programming Languages},
  volume = {9},
  number = {ICFP},
  year = {2025},
  doi = {10.1145/3747505}
}