arXiv:2601.18987cs.CLcs.AI2026-01被引 1

大模型能判断程序是否终止,但难给出正式证明。

LLMs versus the Halting Problem: Characterizing Program Termination Reasoning

  • 用大模型分析C语言程序的终止性,比对验证工具表现。
  • 模型正确判断终止性,但无法生成形式化证明,越长代码越差。
  • 提出新方法刻画非终止条件,适合研究推理与验证融合的人工智能学者。

判断程序是否终止是计算机科学的核心问题。图灵的停机问题表明,不存在通用算法能判定所有程序在所有输入下的终止性。因此,验证工具只能近似处理,常无法证明或反驳终止性,且依赖特定架构和编程语言。近期大模型的发展引发疑问:它们能否推理程序终止性?我们评估了前沿大模型在2025年国际软件验证竞赛(SV-Comp 2025)的多样化C程序上的表现。结果显示,GPT-5与Claude Sonnet-4.5在测试时扩展下达到顶尖验证工具水平。尽管模型常能正确判断程序是否终止,却频繁无法构造形式化证明,暴露出语义识别与符号证明生成间的差距。代码长度增加时性能进一步下降。此外,我们引入一种发散前提公式,将非终止条件表述为逻辑约束。这些发现有望推动真实世界终止性基准、结合大模型与符号验证的神经符号方法,以及大模型在其他不可判定问题上的推理研究。

原文摘要 · Abstract (English)

Determining whether a program terminates is a central problem in computer science. Turing's Halting Problem established termination as undecidable, showing that no algorithm can universally determine termination for all programs and inputs. Hence, verification tools approximate termination, sometimes failing to prove or disprove; these tools rely on problem-specific architectures and are usually tied to particular programming languages. Recent advances in LLMs raise a natural question: To what extent can they reason about program termination? We evaluate frontier LLMs on a diverse set of C programs from the International Competition on Software Verification (SV-Comp) 2025. Our results show that GPT-5 and Claude Sonnet-4.5 achieve scores comparable to top-ranked verification tools (with test-time scaling). However, while models often correctly infer whether programs terminate, they frequently fail to construct a witness as formal proof, revealing a gap between semantic recognition and symbolic proof generation. Performance further degrades as code length increases. Beyond witness automaton graphs, we introduce a divergence-precondition formulation that characterizes non-termination conditions as logical constraints. We hope these findings motivate future research on real-world termination benchmarks, neuro-symbolic approaches that combine LLMs with symbolic verification methods, and, more broadly, LLM reasoning on other undecidable problems.

程序验证大模型推理形式化证明

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。