SMT-LIB Sequences and Regular Expressions

Nikolaj S. Bjørner, Vijay Ganesh, Raphaël Michel, Margus Veanes

Abstract

This paper proposes a standardized SMT-LIB format for reasoning about sequences and regular expressions, aiming to unify the fragmented landscape of string solvers. By introducing the Seq and RegEx theories, the authors provide a common language that allows verification and security tools to swap and compare different solving engines seamlessly.

Introduction: The Babel of String Solvers

Strings are the backbone of modern software, especially in web applications where improper string manipulation leads to critical security vulnerabilities like Cross-Site Scripting (XSS) or SQL injection. To mitigate these risks, researchers have developed specialized "string solvers"—tools designed to determine the satisfiability of string constraints. However, the field currently suffers from a "Babel" problem: solvers like Hampi, Kaluza, and JSA utilize disparate syntaxes and underlying semantics. This incompatibility hinders the ability of developers to switch solvers or for researchers to conduct standardized benchmarks. This paper addresses this by proposing an "SMT-LIBization" of strings—a standardized interchange format for sequences and regular expressions.

Proposed Theories: Seq and RegEx

The authors propose two primary theories and a specific logic fragment to provide a unified framework:

  1. Theory Seq (Sequences): Rather than focusing solely on strings, the authors define a general theory of sequences over an arbitrary alphabet. This includes core operations such as seq-concat, seq-extract, and seq-length.
  2. Theory RegEx (Regular Expressions): Built upon the sequence theory, this includes standard operations like Kleene star, union, and intersection. It also introduces "symbolic" features like re-of-pred, allowing regexes to match characters based on predicates (e.g., "any bit-vector less than 10") rather than explicit enumeration.
  3. Logic QF_BVRE: A practical subset (Quantifier-Free Bit-Vector Regular Expressions) that restricts the alphabet to bit-vectors and constrains string length usage to ensure decidability.

Comparative Expressivity

A central goal of the proposal is to ensure that the new standard can capture the functionality of existing tools. The authors provide a feature matrix comparing the expressivity of major string solvers.

Table 1: Feature comparison of major string solvers against the proposed SMT-LIB operations.

As shown in the table, the proposed format is expressive enough to encompass the diverse features of tools like JSA, Hampi, and Kudzu/Kaluza, while also supporting the advanced symbolic capabilities of the Symbolic Automata/Rex framework.

Key Insights and Design Choices

  • Generality via Sequences: Treating strings as sequences of an arbitrary sort A allows the theory to reason about logs, network packets, or any ordered data, extending its utility beyond simple text processing.
  • Symbolic Character Classes: Traditional regexes struggle with large alphabets like Unicode. By using re-range and re-of-pred, solvers can reason about character ranges mathematically, offering significant performance gains.
  • Desugaring Anchors: The authors argue that anchors like ^ and $ should be handled via a mathematical complete function rather than being part of the core theory, as they are context-dependent.
  • Decidability Trade-offs: Certain operations, such as seq-prefix-of, are excluded from the QF_BVRE logic to maintain a balance between user requirements and computational feasibility.

Conclusion and Future Work

The paper establishes the first comprehensive signature for an SMT-LIB string theory. While the current prototype implementation using Z3 and the Symbolic Automata Toolkit has some efficiency gaps—particularly in mapping sequences to Z3's "List" sort—it demonstrates the feasibility of the approach. Future work will focus on tighter integration of string literals and broader adoption within the SMT community to finalize the standard.

Summary updated

BibTeX
@inproceedings{bjrner2012smt,
  author = {Nikolaj S. Bjørner and Vijay Ganesh and Raphaël Michel and Margus Veanes},
  title = {{SMT-LIB Sequences and Regular Expressions}},
  booktitle = {SMT@IJCAR},
  year = {2012},
  doi = {10.29007/w5m5},
}
Figure