Enhancing Automated Loop Invariant Generation for Complex Programs with Large Language Models

Fuente: arXiv
Gespeichert in:
Bibliographische Detailangaben
Hauptverfasser: Liu, Ruibang, Chen, Minyu, Wu, Ling-I, Ke, Jingyu, Li, Guoqiang
Format: Preprint
Veröffentlicht: 2024
Schlagworte:
Online-Zugang:
Tags: Tag hinzufügen
Keine Tags, Fügen Sie den ersten Tag hinzu!
_version_ 1866909789469016064
author Liu, Ruibang
Chen, Minyu
Wu, Ling-I
Ke, Jingyu
Li, Guoqiang
author_facet Liu, Ruibang
Chen, Minyu
Wu, Ling-I
Ke, Jingyu
Li, Guoqiang
contents Automated program verification has always been an important component of building trustworthy software. While the analysis of real-world programs remains a theoretical challenge, the automation of loop invariant analysis has effectively resolved the problem. However, real-world programs that often mix complex data structures and control flows pose challenges to traditional loop invariant generation tools. To enhance the applicability of invariant generation techniques, we proposed ACInv, an Automated Complex program loop Invariant generation tool, which combines static analysis with Large Language Models (LLMs) to generate the proper loop invariants. We utilize static analysis to extract the necessary information for each loop and embed it into prompts for the LLM to generate invariants for each loop. Subsequently, we employ an LLM-based evaluator to assess the generated invariants, refining them by either strengthening, weakening, or rejecting them based on their correctness, ultimately obtaining enhanced invariants. We conducted experiments on ACInv, which showed that ACInv outperformed previous tools on data sets with data structures, and maintained similar performance to the state-of-the-art tool AutoSpec on numerical programs without data structures. For the total data set, ACInv can solve 21% more examples than AutoSpec and can generate reference data structure templates.
format Preprint
id arxiv_https___arxiv_org_abs_2412_10483
institution arXiv
publishDate 2024
record_format arxiv
spellingShingle Enhancing Automated Loop Invariant Generation for Complex Programs with Large Language Models
Liu, Ruibang
Chen, Minyu
Wu, Ling-I
Ke, Jingyu
Li, Guoqiang
Software Engineering
Artificial Intelligence
Programming Languages
Automated program verification has always been an important component of building trustworthy software. While the analysis of real-world programs remains a theoretical challenge, the automation of loop invariant analysis has effectively resolved the problem. However, real-world programs that often mix complex data structures and control flows pose challenges to traditional loop invariant generation tools. To enhance the applicability of invariant generation techniques, we proposed ACInv, an Automated Complex program loop Invariant generation tool, which combines static analysis with Large Language Models (LLMs) to generate the proper loop invariants. We utilize static analysis to extract the necessary information for each loop and embed it into prompts for the LLM to generate invariants for each loop. Subsequently, we employ an LLM-based evaluator to assess the generated invariants, refining them by either strengthening, weakening, or rejecting them based on their correctness, ultimately obtaining enhanced invariants. We conducted experiments on ACInv, which showed that ACInv outperformed previous tools on data sets with data structures, and maintained similar performance to the state-of-the-art tool AutoSpec on numerical programs without data structures. For the total data set, ACInv can solve 21% more examples than AutoSpec and can generate reference data structure templates.
title Enhancing Automated Loop Invariant Generation for Complex Programs with Large Language Models
topic Software Engineering
Artificial Intelligence
Programming Languages
url https://arxiv.org/abs/2412.10483