[Paper Review] Regular Expressions with Backreferences and Lookaheads Capture NLOG
This paper establishes that regular expressions with backreferences and lookaheads (REWBLk) capture exactly the complexity class NLOG—the set of languages recognizable by log-space nondeterministic Turing machines. The authors achieve this by constructing a translation from REWBLk to log-space NTMs using the Immerman–Szelepcsényi theorem for complementation and log-space nested-oracle machines to handle nested lookaheads, proving the membership problem for REWBLk is PSPACE-complete.
Backreferences and lookaheads are vital features to make classical regular expressions (REGEX) practical. Although these features have been widely used, understanding of the unrestricted combination of them has been limited. Practically, most likely, no implementation fully supports them. Theoretically, while some studies have addressed these features separately, few have dared to combine them. Those few studies showed that the amalgamation of these features significantly enhances the expressiveness of REGEX. However, no acceptable expressivity bound for REWBLk - REGEX with backreferences and lookaheads - has been established. We elucidate this by establishing that REWBLk coincides with NLOG, the class of languages accepted by log-space nondeterministic Turing machines (NTMs). In translating REWBLk to log-space NTMs, negative lookaheads are the most challenging part since it essentially requires complementing log-space NTMs in nondeterministic log-space. To address this problem, we revisit Immerman-Szelepcsényi theorem. In addition, we employ log-space nested-oracles NTMs to naturally handle nested lookaheads of REWBLk. Utilizing such oracle machines, we also present the new result that the membership problem of REWBLk is PSPACE-complete.
Motivation & Objective
- To determine the expressive power of regular expressions extended with backreferences and lookaheads (REWBLk).
- To resolve the open question of which known complexity class REWBLk corresponds to.
- To establish the computational complexity of the membership problem for REWBLk.
- To develop a formal translation mechanism from REWBLk to log-space nondeterministic Turing machines (NTMs).
Proposed method
- Translating REWBLk expressions into log-space nondeterministic Turing machines (NTMs) using a modified McNaughton–Yamada–Thompson construction for the regex core.
- Applying variable renaming (alpha-conversion-like transformation) to eliminate nested variable captures and simplify backreference handling.
- Using special working tapes to store and compare backreference values (captured substrings) in binary form during execution.
- Introducing log-space nested-oracle NTMs to handle nested lookaheads, where oracles simulate lookahead conditions.
- Employing the Immerman–Szelepcsényi theorem to complement log-space NTMs, enabling correct handling of negative lookaheads (!(E)) by simulating non-acceptance.
- Constructing a unique source and sink state in the machine to ensure full input consumption, aligning with regex semantics.
Experimental results
Research questions
- RQ1What is the expressive power of regular expressions augmented with both backreferences and lookaheads (REWBLk)?
- RQ2Is the class REWBLk equal to any known complexity class in computational theory?
- RQ3What is the computational complexity of the membership problem for REWBLk?
- RQ4Can negative lookaheads be correctly emulated in log-space NTMs, given that they require complementing nondeterministic log-space machines?
Key findings
- REWBLk is exactly equal to NLOG—the class of languages recognized by log-space nondeterministic Turing machines.
- The membership problem for REWBLk is PSPACE-complete, establishing its computational hardness.
- The paper provides a formal translation from any REWBLk expression to a log-space NTM, proving the equivalence with NLOG.
- The Immerman–Szelepcsényi theorem is applied to handle negative lookaheads by enabling complementation of log-space NTMs.
- Nested lookaheads are handled via log-space nested-oracle NTMs, which support recursive oracle queries in logarithmic space.
- An NLOG-complete language is shown to be expressible within REWB (without lookaheads), confirming the expressiveness of the core extension.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.