Method for converting Boolean satisfiability problem into 3-coloring problem

By converting the SAT problem into a 3-shading problem, using graph structure and shading constraints, the problem of low computational efficiency in existing SAT solvers in large-scale application examples is solved, and a more efficient SAT solution is achieved.

CN119888033APending Publication Date: 2025-04-25BEIJING TECH & BUSINESS UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411678410.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-22
Publication Date
2025-04-25

AI Technical Summary

Technical Problem

Existing SAT solvers are inefficient in computing when facing large-scale application instances, and even cannot solve them. They need an efficient method to solve SAT problems.

Method used

By converting the SAT problem into a 3-coloring problem, the 3-coloring scheme of Figure G can directly correspond to the SAT solution by designing specific graph structures and shading constraints.

Benefits of technology

The existing 3-graph shading method is used to solve large-scale SAT instance problems, which significantly improves the solution efficiency and shows higher efficiency in solving complex problems.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119888033A_ABST
    Figure CN119888033A_ABST
Patent Text Reader

Abstract

The invention relates to the field of computer science, in particular to a method for converting a Boolean satisfiability problem (SAT) into a 3-coloring problem. According to the method, variables and clauses in an SAT formula are mapped into vertexes of a graph through a specific graph structure and coloring constraints, and logic constraints are represented through edges, so that solution of a Boolean formula is converted into a graph coloring problem. The method comprises the following steps: S1, reading an SAT problem, and initializing an adjacent matrix of a topological graph; s2, setting fixed coloring points, and performing necessary connection on the fixed coloring points and vertexes of the correlation graph; s3, sequentially selecting two SAT variables each time, newly adding intermediate graph vertexes in the graph, and connecting the intermediate graph vertexes in the graph according to a logical relationship in the SAT and a rule set by the invention; s4, circularly performing the step S3 until the logic relationship of all the variables has a complete description in the graph; and S5, finally forming a 3-graph coloring graph. According to the conversion method provided by the invention, the structure of the SAT problem is simplified, so that the SAT problem can be applied to an existing graph theory algorithm, the possibility of solving parallelization capability of a large-scale problem is provided, and the visual analysis of the solution is more intuitive. The method has the advantages of improving the visualization degree of the solution and being simple and rapid in conversion.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to computational theory, and in particular to a method for transforming a SAT problem into a 3-coloring problem. Background Art

[0002] The Boolean satisfiability problem (SAT problem) and the graph coloring problem are classic NP-complete problems. The SAT problem is widely used in scenarios such as asynchronous circuit synthesis, software verification, and planning (air traffic control, telegraph routing), but existing SAT solvers have low computational efficiency when facing large-scale application instances, and in severe cases, they cannot even solve the problem. Converting the SAT problem into a graph coloring problem and then into solving the computational graph provides another way to solve the SAT problem. Based on this technical route, existing tensor processors (such as GPU, NPU, FPGA) and other computing platforms can be efficiently used to solve the SAT problem, greatly improving the efficiency of solving the problem.

[0003] The method of patent CN118350472A mainly improves the efficiency of solving the 3-SAT problem by reducing the noise introduced in the normalization process, which involves converting graph coloring data into a 3-SAT problem. In contrast, the method of the present invention is a general method for converting a SAT problem into a 3-coloring problem, which does not involve the implementation details of the specific solution, and realizes a concise and general conversion method. Summary of the invention

[0004] The present invention proposes a method for converting a SAT problem into a 3-coloring problem. Given a SAT problem, firstly, an undirected graph G is initialized, in which each variable is mapped to a vertex in the graph, and then vertices and edges are added to the graph G through the logical relationship between the variables. By designing a specific graph structure and coloring constraints, the 3-coloring scheme of the graph G can directly correspond to the solution of SAT. A solution of the 3-coloring graph corresponds to a solution of the SAT problem. If the 3-coloring graph has no solution, then the corresponding SAT problem has no solution.

[0005] By mapping the SAT problem to the 3-coloring problem, the present invention can solve large-scale SAT instance problems using the existing 3-coloring method, showing higher efficiency in solving complex problems. To achieve the above purpose, the technical solution adopted by the present invention includes:

[0006] S1, for any SAT problem to the transformation of the graph vertex 3-coloring problem, a Boolean quantity uniquely corresponds to a vertex in the graph. Now define a color set C = {0, 1, a}, for the points in the graph G, each point can only take a color in the color set C, and the element 1 and element 0 in the color set C correspond to true and false respectively, to satisfy the Boolean value of the variable in the SAT problem.

