Smt-Switch: A Solver-Agnostic C++ API for SMT Solving

Makai Mann, Amalee Wilson, Yoni Zohar, Lindsey Stuntz, Ahmed Irfan, Kristopher Brown, Caleb Donovick, Allison Guman, Cesare Tinelli, Clark W. Barrett · DOI

Abstract

Smt-Switch is a lightweight, open-source C++ API that provides a uniform interface for interacting with multiple Satisfiability Modulo Theories (SMT) solvers. By offering a native C++ library, it allows developers to write solver-agnostic code for high-performance applications like formal verification and automated reasoning, avoiding the performance overhead of interpreted languages or the "lock-in" associated with solver-specific APIs. This paper describes the architecture, design choices, and current capabilities of Smt-Switch.

Introduction

SMT solvers are the "workhorses" behind modern software verification, planning, and formal methods. However, integrating them into high-performance tools often presents a difficult choice for developers. One must either commit to a single solver's specific API (solver lock-in), use the slow textual SMT-LIB interface, or rely on higher-level Python wrappers like PySMT which may introduce unacceptable overhead for performance-critical engines. Smt-Switch fills this gap by providing a native C++ API that is fast, memory-efficient, and completely agnostic to the underlying solver.

Architecture and Methods

The authors designed Smt-Switch as a "thin" wrapper around the native C/C++ APIs of various SMT solvers. Its architecture relies on three primary abstract classes: AbsSort (representing data types), AbsTerm (representing expressions), and AbsSmtSolver (the main interface for asserting formulas and checking satisfiability).

The high-level architecture of Smt-Switch, illustrating the abstraction layer over specific solver backends like Boolector, CVC4, MathSAT, and Yices2.

Key technical choices include the use of smart pointers for dynamic backend logic dispatch and a higher-order logic perspective where uninterpreted functions are treated as terms. To handle solvers that perform "on-the-fly" rewriting, Smt-Switch includes an optional LoggingSolver layer that maintains a term Directed Acyclic Graph (DAG) at the API level, ensuring users can track expressions exactly as they were created.

Key Insights and Design Principles

Smt-Switch prioritizes intentional minimalism, delegating error checking to the underlying solvers to keep the memory footprint low. It also enforces explicit transfer of terms between different solver instances to prevent subtle memory bugs. The API's internal enums map one-to-one with SMT-LIB operators, providing an intuitive experience for researchers familiar with the standard.

Results and Capabilities

At present, Smt-Switch supports four major backends: Boolector, CVC4, MathSAT, and Yices2. It provides broad theory coverage, including quantifier-free formulas over booleans, bit-vectors, integers, reals, arrays, and uninterpreted functions. While optimized for C++11, the library includes Python bindings generated via Cython, facilitating rapid prototyping. Its modular build system allows users to link only the necessary solver backends, maintaining a lean binary.

Conclusion and Future Work

As an evolving project, future work for Smt-Switch includes expanding theory support to include quantifiers and inductive datatypes, adding a backend for the Z3 solver, and further optimizing internal data structures. Advanced features such as bit-blasting and portfolio solving are also on the roadmap.

Summary updated

BibTeX
@inproceedings{mann2021smt,
  author = {Makai Mann and Amalee Wilson and Yoni Zohar and Lindsey Stuntz and Ahmed Irfan and Kristopher Brown and Caleb Donovick and Allison Guman and Cesare Tinelli and Clark W. Barrett},
  title = {{Smt-Switch: A Solver-Agnostic C++ API for SMT Solving}},
  booktitle = {SAT},
  year = {2021},
  doi = {10.1007/978-3-030-80223-3\_26},
}
Figure