Program analysis method and system based on bit vector-oriented optimization modulus theory

The OBV-BS method, which utilizes multi-threaded parallelization and information sharing mechanisms, solves the efficiency problem of OMT solvers under large-scale complex constraints, achieving more efficient program analysis and optimization.

CN118981386APending Publication Date: 2024-11-19INSTITUTE OF COMPUTING INNOVATION ZHEJIANG UNIVERSITY
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202411063318.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-05
Publication Date
2024-11-19

AI Technical Summary

Technical Problem

Existing OMT solvers suffer from excessive computation time and resource consumption when dealing with large-scale complex constraints, and lack support for parallelization and distributed computing, which limits their application in large-scale software analysis.

Method used

A multi-threaded parallelization approach, combined with an information sharing mechanism, is adopted to solve the bit vector-oriented optimization modulus theoretical model using the parallel OBV-BS method. This approach leverages the computing power of multi-core processors to reduce redundant searches and resource redundancy, thereby improving solution efficiency.

Benefits of technology

It significantly improves the solution efficiency of the OMT solver, enabling it to better handle optimization problems in large-scale program analysis, and improves resource utilization and solution speed.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118981386A_ABST
    Figure CN118981386A_ABST
Patent Text Reader

Abstract

The invention discloses a program analysis method and system based on a bit vector-oriented optimization modulus theory. Comprising the following steps: receiving optimization request information sent by a program analysis tool in a client; based on the received optimization request information, constructing a bit vector-oriented optimization model theoretical model; converting the bit vector oriented optimal model theoretical model into a conjunctive normal form; and after the conjunctive normal form is solved by using a parallel OBV-BS method, obtaining an optimization result and returning the optimization result to the program analysis tool. According to the method, a multi-thread parallelization method is used, an information sharing mechanism is combined, the solving efficiency of the optimization model theory is improved, and the optimization problem in program analysis is better helped to be solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to a program analysis method and system, and in particular to a program analysis method and system based on bit vector-oriented optimization module theory. Background Art

[0002] Program analysis technology is a very important field in computer science. It mainly studies how to automatically analyze and understand the behavior and properties of programs. Program analysis can check the quality of code, find problems such as syntax errors and logical errors in the code, and improve the readability of the code; it can identify performance bottlenecks such as dead code and redundant variables, optimize the code structure, and improve the running efficiency. In addition, program analysis will also face optimization analysis problems, such as compiler optimization, software security optimization, and test coverage optimization. In the process of program analysis and testing, the selection of test cases will affect the efficiency of program testing. How to select the smallest set of test cases while ensuring that all relevant program paths can be covered is a specific optimization problem. Some optimization problems can be modeled as integer linear programming (ILP) problems. Using ILP solvers to solve them can obtain global optimal solutions, but the solution efficiency is relatively low and can only be applied to small and medium-sized problems. More optimization problems can be modeled as optimization module theory (OMT) problems and solved using OMT solvers.

[0003] Optimization Modulo Theory (OMT) is an extended problem of Satisfiability Modulo Theory (SMT): given a logical constraint P and an objective function f(x), the goal is to calculate a satisfiable solution to P so that the value of the objective function f is maximized or minimized. The current mainstream OMT solvers include Z3, OptiMathSAT, and CVC5. Z3 is a powerful SMT solver developed by Microsoft Research and is widely used in program verification and reasoning. Although Z3 itself is an SMT solver, it also supports some basic optimization functions. By extending and combining with other tools, Z3 can be used to solve certain OMT problems. OptiMathSAT is an extended SMT solver that supports optimization problems. It adds processing of the objective function on the basis of traditional SMT solving, and can optimize the objective value while satisfying the constraints. OptiMathSAT supports a variety of logics, including linear integer arithmetic, linear real arithmetic, Boolean algebra, etc.

[0004] However, current OMT solvers also have shortcomings and limitations. The first is in terms of computing time and resource consumption. OMT problems usually involve solving complex constrained optimization problems, which may require the solver to perform a large number of calculations. As the size and complexity of the problem increase, the solution time may increase exponentially, resulting in a solution that cannot be obtained within a reasonable time. At the same time, solving complex OMT problems requires a lot of memory and computing resources, which may exceed the capacity of a single machine, especially when dealing with high-dimensional or large-scale constraints.

[0005] The second is the limitation of scale and complexity. The performance of OMT solver drops significantly when dealing with large-scale problems. For example, in industrial-level optimization problems, the number of variables and constraints may be very large, which places extremely high demands on the solver's capabilities. Complex constraints are difficult to handle, and the introduction of complex constraints will significantly increase the difficulty and time of solving.

