SATformer: Transformers for SAT Solving

Zhengyuan Shi1, Min Li1, Sadaf Khan1, Hui-Ling Zhen2, Mingxuan Yuan2, Qiang Xu1
Abstract

In this paper, we propose SATformer, a novel Transformer-based solution for Boolean satisfiability (SAT) solving. Different from existing learning-based SAT solvers that learn at the problem instance level, SATformer learns the minimum unsatisfiable cores (MUC) of unsatisfiable problem instances, which provide rich information for the causality of such problems. Specifically, we apply a graph neural network (GNN) to obtain the embeddings of the clauses in the conjunctive normal format (CNF). A hierarchical Transformer architecture is applied on the clause embeddings to capture the relationships among clauses, and the self-attention weight is learned to be high when those clauses forming UNSAT cores are attended together, and set to be low otherwise. By doing so, SATformer effectively learns the correlations among clauses for SAT prediction. Experimental results show that SATformer is more powerful than existing end-to-end learning-based SAT solvers.

\nocopyright\affiliations

1 The Chinese University of Hong Kong
2 Noah’s Ark Lab, Huawei Ltd.
{zyshi21, mli, skhan, qxu}@cse.cuhk.edu.hk, {zhenhuiling2, yuan.mingxuan}@huawei.com

1 Introduction

The Boolean Satisfiability (SAT) problem is one of the most fundamental problems in various fields. For example, solving the SAT problem has been the core of dealing with software verification Jackson and Vaziri (2000), circuit design Goldberg et al. (2001) and AI planning Kautz et al. (1992). It determines whether there exists at least one assignment for these variables that makes a given formula evaluate to .

However, the SAT problem is the first proven NP-complete problem Cook (1971), and there is no solving algorithm in polynomial time. To handle the large industrial SAT instance, the prevalent modern solvers Sorensson and Een (2005); Biere et al. (2020); Selman et al. (1993) follow the heuristic-based searching strategies. With the emergence of deep learning, many learning-based SAT solving approaches have been studied extensively in the past few years. The learning-based approaches fall into two directions. On the one hand, learning-aided approaches try to learn an efficient heuristic and are integrated with the traditional SAT solvers Kurin et al. (2020); Zhang et al. (2020); Selsam and Bjørner (2019). On the other hand, the end-to-end approaches Selsam et al. (2018); Amizadeh et al. (2018); Ozolins et al. (2021); Li et al. (2022) solve SAT problems from scratch in a standalone way. Generally, the performance of the end-to-end solver lags behind the learning-aided approaches by a large margin. Nevertheless, since the neural network in the learning-aided SAT solving approach is only a plug-in component, the upper-bound performance of learning-aided solvers is limited by the corresponding backbone solvers. In contrast, end-to-end approaches provide a potential way to improve the efficiency of SAT solving by fundamentally breaking such an upper bound. In this work, we focus on boosting the performance of the end-to-end learning approaches.

Among end-to-end SAT solvers, NeuroSAT Selsam et al. (2018) models the SAT problem as a classification task and trains a classifier only with single-bit supervision (satisfiable or not). However, the instance level supervision is relatively weak for the model training. DG-DAGRNN Amizadeh et al. (2018) and DeepSAT Li et al. (2022) target on the circuit satisfiability problem. They leverage the structure information of the circuit rather than the uniform Boolean formula expression in conjunctive normal form (CNF). Different from the previous approaches, we take CNF instance as inputs and start from the inverse proposition of Boolean satisfiability, i.e., unsatisfiability. In the searching-based solving algorithm, the solver asserts the instance to be unsatisfiable if and only if an unavoidable conflict exists when exploring the satisfying assignment. This conflict is reflected in a subset of clauses, named Unsatisfiable Core (UNSAT Core). Specifically, the sub-problem constituted by the UNSAT core is still unsatisfiable. Therefore, the solving procedure can be considered as modeling the interaction among the clauses and determining whether an UNSAT core can be discovered from the original instance.

In this paper, we present SATformer, a Transformer-based SAT solving approach guided by the UNSAT cores. Firstly, to differentiate the clauses involved in the UNSAT core, our model applies a graph neural network (GNN) to obtain the clause embeddings and learns a probability distribution of clauses to formulate the contribution to unsatisfiability. Since the unsatisfiable instance does not contain only a single UNSAT core, we take the minimal unsatisfiable core (MUC) as supervision (similar to NeuroCore Selsam and Bjørner (2019)), which has less uncertainty.

Secondly, as a set of clauses may construct an UNSAT core, satisfiability solving can be realized by modeling the clause interactions. To this end, we equip the Transformer blocks to draw the connection between clauses. With the guidance from UNSAT core prediction, our model can learn to assign higher attention weight to these key clauses causing unsatisfiable.

