Introduction
String constraints—logical formulas involving regular expression matching and string equality—are foundational to software verification, web security, and cloud access control. Solving these constraints is computationally intensive. Modern Satisfiability Modulo Theories (SMT) solvers typically adopt a "lazy" approach, treating strings as an opaque theory. While flexible, lazy solvers often struggle with complex regular expression overlaps.
In contrast, "eager" approaches translate string constraints directly into propositional logic (SAT). Historically, eager solvers have been hampered by the massive size of string alphabets (e.g., Unicode) and the unknown length bounds of satisfying strings. This paper introduces nfa2sat, a new eager solver that overcomes these challenges through clever alphabet reduction and incremental solving.
The nfa2sat Architecture
The nfa2sat solver employs a multi-stage pipeline to transform high-level string constraints into efficient SAT instances.
Key Methodological Innovations
- Boolean Abstraction: The solver first abstracts the input formula $\psi$ into a purely boolean structure $\psi_{\mathcal{A}}$, replacing string predicates with boolean variables. This allows the SAT solver to reason about the logical structure independently of the string theory.
- Alphabet Reduction: A critical optimization is the reduction of the character alphabet. The authors prove that solving a formula only requires the characters explicitly mentioned in the constraints plus one unique "extra" character per variable. This reduces the search space from thousands of Unicode characters to a manageable handful.
- Incremental Encoding and Bound Refinement: Rather than guessing a maximum string length,
nfa2satstarts with minimal length bounds. It encodes the problem into SAT; if unsatisfiable, it uses Unsatisfiable-Core Analysis to identify which specific variables must have their length bounds increased, rather than blindly incrementing all variables. - NFA-to-SAT Translation: Regular expressions are converted into Nondeterministic Finite Automata (NFAs) and "bit-blasted" into SAT clauses representing state transitions.
Experimental Evaluation
The authors evaluated nfa2sat using the ZaligVinder repository, focusing on a subset of 29,599 unique problems involving regular membership and equality constraints.
Performance Results
- Standalone Efficiency:
nfa2satsolved 29,327 problems, outperforming the state-of-the-art solver cvc5 (29,154) and performing competitively with Z3 (29,413). It was particularly fast on satisfiable instances, often finding solutions in milliseconds. - The Portfolio Effect: The most significant result came from combining
nfa2sat(eager) with Z3 (lazy) in a portfolio. This hybrid approach reduced total solve time from approximately 79 hours (Z3 alone) to just 8 hours—a 90% reduction. This demonstrates that eager and lazy solvers are highly complementary: eager solvers excel at finding SAT instances, while lazy solvers are better at proving UNSAT.
Discussion and Limitations
The success of nfa2sat demonstrates that bit-blasting strings is a viable strategy when combined with effective abstraction and reduction techniques. By representing strings as "filled positions" (using a special $\lambda$ symbol for empty space), string reasoning is reduced to hardware-level logic optimized for modern SAT solvers.
However, the current implementation has limitations. It does not yet support string concatenation in equations (e.g., $x = y \cdot z$), which is common in general software bug-finding. Additionally, as an eager solver, it can be memory-intensive, leading to timeouts or memory exhaustion on a small number of complex instances.
Conclusion
nfa2sat represents a significant step forward for eager string solving. By integrating alphabet reduction with incremental SAT solving and unsat-core analysis, it provides a powerful tool for industrial applications like AWS security policy checking. Future work will focus on extending the solver to handle word equations and exploring parallel solving strategies to further improve performance.
Summary updated