Ruibang Liu, Minyu Chen, Ling-I Wu, Jingyu Ke, Guoqiang Li
{"title":"增强具有大型语言模型的复杂程序的自动循环不变量生成","authors":"Ruibang Liu, Minyu Chen, Ling-I Wu, Jingyu Ke, Guoqiang Li","doi":"10.1016/j.scico.2025.103387","DOIUrl":null,"url":null,"abstract":"<div><div>Automated program verification has always been an important component of building trustworthy software. While the analysis of loops remains a theoretical challenge, the automation of loop invariant analysis has effectively resolved the problem. However, existing invariant generation tools are predominantly effective for programs with purely numerical or purely pointer-based structures. Real-world programs often mix complex data structures and control flows. These structures can include arrays, pointers, and recursive definitions, while control flows may involve multiple nested or concurrent loops. Traditional methods generally only generate invariants for simple numerical programs or specific segments, lacking broad applicability. In order to automatically generate loop invariants for real-world programs, we proposed <em>ACInv</em>, an Automated Complex program loop Invariant generation tool, which combines static analysis with prompting with Large Language Models (LLM) to generate the proper loop invariants. We employ static analysis to systematically decompose the program's data structures and loops. This involves layer-by-layer transmission of structural information about variables, numerical data, and the complete loop structure to the LLM, enabling the generation of corresponding invariants. In comparison to prior work on AutoSpec, we delve deeper into the variable information within each loop. 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.</div></div>","PeriodicalId":49561,"journal":{"name":"Science of Computer Programming","volume":"248 ","pages":"Article 103387"},"PeriodicalIF":1.4000,"publicationDate":"2025-08-29","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":"0","resultStr":"{\"title\":\"Enhancing automated loop invariant generation for complex programs with large language models\",\"authors\":\"Ruibang Liu, Minyu Chen, Ling-I Wu, Jingyu Ke, Guoqiang Li\",\"doi\":\"10.1016/j.scico.2025.103387\",\"DOIUrl\":null,\"url\":null,\"abstract\":\"<div><div>Automated program verification has always been an important component of building trustworthy software. While the analysis of loops remains a theoretical challenge, the automation of loop invariant analysis has effectively resolved the problem. However, existing invariant generation tools are predominantly effective for programs with purely numerical or purely pointer-based structures. Real-world programs often mix complex data structures and control flows. These structures can include arrays, pointers, and recursive definitions, while control flows may involve multiple nested or concurrent loops. Traditional methods generally only generate invariants for simple numerical programs or specific segments, lacking broad applicability. In order to automatically generate loop invariants for real-world programs, we proposed <em>ACInv</em>, an Automated Complex program loop Invariant generation tool, which combines static analysis with prompting with Large Language Models (LLM) to generate the proper loop invariants. We employ static analysis to systematically decompose the program's data structures and loops. This involves layer-by-layer transmission of structural information about variables, numerical data, and the complete loop structure to the LLM, enabling the generation of corresponding invariants. In comparison to prior work on AutoSpec, we delve deeper into the variable information within each loop. 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.</div></div>\",\"PeriodicalId\":49561,\"journal\":{\"name\":\"Science of Computer Programming\",\"volume\":\"248 \",\"pages\":\"Article 103387\"},\"PeriodicalIF\":1.4000,\"publicationDate\":\"2025-08-29\",\"publicationTypes\":\"Journal Article\",\"fieldsOfStudy\":null,\"isOpenAccess\":false,\"openAccessPdf\":\"\",\"citationCount\":\"0\",\"resultStr\":null,\"platform\":\"Semanticscholar\",\"paperid\":null,\"PeriodicalName\":\"Science of Computer Programming\",\"FirstCategoryId\":\"94\",\"ListUrlMain\":\"https://www.sciencedirect.com/science/article/pii/S0167642325001261\",\"RegionNum\":4,\"RegionCategory\":\"计算机科学\",\"ArticlePicture\":[],\"TitleCN\":null,\"AbstractTextCN\":null,\"PMCID\":null,\"EPubDate\":\"\",\"PubModel\":\"\",\"JCR\":\"Q3\",\"JCRName\":\"COMPUTER SCIENCE, SOFTWARE ENGINEERING\",\"Score\":null,\"Total\":0}","platform":"Semanticscholar","paperid":null,"PeriodicalName":"Science of Computer Programming","FirstCategoryId":"94","ListUrlMain":"https://www.sciencedirect.com/science/article/pii/S0167642325001261","RegionNum":4,"RegionCategory":"计算机科学","ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"","PubModel":"","JCR":"Q3","JCRName":"COMPUTER SCIENCE, SOFTWARE ENGINEERING","Score":null,"Total":0}
Enhancing automated loop invariant generation for complex programs with large language models
Automated program verification has always been an important component of building trustworthy software. While the analysis of loops remains a theoretical challenge, the automation of loop invariant analysis has effectively resolved the problem. However, existing invariant generation tools are predominantly effective for programs with purely numerical or purely pointer-based structures. Real-world programs often mix complex data structures and control flows. These structures can include arrays, pointers, and recursive definitions, while control flows may involve multiple nested or concurrent loops. Traditional methods generally only generate invariants for simple numerical programs or specific segments, lacking broad applicability. In order to automatically generate loop invariants for real-world programs, we proposed ACInv, an Automated Complex program loop Invariant generation tool, which combines static analysis with prompting with Large Language Models (LLM) to generate the proper loop invariants. We employ static analysis to systematically decompose the program's data structures and loops. This involves layer-by-layer transmission of structural information about variables, numerical data, and the complete loop structure to the LLM, enabling the generation of corresponding invariants. In comparison to prior work on AutoSpec, we delve deeper into the variable information within each loop. 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.
期刊介绍:
Science of Computer Programming is dedicated to the distribution of research results in the areas of software systems development, use and maintenance, including the software aspects of hardware design.
The journal has a wide scope ranging from the many facets of methodological foundations to the details of technical issues andthe aspects of industrial practice.
The subjects of interest to SCP cover the entire spectrum of methods for the entire life cycle of software systems, including
• Requirements, specification, design, validation, verification, coding, testing, maintenance, metrics and renovation of software;
• Design, implementation and evaluation of programming languages;
• Programming environments, development tools, visualisation and animation;
• Management of the development process;
• Human factors in software, software for social interaction, software for social computing;
• Cyber physical systems, and software for the interaction between the physical and the machine;
• Software aspects of infrastructure services, system administration, and network management.