Large model assisted automatic program verification method and system
Patent Information
- Application Number
- CN202510894855.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-30
- Publication Date
- 2025-11-07
AI Technical Summary
Existing program verification technologies consume excessive computing resources and have low verification efficiency when dealing with large-scale and complex programs. In particular, they are difficult to find suitable loop invariants quickly when dealing with complex loop structures, resulting in excessively long verification time or failure to complete the verification process.
An automated program verification method assisted by a large model is adopted. By analyzing the correlation between the semantic logic of the program and the data scale, the data scale is optimized. When optimization is not possible, defect analysis and counterexample generation are performed to achieve fully automated verification.
It significantly reduces the consumption of computing resources and time in the verification process, and improves the accuracy and efficiency of verification, especially in complex program scenarios where it can efficiently complete verification tasks.
Smart Images

Figure CN120909897A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the model checking technology in the field of software engineering, in particular to a large model assisted automated program verification method and system, wherein the large model is used as an auxiliary tool to support program analysis and verification. BACKGROUND
[0002] In the field of formal methods, model checking is a key automated technology that verifies whether a system design meets specific specifications and requirements by exhaustively exploring all possible states of the system model. Model checking is widely used in hardware circuits, software programs, protocol verification, and other fields, and plays a crucial role in ensuring that system behavior meets expectations. With the increasing size and complexity of systems, traditional model checking methods face the problem of state space explosion, which poses a huge challenge to their application efficiency in large-scale systems. Program verification, as an important branch of model checking, is committed to using mathematical methods to rigorously prove whether a program meets predetermined goals and specifications. Program verification can be divided into partial correctness verification (i.e., verifying the correctness of program output) and complete correctness verification (verifying both the correctness of program output and the termination of the program). Unlike program testing, which relies on actual execution to check program behavior, program verification uses strict logic and mathematical tools to prove program correctness, including inductive assertion, formal verification, symbolic execution, and other methods. Formal verification helps ensure software quality and system reliability in the development of high-security requirements and complex systems, reducing defects and improving system stability and security.
[0003] The complexity of software systems mainly comes from two aspects: first, the complexity of software code, which increases the complexity of the internal structure of the software; second, the large size of data, which not only increases the difficulty of data processing, but also makes the behavior of the software system highly uncertain. This complexity often exceeds the processing capacity of existing verification tools, limiting the effectiveness of these tools in practical applications, which poses a challenge to the reliability and stability of software systems.
[0004] The handling of loop structures has always been one of the core challenges in program verification. Loop structures make the control flow of a program more complex, increasing the difficulty of predicting and verifying the behavior of the program. One of the core tasks for verification tools when dealing with loops is to identify and compute loop invariants, which are expressions that describe conditions or properties that remain unchanged during the execution of the loop. The identification of loop invariants is crucial for proving the correctness of a program, as they can reveal the evolution of the state inside the loop and provide important logical evidence for the termination and safety of the loop. However, as the size of the data processed by the program grows, the complexity of computing and deriving loop invariants also increases dramatically. Especially when the data set processed by the program presents a multi-dimensional and multi-level complex structure, the derivation process of loop invariants often involves a comprehensive analysis of the state inside the loop body, which makes the analysis process very tedious and challenging. More importantly, the presence of large-scale data sets causes the computational resources required for the derivation of loop invariants to grow exponentially, including time, memory, processor capacity, etc., which may lead to a significant decrease in the efficiency of the verification process in practical applications, or even make it unfeasible.
[0005] Existing program verification techniques have exposed problems such as excessive resource consumption, low verification efficiency, and insufficient effectiveness of verification results in the program verification process. Specifically, the resource consumption problem faced by verification tools during the verification process is particularly prominent, especially in terms of memory usage and computational overhead. Generally speaking, traditional program verification tools usually convert all possible paths in the program into SAT or SMT problems for analysis by solvers. However, as the size and complexity of the program increase, the number of program paths grows exponentially, leading to an explosion of state space and thus significantly increasing memory consumption and computational resource requirements. In the case of complex nested loops or scenarios with an uncertain number of iterations, verification tools often need to fully expand the loops, and the number of expansions depends on the size of the input data, which further exacerbates the consumption of computational resources and time complexity. In addition, for programs involving dynamic memory allocation, verification tools also need to model each memory allocation and release, especially when dealing with complex memory management programs, the resource consumption increases significantly. This makes it difficult for traditional tools to efficiently complete the verification task when faced with complex programs. Especially when the program contains complex loop structures, the verification process often needs to derive accurate loop invariants to prove the correctness of the program. However, automatically deriving loop invariants is a challenging task, especially when the loop involves complex data dependency relationships, verification tools may have difficulty quickly finding suitable loop invariants, thus significantly slowing down the verification process. As the size of the program code and the complexity of the modules continue to increase, the time required for verification presents a non-linear growth, which makes the efficiency of traditional tools in verifying large and complex projects gradually decline, and the verification task may even fall into the dilemma of timeout or failure to complete.
[0006] In the field of deep learning, large language models (or simply large models) are complex systems composed of deep neural networks, possessing billions to hundreds of billions of parameters. Trained on massive datasets, these models can capture and learn deep patterns and complex relationships within the data, thus exhibiting superior performance and powerful generalization capabilities in multiple fields such as natural language processing and computer vision. The construction and training of large models aim to improve their expressive power and prediction accuracy, enabling them to handle more complex problems and demonstrate stronger abstraction and reasoning abilities. However, despite significant progress made by large models in some tasks, particularly in natural language generation, text understanding, and machine translation, where their performance has approached or even surpassed that of human experts, they have not yet achieved truly remarkable results. Summary of the Invention The technical problem to be solved by this invention is to provide a large model-assisted automated program verification method and system to address the above-mentioned problems of existing program verification technologies. This invention aims to reduce the consumption of computing resources during the verification process, shorten the verification time, improve the accuracy of verification, and especially improve the efficiency of complex program verification.
[0007] To solve the above-mentioned technical problems, the technical solution adopted by the present invention is as follows: A large model-assisted automated program verification method includes the following steps: S1. Perform a data scale correlation analysis on the program to be verified to determine whether the data scale can be optimized. If the data scale can be optimized, proceed to step S2; otherwise, proceed to step S3. S2, optimize the data size of the program, verify the optimized program using a verification tool, and then exit; S3, Perform defect analysis on the program to be verified to determine if there are any defects. If there are defects, proceed to step S4; otherwise, use the verification tool to verify the source code of the program to be verified, then end and exit. S4. Perform defect analysis on the program to be verified, generate corresponding counterexamples, and encapsulate the counterexamples into test cases for subsequent verification. S5: Verify the generated test cases. If the verification result is unsuccessful, proceed to step S3; otherwise, end and exit.
[0008] Optionally, step S1, which involves performing a data size correlation analysis on the program to be verified to determine whether data size optimization is possible, includes: S1.1, the large model analyzes the correlation between semantic logic and data size by: a) parsing the control flow graph CFG of the program, identifying loop boundaries, program variable ranges, and variable dependency relationships; b) combining natural language processing techniques to analyze the size semantics features in program comments and variable naming, and constructing a mapping between program logic and data size; S1.2, according to the analysis result, it is judged whether there is a correlation between the semantic logic and the data size of the to-be-verified program, so as to determine whether the to-be-verified program can be optimized for data size, including: a) if the output of the to-be-verified program is sensitive to the input size, or there is unbound dynamic memory allocation, it is determined that there is a correlation between the semantic logic and the data size of the to-be-verified program, and the data size optimization cannot be performed; b) if the to-be-verified program is size-independent logic, it is determined that the data size optimization can be performed, and the size-independent logic includes fixed rule string processing.
[0009] Optionally, the data size optimization performed in step S2 includes: finding a data size variable in the to-be-verified program as a threshold of a loop body for representing a data size, modifying the value of the data size variable in the to-be-verified program to a specified optimization constant value to obtain an optimized program; and when the value of the data size variable in the to-be-verified program is modified to the specified optimization constant value, the selection strategy of the optimization constant value includes: a) based on the analysis of the program behavior, the data size variable adopts the minimization principle; b) verifying the candidate value generated by the large model to ensure the invariance of the behavior of the optimized program.
[0010] Optionally, when the data size variable in the to-be-verified program as a threshold of a loop body for representing a data size is found, filtering is further performed on all the found data size variables, and only the data size variables related to the verification target are retained.
[0011] Optionally, the defect analysis performed on the to-be-verified program in step S3 to determine whether there is a defect includes: S3.1, analyze the to-be-verified program in an assisted manner by the large model, and identify potential defects in the program; S3.2, determine whether there is a defect in the to-be-verified program according to the analysis result.
[0012] Optionally, the counterexample generation performed in step S4 includes: S4.1, based on the large model, the potential defects of the program are causally inferred, and when the inference finds that the defect exists, the input data capable of triggering the program defect is generated; S4.2, constructing a counterexample according to the generated input data.
[0013] Optionally, the counterexample verification performed by using the generated counterexample in step S5 includes: The counterexample is encapsulated into a test case, a verification tool is used to test the encapsulated test case, and the correctness of the counterexample is reflected by whether the test case passes the test; if the verification fails, step S3 is returned to correct the defect corresponding to the counterexample; otherwise, the process is ended and exited.
[0014] In addition, the present application also provides a large model assisted automated program verification system, comprising a microprocessor and a memory connected to each other, the microprocessor being programmed or configured to execute the large model assisted automated program verification method.
[0015] In addition, the present application also provides a computer readable storage medium, which stores a computer program or instructions, the computer program or instructions being programmed or configured to execute the large model assisted automated program verification method by a processor.
[0016] In addition, the present application also provides a computer program product, comprising a computer program or instructions, the computer program or instructions being programmed or configured to execute the large model assisted automated program verification method by a processor.
[0017] Compared with the prior art, the present application mainly has the following advantages: 1. The present application can automatically optimize the data scale without correlation between the program semantic logic and the data scale by in-depth analysis of the relationship between the two. This optimization not only greatly reduces the computing resources and memory consumption required by the program verification tool during verification, but also significantly improves the verification efficiency. Especially when dealing with complex programs, the present application effectively solves the state space explosion problem commonly encountered in traditional program verification methods, thereby greatly improving the feasibility and efficiency of the verification process. This optimization strategy enables program verification to maintain high performance in large-scale data sets or high-complexity programs, greatly improving the applicability and scalability of the verification tool.
[0018] 2. The present application uses defect analysis to analyze potential defects in the program and automatically generates corresponding counterexamples, i.e. constructs specific input data that can trigger program defects to verify the correctness of the program. If the verification fails, the system can automatically correct the defects and update the counterexamples in each iteration until the verification is successful or the maximum number of iterations is reached. This automatic error correction mechanism effectively improves the accuracy and reliability of the verification, avoiding the need for manual intervention and ensuring the precision of the verification process. The combination of counterexample generation and iterative correction not only improves the quality of program verification, but also ensures that the verification tool can gradually optimize and find potential problems when faced with complex programs.
[0019] 3. The present application realizes the whole process automation combined with scale optimization and defect analysis. Only the source code needs to be provided, and the system can automatically complete the data scale optimization, defect verification and other tasks, completely avoiding manual intervention. This automation process not only reduces the workload of the verification personnel, but also significantly improves the verification efficiency, and is particularly suitable for the verification of large-scale and complex software systems. In large systems, the complexity and scale of the program often lead to many difficulties in the verification process, and the present application can maximize the verification coverage with minimal human intervention, greatly improving the efficiency and scalability of verification.
[0020] 4. Compared with the traditional verification method, the present application effectively overcomes the technical difficulties of state space explosion and counterexample generation difficulty through intelligent assistance of large models while maintaining the reliability of strict formal verification. The scale optimization strategy and defect analysis mechanism of the present application provide a new solution for the reliability verification of complex software systems. BRIEF DESCRIPTION OF DRAWINGS
[0021] Figure 1 The figure is a basic flowchart of the embodiment method of the present application.
[0022] Figure 2 The figure is an example of the data scale optimization process in the embodiment of the present application. Figure 3 The figure is an example of defect analysis and counterexample generation for the program to be verified in the embodiment of the present application. DETAILED DESCRIPTION
[0023] In view of the problem of large verification overhead and long verification time caused by large data scale in the program verification process in the prior art, the present application provides an automatic program verification method and system assisted by a large model. The purpose of the present application is to analyze the relationship between the semantic logic of the program to be verified and the data scale, optimize the data scale under the premise of ensuring the invariance of the program semantic logic, thereby effectively reducing the complexity of the software code and improving the efficiency and accuracy of the program verification tool. When data scale optimization cannot be used to reduce the verification difficulty, the system will analyze the potential defects in the program and perform automatic verification. Through the above method, the calculation resource consumption in the verification process can be significantly reduced, the verification time can be shortened, and the accuracy of the verification can be improved, which is particularly suitable for complex program verification scenarios. In order to enable personnel in the technical field to better understand the technical solutions of the present application, the technical solutions of the present application will be further described in detail below in combination with the drawings in the embodiments of the present application.
[0024] As shown in Figure 1 The automatic program verification method assisted by a large model of the present embodiment includes the following steps: S1, data scale correlation analysis is performed on the program to be verified to determine whether data scale optimization is possible, if data scale optimization is possible, jump to step S2; otherwise, jump to step S3; S2, the data scale of the program is optimized, and the obtained optimized program is verified using a verification tool, and the process ends and exits; S3, defect analysis is performed on the program to be verified to determine whether there is a defect, if there is a defect, jump to step S4; otherwise, the source program of the program to be verified is verified using a verification tool, and the process ends and exits; S4, defect analysis is performed on the program to be verified, and the corresponding counterexample is generated and encapsulated into a test case for subsequent verification; S5, the generated test case is verified, if the verification result is not passed, jump to step S3; otherwise, the process ends and exits.
[0025] By introducing a large model assisted way to analyze the program, the relationship between the semantic logic of the program and the data scale is inferred. If the analysis result shows that there is no correlation between the semantic logic of the program and the data scale, the complexity of the verification task can be simplified by optimizing the data scale. In this case, the system will provide an optimization scheme, so that the program can complete the verification under a smaller data scale while ensuring the correctness of the function, thereby reducing the required computing resources and verification time. The optimized program will be further verified by a program verification tool, which will check the simplified program and draw a verification conclusion. However, if the system finds that there is a close correlation between the semantic logic of the program and the data scale, or cannot reduce the verification difficulty through data scale optimization, the verification tool may still face high computational complexity or cannot effectively verify. In this case, the system will analyze the potential defects in the program and convert the defects into specific counterexamples, which will be verified to check the correctness of the defects. If the verification result shows that there is no such defect in the program, the system will feedback the error and generate a new counterexample for the next round of verification. This process will be iterated to ensure the accuracy and integrity of the entire defect verification process. If the number of iterations reaches the upper limit and the defect is still not found, the original program will be verified using a verification tool.
[0026] In this embodiment, the relationship between the semantic logic of the to-be-verified program and the data scale will be analyzed by means of the large model. If it is found that there is no correlation between the semantic logic of the program and the data scale, the complexity of the verification task can be reduced by optimizing the data scale. At this time, the system will provide an optimization scheme, so that the program can complete the verification under a smaller scale while maintaining functional correctness, thereby reducing the computing resources and time required for program verification. The optimized program will be input into the program verification tool for subsequent verification, and the verification tool will verify according to the simplified program to obtain the final verification conclusion.
[0027] For many algorithms, the size of the program data scale has no direct correlation with the correctness of its semantic logic. For example, Figure 2As shown in the figure, the left side is the source code, and the right side is the large model's question and answer, where Q is the input large model question, and A is the large model's reply. The box is marked as the key content. The program shown in the figure implements the sorting of an array from small to large. The data size of the program is represented by the parameter N, where the values of the array are obtained by the rand() function to obtain random values. The verification content is that the array needs to be sorted from small to large. The original data size of the program in the figure is 100000, that is, the program will perform bubble sort on an array containing 100000 random numbers from small to large. Without data size optimization, the verification tool is used to verify the verification content of the program, and the verification result cannot be obtained within 900 seconds, and the memory usage is very high during the verification process, with a maximum memory size of 21.2GB. For sorting algorithms, the algorithm semantic logic is not related to the size of the data size, so the data size can be optimized to 10, that is, the program will perform bubble sort on an array containing 10 random numbers. At this time, when the tool is used for verification, it only takes 1.572 seconds to get the verification result, and the maximum memory size used during the verification process is 30.6MB. In fact, when verifying the semantic logic correctness of an algorithm, it is not necessary to process the complete data size. By reducing the data size, the semantic logic of the algorithm can be effectively verified within a smaller range. Based on this concept, through analysis and experimental discovery of the large model, although the accuracy of the large model in analyzing the correctness of the security properties or assertions is not very ideal, it can usually obtain high accuracy when analyzing the fixed relationship between data size and logical semantics. This shows that the large model can effectively identify the relevance between program data size and logical semantics, and provide valuable support for subsequent verification. Therefore, during verification, the large model assisted method can be used to first analyze and judge the relationship between code semantic logic and data size. If there is no correlation between the two, the calculation complexity in the verification process can be reduced by simplifying the data size. The simplified model not only maintains the semantic correctness, but also significantly reduces the verification overhead and improves the verification efficiency. This method not only optimizes the verification process and reduces the computational burden caused by the large data size, but also provides a new idea for large-scale program verification tasks. Specifically, the data size correlation analysis in step S1 of the embodiment is performed on the program to be verified to determine whether the data size can be optimized, including: S1.1, the large model analyzes the correlation between the semantic logic and the data size by the following way: a) Parse the control flow graph CFG of the program, identify the loop boundary, program variable range, and variable dependency relationship, etc. b) Combine natural language processing techniques to analyze the size semantics in program comments and variable naming, and construct a mapping between program logic and data size.
[0028] S1.2, according to the analysis result, judge whether there is a correlation between the semantic logic and the data size of the program to be verified, so as to determine whether the program to be verified can be optimized for data size. The correlation determination criteria include: a) If the program output is sensitive to the input size (such as sorting algorithm), or there is unbound dynamic memory allocation, it is determined that it cannot be optimized; b) If it is a size-independent logic (such as fixed rule string processing), it is determined that it can be optimized.
[0029] The data size optimization performed in step S2 of the embodiment includes: finding the threshold value in the program to be verified as the loop body for representing the data size variable, modifying the value of the data size variable in the program to be verified to the specified optimization constant value to obtain the optimized program.
[0030] Optimization constant value selection strategy: a) Based on the analysis of program behavior, the variable value minimization principle; b) Verify the candidate values generated by the large model to ensure the invariance of the behavior of the optimized program.
[0031] If the system finds that the semantic logic of the program is closely related to the data size, or cannot be reduced by data size optimization, the verification tool may still face the problem of high computational complexity or ineffective verification. In this case, the system will analyze the potential defects in the program and convert the defects into specific counterexamples, and verify the correctness of the defects by verifying the counterexamples. If the verification result shows that there is no defect in the program, return the defect error feedback and generate new counterexamples, enter the next round of defect verification process. This process will be iterated to ensure the accuracy and integrity of the verification result. If the number of iterations reaches the upper limit but still cannot find potential defects, directly use the verification tool to verify the original verification program. Specifically, the defect analysis in step S3 of the embodiment for the program to be verified includes: S3.1, analyze the program to be verified in a large model assisted manner to identify potential defects in the program; S3.2, determine whether the program to be verified has defects according to the analysis result.
[0032] When receiving the defect for verification, the system should have the function of feeding back whether the defect is correct. In the process, the system first converts the defect into a specific counterexample, encapsulates the counterexample into a test case, tests the test case obtained by encapsulation using a verification tool, reflects the correctness of the counterexample according to whether the test case passes the test, and finally obtains the correctness of the defect. In this process, if the verification result shows that the defect does not exist in the program, the feedback of defect error will be returned, and a new counterexample will be generated, re-encapsulated, and entered into the next round of verification process, and the process will be repeated until the verification task is completed or the upper limit of the set iteration number is reached, ensuring the accuracy and integrity of the verification result. Specifically, the counterexample generation in step S4 for the program to be verified includes: S4.1, based on the large model, the potential defects of the program are causally inferred, and a specific input data set capable of triggering the program defects is generated; S4.2, according to the generated input data, a counterexample is constructed.
[0033] In step S5, the generated counterexample is executed for counterexample verification, which includes: The counterexample is encapsulated into a test case, and the test case obtained by encapsulation is tested using a verification tool to reflect the correctness of the counterexample according to whether the test case passes the test. If the verification does not pass, the defect corresponding to the counterexample is modified in step S3; otherwise, it is ended and exited.
[0034] For the defect verification part, Figure 3For the defect analysis and counterexample generation of the program to be verified in this embodiment, the left side is the source code, and the right side is the question and answer of the large model, where Q is the input question of the large model, and A is the reply of the large model. The box is marked as the key content. The property to be verified is the assertion assert(a[i]>= (i + 3)). The large model discovers that the program may violate the property through reasoning and finds a specific test case variable assignment instance: n=2, j=1, k=1. First, the value of the variable n is set to 2, which satisfies the condition of assume(n<100000); the value of the variable j is set to 1, which satisfies the condition of assume(j>0&&j<10000); in the first loop, the generated variable k value is 1, which also satisfies the condition of assume(k>0&&k<10000). When i=1, a[1]=1+1+1=3 is calculated according to a[i]=i+j+k, during the execution of the first loop. Then, the program enters the second loop for verification, and the assertion assert(a[i]>= (i+ 3)) needs to be true. When i=1, a[1]>= (1 + 3) needs to be verified, that is, 3>= 4. This condition is not true, resulting in a failed assertion, thus discovering a program defect. According to the defect analysis, the constructed counterexample sets the input of the program to run as n=2, j=1, k=1. By verifying the counterexample, the result is that the assertion assert(a[i]>= (i + 3)) fails, proving that the analysis process has found a correct program defect.
[0035] In summary, the large model assisted automated program verification method of the embodiment first analyzes the correlation between the semantic logic and the data scale of the program by introducing a large model assisted manner. If there is no correlation between the two, the system will optimize the data scale of the program, and input the optimized program into the verification tool for verification, and use the simplified verification result as the final verification basis. If the analysis result shows that the code semantic logic and the data scale are closely related, and cannot be directly solved by data scale optimization, the system will analyze the potential defects in the program and verify the defects. The embodiment can fully utilize the abstraction and reasoning capabilities of the large model, reduce the complexity of program verification by combining data scale optimization and defect analysis mechanisms, and improve the efficiency and scalability of the verification tool when processing complex software systems, thereby meeting the demand for efficient verification of modern complex software systems. The whole process of program verification in the embodiment is automated, and only the source code needs to be provided. The tool can automatically perform data scale optimization, defect verification and other processes without human intervention.
[0036] In addition, the embodiment further provides a large model assisted automated program verification system, comprising a microprocessor and a memory connected to each other, the microprocessor being programmed or configured to execute the large model assisted automated program verification method.
[0037] In addition, the embodiment further provides a computer readable storage medium, wherein a computer program or instructions are stored, the computer program or instructions being programmed or configured to execute the large model assisted automated program verification method by a processor.
[0038] In addition, the embodiment further provides a computer program product, comprising a computer program or instructions, the computer program or instructions being programmed or configured to execute the large model assisted automated program verification method by a processor.
[0039] Those skilled in the art should understand that the technical solutions provided by the embodiments of the present application can be in the form of a method, a system or a computer program product. Therefore, the present application can be in the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Moreover, the present application can be in the form of a computer program product implemented on one or more computer readable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer usable program code. The present application is described with reference to flowcharts and / or block diagrams of the methods, devices (systems) and computer program products according to the embodiments of the present application. It should be understood that each flow and / or block in the flowcharts and / or block diagrams can be realized by computer program instructions. The combination of flows and / or blocks in the flowcharts and / or block diagrams can also be realized by computer program instructions. These computer program instructions can be provided to a processor of a general purpose computer, a special purpose computer, an embedded processor or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device produce a device implemented in the flowcharts and / or block diagrams. Figure 1 one or more flows and / or blocks Figure 1 means for performing the function specified by one or more flows and / or blocks. These computer program instructions can also be stored in a computer readable storage that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable storage produce a manufactured product including instruction means, which realizes the functions specified in the flowcharts and / or block diagrams. Figure 1 one or more flows and / or blocks Figure 1 means for performing the function specified by one or more flows and / or blocks. These computer program instructions can also be stored in a computer readable storage that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable storage produce a manufactured product including instruction means, which realizes the functions specified in the flowcharts and / or block diagrams. Figure 1a process or processes and / or blocks Figure 1 steps of the functions specified in the block or blocks.
[0040] The above merely describes the preferred embodiments of the present application, and the protection scope of the present application is not limited to the above-mentioned embodiments. Any technical scheme falling within the concept of the present application shall fall within the protection scope of the present application. It should be noted that, for ordinary skilled persons in the art, some improvements and refinements without departing from the principles of the present application shall also be considered as falling within the protection scope of the present application.
Claims
1. A large model assisted automated program verification method, characterized in that, The method comprises the following steps: S1, performing data scale correlation analysis on the to-be-verified program to determine whether data scale optimization is possible, if data scale optimization is possible, jumping to step S2; otherwise, jumping to step S3; S2, optimizing the data scale of the program, and verifying the obtained optimized program using a verification tool, ending and exiting; S3, performing defect analysis on the to-be-verified program to determine whether there is a defect, if there is a defect, jumping to step S4; otherwise, verifying the source program of the to-be-verified program using a verification tool, ending and exiting; S4, performing defect analysis on the to-be-verified program, generating corresponding counterexamples, and encapsulating the counterexamples into test cases for subsequent verification; S5, verifying the generated test cases, if the verification result is not passed, jumping to step S3; otherwise, ending and exiting.
2. The large model assisted automated program verification method of claim 1, wherein, The data scale correlation analysis performed on the to-be-verified program in step S1 to determine whether data scale optimization is possible comprises: S1.1, the large model analyzes the correlation between semantic logic and data scale by the following ways: a) parsing the control flow graph CFG of the program, identifying the loop boundary, the variable range and the variable dependency relationship of the program; b) combining the natural language processing technology to analyze the scale semantic features in the program annotation and variable naming, and constructing the correlation mapping between the program logic and the data scale; S1.2, according to the analysis result, it is judged whether there is a correlation between the semantic logic and the data scale of the to-be-verified program, so as to determine whether the to-be-verified program can be optimized in data scale, including: a) if the output of the to-be-verified program is sensitive to the input scale, or there is unbound dynamic memory allocation, it is determined that there is a correlation between the semantic logic and the data scale of the to-be-verified program, and the data scale optimization cannot be performed; b) if the to-be-verified program is scale-independent logic, it is determined that the data scale optimization can be performed, and the scale-independent logic includes fixed rule string processing.
3. The large model assisted automated program verification method of claim 1, wherein, The data scale optimization performed in step S2 comprises: finding the data scale variable in the to-be-verified program as the threshold of the loop body for representing the data scale, modifying the value of the data scale variable in the to-be-verified program to a specified optimization constant value to obtain an optimized program; and when the value of the data scale variable in the to-be-verified program is modified to the specified optimization constant value, the selection strategy of the optimization constant value comprises: a) based on the analysis of the program behavior, the data scale variable adopts the minimization principle; b) verifying the candidate value generated by the large model to ensure the behavior invariance of the optimized program.
4. The large model assisted automated program verification method of claim 3, wherein, When the data scale variable in the to-be-verified program as the threshold of the loop body for representing the data scale is found, the filtering is further performed on all the found data scale variables, and only the data scale variables related to the verification target are reserved.
5. The large model assisted automated program verification method of claim 1, wherein, The defect analysis performed on the to-be-verified program in step S3 to determine whether there is a defect comprises: S3.1, analyzing the to-be-verified program in an assisted manner by the large model, and identifying potential defects in the program; S3.2, determining whether there is a defect in the to-be-verified program according to the analysis result.
6. The large model assisted automated program verification method of claim 1, wherein, The counterexample generation in step S4 comprises: S4.1, performing causal reasoning on potential defects of the program based on the large model, and generating input data capable of triggering the defects of the program when the reasoning finds that the defects exist; S4.2, constructing counterexamples according to the generated input data.
7. The large model assisted automated program verification method of claim 1, wherein, The execution of the counterexample verification in step S5 includes: The counterexample is encapsulated into a test case, and the test case obtained by encapsulation is tested using a verification tool, and the correctness of the counterexample is reflected by whether the test case passes the test; if the verification fails, return to step S3 to modify the defects corresponding to the counterexample; otherwise, end and exit.
8. A large model assisted automated program verification system comprising microprocessors and memories interconnected, characterized in that, The microprocessor is programmed or configured to perform the large model assisted automated program verification method of any one of claims 1-7.
9. A computer-readable storage medium having stored therein a computer program or instructions, characterized in that, The computer program or instructions are programmed or configured to perform the large model assisted automated program verification method of any one of claims 1-7 by the processor.
10. A computer program product comprising computer programs or instructions, characterized in that, The computer program or instructions are programmed or configured to perform the large model assisted automated program verification method of any one of claims 1-7 by the processor.