Abstract 1 Introduction 2 Preliminaries 3 View-based Query Determinacy 4 All-walks and Trail Semantics 5 Shortest Walk Semantics 6 Conclusion References Appendix A Handling Empty Words in Query and View Languages Appendix B Alternate Construction of 𝑨π“₯,𝑸 for the Proof of Theorem 2 Appendix C Additional Material for the Proof of Theorem 3

View-Based Query Determinacy for Walk-Based Semantics

Nadime Francis ORCID LIGM, UniversitΓ© Gustave Eiffel, CNRS, Marne-la-VallΓ©e, France
Abstract

The view-based query determinacy problem asks, given a view 𝒱 and a query Q whether the information contained in 𝒱 always suffices to answer the query Q. It is a notoriously hard problem that is known to be undecidable even in very restricted settings. Here, we study it in the context of graph databases and regular path queries and views evaluated under several β€œwalk-based semantics”, that is, semantics in which queries and views return the matched walks in full as opposed to the classical β€œendpoint semantics”. Our main finding is that view-based query determinacy is decidable for regular path queries under both trail and shortest walk semantics.

Keywords and phrases:
graph databases, regular path queries, trail semantics, shortest walk semantics, view-based query determinacy
Copyright and License:
[Uncaptioned image] © Nadime Francis; licensed under Creative Commons License CC-BY 4.0
2012 ACM Subject Classification:
Theory of computation β†’ Database theory
Acknowledgements:
I gratefully thank Yann Strozecki for reading early versions of this work and providing constructive feedback.
Editors:
Balder ten Cate and Maurice Funk

1 Introduction

The view-based query determinacy problem is a classical static analysis problem in database theory. It arises in many reasoning scenarios, including data exchange and integration, query optimization and data privacy. Given a set of queries 𝒱 called the view and a target query Q, one has to decide whether, for all databases D, the answers to the queries in 𝒱, denoted as 𝒱⁒(D) always suffice to compute Q⁒(D) regardless of the underlying data that was used to compute 𝒱⁒(D). When this is the case, we say that 𝒱 determines Q. Formally, this means that there exists a functional dependency from 𝒱 to Q: for all databases D and Dβ€², if 𝒱⁒(D)=𝒱⁒(Dβ€²), then Q⁒(D)=Q⁒(Dβ€²).

This problem is known to be computationally very hard in many settings, even for the most basic query and view languages. It is already undecidable for conjunctive queries and conjunctive views in relational databases [11, 12]. Some fragments and restrictions of the problem are known to be decidable, but the strength of the restrictions can be seen as a testimony to the original problem’s hardness. These include chain queries (that is, conjunctive queries whose underlying graph is a path) [2] with a narrow extension in [6] and the monotone determinacy setting, in which the functional dependencies from the view to the target query is furthermore assumed to be monotonic [19].

In the graph database setting, the problem turns out, perhaps unsurprisingly, to also be computationally hard. The building block for most query languages over graphs are regular path queries [18]: queries which look for walks in the graph whose label conforms to a given regular expression. Unfortunately, query determinacy is undecidable for regular path queries and views, even for a very restricted form of regular expression with no Kleene star [10]. As in the relational case, the monotone setting is decidable, as shown in [9] using techniques from [4]. However, these results do not tell the whole story: in existing work, regular path queries are evaluated under the so-called endpoint semantics, where queries only return the endpoints of walks in the database whose label conforms to the query. While theoretically very sound, the endpoint semantics do not capture the behavior of real-life systems, in which the matching walks are returned in full. To the best of our knowledge, there are no known results for query determinacy under walk-based semantics.

Moving from endpoint semantics to walk-based semantics leads to many complications. Indeed, since databases can contain cycles, it may happen that the set of walks to be returned by a given query is infinite. To address this issue, real-life systems evaluate queries under specific semantics, that is, criteria that ensure the finiteness of the output. The most common semantics are trail semantics, which filters out walks that contain repeated edges, and shortest walk semantics, which only returns the shortest witness for each fixed source and target vertex. These semantics come at a severe cost in complexity (testing emptiness for a given regular path query is NP-complete under trail semantics [17], which makes query evaluation intractable) and expressivity (by filtering out potentially interesting results). These semantics are nonetheless commonly seen in practice, which strongly implies that there is a real demand for walk-based semantics. Notable examples include Cypher, which is evaluated under trail semantics [8] and GSQL [21] and G-Core [3], which both use shortest walk semantics. Finally, the language GQL [5, 7], which has been designed as a standard for graph query languages, implements both trail and shortest walk semantics.

This article addresses the query determinacy problem in the graph database setting for regular path queries and views that are evaluated under walk-based semantics. In addition to the trail and shortest walk semantics, we also consider the all-walks semantics which simply returns all walks that match the query, even though the set of answers could be infinite. This is not only a theoretical consideration. We will see that in the context of query determinacy, the decision procedure for this semantics actually applies to all semantics that are β€œedge-covering” [16]: if an edge of the graph is useful to the query (it occurs in at least one matching walk), then this edge should appear in at least one walk of the answer.

Note that it is not immediately obvious whether query determinacy under walk-based semantics is harder than under endpoints semantics: we are assigned a harder task (computing the walks that match the query in full) but we are given a view that provides much more information. This is similar to the case of full conjunctive queries and views in the relational setting, where it is assumed that all variables in the body of the query are also output variables in the head. This setting is known to be decidable [2] with a simple criterion: full views determine the query if they cover all atoms of a specific canonical database. The graph database setting turns out to also be decidable under walk-based semantics but poses new challenges. First, regular path queries are essentially infinite (albeit regular) unions of conjunctive queries, which means that there would naively be infinitely many databases against which determinacy must be checked. Second, the semantics under which queries and views are evaluated might filter out necessary information, even though the walks containing said information do match the given regular languages.

Contributions.

We start by showing how the classical query determinacy problem translates to our setting. As a side result, we remark that the query rewriting problem using views [19] turns out to be trivial in our setting: the rewriting, when it exists, will simply be the original query itself. Then our main contribution is to prove upper and lower complexity bounds for the problem of deciding query determinacy under all-walks, trail and shortest walk semantics. First, we establish a lower bound that covers all three semantics:

Theorem 1.

Determinacy for regular path queries and views is PSpace-hard under all-walks, trail and shortest walk semantics, even if the automata that define the queries and views are deterministic.

In this work, we assume that the regular path queries are given as finite automata. Thus, it is a natural concern whether the complexity depends on the properties of the specific automaton that implements the query. Our result, however, shows that the lower bound holds even in the favorable case where the automaton is deterministic. Next, we prove a matching upper bound for all-walks and trail semantics, which makes the problem PSpace-complete:

Theorem 2.

Determinacy for regular path queries and views can be decided in PSpace under all-walks and trail semantics, even for nondeterministic query and view automata.

Finally, we prove a matching upper bound for shortest walk semantics, which turns out to be our most difficult result:

Theorem 3.

Determinacy for regular path queries and views can be decided in PSpace under shortest walk semantics, provided that the query is given as a deterministic automaton.

This upper bound only holds when the query is given as a deterministic automaton (the automata defining the view may be nondeterministic). One could always choose to determinize the input to use this decision algorithm, but then the upper bound becomes ExpSpace, and no longer matches the lower bound. Unfortunately, this gap remains as an open question: we neither have a better upper bound for the nondeterministic case, nor a tighter lower bound when the automaton can be nondeterministic.

Outline.

Section 2 defines the data and query models of our setting. Section 3 defines the view-based query determinacy problem and shows preliminary results that apply to all three semantics, including the PSpace lower bound. Section 4 proves the upper bound for the all-walks and trail semantics. While interesting in its own right, this section also serves as a warm-up for Section 5 where we prove the upper bound for the shortest walk semantics. Indeed, the techniques in Section 5 reuse and expand upon the core ideas of Section 4.

2 Preliminaries

In this section, we define the data and query models that are used throughout the article. Particular attention should be given to Section 2.3 that defines the walk-based semantics under which regular path queries are to be evaluated.

2.1 Graph databases

We represent graph databases as multi-edge multi-label graphs. All results naturally translate to the traditional theoretical model where databases are more simply represented as edge-labeled graphs [18]. Here, we chose to use a more general model that more closely resembles the property graph data model used in practice [5], where both vertices and edges are assumed to have a unique identifier. In particular, it is not enough to know that a vertex x is connected to a vertex y with an a-labeled edge: we will also need the specific identifier e of said edge.

Definition 4 (Database).

A database D is a tuple (Ξ£,Node,Edge,Src,Tgt,Lbl) where:

  • β– 

    Ξ£ is a finite set of symbols, or labels;

  • β– 

    Node is a finite set of vertices;

  • β– 

    Edge is a finite set of edges;

  • β– 

    Src:Edge→Node is the source function;

  • β– 

    Tgt:Edge→Node is the target function;

  • β– 

    Lbl:Edge→2Σ is the labeling function.

Definition 5 (Walk).

A walk Ο€ in a database D is a nonempty finite sequence of alternating vertices and edges of the form Ο€=(x0,e0,x1,…,ekβˆ’1,xk) where kβ‰₯0, x0,…,xk∈Node, e0,…,ekβˆ’1∈Edge, such that, βˆ€i<k,Src⁑(ei)=xi⁒ and ⁒Tgt⁑(ei)=xi+1.

We call k the length of Ο€ and denote it by Len⁑(Ο€). We extend the functions Src, Tgt and Lbl to the walks in D as follows. For each walk Ο€=(x0,e0,x1,…,ekβˆ’1,xk) in D, Src⁑(Ο€)=x0, Tgt⁑(Ο€)=xk, and Lbl⁑(Ο€)={a0⁒a1⁒⋯⁒akβˆ’1βˆ£βˆ€i<k,ai∈Lbl⁑(ei)}. Finally, we write sβ†’πœ‹t to say that Src⁑(Ο€)=s and Tgt⁑(Ο€)=t.

