paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Turner, Bird, Eratosthenes: An eternal burning thread

Turner、Bird、Eratosthenes:一条永恒燃烧的线索
JFP vol.352025匹配度 1/10 · 论文关注函数式编程中的惰性求值、循环程序与生产性证明,属于理论PL/形式化验证边缘话题;未涉及用户核心方向中的LLM/Agent、静态分析、浮点程序分析或贝叶斯程序分析,交叉匹配度很低。引用 0 inbox
JEREMY GIBBONS
crossref: 2026-09-10

AI 速览

一句话:以 Bird 的循环埃拉托斯特尼筛为例,探讨其生产性证明,并把它作为 Turner 总体函数式编程的挑战问题。

文章回顾 Turner 对惰性求值和列表推导的推广,特别是他普及的一行递归素数生成程序,即所谓埃拉托斯特尼筛。O’Neill 指出该程序并非真正筛法并用优先队列给出忠实实现;Bird 提出仅用列表与循环编程的变体。Bird 在教材中再次描述该循环程序并把正确性证明留作练习,但其提示有误。本文追问该循环程序为何具有生产性,正确证明应如何构造,并将 Bird 的循环筛作为 Turner“总体函数式编程”的挑战问题,讨论结构递归/余递归对终止性与生产性的保证,以及总体函数式风格能否覆盖此类算法。

问题
Turner 流行的一行素数筛并非真正的埃拉托斯特尼筛,而 Bird 的纯列表循环版本虽巧妙,其生产性/正确性证明被留作练习且提示有误。
方法
文章以 Bird 的循环筛为案例,结合惰性求值、循环编程和总体函数式编程的结构递归/余递归思想,分析并构造其生产性与正确性证明。
评估
通过概念分析和证明推演来评估该循环程序与总体函数式编程的适用范围;摘要未报告实验或机器化验证。
原文摘要(Abstract)

Abstract Functional programmers have many things for which to thank the late David Turner: design decisions he made in his languages SASL, KRC, and Miranda over the last 50 years are still influential and inspirational now. In particular, Turner was a strong advocate of lazy evaluation and of list comprehensions. As an illustration of these techniques, he popularized a one-line recursive “sieve” to generate the infinite list of prime numbers. Turner called this algorithm The Sieve of Eratosthenes. In a lovely paper called “The Genuine Sieve of Eratosthenes”, Melissa O’Neill argued that Turner’s program is not in fact a faithful implementation of the algorithm, and gave a detailed presentation using priority queues of the real thing. She included a variation by Richard Bird, which uses only lists but makes clever use of circular programming. Bird describes his circular program again in his textbook “Thinking Functionally with Haskell”, and sets its proof of correctness as an exercise. In particular, why is this circular program productive? Unfortunately, Bird’s hint for a solution is incorrect. So what should a proof look like? One of the last projects Turner worked on was the notion of “Total Functional Programming”. He observed that most programs are already structurally recursive or corecursive, therefore guaranteed respectively terminating or productive; he conjectured that “with more practice we will find this is always true”. We explore Bird’s circular Sieve of Eratosthenes as a challenge problem for Turner’s Total Functional Programming.

链接与引用

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

BibTeX
@article{Gibbons25,
  title = {Turner, Bird, Eratosthenes: An eternal burning thread},
  author = {JEREMY GIBBONS},
  journal = {Journal of Functional Programming},
  volume = {35},
  year = {2025},
  doi = {10.1017/s0956796824000194}
}