LLM For Loop Invariant Generation and Fixing: How Far Are We?
By: Mostafijur Rahman Akhond, Saikat Chakraborty, Gias Uddin
Potential Business Impact:
Helps computers check programs for safety mistakes.
A loop invariant is a property of a loop that remains true before and after each execution of the loop. The identification of loop invariants is a critical step to support automated program safety assessment. Recent advancements in Large Language Models (LLMs) have demonstrated potential in diverse software engineering (SE) and formal verification tasks. However, we are not aware of the performance of LLMs to infer loop invariants. We report an empirical study of both open-source and closed-source LLMs of varying sizes to assess their proficiency in inferring inductive loop invariants for programs and in fixing incorrect invariants. Our findings reveal that while LLMs exhibit some utility in inferring and repairing loop invariants, their performance is substantially enhanced when supplemented with auxiliary information such as domain knowledge and illustrative examples. LLMs achieve a maximum success rate of 78\% in generating, but are limited to 16\% in repairing the invariant.
Similar Papers
Loop Invariant Generation: A Hybrid Framework of Reasoning optimised LLMs and SMT Solvers
Logic in Computer Science
Helps computers prove programs are correct automatically.
Beyond Affine Loops: A Geometric Approach to Program Synthesis
Symbolic Computation
Makes computer programs work correctly by finding math rules.
From Affine to Polynomial: Synthesizing Loops with Branches via Algebraic Geometry
Programming Languages
Finds errors in computer programs automatically.