AI
LLMs Boost Loop Termination Proofs with Automated Ranking Function Synthesis
A new neuro-symbolic framework combines language models with formal verification to automatically generate ranking functions that prove whether loops terminate.
Proving that computer programs will eventually stop—rather than run forever—is a fundamental challenge in formal verification. Ranking functions are the classical mathematical tool used to establish loop termination, but creating them has traditionally been an expert-level task. Researchers have now developed a system that harnesses large language models to generate these functions automatically.
The RAINFALL Framework#
The new approach, called RAINFALL, combines large language models with symbolic verification in what the authors describe as a generate-verify-refine cycle. Rather than treating LLM code generation and formal proof as separate steps, RAINFALL weaves them tightly together: an LLM proposes ranking functions, a symbolic verifier tests them, and when verification fails, the diagnostic feedback becomes natural-language guidance for the model to refine its next attempt.
The system frames ranking function synthesis as a constrained code-completion problem. For each loop in a program, RAINFALL inserts four placeholder slots that the language model fills in. The completed code then undergoes symbolic verification.
Performance and Results#
Evaluated on 358 terminating C programs across two public benchmarks, RAINFALL using the DeepSeek-V4.1-Flash model successfully synthesized verified ranking functions for 333 programs (93.02%)—surpassing all tested baselines. It solved 22 more programs than PROTON 2.1, the winner of the 2026 SV-COMP Termination Category. When RAINFALL was combined with PROTON 2.1, the combined success rate reached 96.65% (346/358 programs).
What Makes It Work#
Ablation studies revealed which components contributed most to the system's effectiveness: placeholder contracts that guide the LLM, few-shot examples that demonstrate the expected style, symbolic verification for correctness checking, and diagnostic feedback for iterative refinement. The framework proved broadly applicable across different language models, though results varied by model choice.
The work demonstrates how neuro-symbolic integration—pairing neural networks' pattern-matching strengths with symbolic reasoning's guarantees—can tackle a traditionally difficult formal-methods problem.

