Matching Multiplications in Bit-Vector Formulas

Supratik Chakraborty, Ashutosh Gupta, Rahul Jain

TL;DR

State-of-the-art SMT solvers often choke on bit-vector formulas where multiplication is "decomposed" into lower-level logic (like long multiplication or Wallace-trees). This paper introduces a pre-processing heuristic that identifies these patterns and adds "tautological hints" to the formula, allowing solvers to resolve in seconds what previously took over 24 hours.

What Problem Does This Paper Address?

In hardware verification, engineers often use Satisfiability Modulo Theories (SMT) solvers to check if a design meets its specification. While solvers like Z3, CVC4, and Boolector are incredibly powerful, they have a notorious Achilles' heel: multiplication.

The problem is particularly acute when a high-level multiplication operation (like a * b) is implemented in hardware as a complex web of partial products and adders (decomposed multiplication). When an SMT solver encounters these decomposed structures, it often fails to recognize them as multiplication. Instead, it falls back on "bit-blasting"—converting the entire problem into a massive, unmanageable sea of Boolean gates. This leads to a "dramatic blowup" in run-time, where even simple 32-bit multiplication checks can cause a solver to hang indefinitely.

Methods

The authors propose a non-intrusive pre-processing step. Rather than rewriting the formula (which can be risky and lose semantic information), they use a pattern detection approach to find "hidden" multipliers.

  1. Pattern Matching Algorithms: They developed two primary algorithms:
  2. MatchLong: Identifies structures resembling "long multiplication" (the shift-and-add method we learn in school).
  3. MatchWallaceTree: Identifies "Wallace-tree" structures, which use a cascade of full and half adders to sum partial products quickly.
  4. Tautological Assertions: Once a pattern is matched, the tool doesn't replace the code. Instead, it adds a "hint" to the solver in the form of a tautology: Assertion: (decomposed_structure == original_multiplication_term).
  5. Solver Independence: Because the tool simply adds valid assertions to the input formula, it works as a front-end for any standard SMT solver.

The core innovation here is the move away from "peep-hole" rewriting. By adding equivalences rather than replacing terms, the authors allow the solver to use the high-level multiplication logic for reasoning while keeping the original structure intact for other potential simplifications.

Datasets

The authors evaluated their approach on 20 benchmarks derived from real-world hardware verification problems, specifically:

  • Word-level Symbolic Trajectory Evaluation (WSTE) and Bounded Model Checking (WBMC) of embedded hardware.
  • A "motivating example" involving a pipelined serial multiplier that originally caused all major solvers to time out after 24 hours.
  • Custom-generated benchmarks varying bit-widths (4-bit to 16-bit) and multiplication styles to test the robustness of the matching algorithms.

Key Insights and Ideas

  • The Ambiguity Trap: The authors highlight that the same set of partial products can sometimes represent different multiplications. This makes direct "rewriting" dangerous. By adding tautologies instead, they bypass the need to "guess" the single correct rewrite.
  • Word-Level vs. Bit-Level: The added assertions act as a bridge. They allow the solver to perform "word-level" reasoning (using the properties of multiplication) even if the original formula was written at the "bit-level."
  • Pruning the Search Space: Even if the solver eventually decides to bit-blast the formula, the added tautologies help the underlying SAT solver prune its search space significantly, leading to fewer conflicts and faster decisions.

Key Results

The performance gains were massive.

  • The 24-Hour Wall: Benchmarks that previously timed out after 24 hours on Z3, CVC4, and Boolector were solved in 0.073s (Z3) and 0.017s (CVC4) after the pre-processing step.
  • Consistency: Across the long multiplication benchmarks, the "OurSolver" configuration (using CVC4 as the backend) consistently hit the 0.01s mark, whereas the standard solvers frequently timed out at 3600s.
  • Wallace-Tree Success: For Wallace-tree multipliers, Z3 benefited the most, solving 16-bit instances in under 3 seconds that previously caused timeouts.

Limitations and Future Work

  • Scope of Patterns: The current implementation only targets long multiplication and Wallace-trees. It does not yet support Booth multipliers or more complex recursive multiplication patterns.
  • Syntactic Sensitivity: The matching is somewhat sensitive to how the input formula is structured. For instance, if a solver internally transforms all AND gates to OR gates, the pattern matcher might fail to recognize the structure.
  • Constant Optimizations: The tool currently struggles with multiplications involving constants (which often use bit-shifting optimizations).
  • Future Directions: The authors plan to extend the tool to support Booth multipliers and integrate "proof generation" so that the added tautologies can be formally verified by the solver's internal logic.

Summary updated

Abstract

Bit-vector formulas arising from hardware verification problems often contain word-level arithmetic operations. Empirical evidence shows that state-of-the-art SMT solvers are not very efficient at reasoning about bit-vector formulas with multiplication. This is particularly true when multiplication operators are decomposed and represented in alternative ways in the formula. We present a pre-processing heuristic that identifies certain types of decomposed multipliers, and adds special assertions to the input formula that encode the equivalence of sub-terms and word-level multiplication terms. The pre-processed formulas are then solved using an SMT solver. Our experiments with three SMT solvers show that our heuristic allows several formulas to be solved quickly, while the same formulas time out without the pre-processing step.
BibTeX
@inproceedings{chakraborty2017matching,
  author = {Supratik Chakraborty and Ashutosh Gupta and Rahul Jain},
  title = {{Matching Multiplications in Bit-Vector Formulas}},
  booktitle = {VMCAI},
  year = {2017},
  url = {https://openreview.net/forum?id=22AoFy7nNvv},
}

Loading related content...

Figure