Faster SAT Solving for Software with Repeated Structures (with Case Studies on Software Test Suite Minimization)

Jianfeng Chen, Xipeng Shen, Tim MenziesarXiv 2021

The Redundancy Problem in Modern SAT Solving

Modern software verification often relies on Boolean Satisfiability (SAT) solvers like Z3 to navigate models containing hundreds of thousands of variables. However, traditional solvers frequently struggle with scale, often generating redundant test cases that bloat test suites without increasing coverage. In some benchmarks, state-of-the-art tools like QuickSampler produce outputs where 99% of generated tests are duplicates. This inefficiency results in expensive execution times and increased manual analysis for developers. The core challenge lies in generating a small, diverse, and 100% valid set of tests efficiently.

The Snap Approach: Clustering and Mutation

To address these inefficiencies, the authors introduce Snap, a tool that leverages the "naturalness" of software—the observation that code follows patterns similar to human language (e.g., Zipf’s Law). Snap operates through a five-stage process:

  1. Initial Sampling: Using Z3 to find a small set of initial valid solutions ($N=100$).
  2. Delta Preparation: Calculating differences (deltas) between solutions via XOR operations to identify common patterns of change.
  3. Clustering: Employing k-means clustering to identify "centroids" that represent distinct regions of the solution space.
  4. Mutation: Applying small mutations to these centroids based on discovered deltas rather than generating new solutions from scratch.
  5. Verification and Repair: Using Z3 to verify and, if necessary, "repair" mutated candidates. Repairing a nearly-correct solution is significantly faster than full generation because the search space is constrained.

Experimental Evaluation: Benchmarking at Scale

The researchers evaluated Snap against 27 real-world programs and models, ranging from small circuit models to massive program synthesis constraints. These benchmarks are categorized by their complexity, with the largest models exceeding 480,000 variables and 2.5 million clauses.

Table 1: Overview of benchmarks categorized by size (Small, Medium, Large), showing variable and clause counts.

Performance Gains and Validity

Snap demonstrates significant improvements over QuickSampler in speed, suite size, and validity. While QuickSampler's validity often drops below 70%, Snap maintains 100% validity across all tests. Furthermore, Snap's test suites are 10 to 750 times smaller while maintaining comparable diversity, as measured by Normalized Compression Distance (NCD).

Figure 1: Sampling time comparison between SNAP and QuickSampler across various benchmarks. SNAP consistently terminates faster, especially on larger models.

In terms of raw performance, Snap was found to be 10 to 3000 times faster at terminating. For the most complex models, Snap completed its tasks in under an hour, whereas competing tools required days.

Limitations and Future Work

Despite its success, Snap's performance is sensitive to hyperparameters, such as the number of clusters ($k$). Optimizing these for specific domains remains an open challenge. Additionally, while Snap excels in deterministic systems, future work is needed to extend its capabilities to non-deterministic requirements and complex, nested data structures that may require invariant-aware sampling.

Summary updated

BibTeX
@misc{chen2021faster,
  author = {Jianfeng Chen and Xipeng Shen and Tim Menzies},
  title = {{Faster SAT Solving for Software with Repeated Structures (with Case Studies on Software Test Suite Minimization)}},
  year = {2021},
  eprint = {2101.02817},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2101.02817},
}
Figure