Abstract
Algebraic Data Types (ADTs) are fundamental to modern programming languages, yet reasoning about them in Satisfiability Modulo Theories (SMT) solvers remains a challenge. Traditional solvers employ "lazy" approaches that often struggle with complex inductive constraints. This paper introduces Algaroba, an eager SMT solver that reduces quantifier-free ADT formulas to Uninterpreted Functions (UF). By leveraging a novel bounded acyclicality proof, Algaroba achieves significant performance gains on complex benchmarks, particularly in the AI planning domain.
Introduction
Algebraic Data Types (ADTs), including lists, trees, and sum types, are ubiquitous in functional and modern imperative languages like Rust and Python. Verifying software that utilizes these types requires efficient SMT solvers. However, dominant solvers like Z3 and CVC5 typically treat ADTs using a "lazy" theory-solving approach. In this paradigm, the solver handles core propositional logic first and checks ADT-specific constraints—such as acyclicality—only as needed. This can lead to inefficient search patterns and scaling bottlenecks.
While "eager" approaches (translating higher-level theories into simpler ones upfront) have revolutionized bit-vector solving, they have seen limited application in ADTs. We present Algaroba, a prototype solver that demonstrates the viability and superiority of an eager reduction for complex ADT queries.
Methodology: Theory Reduction to UF
Algaroba transforms quantifier-free ADT formulas into equi-satisfiable formulas using only Uninterpreted Functions (UF). This reduction allows the solver to benefit from highly optimized UF engines. The transformation involves three primary steps:
- Flattening: The input formula is simplified such that every term is either a variable or a single function application.
- Axiom Instantiation: Rather than relying on expensive universal quantifiers, Algaroba instantiates specific ADT axioms (e.g., tester properties and selector behaviors) only for terms relevant to the specific query.
- Bounded Acyclicality: A critical challenge in ADT reasoning is ensuring that no term is a "child" of itself. We prove that for a query containing $k$ variables, enforcing acyclicality up to depth $k$ is sufficient to guarantee correctness. This bound allows for the generation of a finite set of constraints, preventing infinite loops in the solver.
Algaroba is implemented in OCaml, utilizing the Z3 API as its underlying engine for the reduced UF formulas.
Benchmarks and Evaluation
We evaluated Algaroba against three distinct benchmark sets:
- Barrett et al. (2007): A standard suite where most modern solvers perform well.
- Bouvier (2021): A challenging set focused on sum types (enumerations).
- Blocks World: A new benchmark introduced in this work based on classic AI planning. These queries involve complex interactions between sum, product, and inductive types (e.g., recursive stacks of blocks).
Key Results
Algaroba demonstrates superior performance on the most difficult benchmarks. In the Blocks World set, it solved 61.4% of queries, outperforming Z3 (56.2%) and achieving a 2.0x speedup on successful queries. In the Bouvier set, Algaroba solved 8.5% more queries than the next best solver, with a 2.3x average speedup.
A key metric of success is "contribution rank"—the ability to solve queries that no other solver can. Algaroba solved a significant portion of the Blocks World and Bouvier sets that remained "stumpers" for both CVC5 and Z3. Furthermore, Algaroba exhibited lower standard deviation in solve times, suggesting more predictable performance on hard problems compared to solvers like Princess.
Conclusion and Future Work
The eager approach implemented in Algaroba proves that reducing ADTs to UF is not only feasible but highly effective for complex, inductive queries. By bounding acyclicality based on query depth, we avoid the pitfalls of infinite recursion while leveraging optimized UF solvers.
Future work will focus on:
- Proof Generation: Enabling the solver to produce certificates for unsatisfiable formulas.
- Quantifier Support: Extending the eager reduction to handle quantified formulas.
- Hybrid Strategies: Developing heuristics to automatically switch between eager and lazy strategies based on input characteristics.
While theoretical risks of exponential blowup exist for deeply nested recursive types, our empirical results suggest that for practical software verification and planning tasks, the eager approach offers a significant step forward in SMT solving capabilities.
Summary updated