Abstract 1 Introduction 2 Preliminaries: Property Graphs, GQL and Logic 3 Complexity Bounds for GQL Queries 4 Incorporating Domain-Specific Operators 5 Logical Graph Querying Benefits 6 Conclusion References

Complexity of Evaluating GQL Queries

Diego Figueira ORCID University of Bordeaux, CNRS, Bordeaux INP, LaBRI, UMR 5800, F-33400, Talence, France Anthony W. Lin ORCID University of Kaiserslautern-Landau, Germany
MPI-SWS, Kaiserslautern, Germany
Liat Peterfreund ORCID Hebrew University of Jerusalem, Israel
Abstract

GQL has recently emerged as the standard query language over graph databases, particularly, property graphs. Indeed, this is analogous to the role of SQL for relational databases. Unlike SQL, however, fundamental problems regarding GQL are still unsolved, most notably the complexity of query evaluation. In this paper we provide a complete solution to this problem for the core fragment of GQL and for its extension with path restrictors. In particular, we show that the data complexity of these fragments is PNP[log]-complete in general, and drops to NL-complete when restrictors are disallowed. Using techniques from embedded finite model theory, we show that this is true, even when the queries use data from infinite concrete domains such as real numbers with arithmetic. In proving these results, we establish and exploit tight connections between GQL and query languages over relational databases, especially extensions of relational calculus with transitive closure operators and fragments of second-order logic.

Keywords and phrases:
Graph query languages, GQL, complexity, database theory
Funding:
Diego Figueira: Partially supported by ANR grants INTENDED (ANR-19-CHIA-0014) and EXPAND (ANR-25-CE23-1215).
Anthony W. Lin: Supported by the European Research Council111https://doi.org/10.13039/100010663 under Grant No. 101089343 (LASD).
Liat Peterfreund: Supported by Israel Science Foundation 2355/24.
Copyright and License:
[Uncaptioned image] © Diego Figueira, Anthony W. Lin, and Liat Peterfreund; licensed under Creative Commons License CC-BY 4.0
2012 ACM Subject Classification:
Theory of computation Database theory
Related Version:
Full Version: https://arxiv.org/pdf/2407.06766
Acknowledgements:
We thank Michael Benedikt, Leonid Libkin and anonymous reviewers for valuable feedback.
Editors:
Balder ten Cate and Maurice Funk

1 Introduction

Property-graph databases and related knowledge-graph applications gained significant popularity in the last decades, with numerous application domains, including social networks, semantic web, biological and ecological databases, and more. On the practical side, there has been rapid growth in the development of commercial graph database systems, including systems such as Neo4j, Oracle, IBM, TigerGraph, and JanusGraph. This wealth of available systems has also motivated the recent and still ongoing standardization effort of graph data models (in particular, property graphs) and query languages (in particular, GQL), which has been undertaken by several working groups consisting of research leaders from academia and industry (see, e.g., [20, 11]).

GQL [10] was developed to fill in the role of SQL (i.e., as a yardstick query language) for property graphs. Unlike SQL, whose complexity landscape has been mapped for decades, the rigorous study of GQL is only now taking shape. A first informal description of the language appeared in [11], followed by a formal treatment of its pattern-matching layer in [14]. The relational-algebra layer was analyzed soon after in [15], and a study of expressiveness subsequently distilled a streamlined theoretical core [16]. Consequently, even the most basic issue – that of data complexity (query evaluation with only the database as input) – remains largely open. Hitherto, we know only that the complexity of enumerating query outputs is in PSpace [14], and we have an NP-hard lower bound easily derivable from [27]. In this paper, we identify the precise data complexity of the core fragment of GQL for the first time.

GQL on property graphs in a nutshell.

Figure 1: A property graph G𝚋𝚒𝚔𝚎 of bike lanes and road connections between towns and crossroads.

A property graph [2] is a graph whose nodes and edges are labeled, often to represent their type or role in the graph, and are enriched with additional attributes called properties. These properties are stored in a key-value format, enabling a flexible and detailed representation of both entities and their relationships. Figure 1 depicts a property graph G𝚋𝚒𝚔𝚎 of bike lanes and roads between towns and crossroads. It has two node types indicated by their labels – Town and Crossroad, and two edge types, namely Bike-lane and Road. Towns have properties like names, and coordinates specifying their exact location, Bike-lanes and Roads have length and possibly toll.

GQL queries are essentially SQL queries over relations of nodes, edges, and properties, extracted using patterns that capture both data and graph topology (i.e., paths).

Example 1.1.

To find all pairs (x,y) of towns accessible by a bike lane we apply the pattern

((x:Town):BikeLane(y:Town))x,y

on G𝚋𝚒𝚔𝚎. The output is a binary relation with attributes x,y, containing, among others, the pair (n2,n1). To find pairs of places accessible by one or more bike-lanes, we can incorporate unbounded repetition of edges:

R(x,y):=((x:Town):BikeLane1..(y:Town))x,y (1)

Here, the output is the transitive closure of the previous output. We can refine matched patterns by appending a Boolean filter, e.g., returning every town y reachable by bicycle from Leerdam with one or more bike-lanes:

((x:Town):BikeLane1..(y)x.name=“Leerdam”)y

The condition x.name=“Leerdam” filters the matches to paths starting at Leerdam. To prevent re-using the same bike-lane or revisiting the same place we prefix the pattern with an appropriate restrictor: we use simple to forbid repeating a node, or trail to forbid re-using an edge. For instance, suppose we want to organize a day trip from Meekerk to Leerdam using at least two bike lanes without passing through the same town twice. In this case, we would use the pattern

simple((x):BikeLane2..(y)x.name=“Meekerk”y.name=“Leerdam”)

Here, the simple restrictor enforces the non-repetition of nodes.

In GQL, SQL-like-queries are applied to the relations produced by pattern matching over the graph. To query a round-trip, out by bicycle on bike lanes and back by car on roads, we combine the pattern in (1), namely R(x,y), with the pattern

S(x,y):=((x:Town):Road1..(z:Town))x,y

via πx,y(σy=xx=z(R(x,y)×S(x,z))) that joins the two relations on the conjunction y=xx=z of equalities.  

In this paper, we study the query evaluation problem of GQL: given a GQL query Q, a property graph G, and a candidate tuple t¯, determine whether t¯ belongs to the result of evaluating Q over G. To study the complexity of the problem, we use data complexity [30], which is the standard complexity measure for query evaluation problems. That is, since we typically deal with queries of “small size” and “large” databases, we consider the query component Q as fixed (i.e., not part of the input) and only measure the computational complexity in terms of the data (i.e., G).

Contributions.

