A conjunctive normal form based semi-tensor product SAT solving method and device
By converting conjunctive normal form clauses into logical matrices and utilizing matrix semi-tensor products for computation, the inefficiency of the SAT solver in large-scale CNF formulas is solved, achieving faster computation speed and more compact satisfiable solutions, and reducing the cost of logic synthesis.
Patent Information
- Application Number
- CN202210397830.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-15
- Publication Date
- 2026-02-13
- Estimated Expiration
- 2042-04-15
AI Technical Summary
Existing SAT solvers are inefficient when dealing with large-scale CNF formulas, struggle to cope with the problem of increased variable correlation, and traditional algorithms cannot guarantee computational speed and the compactness of the solution.
We employ a semi-tensor product SAT solution method based on conjunctive normal form. This method converts conjunctive normal form clauses into logical matrix representations, calculates the logical matrix using the matrix semi-tensor product, and combines advanced cutting algorithms to optimize computation time and accuracy.
It significantly improves computational efficiency, reduces CPU computation time and the number of satisfyable solutions, enhances computation speed and solution compactness, and optimizes the cost of logic synthesis.
Smart Images

Figure CN114722748B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computer, in particular to a conjunctive normal form based semi-tensor product SAT solving method and device. BACKGROUND
[0002] Boolean satisfiability problem (SAT problem) is the first NP problem proved to be solvable by a polynomial algorithm, and the method for solving the problem plays an important role in EDA (electronic design automation), such as combination equivalence checking, formal verification, model checking, logic reasoning, integrated circuit design, etc.
[0003] In theory, the SAT problem is used to determine whether a Boolean logic formula has a set of satisfiable solutions, i.e. a set of Boolean variable assignments that can make the Boolean formula true. Therefore, the actual problem needs to be converted into a Boolean formula first, and then the solving method and tool of the SAT problem can be used to solve it. The standard form of the Boolean formula in the field of SAT problem is conjunctive normal form (CNF), and the tool for calculating the true assignment of the CNF formula is called SAT solver. Like most computing tools, the traditional SAT solver is implemented in software, and its solving algorithm is divided into complete algorithm and incomplete algorithm. The complete algorithm exhaustively searches the solution space of the SAT formula, and theoretically can conclude the satisfiability of a certain SAT formula, but the SAT problem belongs to NP problem, and its solution space increases exponentially with the number of variables of the formula, so the efficiency of this algorithm is low, and it is not suitable for solving large-scale SAT problems. In addition, the incomplete algorithm does not search the entire solution space, but uses a heuristic method to search part of the solution space, which is faster in solving, but cannot guarantee the satisfiability of the SAT problem.
[0004] The number of variables contained in the CNF formula of the current practical system has increased dramatically, and the relevance of variables in actual problems is becoming stronger, so the SAT solver has been difficult to cope with the above challenges. The solution of SAT is crucial for circuit transformation in logic synthesis. The optimal solution of SAT can greatly reduce the cost of logic synthesis, and we can easily find the optimal solution among all solutions. SUMMARY
[0005] In order to solve the problems in the prior art, the purpose of the present application is to provide a conjunctive normal form based semi-tensor product SAT solving method and device, which can not only reduce the calculation time and improve the calculation efficiency, but also improve the compactness of the satisfiable solution.
[0006] To achieve the above object, the application provides a semi-tensor product SAT solving method based on conjunctive normal form, comprising,
[0007] Analyzing conjunctive normal form clauses;
[0008] According to the analyzed conjunctive normal form clauses, converting each clause C x into a corresponding logical matrix representation M x , and combining the obtained M x into a group of matrix expressions through logical relationships.
[0009] Calculating logical matrix representation according to semi-tensor product SAT solving;
[0010] According to the satisfiable assignment of each C x , taking the intersection of each group of satisfiable assignments to obtain a group of satisfiable Boolean assignments satisfying all independent clauses C.
[0011] Further, the step of analyzing conjunctive normal form clauses further comprises,
[0012] Analyzing conjunctive normal form clauses, defining two integer variables: V and C, wherein V represents the number of variables in the formula, and C represents the number of independent clauses in the formula;
[0013] Defining C independent disjunctive clauses: C x , wherein the Boolean relationship between variables in C x is "or", and the value range of x is 0
[0014] Further, the step of converting each clause C x into a corresponding logical matrix representation M x , and combining the obtained M x into a group of matrix expressions through logical relationships further comprises,
[0015] Defining the matrix form of logical variable V, and its expression is:
[0016]
[0017] For the logical matrix representation M x of semi-tensor product, the following formulas (2) or (3) or (4) or (5) or (6) are satisfied:
[0018]
[0019]
[0020]
[0021]
[0022]
[0023] In formula (1), any Boolean variable V is True, and its matrix expression is Otherwise, it is
[0024] In formula (2), M n represents the unary logical operation "not";
[0025] In formulas (3)-(6), M c , M d , M i and M e respectively represent the binary logical operations "and", "or", "implies" and "equivalent".
[0026] Further, it also includes,
[0027] For the logical relationship between any variables, P and Q are Boolean logical variables, and for any Boolean variable, the expression of the "not" operation is:
[0028]
[0029] For the logical relationship between any two Boolean variables, σ is ∨, ∧, → or Any binary operator, the expression is:
[0030] PσQ=M σ PQ (8).
[0031] Further, the step of solving the calculation of the logical matrix representation according to the semi-tensor product SAT, further includes,
[0032] Each group of M x is a matrix semi-tensor product combination, which includes Boolean variables P i and its corresponding logical relationship M σ ;
[0033] A final logical matrix M L is obtained by matrix semi-tensor product calculation, and the expression L=1.
[0034] All variables V of each independent clause C x satisfiable Boolean assignment are obtained by matrix equation.
[0035] Further, it also includes,
[0036] The matrix semi-tensor product calculation, the expression is:
[0037] L(P1, P2, …, P s )=M L P1P2…P s =1 (9)
[0038] The dimension of the final logic matrix M L is (2*2 s ).
[0039] To achieve the above object, the application further provides a semi-tensor product SAT solving device based on conjunctive normal form, comprising a clause analysis module, a matrix conversion module, an assignment solving module and a satisfiable solution merging module, wherein,
[0040] The clause analysis module is used for segmenting the input conjunctive normal form and analyzing it into a form to be solved.
[0041] The matrix conversion module is used for converting the form to be solved analyzed by the clause analysis module into a corresponding matrix form to be solved.
[0042] The assignment solving module is used for assigning values to the matrix to be solved, and the assignment condition of each clause is independent of other clauses.
[0043] The satisfiable solution merging module is used for taking the intersection of each independent solution of the assignment solving module to obtain a satisfiable solution satisfying all clauses.
[0044] To achieve the above object, the application further provides a computer readable storage medium having a computer program stored thereon, wherein the computer program performs the steps of the semi-tensor product SAT solving method based on conjunctive normal form as described above when running.
[0045] The semi-tensor product SAT solving method and device based on conjunctive normal form have the following beneficial effects:
[0046] 1) The semi-tensor product SAT solver based on conjunctive normal form is an accurate SAT solver based on mathematical calculation, which combines the logic operation of the matrix semi-tensor product with faster calculation speed and an advanced cutting algorithm to apply matrix calculation to SAT solving under the premise of ensuring the correctness of the calculation of satisfiable solutions, defines a logic matrix as a primitive in the logic network for solving SAT problems, retains the topological information between circuits, and converts logical reasoning into mathematical calculation, thereby optimizing the calculation time and calculation accuracy.
[0047] 2) Compared with the traditional SAT solver with better performance, the conjunctive normal form based semi-tensor product SAT solver provided by the application has excellent performance, and the improvement in calculation time and the number of satisfiable solutions is obvious: the conjunctive normal form based semi-tensor product SAT solver provided by the application reduces the CPU calculation time and the number of satisfiable solutions by 26.4 times and 50.0%, respectively. Therefore, the conjunctive normal form based semi-tensor product SAT solver provided by the application greatly improves the calculation efficiency.
[0048] 3) A new research idea is provided, which can reduce the calculation time and improve the compactness of the satisfiable solution, has strong practical significance for the development of SAT solver design and the application of SAT solver in logic synthesis.
[0049] Other features and advantages of the present application will be set forth in the following description, and in part will become apparent from the description, or can be learned by practice of the present application. BRIEF DESCRIPTION OF DRAWINGS
[0050] The accompanying drawings are included to provide a further understanding of the present application, and constitute a part of the specification, and together with the embodiments of the present application, serve to explain the present application, and do not constitute a limitation on the present application. In the drawings:
[0051] Figure 1 It is a schematic diagram of the conjunctive normal form based semi-tensor product SAT solving device according to the application;
[0052] Figure 2 It is a flow chart of the conjunctive normal form based semi-tensor product SAT solving method according to the application;
[0053] Figure 3 It is a schematic diagram of the matrix semi-tensor product multiplication instance according to the first embodiment of the application;
[0054] Figure 4 It is a schematic diagram of the solving process of the traditional conjunctive normal form based SAT solver according to the first embodiment of the application;
[0055] Figure 5 It is a schematic diagram of the circuit representation of MCNC c17.aig according to the first embodiment of the application;
[0056] Figure 6 It is a schematic diagram of the corresponding conjunctive normal form of the circuit representation of MCNC c17.aig according to the first embodiment of the application;
[0057] Figure 7 It is a schematic diagram of the solving process of the conjunctive normal form based semi-tensor product SAT solving device according to the first embodiment of the application;
[0058] Figure 8An example result diagram of a conjunctive normal form based semi-tensor product SAT solver according to an embodiment of the present application. DETAILED DESCRIPTION
[0059] The preferred embodiments of the present application will be described herein below with reference to the accompanying drawings, in which it is understood that the preferred embodiments described herein are illustrative only and not limiting upon the present application.
[0060] Embodiment 1
[0061] Figure 1 An example result diagram of a conjunctive normal form based semi-tensor product SAT solver according to an embodiment of the present application. Figure 1 As shown in the drawing, the conjunctive normal form based semi-tensor product SAT solver according to the present application comprises a clause parsing module 10, a matrix conversion module 20, an assignment solving module 30 and a satisfiable solution merging module 40, wherein,
[0062] The clause parsing module 10 is configured to split the input conjunctive normal form, i.e. CNF formula, and parse it into a form to be solved.
[0063] The matrix conversion module 20 is configured to convert the form to be solved parsed by the clause parsing module 10 into a corresponding matrix form to be solved.
[0064] The assignment solving module 30 is configured to assign values to the matrix to be solved, and the assignment of each clause is independent of other clauses.
[0065] The satisfiable solution merging module 40 is configured to take the intersection of each independent solution of the assignment solving module 30 to obtain a satisfiable solution satisfying all clauses.
[0066] Embodiment 2
[0067] Figure 2 A flow chart of a conjunctive normal form based semi-tensor product SAT solving method according to the present application will be described in detail below. Figure 2
[0068] First, in step 101, parse the conjunctive normal form clauses.
[0069] Preferably, parse the CNF formula by a parser, and define two integer variables: V and C, wherein V represents the number of variables in the formula, and C represents the number of independent clauses in the formula. Define C independent disjunctive clauses: C x wherein the Boolean relationship between the variables in C x is "or", and the value range of x is 0 < x < C.
[0070] In step 102, according to the parsed conjunctive normal form clauses, assign values to each clause Cx denotes the conversion into the corresponding logical matrix representation M x and the resulting M x is combined into a set of matrix expressions by logical relations.
[0071] Preferably, the matrix form of the logical variable V is expressed as:
[0072]
[0073] Preferably, for the semi-tensor product of the logical matrix representation M x satisfies the following formula (2) or (3) or (4) or (5) or (6):
[0074]
[0075]
[0076]
[0077]
[0078]
[0079] In formula (1), when any Boolean variable V is True, its matrix expression is and vice versa In formula (2), M n denotes the unary logical operation "NOT"; in formulas (3)-(6), M c , M d , M i and M e denote the binary logical operations "AND", "OR", "IMPLIES" and "EQUIVALENT", respectively.
[0080] Preferably, for the logical relationship between any variables, let P, Q be Boolean logical variables, and for any Boolean variable, the "NOT" operation is:
[0081]
[0082] For the logical relationship between any two Boolean variables, σ is ∧, ∨, → or Any binary operator has:
[0083] PσQ = M σ PQ (8)
[0084] P i In step 103, the logical matrix representation is calculated by the semi-tensor product SAT solver.
[0085] Preferably, each set of Mx It is a combination of matrix semi-tensor products, which includes Boolean variable P. i and its corresponding logical relationship M σ A final logical matrix M is obtained by calculating the matrix semi-tensor product. L And let the expression L = 1; finally, solve the equation using a matrix to obtain each independent clause C. x All variables V are satisfiable Boolean assignments.
[0086] Preferably, the matrix semi-tensor product calculation, its
[0087] L(P1, P) 2, …, P s ) = M L P1P2…P s =1 (9)
[0088] Final logic matrix M L The dimension is (2×2) s ).
[0089] In step 104, based on the obtained C x The satisfiable assignments are obtained by taking the intersection of each set of satisfiable assignments, resulting in a set of satisfiable Boolean assignments that satisfy all independent clauses C.
[0090] Example 3
[0091] Figure 3 This is a schematic diagram illustrating an example of a matrix semi-tensor product according to Embodiment 1 of the present invention. Figure 3 As shown, by performing dimensional segmentation and matching on the two matrices, the multiplication of two matrices with different dimensions is achieved.
[0092] Figure 4 This is a schematic diagram of the solution process of a conventional SAT solver based on the conjunction normal form according to Embodiment 1 of the present invention. Figure 4 As shown, first, a variable a, b, or c is randomly selected and assigned a value, simultaneously forming a binary tree data structure. Since the constraint of SAT is that the expression can be satisfied (equal to 1), the next variable is assigned a value, and this process continues until all variables have been assigned values. If the result of SAT is obtained, the process returns. If the result of UNSAT is obtained, the process backtracks to the previous assignment level and performs another assignment.
[0093] Figure 5 This is a schematic diagram of the circuit representation of MCNC c17.aig according to Embodiment 1 of the present invention. Figure 5 As shown, the circuit has two main outputs and five main inputs. The SAT solver needs to determine the values of the five main inputs for the circuit to satisfy the condition that both main outputs are equal to 1. Therefore, this invention employs the following...Figure 6 The conjunctive normal form CNF shown as the input of the SAT solver is obtained by encoding, each row corresponds to a clause, and the clauses of other rows are independent of each other, which includes three parts, respectively, the number of variables 11, the number of clauses 18 and 18 corresponding independent clauses; 11 variables correspond to Figure 5 11 logic nodes of the circuit shown.
[0094] Figure 7 It is a solving flowchart of a semi-tensor product SAT solving device based on a conjunctive normal form according to an embodiment of the application, and the design adopts a calculation process shown in the flowchart, which includes (a): a clause analysis module, (b): a matrix conversion module, (c): an assignment solving module and (d): a satisfiable solution merging module. The clause analysis module is used to divide the input conjunctive normal form, that is, the CNF formula, and analyze it into a form to be solved; the matrix conversion module is used to convert the form to be solved analyzed by the clause analysis module into a corresponding form to be solved matrix; the assignment solving module is used to assign values to the matrix to be solved, and the assignment of each clause is independent of other clauses; the satisfiable solution merging module is used to take the intersection of each independent solution of the assignment solving module to obtain a satisfiable solution that satisfies all clauses. Figure 7
[0095] In the embodiment of the application, for the SAT solving problem of the c17.aig circuit, the implementation process of solving the satisfiable solution of the method includes the following steps:
[0096] Step (1), analyzing the conjunctive normal form clause
[0097] The CNF formula shown is parsed by the parser Figure 6 The CNF formula shown is parsed by the parser x , wherein C x The Boolean relationship between the variables in C x is "or", and the value range of x is 0<x<18.
[0098] Step (2), on the basis of the disjunctive clauses obtained in step (1), each clause C x is converted into a corresponding logical matrix representation M x , and the obtained M x is combined into a group of matrix expressions through logical relationship;
[0099] For the logical matrix representation M x of the semi-tensor product, the following formulas (2) or (3) or (4) or (5) or (6) are satisfied:
[0100]
[0101]
[0102]
[0103]
[0104]
[0105] In formula (2), M n represents the unary logical operation "NOT"; in formulas (3)-(6), M c , M d , M i and M e represent the binary logical operations "AND", "OR", "IMPLIES" and "EQUIVALENT", respectively.
[0106] For the logical relationship between any variables, let P and Q be Boolean logical variables, and for any Boolean variable, the "NOT" operation is taken, and there is:
[0107]
[0108] For the logical relationship of any two Boolean variables, we define σ as any binary operator (V, A, →, or ), and there is:
[0109] pσQ = M σ PQ (8)
[0110] As for the 4th row 2-30 of CNF, the matrix form M4 is:
[0111]
[0112] Step (3), calculate the logical matrix representation by the semi-tensor product SAT solver.
[0113] Each group M x is a matrix semi-tensor product combination, which includes the Boolean variable P i and its corresponding logical relationship M σ ; through matrix semi-tensor product calculation, a final logical matrix M L is obtained, and the expression L = 1; finally, through matrix equation solving, the satisfiable Boolean assignment of all variables V of each independent clause C x is obtained.
[0114] For the final logical matrix M4, its dimension is (2x4), and there is:
[0115]
[0116] Then there are satisfyable solution pairs: and That is, both 2 and 3 are true, 2 is true and 3 is false, and both 2 and 3 are false.
[0117] Step (4), in step (3) each C is obtained x Based on the satisfiable assignments, take the intersection of each set of satisfiable assignments to obtain a set of satisfiable Boolean assignments that satisfy all independent clauses C, such as... Figure 8 As shown.
[0118] The semi-tensor product SAT solver based on the conjunctive normal form proposed in this invention outperforms the traditional best-performing SAT solver. N. Minisat 2.2 and minisat++1.1[J]. A short description in SATRace, 2010, 2010.), which reduces the computation speed by an average of 26.4 times and the number of satisfyable solutions by 50%. The performance comparison between the proposed SAT solver based on the conjunctive normal form and the traditional best-performing SAT solver is shown in Table 1.
[0119] Table 1
[0120]
[0121] The semi-tensor product SAT solver proposed in this invention significantly improves computational efficiency. This invention provides a new research approach for the design of SAT solvers based on semi-tensor products, reducing computation time and improving the compactness of satisfyable solutions. It has strong practical significance for the development of SAT solver design and its application in logic synthesis.
[0122] The application discloses a semi-tensor product SAT solving device based on conjunctive normal form, and is a precise SAT solver based on mathematical calculation. Under the premise of ensuring the correctness of the calculated satisfiable solution, the semi-tensor product SAT solving device based on conjunctive normal form combines the logical operation of the matrix semi-tensor product with faster calculation speed and an advanced cutting algorithm, applies matrix calculation to SAT solving, defines a logical matrix as a base element in a logical network for solving SAT problems, retains the topological information between circuits, and converts logical reasoning into mathematical calculation, thereby optimizing the calculation time and calculation accuracy. Compared with a traditional SAT solver with better performance, the semi-tensor product SAT solving device based on conjunctive normal form has excellent performance and obvious improvement in the calculation time and the number of satisfiable solutions. The semi-tensor product SAT solving device based on conjunctive normal form reduces the CPU calculation time and the number of satisfiable solutions by 26.4 times and 50.0%, respectively. Therefore, the semi-tensor product SAT solving device based on conjunctive normal form greatly improves the calculation efficiency. The application provides a new research idea for the design of the SAT solver based on semi-tensor product, can reduce the calculation time and improve the compactness of the satisfiable solution, and has strong practical significance for the development of the SAT solver design and the application of the SAT solver in logic synthesis.
[0123] In one embodiment of the application, a computer readable storage medium is also provided, and the computer readable storage medium has a computer program stored thereon, wherein the computer program performs the steps of the semi-tensor product SAT solving method based on conjunctive normal form when the computer program is executed.
[0124] Those skilled in the art can understand that the above description is only preferred embodiments of the application and is not used to limit the application, and although the application is described in detail with reference to the foregoing embodiments, those skilled in the art can still modify the technical solutions recorded in the foregoing embodiments or make equivalent replacements to some technical features. Any modification, equivalent replacement, improvement, etc. within the spirit and principle of the application shall be included in the protection scope of the application.
Claims
1. A method for solving the semi-tensor product SAT based on the conjunctive normal form, applied in EDA technology for combinatorial equivalence checking, formal verification, model checking, logical reasoning, and integrated circuit design, characterized in that... Includes the following steps, Parse the conjunctive normal form clauses and parse the conjunctive normal form formula into C independent disjunctive clauses C x , where the value range of x is 0 < x < C, and each clause C x The Boolean variables within are in a logical "or" relationship; among them, the Boolean variables correspond to the logical nodes in the circuit, and the disjunctive clause represents the logical constraint relationship that the logical nodes need to satisfy; Based on the conjunctive normal form clauses obtained from the analysis, each clause C... x This represents the transformation into the corresponding logical matrix representation M. x and the resulting M x A set of matrix expressions are combined through logical relationships; The logical matrix representation is calculated by solving the semi-tensor product SAT. Based on the obtained C x The satisfiable assignments are obtained by taking the intersection of each set of satisfiable assignments to obtain a set of satisfiable Boolean assignments that satisfy all independent clauses C. The conjunctive normal form clauses obtained from the analysis are then used to classify each clause C. x This represents the transformation into the corresponding logical matrix representation M. x and the resulting M x The step of combining logical relationships into a set of matrix expressions also includes, Define the Boolean variable V in matrix form, its expression is: For the logical matrix representation M of the semitensor product x It satisfies the following formula (2) or (3) or (4) or (5) or (6): In equation (1), when any Boolean variable V is True, its matrix expression is as follows: Conversely, it is In equation (2), M n This represents the unary logical operation "NOT"; In equations (3) to (6), M c M d M i and M e These represent the binary logical operations "AND", "OR", "implication", and "equivalence", respectively.
2. The method for solving the semi-tensor product SAT based on conjunctive normal form according to claim 1, characterized in that, It also includes, For any logical relationship between variables, let P and Q be Boolean logic variables. The expression for taking the "NOT" operation on any Boolean variable is: For any logical relationship between two Boolean variables, σ is any ∧, ∨, → or ∧. Binary operators are expressed as follows: Pσ Q =M σ P Q (8).
3. The method for solving the semi-tensor product SAT based on conjunctive normal form according to claim 1, characterized in that, The step of calculating the logical matrix representation based on the semi-tensor product SAT further includes, M per group x It is a combination of matrix semi-tensor products, which includes Boolean variable P. i and its corresponding logical relationship M σ ; The final logical matrix M is obtained by calculating the matrix semi-tensor product. L And let the expression L = 1; Each independent clause C is obtained by solving the equation using a matrix. x All variables V are satisfiable Boolean assignments.
4. The method for solving the semi-tensor product SAT based on the conjunctive normal form according to claim 3, characterized in that, It also includes, The expression for calculating the matrix semi-tensor product is as follows: L(P1,P2,...,P s )=M L P1P2...P s =1 (9) Final logic matrix M L The dimension is (2×2) s ).
5. A semi-tensor product SAT solving device based on conjunctive normal form, employing the semi-tensor product SAT solving method based on conjunctive normal form as described in any one of claims 1 to 4, characterized in that, It includes a clause parsing module, a matrix transformation module, an assignment and solution module, and a solution merging module. The clause parsing module is used to segment the input conjunctive normal form and parse it into a form to be solved; The matrix transformation module is used to transform the form to be solved by the clause parsing module into the corresponding form of the matrix to be solved; The assignment and solving module is used to assign values to the matrix to be solved, and the assignment of each clause is independent of other clauses; The satisfiable solution merging module is used to take the intersection of each independent solution of the assignment solving module to obtain a satisfiable solution that satisfies all clauses.
6. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is run, it executes the steps of the SAT solution method based on conjunctive normal form as described in any one of claims 1 to 4.
Citation Information
Patent Citations
A SAT Solver
CN109146077A
Boolean satisfiability judgment method based on linear programming
CN114091392A