[0006] In addition, current OMT solvers do not support parallelization and distributed computing. Although some OMT solvers support parallel computing, their parallelization is limited and it is difficult to fully utilize the computing power of multi-core processors. Most OMT solvers are designed mainly for single-machine environments and lack good support for distributed computing, and cannot run efficiently in cluster or cloud computing environments.

[0007] Although researchers have proposed multiple OMT solution methods and launched solvers such as OptiMathSAT, VZ, and CVC5, existing methods still have performance issues when dealing with complex constraints. Because solving OMT problems is more expensive than solving their SMT counterparts, usually at least an order of magnitude higher, this situation limits the application of OMT in large-scale software analysis. In addition, the Z3 solver supports parallel solution of SMT problems, but not OMT problems, while OptiMathSAT and CVC5 do not support parallel solution of both SMT and OMT.

[0008] There are several mainstream OMT solvers, such as Z3, OptiMathSAT, and CVC5, which can handle a variety of multi-objective optimization problems. However, as the scale of software becomes larger and larger, the amount of code becomes larger and larger, and the scale of constraints becomes larger and more complex during program analysis. When dealing with complex constraints, existing OMT solving methods and solvers still have performance issues. At the same time, the Z3 solver supports parallel solving of SMT problems, but does not support parallel solving of OMT problems, while OptiMathSAT and CVC5 do not support parallel solving of both SMT and OMT.

[0009] Table 1 shows the performance of the three solvers: Z3, OptiMathSAT, and CVC5

[0010]

[0011] In summary, the performance of several mainstream OMT solvers is shown in Table 1. It can be seen from the table that the research on parallel OMT solving is very limited. Therefore, there is currently a lack of a new parallel method for bit vector constraints to improve the efficiency of solving the optimization module theory and thus optimize the program analysis. Summary of the invention

[0012] In order to solve the needs and problems in the background technology, the present invention proposes a program analysis method based on bit vector-oriented optimization module theory. The present invention proposes a new method for solving bit vector constraint optimization by using a multi-threaded parallelization method and combining an information sharing mechanism, thereby improving the solving efficiency of the optimization module theory (OMT). It is a formal verification method that better helps solve the optimization problem in program analysis.

[0013] The technical solution of the present invention is as follows:

[0014] 1. A program analysis method based on bit-vector-oriented optimization modular theory

[0015] Receiving optimization request information sent by a program analysis tool in a client;

[0016] Building a bit vector-oriented optimization module theory model based on the received optimization request information;

[0017] Transform the modular theoretical model of bit-vector-oriented optimization into conjunctive normal form;

[0018] After solving the conjunction normal form using the parallel OBV-BS method, the optimization results are obtained and returned to the program analysis tool.

[0019] The step of constructing a bit vector-oriented optimization module theory model based on the received optimization request information includes:

[0020] Combined with the bit vector theory, the variables and constraints of the optimization modular theory are determined according to the received optimization request information, and then the bit vector-oriented optimization modular theory model in the SMT-LIB2 format is obtained after declaring variables, encoding constraints and constructing the objective function according to the SMT-LIB2 format.

[0021] The step of converting the bit vector-oriented optimization module theory model into a conjunctive normal form includes:

[0022] The bit-blasting method is used to transform the bit-vector oriented optimization modulo theory model into conjunctive normal form.

[0023] After solving the conjunction normal form using the parallel OBV-BS method, the optimization results are obtained, including:

[0024] The parallel OBV-BS method adopts a multi-threaded approach to simultaneously solve the conjunction normal form, and obtains the optimization result after maximizing the bit vector target in the conjunction normal form through information sharing between multiple threads.

[0025] The information sharing methods include sharing learning clauses, sharing solutions and sharing solution progress, and one or more information sharing methods are used to solve the problem.

[0026] The shared learning clause specifically includes:

[0027] If different threads enter the same search space, they share learning clauses so that threads that enter the search space later do not enter paths that are clearly unreachable in the search space.

[0028] The solution obtained by sharing specifically includes:

[0029] If the SAT solver returns satisfiable during the solving process, the corresponding solution of the satisfiable problem is obtained and shared among different threads. Different threads reduce the number of solving times according to the information provided by the solution.

[0030] The shared solution progress specifically includes:

[0031] When there are different solving progresses on multiple threads, the solution result of the thread with the fastest solving progress is shared with other threads, so that other threads can continue to solve based on the solution result.

[0032] 2. A Program Analysis System Based on Bit-Vector-Oriented Optimization Modulo Theory

[0033] A receiving module, used for receiving optimization request information sent by a program analysis tool in a client;