Our analysis is centered on the core fragment of GQL as formalized in [16], which captures the essential pattern-matching constructs and their combination via relational algebra. In addition, we study an extension of this core with restrictors (e.g., simple, trail, shortest), which are part of practical GQL but are not included in the core fragment. Our complexity results distinguish explicitly between these two settings.

Theorem 1.2.

The data complexity of GQL extended with path restrictors is PNP[log]-complete. The data complexity of GQL without restrictors improves to NL-complete.

That is, GQL query evaluation is representative of problems that can be solved in polynomial time with logarithmically many calls to NP oracles. Note that PNP[log] lies in the second-level of polynomial hierarchy (which is in PSpace), and subsumes the entire boolean hierarchy (which is a boolean closure of NP-complete problems). The class PNP[log] includes some natural problems related to optimization (e.g., [31, 29]) and logical reasoning (e.g., [17, 18]). In the absence of path restrictors, the NP-hardness from [27] on querying simple paths or trails of even length no longer applies. Indeed, we show that the complexity in this case drops to NL-complete.

Our proof technique for the upper bound complexities is via a relational embedding of GQL to extensions of first-order logic over relational structures, namely, either with transitive closure operator, or with existential second-order definable relational views. This relational viewpoint of property graphs yields several benefits, including applicability of techniques from embedded finite model theory (see [24, Chapter 13] and [5]) to derive the same data complexity of GQL in the presence of numeric data and arithmetic constraints (e.g. constraints from Tarski’s theory of real field). In particular, the framework essentially allows unrestricted quantification over an infinite domain such as the set of real numbers thereby allowing us to define interesting queries over spatial databases, e.g., there is a path from x to y that uses edges that lie on a straight-line (see [24, Chapter13]). We summarize this in the following corollary:

Corollary 1.3.

Let 𝐒 be a structure satisfying the property of Restricted Quantifier Collapse (RQC), in particular Linear Real Arithmetic (LRA), Linear Integer Arithmetic (LIA), or Real-ordered Fields (ROF). Then, the data complexity of GQL with restrictors extended with unrestricted quantification over 𝐒 is PNP[log]-complete and, without restrictors, NL-complete.

Related Work.

The study of graph databases in database theory can be traced back to the work of Mendelzon and Wood [28] on Regular Path Queries (RPQ), where they popularized the data model of edge-labeled graphs. This has been the standard graph data model for a long time in database theory [22, 9, 28, 4, 13, 21]. Since then the area has undergone several paradigm shifts on the notion of a “graph data model”, including data graphs [25] and property graphs [2, 11, 14]. Data graphs were introduced in [26, 25] owing to the lack of a treatment of “data” (properties associated with nodes and edges, like “id”, “name” and “age” of a person) in the data model of edge-labeled graphs. Many classical query languages (like RPQ) have been extended to also incorporate such data [2, 25, 3, 12], e.g., in the query language RDPQ (Regular Data Path Queries). Data graphs still do not capture the graph model that has been adopted by practitioners, e.g., the “schemaless” nature of a graph. The property graph data model [2, 11] has been proposed to address such deficiencies.

Unlike the case of GQL, the precise data complexity of most query languages for edge-labeled graphs (e.g., RPQs and extensions) and data graphs (e.g., RDPQs) is known to be NL-complete. For example, see [28, 4, 13, 21, 22, 25]. These results were also recently extended to the case of numeric and string data domains and operations [12]. The reason for the low computational complexity in these settings is analogous to our NL upper bound for GQL without restrictors. By contrast, adding path restrictors is what enables NP-hardness (cf. [27]). Incidentally, our technique of relational embedding can be shown to provide a simpler proof of the NL upper bound in [12]. There are relatively few results on the expressivity landscape of GQL. Initial investigations have been conducted in [16, 8].

Organization.

Section 2 recalls preliminaries on property graphs, GQL, and general logic. Section 3 presents our main complexity results for GQL. In Section 4, we extend the analysis to incorporate data values and domain-specific operators. Section 5 highlights the benefits of analyzing graph query languages from a logical perspective. We conclude in Section 6. Some details are deferred to the full version.

2 Preliminaries: Property Graphs, GQL and Logic

We follow the standard definition of property graph data model, and the formal syntax and semantics of GQL [16, 15, 14]. We also introduce some classical definitions from logic.

Property Graphs.

We assume pairwise disjoint countable infinite sets of nodes 𝒩, (directed) edges , labels , property values 𝒫 and keys 𝒦. A property graph G is a tuple (NG,EG,𝗌𝗋𝖼G,𝗍𝗀𝗍G,𝗉𝗋𝗈𝗉G,𝗅𝖻𝗅G) where NG𝒩,EG, are finite sets of node and edge identifiers, respectively, and 𝗌𝗋𝖼G,𝗍𝗀𝗍G:EGNG are functions that specify the source and target, respectively, of an edge, 𝗉𝗋𝗈𝗉G:(EGNG)×𝒦𝒫 is a partial function that maps a given edge or node and a key to the corresponding property value, if defined, and 𝗅𝖻𝗅G(EGNG)× specifies the labels attached to nodes and edges. We omit the superscript G when it is clear from the context.

2.1 GQL Syntax

We follow the core GQL definition [16]. Core GQL deliberately omits several features present in the full GQL language. In particular, patterns are designed to return relations over an explicitly specified set of variables, ensuring that all query results are in first normal form: relations contain no null values, and all attribute values are atomic (in particular, paths or lists are not first-class values).

Let Vars be an infinite set of variables. Path patterns π are defined via mutual recursion along with their free variables 𝖿𝗏(π). Pattern matching is the key component of GQL. Path patterns are defined recursively as follows:

π:=(x)node pattern𝑥edge pattern𝑥edge patternπ1π2concatenationπ1+π2if 𝖿𝗏(π1)=𝖿𝗏(π2)disjunctionπn..mrepetitionπθfiltering

where

  • xVars and 0nm;

  • variables x in node patterns (x), and edge patterns 𝑥 and 𝑥 are optional,

  • πθ is a conditional pattern, where conditions θ are given by θ:=x.k=x.k(x)θθθθ¬θ222This condition checks whether x is labeled with . For convenience, we often use the shorthand (x:), which incorporates the label directly into the node pattern. where x,xVars , , and k,k𝒦;

The free variables of path patterns are defined as follows:

𝖿𝗏((x))=𝖿𝗏(𝑥)=𝖿𝗏(𝑥):={x}𝖿𝗏(π1+π2):=𝖿𝗏(π1)𝖿𝗏(π1π2):=𝖿𝗏(π1)𝖿𝗏(π2)𝖿𝗏(πn..m):=𝖿𝗏(πθ):=𝖿𝗏(π)

