An Eager Satisfiability Modulo Theories Solver for Algebraic Datatypes

Amar Shah, Federico Mora, Sanjit A. Seshia

Introduction

Algebraic Datatypes (ADTs), such as lists, trees, and stacks, are fundamental to modern programming languages like Rust, Swift, and Python. As these types become ubiquitous, the need for efficient Satisfiability Modulo Theories (SMT) solvers capable of reasoning about them has grown. Researchers from UC Berkeley have introduced Algaroba, a novel SMT solver that employs an "eager" reduction strategy. By transforming complex ADT queries into simpler logical problems, Algaroba demonstrates significant performance gains over established solvers like Z3 and cvc5, particularly on benchmarks involving deep inductive structures.

The Challenge of ADTs in SMT

Traditional SMT solvers typically handle ADTs using a "lazy" approach. In this paradigm, the solver reasons about the core logic first and only invokes ADT-specific constraints (such as acyclicality or constructor-selector consistency) on an as-needed basis. While this has been the standard since the 1980s, it often fails to scale with the complexity of modern software verification tasks. As queries grow, the overhead of checking these constraints iteratively becomes a bottleneck.

The Algaroba Method: Eager Reduction

Algaroba departs from the lazy tradition by using an eager reduction strategy. Instead of checking constraints during the search process, it translates the entire ADT query upfront into an equi-satisfiable formula using Uninterpreted Functions (UF)—a much simpler and more mature logical theory.

The primary technical hurdle in eager reduction for ADTs is enforcing acyclicality—the property that a data structure cannot contain itself as a descendant. A naive translation could lead to infinite definitions. The authors' key innovation is a proof showing that for any query with $k$ variables, acyclicality only needs to be enforced up to a depth of $k$. This allows Algaroba to generate a finite set of constraints that fully capture the ADT's properties without falling into an infinite loop.

Experimental Evaluation

The authors evaluated Algaroba against three major benchmarks: the standard BST set, the more recent Bouvier set (focusing on sum types), and a newly introduced Blocks World benchmark.

A sequence of moves in the Blocks World benchmark, illustrating reasoning over inductive stacks.

The Blocks World benchmark is particularly significant as it models classic AI planning problems using inductive types (recursive stacks of blocks). This set was designed to challenge the inductive reasoning capabilities of existing lazy solvers, which often struggle with the recursive depth of such problems.

Results and Impact

Algaroba's performance highlights the advantages of the eager approach:

  • Bouvier Benchmark: Algaroba solved 45.75% of queries, significantly outperforming Z3 and cvc5 (~37%). On successful queries, it was 2.3x faster on average than its closest competitor.
  • Blocks World: Algaroba solved 61.4% of queries. Notably, it outperformed the "Virtual Best Solver" (a composite of all other solvers), indicating it can solve "hard" problems that lazy architectures find fundamentally difficult.
  • Contribution Rank: In SMT competitions, the "Contribution Rank" measures a solver's ability to solve unique, difficult problems. Algaroba excels here, tackling many queries that timed out for other state-of-the-art tools.

Conclusion and Future Work

Algaroba demonstrates that eager reduction is a viable and often superior alternative for ADT reasoning. While currently a powerful prototype for quantifier-free logic, future development aims to support universal quantifiers and automated proof generation. The authors also suggest that hybrid systems, combining eager and lazy techniques, may represent the next frontier in SMT solver design.

Summary updated

BibTeX
@inproceedings{shah2024eager,
  author = {Amar Shah and Federico Mora and Sanjit A. Seshia},
  title = {{An Eager Satisfiability Modulo Theories Solver for Algebraic Datatypes}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2024},
  doi = {10.1609/aaai.v38i8.28649},
}
Figure