OSTRICH2: Solver for Complex String Constraints

Matthew Hague, Denghang Hu, Artur Jez, Anthony W. Lin, Oliver Markgraf, Philipp Rümmer, Zhilin Wu · DOI

Introduction

Strings serve as the fundamental data structure for modern software, particularly within web-centric ecosystems powered by JavaScript and Python. However, the ubiquity of strings is matched by the complexity of verifying string-heavy code. Security vulnerabilities, such as Cross-Site Scripting (XSS), frequently reside within intricate string transformations—for instance, the recursive replacement of special characters or the application of complex regular expressions.

Traditional Satisfiability Modulo Theories (SMT) solvers often struggle with the "messy" reality of these operations. While basic concatenation is well-supported, modern features like ECMAScript-style regular expressions (including look-around assertions and greedy/lazy quantifiers), global replacements (replace_all), and user-defined transducers remain significant bottlenecks. OSTRICH2 addresses these challenges through a unified, extensible framework designed to provide state-of-the-art performance and completeness guarantees for complex string logic.

Methodology: The Portfolio Architecture

OSTRICH2 is built upon the Princess SMT solver and utilizes a sophisticated portfolio-based architecture. Rather than relying on a single monolithic algorithm, OSTRICH2 orchestrates three distinct solving engines in a time-sliced configuration. This approach allows the solver to leverage the unique strengths of different theoretical frameworks to cover the "blind spots" of any individual method.

The Three Engines of OSTRICH2

  1. ADT-Str (Algebraic Data Types): This engine treats strings as lists using nil and cons constructors. By modeling strings as algebraic data types, it excels at reasoning about operations involving integer offsets, such as substring or indexof. These operations are traditionally difficult for automata-based solvers but are handled naturally within a list-based framework.
  2. RCP (Regular Constraint Propagation): Serving as the core engine for regular expression handling, RCP propagates constraints both forward and backward through string functions. A key innovation here is the use of prioritized finite-state transducers. These transducers correctly model the specific "greedy" versus "lazy" matching behaviors required by the ECMAScript standard, ensuring the solver's behavior matches real-world JavaScript engines.
  3. CE-Str (Cost-Enriched String Engine): This engine utilizes Cost-Enriched Finite Automata (CEFAs). These automata track numerical "costs"—such as string length or specific character counts—directly within their transitions. This integration allows OSTRICH2 to reason about length constraints and regex membership simultaneously, a common requirement in complex verification tasks.

Before these engines engage, OSTRICH2 employs a robust preprocessing layer. This layer simplifies constraints, infers length bounds, and rewrites complex functions into simpler equational forms, significantly reducing the workload for the downstream engines.

Experimental Evaluation

The authors evaluated OSTRICH2 using a representative sample of 2,000 instances from the SMT-LIB 2025 benchmark release, drawn from the QF_S (pure strings) and QF_SLIA (strings with linear integer arithmetic) tracks. The solver was compared against leading competitors, including cvc5, Z3, Z3-alpha, and Z3-Noodler.

Key Results

  • Overall Performance: OSTRICH2 solved 1,905 out of 2,000 benchmarks. This performance places it in the top tier of modern solvers, narrowly trailing Z3-Noodler (1,945) while outperforming standard Z3 and cvc5.
  • Unsatisfiability Champion: OSTRICH2 proved exceptionally strong at identifying UNSAT (unsatisfiable) instances. It solved 758 UNSAT problems, outperforming most competitors in this category and demonstrating its utility for formal verification where proving the absence of a solution is critical.
  • The replace_all Edge: The solver's unique strength lies in global string transformations. In a specialized subset of 35 benchmarks involving the replace_all operator, OSTRICH2 solved 25 instances. In contrast, cvc5 and Z3 solved only 2, and Z3-Noodler solved 0. This highlights OSTRICH2 as the premier tool for reasoning about global replacements.
  • Efficiency: The portfolio approach, combined with improved preprocessing and new proof rules, resulted in significant speedups compared to the original OSTRICH tool.

Insights and Future Work

The success of OSTRICH2 underscores the value of algorithmic diversity. By combining list-based reasoning, prioritized transducers, and cost-aware automata, the solver achieves a level of robustness that single-engine solvers lack. Furthermore, the introduction of the PreOp trait makes the solver highly extensible, allowing researchers to add support for new functions (like str.reverse) by simply defining their pre-image and post-image behaviors.

Despite these gains, challenges remain. The solver's reliance on heuristics means it may still struggle with certain search space explorations. Additionally, while regex back-references are supported in replacement strings, they are not yet supported within matching patterns. Future research will focus on more aggressive information sharing between the portfolio engines, such as the exchange of learned clauses, to further enhance solving efficiency.

Summary updated

BibTeX
@inproceedings{hague2025ostrich,
  author = {Matthew Hague and Denghang Hu and Artur Jez and Anthony W. Lin and Oliver Markgraf and Philipp Rümmer and Zhilin Wu},
  title = {{OSTRICH2: Solver for Complex String Constraints}},
  booktitle = {FMCAD},
  year = {2025},
  doi = {10.34727/2025/isbn.978-3-85448-084-6\_21},
}
Figure