We then define output patterns as ρ¯πΩ where

  • ρ¯:=[shortest][simple|trail] is sequence of restrictors such that parts within squared brackets are optional, and

  • Ω is a (possibly empty) finite sequence of elements of the form x and x.k where xVars and k𝒦.

Intuitively, ρ¯ imposes constraints on the matched paths, and Ω specifies which variables and properties are returned (i.e., projected) in the output relation.

Notice that while [16] omitted restrictors from the language, we include them and give them a precise semantics that is consistent with the standard [15], extending the core fragment and aligning the formal model more closely with the practical language.

Finally, we associate every output pattern ρ¯πΩ with a relation symbol Rρ¯πΩ. GQL queries 𝒬 are then defined as the closure of these symbols under the standard operators of relational algebra.444Notice that while [16] uses a linear form of relational algebra, we use the more convenient standard relational algebra as the equivalence is already established in that work. Formally,

𝒬:=Rρ¯πΩ𝒬𝒬𝒬×𝒬𝒬𝒬πx¯𝒬σθ𝒬

for every output pattern ρ¯πΩ where x¯ is a vector of Vars and θ:=x=yθθθθ¬θ with x,yVars. Note that the operators used here are the standard operators of relational algebra, namely union , Cartesian product ×, difference , projection π, and selection σ, with the usual semantics over relations (see, e.g., [1]). The schema sch(𝒬) of a GQL query 𝒬 is defined inductively. For the base case, we set sch(Rρ¯πΩ):=Ω. For composite queries the schema is defined in the standard way (see, e.g., [1]).

2.2 GQL Semantics

The semantics of output patterns is defined in terms of the semantics of path patterns. We therefore begin by defining the latter.

A path p in a property graph G is an alternating sequence of nodes and edges that start and end with a node, that is, n0e0n1e1ek1nk where n0,,nkN, and e0,,ek1E. Each edge ei must connect the adjacent nodes, meaning either (1) 𝗌𝗋𝖼(ei)=ni and 𝗍𝗀𝗍(ei)=ni+1 or (2) 𝗍𝗀𝗍(ei)=ni and 𝗌𝗋𝖼(ei)=ni+1.

The semantics πG of a path pattern π over a property graph G is defined as a set of pairs (p,μ), where:

  • p is a path in G, and

  • μ:VarsNE is a partial assignment that is defined on dom(μ):=𝖿𝗏(π).

We define 𝗌𝗋𝖼(p):=n0,𝗍𝗀𝗍(p):=nk, and 𝗅𝖾𝗇(p):=k. For two paths p1,p2, we write p1p2 to indicate that 𝗍𝗀𝗍(p1)=𝗌𝗋𝖼(p2). In this case, p1p2 is the concatenation of the paths. For partial mappings μ1,μ2:VarsNE, we use μ1μ2 to denote that for every xdom(μ1)dom(μ2), it holds that μ1(x)=μ2(x) and define (μ1μ2)(x):=μ1(x) if xdom(μ1), and μ2(x) otherwise. We represent mappings μ as sets of elements xo, where μ(x)=o. (If dom(μ)= then we represent μ by .)

The semantics πG of path patterns on a graph G is defined in Figure 2. We emphasize that the semantics of repetition deliberately ignores variable inside the repeated subpattern, following [16]. This restriction ensures that all query results are in first normal form, avoiding list-valued outputs that are permitted in the full GQL language but excluded from the core fragment.

Path Patterns.(x)G:={((n),{xn})|nN}𝑥G:={((n1,e,n2),{xe})|eE,𝗌𝗋𝖼(e)=n1,𝗍𝗀𝗍(e)=n2}𝑥G:={((n1,e,n2),{xe})|eE,𝗌𝗋𝖼(e)=n2,𝗍𝗀𝗍(e)=n1}π1π2G:={(p1p2,μ1μ2)|(p1,μ1)π1G,(p2,μ2)π2Gp1p2,μ1μ2,}π1+π2G:=π1Gπ2GπθG:={(p,μ)|(p,μ)πG,θμG=}πn..mG:=i=nmπiG where π0G:={((n),)|nN}πkG:={(p1pk,)|(p1,μ1)πG,,(pk,μk)πG},k>0
Conditions.(x)μG:= if 𝗅𝖻𝗅(μ(x))x.k=x.kμG:= if 𝗉𝗋𝗈𝗉(μ(x),k)=𝗉𝗋𝗈𝗉(μ(x),k)θ1θ2μG:=θ1μGθ2μGθ1θ2μG:=θ1μGθ2μG¬θμG:=¬θμG
Figure 2: Semantics of GQL’s Path Patterns and Conditions.

For the semantics of output patterns ρπΩ, we first define the intermediate semantics of path patterns preceded by restrictors, iterating through possible cases. For ρ{simple,trail}, we define ρπG:={(p,μ)|(p,μ)πG,ρ(p)} where ρ(p)= if and only if p is a simple path or a trail, respectively. Next, for π~ of the form [simple|trail]π (with the restrictors being optional) we define

shortestπ~G:={(p,μ)|(p,μ)π~G,𝗅𝖾𝗇(p)=mp}

where mp is the minimal length among paths that match π~ with the same endpoints as p, or, more formally,

mp=min{𝗅𝖾𝗇(p)|(p,μ)π~G,𝗌𝗋𝖼(p)=𝗌𝗋𝖼(p),𝗍𝗀𝗍(p)=𝗍𝗀𝗍(p)}.

Let Ω be a (possibly empty) finite sequence of elements of the form x and x.k where xVars and k𝒦. We say that a mapping μ is compatible with Ω if for each xΩ, μ is defined on x, and for each x.kΩ, μ is defined on x and 𝗉𝗋𝗈𝗉(μ(x),k) is defined. In this case, we define μΩ:ΩNE𝒫 as the projection of μ on Ω:

