Solving String Constraints With Regex-Dependent Functions Through Transducers With Priorities And Variables

11/08/2021
by   Taolue Chen, et al.
0

Regular expressions are a classical concept in formal language theory. Regular expressions in programming languages (RegEx) such as JavaScript, feature non-standard semantics of operators (e.g. greedy/lazy Kleene star), as well as additional features such as capturing groups and references. While symbolic execution of programs containing RegExes appeals to string solvers natively supporting important features of RegEx, such a string solver is hitherto missing. In this paper, we propose the first string theory and string solver that natively provide such a support. The key idea of our string solver is to introduce a new automata model, called prioritized streaming string transducers (PSST), to formalize the semantics of RegEx-dependent string functions. PSSTs combine priorities, which have previously been introduced in prioritized finite-state automata to capture greedy/lazy semantics, with string variables as in streaming string transducers to model capturing groups. We validate the consistency of the formal semantics with the actual JavaScript semantics by extensive experiments. Furthermore, to solve the string constraints, we show that PSSTs enjoy nice closure and algorithmic properties, in particular, the regularity-preserving property (i.e., pre-images of regular constraints under PSSTs are regular), and introduce a sound sequent calculus that exploits these properties and performs propagation of regular constraints by means of taking post-images or pre-images. Although the satisfiability of the string constraint language is undecidable, we show that our approach is complete for the so-called straight-line fragment. We evaluate the performance of our string solver on over 195000 string constraints generated from an open-source RegEx library. The experimental results show the efficacy of our approach, drastically improving the existing methods in both precision and efficiency.

READ FULL TEXT
research
11/09/2017

What Is Decidable about String Constraints with the ReplaceAll Function

Recently, it was shown that any theory of strings containing the string-...
research
10/10/2018

Sound Regular Expression Semantics for Dynamic Symbolic Execution of JavaScript

Existing support for regular expressions in automated test generation or...
research
12/11/2021

CertiStr: A Certified String Solver (technical report)

Theories over strings are among the most heavily researched logical theo...
research
08/03/2020

Implicit automata in typed λ-calculi II: streaming transducers vs categorical semantics

We characterize regular string transductions as programs in a linear λ-c...
research
11/07/2018

Decision Procedures for Path Feasibility of String-Manipulating Programs with Complex Operations

The design and implementation of decision procedures for checking path f...
research
06/04/2020

Twinning automata and regular expressions for string static analysis

In this paper we formalize and prove the soundness of Tarsis, a new abst...
research
12/05/2022

Word Equations in Synergy with Regular Constraints (Technical Report)

When eating spaghetti, one should have the sauce and noodles mixed inste...

Please sign up or login with your details

Forgot password? Click here to reset