LLMs versus the Halting Problem: Revisiting Program Termination Prediction

Oren Sultan, Jordi Armengol-Estape, Pascal Kesseli, Julien Vanegue, Dafna Shahaf, Yossi Adi, Peter W. O’Hearn · DOI

Abstract

Determining whether a program terminates is a central problem in computer science. Turing's foundational result established the Halting Problem as undecidable, showing that no algorithm can universally determine termination for all programs and inputs. Consequently, automatic verification tools approximate termination, sometimes failing to prove or disprove; these tools rely on problem-specific architectures and abstractions, and are usually tied to particular programming languages. Recent success and progress in large language models (LLMs) raises the following question: can LLMs reliably predict program termination? In this work, we evaluate LLMs on a diverse set of C programs from the Termination category of the International Competition on Software Verification (SV-Comp) 2025. Our results suggest that LLMs perform remarkably well at predicting program termination, where GPT-5 and Claude Sonnet-4.5 would rank just behind the top-ranked tool (using test-time-scaling), and Code World Model (CWM) would place just behind the second-ranked tool. While LLMs are effective at predicting program termination, they often fail to provide a valid witness as a proof. Moreover, LLMs performance drops as program length increases. We hope these insights motivate further research into program termination and the broader potential of LLMs for reasoning about undecidable problems.

Introduction: The Challenge of Undecidability

The Halting Problem—determining if a program will eventually stop or run forever—is a cornerstone of computer science. Alan Turing proved in 1936 that this problem is undecidable; no single algorithm can solve it for every possible program. To address this, engineers traditionally rely on formal verification tools that employ complex mathematical abstractions, such as symbolic execution and automata, to approximate answers. However, these tools are often brittle, language-specific, and require significant expert effort to develop. This research investigates whether the reasoning capabilities of modern Large Language Models (LLMs) can bypass these complex architectures to reliably predict program termination in a language-agnostic manner.

Methodology

The study evaluated several state-of-the-art models, including GPT-5, Claude 3.5 Sonnet, and open-weights models like Code World Model (CWM) and Qwen3-32B, using GPT-4o as a non-reasoning baseline. The evaluation utilized the SV-Comp 2025 dataset, comprising 2,328 C programs across categories like BitVectors, MainControlFlow, and MainHeap.

Comparison of traditional symbolic architecture (PROTON) versus the LLM-based approach for termination analysis.

Key methodological innovations included:

  • Test-Time Scaling (TTS): To reduce hallucinations, the researchers employed "Consensus Voting," where multiple responses were generated and an answer was only accepted if the model reached a unanimous consensus.
  • Witness Validation: For programs identified as non-terminating, models were tasked with producing a "witness"—a formal graph in JSON format representing an infinite loop. These witnesses were then verified by the symbolic validator UAutomizer.
  • Domain Witness Prompting: A more natural explanation method was proposed, where LLMs provide logical preconditions (e.g., "the program fails to halt if $x < 0$") instead of complex graph formats.

Key Insights and Results

The most striking finding is that GPT-5 and Claude 3.5 Sonnet would have placed 2nd and 3rd, respectively, in the SV-Comp 2025 competition, trailing only the specialized tool PROTON. GPT-5 achieved a score of 3,520, outperforming the silver-medalist tool UAutomizer (3,334).

The pipeline for LLM witness prediction and subsequent validation by UAutomizer.

Despite high classification accuracy (F1 scores up to 0.98), a significant "Proof Gap" remains. While LLMs can "know" the answer, they struggle to "prove" it formally. Even GPT-5 only produced a valid formal proof for 41.4% of its correct non-termination predictions. Furthermore, performance correlates inversely with code length; as programs become longer and more complex, LLM accuracy drops sharply.

Conclusion and Future Directions

While LLMs show remarkable potential in tackling undecidable problems like program termination, they are currently limited by format sensitivity and scalability to large codebases. The results suggest a promising "neuro-symbolic" future where LLMs propose logical termination arguments or preconditions that are subsequently verified by traditional symbolic solvers. This hybrid approach could leverage the intuitive reasoning of LLMs alongside the rigorous guarantees of formal verification.

Summary updated

BibTeX
@misc{sultan2026llms,
  author = {Oren Sultan and Jordi Armengol-Estape and Pascal Kesseli and Julien Vanegue and Dafna Shahaf and Yossi Adi and Peter W. O’Hearn},
  title = {{LLMs versus the Halting Problem: Revisiting Program Termination Prediction}},
  year = {2026},
  eprint = {2601.18987},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2601.18987},
}
Figure