计算机科学 > 计算机科学中的逻辑
[提交于 2024年3月13日 (v1),最后修订于 2025年8月14日 (此版本, v3)]
标题:A bargain for mergesorts -- How to prove your mergesort correct and stable, almost for free
查看原文 PDF 中文 PDF (下批处理) EasyResearch 阅读摘要: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).