Thirdly, the self-attention mechanism of the plain Transformer only learns pairwise dependency. To accommodate the requirements of modeling multiple clauses, we design a hierarchical Transformer structure. Our model merges clauses into clause groups level by level and captures the relationships between a pair of clause groups with various scales.

The experimental results indicate that our proposed model is competitive with previous end-to-end SAT solvers. We also prove that after classifying clauses into two categories: likely and unlikely to form an UNSAT core, the effectiveness of our SATformer comes from focusing on these clauses tending to form an UNSAT core.

The contributions of this work are summarized as follows:

  • We model the learning-based SAT solving from a novel perspective. In particular, we design a Transformer-based model to capture the correlation among clauses and determine whether the instance is satisfiable or not.

  • We apply the minimal UNSAT core as significant clause-level supervision. Our proposed model distinguishes clauses as likely or unlikely to form an UNSAT core. Moreover, the Transformer blocks inside our model pays much attention to these important clauses with core-guided.

  • We propose a hierarchical Transformer structure to package clauses. Therefore, our model can model relationships from different granularities, instead of pair relationships between clauses.

2 Related Work

2.1 Learning-based SAT Solver

The mainstream SAT solvers depend on heuristic strategies to speed up the solving process. However, the state-of-the-art SAT solvers are still suffering from the increasing sizes of the problem instances. In the combinatorial optimization area, especially for the SAT problem, deep learning provides an attractive solution to improve the solving efficiency, as surveyed in  Guo et al. (2022).

Generally, there are two approaches to applying deep learning to solve the SAT problem: Learning-aided and end-to-end. On the one hand, the learning-aided approaches aid traditional SAT solvers with a neural network instead of the manual-crafted heuristics. For example, NLocalSAT Zhang et al. (2020) boosts the traditional SAT solver by producing the initialization assignments, and Graph--SAT Kurin et al. (2020) replaces the searching heuristic with a reinforcement learning agent. NeuroCore Selsam and Bjørner (2019) and NeuroComb Wang et al. (2021) learn the UNSAT core distribution to guide SAT solving. Although some modern SAT solvers equipped with learning-aided heuristics can solve more industrial problem instances within acceptable runtime, the performance of the overall solving system is still limited by the backbone SAT solver.

On the other hand, the end-to-end approaches solve the SAT problem with neural networks solely. For example, NeuroSAT Selsam et al. (2018) treats the SAT problem as a classification task and trains an end-to-end GNN-based framework to predict the binary results (satisfiable or unsatisfiable). DG-DAGRNN Amizadeh et al. (2018) focuses on the circuit satisfiability problem, i.e., determining whether the single primary output of a given circuit can return logic ’1’. They propose a differentiable method to evaluate the satisfiability value. By maximizing the value, the solver is more likely to find a satisfiable assignment. DeepSAT Li et al. (2022) formulates the SAT solution as produce of conditional Bernoulli distributions and obtains assignment by maximizing the joint probability. Similar to the later learning-based approach, SATformer also aims to solve the SAT problem in a standalone way.

2.2 Transformer and Self-attention Mechanism

The Transformer Vaswani et al. (2017) is well acknowledged as one of the most powerful architectures in modeling sequential data. With the adoption of Transformer, tremendous progress has been achieved in the field of text comprehension Meng et al. (2020), machine translation Wang et al. (2019) and even computer vision Dosovitskiy et al. (2020); Liu et al. (2021). With the self-attention mechanism, the Transformer block regards the sequential input tokens as a fully connected graph and represents the connectivity between every two nodes. Hence, the Transformer-based model is able to capture the correlation between each pair of tokens.

The first attempt to involve the Transformer for solving MaxSAT problem (a variant of SAT problem) is introduced in Shi et al. (2021). The proposed model represents a given SAT instance into a bipartite graph and applies Transformers to aggregate the message over these nodes. In our work, we regard the clauses as a non-ordering sequence and apply the Transformer to capture the correlations among these clauses.

3 Methodology

3.1 Preliminaries

A Boolean formula consists of a set of variables and a set of Boolean operators {AND (), OR(), NOT(), …} over these variables. Solving the SAT problem is determining whether there is at least one valid assignment on the variables so that the given formula returns .

An arbitrary Boolean formula can be converted into conjunctive normal form (CNF) with an equivalent transformation in linear time Tseitin (1983). Under CNF conventions, variables and theirs negations are named as literal (denoted as or ). A disjunction of several literals constructs a clause . A conjunction of clauses forms the propositional instance . In Eq. (1), we provide an example to explain the CNF, wherein the instance has three variables and consists of three clauses .

(1)
An example of Literal-clause Graph (LCG).
Figure 1: An example of Literal-clause Graph (LCG).