[0007] S2, in order to distinguish between variables and constants, the vertices of the graph in the present invention are divided into two types: fixed colored vertices and indefinite colored vertices. Fixed colored vertices refer to vertices that have been colored in advance, corresponding to Boolean constants. Indefinite colored vertices correspond to Boolean variables, and are constrained by fixed colored vertices according to the principle of different colors for adjacent vertices. In the legend of this article, for distinction, a circle with letters or numbers inside represents a fixed colored vertex, and a circle without letters inside represents an indefinite colored vertex. For example, Figure 2 Under the color set C, there are 3 fixed colored vertices A, B, C and 1 indefinite colored vertex D. According to the coloring principle, the coloring of vertex D is different from the coloring of its neighbor C, so the coloring set of vertex D is {0,1}, which corresponds to a Boolean variable. The vertices corresponding to Boolean variables will be frequently used in the Boolean variable operations below. Figure 3 A simplified representation of the vertices in the coloring set is a square, with the vertices being {0,1}.

[0008] S3, consider the support of the coloring system for basic Boolean operations. First consider the NOT gate Y=-A, and Table 1 is its truth table. The graph vertex coloring mapping of the NOT gate is relatively intuitive. Figure 4 As shown in the figure, the negation operation can be realized by making the vertices corresponding to the two Boolean variables adjacent. When vertex A is colored 0, vertex Y is colored 1 based on the coloring principle, and vice versa.

[0009] Table 1. NOT gate truth table

[0010] Input A NOT gate output Y 0 1 1 0

[0011] S4, consider the graph vertex coloring operation of AND gate Y=A^B and OR gate Y=AvB, the truth table is shown in Table 2. Comparing the truth tables of AND gate and OR gate, they have some of the same functions I: when input A and B are the same, the output Y is the same as input A and B. In addition, the AND gate has the function : When input A and B are different, the output Y takes the value 0. The OR gate has the function : When input A and B are different, the output Y takes the value of 1. For simplicity, the following uses two simplified representations of vertex coloring, with the coloring set of the vertex represented by a triangle as {1, a}, such as Figure 5 , the coloring set of the vertices represented by regular pentagons is {0,a}, such as Figure 6 .

[0012] Table 2. Truth table of AND gate and OR gate

[0013] Input A Input B AND gate output Y OR gate output Y 0 0 0 0 0 1 0 1 1 0 0 1 1 1 1 1

[0014] S5, for function I, it can be mapped to graph structure I, such as Figure 7. Assume that vertices A and B are colored with the same color 0, then the color sets of vertices C and D are both {1,a}. Without loss of generality, let vertex C be colored with color 1 and vertex D be colored with color a. Thus, the vertex is colored with color 0. Similarly, when vertices A and B are both colored with color 1, vertex Y is also colored with color 1. In addition, under the color set {0,1}, when vertices A and B are colored with different colors, vertex Y can be colored with any of the colors.

[0015] S6, for function II, it can be mapped to graph structure II, such as Figure 8 . Assume that in the color set {0,1}, vertices A and B are colored with different colors, then vertex C is colored with color a. Therefore, vertex D is colored with color 1, and vertex Y is colored with color 0. In addition, it is easy to know that when vertices A and B are colored with the same color, vertex Y can be colored with any color in the color set {0,1}.

[0016] S7, for function III, can be mapped to graph structure III, such as Fig. 9 . Assume that in the color set {0,1}, vertices A and B are colored with different colors, then vertex C is colored with color a. Therefore, vertex D is colored with color 0, and vertex Y is colored with color 1. In addition, when vertices A and B are colored with the same color, vertex Y can be colored with any color in the color set {0,1}.

[0017] S8, based on the three graph structures I, II, and III, as described above Fig.10 , is the AND gate is a composite of structure I| and structure II; Fig.11 , is the composite of structure I| and structure III. In a similar way, we can also construct the graph vertex coloring structure of XOR gate Y=(A^-B)v(-A^B), such as Fig.12 . So far, we have completed the graph vertex coloring calculation structure of three basic logic gates and XOR gate. Based on the three basic logic gates of AND, OR, and NOT, the SAT problem can be transformed into a graph vertex 3-coloring problem. However, please note that the present invention only uses the graph structure based on the three basic logic gates of AND, OR, and NOT to transform the SAT problem into a 3-coloring graph problem, and the XOR gate graph structure is not used.