[0034] An optimization model building module, used for building an optimization module theory model for bit vectors based on the received optimization request information;

[0035] Conjunctive Normal Form Conversion Module, used to convert the bit vector-oriented optimization module theory model into conjunctive normal form;

[0036] The parallel solution module is used to solve the conjunction normal form using the parallel OBV-BS method, obtain the optimization results and return them to the program analysis tool.

[0037] The parallel solution module includes a multi-thread processing module. During the solution process of the multi-thread processing module calling the SAT solver, different threads interact with each other through an information sharing mechanism, so that the solution efficiency is significantly improved.

[0038] 3. A computer device

[0039] The computer device includes a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the steps of the program analysis method based on the bit vector-oriented optimization module theory are implemented.

[0040] 4. A computer-readable storage medium

[0041] The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the program analysis method based on the bit vector-oriented optimization module theory are implemented.

[0042] V. A computer program product

[0043] The computer program product comprises a computer program / instruction, which, when executed by a processor, implements the steps of the program analysis method based on bit vector-oriented optimization module theory.

[0044] Beneficial effects of the present invention:

[0045] The current mainstream OMT solvers do not support parallel OMT solving and will face certain performance issues when facing large-scale complex constraints. The present invention uses a multi-threaded parallel solution method to fully utilize the performance of multi-core processors and improve the solution efficiency. Considering that there may be more searches for repeated spaces and a large amount of redundant information in multi-threaded parallel solutions, three different information sharing mechanisms are proposed to reduce the search for repeated spaces and the call to the solver, and to improve the solution efficiency of the solver, so as to use resources more efficiently and better help solve the optimization problems in program analysis. BRIEF DESCRIPTION OF THE DRAWINGS

[0046] Figure 1 The present invention is a flow chart of the method. DETAILED DESCRIPTION

[0047] In order to enable those skilled in the art to better understand the present invention, and thus to more clearly define the scope of protection claimed in the present invention, the present invention is described in detail with respect to certain specific embodiments and drawings of the present invention. It should be noted that the following are only certain specific implementation methods of the present invention, which are only part of the embodiments of the present invention, wherein the specific and direct description of the relevant structures is only for the convenience of understanding the present invention, and each specific feature does not naturally and directly limit the scope of implementation of the present invention. The conventional selections and substitutions made by those skilled in the art under the guidance of the present invention, as well as the reasonable arrangement and combination of several technical features under the guidance of the present invention, should all be deemed to be within the scope of protection claimed in the present invention.

[0048] The present invention proposes a program analysis method based on bit vector-oriented optimization module theory, which is applied to a server connected to at least one client; Figure 1 As shown, including:

[0049] Program analysis often requires processing various optimization issues and receiving optimization request information sent by the program analysis tool in the client;

[0050] Based on the received optimization request information, an optimization module theory model for bit vector is constructed, including:

[0051] Combined with the bit vector theory, the variables and constraints of the optimization module theory are determined according to the received optimization request information, and then the variables, encoding constraints and objective functions are declared according to the SMT-LIB2 format to obtain the bit vector-oriented optimization module theory model in the SMT-LIB2 format, that is, according to the optimization problem that arises in program analysis, it is modeled as an OMT problem with constraints and optimization goals. For example, in test case coverage optimization, the constraint condition is to ensure that the selected test case collection can cover all test targets. The test target may be statement coverage, branch coverage, etc. The decision variable is whether to select a certain test case, and the optimization objective function is to minimize the number of selected test cases.

[0052] Convert the bit-vector-oriented optimization modular theory model into conjunctive normal form (CNF), including:

[0053] The bit-blasting method is used to transform the bit-vector-oriented optimization modulo theory model into the conjunction normal form for subsequent bit-level methods. Bit-blasting is an important technology in the field of logic verification. It refines high-level logic formulas, such as complex logic formulas of integer variables and bit vectors, into Boolean formulas, so that complex logic verification problems can be efficiently processed by existing SAT solvers. It is a method often used in solvers.

[0054] After solving the conjunction normal form using the parallel OBV-BS method, the optimization results are obtained and returned to the program analysis tool. The program analysis tool continues to process the target optimization problem based on the received optimization results. Taking the test case coverage optimization as an example, after the solution is completed, the minimum number of test cases selected can be obtained under the condition that the selected test case collection can cover all test targets. In this way, the use of redundant test cases for testing can be reduced, thereby improving the efficiency of program analysis testing and improving resource utilization.

[0055] Among them, after solving the conjunction normal form using the parallel OBV-BS method, the optimization results are obtained, including:

