Relative Expressiveness of Nested Regular Expressions

Pablo Barceló, Jorge Pérez, Juan L. ReutterAMW 2012

As graph-structured data—ranging from social networks to the Semantic Web and bioinformatics—scales toward terabyte levels, the demand for query languages that balance expressive power with computational efficiency has never been higher. This paper investigates the landscape of graph query languages, specifically focusing on Nested Regular Expressions (NREs). The authors demonstrate that NREs occupy a unique "sweet spot," offering significant expressive capabilities while maintaining linear-time evaluation.

The Challenge of Graph Queries

The traditional "gold standard" for querying graphs is the class of Conjunctive Two-way Regular Path Queries (C2RPQs). These allow users to define complex patterns and paths across a graph. However, C2RPQs come with a significant computational cost: their evaluation is NP-complete. While simpler "acyclic" versions of these queries exist and can be evaluated in linear time, they are often too restrictive for real-world applications.

Mapping the Expressive Power of NREs

The researchers utilized formal language theory and complexity analysis to compare NREs against C2RPQs. Their findings reveal that the two languages are technically incomparable. There are patterns one can express that the other cannot, and vice versa.

The "Memoryless" Limitation

One of the key insights is that NREs are essentially "memoryless." They lack the ability to "remember" a previously visited node to check if a path has returned to it later, effectively forming a cycle. This limitation means that NREs cannot express certain cyclic C2RPQs.

A simple cyclic graph. NREs struggle with such structures because they cannot 'remember' nodes to detect cycles.

The Power of Nesting

Conversely, NREs possess a unique strength: the ability to perform recursion over "existential tests" through a nesting operator. This allows an NRE to find a path where every node along that path must itself be the starting point of another specific sub-path—a capability that standard C2RPQs lack.

A graph structure illustrating the power of nesting: a path where each node must satisfy an existential test (e.g., having a 'b' edge to a side node).

The Acyclic Connection: A Syntactic Bridge

A major contribution of this work is the discovery of a "bridge" between NREs and C2RPQs. The authors identified a natural fragment of NREs, termed "nesting-star alternation-free" expressions, which coincides perfectly in expressive power with the class of unions of acyclic, connected C2RPQs. This fragment avoids using the nesting operator inside a Kleene star (recursion), yet it remains powerful enough to capture a broad class of efficient graph queries.

Performance and Efficiency

Beyond expressivity, the paper reaffirms the performance benefits of NREs. While general C2RPQs face an exponential "computational explosion," NREs can be evaluated in $O(|G| \cdot |nexp|)$ time, where $|G|$ is the size of the graph and $|nexp|$ is the size of the query. This linear-time complexity makes NREs highly suitable for large-scale data.

Conclusion

The study concludes that NREs represent a highly effective alternative for graph querying. By properly extending the class of acyclic queries without falling into the NP-complete complexity of general C2RPQs, NREs provide a practical tool for navigating complex, large-scale graph databases. Future work may explore how these findings integrate into broader navigational query algebras and specific vocabularies like RDFS.

Summary updated

BibTeX
@inproceedings{barcelo2012relative,
  author = {Pablo Barceló and Jorge Pérez and Juan L. Reutter},
  title = {{Relative Expressiveness of Nested Regular Expressions}},
  booktitle = {AMW},
  year = {2012},
  url = {https://openreview.net/forum?id=3guNliMD-OU},
}
Figure