Literal-clause Graph (LCG) is a bipartite graph representation of the CNF formulas, which is composed of literal nodes and clause nodes. Two types of edges are defined in LCG: one connects a literal node with a clause node, and another connects a literal node with its corresponding negation. Fig. 1 is an example representing the Eq. (1) in LCG.

Besides, given an unsatisfiable instance in CNF, if a sub-problem constructed by its several clauses is also unsatisfiable, then such sub-problem with specific clauses is referred to as an UNSAT core. Take the unsatisfiable instance shown in Eq. (2) as an example. We can extract an unsatisfiable sub-problem as one of the UNSAT cores of the original instance . The concept of UNSAT core is further explained by the searching-based solving process. As the clauses and only include one literal, to satisfy both clauses, the variables must be assigned as . Nevertheless, the assignment does not satisfy clause under any cases, no matter what value is assigned to the remaining variable . Therefore, the solver proves there is an inevitable conflict within these clauses so that all searching branches for solving problem fail. It should be noted that there is no UNSAT core in a satisfiable instance.

(2)

Since the UNSAT cores provide sufficient causality for unsatisfiability judgement, one can determine a CNF instance is unsatisfiable or not by converting the original problems into UNSAT core extraction. In this work, we solve the SAT problem in a novel manner by learning to capture the clauses which leads to the unsatisfiablity of the instance (i.e., clauses included in UNSAT core) and modeling the interactions among these clauses.

3.2 Overview

The overview of model architecture.
Figure 2: The overview of model architecture.

Fig. 2 shows the overview of our proposed SATformer. Firstly, our model employs GNN to obtain the clause representation and literal representation from a CNF instance. After performing message-passing for several iterations based on the LCG, the GNN learns the literal embeddings with rich information from the connecting clauses and the clause embeddings containing information from the involving literals.

Secondly, after getting the clause embedding, we design a classifier to predict which clauses are involved in UNSAT core. Formally, the classifier is implemented by a Multilayer Perceptron (MLP)as shown in Eq. (3), where is the embedding of clause produced by GNN, is the prediction, and is the number of clauses. It should be noted that this structure is not perfect for classifying clauses with high accuracy. Nevertheless, similar to the NeuroCore Selsam and Bjørner (2019) which learns a heuristic that assigns higher priority to the important variables, the proposed classifier can help to highlight the clauses that are contributing more to unsatisfiability.

(3)

Thirdly, we consider that the unsatisfiability comes from the interaction among clauses in the UNSAT core. We take the clauses embeddings from GNN as inputs and apply the Transformer to capture such clause relationships. Benefiting from the self-attention mechanism inside the Transformer, the SATformer gives more attention to the clauses likely to be involved in the UNSAT core, which is proved in Sec. 4.3. However, the plain Transformer only learns the pairwise correlation. There is almost no cause of unsatisfiability coming from a pair of clauses. To deal with this problem, we merge clauses into clauses groups in a hierarchical manner and train a Hierarchical Transformer to model clause groups, which is elaborated in Sec. 3.4.

3.3 Training Objective

We adopt the multi-task learning (MTL) Caruana (1997) strategy to improve the performance of SATformer. As shown in Fig. 2, we train our model to predict UNSAT core (Task-a) and satisfiability (Task-b) simultaneously.

Firstly, although the UNSAT core is not unique for a given instance, there are only a few possible combinations of minimal unsatisfiable core (MUC), i.e., the UNSAT core with minimal size. We denote as the number of clauses and label a binary vector as a ground truth for each instance, which represents whether the clause is included in MUC. Hence, the binary vector for a satisfiable instance is all zero and some bits are assigned one for an unsatisfiable instance.

We denote that the clause embedding matrix is and obtain to model a probability distribution over clauses as Eq. (4). We regard as the contribution to unsatisfiability, where the larger value means that the corresponding clauses are more likely to form the MUC.

(4)

The model is trained by minimizing the Kullback-Leibler (KL) divergence Kullback and Leibler (1951):

(5)

Secondly, the SATformer predicts binary satisfiability as another task (Task-b). The model learns to produce a prediction results with single-bit supervision . We apply Binary Cross-Entropy (BCE) loss to train the model.

(6)

Thus, the overall loss is the weighted sum of and

(7)

Intuitively, Task-a aims to distinguish which clauses contribute more to unsatisfiability. In this case, our model learns to pay much attention to these clauses and predicts the final satisfiability as Task-b. Therefore, we can improve the solving accuracy by leveraging useful information between these two related tasks.

3.4 Hierarchical Design

We further propose a Hierarchical Transformer design to model the correlation among clauses. Formally, for the plain Transformer , we define the embeddings of the input tokens as . The self-attention matrix and updated embedding are denoted as:

(8)

