Abstraction gradient descent optimization method and system for unexplained predicate generation
By adopting the abstract gradient descent optimization method in the generation of unexplained predicates, and using backward abstract interpretation and abstract chain rules, the problem that gradient descent is difficult to achieve global optimization and inverse mapping is difficult to ensure symbolic expression equivalence, and the unexplained predicates generation method is achieved.
Patent Information
- Application Number
- CN202411972762.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-30
- Publication Date
- 2025-05-16
AI Technical Summary
In the unexplained predicate generation, the prior art has problems in the problem that gradient descent is difficult to achieve global optimality and inverse mapping is difficult to ensure symbolic expression equivalence.
The abstract gradient descent optimization method is adopted, and the abstract gradient is calculated and optimized through backward abstract interpretation and abstract chain rules, which avoids the neural relaxation process and is directly optimized on discrete functions.
A simpler, easier to implement and better optimization solution in unexplained predicate generation is implemented, and it can optimize in non-empty abstract gradient descent and make reliable conclusions when globally optimal.
Smart Images

Figure CN120012861A_ABST
Abstract
Description
Technical Field
[0001] The present invention mainly relates to the field of verification technology, and in particular to an abstract gradient descent optimization method and system for generating uninterpreted predicates. Background Art
[0002] Currently, the guess-and-check method is considered to be a promising idea for solving the problem of unexplained predicate generation. This type of method consists of a guesser and a verifier, in which the guesser repeatedly proposes possible predicate formula candidates to try to hit the correct predicate formula. These predicate formula candidates are verified by SMT verifiers such as Z3. If the candidate fails to make the constraint formula always true, the SMT solver will provide a counterexample (making its Boolean value false). Then, the guesser will propose the next predicate formula candidate. This method is a general search method for solving general unexplained predicate generation. Many industrial tools, such as Z3, CVC5, etc., are based on such a framework, supplemented by manually designed heuristics or templates to speed up the solution process.
[0003] In addition to the above search framework, some practitioners have proposed an implementation based on neural relaxation; the main idea is to relax the uninterpreted predicate generation problem into a continuous and deterministic objective function, and optimize it using the gradient descent method of the neural network. For example, the paper "Differentiable Synthesis of Program Architecture" details how to use the neural relaxation method for program synthesis generation; its method can be directly transferred to the uninterpreted predicate generation, because both are the process of generating corresponding expressions from a grammar. Specifically, the method is divided into four steps. The first step is to parameterize the uninterpreted predicate into a function with parameters; the second step is to relax the constraint formula of the uninterpreted predicate into a differentiable objective function, that is, a neural network, in which the uninterpreted predicate part is replaced by the parameterized function in the first step; the third step is to perform gradient descent on the objective function; the fourth step is to remap the optimized neural network back to a discrete grammatical predicate formula.
[0004] The first step, "parameterization of uninterpreted predicates", is based on formula grammar and introduces a "selection operator", which is generally an ITE (if-then-else) statement. For example, when the uninterpreted predicate P of the constraint (P(x, y)→(x≥y))∧(P(x, y)→(x≤y)) can have two choices of e<1|y≤4, it can be written as P: Ite(a, e<1, y≤4) using an ITE function, where a is a parameter with a value of 0 or 1. When a is 1, P: e<1, and when a is 0, P: y≤4. If the grammatical expansion of e has x|y, it can be further written as P: Ite(a1 , Ite(a 2 , x, y)<1, y≤4). For any uninterpreted predicate, its parameterization process starts from the grammar start symbol A, and each grammar expansion is constructed by the ITE function until the depth of the grammar tree reaches the upper limit. After the conversion is completed, a set of determined assignments of all parameters uniquely corresponds to a legal grammar expression, and all ITE functions can be removed.
[0005] The second step, “constraint formula neural relaxation”, consists of two sub-steps. First, the parameterized uninterpreted predicate is replaced into the constraint. For example, the constraint (P(x, y)→(x≥y))∧(P(x, y)→(x≤y)) will be replaced by (Ite(a 1 , Ite(a 2 ,x,y)<1,y≤4)→(x≥y))∧(Ite(a 1 , Ite(a 2 , x, y)<1, y≤4)→(x≤y)). Next, the method needs to convert the constraint into a continuously differentiable function. The specific method is to inductively transform the composite continuous function through the grammatical structure of the constraint. The relaxation conversion process starts from the leaf node of the grammatical tree of the constraint. For any real variable or constant, it can be directly used as a variable or constant in the converted function; for integer variables or constants, it is converted to an equal real variable or constant; for addition, subtraction, multiplication and division symbols, it is directly used as the corresponding addition, subtraction, multiplication and division continuously differentiable function; for less than <, less than or equal to ≤, equal to =, it is relaxed to a similar continuous differentiable function, such as a "Shifted Sigmoid" function, denoted as SF. SF(x, y) inputs two real values and outputs a real number between 0 and 1. When x≤y, the output is close to 1, and when x>y, the output is close to 0. For ITE functions, weighted sum is generally used to complete relaxation. For example, Ite(a, e<1, y≤4) is converted to a×SF(e, 1)+(1-a)×SF(y, 4). For ∧ and V, they can be relaxed to multiplication and addition. After completing the above relaxation conversion from the leaf node to the root node, the continuously differentiable objective function of the constraint formula can be obtained. When the objective function value is 1, the constraint formula is satisfied. When the objective function value is 0, the constraint formula is not satisfied. The converted objective function is recorded as Loss(a, x).
[0006] The third step, "objective function gradient descent", refers to the use of gradient descent to achieve two optimization goals:
[0007] min a 1-Loss(a,x)
[0008] min x Loss(a,x)
[0009] The first goal is to use gradient descent to optimize the Loss to 1, and the optimized variable is a; the second goal is to use gradient descent to optimize the Loss to 0, and the optimized variable is x. When optimizing a makes the Loss 1, and no matter how to optimize x, the Loss value cannot be made 0, the optimization is completed.
[0010] The key to the fourth step "reverse mapping symbolic expressions" lies in the reverse mapping of integer variables and the reverse mapping of the first parameter a of the Ite function. Both variables are reverse mappings from a real number to an integer, and are generally rounded off. After rounding, all Ite functions can be replaced by the second or third parameter. Finally, all functions are converted back to the original logical symbols, so that the uninterpreted predicate formula that conforms to the grammar can be obtained. For example, 0.6×SF(x, 1)+(1-0.6)×SF(y, 4) is converted to x<1.
[0011] There are two problems with the above neural relaxation method. First, it is difficult for gradient descent to reach the global optimum, and sometimes it is difficult to prove that the global optimum has been reached. Second, even if the global optimum is reached, it is difficult to guarantee that an equivalent symbolic expression can be obtained in the inverse mapping. Summary of the invention
[0012] The technical problem to be solved by the present invention is that, in response to the technical problems existing in the prior art, the present invention provides an abstract gradient descent optimization method and system for generating uninterpreted predicates which has a simple principle, is easy to implement and has a good optimization effect.
[0013] In order to solve the above technical problems, the present invention adopts the following technical solutions:
[0014] An abstract gradient descent optimization method for uninterpreted predicate generation, comprising:
[0015] Step S1: uninterpreted predicate parameterization;
[0016] Use ITE functions to perform finite expansion of the grammar;
[0017] Step S2: abstract gradient descent of constraint function;
[0018] Establish the association between abstract gradient descent and backward abstract interpretation, and implement gradient descent through backward abstract refinement algorithm.
[0019] As a further improvement of the method of the present invention: in step S2, for any uninterpreted predicate constraint, after parameterization, it is a discrete function that outputs 0 or 1; the optimization direction of the variable is calculated so that the value of the entire objective function decreases, and the first-order partial derivatives of each variable are calculated, and the result is obtained by propagating backward layer by layer through the composite structure of the function.
[0020] As a further improvement of the method of the present invention: for any function F(v), its abstract gradient function is recorded as
[0021]
[0022] Right now, is a set that contains all the change directions Δv about v that can make the value of F(v-Δv) less than the current value; when the calculation is After that, we only need to sample any change direction and use v:=v-Δv to optimize the function value. When the calculated set is empty, it can be proved that the global optimum has been reached.
[0023] As a further improvement of the method of the present invention: the backward abstract interpretation refers to constructing a mapping function from its image to the original image for a function F It is a backward abstraction function, which takes as input a set Y of value range and outputs a set of definition domain Satisfy the following formula:
[0024]
[0025] That is, input any image of the function F and output its corresponding original image; the abstract gradient set is composed of Equivalent calculation.
[0026] As a further improvement of the method of the present invention: the construction of the backward abstraction function has the property of the "abstract chain rule":
[0027]
[0028] That is, the backward abstraction function of a composite function is composed of the composite of the backward abstraction functions of each function; according to the "abstract chain rule", the backward abstraction function of any function is recursively constructed according to its composite structure; any function F is represented as a composite of several "layer functions"; a layer function refers to a function whose "projection function" in each dimension is a function of an atomic function; the projection function g of a function g in the i-th dimension is i is a function that satisfies the following formula:
[0029]
[0030] Based on this, any function F is always expressed as a composite of n layers of functions, where n is greater than or equal to 1, that is:
[0031]
[0032] The calculation is converted into each layer function Calculation of the layer function The computation of is converted into a backward abstract computation of atomic functions of its various dimensions.
[0033] As a further improvement of the method of the present invention: in the calculation process, instead of calculating the backward abstract function, the backward "down" abstract function is calculated. And the backward "up" abstract function They are:
[0034]
[0035] Back-down abstraction function The output is the backward abstraction function Subset of; backward abstraction function The output is the backward abstraction function A superset of When it is not empty, perform abstract gradient descent; when When is empty, it is proved to reach the global optimum; the "abstraction chain rule" also applies to backward and downward abstraction.
[0036] As a further improvement of the method of the present invention: the backward abstract interpretation method for the atomic function is: the backward abstract calculation of the atomic function y=f(x) is performed by an abstract rule; the abstract rule is in the form of the following formula:
[0037] As a further improvement of the method of the present invention: the backward abstract interpretation method of the layer function is: the abstraction of the layer function is constructed from the abstraction of its projected atomic function;
[0038] The layer function g (i) The projection atomic function in the jth dimension is The corresponding abstract rule is recorded as Then the layer function g (i) The rules are as follows:
[0039] As a further improvement of the method of the present invention: adopting an abstract refinement method of a composite function;
[0040] When the backward abstract set of a certain layer of functions of the composite function F is an empty set, try to generate a non-empty set by sampling the coefficients of another set of different rules;
[0041] When the backward abstract set of a layer function is empty, backtrack to the layer function of the previous layer and calculate a different abstract set;
[0042] When the downward abstract set after calculating a layer function is not an empty set, it is passed to the layer function of the next layer and starts calculation;
[0043] When backtracking to the outermost layer and calculating different backward abstract sets, which can only be empty sets, it is proved that the backward abstract set of F is empty. When used for abstract gradient calculation, it is proved that the global optimum is reached.
[0044] When passed to the innermost layer and the backward abstract set is not an empty set, it proves that the backward abstract set of F is not empty. When applied to abstract gradient descent, any element in any sampling set is used to generate the function optimization direction.
[0045] The present invention further provides an abstract gradient descent optimization system for uninterpreted predicate generation, comprising a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the steps of any one of the above methods.
[0046] Compared with the prior art, the advantages of the present invention are:
[0047] The abstract gradient descent optimization method and system for uninterpreted predicate generation of the present invention has a simple principle, is easy to implement, and has a good optimization effect. When the method of the present invention is executed, when the lower abstraction is not empty, it can be sampled for optimization, and when the upper abstraction is empty, the global optimal can be proved, and the other cases can be refined and iterated; in addition, since there is no relaxation process, the abstract gradient descent is directly optimized on the discrete function of the uninterpreted predicate constraint, so there is no need for inverse mapping, and the optimization is completed when the uninterpreted predicate is solved. In other words, the present invention does not need to perform neural relaxation, and can also perform a gradient descent-like algorithm on the constraints, and can make a reliable conclusion on the global optimal. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] Figure 1 It is a schematic flow diagram of the method of the present invention. DETAILED DESCRIPTION
[0049] The present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0050] like Figure 1 As shown, an abstract gradient descent optimization method for uninterpreted predicate generation of the present invention comprises:
[0051] Step S1: uninterpreted predicate parameterization;
[0052] Use ITE functions to perform finite expansion of the grammar. Specifically, the same method as the neural relaxation method can be used;
[0053] Step S2: abstract gradient descent of constraint function;
[0054] Establish the association between abstract gradient descent and backward abstract interpretation, and implement gradient descent through backward abstract refinement algorithm.
[0055] Compared with the traditional neural relaxation method, the method of the present invention no longer has the step of neural relaxation. That is to say, the above method of the present invention is a method that can perform gradient descent on constraints without neural relaxation and can make reliable conclusions about the global optimum. The method of the present invention aims to design a gradient descent method for discrete functions.
[0056] In step S2, in the backward abstract interpretation implementation technology of abstract gradient descent, for any uninterpreted predicate constraint, after parameterization, it is a discrete function that outputs 0 or 1; for example, (Ite(a 1 ,Ite(a 2 ,x,y)<1,y≤4)→(x≥y))∧(Ite(a 1 ,Ite(a 2 ,x,y)<1,y≤4)→(x≤y)) is a discrete function, input x, y, a 1 , a 2 The value of , outputs a Boolean value. The purpose of gradient descent is to calculate the optimization direction of the variable so that the value of the entire objective function decreases. Gradient descent requires the calculation of the first-order partial derivatives of each variable, and this calculation process can be obtained by the composite structure of the function and backward propagation layer by layer. In the uninterpreted predicate generation task, since the corresponding discrete function is not continuous, it is also not differentiable, and the gradient descent optimization technology cannot be used. In view of this, the present invention innovatively proposes an abstract gradient calculation technology for discrete functions.
[0057] In a specific application example, in step S2, the backward abstract interpretation implementation process of abstract gradient descent includes:
[0058] For any function F(v) (F(v) may be a discrete function), its abstract gradient function is recorded as
[0059]
[0060] Right now, is a set that contains all the change directions Δv about v that can make the value of F(v-Δv) smaller than the current value.
[0061] For example, for the "less than or equal to" discrete function f ≤ For example, When x = 2 When calculated After that, we only need to sample any change direction and use v:=v-Δv to optimize the function value. When the calculated set is empty, it can be proved that the global optimum has been reached.
[0062] However, for any discrete function, The calculation of is difficult to complete using the above simple expression. Therefore, the method of the present invention further adopts a backward abstract interpretation method to solve
[0063] As a preferred embodiment, the present invention adopts a backward abstract interpretation method, wherein the backward abstract interpretation refers to constructing a mapping function from its image to the original image for a function F. (called backward abstraction function), which takes as input a set Y of range and outputs a set of domains Satisfy the following formula:
[0064]
[0065] That is, input any image of the function F and output its corresponding original image.
[0066] The abstract gradient set can be composed of Equivalent calculation.
[0067] The construction of backward abstraction functions has the property of the "chain rule of abstraction":
[0068]
[0069] That is, the backward abstraction function of a composite function can be composed of the composite of the backward abstraction functions of each function. According to the "Abstract Chain Rule", the backward abstraction function of any function can be recursively constructed according to its composite structure. Based on this, any function F can be expressed as a composite of several "layer functions". A layer function refers to a function whose "projection function" in each dimension is an atomic function. The projection function g of a function g in the i-th dimension is i is a function that satisfies the following formula:
[0070]
[0071] Based on this, any function F is always expressed as a composite of n layers (n is greater than or equal to 1), that is:
[0072]
[0073] in this way, The calculation can be converted into each layer function Calculation.
[0074] Simultaneous layer functions The calculation of can be converted into the backward abstract calculation of the projection function (atomic function) of its various dimensions.
[0075] At the same time, in order to allow the calculation process to terminate, the backward abstract function is not calculated, but the backward "down" abstract function is calculated And the backward "up" abstract function They are:
[0076]
[0077] Back-down abstraction function The output is the backward abstraction function Subset of; backward abstraction function The output is the backward abstraction function A superset of .
[0078] when When it is not empty, abstract gradient descent can be performed; when When it is empty, it can be proved that it reaches the global optimum. The "Abstract Chain Rule" also applies to backward and downward abstraction.
[0079] In a specific application example, the present invention further provides a backward abstract interpretation method for atomic functions:
[0080] The backward abstract calculation of the atomic function y=f(x) can be performed by the abstract rule; the abstract rule is as follows:
[0081]
[0082] For example, the addition function f + (x 1 ,x 2 ) is as follows:
[0083]
[0084] where s l ,s u , l, u are called the coefficients of the rule. For any output set Y, if there exists l, u such that Then we can sample any s l and u The value of the input set is obtained by abstracting it downward The above abstract input set can be calculated by the following theorem:
[0085]
[0086] Where S c It means to take the complement of set S. The above formula means that the upper abstract input set is equivalent to Y cThe complement of the lower abstract input set.
[0087] Other functions such as f ∧ , f - , f × , f ÷ etc. all have corresponding atomic function rules; for example, there are relevant rules in interval arithmetic theory.
[0088] In a specific application example, the present invention further provides a backward abstract interpretation method of a layer function; the abstraction of a layer function can be constructed from the abstraction of its projected atomic function. (i) The projection atomic function in the jth dimension (k dimensions in total) is The corresponding abstract rule is recorded as Then the layer function g (i) There can be rules like:
[0089]
[0090] It can be seen that the rule is reliable, that is, the calculated downward abstract input set still conforms to the definition.
[0091] In a specific application example, the present invention further provides an abstract refinement method for a composite function; when the backward abstract set of a layer function of the composite function F is an empty set, the present invention attempts to generate a non-empty set by sampling the coefficients of another set of different rules. When the backward upward abstract set of a layer function is an empty set, it is possible to trace back to the layer function of the previous layer and calculate a different abstract set. When the backward downward abstract set of a layer function is not an empty set, it can be passed to the layer function of the next layer and start calculation.
[0092] When backtracking to the outermost layer and calculating different backward abstract sets can only be empty sets, it is proved that the backward abstract set of F is empty. When used for abstract gradient calculation, it is proved that the global optimum is reached.
[0093] When it is passed to the innermost layer and the backward abstract set is not an empty set, it proves that the backward abstract set of F is not empty. When applied to abstract gradient descent, any element in the sampled set can be used to generate the function optimization direction.
[0094] The above are only preferred embodiments of the present invention, and the protection scope of the present invention is not limited to the above embodiments. All technical solutions under the concept of the present invention belong to the protection scope of the present invention. It should be pointed out that for ordinary technicians in this technical field, some improvements and modifications without departing from the principle of the present invention should be regarded as the protection scope of the present invention.
Claims
1. An abstract gradient descent optimization method for uninterpreted predicate generation, characterized in that include: Step S1: uninterpreted predicate parameterization; Use ITE functions to perform finite expansion of the grammar; Step S2: abstract gradient descent of constraint function; Establish the association between abstract gradient descent and backward abstract interpretation, and implement gradient descent through backward abstract refinement algorithm.
2. The abstract gradient descent optimization method for uninterpreted predicate generation according to claim 1, characterized in that: In step S2, for any uninterpreted predicate constraint, after parameterization, it is a discrete function that outputs 0 or 1; the optimization direction of the variable is calculated so that the value of the entire objective function decreases, and the first-order partial derivatives of each variable are calculated, and then propagated backward layer by layer through the composite structure of the function.
3. The abstract gradient descent optimization method for uninterpreted predicate generation according to claim 2, characterized in that: For any function F(v), its abstract gradient function is recorded as Right now, is a set that contains all the change directions Δv about v that can make the value of F(v-Δv) less than the current value; when the calculation is After that, we only need to sample any change direction and use v:=v-Δv to optimize the function value. When the calculated set is empty, it can be proved that the global optimum has been reached.
4. The abstract gradient descent optimization method for uninterpreted predicate generation according to claim 2 or 3, characterized in that: The backward abstract interpretation refers to constructing a mapping function from its image to the original image for a function F. It is a backward abstraction function, which takes as input a set Y of value range and outputs a set of definition domain Satisfy the following formula: That is, input any image of the function F and output its corresponding original image; the abstract gradient set is composed of Equivalent calculation.
5. The abstract gradient descent optimization method for uninterpreted predicate generation according to claim 4, characterized in that: The construction of the backward abstraction function has the property of the "abstract chain rule": That is, the backward abstract function of the composite function is composed of the composite of the backward abstract functions of each function; according to the "abstract chain rule", the backward abstract function of any function is recursively constructed according to its composite structure; any function F is represented as a composite of several "layer functions"; a layer function refers to the function whose "projection function" in each dimension is a function of an atomic function; the projection function g of a function g in the i-th dimension is i is a function that satisfies the following formula: Based on this, any function F is always expressed as a composite of n layers of functions, where n is greater than or equal to 1, that is: F=g (n) °g (n-1) °…°g (1) The calculation is converted into each layer function Calculation of the layer function The computation of is converted into a backward abstract computation of atomic functions of its various dimensions.
6. The abstract gradient descent optimization method for uninterpreted predicate generation according to claim 5, characterized in that: In the calculation process, the backward abstract function is not calculated, but the backward "down" abstract function is calculated. And backward "up" abstract function They are: Back-down abstraction function The output is the backward abstraction function Subset of; backward abstraction function The output is the backward abstraction function A superset of When it is not empty, perform abstract gradient descent; when When is empty, it is proved to reach the global optimum; the "abstraction chain rule" also applies to backward and downward abstraction.
7. The abstract gradient descent optimization method for uninterpreted predicate generation according to claim 5, characterized in that: The backward abstract interpretation method for the atomic function is: The backward abstract calculation of the atomic function y=f(x) is performed by the abstract rule; the abstract rule is as follows:
8. The abstract gradient descent optimization method for uninterpreted predicate generation according to claim 5, characterized in that: The backward abstract interpretation method of the layer function is as follows: the abstraction of the layer function is constructed from the abstraction of its projected atomic function; The layer function g (i) The projection atomic function in the jth dimension is The corresponding abstract rule is recorded as Then the layer function g (i) The rules are as follows:
9. The abstract gradient descent optimization method for uninterpreted predicate generation according to any one of claims 1 to 3, characterized in that: Adopting the abstract refinement method of composite functions; When the backward abstract set of a certain layer of functions of the composite function F is an empty set, try to generate a non-empty set by sampling the coefficients of another set of different rules; When the backward abstract set of a layer function is empty, backtrack to the layer function of the previous layer and calculate a different abstract set; When the downward abstract set after calculating a layer function is not an empty set, it is passed to the layer function of the next layer and starts calculation; When backtracking to the outermost layer and calculating different backward abstract sets, which can only be empty sets, it is proved that the backward abstract set of F is empty. When used for abstract gradient calculation, it is proved that the global optimum is reached. When passed to the innermost layer and the backward abstract set is not an empty set, it proves that the backward abstract set of F is not empty. When applied to abstract gradient descent, any element in any sampling set is used to generate the function optimization direction.
10. An abstract gradient descent optimization system for uninterpreted predicate generation, comprising a memory, a processor, and a computer program stored in the memory, characterized in that: The processor executes the computer program to implement the steps of the method according to any one of claims 1 to 9.