μΩ(ω):={μ(x)if ω=xVars𝗉𝗋𝗈𝗉(μ(x),k)if ω=x.k

Finally, we define ρ¯πΩG:={μΩ|(p,μ)ρ¯πG}. Note that the semantics of an output pattern can be interpreted as a relation as it is a set of partial mappings that share the same domain. Once this is fixed, the semantics of an entire GQL query is obtained exactly as in standard relational algebra (see, e.g., [1]).

2.3 First and Second-Order Logic

We assume basic familiarity with mathematical logic (e.g., [24]). In the sequel, we deal only with finite relational structures.

Relational structures.

We fix disjoint countably infinite sets of relation names Rel, constant names Const, and variables Vars. Every relation name RRel is associated with a positive integer, namely its arity ar(R). We write R(ar(R)) to make the arity explicit. A vocabulary is a finite set σRel. A relation is a finite set of tuples in Constar(R). A σ-structure 𝐒 maps every R(k)σ to a finite relation [[R]]𝐒Constk. Its active domain is adom(𝐒)={cConst:c occurs in [[R]]𝐒 for some Rσ}. Property graphs can naturally be viewed as σ-structures over the vocabulary consisting of the relation names N,E,𝗌𝗋𝖼,𝗍𝗀𝗍,𝗉𝗋𝗈𝗉,𝗅𝖻𝗅 and interpreted accordingly.

First-order logic.

FO is defined in the usual way over σ-structures. That is, terms t are defined by t:=xc where xVars, cConst and formulas φ:=t=tR(t1,,tk)¬φφφxφ. We use the standard , as syntactic sugar.

For a formula φ, we write φ(x¯) to explicitly indicate that x¯ are its free variables. An x¯-valuation is a function ν mapping variables of x¯ to elements of the active domain of a relational structure 𝐒. We write φ(x¯)ν𝐒 for the truth value or of φ under the valuation ν:x¯adom(𝐒). We denote by φ(x¯)𝐒 the set of valuations ν that satisfy φ in 𝐒, that is, valuations for which φ(x¯)ν𝐒=.

Transitive closure.

First-order logic extended with the transitive-closure operator is denoted FO[TC]. Transitive-closure formulas are of the form TCu¯,v¯(φ(u¯,v¯,p¯))(x¯,y¯), where p¯x¯y¯ are the free variables. Such a formula is true in a structure 𝐒 under a valuation ν iff there exists a finite sequence of tuples d¯0,d¯1,,d¯nadom(𝐒)|u¯| with d¯0=ν(x¯) and d¯n=ν(y¯), such that for every i<n, φμi𝐒=, where μi is the valuation mapping u¯, v¯ and p¯ to d¯i, d¯i+1 and ν(p¯) respectively.

Second-order logic.

SO (second-order logic) extends FO by allowing quantification not only over individual elements of the active domain, but also over relation symbols of arbitrary arity. Concretely, SO formulas may include subformulas of the form

R(ψ(R))orR(ψ(R)),

where R is a relation variable and ψ(R) is an FO formula in which R may occur as R(x1,,xk).

The fragment ESO consists of those SO formulas in which all second-order quantifiers are existentially quantified. Note that negation in ESO is permitted only within the first-order component and cannot apply to second-order quantifiers.

3 Complexity Bounds for GQL Queries

We now use standard logics to capture core GQL with and without restrictors, turning syntactic translations into complexity bounds.

3.1 Restrictor-Free GQL Queries and FO[TC]

We call a GQL query restrictor-free if no output pattern occurring in it is prefixed by a restrictor.

Lemma 3.1.

For every restrictor-free GQL query 𝒬 there is an FO[TC] formula φ𝒬(x¯) where x¯=sch(𝒬) such that 𝒬G=φ𝒬(x¯)G for every graph G.

Proof Sketch.

The proof translates a restrictor-free GQL query into an FO[TC] formula whose answer relation coincides with the query result. The construction involves three main steps:

(1) Path patterns.

For every path pattern π we build an FO[TC] formula φπ(s,t,x¯) whose free variables are the start node s and end node t of the matched path, and the pattern variables x¯=𝖿𝗏(π). The translation is recursive:

  • Atomic patterns use predicates such as N(x) for node patterns, and combination of E(e), 𝗌𝗋𝖼(e,s), 𝗍𝗀𝗍(e,t) for edge patterns, depending on their direction.

  • Union and concatenation. π1+π2 translates to disjunction, and for π1π2 we use an existentially quantified concatenation node.

  • Filters. A condition πθ becomes φπφθ, where each atomic condition (x:,  x.a=y.b, etc.) is rendered, in turn, into FO.

  • Kleene bounds. Bounded repetition πn..m with m unrolls into a finite disjunction of FO formula; unbounded repetition π0.. is captured with a transitive closure operator applied to φπ.

(2) Output patterns.

An output pattern πΩ returns a tuple of node/edge IDs and property values. To construct the corresponding output pattern formula, we start from φπ and, for each element in the return list Ω, add a first-order constraint that links the output variable to the witness variables introduced by φπ.

(3) Full queries.

A restrictor-free GQL query is just a relational-algebra expression over the auxiliary relations defined in step (2). Because every RA operator is FO-definable, an easy induction pushes all definitions inside and yields a single FO[TC] sentence φ𝒬(x¯) whose free variables x¯=sch(𝒬).

Example 3.2.

Query (1) from Section 1 can be expressed as φ1(x,y):=[TC(φ(u,v))](x,y) where φ(u,v):=e(E(e)𝗌𝗋𝖼(e,u)𝗍𝗀𝗍(e,v)𝗅𝖻𝗅(e,“BikeLane”)). Here, the relation names E, 𝗌𝗋𝖼, 𝗍𝗀𝗍, and 𝗅𝖻𝗅 constitute the vocabulary of the graph.  

Combining Lemma 3.1 with the known fact that the data complexity of the evaluation problem for FO[TC] is NL-complete [24] gives an NL upper bound. A matching lower bound via a reduction from graph reachability yields the following tight bound.

Theorem 3.3.

The data complexity of the evaluation problem for restrictor-free GQL queries is NL-complete.

Having settled the complexity of restrictor-free queries, we now turn to queries with restrictors.

3.2 GQL Queries and FO[ESO]

We define FO[ESO] as first-order logic extended with ESO-based first-order views. Specifically, we call an ESO formula whose free variables are first-order variables an ESO FO-view, and define FO[ESO] as the set of first-order formulas that may include such views as sub-formulas.

Lemma 3.4.

For every GQL query 𝒬 with restrictors there is an FO[ESO] formula φ𝒬(x¯) with x¯=sch(𝒬) such that 𝒬G= if and only if φ𝒬(x¯)G= for every graph G.

Proof Sketch.

The proof translates a GQL query with restrictors into a FO[ESO] formula whose emptiness coincides with the query’s emptiness.

(1) Encoding a restricted path.

We encode a path (n1,e1,,nk,ek,nk+1) with a ternary relation R(x,e,y) containing the k triples (nj,ej,nj+1). For the simple restrictor we use the FO test ψ𝗌𝗂𝗆𝗉𝗅𝖾(R). To define it we use the following auxiliary shortcuts

𝖾𝖽𝗀𝖾(e):=x,yR(x,e,y),𝗇𝗈𝖽𝖾(x):=e,y(R(x,e,y)R(y,e,x)),𝗌𝗈𝗎𝗋𝖼𝖾(x):=𝗇𝗈𝖽𝖾(x)¬e,yR(y,e,x),𝗍𝖺𝗋𝗀𝖾𝗍(x):=𝗇𝗈𝖽𝖾(x)¬e,yR(x,e,y).

The conjunction of the following requirements gives us ψ𝗌𝗂𝗆𝗉𝗅𝖾(R):

  1. (i)

    There is exactly one source

    s(𝗌𝗈𝗎𝗋𝖼𝖾(s)s(𝗌𝗈𝗎𝗋𝖼𝖾(s)s=s)).
  2. (ii)

    There is exactly one target

    t(𝗍𝖺𝗋𝗀𝖾𝗍(t)t(𝗍𝖺𝗋𝗀𝖾𝗍(t)t=t)).
  3. (iii)

    Every internal node (i.e., neither the source nor the target) has precisely one incomig edge and one outgoing edge n((𝗇𝗈𝖽𝖾(n)¬𝗌𝗈𝗎𝗋𝖼𝖾(n)¬𝗍𝖺𝗋𝗀𝖾𝗍(n))(𝗈𝗇𝖾_𝗂𝗇(n)𝗈𝗇𝖾_𝗈𝗎𝗍(n))) where 𝗈𝗇𝖾_𝗂𝗇(n):=y,e(R(y,e,n)y,e(R(y,e,n)(e=ey=y))) and 𝗈𝗇𝖾_𝗈𝗎𝗍(n) is defined symmetrically.

For the trail restrictor, we drop condition (iii) and instead require that each edge has at most one successor edge and one predecessor edge. To express this, we define a successor formula over pairs of edges.

𝗌𝗎𝖼𝖼(e,e):=x,y,z(R(x,e,y)R(y,e,z))

and with that at hand, we define

e,e1,e2((𝗌𝗎𝖼𝖼(e,e1)𝗌𝗎𝖼𝖼(e,e2))e1=e2)e,e1,e2((𝗌𝗎𝖼𝖼(e1,e)𝗌𝗎𝖼𝖼(e2,e))e1=e2).

For the shortest restrictor, no special handling is needed, as the emptiness of a pattern is preserved when this restrictor is applied.

(2) Changing the atomic patterns.

For every path pattern π we build, by structural induction, an ESO formula φπR(x¯) with x¯=𝖿𝗏(π) that is true iff R encodes a restricted path matching π. Only the base cases differ from the FO[TC] construction of Lemma 3.1, for example:

φ(x)(s,t,x) :=𝗇𝗈𝖽𝖾(x)s=xt=x,
φ𝑥(s,t,x) :=𝖾𝖽𝗀𝖾(x)𝗌𝗋𝖼(x,s)𝗍𝗀𝗍(x,t),

with 𝗇𝗈𝖽𝖾(x) and 𝖾𝖽𝗀𝖾(x) as reconstructed above from R. A restricted path pattern is therefore represented by R(ψρ(R)φπR(x¯)), an ESO sentence with free variables x¯.

(3) From output patterns to queries.

Every output pattern ρ¯πΩ introduces a relation symbol Rρ¯πΩ and the ESO definition obtained in step 2. A complete GQL query is an RA expression over these symbols. Because each RA operator (projection, join, union, difference) is FO-definable, substituting the ESO definitions and pushing the FO connectives outward yields an FO[ESO] formula φ𝒬(x¯) satisfying 𝒬G=φ𝒬(x¯)G= for every graph G.

Example 3.5.

Continuing Example 3.2, if the pattern is preceded by the restrictor simple then the translation is φ2(x,y):=R:ψsimple(R)φ~1(x,y) where φ~1(x,y) is obtained from φ1(x,y) by replacing E(e) with 𝖾𝖽𝗀𝖾(e) derived from R (as detailed in the proof sketch of Lemma 3.4).  

The complexity class PNP[log] consists of decision problems solvable in deterministic polynomial time using logarithmically many adaptive queries to an NP oracle [31, 29]. Equivalently, it can be defined as the class of problems solvable by first generating polynomially many NP oracle queries, performing all of them in parallel (non-adaptively), and then computing the final answer from the oracle’s yes/no responses.

Corollary 3.6.

The data complexity of the evaluation problem for GQL queries is in PNP[log].

Proof Sketch.

Let 𝒬 be a GQL query and let φ𝒬 be the FO[ESO] formula guaranteed in Lemma 3.4. Let us denote by φ1,,φk the first-order ESO views. Assume that each φi has arity ki, and let us denote n:=|adom(G)|.

  1. 1.

    For every i and every tuple a¯adom(G)ki ask the NP oracles whether φix¯a¯G=. The total number of queries is inki=nO(1).

  2. 2.

    Issue this batch of polynomially many queries in parallel to obtain the complete satisfying assignments for all of the φis.

  3. 3.

    Evaluate the remaining first-order part of φ𝒬 deterministically in poly(n) time.

Notice that the algorithm makes polynomially many non-adaptive NP calls.

Is the bound tight?

To investigate this, we introduce the Odd-Index problem. In its original form [31, Theorem 5.2], the problem asks: given a list of Boolean formulas φ1,,φn in 3-CNF, is there an odd index i[n] such that:

  • all formulas φ1,,φi are satisfiable, and

  • all formulas φi+1,,φn are unsatisfiable?

This problem can be generalized by replacing the 3-CNF satisfiability with any NP-hard decision problem. In our context we replace it with simple-path (trail) even-length reachability in graphs. Formally, we define the following problem:

Given a list (G1,s1,t1),,(Gn,sn,tn), where each Gi is a graph and si,ti are designated nodes, determine whether there exists an odd index i[n] such that:

  • for all ji, there is a simple path (trail) of even length from sj to tj in Gj, and

  • for all j>i, there is no such simple path (trail) of even length.

We reduce this problem to the evaluation of a GQL query, thereby establishing the following lower bound.

Lemma 3.7.

The evaluation problem for GQL queries with restrictors is PNP[log]-hard.

Combining Corollary 3.6 with Lemma 3.7 yields the following tight bound:

Theorem 3.8.

The evaluation problem for GQL queries with restrictors is PNP[log]-complete.

This completes the PNP[log]-completeness characterization for GQL queries with restrictors.

3.3 Proof of Lemma 3.7: PNP[log] Lower Bound

Figure 3: The graph G used in the reduction. Lower layer: Copies Gi𝗅𝗈 of each input graph Gi are linked by edges ss1, tisi+1, and odd-index nodes vj (label 0) are appended via tjvj. Upper layer: Fresh copies Gj𝗎𝗉 for j2 have sources sj connected from every vi with i<j, and all upper targets tj feed into the global sink t. Source nodes s,si,sj carry label s; targets t,ti,tj carry t; and each vj (odd j) carries 0.

We give a log-space reduction from the PNP[log]-complete Odd-Index problem to the evaluation of a GQL query that uses the simple restrictor. (A similar construction works with trail.)

Query.

We define the query Q:=QLQR where

QL simple((:s)π(x:0))xwhereπ(:s)()(:t)((:s)()(:t))
QR (x:0)xsimple((x:0)(:s)()(:t)(:t))x

Graph construction.

Assume the input list (G1,s1,t1),,(Gn,sn,tn) is pairwise disjoint, and each si,ti carries labels s,t, respectively. We build G, depicted in Figure 3, as follows:

  1. 1.

    Lower layer.

    1. (a)

      For every 1in add a fresh copy Gilo.

    2. (b)

      Add a fresh node s labeled by s, and an edge ss1.

    3. (c)

      For each i<n add an edge tisi+1.

    4. (d)

      For each odd j add a node vj labeled 0, and an edge tjvj.

  2. 2.

    Upper layer.

    1. (a)

      For every 2jn add a fresh copy Gjup with nodes sj,tj (replacing sj,tj).

    2. (b)

      Add an edge vjsi for every odd j and ij+1.

    3. (c)

      Add a fresh node t labeled by t, and edges tit for all i2.

Label summary: all sources s,s1,,sn,s2,,sn carry s; all targets t,t1,,tn,t2,,tn carry t; each vj (odd j) carries 0.

Notice that G construction is first-order definable and uses only logarithmic space.

Correctness.

To prove correctness, we investigate both parts QL and QR of the query in the following lemmas.

Lemma 3.9.

QL evaluated on G returns exactly those nodes vj such that for every ij, the graph Gi contains a simple path of even-length from si to ti.

Proof.

Assume first that QL evaluated on G returns a node n. Due to QL’s definition, there must exist in G a simple path of the form

ss1p1t1s2p2t2sipitin,

where (1) 1in; (2) s is the unique fresh node labeled s created in Step 1(b), (3) si is the source of Gilo in the the lower layer; (4) each pi consists of an even number of edges; and (5) n is labeled 0.

Notice that the only 0-labelled nodes are v1,v3,v5,. Let us denote n=vj for the corresponding odd j. By construction vj is attached to tj, hence t=tj.

Due to the structure of G and to the labels specified in QL, the matched path is forced to traverse, in order,

G1lo,G2lo,,Gjlo,

employing the connecting edges tisi+1 for i<j. As the overall walk is simple, in each lower copy Gilo the sub-path from si to ti is itself simple. Consequently, for all ij, it holds that Gi contains a simple path of even length siti from si to ti.

Conversely, suppose there is an odd index j such that every Gi(ij) has a simple even-length path siti. Concatenate those paths with the connecting edges

ss1,tisi+1(i<j),tjvj;

The result is a simple path that matches QL, hence vj is returned.

Lemma 3.10.

QR evaluated on G returns exactly those nodes vj such that, for every ij+1, the graph Gi contains no simple path of even-length from si to ti.

Proof.

Recall QR(x:0)xsimple((x:0)(:s)()(:t)(:t))x We refer to the patterns before and after , respectively, as left and right parts.

Left part.

The projection (x:0)x simply returns every 0-labelled vertex, i.e. the odd-indexed nodes v1,v3,v5,.

Right part.

A node vj is matched to the right part if there is a path

vjsititfor some ij+1

exists in G. where siti is of even length, The edge tit is the only occurrence of two consecutive t-labelled nodes, so any matched path must enter the upper copy Giup at its source si and reach ti without repeating nodes. Because each Giup is disjoint from the rest of the graph, such a sub-path exists iff the original graph Gi contains a simple path of even length siti.

The difference of the left part and the right part

Due to the above, vj is outputted by QR whenever there is no even-length simple path in Giup from si to ti for every ij+1.

Combining Claims 1 and 2.

Claim 1 shows that QL returns precisely those markers vj for which every graph Gi with ij admits a simple even-length siti path. Claim 2 shows that QR returns exactly those same markers vj for which no graph Gi with ij+1 admits such a path. Since our full query takes the intersection of these two results, it will be nonempty exactly when there exists some index j satisfying both “all earlier graphs succeed” and “all later graphs fail”. But this is exactly the odd-index condition required by the source problem, which completes the correctness argument.

Exactly the same reduction goes through if we replace the simple restrictor by trail, yielding identical bound.

4 Incorporating Domain-Specific Operators

Logics considered so far let us combine the topology of a graph with simple data tests restricted to equality. Yet, practical languages operate over concrete domains equipped with a rich set of comparisons and functions.

To add such data operations without worsening complexity, we rely on classical results from the study of constraint databases [23] and embedded finite model theory [19, 6]. These results allow us to extend GQL with typed data operations while preserving data-complexity bounds.

The underlying idea is to “embed” a finite database inside an infinite structure 𝐒 with a decidable first-order theory. Queries can then use formulas over 𝐒 to express operations on domain values. Three notable examples [19, Chapter 5]) include:

  • The Linear Integer Arithmetic (LIA) structure 𝔐,+,<=,0,1,+, – linear arithmetic over integers.

  • The Linear Real Arithmetic (LRA) structure 𝔐,+,=,0,1,+, – linear arithmetic over reals.

  • The Real Ordered Field (ROF) structure 𝔐,+,×,=,0,1,+,, – real closed field (Tarski’s structure).