where the , , produced by three projections represent quires, keys, and values. , , are three learnable weights. The self-attention matrix describes the similarities between queries and keys for each pair of input tokens.

The architecture of the proposed Hierarchical Transformer.
Figure 3: The architecture of the proposed Hierarchical Transformer.

The unsatisfiability can not be determined by a pair of clauses. As the example instance in Eq. (2), the solver require to consider at least clauses (, and ) to assert unsatisfiable. However, capturing the dependency among multiple tokens within one Transformer block is impractical. Even if increasing the number of Transformer blocks can mitigate this problem, this approach significantly increases the model complexity. In this paper, we propose a Transformer structure in a hierarchical manner, as shown in Fig. 3. Briefly, the model merges clauses within a fixed-size window into a clause group and then packages these groups into another group. The produced clause group embedding contains the information from all clauses covered by the lower-level groups. At a higher level, the model takes clause group embeddings as input tokens and learns the relationship between two clause groups.

More formally, the clause embeddings from the GNN model are denoted as , where is the number of clauses. We also denote the clause group embeddings as , where is the number of windows in level and the maximum level is . Given the fixed window size , we calculate as Eq. (9). Before dividing the embeddings into groups, we randomly pad the length of the embedding matrix as . For example, if there are clauses and the window size , we divide these clauses with more padding clauses into windows at the first level.

(9)

Within a window with size , the clause embeddings (clause group embeddings) are updated as:

(10)

where is the window index and matrix consists of the embedding vectors of clauses in the window . We also combine these clause embeddings into one group embedding for each window. The combination of clause group embedding is implemented with linear transformation LN. For the higher level, i.e., , the inputs of the Transformer Block should be clause group embeddings instead of .

We still take the instance in Eq. (2) as an example. When the window size is , these clauses are divided into clause groups, where contains the information from , represents , and so on. We cannot find any UNSAT cores by combining clauses pairwise, but at a high level, the clauses contained by and can construct an UNSAT core. Therefore, to determine whether the instance is satisfiable, the model should consider the pairwise relationship of groups in various grain sizes.

As shown in Eq. (12), similar to the Feature Pyramid Networks (FPN) Lin et al. (2017), we also obtain level embedding based on the maximum pooling (MaxPooling) of all or as belows:

(11)

Finally, a MLP readout the concatenation (Cat) of these level embeddings and the pooling of final clause group embedding .

(12)

With the Hierarchical Transformer, our proposed SATformer can capture the effect on satisfiability among multiple clauses rather than pairs of clauses.

4 Experiments

4.1 Experimental setting

We present the details of the experimental setting, including the construction of datasets and the hyperparameter of the SATformer model. In the following experiments, we adopt the same settings described here for all models if there is no special case.

Evaluation metric: Our SATformer predicts the satisfiability of a given instance. We construct both satisfiable and unsatisfiable instances in the testing dataset and record the accuracy of binary classification. We still try to decode the satisfiability assignment in the appendix, which is similar to NeuroSAT Selsam et al. (2018).

Dataset preparation: We generate satisfiable instances and unsatisfiable instances. Following the same dataset generation scheme in  Selsam et al. (2018), a pair of random -SAT satisfiable and unsatisfiable instances are generated together with only one different edge connection. Here, SR() represents that the instance contains variables. In our training dataset, we set the problem size as SR(). Furthermore, we enumerate all possible clause subsets of each instance and label the minimal UNSAT cores. We also generate default testing datasets, each containing satisfiable and unsatisfiable instances in SR(-), SR(), SR() and SR(), respectively.

Implementation Details: In the GNN structure, we adopt the same configurations as NeuroSAT Selsam et al. (2018), except for reducing the number of message-passing iterations from to . In the Hierarchical Transformer structure, we directly use clause embeddings as input tokens, resulting in the same hidden state dimension as . The window size is assigned to , and the total level of the hierarchical structure is . Inside each Transformer block, we set the number of heads in the multiple head self-attention mechanism as . The MLPs to produce two predictions for Task-a and Task-b are all configured as 3 layers. We train the model for epochs with batch-size on a single Nvidia V100 GPU. We adopt the Adam optimizer Kingma and Ba (2014) with learning rate and weight decay .

Model Complexity: The complexity of NeuroSAT and above SATformer are illustrated in Tab. 1, where # FLOPs is the number of floating-point operations and # Para. is the total number of trainable parameters. Although our model requires more trainable parameters to build up Transformer structures, SATformer performs faster (lower # FLOPs) than NeuroSAT due to the fewer message-passing iterations.

NeuroSAT SATformer
# Param. 429.31 K 732.47 K
# FLOPs 207.91 M 152.93 M
Table 1: The Model Complexity of NeuroSAT and SATformer.