[0056] The parallel OBV-BS method uses a multi-threaded approach to simultaneously solve the conjunction normal form, that is, multiple threads process the same target, and the multiple threads maximize the bit vector target in the conjunction normal form (that is, bit by bit from high to low) through information sharing to obtain the optimization result.

[0057] Among them, the information sharing methods include sharing learning clauses, sharing solutions and sharing solution progress. One or more information sharing methods are used to solve the problem, thereby improving the efficiency of parallel solving.

[0058] For the shared learning clause, it is approached from the perspective of the solution process, including:

[0059] Learning clauses, also known as conflict clauses, refer to new clauses generated by analyzing the causes of conflicts when the solver encounters conflicts (i.e., situations where the current partial assignments are unsatisfiable) during the solution process. These clauses express certain unsatisfiable conditions, which can help the solver avoid entering a similar conflict state again. Learning clauses have a significant optimization effect on SAT solvers. By adding learning clauses, the search space can be effectively pruned to avoid repeated searches of paths that have been determined to be unsatisfiable. At the same time, the number of conflicts can be reduced, and the speed of finding a satisfactory solution or proving unsatisfiability can be accelerated. By continuously learning and adding new clauses, the solver can be made more flexible and efficient in processing complex formulas. If different threads enter the same search space, different threads share learning clauses, so that the threads that enter the search space later do not enter the paths that have been clearly unreachable in the search space. This can reduce the repeated redundant searches of the solvers of each thread during the solution process, reduce the number of conflicts and the handling of conflicts, thereby making better use of resources and improving the efficiency of the solution.

[0060] The solutions obtained through sharing include:

[0061] Solver solving is a step that consumes a lot of time and resources. When using the OBV-BS method and calling the SAT solver to solve, if the solver returns unsatisfiable, the current bit can be assigned 0. If it is satisfiable, a solution can be obtained, that is, if the SAT solver returns satisfiable during the solving process, the corresponding solution that can be satisfied is obtained and shared among different threads. Different threads reduce the number of solving times based on the information provided by the solution, thereby saving time and improving efficiency. For example, based on the corresponding solution that can be satisfied, the values ​​of the next few bits are preliminarily judged. If there are several consecutive bits that are 1, the judgment of these bits can be skipped directly and these bits are assigned 1. Otherwise, the solution is continued from the next bit that is not 1. This reduces the number of solving times, thereby saving time and improving efficiency.

[0062] For the shared solution progress, it is from the perspective of the target completion progress, including:

[0063] The SAT solver uses randomization and heuristic methods, and introduces randomness in the selection of branch variables, backtracking and other steps. Some heuristic methods such as variable selection strategies and learning clauses will be dynamically adjusted according to the intermediate results during the solution process, so the solution process and progress of different threads will be different. When there are different solution progress on multiple threads, the solution result of the thread with the fastest solution progress will be shared with other threads, so that other threads can continue to solve on the solution result. For example, the first thread determines the first five values ​​of the target, while the second thread only determines the first three values ​​of the target, but the two threads solve the same target, so the final result should also be the same. Therefore, the first thread can share the first five results with the second thread, so that the second thread can also get the first five values, thereby reducing the solution of the fourth and fifth values, and speeding up the solution process of the second thread. When a thread completes the solution of all the bits of the target and obtains the final result, it will share the completed state among the threads, so that each thread stops solving, thereby releasing resources.

[0064] The present invention uses multi-threaded parallel solution of single-objective bit vector constraints, and the threads improve the solution efficiency by sharing information. The parallel OBV-BS method proposed in the present invention is the first parallel solution method for single-objective optimization problems with bit vector constraints. According to the optimization problem in program analysis, it is modeled as an OMT problem, the constraints and optimization targets in the standard SMT-LIB2 format are obtained, the method is run and the optimal value of the target that meets the constraints is finally output, thereby solving the optimization problem.

[0065] The present invention utilizes the previous technologies and methods, and combines the parallelization method for the first time on the basis of the previous ones, proposes two different information sharing mechanisms to improve the parallel efficiency, and finally solves the single-objective bit vector optimization modular theory problem. In practical applications, it can help different program analysis tools improve the efficiency of constraint solving, and accelerate the processes such as abstract interpretation and symbolic execution.

[0066] On the one hand, the present invention also proposes a program analysis system based on bit vector-oriented optimization module theory, comprising:

[0067] A receiving module, used for receiving optimization request information sent by a program analysis tool in a client;

[0068] An optimization model building module, used for building an optimization module theory model for bit vectors based on the received optimization request information;

[0069] Conjunctive Normal Form Conversion Module, used to convert the bit vector-oriented optimization module theory model into Conjunctive Normal Form (CNF);

