String Constraints for Verification

Parosh Aziz Abdulla, Mohamed Faouzi Atig, Yu-Fang Chen, Lukás Holík, Ahmed Rezine, Philipp Rümmer, Jari StenmanCAV 2014

Introduction

Strings are ubiquitous in modern software, particularly in web applications and database interfaces. However, verifying that programs handle strings correctly is a notoriously difficult challenge in formal methods. A robust string solver must simultaneously reason about three distinct but interacting domains: word equations (e.g., string concatenations), length constraints (e.g., minimum character counts), and regular language membership (e.g., regex pattern matching).

Combining these elements often leads to undecidability, and many existing tools resort to "bit-blasting" or assuming a maximum string length, which compromises soundness. This paper introduces a new decision procedure and a tool called NORN designed to handle these complex constraints over strings of arbitrary length, enabling the verification of programs previously beyond the reach of automated tools.

The $\mathcal{E}_{e,r,l}$ Logic

The core of this research is the development of a logic named $\mathcal{E}_{e,r,l}$. This logic provides a formal framework for expressing the complex interactions between string content and numerical properties.

Syntax of the string logic $\mathcal{E}_{e,r,l}$, encompassing word equations, length constraints, and regular expressions.

As shown in the syntax above, the logic allows for the construction of formulae involving (dis)equalities, arithmetic inequalities on string lengths, and membership predicates for regular expressions. By integrating these into a single grammar, the authors can propagate facts across different logical domains—for instance, recognizing that a word equation $u = v \cdot w$ implies a specific length relationship $|u| = |v| + |w|$.

Methodology and Tooling

The authors propose a decision procedure based on several key innovations:

  • Inference Rules: A systematic set of rules simplifies complex constraints. This includes "symbolic matching" to explore potential solutions for word equations.
  • The Acyclic Fragment: To ensure the solver terminates, the authors identified an "acyclic" fragment of the logic. They proved that for any formula within this fragment, the procedure is guaranteed to reach a correct conclusion.
  • NORN and Eldarica: The logic is implemented in the NORN tool. To handle program verification, NORN is integrated into the Eldarica model checker using Horn Clauses.
  • Constraint-based Craig Interpolation: A novel interpolation technique allows the tool to automatically "learn" string invariants. This automation is crucial, as it removes the need for human experts to manually provide regular language properties to prove a program's correctness.

Evaluation and Results

The effectiveness of NORN was evaluated against a suite of challenging string-processing benchmarks, including classic non-regular language tests ($a^n b^n$), string replacement functions, and standard algorithms like Levenshtein and Hamming distance. These benchmarks are specifically designed to test the interaction between loops, string length, and content.

Key results from the evaluation include:

  • Capability: NORN successfully verified functional correctness for programs that were previously considered beyond the scope of state-of-the-art software model checkers.
  • Performance: Verification runtimes were efficient, ranging from approximately 4.5 seconds for StringReplace to 27.1 seconds for the more complex HammingDistance algorithm.
  • Soundness: By reasoning about strings of arbitrary length rather than using bounded approximations, the tool provides valid results for any possible input.

Conclusion and Future Work

While the general problem of combining all three types of string constraints remains undecidable, this work provides a powerful, sound approach for the acyclic fragment. NORN demonstrates that integrating word equations, length, and regex membership into a unified solver is not only possible but highly effective for verifying real-world string-heavy logic. Future work will focus on optimizing the prototype for industrial-scale codebases and exploring the integration of string theory with other data types, such as floating-point numbers or complex heap structures.

Summary updated

BibTeX
@inproceedings{abdulla2014string,
  author = {Parosh Aziz Abdulla and Mohamed Faouzi Atig and Yu-Fang Chen and Lukás Holík and Ahmed Rezine and Philipp Rümmer and Jari Stenman},
  title = {{String Constraints for Verification}},
  booktitle = {CAV},
  year = {2014},
  doi = {10.1007/978-3-319-08867-9\_10},
}
Figure