4.2 Performance Comparison with NeuroSAT

We compare our SATformer with another learning-based SAT solver NeuroSAT Selsam et al. (2018). As an end-to-end SAT solver, SATformer does not compare with the learning-aided approaches. We also do not consider the other standalone SAT solver Amizadeh et al. (2018); Ozolins et al. (2021); Li et al. (2022) because they can not produce a single binary result.

Both NeuroSAT and our SATformer require the input instances are in CNF. While SR() presents the problem scale, we use another metric to better quantize the problem difficulty, where is the number of clauses and is the number of variables. The higher value means that there are more clause constraints in the formula, and the instance is more difficult to be solved. The instances from the training dataset and the default testing dataset have . These satisfiable instances only have or possible satisfying assignments in total. Besides, we also produce the satisfiable and unsatisfiable simplified instances with for each scale of problems. To ensure fairness, we train the NeuroSAT on the same training dataset in SR(-). The results of binary classification are listed in Tab. 2.

SR(-) SR() SR() SR()
> NeuroSAT 87% 61% 58% 50%
SATformer 94% 77% 68% 61%
Impr. 7% 16% 10% 11%
NeuroSAT 83% 59% 58% 50%
SATformer 99% 98% 91% 86%
Impr. 16% 39% 33% 36%
NeuroSAT 89% 50% 57% 50%
SATformer 99% 98% 98% 98%
Impr. 10% 48% 98% 48%
Table 2: Performance comparison of NeuroSAT and SATformer.

From Tab. 2, we have a few observations. Firstly, our SATformer achieves higher performance than NeuroSAT across all datasets. For example, the NeuroSAT can only correctly classify in SR() and in SR() when , but our SATformer has an accuracy of in SR() and in SR(). Secondly, the results of NeuroSAT have no significant difference when reducing the problem difficulty, but our SATformer performs better on the simplified instances. For example, SATformer solves all instances with despite the problem scale. The reason is that SATformer relies on the correlation among clauses to solve SAT problems. With the smaller number of clauses, SATformer harnesses such correlation more easily. In contrast, NeuroSAT only learns the instance-level feature with single-bit supervision and does not obtain richer representations with the reduction of problem difficulty.

To conclude, our SATformer outperforms the NeuroSAT. Our SATformer also shows a similar property as the traditional SAT solver, i.e., they can achieve higher performance on these instances with lower difficulty.

4.3 Effectiveness of Transformer Blocks