We focus on these numeric structures, though similar approaches exist for other domains like strings (e.g., reducts of the universal automatic structure [7]).

4.1 Embedded Finite Model Framework

Embedded finite structures.

An element u from the domain D of 𝔐 is definable over 𝔐 if there exists a 𝔐-formula φ(x) such that for each vD we have φ(x)xu𝔐= iff u=v. For example, over 𝔐,+,, the definable elements are exactly the rationals. An 𝔐-embedded finite relational structure over σ is a finite relational structure whose domain consists of such definable elements.

Logics with active–domain quantifiers.

A hybrid transitive-closure operator

TCu¯,v¯(φ(u¯v¯p¯))

is defined like the standard TC except that every intermediate tuple must lie in the active domain. We denote by FO[HTC] first-order logic extended with hybrid TC operators.

Active-domain restrictions also apply to second-order quantifiers. In HSO for hybrid second-order logic, relation variables range only over the active domain. We write HESO for its existential fragment.

For any L{FO[HTC],HSO,HESO}, let L[𝔐] denote the logic extended with predicates from an infinite structure 𝔐, enriched with active-domain quantifiers adomx and adomR. A formula is active-domain if all quantifiers are of this form.

Restricted-quantifier collapses.

Over the arithmetic domains introduced above, quantifiers can be restricted to the active domain without losing expressive power:

Proposition 4.1 (Restricted-quantifier collapse [6]).

Let 𝔐{𝔐,+,<,𝔐,+,,𝔐,+,×,}. Over 𝔐-embedded structures:

  1. (i)

    Every FO[HTC][𝔐]-formula is equivalent to an active-domain FO[HTC][𝔐]-formula, and its data complexity lies in NL.

  2. (ii)

    Every HESO[𝔐]-formula is equivalent to an active-domain HESO[𝔐]-formula, and its data complexity lies in NP.

These collapses allow us enriching GQL with operations from 𝔐 while keeping the usual bounds.

4.2 Extending GQL with Data Types

We fix an infinite structure 𝔐. and define GQL queries with an 𝔐-data type. To this end, we first extend the definition of terms to 𝔐-terms defined as follows:

χ:=x.acyfm(χ1,,χm)

where c is an 𝔐-definable constant, y is a variable ranging over the domain of 𝔐, fm is an m-ary function name in the vocabulary of 𝔐, xVars, a𝒦, and every χi is an 𝔐-term. We also extend the definition of conditions to 𝔐-conditions by adding θ:=Rm(χ1,,χm) where Rm is an m-ary relation name in the vocabulary of 𝔐, and every χi is an 𝔐-term. The semantics of θ extends by interpreting χ and θ “inside” 𝔐.