[0018] Compared with the prior art, the present invention has the following advantages and technical effects:

[0019] The present invention constructs a topological graph for the SAT problem with as few graph vertices as possible, considering that both the SAT problem and the 3-graph coloring problem are NP-complete. In the graph coloring solution, the coloring of the corresponding vertices is equivalent to the value of the variable in SAT, and if the graph coloring has no solution, it means that the SAT problem has no solution. The present invention makes full use of the existing graph coloring algorithms, graph theory tools and parallel processing capabilities, while improving the solution efficiency and visualization effect in certain specific cases. This method is not only highly versatile, but also can show good simplicity, scalability and applicability in different computing environments. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] The present invention is further described below in conjunction with the accompanying drawings and embodiments.

[0021] Figure 1 It is an operation step diagram of the present invention;

[0022] Figure 2 is a graph of Boolean constants and Boolean variables;

[0023] Figure 3 The simplified form graph of vertices corresponding to the color set {0, 1};

[0024] Figure 4 It is the topological structure diagram of NOT gate;

[0025] Figure 5 The simplified form graph of vertices corresponding to the color set {1, a};

[0026] Figure 6 The simplified form graph of vertices corresponding to the color set {0, a};

[0027] Figure 7 is the graph structure I;

[0028] Figure 8 is the graph structure II;

[0029] Fig. 9 is the graph structure III;

[0030] Fig.10 It is the topological structure diagram of AND gate;

[0031] Fig.11 It is the topological structure diagram of the OR gate;

[0032] Fig.12 This is the topological structure diagram of the XOR gate. DETAILED DESCRIPTION

[0033] In order to make the technical solution of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the accompanying drawings of the present invention. Note that the original intention of the present invention is to solve large-scale SAT problems using 3-graph coloring, so the form of the SAT problem given in the embodiment is CNF (conjunctive normal form), and each row of clauses in CNF contains 3 variables. Of course, other forms of CNF, such as CNF with only 2 variables in each row of clauses, can use the method given in this embodiment. Obviously, the embodiment described in this article is one embodiment of the present invention, not all embodiments.

[0034] Figure 1 A method for converting a SAT problem into a 3-coloring problem is shown. In this embodiment, an adjacency matrix is ​​used to represent an undirected graph G, and the method includes the following steps:

[0035] S1, read the CNF of the SAT problem and determine the variables contained in the SAT problem (1≤ ≤ ) , and the number of clauses . Initialize the undirected graph for the number of variables The adjacency matrix of :definition The initial order is 2* ,in No. (0≤ ≤ ) lines represent variables The connection relationship, such as the 0th row of the matrix represents the variable connection relationship; No. ( ≤ ≤2 -1) Rows represent variables The connection relationship of Rows represent variables The connection relationship of . Set the initial adjacency matrix as described above, just check Top 2* The coloring of the vertices represented by the indices is the solution to the SAT problem.

[0036] S2, take the color set of the vertices of graph G as C = {0, 1, a}. Figure 3 As shown in , the square nodes represent the vertices corresponding to the color set {0, 1}, and such nodes must be connected to the vertices colored a. Figure 5 , Figure 6 As shown, the triangle vertices and the pentagon vertices represent the vertices corresponding to the color set {1, a} and the vertices corresponding to the color set {0, a}, respectively. The vertices corresponding to the color set {1, a} must be connected to the vertices with color 0, and the vertices corresponding to the color set {0, a} must be connected to the vertices with color 1. Therefore, the present invention sets three fixed coloring points with colors 0, 1, and a, respectively. Add 3 levels: Stage, Step, The order represents three fixed coloring points of color 0, color 1, and color a. All vertices (squares) representing SAT variables in S1 are connected to the vertices colored a. All output nodes Y (squares) added in the subsequent graph should also be connected to the vertices colored a. At this point, the adjacency matrix initialization of the entire conversion method is completed.

[0037] S3, when processing each separate CNF clause, assume that the three variables in the mth clause are , , , connected by or in sequence, the result is expressed as:

[0038]

[0039] There are two specific cases for variables in a clause: all variables in the clause are positive or at least one variable in the clause is negative.

