Maximum Model Counting

Daniel J. Fremont, Markus N. Rabe, Sanjit A. Seshia

Abstract

The computational problems of Boolean satisfiability (SAT) and model counting (#SAT) are fundamental to computer science, yet many real-world applications require a hybrid approach. This paper introduces Max#SAT, a new problem class that seeks an input maximizing the number of resulting solutions. We present MAXCOUNT, a randomized approximation algorithm that leverages a novel $k$-self-composition trick to amplify the "signal" of high-count assignments. Experimental results across security analysis and program synthesis demonstrate that MAXCOUNT efficiently finds near-optimal solutions, often requiring only small values of $k$ to achieve high accuracy.

Introduction: The Gap Between SAT and #SAT

In logic and automated reasoning, two classic problems dominate the landscape:

  1. SAT (Satisfiability): Determining if any assignment makes a formula true.
  2. #SAT (Model Counting): Determining how many assignments make a formula true.

While SAT is NP-complete and #SAT is #P-complete, many practical tasks fall into a gap between them. For instance, in security, one might ask: "Which public input maximizes the leakage of a secret?" In program synthesis: "Which program candidate satisfies a specification for the maximum number of test cases?" These questions define Max#SAT. Formally, given a formula $\phi(X, Y, Z)$, the goal is to find an assignment to $X$ that maximizes the number of assignments to $Y$ that can be extended to a full solution. This problem resides in the complexity class $NP^{PP}$, making it significantly harder than standard SAT.

Methodology: The MAXCOUNT Algorithm

The primary challenge of Max#SAT is the exponentially large search space of $X$. To address this, the authors propose MAXCOUNT, which avoids exhaustive search through a clever "amplification" strategy.

The $k$-Self-Composition Trick

The core of MAXCOUNT is the definition of a composed formula, $\phi^k$. This formula consists of $k$ independent copies of the $Y$ and $Z$ variables, all constrained by the same $X$ variables. If an assignment $x$ has $C_x$ solutions in the original formula, it will have $(C_x)^k$ solutions in $\phi^k$. By increasing $k$, assignments with higher counts become exponentially more likely to be selected during random sampling.

Figure 1: Impact of the composition parameter $k$ on leakage bounds and runtime. As $k$ increases, the estimated leakage bounds tighten, though runtime grows.

Algorithm Workflow

  1. Sample: A "projected sampler" is applied to $\phi^k$ to pick solutions uniformly at random. Due to amplification, a random sample is highly likely to yield an $x$ with a near-maximum count.
  2. Count: For a candidate $x$, an approximate model counter (e.g., ApproxMC) estimates the actual solution count.
  3. Iterate: The process is repeated to ensure statistical confidence.

Experimental Evaluation

The authors evaluated MAXCOUNT on several domains, most notably Quantitative Information Flow (QIF) and Program Synthesis.

Security Analysis (QIF)

In QIF, the goal is to measure the channel capacity—the maximum information a program can leak. The authors tested MAXCOUNT on Linux kernel vulnerabilities (CVEs) and custom "backdoor" benchmarks.

Table 1: Performance of MAXCOUNT on security-related benchmarks (QIF). The algorithm successfully identifies maximum information leaks (leak bits) with high precision.

As shown in Table 1, MAXCOUNT effectively identifies the leakage bits for various vulnerabilities. For example, in backdoor-32-24, it identified a 32-bit leak in 150 seconds.

Program Synthesis

Using the Sketch performance benchmark set, the authors sought "best-effort" programs that satisfy specifications for the maximum number of inputs. Across benchmarks like ActivityService and LoginService, MAXCOUNT found programs that were correct for over 95% of inputs, often reaching 100% correctness in under three minutes.

Key Insights and Discussion

A significant finding is that while theoretical bounds might suggest a large $k$ is necessary, in practice, $k=1$ or $k=2$ often suffices. This is because real-world problems typically exhibit a large gap between "typical" solution counts and the "maximum" count, allowing the amplification trick to work efficiently even with low composition factors.

While MAXCOUNT is not a replacement for specialized MaxSAT solvers in standard weighted optimization, it provides a unified framework for problems that are more succinctly encoded as Max#SAT. Future work includes refining the tool for probabilistic programming and Marginal MAP tasks in AI, where "almost always" properties are critical.

Summary updated

BibTeX
@inproceedings{fremont2017maximum,
  author = {Daniel J. Fremont and Markus N. Rabe and Sanjit A. Seshia},
  title = {{Maximum Model Counting}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2017},
  doi = {10.1609/aaai.v31i1.11138},
}
Figure