We say that two walks Ο€=(x0,e0,x1,…,ekβˆ’1,xk) and Ο€β€²=(y0,f0,y1,…,fβ„“βˆ’1,yβ„“) concatenate if Tgt⁑(Ο€)=Src⁑(Ο€β€²), in which case we define their concatenation Ο€β‹…Ο€β€² as

Ο€β‹…Ο€β€²=(x0,e0,x1,…,ekβˆ’1,xk,f0,y1,…,fβ„“βˆ’1,yβ„“)

that is, we concatenate the two lists and remove one occurrence of the repeated vertex xk=y0.

A walk is said to be simply labeled if each edge of the walk has at most one label.

Finally, a walk is called a trail if it contains no repeated edge. It is furthermore called a simple walk if it contains no repeated vertex.

When we are given a walk, typically as returned by a query, we assume that it is given together with all the data that occurs in the vertices and edges along the walk, namely their identifiers and labels. This is in line with real-life database systems, where a returned object can be subsequently inspected for any data it might contain. It will be useful to consider this data as its own database, as defined below.

Definition 6 (Data in a walk).

Let Ο€ be a walk in a database D. We define Data⁑(Ο€) as the restriction of D to the vertices and edges that occur in Ο€. Formally, Data⁑(Ο€) is the database DΟ€=(Ξ£,NodeΟ€,EdgeΟ€,SrcΟ€,TgtΟ€,LblΟ€) defined as:

  • β– 

    NodeΟ€={xβˆ£Ο€=Ο€1β‹…(x)β‹…Ο€2}

  • β– 

    EdgeΟ€={eβˆ£Ο€=Ο€1β‹…(x1,e,x2)β‹…Ο€2}

  • β– 

    SrcΟ€=Src|EdgeΟ€, TgtΟ€=Tgt|EdgeΟ€, LblΟ€=Lbl|EdgeΟ€

2.2 Queries and Automata

A regular path query (RPQ) is defined by a regular language. In real-life systems, RPQs are typically input with a syntax that resembles regular expressions. Here, we define queries using finite state automata, which makes formal proofs easier and allows a finer complexity analysis depending on whether the given automaton is deterministic. This does not affect the applicability of our upper bounds, as regular expressions can be translated to nondeterministic automata in linear time (see for instance [20]). Note that the same does not hold for deterministic automata, which is why the deterministic case enjoys better bounds.

Formally, lower bounds do not immediately translate from one setting to the other. Fortunately the proof for regular expressions happens to be extremely similar (see Remark 22). In examples, we will informally use regular expressions, which are more human-readable.

Definition 7 (Automaton).

A nondeterministic automaton A is a 5-tuple (Ξ£,S,Ξ”,I,F) where Ξ£ is a finite set of symbols, S is a finite set of states, IβŠ†S is the set of initial states, Ξ”βŠ†S×Σ×S is the set of transitions and FβŠ†S is the set of final or accepting states. We denote as Δ⁒(q,a) the set {p∣(q,a,p)βˆˆΞ”}, and for a set KβŠ†S, Δ⁒(K,a)=βˆͺq∈KΔ⁒(q,a).

An automaton A is deterministic if |I|≀1, and for all q,a∈SΓ—Ξ£, |Δ⁒(q,a)|≀1. In that case, we will interpret Ξ” as a partial function Ξ΄:SΓ—Ξ£β†’S, written in lowercase to avoid confusion.

We denote by L⁒(A) the language of A, that is, the set of words w such that Δ⁒(I,w)∩Fβ‰ βˆ….

A regular path query Q is defined by an automaton A. We use L⁒(Q) and L⁒(A) interchangeably. An RPQ Q matches walks which carry a label that belong to L⁒(Q):

Definition 8 (Match).

Let D be a database and Ο€ be a walk in D. We say that Ο€ matches an RPQ Q if Lbl⁑(Ο€)∩L⁒(Q)β‰ βˆ…. We denote as Match⁑(Q,D) the (possibly infinite) set of all walks of D that match Q.

Warning.

For simplicity, we assume that languages never contain the empty word Ρ. This is without loss of generality: the corner case where Ρ∈L⁒(Q) can be solved separately (see Appendix A) and excluding it avoids special cases and technical overhead in subsequent statements and proofs. From now on, matched walks always contain at least one edge.

2.3 Walk-based Semantics

