TL;DR
This paper introduces a native SMT (Satisfiability Modulo Theories) theory of sequences to efficiently reason about dynamic arrays (vectors) in software verification. By combining string-based concatenation reasoning with array-based "weak equivalence" techniques, the authors implemented a solver in cvc5 that significantly outperforms existing methods and solvers like Z3 on real-world verification tasks.
What Problem Does This Paper Address?
In software verification, reasoning about dynamic arrays—commonly called vectors (e.g., std::vector in C++)—is a major hurdle. The traditional Theory of Arrays used by SMT solvers assumes arrays have a fixed size determined by their index type.
To model dynamic vectors using standard arrays, researchers usually have to add extra variables for length and use complex quantifiers to describe operations like resizing or concatenation. This approach is brittle: quantifiers often lead to solver timeouts or "unknown" results, making automated verification tools less reliable. The authors sought a "cleaner" way to represent vectors that natively supports variable lengths and common operations (like update, nth, and concat) without relying on heavy axiomatization.
Methods
The authors propose a formal Theory of Sequences ($T_{Seq}$). Its signature includes standard operations like length ($|s|$), element access ($nth$), update, extraction, and concatenation.
The core contribution lies in two distinct SMT-based calculi:
- BASE Calculus: This adapts techniques from string solvers. It reduces complex operations like
nthandupdateinto equations involving concatenation. While sound, this can be computationally expensive because concatenation reasoning is notoriously difficult for solvers. - EXT (Extended) Calculus: This is the paper's primary innovation. It integrates reasoning methods from array solvers—specifically the "weak-equivalence" approach—directly into the sequence solver. This allows the solver to reason about
nthandupdateterms directly, avoiding the overhead of reducing them to concatenations whenever possible.
The authors implemented these calculi in the cvc5 SMT solver, creating two versions: cvc5 (base) and cvc5-a (extended).
Datasets
The authors evaluated their implementation using two primary benchmark sets:
- ARRAYS: 551 benchmarks derived from the standard SMT-LIB
QF_AX(Quantifier-Free Arrays with Extensionality) suite. These were modified to replace fixed-size arrays with sequences and handle out-of-bounds cases. - DIEM: 558 verification conditions generated by the Move Prover, a tool used to verify smart contracts for the Diem blockchain framework. These benchmarks are representative of real-world software verification tasks and involve heavy use of vectors.
Key Insights and Ideas
- Sequences > Arrays for Vectors: Sequences provide a more natural abstraction for modern programming constructs than fixed-size arrays. They natively handle the "length" property, which is often central to safety properties (like bounds checking).
- Hybrid Reasoning is Key: The "aha moment" is that you don't have to choose between string-style and array-style reasoning. By using array-style "read-over-write" logic for atomic sequence segments and string-style concatenation logic for combining them, you get the best of both worlds: expressivity and performance.
- Handling the "Out-of-Bounds" Gap: Unlike standard arrays, sequence operations have specific behaviors when indices are out of bounds (e.g., returning an empty sequence or a default value). Natively modeling these cases in the theory simplifies the work for front-end verification tools.
Key Results
The evaluation showed that the extended calculus (cvc5-a) is a clear winner:
- Solving Power: On the
ARRAYSset,cvc5-asolved 390 benchmarks, compared to 242 for the base version and only 170 for Z3. - Real-World Efficacy: On the
DIEMsmart contract benchmarks,cvc5-asolved 547 out of 558 instances, outperforming Z3's 443. - Speedup: For harder problems, the extended solver showed significant gains. On instances solved by both cvc5 versions, the extended version was approximately 2.47x faster (426s vs 1053s total time).
Limitations and Future Work
- Decidability: The authors note that the decidability of the full theory of sequences remains an open question in the field. Their procedure is sound (it won't give wrong answers) but not a complete decision procedure (it might not terminate).
- Theory Combination: While the theory works well for "sequences of elements," more work is needed to study its "politeness"—a technical property required for combining it seamlessly with other arbitrary theories in an SMT solver.
- Performance Tuning: While
cvc5-ais faster on hard problems, the authors noted it can be slightly slower on very easy problems due to the overhead of the extra "machinery." Future work will focus on optimizing these heuristics.
Summary updated