Interpreting Tree-to-Tree Queries

We establish correspondences between top-down tree building query languages and predicate logics. We consider the expressive power of the query language XQ, a clean core of the practitioner's language XQuery. We show that all queries in XQ with only atomic equality are equivalent to “first-order interpretations”, an analog to first-order logic (FO) in the setting of transformations of tree-structured data. When XQ is considered with deep equality, we find that queries can be translated into FO with counting (FO(Cnt)). We establish partial converses to this, characterizing the subset of the FO resp. FO(Cnt) interpretations that correspond to XQ. Finally, we study the expressive power of fragments of XQ and obtain partial characterizations in terms of existential FO and a fragment of FO that is two-variable if the tree node labeling alphabet is assumed fixed