创建

登录 ReadmeX

或

了解我们如何处理你的信息: 隐私政策

ReadmeX

陪你读懂 AI 动态

今天,想先了解什么?

选一份动态总结,或直接聊聊你的问题。

社区和关注动态总结只属于你自己。

资讯

AI 智能体用 Lean 形式化 CPython 并报告缺陷

AI 总结

David Andrews 和 Chao Zhang 称,AI 智能体已将 CPython 3.15.2 的 4,071 个函数重写为 Lean 代码,形成 1,539 个文件中的 613,318 行内容及 18,898 个定理和引理。每个重写版本先在数万组输入上与真实 Python 进行差分测试,再由另一智能体和 Lean 证明检查器核验。项目还产生了 418 份缺陷报告,其中约 55 份据称可导致解释器崩溃或内存损坏。

深度见解

该项目展示了一种大规模 AI 辅助形式化验证流程,并利用机器检查的证明发现生产软件中的边界条件缺陷。

AI agents wrote 613,318 lines of Lean that copy Python's internals line by line, tested every piece against the real Python, had a computer check every proof, and turned up 418 bug reports in Python along the way.

CPython · Objects/rangeobject.c

static unsigned longget_len_of_range(long lo, long hi, long step){ assert(step != 0); if (step > 0 && lo < hi) return 1UL + (hi - 1UL - lo) / step; else if (step < 0 && lo > hi) return 1UL + (lo - 1UL - hi) / (0UL - step); else return 0UL;}

Lean copy · RangeSlice/Model.lean

def getLenOfRange (lo hi step : Int) : Int := if step > 0 ∧ lo < hi then uadd 1 (usub (usub (toU hi) 1) (toU lo) / toU step) else if step < 0 ∧ lo > hi then uadd 1 (usub (usub (toU lo) 1) (toU hi) / usub 0 (toU step)) else 0 -- step ≠ 0 is assumed by every proof-- uadd, usub: C's unsigned arithmetic,-- which wraps around past 2^64

A function from CPython's C source (left) and the Lean copy an agent wrote of it (right). Hover over a line to see its counterpart.

#Formalizing CPython#CPython 3.15.2#Lean#Opus 5.5#Python

原文约 12 分钟读完阅读原文
群聊

还没有评论,来说说你的看法。