Answering Path Queries under Linear and Guarded Existential Rules

arXiv cs.AI Papers

Summary

This paper studies the complexity of answering two-way (conjunctive) regular path queries over knowledge bases with linear and guarded existential rules, establishing completeness results for data and combined complexity.

arXiv:2607.22636v1 Announce Type: new Abstract: Ontology-mediated query answering is concerned with the problem of answering queries over knowledge bases consisting of a database instance and an ontology. While most work in the area focuses on conjunctive queries (CQs), navigational queries have gained increasing attention. In this paper, we investigate the complexity of answering two-way (conjunctive) regular path queries ((C)RPQs) over knowledge bases whose ontology is given by a set of guarded existential rules. We first consider the subclass of linear existential rules and show that (C)RPQ answering is NL-complete in data complexity, which matches the data complexity of answering RPQs over plain graph databases (i.e., without an ontology). In combined complexity, both tasks are ExpTime-complete in the general case, but RPQ and CRPQ answering drop to PTime-complete and PSpace-complete respectively if there is a bound on predicate arity. For guarded rules, we provide a non-trivial reduction to the linear case, which allows us to show that the complexity of (C)RPQ answering is the same as for CQs, namely 2ExpTime-complete in combined complexity (ExpTime-complete in the bounded-arity case) and PTime-complete in data complexity.
Original Article
View Cached Full Text

Cached at: 07/28/26, 06:27 AM

# Answering Path Queries under Linear and Guarded Existential Rules
Source: [https://arxiv.org/html/2607.22636](https://arxiv.org/html/2607.22636)
\\JAIRAE

Roberta Calegari\\JAIRTrack

Jean\-François Baget,Meghyn Bienvenu[0000\-0001\-6229\-8103](https://orcid.org/0000-0001-6229-8103)[meghyn\.bienvenu@labri\.fr](https://arxiv.org/html/2607.22636v1/mailto:[email protected])Univ\. Bordeaux, CNRS, Bordeaux INP, LaBRITalenceFrance,Marie\-Laure Mugnier[0000\-0002\-0574\-3693](https://orcid.org/%200000-0002-0574-3693)[mugnier@lirmm\.fr](https://arxiv.org/html/2607.22636v1/mailto:[email protected])LIRMM, Inria, University of Montpellier, CNRSMontpellierFranceandMichaël Thomazo[0000\-0002\-1437\-6389](https://orcid.org/0000-0002-1437-6389)[michael\.thomazo@inria\.fr](https://arxiv.org/html/2607.22636v1/mailto:[email protected])Inria, DIENS, ENS, PSL University, CNRSParisFrance

\(2026\)

###### Abstract\.

Ontology\-mediated query answering is concerned with the problem of answering queries over knowledge bases consisting of a database instance and an ontology\. While most work in the area focuses on conjunctive queries \(CQs\), navigational queries have gained increasing attention\. In this paper, we investigate the complexity of answering two\-way \(conjunctive\) regular path queries \(\(C\)RPQs\) over knowledge bases whose ontology is given by a set of guarded existential rules\. We first consider the subclass of linear existential rules and show that \(C\)RPQ answering is NL\-complete in data complexity, which matches the data complexity of answering RPQs over plain graph databases \(i\.e\., without an ontology\)\. In combined complexity, both tasks areExpTime\-complete in the general case, but RPQ and CRPQ answering drop toPTime\-complete andPSpace\-complete respectively if there is a bound on predicate arity\. For guarded rules, we provide a non\-trivial reduction to the linear case, which allows us to show that the complexity of \(C\)RPQ answering is the same as for CQs, namely 2ExpTime\-complete in combined complexity \(ExpTime\-complete in the bounded\-arity case\) andPTime\-complete in data complexity\.

††copyright:cc††journalyear:2026††doi:10\.1613/jair\.1\.xxxxx††journalvolume:4††article:111††publicationmonth:8††journalyear:2026## 1\.Introduction

Over the past two decades, significant research efforts have been devoted to*ontology\-mediated query answering*\(OMQA\), in which data is enriched with an ontology that expresses domain knowledge, and queries are answered by taking both the data and the ontology into account \(see e\.g\.\(Poggi et al\.,[2008](https://arxiv.org/html/2607.22636#bib.bib54)\)for a seminal early work and\(Xiao et al\.,[2018](https://arxiv.org/html/2607.22636#bib.bib58)\)for a short survey\)\. Adding an ontological layer on top of data allows a user to formulate queries in a more familiar way, closer to their conceptualization of the application domain, thereby abstracting from the actual structure of databases, which may have been designed for independent purposes\. On the other hand, it can also provide more complete answers to queries, as answers are based not only on facts explicitly stored in the data but also on those that are consequences of the ontology and the data\. Finally, in the context of data integration, it provides a uniform mediating layer that facilitates the integration of heterogeneous data sources\. The OMQA approach thus offers several important advantages, which are of relevance in diverse application areas \(we refer readers to\(Xiao et al\.,[2019](https://arxiv.org/html/2607.22636#bib.bib59)\)for an overview of OMQA applications\)\. However, the need to take ontological information into account when computing query answers can make the query answering task significantly more complex, depending on the expressivity of the ontology and query languages\.

Two families of ontology languages are mainly considered in OMQA, namely description logics \(DLs\) and existential rules \(see e\.g\. the survey chapters\(Ortiz and Simkus,[2012](https://arxiv.org/html/2607.22636#bib.bib52);Kontchakov et al\.,[2013](https://arxiv.org/html/2607.22636#bib.bib44);Bienvenu and Ortiz,[2015](https://arxiv.org/html/2607.22636#bib.bib12)\)on OMQA with DLs and\(Calì et al\.,[2009a](https://arxiv.org/html/2607.22636#bib.bib17);Mugnier and Thomazo,[2014](https://arxiv.org/html/2607.22636#bib.bib50)\)for existential rules\)\. These ontology languages allow one to reason in open domains, which means that existing entities are not supposed to be restricted to those explicitly encoded in the data\. Existential rules, also known as tuple generating dependencies\(Abiteboul et al\.,[1994](https://arxiv.org/html/2607.22636#bib.bib2)\), can be seen as an extension of Datalog \(equivalently, function\-free Horn rules\) with existentially quantified variables in the rule heads\. For instance, the following existential rule expresses that ‘every person has a parent who is a person’:∀x\.h​u​m​a​n​\(x\)→∃y\.h​a​s​P​a​r​e​n​t​\(x,y\)∧h​u​m​a​n​\(y\)\\forall x\.~human\(x\)\\rightarrow\\exists y\.~hasParent\(x,y\)\\land human\(y\)\. Applied to a fact likeh​u​m​a​n​\(a\)human\(a\), this rule leads to infer the existence of an infinite number of entites\. Existential rules generalize most DLs that are used in the context of data access, often referred to as Horn description logics\. More generally, they overcome some well\-known limitations of DLs by their unrestricted predicate arity and their ability to express non\-tree\-shaped relationships between atoms\. This added expressivity makes ground fact entailment undecidable \(e\.g\.\(Beeri and Vardi,[1981](https://arxiv.org/html/2607.22636#bib.bib9)\)\), however many decidable classes of existential rules have been exhibited, which offer different tradeoffs between expressivity and reasoning complexity\. We focus here on two central classes\(Calì et al\.,[2009b](https://arxiv.org/html/2607.22636#bib.bib18),[2013](https://arxiv.org/html/2607.22636#bib.bib16)\):*guarded*existential rules, in which the body of a rule has a guard, i\.e\., an atom that contains all the variables occurring in the rule body, and*linear*existential rules, a subclass of guarded rules in which the body of a rule is made of a single atom, as in the above example rule\.

As for the query language, most work on OMQA has focused on*conjunctive queries*\(CQs\), a fundamental query class in relational databases and in the Semantic Web, where this class is also known as basic graph pattern queries\. However, the increasing popularity of graph databases and the rise of knowledge graphs have shifted attention towards navigational queries\(Angles et al\.,[2017](https://arxiv.org/html/2607.22636#bib.bib3);Libkin et al\.,[2025](https://arxiv.org/html/2607.22636#bib.bib46)\), which are able to capture structural patterns of unbounded size\. The simplest such queries are*regular path queries*\(RPQs\)\(Cruz et al\.,[1987](https://arxiv.org/html/2607.22636#bib.bib27);Mendelzon and Wood,[1995](https://arxiv.org/html/2607.22636#bib.bib49);Calvanese et al\.,[2002](https://arxiv.org/html/2607.22636#bib.bib25)\), which ask for paths of potentially arbitrary length whose label conforms to a given regular language, hence allowing for a controlled form of recursion over binary predicates\. Many extensions of RPQs have been investigated, including*conjunctive regular path queries*\(CRPQs\)\(Florescu et al\.,[1998](https://arxiv.org/html/2607.22636#bib.bib35);Calvanese et al\.,[2000](https://arxiv.org/html/2607.22636#bib.bib24);Cucumides et al\.,[2023](https://arxiv.org/html/2607.22636#bib.bib28)\)which generalize both RPQs and CQs\. In particular, the core queries of SPARQL 1\.1 \(the W3C standard111SPARQL 1\.1 Query Language W3C Recommendation:[http://www\.w3\.org/TR/sparql11\-query](http://www.w3.org/TR/sparql11-query)for querying RDF data\) roughly correspond to CRPQs\. The next example illustrates these different types of queries in the context of ontology\-mediated query answering with existential rules\. It will be used as a running example throughout the paper to provide a high\-level overview of the key notions\. Additional dedicated examples will illustrate the details and subtilities underlying the technical constructions\.

###### Example 1 \(Running Example\)\.

Consider data describing relationships in a social network, which uses the predicates𝖿𝗈𝗅𝗅𝗈𝗐𝗌\\mathsf\{follows\}\(xx,yy\),𝗂𝗌𝖥𝗋𝗂𝖾𝗇𝖽𝖮𝖿\\mathsf\{isFriendOf\}\(xx,yy\) and𝗆𝖾𝗌𝗌𝖺𝗀𝖾\\mathsf\{message\}\(m,x,ym,x,y\), meaning that messagemmwas sent fromxxtoyy\. Asking for all pairs\(x,y\)\(x,y\)such thatxxandyyboth follow some person can be expressed as a CQ:

q1​\(x,y\)=∃z\.𝖿𝗈𝗅𝗅𝗈𝗐𝗌​\(x,z\)∧𝖿𝗈𝗅𝗅𝗈𝗐𝗌​\(y,z\)q\_\{1\}\(x,y\)=\\exists z\.~\\mathsf\{follows\}\(x,z\)\\land\\mathsf\{follows\}\(y,z\)It can also be expressed as an RPQ:

q2​\(x,y\)=𝖿𝗈𝗅𝗅𝗈𝗐𝗌⋅𝖿𝗈𝗅𝗅𝗈𝗐𝗌−​\(x,y\)q\_\{2\}\(x,y\)=\\mathsf\{follows\\cdot follows^\{\-\}\}\(x,y\)where the operator\-denotes the inverse relation\. Asking for pairs\(x,y\)\(x,y\)such thatyyis a direct or indirect follower ofxxcan be expressed by an RPQ but not by a CQ:

q3​\(x,y\)=𝖿𝗈𝗅𝗅𝗈𝗐𝗌−⋅\(𝖿𝗈𝗅𝗅𝗈𝗐𝗌−\)∗​\(x,y\)q\_\{3\}\(x,y\)=\\mathsf\{follows\}^\{\-\}\\cdot\(\\mathsf\{follows\}^\{\-\}\)^\{\*\}\(x,y\)In turn, asking for pairs\(x,y\)\(x,y\)such thatxxandyyfollow each other can be expressed by a CQ but not by an RPQ:

q4​\(x,y\)=𝖿𝗈𝗅𝗅𝗈𝗐𝗌​\(x,y\)∧𝖿𝗈𝗅𝗅𝗈𝗐𝗌​\(y,x\)q\_\{4\}\(x,y\)=\\mathsf\{follows\}\(x,y\)\\land\\mathsf\{follows\}\(y,x\)Now, to retrieve pairs\(x,y\)\(x,y\)such thatxxfollowsyyandyydirectly or indirectly followsxxrequires the expressivity of a CRPQ, which generalizesq4q\_\{4\}by replacing a standard predicate with a path expression:

q5​\(x,y\)=𝖿𝗈𝗅𝗅𝗈𝗐𝗌​\(x,y\)∧𝖿𝗈𝗅𝗅𝗈𝗐𝗌⋅𝖿𝗈𝗅𝗅𝗈𝗐𝗌∗​\(y,x\)q\_\{5\}\(x,y\)=\\mathsf\{follows\}\(x,y\)\\land\\mathsf\{follows\\cdot follows\}^\{\*\}\(y,x\)Asking whether user𝖠𝗅𝗂𝖼𝖾\\mathsf\{Alice\}received a message from someone she follows directly or indirectly can be expressed by a \(Boolean\) CRPQ:

q6​\(\)=∃y,m\.𝖿𝗈𝗅𝗅𝗈𝗐𝗌⋅𝖿𝗈𝗅𝗅𝗈𝗐𝗌∗​\(A​l​i​c​e,y\)∧m​e​s​s​a​g​e​\(m,y,A​l​i​c​e\)q\_\{6\}\(\)=\\exists y,m\.~\\mathsf\{follows\\cdot follows\}^\{\*\}\(Alice,y\)\\land message\(m,y,Alice\)Now, let us add ontological knowledge stating that \(1\) the relation𝗂𝗌𝖥𝗋𝗂𝖾𝗇𝖽𝖮𝖿\\mathsf\{isFriendOf\}is symmetric, \(2\) it is a specific case of the relation𝖿𝗈𝗅𝗅𝗈𝗐𝗌\\mathsf\{follows\}, and \(3\) following someone implies sending her a message\. This can be expressed using the following three linear rules:

> \(ρ1\)\(\\rho\_\{1\}\)∀x,y\.𝗂𝗌𝖥𝗋𝗂𝖾𝗇𝖽𝖮𝖿​\(x,y\)→𝗂𝗌𝖥𝗋𝗂𝖾𝗇𝖽𝖮𝖿​\(y,x\)\\forall x,y\.~\\mathsf\{isFriendOf\}\(x,y\)\\rightarrow\\mathsf\{isFriendOf\}\(y,x\) \(ρ2\)\(\\rho\_\{2\}\)∀x,y\.𝗂𝗌𝖥𝗋𝗂𝖾𝗇𝖽𝖮𝖿​\(x,y\)→𝖿𝗈𝗅𝗅𝗈𝗐𝗌​\(x,y\)\\forall x,y\.~\\mathsf\{isFriendOf\}\(x,y\)\\rightarrow\\mathsf\{follows\}\(x,y\) \(ρ3\)\(\\rho\_\{3\}\)∀x,y\.𝖿𝗈𝗅𝗅𝗈𝗐𝗌​\(x,y\)→∃m\.𝗆𝖾𝗌𝗌𝖺𝗀𝖾​\(m,x,y\)\\forall x,y\.~\\mathsf\{follows\}\(x,y\)\\rightarrow\\exists m\.~\\mathsf\{message\}\(m,x,y\)

Assume the data indicates that𝖡𝗈𝖻\\mathsf\{Bob\}follows𝖠𝗅𝗂𝖼𝖾\\mathsf\{Alice\}and they have a common friend𝖢𝖺𝗋𝗆𝖾𝗇\\mathsf\{Carmen\}, which is expressed by the facts𝖿𝗈𝗅𝗅𝗈𝗐𝗌​\(𝖡𝗈𝖻,𝖠𝗅𝗂𝖼𝖾\),𝗂𝗌𝖥𝗋𝗂𝖾𝗇𝖽𝖮𝖿​\(𝖢𝖺𝗋𝗆𝖾𝗇,𝖠𝗅𝗂𝖼𝖾\)\\mathsf\{follows\(Bob,Alice\)\},\\mathsf\{isFriendOf\(Carmen,Alice\)\}and𝗂𝗌𝖥𝗋𝗂𝖾𝗇𝖽𝖮𝖿​\(𝖢𝖺𝗋𝗆𝖾𝗇,𝖡𝗈𝖻\)\\mathsf\{isFriendOf\(Carmen,Bob\)\}\. None of the preceding queries have an answer on this data alone, while all of them have answers when the rules are taken into account\. Indeed, the following facts are inferred from the data and the rules:

> 𝗂𝗌𝖥𝗋𝗂𝖾𝗇𝖽𝖮𝖿​\(𝖠𝗅𝗂𝖼𝖾,𝖢𝖺𝗋𝗆𝖾𝗇\),𝗂𝗌𝖥𝗋𝗂𝖾𝗇𝖽𝖮𝖿​\(𝖡𝗈𝖻,𝖢𝖺𝗋𝗆𝖾𝗇\)\\mathsf\{isFriendOf\(Alice,Carmen\)\},\\mathsf\{isFriendOf\(Bob,Carmen\)\} 𝖿𝗈𝗅𝗅𝗈𝗐𝗌​\(𝖢𝖺𝗋𝗆𝖾𝗇,𝖠𝗅𝗂𝖼𝖾\),𝖿𝗈𝗅𝗅𝗈𝗐𝗌​\(𝖢𝖺𝗋𝗆𝖾𝗇,𝖡𝗈𝖻\),𝖿𝗈𝗅𝗅𝗈𝗐𝗌​\(𝖠𝗅𝗂𝖼𝖾,𝖢𝖺𝗋𝗆𝖾𝗇\),𝖿𝗈𝗅𝗅𝗈𝗐𝗌​\(𝖡𝗈𝖻,𝖢𝖺𝗋𝗆𝖾𝗇\)\\mathsf\{follows\(Carmen,Alice\)\},\\mathsf\{follows\(Carmen,Bob\)\},\\mathsf\{follows\(Alice,Carmen\)\},\\mathsf\{follows\(Bob,Carmen\)\} 𝗆𝖾𝗌𝗌𝖺𝗀𝖾​\(𝗆𝟢,𝖡𝗈𝖻,𝖠𝗅𝗂𝖼𝖾\),𝗆𝖾𝗌𝗌𝖺𝗀𝖾​\(𝗆𝟣,𝖢𝖺𝗋𝗆𝖾𝗇,𝖠𝗅𝗂𝖼𝖾\),𝗆𝖾𝗌𝗌𝖺𝗀𝖾​\(𝗆𝟤,𝖢𝖺𝗋𝗆𝖾𝗇,𝖡𝗈𝖻\),\\mathsf\{message\(m\_\{0\},Bob,Alice\)\},\\mathsf\{message\(m\_\{1\},Carmen,Alice\)\},\\mathsf\{message\(m\_\{2\},Carmen,Bob\)\}, 𝗆𝖾𝗌𝗌𝖺𝗀𝖾​\(𝗆𝟥,𝖠𝗅𝗂𝖼𝖾,𝖢𝖺𝗋𝗆𝖾𝗇\),𝗆𝖾𝗌𝗌𝖺𝗀𝖾​\(𝗆𝟦,𝖡𝗈𝖻,𝖢𝖺𝗋𝗆𝖾𝗇\)\\mathsf\{message\(m\_\{3\},Alice,Carmen\)\},\\mathsf\{message\(m\_\{4\},Bob,Carmen\)\}

For instance, the facts𝖿𝗈𝗅𝗅𝗈𝗐𝗌​\(𝖠𝗅𝗂𝖼𝖾,𝖢𝖺𝗋𝗆𝖾𝗇\)\\mathsf\{follows\(Alice,Carmen\)\}and𝖿𝗈𝗅𝗅𝗈𝗐𝗌​\(𝖢𝖺𝗋𝗆𝖾𝗇,𝖡𝗈𝖻\)\\mathsf\{follows\(Carmen,Bob\)\}yield the answer\(𝖡𝗈𝖻,𝖠𝗅𝗂𝖼𝖾\)\\mathsf\{\(Bob,Alice\)\}toq3q\_\{3\}; from these two facts and𝗆𝖾𝗌𝗌𝖺𝗀𝖾​\(𝗆𝟢,𝖡𝗈𝖻,𝖠𝗅𝗂𝖼𝖾\)\\mathsf\{message\(m\_\{0\},Bob,Alice\)\}, we conclude thatq6q\_\{6\}is answered positively\.

As an example of a guarded rule, consider the following rule defining the predicate𝗂𝗌𝖯𝖺𝗂𝗋𝖾𝖽\\mathsf\{isPaired\}:

> \(ρ4\)\(\\rho\_\{4\}\)∀x,y\.𝖿𝗈𝗅𝗅𝗈𝗐𝗌​\(x,y\)∧𝖿𝗈𝗅𝗅𝗈𝗐𝗌​\(y,x\)→𝗂𝗌𝖯𝖺𝗂𝗋𝖾𝖽​\(x,y\)\\forall x,y\.~\\mathsf\{follows\}\(x,y\)\\land\\mathsf\{follows\}\(y,x\)\\rightarrow\\mathsf\{isPaired\}\(x,y\)

Finally, the rules below define the predicate𝖾𝗑𝗍𝖥𝗈𝗅𝗅𝗈𝗐𝗌\\mathsf\{extFollows\}, which captures the regular expression𝖿𝗈𝗅𝗅𝗈𝗐𝗌\.𝖿𝗈𝗅𝗅𝗈𝗐𝗌∗\\mathsf\{follows\.follows\}^\{\*\}:

> ∀x,y\.𝖿𝗈𝗅𝗅𝗈𝗐𝗌​\(x,y\)→𝖾𝗑𝗍𝖥𝗈𝗅𝗅𝗈𝗐𝗌​\(x,y\)\\forall x,y\.~\\mathsf\{follows\}\(x,y\)\\rightarrow\\mathsf\{extFollows\}\(x,y\) ∀x,y,z\.𝖿𝗈𝗅𝗅𝗈𝗐𝗌​\(x,y\)∧𝖾𝗑𝗍𝖥𝗈𝗅𝗅𝗈𝗐𝗌​\(y,z\)→𝖾𝗑𝗍𝖥𝗈𝗅𝗅𝗈𝗐𝗌​\(x,z\)\\forall x,y,z\.~\\mathsf\{follows\}\(x,y\)\\land\\mathsf\{extFollows\}\(y,z\)\\rightarrow\\mathsf\{extFollows\}\(x,z\)

Using the predicate𝖾𝗑𝗍𝖥𝗈𝗅𝗅𝗈𝗐𝗌\\mathsf\{extFollows\}, the above \(C\)RPQs can be reformulated as CQs\. Note however that the last rule is not guarded, hence does not belong to the existential rule fragments studied in this paper\. This shows that navigational features in queries can compensate for certain limitations of the selected ontological fragment\.

As description logics are well suited to expressing ontological knowledge about graph\-like data, such as ABoxes and RDF graphs, it is not surprising that navigational queries have long been investigated for DL ontologies\. Such studies cover a variety of DLs, ranging from highly expressive DLs of the𝒵\\mathcal\{Z\}family\(Calvanese et al\.,[2007b](https://arxiv.org/html/2607.22636#bib.bib21),[2009](https://arxiv.org/html/2607.22636#bib.bib22),[2014](https://arxiv.org/html/2607.22636#bib.bib23)\), to Horn DLs like Horn\-𝒮​ℛ​𝒪​ℐ​𝒬\\mathcal\{SROIQ\}\(Ortiz et al\.,[2011](https://arxiv.org/html/2607.22636#bib.bib51);Bienvenu et al\.,[2014](https://arxiv.org/html/2607.22636#bib.bib11)\)and lightweight DLs of the DL\-Lite andℰ​ℒ\\mathcal\{EL\}families\(Stefanoni et al\.,[2014](https://arxiv.org/html/2607.22636#bib.bib56);Kostylev et al\.,[2015](https://arxiv.org/html/2607.22636#bib.bib45);Bienvenu et al\.,[2015](https://arxiv.org/html/2607.22636#bib.bib13)\)\. While the main focus of the preceding work was on establishing the complexity of answering navigational queries, there has also been some very recent work exploring how to obtain practical algorithms\(Dragovic et al\.,[2023](https://arxiv.org/html/2607.22636#bib.bib30);Löhnert et al\.,[2025](https://arxiv.org/html/2607.22636#bib.bib47)\)\.

By allowing predicates of any arity, in addition to the expression of cyclic relations between entities, existential rules naturally apply not only to graph data but also to data with a more complex hypergraph structure, such as relational databases or graph data enriched with contextual information\. This flexibility is particularly useful in applications involving heterogeneous data, since it makes it possible to handle each kind of data as it is, without breaking it down into binary facts\. This does not contradict the observation that binary relationships are still central in any context, whether they are found directly in certain data or built as part of the ontological modeling\. Hence, navigational queries remain highly relevant even when the data and/or ontology includes higher\-arity relations\. However, while there is now an extensive literature on navigational queries in the presence of DL ontologies, very little is known about the complexity \(or even decidability\) of answering such queries under different kinds of existential rules\.

Our paper makes an important contribution towards clarifying the complexity landscape for navigational queries under existential rules by establishing the complexity of answering \(C\)RPQs in the presence of linear and guarded existential rulesets\. To the best of our knowledge, these results \(which were first reported in the conference papers\(Bienvenu and Thomazo,[2016](https://arxiv.org/html/2607.22636#bib.bib14);Baget et al\.,[2017](https://arxiv.org/html/2607.22636#bib.bib7)\)\) constitute the first and the only complexity results targeting navigational queries with existential rules\. However, two recent works have established the decidability of \(i\) RPQ answering for sticky existential rulesets\(Ostropolski\-Nalewaja and Rudolph,[2024](https://arxiv.org/html/2607.22636#bib.bib53)\), and \(ii\) answering an extension of CRPQs for finite clique\-width rulesets\(Feller et al\.,[2023](https://arxiv.org/html/2607.22636#bib.bib33)\)\(in both cases without any upper complexity bounds\), demonstrating the continued interest in the topic\.

#### Contributions\.

We obtain tight complexity results for both combined and data complexities over guarded rules and their linear subclass for both RPQ and CRPQ answering\. With respect to combined complexity, we furthermore distinguish between bounded and unbounded predicate arity\. These results are synthesized in Table[1](https://arxiv.org/html/2607.22636#S1.T1)for linear rules and in Table[2](https://arxiv.org/html/2607.22636#S1.T2)for guarded rules, alongside existing results for CQs \(the grey background indicates new results\)\. In the linear case, we see that CRPQ answering and RPQ answering have the same data and unbounded\-arity combined complexities, and these complexities are higher than those of CQ answering\. However, for bounded\-arity combined complexity, RPQ answering is easier than CQ answering, while CRPQ is more difficult\. In the guarded case, we show that RPQ answering and CRPQ answering both have the same complexity as CQ answering, regardless of the complexity measure\. All these results are proven for existential rules with a single head atom; since arbitrary linear rules \(respectively guarded rules\) can be polynomially translated into atomic\-head linear rules \(respectively guarded rules\), the results also hold for combined complexity with unbounded predicate arity as well as data complexity\. Even though the translation does not preserve bounded predicate arity, we show that for arbitrary linear rules the same upper bounds apply \(and we conjecture this is true also for guarded rules\)\. It is also worth noting that, while our complexity results for \(C\)RPQs are in most cases higher than the analogous results for plain graph databases, theNLdata complexity of \(C\)RPQ answering with linear rules coincides with the data complexity of \(C\)RPQs in the ontology\-free setting\.

Table 1\.Landscape of \(C\)\(RP\)Q Answering Complexity under Linear RulesTable 2\.Landscape of \(C\)\(RP\)Q Answering Complexity under Guarded Rules
#### Paper organization\.

After a preliminary section, we first investigate the complexity of query answering for RPQs and linear existential rules\. We rely on a forward chaining scheme, known as the*chase*\(Maier et al\.,[1979](https://arxiv.org/html/2607.22636#bib.bib48);Beeri and Vardi,[1984](https://arxiv.org/html/2607.22636#bib.bib10)\)which, starting from a \(finite\) set of facts, iteratively applies rules until a fixpoint is reached, if any\. To get complexity upper bounds, we provide an algorithm that exploits the structure of paths of terms in the chase to guess a path that complies with the language defined by the RPQ \(Section[3](https://arxiv.org/html/2607.22636#S3)\)\. We then prove that this algorithm is worst\-case optimal: in the bounded arity case by using known lower bounds for DL\-Lite, a language in which relevant assertions are specific linear rules\(Bienvenu et al\.,[2015](https://arxiv.org/html/2607.22636#bib.bib13)\), and in the general case by providing a novel reduction from an alternatingPSpaceTuring machine to RPQ answering under linear rules \(Section[4](https://arxiv.org/html/2607.22636#S4)\)\. We then consider CRPQ answering, still under linear rules \(Section[5](https://arxiv.org/html/2607.22636#S5)\)\. We devise an algorithm that exploits additional structural properties of the chase and uses the previous RPQ answering algorithm as an oracle, which allows us to upper\-bound the problem complexity\. As the obtained upper bounds match lower bounds coming from previous results, this algorithm is worst\-case optimal\. Finally, to study the complexity of CRPQ answering under guarded rules, we provide a non\-trivial reduction of the guarded case to the linear case \(Section[6](https://arxiv.org/html/2607.22636#S6)\)\. This translation involves a double exponential blow\-up of the set of rules \(while the instance only grows exponentially in the predicate arity\)\. However, a careful analysis of the algorithm provided for CRPQ answering under linear rules shows that it actually runs in 2ExpTimewith respect to the input guarded knowledge base \(and inExpTimein the case of bounded\-arity rules\)\. We end with a presentation of closely related work \(Section[7](https://arxiv.org/html/2607.22636#S7)\) and remaining questions \(Section[8](https://arxiv.org/html/2607.22636#S8)\)\.

This article is an extended version of two previously published conference papers\(Bienvenu and Thomazo,[2016](https://arxiv.org/html/2607.22636#bib.bib14);Baget et al\.,[2017](https://arxiv.org/html/2607.22636#bib.bib7)\)\. With respect to these conference papers, we provide a unified presentation, full proofs of the results, detailed examples and a review of related work with the latest results\.

## 2\.Preliminaries

We consider logical vocabularies of the form𝒱=\(𝒫,𝒞\)\\mathcal\{V\}=\(\\mathcal\{P\},\\mathcal\{C\}\), where𝒫\\mathcal\{P\}is a finite set of predicates and𝒞\\mathcal\{C\}is an infinite set of constants\. A \(standard\)*atom*α\\alphahas the formr​\(𝐭\)r\(\\mathbf\{t\}\)whererris a predicate of aritynnand𝐭\\mathbf\{t\}is a tuple of terms \(i\.e\., variables or constants\) with\|𝐭\|=n\|\\mathbf\{t\}\|=n\. For1≤i≤\|𝐭\|1\\leq i\\leq\|\\mathbf\{t\}\|, we denote byα​\[i\]\\alpha\[i\]the term at positioniiinα\\alpha\. We denote by𝗍𝖾𝗋𝗆𝗌​\(α\)\\mathsf\{terms\}\{\(\\alpha\)\}\(resp\.𝗏𝖺𝗋𝗌\(α\)\)\\mathsf\{vars\}\{\(\\alpha\)\}\)the set of terms \(resp\. variables\) inα\\alphaand extend the notations to a set of atoms\. A*ground*atom contains only constants\. A formula is*atomic*if it is a single atom\. It is*closed*if it has no free variable\. Given a \(possibly infinite\) set of atomsAAand a \(possibly infinite\) set of termsTT,A∣TA\_\{\\mid T\}denotes the restriction ofAAto atomsα\\alphawith𝗍𝖾𝗋𝗆𝗌​\(α\)⊆T\\mathsf\{terms\}\{\(\\alpha\)\}\\subseteq T\.

An*interpretation*of a vocabulary𝒱=\(𝒫,𝒞\)\\mathcal\{V\}=\(\\mathcal\{P\},\\mathcal\{C\}\)is denoted byℐ=\(Δℐ,\.ℐ\)\\mathcal\{I\}=\(\\Delta\_\{\\mathcal\{I\}\},\.^\{\\mathcal\{I\}\}\), whereΔℐ\\Delta\_\{\\mathcal\{I\}\}is the possibly infinite \(non\-empty\) domain ofℐ\\mathcal\{I\}and\.ℐ\.^\{\\mathcal\{I\}\}is the interpretation function, such thataℐ∈Δa^\{\\mathcal\{I\}\}\\in\\Deltafor eacha∈𝒞a\\in\\mathcal\{C\}andrℐ⊆Δnr^\{\\mathcal\{I\}\}\\subseteq\\Delta^\{n\}for each predicater∈𝒫r\\in\\mathcal\{P\}with aritynn\. An interpretation is a*model*of a closed formulaFF\(resp\. a set of closed formulasFF\) if it makesFF\(resp\. every formula inFF\) true\. ForFFa conjunction of atoms, a*match*ofFFinℐ\\mathcal\{I\}is a mappingπ\\pifrom𝗍𝖾𝗋𝗆𝗌​\(F\)\\mathsf\{terms\}\{\(F\)\}to elements ofΔℐ\\Delta\_\{\\mathcal\{I\}\}such that\(i\)π​\(a\)=aℐ\\pi\(a\)=a^\{\\mathcal\{I\}\}for each constantaa;\(ii\)π​\(𝐭\)∈rℐ\\pi\(\\mathbf\{t\}\)\\in r^\{\\mathcal\{I\}\}for each atomr​\(𝐭\)r\(\\mathbf\{t\}\)inFF\. Then, it holds thatℐ\\mathcal\{I\}is a model of a closed formulaFFiff there is a*match*ofFFinℐ\\mathcal\{I\}\. We consider classical logical entailment: given a set of closed formulasFFand a closed formulaff,F⊧fF\\models fmeans that every model ofFFis a model offf\. In the following, we identify \(the existential closure of\) a conjunction of atoms with the set of these atoms\. Given two sets of atomsA1A\_\{1\}andA2A\_\{2\}, a*homomorphism*fromA2A\_\{2\}toA1A\_\{1\}is a substitutionπ\\piof𝗏𝖺𝗋𝗌​\(A2\)\\mathsf\{vars\}\{\(A\_\{2\}\)\}by𝗍𝖾𝗋𝗆𝗌​\(A1\)\\mathsf\{terms\}\{\(A\_\{1\}\)\}such thatπ​\(A2\)⊆A1\\pi\(A\_\{2\}\)\\subseteq A\_\{1\}\. An*isomorphism*fromA2A\_\{2\}toA1A\_\{1\}is a bijective substitutionbbof𝗏𝖺𝗋𝗌​\(A2\)\\mathsf\{vars\}\{\(A\_\{2\}\)\}by𝗏𝖺𝗋𝗌​\(A1\)\\mathsf\{vars\}\{\(A\_\{1\}\)\}such thatb​\(A2\)=A1b\(A\_\{2\}\)=A\_\{1\}\.

Given two existentially closed conjunctions of atomsA1A\_\{1\}andA2A\_\{2\}, it holds thatA1⊧A2A\_\{1\}\\models A\_\{2\}iff there is a homomorphism from \(the set of atoms in\)A2A\_\{2\}to \(the set of atoms in\)A1A\_\{1\}\. Hence,A1A\_\{1\}andA2A\_\{2\}are logically equivalent if and only if they are homomorphically equivalent\. It is worth noticing that equivalent sets of atoms are not necessarily isomorphic\.

### 2\.1\.Existential Rule Knowledge Bases

An*instance*is a finite set of ground atoms\. An*extended instance*is a finite set of arbitrary atoms, logically translated into an existentially\-closed conjunction of atoms\. An*existential rule*ρ\\rho\(or simply*rule*\) is of the form∀𝐱​∀𝐲​\[B​\(𝐱,𝐲\)→∃𝐳​H​\(𝐱,𝐳\)\]\\forall\\mathbf\{x\}\\forall\\mathbf\{y\}~\[~B\(\\mathbf\{x\},\\mathbf\{y\}\)\\rightarrow\\exists\\mathbf\{z\}~H\(\\mathbf\{x\},\\mathbf\{z\}\)~\], whereBBandHHare non\-empty conjunctions of atoms on variables, respectively called the*body*and the*head*ofρ\\rho, and𝐱,𝐲\\mathbf\{x\},\\mathbf\{y\}and𝐳\\mathbf\{z\}are pairwise disjoint\. We also denote the body and the head of a ruleρ\\rhoby𝖻𝗈𝖽𝗒​\(ρ\)\\mathsf\{body\}\(\\rho\)and𝗁𝖾𝖺𝖽​\(ρ\)\\mathsf\{head\}\(\\rho\), respectively\. We make the common assumption that rules do not contain constants, which simplifies technical tools\. The variables of𝐱\\mathbf\{x\}\(resp\.𝐳\\mathbf\{z\}\) are called*frontier variables*\(resp\.*existential variables*\)\. For brevity, we denote byB→HB\\rightarrow Ha rule with bodyBBand headHHand in our examples universal quantifiers are implicit\.

A*knowledge base*\(KB\) is of the form𝒦=\(I,ℛ\)\\mathcal\{K\}=\(I,\\mathcal\{R\}\), whereIIis an instance andℛ\\mathcal\{R\}a set of existential rules\. In the following, we assume that distinct rules inℛ\\mathcal\{R\}have disjoint sets of variables, even if we reuse variables in examples for the sake of simplicity\.

A ruleρ=B→H\\rho=B\\rightarrow His*applicable*to a set of atomsAAif there is a homomorphismπ\\pifromBBtoAA\. The pair\(ρ,π\)\(\\rho,\\pi\)is called a*trigger*onAA\. The application ofρ\\rhoaccording toπ\\pi\(or: the application of the trigger\(ρ,π\)\(\\rho,\\pi\)\) produces a set of atoms obtained from𝗁𝖾𝖺𝖽​\(ρ\)\\mathsf\{head\}\(\\rho\)by replacing each frontier variablexxwithπ​\(x\)\\pi\(x\)and each existential variable with a fresh variable, usually called a*null*\. We denote byπsafe\\pi^\{\\mathrm\{safe\}\}this extension ofπ\\pithat “safely” renames existential variables, so that distinct applications of the same rule produce disjoint sets of nulls\. The resulting set of atoms isA∪πsafe​\(H\)A\\cup\\pi^\{\\mathrm\{safe\}\}\(H\)\. An atomα∈πsafe​\(H\)\\alpha\\in\\pi^\{\\mathrm\{safe\}\}\(H\)is said to be*\(directly\) generated*by the trigger\(ρ,π\)\(\\rho,\\pi\)ifα∉A\\alpha\\not\\in A\. Observe that an atomα\\alphathat is produced by a trigger\(ρ,π\)\(\\rho,\\pi\)without being “generated” by that trigger necessarily comes from an atom in𝗁𝖾𝖺𝖽​\(ρ\)\\mathsf\{head\}\(\\rho\)that does not contain any existential variable\.

The fundamental tool for reasoning on existential rules is a forward chaining procedure known as the*chase*\. Briefly, the chase enriches a given instance by applying rules until a fixpoint is reached\. This process may be infinite, as for instance withℛ=\{h​\(x\)→∃z​p​\(x,z\)∧h​\(z\)\}\\mathcal\{R\}=\\\{h\(x\)\\rightarrow\\exists z~p\(x,z\)\\land h\(z\)\\\}\(“every human has a parent who is a human”\) andI=\{h​\(a\)\}I=\\\{h\(a\)\\\}\. Several variants of the chase are known \(see e\.g\.,\(Grahne and Onet,[2018](https://arxiv.org/html/2607.22636#bib.bib40)\)\)\. We consider here the simplest variant, called the*oblivious chase*\(Calì et al\.,[2013](https://arxiv.org/html/2607.22636#bib.bib16)\)\.

Formally, anℛ\\mathcal\{R\}\-*derivation*from an \(extended\) instanceIIis a possibly infinite sequence of \(extended\) instances and triggersD=I0\(=I\)\(ρ1,π1\)I1…\(ρn,πn\)In,…D=I\_\{0\}\(=I\)~\(\\rho\_\{1\},\\pi\_\{1\}\)~I\_\{1\}\\ldots~\(\\rho\_\{n\},\\pi\_\{n\}\)~I\_\{n\},\\dots, where, for alli≥1i\\geq 1,IiI\_\{i\}results from the application of the trigger\(ρi,πi\)\(\\rho\_\{i\},\\pi\_\{i\}\)onIi−1I\_\{i\-1\}, withρi∈ℛ\\rho\_\{i\}\\in\\mathcal\{R\}, and no trigger appears twice inDD\. It is simply called a derivation whenℛ\\mathcal\{R\}is clear from the context; and it is writtenI0\(=I\)I1…In,…I\_\{0\}\(=I\)~I\_\{1\}\\ldots~I\_\{n\},\\dotswhen the triggers are not needed\. The*result*ofDDis the set of atoms obtained along the sequence, i\.e\.,⋃i≥0Ii\\bigcup\_\{i\\geq 0\}I\_\{i\}, and we denote it bya​t​o​m​s​\(D\)atoms\(D\)\. The derivationDDis*fair*if, for anyIiI\_\{i\}and trigger\(ρ,π\)\(\\rho,\\pi\)onIiI\_\{i\}, there isIjI\_\{j\}inDDsuch thatIjI\_\{j\}results from the application of\(ρ,π\)\(\\rho,\\pi\)\. An \(oblivious\)*chase sequence*of𝒦=\(I,ℛ\)\\mathcal\{K\}=\(I,\\mathcal\{R\}\)is a fairℛ\\mathcal\{R\}\-derivation fromII\.

It is known that oblivious chase sequences on a given KB are either all finite or all infinite, and that they result in isomorphic sets of atoms\(Calì et al\.,[2013](https://arxiv.org/html/2607.22636#bib.bib16)\)\. Hence, given a KB𝒦=\(I,ℛ\)\\mathcal\{K\}=\(I,\\mathcal\{R\}\), we denote by chase\(𝒦\)\(\\mathcal\{K\}\), or chase\(I,ℛ\)\(I,\\mathcal\{R\}\), the result of any oblivious chase sequence of𝒦\\mathcal\{K\}\. Furthermore, the name chase is classically used to denote both the forward chaining process and its result\.

The \(result of the\) chase of𝒦\\mathcal\{K\}can be seen as a logical interpretation, which is a model of𝒦\\mathcal\{K\}\. This modelℐ𝒦=\(Δℐ𝒦,\.ℐ𝒦\)\\mathcal\{I\}\_\{\\mathcal\{K\}\}=\(\\Delta\_\{\\mathcal\{I\}\_\{\\mathcal\{K\}\}\},\.^\{\\mathcal\{I\}\_\{\\mathcal\{K\}\}\}\)has for domainΔℐ𝒦=𝗍𝖾𝗋𝗆𝗌​\(chase​\(𝒦\)\)\\Delta\_\{\\mathcal\{I\}\_\{\\mathcal\{K\}\}\}=\\mathsf\{terms\}\{\(\\text\{chase\}\(\\mathcal\{K\}\)\)\}and its interpretation function\.ℐ𝒦\.^\{\\mathcal\{I\}\_\{\\mathcal\{K\}\}\}is defined by the atoms in chase\(𝒦\)\(\\mathcal\{K\}\)\(i\.e\., for each constantcc,cℐ𝒦=cc^\{\\mathcal\{I\}\_\{\\mathcal\{K\}\}\}=cholds, and, for each predicatepp,pℐ𝒦p^\{\\mathcal\{I\}\_\{\\mathcal\{K\}\}\}is the set of tuples\(t1,…​tk\)\(t\_\{1\},\\ldots t\_\{k\}\)such thatp​\(t1,…​tk\)∈chase​\(𝒦\)p\(t\_\{1\},\\ldots t\_\{k\}\)\\in\\text\{chase\}\(\\mathcal\{K\}\)\)\. Furthermore,ℐ𝒦\\mathcal\{I\}\_\{\\mathcal\{K\}\}has the fundamental property of being a*universal*model of𝒦\\mathcal\{K\}, i\.e\., it homomorphically maps to any other model of𝒦\\mathcal\{K\}\(Fagin et al\.,[2005](https://arxiv.org/html/2607.22636#bib.bib32);Deutsch et al\.,[2008](https://arxiv.org/html/2607.22636#bib.bib29)\)\. It follows that it can act as a representative of all models of𝒦\\mathcal\{K\}to check entailment of conjunctive queries, and the more general conjunctive regular path queries, as explained next \(see Section[2\.3](https://arxiv.org/html/2607.22636#S2.SS3)\)\.

We will consider two specific classes of existential rules, namely linear and guarded\. A rule is*linear*if its body is atomic\. A set of atomsAAis*guarded*if it contains an atomα\\alpha, called a guard, such that𝗍𝖾𝗋𝗆𝗌​\(α\)=𝗍𝖾𝗋𝗆𝗌​\(A\)\\mathsf\{terms\}\{\(\\alpha\)\}=\\mathsf\{terms\}\{\(A\)\}\. SinceAAmay contain several guards, we use the notation\(A,α\)\(A,\\alpha\)to specify thatα\\alphais the considered guard\. A rule is*guarded*if its body is guarded\. Note that a linear rule is trivially guarded\.

#### Single\-head translation

In the following, we will make the assumption that the head of an existential rule is atomic\. It is well\-known that any existential ruleρ\\rhoon a vocabulary𝒱\\mathcal\{V\}can be decomposed into a set of atomic\-head rules by adding a fresh predicatepρp\_\{\\rho\}, whose arity is the number of variables in the head ofρ\\rho\. E\.g\., the ruleρ=r​\(x,y\)→∃z​q​\(x,z\)∧q​\(y,z\)\\rho=r\(x,y\)\\rightarrow\\exists z~q\(x,z\)\\wedge q\(y,z\)can be decomposed into three atomic\-head rules:r​\(x,y\)→∃z​pρ​\(x,y,z\)r\(x,y\)\\rightarrow\\exists z~p\_\{\\rho\}\(x,y,z\);pρ​\(x,y,z\)→q​\(x,z\)p\_\{\\rho\}\(x,y,z\)\\rightarrow q\(x,z\);pρ​\(x,y,z\)→q​\(y,z\)p\_\{\\rho\}\(x,y,z\)\\rightarrow q\(y,z\)\. This polynomial translation preserves entailment of formulas on𝒱\\mathcal\{V\}\. Moreover, the decomposition of a guarded \(resp\. linear\) rule yields a set of guarded \(resp\. linear\) rules\. Hence, the assumption that rules have an atomic head can be made without loss of generality regarding combined complexity with unbounded predicate arity, as well as data complexity\.

### 2\.2\.Properties of Linear Rules

A well\-known property of linear rules is that chasing independently each atom of an instance yields a result equivalent to the chase of this instance, i\.e\.,∪α∈I𝖼𝗁𝖺𝗌𝖾​\(\{α\},ℛ\)\\cup\_\{\\alpha\\in I\}\\mathsf\{chase\}\(\\\{\\alpha\\\},\\mathcal\{R\}\)and𝖼𝗁𝖺𝗌𝖾​\(I,ℛ\)\\mathsf\{chase\}\(I,\\mathcal\{R\}\)are homomorphically equivalent\. Indeed, the key property of linear rules is that a pair\(ρ,π\)\(\\rho,\\pi\)is a trigger on a set of atomsAAiff there isα∈A\\alpha\\in Asuch that\(ρ,π\)\(\\rho,\\pi\)is a trigger on\{α\}\\\{\\alpha\\\}\. Hence, the sequence of triggers in a derivation fromIIcan be split into sequences of triggers that each define a derivation from an atom inII\. It follows that𝖼𝗁𝖺𝗌𝖾​\(I,ℛ\)\\mathsf\{chase\}\(I,\\mathcal\{R\}\)is isomorphic to a subset of∪α∈I𝖼𝗁𝖺𝗌𝖾​\(\{α\},ℛ\)\\cup\_\{\\alpha\\in I\}\\mathsf\{chase\}\(\\\{\\alpha\\\},\\mathcal\{R\}\)\. In the other direction, the sequence of triggers in a derivation from any atomα∈I\\alpha\\in Idefines a derivation fromII\. It follows that𝖼𝗁𝖺𝗌𝖾​\(\{α\},ℛ\)\\mathsf\{chase\}\(\\\{\\alpha\\\},\\mathcal\{R\}\)is isomorphic to a subset of𝖼𝗁𝖺𝗌𝖾​\(I,ℛ\)\\mathsf\{chase\}\(I,\\mathcal\{R\}\)\. However, while∪α∈I𝖼𝗁𝖺𝗌𝖾​\(\{α\},ℛ\)\\cup\_\{\\alpha\\in I\}\\mathsf\{chase\}\(\\\{\\alpha\\\},\\mathcal\{R\}\)and𝖼𝗁𝖺𝗌𝖾​\(I,ℛ\)\\mathsf\{chase\}\(I,\\mathcal\{R\}\)are homomorphically equivalent, they are not necessarily isomorphic, as illustrated by the next example\.

###### Example 1\.

LetI=\{p​\(a,b\),q​\(a,b\)\}I=\\\{p\(a,b\),q\(a,b\)\\\}andℛ=\{ρ1,ρ2\}\\mathcal\{R\}=\\\{\\rho\_\{1\},\\rho\_\{2\}\\\}withρ1=p​\(x,y\)→q​\(x,y\)\\rho\_\{1\}=p\(x,y\)\\rightarrow q\(x,y\)andρ2=q​\(x,y\)→∃z​r​\(y,z\)\\rho\_\{2\}=q\(x,y\)\\rightarrow\\exists z~r\(y,z\)\. Then𝖼𝗁𝖺𝗌𝖾​\(I,ℛ\)=\{p​\(a,b\),q​\(a,b\),r​\(b,z0\)\}\\mathsf\{chase\}\(I,\\mathcal\{R\}\)=\\\{p\(a,b\),q\(a,b\),r\(b,z\_\{0\}\)\\\}, wherez0z\_\{0\}is a null, by the sequence of triggers𝗍1=\(ρ1,\{x↦a,y↦b\}\)\\mathsf\{t\}\_\{1\}=\(\\rho\_\{1\},\\\{x\\mapsto a,y\\mapsto b\\\}\),𝗍2=\(ρ2,\{x↦a,y↦b\}\)\\mathsf\{t\}\_\{2\}=\(\\rho\_\{2\},\\\{x\\mapsto a,y\\mapsto b\\\}\)\(or the reverse sequence\)\. Trigger𝗍1\\mathsf\{t\}\_\{1\}does not generate any atom because it producesq​\(a,b\)q\(a,b\)andq​\(a,b\)∈Iq\(a,b\)\\in I\. Letα1=p​\(a,b\)∈I\\alpha\_\{1\}=p\(a,b\)\\in I:𝖼𝗁𝖺𝗌𝖾​\(\{α1\},ℛ\)=\{p​\(a,b\),q​\(a,b\),r​\(b,z0\)\}\\mathsf\{chase\}\(\\\{\\alpha\_\{1\}\\\},\\mathcal\{R\}\)=\\\{p\(a,b\),q\(a,b\),r\(b,z\_\{0\}\)\\\}by the same sequence of triggers\. Now,𝗍1\\mathsf\{t\}\_\{1\}*generates*the atomq​\(a,b\)q\(a,b\)\. Letα2=q​\(a,b\)∈I\\alpha\_\{2\}=q\(a,b\)\\in I:𝖼𝗁𝖺𝗌𝖾​\(\{α2\},ℛ\)=\{q​\(a,b\),q​\(b,z1\)\}\\mathsf\{chase\}\(\\\{\\alpha\_\{2\}\\\},\\mathcal\{R\}\)=\\\{q\(a,b\),q\(b,z\_\{1\}\)\\\}by𝗍2\\mathsf\{t\}\_\{2\}\. The union of the two chases is:

\{p​\(a,b\),q​\(a,b\),r​\(b,z0\),r​\(b,z1\)\}\\\{p\(a,b\),q\(a,b\),r\(b,z\_\{0\}\),r\(b,z\_\{1\}\)\\\}which maps to𝖼𝗁𝖺𝗌𝖾​\(I,ℛ\)\\mathsf\{chase\}\(I,\\mathcal\{R\}\)by the homomorphismπ=\{z1↦z0\}\\pi=\\\{z\_\{1\}\\mapsto z\_\{0\}\\\}, but is not isomorphic to it\.

Let us say that an atomαj\\alpha\_\{j\}is*generated*from an atomαi\\alpha\_\{i\}in𝖼𝗁𝖺𝗌𝖾​\(I,ℛ\)\\mathsf\{chase\}\(I,\\mathcal\{R\}\)if*\(i\)*αj\\alpha\_\{j\}is directly generated by a trigger onαi\\alpha\_\{i\}, or*\(ii\)*αj\\alpha\_\{j\}is directly generated by a trigger on an atom itself generated fromαi\\alpha\_\{i\}\. In the rest of this paper, we will specifically rely on the following two immediate properties\. First, atoms generated from distinct \(ground\) atomsα\\alphaandα′\\alpha^\{\\prime\}inIIdo not share any null \(Proposition[2](https://arxiv.org/html/2607.22636#Thmtheorem2)\)\. Second, the set of atomsAαA\_\{\\alpha\}generated from an atomα∈I\\alpha\\in Iforms a subset of𝖼𝗁𝖺𝗌𝖾​\(\{α\},ℛ\)\\mathsf\{chase\}\(\\\{\\alpha\\\},\\mathcal\{R\}\), up to the choice of nulls \(Proposition[3](https://arxiv.org/html/2607.22636#Thmtheorem3)\)\. We will in fact only use a corollary of Proposition[3](https://arxiv.org/html/2607.22636#Thmtheorem3): every finite set of atoms that are all generated from an atomα∈I\\alpha\\in Iforms a subset of𝖼𝗁𝖺𝗌𝖾​\(\{α\},ℛ\)\\mathsf\{chase\}\(\\\{\\alpha\\\},\\mathcal\{R\}\)\.

###### Proposition 2\.

Given any𝒦=\(I,ℛ\)\\mathcal\{K\}=\(I,\\mathcal\{R\}\), letαi\\alpha\_\{i\}andαj\\alpha\_\{j\}be generated from distinct atoms inIIby𝖼𝗁𝖺𝗌𝖾​\(I,ℛ\)\\mathsf\{chase\}\(I,\\mathcal\{R\}\)\. Then,𝗏𝖺𝗋𝗌​\(αi\)∩𝗏𝖺𝗋𝗌​\(αj\)=∅\\mathsf\{vars\}\{\(\\alpha\_\{i\}\)\}\\cap\\mathsf\{vars\}\{\(\\alpha\_\{j\}\)\}=\\emptyset\.

###### Proof\.

If two \(distinct\) atomsαi\\alpha\_\{i\}andαj\\alpha\_\{j\}share a \(necessarily fresh\) variable, then they are generated from the same ground atom fromII\. Indeed, letαk\\alpha\_\{k\}be the atom in which this variable is introduced\. Ifαk=αi\\alpha\_\{k\}=\\alpha\_\{i\}orαk=αj\\alpha\_\{k\}=\\alpha\_\{j\}, then one atom is generated from the other\. Otherwise,αi\\alpha\_\{i\}andαj\\alpha\_\{j\}are both generated fromαk\\alpha\_\{k\}\. In all the cases,αi\\alpha\_\{i\}andαj\\alpha\_\{j\}are generated from the same atomα∈I\\alpha\\in Ifrom whichαk\\alpha\_\{k\}is generated\. ∎

###### Proposition 3\.

For any KB𝒦=\(I,ℛ\)\\mathcal\{K\}=\(I,\\mathcal\{R\}\)withℛ\\mathcal\{R\}a linear ruleset, atomα∈I\\alpha\\in Iand setAαA\_\{\\alpha\}of all the atoms generated fromα\\alphain𝖼𝗁𝖺𝗌𝖾​\(I,ℛ\)\\mathsf\{chase\}\(I,\\mathcal\{R\}\), there is an isomorphism from\{α\}∪Aα\\\{\\alpha\\\}\\cup A\_\{\\alpha\}to a subset of𝖼𝗁𝖺𝗌𝖾​\(\{α\},ℛ\)\\mathsf\{chase\}\(\\\{\\alpha\\\},\\mathcal\{R\}\)\.

###### Proof\.

LetDα=I0\(=α\)\(ρ1,π1\)I1…\(ρn,πn\)In,…D\_\{\\alpha\}=I\_\{0\}\(=\\alpha\)~\(\\rho\_\{1\},\\pi\_\{1\}\)~I\_\{1\}\\ldots~\(\\rho\_\{n\},\\pi\_\{n\}\)~I\_\{n\},\\dotsbe the \(possibly infinite\) derivation resulting in\{α\}∪Aα\\\{\\alpha\\\}\\cup A\_\{\\alpha\}, which is extracted from the derivation associated with𝖼𝗁𝖺𝗌𝖾​\(I,ℛ\)\\mathsf\{chase\}\(I,\\mathcal\{R\}\)\. We inductively build a sequence of substitutionsϕ0,…,ϕn,…\\phi\_\{0\},\\ldots,\\phi\_\{n\},\\ldots, such that for alli≥0i\\geq 0,ϕi\\phi\_\{i\}is an isomorphism fromIiI\_\{i\}to a subset of𝖼𝗁𝖺𝗌𝖾​\(I,ℛ\)\\mathsf\{chase\}\(I,\\mathcal\{R\}\)\. Fori=0i=0,ϕi\\phi\_\{i\}is the empty substitution \(i\.e\.,ϕ0​\(α\)=α\\phi\_\{0\}\(\\alpha\)=\\alpha\)\. Fori\>0i\>0, letαi=Ii∖Ii−1\\alpha\_\{i\}=I\_\{i\}\\setminus I\_\{i\-1\}, and letti=\(ρi,πi\)t\_\{i\}=\(\\rho\_\{i\},\\pi\_\{i\}\)be the trigger that producesαi\\alpha\_\{i\}\. Letαji\\alpha\_\{j\_\{i\}\}be the atom on whichtit\_\{i\}is applied\. Ifαi\\alpha\_\{i\}does not contain a new null,ϕi=ϕi−1\\phi\_\{i\}=\\phi\_\{i\-1\}\. Otherwise, letα′=ϕi−1​\(αji\)\\alpha^\{\\prime\}=\\phi\_\{i\-1\}\(\\alpha\_\{j\_\{i\}\}\): the pairt′=\(ρi,ϕi−1∘πi\)t^\{\\prime\}=\(\\rho\_\{i\},\\phi\_\{i\-1\}\\circ\\pi\_\{i\}\)is a trigger onα′\\alpha^\{\\prime\}and it necessarily*generates*an atom since a new null is created\. Then,ϕi\\phi\_\{i\}is obtained by extendingϕi−1\\phi\_\{i\-1\}in the obvious way to bijectively map the nulls introduced bytit\_\{i\}to those introduced byt′t^\{\\prime\}\. By construction,ϕi\\phi\_\{i\}is an isomorphism fromIiI\_\{i\}to a subset of𝖼𝗁𝖺𝗌𝖾​\(\{α\},ℛ\)\\mathsf\{chase\}\(\\\{\\alpha\\\},\\mathcal\{R\}\)\. Furthermore,∪i=0∞ϕi\\cup\_\{i=0\}^\{\\infty\}\\phi\_\{i\}is an injective substitution of𝗏𝖺𝗋𝗌​\(\{α\}∪Aα\)\\mathsf\{vars\}\{\(\\\{\\alpha\\\}\\cup A\_\{\\alpha\}\)\}by𝗏𝖺𝗋𝗌​\(𝖼𝗁𝖺𝗌𝖾​\(\{α\},ℛ\)\)\\mathsf\{vars\}\{\(\\mathsf\{chase\}\(\\\{\\alpha\\\},\\mathcal\{R\}\)\)\}, i\.e\., an isomorphism from\{α\}∪Aα\\\{\\alpha\\\}\\cup A\_\{\\alpha\}to a subset of𝖼𝗁𝖺𝗌𝖾​\(\{α\},ℛ\)\\mathsf\{chase\}\(\\\{\\alpha\\\},\\mathcal\{R\}\)\. ∎

### 2\.3\.Queries

We now define the classes of queries we consider: conjunctive queries, regular path queries and their common generalisation, namely conjunctive regular path queries\. In short, a conjunctive query is an existentially quantified conjunction of standard atoms; a regular path query is a single “path atom”, i\.e\., an atom on a binary predicate corresponding to a regular language; and a conjunctive regular path query is an existentially quantified conjunction of standard and path atoms\.

A regular language can be represented by a regular expression or by a non\-deterministic finite automaton \(NFA\)\. LetΣ\\Sigmabe a finite set of symbols\. A regular expressionℰ\\mathcal\{E\}overΣ\\Sigmais defined by the grammar:ℰ→ε​∣a∣​ℰ⋅ℰ​∣ℰ\+ℰ∣​ℰ∗\\mathcal\{E\}\\rightarrow\\varepsilon\\mid a\\mid\\mathcal\{E\}\\cdot\\mathcal\{E\}\\mid\\mathcal\{E\}\+\\mathcal\{E\}\\mid\\mathcal\{E\}^\{\*\}, wherea∈Σa\\in\\Sigmaandε\\varepsilondenotes the empty word\. An NFA overΣ\\Sigmais a tuple𝔸=\(S,Σ,δ,s0,F\)\\mathbb\{A\}=\(S,\\Sigma,\\delta,s\_\{0\},F\), whereSSis a finite set of states,δ⊆S×Σ×S\\delta\\subseteq S\\times\\Sigma\\times Sis the transition relation,s0∈Ss\_\{0\}\\in Sis the initial state andF⊆SF\\subseteq Sis the set of final states\. For convenience, we sometimes use the notations′∈δ​\(s,a\)s^\{\\prime\}\\in\\delta\(s,a\)to denote that\(s,a,s′\)∈δ\(s,a,s^\{\\prime\}\)\\in\\delta\. Since NFAs are exponentially more succinct than regular expressions\(Ehrenfeucht and Zeiger,[1976](https://arxiv.org/html/2607.22636#bib.bib31)\), the complexity proofs should use the NFA representation for upper bounds and the regular expression representation for lower bounds, so that the results hold regardless of the representation\. We indeed use the NFA representation for upper bounds\. For lower bounds, we mostly rely on previous results, which indeed use the regular expression representation; for our only proof of a lower bound \(Section[4](https://arxiv.org/html/2607.22636#S4)\), the query is of the formp∗p^\{\*\}, hence the choice of a representation does not matter\.

We denote byℒ​\(ℰ\)\\mathcal\{L\}\(\\mathcal\{E\}\)the language defined by the regular expressionℰ\\mathcal\{E\}\. Simarly, we denote byℒ​\(𝔸\)\\mathcal\{L\}\(\\mathbb\{A\}\)the language recognized by the automaton𝔸\\mathbb\{A\}\. Furthermore, we denote byℒ𝔸​\(si,sj\)\\mathcal\{L\}\_\{\\mathbb\{A\}\}\(s\_\{i\},s\_\{j\}\)the set of words that take𝔸\\mathbb\{A\}to the statesjs\_\{j\}when they are read from the statesis\_\{i\}\. Whensi=s0s\_\{i\}=s\_\{0\}andsj∈Fs\_\{j\}\\in F,ℒ𝔸​\(si,sj\)⊆ℒ​\(𝔸\)\\mathcal\{L\}\_\{\\mathbb\{A\}\}\(s\_\{i\},s\_\{j\}\)\\subseteq\\mathcal\{L\}\(\\mathbb\{A\}\)\.

We denote by𝒫2\\mathcal\{P\}\_\{2\}the subset of binary predicates in the considered vocabulary𝒱=\(𝒫,𝒞\)\\mathcal\{V\}=\(\\mathcal\{P\},\\mathcal\{C\}\)\. Given a binary predicaterr, we also consider its inverse predicater−r^\{\-\}\(i\.e\., for all termst1t\_\{1\}andt2t\_\{2\},r​\(t1,t2\)r\(t\_\{1\},t\_\{2\}\)holds iffr−​\(t2,t1\)r^\{\-\}\(t\_\{2\},t\_\{1\}\)holds\)\. We set𝒫2±=𝒫2∪\{r−∣r∈𝒫2\}\\mathcal\{P\}\_\{2\}^\{\\pm\}=\\mathcal\{P\}\_\{2\}\\cup\\\{r^\{\-\}\\mid r\\in\\mathcal\{P\}\_\{2\}\\\}\. A*path predicate*Λ\\Lambdais a binary predicate given by an NFA or a regular expression defining a regular languageL​\(Λ\)L\(\\Lambda\)over𝒫2±\\mathcal\{P\}\_\{2\}^\{\\pm\}\. A*path atom*is an atom built on a path predicate, i\.e\., it takes the formΛ​\(t1,t2\)\\Lambda\(t\_\{1\},t\_\{2\}\), whereΛ\\Lambdais a path predicate andt1,t2t\_\{1\},t\_\{2\}are terms\. Note that standard binary predicates are a special case of path predicates\. We assume without loss of generality that automata associated with distinct path predicates have disjoint sets of states\.

A*conjunctive \(two\-way\) regular path query*\(CRPQ\)222As we only consider the two\-way variant, we will use the abbreviation \(C\)RPQ instead of the more usual \(C\)2RPQ\.has the formq​\(𝐱\)=∃𝐲​Bq\(\\mathbf\{x\}\)=\\exists\\mathbf\{y\}B, where𝐱\\mathbf\{x\}and𝐲\\mathbf\{y\}are disjoint tuples of variables, andBBis a conjunction of standard and path atoms with𝗍𝖾𝗋𝗆𝗌​\(B\)=𝐱∪𝐲\\mathsf\{terms\}\{\(B\)\}=\\mathbf\{x\}\\cup\\mathbf\{y\}\. The free variables ofqq, i\.e\., the𝐱\\mathbf\{x\}variables, are called*answer variables*\. A CRPQ is*Boolean*if it is a closed formula, i\.e\.,𝐱=∅\\mathbf\{x\}=\\emptyset\. A*conjunctive query*\(CQ\) is a CRPQq​\(𝐱\)=∃𝐲​Bq\(\\mathbf\{x\}\)=\\exists\\mathbf\{y\}BwhereBBcontains only standard atoms\. A*regular path query*\(RPQ\) is a CRPQ of the formq​\(x1,x2\)=Λ​\(x1,x2\)q\(x\_\{1\},x\_\{2\}\)=\\Lambda\(x\_\{1\},x\_\{2\}\), whereΛ​\(x1,x2\)\\Lambda\(x\_\{1\},x\_\{2\}\)is a path atom\. Hence, an RPQ contains exactly two variables, which are answer variables\.

Given an interpretationℐ=\(Δ,\.ℐ\)\\mathcal\{I\}=\(\\Delta,\.^\{\\mathcal\{I\}\}\), we extend the set of interpreted symbols as follows\. First, for everyr∈𝒫2r\\in\\mathcal\{P\}\_\{2\}, we set\(r−\)ℐ=\{\(e2,e1\)\|\(e1,e2\)∈rℐ\}\(\{r^\{\-\}\}\)^\{\\mathcal\{I\}\}=\\\{\(e\_\{2\},e\_\{1\}\)\|\(e\_\{1\},e\_\{2\}\)\\in r^\{\\mathcal\{I\}\}\\\}\. Second, we call*path*\(frome0e\_\{0\}toene\_\{n\}\) inℐ\\mathcal\{I\}a \(finite\) sequencee0​r1​e1​…​rn​ene\_\{0\}r\_\{1\}e\_\{1\}\\ldots r\_\{n\}e\_\{n\}, withn≥0n\\geq 0such thate0∈Δℐe\_\{0\}\\in\\Delta\_\{\\mathcal\{I\}\}and for every1≤i≤n1\\leq i\\leq n,ei∈Δℐe\_\{i\}\\in\\Delta\_\{\\mathcal\{I\}\},ri∈𝒫2±r\_\{i\}\\in\\mathcal\{P\}\_\{2\}^\{\\pm\}and\(ei−1,ei\)∈riℐ\(e\_\{i\-1\},e\_\{i\}\)\\in r\_\{i\}^\{\\mathcal\{I\}\}\. The*label*λ​\(p\)\\lambda\(p\)of a pathp=e0​r1​e1​…​rn​enp=e\_\{0\}r\_\{1\}e\_\{1\}\\ldots r\_\{n\}e\_\{n\}is the wordr1​…​rnr\_\{1\}\\ldots r\_\{n\}\. Ifn=0n=0,λ​\(p\)\\lambda\(p\)is the empty wordε\\varepsilon\. Then, for any path predicateΛ\\Lambda, we set:

Λℐ=\{\(e0,en\)\|\\Lambda^\{\\mathcal\{I\}\}=\\\{\(e\_\{0\},e\_\{n\}\)\|there is a pathppfrome0e\_\{0\}toene\_\{n\}inℐ\\mathcal\{I\}such thatλ\(p\)∈ℒ\(Λ\)\}\\lambda\(p\)\\in\\mathcal\{L\}\(\\Lambda\)\\\}

The notion of model of a Boolean CRPQ is the classical logical notion, up to the above extensions of the set of interpreted symbols\. The notion of match in an interpretation is extended in the same way, i\.e\., a*match*of a CRPQqqin an interpretationℐ\\mathcal\{I\}is a mappingπ\\pifrom𝗍𝖾𝗋𝗆𝗌​\(q\)\\mathsf\{terms\}\{\(q\)\}to elements ofΔℐ\\Delta\_\{\\mathcal\{I\}\}such that\(i\)π​\(a\)=aℐ\\pi\(a\)=a^\{\\mathcal\{I\}\}for each constantaa;\(ii\)π​\(𝐭\)∈rℐ\\pi\(\\mathbf\{t\}\)\\in r^\{\\mathcal\{I\}\}for each \(standard or path\) atomr​\(𝐭\)r\(\\mathbf\{t\}\)inqq\. It follows that an interpretationℐ\\mathcal\{I\}is a model of a Boolean CRPQqqiff there is a*match*ofqqinℐ\\mathcal\{I\}\.

Given a CRPQq​\(𝐱\)=∃𝐲​Bq\(\\mathbf\{x\}\)=\\exists\\mathbf\{y\}Bwith𝐱=\(x1​…​xk\)\\mathbf\{x\}=\(x\_\{1\}\\ldots x\_\{k\}\), a tuple of constantsa=\(a1​…​ak\)\\textbf\{a\}=\(a\_\{1\}\\ldots a\_\{k\}\)is an*answer*toqqinℐ\\mathcal\{I\}if there is a matchπ\\piofqqinℐ\\mathcal\{I\}such thatπ​\(xi\)=aiℐ\\pi\(x\_\{i\}\)=a\_\{i\}^\{\\mathcal\{I\}\}for1≤i≤k1\\leq i\\leq k\. Equivalently,ℐ\\mathcal\{I\}is a model of the Boolean CRPQq​\(\)q\(\)obtained fromq​\(𝐱\)q\(\\mathbf\{x\}\)by substituting eachxix\_\{i\}withaia\_\{i\}\.

We can now define the notion of a certain answer to a CRPQ on a KB\. Given a CRPQq​\(𝐱\)=∃𝐲​Bq\(\\mathbf\{x\}\)=\\exists\\mathbf\{y\}Band a KB𝒦=\(I,ℛ\)\\mathcal\{K\}=\(I,\\mathcal\{R\}\), a tuple of constants𝐚=s​\(𝐱\)\\mathbf\{a\}=s\(\\mathbf\{x\}\), wheressdenotes a substitution, is a*certain answer*to a CRPQq​\(𝐱\)q\(\\mathbf\{x\}\)over𝒦\\mathcal\{K\}ifI∪ℛ⊧q​\(𝐚\)I\\cup\\mathcal\{R\}\\models q\(\\mathbf\{a\}\), whereq​\(𝐚\)=∃𝐲\.s​\(B\)q\(\\mathbf\{a\}\)=\\exists\\mathbf\{y\}\.s\(B\)\. In other words,𝐚\\mathbf\{a\}is an answer toqqin each model of𝒦\\mathcal\{K\}\. Concerning the specific case ofqqbeing a Boolean CRPQ, we have that the empty tuple\(\)\(\)is a certain answer toqqon𝒦\\mathcal\{K\}ifI∪ℛ⊧qI\\cup\\mathcal\{R\}\\models q\.

Although certain answers are defined with respect to all models of the KB, it is actually sufficient to consider answers in the unique model defined by the chase of the KB\. This immediately follows from two properties:*\(i\)*the chase of a KB𝒦\\mathcal\{K\}is a universal model of𝒦\\mathcal\{K\}, and*\(ii\)*CRPQs are closed under homomorphism, which means that for any Boolean CRPQqqand modelℐ\\mathcal\{I\}ofqq, any interpretationℐ′\\mathcal\{I\}^\{\\prime\}to whichℐ\\mathcal\{I\}homomorphically maps is also a model ofqq\.

###### Proposition 4\.

For any KB𝒦\\mathcal\{K\}and CRPQq​\(𝐱\)q\(\\mathbf\{x\}\), a tuple of constants\(𝐚\)\(\\mathbf\{a\}\)is a certain answer toqqover𝒦\\mathcal\{K\}if and only if there is a matchπ\\piofqqin chase\(𝒦\\mathcal\{K\}\) such thatπ​\(𝐱\)=\(𝐚\)\\pi\(\\mathbf\{x\}\)=\(\\mathbf\{a\}\)\.

In the following, we will identify the chase with the interpretation naturally associated with it\. In particular, a*path of terms*in the chase is the natural translation of a path in the associated interpretation\. We denote a path of terms byp=t0​r1​t1​⋯​rn​tnp=t\_\{0\}r\_\{1\}t\_\{1\}\\cdots r\_\{n\}t\_\{n\}, where thetit\_\{i\}are terms, and therir\_\{i\}elements of𝒫2±\\mathcal\{P\}\_\{2\}^\{\\pm\}, and simply byt0​⋯​tnt\_\{0\}\\cdots t\_\{n\}when only the extremities are needed\.

Finally, we point out that, whenever there is a match of a CRPQ in the possibly infinite chase, this match can be found in a finite portion of the chase\.

###### Proposition 5\.

For any KB𝒦=\(I,ℛ\)\\mathcal\{K\}=\(I,\\mathcal\{R\}\)and CRPQqq, if there a matchπ\\piofqqin𝖼𝗁𝖺𝗌𝖾​\(𝒦\)\\mathsf\{chase\}\(\\mathcal\{K\}\), then for any chase sequenceD=I0\(=I\)I1…In,…D=I\_\{0\}\(=I\)~I\_\{1\}\\ldots~I\_\{n\},\\dotsof𝒦\\mathcal\{K\}, there isIiI\_\{i\}inDDsuch thatπ\\piis a match ofqqinIiI\_\{i\}\.

###### Proof\.

\(Sketch\) Letπ\\pibe a match ofqqin chase\(𝒦\\mathcal\{K\}\)\. LetD=I0\(=I\)I1…In,…D=I\_\{0\}\(=I\)~I\_\{1\}\\ldots~I\_\{n\},\\dotsbe a chase sequence of𝒦\\mathcal\{K\}\. Given any standard atomα\\alphainqq, let rank\(α\\alpha\) be the smallestiisuch thatπ​\(α\)∈Ii\\pi\(\\alpha\)\\in I\_\{i\}\. Given any path atomα=Λ​\(t,t′\)\\alpha=\\Lambda\(t,t^\{\\prime\}\)inqq, let rank\(α\\alpha\) be the smallestiisuch thatIiI\_\{i\}contains all the \(standard\) atoms of a patht0\(=π\(t\)\)r1t1⋯rntn\(=π\(t′\)\)t\_\{0\}\(=\\pi\(t\)\)r\_\{1\}t\_\{1\}\\cdots r\_\{n\}t\_\{n\}\(=\\pi\(t^\{\\prime\}\)\)\. Letjjbe the maximal value of rank\(α\\alpha\) among all standard and path atomsα\\alphainqq\. Then,π\\piis a match ofqqinIjI\_\{j\}\. ∎

Hence, given a Boolean CRPQqqand a KB𝒦=\(I,ℛ\)\\mathcal\{K\}=\(I,\\mathcal\{R\}\), it holds that𝒦⊧q\\mathcal\{K\}\\models qif and only if there a finiteℛ\\mathcal\{R\}\-derivation fromIIthat results in a set of atomsInI\_\{n\}such thatIn⊧qI\_\{n\}\\models q\.

### 2\.4\.Query Answering Problem

Let𝐂∈\{CQ, RPQ, CRPQ\}\\mathbf\{C\}\\in\\\{\\text\{CQ, RPQ, CRPQ\}\\\}denote a class of queries\. The*𝐂\\mathbf\{C\}answering problem*asks, given a KB𝒦=\(I,ℛ\)\\mathcal\{K\}=\(I,\\mathcal\{R\}\), a queryqqfrom the class𝐂\\mathbf\{C\}and a tuple of constants𝐚\\mathbf\{a\}, whether𝐚\\mathbf\{a\}is an answer toqqover𝒦\\mathcal\{K\}\. Since ground atom entailment from an existential rule KB is undecidable in general \(see\(Beeri and Vardi,[1981](https://arxiv.org/html/2607.22636#bib.bib9);Chandra et al\.,[1981](https://arxiv.org/html/2607.22636#bib.bib26)\)for the first undecidability results about equivalent problems on tuple\-generating dependencies\), the𝐂\\mathbf\{C\}answering problem is undecidable for any query class𝐂\\mathbf\{C\}\.

We will study the complexity of \(C\)RPQ answering in the case of linear and guarded rules, according to two complexity measures:*combined*complexity, where𝒦\\mathcal\{K\}andqqare both part of the problem input, and*data*complexity, whereqqandℛ\\mathcal\{R\}are fixed, and onlyIIis part of the input\. This second complexity measure is specially relevant when it can be assumed that the sizes of the query and the set of rules are small compared to the size of the instance\. With respect to combined complexity, we will in turn distinguish between two cases, depending on whether the predicate arity is*bounded*or*unbounded*\.

We will refer to standard complexity classes:NL\(problems solvable in non\-deterministic logarithmic space\), also calledNLogSpace,PTime\(problems solvable in deterministic polynomial time\),NP\(problems solvable in non\-deterministic polynomial time\),PSpace\(problems solvable in polynomial space\),ExpTime\(problems solvable in deterministic exponential time\) and 2ExpTime\(problems solvable in deterministic doubly exponential time\)\. In Table[1](https://arxiv.org/html/2607.22636#S1.T1), we furthermore mentionAC0, a class from circuit complexity, which is a strict subclass ofNL\. To sum up, these classes are ordered as follows:AC0⊂NL⊆PTime⊆NP⊆PSpace⊆ExpTime⊆2​ExpTime\\textsc\{AC$\{\}\_\{0\}$\}\\subset\\textsc\{NL\}\\subseteq\\textsc\{PTime\}\\subseteq\\textsc\{NP\}\\subseteq\\textsc\{PSpace\}\\subseteq\\textsc\{ExpTime\}\\subseteq 2\\textsc\{ExpTime\}\.

The complexities of CQ answering under linear or guarded rules are recalled in Tables[1](https://arxiv.org/html/2607.22636#S1.T1)and[2](https://arxiv.org/html/2607.22636#S1.T2)\. It is well known that CQ evaluation \(or CQ answering withℛ=∅\\mathcal\{R\}=\\emptyset\) is in AC0for data complexity and NP\-complete for combined complexity, regardless of the assumption on predicate arity\. Under linear rules, CQ answering remains in AC0for data complexity\(Calì et al\.,[2009b](https://arxiv.org/html/2607.22636#bib.bib18)\)and NP\-complete for combined complexity with bounded arity \(follows from\(Johnson and Klug,[1984](https://arxiv.org/html/2607.22636#bib.bib42);Gottlob and Schwentick,[2012](https://arxiv.org/html/2607.22636#bib.bib39)\)\)333\(Johnson and Klug,[1984](https://arxiv.org/html/2607.22636#bib.bib42)\)proves that inclusion dependencies \(a subclass of linear rules\) of bounded predicate arity enjoy the Polynomial Witness Property and\(Gottlob and Schwentick,[2012](https://arxiv.org/html/2607.22636#bib.bib39)\)points out that the proof extends to linear rules\. This implies the NP membership\. NP\-hardness follows from the complexity of CQ evaluation\.but it becomesPSpace\-complete for combined complexity with unbounded arity\(Calì et al\.,[2009a](https://arxiv.org/html/2607.22636#bib.bib17)\)\. Under guarded rules, CQ answering isPTime\-complete for data complexity\(Calì et al\.,[2009b](https://arxiv.org/html/2607.22636#bib.bib18)\),ExpTime\-complete for combined complexity with bounded arity\(Calì et al\.,[2013](https://arxiv.org/html/2607.22636#bib.bib16)\)and 2ExpTime\-complete for combined complexity with unbounded arity\(Calì et al\.,[2013](https://arxiv.org/html/2607.22636#bib.bib16)\)\.

For the sake of comparison, let us further recall the complexity444The reason that we do not provide references for the complexity results for graph databases is that they are considered folklore in the area \(and explicitly noted as such in the survey chapter\(Figueira,[2021](https://arxiv.org/html/2607.22636#bib.bib34)\)\)\.of answering \(C\)RPQs over graph databases, in the absence of any ontology\. RPQ evaluation is known to beNL\-complete in both data and combined complexity\. For CRPQs, the data complexity remainsNL\-complete, but the combined complexity rises toNP\-complete \(matching that of CQ evaluation in databases\)\. To prove the results about CRPQ answering, it will be convenient to consider the following problem, called*CRPQ Entailment*, which asks, given a KB𝒦=\(I,ℛ\)\\mathcal\{K\}=\(I,\\mathcal\{R\}\)and a Boolean CRPQqq, ifI∪ℛ⊧qI\\cup\\mathcal\{R\}\\models q\. Both problems are linearly reducible one to the other, since, given a Boolean CRPQqq, it holds thatI∪ℛ⊧qI\\cup\\mathcal\{R\}\\models qif and only if\(\)\(\)is a certain answer toqq, and, in turn, a tuple of constants\(𝐚\)\(\\mathbf\{a\}\)is a certain answer to a CRPQq​\(𝐱\)q\(\\mathbf\{x\}\)if and only ifI∪ℛ⊧q\(𝐱↦𝐚\)I\\cup\\mathcal\{R\}\\models q\_\{\(\\mathbf\{x\}\\mapsto\\mathbf\{a\}\)\}, whereq\(𝐱↦𝐚\)q\_\{\(\\mathbf\{x\}\\mapsto\\mathbf\{a\}\)\}is the Boolean CRPQ obtained fromq​\(𝐱\)q\(\\mathbf\{x\}\)by substituting eachxix\_\{i\}in𝐱\\mathbf\{x\}withaia\_\{i\}in𝐚\\mathbf\{a\}\.

## 3\.RPQ Answering under Linear Rules: Upper Bound

We consider the problem of computing the certain answers to a regular path query in the presence of a set of linear rules and present an algorithm that is inspired by a related algorithm for DL\-Lite ontologies\(Bienvenu et al\.,[2015](https://arxiv.org/html/2607.22636#bib.bib13)\)\(see Section[7](https://arxiv.org/html/2607.22636#S7)for discussion\)\. The algorithm takes as input an RPQ whose regular language is given by an NFA and works roughly as follows:

- •a path in the chase is guessed step by step, keeping in memory only the current constant of the instance and current state of the automaton;
- •when a path passes through nulls in the chase, these terms are not guessed, instead the state of the automaton when the path returns to constants of the instance is guessed\.

The first item corresponds to a standard algorithm for RPQ answering over bare data\. The real difficulty lies in the second item, which requires a characterization of when it is possible to reach an automaton state through a path involving null elements\.

The following proposition makes a first step towards such a characterization by observing that every ‘anonymous’ path in the chase can be localized within the chase of a single ground atom\. It exploits the fact that for linear rules, each atom can be ‘chased’ independently \(see Section[2\.2](https://arxiv.org/html/2607.22636#S2.SS2)\)\.

###### Proposition 1\.

Letℛ\\mathcal\{R\}be a set of linear rules andIIbe an instance\. Then for every pathp=d0​r1​d1​⋯​rn​dnp=d\_\{0\}r\_\{1\}d\_\{1\}\\cdots r\_\{n\}d\_\{n\}in𝖼𝗁𝖺𝗌𝖾​\(I,ℛ\)\\mathsf\{chase\}\(I,\\mathcal\{R\}\)such thatd0,dn∈𝗍𝖾𝗋𝗆𝗌​\(I\)d\_\{0\},d\_\{n\}\\in\\mathsf\{terms\}\{\(I\)\}anddi∉𝗍𝖾𝗋𝗆𝗌​\(I\)d\_\{i\}\\not\\in\\mathsf\{terms\}\{\(I\)\}for0<i<n0<i<n, there exists an atomα∈I\\alpha\\in Iwithd0,dn∈𝗍𝖾𝗋𝗆𝗌​\(α\)d\_\{0\},d\_\{n\}\\in\\mathsf\{terms\}\{\(\\alpha\)\}such that there is a pathp′p^\{\\prime\}in𝖼𝗁𝖺𝗌𝖾​\(\{α\},ℛ\)\\mathsf\{chase\}\(\\\{\\alpha\\\},\\mathcal\{R\}\)fromd0d\_\{0\}todnd\_\{n\}withλ​\(p′\)=λ​\(p\)\\lambda\(p^\{\\prime\}\)=\\lambda\(p\)\.

###### Proof\.

LetApA\_\{p\}be the set of atoms inpp\. Any consecutive atoms inApA\_\{p\}, i\.e\.,ri​\(di−1,di\)r\_\{i\}\(d\_\{i\-1\},d\_\{i\}\)andri\+1​\(di,di\+1\)r\_\{i\+1\}\(d\_\{i\},d\_\{i\+1\}\),0<i<n0<i<n, share a null, hence, by Proposition[2](https://arxiv.org/html/2607.22636#Thmtheorem2), there is a unique atomα∈I\\alpha\\in Ifrom which all the atoms inApA\_\{p\}are generated in𝖼𝗁𝖺𝗌𝖾​\(I,ℛ\)\\mathsf\{chase\}\(I,\\mathcal\{R\}\)\. From Proposition[3](https://arxiv.org/html/2607.22636#Thmtheorem3),ApA\_\{p\}is isomorphic to a subset of𝖼𝗁𝖺𝗌𝖾​\(\{α\},ℛ\)\\mathsf\{chase\}\(\\\{\\alpha\\\},\\mathcal\{R\}\), which yields the pathp′p^\{\\prime\}\. ∎

We can therefore concentrate on identifying the paths that occur within the chase of a single atom\. In order to abstract from the particular terms occurring in an atom, we introduce the following notion of type:

###### Definition 2 \(Type of an atom\)\.

A*type*is a pairT=\(r,∼T\)T=\(r,\\sim\_\{T\}\)whererris a predicate of aritykkand∼T\\sim\_\{T\}is an equivalence relation on\{1,…,k\}\\\{1,\\ldots,k\\\}\. The type of an atomα\\alpha, denoted by𝗍𝗒𝗉𝖾​\(α\)\\mathsf\{type\}\{\(\\alpha\)\}, is the pairT=\(r,∼T\)T=\(r,\\sim\_\{T\}\)whererris the predicate ofα\\alphaandi∼Tji\\sim\_\{T\}jiff theithi^\{\\mathrm\{th\}\}and thejthj^\{\\mathrm\{th\}\}arguments ofα\\alphaare equal\.

For instance, the atomsr​\(x,y\)r\(x,y\),r​\(y,a\)r\(y,a\)andr​\(a,b\)r\(a,b\), whereaaandbbare constants, have the same typeT=\(r,\{\{1\},\{2\}\}\)T=\(r,\\\{\\\{1\\\},\\\{2\\\}\\\}\), while the atomr​\(x,x\)r\(x,x\)has type\(r,\{\{1,2\}\}\)\(r,\\\{\\\{1,2\\\}\\\}\); here,∼T\\sim\_\{T\}is given by its set of equivalence classes\.

When atomsα1\\alpha\_\{1\}andα2\\alpha\_\{2\}have the same type, there exists a bijective mappingθ12\\theta\_\{12\}from𝗍𝖾𝗋𝗆𝗌​\(α1\)\\mathsf\{terms\}\{\(\\alpha\_\{1\}\)\}to𝗍𝖾𝗋𝗆𝗌​\(α2\)\\mathsf\{terms\}\{\(\\alpha\_\{2\}\)\}such thatα2=θ12​\(α1\)\\alpha\_\{2\}=\\theta\_\{12\}\(\\alpha\_\{1\}\)\. We call this mapping the*natural mapping*fromα1\\alpha\_\{1\}toα2\\alpha\_\{2\}and observe thatθ21=θ12−1\\theta\_\{21\}=\\theta\_\{12\}^\{\-1\}\. With this notion in hand, we can formalize the idea that atoms with the same type behave the same regarding rule applications\.

###### Proposition 3\.

Letα1\\alpha\_\{1\}andα2\\alpha\_\{2\}be two atoms of the same type, and letθ12\\theta\_\{12\}be the natural mapping fromα1\\alpha\_\{1\}toα2\\alpha\_\{2\}\. Ifρ∈ℛ\\rho\\in\\mathcal\{R\}is applicable toα1\\alpha\_\{1\}byπ\\picreatingα1′\\alpha^\{\\prime\}\_\{1\}, thenρ\\rhois applicable toα2\\alpha\_\{2\}byθ12∘π\\theta\_\{12\}\\circ\\picreatingα2′\\alpha^\{\\prime\}\_\{2\}, whereα1′\\alpha\_\{1\}^\{\\prime\}andα2′\\alpha\_\{2\}^\{\\prime\}have the same type, and the natural mappingθ12′\\theta^\{\\prime\}\_\{12\}fromα1′\\alpha^\{\\prime\}\_\{1\}toα2′\\alpha^\{\\prime\}\_\{2\}coincides withθ12\\theta\_\{12\}on the terms on which they are both defined\.

A corollary of this proposition is that𝖼𝗁𝖺𝗌𝖾​\(\{α1\},ℛ\)\\mathsf\{chase\}\(\\\{\\alpha\_\{1\}\\\},\\mathcal\{R\}\)and𝖼𝗁𝖺𝗌𝖾​\(\{α2\},ℛ\)\\mathsf\{chase\}\(\\\{\\alpha\_\{2\}\\\},\\mathcal\{R\}\)will contain the same kinds of paths, as formalized next\.

###### Corollary 4\.

Letα\\alphaandα′\\alpha^\{\\prime\}be atoms with𝗍𝗒𝗉𝖾​\(α\)=𝗍𝗒𝗉𝖾​\(α′\)\\mathsf\{type\}\{\(\\alpha\)\}=\\mathsf\{type\}\{\(\\alpha^\{\\prime\}\)\}\. Then there is a path in𝖼𝗁𝖺𝗌𝖾​\(\{α\},ℛ\)\\mathsf\{chase\}\(\\\{\\alpha\\\},\\mathcal\{R\}\)from termα​\[i\]\\alpha\[i\]to termα​\[j\]\\alpha\[j\]with labelllif and only if there is a path in𝖼𝗁𝖺𝗌𝖾​\(\{α′\},ℛ\)\\mathsf\{chase\}\(\\\{\\alpha^\{\\prime\}\\\},\\mathcal\{R\}\)fromα′​\[i\]\\alpha^\{\\prime\}\[i\]toα′​\[j\]\\alpha^\{\\prime\}\[j\]with labelll\.

###### Proof\.

From Proposition[3](https://arxiv.org/html/2607.22636#Thmtheorem3a), there is a bijective mappingθ\\thetafrom the terms in𝖼𝗁𝖺𝗌𝖾​\(\{α\},ℛ\)\\mathsf\{chase\}\(\\\{\\alpha\\\},\\mathcal\{R\}\)to the terms in𝖼𝗁𝖺𝗌𝖾​\(\{α′\},ℛ\)\\mathsf\{chase\}\(\\\{\\alpha^\{\\prime\}\\\},\\mathcal\{R\}\), such thatθ​\(𝖼𝗁𝖺𝗌𝖾​\(\{α\},ℛ\)\)=𝖼𝗁𝖺𝗌𝖾​\(\{α′\},ℛ\)\\theta\(\\mathsf\{chase\}\(\\\{\\alpha\\\},\\mathcal\{R\}\)\)=\\mathsf\{chase\}\(\\\{\\alpha^\{\\prime\}\\\},\\mathcal\{R\}\)\. Hence, every pathppin𝖼𝗁𝖺𝗌𝖾​\(\{α\},ℛ\)\\mathsf\{chase\}\(\\\{\\alpha\\\},\\mathcal\{R\}\)from termα​\[i\]\\alpha\[i\]to termα​\[j\]\\alpha\[j\]is mapped byθ\\thetato a pathp′p^\{\\prime\}in𝖼𝗁𝖺𝗌𝖾​\(\{α′\},ℛ\)\\mathsf\{chase\}\(\\\{\\alpha^\{\\prime\}\\\},\\mathcal\{R\}\)fromα′​\[i\]\\alpha^\{\\prime\}\[i\]toα′​\[j\]\\alpha^\{\\prime\}\[j\]with the same label aspp\. ∎

The following proposition shows that it is possible to take paths in the chase of a single atom and reproduce them in a larger chase that contains an atom of the same type\.

###### Proposition 5\.

Letα\\alpha,α′\\alpha^\{\\prime\},β\\betabe atoms such that𝗍𝗒𝗉𝖾​\(α\)=𝗍𝗒𝗉𝖾​\(α′\)\\mathsf\{type\}\{\(\\alpha\)\}=\\mathsf\{type\}\{\(\\alpha^\{\\prime\}\)\}andα∈𝖼𝗁𝖺𝗌𝖾​\(\{β\},ℛ\)\\alpha\\in\\mathsf\{chase\}\(\\\{\\beta\\\},\\mathcal\{R\}\)\. If there is a path in𝖼𝗁𝖺𝗌𝖾​\(\{α′\},ℛ\)\\mathsf\{chase\}\(\\\{\\alpha^\{\\prime\}\\\},\\mathcal\{R\}\)from termα′​\[i\]\\alpha^\{\\prime\}\[i\]to termα′​\[j\]\\alpha^\{\\prime\}\[j\]with labelll, then there is a path in𝖼𝗁𝖺𝗌𝖾​\(\{β\},ℛ\)\\mathsf\{chase\}\(\\\{\\beta\\\},\\mathcal\{R\}\)fromα​\[i\]\\alpha\[i\]toα​\[j\]\\alpha\[j\]with labelll\.

###### Proof\.

Letp′p^\{\\prime\}be a path in𝖼𝗁𝖺𝗌𝖾​\(\{α′\},ℛ\)\\mathsf\{chase\}\(\\\{\\alpha^\{\\prime\}\\\},\\mathcal\{R\}\)from termα′​\[i\]\\alpha^\{\\prime\}\[i\]to termα′​\[j\]\\alpha^\{\\prime\}\[j\]with labelll\. Since𝗍𝗒𝗉𝖾​\(α\)=𝗍𝗒𝗉𝖾​\(α′\)\\mathsf\{type\}\{\(\\alpha\)\}=\\mathsf\{type\}\{\(\\alpha^\{\\prime\}\)\}, by Corollary[4](https://arxiv.org/html/2607.22636#Thmtheorem4a), there is a pathppin𝖼𝗁𝖺𝗌𝖾​\(\{α\},ℛ\)\\mathsf\{chase\}\(\\\{\\alpha\\\},\\mathcal\{R\}\)from termα​\[i\]\\alpha\[i\]to termα​\[j\]\\alpha\[j\]with labelll\. We then show that𝖼𝗁𝖺𝗌𝖾​\(\{α\},ℛ\)\\mathsf\{chase\}\(\\\{\\alpha\\\},\\mathcal\{R\}\)is isomorphic to a subset of𝖼𝗁𝖺𝗌𝖾​\(\{β\},ℛ\)\\mathsf\{chase\}\(\\\{\\beta\\\},\\mathcal\{R\}\), from which we conclude that𝖼𝗁𝖺𝗌𝖾​\(\{β\},ℛ\)\\mathsf\{chase\}\(\\\{\\beta\\\},\\mathcal\{R\}\)contains a pathp′′p^\{\\prime\\prime\}fromα​\[i\]\\alpha\[i\]toα​\[j\]\\alpha\[j\]with labelll\. We prove that there is an isomorphism from the result of anyℛ\\mathcal\{R\}\-derivation fromα\\alphato a subset of𝖼𝗁𝖺𝗌𝖾​\(\{β\},ℛ\)\\mathsf\{chase\}\(\\\{\\beta\\\},\\mathcal\{R\}\), by induction on the length of this derivation\. At rank 0, the property is true sinceα∈𝖼𝗁𝖺𝗌𝖾​\(\{β\},ℛ\)\\alpha\\in\\mathsf\{chase\}\(\\\{\\beta\\\},\\mathcal\{R\}\)\. Assume it is true until ranknn\. Consider a derivation fromα\\alphaof lengthn\+1n\+1: letAnA\_\{n\}be the set of atoms obtained after applying thenthn^\{\\mathrm\{th\}\}trigger; let\(ρ,π\)\(\\rho,\\pi\)be thenth\+1n^\{\\mathrm\{th\}\}\+1trigger,a=π​\(𝖻𝗈𝖽𝗒​\(ρ\)\)a=\\pi\(\\mathsf\{body\}\(\\rho\)\)anda′a^\{\\prime\}be the resulting atom\. Letψn\\psi\_\{n\}be the isomorphism fromAnA\_\{n\}to a subset of𝖼𝗁𝖺𝗌𝖾​\(\{β\},ℛ\)\\mathsf\{chase\}\(\\\{\\beta\\\},\\mathcal\{R\}\)\. Sinceaaandψn​\(a\)\\psi\_\{n\}\(a\)have the same type,\(ρ,ψn∘π\)\(\\rho,\\psi\_\{n\}\\circ\\pi\)is a trigger onψn​\(a\)\\psi\_\{n\}\(a\)and occurs in the derivation that builds𝖼𝗁𝖺𝗌𝖾​\(\{β\},ℛ\)\\mathsf\{chase\}\(\\\{\\beta\\\},\\mathcal\{R\}\), creating atoma′′a^\{\\prime\\prime\}of the same type asa′a^\{\\prime\}\(as in Proposition[3](https://arxiv.org/html/2607.22636#Thmtheorem3a)\)\. We build the mappingψn\+1\\psi\_\{n\+1\}fromAn∪\{a′\}A\_\{n\}\\cup\\\{a^\{\\prime\}\\\}to𝖼𝗁𝖺𝗌𝖾​\(\{β\},ℛ\)\\mathsf\{chase\}\(\\\{\\beta\\\},\\mathcal\{R\}\)by extendingψn\\psi\_\{n\}according to the natural mapping froma′a^\{\\prime\}toa′′a^\{\\prime\\prime\}\. Sinceψn\\psi\_\{n\}is an isomorphism fromAnA\_\{n\}to a subset of𝖼𝗁𝖺𝗌𝖾​\(\{β\},ℛ\)\\mathsf\{chase\}\(\\\{\\beta\\\},\\mathcal\{R\}\),ψn\+1\\psi\_\{n\+1\}is an isomorphism fromAn∪\{a′\}A\_\{n\}\\cup\\\{a^\{\\prime\}\\\}to a subset of𝖼𝗁𝖺𝗌𝖾​\(\{β\},ℛ\)\\mathsf\{chase\}\(\\\{\\beta\\\},\\mathcal\{R\}\)\. ∎

It now remains to determine which paths are available starting from an atom of a given type\. More specifically, we want to know, given a typeTT, positionsj,j′j,j^\{\\prime\}in any atomα\\alphaof typeTT, automaton𝔸\\mathbb\{A\}, and statessi,si′s\_\{i\},s\_\{i\}^\{\\prime\}, whether𝖼𝗁𝖺𝗌𝖾​\(α,ℛ\)\\mathsf\{chase\}\(\\alpha,\\mathcal\{R\}\)contains a pathppfromα​\[j\]\\alpha\[j\]toα​\[j′\]\\alpha\[j^\{\\prime\}\]whose labelλ​\(p\)\\lambda\(p\)takes𝔸\\mathbb\{A\}from statesis\_\{i\}to statesi′s^\{\\prime\}\_\{i\}\. To this end, we formalize the notion of a type admitting a loop:

###### Definition 6\.

We say that a*typeTTadmits an\(si,j,si′,j′\)\(s\_\{i\},j,s^\{\\prime\}\_\{i\},j^\{\\prime\}\)\-loop \(w\.r\.t\. a linear rulesetℛ\\mathcal\{R\}and NFA𝔸\\mathbb\{A\}\)*if there is a pathppin𝖼𝗁𝖺𝗌𝖾​\(\{αT\},ℛ\)\\mathsf\{chase\}\(\\\{\\alpha\_\{T\}\\\},\\mathcal\{R\}\)fromαT​\[j\]\\alpha\_\{T\}\[j\]toαT​\[j′\]\\alpha\_\{T\}\[j^\{\\prime\}\]such thatλ​\(p\)∈ℒ𝔸​\(si,si′\)\\lambda\(p\)\\in\\mathcal\{L\}\_\{\\mathbb\{A\}\}\(s\_\{i\},s\_\{i^\{\\prime\}\}\), whereαT\\alpha\_\{T\}is any atom of typeTT\.

Any choice of the atomαT\\alpha\_\{T\}will give the same result, due to Corollary[4](https://arxiv.org/html/2607.22636#Thmtheorem4a)\. Before detailing the algorithms, we provide below a high\-level overview of how they work using the running example\.

###### Example 7 \(Running example—continued\)\.

Letℛ\\mathcal\{R\}be the following set of linear rules:

> \(ρ1\)𝗂𝗌𝖥𝗋𝗂𝖾𝗇𝖽𝖮𝖿​\(x,y\)→𝗂𝗌𝖥𝗋𝗂𝖾𝗇𝖽𝖮𝖿​\(y,x\)\{\(\\rho\_\{1\}\)\}\\quad\\mathsf\{isFriendOf\}\(x,y\)\\rightarrow\\mathsf\{isFriendOf\}\(y,x\) \(ρ2\)𝗂𝗌𝖥𝗋𝗂𝖾𝗇𝖽𝖮𝖿​\(x,y\)→𝖿𝗈𝗅𝗅𝗈𝗐𝗌​\(x,y\)\(\\rho\_\{2\}\)\\quad\\mathsf\{isFriendOf\}\(x,y\)\\rightarrow\\mathsf\{follows\}\(x,y\) \(ρ3\)𝖿𝗈𝗅𝗅𝗈𝗐𝗌​\(x,y\)→∃m​𝗆𝖾𝗌𝗌𝖺𝗀𝖾​\(m,x,y\)\(\\rho\_\{3\}\)\\quad\\mathsf\{follows\}\(x,y\)\\rightarrow\\exists m~\\mathsf\{message\}\(m,x,y\) \(ρ5\)𝗆𝖾𝗌𝗌𝖺𝗀𝖾​\(m,x,y\)→𝗌𝖾𝗇𝖽𝗌​\(x,m\)\(\\rho\_\{5\}\)\\quad\\mathsf\{message\}\(m,x,y\)\\rightarrow\\mathsf\{sends\}\(x,m\) \(ρ6\)𝗆𝖾𝗌𝗌𝖺𝗀𝖾​\(m,x,y\)→𝗋𝖾𝖼𝖾𝗂𝗏𝖾𝗌​\(y,m\)\(\\rho\_\{6\}\)\\quad\\mathsf\{message\}\(m,x,y\)\\rightarrow\\mathsf\{receives\}\(y,m\)

The first three rules were already introduced in Example[1](https://arxiv.org/html/2607.22636#Thmtheorem1)and the two additional rules allow us to reformulate the CRPQq6q\_\{6\}in the form of an RPQ\. Recall thatq6q\_\{6\}asks whether user𝖠𝗅𝗂𝖼𝖾\\mathsf\{Alice\}\(abbreviated as𝖠\\mathsf\{A\}in the following\) received a message from someone she follows directly or indirectly\. Instead of the CRPQq6q\_\{6\}, we can consider the following RPQq6′q^\{\\prime\}\_\{6\}and check whether\(𝖠,𝖠\)\(\\mathsf\{A\},\\mathsf\{A\}\)is a certain answer:

q6′​\(x,y\)=𝖿𝗈𝗅𝗅𝗈𝗐𝗌⋅𝖿𝗈𝗅𝗅𝗈𝗐𝗌∗⋅𝗌𝖾𝗇𝖽𝗌⋅𝗋𝖾𝖼𝖾𝗂𝗏𝖾𝗌−​\(x,y\)q^\{\\prime\}\_\{6\}\(x,y\)=\\mathsf\{follows\\cdot follows\}^\{\*\}\\cdot\\mathsf\{sends\}\\cdot\\mathsf\{receives\}^\{\-\}\(x,y\)We assign toq6′q^\{\\prime\}\_\{6\}the NFA representation𝔸\\mathbb\{A\}with states\{s0,s1,s2,sf\}\\\{s\_\{0\},s\_\{1\},s\_\{2\},s\_\{f\}\\\}\(withs0s\_\{0\}initial andsfs\_\{f\}final\) and four transitions:\(s0,𝖿𝗈𝗅𝗅𝗈𝗐𝗌,s1\)\(s\_\{0\},\\mathsf\{follows\},s\_\{1\}\),\(s1,𝖿𝗈𝗅𝗅𝗈𝗐𝗌,s1\)\(s\_\{1\},\\mathsf\{follows\},s\_\{1\}\),\(s1,𝗌𝖾𝗇𝖽𝗌,s2\)\(s\_\{1\},\\mathsf\{sends\},s\_\{2\}\)and\(s2,𝗋𝖾𝖼𝖾𝗂𝗏𝖾𝗌−,sf\)\(s\_\{2\},\\mathsf\{receives\}^\{\-\},s\_\{f\}\)\.

Let us consider again the instanceI=\{𝖿𝗈𝗅𝗅𝗈𝗐𝗌​\(𝖡,𝖠\),𝗂𝗌𝖥𝗋𝗂𝖾𝗇𝖽𝖮𝖿​\(𝖢,𝖠\),𝗂𝗌𝖥𝗋𝗂𝖾𝗇𝖽𝖮𝖿​\(𝖢,𝖡\)\}I=\\\{\\mathsf\{follows\(B,A\)\},\\mathsf\{isFriendOf\(C,A\)\},\\mathsf\{isFriendOf\(C,B\)\}\\\}\. Queryq6′q^\{\\prime\}\_\{6\}can be matched to the following path of terms in𝖼𝗁𝖺𝗌𝖾​\(I,ℛ\)\\mathsf\{chase\}\(I,\\mathcal\{R\}\):

\(𝖠​𝖿𝗈𝗅𝗅𝗈𝗐𝗌​𝖢​𝖿𝗈𝗅𝗅𝗈𝗐𝗌​𝖡​𝗌𝖾𝗇𝖽𝗌​𝗆𝟢​𝗋𝖾𝖼𝖾𝗂𝗏𝖾𝗌−​𝖠\)\(\\mathsf\{A\}~\\mathsf\{follows\}~\\mathsf\{C\}~\\mathsf\{follows\}~\\mathsf\{B\}~\\mathsf\{sends\}~\\mathsf\{m\_\{0\}\}~\\mathsf\{receives\}^\{\-\}\\mathsf\{A\}\)with𝗆𝟢\\mathsf\{m\_\{0\}\}the null introduced when applying the rule\(ρ3\)\(\\rho\_\{3\}\)to𝖿𝗈𝗅𝗅𝗈𝗐𝗌​\(𝖡,𝖠\)\\mathsf\{follows\(B,A\)\}\. The facts𝖿𝗈𝗅𝗅𝗈𝗐𝗌​\(𝖠,𝖢\)\\mathsf\{follows\(A,C\)\}and𝖿𝗈𝗅𝗅𝗈𝗐𝗌​\(𝖢,𝖡\)\\mathsf\{follows\(C,B\)\}, witnessing the subpath\(𝖠​𝖿𝗈𝗅𝗅𝗈𝗐𝗌​𝖢​𝖿𝗈𝗅𝗅𝗈𝗐𝗌​𝖡\)\(\\mathsf\{A\}~\\mathsf\{follows\}~\\mathsf\{C\}~\\mathsf\{follows\}~\\mathsf\{B\}\), are derived from the facts𝗂𝗌𝖥𝗋𝗂𝖾𝗇𝖽𝖮𝖿​\(𝖢,𝖠\)\\mathsf\{isFriendOf\(C,A\)\}and𝗂𝗌𝖥𝗋𝗂𝖾𝗇𝖽𝖮𝖿​\(𝖢,𝖡\)\\mathsf\{isFriendOf\(C,B\)\}, respectively, using rulesρ1\\rho\_\{1\}andρ2\\rho\_\{2\}\. As these are ground facts, the corresponding subpath\(A​𝖿𝗈𝗅𝗅𝗈𝗐𝗌​C​𝖿𝗈𝗅𝗅𝗈𝗐𝗌​B\)\(A~\\mathsf\{follows\}~C~\\mathsf\{follows\}~B\)will be entirely guessed by the algorithm\. This subpath takes𝔸\\mathbb\{A\}from states0s\_\{0\}tos1s\_\{1\}\. By contrast, the subpath\(B​𝗌𝖾𝗇𝖽𝗌​m0​𝗋𝖾𝖼𝖾𝗂𝗏𝖾𝗌−​A\)\(B~\\mathsf\{sends\}~m\_\{0\}~\\mathsf\{receives\}^\{\-\}A\), whose witnessing atoms contain the nullm0m\_\{0\}, will not be guessed\. Instead, we will rely on Proposition[1](https://arxiv.org/html/2607.22636#Thmtheorem1b)and find a ground fact inII, hereα=𝖿𝗈𝗅𝗅𝗈𝗐𝗌​\(B,A\)\\alpha=\\mathsf\{follows\}\(B,A\), such that\(B​𝗌𝖾𝗇𝖽𝗌​m0​𝗋𝖾𝖼𝖾𝗂𝗏𝖾𝗌−​A\)\(B~\\mathsf\{sends\}~m\_\{0\}~\\mathsf\{receives\}^\{\-\}A\)occurs in𝖼𝗁𝖺𝗌𝖾​\(α,ℛ\)\\mathsf\{chase\}\(\\alpha,\\mathcal\{R\}\)\. More precisely: the type\(𝖿𝗈𝗅𝗅𝗈𝗐𝗌,\{\{1\},\{2\}\}\)\(\\mathsf\{follows\},\\\{\\\{1\\\},\\\{2\\\}\\\}\), which is the type ofα\\alpha, admits a loop from the term in position 1 to the term in position 2 that takes𝔸\\mathbb\{A\}from states1s\_\{1\}tosfs\_\{f\}\(in short: an\(s1,1,sf,2\)\(s\_\{1\},1,s\_\{f\},2\)\-loop\)\.

We will use Algorithm 1, detailed later, to compute the set of loops admitted by each of the types associated withℛ\\mathcal\{R\}\. In particular, we have here that*\(i\)*type\(𝗌𝖾𝗇𝖽𝗌,\{\{1\},\{2\}\}\)\(\\mathsf\{sends\},\\\{\\\{1\\\},\\\{2\\\}\\\}\)admits an\(s1,1,s2,2\)\(s\_\{1\},1,s\_\{2\},2\)\-loop and*\(ii\)*type\(𝗋𝖾𝖼𝖾𝗂𝗏𝖾𝗌−,\{\{1\},\{2\}\}\)\(\\mathsf\{receives\}^\{\-\},\\\{\\\{1\\\},\\\{2\\\}\\\}\)admits an\(s2,2,sf,1\)\(s\_\{2\},2,s\_\{f\},1\)\-loop, which is directly obtained from the transitions in𝔸\\mathbb\{A\}\. From*\(i\)*and rule\(ρ5\)\(\\rho\_\{5\}\)considered “from head to body”, we obtain that type\(𝗆𝖾𝗌𝗌𝖺𝗀𝖾,\{\{1\},\{2\},\{3\}\}\)\(\\mathsf\{message\},\\\{\\\{1\\\},\\\{2\\\},\\\{3\\\}\\\}\)admits an\(s1,2,s2,1\)\(s\_\{1\},2,s\_\{2\},1\)\-loop\. Similarly, from*\(ii\)*and rule\(ρ6\)\(\\rho\_\{6\}\), we obtain that type\(𝗆𝖾𝗌𝗌𝖺𝗀𝖾,\{\{1\},\{2\},\{3\}\}\)\(\\mathsf\{message\},\\\{\\\{1\\\},\\\{2\\\},\\\{3\\\}\\\}\)admits an\(s2,1,sf,3\)\(s\_\{2\},1,s\_\{f\},3\)\-loop\. Concatenating the two loops admitted by type\(𝗆𝖾𝗌𝗌𝖺𝗀𝖾,\{\{1\},\{2\},\{3\}\}\)\(\\mathsf\{message\},\\\{\\\{1\\\},\\\{2\\\},\\\{3\\\}\\\}\), we add an\(s1,2,sf,3\)\(s\_\{1\},2,s\_\{f\},3\)\-loop to that type, which, using rule\(ρ3\)\(\\rho\_\{3\}\), yields the\(s1,1,sf,2\)\(s\_\{1\},1,s\_\{f\},2\)\-loop for the type\(𝖿𝗈𝗅𝗅𝗈𝗐𝗌,\{\{1\},\{2\}\}\)\(\\mathsf\{follows\},\\\{\\\{1\\\},\\\{2\\\}\\\}\)ofα=𝖿𝗈𝗅𝗅𝗈𝗐𝗌​\(B,A\)\\alpha=\\mathsf\{follows\}\(B,A\)\.

Algorithm 2, which is the global algorithm, takes as inputII,ℛ\\mathcal\{R\},𝔸\\mathbb\{A\}, as well as a candidate answer \(the pair\(𝖠,𝖠\)\(\\mathsf\{A\},\\mathsf\{A\}\)in our example\)\. It first calls Algorithm 1 to build the table of loops associated with types, then tries to verify the existence of a witnessing path in𝖼𝗁𝖺𝗌𝖾​\(I,ℛ\)\\mathsf\{chase\}\(I,\\mathcal\{R\}\), while being guided by the transitions in𝔸\\mathbb\{A\}and loops assigned to types\. Here, starting from states0s\_\{0\}and constant𝖠\\mathsf\{A\}, it will guess the atoms𝖿𝗈𝗅𝗅𝗈𝗐𝗌​\(𝖠,𝖢\)\\mathsf\{follows\(A,C\)\}and𝖿𝗈𝗅𝗅𝗈𝗐𝗌​\(𝖢,𝖡\)\\mathsf\{follows\(C,B\)\}using transitions in𝔸\\mathbb\{A\}and check that these atoms are indeed entailed by\(I,ℛ\)\(I,\\mathcal\{R\}\)\. This corresponds to the subpath\(A​𝖿𝗈𝗅𝗅𝗈𝗐𝗌​C​𝖿𝗈𝗅𝗅𝗈𝗐𝗌​B\)\(A~\\mathsf\{follows\}~C~\\mathsf\{follows\}~B\), which takes𝔸\\mathbb\{A\}from states0s\_\{0\}tos1s\_\{1\}\. Then, the algorithm guesses constantAAand statesfs\_\{f\}together with the\(s1,1,sf,2\)\(s\_\{1\},1,s\_\{f\},2\)\-loop for type\(𝖿𝗈𝗅𝗅𝗈𝗐𝗌,\{\{1\},\{2\}\}\)\(\\mathsf\{follows\},\\\{\\\{1\\\},\\\{2\\\}\\\}\), and checks thatIIcontains the atom𝖿𝗈𝗅𝗅𝗈𝗐𝗌​\(B,A\)\\mathsf\{follows\}\(B,A\)\.

We shall now explain how to compute the loops admitted by a given type\. Algorithm[1](https://arxiv.org/html/2607.22636#algorithm1)builds a tableLoopwhose cells are indexed by tuples\(si,j,si′,j′\)\(s\_\{i\},j,s^\{\\prime\}\_\{i\},j^\{\\prime\}\), with the cell\(si,j,si′,j′\)\(s\_\{i\},j,s^\{\\prime\}\_\{i\},j^\{\\prime\}\)storing the typesTTthat admit an\(si,j,si′,j′\)\(s\_\{i\},j,s^\{\\prime\}\_\{i\},j^\{\\prime\}\)\-loop\. We use the notationLoop​\(si,j,si′,j′\)\\texttt\{Loop\}\(s\_\{i\},j,s^\{\\prime\}\_\{i\},j^\{\\prime\}\)to denote the set of types stored in the cell\(si,j,si′,j′\)\(s\_\{i\},j,s^\{\\prime\}\_\{i\},j^\{\\prime\}\)\. We assume all the cells are empty when they are created\. Line[1](https://arxiv.org/html/2607.22636#algorithm1)initializes the table by stating that one can go from a term in a position to the same term in another position without reading any word \(and thus not moving in the automaton\)\. Lines[1](https://arxiv.org/html/2607.22636#algorithm1)and[1](https://arxiv.org/html/2607.22636#algorithm1)correspond to traversing a single binary atom, reading its label either as anrror anr−r^\{\-\}, in the case where both terms are distinct, i\.e\.,T=\(r,\{\{1\},\{2\}\}\)T=\(r,\\\{\\\{1\\\},\\\{2\\\}\\\}\)\. Lines[1](https://arxiv.org/html/2607.22636#algorithm1)to[1](https://arxiv.org/html/2607.22636#algorithm1)are similar but handle the case where both arguments are equal, i\.e\.,T=\(r,\{\{1,2\}\}\)T=\(r,\\\{\\\{1,2\\\}\\\}\)\. Finally, Lines[1](https://arxiv.org/html/2607.22636#algorithm1)and[1](https://arxiv.org/html/2607.22636#algorithm1)serve to combine these basic paths\. On the one hand, the table is saturated through path concatenation: if one can go from a positionj1j\_\{1\}to a positionj2j\_\{2\}by a path taking the automaton from states1s\_\{1\}to states2s\_\{2\}, and fromj2j\_\{2\}to a positionj3j\_\{3\}by a path taking the automaton froms2s\_\{2\}to states3s\_\{3\}, then one can go fromj1j\_\{1\}toj3j\_\{3\}by a path taking the automaton froms1s\_\{1\}tos3s\_\{3\}\. On the other hand, rules are taken into account: for any ruleα→β\\alpha\\rightarrow\\beta, ifα\\alphaandβ\\betaboth contain variablesxxandyy\(with possiblyx=yx=y\) and one can go from the position ofxxinβ\\betato the position ofyyinβ\\betataking the automaton from states1s\_\{1\}to states2s\_\{2\}then the same move is possible from the position ofxxinα\\alphato the position ofyyinα\\alpha\. Indeed, in the chase of any atomα1\\alpha\_\{1\}of type𝗍𝗒𝗉𝖾​\(α\)\\mathsf\{type\}\{\(\\alpha\)\}, there is an atomβ1\\beta\_\{1\}of type𝗍𝗒𝗉𝖾​\(β\)\\mathsf\{type\}\{\(\\beta\)\}, which has the same terms asα1\\alpha\_\{1\}in the positions ofxxandyy\. We further illustrate the different steps of Algorithm 1 with an example\.

###### Example 8\.

Let the rulesetℛ\\mathcal\{R\}consist of the following three linear rules:

p​\(x,x,z\)→∃w​q​\(x,z,w\)q​\(x,z,w\)→u​\(w,x\)q​\(x,z,w\)→r​\(w,z\)p\(x,x,z\)\\rightarrow\\exists w\\,q\(x,z,w\)\\qquad q\(x,z,w\)\\rightarrow u\(w,x\)\\qquad q\(x,z,w\)\\rightarrow r\(w,z\)and consider the types associated with the atoms appearing in these rules:

Tp=\(p,\{\{1,2\},\{3\}\}\)Tq=\(q,\{\{1\},\{2\},\{3\}\}Tu=\(u,\{\{1\},\{2\}\}\)Tr=\(r,\{\{1\},\{2\}\}\)T\_\{p\}=\(p,\\\{\\\{1,2\\\},\\\{3\\\}\\\}\)\\quad T\_\{q\}=\(q,\\\{\\\{1\\\},\\\{2\\\},\\\{3\\\}\\\}\\quad T\_\{u\}=\(u,\\\{\\\{1\\\},\\\{2\\\}\\\}\)\\quad T\_\{r\}=\(r,\\\{\\\{1\\\},\\\{2\\\}\\\}\)For our query, we take the RPQr−⋅u∗​\(t1,t2\)r^\{\-\}\\\!\\\!\\cdot u^\{\*\}\(t\_\{1\},t\_\{2\}\)wherer,u∈𝒫2r,u\\in\\mathcal\{P\}\_\{2\}\. To apply Algorithm[1](https://arxiv.org/html/2607.22636#algorithm1), we consider the corresponding NFA representation𝔸\\mathbb\{A\}with states\{s0,sf\}\\\{s\_\{0\},s\_\{f\}\\\}\(withs0s\_\{0\}initial andsfs\_\{f\}final\) and two transitions:\(s0,r−,sf\)\(s\_\{0\},r^\{\-\},s\_\{f\}\)and\(sf,u,sf\)\(s\_\{f\},u,s\_\{f\}\)\. We indicate which parts of the algorithm allow us to add typeTpT\_\{p\}toLoop​\(s0,3,sf,1\)\\texttt\{Loop\}\(s\_\{0\},3,s\_\{f\},1\):

- •TypeTrT\_\{r\}is added toLoop​\(s0,2,sf,1\)\\texttt\{Loop\}\(s\_\{0\},2,s\_\{f\},1\)in Line[1](https://arxiv.org/html/2607.22636#algorithm1)due to transition\(s0,r−,sf\)\(s\_\{0\},r^\{\-\},s\_\{f\}\)\.
- •TypeTuT\_\{u\}is added toLoop​\(sf,1,sf,2\)\\texttt\{Loop\}\(s\_\{f\},1,s\_\{f\},2\)in Line[1](https://arxiv.org/html/2607.22636#algorithm1)due to transition\(sf,u,sf\)\(s\_\{f\},u,s\_\{f\}\)\.
- •TypeTqT\_\{q\}is added toLoop​\(s0,2,sf,3\)\\texttt\{Loop\}\(s\_\{0\},2,s\_\{f\},3\)in Line[1](https://arxiv.org/html/2607.22636#algorithm1)due to ruleq​\(x,z,w\)→r​\(w,z\)q\(x,z,w\)\\rightarrow r\(w,z\),Tr∈Loop​\(s0,2,sf,1\)T\_\{r\}\\in\\texttt\{Loop\}\(s\_\{0\},2,s\_\{f\},1\), and the 2nd and 3rd arguments ofq​\(x,z,w\)q\(x,z,w\)coinciding with the 2nd and 1st arguments ofr​\(w,z\)r\(w,z\)\.
- •TypeTqT\_\{q\}is added toLoop​\(sf,3,sf,1\)\\texttt\{Loop\}\(s\_\{f\},3,s\_\{f\},1\)in Line[1](https://arxiv.org/html/2607.22636#algorithm1)due to ruleq​\(x,z,w\)→u​\(w,x\)q\(x,z,w\)\\rightarrow u\(w,x\),Tu∈Loop​\(sf,1,sf,2\)T\_\{u\}\\in\\texttt\{Loop\}\(s\_\{f\},1,s\_\{f\},2\), and the 3rd and 1st arguments ofq​\(x,z,w\)q\(x,z,w\)coinciding with the 1st and 2nd arguments ofu​\(w,x\)u\(w,x\)\.
- •TypeTqT\_\{q\}is added toLoop​\(s0,2,sf,1\)\\texttt\{Loop\}\(s\_\{0\},2,s\_\{f\},1\)in Line[1](https://arxiv.org/html/2607.22636#algorithm1)because it is in bothLoop​\(s0,2,sf,3\)\\texttt\{Loop\}\(s\_\{0\},2,s\_\{f\},3\)andLoop​\(sf,3,sf,1\)\\texttt\{Loop\}\(s\_\{f\},3,s\_\{f\},1\)\.
- •TypeTpT\_\{p\}is added toLoop​\(s0,3,sf,1\)\\texttt\{Loop\}\(s\_\{0\},3,s\_\{f\},1\)in Line[1](https://arxiv.org/html/2607.22636#algorithm1)due to rulep​\(x,x,z\)→∃w​q​\(x,z,w\)p\(x,x,z\)\\rightarrow\\exists w\\,q\(x,z,w\),Tq∈Loop​\(s0,2,sf,1\)T\_\{q\}\\in\\texttt\{Loop\}\(s\_\{0\},2,s\_\{f\},1\), and the 3rd and 1st arguments ofp​\(x,x,z\)p\(x,x,z\)coinciding with the 2nd and 1st arguments ofq​\(x,z,w\)q\(x,z,w\)\. Note that since the 1st and 2nd arguments ofp​\(x,x,z\)p\(x,x,z\)are the same, the algorithm will also addTpT\_\{p\}toLoop​\(s0,3,sf,2\)\\texttt\{Loop\}\(s\_\{0\},3,s\_\{f\},2\)\.

The inclusion of typeTpT\_\{p\}inLoop​\(s0,3,sf,1\)\\texttt\{Loop\}\(s\_\{0\},3,s\_\{f\},1\)allows one to infer for example that\{p​\(a,a,c\)\},ℛ⊧r−⋅u∗​\(c,a\)\\\{p\(a,a,c\)\\\},\\mathcal\{R\}\\models r^\{\-\}\\\!\\\!\\cdot u^\{\*\}\(c,a\)\.

Data:A set of linear rules

ℛ\\mathcal\{R\}and NFA

𝔸=\(S,Σ,δ,s0,F\)\\mathbb\{A\}=\(S,\\Sigma,\\delta,s\_\{0\},F\)
Result:A table whose cells are indexed by tuples

\(s,j,s′,j′\)∈S×\[1,w\]×S×\[1,w\]\(s,j,s^\{\\prime\},j^\{\\prime\}\)\\in S\\times\[1,w\]\\times S\\times\[1,w\], with

wwthe maximal predicate arity in

ℛ\\mathcal\{R\}, and each cell contains a set of types on predicates from

ℛ\\mathcal\{R\}
1

/\*Initialization step \*/

2for*typeTTof predicate of aritykk*do

3for*pair\(j,j′\)∈\{1,…,k\}2\(j,j^\{\\prime\}\)\\in\\\{1,\\ldots,k\\\}^\{2\}withj∼Tj′j\\sim\_\{T\}j^\{\\prime\}*do

4for*s∈Ss\\in S*do

5

Loop​\(s,j,s,j′\)←Loop​\(s,j,s,j′\)∪\{T\}\\texttt\{Loop\}\(s,j,s,j^\{\\prime\}\)\\leftarrow\\texttt\{Loop\}\(s,j,s,j^\{\\prime\}\)\\cup\\\{T\\\};

6

7

8

9for*typeTTbased onr​\(x,y\)r\(x,y\)*do

10for*\(s1,r,s2\)∈δ\(s\_\{1\},r,s\_\{2\}\)\\in\\delta*do

11

Loop​\(s1,1,s2,2\)←Loop​\(s1,1,s2,2\)∪\{T\}\\texttt\{Loop\}\(s\_\{1\},1,s\_\{2\},2\)\\leftarrow\\texttt\{Loop\}\(s\_\{1\},1,s\_\{2\},2\)\\cup\\\{T\\\};

12for*\(s1,r−,s2\)∈δ\(s\_\{1\},r^\{\-\},s\_\{2\}\)\\in\\delta*do

13

Loop​\(s1,2,s2,1\)←Loop​\(s1,2,s2,1\)∪\{T\}\\texttt\{Loop\}\(s\_\{1\},2,s\_\{2\},1\)\\leftarrow\\texttt\{Loop\}\(s\_\{1\},2,s\_\{2\},1\)\\cup\\\{T\\\};

14

15for*typeTTbased onr​\(x,x\)r\(x,x\)*do

16for*\(s1,r,s2\)∈δ\(s\_\{1\},r,s\_\{2\}\)\\in\\deltaor\(s1,r−,s2\)∈δ\(s\_\{1\},r^\{\-\},s\_\{2\}\)\\in\\delta*do

17

Loop​\(s1,1,s2,1\)←Loop​\(s1,1,s2,1\)∪\{T\}\\texttt\{Loop\}\(s\_\{1\},1,s\_\{2\},1\)\\leftarrow\\texttt\{Loop\}\(s\_\{1\},1,s\_\{2\},1\)\\cup\\\{T\\\};

18

Loop​\(s1,1,s2,2\)←Loop​\(s1,1,s2,2\)∪\{T\}\\texttt\{Loop\}\(s\_\{1\},1,s\_\{2\},2\)\\leftarrow\\texttt\{Loop\}\(s\_\{1\},1,s\_\{2\},2\)\\cup\\\{T\\\};

19

Loop​\(s1,2,s2,1\)←Loop​\(s1,2,s2,1\)∪\{T\}\\texttt\{Loop\}\(s\_\{1\},2,s\_\{2\},1\)\\leftarrow\\texttt\{Loop\}\(s\_\{1\},2,s\_\{2\},1\)\\cup\\\{T\\\};

20

Loop​\(s1,2,s2,2\)←Loop​\(s1,2,s2,2\)∪\{T\}\\texttt\{Loop\}\(s\_\{1\},2,s\_\{2\},2\)\\leftarrow\\texttt\{Loop\}\(s\_\{1\},2,s\_\{2\},2\)\\cup\\\{T\\\};

21

22

23

/\*Saturation step \*/

24while*something added*do

25for*T∈𝙻𝚘𝚘𝚙​\(s1,j1,s2,j2\)∩𝙻𝚘𝚘𝚙​\(s2,j2,s3,j3\)T\\in\\mathtt\{Loop\}\(s\_\{1\},j\_\{1\},s\_\{2\},j\_\{2\}\)\\cap\\mathtt\{Loop\}\(s\_\{2\},j\_\{2\},s\_\{3\},j\_\{3\}\)*do

26

𝙻𝚘𝚘𝚙​\(s1,j1,s3,j3\)←𝙻𝚘𝚘𝚙​\(s1,j1,s3,j3\)∪\{T\}\\mathtt\{Loop\}\(s\_\{1\},j\_\{1\},s\_\{3\},j\_\{3\}\)\\leftarrow\\mathtt\{Loop\}\(s\_\{1\},j\_\{1\},s\_\{3\},j\_\{3\}\)\\cup\\\{T\\\};

27

28for*α→β∈ℛ\\alpha\\rightarrow\\beta\\in\\mathcal\{R\}*do

29if*α​\[iα\]=β​\[iβ\]\\alpha\[i\_\{\\alpha\}\]=\\beta\[i\_\{\\beta\}\],α​\[jα\]=β​\[jβ\]\\alpha\[j\_\{\\alpha\}\]=\\beta\[j\_\{\\beta\}\], and𝗍𝗒𝗉𝖾​\(β\)∈𝙻𝚘𝚘𝚙​\(s1,iβ,s2,jβ\)\\mathsf\{type\}\{\(\\beta\)\}\\in\\mathtt\{Loop\}\(s\_\{1\},i\_\{\\beta\},s\_\{2\},j\_\{\\beta\}\)*then

30

Loop​\(s1,iα,s2,jα\)←Loop​\(s1,iα,s2,jα\)∪\{𝗍𝗒𝗉𝖾​\(α\)\}\\texttt\{Loop\}\(s\_\{1\},i\_\{\\alpha\},s\_\{2\},j\_\{\\alpha\}\)\\leftarrow\\texttt\{Loop\}\(s\_\{1\},i\_\{\\alpha\},s\_\{2\},j\_\{\\alpha\}\)\\cup\\\{\\mathsf\{type\}\{\(\\alpha\)\}\\\};

31

32

Algorithm 1Creating theLooptableThe following propositions establish the correctness of Algorithm[1](https://arxiv.org/html/2607.22636#algorithm1)and provide upper bounds on its running time\. Note that the algorithm is independent from the data\.

###### Proposition 9\.

Letℛ\\mathcal\{R\}be a set of linear rules,𝔸\\mathbb\{A\}be an NFA,TTbe a type whose predicate occurs inℛ\\mathcal\{R\}, and𝙻𝚘𝚘𝚙\\mathtt\{Loop\}be the table constructed by Algorithm[1](https://arxiv.org/html/2607.22636#algorithm1)on input \(ℛ,𝔸\\mathcal\{R\},\\mathbb\{A\}\)\. ThenT∈𝙻𝚘𝚘𝚙​\(s,i,s′,j\)T\\in\\mathtt\{Loop\}\(s,i,s^\{\\prime\},j\)iffTTadmits an\(s,i,s′,j\)\(s,i,s^\{\\prime\},j\)\-loop\.

###### Proof\.

Throughout the proof, we assume that for each typeTT, we have selected some atomαT\\alpha\_\{T\}of typeTT\.

\(⇒\\Rightarrow\) We prove, by induction on the order of addition of types that whenever a typeTTis added to a cell inLoop​\(s,i,s′,j\)\\texttt\{Loop\}\(s,i,s^\{\\prime\},j\), thenTTadmits an\(s,i,s′,j\)\(s,i,s^\{\\prime\},j\)\-loop\. First, suppose thatTTis added toLoop​\(s,j,s,j′\)\\texttt\{Loop\}\(s,j,s,j^\{\\prime\}\)at Line[1](https://arxiv.org/html/2607.22636#algorithm1)\. Then the trivial length\-0 pathαT​\[j\]\\alpha\_\{T\}\[j\]\(=αT​\[j′\]\\alpha\_\{T\}\[j^\{\\prime\}\]\) in𝖼𝗁𝖺𝗌𝖾​\(\{αT\},ℛ\)\\mathsf\{chase\}\(\\\{\\alpha\_\{T\}\\\},\\mathcal\{R\}\)witnesses thatTTadmits an\(s,j,s,j′\)\(s,j,s,j^\{\\prime\}\)\-loop, since it is labeled by the empty word, which does not change the state of the automaton\. Next, consider the case in whichTTis added toLoop​\(s1,1,s2,2\)\\texttt\{Loop\}\(s\_\{1\},1,s\_\{2\},2\)at Line[1](https://arxiv.org/html/2607.22636#algorithm1)\. ThenαT\\alpha\_\{T\}takes the formr​\(t1,t2\)r\(t\_\{1\},t\_\{2\}\), so𝖼𝗁𝖺𝗌𝖾​\(\{αT\},ℛ\)\\mathsf\{chase\}\(\\\{\\alpha\_\{T\}\\\},\\mathcal\{R\}\)contains anrr\-labeled path fromαT​\[1\]\\alpha\_\{T\}\[1\]toαT​\[2\]\\alpha\_\{T\}\[2\], which belongs toℒ𝔸​\(s1,s2\)\\mathcal\{L\}\_\{\\mathbb\{A\}\}\(s\_\{1\},s\_\{2\}\)sinces2∈δ​\(s1,r\)s\_\{2\}\\in\\delta\(s\_\{1\},r\); hence,TTadmits an\(s1,1,s2,2\)\(s\_\{1\},1,s\_\{2\},2\)\-loop\. The reasoning is similar for types added at Line[1](https://arxiv.org/html/2607.22636#algorithm1)and Lines[1](https://arxiv.org/html/2607.22636#algorithm1)to[1](https://arxiv.org/html/2607.22636#algorithm1)\.

IfTTis added toLoop​\(s1,j1,s3,j3\)\\texttt\{Loop\}\(s\_\{1\},j\_\{1\},s\_\{3\},j\_\{3\}\)at Line[1](https://arxiv.org/html/2607.22636#algorithm1), then there must exist a states2s\_\{2\}for whichTThas already been added toLoop​\(s1,j1,s2,j2\)\\texttt\{Loop\}\(s\_\{1\},j\_\{1\},s\_\{2\},j\_\{2\}\)andLoop​\(s2,j2,s3,j3\)\\texttt\{Loop\}\(s\_\{2\},j\_\{2\},s\_\{3\},j\_\{3\}\)\. By the induction assumption, there is a wordu1u\_\{1\}\(resp\.u2u\_\{2\}\) inℒ𝔸​\(s1,s2\)\\mathcal\{L\}\_\{\\mathbb\{A\}\}\(s\_\{1\},s\_\{2\}\)\(resp\.ℒ𝔸​\(s2,s3\)\\mathcal\{L\}\_\{\\mathbb\{A\}\}\(s\_\{2\},s\_\{3\}\)\) that labels a path in𝖼𝗁𝖺𝗌𝖾​\(\{αT\},ℛ\)\\mathsf\{chase\}\(\\\{\\alpha\_\{T\}\\\},\\mathcal\{R\}\)fromαT​\[j1\]\\alpha\_\{T\}\[j\_\{1\}\]\(resp\.αT​\[j2\]\\alpha\_\{T\}\[j\_\{2\}\]\) toαT​\[j2\]\\alpha\_\{T\}\[j\_\{2\}\]\(resp\.αT​\[j3\]\\alpha\_\{T\}\[j\_\{3\}\]\)\. By concatenating these paths, we obtain a path fromαT​\[j1\]\\alpha\_\{T\}\[j\_\{1\}\]toαT​\[j3\]\\alpha\_\{T\}\[j\_\{3\}\]whose labelu1​u2u\_\{1\}u\_\{2\}belongs toℒ𝔸​\(s1,s3\)\\mathcal\{L\}\_\{\\mathbb\{A\}\}\(s\_\{1\},s\_\{3\}\), which proves thatTTadmits an\(s1,j1,s3,j3\)\(s\_\{1\},j\_\{1\},s\_\{3\},j\_\{3\}\)\-loop\.

Finally, assume that𝗍𝗒𝗉𝖾​\(α\)\\mathsf\{type\}\{\(\\alpha\)\}is added toLoop​\(s1,iα,s2,jα\)\\texttt\{Loop\}\(s\_\{1\},i\_\{\\alpha\},s\_\{2\},j\_\{\\alpha\}\)at Line[1](https://arxiv.org/html/2607.22636#algorithm1)during the examination of ruleα→β∈ℛ\\alpha\\rightarrow\\beta\\in\\mathcal\{R\}\. Then it must be the case thatα​\[iα\]=β​\[iβ\]\\alpha\[i\_\{\\alpha\}\]=\\beta\[i\_\{\\beta\}\],α​\[jα\]=β​\[jβ\]\\alpha\[j\_\{\\alpha\}\]=\\beta\[j\_\{\\beta\}\], and𝗍𝗒𝗉𝖾​\(β\)∈Loop​\(s1,iβ,s2,jβ\)\\mathsf\{type\}\{\(\\beta\)\}\\in\\texttt\{Loop\}\(s\_\{1\},i\_\{\\beta\},s\_\{2\},j\_\{\\beta\}\)\. By the induction assumption,𝗍𝗒𝗉𝖾​\(β\)\\mathsf\{type\}\{\(\\beta\)\}admits an\(s1,iβ,s2,jβ\)\(s\_\{1\},i\_\{\\beta\},s\_\{2\},j\_\{\\beta\}\)\-loop, which implies that there is a pathppin𝖼𝗁𝖺𝗌𝖾​\(β,ℛ\)\\mathsf\{chase\}\(\\beta,\\mathcal\{R\}\)fromβ​\[iβ\]\\beta\[i\_\{\\beta\}\]toβ​\[jβ\]\\beta\[j\_\{\\beta\}\]such thatλ​\(p\)∈ℒ𝔸​\(s1,s2\)\\lambda\(p\)\\in\\mathcal\{L\}\_\{\\mathbb\{A\}\}\(s\_\{1\},s\_\{2\}\)\. Sinceβ∈𝖼𝗁𝖺𝗌𝖾​\(\{α\},ℛ\)\\beta\\in\\mathsf\{chase\}\(\\\{\\alpha\\\},\\mathcal\{R\}\)we can apply Proposition[5](https://arxiv.org/html/2607.22636#Thmtheorem5a)to infer that there is a pathp′p^\{\\prime\}in𝖼𝗁𝖺𝗌𝖾​\(\{α\},ℛ\)\\mathsf\{chase\}\(\\\{\\alpha\\\},\\mathcal\{R\}\)fromβ​\[iβ\]\\beta\[i\_\{\\beta\}\]toβ​\[jβ\]\\beta\[j\_\{\\beta\}\]such thatλ​\(p′\)∈ℒ𝔸​\(s1,s2\)\\lambda\(p^\{\\prime\}\)\\in\\mathcal\{L\}\_\{\\mathbb\{A\}\}\(s\_\{1\},s\_\{2\}\)\. Asα​\[iα\]=β​\[iβ\]\\alpha\[i\_\{\\alpha\}\]=\\beta\[i\_\{\\beta\}\],α​\[jα\]=β​\[jβ\]\\alpha\[j\_\{\\alpha\}\]=\\beta\[j\_\{\\beta\}\], it follows thatp′p^\{\\prime\}is also a path fromα​\[iα\]\\alpha\[i\_\{\\alpha\}\]toα​\[jα\]\\alpha\[j\_\{\\alpha\}\], which witnesses that𝗍𝗒𝗉𝖾​\(α\)\\mathsf\{type\}\{\(\\alpha\)\}admits an\(s1,iα,s2,jα\)\(s\_\{1\},i\_\{\\alpha\},s\_\{2\},j\_\{\\alpha\}\)\-loop\.

\(⇐\\Leftarrow\) We suppose thatTTadmits an\(s,i,s′,j\)\(s,i,s^\{\\prime\},j\)\-loop and our aim is to show thatTTis added toLoop​\(s,i,s′,j\)\\texttt\{Loop\}\(s,i,s^\{\\prime\},j\)\. We proceed by induction on the length of the shortest path in𝖼𝗁𝖺𝗌𝖾​\(\{αT\},ℛ\)\\mathsf\{chase\}\(\\\{\\alpha\_\{T\}\\\},\\mathcal\{R\}\)that witnesses thatTTadmits an\(s,i,s′,j\)\(s,i,s^\{\\prime\},j\)\-loop\.

Base case, path of length 0:In this case, there is length\-0 pathppin𝖼𝗁𝖺𝗌𝖾​\(\{αT\},ℛ\)\\mathsf\{chase\}\(\\\{\\alpha\_\{T\}\\\},\\mathcal\{R\}\)fromαT​\[i\]\\alpha\_\{T\}\[i\]toαT​\[j\]\\alpha\_\{T\}\[j\]that takes𝔸\\mathbb\{A\}from statessto states′s^\{\\prime\}\. We thus haveλ​\(p\)=ε\\lambda\(p\)=\\varepsilon, which implies thats=s′s=s^\{\\prime\}andi∼Tji\\sim\_\{T\}j\. HenceTTwill be added toLoop​\(s,i,s′,j\)\\texttt\{Loop\}\(s,i,s^\{\\prime\},j\)at Line[1](https://arxiv.org/html/2607.22636#algorithm1)\. Base case, path of length 1:The fact thatTTadmits an\(s,i,s′,j\)\(s,i,s^\{\\prime\},j\)\-loop is witnessed by a length\-one path\. LetαT​\[i\]​q​αT​\[j\]\\alpha\_\{T\}\[i\]q\\alpha\_\{T\}\[j\]be the witnessing path, whereq∈𝒫2±q\\in\\mathcal\{P\}\_\{2\}^\{\\pm\}andq∈ℒ𝔸​\(s,s′\)q\\in\\mathcal\{L\}\_\{\\mathbb\{A\}\}\(s,s^\{\\prime\}\)\(i\.e\.,s′∈δ​\(s,q\)s^\{\\prime\}\\in\\delta\(s,q\)\)\. There are three possibilities:

- \(a\)ifq=r∈𝒫2q=r\\in\\mathcal\{P\}\_\{2\}andαT​\[i\]≠αT​\[j\]\\alpha\_\{T\}\[i\]\\neq\\alpha\_\{T\}\[j\], thenβ=r​\(αT​\[i\],αT​\[j\]\)∈𝖼𝗁𝖺𝗌𝖾​\(\{αT\},ℛ\)\\beta=r\(\\alpha\_\{T\}\[i\],\\alpha\_\{T\}\[j\]\)\\in\\mathsf\{chase\}\(\\\{\\alpha\_\{T\}\\\},\\mathcal\{R\}\)and𝗍𝗒𝗉𝖾​\(β\)\\mathsf\{type\}\{\(\\beta\)\}is added toLoop​\(s,1,s′,2\)\\texttt\{Loop\}\(s,1,s^\{\\prime\},2\)in Line 7;
- \(b\)ifq=r−q=r^\{\-\}forr∈𝒫2r\\in\\mathcal\{P\}\_\{2\}andαT​\[i\]≠αT​\[j\]\\alpha\_\{T\}\[i\]\\neq\\alpha\_\{T\}\[j\], thenβ=r​\(αT​\[j\],αT​\[i\]\)∈𝖼𝗁𝖺𝗌𝖾​\(\{αT\},ℛ\)\\beta=r\(\\alpha\_\{T\}\[j\],\\alpha\_\{T\}\[i\]\)\\in\\mathsf\{chase\}\(\\\{\\alpha\_\{T\}\\\},\\mathcal\{R\}\), so𝗍𝗒𝗉𝖾​\(β\)\\mathsf\{type\}\{\(\\beta\)\}is added toLoop​\(s,2,s′,1\)\\texttt\{Loop\}\(s,2,s^\{\\prime\},1\)in Line 9;
- \(c\)ifαT​\[i\]=αT​\[j\]\\alpha\_\{T\}\[i\]=\\alpha\_\{T\}\[j\], then the atom β=r​\(αT​\[i\],αT​\[i\]\)=r​\(αT​\[j\],αT​\[j\]\)=r​\(αT​\[i\],αT​\[j\]\)=r​\(αT​\[j\],αT​\[i\]\)\\beta=r\(\\alpha\_\{T\}\[i\],\\alpha\_\{T\}\[i\]\)=r\(\\alpha\_\{T\}\[j\],\\alpha\_\{T\}\[j\]\)=r\(\\alpha\_\{T\}\[i\],\\alpha\_\{T\}\[j\]\)=r\(\\alpha\_\{T\}\[j\],\\alpha\_\{T\}\[i\]\)belongs to𝖼𝗁𝖺𝗌𝖾​\(\{αT\},ℛ\)\\mathsf\{chase\}\(\\\{\\alpha\_\{T\}\\\},\\mathcal\{R\}\), so𝗍𝗒𝗉𝖾​\(β\)\\mathsf\{type\}\{\(\\beta\)\}will be added toLoop​\(s,1,s′,1\)\\texttt\{Loop\}\(s,1,s^\{\\prime\},1\),Loop​\(s,1,s′,2\)\\texttt\{Loop\}\(s,1,s^\{\\prime\},2\),Loop​\(s,2,s′,1\)\\texttt\{Loop\}\(s,2,s^\{\\prime\},1\)andLoop​\(s,2,s′,2\)\\texttt\{Loop\}\(s,2,s^\{\\prime\},2\)in Lines 12\-15\.

In all three cases, the atomβ\\betabelongs to𝖼𝗁𝖺𝗌𝖾​\(\{αT\},ℛ\)\\mathsf\{chase\}\(\\\{\\alpha\_\{T\}\\\},\\mathcal\{R\}\), which means that there exists a finite sequence of atomsαT=α0,…,αm=β\\alpha\_\{T\}=\\alpha\_\{0\},\\ldots,\\alpha\_\{m\}=\\betasuch thatαi\+1\\alpha\_\{i\+1\}is generated by an application ofρi∈ℛ\\rho\_\{i\}\\in\\mathcal\{R\}mapping𝖻𝗈𝖽𝗒​\(ρi\)\\mathsf\{body\}\(\\rho\_\{i\}\)toαi\\alpha\_\{i\}\. We proceed by induction on the lengthmmof the sequence\.

First suppose thatm=0m=0, which means thatβ=αT\\beta=\\alpha\_\{T\}\. In case \(a\), we haveT=𝗍𝗒𝗉𝖾​\(β\)T=\\mathsf\{type\}\{\(\\beta\)\}, which means thati=1i=1,j=2j=2, andTTis added toLoop​\(s,i,s′,j\)\\texttt\{Loop\}\(s,i,s^\{\\prime\},j\)as desired\. If we are in case \(b\), then we again haveT=𝗍𝗒𝗉𝖾​\(β\)T=\\mathsf\{type\}\{\(\\beta\)\}andTTis added toLoop​\(s,2,s′,1\)\\texttt\{Loop\}\(s,2,s^\{\\prime\},1\)\. Again in case \(c\),𝗍𝗒𝗉𝖾​\(β\)=T\\mathsf\{type\}\{\(\\beta\)\}=TandTTis added toLoop​\(s,1,s′,1\)\\texttt\{Loop\}\(s,1,s^\{\\prime\},1\),Loop​\(s,1,s′,2\)\\texttt\{Loop\}\(s,1,s^\{\\prime\},2\),Loop​\(s,2,s′,1\)\\texttt\{Loop\}\(s,2,s^\{\\prime\},1\), andLoop​\(s,2,s′,2\)\\texttt\{Loop\}\(s,2,s^\{\\prime\},2\)\.

Next suppose thatm\>1m\>1and that the property holds for all sequences of length at mostm−1m\-1\. AsαT​\[i\]\\alpha\_\{T\}\[i\]andαT​\[j\]\\alpha\_\{T\}\[j\]appear inβ\\beta, it holds that there existi′i^\{\\prime\}andj′j^\{\\prime\}such thatα1​\[i′\]=αT​\[i\]\\alpha\_\{1\}\[i^\{\\prime\}\]=\\alpha\_\{T\}\[i\]andα1​\[j′\]=αT​\[j\]\\alpha\_\{1\}\[j^\{\\prime\}\]=\\alpha\_\{T\}\[j\]\. Asβ∈𝖼𝗁𝖺𝗌𝖾​\(\{α1\},ℛ\)\\beta\\in\\mathsf\{chase\}\(\\\{\\alpha\_\{1\}\\\},\\mathcal\{R\}\),𝗍𝗒𝗉𝖾​\(α1\)\\mathsf\{type\}\{\(\\alpha\_\{1\}\)\}admits an\(s,i′,s′,j′\)\(s,i^\{\\prime\},s^\{\\prime\},j^\{\\prime\}\)\-loop, and there exists a derivation of lengthm−1m\-1that generatesβ\\betafromα1\\alpha\_\{1\}\. By our induction assumption for sequences of length at mostm−1m\-1, it holds that𝗍𝗒𝗉𝖾​\(α1\)\\mathsf\{type\}\{\(\\alpha\_\{1\}\)\}has been added toLoop​\(s,i′,s′,j′\)\\texttt\{Loop\}\(s,i^\{\\prime\},s^\{\\prime\},j^\{\\prime\}\)\. Asα1\\alpha\_\{1\}is generated fromαT\\alpha\_\{T\}by the application of a rule, Line[1](https://arxiv.org/html/2607.22636#algorithm1)addsTTtoLoop​\(s,i,s′,j\)\\texttt\{Loop\}\(s,i,s^\{\\prime\},j\)\.

Induction step:Let us assume that the result holds for any path of length up ton−1,n≥2n\-1,n\\geq 2, and consider the pathp=t0​q1​t1​…​qn​tnp=t\_\{0\}q\_\{1\}t\_\{1\}\\ldots q\_\{n\}t\_\{n\}\. First consider the case in whichtkt\_\{k\}is contained inαT\\alpha\_\{T\}for some1≤k<n1\\leq k<n, and letllbe a position oftkt\_\{k\}inαT\\alpha\_\{T\}\. There exists a path fromt0t\_\{0\}totkt\_\{k\}of length strictly smaller thannn, and similarly fromtkt\_\{k\}totnt\_\{n\}\. By the induction assumption,T=𝗍𝗒𝗉𝖾​\(αT\)T=\\mathsf\{type\}\{\(\\alpha\_\{T\}\)\}is in bothLoop​\(s,i,s′′,l\)\\texttt\{Loop\}\(s,i,s^\{\\prime\\prime\},l\)andLoop​\(s′′,l,s′,j\)\\texttt\{Loop\}\(s^\{\\prime\\prime\},l,s^\{\\prime\},j\)for some states′′s^\{\\prime\\prime\}\. An application of Line[1](https://arxiv.org/html/2607.22636#algorithm1)yieldsT=𝗍𝗒𝗉𝖾​\(αT\)∈Loop​\(s,i,s′,j\)T=\\mathsf\{type\}\{\(\\alpha\_\{T\}\)\}\\in\\texttt\{Loop\}\(s,i,s^\{\\prime\},j\)\. Next suppose there is notkt\_\{k\}\(1≤k<n1\\leq k<n\) that occurs inαT\\alpha\_\{T\}, which in particular means thattk∉\{t0,tn\}t\_\{k\}\\not\\in\\\{t\_\{0\},t\_\{n\}\\\}for1≤k<n1\\leq k<n\. Consider a finite derivation that generates all of the binary atoms from the pathpp\. Lettkt\_\{k\}be such that no othertit\_\{i\}\(1≤i<n1\\leq i<n\) is created earlier in the derivation, and letβ\\betabe the atom in whichtkt\_\{k\}is created\. We prove that the pathppis contained in𝖼𝗁𝖺𝗌𝖾​\(\{β\},ℛ\)\\mathsf\{chase\}\(\\\{\\beta\\\},\\mathcal\{R\}\)\. Indeed, the atomsqk−1​\(tk−1,tk\)q\_\{k\-1\}\(t\_\{k\-1\},t\_\{k\}\)andqk​\(tk,tk\+1\)q\_\{k\}\(t\_\{k\},t\_\{k\+1\}\)must occur in𝖼𝗁𝖺𝗌𝖾​\(\{β\},ℛ\)\\mathsf\{chase\}\(\\\{\\beta\\\},\\mathcal\{R\}\)sinceβ\\betacreatedtkt\_\{k\}\. By induction, we obtain that the same holds for all other atoms inpp; this moreover implies thatt0t\_\{0\}\(resp\.tnt\_\{n\}\) must occur inβ\\beta, let us say at positioni′i^\{\\prime\}\(resp\.j′j^\{\\prime\}\)\. By the induction hypothesis,𝗍𝗒𝗉𝖾​\(β\)\\mathsf\{type\}\{\(\\beta\)\}belongs toLoop​\(s,i′,s′′,k′\)\\texttt\{Loop\}\(s,i^\{\\prime\},s^\{\\prime\\prime\},k^\{\\prime\}\)and toLoop​\(s′′,k′,s′,j′\)\\texttt\{Loop\}\(s^\{\\prime\\prime\},k^\{\\prime\},s^\{\\prime\},j^\{\\prime\}\)for some states′′s^\{\\prime\\prime\}, wherek′k^\{\\prime\}is the position oftkt\_\{k\}inβ\\beta\. Hence, by Line[1](https://arxiv.org/html/2607.22636#algorithm1),𝗍𝗒𝗉𝖾​\(β\)\\mathsf\{type\}\{\(\\beta\)\}is in the cellLoop​\(s,i′,s′,j′\)\\texttt\{Loop\}\(s,i^\{\\prime\},s^\{\\prime\},j^\{\\prime\}\)\. Following the same reasoning as in the base case for paths of length11, by \(repeated\) application of Line[1](https://arxiv.org/html/2607.22636#algorithm1),𝗍𝗒𝗉𝖾​\(αT\)\\mathsf\{type\}\{\(\\alpha\_\{T\}\)\}is in the cellLoop​\(s,i,s′,j\)\\texttt\{Loop\}\(s,i,s^\{\\prime\},j\), which concludes the proof\. ∎

###### Proposition 10\.

Algorithm[1](https://arxiv.org/html/2607.22636#algorithm1)runs in exponential time, and in polynomial time if the predicate arity is bounded\.

###### Proof\.

There are polynomially many cells in the table, each of which can contain at most all types\. The numberntn\_\{t\}of distinct types is single exponential in the maximum predicate arity \(hence polynomial for bounded\-arity predicates\)\. The first for loop runs in𝒪​\(nt\)\\mathcal\{O\}\(n\_\{t\}\), the next two run in polynomial time, and the while loop is performed at mostntn\_\{t\}times\. ∎

There is a subtlety however that demands our attention, namely, the case of linear rulesets obtained via the single\-head translation \(see page[2\.1](https://arxiv.org/html/2607.22636#S2.SS1.SSS0.Px1)\)\. Indeed, the preceding result establishes polynomial time complexity for bounded\-arity linear rules*with atomic heads*\. However, if the original ruleset contains rules with multiple atoms in the head, then we must first apply the single\-head translation, introducing new predicates which may have higher arities\. This issue can be addressed by suitably modifying Algorithm[1](https://arxiv.org/html/2607.22636#algorithm1)to take into account such new predicates\. Specifically, for each such fresh predicatepρp\_\{\\rho\}\(introduced for ruleρ\\rho\), which occurs in the head of new rule𝖻𝗈𝖽𝗒​\(ρ\)→∃y1​…​∃yℓ​pρ​\(x1,…,xk,y1,…,yℓ\)\\mathsf\{body\}\(\\rho\)\\rightarrow\\exists y\_\{1\}\\dots\\exists y\_\{\\ell\}\\,p\_\{\\rho\}\(x\_\{1\},\\dots,x\_\{k\},y\_\{1\},\\dots,y\_\{\\ell\}\), the modified algorithm only considers types forpρp\_\{\\rho\}that contain\{\{k\+1\},…​\{k\+ℓ\}\}\\\{\\\{k\+1\\\},\\ldots\\\{k\+\\ell\\\}\\\}\(i\.e\. the positions that store existential variables are never merged with other positions\)\. Note that for the original predicates, the modified algorithm considers all possible types \(just like in Algorithm[1](https://arxiv.org/html/2607.22636#algorithm1)\)\. The following result shows that the modified algorithm satisfies the required properties\.

###### Proposition 11\.

The modified Algorithm[1](https://arxiv.org/html/2607.22636#algorithm1)runs in polynomial time for rulesets obtained by applying the single\-head translation to linear rulesets with bounded predicate arity\. Moreover, for any linear rulesetℛ\\mathcal\{R\}, whose single\-head translation isℛ′\\mathcal\{R\}^\{\\prime\}, any NFA𝔸\\mathbb\{A\}, and any typeTTbased upon a predicate inℛ\\mathcal\{R\}, typeTTbelongs to𝙻𝚘𝚘𝚙′​\(s,i,s′,j\)\\mathtt\{Loop\}^\{\\prime\}\(s,i,s^\{\\prime\},j\)in the table produced by running the modified algorithm on input \(ℛ′,𝔸\\mathcal\{R\}^\{\\prime\},\\mathbb\{A\}\) iffTTadmits an\(s,i,s′,j\)\(s,i,s^\{\\prime\},j\)\-loop \(w\.r\.t\.ℛ\\mathcal\{R\}\)\.

###### Proof\.

The only predicates inℛ′\\mathcal\{R\}^\{\\prime\}whose arity exceeds the maximum predicate arity ofℛ\\mathcal\{R\}are the newly introduced predicates, and each such predicatepρp\_\{\\rho\}can only appear in the head of a single rule of the form𝖻𝗈𝖽𝗒​\(ρ\)→∃y1​…​∃yℓ​pρ​\(x1,…,xk,y1,…,yℓ\)\\mathsf\{body\}\(\\rho\)\\rightarrow\\exists y\_\{1\}\\dots\\exists y\_\{\\ell\}\\,p\_\{\\rho\}\(x\_\{1\},\\dots,x\_\{k\},y\_\{1\},\\dots,y\_\{\\ell\}\)and in the body of rulespρ​\(x1,…,xk,y1,…,yℓ\)→q​\(u→\)p\_\{\\rho\}\(x\_\{1\},\\dots,x\_\{k\},y\_\{1\},\\dots,y\_\{\\ell\}\)\\rightarrow q\(\\vec\{u\}\)\(for eachq​\(u→\)q\(\\vec\{u\}\)which is a head atom ofρ\\rho\)\. As a consequence, the only types with predicatepρp\_\{\\rho\}which are necessary to consider in Algorithm[1](https://arxiv.org/html/2607.22636#algorithm1)are those which contain the trivial partition\{\{k\+1\},…​\{k\+ℓ\}\}\\\{\\\{k\+1\\\},\\ldots\\\{k\+\\ell\\\}\\\}\. Indeed, by using the same arguments as in Prop\.[10](https://arxiv.org/html/2607.22636#Thmtheorem10), we can show that ifTTis any type for an original predicate inℛ\\mathcal\{R\}, thenTTbelongs to𝙻𝚘𝚘𝚙′​\(s,i,s′,j\)\\mathtt\{Loop\}^\{\\prime\}\(s,i,s^\{\\prime\},j\)in the table produced by the modified algorithm on input \(ℛ′,𝔸\\mathcal\{R\}^\{\\prime\},\\mathbb\{A\}\) iffTTadmits an\(s,i,s′,j\)\(s,i,s^\{\\prime\},j\)\-loop\. Finally, to establish polynomial complexity, it suffices to remark that there can only be polynomially many types for the new predicates \(sincekkis bounded by a constant\)\. ∎

The remainder of the decision procedure relies on the following ideas \(Algorithm[2](https://arxiv.org/html/2607.22636#algorithm2)\): starting from a constantaaand the initial state of𝔸\\mathbb\{A\}, we guess the next constantddinIIon a path fromaatobband the state of𝔸\\mathbb\{A\}after taking this step \(Line[2](https://arxiv.org/html/2607.22636#algorithm2)\)\. Note thataaandddmay be equal\. We then check that this choice is valid, i\.e\., there is indeed a path fromaato the guessed constantddwhich takes the automaton from the initial state to the current guessed state\. This can be done either by checking that a corresponding binary atom is entailed \(Lines 6\-7\), or by checking that a path going through the anonymous part of the chase allows us to reach the next constant in the required state, using theLooptable \(Lines 8\-9\)\. We repeat this procedure until we reach the constantbbin a final state, or hit the maximal path length\.

Input:An NFA

𝔸=\(S,Σ,δ,s0,F\)\\mathbb\{A\}=\(S,\\Sigma,\\delta,s\_\{0\},F\), an instance

II, a set of linear rules

ℛ\\mathcal\{R\},

\(a,b\)∈𝗍𝖾𝗋𝗆𝗌​\(I\)×𝗍𝖾𝗋𝗆𝗌​\(I\)\(a,b\)\\in\\mathsf\{terms\}\{\(I\)\}\\times\\mathsf\{terms\}\{\(I\)\}
Output:Yes if and only if

\(a,b\)\(a,b\)is a certain answer to the RPQ defined by

𝔸\\mathbb\{A\}
1ComputeLooptable for

ℛ\\mathcal\{R\}and

𝔸\\mathbb\{A\}\(using Algorithm[1](https://arxiv.org/html/2607.22636#algorithm1)\);

2current=

\(a,s0\)\(a,s\_\{0\}\);

3count

=0=0,max

=\|S\|×\|I\|=\|S\|\\times\|I\|;

4while*count<<maxandcurrent∉\{\(b,sf\)∣sf∈F\}\\not\\in\\\{\(b,s\_\{f\}\)\\mid s\_\{f\}\\in F\\\}*do

5Define

\(c,s\)=\(c,s\)=current;

6Guess

\(d,s′\)\(d,s^\{\\prime\}\)together with either

\(s,r,s′\)∈δ\(s,r,s^\{\\prime\}\)\\in\\deltaor

T,ic,idT,i\_\{c\},i\_\{d\}such that

T∈Loop​\(s,ic,s′,id\)T\\in\\texttt\{Loop\}\(s,i\_\{c\},s^\{\\prime\},i\_\{d\}\);

7if*\(s,r,s′\)\(s,r,s^\{\\prime\}\)was guessed and\(I,ℛ⊧̸r​\(c,d\)\)\(I,\\mathcal\{R\}\\not\\models r\(c,d\)\)*then

8return*No*

9else if*T,ic,idT,i\_\{c\},i\_\{d\}was guessed andIIdoes not contain any atomα\\alphaof typeTTsuch thatα​\[ic\]=c\\alpha\[i\_\{c\}\]=candα​\[id\]=d\\alpha\[i\_\{d\}\]=d*then

10return*No*

11else

12current=

\(d,s′\)\(d,s^\{\\prime\}\),count=count

\+1\+1;

13

14

15if*current=\(b,sf\)\(b,s\_\{f\}\)for somesf∈Fs\_\{f\}\\in F*thenreturn*Yes*elsereturn*No*

Algorithm 2RPQ answering over linear rulesThe following lemma proves an invariant that will be used to establish the correctness of Algorithm[2](https://arxiv.org/html/2607.22636#algorithm2)\.

###### Lemma 12\.

At the beginning of each iteration of the while loop of Algorithm[2](https://arxiv.org/html/2607.22636#algorithm2), it holds that there is a path in𝖼𝗁𝖺𝗌𝖾​\(I,ℛ\)\\mathsf\{chase\}\(I,\\mathcal\{R\}\)fromaato the first element ofcurrentthat takes the NFA𝔸\\mathbb\{A\}from the initial states0s\_\{0\}to the state in the second argument ofcurrent\.

###### Proof\.

At the beginning of the first iteration of the while loop,currentis equal to\(a,s0\)\(a,s\_\{0\}\)\. Thus, the pathaa, whose label isε\\varepsilon, goes fromaatoaaandε∈ℒ𝔸​\(s0,s0\)\\varepsilon\\in\\mathcal\{L\}\_\{\\mathbb\{A\}\}\(s\_\{0\},s\_\{0\}\)\.

Let\(ai,si\)\(a\_\{i\},s\_\{i\}\)be the content ofcurrentat the beginning of theithi^\{\\textrm\{th\}\}iteration of the while loop\. Letwiw\_\{i\}be the label of a path froma0a\_\{0\}toaia\_\{i\}such thatwi∈ℒ𝔸​\(s0,si\)w\_\{i\}\\in\\mathcal\{L\}\_\{\\mathbb\{A\}\}\(s\_\{0\},s\_\{i\}\)\. If there is an\(i\+1\)th\(i\+1\)^\{\\textrm\{th\}\}iteration, either\(s,r,s′\)\(s,r,s^\{\\prime\}\)or\(T,ic,id\)\(T,i\_\{c\},i\_\{d\}\)has been guessed, and the corresponding check was successful\. Let us consider each case:

- •if\(s,r,s′\)\(s,r,s^\{\\prime\}\)has been guessed and checked, thenr∈𝒫2±r\\in\\mathcal\{P\}\_\{2\}^\{\\pm\}, and there is a path fromaia\_\{i\}toai\+1a\_\{i\+1\}in𝖼𝗁𝖺𝗌𝖾​\(I,ℛ\)\\mathsf\{chase\}\(I,\\mathcal\{R\}\)labeled byrr\. Moreover,rrlabels an edge fromsstos′s^\{\\prime\}in𝔸\\mathbb\{A\}\. We can thus definewi\+1=wi\.rw\_\{i\+1\}=w\_\{i\}\.r
- •if\(T,ic,id\)\(T,i\_\{c\},i\_\{d\}\)has been guessed, it means thatTTbelongs toLoop​\(si,ic,si\+1,id\)\\texttt\{Loop\}\(s\_\{i\},i\_\{c\},s\_\{i\+1\},i\_\{d\}\)\. By the definition ofLoop, there is a pathpp\(in the anonymous part\) from any term at positionici\_\{c\}of an atom of typeTTto the positionidi\_\{d\}of an atom of typeTTsuch thatλ​\(p\)∈ℒ𝔸​\(s,s′\)\\lambda\(p\)\\in\\mathcal\{L\}\_\{\\mathbb\{A\}\}\(s,s^\{\\prime\}\)\. Letα\\alphabe as defined Line[2](https://arxiv.org/html/2607.22636#algorithm2)\. AsI,ℛ⊧αI,\\mathcal\{R\}\\models\\alpha, where𝗍𝗒𝗉𝖾​\(α\)=T\\mathsf\{type\}\{\(\\alpha\)\}=T,aia\_\{i\}appears at positionici\_\{c\}ofα\\alpha, andai\+1a\_\{i\+1\}appears at positionidi\_\{d\}ofα\\alpha, there is such a path fromaia\_\{i\}toai\+1a\_\{i\+1\}\. We can thus setwi\+1=wi\.pw\_\{i\+1\}=w\_\{i\}\.p\. ∎

The next proposition establishes the correctness of Algorithm[2](https://arxiv.org/html/2607.22636#algorithm2)\. To prove the correctness when the algorithm outputs Yes, we rely on the invariant given by the previous lemma, which allows us to construct a witnessing path in𝖼𝗁𝖺𝗌𝖾​\(I,ℛ\)\\mathsf\{chase\}\(I,\\mathcal\{R\}\)\. To prove the correctness when the algorithm outputs No, we consider any path of minimal length fromaatobbthat satisfies the input RPQ and build a sequence of guesses associated with it that is necessarily accepted by the algorithm\.

###### Proposition 13\.

There is an execution of Algorithm[2](https://arxiv.org/html/2607.22636#algorithm2)that outputs Yes if and only if the RPQ given by𝔸\\mathbb\{A\}is entailed from\(I,ℛ\)\(I,\\mathcal\{R\}\)\.

###### Proof\.

\(⇒\\Rightarrow\) If the algorithm outputs Yes, the while loop has been exited withcurrentequal to\(b,sf\)\(b,s\_\{f\}\), withsfs\_\{f\}a final state of𝔸\\mathbb\{A\}\. By Lemma[12](https://arxiv.org/html/2607.22636#Thmtheorem12), this means that there is a path fromaatobbwhose label takes𝔸\\mathbb\{A\}froms0s\_\{0\}tosfs\_\{f\}, hence is accepted by𝔸\\mathbb\{A\}\. This shows that whenever Algorithm[2](https://arxiv.org/html/2607.22636#algorithm2)accepts,\(a,b\)\(a,b\)is a certain answer to the RPQ given by𝔸\\mathbb\{A\}\.

\(⇐\\Leftarrow\) If\(a,b\)\(a,b\)is a certain answer to the RPQ based upon𝔸\\mathbb\{A\}, then there is path of minimal lengthp=a0′​r1​a1′​…​rn​an′p=a^\{\\prime\}\_\{0\}r\_\{1\}a^\{\\prime\}\_\{1\}\\ldots r\_\{n\}a^\{\\prime\}\_\{n\}froma=a0′a=a^\{\\prime\}\_\{0\}tob=an′b=a^\{\\prime\}\_\{n\}in𝖼𝗁𝖺𝗌𝖾​\(I,ℛ\)\\mathsf\{chase\}\(I,\\mathcal\{R\}\)such thatλ​\(p\)=r1​…​rn∈ℒ𝔸​\(s0,sf\)\\lambda\(p\)=r\_\{1\}\\ldots r\_\{n\}\\in\\mathcal\{L\}\_\{\\mathbb\{A\}\}\(s\_\{0\},s\_\{f\}\)for some final statesfs\_\{f\}\. Lets0′​s1′​…​sn′s^\{\\prime\}\_\{0\}s^\{\\prime\}\_\{1\}\\ldots s^\{\\prime\}\_\{n\}be a sequence of states of𝔸\\mathbb\{A\}such thatsn′s^\{\\prime\}\_\{n\}is a final state of𝔸\\mathbb\{A\}and for every1≤i≤n1\\leq i\\leq n,\(si−1,ri,si\)∈δ\(s\_\{i\-1\},r\_\{i\},s\_\{i\}\)\\in\\delta\. Sinceppis of minimal length, there is no pair\(i,j\)\(i,j\)withi≠ji\\not=jsuch that\(ai,si\)=\(aj,sj\)\(a\_\{i\},s\_\{i\}\)=\(a\_\{j\},s\_\{j\}\)\. Let us consider the sequencep′=\(\(ai,si\)\)ip^\{\\prime\}=\(\(a\_\{i\},s\_\{i\}\)\)\_\{i\}such that:

- •for anyii,aia\_\{i\}is theithi^\{\\textrm\{th\}\}constant, sayaki′a^\{\\prime\}\_\{k\_\{i\}\}, inppbelonging to𝗍𝖾𝗋𝗆𝗌​\(I\)\\mathsf\{terms\}\{\(I\)\};
- •for anyii,si=ski′s\_\{i\}=s^\{\\prime\}\_\{k\_\{i\}\}\.

Moreover, for anyii, ifki\+1=ki\+1k\_\{i\+1\}=k\_\{i\}\+1, we define𝖺𝗎𝗑i=\(si,ri\+1,si\+1\)\\mathsf\{aux\}\_\{i\}=\(s\_\{i\},r\_\{i\+1\},s\_\{i\+1\}\)\. Otherwise, let𝖺𝗎𝗑i=\(𝗍𝗒𝗉𝖾​\(α\),ic,id\)\\mathsf\{aux\}\_\{i\}=\(\\mathsf\{type\}\{\(\\alpha\)\},i\_\{c\},i\_\{d\}\),where:

- •α\\alphais such thatα∈I\\alpha\\in Iand𝗍𝗒𝗉𝖾​\(α\)∈Loop​\(si,ic,si\+1,id\)\\mathsf\{type\}\{\(\\alpha\)\}\\in\\texttt\{Loop\}\(s\_\{i\},i\_\{c\},s\_\{i\+1\},i\_\{d\}\);
- •akia\_\{k\_\{i\}\}appears at positionici\_\{c\}ofα\\alphaandaki\+1a\_\{k\_\{i\+1\}\}appears at positionidi\_\{d\}ofα\\alpha\.

In the second case, we can define𝖺𝗎𝗑i\\mathsf\{aux\}\_\{i\}in such a way, as the pathps=aki′​rki\+1​…​aki\+1′p\_\{s\}=a^\{\\prime\}\_\{k\_\{i\}\}r\_\{k\_\{i\}\+1\}\\ldots a^\{\\prime\}\_\{k\_\{i\+1\}\}goes fromakia\_\{k\_\{i\}\}toaki\+1a\_\{k\_\{i\+1\}\}andbelongs toℒ𝔸​\(si,si\+1\)\\mathcal\{L\}\_\{\\mathbb\{A\}\}\(s\_\{i\},s\_\{i\+1\}\)by definition ofsis\_\{i\}\. We show that the sequence of guesses\(ai,si,𝖺𝗎𝗑i\)\(a\_\{i\},s\_\{i\},\\mathsf\{aux\}\_\{i\}\)leads Algorithm[2](https://arxiv.org/html/2607.22636#algorithm2)to accept\. Sinceppis minimal, the length ofp′p^\{\\prime\}is less than\|𝔸\|×\|I\|\|\\mathbb\{A\}\|\\times\|I\|\. Moreover,an=ba\_\{n\}=bandsfs\_\{f\}is a final state\. Thus, the only way for Algorithm[2](https://arxiv.org/html/2607.22636#algorithm2)to reject with this sequence of guesses is to reject during checks, i\.e\., one of the checks performed at Lines[2](https://arxiv.org/html/2607.22636#algorithm2)and[2](https://arxiv.org/html/2607.22636#algorithm2)fails\. Let\(ai,si,𝖺𝗎𝗑i\)\(a\_\{i\},s\_\{i\},\\mathsf\{aux\}\_\{i\}\)be the guess at one of the steps\. If𝖺𝗎𝗑i\\mathsf\{aux\}\_\{i\}is of the form\(si,ri\+1,si\+1\)\(s\_\{i\},r\_\{i\+1\},s\_\{i\+1\}\), thenakia\_\{k\_\{i\}\}andaki\+1a\_\{k\_\{i\+1\}\}are consecutive elements inpp, and there is an atomri\+1​\(aki,aki\+1\)r\_\{i\+1\}\(a\_\{k\_\{i\}\},a\_\{k\_\{i\+1\}\}\)in𝖼𝗁𝖺𝗌𝖾​\(I,ℛ\)\\mathsf\{chase\}\(I,\\mathcal\{R\}\)\. Thus,ri\+1​\(aki,aki\+1\)r\_\{i\+1\}\(a\_\{k\_\{i\}\},a\_\{k\_\{i\+1\}\}\)is entailed byIIandℛ\\mathcal\{R\}, and the check at Line[2](https://arxiv.org/html/2607.22636#algorithm2)is successful\. If𝖺𝗎𝗑i\\mathsf\{aux\}\_\{i\}is of the form\(𝗍𝗒𝗉𝖾​\(α\),ic,id\)\(\\mathsf\{type\}\{\(\\alpha\)\},i\_\{c\},i\_\{d\}\), then there isα∈I\\alpha\\in Isuch that𝗍𝗒𝗉𝖾​\(α\)∈Loop​\(si,ic,si\+1,id\)\\mathsf\{type\}\{\(\\alpha\)\}\\in\\texttt\{Loop\}\(s\_\{i\},i\_\{c\},s\_\{i\+1\},i\_\{d\}\), and withakia\_\{k\_\{i\}\}\(resp\.aki\+1a\_\{k\_\{i\+1\}\}\) appearing at positionici\_\{c\}\(resp\.idi\_\{d\}\) ofα\\alpha\. The atomα\\alphafulfills the conditions of Line[2](https://arxiv.org/html/2607.22636#algorithm2)\. Thus the defined sequence never triggers a rejection from Algorithm[2](https://arxiv.org/html/2607.22636#algorithm2), which concludes the proof\. ∎

By analyzing the time and space required by Algorithm[2](https://arxiv.org/html/2607.22636#algorithm2), we obtain the following upper\-bounds forRPQAnswering in the presence of linear existential rules\.

###### Theorem 14\.

RPQAnswering in the presence of linear existential rules is:

- •inNLin data complexity;
- •inPTimein combined complexity with bounded arity;
- •inExpTimein combined complexity with unbounded arity\.

###### Proof\.

Algorithm[2](https://arxiv.org/html/2607.22636#algorithm2)is a non\-deterministic algorithm that needs to keep in memory the current state, the current constant, and the number of iterations done so far\. It performs two types of operations: checking entailment of an atom with linear rules and accessing the contents of theLooptable \(more precisely, deciding whetherT∈Loop​\(s,ic,s′,id\)T\\in\\texttt\{Loop\}\(s,i\_\{c\},s^\{\\prime\},i\_\{d\}\)\)\. Hence, it can be seen as an NL algorithm making oracle calls whenever an entailment check is performed or a cell ofLoopis retrieved\. Entailment checks are in NL in data complexity \(more precisely, AC0, see Section[2\.4](https://arxiv.org/html/2607.22636#S2.SS4)\), andLoopis independent from the data: the overall algorithm thus runs in NL in data complexity\. In combined complexity with bounded arity, entailment checks can be performed inPTime\(Section[2\.4](https://arxiv.org/html/2607.22636#S2.SS4)\), whileLoopcan be computed in polynomial time \(even if multiple head atoms are allowed, due to Proposition[11](https://arxiv.org/html/2607.22636#Thmtheorem11)\)\. The overall algorithm is thus inPTimewith bounded arity\. In the unbounded arity case, the entailment checks can be performed inPSpace\(Section[2\.4](https://arxiv.org/html/2607.22636#S2.SS4)\), while theLooptable can be computed inExpTime: the overall algorithm thus runs inExpTime\. ∎

## 4\.RPQ Answering under Linear Rules: Lower Bound

The data complexity \(resp\. combined complexity\) of RPQs under linear rules \(resp\. linear rules with bounded arity\) is already known to beNL\-hard \(resp\.PTime\-hard\)\(Bienvenu et al\.,[2015](https://arxiv.org/html/2607.22636#bib.bib13)\)\. As these bounds match the upper bounds obtained in the preceding section, we focus on providing a matchingExpTimelower bound for the combined complexity of evaluating RPQs under linear rules of unbounded arity\.

We recall thatExpTimecan be reformulated asAPSpace, the class of problems that can be solved in polynomial space by an alternating Turing Machine \(ATM\)\. Our proof relies on this equivalence and shows that aPSpaceATM can be simulated by means of linear rules\. Without loss of generality, we consider an ATM where each non\-final universal \(resp\. existential\) state has exactly two existential \(resp\. universal\) sucessors\.

It is already known thatPSpaceTMs can be simulated by means of linear rules\(Gottlob and Papadimitriou,[2003](https://arxiv.org/html/2607.22636#bib.bib38)\)\. In the following, we explain how to adapt this construction to simulate ATMs\. To simplify the presentation, we will use rules with both constants and multiple atoms in the head\. This can be done without loss of generality, since we can apply classical transformations to turn such rules into constant\-free atomic\-head rules \(see, e\.g\., Definition 1\.37 in\(Rocher,[2016](https://arxiv.org/html/2607.22636#bib.bib55)\)for the removal of constants, and Section[2\.1](https://arxiv.org/html/2607.22636#S2.SS1)for the single\-head translation\)\. These translations are both polynomial in the size of the input ruleset and preserve the property of being a linear ruleset\.

The key point in the construction from\(Gottlob and Papadimitriou,[2003](https://arxiv.org/html/2607.22636#bib.bib38)\)is the following: the configuration of aPSpaceTMℳ\\mathcal\{M\}is represented by a single atom of polynomial arity\. The initial configuration can thus be represented by an instanceIℳI\_\{\\mathcal\{M\}\}containing a single atom\. Then, for each transition of the TM, polynomially many linear rules are created, each one representing the action of the transition on a cell at a given position\. All these rules are part ofℛℳ\\mathcal\{R\}\_\{\\mathcal\{M\}\}\. The initial configuration of the TM is accepted if and only if an atom that encodes a configuration having an accepting state is entailed byIℳI\_\{\\mathcal\{M\}\}andℛℳ\\mathcal\{R\}\_\{\\mathcal\{M\}\}\.

We modify this construction in the following way to deal with an ATM: to each atom, we add two positions, that will act as “input” and “output” positions\. Moreover, we maintain the following property: for any atomα\\alphaencoding a configurationcc, there is a path, whose edges are all labeled by the same predicatepp, from the termici\_\{c\}in input position ofα\\alphato the termoco\_\{c\}in output position ofα\\alpha, entailed by𝖼𝗁𝖺𝗌𝖾​\(I\{α\},ℛℳ\)\\mathsf\{chase\}\(I\_\{\\\{\\alpha\\\}\},\\mathcal\{R\}\_\{\\mathcal\{M\}\}\)if and only if the configuration represented byα\\alphais accepted byℳ\\mathcal\{M\}\. Acceptance occurs in the following cases:

- •the state of the current configuration is accepting\. It is then enough to add app\-edge fromici\_\{c\}tooco\_\{c\}; this is possible as the Turing Machine is assumed to never leave an accepting state;
- •the current state is existential and one of the two successor configurations is accepting\. We thus addpp\-edges from the input of the current configuration to the input of the two children, and from the output of the two children to the output of the current configuration;
- •the current state is universal, and both successor configurations are accepting\. We thus addpp\-edges from the input of the current configuration to the input of the first successor configuration, then from the output of that configuration to the input of the other successor, and lastly from the output of the second successor to the output of the current configuration\.

We now formalize the construction sketched above, staying as close as possible to the notations in\(Gottlob and Papadimitriou,[2003](https://arxiv.org/html/2607.22636#bib.bib38)\)\. Given an ATMℳ\\mathcal\{M\}and an inputxx, such thatℳ\\mathcal\{M\}runs inP​\(\|x\|\)P\(\|x\|\)space for a polynomialPP, we can represent a configurationccreached during the computation by storing the content of the firstP​\(\|x\|\)P\(\|x\|\)cells, as well as the position of the head ofℳ\\mathcal\{M\}and the current state ofℳ\\mathcal\{M\}\. Adding input and output positions, this can be encoded by a predicate𝖼𝗈𝗇𝖿\\mathsf\{conf\}of arity2​P​\(\|x\|\)\+32P\(\|x\|\)\+3:

𝖼𝗈𝗇𝖿​\(ic,s​t​a​t​e,c​e​l​l1,c​u​r1,c​e​l​l2,c​u​r2,…,c​e​l​lP​\(\|x\|\),c​u​rP​\(\|x\|\),oc\),\\mathsf\{conf\}\(i\_\{c\},state,cell\_\{1\},cur\_\{1\},cell\_\{2\},cur\_\{2\},\\ldots,cell\_\{P\(\|x\|\)\},cur\_\{P\(\|x\|\)\},o\_\{c\}\),wheres​t​a​t​estatecontains the state identifier,c​e​l​licell\_\{i\}represents the content of theithi^\{\\textrm\{th\}\}cell,c​u​ricur\_\{i\}is equal to11if the head ofℳ\\mathcal\{M\}is on celliiand0otherwise, andici\_\{c\}andoco\_\{c\}are the input and output terms of this atom\. We say that the above atom*represents*configurationcc\. Given an atomα\\alpha, the term at its input \(resp\. output\) position is denoted byi​\(α\)i\(\\alpha\)\(resp\.o​\(α\)o\(\\alpha\)\)\. We denote byIℳ,xI\_\{\\mathcal\{M\},x\}the instance containing a single atom representing the initial configuration ofℳ\\mathcal\{M\}on inputxx\.

For every accepting stateqfq\_\{f\}, we create the following rule \(whereqfq\_\{f\}denotes a constant\):

\(1\)𝖼𝗈𝗇𝖿​\(ic,qf,…,oc\)→p​\(ic,oc\)\\displaystyle\\mathsf\{conf\}\(i\_\{c\},q\_\{f\},\\ldots,o\_\{c\}\)\\rightarrow p\(i\_\{c\},o\_\{c\}\)
For each existential stateqqand each transitionδ​\(q,γ\)=\{\(q′,γ′,L\),\(q′′,γ′′,L\)\}\\delta\(q,\\gamma\)=\\\{\(q^\{\\prime\},\\gamma^\{\\prime\},L\),\(q^\{\\prime\\prime\},\\gamma^\{\\prime\\prime\},L\)\\\}, and for every positioniion the tape, we create the following rule \(whereqq,q′q^\{\\prime\},q′′q^\{\\prime\\prime\},γ\\gamma,γ′\\gamma^\{\\prime\}andγ′′\\gamma^\{\\prime\\prime\}denote constants\):

\(2\)𝖼𝗈𝗇𝖿​\(ic,q,c​e​l​l1,c​u​r1,…,c​e​l​li−1,0,γ,1,…,oc\)→∃ic′,oc′,ic′′,oc′′​𝖼𝗈𝗇𝖿​\(ic′,q′,c​e​l​l1,c​u​r1,…,c​e​l​li−1,1,γ′,0,…,oc′\),𝖼𝗈𝗇𝖿​\(ic′′,q′′,c​e​l​l1,c​u​r1,…,c​e​l​li−1,1,γ′′,0,…,oc′′\),p​\(ic,ic′\),p​\(oc′,oc\),p​\(ic,ic′′\),p​\(oc′′,oc\)\\mathsf\{conf\}\(i\_\{c\},q,cell\_\{1\},cur\_\{1\},\\ldots,cell\_\{i\-1\},0,\\gamma,1,\\ldots,o\_\{c\}\)\\rightarrow\\\\ \\exists i\_\{c^\{\\prime\}\},o\_\{c^\{\\prime\}\},i\_\{c^\{\\prime\\prime\}\},o\_\{c^\{\\prime\\prime\}\}~\\mathsf\{conf\}\(i\_\{c^\{\\prime\}\},q^\{\\prime\},cell\_\{1\},cur\_\{1\},\\ldots,cell\_\{i\-1\},1,\\gamma^\{\\prime\},0,\\ldots,o\_\{c^\{\\prime\}\}\),\\\\ \\mathsf\{conf\}\(i\_\{c^\{\\prime\\prime\}\},q^\{\\prime\\prime\},cell\_\{1\},cur\_\{1\},\\ldots,cell\_\{i\-1\},1,\\gamma^\{\\prime\\prime\},0,\\ldots,o\_\{c^\{\\prime\\prime\}\}\),\\\\ p\(i\_\{c\},i\_\{c^\{\\prime\}\}\),p\(o\_\{c^\{\\prime\}\},o\_\{c\}\),p\(i\_\{c\},i\_\{c^\{\\prime\\prime\}\}\),p\(o\_\{c^\{\\prime\\prime\}\},o\_\{c\}\)
For each universal stateqqand each transitionδ​\(q,γ\)=\{\(q′,γ′,L\),\(q′′,γ′′,L\)\}\\delta\(q,\\gamma\)=\\\{\(q^\{\\prime\},\\gamma^\{\\prime\},L\),\(q^\{\\prime\\prime\},\\gamma^\{\\prime\\prime\},L\)\\\}, and for every positioniion the tape, we create the following rule \(with the same constants as in the preceding rule\):

\(3\)𝖼𝗈𝗇𝖿​\(ic,q,c​e​l​l1,c​u​r1,…,c​e​l​li,0,γ,1,…,oc\)→∃ic′,oc′,ic′′,oc′′​𝖼𝗈𝗇𝖿​\(ic′,q′,c​e​l​l1,c​u​r1,…,c​e​l​li,1,γ′,0,…,oc′\),𝖼𝗈𝗇𝖿​\(ic′′,q′′,c​e​l​l1,c​u​r1,…,c​e​l​li,1,γ′′,0,…,oc′′\),p​\(ic,ic′\),p​\(oc′,ic′′\),p​\(oc′′,oc\)\\mathsf\{conf\}\(i\_\{c\},q,cell\_\{1\},cur\_\{1\},\\ldots,cell\_\{i\},0,\\gamma,1,\\ldots,o\_\{c\}\)\\rightarrow\\\\ \\exists i\_\{c^\{\\prime\}\},o\_\{c^\{\\prime\}\}~,i\_\{c^\{\\prime\\prime\}\},o\_\{c^\{\\prime\\prime\}\}~\\mathsf\{conf\}\(i\_\{c^\{\\prime\}\},q^\{\\prime\},cell\_\{1\},cur\_\{1\},\\ldots,cell\_\{i\},1,\\gamma^\{\\prime\},0,\\ldots,o\_\{c^\{\\prime\}\}\),\\\\ \\qquad\\qquad\\qquad\\qquad\\,\\,\\mathsf\{conf\}\(i\_\{c^\{\\prime\\prime\}\},q^\{\\prime\\prime\},cell\_\{1\},cur\_\{1\},\\ldots,cell\_\{i\},1,\\gamma^\{\\prime\\prime\},0,\\ldots,o\_\{c^\{\\prime\\prime\}\}\),\\\\ p\(i\_\{c\},i\_\{c^\{\\prime\}\}\),p\(o\_\{c^\{\\prime\}\},i\_\{c^\{\\prime\\prime\}\}\),p\(o\_\{c^\{\\prime\\prime\}\},o\_\{c\}\)
We proceed similarly to translate transitions in which the head is moving to the right\. Figure[1](https://arxiv.org/html/2607.22636#S4.F1)\(resp\. Figure[2](https://arxiv.org/html/2607.22636#S4.F2)\) illustrates the functioning of rules of type \([2](https://arxiv.org/html/2607.22636#S4.E2)\) \(resp\. type \([3](https://arxiv.org/html/2607.22636#S4.E3)\)\)\. We denote byℛℳ,x\\mathcal\{R\}\_\{\\mathcal\{M\},x\}the set of all the rules defined above\. Note thatxxis required to determine the arity of𝖼𝗈𝗇𝖿\\mathsf\{conf\}\.

The following proposition establishes the correctness of the reduction\.

c​e​l​licell\_\{i\}…\\ldotsici\_\{c\}…\\ldotsoco\_\{c\}c​e​l​li′cell^\{\\prime\}\_\{i\}…\\ldotsic′i\_\{c^\{\\prime\}\}…\\ldotsoc′o\_\{c^\{\\prime\}\}c​e​l​li′′cell^\{\\prime\\prime\}\_\{i\}…\\ldotsic′′i\_\{c^\{\\prime\\prime\}\}…\\ldotsoc′′o\_\{c^\{\\prime\\prime\}\}Figure 1\.The existential gadgetc​e​l​licell\_\{i\}…\\ldotsici\_\{c\}…\\ldotsoco\_\{c\}c​e​l​li′cell^\{\\prime\}\_\{i\}…\\ldotsic′i\_\{c^\{\\prime\}\}…\\ldotsoc′o\_\{c^\{\\prime\}\}c​e​l​li′′cell^\{\\prime\\prime\}\_\{i\}…\\ldotsic′′i\_\{c^\{\\prime\\prime\}\}…\\ldotsoc′′o\_\{c^\{\\prime\\prime\}\}Figure 2\.The universal gadget###### Proposition 1\.

Letℳ\\mathcal\{M\}be aPSpaceATM and letα\\alphabe an atom of𝖼𝗁𝖺𝗌𝖾\\mathsf\{chase\}\(Iℳ,xI\_\{\\mathcal\{M\},x\},ℛℳ,x\\mathcal\{R\}\_\{\\mathcal\{M\},x\}\) representing a configurationc​\(α\)c\(\\alpha\)\. Thenc​\(α\)c\(\\alpha\)is an accepting configuration ofℳ\\mathcal\{M\}if and only if there is a path in𝖼𝗁𝖺𝗌𝖾​\(Iℳ,x,ℛℳ,x\)\\mathsf\{chase\}\(I\_\{\\mathcal\{M\},x\},\\mathcal\{R\}\_\{\\mathcal\{M\},x\}\)fromi​\(α\)i\(\\alpha\)too​\(α\)o\(\\alpha\)whose label belongs top∗p^\{\*\}\.

###### Proof\.

\(⇐\\Leftarrow\) Letα∈𝖼𝗁𝖺𝗌𝖾​\(Iℳ,x,ℛℳ,x\)\\alpha\\in\\mathsf\{chase\}\(I\_\{\\mathcal\{M\},x\},\\mathcal\{R\}\_\{\\mathcal\{M\},x\}\)represent a configurationc​\(α\)c\(\\alpha\), and letCαC\_\{\\alpha\}be the restriction of𝖼𝗁𝖺𝗌𝖾​\(Iℳ,x,ℛℳ,x\)\\mathsf\{chase\}\(I\_\{\\mathcal\{M\},x\},\\mathcal\{R\}\_\{\\mathcal\{M\},x\}\)toα\\alphaand the atoms generated fromα\\alpha\. We show by induction on the number of atoms ofCαC\_\{\\alpha\}that when the desired path exists inCαC\_\{\\alpha\},c​\(α\)c\(\\alpha\)is accepting\. Note that the induction is well\-founded as the considered Turing Machines terminate\.

- •IfCαC\_\{\\alpha\}contains a single atom, then there can be no path in𝖼𝗁𝖺𝗌𝖾​\(Iℳ,x,ℛℳ,x\)\\mathsf\{chase\}\(I\_\{\\mathcal\{M\},x\},\\mathcal\{R\}\_\{\\mathcal\{M\},x\}\)witnessingp∗​\(i​\(α\),o​\(α\)\)p^\{\*\}\(i\(\\alpha\),o\(\\alpha\)\)\. Suppose then thatCαC\_\{\\alpha\}contains two atoms\. In this case, the only atom inCαC\_\{\\alpha\}other thanα\\alphamust bep​\(i​\(α\),o​\(α\)\)p\(i\(\\alpha\),o\(\\alpha\)\)\. The only way to derive such an atom is to apply a rule of the form \([1](https://arxiv.org/html/2607.22636#S4.E1)\), which is applied if and only ifc​\(α\)c\(\\alpha\)is in an accepting state, hencec​\(α\)c\(\\alpha\)is an accepting configuration ofℳ\\mathcal\{M\}\.
- •Next, assume that the result holds for any atomα\\alphasuch thatCαC\_\{\\alpha\}has less thannnatoms, and letα\\alphabe an atom such thatCαC\_\{\\alpha\}containsnnatoms, withn\>2n\>2\. We distinguish two cases: - –Case 1: the state ofc​\(α\)c\(\\alpha\)is existential\. Then, since the rules of type \([2](https://arxiv.org/html/2607.22636#S4.E2)\) must be satisfied,CαC\_\{\\alpha\}contains atomsα1\\alpha\_\{1\}andα2\\alpha\_\{2\}representing the successor configurations ofc​\(α\)c\(\\alpha\)\. The existence of a path fromi​\(α\)i\(\\alpha\)too​\(α\)o\(\\alpha\)implies that there is either a path fromi​\(α1\)i\(\\alpha\_\{1\}\)too​\(α1\)o\(\\alpha\_\{1\}\)or a path fromi​\(α2\)i\(\\alpha\_\{2\}\)too​\(α2\)o\(\\alpha\_\{2\}\)\. To see why, observe that everypp\-atom involvingi​\(α\)i\(\\alpha\)oro​\(α\)o\(\\alpha\)is added either by the same rule application that createdα\\alphaor by a rule of type \([2](https://arxiv.org/html/2607.22636#S4.E2)\) applied toα\\alpha\. Only atoms of the second kind \(refer to Fig\.[1](https://arxiv.org/html/2607.22636#S4.F1), left\) can belong to a shortest path fromi​\(α\)i\(\\alpha\)too​\(α\)o\(\\alpha\), since atoms of the first kind havei​\(α\)i\(\\alpha\)\(resp\.o​\(α\)o\(\\alpha\)\) as second \(resp\. first\) argument\. If we have a path fromi​\(α1\)i\(\\alpha\_\{1\}\)too​\(α1\)o\(\\alpha\_\{1\}\), then we can apply the induction assumption toα1\\alpha\_\{1\}to get thatc​\(α1\)c\(\\alpha\_\{1\}\)is an accepting configuration, which implies thatc​\(α\)c\(\\alpha\)is also accepting\. We can proceed analogously if we have a path fromi​\(α2\)i\(\\alpha\_\{2\}\)too​\(α2\)o\(\\alpha\_\{2\}\)\. - –Case 2: the state ofc​\(α\)c\(\\alpha\)is universal\. As the rules of type \([3](https://arxiv.org/html/2607.22636#S4.E3)\) must be satisfied, the existence of a path fromi​\(α\)i\(\\alpha\)too​\(α\)o\(\\alpha\)implies the existence of a path fromi​\(α1\)i\(\\alpha\_\{1\}\)too​\(α1\)o\(\\alpha\_\{1\}\)and a path fromi​\(α2\)i\(\\alpha\_\{2\}\)too​\(α2\)o\(\\alpha\_\{2\}\), whereα1\\alpha\_\{1\}andα2\\alpha\_\{2\}represent the successor configurations ofc​\(α\)c\(\\alpha\)\(refer to Fig\.[2](https://arxiv.org/html/2607.22636#S4.F2)\)\. By the induction assumption,c​\(α1\)c\(\\alpha\_\{1\}\)andc​\(α2\)c\(\\alpha\_\{2\}\)are both accepting configurations, which means thatc​\(α\)c\(\\alpha\)is also accepting\.

\(⇒\\Rightarrow\) We prove the other direction by induction on the number of transitions that need to be performed to prove thatc​\(α\)c\(\\alpha\)is accepted byℳ\\mathcal\{M\}\.

- •If no transitions are required, this means thatc​\(α\)c\(\\alpha\)is in an accepting state\. Thus, Rule \([1](https://arxiv.org/html/2607.22636#S4.E1)\) is applicable, andp​\(i​\(α\),o​\(α\)\)p\(i\(\\alpha\),o\(\\alpha\)\)is present in𝖼𝗁𝖺𝗌𝖾​\(Iℳ,x,ℛℳ,x\)\\mathsf\{chase\}\(I\_\{\\mathcal\{M\},x\},\\mathcal\{R\}\_\{\\mathcal\{M\},x\}\)\.
- •Assume the result holds up tonnrequired transitions\. We distinguish two cases: - –Case 1: the state ofc​\(α\)c\(\\alpha\)is existential\. Asc​\(α\)c\(\\alpha\)is accepting, this means that one of its two successor configurations, sayc​\(α1\)c\(\\alpha\_\{1\}\), is accepting\. Moreover, the number of transitions required to acceptc​\(α1\)c\(\\alpha\_\{1\}\)is strictly smaller than forc​\(α\)c\(\\alpha\)\. By the induction assumption,p∗​\(i​\(α1\),o​\(α1\)\)p^\{\*\}\(i\(\\alpha\_\{1\}\),o\(\\alpha\_\{1\}\)\)is present in𝖼𝗁𝖺𝗌𝖾​\(Iℳ,x,ℛℳ,x\)\\mathsf\{chase\}\(I\_\{\\mathcal\{M\},x\},\\mathcal\{R\}\_\{\\mathcal\{M\},x\}\)\. Asp​\(i​\(α\),i​\(α1\)\)p\(i\(\\alpha\),i\(\\alpha\_\{1\}\)\)andp​\(o​\(α1\),o​\(α\)\)p\(o\(\\alpha\_\{1\}\),o\(\\alpha\)\)are also present \(since the rules of the form \([2](https://arxiv.org/html/2607.22636#S4.E2)\) generate them\), this proves thatp∗​\(i​\(α\),o​\(α\)\)p^\{\*\}\(i\(\\alpha\),o\(\\alpha\)\)is present as well\. - –Case 2: the state ofc​\(α\)c\(\\alpha\)is universal\. Asc​\(α\)c\(\\alpha\)is accepting, this means that its two successor configuration are also accepting\. By the induction assumption, this means thatp∗​\(i​\(α1\),o​\(α1\)\)p^\{\*\}\(i\(\\alpha\_\{1\}\),o\(\\alpha\_\{1\}\)\)andp∗​\(i​\(α2\),o​\(α2\)\)p^\{\*\}\(i\(\\alpha\_\{2\}\),o\(\\alpha\_\{2\}\)\)are present in𝖼𝗁𝖺𝗌𝖾​\(Iℳ,x,ℛℳ,x\)\\mathsf\{chase\}\(I\_\{\\mathcal\{M\},x\},\\mathcal\{R\}\_\{\\mathcal\{M\},x\}\)\. As the rules of the form \([3](https://arxiv.org/html/2607.22636#S4.E3)\) also generatep​\(i​\(α\),i​\(α1\)\)p\(i\(\\alpha\),i\(\\alpha\_\{1\}\)\),p​\(o​\(α1\),i​\(α2\)\)p\(o\(\\alpha\_\{1\}\),i\(\\alpha\_\{2\}\)\), andp​\(o​\(α2\),o​\(α\)\)p\(o\(\\alpha\_\{2\}\),o\(\\alpha\)\), this proves thatp∗​\(i​\(α\),o​\(α\)\)p^\{\*\}\(i\(\\alpha\),o\(\\alpha\)\)is present in𝖼𝗁𝖺𝗌𝖾​\(Iℳ,x,ℛℳ,x\)\\mathsf\{chase\}\(I\_\{\\mathcal\{M\},x\},\\mathcal\{R\}\_\{\\mathcal\{M\},x\}\)\. ∎

Now letℳ\\mathcal\{M\}be aPSpaceATM,xxbe an input toℳ\\mathcal\{M\}, andα\\alphabe the unique atom inIℳ,xI\_\{\\mathcal\{M\},x\}\. Then by Proposition[1](https://arxiv.org/html/2607.22636#Thmtheorem1c),c​\(α\)c\(\\alpha\)is an accepting configuration ofℳ\\mathcal\{M\}if and only ifIℳ,x,ℛℳ,x⊧p∗​\(i​\(α\),o​\(α\)\)I\_\{\\mathcal\{M\},x\},\\mathcal\{R\}\_\{\\mathcal\{M\},x\}\\models p^\{\*\}\(i\(\\alpha\),o\(\\alpha\)\); in other words: if and only if\(i​\(α\),o​\(α\)\)\(i\(\\alpha\),o\(\\alpha\)\)is a certain answer to the RPQp∗​\(x,y\)p^\{\*\}\(x,y\)on the KB\(Iℳ,x,ℛℳ,x\)\(I\_\{\\mathcal\{M\},x\},\\mathcal\{R\}\_\{\\mathcal\{M\},x\}\)\. This, together with known results, yields the following lower bounds:

###### Theorem 2\.

RPQAnswering in the presence of linear existential rules isNL\-hard in data complexity,PTime\-hard in combined complexity with bounded arity andExpTime\-hard in combined complexity without arity bound, even for a fixed RPQ\.

#### Note

The preceding reduction can be used to show that atomic query entailment under rulesets composed of linear rules and transitivity rules \(AQELT\) isExpTime\-hard in combined complexity, already with a single transitivity rule\. Indeed, a pair of constants\(a,b\)\(a,b\)is an answer to an RPQp\+​\(x,y\)p^\{\+\}\(x,y\)on a KB𝒦=\(I,ℛ\)\\mathcal\{K\}=\(I,\\mathcal\{R\}\)withℛ\\mathcal\{R\}a linear ruleset iff the atomic Boolean queryp′​\(a,b\)p^\{\\prime\}\(a,b\)is entailed by the KB\(I,ℛ∪\{p\(x,y\)→p′\(x,y\);p′\(x,y\)∧p′\(y,z\)→p′\(x,z\)\}\(I,\\mathcal\{R\}\\cup\\\{p\(x,y\)\\rightarrow p^\{\\prime\}\(x,y\);p^\{\\prime\}\(x,y\)\\land p^\{\\prime\}\(y,z\)\\rightarrow p^\{\\prime\}\(x,z\)\\\}, wherep′p^\{\\prime\}is a fresh predicate introduced to avoid interactions between the new rules and those fromℛ\\mathcal\{R\}\.

AssumingExpTime≠\\neqPSpace, our result is in contradiction with Theorem 5 in\(Baget et al\.,[2015a](https://arxiv.org/html/2607.22636#bib.bib5)\), which purports to show aPSpaceupper bound for the AQELT problem\. After reexamining the proofs, the authors of the latter work have identified the flaw, which occurs in the analysis of the combined complexity of their rewriting\-based decision procedure\. It turns out that their procedure runs in exponential time, rather than in polynomial space \(theirNLupper bound in data complexity remains valid\)\. Combining our lower bound with their procedure shows that the AQELT problem isExpTime\-complete in combined complexity\. The incorrect claim from\(Baget et al\.,[2015a](https://arxiv.org/html/2607.22636#bib.bib5)\)was corrected in the companion report with full proofs\(Baget et al\.,[2015b](https://arxiv.org/html/2607.22636#bib.bib6)\)\.

## 5\.CRPQ Answering under Linear Rules: Upper Bound

We now study the complexity of CRPQ answering under linear rules\. The algorithm we propose to solve this problem is based on two notions\. First, the notion of a*proof scheme*, which \(under some validity conditions\) captures a finite portion of the chase\. Second, the notion of a*match*of a \(Boolean\) CRPQ in a proof scheme, which attests that this CRPQ is entailed by the portion of the chase captured by this proof scheme\. The algorithm roughly works as follows: it enumerates all proof schemes of ‘small’ size and checks whether one of them is valid and admits a match of the query\. To obtain our complexity results, we will upper bound both the size of the proof schemes that need to be considered and the cost of the validity check\.

Section[5\.1](https://arxiv.org/html/2607.22636#S5.SS1)introduces the fundamental notions\. It concludes with Proposition[7](https://arxiv.org/html/2607.22636#Thmtheorem7a), which states that a queryqqis entailed by a knowledge base if and only if there exists a match ofqqin some valid proof scheme\. Section[5\.2](https://arxiv.org/html/2607.22636#S5.SS2)proves \(the hard direction of\) that proposition, by exhibiting a suitable proof scheme wheneverqqis entailed by the knowledge base\. Finally, Section[5\.3](https://arxiv.org/html/2607.22636#S5.SS3)analyzes the computational resources required to enumerate proof schemes and to check their validity as well as the existence of a match ofqqin one of them\.

### 5\.1\.Proof Schemes

We recall that a CRPQqqmay contain both standard atoms and path atoms whose predicate is defined by an automaton\. Given a pair of atoms, it will be important to keep track of the paths in the chase that link terms occurring in these atoms and correspond to words that can be read by the automata appearing inqq, i\.e\., that take one of these automata from a states1s\_\{1\}to a states2s\_\{2\}\. The next definition of*transitions*between atoms plays this role\.

###### Definition 1 \(Transition\)\.

LetAAbe a set of atoms\. Letα1\\alpha\_\{1\}andα2\\alpha\_\{2\}be two atoms ofAAof arityk1k\_\{1\}andk2k\_\{2\}respectively\. Given a queryqq, the*set of transitions fromα1\\alpha\_\{1\}toα2\\alpha\_\{2\}inAA*, denoted by𝒯q,A​\(α1,α2\)\\mathcal\{T\}\_\{q,A\}\(\\alpha\_\{1\},\\alpha\_\{2\}\), is the set of quadruples\(i1,s1,i2,s2\)\(i\_\{1\},s\_\{1\},i\_\{2\},s\_\{2\}\)with1≤i1≤k11\\leq i\_\{1\}\\leq k\_\{1\}and1≤i2≤k21\\leq i\_\{2\}\\leq k\_\{2\}, such that there are an automaton𝔸\\mathbb\{A\}inqqand a pathppinAAgoing fromα1​\[i1\]\\alpha\_\{1\}\[i\_\{1\}\]toα2​\[i2\]\\alpha\_\{2\}\[i\_\{2\}\]such thatλ​\(p\)\\lambda\(p\)∈ℒ𝔸\(s1,s2\\in\\mathcal\{L\}\_\{\\mathbb\{A\}\}\(s\_\{1\},s\_\{2\}\)\. More generally, by*transition*, we will mean a quadruple\(i1,s1,i2,s2\)\(i\_\{1\},s\_\{1\},i\_\{2\},s\_\{2\}\)wheres1,s2s\_\{1\},s\_\{2\}are states of an automaton inqq, andi1,i2i\_\{1\},i\_\{2\}do not exceed the maximum predicate arity inI∪ℛI\\cup\\mathcal\{R\}\.

This allows us to introduce the key technical notion underlying our approach, namely,*proof schemes*\. Briefly, a proof scheme is a directed forest whose nodes are atoms, together with transitions for different pairs of atoms in this forest\. Intuitively, under some validity conditions defined later \(Definition[5](https://arxiv.org/html/2607.22636#Thmtheorem5b)\), a proof scheme corresponds to a subset of the chase, with the transitions placing requirements on the paths linking these atoms\.

###### Definition 2 \(Proof scheme\)\.

A*proof scheme*is a pairℙ=\(ℱ,𝒯\)\\mathbb\{P\}=\(\\mathcal\{F\},\\mathcal\{T\}\)such that:

1. \(1\)ℱ=\(V,E\)\\mathcal\{F\}=\(V,E\)is a directed forest;
2. \(2\)VVis a set of atoms;
3. \(3\)for each null⊥\\bot, the set of nodes in which⊥\\botoccurs form a connected subgraph ofℱ\\mathcal\{F\};
4. \(4\)𝒯\\mathcal\{T\}is a set of pairs\(τ,\(α1,α2\)\)\(\\tau,\(\\alpha\_\{1\},\\alpha\_\{2\}\)\), whereα1\\alpha\_\{1\}andα2\\alpha\_\{2\}belong toVVandτ\\tauis a transition fromα1\\alpha\_\{1\}toα2\\alpha\_\{2\}\.
5. \(5\)for each\(τ,\(α1,α2\)\)∈𝒯\(\\tau,\(\\alpha\_\{1\},\\alpha\_\{2\}\)\)\\in\\mathcal\{T\}, eitherα1=α2\\alpha\_\{1\}=\\alpha\_\{2\},\(α1,α2\)∈E\(\\alpha\_\{1\},\\alpha\_\{2\}\)\\in E,\(α2,α1\)∈E\(\\alpha\_\{2\},\\alpha\_\{1\}\)\\in E, or bothα1\\alpha\_\{1\}andα2\\alpha\_\{2\}are roots\.

We denote by𝗏𝖺𝗋𝗌​\(ℙ\)\\mathsf\{vars\}\{\(\\mathbb\{P\}\)\}and𝗍𝖾𝗋𝗆𝗌​\(ℙ\)\\mathsf\{terms\}\{\(\\mathbb\{P\}\)\}the variables and terms occurring in atoms ofVV, i\.e\.,𝗏𝖺𝗋𝗌​\(ℙ\)=𝗏𝖺𝗋𝗌​\(V\)\\mathsf\{vars\}\{\(\\mathbb\{P\}\)\}=\\mathsf\{vars\}\{\(V\)\}and𝗍𝖾𝗋𝗆𝗌​\(ℙ\)=𝗍𝖾𝗋𝗆𝗌​\(V\)\\mathsf\{terms\}\{\(\\mathbb\{P\}\)\}=\\mathsf\{terms\}\{\(V\)\}\.

In a proof scheme, transitions are assigned to pairs of atoms that comply with specific conditions: the atoms are equal, or both are roots, or one is the parent of the other in a tree\. To check the existence of paths that link terms occurring in arbitrary pairs of atoms, we can compose these transitions\. The*saturation*of a proof scheme, defined next, enriches the proof scheme with all the transitions that can be obtained by composition\.

###### Definition 3 \(Saturation of a proof scheme\)\.

Letℙ=\(ℱ,𝒯\)\\mathbb\{P\}=\(\\mathcal\{F\},\\mathcal\{T\}\)be a proof scheme\. The*saturation*ofℙ\\mathbb\{P\}is the pair\(ℱ,𝒯′\)\(\\mathcal\{F\},\\mathcal\{T\}^\{\\prime\}\)where𝒯′\\mathcal\{T\}^\{\\prime\}is the smallest set such that𝒯⊆𝒯′\\mathcal\{T\}\\subseteq\\mathcal\{T\}^\{\\prime\}and\{\(\(i1,s1,i2,s2\),\(α1,α2\)\),\(\(i2,s2,i3,s3\),\(α2,α3\)\)\}⊆𝒯′\\\{\(\(i\_\{1\},s\_\{1\},i\_\{2\},s\_\{2\}\),\(\\alpha\_\{1\},\\alpha\_\{2\}\)\),\(\(i\_\{2\},s\_\{2\},i\_\{3\},s\_\{3\}\),\(\\alpha\_\{2\},\\alpha\_\{3\}\)\)\\\}\\subseteq\\mathcal\{T\}^\{\\prime\}implies\(\(i1,s1,i3,s3\),\(α1,α3\)\)∈𝒯′\(\(i\_\{1\},s\_\{1\},i\_\{3\},s\_\{3\}\),\(\\alpha\_\{1\},\\alpha\_\{3\}\)\)\\in\\mathcal\{T\}^\{\\prime\}\.

###### Definition 4 \(Match in a proof scheme\)\.

Letℙ=\(ℱ,𝒯\)\\mathbb\{P\}=\(\\mathcal\{F\},\\mathcal\{T\}\)be a proof scheme withℱ=\(V,E\)\\mathcal\{F\}=\(V,E\)\. A*match*ofqqinℙ\\mathbb\{P\}is a mappingπ\\pifrom𝗏𝖺𝗋𝗌​\(q\)\\mathsf\{vars\}\{\(q\)\}to𝗍𝖾𝗋𝗆𝗌​\(ℙ\)\\mathsf\{terms\}\{\(\\mathbb\{P\}\)\}such that:

- •ifα\\alphais a standard atom inqq, thenπ​\(α\)∈V\\pi\(\\alpha\)\\in V;
- •ifα=Λ​\(x,y\)\\alpha=\\Lambda\(x,y\)is a path atom inqqwith associated NFA𝔸\\mathbb\{A\}, then there exists a pair\(\(ix,sx,iy,sy\),\(αx,αy\)\)\(\(i\_\{x\},s\_\{x\},i\_\{y\},s\_\{y\}\),\(\\alpha\_\{x\},\\alpha\_\{y\}\)\)in the saturation ofℙ\\mathbb\{P\}such thatπ​\(x\)=αx​\[ix\]\\pi\(x\)=\\alpha\_\{x\}\[i\_\{x\}\],π​\(y\)=αy​\[iy\]\\pi\(y\)=\\alpha\_\{y\}\[i\_\{y\}\]andsxs\_\{x\}\(resp\.sys\_\{y\}\) is the initial \(resp\. a final\) state of𝔸\\mathbb\{A\}\.

Note that, in the second point of the previous definition,xxandyyare not necessarily variables and we silently extendπ\\pito constants by settingπ​\(c\)=c\\pi\(c\)=cfor any constantcc\. The problem of deciding if there is a match of a given queryqqin a given proof schemeℙ\\mathbb\{P\}is NP\-complete\. Indeed, checking whether a candidate mapping is indeed a match ofqqinℙ\\mathbb\{P\}can be done in polynomial time, since the saturation of a proof scheme can be computed in polynomial time; NP\-hardness can be shown by reducing the homomorphism problem \(given an instanceIIand a CQqq, is there a homomorphism fromqqtoII?\), withIIbeing translated into a trivial proof scheme whereV=IV=I,E=∅E=\\emptysetand𝒯=∅\\mathcal\{T\}=\\emptyset\.

As already mentioned, not all proof schemes actually encode a part of the chase\. More precisely, a proof scheme is said to be*valid*if it can be embedded into the chase by a mapping called a ‘witnessing embedding’\. Then, given a valid proof schemeℙ\\mathbb\{P\}and a queryqq, the composition of a match ofqqinℙ\\mathbb\{P\}and a witnessing embedding ofℙ\\mathbb\{P\}yields a match ofqqin the chase\. We will also show that, whenever there is a match ofqqin the chase, there is a match ofqqin some valid proof scheme\.

###### Definition 5 \(Valid proof scheme and witnessing embedding\)\.

A proof schemeℙ=\(ℱ,𝒯\)\\mathbb\{P\}=\(\\mathcal\{F\},\\mathcal\{T\}\)withℱ=\(V,E\)\\mathcal\{F\}=\(V,E\)is*valid*w\.r\.t\.\(I,ℛ,q\)\(I,\\mathcal\{R\},q\)if there is a mappingψ\\psifrom𝗏𝖺𝗋𝗌​\(ℙ\)\\mathsf\{vars\}\{\(\\mathbb\{P\}\)\}to𝗍𝖾𝗋𝗆𝗌​\(𝖼𝗁𝖺𝗌𝖾​\(I,ℛ\)\)\\mathsf\{terms\}\{\(\\mathsf\{chase\}\(I,\\mathcal\{R\}\)\)\}such that:

1. \(1\)for each root atomα∈V\\alpha\\in V,ψ​\(α\)=α\\psi\(\\alpha\)=\\alphaandα∈I\\alpha\\in I;
2. \(2\)for each atomα∈V\\alpha\\in V,ψ​\(α\)∈𝖼𝗁𝖺𝗌𝖾​\(I,ℛ\)\\psi\(\\alpha\)\\in\\mathsf\{chase\}\(I,\\mathcal\{R\}\);
3. \(3\)for each edge\(α1,α2\)∈E\(\\alpha\_\{1\},\\alpha\_\{2\}\)\\in E, there is anℛ\\mathcal\{R\}\-derivation from\{ψ​\(α1\)\}\\\{\\psi\(\\alpha\_\{1\}\)\\\}to \(an extended instance that contains\)ψ​\(α2\)\\psi\(\\alpha\_\{2\}\)\.
4. \(4\)for each\(τ,\(α1,α2\)\)∈𝒯\(\\tau,\(\\alpha\_\{1\},\\alpha\_\{2\}\)\)\\in\\mathcal\{T\}:τ∈𝒯q,𝖼𝗁𝖺𝗌𝖾​\(I,ℛ\)​\(ψ​\(α1\),ψ​\(α2\)\)\\tau\\in\\mathcal\{T\}\_\{q,\\mathsf\{chase\}\(I,\\mathcal\{R\}\)\}\(\\psi\(\\alpha\_\{1\}\),\\psi\(\\alpha\_\{2\}\)\)\.

We sayψ\\psiis a*witnessing embedding*ofℙ\\mathbb\{P\}\.

Note that the saturation of a proof scheme is generally not a proof scheme, as the added transitions may label arbitrary pairs of atoms\. However, and this is a point worth noting even if it is immediate, the saturation of a valid proof scheme also fulfills all the validity conditions from Definition[5](https://arxiv.org/html/2607.22636#Thmtheorem5b)\.

###### Example 6 \(Running Example—continued\)\.

Letℛ\\mathcal\{R\}be the set of linear rules from Example[1](https://arxiv.org/html/2607.22636#Thmtheorem1):

> \(ρ1\)𝗂𝗌𝖥𝗋𝗂𝖾𝗇𝖽𝖮𝖿​\(x,y\)→𝗂𝗌𝖥𝗋𝗂𝖾𝗇𝖽𝖮𝖿​\(y,x\)\(\\rho\_\{1\}\)\\quad\\mathsf\{isFriendOf\}\(x,y\)\\rightarrow\\mathsf\{isFriendOf\}\(y,x\) \(ρ2\)𝗂𝗌𝖥𝗋𝗂𝖾𝗇𝖽𝖮𝖿​\(x,y\)→𝖿𝗈𝗅𝗅𝗈𝗐𝗌​\(x,y\)\(\\rho\_\{2\}\)\\quad\\mathsf\{isFriendOf\}\(x,y\)\\rightarrow\\mathsf\{follows\}\(x,y\) \(ρ3\)𝖿𝗈𝗅𝗅𝗈𝗐𝗌​\(x,y\)→∃m​𝗆𝖾𝗌𝗌𝖺𝗀𝖾​\(m,x,y\)\(\\rho\_\{3\}\)\\quad\\mathsf\{follows\}\(x,y\)\\rightarrow\\exists m~\\mathsf\{message\}\(m,x,y\)

Consider again the instanceI=\{𝖿𝗈𝗅𝗅𝗈𝗐𝗌​\(𝖡,𝖠\),𝗂𝗌𝖥𝗋𝗂𝖾𝗇𝖽𝖮𝖿​\(𝖢,𝖠\),𝗂𝗌𝖥𝗋𝗂𝖾𝗇𝖽𝖮𝖿​\(𝖢,𝖡\)\}I=\\\{\\mathsf\{follows\(B,A\)\},\\mathsf\{isFriendOf\(C,A\)\},\\mathsf\{isFriendOf\(C,B\)\}\\\}and the following CRPQ:

q6​\(\)=∃y,m\.𝖿𝗈𝗅𝗅𝗈𝗐𝗌\.𝖿𝗈𝗅𝗅𝗈𝗐𝗌∗​\(A,y\)∧m​e​s​s​a​g​e​\(m,y,A\)q\_\{6\}\(\)=\\exists y,m\.~\\mathsf\{follows\.follows\}^\{\*\}\(A,y\)\\land message\(m,y,A\)We assign to the path predicate𝖿𝗈𝗅𝗅𝗈𝗐𝗌\.𝖿𝗈𝗅𝗅𝗈𝗐𝗌∗\\mathsf\{follows\.follows\}^\{\*\}the NFA representation𝔸\\mathbb\{A\}with states\{s0,sf\}\\\{s\_\{0\},s\_\{f\}\\\}and two transitions:\(s0,𝖿𝗈𝗅𝗅𝗈𝗐𝗌,sf\)\(s\_\{0\},\\mathsf\{follows\},s\_\{f\}\),\(sf,𝖿𝗈𝗅𝗅𝗈𝗐𝗌,sf\)\(s\_\{f\},\\mathsf\{follows\},s\_\{f\}\)\. Recall that queryq6q\_\{6\}can be matched to the following part of𝖼𝗁𝖺𝗌𝖾​\(I,ℛ\)\\mathsf\{chase\}\(I,\\mathcal\{R\}\):\{𝖿𝗈𝗅𝗅𝗈𝗐𝗌​\(A,C\),𝖿𝗈𝗅𝗅𝗈𝗐𝗌​\(C,B\),𝗆𝖾𝗌𝗌𝖺𝗀𝖾​\(m0,B,A\)\}\\\{\\mathsf\{follows\}\(A,C\),\\mathsf\{follows\}\(C,B\),\\mathsf\{message\}\(m\_\{0\},B,A\)\\\}\.

A proof schemeℙ=\(ℱ,𝒯\)\\mathbb\{P\}=\(\\mathcal\{F\},\\mathcal\{T\}\)forq6q\_\{6\}is pictured in Figure[3](https://arxiv.org/html/2607.22636#S5.F3)\. The forestℱ\\mathcal\{F\}contains a single tree, having two nodes\. The only appearing null ism0m\_\{0\}and it occurs in a single node, which trivially forms a connected subgraph ofℱ\\mathcal\{F\}\. The set of transitions𝒯\\mathcal\{T\}contains a single transition\(τ,\(α1,α1\)\)\(\\tau,\(\\alpha\_\{1\},\\alpha\_\{1\}\)\), whereτ=\(2,s0,1,sf\)\\tau=\(2,s\_\{0\},1,s\_\{f\}\)\. Proof schemeℙ\\mathbb\{P\}is valid w\.r\.t\.\(I,ℛ,q6\)\(I,\\mathcal\{R\},q\_\{6\}\), as attested by a witnessing embeddingψ=\{m0↦m0\}\\psi=\\\{m\_\{0\}\\mapsto m\_\{0\}\\\}\. Note that the transition holds due to the atoms𝖿𝗈𝗅𝗅𝗈𝗐𝗌​\(A,C\)\\mathsf\{follows\}\(A,C\)and𝖿𝗈𝗅𝗅𝗈𝗐𝗌​\(C,B\)\\mathsf\{follows\}\(C,B\)inII\. Queryq6q\_\{6\}has a match inℙ\\mathbb\{P\}given byπ=\{y↦B,m↦m0\}\\pi=\\\{y\\mapsto B,m\\mapsto m\_\{0\}\\\}\.

𝖿𝗈𝗅𝗅𝗈𝗐𝗌​\(𝖡,𝖠\)\\mathsf\{follows\(B,A\)\}𝗆𝖾𝗌𝗌𝖺𝗀𝖾​\(𝗆𝟢,𝖡,𝖠\)\\mathsf\{message\(m\_\{0\},B,A\)\}α1\\alpha\_\{1\}α2\\alpha\_\{2\}ℱ\\mathcal\{F\}:Figure 3\.Valid proof scheme\(ℱ,𝒯\)\(\\mathcal\{F\},\\mathcal\{T\}\), with𝒯=\{\(\(2,s0,1,sf\),\(α1,α1\)\)\}\\mathcal\{T\}=\\\{\(\(2,s\_\{0\},1,s\_\{f\}\),\(\\alpha\_\{1\},\\alpha\_\{1\}\)\)\\\}\(Example[6](https://arxiv.org/html/2607.22636#Thmtheorem6a)\)The next proposition states that CRPQ answering can be recast as deciding whether there is a match of the query in a ‘small’ valid proof scheme\.

###### Proposition 7\.

I,ℛ⊧qI,\\mathcal\{R\}\\models qiff there exists a match ofqqin some valid proof scheme of polynomial size inqq\.

###### Proof\.

\(⇐\\Leftarrow\) Letℙ\\mathbb\{P\}be a valid proof scheme andψ\\psibe a witnessing embedding ofℙ\\mathbb\{P\}in𝖼𝗁𝖺𝗌𝖾​\(I,ℛ\)\\mathsf\{chase\}\(I,\\mathcal\{R\}\)\. Letπ\\pibe a match ofqqinℙ\\mathbb\{P\}\. We claim thatψ∘π\\psi\\circ\\piis a match ofqqin𝖼𝗁𝖺𝗌𝖾​\(I,ℛ\)\\mathsf\{chase\}\(I,\\mathcal\{R\}\), which proves thatI,ℛ⊧qI,\\mathcal\{R\}\\models q\. Indeed, take any atomα\\alphaofqq\. Ifα\\alphais a standard atom,π​\(α\)∈V\\pi\(\\alpha\)\\in V, henceψ∘π​\(α\)∈𝖼𝗁𝖺𝗌𝖾​\(I,ℛ\)\\psi\\circ\\pi\(\\alpha\)\\in\\mathsf\{chase\}\(I,\\mathcal\{R\}\)\. Ifα\\alphais a path atom, letα=Λ​\(x,y\)\\alpha=\\Lambda\(x,y\), then there is a pair\(\(ix,sx,iy,sy\),\(αx,αy\)\)\(\(i\_\{x\},s\_\{x\},i\_\{y\},s\_\{y\}\),\(\\alpha\_\{x\},\\alpha\_\{y\}\)\)in the saturation ofℙ\\mathbb\{P\}, such thatπ​\(x\)=αx​\[ix\]\\pi\(x\)=\\alpha\_\{x\}\[i\_\{x\}\]andπ​\(y\)=αy​\[iy\]\\pi\(y\)=\\alpha\_\{y\}\[i\_\{y\}\], withsxs\_\{x\}andsys\_\{y\}initial and final states in the automaton associated withΛ\\Lambda\. Asℙ\\mathbb\{P\}is valid, its saturation also fulfills the validity conditions\. Hence, there is a pathppfromψ​\(π​\(x\)\)\\psi\(\\pi\(x\)\)toψ​\(π​\(y\)\)\\psi\(\\pi\(y\)\)in𝖼𝗁𝖺𝗌𝖾​\(I,ℛ\)\\mathsf\{chase\}\(I,\\mathcal\{R\}\)such thatλ​\(p\)\\lambda\(p\)belongs toℒ​\(Λ\)\\mathcal\{L\}\(\\Lambda\)\. We conclude thatψ∘π\\psi\\circ\\piis a match ofqqin𝖼𝗁𝖺𝗌𝖾​\(I,ℛ\)\\mathsf\{chase\}\(I,\\mathcal\{R\}\)\.

\(⇒\\Rightarrow\) This part of the proof is addressed in Section[5\.2](https://arxiv.org/html/2607.22636#S5.SS2)\. ∎

### 5\.2\.Proof of Proposition[7](https://arxiv.org/html/2607.22636#Thmtheorem7a)

We now prove that ifI,ℛ⊧qI,\\mathcal\{R\}\\models q, then one can build a valid proof schemeℙ\\mathbb\{P\}of polynomial size inqq, such that there is a match ofqqinℙ\\mathbb\{P\}\. For that, we rely on a classical tool, namely the*chase graph*associated with a derivation, which keeps track of how atoms are generated in this derivation\. Nodes are labeled by the atoms occurring in the derivation and there is an edge\(ν,ν′\)\(\\nu,\\nu^\{\\prime\}\)if a trigger in the derivation is applied on the atom that labelsν\\nuand leads to generate the atom that labelsν′\\nu^\{\\prime\}\. Note that we only keep track of rule applications that produce new atoms and that the derivation may not be fair \(yet\)\.

###### Definition 8 \(Chase graph associated with a derivation\)\.

LetIIbe an instance andℛ\\mathcal\{R\}be a set of linear rules\. The*chase graph*associated with a \(possibly infinite\)ℛ\\mathcal\{R\}\-derivationDDfromII, denoted by𝒞​𝒢D\\mathcal\{CG\}\_\{D\}, is a \(possibly infinite\) node\-labeled directed forest built as follows \(we useℓ\\ellfor the labeling function\):

- •its set of nodes is in bijection with𝖺𝗍𝗈𝗆𝗌​\(D\)\\mathsf\{atoms\}\{\(D\)\}viaℓ\\ell;
- •for each trigger\(ρi,πi\)\(\\rho\_\{i\},\\pi\_\{i\}\)inDDthat*directly generates*an atomαi\\alpha\_\{i\}, there is an edge\(ν,ν′\)\(\\nu,\\nu^\{\\prime\}\)whereℓ​\(ν\)=πi​\(𝖻𝗈𝖽𝗒​\(ρi\)\)\\ell\(\\nu\)=\\pi\_\{i\}\(\\mathsf\{body\}\(\\rho\_\{i\}\)\)andℓ​\(ν′\)=αi\\ell\(\\nu^\{\\prime\}\)=\\alpha\_\{i\}\.

The set of atoms that label the nodes of𝒞​𝒢D\\mathcal\{CG\}\_\{D\}is denoted by𝖺𝗍𝗈𝗆𝗌​\(𝒞​𝒢D\)\\mathsf\{atoms\}\{\(\\mathcal\{CG\}\_\{D\}\)\}\.

Note that𝒞​𝒢D\\mathcal\{CG\}\_\{D\}is indeed a forest because each atom outsideIIis directly generated exactly once inDDand there is a single node labeled by this atom\. Also note that𝖺𝗍𝗈𝗆𝗌​\(𝒞​𝒢D\)=𝖺𝗍𝗈𝗆𝗌​\(D\)\\mathsf\{atoms\}\{\(\\mathcal\{CG\}\_\{D\}\)\}=\\mathsf\{atoms\}\{\(D\)\}\.

The next example will be used to illustrate the technical notions of this section, beginning with that of a chase graph\.

###### Example 9\.

LetI=\{h​\(a1,a2\),m​\(a2\)\}I=\\\{h\(a\_\{1\},a\_\{2\}\),m\(a\_\{2\}\)\\\}andℛ\\mathcal\{R\}containing the following rules:

R1:h​\(x,y\)→∃z​b​\(x,y,z\)R\_\{1\}:h\(x,y\)\\rightarrow\\exists z~b\(x,y,z\)R2:b​\(x,y,z\)→∃t​b′​\(x,z,t\)R\_\{2\}:b\(x,y,z\)\\rightarrow\\exists t\\ b^\{\\prime\}\(x,z,t\)R5:b​\(x,y,z\)→∃t​b′′​\(y,z,t\)R\_\{5\}:b\(x,y,z\)\\rightarrow\\exists t~b^\{\\prime\\prime\}\(y,z,t\)R3:b′​\(x,y,z\)→s​\(x,z\)R\_\{3\}:b^\{\\prime\}\(x,y,z\)\\rightarrow s\(x,z\)R6:b′′​\(x,y,z\)→r​\(y,z\)R\_\{6\}:b^\{\\prime\\prime\}\(x,y,z\)\\rightarrow r\(y,z\)R4:b′​\(x,y,z\)→r​\(z,y\)R\_\{4\}:b^\{\\prime\}\(x,y,z\)\\rightarrow r\(z,y\)R7:b′′​\(x,y,z\)→s​\(x,z\)R\_\{7\}:b^\{\\prime\\prime\}\(x,y,z\)\\rightarrow s\(x,z\)
The chase graph associated with a \(fair\)ℛ\\mathcal\{R\}\-derivationDDfromIItoI′I^\{\\prime\}is pictured in Figure[4](https://arxiv.org/html/2607.22636#S5.F4), left\. Letq=∃x1​∃x2​∃x3​∃x4​h​\(x1,x2\)∧m​\(x2\)∧s∗​\(x1,x3\)∧r∗​\(x3,x4\)∧s∗​\(x2,x4\)q=\\exists x\_\{1\}\\exists x\_\{2\}\\exists x\_\{3\}\\exists x\_\{4\}\\ h\(x\_\{1\},x\_\{2\}\)\\wedge m\(x\_\{2\}\)\\wedge s^\{\*\}\(x\_\{1\},x\_\{3\}\)\\wedge r^\{\*\}\(x\_\{3\},x\_\{4\}\)\\wedge s^\{\*\}\(x\_\{2\},x\_\{4\}\)\. There is a matchπ\\piofqqinI′I^\{\\prime\}defined by:\{x1→a1,x2→a2,x3→t0,x4→t1\}\\\{x\_\{1\}\\rightarrow a\_\{1\},x\_\{2\}\\rightarrow a\_\{2\},x\_\{3\}\\rightarrow t\_\{0\},x\_\{4\}\\rightarrow t\_\{1\}\\\}\.

h​\(a1,a2\)\{h\(a\_\{1\},a\_\{2\}\)\}m​\(a2\)\{m\(a\_\{2\}\)\}b​\(a1,a2,z0\)b\(a\_\{1\},a\_\{2\},z\_\{0\}\)b′′​\(a2,z0,t1\)b^\{\\prime\\prime\}\(a\_\{2\},z\_\{0\},t\_\{1\}\)b′​\(a1,z0,t0\)b^\{\\prime\}\(a\_\{1\},z\_\{0\},t\_\{0\}\)s​\(a1,t0\)\{s\(a\_\{1\},t\_\{0\}\)\}r​\(t0,z0\)\{r\(t\_\{0\},z\_\{0\}\)\}s​\(a2,t1\)\{s\(a\_\{2\},t\_\{1\}\)\}r​\(z0,t1\)\{r\(z\_\{0\},t\_\{1\}\)\}h​\(a1,a2\)\{h\(a\_\{1\},a\_\{2\}\)\}m​\(a2\)\{m\(a\_\{2\}\)\}b​\(a1,a2,z0\)b\(a\_\{1\},a\_\{2\},z\_\{0\}\)r​\(z0,t1\)r\(z\_\{0\},t\_\{1\}\)s​\(a1,t0\)s\(a\_\{1\},t\_\{0\}\)Figure 4\.Chase graph𝒞​𝒢D\\mathcal\{CG\}\_\{D\}on the left and a backbone ofπ\\pion the right \(Example[9](https://arxiv.org/html/2607.22636#Thmtheorem9a)\)To simplify writing, when a termttoccurs in an atomα=ℓ​\(ν\)\\alpha=\\ell\(\\nu\), we will say thatα\\alphacontainstt, and by extension thatν\\nu*contains*tt\. This is extended to a set of nodes and a subgraph\. A chase graph𝒞​𝒢D\\mathcal\{CG\}\_\{D\}can also be seen as a tree decomposition of the set of atomsa​t​o​m​s​\(𝒞​𝒢D\)atoms\(\\mathcal\{CG\}\_\{D\}\), in the following sense:𝒞​𝒢D\\mathcal\{CG\}\_\{D\}is a forest structure such that*\(i\)*nodes are labeled by atoms froma​t​o​m​s​\(𝒞​𝒢D\)atoms\(\\mathcal\{CG\}\_\{D\}\),*\(ii\)*any atom ofa​t​o​m​s​\(𝒞​𝒢D\)atoms\(\\mathcal\{CG\}\_\{D\}\)is the label of some node of𝒞​𝒢D\\mathcal\{CG\}\_\{D\}and*\(iii\)*for any null⊥\\bot, the set of nodes that contain⊥\\botforms a connected \(rooted\) subgraph of𝒞​𝒢D\\mathcal\{CG\}\_\{D\}; for any constantcc, the set of nodes*in a tree that contains*ccform a connected \(rooted\) subgraph of𝒞​𝒢D\\mathcal\{CG\}\_\{D\}\. Next, the item*\(iii\)*is called the*connectivity property*of the chase graph\.

The next proposition relates paths in a chase graph, which correspond to \(undirected\) paths of atoms, and paths in the chase, which are \(directed\) paths of terms\. Informally, it says that, given any atomsαx\\alpha\_\{x\}andαy\\alpha\_\{y\}in the same tree of the chase graph, any path of terms in the chase, from a termxxoccurring inαx\\alpha\_\{x\}to a termyyoccurring inαy\\alpha\_\{y\}, goes through any atom along the unique shortest path fromαx\\alpha\_\{x\}toαy\\alpha\_\{y\}in the chase graph\.

###### Proposition 10 \(Path property\)\.

Let𝒞​𝒢D\\mathcal\{CG\}\_\{D\}be a chase graph associated with a derivationDD\. Letνx\\nu\_\{x\}andνy\\nu\_\{y\}be nodes in the same tree of𝒞​𝒢D\\mathcal\{CG\}\_\{D\}, such thatνx\\nu\_\{x\}contains termxxandνy\\nu\_\{y\}contains termyy\. Letν\\nube any node on the unique shortest \(undirected\) path fromνx\\nu\_\{x\}toνy\\nu\_\{y\}in𝒞​𝒢D\\mathcal\{CG\}\_\{D\}\. Then, any path \(of terms\)ppfromxxtoyyina​t​o​m​s​\(𝒞​𝒢D\)atoms\(\\mathcal\{CG\}\_\{D\}\)can be writtenp=p1\.p2p=p\_\{1\}\.p\_\{2\}, wherep1p\_\{1\}andp2p\_\{2\}are paths \(of terms\) in𝖼𝗁𝖺𝗌𝖾​\(I,ℛ\)\\mathsf\{chase\}\(I,\\mathcal\{R\}\), respectively fromxxtozzand fromzztoyy, such thatν\\nucontainszz\.

###### Proof\.

Letp=t0​r1​t1​…​rn​tnp=t\_\{0\}r\_\{1\}t\_\{1\}\\ldots r\_\{n\}t\_\{n\}such thatt0=xt\_\{0\}=xandtn=yt\_\{n\}=y\. Ifν\\nucontainsxx\(resp\.yy\), the statement trivially holds: we takep1p\_\{1\}empty andp2=pp\_\{2\}=p\(resp\.p1=pp\_\{1\}=pandp2p\_\{2\}empty\)\. Otherwise \(we know thatν≠νx\\nu\\neq\\nu\_\{x\}andν≠νy\\nu\\neq\\nu\_\{y\}\), removingν\\nufrom𝒞​𝒢D\\mathcal\{CG\}\_\{D\}splits the graph into several connected components, including one, that we callCxC\_\{x\}\(resp\.CyC\_\{y\}\) containingνx\\nu\_\{x\}\(resp\.νy\\nu\_\{y\}\)\. Let us consider the smallestiiinppsuch thattit\_\{i\}occurs in a connected componentC≠CxC\\neq C\_\{x\}\. There must be such anii, sincetn=yt\_\{n\}=yoccurs inCyC\_\{y\}\. We show thattit\_\{i\}occurs inν\\nu, i\.e\.,tit\_\{i\}is a termzzas required by the property\. Sinceri​\(ti−1,ti\)∈a​t​o​m​s​\(𝒞​𝒢D\)r\_\{i\}\(t\_\{i\-1\},t\_\{i\}\)\\in atoms\(\\mathcal\{CG\}\_\{D\}\), there is a nodeν′\\nu^\{\\prime\}of𝒞​𝒢D\\mathcal\{CG\}\_\{D\}labeled byri​\(ti−1,ti\)r\_\{i\}\(t\_\{i\-1\},t\_\{i\}\)\. By hypothesis ontit\_\{i\},ti−1t\_\{i\-1\}does not appear outsideCx∪\{ν\}C\_\{x\}\\cup\\\{\\nu\\\}, henceν′\\nu^\{\\prime\}belongs toCx∪\{ν\}C\_\{x\}\\cup\\\{\\nu\\\}\. Eitherν′=ν\\nu^\{\\prime\}=\\nu\(andtit\_\{i\}appears inν\\nu\), orν′\\nu^\{\\prime\}belongs toCxC\_\{x\}: in this case,tit\_\{i\}appears both inCxC\_\{x\}and inC≠CxC\\neq C\_\{x\}, hence, by the connectivity property ontit\_\{i\},tit\_\{i\}must also appear inν\\nu, which concludes the proof\. ∎

Example[9](https://arxiv.org/html/2607.22636#Thmtheorem9a)\(continued\)\.See also Figure[4](https://arxiv.org/html/2607.22636#S5.F4)\(left\)\. Letp=a1​s​t0​r​z0​r​t1​s−​a2p=a\_\{1\}~s~t\_\{0\}~r~z\_\{0\}~r~t\_\{1\}~s^\{\-\}~a\_\{2\}be a path of terms, which occurs in the chase\. We can see thatpphas no direct connection with the structure of the chase graph pictured in Figure[4](https://arxiv.org/html/2607.22636#S5.F4)\(left\)\. Now, take, e\.g\., the nodesνa1\\nu\_\{a\_\{1\}\}labeled byb′​\(a1,z0,t0\)b^\{\\prime\}\(a\_\{1\},z\_\{0\},t\_\{0\}\)andνa2\\nu\_\{a\_\{2\}\}labeled bys​\(a2,t1\)s\(a\_\{2\},t\_\{1\}\), and consider the shortest path of atoms fromνa1\\nu\_\{a\_\{1\}\}toνa2\\nu\_\{a\_\{2\}\}in the chase graph, which goes throughb​\(a1,a2,z0\)b\(a\_\{1\},a\_\{2\},z\_\{0\}\), andb′′​\(a2,z0,t1\)b^\{\\prime\\prime\}\(a\_\{2\},z\_\{0\},t\_\{1\}\)\. W\.r\.t\. the atomb​\(a1,a2,z0\)b\(a\_\{1\},a\_\{2\},z\_\{0\}\),ppcan be writtenp1\.p2p\_\{1\}\.p\_\{2\}withp1=a1​s​t0​r​z0p\_\{1\}=a\_\{1\}~s~t\_\{0\}~r~z\_\{0\}andp2=z0​r​t1​s−​a2p\_\{2\}=z\_\{0\}~r~t\_\{1\}~s^\{\-\}~a\_\{2\}\. W\.r\.t\. the atomb′′​\(a2,z0,t1\)b^\{\\prime\\prime\}\(a\_\{2\},z\_\{0\},t\_\{1\}\),ppcan be decomposed in the same way, or alsop1′′\.p2′′p^\{\\prime\\prime\}\_\{1\}\.p^\{\\prime\\prime\}\_\{2\}withp1′′=a1​s​t0​r​z0​r​t1p^\{\\prime\\prime\}\_\{1\}=a\_\{1\}~s~t\_\{0\}~r~z\_\{0\}~r~t\_\{1\}andp2′′=t1​s−​a2p^\{\\prime\\prime\}\_\{2\}=t\_\{1\}~s^\{\-\}~a\_\{2\}\.

WhenI,ℛ⊧qI,\\mathcal\{R\}\\models q, there is a finite derivationDDfromIIto an extended instanceInI\_\{n\}with a matchπ\\piofqqinInI\_\{n\}\. We will now build a valid proof scheme fromDDandπ\\pi\. To do so, guided byπ\\pi, we first select some atoms inInI\_\{n\}:*\(i\)*the images of the standard atoms ofqq,*\(ii\)*for each variable ofqqmapped to a null, an atom containing its image, and*\(iii\)*some atoms that allow to check for the existence of required paths\. Note that some terms ofqqmay appear only in path atoms, which justifies*\(ii\)*\. Each of these atoms being the label of a unique node in𝒞​𝒢D\\mathcal\{CG\}\_\{D\}, the selected set of atoms is naturally structured in a forest induced by𝒞​𝒢D\\mathcal\{CG\}\_\{D\}\. From this ‘backbone’, we then build the intended proof scheme by adding all the transitions that appear between eligible pairs of atoms\.

Next, we use the notationν1≺ν2\\nu\_\{1\}\\prec\\nu\_\{2\}to denote thatν1\\nu\_\{1\}is a*strict ancestor*ofν2\\nu\_\{2\}in the considered chase graph\. Also, forν\\nuandν′\\nu^\{\\prime\}in the same tree of a chase graph,𝗀𝗅𝖻​\(ν,ν′\)\\mathsf\{glb\}\{\(\\nu,\\nu^\{\\prime\}\)\}denotes their*greatest lower bound*\(i\.e\., their deepest common ancestor\) in this graph\.

###### Definition 11 \(Backbone of a match\)\.

LetDDbe anℛ\\mathcal\{R\}\-derivation fromIItoInI\_\{n\}, such thatIn⊧qI\_\{n\}\\models q\. Letπ\\pibe a match ofqqinInI\_\{n\}\. A*backbone*ofπ\\piis a directed forest\(V,E\)\(V,E\)defined as follows:

- •VVis a subset ofInI\_\{n\}restricted to the following atoms: - –for each standard atomα∈q\\alpha\\in q, the atomπ​\(α\)\\pi\(\\alpha\); - –for each variablexxofqqsuch thatπ​\(x\)\\pi\(x\)is a null, someαx∈In\\alpha\_\{x\}\\in I\_\{n\}that containsπ​\(x\)\\pi\(x\); - –for each atomα∈V\\alpha\\in V, the atomℓ​\(νr\)\\ell\(\\nu\_\{r\}\), whereνr\\nu\_\{r\}is the root of the tree of𝒞​𝒢D\\mathcal\{CG\}\_\{D\}in which the nodeν\\nuwithℓ​\(ν\)=α\\ell\(\\nu\)=\\alphaoccurs; - –for each pair\(α1,α2\)∈V×V\(\\alpha\_\{1\},\\alpha\_\{2\}\)\\in V\\times Vsuch thatα1=ℓ​\(ν1\),α2=ℓ​\(ν2\)\\alpha\_\{1\}=\\ell\(\\nu\_\{1\}\),\\alpha\_\{2\}=\\ell\(\\nu\_\{2\}\), andν1\\nu\_\{1\},ν2\\nu\_\{2\}belong to the same tree of𝒞​𝒢D\\mathcal\{CG\}\_\{D\}, the atomℓ​\(ν\)\\ell\(\\nu\), whereν=𝗀𝗅𝖻​\(ν1,ν2\)\\nu=\\mathsf\{glb\}\{\(\\nu\_\{1\},\\nu\_\{2\}\)\}in𝒞​𝒢D\\mathcal\{CG\}\_\{D\};
- •E⊆V×VE\\subseteq V\\times Vis the set of edges induced by𝒞​𝒢D\\mathcal\{CG\}\_\{D\}, i\.e\., it contains\(α1,α2\)\(\\alpha\_\{1\},\\alpha\_\{2\}\)if and only ifα1=ℓ​\(ν1\)\\alpha\_\{1\}=\\ell\(\\nu\_\{1\}\),α2=ℓ​\(ν2\)\\alpha\_\{2\}=\\ell\(\\nu\_\{2\}\),ν1≺ν2\\nu\_\{1\}\\prec\\nu\_\{2\}in𝒞​𝒢D\\mathcal\{CG\}\_\{D\}, and there is no nodeν3\\nu\_\{3\}withν1≺ν3≺ν2\\nu\_\{1\}\\prec\\nu\_\{3\}\\prec\\nu\_\{2\}andℓ​\(ν3\)∈V\\ell\(\\nu\_\{3\}\)\\in V\.

Example[9](https://arxiv.org/html/2607.22636#Thmtheorem9a)\(continued\)\.Consider again the matchπ\\piofqqin the instanceI′I^\{\\prime\}\(Figure[4](https://arxiv.org/html/2607.22636#S5.F4), left\) defined by:\{x1→a1,x2→a2,x3→t0,x4→t1\}\\\{x\_\{1\}\\rightarrow a\_\{1\},x\_\{2\}\\rightarrow a\_\{2\},x\_\{3\}\\rightarrow t\_\{0\},x\_\{4\}\\rightarrow t\_\{1\}\\\}\. A backbone ofπ\\piis shown on the right of Figure[4](https://arxiv.org/html/2607.22636#S5.F4):h​\(a1,a2\)h\(a\_\{1\},a\_\{2\}\)andm​\(a2\)m\(a\_\{2\}\)belong to the backbone because they each are the image of a standard atom ofqq;s​\(a1,t0\)s\(a\_\{1\},t\_\{0\}\)andr​\(z,t1\)r\(z,t\_\{1\}\)are selected because they contain the nullsπ​\(x3\)=t0\\pi\(x\_\{3\}\)=t\_\{0\}andπ​\(x4\)=t1\\pi\(x\_\{4\}\)=t\_\{1\}\(note thatx3x\_\{3\}andx4x\_\{4\}only occur in path atoms ofqq\);b​\(a1,a2,z0\)b\(a\_\{1\},a\_\{2\},z\_\{0\}\)is selected because it is the deepest common ancestor ofs​\(a1,t0\)s\(a\_\{1\},t\_\{0\}\)andr​\(z0,t1\)r\(z\_\{0\},t\_\{1\}\)\. Then, to define the associated proof scheme induced byπ\\pi, we will enrich that backbone by all the possible transitions \(which is not shown on the figure\)\.

###### Definition 12 \(Proof scheme induced by a match\)\.

Letπ\\pibe a match ofqqin someInI\_\{n\}obtained by anℛ\\mathcal\{R\}\-derivation fromII\. A proof schemeℙπ\\mathbb\{P\}\_\{\\pi\}induced byπ\\piis\(ℱ=\(V,E\),𝒯\)\(\\mathcal\{F\}=\(V,E\),\\mathcal\{T\}\), where:

- •ℱ\\mathcal\{F\}is a backbone ofπ\\pi;
- •𝒯\\mathcal\{T\}is the set of all pairs\(t,\(α1,α2\)\)\(t,\(\\alpha\_\{1\},\\alpha\_\{2\}\)\)with\(α1,α2\)∈V×V\(\\alpha\_\{1\},\\alpha\_\{2\}\)\\in V\\times Vandt∈𝒯q,In​\(α1,α2\)t\\in\\mathcal\{T\}\_\{q,I\_\{n\}\}\(\\alpha\_\{1\},\\alpha\_\{2\}\), that are legal in a proof scheme, i\.e\.,α1=α2\\alpha\_\{1\}=\\alpha\_\{2\},\(α1,α2\)∈E\(\\alpha\_\{1\},\\alpha\_\{2\}\)\\in E,\(α2,α1\)∈E\(\\alpha\_\{2\},\\alpha\_\{1\}\)\\in E, or bothα1\\alpha\_\{1\}andα2\\alpha\_\{2\}are roots\.

Example[9](https://arxiv.org/html/2607.22636#Thmtheorem9a)\(continued\)\.For instance, let us assume an automaton with a single statesrs\_\{r\}to encoder∗r^\{\*\}\. The transition\(\(1,sr,2,sr\),\(r​\(z0,t1\),r​\(z0,t1\)\)\)\(\(1,s\_\{r\},2,s\_\{r\}\),\(r\(z\_\{0\},t\_\{1\}\),r\(z\_\{0\},t\_\{1\}\)\)\)is inℙπ\\mathbb\{P\}\_\{\\pi\}because*\(i\)*r​\(z0,t1\)=r​\(z0,t1\)r\(z\_\{0\},t\_\{1\}\)=r\(z\_\{0\},t\_\{1\}\)and*\(ii\)*the atomr​\(z0,t1\)r\(z\_\{0\},t\_\{1\}\)belongs to𝖼𝗁𝖺𝗌𝖾​\(I,ℛ\)\\mathsf\{chase\}\(I,\\mathcal\{R\}\)\. It also holds that\(\(2,sr,3,sr\),\(s​\(a1,t0\),b​\(a1,a2,z0\)\)\)∈𝒯\(\(2,s\_\{r\},3,s\_\{r\}\),\(s\(a\_\{1\},t\_\{0\}\),b\(a\_\{1\},a\_\{2\},z\_\{0\}\)\)\)\\in\\mathcal\{T\}is inℙπ\\mathbb\{P\}\_\{\\pi\}, because*\(i\)*s​\(a1,t0\)s\(a\_\{1\},t\_\{0\}\)is a child ofb​\(a1,a2,z0\)b\(a\_\{1\},a\_\{2\},z\_\{0\}\)and*\(ii\)*the atomr​\(t0,z0\)r\(t\_\{0\},z\_\{0\}\)belongs to𝖼𝗁𝖺𝗌𝖾​\(I,ℛ\)\\mathsf\{chase\}\(I,\\mathcal\{R\}\)\.

The transition\(\(1,sr,2,sr\),\(r​\(t0,z0\),r​\(z0,t1\)\)\)\(\(1,s\_\{r\},2,s\_\{r\}\),\(r\(t\_\{0\},z\_\{0\}\),r\(z\_\{0\},t\_\{1\}\)\)\)does not belong toℙπ\\mathbb\{P\}\_\{\\pi\}, becauser​\(t0,z0\)r\(t\_\{0\},z\_\{0\}\)is neither equal to nor a parent or child ofr​\(z0,t1\)r\(z\_\{0\},t\_\{1\}\), but it belongs to the saturation ofℙπ\\mathbb\{P\}\_\{\\pi\}because of the above two transitions\.

Let us note that the proof scheme induced by a match ofqqhas a size polynomial inqq\. We now prove that it is indeed a proof scheme and that it is valid\.

###### Proposition 13\.

Letπ\\pibe a match ofqqinInI\_\{n\}obtained by anℛ\\mathcal\{R\}\-derivationDDfromII\. Any proof scheme induced byπ\\piis valid\.

###### Proof\.

Letℙπ=\(ℱ,𝒯\)\\mathbb\{P\}\_\{\\pi\}=\(\\mathcal\{F\},\\mathcal\{T\}\)be a proof scheme induced byπ\\pi\. We first prove thatℙπ\\mathbb\{P\}\_\{\\pi\}is indeed a proof scheme\. Numbers refer to items of Definition[2](https://arxiv.org/html/2607.22636#Thmtheorem2c)\. \([1](https://arxiv.org/html/2607.22636#S5.I1.i1)\): since the chase graph𝒞​𝒢D\\mathcal\{CG\}\_\{D\}is a directed forest,ℱ\\mathcal\{F\}is a directed forest; \([2](https://arxiv.org/html/2607.22636#S5.I1.i2)\):VVis by definition a set of atoms; \([3](https://arxiv.org/html/2607.22636#S5.I1.i3)\): letα1\\alpha\_\{1\}andα2\\alpha\_\{2\}be two atoms ofℱ\\mathcal\{F\}containing⊥\\bot\. By the connectivity property of𝒞​𝒢D\\mathcal\{CG\}\_\{D\},α1\\alpha\_\{1\}andα2\\alpha\_\{2\}are labels of connected nodes in𝒞​𝒢D\\mathcal\{CG\}\_\{D\}\. Letν1\\nu\_\{1\}andν2\\nu\_\{2\}be these nodes and letν3=𝗀𝗅𝖻​\(ν1,ν2\)\\nu\_\{3\}=\\mathsf\{glb\}\{\(\\nu\_\{1\},\\nu\_\{2\}\)\}: by construction,ℓ​\(ν3\)\\ell\(\\nu\_\{3\}\)belongs toℱ\\mathcal\{F\}and is an ancestor ofν1\\nu\_\{1\}andν2\\nu\_\{2\}inℱ\\mathcal\{F\}\. Hence,α1\\alpha\_\{1\}andα2\\alpha\_\{2\}are connected inℱ\\mathcal\{F\}\. \([4](https://arxiv.org/html/2607.22636#S5.I1.i4)\) and \([5](https://arxiv.org/html/2607.22636#S5.I1.i5)\): by construction, all the transitions in the induced proof scheme are of the correct syntactic shape\.

We now show that the identity is a witnessing embedding ofℙπ\\mathbb\{P\}\_\{\\pi\}in𝒞​𝒢D\\mathcal\{CG\}\_\{D\}, proving its validity\. Numbers refer to items in Definition[5](https://arxiv.org/html/2607.22636#Thmtheorem5b)\. \([1](https://arxiv.org/html/2607.22636#S5.I3.i1)\) By construction ofVV, all the root atoms are labels of roots of𝒞​𝒢D\\mathcal\{CG\}\_\{D\}, hence they belong toII\. \([2](https://arxiv.org/html/2607.22636#S5.I3.i2)\) By construction,V⊆InV\\subseteq I\_\{n\}, andψ\\psiis the identity, soψ​\(α\)\\psi\(\\alpha\)belongs toInI\_\{n\}for allα∈V\\alpha\\in V\. \([3](https://arxiv.org/html/2607.22636#S5.I3.i3)\) By construction, for each edge\(α1,α2\)\(\\alpha\_\{1\},\\alpha\_\{2\}\)inEE,ℓ−1​\(α1\)≺ℓ−1​\(α2\)\\ell^\{\-1\}\(\\alpha\_\{1\}\)\\prec\\ell^\{\-1\}\(\\alpha\_\{2\}\)in𝒞​𝒢D\\mathcal\{CG\}\_\{D\}, hence there is a derivation as required\. \([4](https://arxiv.org/html/2607.22636#S5.I3.i4)\) By construction, each\(t,\(α1,α2\)\)∈𝒯\(t,\(\\alpha\_\{1\},\\alpha\_\{2\}\)\)\\in\\mathcal\{T\}belongs to𝒯q,In​\(α1,α2\)\\mathcal\{T\}\_\{q,I\_\{n\}\}\(\\alpha\_\{1\},\\alpha\_\{2\}\), hence to𝒯q,In​\(ψ​\(α1\),ψ​\(α2\)\)\\mathcal\{T\}\_\{q,I\_\{n\}\}\(\\psi\(\\alpha\_\{1\}\),\\psi\(\\alpha\_\{2\}\)\)becauseψ\\psiis the identity\. We conclude thatℙ\\mathbb\{P\}is a valid proof scheme w\.r\.t\(I,ℛ,q\(I,\\mathcal\{R\},q\)\. ∎

We now show that there is indeed a match ofqqin the \(valid\) proof scheme induced by a match ofqqin the chase\.

###### Proposition 14\.

Letℙπ\\mathbb\{P\}\_\{\\pi\}be a proof scheme induced by a matchπ\\piofqqinInI\_\{n\}, whereInI\_\{n\}is the result of some derivationDDfromII\. There exists a match ofqqinℙπ\\mathbb\{P\}\_\{\\pi\}\.

###### Proof\.

We show thatπ\\piis a match ofqqinℙπ\\mathbb\{P\}\_\{\\pi\}=\(ℱ=\(V,E\),𝒯\)\(\\mathcal\{F\}=\(V,E\),\\mathcal\{T\}\)\.

- •By definition ofℙπ\\mathbb\{P\}\_\{\\pi\}, ifα∈q\\alpha\\in qis a standard atom, thenπ​\(α\)∈V\\pi\(\\alpha\)\\in V\.
- •Letα=Λ​\(x,y\)\\alpha=\\Lambda\(x,y\)be a path atom\. Asπ\\piis a match ofqq, there is a path inInI\_\{n\}fromπ​\(x\)\\pi\(x\)toπ​\(y\)\\pi\(y\), whose label is recognized by the automaton associated withΛ\\Lambda\. By definition ofVV\(Definition[11](https://arxiv.org/html/2607.22636#Thmtheorem11a)\), there existαx\\alpha\_\{x\}andαy\\alpha\_\{y\}inVVcontainingπx\\pi\_\{x\}andπy\\pi\_\{y\}\. Letνx\\nu\_\{x\}andνy\\nu\_\{y\}s\.t\.ℓ​\(νx\)=αx\\ell\(\\nu\_\{x\}\)=\\alpha\_\{x\}andℓ​\(νy\)=αy\\ell\(\\nu\_\{y\}\)=\\alpha\_\{y\}\. We show by induction that whenever there is a path fromαx​\[i\]\\alpha\_\{x\}\[i\]toαy​\[j\]\\alpha\_\{y\}\[j\]inInI\_\{n\}that moves the automaton fromsxs\_\{x\}tosys\_\{y\}, then\(\(ix,sx,iy,sy\),\(αx,αy\)\)\(\(i\_\{x\},s\_\{x\},i\_\{y\},s\_\{y\}\),\(\\alpha\_\{x\},\\alpha\_\{y\}\)\)is in the saturation ofℙ\\mathbb\{P\}\. We study the possible cases regarding the relationship betweenαx\\alpha\_\{x\}andαy\\alpha\_\{y\}inℙπ\\mathbb\{P\}\_\{\\pi\}: - –ifαx=αy\\alpha\_\{x\}=\\alpha\_\{y\}, orαx\\alpha\_\{x\}is the parent ofαy\\alpha\_\{y\}\(or vice\-versa\): the property holds by definition of the proof scheme induced by a match \(Definition[12](https://arxiv.org/html/2607.22636#Thmtheorem12a)\); - –ifαx\\alpha\_\{x\}is a strict ancestor ofαy\\alpha\_\{y\}, but not a parent: we show the result by induction on the length of the path fromαx\\alpha\_\{x\}toαy\\alpha\_\{y\}\. The base case has been treated in the previous item\. Letα\\alphabe the child ofαx\\alpha\_\{x\}that is an ancestor ofαy\\alpha\_\{y\}\. Letν\\nube the node of𝒞​𝒢D\\mathcal\{CG\}\_\{D\}s\.t\.ℓ​\(ν\)=α\\ell\(\\nu\)=\\alpha\. By the path property of𝒞​𝒢D\\mathcal\{CG\}\_\{D\}, any path that goes fromxxtoyymust go through somez∈𝗍𝖾𝗋𝗆𝗌​\(α\)z\\in\\mathsf\{terms\}\{\(\\alpha\)\}occurring at some positionizi\_\{z\}\. Letp=p1\.p2p=p\_\{1\}\.p\_\{2\}, such thatp1p\_\{1\}goes fromxxtozzandp2p\_\{2\}goes fromzztoyy\. Letszs\_\{z\}be the state of𝔸\\mathbb\{A\}after readingp1p\_\{1\}starting fromsxs\_\{x\}\. By induction assumption,\(\(ix,sx,iz,sz\),\(αx,α\)\)\(\(i\_\{x\},s\_\{x\},i\_\{z\},s\_\{z\}\),\(\\alpha\_\{x\},\\alpha\)\)and\(\(iz,sz,iy,sy\),\(α,αy\)\)\(\(i\_\{z\},s\_\{z\},i\_\{y\},s\_\{y\}\),\(\\alpha,\\alpha\_\{y\}\)\)belong to the saturation ofℙπ\\mathbb\{P\}\_\{\\pi\}\. Hence,\(\(ix,sx,iy,sy\),\(αx,αy\)\)\(\(i\_\{x\},s\_\{x\},i\_\{y\},s\_\{y\}\),\(\\alpha\_\{x\},\\alpha\_\{y\}\)\)is in the saturation ofℙ\\mathbb\{P\}; - –αx\\alpha\_\{x\}andαy\\alpha\_\{y\}are not in an ancestor relationship but are in the same tree\. By the path property of𝒞​𝒢D\\mathcal\{CG\}\_\{D\}, any path fromπ​\(x\)\\pi\(x\)toπ​\(y\)\\pi\(y\)must go through a termzzof𝗀𝗅𝖻​\(νx,νy\)\\mathsf\{glb\}\{\(\\nu\_\{x\},\\nu\_\{y\}\)\}, whose label we denote byα\\alpha\. Letp=p1\.p2p=p\_\{1\}\.p\_\{2\}such thatp1p\_\{1\}is a path fromxxtozzandp2p\_\{2\}is a path fromzztoyy\. Letszs\_\{z\}be the state in which𝔸\\mathbb\{A\}is after readingp1p\_\{1\}starting fromsxs\_\{x\}\. Assumingz=α​\[iz\]z=\\alpha\[i\_\{z\}\], by induction assumption,\(\(ix,sx,iz,sz\),\(αx,α\)\)\(\(i\_\{x\},s\_\{x\},i\_\{z\},s\_\{z\}\),\(\\alpha\_\{x\},\\alpha\)\)and\(\(iz,sz,iy,sy\),\(α,αy\)\)\(\(i\_\{z\},s\_\{z\},i\_\{y\},s\_\{y\}\),\(\\alpha,\\alpha\_\{y\}\)\)belong to the saturation ofℙπ\\mathbb\{P\}\_\{\\pi\}\. Hence,\(\(ix,sx,iy,sy\),\(αx,αy\)\)\(\(i\_\{x\},s\_\{x\},i\_\{y\},s\_\{y\}\),\(\\alpha\_\{x\},\\alpha\_\{y\}\)\)is in the saturation ofℙπ\\mathbb\{P\}\_\{\\pi\}; - –αx\\alpha\_\{x\}andαy\\alpha\_\{y\}are not in the same tree: letαRx\\alpha\_\{R\_\{x\}\}\(resp\.αRy\\alpha\_\{R\_\{y\}\}\) be the root of the tree containingαx\\alpha\_\{x\}\(resp\.αy\\alpha\_\{y\}\)\. By the connectivity property of𝒞​𝒢D\\mathcal\{CG\}\_\{D\}, any path fromxxtoyymust go throughαRx​\[itx\]\\alpha\_\{R\_\{x\}\}\[i\_\{t\_\{x\}\}\]for someitxi\_\{t\_\{x\}\}\(resp\.αRy​\[ity\]\\alpha\_\{R\_\{y\}\}\[i\_\{t\_\{y\}\}\]for someityi\_\{t\_\{y\}\}\)\. By the preceding cases, it holds that\(\(ix,sx,itx,stx\),\(αx,αRx\)\)\(\(i\_\{x\},s\_\{x\},i\_\{t\_\{x\}\},s\_\{t\_\{x\}\}\),\(\\alpha\_\{x\},\\alpha\_\{R\_\{x\}\}\)\)and\(\(ity,sty,iy,sy\),\(αRy,αy\)\)\(\(i\_\{t\_\{y\}\},s\_\{t\_\{y\}\},i\_\{y\},s\_\{y\}\),\(\\alpha\_\{R\_\{y\}\},\\alpha\_\{y\}\)\)belong to the saturation ofℙπ\\mathbb\{P\}\_\{\\pi\}\. By definition ofℙπ\\mathbb\{P\}\_\{\\pi\}, becauseαRx\\alpha\_\{R\_\{x\}\}andαRy\\alpha\_\{R\_\{y\}\}are roots ofℙπ\\mathbb\{P\}\_\{\\pi\}, it holds that\(\(itx,stx,ity,sty\),\(αRx,αRy\)\)\(\(i\_\{t\_\{x\}\},s\_\{t\_\{x\}\},i\_\{t\_\{y\}\},s\_\{t\_\{y\}\}\),\(\\alpha\_\{R\_\{x\}\},\\alpha\_\{R\_\{y\}\}\)\)belongs toℙπ\\mathbb\{P\}\_\{\\pi\}\. Hence, by definition of the saturation ofℙπ\\mathbb\{P\}\_\{\\pi\},\(\(ix,sx,iy,sy\),\(αx,αy\)\)\(\(i\_\{x\},s\_\{x\},i\_\{y\},s\_\{y\}\),\(\\alpha\_\{x\},\\alpha\_\{y\}\)\)also belongs to the saturation ofℙπ\\mathbb\{P\}\_\{\\pi\}, which concludes the proof\.∎

### 5\.3\.Complexity Analysis

By Proposition[7](https://arxiv.org/html/2607.22636#Thmtheorem7a), we know thatqqis entailed byIIandℛ\\mathcal\{R\}if and only if there exists a valid proof schemeℙ\\mathbb\{P\}of polynomial size inqqsuch that there is a match ofqqinℙ\\mathbb\{P\}\. We now investigate how to check the validity of a proof scheme\. To do so, we will consider a variant of the previous chase graph, in which we keep track of all possible ways of producing atoms\. We call it the chase graph associated with\(I,ℛ\)\(I,\\mathcal\{R\}\), because its set of atoms is homomorphically equivalent to𝖼𝗁𝖺𝗌𝖾​\(I,ℛ\)\\mathsf\{chase\}\(I,\\mathcal\{R\}\)\.

###### Definition 15 \(Chase graph associated with\(I,ℛ\)\(I,\\mathcal\{R\}\)\)\.

LetIIbe an instance andℛ\\mathcal\{R\}be a set of linear rules\. The*chase graph*associated with\(I,ℛ\)\(I,\\mathcal\{R\}\), denoted by𝒞​𝒢​\(I,ℛ\)\\mathcal\{CG\}\(I,\\mathcal\{R\}\), is the node\-labeled directed graph defined as follows \(we useℓ\\ellfor the labeling function\):

- •The restriction ofℓ\\ellto the root nodes of𝒞​𝒢​\(I,ℛ\)\\mathcal\{CG\}\(I,\\mathcal\{R\}\)defines a bijection between the root nodes andII\.
- •For every nodeν\\nu, the children ofν\\nuare in bijection with the finite set of triggers\(ρi,πi\)\(\\rho\_\{i\},\\pi\_\{i\}\)onℓ​\(ν\)\\ell\(\\nu\), and the labels of the children are precisely the atomsαi\\alpha\_\{i\}resulting from the application of these triggers toℓ​\(ν\)\\ell\(\\nu\)\(using globally unique fresh nulls\)\.
- •Only the nodes and edges required by the preceding two items are present in𝒞​𝒢​\(I,ℛ\)\\mathcal\{CG\}\(I,\\mathcal\{R\}\)\.

Importantly,𝒞​𝒢​\(I,ℛ\)\\mathcal\{CG\}\(I,\\mathcal\{R\}\)still fulfils the connectivity property \(for the same reasons as the chase graph associated with derivations\)\. The following lemma shows how transitions between an atom in the chase graph and an ancestor atom can be computed using the transitions relating its parent atom to the same ancestor, together with the transitions that can be obtained by considering the atom in isolation\.

###### Lemma 16\.

Letν1\\nu\_\{1\},ν2\\nu\_\{2\}andν3\\nu\_\{3\}be nodes in𝒞​𝒢​\(I,ℛ\)\\mathcal\{CG\}\(I,\\mathcal\{R\}\)such thatν1\\nu\_\{1\}is a \(strict\) ancestor ofν2\\nu\_\{2\}, andν3\\nu\_\{3\}is a successor ofν2\\nu\_\{2\}\. Letαi=ℓ​\(νi\)\\alpha\_\{i\}=\\ell\(\\nu\_\{i\}\)for1≤i≤31\\leq i\\leq 3\. Then:

1. \(1\)\(i1,s1,i3,s3\)∈𝒯q,𝖼𝗁𝖺𝗌𝖾​\(I,ℛ\)​\(α1,α3\)\(i\_\{1\},s\_\{1\},i\_\{3\},s\_\{3\}\)\\in\\mathcal\{T\}\_\{q,\\mathsf\{chase\}\(I,\\mathcal\{R\}\)\}\(\\alpha\_\{1\},\\alpha\_\{3\}\)iff there existi2,s2,i2′i\_\{2\},s\_\{2\},i^\{\\prime\}\_\{2\}such that\(i1,s1,i2,s2\)∈𝒯q,𝖼𝗁𝖺𝗌𝖾​\(I,ℛ\)​\(α1,α2\)\(i\_\{1\},s\_\{1\},i\_\{2\},s\_\{2\}\)\\in\\mathcal\{T\}\_\{q,\\mathsf\{chase\}\(I,\\mathcal\{R\}\)\}\(\\alpha\_\{1\},\\alpha\_\{2\}\),\(i2′,s2,i3,s3\)∈𝒯q,𝖼𝗁𝖺𝗌𝖾​\(\{α3\},ℛ\)​\(α3,α3\)\(i\_\{2\}^\{\\prime\},s\_\{2\},i\_\{3\},s\_\{3\}\)\\in\\mathcal\{T\}\_\{q,\\mathsf\{chase\}\(\\\{\\alpha\_\{3\}\\\},\\mathcal\{R\}\)\}\(\\alpha\_\{3\},\\alpha\_\{3\}\)andα2​\[i2\]=α3​\[i2′\];\\alpha\_\{2\}\[i\_\{2\}\]=\\alpha\_\{3\}\[i\_\{2\}^\{\\prime\}\];
2. \(2\)\(i1,s1,i3,s3\)∈𝒯q,𝖼𝗁𝖺𝗌𝖾​\(I,ℛ\)​\(α3,α1\)\(i\_\{1\},s\_\{1\},i\_\{3\},s\_\{3\}\)\\in\\mathcal\{T\}\_\{q,\\mathsf\{chase\}\(I,\\mathcal\{R\}\)\}\(\\alpha\_\{3\},\\alpha\_\{1\}\)iff there existi2,s2,i2′i\_\{2\},s\_\{2\},i^\{\\prime\}\_\{2\}such that\(i1,s1,i2′,s2\)∈𝒯q,𝖼𝗁𝖺𝗌𝖾​\(\{α3\},ℛ\)​\(α3,α3\)\(i\_\{1\},s\_\{1\},i\_\{2\}^\{\\prime\},s\_\{2\}\)\\in\\mathcal\{T\}\_\{q,\\mathsf\{chase\}\(\\\{\\alpha\_\{3\}\\\},\\mathcal\{R\}\)\}\(\\alpha\_\{3\},\\alpha\_\{3\}\),\(i2,s2,i3,s3\)∈𝒯q,𝖼𝗁𝖺𝗌𝖾​\(I,ℛ\)​\(α2,α1\)\(i\_\{2\},s\_\{2\},i\_\{3\},s\_\{3\}\)\\in\\mathcal\{T\}\_\{q,\\mathsf\{chase\}\(I,\\mathcal\{R\}\)\}\(\\alpha\_\{2\},\\alpha\_\{1\}\)andα2​\[i2\]=α3​\[i2′\];\\alpha\_\{2\}\[i\_\{2\}\]=\\alpha\_\{3\}\[i\_\{2\}^\{\\prime\}\];
3. \(3\)\(i1,s1,i4,s4\)∈𝒯q,𝖼𝗁𝖺𝗌𝖾​\(I,ℛ\)​\(α3,α3\)\(i\_\{1\},s\_\{1\},i\_\{4\},s\_\{4\}\)\\in\\mathcal\{T\}\_\{q,\\mathsf\{chase\}\(I,\\mathcal\{R\}\)\}\(\\alpha\_\{3\},\\alpha\_\{3\}\)iff there existi2,s2,i2′,i3,s3,i3′i\_\{2\},s\_\{2\},i^\{\\prime\}\_\{2\},i\_\{3\},s\_\{3\},i^\{\\prime\}\_\{3\}such that\(i1,s1,i2′,s2\)∈𝒯q,𝖼𝗁𝖺𝗌𝖾​\(\{α3\},ℛ\)​\(α3,α3\)\(i\_\{1\},s\_\{1\},i\_\{2\}^\{\\prime\},s\_\{2\}\)\\in\\mathcal\{T\}\_\{q,\\mathsf\{chase\}\(\\\{\\alpha\_\{3\}\\\},\\mathcal\{R\}\)\}\(\\alpha\_\{3\},\\alpha\_\{3\}\),\(i2,s2,i3,s3\)∈𝒯q,𝖼𝗁𝖺𝗌𝖾​\(I,ℛ\)​\(α2,α2\)\(i\_\{2\},s\_\{2\},i\_\{3\},s\_\{3\}\)\\in\\mathcal\{T\}\_\{q,\\mathsf\{chase\}\(I,\\mathcal\{R\}\)\}\(\\alpha\_\{2\},\\alpha\_\{2\}\),\(i3′,s3,i4,s4\)∈𝒯q,𝖼𝗁𝖺𝗌𝖾​\(\{α3\},ℛ\)​\(α3,α3\)\(i\_\{3\}^\{\\prime\},s\_\{3\},i\_\{4\},s\_\{4\}\)\\in\\mathcal\{T\}\_\{q,\\mathsf\{chase\}\(\\\{\\alpha\_\{3\}\\\},\\mathcal\{R\}\)\}\(\\alpha\_\{3\},\\alpha\_\{3\}\)andα3​\[i2′\]=α2​\[i2\]\\alpha\_\{3\}\[i\_\{2\}^\{\\prime\}\]=\\alpha\_\{2\}\[i\_\{2\}\]andα3​\[i3′\]=α2​\[i3\]\.\\alpha\_\{3\}\[i\_\{3\}^\{\\prime\}\]=\\alpha\_\{2\}\[i\_\{3\}\]\.

###### Proof\.

The ‘if’ direction of the equivalences are trivial, so we concentrate on proving the ‘only if’ directions\.

For the first statement, suppose that\(i1,s1,i3,s3\)∈𝒯q,𝖼𝗁𝖺𝗌𝖾​\(I,ℛ\)​\(α1,α3\)\(i\_\{1\},s\_\{1\},i\_\{3\},s\_\{3\}\)\\in\\mathcal\{T\}\_\{q,\\mathsf\{chase\}\(I,\\mathcal\{R\}\)\}\(\\alpha\_\{1\},\\alpha\_\{3\}\)\. It follows that there is a pathppin𝖼𝗁𝖺𝗌𝖾​\(I,ℛ\)\\mathsf\{chase\}\(I,\\mathcal\{R\}\)that begins int1=α1​\[i1\]t\_\{1\}=\\alpha\_\{1\}\[i\_\{1\}\], ends int3=α3​\[i3\]t\_\{3\}=\\alpha\_\{3\}\[i\_\{3\}\], and is such thatλ​\(p\)\\lambda\(p\)takes an automaton𝔸\\mathbb\{A\}inqqfrom states1s\_\{1\}to states3s\_\{3\}\. Letp2p\_\{2\}be the longest suffix ofppthat starts int2∈𝗍𝖾𝗋𝗆𝗌​\(α3\)t\_\{2\}\\in\\mathsf\{terms\}\{\(\\alpha\_\{3\}\)\}, and whose label labels a path fromt2t\_\{2\}tot3t\_\{3\}in𝖼𝗁𝖺𝗌𝖾​\(\{α3\},ℛ\)\\mathsf\{chase\}\(\\\{\\alpha\_\{3\}\\\},\\mathcal\{R\}\)\. Note that such a pathp2p\_\{2\}is guaranteed to exist, as we can always choose the empty path fromt3t\_\{3\}tot3t\_\{3\}\. We letp1p\_\{1\}be such thatp=p1\.p2p=p\_\{1\}\.p\_\{2\}, and lets2s\_\{2\}be a state suchλ​\(p1\)\\lambda\(p\_\{1\}\)takes𝔸\\mathbb\{A\}from states1s\_\{1\}tos2s\_\{2\}andλ​\(p2\)\\lambda\(p\_\{2\}\)takes𝔸\\mathbb\{A\}froms2s\_\{2\}tos3s\_\{3\}\. We consider two cases:

- •Case 1:p=p2p=p\_\{2\}\. Thent2=t1t\_\{2\}=t\_\{1\}, andt1t\_\{1\}must belong toα3\\alpha\_\{3\}\. By the connectivity property of𝒞​𝒢​\(I,ℛ\)\\mathcal\{CG\}\(I,\\mathcal\{R\}\),t1t\_\{1\}must also belong toα2\\alpha\_\{2\}\. There are thus indicesi2i\_\{2\}andi2′i\_\{2\}^\{\\prime\}such thatα1​\[i1\]=α2​\[i2\]=α3​\[i2′\]\\alpha\_\{1\}\[i\_\{1\}\]=\\alpha\_\{2\}\[i\_\{2\}\]=\\alpha\_\{3\}\[i\_\{2\}^\{\\prime\}\]\. We thus have\(i1,s1,i2,s1\)∈𝒯q,𝖼𝗁𝖺𝗌𝖾​\(I,ℛ\)​\(α1,α2\)\(i\_\{1\},s\_\{1\},i\_\{2\},s\_\{1\}\)\\in\\mathcal\{T\}\_\{q,\\mathsf\{chase\}\(I,\\mathcal\{R\}\)\}\(\\alpha\_\{1\},\\alpha\_\{2\}\)and\(i2′,s1,i3,s3\)∈𝒯q,𝖼𝗁𝖺𝗌𝖾​\(\{α3\},ℛ\)​\(α3,α3\)\(i\_\{2\}^\{\\prime\},s\_\{1\},i\_\{3\},s\_\{3\}\)\\in\\mathcal\{T\}\_\{q,\\mathsf\{chase\}\(\\\{\\alpha\_\{3\}\\\},\\mathcal\{R\}\)\}\(\\alpha\_\{3\},\\alpha\_\{3\}\)\.
- •Case 2:p≠p2p\\neq p\_\{2\}\. Lett2′t\_\{2\}^\{\\prime\}be the \(unique\) term that precedest2t\_\{2\}inpp\(hence, inp1p\_\{1\}\), and letp2′p\_\{2\}^\{\\prime\}be the length\-one path fromt2′t\_\{2\}^\{\\prime\}tot2t\_\{2\}that immediately precedesp2p\_\{2\}inpp\. Clearly,t2∈𝗍𝖾𝗋𝗆𝗌​\(α3\)t\_\{2\}\\in\\mathsf\{terms\}\{\(\\alpha\_\{3\}\)\}, and we claim thatt2∈𝗍𝖾𝗋𝗆𝗌​\(α2\)t\_\{2\}\\in\\mathsf\{terms\}\{\(\\alpha\_\{2\}\)\}\. To see why, letqqbe the final predicate inp1p\_\{1\}, which means the atomq​\(t2′,t2\)q\(t\_\{2\}^\{\\prime\},t\_\{2\}\)occurs in𝖼𝗁𝖺𝗌𝖾​\(I,ℛ\)\\mathsf\{chase\}\(I,\\mathcal\{R\}\)\. The connectivity property of𝒞​𝒢​\(I,ℛ\)\\mathcal\{CG\}\(I,\\mathcal\{R\}\)implies thatt2t\_\{2\}must occur in all atoms that label a path between any node labeled byq​\(t2′,t2\)q\(t\_\{2\}^\{\\prime\},t\_\{2\}\)andν3\\nu\_\{3\}\. Asp2p\_\{2\}is the longest suffix ofppthat is a path in𝖼𝗁𝖺𝗌𝖾​\(\{α3\},ℛ\)\\mathsf\{chase\}\(\\\{\\alpha\_\{3\}\\\},\\mathcal\{R\}\), we know thatq​\(t2′,t2\)q\(t\_\{2\}^\{\\prime\},t\_\{2\}\)does not appear in a descendant ofν3\\nu\_\{3\}in𝒞​𝒢​\(I,ℛ\)\\mathcal\{CG\}\(I,\\mathcal\{R\}\)\. It follows that such a path necessarily goes throughν2\\nu\_\{2\}, hencet2t\_\{2\}occurs inα2\\alpha\_\{2\}\.

The second statement can be proven analogously\. For the third statement, suppose that\(i1,s1,i4,s4\)∈𝒯q,𝖼𝗁𝖺𝗌𝖾​\(I,ℛ\)​\(α3,α3\)\(i\_\{1\},s\_\{1\},i\_\{4\},s\_\{4\}\)\\in\\mathcal\{T\}\_\{q,\\mathsf\{chase\}\(I,\\mathcal\{R\}\)\}\(\\alpha\_\{3\},\\alpha\_\{3\}\)\. Then there exists a pathppin𝖼𝗁𝖺𝗌𝖾​\(I,ℛ\)\\mathsf\{chase\}\(I,\\mathcal\{R\}\)that begins int3=α3​\[i1\]t\_\{3\}=\\alpha\_\{3\}\[i\_\{1\}\]and ends int3′=α3​\[i4\]t^\{\\prime\}\_\{3\}=\\alpha\_\{3\}\[i\_\{4\}\]\. Ifppis a path in𝖼𝗁𝖺𝗌𝖾​\(\{α3\},ℛ\)\\mathsf\{chase\}\(\\\{\\alpha\_\{3\}\\\},\\mathcal\{R\}\), then the statement trivially holds\. Otherwise, letp1p\_\{1\}\(resp\.p3p\_\{3\}\) be the longest prefix \(resp\. longest suffix\) ofppending \(resp\. starting\) in a termt2t\_\{2\}\(resp\.t2′t^\{\\prime\}\_\{2\}\) ofα3\\alpha\_\{3\}whose label labels a path fromt1t\_\{1\}tot2t\_\{2\}\(resp\. fromt2′t^\{\\prime\}\_\{2\}tot3t\_\{3\}\) in𝖼𝗁𝖺𝗌𝖾​\(\{α3\},ℛ\)\\mathsf\{chase\}\(\\\{\\alpha\_\{3\}\\\},\\mathcal\{R\}\)\. Note that sinceppis not a path in𝖼𝗁𝖺𝗌𝖾​\(\{α3\},ℛ\)\\mathsf\{chase\}\(\\\{\\alpha\_\{3\}\\\},\\mathcal\{R\}\), there exists a non\-empty subpathp2p\_\{2\}such thatp=p1​p2​p3p=p\_\{1\}p\_\{2\}p\_\{3\}\. Arguing as above, we can show thatt2t\_\{2\}andt2′t^\{\\prime\}\_\{2\}must also belong to𝗍𝖾𝗋𝗆𝗌​\(α2\)\\mathsf\{terms\}\{\(\\alpha\_\{2\}\)\}\. Indeed,p2p\_\{2\}starts with an atom that containst2t\_\{2\}but does not appear in𝖼𝗁𝖺𝗌𝖾​\(\{α3\},ℛ\)\\mathsf\{chase\}\(\\\{\\alpha\_\{3\}\\\},\\mathcal\{R\}\), hence by the connectivity property,t2t\_\{2\}must appear inα2\\alpha\_\{2\}, and similarly for the last atom ofp2p\_\{2\}and termt2′t^\{\\prime\}\_\{2\}\. We can thus find indicesi2,i2′,i3,i3′i\_\{2\},i\_\{2\}^\{\\prime\},i\_\{3\},i\_\{3\}^\{\\prime\}such thatt2=ν2​\[i2\]=α3​\[i2′\]t\_\{2\}=\\nu\_\{2\}\[i\_\{2\}\]=\\alpha\_\{3\}\[i\_\{2\}^\{\\prime\}\]andt2′=ν2​\[i3\]=ν3​\[i3′\]t\_\{2\}^\{\\prime\}=\\nu\_\{2\}\[i\_\{3\}\]=\\nu\_\{3\}\[i\_\{3\}^\{\\prime\}\]\. Putting everything together, we obtain the following:\(i1,s1,i2′,s2\)∈𝒯q,𝖼𝗁𝖺𝗌𝖾​\(\{α3\},ℛ\)​\(α3,α3\)\(i\_\{1\},s\_\{1\},i\_\{2\}^\{\\prime\},s\_\{2\}\)\\in\\mathcal\{T\}\_\{q,\\mathsf\{chase\}\(\\\{\\alpha\_\{3\}\\\},\\mathcal\{R\}\)\}\(\\alpha\_\{3\},\\alpha\_\{3\}\),\(i2,s2,i3,s3\)∈𝒯q,𝖼𝗁𝖺𝗌𝖾​\(I,ℛ\)​\(α2,α2\)\(i\_\{2\},s\_\{2\},i\_\{3\},s\_\{3\}\)\\in\\mathcal\{T\}\_\{q,\\mathsf\{chase\}\(I,\\mathcal\{R\}\)\}\(\\alpha\_\{2\},\\alpha\_\{2\}\), and\(i3′,s3,i4,s4\)∈𝒯q,𝖼𝗁𝖺𝗌𝖾​\(\{α3\},ℛ\)​\(α3,α3\)\(i\_\{3\}^\{\\prime\},s\_\{3\},i\_\{4\},s\_\{4\}\)\\in\\mathcal\{T\}\_\{q,\\mathsf\{chase\}\(\\\{\\alpha\_\{3\}\\\},\\mathcal\{R\}\)\}\(\\alpha\_\{3\},\\alpha\_\{3\}\)\. ∎

We now exploit this lemma and existing complexity results on RPQ answering to design a procedure for checking validity of a proof scheme, with the following complexity:

###### Proposition17\.

Checking the validity of a proof scheme can be done in single exponential time, in polynomial space if predicate arity is bounded, and in NL ifqqandℛ\\mathcal\{R\}are fixed\.

###### Proof sketch\.

Letℙ=\(ℱ=\(V,E\),𝒯\)\\mathbb\{P\}=\(\\mathcal\{F\}=\(V,E\),\\mathcal\{T\}\)be a proof scheme whose validity w\.r\.t\.\(I,ℛ,q\)\(I,\\mathcal\{R\},q\)we wish to test\. To establish the complexity bounds, we will show that a proof scheme is valid just in the case that some execution of the following non\-deterministic procedure returns ‘valid’\. For the bound on the number of iterations of the inner while loop, we will useMax=P∗\(\|A\|\+\|𝗍𝖾𝗋𝗆𝗌​\(I\)∪𝗍𝖾𝗋𝗆𝗌​\(αp\)∪𝗍𝖾𝗋𝗆𝗌​\(αc\)\|\)A∗23∗N2∗A2\\textsc\{Max\}=P\*\(\|A\|\+\|\\mathsf\{terms\}\{\(I\)\}\\cup\\mathsf\{terms\}\{\(\\alpha\_\{p\}\)\}\\cup\\mathsf\{terms\}\{\(\\alpha\_\{c\}\)\}\|\)^\{A\}\*2^\{3\*N^\{2\}\*A^\{2\}\}, wherePPandAAare respectively the number of predicates and maximum predicate arity for the rulesetℛ\\mathcal\{R\}, andNNis the total number of states across all of the automata inqq\. \(We will explain later the origin of this bound\.\)

Step 1: Check that every root atom inVVbelongs toII, and return ‘not valid’ if not\. Next consider each pair\(α,α′\)\(\\alpha,\\alpha^\{\\prime\}\)of \(not necessarily distinct\) root atoms in turn\. For each possible transitionτ=\(i1,s1,i2,s2\)\\tau=\(i\_\{1\},s\_\{1\},i\_\{2\},s\_\{2\}\)w\.r\.t\.qqand\(α,α′\)\(\\alpha,\\alpha^\{\\prime\}\), construct the corresponding RPQqτ=ℒ𝔸​\(s1,s2\)​\(α​\[i1\],α′​\[i2\]\)q\_\{\\tau\}=\\mathcal\{L\}\_\{\\mathbb\{A\}\}\(s\_\{1\},s\_\{2\}\)\(\\alpha\[i\_\{1\}\],\\alpha^\{\\prime\}\[i\_\{2\}\]\)\(with𝔸\\mathbb\{A\}the automaton containing statess1,s2s\_\{1\},s\_\{2\}\) and use the RPQ Entailment oracle to decide whetherqτq\_\{\\tau\}is entailed from\(I,ℛ\)\(I,\\mathcal\{R\}\)\. Store inTrans​\(α,α′\)\\textsc\{Trans\}\(\\alpha,\\alpha^\{\\prime\}\)the transitionsτ\\taufor whichqτq\_\{\\tau\}is entailed\. If there is some\(τ,\(α,α′\)\)∈𝒯\(\\tau,\(\\alpha,\\alpha^\{\\prime\}\)\)\\in\\mathcal\{T\}such thatτ∉Trans​\(α,α′\)\\tau\\not\\in\\textsc\{Trans\}\(\\alpha,\\alpha^\{\\prime\}\), return ‘not valid’, else continue to Step 2\.

Step 2: LetUnexaminedbe the set of non\-root nodes inVV\.

WhileUnexamined≠∅\\textsc\{Unexamined\}\\neq\\emptyset, choose someαc∈Unexamined\\alpha\_\{c\}\\in\\textsc\{Unexamined\}whose parentαp\\alpha\_\{p\}is such thatαp∉Unexamined\\alpha\_\{p\}\\not\\in\\textsc\{Unexamined\}, and proceed as follows:

- •Removeαc\\alpha\_\{c\}fromUnexamined\.
- •SetCount=0\\textsc\{Count\}=0andαi=αp\\alpha\_\{i\}=\\alpha\_\{p\}\.
- •WhileCount≤Max\\textsc\{Count\}\\leq\\textsc\{Max\}andαi≠αc\\alpha\_\{i\}\\neq\\alpha\_\{c\} 1. \(a\)Guess a ruleρ∈ℛ\\rho\\in\\mathcal\{R\}that is applicable toαi\\alpha\_\{i\}using substitutionσ\\sigma\(return ‘not valid’ if no such rule\)\. 2. \(b\)Letαi′\\alpha\_\{i\}^\{\\prime\}be the result of applyingρ\\rhotoαi\\alpha\_\{i\}underσ\\sigma\. We assume that existential variables in the head ofρ\\rhoare replaced with either nulls from𝗍𝖾𝗋𝗆𝗌​\(αc\)∖\(𝗍𝖾𝗋𝗆𝗌​\(αp\)∪𝗍𝖾𝗋𝗆𝗌​\(αi\)\)\\mathsf\{terms\}\{\(\\alpha\_\{c\}\)\}\\setminus\(\\mathsf\{terms\}\{\(\\alpha\_\{p\}\)\}\\cup\\mathsf\{terms\}\{\(\\alpha\_\{i\}\)\}\)or fresh nulls \(not in𝗍𝖾𝗋𝗆𝗌​\(ℱ\)\\mathsf\{terms\}\{\(\\mathcal\{F\}\)\}\) using the next available ids\. 3. \(c\)For each possible transitionτ=\(k1,s1,k2,s2\)\\tau=\(k\_\{1\},s\_\{1\},k\_\{2\},s\_\{2\}\)w\.r\.t\.qqand\(αi′,αi′\)\(\\alpha\_\{i\}^\{\\prime\},\\alpha\_\{i\}^\{\\prime\}\) - –construct the RPQqτ=ℒ𝔸​\(s1,s2\)​\(αi′​\[k1\],αi′​\[k2\]\)q\_\{\\tau\}=\\mathcal\{L\}\_\{\\mathbb\{A\}\}\(s\_\{1\},s\_\{2\}\)\(\\alpha\_\{i\}^\{\\prime\}\[k\_\{1\}\],\\alpha\_\{i\}^\{\\prime\}\[k\_\{2\}\]\)\(with𝔸\\mathbb\{A\}the automaton containing statess1,s2s\_\{1\},s\_\{2\}\) - –use the RPQ Entailment oracle to decide ifqτq\_\{\\tau\}is entailed from\(\{αi′\},ℛ\)\(\\\{\\alpha\_\{i\}^\{\\prime\}\\\},\\mathcal\{R\}\) - –ifqτq\_\{\\tau\}is entailed, then storeτ\\tauinTrans↓​\(αi′,αi′\)\\textsc\{Trans\}^\{\\downarrow\}\(\\alpha\_\{i\}^\{\\prime\},\\alpha\_\{i\}^\{\\prime\}\) 4. \(d\)For every possible transitionτ=\(k1,s1,k3,s3\)\\tau=\(k\_\{1\},s\_\{1\},k\_\{3\},s\_\{3\}\)w\.r\.t\.qqand\(αp,αi′\)\(\\alpha\_\{p\},\\alpha\_\{i\}^\{\\prime\}\), addτ\\tautoTrans​\(αp,αi′\)\\textsc\{Trans\}\(\\alpha\_\{p\},\\alpha\_\{i\}^\{\\prime\}\)if there exist transitions\(k1,s1,k2,s2\)∈Trans​\(αp,αi\)\(k\_\{1\},s\_\{1\},k\_\{2\},s\_\{2\}\)\\in\\textsc\{Trans\}\(\\alpha\_\{p\},\\alpha\_\{i\}\)and\(k2′,s2,k3,s3\)∈Trans↓​\(αi′,αi′\)\(k\_\{2\}^\{\\prime\},s\_\{2\},k\_\{3\},s\_\{3\}\)\\in\\textsc\{Trans\}^\{\\downarrow\}\(\\alpha\_\{i\}^\{\\prime\},\\alpha\_\{i\}^\{\\prime\}\)such thatαi​\[k2\]=αi′​\[k2′\]\\alpha\_\{i\}\[k\_\{2\}\]=\\alpha\_\{i\}^\{\\prime\}\[k\_\{2\}^\{\\prime\}\] 5. \(e\)For every possible transitionτ=\(k1,s1,k3,s3\)\\tau=\(k\_\{1\},s\_\{1\},k\_\{3\},s\_\{3\}\)w\.r\.t\.qqand\(αi′,αp\)\(\\alpha\_\{i\}^\{\\prime\},\\alpha\_\{p\}\), addτ\\tautoTrans​\(αi′,αp\)\\textsc\{Trans\}\(\\alpha\_\{i\}^\{\\prime\},\\alpha\_\{p\}\)if there exist transitions\(k1,s1,k2′,s2\)∈Trans↓​\(αi′,αi′\)\(k\_\{1\},s\_\{1\},k\_\{2\}^\{\\prime\},s\_\{2\}\)\\in\\textsc\{Trans\}^\{\\downarrow\}\(\\alpha\_\{i\}^\{\\prime\},\\alpha\_\{i\}^\{\\prime\}\)and\(k2,s2,k3,s3\)∈Trans​\(αi,αp\)\(k\_\{2\},s\_\{2\},k\_\{3\},s\_\{3\}\)\\in\\textsc\{Trans\}\(\\alpha\_\{i\},\\alpha\_\{p\}\)such thatαi′​\[k2′\]=αi​\[k2\]\\alpha\_\{i\}^\{\\prime\}\[k\_\{2\}^\{\\prime\}\]=\\alpha\_\{i\}\[k\_\{2\}\] 6. \(f\)For every possible transitionτ=\(k1,s1,k4,s4\)\\tau=\(k\_\{1\},s\_\{1\},k\_\{4\},s\_\{4\}\)w\.r\.t\.qqand\(αi′,αi′\)\(\\alpha\_\{i\}^\{\\prime\},\\alpha\_\{i\}^\{\\prime\}\), addτ\\tautoTrans​\(αi′,αi′\)\\textsc\{Trans\}\(\\alpha\_\{i\}^\{\\prime\},\\alpha\_\{i\}^\{\\prime\}\)whenever there exist transitions\(k1,s1,k2′,s2\)∈Trans↓​\(αi′,αi′\)\(k\_\{1\},s\_\{1\},k\_\{2\}^\{\\prime\},s\_\{2\}\)\\in\\textsc\{Trans\}^\{\\downarrow\}\(\\alpha\_\{i\}^\{\\prime\},\\alpha\_\{i\}^\{\\prime\}\),\(k2,s2,k3,s3\)∈Trans​\(αi,αi\)\(k\_\{2\},s\_\{2\},k\_\{3\},s\_\{3\}\)\\in\\textsc\{Trans\}\(\\alpha\_\{i\},\\alpha\_\{i\}\), and\(k3′,s3,k4,s4\)∈Trans↓​\(αi′,αi′\)\(k\_\{3\}^\{\\prime\},s\_\{3\},k\_\{4\},s\_\{4\}\)\\in\\textsc\{Trans\}^\{\\downarrow\}\(\\alpha\_\{i\}^\{\\prime\},\\alpha\_\{i\}^\{\\prime\}\)such thatαi′​\[k2′\]=αi​\[k2\]\\alpha\_\{i\}^\{\\prime\}\[k\_\{2\}^\{\\prime\}\]=\\alpha\_\{i\}\[k\_\{2\}\]andαi′​\[k3′\]=αi​\[k3\]\\alpha\_\{i\}^\{\\prime\}\[k\_\{3\}^\{\\prime\}\]=\\alpha\_\{i\}\[k\_\{3\}\] 7. \(g\)Setαi=αi′\\alpha\_\{i\}=\\alpha^\{\\prime\}\_\{i\}and incrementCount\.
- •Return ‘not valid’ if one of the following conditions does not hold: - –αi=αc\\alpha\_\{i\}=\\alpha\_\{c\} - –\{τ∣\(τ,\(αc,αc\)\)∈𝒯\}⊆Trans​\(αc,αc\)=Trans​\(αi,αi\)\\\{\\tau\\mid\(\\tau,\(\\alpha\_\{c\},\\alpha\_\{c\}\)\)\\in\\mathcal\{T\}\\\}\\subseteq\\textsc\{Trans\}\(\\alpha\_\{c\},\\alpha\_\{c\}\)=\\textsc\{Trans\}\(\\alpha\_\{i\},\\alpha\_\{i\}\) - –\{τ∣\(τ,\(αp,αc\)\)∈𝒯\}⊆Trans​\(αp,αc\)=Trans​\(αp,αi\)\\\{\\tau\\mid\(\\tau,\(\\alpha\_\{p\},\\alpha\_\{c\}\)\)\\in\\mathcal\{T\}\\\}\\subseteq\\textsc\{Trans\}\(\\alpha\_\{p\},\\alpha\_\{c\}\)=\\textsc\{Trans\}\(\\alpha\_\{p\},\\alpha\_\{i\}\) - –\{τ∣\(τ,\(αc,αp\)\)∈𝒯\}⊆Trans​\(αc,αp\)=Trans​\(αi,αp\)\\\{\\tau\\mid\(\\tau,\(\\alpha\_\{c\},\\alpha\_\{p\}\)\)\\in\\mathcal\{T\}\\\}\\subseteq\\textsc\{Trans\}\(\\alpha\_\{c\},\\alpha\_\{p\}\)=\\textsc\{Trans\}\(\\alpha\_\{i\},\\alpha\_\{p\}\)

Return ‘valid’\.

We remark that the preceding procedure runs in polynomial space, except that it makes some calls to an oracle for RPQ Entailment\. As RPQ entailment is inExpTimeandPSpace=NPSpace⊆\\subseteqExptime, the procedure can be made to run inExptime\. If we consider rules of bounded arity, then RPQ entailment is inPSpace, so the procedure runs in polynomial space\. Finally, let us consider the case whereqqandℛ\\mathcal\{R\}are fixed and show that the procedure can be made to run in non\-deterministic logarithmic space\. For Step 1, it suffices to iterate over the polynomially many combinations of possible transitions and pairs of root atoms, and for every such combination, test whether the corresponding RPQ is entailed\. As RPQ Entailment is inNLogSpacein data complexity, and it is known thatNLogSpaceNLogSpace⊆NLogSpace\\textsc\{NLogSpace\}^\{\\textsc\{NLogSpace\}\}\\subseteq\\textsc\{NLogSpace\}, Step 1 can be implemented inNLogSpace\. For Step 2, by proceeding in a depth\-first manner, we can examine each of the nodes in the proof scheme using only logarithmic space to keep track of which nodes remain to be visited\. For each nodeαc\\alpha\_\{c\}with parentαp\\alpha\_\{p\}, the maximal number of iterations of the inner while loop is bounded by a constant \(as it depends only onqqandℛ\\mathcal\{R\}\)\. Moreover, it is easily verified that all operations in the inner while loop can be performed using constant space, except for Step 2\(c\), which involves a constant number of RPQ Entailment checks, each of which can be handled by anNLogSpaceoracle\. Thus, the entire procedure can be implemented in non\-deterministic logspace, yielding the desiredNLogSpaceupper bound\. We have thus shown that the procedure gives the required complexity bounds, and in the appendix, we establish its correctness\.∎

Note that the proposition can be extended to arbitrary linear rules with multiple head atoms \(translated into atomic\-head linear rules\)\. Indeed, for combined complexity in the bounded predicate arity case, we know that RPQ entailment remains inPTime, see Proposition[11](https://arxiv.org/html/2607.22636#Thmtheorem11)and Theorem[14](https://arxiv.org/html/2607.22636#Thmtheorem14); hence, checking the validity of a proof scheme remains inPSpace\.

It follows from Proposition[17](https://arxiv.org/html/2607.22636#Thmtheorem17)that enumerating polysize proof schemes and checking for their validity and for the existence of a match ofqqin them yields a sound and complete algorithm for CRPQ answering\.

###### Theorem 18\.

CRPQ answering under linear rules isExpTime\-complete in combined complexity,PSpace\-complete in combined complexity with bounded\-predicate arity, andNL\-complete in data complexity\.

###### Proof\.

By Proposition[7](https://arxiv.org/html/2607.22636#Thmtheorem7a), CRPQ entailment comes down to deciding whether there exists a polynomial \(in the query\) proof scheme that is valid and contains a match for the query\.

Though polysize proof schemes are defined on an infinite number of atoms, and are thus infinite in number, we can enumerate in exponential time those that are different up to a renaming of nulls\. Thus, for the general case, we can enumerate all polysize proof schemes that are distinct up to a renaming of nulls in polynomial space \(and exponential time\) and check whether there exists a valid proof scheme that contains a match for the query\. As already noted, deciding existence of a match in a proof scheme is in NP, and by Proposition[17](https://arxiv.org/html/2607.22636#Thmtheorem17), validity checking is inExpTime\. Thus, the described procedure runs in single\-exponential time\. When the arity is bounded, validity checking is inPSpace\(by Proposition[17](https://arxiv.org/html/2607.22636#Thmtheorem17)\), and so the overall procedure runs in polynomial space\. Finally, if bothqqandℛ\\mathcal\{R\}are fixed, the number of relevant proof schemes and their size are constants\. Thus, we can enumerate all proof schemes in constant time, and checking for a match is also in constant time\. By Proposition[17](https://arxiv.org/html/2607.22636#Thmtheorem17), the validity checking is inNLw\.r\.t\. the size of the data, so the overall procedure runs in non\-deterministic logspace for data complexity\.

TheExpTimelower bound in combined complexity and theNLlower bound in data complexity are immediate consequence of theExpTime\-hardness \(resp\.NL\-hardness\) of RPQ answering for linear rules w\.r\.t\. combined \(resp\. data\) complexity\. ThePSpacelower bound in the bounded arity case is inherited from thePSpace\-hardness of CRPQ answering over DL\-LiteRknowledge bases\(Bienvenu et al\.,[2015](https://arxiv.org/html/2607.22636#bib.bib13)\)\. ∎

## 6\.CRPQ Answering under Guarded Rules: Upper Bound

To upper bound the complexity of CRPQ answering under guarded rules, we reduce this problem to CRPQ answering under linear rules\. For simplicity, we assume that all the predicates inIIalso occur inℛ\\mathcal\{R\}\(however, the reduction is easily extended to drop this restriction\)\.

Two main ideas underly the reduction\. First, we define an alternative notion of derivation, called ‘locally complete’ derivation, which ensures the following property: at each stepkkof the derivation, the considered extended instanceI^k\\hat\{I\}\_\{k\}contains exactly the subset of the chase restricted to its terms,*i\.e\.*,𝖼𝗁𝖺𝗌𝖾​\(I,ℛ\)\|𝗍𝖾𝗋𝗆𝗌​\(I^k\)\\mathsf\{chase\}\(I,\\mathcal\{R\}\)\|\_\{\\mathsf\{terms\}\{\(\\hat\{I\}\_\{k\}\)\}\}\. Of course such a derivation is not computable for an arbitrary set of rules, because it requires the decidability of \(atom\) entailment, but it is for guarded rules\. Second, the application of guarded rules \(in a locally complete derivation\) is simulated through linear rules \(in a classical derivation\) expressed on an extended vocabulary, in which each predicate represents a guarded set of atoms\. We use a finite set of canonical variables to rename terms occurring in the chase atoms\. This ensures there are finitely many guarded sets to be considered\.

Let us first formally introduce the notion of locally complete derivation\. A locally complete derivation is a sequence of extended instancesI^i\\hat\{I\}\_\{i\}that have the property of being closed with respect to the atoms on𝗍𝖾𝗋𝗆𝗌​\(I^i\)\\mathsf\{terms\}\{\(\\hat\{I\}\_\{i\}\)\}that can be derived fromI^i\\hat\{I\}\_\{i\}\. Starting from an instanceII,I^0\\hat\{I\}\_\{0\}is obtained fromIIby closing it under atomic entailment\. At each stepii, a rule is applied onI^i\\hat\{I\}\_\{i\}and the resulting set is again closed to yieldI^i\+1\\hat\{I\}\_\{i\+1\}\.

###### Definition 1 \(Locally complete derivation\)\.

LetIIbe an instance andℛ\\mathcal\{R\}be a set of existential rules\. A*locally completeℛ\\mathcal\{R\}\-derivation*fromIIresulting inI^n\\hat\{I\}\_\{n\}is a sequenceI^0,I^1,…,I^n\\hat\{I\}\_\{0\},\\hat\{I\}\_\{1\},\\ldots,\\hat\{I\}\_\{n\}withI^0=𝖼𝗁𝖺𝗌𝖾​\(I,ℛ\)∣𝗍𝖾𝗋𝗆𝗌\(I\)\\hat\{I\}\_\{0\}=\\mathsf\{chase\}\(I,\\mathcal\{R\}\)\_\{\\mid\\mathsf\{terms\}\{\(I\)\}\}and such that for alli≥0i\\geq 0, there areρi∈ℛ\\rho\_\{i\}\\in\\mathcal\{R\}and a homomorphismπi\\pi\_\{i\}from𝖻𝗈𝖽𝗒​\(ρi\)\\mathsf\{body\}\(\\rho\_\{i\}\)toI^i\\hat\{I\}\_\{i\}such thatI^i\+1=𝖼𝗁𝖺𝗌𝖾​\(I^i′,ℛ\)∣𝗍𝖾𝗋𝗆𝗌\(I^i′\)\\hat\{I\}\_\{i\+1\}=\\mathsf\{chase\}\(\\hat\{I\}^\{\\prime\}\_\{i\},\\mathcal\{R\}\)\_\{\\mid\\mathsf\{terms\}\{\(\\hat\{I\}^\{\\prime\}\_\{i\}\)\}\}whereI^i′=I^i∪πisafe​\(𝗁𝖾𝖺𝖽​\(ρi\)\)\\hat\{I\}^\{\\prime\}\_\{i\}=\\hat\{I\}\_\{i\}\\cup\\pi\_\{i\}^\{\\mathrm\{safe\}\}\(\\mathsf\{head\}\(\\rho\_\{i\}\)\)\.

Note that a locally complete derivation could have been defined as a possibly infinite sequence, but we will only need finite sequences to state our results\. Next, we show that \(finite\) classical derivations and locally complete derivations are equivalent for our purposes, meaning that they entail the same Boolean CRPQs\. This result holds more generally for homomorphism\-closed queries, as stated in Proposition[5](https://arxiv.org/html/2607.22636#Thmtheorem5c)\.

Let us first illustrate the notion of locally complete derivation on the running example\.

###### Example 2 \(Running Example—continued\)\.

Letℛ=\{ρ1,…,ρ6\}\\mathcal\{R\}=\\\{\\rho\_\{1\},\\ldots,\\rho\_\{6\}\\\}be the considered set of rules, which we recall below for reading convenience\.

> \(ρ1\)𝗂𝗌𝖥𝗋𝗂𝖾𝗇𝖽𝖮𝖿​\(x,y\)→𝗂𝗌𝖥𝗋𝗂𝖾𝗇𝖽𝖮𝖿​\(y,x\)\(\\rho\_\{1\}\)\\quad\\mathsf\{isFriendOf\}\(x,y\)\\rightarrow\\mathsf\{isFriendOf\}\(y,x\) \(ρ2\)𝗂𝗌𝖥𝗋𝗂𝖾𝗇𝖽𝖮𝖿​\(x,y\)→𝖿𝗈𝗅𝗅𝗈𝗐𝗌​\(x,y\)\(\\rho\_\{2\}\)\\quad\\mathsf\{isFriendOf\}\(x,y\)\\rightarrow\\mathsf\{follows\}\(x,y\) \(ρ3\)𝖿𝗈𝗅𝗅𝗈𝗐𝗌​\(x,y\)→∃m​𝗆𝖾𝗌𝗌𝖺𝗀𝖾​\(m,x,y\)\(\\rho\_\{3\}\)\\quad\\mathsf\{follows\}\(x,y\)\\rightarrow\\exists m~\\mathsf\{message\}\(m,x,y\) \(ρ4\)𝖿𝗈𝗅𝗅𝗈𝗐𝗌​\(x,y\)∧𝖿𝗈𝗅𝗅𝗈𝗐𝗌​\(y,x\)→𝗂𝗌𝖯𝖺𝗂𝗋𝖾𝖽​\(x,y\)\(\\rho\_\{4\}\)\\quad\\mathsf\{follows\}\(x,y\)\\land\\mathsf\{follows\}\(y,x\)\\rightarrow\\mathsf\{isPaired\}\(x,y\) \(ρ5\)𝗆𝖾𝗌𝗌𝖺𝗀𝖾​\(m,x,y\)→𝗌𝖾𝗇𝖽𝗌​\(x,m\)\(\\rho\_\{5\}\)\\quad\\mathsf\{message\}\(m,x,y\)\\rightarrow\\mathsf\{sends\}\(x,m\) \(ρ6\)𝗆𝖾𝗌𝗌𝖺𝗀𝖾​\(m,x,y\)→𝗋𝖾𝖼𝖾𝗂𝗏𝖾𝗌​\(y,m\)\(\\rho\_\{6\}\)\\quad\\mathsf\{message\}\(m,x,y\)\\rightarrow\\mathsf\{receives\}\(y,m\)

Consider again the instanceI=\{𝖿𝗈𝗅𝗅𝗈𝗐𝗌​\(𝖡,𝖠\),𝗂𝗌𝖥𝗋𝗂𝖾𝗇𝖽𝖮𝖿​\(𝖢,𝖠\),𝗂𝗌𝖥𝗋𝗂𝖾𝗇𝖽𝖮𝖿​\(𝖢,𝖡\)\}I=\\\{\\mathsf\{follows\(B,A\)\},\\mathsf\{isFriendOf\(C,A\)\},\\mathsf\{isFriendOf\(C,B\)\}\\\}\. Then,I^0\\hat\{I\}\_\{0\}is obtained fromIIby adding all the entailed facts on terms in\{𝖠,𝖡,𝖢\}\\\{\\mathsf\{A,B,C\}\\\}:

> 𝗂𝗌𝖥𝗋𝗂𝖾𝗇𝖽𝖮𝖿​\(𝖠,𝖢\),𝗂𝗌𝖥𝗋𝗂𝖾𝗇𝖽𝖮𝖿​\(𝖡,𝖢\)\\mathsf\{isFriendOf\(A,C\)\},\\mathsf\{isFriendOf\(B,C\)\}, 𝖿𝗈𝗅𝗅𝗈𝗐𝗌​\(𝖢,𝖠\),𝖿𝗈𝗅𝗅𝗈𝗐𝗌​\(𝖢,𝖡\),𝖿𝗈𝗅𝗅𝗈𝗐𝗌​\(𝖠,𝖢\),𝖿𝗈𝗅𝗅𝗈𝗐𝗌​\(𝖡,𝖢\)\\mathsf\{follows\(C,A\)\},\\mathsf\{follows\(C,B\)\},\\mathsf\{follows\(A,C\)\},\\mathsf\{follows\(B,C\)\}, 𝗂𝗌𝖯𝖺𝗂𝗋𝖾𝖽​\(𝖢,𝖠\),𝗂𝗌𝖯𝖺𝗂𝗋𝖾𝖽​\(𝖠,𝖢\),𝗂𝗌𝖯𝖺𝗂𝗋𝖾𝖽​\(𝖢,𝖡\),𝗂𝗌𝖯𝖺𝗂𝗋𝖾𝖽​\(𝖡,𝖢\)\\mathsf\{isPaired\(C,A\)\},\\mathsf\{isPaired\(A,C\)\},\\mathsf\{isPaired\(C,B\)\},\\mathsf\{isPaired\(B,C\)\}\.

In a classical derivation,I^0\\hat\{I\}\_\{0\}would be obtained fromIIby triggering the rulesρ1\\rho\_\{1\},ρ2\\rho\_\{2\}andρ4\\rho\_\{4\}\. Now, assume Ruleρ3\\rho\_\{3\}is applied onI^0\\hat\{I\}\_\{0\}by homomorphismπ=\{x↦𝖡,y↦𝖠\}\\pi=\\\{x\\mapsto\\mathsf\{B\},y\\mapsto\\mathsf\{A\}\\\}\. Then,I1′=I^0∪\{𝗆𝖾𝗌𝗌𝖺𝗀𝖾​\(𝗆𝟢,𝖡,𝖠\)\}I^\{\\prime\}\_\{1\}=\\hat\{I\}\_\{0\}\\cup\\\{\\mathsf\{message\(m\_\{0\},\\mathsf\{B\},\\mathsf\{A\}\)\}\\\}, andI^1=I1′∪\{𝗌𝖾𝗇𝖽𝗌​\(𝖡,m0\),𝗋𝖾𝖼𝖾𝗂𝗏𝖾𝗌​\(𝖠,m0\)\}\\hat\{I\}\_\{1\}=I^\{\\prime\}\_\{1\}\\cup\\\{\\mathsf\{sends\}\(\\mathsf\{B\},m\_\{0\}\),\\mathsf\{receives\}\(\\mathsf\{A\},m\_\{0\}\)\\\}\. In a classical derivation,I^1\\hat\{I\}\_\{1\}would be obtained fromI1′I^\{\\prime\}\_\{1\}by triggering the rulesρ5\\rho\_\{5\}andρ6\\rho\_\{6\}\. The locally complete derivation can be continued by applyingρ3\\rho\_\{3\}on the other facts with predicate𝖿𝗈𝗅𝗅𝗈𝗐𝗌\\mathsf\{follows\}\.

Let us outline the main ideas of the reduction presented next\. We define a finite set of*complex predicates*, which are canonical encodings of all the guarded sets on a vocabulary\. Then, each atomα\\alphainIIis replaced by a complex atom \(i\.e\., an atom with a complex predicate\) encodingα\\alphaand its guarded set inI^0\\hat\{I\}\_\{0\}\. For example,α=𝗂𝗌𝖥𝗋𝗂𝖾𝗇𝖽𝖮𝖿​\(𝖢,𝖠\)\\alpha=\\mathsf\{isFriendOf\(C,A\)\}is replaced by a complex atom encodingα\\alphaand the following set:

\{𝗂𝗌𝖥𝗋𝗂𝖾𝗇𝖽𝖮𝖿​\(𝖢,𝖠\),𝗂𝗌𝖥𝗋𝗂𝖾𝗇𝖽𝖮𝖿​\(𝖠,𝖢\),𝖿𝗈𝗅𝗅𝗈𝗐𝗌​\(𝖢,𝖠\),𝖿𝗈𝗅𝗅𝗈𝗐𝗌​\(𝖠,𝖢\),𝗂𝗌𝖯𝖺𝗂𝗋𝖾𝖽​\(𝖢,𝖠\),𝗂𝗌𝖯𝖺𝗂𝗋𝖾𝖽​\(𝖠,𝖢\)\}\\\{\\mathsf\{isFriendOf\(C,A\)\},\\mathsf\{isFriendOf\(A,C\)\},\\mathsf\{follows\(C,A\)\},\\mathsf\{follows\(A,C\)\},\\mathsf\{isPaired\(C,A\)\},\\mathsf\{isPaired\(A,C\)\}\\\}Furthermore, each rule fromℛ\\mathcal\{R\}is replaced by a set of*complex rules*, which are linear rules using complex predicates, such that each application of a complex rule simulates a step of a locally complex derivation\. Finally,*reconstruction rules*translate back atoms on the complex predicates into atoms on the initial predicates\. We will illustrate the multiple intricacies of this translation using specific technical examples\.

The following Lemmas[3](https://arxiv.org/html/2607.22636#Thmtheorem3c)and[4](https://arxiv.org/html/2607.22636#Thmtheorem4c)allow us to show that classical derivations and locally complete derivations are able to derive exactly the same conclusions\.

###### Lemma 3\.

For any classicalℛ\\mathcal\{R\}\-derivation fromIItoInI\_\{n\}, there exists a locally completeℛ\\mathcal\{R\}\-derivation fromIItoI^m\\hat\{I\}\_\{m\}such thatI^m⊧In\\hat\{I\}\_\{m\}\\models I\_\{n\}\.

###### Proof\.

We prove the result by induction on the length of the classical derivation\. Ifn=0n=0, the result holds sinceI0⊆^​I0I\_\{0\}\\subseteq\\hat\{\}I\_\{0\}\. Otherwise, let us assume that the result holds for any classical derivation of lengthn≥0n\\geq 0\. LetI=I0,…,In,In\+1I=I\_\{0\},\\ldots,I\_\{n\},I\_\{n\+1\}be a classical derivation of lengthn\+1n\+1, andρn\\rho\_\{n\}andπn\\pi\_\{n\}be such thatIn\+1I\_\{n\+1\}is obtained fromInI\_\{n\}by applying the trigger\(ρn,πn\)\(\\rho\_\{n\},\\pi\_\{n\}\)\. By induction assumption, there is a locally completeℛ\\mathcal\{R\}\-derivation fromIIresulting inI^m\\hat\{I\}\_\{m\}such thatI^m⊧In\\hat\{I\}\_\{m\}\\models I\_\{n\}\. Hence, there is a homomorphismhnh\_\{n\}fromInI\_\{n\}toI^m\\hat\{I\}\_\{m\}\. Thus\(ρn,hn∘πn\)\(\\rho\_\{n\},h\_\{n\}\\circ\\pi\_\{n\}\)is a trigger onI^m\\hat\{I\}\_\{m\}, andhnh\_\{n\}can be extended to a homomorphism fromIn\+1I\_\{n\+1\}toI^m\+1′=I^m∪\(hn∘πn\)safe​\(𝗁𝖾𝖺𝖽​\(ρn\)\)\\hat\{I\}^\{\\prime\}\_\{m\+1\}=\\hat\{I\}\_\{m\}\\cup\(h\_\{n\}\\circ\\pi\_\{n\}\)^\{\\mathrm\{safe\}\}\(\\mathsf\{head\}\(\\rho\_\{n\}\)\)by mapping the existential variables inπnsafe​\(𝗁𝖾𝖺𝖽​\(ρn\)\)\\pi\_\{n\}^\{\\mathrm\{safe\}\}\(\\mathsf\{head\}\(\\rho\_\{n\}\)\)to the corresponding existential variables in\(hn∘πn\)safe​\(𝗁𝖾𝖺𝖽​\(ρn\)\)\(h\_\{n\}\\circ\\pi\_\{n\}\)^\{\\mathrm\{safe\}\}\(\\mathsf\{head\}\(\\rho\_\{n\}\)\)\. Hence, the locally complete derivation fromIIresulting inI^m\\hat\{I\}\_\{m\}can be extended to a locally complete derivation fromIIresulting inI^m\+1=𝖼𝗁𝖺𝗌𝖾​\(I^m\+1′,ℛ\)∣𝗍𝖾𝗋𝗆𝗌\(I^m\+1′\)\\hat\{I\}\_\{m\+1\}=\\mathsf\{chase\}\(\\hat\{I\}^\{\\prime\}\_\{m\+1\},\\mathcal\{R\}\)\_\{\\mid\\mathsf\{terms\}\{\(\\hat\{I\}^\{\\prime\}\_\{m\+1\}\)\}\}, andI^m\+1⊧I^m\+1′⊧In\+1\\hat\{I\}\_\{m\+1\}\\models\\hat\{I\}^\{\\prime\}\_\{m\+1\}\\models I\_\{n\+1\}, which concludes this proof\. ∎

###### Lemma 4\.

For any locally completeℛ\\mathcal\{R\}\-derivation fromIIresulting inI^n\\hat\{I\}\_\{n\}, there exists a classicalℛ\\mathcal\{R\}\-derivation fromIIresulting inI′I^\{\\prime\}such thatI′⊧I^nI^\{\\prime\}\\models\\hat\{I\}\_\{n\}\.

###### Proof\.

We prove the result by induction on the length of a locally complete derivationI^0,…,I^n\\hat\{I\}\_\{0\},\\ldots,\\hat\{I\}\_\{n\}\. Forn=0n=0,I^n=𝖼𝗁𝖺𝗌𝖾​\(I,ℛ\)∣𝗍𝖾𝗋𝗆𝗌\(I\)\\hat\{I\}\_\{n\}=\\mathsf\{chase\}\(I,\\mathcal\{R\}\)\_\{\\mid\\mathsf\{terms\}\{\(I\)\}\}\. As𝖼𝗁𝖺𝗌𝖾​\(I,ℛ\)⊧𝖼𝗁𝖺𝗌𝖾​\(I,ℛ\)∣𝗍𝖾𝗋𝗆𝗌\(I\)\\mathsf\{chase\}\(I,\\mathcal\{R\}\)\\models\\mathsf\{chase\}\(I,\\mathcal\{R\}\)\_\{\\mid\\mathsf\{terms\}\{\(I\)\}\}, there isImI\_\{m\}derivable fromIIsuch thatIm⊧I^nI\_\{m\}\\models\\hat\{I\}\_\{n\}, which concludes that case\. For the induction step, let us assume the result for any locally complete derivation of length up ton≥0n\\geq 0, and letI^n\+1\\hat\{I\}\_\{n\+1\}be obtained from a locally complete derivation of lengthn\+1n\+1\. We obtainedI^n\+1\\hat\{I\}\_\{n\+1\}fromI^n\\hat\{I\}\_\{n\}by a single locally complete rule application of ruleρn\\rho\_\{n\}throughπn\\pi\_\{n\}\. LetI=I0,…,ImI=I\_\{0\},\\ldots,I\_\{m\}be a derivation such thatIm⊧I^nI\_\{m\}\\models\\hat\{I\}\_\{n\}, andφn\\varphi\_\{n\}be a homomorphism fromI^n\\hat\{I\}\_\{n\}toImI\_\{m\}\. Thenρn\\rho\_\{n\}is applicable toImI\_\{m\}usingφn∘πn\\varphi\_\{n\}\\circ\\pi\_\{n\}, creatingIm\+1I\_\{m\+1\}\. Letφn\+\\varphi\_\{n\}^\{\+\}be the extension ofφn\\varphi\_\{n\}such that each variable introduced by the application ofρn\\rho\_\{n\}toI^n\\hat\{I\}\_\{n\}throughπn\\pi\_\{n\}is mapped to the corresponding variable inIm\+1I\_\{m\+1\}\. We show that there exist an extensionI0,…,Im\+1,…,Im′I\_\{0\},\\ldots,I\_\{m\+1\},\\ldots,I\_\{m^\{\\prime\}\}of the derivationI0,…,Im\+1I\_\{0\},\\ldots,I\_\{m\+1\}and a homomorphismφn\+1\\varphi\_\{n\+1\}fromI^n\+1\\hat\{I\}\_\{n\+1\}toIm′I\_\{m^\{\\prime\}\}\.

First observe thatφn\+\\varphi\_\{n\}^\{\+\}is a homomorphism fromI^n′=I^n∪πnsafe​\(𝗁𝖾𝖺𝖽​\(ρn\)\)\\hat\{I\}^\{\\prime\}\_\{n\}=\\hat\{I\}\_\{n\}\\cup\\pi\_\{n\}^\{\\mathrm\{safe\}\}\(\\mathsf\{head\}\(\\rho\_\{n\}\)\)toIm\+1I\_\{m\+1\}\. By definition,I^n\+1=𝖼𝗁𝖺𝗌𝖾​\(I^n′,ℛ\)∣𝗍𝖾𝗋𝗆𝗌\(I^n′\)\\hat\{I\}\_\{n\+1\}=\\mathsf\{chase\}\(\\hat\{I\}^\{\\prime\}\_\{n\},\\mathcal\{R\}\)\_\{\\mid\\mathsf\{terms\}\{\(\\hat\{I\}^\{\\prime\}\_\{n\}\)\}\}\. There is thus a sequence of rule applications\{\(ρi′,πi′\)\}1≤i≤l\\\{\(\\rho^\{\\prime\}\_\{i\},\\pi^\{\\prime\}\_\{i\}\)\\\}\_\{1\\leq i\\leq l\}starting fromI^n′\\hat\{I\}^\{\\prime\}\_\{n\}whose result entailsI^n\+1\\hat\{I\}\_\{n\+1\}; let us denote byI′^ni\\hat\{I^\{\\prime\}\}\_\{n\}^\{i\}the set of atoms obtained after the application of\(ρi′,πi′\)\(\\rho^\{\\prime\}\_\{i\},\\pi^\{\\prime\}\_\{i\}\)\. We build by induction onlla sequence of pairs\(φi,Im\+1\+i\)\(\\varphi^\{i\},I\_\{m\+1\+i\}\)such thatφi\\varphi^\{i\}is a homomorphism fromI′^ni\\hat\{I^\{\\prime\}\}\_\{n\}^\{i\}toIm\+1\+iI\_\{m\+1\+i\}:

- •If the sequence of rule applications is empty, one can takeφn\+\\varphi\_\{n\}^\{\+\}andIm\+1I\_\{m\+1\}\.
- •If we have builtφi\\varphi^\{i\}andIm\+1\+iI\_\{m\+1\+i\}fulfilling the induction condition, thenρi\+1′\\rho^\{\\prime\}\_\{i\+1\}is applicable toIm\+1\+iI\_\{m\+1\+i\}byφi∘πi\+1′\\varphi^\{i\}\\circ\\pi^\{\\prime\}\_\{i\+1\}, and let us denote byIm\+1\+i\+1I\_\{m\+1\+i\+1\}the result of that application\. Thenφi\\varphi^\{i\}can be extended to a homomorphismφi\+1\\varphi^\{i\+1\}fromI′^ni\+1\\hat\{I^\{\\prime\}\}\_\{n\}^\{i\+1\}toIm\+1\+i\+1I\_\{m\+1\+i\+1\}, by mapping the introduced fresh nulls inI′^ni\+1\\hat\{I^\{\\prime\}\}\_\{n\}^\{i\+1\}to the corresponding fresh nulls inIm\+1\+i\+1I\_\{m\+1\+i\+1\}\.

We finally defineIm′I\_\{m^\{\\prime\}\}asIm\+lI\_\{m\+l\}andφn\+1\\varphi\_\{n\+1\}asφl\\varphi^\{l\}, and we have thatIm′⊧I^n\+1I\_\{m^\{\\prime\}\}\\models\\hat\{I\}\_\{n\+1\}, asφn\+1\\varphi\_\{n\+1\}is a homomorphism fromI^n\+1\\hat\{I\}\_\{n\+1\}toIm′I\_\{m^\{\\prime\}\}\. ∎

###### Proposition 5\.

For any KB\(I,ℛ\)\(I,\\mathcal\{R\}\)and homomorphism\-closed Boolean queryqq, there is a \(classical\)ℛ\\mathcal\{R\}\-derivation fromIIresulting inInI\_\{n\}withIn⊧qI\_\{n\}\\models qif and only if there is a locally completeℛ\\mathcal\{R\}\-derivation fromIIresulting inI^m\\hat\{I\}\_\{m\}withI^m⊧q\\hat\{I\}\_\{m\}\\models q\.

###### Proof\.

This is a direct consequence of Lemmas[3](https://arxiv.org/html/2607.22636#Thmtheorem3c)and[4](https://arxiv.org/html/2607.22636#Thmtheorem4c)\. ∎

The previous correspondence between classical and locally complete derivations holds for arbitrary instancesIIand rulesetsℛ\\mathcal\{R\}\. However, evenI^0\\hat\{I\}\_\{0\}is not computable in the general case \(whereas eachI^i\\hat\{I\}\_\{i\}is computable in the case of guarded rules\)\. Next, we want to simulate locally complete derivations under guarded rules by classical derivations under linear rules\. To that end, we will finitely encode the infinite set of all guarded sets that can be defined on a KB vocabulary𝒱=\(𝒫,𝒞\)\\mathcal\{V\}=\(\\mathcal\{P\},\\mathcal\{C\}\)\. Note that a guarded set itself is necessarily finite because only a finite set of atoms can be defined on a finite set of terms \(those of the guard\) and a finite set of predicates \(as𝒫\\mathcal\{P\}is finite\)\.

To finitely encode all guarded sets, we first rename them in a canonical way\. We consider a new set of*canonical variables*𝒳=\{X1,…,X2​w\}\\mathcal\{X\}=\\\{X\_\{1\},\\ldots,X\_\{2w\}\\\}, wherewwis the maximal predicate arity in𝒱\\mathcal\{V\}\(then,2​w2wis be the maximal number of variables in a guarded rule and this will also hold for the linear rules built by the reduction\)\. The set𝒳\\mathcal\{X\}is linearly ordered according to1​…​2​w1\\ldots 2w\. The canonical renaming of an atom on𝒱\\mathcal\{V\}is obtained by substituting all its terms by canonical variables\. We will need to consider atoms in which canonical variables from a subset𝒴⊆𝒳\\mathcal\{Y\}\\subseteq\\mathcal\{X\}may already appear\. In this case, its canonical renaming is obtained by substituting each other term by the next variable in𝒳∖𝒴\\mathcal\{X\}\\setminus\\mathcal\{Y\}\.

###### Definition 6 \(Canonical renaming\)\.

Letα\\alphabe an atom that may contain both classical terms and canonical variables from𝒳\\mathcal\{X\}\. The*canonical renaming*ofα\\alphaw\.r\.t𝒴⊆𝒳\\mathcal\{Y\}\\subseteq\\mathcal\{X\}is a substitutionΦα,𝒴\\varPhi\_\{\\alpha,\\mathcal\{Y\}\}from𝗍𝖾𝗋𝗆𝗌​\(α\)\\mathsf\{terms\}\{\(\\alpha\)\}to𝒳\\mathcal\{X\}such thatΦα,𝒴​\(ti\)=ti\\varPhi\_\{\\alpha,\\mathcal\{Y\}\}\(t\_\{i\}\)=t\_\{i\}ifti∈𝒳t\_\{i\}\\in\\mathcal\{X\}, otherwiseΦα,𝒴​\(ti\)=Xj\\varPhi\_\{\\alpha,\\mathcal\{Y\}\}\(t\_\{i\}\)=X\_\{j\}wherejjis the smallest integer such thatXj∉𝒴X\_\{j\}\\not\\in\\mathcal\{Y\},XjX\_\{j\}does not occur inα\\alpha, andXj≠Φα,𝒴​\(tk\)X\_\{j\}\\neq\\varPhi\_\{\\alpha,\\mathcal\{Y\}\}\(t\_\{k\}\)for allk<ik<i\. If𝒴=∅\\mathcal\{Y\}=\\emptyset, we simply writeΦα\\varPhi\_\{\\alpha\}\.

Note that, for a guarded setGGwith guardα\\alpha\(we recall that such set is denoted by the pair\(G,α\)\(G,\\alpha\)\), the canonical renaming ofα\\alphayields a renaming of all terms inGG\.

Given a vocabulary𝒱=\(𝒫,𝒞\)\\mathcal\{V\}=\(\\mathcal\{P\},\\mathcal\{C\}\), we denote by𝒢\\mathcal\{G\}the \(finite\) set of all guarded sets of atoms with predicates in𝒫\\mathcal\{P\}and terms in the canonical set of variables𝒳\\mathcal\{X\}\. For any guarded set\(G,α\)\(G,\\alpha\)on𝒱\\mathcal\{V\}, it holds that that\(Φα​\(G\),Φα​\(α\)\)∈𝒢\(\\varPhi\_\{\\alpha\}\(G\),\\varPhi\_\{\\alpha\}\(\\alpha\)\)\\in\\mathcal\{G\}\. Furthermore, to each guarded set\(G,α\)\(G,\\alpha\)we assign a*complex predicate*, of the formpΦα​\(G\)p\_\{\{\\varPhi\_\{\\alpha\}\(G\)\}\}with the same arity asα\\alpha\. As𝒢\\mathcal\{G\}is finite, so is the set of complex predicates\. A*complex atom*is an atom with a complex predicate \(and classical terms\)\. The*canonical atom*associated with a guarded set\(G,α\)\(G,\\alpha\)is𝖼𝖺𝗇​\(G,α\)\\mathsf\{can\}\(G,\\alpha\)=pΦα​\(G\)​\(𝗍𝖾𝗋𝗆𝗌​\(α\)\)p\_\{\\varPhi\_\{\\alpha\}\(G\)\}\(\\mathsf\{terms\}\{\(\\alpha\)\}\)\.

In this way, an instance can be encoded by the canonical atoms associated with all the guarded sets of its atoms\. Similarly, a guarded rule is encoded by two canonical atoms respectively associated with its \(guarded\) body and head, which yields a linear rule\. However, as illustrated by the next example, additional information will be needed to mimic guarded rule derivations with linear rule derivations\.

###### Example 7\.

ConsiderI=\{p​\(a\),r​\(a,b\),r​\(b,c\),q​\(c\)\}I=\\\{p\(a\),r\(a,b\),r\(b,c\),q\(c\)\\\}andℛ=\{r​\(x,y\)∧q​\(y\)→q​\(x\);p​\(x\)∧q​\(x\)→∃y​s​\(x,y\);q​\(x\)∧s​\(x,y\)→h​\(y\)\}\\mathcal\{R\}=\\\{r\(x,y\)\\wedge q\(y\)\\rightarrow q\(x\);p\(x\)\\wedge q\(x\)\\rightarrow\\exists y\\ s\(x,y\);q\(x\)\\wedge s\(x,y\)\\rightarrow h\(y\)\\\}\. The way we intend to encode the instanceIIworks as follows\. Considerr​\(a,b\)r\(a,b\)for instance\. It guards the set of atoms\{p​\(a\),r​\(a,b\)\}\\\{p\(a\),r\(a,b\)\\\}\. As such, we would encode it byp\{r​\(X1,X2\),p​\(X1\)\}​\(a,b\)p\_\{\\\{r\(X\_\{1\},X\_\{2\}\),p\(X\_\{1\}\)\\\}\}\(a,b\)\. Similarly, we would also encode the set\{r​\(b,c\),q​\(c\)\}\\\{r\(b,c\),q\(c\)\\\}guarded byr​\(b,c\)r\(b,c\)through the atomp\{r​\(X1,X2\),q​\(X2\)\}​\(b,c\)p\_\{\\\{r\(X\_\{1\},X\_\{2\}\),q\(X\_\{2\}\)\\\}\}\(b,c\)\.

One could try to simulate the effect ofr​\(x,y\)∧q​\(y\)→q​\(x\)r\(x,y\)\\wedge q\(y\)\\rightarrow q\(x\)by linear rules of the shapep\{r​\(X1,X2\),q​\(X2\)\}​\(x,y\)→p\{r​\(X1,X2\),q​\(X2\),q​\(X1\)\}​\(x,y\)p\_\{\\\{r\(X\_\{1\},X\_\{2\}\),q\(X\_\{2\}\)\\\}\}\(x,y\)\\rightarrow p\_\{\\\{r\(X\_\{1\},X\_\{2\}\),q\(X\_\{2\}\),q\(X\_\{1\}\)\\\}\}\(x,y\)\. The ruler​\(x,y\)∧q​\(y\)→q​\(x\)r\(x,y\)\\wedge q\(y\)\\rightarrow q\(x\)is applicable onIIby mappingxxtobbandyytoccproducingq​\(b\)q\(b\); similarly,p\{r​\(X1,X2\),q​\(X2\)\}​\(x,y\)→p\{r​\(X1,X2\),q​\(X2\),q​\(X1\)\}​\(x,y\)p\_\{\\\{r\(X\_\{1\},X\_\{2\}\),q\(X\_\{2\}\)\\\}\}\(x,y\)\\rightarrow p\_\{\\\{r\(X\_\{1\},X\_\{2\}\),q\(X\_\{2\}\),q\(X\_\{1\}\)\\\}\}\(x,y\)is applicable on the encoded instance by mappingxxtobbandyytocc, producing the atomp\{r​\(X1,X2\),q​\(X2\),q​\(X1\)\}​\(b,c\)p\_\{\\\{r\(X\_\{1\},X\_\{2\}\),q\(X\_\{2\}\),q\(X\_\{1\}\)\\\}\}\(b,c\)\. However, the next application of the same rule, mappingxxtoaaandyytobb, cannot be simulated in the translation, becauseq​\(b\)q\(b\)is not encoded in the atomp\{r​\(X1,X2\),p​\(X1\)\}​\(a,b\)p\_\{\\\{r\(X\_\{1\},X\_\{2\}\),p\(X\_\{1\}\)\\\}\}\(a,b\), which prevents further rule applications\.

As witnessed by Example[7](https://arxiv.org/html/2607.22636#Thmtheorem7b), starting from the guarded sets present inIIis not enough to mimic guarded rule derivations by linear rule derivations\. A first idea would be to start from saturated guarded sets, as supported by the following proposition \(whose proof is given in the appendix\)\.

###### Proposition8\.

Letℛ\\mathcal\{R\}be a set of guarded rules andIIbe an instance\. For each atomα∈I\\alpha\\in I, we noteIα∗=𝖼𝗁𝖺𝗌𝖾​\(I,ℛ\)∣𝗍𝖾𝗋𝗆𝗌\(α\)I^\{\*\}\_\{\\alpha\}=\\mathsf\{chase\}\(I,\\mathcal\{R\}\)\_\{\\mid\\mathsf\{terms\}\{\(\\alpha\)\}\}\. Then:

- \(⇒\)\(\\Rightarrow\)For anyℛ\\mathcal\{R\}\-derivation fromIItoInI\_\{n\}, we can define for everyα∈I\\alpha\\in Ianℛ\\mathcal\{R\}\-derivation fromIα∗I^\{\*\}\_\{\\alpha\}toIα′I^\{\\prime\}\_\{\\alpha\}such that⋃α∈IIα′⊧In\\bigcup\_\{\\alpha\\in I\}I^\{\\prime\}\_\{\\alpha\}\\models I\_\{n\};
- \(⇐\)\(\\Leftarrow\)Let for anyα∈I\\alpha\\in Ianℛ\\mathcal\{R\}\-derivation fromIα∗I^\{\*\}\_\{\\alpha\}toIα′I^\{\\prime\}\_\{\\alpha\}; there exists anℛ\\mathcal\{R\}\-derivation fromIItoI′I^\{\\prime\}such thatI′⊧⋃α∈IIα′I^\{\\prime\}\\models\\bigcup\_\{\\alpha\\in I\}I^\{\\prime\}\_\{\\alpha\}\.

However, a similar problem of incompleteness would occur if the \(extended\) instance resulting from a rule application was not closed as well\. That is why the notion of locally complete derivation considers at each step the chase of the resulting instance restricted to the terms of this instance\.

We are now ready to define the reduction itself\. Given a KB\(I,ℛ\)\(I,\\mathcal\{R\}\)on a vocabulary𝒱\\mathcal\{V\}\(the ‘original vocabulary’\), whereℛ\\mathcal\{R\}is a set of guarded rules, we build\(I′,ℛ′\)\(I^\{\\prime\},\\mathcal\{R\}^\{\\prime\}\)whereℛ′\\mathcal\{R\}^\{\\prime\}is a set of linear rules, such that for any Boolean CRPQqqon𝒱\\mathcal\{V\}, it holds thatI,ℛ⊧qI,\\mathcal\{R\}\\models qif and only ifI′,ℛ′⊧qI^\{\\prime\},\\mathcal\{R\}^\{\\prime\}\\models q\. The new instanceI′I^\{\\prime\}is the encoding of𝖼𝗁𝖺𝗌𝖾​\(I,ℛ\)∣𝗍𝖾𝗋𝗆𝗌\(I\)\\mathsf\{chase\}\(I,\\mathcal\{R\}\)\_\{\\mid\\mathsf\{terms\}\{\(I\)\}\}using complex predicates, whileℛ′\\mathcal\{R\}^\{\\prime\}contains two kinds of rules:*reconstruction rules*, which allow to generate back atoms on𝒱\\mathcal\{V\}from atoms on complex predicates, and*complex rules*, which simulate one step of a locally complete derivation\. Let us start with the definition ofI′I^\{\\prime\}and its illustration\.

###### Definition 9 \(Guarded Translation ofII\(I′I^\{\\prime\}\)\)\.

The*guarded translation*ofIIw\.r\.t\.ℛ\\mathcal\{R\}isI′=\{𝖼𝖺𝗇​\(Iα∗,α\)\|α∈I\}I^\{\\prime\}=\\\{\\mathsf\{can\}\(I^\{\*\}\_\{\\alpha\},\\alpha\)~\|~\\alpha\\in I\\\}, where\(Iα∗,α\)\(I^\{\*\}\_\{\\alpha\},\\alpha\)denotes the guarded set\(𝖼𝗁𝖺𝗌𝖾​\(I,ℛ\)∣𝗍𝖾𝗋𝗆𝗌\(α\),α\)\(\\mathsf\{chase\}\(I,\\mathcal\{R\}\)\_\{\\mid\\mathsf\{terms\}\{\(\\alpha\)\}\},\\alpha\)\.

###### Example 10\.

ConsiderIIandℛ\\mathcal\{R\}from Example[7](https://arxiv.org/html/2607.22636#Thmtheorem7b), and letα1=r​\(b,c\)\\alpha\_\{1\}=r\(b,c\)andα2=r​\(a,b\)\\alpha\_\{2\}=r\(a,b\)\. In the following, we underline the guard in a guarded set\.\(Iα1∗,α1\)=\{r​\(b,c\)¯,q​\(b\),q​\(c\)\}\(I\_\{\\alpha\_\{1\}\}^\{\*\},\\alpha\_\{1\}\)=\\\{\\underline\{r\(b,c\)\},q\(b\),q\(c\)\\\}, hence𝖼𝖺𝗇​\(Iα1∗,α1\)=p\{r​\(X1,X2\)¯,q​\(X1\),q​\(X2\)\}​\(b,c\)\\mathsf\{can\}\(I\_\{\\alpha\_\{1\}\}^\{\*\},\\alpha\_\{1\}\)=p\_\{\\\{\\underline\{r\(X\_\{1\},X\_\{2\}\)\},q\(X\_\{1\}\),q\(X\_\{2\}\)\\\}\}\(b,c\)\. Similarly,\(Iα2∗,α2\)=\{r​\(a,b\)¯,p​\(a\),q​\(a\),q​\(b\)\}\(I\_\{\\alpha\_\{2\}\}^\{\*\},\\alpha\_\{2\}\)=\\\{\\underline\{r\(a,b\)\},p\(a\),q\(a\),q\(b\)\\\}, hence𝖼𝖺𝗇​\(Iα2∗,α2\)=p\{r​\(X1,X2\)¯,p​\(X1\),q​\(X1\),q​\(X2\)\}​\(a,b\)\\mathsf\{can\}\(I\_\{\\alpha\_\{2\}\}^\{\*\},\\alpha\_\{2\}\)=p\_\{\\\{\\underline\{r\(X\_\{1\},X\_\{2\}\)\},p\(X\_\{1\}\),q\(X\_\{1\}\),q\(X\_\{2\}\)\\\}\}\(a,b\)\.

We now present the set of linear rulesℛ′=ℛr∪ℛc\\mathcal\{R\}^\{\\prime\}=\\mathcal\{R\}\_\{r\}\\cup\\mathcal\{R\}\_\{c\}, which simulates the locally complete chase, starting with reconstruction rulesℛr\\mathcal\{R\}\_\{r\}\.

###### Definition 11 \(Reconstruction rules \(ℛr\\mathcal\{R\}\_\{r\}\)\)\.

Let\(G,α\)∈𝒢\(G,\\alpha\)\\in\\mathcal\{G\}\. The set of*reconstruction rules*associated with\(G,α\)\(G,\\alpha\)contains for eachβ∈G\\beta\\in Gthe rule of the form𝖼𝖺𝗇​\(G,α\)→β\.\\mathsf\{can\}\(G,\\alpha\)\\rightarrow\\beta\.The set of all reconstruction rules \(associated with𝒢\\mathcal\{G\}\) is denoted byℛr\\mathcal\{R\}\_\{r\}\.

Note that reconstruction rules do not contain any existentially quantified variable\.

###### Example 12\.

Consider the guarded set\{r​\(X1,X2\)¯,p​\(X2\)\}\\\{\\underline\{r\(X\_\{1\},X\_\{2\}\)\},p\(X\_\{2\}\)\\\}\. There are two associated reconstruction rules, namelyp\{r​\(X1,X2\)¯,p​\(X2\)\}​\(X1,X2\)→r​\(X1,X2\)p\_\{\\\{\\underline\{r\(X\_\{1\},X\_\{2\}\)\},p\(X\_\{2\}\)\\\}\}\(X\_\{1\},X\_\{2\}\)\\rightarrow r\(X\_\{1\},X\_\{2\}\)andp\{r​\(X1,X2\)¯,p​\(X2\)\}​\(X1,X2\)→p​\(X2\)p\_\{\\\{\\underline\{r\(X\_\{1\},X\_\{2\}\)\},p\(X\_\{2\}\)\\\}\}\(X\_\{1\},X\_\{2\}\)\\rightarrow p\(X\_\{2\}\)\.

Their role is to reconstruct the atoms on the original vocabulary that are encoded by complex predicates\.

###### Definition 13 \(Expansion\)\.

The*expansion*of a complex atomα\\alpha, denoted byexpansion​\(α\)\\mathrm\{expansion\}\(\\alpha\), is defined as𝖼𝗁𝖺𝗌𝖾​\(α,ℛr\)∖\{α\}\\mathsf\{chase\}\(\\alpha,\\mathcal\{R\}\_\{r\}\)\\setminus\\\{\\alpha\\\}\. The expansion of a set of complex atoms is the union of the expansions of its atoms\.

The next lemmas formalize the role of reconstruction rules\.

###### Lemma 14\.

Let\(G,α\)\(G,\\alpha\)be a guarded set of atoms\. It holds that

expansion​\(𝖼𝖺𝗇​\(G,α\)\)=G\.\\mathrm\{expansion\}\(\\mathsf\{can\}\(G,\\alpha\)\)=G\.

###### Proof\.

We prove both inclusions\. Let us first prove thatG⊆expansion​\(𝖼𝖺𝗇​\(G,α\)\)G\\subseteq\\mathrm\{expansion\}\(\\mathsf\{can\}\(G,\\alpha\)\)\. Letβ∈G\\beta\\in G\. It holds thatΦα​\(β\)∈Φα​\(G\)\\Phi\_\{\\alpha\}\(\\beta\)\\in\\Phi\_\{\\alpha\}\(G\)\. Moreover𝖼𝖺𝗇​\(Φα​\(G\),Φα​\(α\)\)→Φα​\(β\)\\mathsf\{can\}\(\\Phi\_\{\\alpha\}\(G\),\\Phi\_\{\\alpha\}\(\\alpha\)\)\\rightarrow\\Phi\_\{\\alpha\}\(\\beta\)belongs toℛr\\mathcal\{R\}\_\{r\}as\(Φα​\(G\),Φα​\(α\)\)∈𝒢\(\\Phi\_\{\\alpha\}\(G\),\\Phi\_\{\\alpha\}\(\\alpha\)\)\\in\\mathcal\{G\}\. This rule is applicable to𝖼𝖺𝗇​\(G,α\)\\mathsf\{can\}\(G,\\alpha\)and generatesβ\\beta\.

We now prove thatexpansion​\(𝖼𝖺𝗇​\(G,α\)\)⊆G\\mathrm\{expansion\}\(\\mathsf\{can\}\(G,\\alpha\)\)\\subseteq G\. Any reconstruction rule applicable to𝖼𝖺𝗇​\(G,α\)\\mathsf\{can\}\(G,\\alpha\)is of the form𝖼𝖺𝗇​\(Φα​\(G\),Φα​\(α\)\)→Φα​\(γ\)\\mathsf\{can\}\(\\Phi\_\{\\alpha\}\(G\),\\Phi\_\{\\alpha\}\(\\alpha\)\)\\rightarrow\\Phi\_\{\\alpha\}\(\\gamma\)for someγ∈G\\gamma\\in G\. Applying such a rule to𝖼𝖺𝗇​\(G,α\)\\mathsf\{can\}\(G,\\alpha\)generatesβ\\betaonly ifβ∈G\\beta\\in G\. ∎

Using Lemma[14](https://arxiv.org/html/2607.22636#Thmtheorem14b), we show that the expansion ofI′I^\{\\prime\}is the first instance of a locally completeℛ\\mathcal\{R\}\-derivation ofII\.

###### Lemma 15\.

It holds that:

expansion​\(I′\)=𝖼𝗁𝖺𝗌𝖾​\(I,ℛ\)∣𝗍𝖾𝗋𝗆𝗌\(I\)\.\\mathrm\{expansion\}\(I^\{\\prime\}\)=\\mathsf\{chase\}\(I,\\mathcal\{R\}\)\_\{\\mid\\mathsf\{terms\}\{\(I\)\}\}\.

###### Proof\.

By definition,I′=∪α∈I𝖼𝖺𝗇​\(Iα∗,α\)I^\{\\prime\}=\\cup\_\{\\alpha\\in I\}\\mathsf\{can\}\(I^\{\*\}\_\{\\alpha\},\\alpha\)\. Hence,expansion​\(I′\)=∪α∈Iexpansion​\(𝖼𝖺𝗇​\(Iα∗,α\)\)\\mathrm\{expansion\}\(I^\{\\prime\}\)=\\cup\_\{\\alpha\\in I\}\\mathrm\{expansion\}\(\\mathsf\{can\}\(I^\{\*\}\_\{\\alpha\},\\alpha\)\)\. By applying Lemma[14](https://arxiv.org/html/2607.22636#Thmtheorem14b), it holds thatexpansion​\(𝖼𝖺𝗇​\(Iα∗,α\)\)=Iα∗\\mathrm\{expansion\}\(\\mathsf\{can\}\(I^\{\*\}\_\{\\alpha\},\\alpha\)\)=I^\{\*\}\_\{\\alpha\}, henceexpansion​\(I′\)=∪α∈IIα∗\\mathrm\{expansion\}\(I^\{\\prime\}\)=\\cup\_\{\\alpha\\in I\}I^\{\*\}\_\{\\alpha\}\. As∪α∈IIα∗=𝖼𝗁𝖺𝗌𝖾​\(I,ℛ\)∣𝗍𝖾𝗋𝗆𝗌\(I\)\\cup\_\{\\alpha\\in I\}I^\{\*\}\_\{\\alpha\}=\\mathsf\{chase\}\(I,\\mathcal\{R\}\)\_\{\\mid\\mathsf\{terms\}\{\(I\)\}\}by Proposition[8](https://arxiv.org/html/2607.22636#Thmtheorem8b), this concludes the proof\. ∎

We now focus on complex rules\. We recall that their role is to simulate one step of a locally complete derivation\.

###### Definition 16 \(Complex rules \(ℛc\\mathcal\{R\}\_\{c\}\)\)\.

Let\(G,α\)∈𝒢\(G,\\alpha\)\\in\\mathcal\{G\}andρ∈ℛ\\rho\\in\\mathcal\{R\}be applicable toGGbyπ\\pi\. Letα′=πsafe​\(𝗁𝖾𝖺𝖽​\(ρ\)\)\\alpha^\{\\prime\}=\\pi^\{\\mathrm\{safe\}\}\(\\mathsf\{head\}\(\\rho\)\)andΦα′,𝗍𝖾𝗋𝗆𝗌​\(α\)​\(α′\)\\varPhi\_\{\\alpha^\{\\prime\},\\mathsf\{terms\}\{\(\\alpha\)\}\}\(\\alpha^\{\\prime\}\)be the canonical renaming ofα′\\alpha^\{\\prime\}w\.r\.t\.𝗍𝖾𝗋𝗆𝗌​\(α\)\\mathsf\{terms\}\{\(\\alpha\)\}\. The*complex rule*associated withG,ρG,\\rhoandπ\\piis:

𝖼𝖺𝗇​\(G,α\)→𝖼𝖺𝗇​\(G′,Φα′,𝗍𝖾𝗋𝗆𝗌​\(α\)​\(α′\)\)\\mathsf\{can\}\(G,\\alpha\)\\rightarrow\\mathsf\{can\}\(G^\{\\prime\},\\varPhi\_\{\\alpha^\{\\prime\},\\mathsf\{terms\}\{\(\\alpha\)\}\}\(\\alpha^\{\\prime\}\)\)whereG′=Φα′,𝗍𝖾𝗋𝗆𝗌​\(α\)​\(𝖼𝗁𝖺𝗌𝖾​\(G∪\{α′\},ℛ\)∣𝗍𝖾𝗋𝗆𝗌\(α′\)\)G^\{\\prime\}=\\varPhi\_\{\\alpha^\{\\prime\},\\mathsf\{terms\}\{\(\\alpha\)\}\}\(\\mathsf\{chase\}\(G\\cup\\\{\\alpha^\{\\prime\}\\\},\\mathcal\{R\}\)\_\{\\mid\\mathsf\{terms\}\{\(\\alpha^\{\\prime\}\)\}\}\)\. The set of complex rules \(associated with𝒢\\mathcal\{G\}\) is denoted byℛc\\mathcal\{R\}\_\{c\}\.

###### Example 17\.

We continue Example[7](https://arxiv.org/html/2607.22636#Thmtheorem7b)\. Consider the guarded setG=\{r​\(X1,X2\)¯,p​\(X1\),q​\(X1\),q​\(X2\)\}G=\\\{\\underline\{r\(X\_\{1\},X\_\{2\}\)\},p\(X\_\{1\}\),q\(X\_\{1\}\),q\(X\_\{2\}\)\\\}\. The rulep​\(x\)∧q​\(x\)→∃y​s​\(x,y\)p\(x\)\\wedge q\(x\)\\rightarrow\\exists y~s\(x,y\)is applicable toGGthroughπ=\{x↦X1\}\\pi=\\\{x\\mapsto X\_\{1\}\\\}\. Hence, we build the complex rulepr​\(X1,X2\)¯,p​\(X1\),q​\(X1\),q​\(X2\)​\(X1,X2\)→pG′​\(X1,X3\)p\_\{\\underline\{r\(X\_\{1\},X\_\{2\}\)\},p\(X\_\{1\}\),q\(X\_\{1\}\),q\(X\_\{2\}\)\}\(X\_\{1\},X\_\{2\}\)\\rightarrow p\_\{G^\{\\prime\}\}\(X\_\{1\},X\_\{3\}\), whereG′=\{s​\(X1,X3\)¯,p​\(X1\),q​\(X1\),h​\(X3\)\}G^\{\\prime\}=\\\{\\underline\{s\(X\_\{1\},X\_\{3\}\)\},p\(X\_\{1\}\),q\(X\_\{1\}\),h\(X\_\{3\}\)\\\}\. Note thatG′G^\{\\prime\}containsh​\(X3\)h\(X\_\{3\}\), which is not justified by the application ofp​\(x\)∧q​\(x\)→∃y​s​\(x,y\)p\(x\)\\wedge q\(x\)\\rightarrow\\exists y~s\(x,y\)itself, but by the future application ofq​\(x\)∧s​\(x,y\)→h​\(y\)q\(x\)\\wedge s\(x,y\)\\rightarrow h\(y\)\.

We now focus on showing the correspondence between a \(classical\)ℛc\\mathcal\{R\}\_\{c\}\-derivation and a locally completeℛ\\mathcal\{R\}\-derivation\. Lemma[18](https://arxiv.org/html/2607.22636#Thmtheorem18a)specifies the correspondence at the level of a single rule application\.

###### Lemma 18\.

Let\(G,α=r​\(𝐭\)\)\(G,\\alpha=r\(\\mathbf\{t\}\)\)be a guarded set such that𝖼𝗁𝖺𝗌𝖾​\(G,ℛ\)∣𝗍𝖾𝗋𝗆𝗌\(G\)=G\\mathsf\{chase\}\(G,\\mathcal\{R\}\)\_\{\\mid\\mathsf\{terms\}\{\(G\)\}\}=G\. The following statements hold:

- •Letρ∈ℛ\\rho\\in\\mathcal\{R\}be applicable toGGbyπ\\pi, and letG^\\hat\{G\}be obtained by the corresponding locally complete derivation step\. There exists a complex ruleρ′\\rho^\{\\prime\}applicable topΦα​\(G\)​\(𝐭\)p\_\{\\Phi\_\{\\alpha\}\(G\)\}\(\\mathbf\{t\}\)byπ′\\pi^\{\\prime\}such that there exists a homomorphismφ\\varphifromG^\\hat\{G\}toexpansion​\(pΦα​\(G\)​\(𝐭\)∪π′⁣safe​\(𝗁𝖾𝖺𝖽​\(ρ′\)\)\)\\mathrm\{expansion\}\(p\_\{\\Phi\_\{\\alpha\}\(G\)\}\(\\mathbf\{t\}\)\\cup\\pi^\{\\prime\\mathrm\{safe\}\}\(\\mathsf\{head\}\(\\rho^\{\\prime\}\)\)\)withφ\\varphibeing the identity on𝗍𝖾𝗋𝗆𝗌​\(G\)\\mathsf\{terms\}\{\(G\)\}\.
- •Letρ′∈ℛc\\rho^\{\\prime\}\\in\\mathcal\{R\}\_\{c\}be applicable toG′=pΦα​\(G\)​\(𝐭\)G^\{\\prime\}=p\_\{\\Phi\_\{\\alpha\}\(G\)\}\(\\mathbf\{t\}\)byπ′\\pi^\{\\prime\}, and letF′=G′∪π′⁣safe​\(𝗁𝖾𝖺𝖽​\(ρ′\)\)F^\{\\prime\}=G^\{\\prime\}\\cup\\pi^\{\\prime\\mathrm\{safe\}\}\(\\mathsf\{head\}\(\\rho^\{\\prime\}\)\)\. There existsρ∈ℛ\\rho\\in\\mathcal\{R\}applicable toGG, generatingG^\\hat\{G\}by one step of locally complete derivation, such that there exists a homomorphismφ\\varphifromexpansion​\(F′\)\\mathrm\{expansion\}\(F^\{\\prime\}\)toG^\\hat\{G\}withφ\\varphibeing the identity on𝗍𝖾𝗋𝗆𝗌​\(G\)\\mathsf\{terms\}\{\(G\)\}\.

###### Proof\.

1. \(1\)Letρ\\rhobe applicable toGGbyπ\\pi, generatingα^\\hat\{\\alpha\}\. Thenρ\\rhois applicable toΦα​\(G\)\\varPhi\_\{\\alpha\}\(G\)byπ∗=Φα∘π\\pi^\{\*\}=\\varPhi\_\{\\alpha\}\\circ\\pi\. By the definition of complex rules, there is a ruleρ′=𝖼𝖺𝗇​\(Φα​\(G\),Φα​\(α\)\)→𝖼𝖺𝗇​\(G∗,Φα∗,𝗍𝖾𝗋𝗆𝗌​\(Φα​\(α\)\)​\(α∗\)\)\\rho^\{\\prime\}=\\mathsf\{can\}\(\\varPhi\_\{\\alpha\}\(G\),\\varPhi\_\{\\alpha\}\(\\alpha\)\)\\rightarrow\\mathsf\{can\}\(G^\{\*\},\\varPhi\_\{\\alpha^\{\*\},\\mathsf\{terms\}\{\(\\varPhi\_\{\\alpha\}\(\\alpha\)\)\}\}\(\\alpha^\{\*\}\)\), where we defineα∗=π∗safe​\(𝗁𝖾𝖺𝖽​\(ρ\)\)\\alpha^\{\*\}=\{\\pi^\{\*\}\}^\{\\mathrm\{safe\}\}\(\\mathsf\{head\}\(\\rho\)\)andG∗=Φα∗,𝗍𝖾𝗋𝗆𝗌​\(Φα​\(α\)\)​\(𝖼𝗁𝖺𝗌𝖾​\(Φα​\(G\)∪\{α∗\},ℛ\)∣𝗍𝖾𝗋𝗆𝗌\(α∗\)\)G^\{\*\}=\\varPhi\_\{\\alpha^\{\*\},\\mathsf\{terms\}\{\(\\varPhi\_\{\\alpha\}\(\\alpha\)\)\}\}\(\\mathsf\{chase\}\(\\varPhi\_\{\\alpha\}\(G\)\\cup\\\{\\alpha^\{\*\}\\\},\\mathcal\{R\}\)\_\{\\mid\\mathsf\{terms\}\{\(\\alpha^\{\*\}\)\}\}\)\. The ruleρ′\\rho^\{\\prime\}is applicable to𝖼𝖺𝗇​\(G,α\)=pΦα​\(G\)​\(𝐭\)\\mathsf\{can\}\(G,\\alpha\)=p\_\{\\varPhi\_\{\\alpha\}\(G\)\}\(\\mathbf\{t\}\)byπ′=Φα−1\\pi^\{\\prime\}=\\varPhi\_\{\\alpha\}^\{\-1\}and yields the atomα′=π′safe​\(𝗁𝖾𝖺𝖽​\(ρ′\)\)\\alpha^\{\\prime\}=\{\\pi^\{\\prime\}\}^\{\\mathrm\{safe\}\}\(\\mathsf\{head\}\(\\rho^\{\\prime\}\)\)\. LetG^\\hat\{G\}be the result of performing a single locally complete derivation step toGGusing the ruleρ\\rhoandπ\\pi, i\.e\.,G^=𝖼𝗁𝖺𝗌𝖾​\(G∪α^,ℛ\)∣𝗍𝖾𝗋𝗆𝗌\(G∪\{α^\}\)\\hat\{G\}=\\mathsf\{chase\}\(G\\cup\\hat\{\\alpha\},\\mathcal\{R\}\)\_\{\\mid\\mathsf\{terms\}\{\(G\\cup\\\{\\hat\{\\alpha\}\\\}\)\}\}\. Defineφ\\varphias the injective mapping that is the identity on the terms ofGGand that associates with each fresh null inα^\\hat\{\\alpha\}the corresponding fresh null fromα′\\alpha^\{\\prime\}that was introduced by applyingρ′\\rho^\{\\prime\}topΦα​\(G\)​\(𝐭\)p\_\{\\varPhi\_\{\\alpha\}\(G\)\}\(\\mathbf\{t\}\)\. We claim thatφ\\varphiis a homomorphism fromG^\\hat\{G\}toexpansion​\(𝖼𝖺𝗇​\(G,α\)∪α′\)\\mathrm\{expansion\}\(\\mathsf\{can\}\(G,\\alpha\)\\cup\\alpha^\{\\prime\}\)\. Indeed, ifβ∈G^\\beta\\in\\hat\{G\}and𝗍𝖾𝗋𝗆𝗌​\(β\)⊆𝗍𝖾𝗋𝗆𝗌​\(G\)\\mathsf\{terms\}\{\(\\beta\)\}\\subseteq\\mathsf\{terms\}\{\(G\)\}, then by assumption,β∈G\\beta\\in G, and thus belongs toexpansion​\(𝖼𝖺𝗇​\(G,α\)\)\\mathrm\{expansion\}\(\\mathsf\{can\}\(G,\\alpha\)\)by Lemma[14](https://arxiv.org/html/2607.22636#Thmtheorem14b)\. Otherwise, we have𝗍𝖾𝗋𝗆𝗌​\(β\)⊆𝗍𝖾𝗋𝗆𝗌​\(α^\)\\mathsf\{terms\}\{\(\\beta\)\}\\subseteq\\mathsf\{terms\}\{\(\\hat\{\\alpha\}\)\}andβ∈𝖼𝗁𝖺𝗌𝖾​\(G∪\{α^\},ℛ\)∣𝗍𝖾𝗋𝗆𝗌\(α^\)\\beta\\in\\mathsf\{chase\}\(G\\cup\\\{\\hat\{\\alpha\}\\\},\\mathcal\{R\}\)\_\{\\mid\\mathsf\{terms\}\{\(\\hat\{\\alpha\}\)\}\}\. We then remark thatexpansion​\(α′\)=𝖼𝗁𝖺𝗌𝖾​\(G∪\{φ−1​\(α^\)\},ℛ\)∣𝗍𝖾𝗋𝗆𝗌\(φ−1\(α^\)\)\\mathrm\{expansion\}\(\\alpha^\{\\prime\}\)=\\mathsf\{chase\}\(G\\cup\\\{\\varphi^\{\-1\}\(\\hat\{\\alpha\}\)\\\},\\mathcal\{R\}\)\_\{\\mid\\mathsf\{terms\}\{\(\\varphi^\{\-1\}\(\\hat\{\\alpha\}\)\)\}\}, from which we obtainφ​\(β\)∈expansion​\(α′\)\\varphi\(\\beta\)\\in\\mathrm\{expansion\}\(\\alpha^\{\\prime\}\)\.
2. \(2\)Supposeρ′∈ℛc\\rho^\{\\prime\}\\in\\mathcal\{R\}\_\{c\}is applicable toG′=pΦα​\(G\)​\(𝐭\)=𝖼𝖺𝗇​\(G,α\)G^\{\\prime\}=p\_\{\\Phi\_\{\\alpha\}\(G\)\}\(\\mathbf\{t\}\)=\\mathsf\{can\}\(G,\\alpha\)byπ′\\pi^\{\\prime\}, and letF′=G′∪\{α′\}F^\{\\prime\}=G^\{\\prime\}\\cup\\\{\\alpha^\{\\prime\}\\\}, whereα′=π′⁣safe​\(𝗁𝖾𝖺𝖽​\(ρ′\)\)\\alpha^\{\\prime\}=\\pi^\{\\prime\\mathrm\{safe\}\}\(\\mathsf\{head\}\(\\rho^\{\\prime\}\)\)\. Asρ′\\rho^\{\\prime\}is a complex rule, it has been created because some\(Gc,αc\)\(G\_\{c\},\\alpha\_\{c\}\)belongs to𝒢\\mathcal\{G\}, withΦαc​\(Gc\)=Φα​\(G\)\\varPhi\_\{\\alpha\_\{c\}\}\(G\_\{c\}\)=\\varPhi\_\{\\alpha\}\(G\), and there is some \(original\) ruleρ\\rhothat is applicable toGcG\_\{c\}through someπ∗\\pi^\{\*\}, such that𝗁𝖾𝖺𝖽​\(ρ′\)=𝖼𝖺𝗇​\(G∗,Φα∗,𝗍𝖾𝗋𝗆𝗌​\(αc\)​\(α∗\)\)\\mathsf\{head\}\(\\rho^\{\\prime\}\)=\\mathsf\{can\}\(G^\{\*\},\\varPhi\_\{\\alpha^\{\*\},\\mathsf\{terms\}\{\(\\alpha\_\{c\}\)\}\}\(\\alpha^\{\*\}\)\), whereα∗=π∗safe​\(𝗁𝖾𝖺𝖽​\(ρ\)\)\\alpha^\{\*\}=\{\\pi^\{\*\}\}^\{\\mathrm\{safe\}\}\(\\mathsf\{head\}\(\\rho\)\)andG∗=Φα∗,𝗍𝖾𝗋𝗆𝗌​\(αc\)​\(𝖼𝗁𝖺𝗌𝖾​\(Gc∪\{α∗\},ℛ\)∣𝗍𝖾𝗋𝗆𝗌\(α∗\)\)G^\{\*\}=\\varPhi\_\{\\alpha^\{\*\},\\mathsf\{terms\}\{\(\\alpha\_\{c\}\)\}\}\(\\mathsf\{chase\}\(G\_\{c\}\\cup\\\{\\alpha^\{\*\}\\\},\\mathcal\{R\}\)\_\{\\mid\\mathsf\{terms\}\{\(\\alpha^\{\*\}\)\}\}\)\. Observe thatGGandGcG\_\{c\}are isomorphic, and letΨ\\Psibe an isomorphism fromGcG\_\{c\}toGG\. Thenρ\\rhois applicable toGGviaπ=Ψ∘π∗\\pi=\\Psi\\circ\\pi^\{\*\}, and the locally complete derivation step yieldsG^=𝖼𝗁𝖺𝗌𝖾\(G∪\{α^\},ℛ\)∣𝗍𝖾𝗋𝗆𝗌\(G∪\{α^\}\)\)\\hat\{G\}=\\mathsf\{chase\}\(G\\cup\\\{\\hat\{\\alpha\}\\\},\\mathcal\{R\}\)\_\{\\mid\\mathsf\{terms\}\{\(G\\cup\\\{\\hat\{\\alpha\}\\\}\)\}\}\), withα^=πsafe​\(𝗁𝖾𝖺𝖽​\(ρ\)\)\\hat\{\\alpha\}=\\pi^\{\\mathrm\{safe\}\}\(\\mathsf\{head\}\(\\rho\)\)\. Now letφ\\varphibe the \(injective\) extension of the identity on𝗍𝖾𝗋𝗆𝗌​\(G\)\\mathsf\{terms\}\{\(G\)\}that maps each fresh null inα′\\alpha^\{\\prime\}introduced during the application ofρ′\\rho^\{\\prime\}toG′G^\{\\prime\}to the corresponding null inα^\\hat\{\\alpha\}introduced by the application ofρ\\rhotoGG\. An atomβ\\betainexpansion​\(F′\)\\mathrm\{expansion\}\(F^\{\\prime\}\)belongs either toexpansion​\(𝖼𝖺𝗇​\(G,α\)\)\\mathrm\{expansion\}\(\\mathsf\{can\}\(G,\\alpha\)\)or toexpansion​\(α′\)\\mathrm\{expansion\}\(\\alpha^\{\\prime\}\)\. By Lemma[14](https://arxiv.org/html/2607.22636#Thmtheorem14b), we haveexpansion​\(𝖼𝖺𝗇​\(G,α\)\)=G\\mathrm\{expansion\}\(\\mathsf\{can\}\(G,\\alpha\)\)=G\. It follows that ifβ∈expansion​\(𝖼𝖺𝗇​\(G,α\)\)\\beta\\in\\mathrm\{expansion\}\(\\mathsf\{can\}\(G,\\alpha\)\), thenφ​\(β\)=β∈G⊆G^\\varphi\(\\beta\)=\\beta\\in G\\subseteq\\hat\{G\}\. Otherwise,β∈expansion​\(α′\)\\beta\\in\\mathrm\{expansion\}\(\\alpha^\{\\prime\}\), soβ∈𝖼𝗁𝖺𝗌𝖾​\(G∪\{φ−1​\(α^\)\},ℛ\)∣𝗍𝖾𝗋𝗆𝗌\(φ−1\(α^\)\)\\beta\\in\\mathsf\{chase\}\(G\\cup\\\{\\varphi^\{\-1\}\(\\hat\{\\alpha\}\)\\\},\\mathcal\{R\}\)\_\{\\mid\\mathsf\{terms\}\{\(\\varphi^\{\-1\}\(\\hat\{\\alpha\}\)\)\}\}\. From this we obtainφ​\(β\)∈𝖼𝗁𝖺𝗌𝖾​\(G∪\{α^\},ℛ\)∣𝗍𝖾𝗋𝗆𝗌\(α^\)⊆G^\\varphi\(\\beta\)\\in\\mathsf\{chase\}\(G\\cup\\\{\\hat\{\\alpha\}\\\},\\mathcal\{R\}\)\_\{\\mid\\mathsf\{terms\}\{\(\\hat\{\\alpha\}\)\}\}\\subseteq\\hat\{G\}\.∎

Repeatedly using the first bullet point of Lemma[18](https://arxiv.org/html/2607.22636#Thmtheorem18a), Proposition[19](https://arxiv.org/html/2607.22636#Thmtheorem19)proves that anything that is entailed by a locally completeℛ\\mathcal\{R\}\-derivation ofIIis also entailed by the expansion of anℛc\\mathcal\{R\}\_\{c\}\-derivation ofI′I^\{\\prime\}—the guarded translation ofII\.

###### Proposition 19\.

Letℛ\\mathcal\{R\}be a set of guarded rules andIIbe an instance\. LetI0^,…,I^n\\hat\{I\_\{0\}\},\\ldots,\\hat\{I\}\_\{n\}be a locally completeℛ\\mathcal\{R\}\-derivation fromII\. LetI′I^\{\\prime\}andℛc\\mathcal\{R\}\_\{c\}be defined as above\. There is a classicalℛc\\mathcal\{R\}\_\{c\}\-derivationI′=I0′,…,In′I^\{\\prime\}=I^\{\\prime\}\_\{0\},\\ldots,I^\{\\prime\}\_\{n\}such that for anyi∈\{1,…,n\}i\\in\\\{1,\\ldots,n\\\}, there exists a homomorphismφi\\varphi\_\{i\}fromIiI\_\{i\}toexpansion​\(Ii′\)\\mathrm\{expansion\}\(I^\{\\prime\}\_\{i\}\), such that for all guarded sets\(G,α\)\(G,\\alpha\)withG⊆IiG\\subseteq I\_\{i\}, there is an atomβ∈Ii′\\beta\\in I^\{\\prime\}\_\{i\}withφi​\(G\)⊆expansion​\(β\)\\varphi\_\{i\}\(G\)\\subseteq\\mathrm\{expansion\}\(\\beta\)\.

###### Proof\.

We prove the result by induction on the length of the locally complete derivation\.

- •If the locally complete derivation is of length0, thenI0=𝖼𝗁𝖺𝗌𝖾​\(I,ℛ\)∣𝗍𝖾𝗋𝗆𝗌\(I\)=expansion​\(I′\)I\_\{0\}=\\mathsf\{chase\}\(I,\\mathcal\{R\}\)\_\{\\mid\\mathsf\{terms\}\{\(I\)\}\}=\\mathrm\{expansion\}\(I^\{\\prime\}\)by Lemma[15](https://arxiv.org/html/2607.22636#Thmtheorem15a), and one can take the identity forφ0\\varphi\_\{0\}\. Indeed, if\(G,α\)\(G,\\alpha\)is a guarded set withG⊆I0G\\subseteq I\_\{0\}, we letβ=𝖼𝖺𝗇​\(Iα∗\)∈I′\\beta=\\mathsf\{can\}\(I^\{\*\}\_\{\\alpha\}\)\\in I^\{\\prime\}and observe thatG⊆𝖼𝗁𝖺𝗌𝖾​\(I,ℛ\)∣𝗍𝖾𝗋𝗆𝗌\(α\)=expansion​\(β\)G\\subseteq\\mathsf\{chase\}\(I,\\mathcal\{R\}\)\_\{\\mid\\mathsf\{terms\}\{\(\\alpha\)\}\}=\\mathrm\{expansion\}\(\\beta\)\.
- •Otherwise, let us assume that there is a homomorphismφi\\varphi\_\{i\}fromIiI\_\{i\}toexpansion​\(Ii′\)\\mathrm\{expansion\}\(I^\{\\prime\}\_\{i\}\)such that for all guarded setsG⊆IiG\\subseteq I\_\{i\}, there existsβ∈Ii′\\beta\\in I^\{\\prime\}\_\{i\}such thatφi​\(G\)⊆expansion​\(β\)\\varphi\_\{i\}\(G\)\\subseteq\\mathrm\{expansion\}\(\\beta\)\. Letρi\\rho\_\{i\}be the rule applied toIiI\_\{i\}throughπi\\pi\_\{i\}to generateIi\+1I\_\{i\+1\}, creating an atomαi\+1\\alpha\_\{i\+1\}\. Asπi​\(𝖻𝗈𝖽𝗒​\(ρi\)\)\\pi\_\{i\}\(\\mathsf\{body\}\(\\rho\_\{i\}\)\)is a guarded set inIiI\_\{i\}, by the induction assumption, there isβi∈Ii′\\beta\_\{i\}\\in I^\{\\prime\}\_\{i\}such thatφi​\(πi​\(𝖻𝗈𝖽𝗒​\(ρi\)\)\)⊆expansion​\(βi\)\\varphi\_\{i\}\(\\pi\_\{i\}\(\\mathsf\{body\}\(\\rho\_\{i\}\)\)\)\\subseteq\\mathrm\{expansion\}\(\\beta\_\{i\}\)\. Let us notice that𝖼𝗁𝖺𝗌𝖾​\(expansion​\(βi\),ℛ\)∣𝗍𝖾𝗋𝗆𝗌\(expansion\(βi\)\)=expansion​\(βi\)\\mathsf\{chase\}\(\\mathrm\{expansion\}\(\\beta\_\{i\}\),\\mathcal\{R\}\)\_\{\\mid\\mathsf\{terms\}\{\(\\mathrm\{expansion\}\(\\beta\_\{i\}\)\)\}\}=\\mathrm\{expansion\}\(\\beta\_\{i\}\), as it holds for any initialβi\\beta\_\{i\}and for any atom added by definition of complex rules\. Also observe thatβi=𝖼𝖺𝗇​\(expansion​\(βi\)\)\\beta\_\{i\}=\\mathsf\{can\}\(\\mathrm\{expansion\}\(\\beta\_\{i\}\)\)\. We can thus apply Lemma[18](https://arxiv.org/html/2607.22636#Thmtheorem18a)to infer that there existsρi′\\rho\_\{i\}^\{\\prime\}applicable toβi\\beta\_\{i\}, whose application createsαi\+1′\\alpha^\{\\prime\}\_\{i\+1\}, such that there is a homomorphism from𝖼𝗁𝖺𝗌𝖾​\(expansion​\(βi\)∪\{αi\+1\},ℛ\)∣𝗍𝖾𝗋𝗆𝗌\(αi\+1\)\\mathsf\{chase\}\(\\mathrm\{expansion\}\(\\beta\_\{i\}\)\\cup\\\{\\alpha\_\{i\+1\}\\\},\\mathcal\{R\}\)\_\{\\mid\\mathsf\{terms\}\{\(\\alpha\_\{i\+1\}\)\}\}toexpansion​\(βi∪αi\+1′\)\\mathrm\{expansion\}\(\\beta\_\{i\}\\cup\\alpha\_\{i\+1\}^\{\\prime\}\)that is the identity on𝗍𝖾𝗋𝗆𝗌​\(expansion​\(βi\)\)\\mathsf\{terms\}\{\(\\mathrm\{expansion\}\(\\beta\_\{i\}\)\)\}We defineφi\+1\\varphi\_\{i\+1\}as the mapping extendingφi\\varphi\_\{i\}by mapping a fresh null introduced inαi\+1\\alpha\_\{i\+1\}to the corresponding fresh null introduced inαi\+1′\\alpha^\{\\prime\}\_\{i\+1\}\. For any guarded setGGofIi\+1I\_\{i\+1\}, one of the two following case holds: - –𝗍𝖾𝗋𝗆𝗌​\(G\)⊆𝗍𝖾𝗋𝗆𝗌​\(Ii\)\\mathsf\{terms\}\{\(G\)\}\\subseteq\\mathsf\{terms\}\{\(I\_\{i\}\)\}, and so by induction assumption, there existsβi∈Ii′\\beta\_\{i\}\\in I\_\{i\}^\{\\prime\}for whichφi\+1​\(G\)=φi​\(G\)⊆expansion​\(βi\)\\varphi\_\{i\+1\}\(G\)=\\varphi\_\{i\}\(G\)\\subseteq\\mathrm\{expansion\}\(\\beta\_\{i\}\); - –𝗍𝖾𝗋𝗆𝗌​\(G\)⊆𝗍𝖾𝗋𝗆𝗌​\(αi\+1\)\\mathsf\{terms\}\{\(G\)\}\\subseteq\\mathsf\{terms\}\{\(\\alpha\_\{i\+1\}\)\}, in which caseαi\+1′∈Ii\+1′\\alpha^\{\\prime\}\_\{i\+1\}\\in I\_\{i\+1\}^\{\\prime\}is such thatφi\+1​\(G\)⊆expansion​\(αi\+1′\)\\varphi\_\{i\+1\}\(G\)\\subseteq\\mathrm\{expansion\}\(\\alpha^\{\\prime\}\_\{i\+1\}\)\. In particular, this implies thatφi\+1\\varphi\_\{i\+1\}is a homomorphism fromIi\+1I\_\{i\+1\}toexpansion​\(Ii\+1′\)\\mathrm\{expansion\}\(I\_\{i\+1\}^\{\\prime\}\)\. ∎

Conversely, Proposition[20](https://arxiv.org/html/2607.22636#Thmtheorem20)uses the second bullet point of Lemma[18](https://arxiv.org/html/2607.22636#Thmtheorem18a)to show that anything that is entailed by the expansion of the result of a classicalℛc\\mathcal\{R\}\_\{c\}\-derivation ofI′I^\{\\prime\}is also entailed by the result of a locally completeℛ\\mathcal\{R\}\-derivation ofII\.

###### Proposition 20\.

Letℛ\\mathcal\{R\}be a set of guarded rules andIIbe an instance\. LetI′I^\{\\prime\}andℛc\\mathcal\{R\}\_\{c\}be defined as above\. For any classicalℛc\\mathcal\{R\}\_\{c\}\-derivationI′=I0′,…,In′I^\{\\prime\}=I^\{\\prime\}\_\{0\},\\ldots,I^\{\\prime\}\_\{n\}, there exists a locally completeℛ\\mathcal\{R\}\-derivationI^0=𝖼𝗁𝖺𝗌𝖾​\(I,ℛ\)∣𝗍𝖾𝗋𝗆𝗌\(I\),…,I^n\\hat\{I\}\_\{0\}=\\mathsf\{chase\}\(I,\\mathcal\{R\}\)\_\{\\mid\\mathsf\{terms\}\{\(I\)\}\},\\ldots,\\hat\{I\}\_\{n\}such that for anyi∈\{0,…,n\}i\\in\\\{0,\\ldots,n\\\}, there is a homomorphismφi\\varphi\_\{i\}fromexpansion​\(Ii′\)\\mathrm\{expansion\}\(I^\{\\prime\}\_\{i\}\)toI^i\\hat\{I\}\_\{i\}\.

###### Proof\.

We show the result by induction on the length of theℛc\\mathcal\{R\}\_\{c\}\-derivation\.

- •If theℛc\\mathcal\{R\}\_\{c\}\-derivation is of length0, thenIn′=I′I^\{\\prime\}\_\{n\}=I^\{\\prime\}, and by Lemma[15](https://arxiv.org/html/2607.22636#Thmtheorem15a),expansion​\(I′\)=𝖼𝗁𝖺𝗌𝖾​\(I,ℛ\)∣𝗍𝖾𝗋𝗆𝗌\(I\)\\mathrm\{expansion\}\(I^\{\\prime\}\)=\\mathsf\{chase\}\(I,\\mathcal\{R\}\)\_\{\\mid\\mathsf\{terms\}\{\(I\)\}\}\. The derivationI^0=𝖼𝗁𝖺𝗌𝖾​\(I,ℛ\)∣𝗍𝖾𝗋𝗆𝗌\(I\)\\hat\{I\}\_\{0\}=\\mathsf\{chase\}\(I,\\mathcal\{R\}\)\_\{\\mid\\mathsf\{terms\}\{\(I\)\}\}is a locally completeℛ\\mathcal\{R\}\-derivation ofIIof length0, and one can takeφ0\\varphi\_\{0\}as the identity;
- •Let us assume that there exists a homomorphismφi\\varphi\_\{i\}fromexpansion​\(Ii′\)\\mathrm\{expansion\}\(I^\{\\prime\}\_\{i\}\)toI^i\\hat\{I\}\_\{i\}\. Letρi∈ℛc\\rho\_\{i\}\\in\\mathcal\{R\}\_\{c\}be the rule applicable toIi′I^\{\\prime\}\_\{i\}byπi\\pi\_\{i\}onα\\alphathat yieldsIi\+1′=Ii′∪\{α′\}I^\{\\prime\}\_\{i\+1\}=I^\{\\prime\}\_\{i\}\\cup\\\{\\alpha^\{\\prime\}\\\}\. By Lemma[18](https://arxiv.org/html/2607.22636#Thmtheorem18a), there existsρ∈ℛ\\rho\\in\\mathcal\{R\}that is applicable toexpansion​\(α\)\\mathrm\{expansion\}\(\\alpha\)byπ′\\pi^\{\\prime\}such that there is a homomorphismhhfromexpansion​\(α∪α′\)\\mathrm\{expansion\}\(\\alpha\\cup\\alpha^\{\\prime\}\)to𝖼𝗁𝖺𝗌𝖾​\(H,ℛ\)∣𝗍𝖾𝗋𝗆𝗌\(H\)\\mathsf\{chase\}\(H,\\mathcal\{R\}\)\_\{\\mid\\mathsf\{terms\}\{\(H\)\}\}withH=expansion​\(α\)∪π′⁣safe​\(𝗁𝖾𝖺𝖽​\(ρ\)\)H=\\mathrm\{expansion\}\(\\alpha\)\\cup\\pi^\{\\prime\\mathrm\{safe\}\}\(\\mathsf\{head\}\(\\rho\)\)that is the identity on𝗍𝖾𝗋𝗆𝗌​\(expansion​\(α\)\)\\mathsf\{terms\}\{\(\\mathrm\{expansion\}\(\\alpha\)\)\}\. It follows in particular thatρ\\rhois applicable toφi​\(expansion​\(α\)\)⊆I^i\\varphi\_\{i\}\(\\mathrm\{expansion\}\(\\alpha\)\)\\subseteq\\hat\{I\}\_\{i\}usingπ′′=φi∘π′\\pi^\{\\prime\\prime\}=\\varphi\_\{i\}\\circ\\pi^\{\\prime\}\. We can thus letI^i\+1=𝖼𝗁𝖺𝗌𝖾​\(I^i∪π′′⁣safe​\(𝗁𝖾𝖺𝖽​\(ρ\)\),ℛ\)∣𝗍𝖾𝗋𝗆𝗌\(I^i∪π′′⁣safe\(𝗁𝖾𝖺𝖽\(ρ\)\)\)\\hat\{I\}\_\{i\+1\}=\\mathsf\{chase\}\(\\hat\{I\}\_\{i\}\\cup\\pi^\{\\prime\\prime\\mathrm\{safe\}\}\(\\mathsf\{head\}\(\\rho\)\),\\mathcal\{R\}\)\_\{\\mid\\mathsf\{terms\}\{\(\\hat\{I\}\_\{i\}\\cup\\pi^\{\\prime\\prime\\mathrm\{safe\}\}\(\\mathsf\{head\}\(\\rho\)\)\)\}\}be the result of applying the locally complete derivation step associated withρ\\rhoandπ′′\\pi^\{\\prime\\prime\}toI^i\\hat\{I\}\_\{i\}\. We observe that there is a homomorphismggfrom𝖼𝗁𝖺𝗌𝖾​\(H,ℛ\)∣𝗍𝖾𝗋𝗆𝗌\(H\)\\mathsf\{chase\}\(H,\\mathcal\{R\}\)\_\{\\mid\\mathsf\{terms\}\{\(H\)\}\}toI^i\+1\\hat\{I\}\_\{i\+1\}defined by settingg​\(t\)=φi​\(t\)g\(t\)=\\varphi\_\{i\}\(t\)for allt∈𝗍𝖾𝗋𝗆𝗌​\(expansion​\(α\)\)t\\in\\mathsf\{terms\}\{\(\\mathrm\{expansion\}\(\\alpha\)\)\}and for allt∈𝗍𝖾𝗋𝗆𝗌​\(π′⁣safe​\(𝗁𝖾𝖺𝖽​\(ρ\)\)\)∖𝗍𝖾𝗋𝗆𝗌​\(expansion​\(α\)\)t\\in\\mathsf\{terms\}\{\(\\pi^\{\\prime\\mathrm\{safe\}\}\(\\mathsf\{head\}\(\\rho\)\)\)\}\\setminus\\mathsf\{terms\}\{\(\\mathrm\{expansion\}\(\\alpha\)\)\}, lettingg​\(t\)g\(t\)be the corresponding fresh term inπ′′⁣safe​\(𝗁𝖾𝖺𝖽​\(ρ\)\)\\pi^\{\\prime\\prime\\mathrm\{safe\}\}\(\\mathsf\{head\}\(\\rho\)\)\. The desired homomorphismφi\+1\\varphi\_\{i\+1\}fromexpansion​\(Ii\+1′\)\\mathrm\{expansion\}\(I^\{\\prime\}\_\{i\+1\}\)toI^i\+1\\hat\{I\}\_\{i\+1\}is obtained by settingφi\+1​\(t\)=φi​\(t\)\\varphi\_\{i\+1\}\(t\)=\\varphi\_\{i\}\(t\)for allt∈𝗍𝖾𝗋𝗆𝗌​\(expansion​\(Ii′\)\)t\\in\\mathsf\{terms\}\{\(\\mathrm\{expansion\}\(I^\{\\prime\}\_\{i\}\)\)\}andφi\+1​\(t\)=g∘h​\(t\)\\varphi\_\{i\+1\}\(t\)=\{g\\circ h\(t\)\}for allt∈𝗍𝖾𝗋𝗆𝗌​\(expansion​\(Ii\+1′\)\)∖𝗍𝖾𝗋𝗆𝗌​\(expansion​\(Ii′\)\)⊆𝗍𝖾𝗋𝗆𝗌​\(expansion​\(α′\)\)∖𝗍𝖾𝗋𝗆𝗌​\(expansion​\(α\)\)t\\in\\mathsf\{terms\}\{\(\\mathrm\{expansion\}\(I^\{\\prime\}\_\{i\+1\}\)\)\}\\setminus\\mathsf\{terms\}\{\(\\mathrm\{expansion\}\(I^\{\\prime\}\_\{i\}\)\)\}\\subseteq\\mathsf\{terms\}\{\(\\mathrm\{expansion\}\(\\alpha^\{\\prime\}\)\)\}\\setminus\\mathsf\{terms\}\{\(\\mathrm\{expansion\}\(\\alpha\)\)\}\. Indeed, this is a consequence of the facts that \(i\)expansion​\(Ii\+1′\)=expansion​\(Ii′\)∪expansion​\(α′\)\\mathrm\{expansion\}\(I^\{\\prime\}\_\{i\+1\}\)=\\mathrm\{expansion\}\(I^\{\\prime\}\_\{i\}\)\\cup\\mathrm\{expansion\}\(\\alpha^\{\\prime\}\), \(ii\)φi\\varphi\_\{i\}is a homomorphism fromexpansion​\(Ii′\)\\mathrm\{expansion\}\(I^\{\\prime\}\_\{i\}\)toI^i⊆I^i\+1\\hat\{I\}\_\{i\}\\subseteq\\hat\{I\}\_\{i\+1\}, \(iii\)g∘hg\\circ his a homomorphism fromexpansion​\(α∪α′\)\\mathrm\{expansion\}\(\\alpha\\cup\\alpha^\{\\prime\}\)toI^i\+1\\hat\{I\}\_\{i\+1\}, \(iv\)φi\\varphi\_\{i\}andg∘hg\\circ hagree on their common domain, and \(v\)𝗍𝖾𝗋𝗆𝗌​\(expansion​\(α′\)\)∩𝗍𝖾𝗋𝗆𝗌​\(expansion​\(Ii′\)\)⊆𝗍𝖾𝗋𝗆𝗌​\(expansion​\(α\)\)\\mathsf\{terms\}\{\(\\mathrm\{expansion\}\(\\alpha^\{\\prime\}\)\)\}\\cap\\mathsf\{terms\}\{\(\\mathrm\{expansion\}\(I^\{\\prime\}\_\{i\}\)\)\}\\subseteq\\mathsf\{terms\}\{\(\\mathrm\{expansion\}\(\\alpha\)\)\}\. ∎

The preceding proposition together with Proposition[5](https://arxiv.org/html/2607.22636#Thmtheorem5c)directly imply the following corollary\.

###### Corollary 21\.

For any KB\(I,ℛ\)\(I,\\mathcal\{R\}\)and homomorphism\-closed Boolean queryqqon the original vocabulary, there is a locally completeℛ\\mathcal\{R\}\-derivation fromIIresulting inI^m\\hat\{I\}\_\{m\}such thatI^m⊧q\\hat\{I\}\_\{m\}\\models qiff there exists a classical\(ℛc∪ℛr\)\(\\mathcal\{R\}\_\{c\}\\cup\\mathcal\{R\}\_\{r\}\)\-derivation fromI′I^\{\\prime\}resulting inIn′I^\{\\prime\}\_\{n\}withIn′⊧qI^\{\\prime\}\_\{n\}\\models q\.

We finally defineℛ′=ℛr∪ℛc\\mathcal\{R\}^\{\\prime\}=\\mathcal\{R\}\_\{r\}\\cup\\mathcal\{R\}\_\{c\}\. Theorem[22](https://arxiv.org/html/2607.22636#Thmtheorem22), which states the correction of our reduction, is a direct consequence of Proposition[5](https://arxiv.org/html/2607.22636#Thmtheorem5c)and Corollary[21](https://arxiv.org/html/2607.22636#Thmtheorem21)\.

###### Theorem 22\.

Letqqbe a Boolean CRPQ on the original vocabulary\. Then𝖼𝗁𝖺𝗌𝖾​\(I,ℛ\)⊧q\\mathsf\{chase\}\(I,\\mathcal\{R\}\)\\models qif and only if𝖼𝗁𝖺𝗌𝖾​\(I′,ℛ′\)⊧q\\mathsf\{chase\}\(I^\{\\prime\},\\mathcal\{R\}^\{\\prime\}\)\\models q\.

It remains to study the computational resources that are required to compute this reduction\.

###### Proposition 23\.

Given\(I,ℛ\)\(I,\\mathcal\{R\}\),I′I^\{\\prime\}andℛ′\\mathcal\{R\}^\{\\prime\}as defined above can be computed in2ExpTimein combined complexity,ExpTimein combined complexity with bounded\-predicate arity, and inPTimein data complexity\. The number of types \(Definition[2](https://arxiv.org/html/2607.22636#Thmtheorem2a)\) whose predicate appears inℛ′\\mathcal\{R\}^\{\\prime\}is at most a double exponential inIIandℛ\\mathcal\{R\}\(exponential when the arity is bounded, and constant*w\.r\.t\.*the data\)\.

###### Proof\.

Letwwbe the maximum arity of a predicate appearing inℛ\\mathcal\{R\}orII,ppbe the number of such predicates, andnnbe the number of atoms ofII, andrrbe the number of rules\.

LetIIbe an instance andℛ\\mathcal\{R\}be a set of guarded rules\. We analyze the size of the instanceI′I^\{\\prime\}and rulesetℛ′\\mathcal\{R\}^\{\\prime\}:

- •I′I^\{\\prime\}containsnnatoms;
- •every guarded set in𝒢\\mathcal\{G\}can be represented in single exponential size \(polynomial when the arity is bounded and in data complexity\): there arep​\(2​w\)wp\(2w\)^\{w\}atoms that can be built using the2​w2wcanonical variables, and a predicate is described by a subset of such atoms \(plus the selected guard atom\); the same bounds apply to space required to store a complex predicate, as each complex predicate corresponds to a guarded set;
- •there is a double exponential number of complex predicates \(exponential when the arity is bounded and constant in data complexity\);
- •for each complex predicate, there is one reconstruction rule per atom in the guarded set of the predicate, hence at mostp​\(2​w\)wp\(2w\)^\{w\}such rules per predicate;
- •for each complex predicate, there is one complex rule per homomorphism of a rule body inℛ\\mathcal\{R\}into the guarded set of atoms defining the predicate; in fact, it only matters where the guard atom is mapped, so we have at mostr​p​\(2​w\)wrp\(2w\)^\{w\}complex rules per new predicate;
- •there is a double exponential number of types \(exponential when the arity is bounded, constant in data complexity\): for each complex predicate, the number of types with this predicate is equal to the number of partitions of the predicate’s arguments\.

To build the instanceI′I^\{\\prime\}, we first compute for each atomα∈I\\alpha\\in Ithe set𝖼𝗁𝖺𝗌𝖾​\(I,ℛ\)∣𝗍𝖾𝗋𝗆𝗌\(α\)\\mathsf\{chase\}\(I,\\mathcal\{R\}\)\_\{\\mid\\mathsf\{terms\}\{\(\\alpha\)\}\}\. This can be done by making at mostn​p​wwnpw^\{w\}calls to a2\-ExpTimeoracle for query answering under guarded rules\. This is a polynomial number of calls to anExpTimeoracle when the arity is bounded, and a polynomial number of calls to aPTimeoracle in data complexity\)\. The new instanceI′I^\{\\prime\}can be constructed in polynomial time from the saturated atoms\.

Building the set of reconstruction rules can be done in polynomial time with respect to the number of guarded sets\. To build the set of complex rules, for each guarded set and each original ruleρ\\rho, we proceed as follows: apply the reconstruction rules, apply the original rule, saturate the resulting atom with respect to the original rules, and create the corresponding complex rule\. The preceding operations can be performed by making an exponential number of calls to a query answering oracle for guarded rules, and thus, this step can be done in double exponential time\. When the arity is bounded, this makes a polynomial number of calls to anExpTimeoracle, hence is doable inExpTime\. In data complexity, we have a constant number of calls to aPTimeoracle, hence is doable inPTime\. ∎

The next theorem follows from the provided reduction and Algorithm[2](https://arxiv.org/html/2607.22636#algorithm2)\. Let us remark that the reduction to linear rules not being polynomial, we cannot directly apply Theorem[14](https://arxiv.org/html/2607.22636#Thmtheorem14)to obtain the desired upper bounds\. However, a careful analysis of Algorithm[2](https://arxiv.org/html/2607.22636#algorithm2)allows us to show that it actually runs polynomially in the number of types built from the predicates in𝒱\\mathcal\{V\}\. The proof details are provided in the appendix\.

###### Theorem24\.

CRPQ answering under guarded rules is2ExpTime\-complete in combined complexity,ExpTime\-complete in combined complexity with bounded\-predicate arity, andPTime\-complete in data complexity\.

We believe that the result for combined complexity in the bounded\-arity case still holds for arbitrary guarded rules with multiple head atoms \(translated into atomic\-head rules\), the key argument being again that the number of types to be considered for a fresh predicate remains polynomial\. However, the proof of that claim would require updating the definitions ofℛc\\mathcal\{R\}\_\{c\}andℛr\\mathcal\{R\}\_\{r\}, intuitively to consider only ‘relevant’ guarded sets, and to revise accordingly all the subsequent statements and their proof\. This would significantly complexify the arguments and obfuscate the main ideas of the reduction, hence we decided not to consider this extension\.

## 7\.Related Work

In the introduction, we gave an overview of related work on answering navigational queries with ontologies\. We observed that such queries had been extensively studied within various description logic fragments, but hardly at all for existential rules\. We now take a closer look at related work more specifically linked to our contributions, whether regarding the techniques used or the complexity results obtained\. We recall that we use the notation \(C\)RPQ for*two\-way*queries, whereas these are also denoted by 2\(C\)RPQ in other works that reserve the term \(C\)RPQ to the restricted form without inverse predicates \(called one\-way\)\.

Concerning relevant description logics, we focus on the DL\-Lite\(Calvanese et al\.,[2007a](https://arxiv.org/html/2607.22636#bib.bib20)\)andℰ​ℒ\\mathcal\{EL\}\(Baader et al\.,[2005](https://arxiv.org/html/2607.22636#bib.bib4)\)families, which are well\-known fragments related to linear and guarded existential rules, respectively\. The most studied member of the DL\-Lite family is the dialect DL\-LiteR, underpinning OWL 2 QL, whose \(positive\) axioms can be seen as linear rules of the formα1→α2\\alpha\_\{1\}\\rightarrow\\alpha\_\{2\}; as usual in DLs, eachαi\\alpha\_\{i\}is a unary atom or a binary atom with distinct variables\. Hence, linear rules strictly generalize DL\-LiteRby unrestricted predicate arity and co\-occurrences of variables in an atom\. Inℰ​ℒ\\mathcal\{EL\}, axioms can be seen as rules of the formB​\[x\]→a​\(x\)B\[x\]\\rightarrow a\(x\)orB​\[x\]→∃z​r​\(x,z\)∧a​\(z\)B\[x\]\\rightarrow\\exists z~r\(x,z\)\\land a\(z\)whereB​\[x\]B\[x\]is a conjunction of unary atoms onxxor a conjunction of the formr′​\(x,y\)∧a′​\(y\)r^\{\\prime\}\(x,y\)\\land a^\{\\prime\}\(y\)\.ℰ​ℒ​ℋ\\mathcal\{ELH\}adds role inclusions, i\.e\., rules of the formr′​\(x,y\)→r​\(x,y\)r^\{\\prime\}\(x,y\)\\rightarrow r\(x,y\)andℰ​ℒ​ℋ​ℐ\\mathcal\{ELHI\}moreover allows for inverse roles, i\.e\., atoms of the formr​\(y,x\)r\(y,x\)\. Note thatℰ​ℒ​ℋ​ℐ\\mathcal\{ELHI\}subsumes \(positive\) DL\-LiteR\. Guarded rules strictly generalizeℰ​ℒ​ℋ​ℐ\\mathcal\{ELHI\}axioms\.

We mentioned in Section[3](https://arxiv.org/html/2607.22636#S3)that our algorithm for RPQ answering under linear rules \(Algorithm[2](https://arxiv.org/html/2607.22636#algorithm2)\) was inspired by a related algorithm for DL\-Lite ontologies\. More specifically, we extended the algorithm presented in\(Bienvenu et al\.,[2015](https://arxiv.org/html/2607.22636#bib.bib13)\)for DL\-LiteRto take higher\-arity predicates and co\-occurrences of variables into account\. Technically, the main differences are the following\. In DL\-LiteR, each detour of a path of terms to the anonymous part of the chase goes from a constant and comes back to the same constant, i\.e\., for any pathp=\(d0,…,dn\)p=\(d\_\{0\},\\ldots,d\_\{n\}\)in the chase, where onlyd0d\_\{0\}anddnd\_\{n\}are constants, it holds thatd0=dnd\_\{0\}=d\_\{n\}\. This is not true anymore for linear rules\. Instead, we observe that for any such pathpp, there is an atomα∈I\\alpha\\in Iin whichd0d\_\{0\}anddnd\_\{n\}both occur, and such that the chase ofα\\alphacontains a path isomorphic topp\(see our Proposition[1](https://arxiv.org/html/2607.22636#Thmtheorem1b)\)\. Hence, we keep track of “loops” within atoms instead of “loops” on constants\. A less important extension relates to the notion of atom type, the idea being that atoms with the same type behave similarly regarding rule applications\. In DL\-Lite, the type of an atom is simply given by its predicate\. For linear rules, we need to take co\-occurrences of terms into account, hence a more general definition of type \(Definition[2](https://arxiv.org/html/2607.22636#Thmtheorem2a)\)\. Modulo these extensions, our Algorithm[2](https://arxiv.org/html/2607.22636#algorithm2)is quite close to the algorithm for DL\-LiteRfrom\(Bienvenu et al\.,[2015](https://arxiv.org/html/2607.22636#bib.bib13)\)\.

In Table[3](https://arxiv.org/html/2607.22636#S7.T3)we indicate the data and combined complexities of \(C\)RPQ answering for the DLs mentioned above, based on\(Bienvenu et al\.,[2015](https://arxiv.org/html/2607.22636#bib.bib13)\)\. To facilitate comparison with our results, we recall the complexities obtained for linear and guarded existential rules; we consider here combined complexity with bounded predicate arity, as DL predicates are at most binary\. It is interesting to observe that the generalizations from DL\-LiteRto linear and fromℰ​ℒ​ℋ​ℐ\\mathcal\{ELHI\}to guarded do not increase worst\-case complexities, neither in data nor in bounded\-arity combined complexity\. Note however, that except for RPQ answering under linear rules \(inspired by the algorithm for DL\-LiteR\), the techniques used to obtain complexity upper bounds in\(Bienvenu et al\.,[2015](https://arxiv.org/html/2607.22636#bib.bib13)\)are quite different from ours, as they rely on a \(non\-deterministic\) query rewriting algorithm that exploits the specificities of DLs\.

RPQ answeringCRPQ answeringFragmentDataCombined\(b\)DataCombined\(b\)DL\-LiteRNL\-cPTime\-cNL\-cPSpace\-cLinearNL\-cPTime\-cNL\-cPSpace\-cℰ​ℒ​ℋ\\mathcal\{ELH\}PTime\-cPTime\-cPTime\-cPSpace\-cℰ​ℒ​ℋ​ℐ\\mathcal\{ELHI\}PTime\-cExpTime\-cPTime\-cExpTime\-cGuardedPTime\-cExpTime\-cPTime\-cExpTime\-c

Table 3\.Data and arity\-bounded combined complexities of \(C\)\-RPQ\-answering under lightweight DL ontologiesFinally, let us mention the work in\(Stefanoni et al\.,[2014](https://arxiv.org/html/2607.22636#bib.bib56)\), which studies XPath queries under the DLℰ​ℒ​ℛ​𝒪\+\\mathcal\{ELRO^\{\+\}\}, underpinning OWL 2 EL\. This DL is incomparable with guarded existential rules, due to the presence of axioms of the formr1​\(x,x1\),…,rk​\(xk−1,y\)→r​\(x,y\)r\_\{1\}\(x,x\_\{1\}\),\\ldots,r\_\{k\}\(x\_\{k\-1\},y\)\\rightarrow r\(x,y\)\. Moreover, the considered XPath queries generalize \(C\)RPQs by allowing to express some constraints on the nodes traversed along a path\. An interesting future work would be to check whether the atom types we use in our algorithm could be extended to process those XPath queries\.

Concerning existential rules, let us first point out similarities between some of our technical tools and those of previous work on CQ answering in the linear and guarded fragments\. Regarding linear rules, our valid proof schemes \(see Definition[5](https://arxiv.org/html/2607.22636#Thmtheorem5b)\) are not far, in essence, from the proof generators used by Gottlob et al\. \(\([2015](https://arxiv.org/html/2607.22636#bib.bib36)\)\) for devising a combined approach for CQ entailment under linear rules; however, the presence of transitions and their interactions with linear rules make the validity check much more intricate \(see the proof of Proposition[17](https://arxiv.org/html/2607.22636#Thmtheorem17)\)\. Also, the reduction employed in Section[6](https://arxiv.org/html/2607.22636#S6)to lift complexity results from linear to guarded rules is very similar to that introduced in\(Gottlob et al\.,[2023](https://arxiv.org/html/2607.22636#bib.bib37)\)\. However, as the technical lemmas provided there are not enough to be used as black boxes to get our results, we provided a novel presentation based on the notion of a locally complete derivation \(Definition[1](https://arxiv.org/html/2607.22636#Thmtheorem1e)\) and its properties of query entailment preservation \(Proposition[5](https://arxiv.org/html/2607.22636#Thmtheorem5c)and Corollary[21](https://arxiv.org/html/2607.22636#Thmtheorem21)\)\.

We now review in more detail known results about \(C\)RPQ answering with existential rules\. Beforehand, it is worth recalling that known decidability results on CQ answering with specific existential rule classes mostly rely on properties of the*chase*or of query*rewriting*: either the universal model of the KB computed by the chase is finite or “well\-shaped”, which allows one to evaluate the CQ against it, or the CQ can be rewritten using the rules into a finite query, which is then evaluated on the instance\. When moving to CRPQs, it turns out that the landscape becomes quite different depending on the underlying technique\. Indeed, recent work has shown that CRPQ answering is decidable for all classes of rules that guarantee the existence of a universal KB model of finite clique\-width \(a notion that generalizes treewidth\)\. As pointed out in\(Ostropolski\-Nalewaja and Rudolph,[2024](https://arxiv.org/html/2607.22636#bib.bib53)\), this follows from a generic result from\(Feller et al\.,[2023](https://arxiv.org/html/2607.22636#bib.bib33)\)\. This result applies to major classes of rules with chase\-based decidable CQ answering, like those defined by acyclicity notions ensuring finite chase\(Grau et al\.,[2013](https://arxiv.org/html/2607.22636#bib.bib41)\)or the guarded family, which includes generalizations of the guarded class considered in this paper\(Thomazo et al\.,[2012](https://arxiv.org/html/2607.22636#bib.bib57)\)\. This contrasts with first results on rule classes with rewriting\-based decidable CQ answering, which are also provided in\(Ostropolski\-Nalewaja and Rudolph,[2024](https://arxiv.org/html/2607.22636#bib.bib53)\)\. Indeed, RPQ answering is shown to be undecidable for first\-order rewritable rule classes, also known as*fus*\(Baget et al\.,[2011](https://arxiv.org/html/2607.22636#bib.bib8)\): such classes guarantee that any CQ can be rewritten as a \(finite\) union of CQs\. This negative result already holds for*one\-way*RPQs\. On the positive side, RPQ answering is shown to be decidable555For the proof to hold, RPQs must be of the formΛ​\(x1,x2\)\\Lambda\(x\_\{1\},x\_\{2\}\)withx1x\_\{1\}andx2x\_\{2\}distinct variables\.for an important fus concrete subclass, namely sticky rules \(introduced in\(Calì et al\.,[2010](https://arxiv.org/html/2607.22636#bib.bib19)\)\)\. However, this decidability result does not yield any upper bound on the complexity of RPQ answering under sticky rules, and it is left as an open question whether \(one\-way\) CRPQ answering is decidable under sticky rules\.

## 8\.Conclusion

In this paper, we provide the first complexity results for \(C\)RPQ answering under existential rules\. These results concern two prominent classes of existential rules, namely linear and guarded rules, and distinguish between data complexity and combined complexity, considering both bounded and unbounded predicate arity\. All of our complexity results are tight, thereby yielding a complete picture of the worst\-case complexity of \(C\)RPQ answering under linear and guarded rules\. Interestingly, when comparing with existing results for description logics, we observe that moving from DL\-LiteRto linear rules and fromℰ​ℒ​ℋ​ℐ\\mathcal\{ELHI\}to guarded rules does not lead to any increase in data complexity, nor in bounded\-arity combined complexity\. Moreover, for linear rules, the data complexity for \(C\)RPQs is the same as for plain graph databases \(namely, NL\-complete\)\.

While we now have clear picture of the complexity for guarded rules, the decidability and complexity landscapes for \(C\)RPQ answering for other classes of existential rules remain largely unexplored\. As detailed in the related work section \(Section[7](https://arxiv.org/html/2607.22636#S7)\), decidability has only recently been established for some major classes of rules with chase\-based decidable CQ answering, including the class of frontier\-guarded rules which generalizes the guarded rules considered in the present paper, but this result does not come with complexity bounds, nor a reasonably implementable algorithmic scheme\. For classes with rewriting\-based decidable CQ answering, there is a general undecidability result, and little is known about the decidability of concrete classes\.

At present, our complexity results are purely of a theoretical nature\. However, we have reason to believe that the algorithm we presented for RPQ answering under linear rules can lead to a practically efficient implementation\. Indeed, the construction of theLooptable is data\-independent, and empirical studies\(Bonifati et al\.,[2020](https://arxiv.org/html/2607.22636#bib.bib15)\)have found that regular languages in real\-world path queries are typically very simple \(thus representable with only a handful of automata states\)\. Moreover, to reduce computation at query time, one could perform an offline preprocessing of the data by adding all entailed binary atoms \(in the spirit of combined approaches to OMQA\(Kontchakov et al\.,[2011](https://arxiv.org/html/2607.22636#bib.bib43)\), which rely upon data enrichment to speed up query answering\)\. This pre\-computation of entailed facts may also enable us to devise RPQ answering procedures via rewriting to path queries over plain graph databases, thereby enabling the use of modern graph database systems \(as has been explored in\(Löhnert et al\.,[2025](https://arxiv.org/html/2607.22636#bib.bib47)\)for description logics\)\. By contrast, the algorithms we devised for CRPQ answering under linear and guarded rules are not readily implementable, so new insights, possibly coupled with restrictions on query structure, will be needed to address such queries in practice\.

###### Acknowledgements\.

This work was partially supported by the French ANR projects PAGODA \(ANR\-12\-JS02\-0007\), CQFD \(ANR\-18\-CE23\-0003\), and EXPAND \(ANR\-25\-CE23\-1215\)\. We thank the reviewers for their comments that helped to enhance the quality of the paper\.

## References

- \(1\)
- Abiteboul et al\.\(1994\)Serge Abiteboul, Richard Hull, and Victor Vianu\. 1994\.*Foundations of Databases*\.Addison Wesley\.
- Angles et al\.\(2017\)Renzo Angles, Marcelo Arenas, Pablo Barceló, Aidan Hogan, Juan L\. Reutter, and Domagoj Vrgoc\. 2017\.Foundations of Modern Query Languages for Graph Databases\.*ACM Comput\. Surv\.*50, 5 \(2017\), 68:1–68:40\.
- Baader et al\.\(2005\)Franz Baader, Sebastian Brandt, and Carsten Lutz\. 2005\.Pushing theℰ​ℒ\\mathcal\{EL\}Envelope\. In*Proceedings of the International Joint Conference on Artificial Intelligence \(IJCAI\)*\. 364–369\.
- Baget et al\.\(2015a\)Jean\-François Baget, Meghyn Bienvenu, Marie\-Laure Mugnier, and Swan Rocher\. 2015a\.Combining Existential Rules and Transitivity: Next Steps\. In*Proceedings of the International Joint Conference on Artificial Intelligence \(IJCAI\)*\. 2720–2726\.
- Baget et al\.\(2015b\)Jean\-François Baget, Meghyn Bienvenu, Marie\-Laure Mugnier, and Swan Rocher\. 2015b\.Combining Existential Rules and Transitivity: Next Steps\.*CoRR*abs/1504\.07443 \(2015\)\.
- Baget et al\.\(2017\)Jean\-François Baget, Meghyn Bienvenu, Marie\-Laure Mugnier, and Michaël Thomazo\. 2017\.Answering Conjunctive Regular Path Queries over Guarded Existential Rules\. In*Proceedings of the International Joint Conference on Artificial Intelligence \(IJCAI\)*\. 793–799\.
- Baget et al\.\(2011\)Jean\-François Baget, Michel Leclère, Marie\-Laure Mugnier, and Eric Salvat\. 2011\.On Rules with Existential Variables: Walking the Decidability Line\.*Artif\. Intell\.*175, 9\-10 \(2011\), 1620–1654\.
- Beeri and Vardi \(1981\)Catriel Beeri and Moshe Vardi\. 1981\.The Implication Problem for Data Dependencies\. In*Proceedings of International Colloquium on Automata, Languages and Programming \(ICALP\)*, Vol\. 115\. 73–85\.
- Beeri and Vardi \(1984\)Catriel Beeri and Moshe Y\. Vardi\. 1984\.A Proof Procedure for Data Dependencies\.*J\. ACM*31, 4 \(1984\), 718–741\.
- Bienvenu et al\.\(2014\)Meghyn Bienvenu, Diego Calvanese, Magdalena Ortiz, and Mantas Simkus\. 2014\.Nested Regular Path Queries in Description Logics\. In*Proceedings of the International Conference on the Principles of Knowledge Representation and Reasoning \(KR\)*\.
- Bienvenu and Ortiz \(2015\)Meghyn Bienvenu and Magdalena Ortiz\. 2015\.Ontology\-Mediated Query Answering with Data\-Tractable Description Logics\. In*Lecture Notes of the International Reasoning Web Summer School \(RW\)**\(LNCS, Vol\. 9203\)*\. Springer, 218–307\.
- Bienvenu et al\.\(2015\)Meghyn Bienvenu, Magdalena Ortiz, and Mantas Simkus\. 2015\.Regular Path Queries in Lightweight Description Logics: Complexity and Algorithms\.*J\. Artif\. Intell\. Res\. \(JAIR\)*53 \(2015\), 315–374\.
- Bienvenu and Thomazo \(2016\)Meghyn Bienvenu and Michaël Thomazo\. 2016\.On the Complexity of Evaluating Regular Path Queries over Linear Existential Rules\. In*Proceedings of the International Conference on Web Reasoning and Rule Systems \(RR\)*\. 1–17\.
- Bonifati et al\.\(2020\)Angela Bonifati, Wim Martens, and Thomas Timm\. 2020\.An Analytical Study of Large SPARQL Query Logs\.*VLDB J\.*29, 2\-3 \(2020\), 655–679\.
- Calì et al\.\(2013\)Andrea Calì, Georg Gottlob, and Michael Kifer\. 2013\.Taming the Infinite Chase: Query Answering under Expressive Relational Constraints\.*J\. Artif\. Intell\. Res\.*48 \(2013\), 115–174\.
- Calì et al\.\(2009a\)Andrea Calì, Georg Gottlob, and Thomas Lukasiewicz\. 2009a\.Datalog Extensions for Tractable Query Answering over Ontologies\.In*Semantic Web Information Management \- A Model\-Based Perspective*\. 249–279\.
- Calì et al\.\(2009b\)Andrea Calì, Georg Gottlob, and Thomas Lukasiewicz\. 2009b\.A General Datalog\-Based Framework For Tractable Query Answering Over Ontologies\. In*Proceedings of the ACM SIGMOD\-SIGACT\-SIGART International Symposium on Principles of Database Systems \(PODS\)*\. 77–86\.
- Calì et al\.\(2010\)Andrea Calì, Georg Gottlob, and Andreas Pieris\. 2010\.Advanced Processing for Ontological Queries\.*Proc\. VLDB Endow\.*3, 1 \(2010\), 554–565\.
- Calvanese et al\.\(2007a\)Diego Calvanese, Giuseppe De Giacomo, Domenico Lembo, Maurizio Lenzerini, and Riccardo Rosati\. 2007a\.Tractable Reasoning and Efficient Query Answering in Description Logics: The*DL\-Lite*Family\.*J\. Autom\. Reasoning*39 \(2007\), 385–429\.
- Calvanese et al\.\(2007b\)Diego Calvanese, Thomas Eiter, and Magdalena Ortiz\. 2007b\.Answering Regular Path Queries in Expressive Description Logics: An Automata\-Theoretic Approach\. In*Proceedings of the International AAAI Conference on Artificial Intelligence*\. 391–396\.
- Calvanese et al\.\(2009\)Diego Calvanese, Thomas Eiter, and Magdalena Ortiz\. 2009\.Regular Path Queries in Expressive Description Logics with Nominals\. In*Proceedings of the International Joint Conference on Artificial Intelligence \(IJCAI\)*\. 714–720\.
- Calvanese et al\.\(2014\)Diego Calvanese, Thomas Eiter, and Magdalena Ortiz\. 2014\.Answering Regular Path Queries in Expressive Description Logics Via Alternating Tree\-Automata\.*Inf\. Comput\.*237 \(2014\), 12–55\.
- Calvanese et al\.\(2000\)Diego Calvanese, Giuseppe De Giacomo, Maurizio Lenzerini, and Moshe Y\. Vardi\. 2000\.Containment of Conjunctive Regular Path Queries with Inverse\. In*Proceedings of the International Conference on the Principles of Knowledge Representation and Reasoning \(KR\)*\. 176–185\.
- Calvanese et al\.\(2002\)Diego Calvanese, Giuseppe De Giacomo, Maurizio Lenzerini, and Moshe Y\. Vardi\. 2002\.Rewriting of Regular Expressions and Regular Path Queries\.*J\. Comput\. Syst\. Sci\.*64, 3 \(2002\), 443–465\.
- Chandra et al\.\(1981\)Ashok K\. Chandra, Harry R\. Lewis, and Johann A\. Makowsky\. 1981\.Embedded Implicational Dependencies and their Inference Problem\. In*Proceedings of the Annual ACM Symposium on Theory of Computing \(STOC\)*\. 342–354\.
- Cruz et al\.\(1987\)Isabel F\. Cruz, Alberto O\. Mendelzon, and Peter T\. Wood\. 1987\.A Graphical Query Language Supporting Recursion\. In*Proceedings of the ACM Special Interest Group on Management of Data Annual Conference*, Umeshwar Dayal and Irving L\. Traiger \(Eds\.\)\. 323–330\.
- Cucumides et al\.\(2023\)Tamara Cucumides, Juan L\. Reutter, and Domagoj Vrgoc\. 2023\.Size Bounds and Algorithms for Conjunctive Regular Path Queries\. In*Proceedings of the International Conference on Database Theory \(ICDT\)*\. 13:1–13:17\.
- Deutsch et al\.\(2008\)Alin Deutsch, Alan Nash, and Jeffrey B\. Remmel\. 2008\.The chase revisited\. In*Proceedings of the ACM SIGMOD\-SIGACT\-SIGART Symposium on Principles of Database Systems \(PODS\)*\. 149–158\.
- Dragovic et al\.\(2023\)Nikola Dragovic, Cem Okulmus, and Magdalena Ortiz\. 2023\.Rewriting Ontology\-Mediated Navigational Queries into Cypher\. In*Proceedings of the International Workshop on Description Logics \(DL\)*\.
- Ehrenfeucht and Zeiger \(1976\)Andrzej Ehrenfeucht and H\. Paul Zeiger\. 1976\.Complexity Measures for Regular Expressions\.*J\. Comput\. Syst\. Sci\.*12, 2 \(1976\), 134–146\.
- Fagin et al\.\(2005\)Ronald Fagin, Phokion G\. Kolaitis, Renée J\. Miller, and Lucian Popa\. 2005\.Data Exchange: Semantics and Query Answering\.*Theor\. Comput\. Sci\.*336, 1 \(2005\), 89–124\.
- Feller et al\.\(2023\)Thomas Feller, Tim S\. Lyon, Piotr Ostropolski\-Nalewaja, and Sebastian Rudolph\. 2023\.Finite\-Cliquewidth Sets of Existential Rules: Toward a General Criterion for Decidable yet Highly Expressive Querying\. In*Proceedings of the International Conference on Database Theory \(ICDT\)*\. 18:1–18:18\.
- Figueira \(2021\)Diego Figueira\. 2021\.Foundations of Graph Path Query Languages\. In*Lecture Notes of the International Reasoning Web Summer School \(RW\)**\(LNCS, Vol\. 13100\)*\. Springer, 1–21\.
- Florescu et al\.\(1998\)Daniela Florescu, Alon Levy, and Dan Suciu\. 1998\.Query Containment for Conjunctive Queries with Regular Expressions\. In*Proceedings of the ACM SIGMOD\-SIGACT\-SIGART International Symposium on Principles of Database Systems \(PODS\)*\.
- Gottlob et al\.\(2015\)Georg Gottlob, Marco Manna, and Andreas Pieris\. 2015\.Polynomial Rewritings for Linear Existential Rules\. In*Proceedings of the Twenty\-Fourth International Joint Conference on Artificial Intelligence \(IJCAI\)*\. 2992–2998\.
- Gottlob et al\.\(2023\)Georg Gottlob, Marco Manna, and Andreas Pieris\. 2023\.Polynomial Combined First\-Order Rewritings For Linear and Guarded Existential Rules\.*Artif\. Intell\.*321 \(2023\), 103936\.
- Gottlob and Papadimitriou \(2003\)Georg Gottlob and Christos H\. Papadimitriou\. 2003\.On the Complexity of Single\-Rule Datalog Queries\.*Inf\. Comput\.*183, 1 \(2003\), 104–122\.
- Gottlob and Schwentick \(2012\)Georg Gottlob and Thomas Schwentick\. 2012\.Rewriting Ontological Queries into Small Nonrecursive Datalog Programs\. In*Proceedings of the International Conference on the Principles of Knowledge Representation and Reasoning*\.
- Grahne and Onet \(2018\)Gösta Grahne and Adrian Onet\. 2018\.Anatomy of the Chase\.*Fundam\. Informaticae*157, 3 \(2018\), 221–270\.
- Grau et al\.\(2013\)Bernardo Cuenca Grau, Ian Horrocks, Markus Krötzsch, Clemens Kupke, Despoina Magka, Boris Motik, and Zhe Wang\. 2013\.Acyclicity Notions for Existential Rules and Their Application to Query Answering in Ontologies\.*J\. Artif\. Intell\. Res\. \(JAIR\)*47 \(2013\), 741–808\.
- Johnson and Klug \(1984\)David S\. Johnson and Anthony C\. Klug\. 1984\.Testing Containment of Conjunctive Queries under Functional and Inclusion Dependencies\.*J\. Comput\. Syst\. Sci\.*28, 1 \(1984\), 167–189\.
- Kontchakov et al\.\(2011\)Roman Kontchakov, Carsten Lutz, David Toman, Frank Wolter, and Michael Zakharyaschev\. 2011\.The Combined Approach to Ontology\-Based Data Access\. In*Proceedings of the 22nd International Joint Conference on Artificial Intelligence \(IJCAI\)*\. 2656–2661\.
- Kontchakov et al\.\(2013\)Roman Kontchakov, Mariano Rodriguez\-Muro, and Michael Zakharyaschev\. 2013\.Ontology\-Based Data Access with Databases: A Short Course\. In*Lectures Notes of the International Reasoning Web \(RW\)**\(LNCS, Vol\. 8067\)*\. Springer, 194–229\.
- Kostylev et al\.\(2015\)Egor V\. Kostylev, Juan L\. Reutter, and Domagoj Vrgoc\. 2015\.XPath for DL Ontologies\. In*Proceedings of the AAAI Conference on Artificial Intelligence*\. 1525–1531\.
- Libkin et al\.\(2025\)Leonid Libkin, Wim Martens, Filip Murlak, Liat Peterfreund, and Domagoj Vrgoc\. 2025\.Querying Graph Data: Where We Are and Where To Go\. In*Companion of the the International Symposium on Principles of Database Systems \(PODS\)*\. 9–26\.
- Löhnert et al\.\(2025\)Bianca Löhnert, Nikolaus Augsten, Cem Okulmus, and Magdalena Ortiz\. 2025\.Towards Practicable Algorithms for Rewriting Graph Queries Beyond DL\-Lite\. In*Proceedings of the 22nd European Semantic Web Conference \(ESWC\)*\. 342–361\.
- Maier et al\.\(1979\)David Maier, Alberto O\. Mendelzon, and Yehoshua Sagiv\. 1979\.Testing Implications of Data Dependencies\.*ACM Trans\. Database Syst\.*4, 4 \(1979\), 455–469\.
- Mendelzon and Wood \(1995\)Alberto O\. Mendelzon and Peter T\. Wood\. 1995\.Finding Regular Simple Paths in Graph Databases\.*SIAM J\. Comput\.*24, 6 \(1995\), 1235–1258\.
- Mugnier and Thomazo \(2014\)Marie\-Laure Mugnier and Michaël Thomazo\. 2014\.An Introduction to Ontology\-Based Query Answering with Existential Rules\. In*Lectures Notes of the International Reasoning Web Summer School \(RW\)*\. 245–278\.
- Ortiz et al\.\(2011\)Magdalena Ortiz, Sebastian Rudolph, and Mantas Šimkus\. 2011\.Query Answering in the Horn Fragments of the Description Logics𝒮​ℋ​𝒪​ℐ​𝒬\\mathcal\{SHOIQ\}and𝒮​ℛ​𝒪​ℐ​𝒬\\mathcal\{SROIQ\}\. In*Proceedings of the International Joint Conference on Artificial Intelligence \(IJCAI\)*\.
- Ortiz and Simkus \(2012\)Magdalena Ortiz and Mantas Simkus\. 2012\.Reasoning and Query Answering in Description Logics\. In*Lecture Notes of the International Reasoning Web Summer School \(RW\)**\(LNCS, Vol\. 7487\)*\. Springer, 1–53\.
- Ostropolski\-Nalewaja and Rudolph \(2024\)Piotr Ostropolski\-Nalewaja and Sebastian Rudolph\. 2024\.The Sticky Path to Expressive Querying: Decidability of Navigational Queries under Existential Rules\. In*Proceedings of the International Conference on Principles of Knowledge Representation and Reasoning \(KR\)*\.
- Poggi et al\.\(2008\)Antonella Poggi, Domenico Lembo, Diego Calvanese, Giuseppe De Giacomo, Maurizio Lenzerini, and Riccardo Rosati\. 2008\.Linking Data to Ontologies\.*J\. Data Semant\.*10 \(2008\), 133–173\.
- Rocher \(2016\)Swan Rocher\. 2016\.*Querying Existential Rule Knowledge Bases: Decidability and Complexity\. \(Interrogation de Bases de Connaissances avec Règles Existentielles : Décidabilité et Complexité\)*\.Ph\. D\. Dissertation\. University of Montpellier, France\.
- Stefanoni et al\.\(2014\)Giorgio Stefanoni, Boris Motik, Markus Krötzsch, and Sebastian Rudolph\. 2014\.The Complexity of Answering Conjunctive and Navigational Queries over OWL 2 EL Knowledge Bases\.*J\. Art\. Intell\. Res\. \(JAIR\)*51 \(2014\), 645–705\.
- Thomazo et al\.\(2012\)Michaël Thomazo, Jean\-François Baget, Marie\-Laure Mugnier, and Sebastian Rudolph\. 2012\.A Generic Querying Algorithm for Greedy Sets of Existential Rules\. In*Proceedings of the International Conference on the Principles of Knowledge Representation and Reasoning \(KR\)*\.
- Xiao et al\.\(2018\)Guohui Xiao, Diego Calvanese, Roman Kontchakov, Domenico Lembo, Antonella Poggi, Riccardo Rosati, and Michael Zakharyaschev\. 2018\.Ontology\-Based Data Access: A Survey\. In*Proceedings of the International Joint Conference on Artificial Intelligence \(IJCAI\)*\. 5511–5519\.
- Xiao et al\.\(2019\)Guohui Xiao, Linfang Ding, Benjamin Cogrel, and Diego Calvanese\. 2019\.Virtual Knowledge Graphs: An Overview of Systems and Use Cases\.*Data Intell\.*1, 3 \(2019\), 201–223\.

Similar Articles