Example 4.2.

Continuing Example 3.2, suppose we also want to enforce that the Manhattan distance between the towns is below a fixed c. We can add the filter

|x.x-coordy.x-coord|+|x.y-coordy.y-coord|<c,

which requires access to built-in arithmetic relations for absolute value, addition, subtraction, and comparison <.  

Using Proposition 4.1, the upper bounds extend to GQL queries with data types.

Theorem 4.3.

For every 𝔐{𝔐,+,<,𝔐,+,,𝔐,+,×,}, the data complexity of the evaluation problem of a Boolean GQL query 𝒬 with an 𝔐-data type is

  • NL-complete if 𝒬 is restrictor-free;

  • PNP[log]-complete otherwise.

GQL can support multiple data types (e.g., strings, numbers) using disjoint infinite structures with restricted quantifier collapse, while preserving data complexity as long as typed variables range over disjoint domains.

5 Logical Graph Querying Benefits

This section advocates viewing graph query languages through a logical lens. Embedding GQL into formal logic simplifies reasoning, clarifies expressiveness, and preserves complexity bounds. We showcase several examples unlocked by this embedding, including schema-level queries and extensions beyond plain GQL.

Meta-Querying.

GQL does not support quantification over properties or labels, limiting its ability to express meta-level queries such as schema checks or property comparisons. For instance, to return pairs of nodes that hold exactly the same data, we have:

φeq(n,n)=k,v(𝗉𝗋𝗈𝗉(n,k,v)𝗉𝗋𝗈𝗉(n,k,v))

where is used as a shorthand for bidirectional implication. Similarly, to ensure that all bike lanes in Example 3.2 are toll-free, we can replace φ(u,v) with

φ(u,v):=e(E(e)𝗌𝗋𝖼(e,u)𝗍𝗀𝗍(e,v)𝗅𝖻𝗅(e,“BikeLane”)𝗇𝗈_𝗍𝗈𝗅𝗅(e))

where 𝗇𝗈_𝗍𝗈𝗅𝗅(e):=¬x:𝗉𝗋𝗈𝗉(e,‘toll’,x) verifies the condition holds. While GQL cannot test for the absence of a toll property, this enriched query remains in NL.

Beyond GQL’s Expressiveness.

GQL is limited in checking conditions on unbounded edge traversals, for instance, checking for decreasing values on edges along a path [16]. The next query expresses this: outputs towns accessible by bike lanes with decreasing lengths:

φ(n,n):=e,e(φ<(e,e)𝗍𝗀𝗍(e,n)𝗌𝗋𝖼(e,n))

where

φ<(e,e):=[TCu,v(E(u)E(v)φincE(u,v))](e,e)

where φincE(u,v) checks if u and v are adjacent edges with decreasing lengths:

φincE(u,v):=n(𝗌𝗋𝖼(v,n)𝗍𝗀𝗍(u,n))l,l(𝗉𝗋𝗈𝗉(u,“length”,l)𝗉𝗋𝗈𝗉(v,“length”,l)l<l)

Here we compute the transitive closure over edges rather than nodes, as it is in GQL’s iteration.

6 Conclusion

In this paper, we have answered a fundamental questions regarding evaluating GQL queries, i.e., its data complexity. Although its complexity (PNP[log]) is higher than that of its SQL counterpart ( polynomial-time), we have shown that the restrictor-free fragment is in NL. We have shown that our results extend to settings with data.

Future Work.

We believe that our logical perspectives on graph databases could further advance the study of graph databases. As we have shown, not only do they generalize GQL in expressivity (e.g., meta-querying, cf. Section 5), they also allow us to employ classical techniques from relational structures (e.g., embedded finite model theory).

One interesting future avenue concerns the extension of GQL with aggregation over paths (by, e.g., summing, counting, averaging, over a given path). While aggregation results are available for relational databases (e.g., in embedded finite model theory), most positive results (e.g., see Chapter 5 of [19]) do not extend to paths and remain within first-order logic.