This section investigates the effectiveness of the Transformer Blocks in SATformer. On the one hand, we compare our SATformer with a derived model framework SATformer-MLP, which replaces Transformer blocks with MLPs of the equivalent number of model paremeters (# Param.). Tab. 3 shows the experimental results. Since the SATformer-MLP regards all clauses equally instead of selectively enhancing the correlation between some clauses, it shows an inferior performance to the original SATformer.

SR(-) SR() SR() SR()
SATformer 94% 77% 68% 61%
SATformer-MLP 90% 72% 60% 52%
Table 3: Performance comparison of SATformer and SATformer-MLP.

On the other hand, as the Transformer distinctively treats token pairs based on the self-attention mechanism, we explore the attention weights on different token pairs. Based on the Task-a UNSAT core prediction, we equally divide the clauses into two categories: likely to form an UNSAT Core (denoted as C-clause) and Ulikely to form an UNSAT core (denoted as U-clause) cause unsatisfiable. Therefore, the pairwise connections are classified into types: between the C-clause and C-clause (CC), the C-clause and U-clause (CU), the U-clause and C-clause (UC), the U-clause and U-clause (UU). We calculate the overall attention weights for these types, respectively, and list the percentage in Tab. 4. The higher percentage means the model pays much attention to the corresponding pairwise correlation. Transformer assigns almost attention weights on the connection CC. Moreover, plus the connection CU and UC, the model allocates for attention weights in total to the capture the correlation related to C-clauses. Therefore, our Transformer-based mainly focuses on the clauses, which contributes more to unsatisfiability.

CC CU UC UU
68.27% 14.95% 14.01% 2.77%
Table 4: The attention weight percentages of four type connections.

To summarize, our SATformer not only captures the relationship among clauses but also learns how to pay much attention to these clauses that are more likely to raise unsatisfiability.

4.4 Effectiveness of Hierarchical Transformer

In this subsection, we design an ablation study and also build some special cases to indicate the effectiveness of our Hierarchical Transformer.

Firstly, we apply some plain Transformer blocks to replace the hierarchical structure. This model takes clause embeddings as input tokens and updates with (same as in default SATformer configuration) stacked Transformer blocks (denoted as SATformer-NoHier). Then, the model produces an embedding vector by pooling all updated clause embeddings and predicts the final binary results. As shown in Tab. 5, SATformer-NoHier deals with fewer instances than SATformer. For example, SATformer-NoHier only achieves accuracy in SR(-) and degrades as a randomly guessing classifier in SR() and SR() instances. On the contrary, the SATformer is still available in SR() and SR(). The reason is that SATformer-NoHier can only learn the pairwise dependency, while a pair of clauses do not show a decisive effect on the satisfiability. Although the model can model multiple relationships by stacking Transformer blocks, layers of Transformer are still far from sufficient.

SR(-) SR() SR() SR()
SATformer 94% 77% 68% 61%
SATformer-NoHier 70% 57% 50% 50%
Table 5: Performance comparison of SATformer and SATformer-NoHier.

Secondly, to further demonstrate the ability of multiple relationship modeling, we construct two equivalent unsatisfiable instances as Eq. (13) based on Eq. (2) with different clause orders. These three clauses , , and forming MUC are highlighted with underlines.

(13)
Two special unsatisfiable cases in hierarchical structure.
Figure 4: Two special unsatisfiable cases in hierarchical structure.

We train the other two SATformer models with window size , but the hierarchical level is different, where one is , and another is . As shown in Fig. 4, for the instance , the clauses (from to ) in the first two groups can construct an unsatisfiable sub-instance. Hence, by modeling the pairwise relationship between input token embeddings and in level can determine the satisfiability. However, no pairwise correlation leads to unsatisfiability in the first hierarchical level in . According to the experimental results, the model relying on the group embeddings in level can only predict correctly as unsatisfiable.

Moreover, if we add one more Transformer block in level , the model can learn group embedding , which contains the information from these clause groups. In this case, the SATformer model predicts both instances correctly.

In summary, our SATformer can learn the relationships among multiple tokens due to the pairwise self-attention mechanism and hierarchical manner. Besides, to mitigate the effect of clause ordering, we shuffle the clauses every training iteration.

4.5 Effectiveness of Multi-task Learning Strategy

To investigate the effectiveness of the MTL strategy in our SATformer, we train another model without UNSAT core supervision (denote as SATformer-NoCore) and compare the model with the original SATformer. Tab. 6 shows the experimental results. After removing the Task-a UNSAT core prediction, the model performance on these datasets all decreases.

SR(-) SR() SR() SR()
SATformer 94% 77% 68% 61%
SATformer-NoCore 89% 67% 57% 51%
Table 6: Performance comparison of SATformer and SATformer-NoCore.

Generally, UNSAT core retains rich information for the contribution of clauses to unsatisfiability. Predicting the UNSAT core is significantly related to SAT solving. Therefore, the MTL strategy benefits the model performance.

5 Conclusion

In this paper, we presents SATformer, a Transformer-based SAT solver. Unlike most previous approaches that solve the SAT problem by searching for a satisfying assignment, SATformer determines the satisfiability from a contrary direction, i.e., unsatisfiability. Specifically, with the CNF inputs, SATformer firstly obtains the clause embeddings with a GNN and predicts which clauses tend to construct the minimal UNSAT cores. Secondly, with the guidance of contribution to unsatisfiability, the Transformer block inside SATformer learns to attend more to these important clauses. Thirdly, we design a hierarchical Transformer structure to fulfill the requirement of capturing multiple clauses correlations. In a hierarchical manner, SATformer packages several clauses into a clause group level by level, which enables learning pairwise dependency of clause groups at higher levels. The satisfiability prediction is based on each level feature and the group embeddings in the last level. Our experimental results show that our SATformer outperforms the other end-to-end learning-based SAT solver.

References

  • S. Amizadeh, S. Matusevych, and M. Weimer (2018) Learning to solve circuit-sat: an unsupervised differentiable approach. In International Conference on Learning Representations, Cited by: §1, §1, §2.1, §4.2.
  • A. Biere, K. Fazekas, M. Fleury, and M. Heisinger (2020) CaDiCaL, Kissat, Paracooba, Plingeling and Treengeling entering the SAT Competition 2020. In Proc. of SAT Competition 2020 – Solver and Benchmark Descriptions, T. Balyo, N. Froleyks, M. Heule, M. Iser, M. Järvisalo, and M. Suda (Eds.), Department of Computer Science Report Series B, Vol. B-2020-1, pp. 51–53. Cited by: §1.
  • R. Caruana (1997) Multitask learning. Machine learning 28 (1), pp. 41–75. Cited by: §3.3.
  • S. A. Cook (1971) The complexity of theorem-proving procedures. In Proceedings of the third annual ACM symposium on Theory of computing, pp. 151–158. Cited by: §1.
  • A. Dosovitskiy, L. Beyer, A. Kolesnikov, D. Weissenborn, X. Zhai, T. Unterthiner, M. Dehghani, M. Minderer, G. Heigold, S. Gelly, et al. (2020) An image is worth 16x16 words: transformers for image recognition at scale. arXiv preprint arXiv:2010.11929. Cited by: §2.2.
  • E. I. Goldberg, M. R. Prasad, and R. K. Brayton (2001) Using sat for combinational equivalence checking. In Proceedings Design, Automation and Test in Europe. Conference and Exhibition 2001, pp. 114–121. Cited by: §1.
  • W. Guo, J. Yan, H. Zhen, X. Li, M. Yuan, and Y. Jin (2022) Machine learning methods in solving the boolean satisfiability problem. arXiv preprint arXiv:2203.04755. Cited by: §2.1.
  • D. Jackson and M. Vaziri (2000) Finding bugs with a constraint solver. ACM SIGSOFT Software Engineering Notes 25 (5), pp. 14–25. Cited by: §1.
  • H. A. Kautz, B. Selman, et al. (1992) Planning as satisfiability.. In ECAI, Vol. 92, pp. 359–363. Cited by: §1.
  • D. P. Kingma and J. Ba (2014) Adam: a method for stochastic optimization. arXiv preprint arXiv:1412.6980. Cited by: §4.1.
  • S. Kullback and R. A. Leibler (1951) On information and sufficiency. The annals of mathematical statistics 22 (1), pp. 79–86. Cited by: §3.3.
  • V. Kurin, S. Godil, S. Whiteson, and B. Catanzaro (2020) Can q-learning with graph networks learn a generalizable branching heuristic for a sat solver?. Advances in Neural Information Processing Systems 33, pp. 9608–9621. Cited by: §1, §2.1.
  • M. Li, Z. Shi, Q. Lai, S. Khan, and Q. Xu (2022) DeepSAT: an eda-driven learning framework for sat. arXiv preprint arXiv:2205.13745. Cited by: §1, §1, §2.1, §4.2.
  • T. Lin, P. Dollár, R. Girshick, K. He, B. Hariharan, and S. Belongie (2017) Feature pyramid networks for object detection. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 2117–2125. Cited by: §3.4.
  • Z. Liu, Y. Lin, Y. Cao, H. Hu, Y. Wei, Z. Zhang, S. Lin, and B. Guo (2021) Swin transformer: hierarchical vision transformer using shifted windows. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pp. 10012–10022. Cited by: §2.2.
  • C. Meng, M. Chen, J. Mao, and J. Neville (2020) Readnet: a hierarchical transformer framework for web article readability analysis. In European Conference on Information Retrieval, pp. 33–49. Cited by: §2.2.
  • E. Ozolins, K. Freivalds, A. Draguns, E. Gaile, R. Zakovskis, and S. Kozlovics (2021) Goal-aware neural sat solver. arXiv preprint arXiv:2106.07162. Cited by: §1, §4.2.
  • B. Selman, H. A. Kautz, B. Cohen, et al. (1993) Local search strategies for satisfiability testing.. Cliques, coloring, and satisfiability 26, pp. 521–532. Cited by: §1.
  • D. Selsam and N. Bjørner (2019) Guiding high-performance sat solvers with unsat-core predictions. In International Conference on Theory and Applications of Satisfiability Testing, pp. 336–353. Cited by: §1, §1, §2.1, §3.2.
  • D. Selsam, M. Lamm, B. Bünz, P. Liang, L. de Moura, and D. L. Dill (2018) Learning a sat solver from single-bit supervision. arXiv preprint arXiv:1802.03685. Cited by: §1, §1, §2.1, §4.1, §4.1, §4.1, §4.2, §6.2.
  • F. Shi, C. Lee, M. K. Bashar, N. Shukla, S. Zhu, and V. Narayanan (2021) Transformer-based machine learning for fast sat solvers and logic synthesis. arXiv preprint arXiv:2107.07116. Cited by: §2.2.
  • N. Sorensson and N. Een (2005) MiniSAT v1. 13-a sat solver with conflict-clause minimization. SAT 2005 (53), pp. 1–2. Cited by: §1.
  • G. S. Tseitin (1983) On the complexity of derivation in propositional calculus. In Automation of reasoning, pp. 466–483. Cited by: §3.1.
  • A. Vaswani, N. Shazeer, N. Parmar, J. Uszkoreit, L. Jones, A. N. Gomez, Ł. Kaiser, and I. Polosukhin (2017) Attention is all you need. Advances in neural information processing systems 30. Cited by: §2.2.
  • Q. Wang, B. Li, T. Xiao, J. Zhu, C. Li, D. F. Wong, and L. S. Chao (2019) Learning deep transformer models for machine translation. arXiv preprint arXiv:1906.01787. Cited by: §2.2.
  • W. Wang, Y. Hu, M. Tiwari, S. Khurshid, K. McMillan, and R. Miikkulainen (2021) NeuroComb: improving sat solving with graph neural networks. arXiv e-prints, pp. arXiv–2110. Cited by: §2.1.
  • W. Zhang, Z. Sun, Q. Zhu, G. Li, S. Cai, Y. Xiong, and L. Zhang (2020) NLocalSAT: boosting local search with solution prediction. arXiv preprint arXiv:2001.09398. Cited by: §1, §2.1.

CV > 5 CV = 4 CV = 3
SR(-) SR() SR() SR() SR(-) SR() SR() SR() SR(-) SR() SR() SR()
NeuroSAT 26 87% 61% 58% 50% 83% 59% 58% 50% 89% 50% 57% 50%
NeuroSAT 10 62% 56% 53% 50% 73% 55% 50% 50% 55% 50% 50% 50%
SATformer 26 94% 83% 70% 63% 99% 98% 91% 90% 100% 98% 98% 98%
SATformer 10 94% 77% 68% 61% 99% 98% 91% 86% 99% 98% 98% 98%
Table 7: Performance comparison of NeuroSAT and SATformer with various GNN rounds
CV>5 CV=4 CV=3
SR(3-10) SR(20) SR(40) SR(60) SR(3-10) SR(20) SR(40) SR(60) SR(3-10) SR(20) SR(40) SR(60)
NeuroSAT 26 84% 50% 28% 8% 86% 81% 48% 40% 94% 86% 84% 80%
NeuroSAT 10 26% 18% 6% 0% 76% 58% 38% 6% 90% 62% 56% 40%
SATformer 26 84% 78% 30% 20% 96% 94% 84% 84% 98% 98% 98% 98%
SATformer 10 82% 50% 12% 4% 96% 92% 70% 46% 98% 96% 92% 90%
Table 8: Performance comparison of NeuroSAT and SATformer in satisfying assignment decoding

6 Appendix

6.1 Analysis of GNN Message-Passing Rounds

We explore the impact of GNN message-passing iterations on the performance of our SATformer. Here, the number of GNN message-passing rounds is denoted as . In the default configuration of SATformer, the GNN module performs times aggregations between literals and clauses, while NeuroSAT has . We incrementally increase the message-passing times of SATformer from to . The results of satisfiability prediction are listed in Tab. 7.

Firstly, although our SATformer has fewer than NeuroSAT (see SATformer and NeuroSAT ), SATformer shows a better accuracy on each dataset than NeuroSAT. For example, SATformer with rounds message-passing predicts instances correctly on the dataset in CV> and SR(-). NeuroSAT has a lower accuracy, where the model predicts and the model only predicts .

Secondly, with the increase of GNN rounds , both SATformer and NeuroSAT gain performance improvement. The prediction accuracy of SATformer increases from to on the dataset in CV> and SR(), when increases from to . Since the SATformer achieves high accuracy on the datasets containing simple problem instances (CV= and CV=), the accuracy improvement is not very significant when we increase the GNN rounds. Besides, the SATformer with shows a higher computational complexity, where # FLOPs is 228.64 M, larger than NeuroSAT 207.91 M.

6.2 Satisfying Assignment Decoding

In this section, we decode one of the satisfying assignments from literal embeddings, as same as the NeuroSAT Selsam et al. (2018). More specifically, we apply -means to cluster the literal embeddings into two clusters ( and ). After that, there are two possible assignments are generated, one assignment contains variables in is assigned to be true and the variables in is false; the reverse cases offer the second potential assignments.If one of the two assignments can satisfy the instance, we consider the SAT problem is solved.

The results are shown in Tab. 8. Firstly, with the same GNN message-passing rounds, SATformer solves more instances than NeuroSAT. For example, SATformer with solves instances in CV> and SR(-). However, NeuroSAT only solves instances in the same dataset. We suspect the superior performance of SATformer comes from two aspects. On the one hand, SATformer learns a better representation than NeuroSAT with the Transformer-based structure to model relationships between clauses. On the other hand, conflict is strongly related to the task searching satisfying assignment in the traditional SAT solver. The model captures inevitable conflict among clauses with strong supervision from the UNSAT core. Therefore, SATformer obtains rich both clause embeddings and literal embeddings, which benefits SAT solving.

Secondly, with the decrease of instance difficulty, i.e., the decrease of CV, both SATformer and NeuroSAT solve more instances. The reason is that there are more potential satisfying assignments in the instances with lower difficulty. Although the model cannot find a clear clustering result for some variables, the produced assignment still has a high probability of satisfying the instance.

To conclude, our SATformer not only predicts satisfiability correctly for more instances but also solves more problem instances than NeuroSAT. Besides, the performance is much better when solving the instance with lower difficulty.