sheaf-上同调程序分析:通过Čech上同调统一Bug查找、等价性验证
Sheaf-Cohomological Program Analysis: Unifying Bug Finding, Equivalence, and Verification via Čech Cohomology
AI总结:
本文提出通过Čech上同调统一程序分析中的类型检查、Bug查找和等价性验证,利用上同调群H^0和H^1解决类型错误和等价性失败问题,并在Deppy工具中验证了其有效性。
摘要:
我们提出一个框架,将程序分析(类型检查、Bug查找和等价性验证)组织为计算程序站点范畴上语义预层的Čech上同调。预层将细化类型信息分配给观察站点,并沿数据流态射限制该信息。H^0群是全局一致的类型空间。第一个上同调群H^1分类粘合障碍——Bug、类型错误和等价失败——每个障碍局部化到一对不一致的站点。这种表述产生了三个在先前工作中不可得的结果:(1) H^1的秩在F_2上的计数是独立修复的最小数;(2) H_1(U, Iso)=0对行为等价是正确且完整的;(3) Mayer-Vietoris使组合、渐进的障碍计数成为可能。我们用Deppy,一个Python分析工具,实现了该框架,并在375个基准测试中评估:133个Bug查找程序,134个等价对,108个规范满足检查。Deppy实现了100%的Bug查找召回率(69%精度,F1=81%),99%的等价准确性(零假等价),98%的规范准确性(零假满足)——优于mypy和pyright,后者在未注释代码上报告零发现。分析将Python语义建模为代数几何:变量在通用纤维(非None)上生活,除非在闭合可空子方案上,整数形成Spec(Z)无有界截面(无溢出),短路评估定义了预层上的开集拓扑。
英文摘要:
We present a framework in which program analysis -- type checking, bug finding, and equivalence verification -- is organized as computing the Čech cohomology of a semantic presheaf over a program's site category. The presheaf assigns refinement-type information to observation sites and restricts it along data-flow morphisms. The cohomology group $H^{0}$ is the space of globally consistent typings. The first cohomology group $H^{1}$ classifies gluing obstructions -- bugs, type errors, and equivalence failures -- each localized to a specific pair of disagreeing sites. This formulation yields three concrete results unavailable in prior work: (1) the rank of $H^1$ over $F_{2}$ counts the minimum independent fixes; (2) $H_{1}(U, Iso) = 0$ is sound and complete for behavioral equivalence; (3) Mayer-Vietoris enables compositional, incremental obstruction counting. We implement the framework in Deppy, a Python analysis tool, and evaluate it on a suite of 375~benchmarks: 133~bug-detection programs, 134~equivalence pairs, and 108~specification-satisfaction checks. Deppy achieves {100% bug-detection recall} (69% precision, F1 = 81%), 99% equivalence accuracy with zero false equivalences, and 98% spec accuracy with zero false satisfactions -- outperforming mypy and pyright, which report zero findings on unannotated code. The analysis models Python semantics as algebraic geometry: variables live on the generic fiber (non-None) unless on the closed nullable subscheme, integers form Spec($\mathbb{Z}$) with no bounded section (no overflow), and short-circuit evaluation defines an open-set topology on the presheaf.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。