References

  • [1] Serge Abiteboul, Richard Hull, and Victor Vianu. Foundations of Databases. Addison–Wesley, Reading, MA, 1995.
  • [2] Renzo Angles, Marcelo Arenas, Pablo Barceló, Aidan Hogan, Juan L. Reutter, and Domagoj Vrgoc. Foundations of modern query languages for graph databases. ACM Comput. Surv., 50(5):68:1–68:40, 2017. doi:10.1145/3104031.
  • [3] Pablo Barceló, Gaëlle Fontaine, and Anthony Widjaja Lin. Expressive path queries on graph with data. Log. Methods Comput. Sci., 11(4), 2015. doi:10.2168/LMCS-11(4:1)2015.
  • [4] Pablo Barceló, Leonid Libkin, Anthony Widjaja Lin, and Peter T. Wood. Expressive languages for path queries over graph-structured data. ACM Trans. Database Syst., 37(4):31:1–31:46, 2012. doi:10.1145/2389241.2389250.
  • [5] Michael Benedikt. Generalizing finite model theory. In Logic Colloquium ’03, pages 3–24. Cambridge University Press, 2006.
  • [6] Michael Benedikt and Leonid Libkin. Relational queries over interpreted structures. J. ACM, 47(4):644–680, 2000. doi:10.1145/347476.347477.
  • [7] Michael Benedikt, Leonid Libkin, Thomas Schwentick, and Luc Segoufin. Definable relations and first-order query languages over strings. J. ACM, 50(5):694–751, 2003. doi:10.1145/876638.876642.
  • [8] Michael Benedikt, Anthony Widjaja Lin, and Di-De Yen. Revisiting the expressiveness landscape of data graph queries. CoRR, abs/2406.17871, 2024. doi:10.48550/arXiv.2406.17871.
  • [9] Diego Calvanese, Giuseppe De Giacomo, Maurizio Lenzerini, and Moshe Y. Vardi. Containment of conjunctive regular path queries with inverse. In KR, 2000.
  • [10] GQL Standards Committee. GQL standards website, 2024. Accessed: November 2024. URL: https://www.gqlstandards.org/.
  • [11] Alin Deutsch, Nadime Francis, Alastair Green, Keith Hare, Bei Li, Leonid Libkin, Tobias Lindaaker, Victor Marsault, Wim Martens, Jan Michels, Filip Murlak, Stefan Plantikow, Petra Selmer, Oskar van Rest, Hannes Voigt, Domagoj Vrgoc, Mingxi Wu, and Fred Zemke. Graph pattern matching in GQL and SQL/PGQ. In SIGMOD, 2022. doi:10.1145/3514221.3526057.
  • [12] Diego Figueira, Artur Jeż, and Anthony W. Lin. Data path queries over embedded graph databases. In ACM Symposium on Principles of Database Systems (PODS), 2022. doi:10.1145/3517804.3524159.
  • [13] Daniela Florescu, Alon Y. Levy, and Dan Suciu. Query containment for conjunctive queries with regular expressions. In ACM Symposium on Principles of Database Systems (PODS), 1998. doi:10.1145/275487.275503.
  • [14] Nadime Francis, Amélie Gheerbrant, Paolo Guagliardo, Leonid Libkin, Victor Marsault, Wim Martens, Filip Murlak, Liat Peterfreund, Alexandra Rogova, and Domagoj Vrgoc. GPC: A pattern calculus for property graphs. In ACM Symposium on Principles of Database Systems (PODS), pages 241–250. ACM, 2023. doi:10.1145/3584372.3588662.
  • [15] Nadime Francis, Amélie Gheerbrant, Paolo Guagliardo, Leonid Libkin, Victor Marsault, Wim Martens, Filip Murlak, Liat Peterfreund, Alexandra Rogova, and Domagoj Vrgoc. A researcher’s digest of GQL (invited talk). In International Conference on Database Theory (ICDT), volume 255 of LIPIcs, pages 1:1–1:22. Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2023. doi:10.4230/LIPIcs.ICDT.2023.1.
  • [16] Amelie Gheerbrant, Leonid Libkin, Liat Peterfreund, and Alexandra Rogova. GQL and SQL/PGQ: Theoretical Models and Expressive Power. Proceedings of the VLDB Endowment (PVLDB), 18(6):1798–1810, 2025. doi:10.14778/3725688.3725707.
  • [17] Stefan Göller, Richard Mayr, and Anthony Widjaja To. On the computational complexity of verifying one-counter processes. In Proceedings of the 24th Annual IEEE Symposium on Logic in Computer Science, LICS 2009, 11-14 August 2009, Los Angeles, CA, USA, pages 235–244. IEEE Computer Society, 2009. doi:10.1109/LICS.2009.37.
  • [18] Georg Gottlob. Np trees and carnap’s modal logic. J. ACM, 42(2):421–457, 1995. doi:10.1145/201019.201031.
  • [19] E. Grädel, P. G. Kolaitis, L. Libkin, M. Marx, J. Spencer, M. Y. Vardi, Y. Venema, and S. Weinstein. Finite Model Theory and Its Applications. Springer, 2007.
  • [20] Alastair Green, Paolo Guagliardo, and Leonid Libkin. Property graphs and paths in gql: Mathematical definitions. Technical Reports TR-2021-01, Linked Data Benchmark Council (LDBC), October 2021. doi:10.54285/ldbc.TZJP7279.
  • [21] Jelle Hellings, Bart Kuijpers, Jan Van den Bussche, and Xiaowang Zhang. Walk logic as a framework for path query languages on graph databases. In International Conference on Database Theory (ICDT), 2013. doi:10.1145/2448496.2448512.
  • [22] H. V. Jagadish, Angela Bonifati, George Fletcher, Hannes Voigt, and Nikolay Yakovets. Querying Graphs. Morgan and Claypool Publishers, 2018.
  • [23] Gabriel Kuper, Leonid Libkin, and Jan Paredaens. Constraint Databases. Springer, 2000.
  • [24] Leonid Libkin. Elements of finite model theory, volume 41. Springer, 2004. doi:10.1007/978-3-662-07003-1.
  • [25] Leonid Libkin, Wim Martens, and Domagoj Vrgoc. Querying graphs with data. J. ACM, 63(2):14:1–14:53, 2016. doi:10.1145/2850413.
  • [26] Leonid Libkin and Domagoj Vrgoc. Regular path queries on graphs with data. In Alin Deutsch, editor, International Conference on Database Theory (ICDT), pages 74–85. ACM, 2012. doi:10.1145/2274576.2274585.
  • [27] Wim Martens, Matthias Niewerth, and Tina Popp. A trichotomy for regular trail queries. Log. Methods Comput. Sci., 19(4), 2023. doi:10.46298/LMCS-19(4:20)2023.
  • [28] Alberto O. Mendelzon and Peter T. Wood. Finding regular simple paths in graph databases. SIAM J. Comput., 24(6):1235–1258, 1995. doi:10.1137/S009753979122370X.
  • [29] Holger Spakowski and Jörg Vogel. Theta2p-completeness: A classical approach for new results. In Sanjiv Kapoor and Sanjiva Prasad, editors, Foundations of Software Technology and Theoretical Computer Science, 20th Conference, FST TCS 2000 New Delhi, India, December 13-15, 2000, Proceedings, volume 1974 of Lecture Notes in Computer Science, pages 348–360. Springer, 2000. doi:10.1007/3-540-44450-5_28.
  • [30] Moshe Y. Vardi. The complexity of relational query languages (extended abstract). In Proceedings of the 14th Annual ACM Symposium on Theory of Computing, May 5-7, 1982, San Francisco, California, USA, pages 137–146, New York, NY, USA, 1982. Association for Computing Machinery. doi:10.1145/800070.802186.
  • [31] Klaus W. Wagner. More complicated questions about maxima and minima, and some closures of NP. Theor. Comput. Sci., 51:53–80, 1987. doi:10.1016/0304-3975(87)90049-1.