Two-way regular path queries (2RPQs) have received increased attention
recently due to their ability to relate pairs of objects by flexibly navigating
graph-structured data. They are present in property paths in SPARQL 1.1, the
new standard RDF query language, and in the XML query language XPath. In line
with XPath, we consider the extension of 2RPQs with nesting, which allows one
to require that objects along a path satisfy complex conditions, in turn
expressed through (nested) 2RPQs. We study the computational complexity of
answering nested 2RPQs and conjunctions thereof (CN2RPQs) in the presence of
domain knowledge expressed in description logics (DLs). We establish tight
complexity bounds in data and combined complexity for a variety of DLs, ranging
from lightweight DLs (DL-Lite, EL) up to highly expressive ones. Interestingly,
we are able to show that adding nesting to (C)2RPQs does not affect worst-case
data complexity of query answering for any of the considered DLs. However, in
the case of lightweight DLs, adding nesting to 2RPQs leads to a surprising jump
in combined complexity, from P-complete to Exp-complete.Comment: added Figure