[0040] For the case where all variables are positive, and like Fig.11 To connect, nodes A and B in the figure are , the node Y in the figure is The adjacency matrix needs to be increased by 5 orders, which means that 5 new vertices are added to the graph G, and the vertices with the intermediate color set {0, a} are connected to the corresponding fixed coloring points as described in S2. The newly added 5 orders are Fig.11 In addition to nodes A and B, there are 4 intermediate nodes and an output Y node. Since the last output node will participate in subsequent connections, its position should be relatively clear, so the output Y node should be the last one in the newly added 5th order. At the same time, the coloring of the intermediate nodes is not very important for the final result, so the intermediate nodes are described in There is no specific requirement for the position in the Then, similarly and Connecting in the diagram as described will give the result of case 1 , expressed as:

[0041]

[0042] For the case where at least one of the variables is negative, assume that the first variable is .Will and In the figure Middle Press Figure 4 The result of this step is expressed as:

[0043]

[0044] Secondly, and According to the method described in case 1, Connect in and get:

[0045]

[0046] Finally and Connect in graph G in the same way as in case 1 to get the result of case 2 , expressed as:

[0047]

[0048]

[0049]

[0050] If more than one variable is negative in case 2, all negative variables can be handled as described above. method to process it.

[0051] S4, after getting the results of all clauses, press Fig.10 Connection shown The result of the clause With The result of the clause , nodes A and B in the figure are , the output node Y is Similarly, according to S3, the adjacency matrix needs to be increased by 5 orders, which means that 5 new vertices are added to the graph G, and the vertices with the intermediate color set {0, 1} need to be connected to the corresponding fixed coloring points according to S2. The results of all clauses are connected in sequence through the following formula to get the entire graph Output Node :

[0052]

[0053] The overall implementation sequence is as follows, which is used to obtain the graph generated by converting the SAT problem represented by CNF into a graph coloring problem: .

[0054]

[0055]

[0056]

[0057]

[0058]

[0059]

[0060] The embodiment is only one of the specific implementations of the present invention, but the protection scope of the present application is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed in the present application should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

Claims

1. A method for converting a SAT problem into a 3-coloring problem, which can be applied to integer programming, code breaking and other fields, comprises the following steps: Construct an undirected graph G, where the Boolean variables in the SAT problem are mapped to some vertices in the graph; Define a color set C, the color set includes exactly three colors, two of which represent Boolean values ​​in the SAT problem respectively; Add nodes and edges to the graph G according to the graph topology that defines specific logical operations; Based on the relationship between the vertices and edges of the graph, the corresponding coloring constraints are defined so that the solution to the 3-coloring problem can correspond to the solution to the SAT problem.

2. The method according to claim 1, characterized in that The vertices of the undirected graph G are divided into fixed coloring vertices and indefinite coloring vertices, the fixed coloring vertices correspond to Boolean constants, the indefinite coloring vertices correspond to Boolean variables, and the colors of the indefinite coloring vertices are constrained by adjacent fixed coloring vertices.

3. The method according to claim 1, characterized in that The coloring of the vertices of the graph can be mapped to Boolean operations in the SAT problem by defining specific logic operations (such as AND gates, OR gates, and NOT gates), thereby solving the SAT problem.

4. The method according to claim 1, characterized in that: The color set C includes three colors, corresponding to the Boolean values ​​"true", "false" and additional auxiliary states, to ensure that the legal 3-coloring of the graph can be uniquely mapped to the solution of the SAT problem.

5. The method according to claim 1, characterized in that The graph construction step includes creating corresponding vertices for each Boolean variable and its negated form in the SAT problem, and ensuring that there is an edge between the vertex of each Boolean variable and the vertex of its negated form in the graph.

6. The method according to claim 1, characterized in that For the final topological graph, a 3-coloring solution corresponds to a solution to the SAT problem. If the topological graph has no 3-coloring solution, the corresponding SAT problem also has no solution.

7. The method according to claim 2, characterized in that The fixed colored vertices are pre-assigned colors according to their Boolean constants in the SAT problem, while the colors of the indefinite colored vertices are determined by the color constraints of the adjacent fixed colored vertices and other indefinite colored vertices.

8. The method according to claim 3, characterized in that The graph structure of the logic operation is implemented by a combination of AND, OR, and NOT gates defined in the present invention, so that the connection relationship between the vertices of the graph can represent the logic clauses in the SAT problem.