Ranking LLM-Generated Loop Invariants for Program Verification

Saikat Chakraborty, Shuvendu K. Lahiri, Sarah Fakhoury, Madanlal Musuvathi, Akash Lal +4 more
10/13/2023
95 citations
cs.PLcs.AIcs.CL

Official code: microsoft/NeuralInvariantRanker (14 stars, Slash, MIT, last commit 2024-08-20).

Abstract

Synthesizing inductive loop invariants is fundamental to automating program verification. In this work, we observe that Large Language Models (such as gpt-3.5 or gpt-4) are capable of synthesizing loop invariants for a class of programs in a 0-shot setting, yet require several samples to generate the correct invariants.

Show full abstract

This can lead to a large number of calls to a program verifier to establish an invariant. To address this issue, we propose a {\it re-ranking} approach for the generated results of LLMs. We have designed a ranker that can distinguish between correct inductive invariants and incorrect attempts based on the problem definition. The ranker is optimized as a contrastive ranker. Experimental results demonstrate that this re-ranking mechanism significantly improves the ranking of correct invariants among the generated candidates, leading to a notable reduction in the number of calls to a verifier. The source code and the experimental data for this paper are available in \url{https://github.com/microsoft/NeuralInvariantRanker}.

View on arXivView PDF

Code Implementations(1)

MIT

Ranking LLM-Generated Loop Invariants for Program Verification.

146Slash, Jupyter NotebookNov 21, 20232 years agoMIT

Similar Papers

Cite this paper

@article{chakraborty2023ranking,
  title  = {Ranking LLM-Generated Loop Invariants for Program Verification},
  author = {Saikat Chakraborty and Shuvendu K. Lahiri and Sarah Fakhoury and Madanlal Musuvathi and Akash Lal and Aseem Rastogi and Aditya Senthilnathan and Rahul Sharma and Nikhil Swamy},
  year   = {2023},
  eprint = {2310.09342},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2310.09342v3}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2310.09342.svg)](https://codeofpaper.com/paper/2310.09342)

Discussion