Ranking Function Generation with LLMs for Termination
Organizations: Key Laboratory of System Software (Chinese Academy of Sciences), China · Institute of Software, Chinese Academy of Sciences, China · University of Chinese Academy of Sciences, China · Nanjing Institute of Software Technology ·
Abstract
Ranking functions are a fundamental technique for proving loop termination, but constructing them manually is challenging and requires substantial expertise. We propose RAINFALL, a neuro-symbolic framework which follows the generate-verify-refine paradigm and tightly integrates LLMs with symbolic verification. RAINFALL formulates ranking function synthesis as a code-completion task by inserting placeholders into the input program and constraining the LLM to fill four predefined slots for each loop. The completed program is then checked by a symbolic verifier. If verification succeeds, a valid ranking function is obtained; otherwise, the verifier's diagnostics are translated into natural-language feedback that guides iterative refinement of the LLM's output. We evaluate RAINFALL on two public benchmark suites comprising 358 terminating C programs. Using MiniMax V2.7, RAINFALL synthesizes verifiable ranking functions for 323 programs (90.22%), outperforming all promising baselines. In particular, it solves 12 more programs than PROTON 2.1, the best-performing baseline and winner of the SV-COMP 2026 Termination category. Furthermore, combining RAINFALL with PROTON 2.1 increases the success rate to 96.65% (346/358 programs). We also conduct ablation study confirming individual contributions of placeholder contracts, few-shot examples, symbolic verification, and diagnostic information feedback. Experiments across LLMs further confirm the effectiveness of RAINFALL. Our results suggest a generic, sound framework for ranking-function synthesis and, beyond termination, LLM-assisted synthesis of formally checkable liveness certificates, both of which represent new directions of software engineering research.
Figures & tables
| Tool | BS-F (170) | BS-L (188) | Total (358) | |||
| #Solved | Time(s) | #Solved | Time(s) | #Solved | Time(s) | |
| AProVE | 123 | 23.52 | 159 | 18.33 | 282 | 20.59 |
| ddlTerm | 140 | 62.95 | N/A | N/A | N/A | N/A |
| UAutomizer | 116 | 11.50 | 167 | 5.26 | 283 | 7.82 |
| FreqTerm | 80 | 78.66 | 75 | 28.36 | 155 | 54.32 |
| LOOPY | 124 | 976.13 | 140 | 785.94 | 264 | 875.27 |
| Model | Size | #Solved | #inTok | #outTok | Cost(USD) | Time (s) |
| Claude-Opus | N/A | 160 | 3600 | 10741 | 0.287 | 95.10 |
| DeepSeek | 1.6T | 156 | 2286 | 18659 | 0.017 | 522.70 |
| GPT | N/A | 163 | 2065 | 2668 | 0.090 | 54.81 |
| MiniMax | 230B | 156 | 2778 | 32004 | 0.039 | 581.83 |
| Qwen-Plus | 397B | 138 | 7109 | 38132 | 0.077 | 741.94 |
| Baseline | Sole | Claude-Opus | DeepSeek | GPT | MiniMax | Qwen-Plus |
| AProVE | 123 | 162 | 162 | 165 | 164 | 159 |
| ddlTerm | 140 | 164 | 161 | 164 | 162 | 157 |
| UAutomizer | 116 | 161 | 159 | 164 | 161 | 155 |
| FreqTerm | 80 | 162 | 158 | 164 | 158 | 143 |
| LOOPY | 124 | 163 | 160 | 166 | 160 | 148 |
| PROTON | 148 | 167 | 167 | 169 | 167 | 164 |
Program Synthesis
Program synthesis automatically constructs executable programs from examples, specifications, demonstrations, or natural-language descriptions.
See all 181 papers