When a database contains cycles, it may happen that an RPQ matches infinitely many walks. While this is not an issue in a theoretical context, real-life systems impose criteria that guarantee finiteness, known as semantics. We say that a semantics is walk-based if it returns a subset of Match⁑(Q,D). Let Q be an RPQ and D be a database. Let X be a semantics. We denote as QX⁒(D) the set of answers to Q under X. We focus on three specific walk-based semantics defined below:

  • β– 

    All-walks semantics: Qw⁒a⁒l⁒k⁒(D)=Match⁑(Q,D).

  • β– 

    Trail semantics: Qt⁒r⁒a⁒i⁒l⁒(D)={Ο€βˆˆMatch⁑(Q,D)βˆ£Ο€β’Β is a trail}.

  • β– 

    Shortest walk semantics: for each pair of vertices s,t, we define the minimal match length Ξ»s,t as Ξ»s,t=min({Len(Ο€)βˆ£Ο€βˆˆMatch(Q,D)Β andΒ sβ†’πœ‹t}. Under shortest walk semantics, Q only returns the walks whose length is minimal between their endpoints: Qs⁒h⁒o⁒r⁒t⁒(D)={Ο€βˆˆMatch⁑(Q,D)∣Len⁑(Ο€)=Ξ»Src⁑(Ο€),Tgt⁑(Ο€)}.

We will make use of some well-known properties of all-walks and trail semantics:

  • β– 

    RPQ under X∈{w⁒a⁒l⁒k,t⁒r⁒a⁒i⁒l} are monotonic: if DβŠ†Dβ€², then QX⁒(D)βŠ†QX⁒(Dβ€²).

  • β– 

    RPQ under w⁒a⁒l⁒k (resp. t⁒r⁒a⁒i⁒l) are closed under homomorphism (resp. edge-injective homomorphism): if Ο† is a homomorphism (resp. edge-injective homomorphism) from D to another database Dβ€², and Ο€βˆˆQX⁒(D), then φ⁒(Ο€)∈QX⁒(φ⁒(D)).

    Indeed, Lbl⁑(Ο€)βŠ†Lbl⁑(φ⁒(Ο€)), thus if Lbl⁑(Ο€)∩L⁒(Q)β‰ βˆ…, then Lbl⁑(φ⁒(Ο€))∩L⁒(Q)β‰ βˆ…. Additionally, if Ο€ is a trail and Ο† is edge-injective, then φ⁒(Ο€) is a trail.

Remark that neither property holds for shortest walk semantics: adding a new walk in D can make previous query answers disappear, as they might no longer be the shortest walks.

Example 9.

Let D be the database depicted below:

Let Q be the query defined by b⁒(a+⁒b)+, that is, L⁒(Q) contains all words which start with a b, end with another b, and without two consecutive b. Then we can evaluate Q over D under the three semantics. For the sake of readability, only the edges are listed in the walks below. Vertices are implicitly defined by the adjacent edges.

  • β– 

    Qt⁒r⁒a⁒i⁒l⁒(D)={(e2⁒e3⁒e4⁒e5),(e6⁒e7⁒e8)}

  • β– 

    Qs⁒h⁒o⁒r⁒t⁒(D)={(e0⁒e9⁒e0),(e0⁒e9⁒e0⁒e1),(e6⁒e7⁒e8)}

  • β– 

    Qw⁒a⁒l⁒k⁒(D) is an infinite set. In addition to walks in Qs⁒h⁒o⁒r⁒t and Qt⁒r⁒a⁒i⁒l, it also contains walks described by the following regular expression: e0⁒(e9⁒e0)+⁒(Ρ+e1).

Remark that Qs⁒h⁒o⁒r⁒t⁒(D) does not contain the β€œtop” walk (e2⁒e3⁒e4⁒e5), because Ξ»x2,x6=3, as witnessed by the β€œbottom” walk (e6⁒e7⁒e8). Conversely, Qt⁒r⁒a⁒i⁒l⁒(D) does not contain any of the β€œlooping” walks, such as (e0⁒e9⁒e0⁒e1), because they repeat e0.

3 View-based Query Determinacy

This section defines the view-based query determinacy problem in our setting, and proves several useful preliminary results that are the foundations of the following sections. It concludes with the proof of Theorem 1 that provides a PSpace lower bound for all three semantics.

Definition 10 (View).

A view 𝒱 is a finite set of queries. If all queries in 𝒱 are regular path queries, we say that 𝒱 is a regular path view.

Definition 11 (View image under X).

Let 𝒱 be a regular path view. Let X be an RPQ semantics and let D be a database. The view image of D through 𝒱 under X is the tuple 𝒱X⁒(D)=(VX⁒(D))Vβˆˆπ’±.

β–ΆΒ Remark 12.

The view image of a database D is a tuple of sets, one set for each query V in the view 𝒱. These sets could be infinite if X does not guarantee a finite output.

We now have all the tools to translate the classical definition of view-based query determinacy (see [19] for a reference) to our setting:

Definition 13 (Determinacy under X).

Let 𝒱 be a view and Q be a query. We say that 𝒱 determines Q under X, and we write 𝒱↠XQ if the following holds:

βˆ€D1,D2,𝒱X⁒(D1)=𝒱X⁒(D2)β‡’QX⁒(D1)=QX⁒(D2)

Informally, this definition states that 𝒱 determines Q if and only if there is a functional dependency from view images to query answers: as soon as two databases have the same view image, they must also return the same answers to the query.

Our goal is to solve the view-based query determinacy problem defined as:

Problem:Query determinacy under semantics XInput:A view ⁒𝒱=(V1,…,Vn),Β a query ⁒QQuestion:Does ⁒𝒱↠XQ⁒?

As in Definition 6, it will be useful to aggregate all data contained in a view image and consider it as a database:

Definition 14 (Data in a view under X).

Let D be a database, 𝒱 be a regular path view and X be an RPQ semantics. We extend Definition 6 to view images as follows:

Data⁑(𝒱X⁒(D))=⋃Vβˆˆπ’±β‹ƒΟ€βˆˆVX⁒(D)Data⁑(Ο€)
β–ΆΒ Remark 15 (Edge-covering Semantics).

Data⁑(𝒱X⁒(D)) is a substructure of D. As such, it is always finite, even if X is not a semantics that guarantees a finite output.

This finite structure is what gives meaning to all-walks semantics beyond being just a theoretical curiosity. Indeed, in our setting, all-walks semantics captures the family of RPQ semantics that are β€œedge-covering” [16]. Intuitively, edge-covering semantics return all edges that are useful to the query at least once. Formally, a semantics X is said to be β€œedge-covering” if and only if, for all queries Q and databases D, for all edges e in D, if there exists a walk Ο€β‹…(x,e,y)β‹…ΞΌβˆˆMatch⁑(Q,D), then there exists a walk Ο€β€²β‹…(x,e,y)β‹…ΞΌβ€²βˆˆQX⁒(D).

Let X be an edge-covering semantics. Then, it is not hard to see that for all views 𝒱, Data⁑(𝒱X⁒(D))=Data⁑(𝒱w⁒a⁒l⁒k⁒(D)). We will see that the content of Data⁑(𝒱X⁒(D)) alone suffices to decide determinacy, without requiring the more precise information contained in 𝒱X⁒(D). Thus, results for all-walks semantics naturally extend to edge-covering semantics.

An example of edge-covering semantics that has been studied in theoretical work is the β€œshortest witness” semantics [14]: for each vertices s,t and edge e, this semantics returns the shortest walks from s to t that contain e. Though not commonly implemented in practice, a similar behavior can usually be achieved in real-life systems that allow performing multiple matches and joining the resulting walks, as in GQL or Neo4j.

Example 16.

Recall the database D from Example 9 and query Q defined by b⁒(a+⁒b)+. Let 𝒱 be the view that contains only Q. Then Data⁑(𝒱w⁒a⁒l⁒k⁒(D))=D, as all edges of D occur in some walk of Qw⁒a⁒l⁒k⁒(D). The case of trail and shortest walk semantics are given below:

  • β– 

    Data⁑(𝒱t⁒r⁒a⁒i⁒l⁒(D)) =

  • β– 

    Data⁑(𝒱s⁒h⁒o⁒r⁒t⁒(D)) =

As is depicted above, under both trail and shortest walk semantics, some part of the database is β€œhidden” to the view.

The following two lemmas hint at the fact that Data⁑(𝒱X⁒(D)) actually contains all relevant information for answering query determinacy:

Lemma 17 (No hidden walks).

Let X∈{w⁒a⁒l⁒k,s⁒h⁒o⁒r⁒t,t⁒r⁒a⁒i⁒l}, D be a database, 𝒱 be a regular path view and Q be an RPQ. If there exists Ο€βˆˆQX⁒(D) such that Ο€ is not a walk in Data⁑(𝒱X⁒(D)), then 𝒱↠̸XQ.

Proof.

Let everything be defined as in the statement of the lemma. Let Ο€βˆˆQX⁒(D) such that Ο€ is not a walk in Data⁑(𝒱X⁒(D)). Then there exists an edge e that occurs in Ο€ but not in Data⁑(𝒱X⁒(D)). Let Dβ€² be a copy of D without this edge. Then one simply has to remark that 𝒱X⁒(D)=𝒱X⁒(Dβ€²), but Ο€βˆ‰QX⁒(Dβ€²). β—€

Lemma 18 (View image from view data).

Let X∈{w⁒a⁒l⁒k,s⁒h⁒o⁒r⁒t,t⁒r⁒a⁒i⁒l}. Let D be a database. Then 𝒱X⁒(D)=𝒱X⁒(Data⁑(𝒱X⁒(D))).

Proof.

Let Vβˆˆπ’±. We show that VX⁒(D)=VX⁒(Data⁑(𝒱X⁒(D))).

(βŠ†)

Let Ο€βˆˆVX⁒(D). Then, by definition, Ο€ is a walk in Data⁑(𝒱X⁒(D)). Thus, Ο€ matches V. Since Data⁑(𝒱X⁒(D)) is a substructure of D, if Ο€ is a trail in D, it is also a trail in Data⁑(𝒱X⁒(D)). Similarly, if Ο€ is a shortest walk between its endpoints in D, it is also a shortest walk in Data⁑(𝒱X⁒(D)).

(βŠ‡)

Let Ο€βˆˆVX⁒(Data⁑(𝒱X⁒(D))). As in the previous case, Ο€ is a walk of D that matches V, and if Ο€ is a trail in Data⁑(𝒱X⁒(D)), then it is a trail in D. The only interesting question is whether Ο€ is a shortest walk in D when X=s⁒h⁒o⁒r⁒t. Assume for the sake of contradiction that there is a walk Ο€β€²βˆˆVs⁒h⁒o⁒r⁒t⁒(D) such that Ο€β€² has the same endpoints as Ο€ and is shorter than Ο€. Then, by definition, Ο€β€² is a walk in Data⁑(𝒱s⁒h⁒o⁒r⁒t⁒(D)). Thus Ο€βˆ‰VX⁒(Data⁑(𝒱s⁒h⁒o⁒r⁒t⁒(D))), which is a contradiction.

β—€

β–ΆΒ Remark 19.

Lemma 18 means that under X∈{w⁒a⁒l⁒k,t⁒r⁒a⁒i⁒l,s⁒h⁒o⁒r⁒t}, only Data⁑(𝒱X⁒(D)) matters. We do not have to keep track of the specific view Vβˆˆπ’± which returned each element of 𝒱X⁒(D). Be careful that this property does not generally hold: one can easily design β€œexotic” semantics that are specifically tailored to falsify this property, such as:

  • β– 

    β€œSecond shortest walk”: return Ο€ if and only if its length is the second shortest length.

  • β– 

    β€œShortest walk hybrid”: return Qw⁒a⁒l⁒k⁒(D) if it is finite, otherwise return Qs⁒h⁒o⁒r⁒t⁒(D).

Lemma 17 and Lemma 18 imply that, in our setting, determinacy admits an alternate and much simpler definition:

Proposition 20 (Determinacy: alternate definition).

Let X∈{w⁒a⁒l⁒k,t⁒r⁒a⁒i⁒l,s⁒h⁒o⁒r⁒t}. Let 𝒱 be a regular path view and Q be an RPQ. Then 𝒱↠XQ if and only if for all databases D, for all walks Ο€βˆˆQX⁒(D), Ο€ is a walk in Data⁑(𝒱X⁒(D)).

Proof.

(β‡’)

This is immediately given as the contraposition of Lemma 17.

(⇐)

Assume that for all databases D, for all walks Ο€βˆˆQX⁒(D), Ο€ is a walk in Data⁑(𝒱X⁒(D)).

Let D1 and D2 be two databases such that 𝒱X⁒(D1)=𝒱X⁒(D2). Let Ο€βˆˆQX⁒(D1). Then Ο€βˆˆData⁑(𝒱X⁒(D1)), which yields Ο€βˆˆData⁑(𝒱X⁒(D2)). If X=w⁒a⁒l⁒k (resp. X=t⁒r⁒a⁒i⁒l), the result immediately follows: Ο€ is then a walk (resp. trail) in D2 that matches Q, thus Ο€βˆˆQX⁒(D2), which means 𝒱↠XQ.

Assume now that X=s⁒h⁒o⁒r⁒t. Since Ο€ is a walk of D2 that matches Q, there are two cases: either Ο€βˆˆQs⁒h⁒o⁒r⁒t⁒(D2) and there is nothing more to prove, or there exists a shorter walk ΞΌ in Qs⁒h⁒o⁒r⁒t⁒(D2) that has the same endpoints as Ο€. In that case, the assumption yields that ΞΌ is a walk in Data⁑(𝒱X⁒(D2)). Thus it is a walk in Data⁑(𝒱X⁒(D1)). This means that Ο€ is not a shorter walk in D1 either, which is a contradiction.

β—€

When the view determines the query, one may be interested in finding rewritings, that is, queries whose answer on the view image coincides with the answer to the original query on the original data [19]. This task may require additional techniques and ideas. In our setting, it turns out that the two tasks coincide. Indeed, Proposition 20 together with Lemma 18 lead to the corollary below, which states that when the view determines the query, a rewriting of the query is the query itself.

Corollary 21 (Rewriting).

Let X∈{w⁒a⁒l⁒k,t⁒r⁒a⁒i⁒l,s⁒h⁒o⁒r⁒t}. Let 𝒱 be a regular path view and Q be an RPQ such that 𝒱↠XQ. Let D be a database. Then QX⁒(D)=QX⁒(Data⁑(𝒱X⁒(D))).

We are now ready to prove the first complexity result: deciding determinacy is PSpace-hard under all-walks, trail and shortest walk semantics.

Theorem 1. [Restated, see original statement.]

Determinacy for regular path queries and views is PSpace-hard under all-walks, trail and shortest walk semantics, even if the automata that define the queries and views are deterministic.

Proof.

Let X∈{w⁒a⁒l⁒k,t⁒r⁒a⁒i⁒l,s⁒h⁒o⁒r⁒t}. The proof is done by reduction from the Intersection Emptiness problem [15], which asks, given n deterministic automata A1,…,An whether L⁒(A1)βˆ©β€¦βˆ©L⁒(An)=βˆ…. Here, we will use the equivalent Union Universality problem: given n deterministic automata A1,…,An, does L⁒(A1)βˆͺ…βˆͺL⁒(An)=Ξ£βˆ—?

Let s⁒t⁒a⁒r⁒t,e⁒n⁒d be two fresh symbols that do not occur in Ξ£. We define A as the usual 3-state deterministic automaton that accepts s⁒t⁒a⁒r⁒tβ‹…Ξ£βˆ—β‹…e⁒n⁒d and we extend each automaton Ai into a deterministic automaton Aiβ€² with a new initial and final state such that L⁒(Aiβ€²)=s⁒t⁒a⁒r⁒tβ‹…L⁒(Ai)β‹…e⁒n⁒d.

Then it remains to remark that Proposition 20 implies that {Aiβ€²}β† XA if and only if L⁒(A1)βˆͺ…βˆͺL⁒(An) is universal. β—€

β–ΆΒ Remark 22.

This lower bounds also holds when the input are given as regular expressions, with a very similar reduction from the Regular Expression Containment problem. [13]

4 All-walks and Trail Semantics

The goal of this section is to prove Theorem 2. To do so, we provide a decision procedure that works in PSpace. The main idea is to show that determinacy has the walk counterexample property: if there is a database D that falsifies the alternate definition of determinacy provided by Proposition 20, then D can be assumed to be a simply labeled simple walk.

Proposition 23 (Determinacy on simple walks).

Let X∈{w⁒a⁒l⁒k,t⁒r⁒a⁒i⁒l}. Let V be a regular path view and Q be an RPQ. Then 𝒱↠XQ if and only if, for all databases that consist of only a simply labeled simple walk Ο€ matching Q, Data⁑(𝒱X⁒(Ο€))=Data⁑(Ο€).

Proof.

(β‡’)

If 𝒱↠XQ, then Lemma 17 implies that Ο€ is a walk in Data⁑(𝒱X⁒(Ο€)). Since Data⁑(𝒱X⁒(Ο€)) is a substructure of Data(Ο€), this implies that Data⁑(𝒱X⁒(Ο€))=Data⁑(Ο€).

(⇐)

Conversely, assume that for all databases that consist of only a simply labeled simple walk Ο€ matching Q, Data⁑(𝒱X⁒(Ο€))=Data⁑(Ο€). Let D be an arbitrary database and Ο€ be a (not necessarily simple) walk in QX⁒(D).

Since Ο€ matches Q, there exists w∈Lbl⁑(Ο€) such that w∈L⁒(Q). Let ΞΌ be an unfolding of Ο€ that is simply labeled by w. Formally, ΞΌ is a copy of Ο€ in which each extra occurrence of a repeating edge or vertex of Ο€ is replaced by a fresh copy. Additionally, only one label of each edge is kept, so that Lbl⁑(ΞΌ)=w. Then, the assumption applied to the database that contains only ΞΌ yields Data⁑(𝒱X⁒(ΞΌ))=Data⁑(ΞΌ).

Assume X=w⁒a⁒l⁒k (resp. X = trail). Let Ο† be the homomorphism (resp. edge-injective homomorphism) that folds ΞΌ into Ο€, that is, Ο† maps each vertex and edge of ΞΌ to the original object in Ο€. Since X is closed under homomorphism (resp. edge-injective homomorphism), Data⁑(φ⁒(ΞΌ))βŠ†Data⁑(𝒱X⁒(φ⁒(ΞΌ))), which means Data⁑(Ο€)βŠ†Data⁑(𝒱X⁒(Ο€)).

Moreover, X is monotone, thus Data⁑(𝒱X⁒(Ο€))βŠ†Data⁑(𝒱X⁒(D)). This implies that Ο€ is a walk (resp. trail) in Data⁑(𝒱X⁒(D)). Therefore, Proposition 20 implies that 𝒱↠XQ.

β—€

Proposition 23 leads to the definition of a counterexample, that is, a specific word in L⁒(Q) whose existence proves that 𝒱↠̸XQ.

Definition 24 (Counterexample under all-walks and trail semantics).

Let X∈{w⁒a⁒l⁒k,t⁒r⁒a⁒i⁒l}. Let 𝒱 be a regular path view and Q be an RPQ. A counterexample for 𝒱 and Q under X is a word w∈L⁒(Q) such that:

  • β– 

    w=uβ‹…aβ‹…v for some u,vβˆˆΞ£βˆ— and a∈Σ;

  • β– 

    for all u1,u2,v1,v2βˆˆΞ£βˆ— such that u=u1β‹…u2 and v=v2β‹…v1, for all Vβˆˆπ’±, u2β‹…aβ‹…v2βˆ‰L⁒(V).

Proposition 25 (Counterexample criterion).

Let X∈{w⁒a⁒l⁒k,t⁒r⁒a⁒i⁒l}. Let 𝒱 be a regular path view and Q be an RPQ. 𝒱↠̸XQ if and only if there exists a counterexample for 𝒱 and Q under X.

Proof.

Proposition 25 is a simple consequence of Proposition 23. Indeed, 𝒱↠̸XQ if and only if there is a simply labeled simple walk Ο€ that matches Q such that Data⁑(𝒱X⁒(Ο€))β‰ Data⁑(Ο€), that is, there is an edge e of Ο€ such that e is not returned by any Vβˆˆπ’±. It then remains to remark that a suitable counterexample is w=Lbl⁑(Ο€), with a=Lbl⁑(e). β—€

Example 26.

We present a few examples of determinacy under X∈{w⁒a⁒l⁒k,t⁒r⁒a⁒i⁒l}. Let L⁒(Q)=b⁒(a+⁒b)+ as in Example 9.

  1. 1.

    L⁒(V1)=b⁒a++a+⁒b. Then {V1}β† XQ. Indeed, words w∈L⁒(Q) consist of concatenated blocks of the form b⁒a+⁒b, which are entirely β€œseen” by the view:

    While this example seems quite simple, it is interesting to remark that this is a case where 𝒱 does not determine Q under shortest walk semantics, as we will see in Example 29.

  2. 2.

    L⁒(V2)=b⁒a+⁒b. With the same argument, {V2}β† XQ. Remark that, under trail semantics, parts of the database that would match the query might be hidden to the view due to repeated edges. However, these parts will also not be usable by the query.

    In the example above, under X=t⁒r⁒a⁒i⁒l, the a-cycle is hidden to the view (no trail that matches V2 contains the top vertex), but it is also not in any answer to Q. Under X=w⁒a⁒l⁒k, the a-cycle appears both in the view image and in the query answers. The fact that cycles are never an issue is a consequence of Proposition 23.

  3. 3.

    L⁒(V3)=b⁒a⁒(a⁒a)βˆ—+(a⁒a)βˆ—β’a⁒b. In this case, the view only β€œsees” sequences of a of odd length, but those can combine to cover any length, as shown below. Hence, {V3}β† XQ.

    However, for L⁒(V3β€²)=b⁒a⁒(a⁒a⁒a)βˆ—+(a⁒a⁒a)βˆ—β’a⁒b, {V3β€²}β† ΜΈXQ. In the picture below, the word w=b⁒a⁒a⁒a⁒b∈L⁒(Q) but the middle a is β€œhidden”.

Remark that in all examples, 𝒱 contains a single query. This can actually be assumed without loss of generality, as a consequence of the proof of Theorem 2. Under X∈{t⁒r⁒a⁒i⁒l,w⁒a⁒l⁒k}, 𝒱↠XQ if and only if Va⁒l⁒lβ† XQ, where L⁒(Va⁒l⁒l)=⋃Vβˆˆπ’±L⁒(V). We will see in Example 29 that this is not true under X=s⁒h⁒o⁒r⁒t.

Proposition 25 is the main ingredient for proving Theorem 2: we show that the set of counterexamples is actually a regular language, whose emptiness can be checked in PSpace.

Theorem 2. [Restated, see original statement.]

Determinacy for regular path queries and views can be decided in PSpace under all-walks and trail semantics, even for nondeterministic query and view automata.

Proof.

Let X∈{w⁒a⁒l⁒k,s⁒h⁒o⁒r⁒t}. Let 𝒱={V1,…,Vn} be a regular path view and Q be a regular path query. Let L𝒱,Q be the set of counterexamples for 𝒱↠XQ as defined in Definition 24. Let A𝒱=(Ξ£,S𝒱,Δ𝒱,I𝒱,F𝒱) be any automaton for L⁒(V1)βˆͺ…βˆͺL⁒(Vn) and AQ=(Ξ£,SQ,Ξ”Q,IQ,FQ) be an automaton for Q. Our goal is to construct an automaton A𝒱,Q of at most exponential size such that L⁒(A𝒱,Q)=L𝒱,Q, whose emptiness can then be checked in PSpace.

The existence of A𝒱,Q can be shown by using well-known closure properties of regular languages. We do this in Appendix B. Here, we will instead show a direct construction of A𝒱,Q. In addition to proving Theorem 2, this also serves as an introduction to the main result of Section 5, which expands upon the construction shown here.

Intuitively, A𝒱,Q runs on a word w∈L⁒(Q) for which it nondeterministically guesses the factorization uβ‹…aβ‹…v that yields the position a that should be hidden to 𝒱. Then A𝒱,Q runs 𝒱 in parallel on each possible starting position in u, and checks that 𝒱 does not accept a factor of w that contains a.

Formally, A𝒱,Q=(Ξ£,S𝒱,Q,Δ𝒱,Q,I𝒱,Q,F𝒱,Q) is defined as follows:

  • β– 

    S𝒱,Q=SQΓ—2S𝒱×{0,1}

  • β– 

    I𝒱,Q=IQΓ—2I𝒱×{0}

  • β– 

    F𝒱,Q=FQΓ—2Sπ’±βˆ’F𝒱×{1}

  • β– 

    For q∈SQ,PβŠ†S𝒱 and b∈Σ, Δ𝒱,Q contains transitions of the following forms:

    1. 1.

      (q,P,0)→𝑏ΔQ⁒(q,b)Γ—{Δ𝒱⁒(P,b)βˆͺI𝒱}Γ—{0}

    2. 2.

      (q,P,0)→𝑏ΔQ⁒(q,b)Γ—{Δ𝒱⁒(P,b)}Γ—{1}  if Δ𝒱⁒(P,b)∩F𝒱=βˆ…

    3. 3.

      (q,P,1)→𝑏ΔQ⁒(q,b)Γ—{Δ𝒱⁒(P,b)}Γ—{1}  if Δ𝒱⁒(P,b)∩F𝒱=βˆ…

Claim 27.

L⁒(A𝒱,Q)=L𝒱,Q.

Assume that w∈L⁒(A𝒱,Q). Then A𝒱,Q has an accepting run over w that starts in some state (q0,P0,0) and ends in (qn,Pn,1). Remark that transitions of the form (2) have to be used exactly once, as they are the only transitions that change the last component from 0 to 1, and there is no transition that changes 1 back to 0. This defines a unique factorization of w as uβ‹…aβ‹…v, where the transition is used when reading a after having read u.

Then, we prove by a straightforward induction that the state (qi,Pi,fi) that is reached after reading the prefix wi of w of length i satisfies the following:

  • β– 

    qiβˆˆΞ”Q⁒(IQ,wi) simulates a run of AQ on wi.

  • β– 

    If i≀Len⁑(u), then Pi contains all states of A𝒱 that can be reached at position i by starting on any position before i. That is, p∈Pi if and only if there exists a suffix u2 of wi such that pβˆˆΞ”π’±β’(IV,u2).

  • β– 

    If iβ‰₯Len⁑(uβ‹…a), then Pi contains all states of A𝒱 that can be reached at the current position by starting on any position of u. That is, p∈Pi if and only if wi if of the form u1β‹…u2β‹…aβ‹…v2, with u=u1β‹…u2 and pβˆˆΞ”π’±β’(IV,u2β‹…aβ‹…v2).

We conclude the proof by remarking that transitions of the form (2) and (3) enforce that P∩F𝒱=βˆ…. This means that for all factorizations of w as u1β‹…u2β‹…aβ‹…v2β‹…v1 with u=u1β‹…u2 and v=v2β‹…v1, we have u2β‹…aβ‹…v2βˆ‰L⁒(A𝒱), which is precisely what Definition 24 requires. Thus w∈L𝒱,Q.

The converse direction is proved in a very similar way. Assume that w∈L𝒱,Q. Then w∈L⁒(Q) and is of the form w=uβ‹…aβ‹…v. We then exhibit an accepting run of A𝒱,Q on w that uses the nondeterministic transition (2) precisely when reading a.

Claim 28.

Emptiness of A𝒱,Q can be checked in PSpace.

This is done by performing a reachability test from any initial state of A𝒱,Q to any accepting state of A𝒱,Q. As A𝒱,Q is a graph of exponential size, it is well known that this can be done in PSpace.

Therefore, emptiness of L𝒱,Q can be checked in PSpace. Proposition 25 states that L𝒱,Q=βˆ… if and only if 𝒱↠XQ for X∈{w⁒a⁒l⁒k,t⁒r⁒a⁒i⁒l}. This concludes the proof. β—€

5 Shortest Walk Semantics

In this section, we prove Theorem 3. The proof reuses the ideas and the general approach of Section 4, which should be read first. However, the case of shortest walk semantics requires a much more careful and technical analysis. Section 5.1 presents the general idea and highlights what changes as compared to Section 4. Section 5.2 proves the main technical ingredient. Finally, Section 5.3 gives the PSpace decision procedure.

5.1 General Idea

As in Section 4, the starting point of our reasoning is Proposition 20: let Q be a regular path query and 𝒱 be a regular path view. Then Vβ† s⁒h⁒o⁒r⁒tQ if and only if, for each database D and shortest walk Ο€ of D that matches Q, each edge e of Ο€ belongs to some walk in Vs⁒h⁒o⁒r⁒t⁒(D). What differs compared to Section 4 is that there are two cases that might cause an edge e to be missing from the view image:

  1. 1.

    Either e does not belong to any walk that matches some Vβˆˆπ’±, in which case the semantics under which V is evaluated does not matter.

  2. 2.

    Or e does belong to some walk Ο€ that matches Vβˆˆπ’±, but all such walks are not shortest walks: one can always find a shorter walk Ο€β€² with the same endpoints that also matches V. Thus V does not return Ο€ under shortest walk semantics.

Case 2 hints at the fact that Proposition 23 is no longer true: under shortest walk semantics, determinacy does not have the walk counterexample property. There exists a regular path view 𝒱 and an RPQ Q such that 𝒱↠̸s⁒h⁒o⁒r⁒tQ, but all databases that witness this fact are not simple walks. This is shown in Example 29 below.

Example 29.

Recall Q and V1 defined by L⁒(Q)=b⁒(a+⁒b)+ and L⁒(V1)=b⁒a++a+⁒b from Example 26. Let 𝒱={V1}. Then 𝒱↠̸s⁒h⁒o⁒r⁒tQ, as witnessed by the following database D:

Indeed, Qs⁒h⁒o⁒r⁒t⁒(D) contains the β€œhorizontal” walk labeled b⁒a⁒a⁒a⁒b. However, the middle edge (highlighted in red) does not belong to 𝒱s⁒h⁒o⁒r⁒t⁒(D). Indeed, despite belonging to the β€œhorizontal” walks labeled b⁒a⁒a, b⁒a⁒a⁒a, a⁒a⁒b and a⁒a⁒a⁒b, none of these walks are shortest walks. For instance, the walk labeled b⁒a⁒a is of length 3, but the β€œtop” walk labeled a⁒b is shorter, matches V1 and has the same endpoints. However, we already know from Example 26 that 𝒱 does determine Q on databases that are simple walks.

Interestingly, this example only works when the matched walk contains a single sequence of a. Indeed, when Ο€ contains two sequences of a, either the bottom or top β€œshortcuts” make it so that the β€œhorizontal” walk is no longer a shortest walk, and thus need not be returned.

As shown on the picture above, if one tries to β€œhide” the red edge with the bottom β€œshortcut”, then the blue walk becomes the shortest walk that matches Q from the leftmost vertex to the rightmost vertex. Therefore, the fact that the red edge is missing from the view is not an issue anymore. Thus, as counterintuitive as it may seem, 𝒱↠s⁒h⁒o⁒r⁒tb⁒(a+⁒b)⁒(a+⁒b)+.

Another important remark is that, contrary to what is explained in Example 26, under shortest walk semantics, we cannot assume that all queries of 𝒱 are grouped in a single query L⁒(Va⁒l⁒l)=⋃Vβˆˆπ’±L⁒(V). Indeed, one can see that {(b⁒a+),(a+⁒b)}β† s⁒h⁒o⁒r⁒tb⁒(a+⁒b)+: in that case, a walk labeled b⁒a⁒a can only be shortcut by a walk labeled b⁒a, and not by a walk labeled a⁒b.

As illustrated in Example 29, counterexamples in the case of shortest walk semantics are more involved than in the case of walk and trail semantics. Here, a counterexample is a pair (Ο€,e), where Ο€ is a walk that matches Q and e is an edge of Ο€, such that, for each Vβˆˆπ’±, for each factorization of Ο€ as ΞΌ1β‹…ΞΌ2β‹…eβ‹…Ξ½2β‹…Ξ½1, one of the following holds. See the figure below to help visualize notations.

  1. 1.

    Lbl⁑(ΞΌ2β‹…(e)β‹…Ξ½2)βˆ‰L⁒(V).

  2. 2.

    There is a ρ such that Len⁑(ρ)≀Len⁑(ΞΌ2β‹…eβ‹…Ξ½2), Lbl⁑(ρ)∈L⁒(V) and Lbl⁑(ΞΌ1⋅ρ⋅ν1)βˆ‰L⁒(Q).

As in the case of all-walks and trail semantics, it turns out that determinacy can be decided by only looking at the labels of counterexamples: we show in Section 5.2 how to prove a counterpart to Proposition 25 for shortest walk semantics. Then, we show in Section 5.3 that the set of these labels is a regular language. Thus, deciding determinacy amounts to checking the emptiness of this language. When Q is given as a deterministic automaton, we show that we can define an automaton of exponential size that precisely accepts this language and conclude that determinacy can be decided in PSpace.

5.2 Counterexample under Shortest Semantics

Definition 30 and Proposition 31 defined below are the key technical ingredients of Theorem 3.

Definition 30 (Counterexample under shortest semantics).

Let 𝒱 be a regular path view and Q be an RPQ. A counterexample for 𝒱 and Q under s⁒h⁒o⁒r⁒t is a word w=uβ‹…aβ‹…v, with u,vβˆˆΞ£βˆ— and a∈Σ such that w∈L⁒(Q), and for all u1,u2,v1,v2βˆˆΞ£βˆ— such that u=u1β‹…u2 and v=v2β‹…v1, for all Vβˆˆπ’±, one of the following holds:

  • β– 

    u2β‹…aβ‹…v2βˆ‰L⁒(V);

  • β– 

    there exists r∈L⁒(V) such that Len⁑(r)<Len⁑(u2β‹…aβ‹…v2) and u1β‹…rβ‹…v1βˆ‰L⁒(Q).

Proposition 31.

Let 𝒱 be a regular path view and Q be an RPQ. 𝒱↠̸s⁒h⁒o⁒r⁒tQ if and only if there exists a counterexample for 𝒱 and Q under s⁒h⁒o⁒r⁒t.

Proof.

(⇐)

Assume that there exists a counterexample w=uβ‹…aβ‹…v. Then we build a database D as follows:

  1. 1.

    Add a simple walk Ο€ with Lbl⁑(Ο€)=w. Let ΞΌ and Ξ½ be the walks such that Ο€=ΞΌβ‹…eβ‹…Ξ½ with Lbl⁑(ΞΌ)=u, Lbl⁑(Ξ½)=v and Lbl⁑(e)=a.

  2. 2.

    For each Vβˆˆπ’±, for each factorization of ΞΌ as ΞΌ1β‹…(x)β‹…ΞΌ2 and Ξ½ as Ξ½2β‹…(y)β‹…Ξ½1, with x,y two vertices of D:

    • β– 

      If Lbl⁑(ΞΌ2β‹…eβ‹…Ξ½2)βˆ‰L⁒(V), there is nothing to do, and we continue with the next factorization.

    • β– 

      If Lbl⁑(ΞΌ2β‹…eβ‹…Ξ½2)∈L⁒(V), we choose a word r∈L⁒(V) such that Len⁑(r)<Len⁑(ΞΌ2β‹…aβ‹…Ξ½2) and Lbl⁑(ΞΌ1β‹…rβ‹…v1)βˆ‰L⁒(Q). We know that such a word exists by definition of w. Then we add to D a simple walk Ο€V,x,y using only fresh vertices from x to y with Lbl⁑(Ο€V,x,y)=r.

Then it is easy to check that Ο€ is the shortest walk from its source to its target that matches Q. Thus Ο€βˆˆQs⁒h⁒o⁒r⁒t⁒(D). However, e is not in 𝒱s⁒h⁒o⁒r⁒t⁒(D). Indeed, for every Vβˆˆπ’±, for every walk that contains e, either the walk is not matched by V, or D contains a strictly shorter walk with the same endpoints that matches V and does not contain e.

(β‡’)

Assume that 𝒱↠̸s⁒h⁒o⁒r⁒tQ. Proposition 20 implies that there exists a database D and a walk Ο€ in D such that Ο€βˆˆQs⁒h⁒o⁒r⁒t⁒(D) and Ο€ is not a walk in Data⁑(𝒱s⁒h⁒o⁒r⁒t⁒(D)). Since Ο€ is not a walk in Data⁑(𝒱s⁒h⁒o⁒r⁒t⁒(D)), at least one edge e of Ο€ does not belong to 𝒱s⁒h⁒o⁒r⁒t⁒(D). Thus, Ο€ is of the form ΞΌβ‹…eβ‹…Ξ½.

Let w=Lbl⁑(Ο€), u=Lbl⁑(ΞΌ), v=Lbl⁑(Ξ½) and a=Lbl⁑(e). Then w=uβ‹…aβ‹…v. It remains to show that w is a counterexample.

Let u=u1β‹…u2 and v=v2β‹…v1 be factorizations of u and v. Let ΞΌ=ΞΌ1β‹…(x)β‹…ΞΌ2 be the corresponding factorization of ΞΌ, that is, Lbl⁑(ΞΌ1)=u1 and Lbl⁑(ΞΌ2)=u2. Similarly, let Ξ½=Ξ½2β‹…(y)β‹…Ξ½1 be the corresponding factorization of Ξ½.

Remark that ΞΌ2β‹…eβ‹…Ξ½2 is a walk from (x) to (y). Let Vβˆˆπ’±. Since e does not belong to 𝒱s⁒h⁒o⁒r⁒t⁒(D), then ΞΌ2β‹…eβ‹…Ξ½2βˆ‰V⁒(D). There are two possibilities:

  1. 1.

    ΞΌ2β‹…eβ‹…Ξ½2 does not match V. This precisely means that u2β‹…aβ‹…v2βˆ‰L⁒(V), which satisfies the first requirement for counterexamples.

  2. 2.

    ΞΌ2β‹…eβ‹…Ξ½2 matches V but is not a shortest walk among walks from (x) to (y) that match V. Thus D contains a shorter walk ρ from (x) to (y) such that ρ∈Vs⁒h⁒o⁒r⁒t⁒(D). Let r=Lbl⁑(ρ). Then Len⁑(r)<Len⁑(u2β‹…aβ‹…v2) and r∈L⁒(V). Finally, remark that ΞΌ1⋅ρ⋅ν1 is shorter than Ο€ and has the same endpoints. Thus ΞΌ1⋅ρ⋅ν1 does not match Q, otherwise Ο€βˆ‰Qs⁒h⁒o⁒r⁒t⁒(D). This implies that u1β‹…rβ‹…v1βˆ‰L⁒(Q), which satisfies the second requirement for counterexamples.

β—€

5.3 Decision Procedure

We now have all ingredients to prove Theorem 3 below. This is done by showing that the set of counterexamples as defined in Definition 30 is actually a regular language, whose emptiness is equivalent to determinacy, as proved in Proposition 31. It now remains to give an automaton of at most exponential size that precisely accepts this language.

Theorem 3. [Restated, see original statement.]

Determinacy for regular path queries and views can be decided in PSpace under shortest walk semantics, provided that the query is given as a deterministic automaton.

Proof.

Let 𝒱={V1,…,Vn} be a regular path view and Q be a regular path query. Let L𝒱,Q be the set of counterexamples for 𝒱↠s⁒h⁒o⁒r⁒tQ, as defined in Definition 30. For each Vβˆˆπ’±, let AV=(Ξ£,SV,Ξ”V,IV,FV) be any automaton for L⁒(V) and AQ=(Ξ£,SQ,Ξ΄Q,q0,FQ) be a deterministic automaton for L⁒(Q). The automaton A𝒱,Q for L𝒱,Q is a much more involved version of the automaton used in the proof of Theorem 2, which should be read first.

Intuitively, A𝒱,Q runs on a word w∈L⁒(Q) for which it nondeterministically guesses the factorization uβ‹…aβ‹…v and the position a that should be hidden to 𝒱. For each factor wβ€² (denoted as u2β‹…aβ‹…v2 in Definition 30) of w that contains a, for each Vβˆˆπ’±, either wβ€² does not belong to L⁒(V) (as in Theorem 2) or A𝒱,Q nondeterministically guesses a β€œshortcut” for wβ€²: a word r∈L⁒(V) such that Len⁑(r)<Len⁑(wβ€²), and maintains information to ensure that using this β€œshortcut” (ie, replacing wβ€² with r in w) does not create an accepting run of AQ.

Instead of giving an explicit transition table for A𝒱,Q, which would be very technical and not very informative, we give a high-level description of the information that are maintained and propagated throughout a computation of A𝒱,Q on w=uβ‹…aβ‹…v. At step (i) of the computation, a state of A𝒱,Q encodes the following information:

  • β– 

    The state q(i)∈SQ of the computation of AQ at step (i) on w.

  • β– 

    A bit Mid(i) that nondeterministically flips to 1 to say when uβ‹…a has been read.

  • β– 

    For each Vβˆˆπ’±, an array RunV(i)⁒[p,n]βŠ†SV that maps each p∈SQ and integer n≀|SQ|Γ—|SV|+1 to the states of SV that are reachable after a run of AV on a factor of w that started before Mid flipped, at step (iβˆ’n), with the added information that q(iβˆ’n)=p. Note that, thanks to standard pumping lemma techniques, we only count n up to NV=|SQ|Γ—|SV|+1, as will be explained below.

    This is a major difference with the proof of Theorem 2. Knowing when AV accepts a factor that contains a is not enough: we also need to know the length n of said factor (in order to find a shorter β€œshortcut”) and the state p of AQ at the beginning of said factor (to ensure that using the β€œshortcut” does not yield an accepting run of AQ).

  • β– 

    A set Err(i)βŠ†SQ that contains β€œerror” states of AQ, that is, states that can be reached at step (i) by taking one of the β€œshortcuts”. Err must contain no accepting state at the end of the computation. Err(i) is populated as follows:

    1. (a)

      If Mid(i)=0, Err(i)=βˆ…. There are no β€œshortcuts” before uβ‹…a.

    2. (b)

      Otherwise, Err(i)←δQ⁒(Err(iβˆ’1),wi), where wi is the ith symbol in w. We propagate the states in Err according to the transition function of AQ.

    3. (c)

      Then, if RunV(i)⁒[p,n]∩FVβ‰ βˆ…, this means that the suffix of length n at step (i) would reveal a through V. Nondeterministically guess a word r∈L⁒(V) such that Len⁑(r)<n and add qe⁒r⁒r=Ξ΄Q⁒(p,r) to Err(i): using this β€œshortcut” brings AQ to qe⁒r⁒r at step (i).

Item (c) is the most critical part. Its correctness hinges on the following key remarks:

  • β– 

    If no suitable r∈L⁒(V) exists, the run aborts and rejects w. This corresponds to the case where there is no way to prevent V from revealing a.

  • β– 

    When nβ‰₯NV, we no longer need to know the precise value of n. Indeed, due to standard pumping lemma techniques, if there exists a word r∈L⁒(V) of length n such that Ξ΄Q⁒(p,r)=qe⁒r⁒r, then there exists a similar rβ€² with Len⁑(rβ€²)<NV.

  • β– 

    AQ being deterministic is crucial here. It ensures that at step (iβˆ’n), AQ is in a unique state p. Keeping track of all possible runs of a nondeterministic automaton would require RunV(i) to be of exponential size.

Figure 1 provides a visual help for notations and update rules on a step (i) that occurs after the hidden edge, shown in red. Remark that each state only stores a polynomial amount of information, which means that A𝒱,Q is of exponential size in the size of Q and 𝒱. Thus, checking its emptiness can be done in PSpace.

It remains to show that L⁒(A𝒱,Q)=L𝒱,Q. As in the proof of Theorem 2, this is done by a technical but not very informative induction that shows that the invariants on Figure 1 are maintained. The precise update rules for A𝒱,Q are given in Appendix C, along with the induction hypotheses. This concludes the proof. β—€

Figure 1: Notations and invariants for the proof of Theorem 3 at step (i) after the hidden edge.

6 Conclusion

We have shown that the view-based query determinacy problem is decidable for regular path queries and views under three walk-based semantics: all-walks, trail and shortest walk semantics. We focused on trail and shortest walk semantics due to their prevalence in real-life systems, but our techniques naturally extend to other semantics. On the one hand, our analysis of trail semantics naturally extends to semantics that filter out results based on topological constraints (called restrictors in GQL [5], or filter-based in [16]), such as acyclic or simple walk semantics. On the other hand, the general idea for shortest walk semantics most likely111This claim is more prudent than for restrictors due to the wide variety of imaginable ranking criteria! applies to other ranking semantics (called selectors in GQL, or order-based in [16]), which return the β€œbest” results according to some criterion, such as k-shortest or cheapest.

Complexity-wise, we proved that the problem is PSpace-hard under all three semantics, and provided a matching upper bound under all-walks and trail semantics. The case of shortest walk semantics is not entirely solved: our results only show that the problem is PSpace-complete when the query is given as a deterministic automaton. Determinizing the input in order to apply our decision procedure would yield an ExpSpace upper bound, which does not match the known lower bound. We leave the search for a tighter lower bound or a more efficient upper bound for future work.

Note that we have only considered the static analysis version of the problem. Another interesting direction for future work is the study of view-based query processing tasks where the view image is given as input, such as computing certain answers and non-answers [1].

References

  • [1] Serge Abiteboul and Oliver M. Duschka. Complexity of answering queries using materialized views. In Proceedings of the Seventeenth ACM SIGACT-SIGMOD-SIGART Symposium on Principles of Database Systems, PODS ’98, pages 254–263, New York, NY, USA, 1998. Association for Computing Machinery. doi:10.1145/275487.275516.
  • [2] Foto N. Afrati. Determinacy and query rewriting for conjunctive queries and views. Theoretical Computer Science, 412(11):1005–1021, 2011. doi:10.1016/j.tcs.2010.12.031.
  • [3] Renzo Angles, Marcelo Arenas, Pablo BarcelΓ³, Peter A. Boncz, George H. L. Fletcher, Claudio Gutierrez, Tobias Lindaaker, Marcus Paradies, Stefan Plantikow, Juan F. Sequeda, Oskar van Rest, and Hannes Voigt. G-CORE: A core for future graph query languages. In SIGMOD, pages 1421–1432. ACM, 2018. doi:10.1145/3183713.3190654.
  • [4] Diego Calvanese, Giuseppe De Giacomo, Maurizio Lenzerini, and Moshe Y. Vardi. Lossless regular views. In Proceedings of the Twenty-First ACM SIGMOD-SIGACT-SIGART Symposium on Principles of Database Systems, PODS ’02, pages 247–258, New York, NY, USA, 2002. Association for Computing Machinery. doi:10.1145/543613.543646.
  • [5] 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, Hannes Voigt, Oskar van Rest, Domagoj Vrgoč, Mingxi Wu, and Fred Zemke. Graph pattern matching in GQL and SQL/PGQ. In SIGMOD’22. ACM, 2022.
  • [6] Nadime Francis. Asymptotic Determinacy of Path Queries using Union-of-Paths Views. Theory of Computing Systems, 61(1):156–190, July 2017. doi:10.1007/s00224-016-9697-x.
  • [7] Nadime Francis, AmΓ©lie Gheerbrant, Paolo Guagliardo, Leonid Libkin, Victor Marsault, Wim Martens, Filip Murlak, Liat Peterfreund, Alexandra Rogova, and Domagoj Vrgoč. A Researcher’s Digest of GQL. In Floris Geerts and Brecht Vandevoort, editors, ICDT’23, volume 255 of LIPIcs. Schloss Dagstuhl – Leibniz-Zentrum fΓΌr Informatik, 2023. doi:10.4230/LIPIcs.ICDT.2023.1.
  • [8] Nadime Francis, Alastair Green, Paolo Guagliardo, Leonid Libkin, Tobias Lindaaker, Victor Marsault, Stefan Plantikow, Mats Rydberg, Petra Selmer, and AndrΓ©s Taylor. Cypher: An evolving query language for property graphs. In Proceedings of the 2018 International Conference on Management of Data, SIGMOD ’18, pages 1433–1445, New York, NY, USA, 2018. Association for Computing Machinery. doi:10.1145/3183713.3190657.
  • [9] Nadime Francis, Luc Segoufin, and Cristina Sirangelo. Datalog Rewritings of Regular Path Queries using Views. Logical Methods in Computer Science, 11(4), December 2015. doi:10.2168/LMCS-11(4:14)2015.
  • [10] Grzegorz GΕ‚uch, Jerzy Marcinkowski, and Piotr Ostropolski-Nalewaja. The First Order Truth Behind Undecidability of Regular Path Queries Determinacy. In 22nd International Conference on Database Theory (ICDT 2019), volume 127 of Leibniz International Proceedings in Informatics (LIPIcs), pages 15:1–15:18, Dagstuhl, Germany, 2019. Schloss Dagstuhl – Leibniz-Zentrum fΓΌr Informatik. doi:10.4230/LIPIcs.ICDT.2019.15.
  • [11] Tomasz Gogacz and Jerzy Marcinkowski. The hunt for a red spider: Conjunctive query determinacy is undecidable. In Logic in Computer Science (LICS), 2015 30th Annual ACM/IEEE Symposium on, pages 281–292, United States, 2015. Institute of Electrical and Electronics Engineers. doi:10.1109/LICS.2015.35.
  • [12] Tomasz Gogacz and Jerzy Marcinkowski. Red spider meets a rainworm: Conjunctive query finite determinacy is undecidable. In Proceedings of the 35th ACM SIGMOD-SIGACT-SIGAI Symposium on Principles of Database Systems, PODS ’16, pages 121–134, New York, NY, USA, 2016. Association for Computing Machinery. doi:10.1145/2902251.2902288.
  • [13] Harry B. Hunt, Daniel J. Rosenkrantz, and Thomas G. Szymanski. On the equivalence, containment, and covering problems for the regular and context-free languages. Journal of Computer and System Sciences, 12(2):222–268, 1976. doi:10.1016/S0022-0000(76)80038-4.
  • [14] Sara Khichane. Study of new semantics for regular path queries. Master’s thesis, UniversitΓ© Paris-CitΓ©, 2024.
  • [15] Dexter Kozen. Lower bounds for natural proof systems. In 18th Annual Symposium on Foundations of Computer Science (sfcs 1977), pages 254–266, 1977. doi:10.1109/SFCS.1977.16.
  • [16] Victor Marsault and Antoine Meyer. Designing and comparing rpq semantics. In ICDT’26, 2026. To appear.
  • [17] Wim Martens, Matthias Niewerth, and Tina Popp. A trichotomy for regular trail queries. Logical Methods in Computer Science, Volume 19, Issue 4, December 2023. doi:10.46298/lmcs-19(4:20)2023.
  • [18] Alberto O. Mendelzon and Peter T. Wood. Finding regular simple paths in graph databases. SIAM Journal on Computing, 24(6):1235–1258, 1995. doi:10.1137/S009753979122370X.
  • [19] Alan Nash, Luc Segoufin, and Victor Vianu. Views and queries: Determinacy and rewriting. ACM Trans. Database Syst., 35(3), 2010. doi:10.1145/1806907.1806913.
  • [20] Jean-Γ‰ric Pin, editor. Handbook of Automata Theory, volume 1. EMS, 2021.
  • [21] TigerGraph Team. TigerGraph Documentation – version 3.1, 2021. URL: https://docs.tigergraph.com/.

Appendix A Handling Empty Words in Query and View Languages

In this section, we show how the case where the views or the query accept the empty word Ξ΅ reduces to the case where Ξ΅ is forbidden, by using no more than Definition 13.

Proposition 32.

Let X∈{w⁒a⁒l⁒k,t⁒r⁒a⁒i⁒l,s⁒h⁒o⁒r⁒t}. Let Q be a regular path query and 𝒱 be a regular path view. Then 𝒱↠XQ if and only if:

  1. 1.

    If Ρ∈L⁒(Q), then there exists Vβˆˆπ’± such that Ρ∈L⁒(V);

  2. 2.

    {V~∣Vβˆˆπ’±}β† XQ~, where A~ is defined as any automaton such that L⁒(A~)=L⁒(A)βˆ–{Ξ΅}.

Proof.

Let 𝒱~={V~∣Vβˆˆπ’±}. Assume that 𝒱↠XQ.

  • β– 

    Assume that Ρ∈L⁒(Q). Let D be a database that contains only a single isolated vertex x, and let Dβ€² be the empty database. Then QX⁒(D)={(x)} and QX⁒(Dβ€²)=βˆ…. Assume for contradiction that for all Vβˆˆπ’±, Ξ΅βˆ‰L⁒(V). Then VX⁒(D)=VX⁒(Dβ€²)=βˆ…. However, QX⁒(D)β‰ QX⁒(Dβ€²), thus 𝒱↠̸XQ.

  • β– 

    Assume for contradiction that 𝒱~β† ΜΈXQ~. Then there exist two databases D and Dβ€² such that 𝒱~X⁒(D)=𝒱~X⁒(Dβ€²) but Q~X⁒(D)β‰ Q~X⁒(Dβ€²). Since Ξ΅βˆ‰L⁒(Q~), this means that there exists an edge e that occurs only in one of Q~X⁒(D) or Q~X⁒(Dβ€²). Since Q and Q~ only differ on walks of length 0, e also only occur in one of QX⁒(D) or QX⁒(Dβ€²). Remark now that since 𝒱~X⁒(D)=𝒱~X⁒(Dβ€²), 𝒱X⁒(D) and 𝒱X⁒(Dβ€²) only differ on walks of length 0, that is, isolated vertices in the view images. We build two new databases E and Eβ€² from D and Dβ€² by adding these isolated vertices to both E and Eβ€². It remains to remark that 𝒱X⁒(E)=𝒱X⁒(Eβ€²) while e still only occur in one of QX⁒(E) or QX⁒(Eβ€²). Thus 𝒱↠̸XQ.

Conversely, assume that Properties 1 and 2 hold. Let D and Dβ€² be two databases such that 𝒱X⁒(D)=𝒱X⁒(Dβ€²). In particular, 𝒱X⁒(D) and 𝒱X⁒(Dβ€²) contain the same walks of length greater than 0. Thus V~X⁒(D)=V~X⁒(Dβ€²), from which (2) implies that Q~X⁒(D)=Q~X⁒(Dβ€²). If Ξ΅βˆ‰L⁒(Q), this immediately yields QX⁒(D)=QX⁒(Dβ€²), hence 𝒱↠XQ. Otherwise, QX⁒(D) and QX⁒(Dβ€²) might differ on walks of length 0. However, (1) gives Vβˆˆπ’± such that Ρ∈L⁒(V). Since VX⁒(D)=VX⁒(Dβ€²), D and Dβ€² must have the same walks of length 0 (that is, D and Dβ€² have the same set of vertices). Thus QX⁒(D)=QX⁒(Dβ€²) which concludes the proof. β—€

Appendix B Alternate Construction of 𝑨π“₯,𝑸 for the Proof of Theorem 2

Let 𝒱={V1,…,Vn} be a regular path view and Q be a regular path query. By using standard automaton construction and closure properties, we show that there exists an automaton A𝒱,Q of exponential size (in the size of the automata that define 𝒱 and Q) that accepts L𝒱,Q, the set of counterexamples for 𝒱 and Q under w⁒a⁒l⁒k and t⁒r⁒a⁒i⁒l (see Definition 24).

Let Ξ£Λ™ be a disjoint copy of Ξ£, whose symbols are called marked symbols. For a∈Σ, we use aΛ™ to denote its copy in Ξ£Λ™.

Let MQ be the automaton that accepts words in L⁒(Q) with a single marked symbol, that is L⁒(MQ)={uβ‹…aΛ™β‹…v∣a∈Σ,uβ‹…aβ‹…v∈L⁒(Q)}. MQ is simply constructed as a copy of any automaton AQ for L⁒(Q) that nondeterministically guesses when to add the marked symbol, and is thus of polynomial size in the size of AQ.

Let A𝒱 be any automaton for L⁒(V1)βˆͺ…βˆͺL⁒(Vn). Similarly, let B𝒱 be a copy of A𝒱 that accepts words in L⁒(A𝒱) with a single marked symbol. Finally, let M𝒱 be an automaton such that L⁒(M𝒱)=Ξ£βˆ—β‹…L⁒(B𝒱)β‹…Ξ£βˆ—. Again, M𝒱 can be guaranteed to be of polynomial size in the size of A𝒱. Intuitively, M𝒱 contains the words in which 𝒱 β€œsees” the marked symbol.

Finally, let H𝒱 be an automaton for (L⁒(M𝒱)Β―)∩(Ξ£βˆ—β‹…Ξ£Λ™β‹…Ξ£βˆ—). Intuitively, H𝒱 accepts the words in which the marked symbol is β€œhidden” to 𝒱. Indeed, if w=uβ‹…aΛ™β‹…v is such that 𝒱 sees aΛ™, then w=u1β‹…u2β‹…aΛ™β‹…v2β‹…v1 with u2β‹…aβ‹…v2∈L⁒(V) for some Vβˆˆπ’±. This means that u2β‹…aΛ™β‹…v2∈L⁒(B𝒱) and thus u1β‹…u2β‹…aΛ™β‹…v2β‹…v1∈L⁒(M𝒱). Remark that H𝒱 can be guaranteed to be at most of exponential size in the size of M𝒱, with a standard construction for the complement of a nondeterministic automaton.

It then remains to remark that L𝒱,Q, is simply L⁒(H𝒱)∩L⁒(MQ) with the mark removed. Thus A𝒱,Q can be constructed as an automaton of at most exponential size.

Appendix C Additional Material for the Proof of Theorem 3

This section completes the proof of Theorem 3 given in Section 5.3.

C.1 Update Rules

A formal description of the transitions of A𝒱,Q are given by the update rules below. Notations follow the notations of the proof in Section 5.3.

Initial state.

  • β– 

    q(0)=q0, the initial state of AQ.

  • β– 

    RunV(0)⁒[q0,0]=IV. All other values are set to βˆ….

  • β– 

    Err(0)=βˆ….

Computation step strictly before 𝒖⋅𝒂 when reading a symbol π’ƒβˆˆπšΊ.

  • β– 

    q(i+1)←δQ⁒(q(i),b)

  • β– 

    Err(i+1)β†βˆ….

  • β– 

    For each Vβˆˆπ’±,p∈SQ,0<n≀NV:

    • –

      If n<NV, RunV(i+1)⁒[p,n+1]←ΔV⁒(RunV(i)⁒[p,n],b).

    • –

      If n=NV, RunV(i+1)⁒[p,n]βˆͺ=Ξ”V⁒(RunV(i)⁒[p,n],b).

  • β– 

    For each Vβˆˆπ’±,p∈SQ, RunV(i+1)⁒[p,0]β†βˆ… if pβ‰ q and RunV(i+1)⁒[q,0]←IV.

Computation step on or after 𝒖⋅𝒂, when reading a symbol π’ƒβˆˆπšΊ.

  • β– 

    q(i+1)←δQ⁒(q(i),b)

  • β– 

    Err(i+1)←δQ⁒(Err(i),b).

  • β– 

    For each Vβˆˆπ’±,p∈SQ,0<n≀NV:

    • –

      If n<NV, RunV(i+1)⁒[p,n+1]←ΔV⁒(RunV(i)⁒[p,n],b).

    • –

      If n=NV, RunV(i+1)⁒[p,n]βˆͺ=Ξ”V⁒(RunV(i)⁒[p,n],b).

  • β– 

    For each Vβˆˆπ’±,p∈SQ, RunV(i+1)⁒[p,0]β†βˆ….

  • β– 

    Then, for each Vβˆˆπ’±,p∈SQ,0<n≀NV:

    • –

      If RunV(i+1)⁒[p,n]∩FV=βˆ…, skip this step.

    • –

      Otherwise, nondeterministically choose a state qe⁒r⁒r such that there exists a word r∈L⁒(V) with Len⁑(r)<n and qe⁒r⁒r=δQ⁒(p,r). If no such r exists, abort the run.

    • –

      Err(i+1)←Err(i+1)βˆͺ{qe⁒r⁒r}.

End state.

Accepting states are states where Mid=1, q∈FQ and Err∩FQ=βˆ….

C.2 Induction Hypotheses

The correctness of A𝒱,Q comes from the following claim, that imitates Definition 30.

Claim 33.

Let w=uβ‹…aβ‹…vβˆˆΞ£βˆ— and assume that A𝒱,Q has a run on w such that Mid flips to 1 after reading uβ‹…a if and only if there exists a family of words (rV,k,β„“)Vβˆˆπ’±,k<Len⁑(u⁒a),Len⁑(u⁒a)≀ℓ≀Len⁑(w) such that, for each factorization of w as u1β‹…u2β‹…aβ‹…v2β‹…v1, for all Vβˆˆπ’±, one of the following holds:

  1. 1.

    u2β‹…aβ‹…v2βˆ‰L⁒(V);

  2. 2.

    rV,k,β„“βˆˆL⁒(V), where k=Len⁑(u1), β„“=Len⁑(uβ‹…aβ‹…v2), Len⁑(rV,k,β„“)<Len⁑(u2β‹…aβ‹…v2).

Moreover, this run is accepting if and only if w∈L⁒(Q) and in each case 2, u1β‹…rV,k,β„“β‹…v1βˆ‰L⁒(Q).

The proof of this claim is done by inductively constructing the family (rV,β„“,k) along a run of A𝒱,Q. The construction relies on the following induction hypotheses that hold at step (i) of the computation on w=w1⁒…⁒wd.

  • β– 

    q(0)=q0 and for i>0,q(i)=δQ⁒(q0,wi), where wi is the prefix of length i of w.

  • β– 

    For n<NV and iβˆ’n<Len⁑(uβ‹…a):

    RunV(i)⁒[q(iβˆ’n),n]=Δ⁒(IV,wiβˆ’n⁒…⁒wi)
  • β– 

    For n=NV and iβˆ’n<Len⁑(uβ‹…a) and p∈SQ:

    RunV(i)⁒[p,n]=⋃mβ‰₯nq(iβˆ’m)=pΔ⁒(IV,wiβˆ’m⁒…⁒wi)
  • β– 

    For i<Len⁑(uβ‹…a), Err(i)=βˆ….

  • β– 

    For iβ‰₯Len⁑(uβ‹…a):

    Err(i)=⋃k<ℓ≀iRunV(β„“)⁒[p,min⁑(β„“βˆ’k,NV)]∩FVβ‰ βˆ…Ξ΄Q⁒(q0,w1⁒…⁒wkβ‹…rV,k,β„“β‹…wβ„“+1⁒…⁒wi)

    where, in the equation above, p is any state in SQ, w1⁒…⁒wk is replaced by Ξ΅ if k=0 and wβ„“+1⁒…⁒wi is replaced by Ξ΅ if β„“=i.

Finally, the run is accepting if and only if q(d)∈FQ and Err(d)∩FQ=βˆ…, which is exactly what the claim requires.