[0070] The parallel solving module is used to solve the conjunction normal form using the parallel OBV-BS method, obtain the optimization result and return it to the program analysis tool. The program analysis tool continues to process the target optimization problem based on the received optimization result.

[0071] The parallel solution module includes a multi-thread processing module. During the process of the multi-thread processing module calling the SAT solver, different threads interact with each other through an information sharing mechanism, which significantly improves the solution efficiency.

[0072] On the one hand, the present invention also proposes a computer device, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, it implements the steps of a program analysis method based on bit vector-oriented optimization module theory.

[0073] On the one hand, the present invention also proposes a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of a program analysis method based on bit vector-oriented optimization module theory.

[0074] On the one hand, the present invention also proposes a computer program product, including a computer program / instruction, which, when executed by a processor, implements the steps of a program analysis method based on bit vector-oriented optimization module theory.

[0075] The above embodiments are used to illustrate the present invention rather than to limit the present invention. Any modification and change made to the present invention within the spirit of the present invention and the protection scope of the claims shall fall within the protection scope of the present invention.

Claims

1. A program analysis method based on bit vector-oriented optimization module theory, characterized in that: include: Receiving optimization request information sent by a program analysis tool in a client; Building a bit vector-oriented optimization module theory model based on the received optimization request information; Transform the bit-vector-oriented optimal modular theory model into conjunctive normal form; After solving the conjunction normal form using the parallel OBV-BS method, the optimization results are obtained and returned to the program analysis tool.

2. A program analysis method based on bit vector-oriented optimization module theory according to claim 1, characterized in that: The step of constructing a bit vector-oriented optimization module theory model based on the received optimization request information includes: Combined with the bit vector theory, the variables and constraints of the optimization modular theory are determined according to the received optimization request information, and then the bit vector-oriented optimization modular theory model in the SMT-LIB2 format is obtained after declaring variables, encoding constraints and constructing the objective function according to the SMT-LIB2 format.

3. A program analysis method based on bit vector-oriented optimization module theory according to claim 1, characterized in that: The step of converting the bit vector-oriented optimization module theory model into a conjunctive normal form includes: The bit-blasting method is used to transform the bit-vector oriented optimization module theory model into conjunctive normal form.

4. A program analysis method based on bit vector-oriented optimization module theory according to claim 1, characterized in that: After solving the conjunction normal form using the parallel OBV-BS method, the optimization results are obtained, including: The parallel OBV-BS method adopts a multi-threaded approach to simultaneously solve the conjunction normal form, and obtains the optimization result after maximizing the bit vector target in the conjunction normal form through information sharing between multiple threads.

5. A method for program analysis based on bit vector-oriented optimization module theory according to claim 4, characterized in that: The information sharing methods include sharing learning clauses, sharing solutions obtained, and sharing solution progress, and the solution is obtained by using one or more information sharing methods.

6. A method for program analysis based on bit vector-oriented optimization module theory according to claim 5, characterized in that: The shared learning clause specifically includes: If different threads enter the same search space, they share learning clauses so that threads that enter the search space later do not enter paths that are clearly unreachable in the search space.

7. A method for program analysis based on bit vector-oriented optimization module theory according to claim 5, characterized in that: The solution obtained by sharing specifically includes: If the SAT solver returns satisfiable during the solving process, the corresponding solution of the satisfiable problem is obtained and shared among different threads. Different threads reduce the number of solving times according to the information provided by the solution.

8. A method for program analysis based on bit vector-oriented optimization module theory according to claim 5, characterized in that: The shared solution progress specifically includes: When there are different solving progresses on multiple threads, the solution result of the thread with the fastest solving progress is shared with other threads, so that other threads can continue to solve based on the solution result.

9. A program analysis system based on bit vector-oriented optimization modular theory, characterized in that: include: A receiving module, used for receiving optimization request information sent by a program analysis tool in a client; An optimization model building module, used for building an optimization module theory model for bit vectors based on the received optimization request information; Conjunctive Normal Form Conversion Module, used to convert the bit vector-oriented optimization module theory model into conjunctive normal form; The parallel solution module is used to solve the conjunction normal form using the parallel OBV-BS method, obtain the optimization results and return them to the program analysis tool.

10. A program analysis system based on bit vector-oriented optimization modular theory according to claim 9, characterized in that: The parallel solution module includes a multi-thread processing module. During the solution process of the multi-thread processing module calling the SAT solver, different threads interact with each other through an information sharing mechanism, so that the solution efficiency is significantly improved.

Citation Information

Patent Citations

  • Software formal verification method, system and equipment based on bit vector SMT

    CN117573537A