Ranking Function Generation with LLMs for Termination
Rongkang Li, Jiaxin Hu, Taolue Chen, Yong Li, Fu Song, Zhilin Wu, Qiusong Yang
原文摘要
Ranking functions are a fundamental technique for proving loop termination, but synthesizing them remains challenging and often requires substantial expertise. Despite considerable progress in their automated synthesis, existing approaches remain limited in their effectiveness. We propose RAINFALL, a neuro-symbolic framework that tightly integrates large language models (LLMs) with symbolic verification. To our best knowledge, RAINFALL is the first to employ a generate-verify-refine paradigm for LLM-based ranking function synthesis. RAINFALL formulates ranking function synthesis as a constrained code-completion task, inserting placeholders into the input program that the LLM must fill in four predefined slots per loop. The resulting program is checked by a symbolic verifier. Successful verification yields a valid ranking function, while verification failures produce diagnostics that are translated into natural-language feedback to guide iterative refinement. We evaluate RAINFALL on two public benchmark suites comprising 358 terminating C programs. Using DeepSeek-V4.1-Flash, RAINFALL synthesizes verified ranking functions for 333 programs (93.02%), outperforming all evaluated baselines. Notably, it solves 22 more programs than PROTON 2.1, the winner of the SV-COMP 2026 Termination Category. Combining RAINFALL with PROTON 2.1 further increases the success rate to 96.65% (346/358 programs). Ablation studies demonstrate the contributions of placeholder contracts, few-shot examples, symbolic verification, and diagnostic feedback, while experiments across different LLMs establish the broader applicability of the framework.
cs.SE · cs.AI · cs.LO