Trois ans, c'est court, et pourtant c'est en écrivant ces remerciements que je me rends compte que j'ai eu l'occasion de rencontrer énormément de gens, qui m'ont tous apporté quelque chose plus ou moins directement, si bien qu'il est difficile d'être sûr de n'oublier personne... Merci tout d'abord à Jean-François et Marie-Laure pour avoir été des directeurs de thèse parfaits ! Tant au niveau scientifique que personnel, vous avez toujours été là lorsque j'en avais besoin.

Bien sûr, merci aussi à Marie-Christine Rousset et Sebastian Rudolph pour votre lecture si attentive de ce manuscrit : ma thèse ne serait pas ce qu'elle est sans vos remarques. Merci également à Andreas Pieris et Christophe Paul pour avoir accepté d'être examinateurs, et merci aussi à Christophe pour avoir participé à mon comité de suivi de thèse ces trois ans ! On s'éloigne un petit peu, mais pas trop, merci à Michel et le projet Qualinca, sans qui je n'aurai pas pu faire cette thèse. Merci Annie pour avoir réussi à garder ton calme malgré ma hantise des démarches administratives. Et merci à toute l'équipe, ses permanents, ses stagiaires et bien sûr ses doctorants (passés et actuels), Michaël pour tes conjectures et tes contre-exemples, Stathis pour tes questions existentielles, Léa pour tes histoires à base de chats et/ou lapins, et tous les autres ! Non doctorant, mais c'est comme si, merci beaucoup Clément, co-bureau à travers les ages, pour les discussions du café, et pour tout le reste d'ailleurs ! On peut porter le regard un peu plus loin car le LIRMM n'est pas seulement une équipe. Merci à tous les gens avec qui j'ai pu discuter au détour d'un couloir ou autour d'un café. En particulier, merci beaucoup à Sabrina, Anaël, Guilhem, Valentin, Julien, François, Florian, Jessie et Nam' à la fois pour la détente, et pour les moments scientifiques. Ces années n'auraient certainement pas été les mêmes sans votre présence ! Non, je ne t'oublie pas, merci Chloé pour m'avoir aidé à en arriver là ! Et merci Marthe pour ton thé parfaitement équilibré et tes nombreux gâteaux ! Finalement, le LIRMM ne serait pas ce qu'il est sans Laurie et Nicolas : toujours souriants, et on ne peut plus efficaces, merci beaucoup pour tout ce que vous avez fait ! Plus loin que Montpellier (beaucoup), merci à Charlotte et Julien pour m'avoir accueilli dans un super paysage quand il fallait que je me change les idées ! Je n'oublierai pas mon "bureau" à la montagne.

iii iv Enfin, il est plus que temps de remercier la famille : merci Luc et Sarah pour votre soutien et n'avoir jamais douté. Et bien entendu merci pour tout Eva ! Il me semble aussi important de remercier la famille un peu moins directe : alors, merci Raphy pour ton accueil, et aussi pour la force de volonté que tu m'as apporté d'ailleurs. Merci également à Lyes, malgré tes blagues douteuses, tu m'as permis de rigoler quand je ne m'y attendais pas ! Et évidemment, merci à Sandie pour m'avoir supporté pendant la rédaction de cette thèse !

Introduction Querying Knowledge Bases

The recent years have been marked by a tremendous increase of the volume and the heterogeneity of available data sometimes referred to as the "data deluge". Exploiting these data has become a major issue in several research domains (knowledge representation and reasoning, data management, Semantic Web, ...) and the need for integrating data semantics into querying mechanisms has been widely acknowledged. This has renewed the interest for ontologies, which are typically used to formalise general background knowledge on the modeled domains.

Indeed, ontologies have several qualities with respect to better exploiting data:

• they can be used to integrate heterogeneous data from different sources by providing a common vocabulary;

• they allow to adapt the querying vocabulary to specific users' needs, hence abstracting from how data are actually stored;

• they allow to infer knowledge that is not explicitly stored in the data, hence palliating incompleteness in the data.

However, taking into account data semantics requires both suitable ontological formalisms and new query answering mechanisms able to integrate ontological knowledge. Indeed, classical query answering mechanisms have been tailored and optimised for databases. Now, the focus has been shifted to knowledge bases, in which an ontological layer is added on top of data.

This motivated a new research line that led to proposals known as Ontology-Based Data Access (OBDA, e.g., [CDL + 07, PLC + 08]), Ontological Query Answering (e.g., [START_REF] Calì | New expressive languages for ontological query answering[END_REF][START_REF] Mugnier | Ontological query answering with existential rules[END_REF]) or Ontology-Mediated Query Answering (OMQA, e.g., [START_REF] Bienvenu | Ontology-mediated query answering with data-tractable description logics[END_REF][START_REF] Bienvenu | Ontology-mediated query answering: Harnessing knowledge to get more from data[END_REF]). In these approaches, the ontological layer is seen as a logical theory in (a fragment of) first-order logic and data are abstracted into logical facts (which can be mapped to actual data).

Existential Rules

These new issues have deeply influenced research in Description Logics, the major family of formalisms to represent and reason with ontologies [BCM + 03]. This led to the definition of new description logics, generally called lightweight description logics, such as the DL-Lite [CDL + 07] and the EL [START_REF] Baader | Pushing the EL envelope[END_REF] families, as well as the associated profiles of the Semantic Web language OWL 2. At the same time, a new logical framework has emerged, called existential rules [START_REF] Baget | On rules with existential variables: Walking the decidability line[END_REF][START_REF] Krötzsch | Extending decidable existential rules by joining acyclicity and guardedness[END_REF], also known as Datalog+/- [START_REF] Calì | A general datalog-based framework for tractable query answering over ontologies[END_REF]. Existential rules have a double origin: on the one hand, they were designed as an extension of Datalog, the language of deductive databases [START_REF] Abiteboul | Foundations of Databases[END_REF], for ontological representation purposes, hence the name Datalog+/-; on the other hand they correspond to the logical translation of rules in a graph-based knowledge representation framework [START_REF] Chein | Graph-based Knowledge Representation -Computational Foundations of Conceptual Graphs[END_REF]. They also have the same form as highlevel constraints from the database theory, known as Tuple Generating Dependencies (TGDs) [START_REF] Beeri | Formal systems for tuple and equality generating dependencies[END_REF]; note however that TGDs define constraints on the data, while existential rules are used to infer knowledge on the data. Finally, it appears that the existential rule framework generalises most of the new description logics developed for querying data.

More precisely, existential rules are positive and conjunctive rules of the form "if body then head ", with a specific feature: it is possible to introduce in the head of a rule variables that do not occur in the body. These variables are existentially quantified. Thanks to this particularity, existential rules are able to infer the existence of individuals not necessarily present in the initial data. This makes them well-adapted to open-world reasoning, in which not only we cannot assume that only what is explicitly encoded in the data is true, but also in which we cannot suppose that the only known objects are those present in the data. Such a feature is considered important for representing and reasoning with ontological knowledge.

Let us illustrate this with a simple example. Consider two roommates Bob and John, and assume we know that John pays for Internet. We can see these data as a set of facts roommates(Bob, John) ∧ paysInternet(John). We now want to know if Bob has Internet at home and so we ask the query ∃x(livesIn(Bob, x) ∧ hasInternet(x)). Without ontological knowledge we are not able to answer positively. Despite, we intuitively would like to answer yes: some ontological knowledge is missing to get a positive answer. First, we know that if two persons are roommates, there is some place where they both live, hence the rule ∀x∀y(roommates(x, y) → ∃z(livesIn(x, z) ∧ livesIn(y, z))). We also want to say that if someone pays for Internet and lives somewhere, then Internet is present in that "somewhere", which we formalise by the rule ∀x∀y(livesIn(x, y) ∧ paysInternet(x) → hasInternet(y)). Now our query gets a positive answer, indeed Bob and John, being roommates, live in the same place. John pays for Internet, hence he gets Internet at home. Therefore, Bob lives in a place where there is Internet. We could even add some other rules to complete the background knowledge of this example, for instance, we could say that roommate is a symmetrical relation, which we could express with the rule ∀x∀y(roommates(x, y) → roommates(y, x)).

Existential rules have the simplicity of rule-based languages, a privileged form to express human knowledge, as well as their flexibility, i.e., they are able to adapt to various kinds of data and are easily extended to encode new information. While being simple, they are highly expressive, which allows to encode various kinds of ontological knowledge. Unsurprisingly, this expressivity has a cost: indeed, most reasoning problems over existential rules knowledge bases are undecidable (e.g., from [START_REF] Beeri | The implication problem for data dependencies[END_REF] on TGDs). This motivated intense research in the last years to find classes of rules for which reasoning is decidable and hopefully tractable. Currently, a large landscape of decidable classes is known with different expressivity-complexity trade-offs.

This thesis makes further contributions to the study of decidable existential rule classes and to the analysis of their complexities.

Contributions of this Thesis

We consider knowledge bases in which the ontology is a set of existential rules. About the queries, we consider conjunctive queries, which can be seen as existentially quantified conjunctions of atoms. These queries correspond to the basic and most used queries in databases. Hence, the fundamental problem we study is the conjunctive query entailment problem (CQ entailment), which asks whether a conjunctive query is entailed by a knowledge base.

Our contribution is twofold. First, we analyse the different "acyclicity-based" decidable rule classes found in the literature. These rule classes rely on acyclicity conditions to ensure the finiteness of some forward chaining algorithm. We propose a tool that allows us to unify most acyclicity notions and to extend them in generic way. We also analyse the complexity of the recognition problem, i.e., deciding whether a given set of existential rules satisfies these new acyclicity notions. The main paper associated with this work is [START_REF] Baget | Extending acyclicity notions for existential rules[END_REF].

Second, we consider the decidability (and complexity) of the CQ entailment problem when combining known decidable rule classes with a frequently required construct in ontological modeling, namely the transitivity of binary relations. We clarify the decidability picture for all the (currently known) classes for which some forward chaining algorithm halts. Then, we study the particular case of linear existential rules, and show that, up to a minor safety condition, linear rules are compatible with transitivity. We finally consider the complexity of the CQ entailment problem over knowledge bases composed of (safe) linear and transitivity rules. Most of this work is reported in [START_REF] Baget | Combining existential rules and transitivity: Next steps[END_REF], however, with respect to that paper, we provide a new undecidability result and correct a flaw in a complexity proof.

Our work on acyclicity-based decidable classes of rules was also motivated by the objective of extending decidable cases of CQ entailment for existential rules extended with a particular nonmonotonic negation, namely stable negation. Briefly, adding nonmonotonic negation to existential rules allows to apply rules only if some negated atoms from the rule body are not entailed by the knowledge base. While it is easy to see that stable negation may complicate the design of algorithms and increase the complexity of the CQ entailment problem, it also appears that it may make this problem undecidable, even when stable negation is added to a decidable class of positive existential rules. We have thus proposed a way to extend the results obtained for acyclicity-based positive existential rules to existential rules with stable negation. This work has been published in [START_REF] Baget | Revisiting chase termination for existential rules and their extension to nonmonotonic negation[END_REF].

Another interesting issue is how to deal with inconsistent knowledge bases. In this thesis, we assume that knowledge bases are consistent, but in practice, there are reasons to believe that it is not a safe assumption. Indeed, in a world where such a volume of data is available, which furthermore come from different data sources, it is likely that inconsistencies arise. From a logical point of view, an inconsistent knowledge base allows to infer everything, and in the context of querying data, it is obviously not the desired behaviour. We focus on the case where the ontology is assumed to be consistent, hence inconsistencies in the knowledge base come from the data (which is the most considered setting). When it is not possible to effectively repair the data, one has to consider query mechanisms tolerant to inconsistencies. Various inconsistency-tolerant semantics have been defined, which all rely on a common idea: answers to queries are drawn from some maximally consistent subsets of the data (possibly added with some consistent inferred knowledge), called repairs. We have taken part in the definition of a general framework that unifies most inconsistency-tolerant semantics from the literature [BBB + 16a]. Briefly, this framework sees an inconsistency-tolerant semantics as a pair, composed of a "modifier" of the inconsistent knowledge base that allows to select some maximal repairs, and an "inference-strategy" that allows to infer conclusions from these selected repairs. Concerning the notion of maximal consistent subset, at least two different measures can be interesting: maximality in terms of set inclusion and maximality in terms of cardinality. The inference strategy may want to find an answer in all selected repairs, in their intersection, in a single one, or in a majority of them. These choices give rise to different semantics, some of them corresponding to existing proposals, while others are new. Our specific contribution in the context of this general framework consisted in analysing the data complexity of the obtained semantics for the fus subset of existential rules, which generalises most members of the DL-Lite family [BBB + 16b].

Finally, we have also developed Kiabora, a software tool that allows to recognise most known decidable rule classes and proposes ways of combining them [START_REF] Leclère | Kiabora: An analyzer of existential rule bases[END_REF]. The first version of this tool is available via a web interface at www.lirmm.fr/ kiabora. The second version has been integrated into the toolkit Graal dedicated to querying knowledge bases within the existential rule framework. Graal provides an abstract layer that allows to store and query various kinds of data (relational databases, RDF triple stores, internal memory, ...), forward and backward chaining algorithms, as well as complementary tools such as Kiabora and translators from or to other languages. More information can be found on Graal website at http: //graphik-team.github.io/graal/. Beside the development of Kiabora itself, we have helped to design and implement part of Graal [BLM + 15, BGL + 15].

Organisation of the Thesis

The remainder of this thesis is organised in as follows.

In Chapter 1, we define required mathematical notions and introduce the existential rule framework. We recall various well-known results that we will use throughout the manuscript.

In Chapter 2, we present an overview of the main rule classes for which the CQ entailment problem is decidable. We first recall three abstract rule classes that ensure a specific behaviour of some reasoning algorithms. These classes are abstract in the sense that the associated recognition problem is undecidable. Then we review the main known concrete decidable rule classes, which are obtained by enforcing some syntactic restrictions on the sets of rules. Most of them belong to one or more abstract rule classes.

Chapter 3 is devoted to decidable rule classes that rely on acyclicity conditions ensuring the halting of some forward chaining variant, also known as chase in database theory. The first part of this chapter is dedicated to the main known chase variants, for which we give a unified formal definition. We then detail acyclicitybased rule classes, which rely on different graphs. We propose a way to unify these different acyclicity notions with a new graph and associated notion of dangerous cycles. Finally, thanks to the tool we used to unify them, we extend previous acyclicity-based rule classes.

In Chapter 4, we are interested in combining the transitivity of binary relations with known decidable rule classes. We first review known results on this issue obtained in the context of existential rules. Then, we provide new undecidability results, which allows to clarify the picture for rule classes for which some forward chaining algorithm halts. Finally, we consider the case of linear existential rules, one of the simplest, yet useful, classes of existential rules. We show that, up to a minor safety condition, linear and transitivity rules are compatible, and provide complexity results for the CQ entailment problem in terms of data and combined complexity.

Finally we summarise our contributions and outline further research in the conclusion.

General Mathematical Notions

In this section we define several basic mathematical notions and notations needed in this thesis.

Basic Notations

Given a function f , we denote by dom(f ) the domain of f . If we are also given a set X, we denote the restriction of f to X by f

| X = {(x, f (x)) | x ∈ dom(f ) ∩ X}.
A sequence S is a function whose domain is N if it is infinite, ∅ if it is of length 0, and {0, . . . , n -1} if it is of length n ∈ N + . We denote by S i the i th element of S, i.e., S i = S(i).

Graph Notions

Given a (hyper)graph G, we denote by V (G) its set of vertices and E(G) its set of (hyper)edges. A (hyper)graph can be either directed or undirected, in the former case edges are ordered, while in the latter they are not, i.e., in an undirected (hyper)graph, edges (x, y) and (y, x) are the same object.

Given a directed graph G and a vertex v ∈ V (G) we denote its neighbourhood Definition 1.5 (Width) Given a tree decomposition T , the width of T is defined as

width(T ) = max t∈V (T ) |λ(t)| -1 .
Finally, the treewidth of a (hyper)graph is the minimal width of one of its tree decompositions.

Definition 1.6 (Treewidth) Given a (hyper)graph G, its treewidth is defined as the minimal width among all tree decompositions of G.

This notion is quite useful as it helps to measure the distance between a graph and a tree, for instance, trees have treewidth one, cycles have treewidth two, and if a graph contains a clique of size k then its treewidth is at least k -1.

Logical Notions

A logical language L = (P, C) is a pair composed of a finite set of predicates P and a (potentially infinite) set of constants C. Furthermore, we are given an infinite set of variables V. With each predicate of P is associated a non-negative integer called its arity. We do not consider functional symbols except for constants (which are functional symbols of arity 0).

Then, a term of L is either an element of C (thus a constant), or a variable from V. An atom of L is of the form p(t 1 , . . . , t k ) where p is a predicate from P of arity k, and t 1 , . . . , t k are terms from L. It is a ground atom if all its terms are constants. For brevity reasons, we sometimes use the expression p-atom to denote an atom with predicate p.

Given an atom α, we denote by terms(α) the set of all terms in α, by var(α) the set of all variables in α and by const(α) the set of all constants in α.

In our examples, we denote variables by letters from the end of the alphabet (x,y,z,u,...), and constants by letters from the beginning of the alphabet (a,b,c,...).

Definition 1.7 (Interpretation)

An interpretation of a logical language L = (P, C) is a pair I = (D, I) where D is a non-empty set called the interpretation domain and where I is an interpretation function of the symbols of L such that:

• for any c ∈ C, I(c) ∈ D;

• for any p ∈ P of arity k, I(p) ⊆ D k .

An interpretation of L is a model of a formula built on L if it makes this formula true by considering the classical interpretation of logical connectives and quantifiers.

Definition 1.8 (Logical Consequence, Equivalence) Given a language L and two formulae φ 1 and φ 2 on L, φ 2 is a (logical) consequence of φ 1 , which is denoted by φ 1 |= φ 2 , if all models of φ 1 are models of φ 2 .

If φ 1 |= φ 2 and φ 2 |= φ 1 , φ 1 and φ 2 are (logically) equivalent, which is denoted by φ 1 ≡ φ 2 . Definition 1.9 (Substitution) Given a set of variables X and a set of terms T , a substitution σ of X by T is a mapping from X to T .

Given an atom α, we denote by σ(α) the atom obtained by substituting each occurrence of x ∈ var(α) ∩ X by σ(x), i.e., if α = p(t 1 , . . . , t k ) then σ(α) = p(σ(t 1 ), . . . , σ(t k )).

Given a set of atoms A, σ(A) denotes the set obtained by applying the substitution on each atom, i.e., σ(A) = {σ(α) | α ∈ A}.

Definition 1.10 (Homomorphism and Isomorphism) Given two sets of atoms A 1 and A 2 , a homomorphism from A 1 to A 2 is a substitution π of var(A 1 ) by terms(A 2 ) such that π(A 1 ) ⊆ A 2 . In this case we say that A 1 maps to A 2 by π.

If π is injective (thus π -1 is a function) and π -1 is a homomorphism from A 2 to A 1 , π is an isomorphism from A 1 to A 2 .

An isomorphism can also be defined as a bijective substitution σ from var(A 1 ) to var(A 2 ) such that σ(A 1 ) = A 2 . That is why it is often called a "bijective variable renaming".

Furthermore, homomorphisms can also be defined for interpretations.

Definition 1.11 (Homomorphism between Interpretations) Given two interpretations I 1 = (D 1 , I 1 ) and I 2 = (D 2 , I 2 ) of a logical language L = (P, C), a homomorphism from I 1 to I 2 is a mapping π from D 1 to D 2 such that:

• for all c ∈ C, π(I 1 (c)) = I 2 (c),

• for all p ∈ P and (t 1 , . . . , t k ) ∈ I 1 (p), (π(t 1 ), . . . , π(t k )) ∈ I 2 (p).

The last basic logical notion we need is that of prenex form.

Definition 1.12 (Prenex Form) A first-order logical formula is in prenex form, if it is written as a sequence of quantifiers followed by a formula without quantifier, and such that the scope of each quantifier is the whole formula.

It is well known that every first-order formula can be rewritten into a first-order formula of prenex form. Hence, in the following we always assume that all formulae we are dealing with are under prenex form, which allows us to simplify the various definitions and proofs.

Complexity Classes

In this thesis we make use of several complexity classes. While we do not define here all needed technical notions, we recall the definitions of the classes themselves by increasing complexity. Definition 1.13 (AC 0 ) A problem is in AC 0 if it can be solved by a Boolean circuit of bounded depth with a polynomial number of and and or gates.

Definition 1.14 (NLogSpace (NL))

A problem is in NL if it can be solved by a non-deterministic Turing machine using only a working tape of logarithmic space in the input.

Definition 1.15 (Polynomial Time (PTime))

A problem is in P if it can be solved by a deterministic Turing machine running in polynomial time in the input.

Definition 1.16 (Non-deterministic Polynomial Time (NP))

A problem is in NP if it can be solved by a non-deterministic Turing machine running in polynomial time in the input.

Definition 1.17 (Polynomial Space (PSpace)) A problem is in PSpace if it can be solved by a Turing machine using only a tape of polynomial space in the input. Note that it has been shown that non-deterministic polynomial space is equivalent to deterministic polynomial space.

Definition 1.18 (Exponential Time (ExpTime))

A problem is in ExpTime if it can be solved by a deterministic Turing machine running in simple exponential time in the input.

Furthermore, a problem P is hard for a given complexity class C if any instance of a problem from C can be reduced to an instance of P through an "adapted" reduction (in most cases, adapted means "running in polynomial time", but for lower classes (PTime and below), logarithmic space reductions must be used).

Finally a problem P is complete for a given complexity class C, if it belongs to C and is hard for C.

For more details about complexity theory notions, the reader is referred to [START_REF] Papadimitriou | Computational complexity[END_REF].

Existential Rule Framework

A knowledge base is composed of a set of facts and of an ontology, which is here a set of existential rules. We consider the basic database queries, which are (unions of) (Boolean) conjunctive queries. In this section we define formally these objects as well as the associated notions that allow to do reasoning. The main problem we study throughout this manuscript is the conjunctive query entailment problem, which asks if a (Boolean) conjunctive query is a logical consequence of a knowledge base.

In most settings, a fact is a ground atom. However, it is convenient to consider facts with existentially quantified variables, which naturally leads to see a fact as an existentially closed conjunction of atoms. Furthermore, the prenex form of a conjunction of facts is itself a fact, hence we can identify the notions of a fact and a set of facts.

Definition 1.19 (Set of Facts) Given a logical language L, a fact or set of facts is an existentially closed conjunction of atoms on L.

In the following we will often consider sets of facts as sets of atoms, which allows to use set theoretic notions such as the inclusion on sets of facts. We also often omit the existential quantifiers in the representation of facts, since there can be no ambiguity.

Example 1.1 (Set of Facts) Consider the first-order formula F: ∃x∃y(p(x, y) ∧ q(y, a, x) ∧ s(x)); where a is a constant.

The formula F is an existentially closed conjunction of atoms, therefore a set of facts, which we can also denote by {p(x, y), q(y, a, x), s(x)}.

Sets of facts can also be seen as (hyper)graphs, which allows to apply several graph notions to them. Indeed, given a set of facts F, one can build a directed hypergraph whose set of vertices is in bijection with the set of terms of F, and whose set of hyperedges is in bijection with the set of atoms of F. Then each vertex is labelled by the corresponding term, and each edge by the predicate of the corresponding atom. If all variables of a conjunctive query Q are quantified (thus Q has the exact same form as a set of facts), we say that Q is a Boolean conjunctive query (BCQ). Throughout this thesis we only consider Boolean conjunctive queries that we simply call conjunctive queries.

A well-known fundamental result is that the logical consequence on existentially closed conjunctions of atoms (e.g., two sets of facts or Boolean conjunctive queries) amounts to the existence of a homomorphism as stated by the next theorem, which has been proven in several contexts (see, e.g., [START_REF] Abiteboul | Foundations of Databases[END_REF] for a version in terms of classical CQ containment).

Let F 1 and F 2 be two sets of facts. There exists a homomorphism from F 1 to F 2 if and only if F 2 |= F 1 .

Theorem 1.1 (Folklore) Since one can compare two sets of facts with respect to logical consequence, it is natural to consider the core of a set of facts, which is a minimal equivalent subset. It should be pointed out that the definition of core we give here is restricted to finite sets of facts, which is enough for our needs. However, a more technical definition for infinite sets exists [START_REF] Bodirsky | The core of a countably categorical structure[END_REF].

Definition 1.21 (Core) Given a finite set of facts F, a core of F is a minimal subset of F equivalent to F. Example 1.3 (Core) Consider the set of facts F = p(x, y) ∧ p(y, z) ∧ p(x, u) ∧ p(u, z). A core of F is p(x, y) ∧ p(y, z).
It is well-known that if F is a finite set of facts, then all its cores are isomorphic, for instance in Example 1.3, the set of facts p(x, u) ∧ p(u, z) is also a core of F.

Furthermore, given a set of facts F, one can define its "isomorphic model", which has the same structure as F.

Definition 1.22 (Isomorphic Model) Given a set of facts F built on the logical language L = (P, C), the isomorphic model of F denoted by M (F) = (D, I) is defined as follows:

• D is in bijection with terms(F) ∪ C (to simplify notations we consider that this bijection is the identity),

• for all c ∈ C,

I(c) = c,
• for all p ∈ P,

I(p) = {(t 1 , . . . , t k ) | p(t 1 , . . . , t k ) ∈ F}.
Finally, it is also well-known that the following properties are equivalent: given two sets of facts F 1 and F 2 ,

1. F 1 |= F 2 , 2. there is a homomorphism from F 2 to F 1 , 3. M (F 1 ) is a model of F 2 .
An existential rule is a positive (and conjunctive) rule. Its special feature is that its head may introduce variables that do not occur in its body, and which are existentially quantified, hence the name "existential rule". This allows to infer the existence of unknown individuals (possibly equal to (known) individuals appearing in the set of facts). Since no ambiguity can arise, we omit the quantifiers in rules.

Example 1.4 (Existential Rule)

Consider the rule R = ∀x∀y(p(x, y) → ∃z(p(y, z))). This rule will also be denoted by R = p(x, y) → p(y, z). Variable y is the only frontier variable of R and z is its only existential variable.

Two other kinds of rules may be added to the framework: negative constraints, which are rules with an absurd head (B → ⊥), and equality rules which are rules whose head specifies the equality between two terms (B → t 1 = t 2 ). For details, see [START_REF] Baget | On rules with existential variables: Walking the decidability line[END_REF][START_REF] Calì | A general datalog-based framework for tractable query answering over ontologies[END_REF]. It should be pointed out that there is no additional complexity (or decidability) cost for considering negative constraints (except if only particular BCQ are considered). By contrast, equality rules are known for being hard to handle from both complexity and decidability points of view. In the following, we restrict our focus to knowledge bases without negative constraints nor equality rules. We are now ready to formally define a knowledge base.

Definition 1.24 (Knowledge Base)

A knowledge base is a pair K = (F, R) where F is a (finite) set of facts and R is a (finite) set of existential rules.

Note that, without loss of generality, we will always assume that sets of facts and all rules use disjoint sets of variables.

In the following, when we consider logical notions involving knowledge bases, sets of rules and/or facts, we implicitly consider the associated formula which is the conjunction of all involved formulae. In particular, (F, R) is seen as the conjunction of the formula associated with F and of all the rules from R.

A nice property of this setting is that given a knowledge base K = (F, R), there always exists a model of K that can be considered as a representative of all models of K, in the sense that is is sufficient to consider this model to check entailment from K. Such a model has the property of being "universal". Definition 1.25 (Universal Model) Given a knowledge base K = (F, R), a universal model M of K is a model of K such that for all models M ′ of K, there is a homomorphism from M to M ′ .

Note that not all knowledge bases have a finite universal model. Now that we have defined all of our basics objects, we can reformulate the entailment problem more formally: Given a knowledge base K = (F, R) and a Boolean conjunctive query Q, the conjunctive query entailment problem (CQ entailment) asks the following question: does

K |= Q hold? Problem 1.1 (Conjunctive Query Entailment)
It is well-known that this problem is undecidable (e.g., [START_REF] Beeri | The implication problem for data dependencies[END_REF]), even under strong restrictions such as using a single rule or restricting the vocabulary (a single binary predicate, no constant, ...), see, for instance, [START_REF] Baget | On rules with existential variables: Walking the decidability line[END_REF].

However many restrictions on the set of rules are known to ensure decidability. Most of them can be classified in three families, which are associated with forward or backward chaining schemes [START_REF] Baget | On rules with existential variables: Walking the decidability line[END_REF]. The first one is that of Finite Expansion Sets (FES). It ensures that a finite universal model of the knowledge base exists. This property allows for some finite Forward Chaining, a process that "applies" rules until an answer to the query is found or nothing "useful" is produced. The second family is called Finite Unification Sets (FUS) and guarantees that some Backward Chaining method halts. This process uses the rules to "rewrite" the query which creates a UCQ, which is then checked against the initial set of facts. Finally, the last family is called Bounded Treewidth Set (BTS) [START_REF] Calì | Taming the infinite chase: Query answering under expressive relational constraints[END_REF]. It ensures that the potentially infinite universal model of the knowledge base has a bounded treewidth. This class does not give an algorithm yet, but thanks to Courcelle's theorem [START_REF] Courcelle | The monadic second-order logic of graphs, II: infinite graphs of bounded width[END_REF], we know that entailment over BTS knowledge bases is decidable. Furthermore, an expressive subclass of BTS, namely Greedy BTS (GBTS) is provided with an algorithm [START_REF] Baget | Walking the complexity lines for generalized guarded existential rules[END_REF][START_REF] Thomazo | Conjunctive Query Answering Under Existential Rules -Decidability, Complexity, and Algorithms[END_REF]. These classes will be precisely defined in Chapter 2.

Forward Chaining

Rules allow to infer new knowledge from an initial set of facts, giving rise to the notion of rule application. This notion is defined as usual in rule languages, i.e., the head of the rule is added to the set of facts according to a homomorphism from the body of the rule to the set of facts. The only specificity for existential rules is that existential variables in the rule head are replaced by fresh variables.

Definition 1.26 (Rule Applicability)

A rule R = B → H is applicable to a set of facts F if there exists a homomorphism π from B to F.

Definition 1.27 (Rule Application)

Given a set of facts F, a rule R = B → H and a homomorphism π from B to F, the result of the application of the rule R on F according to π is defined as

α(F, R, π) = F ∪ π saf e (H)
where π saf e if the extension of π to the existential variables of R, i.e.: for all variables x occurring in H, π saf e (x) = π(x) if x ∈ f r(R) and π saf e (x) = z otherwise, where z is a fresh variable (i.e., a variable that does not occur elsewhere).

Intuitively, π saf e is a "safe" extension of π that maps all existential variables of H to some distinct fresh variables, in order to avoid confusion with variables already occurring in F.

Example 1.5 (Rule Application)

Let F = {c(a)} be a set of facts and R = c(x) → p(x, y) ∧ c(y) be an existential rule.

Rule R is applicable to F since there exists the following homomorphism π = {x → a}, and the application of R on F according to π produces the set of facts

F 1 = α(F, R, π) = c(a) ∧ p(a, y 1 ) ∧ c(y 1 ).
Then rule R is applicable to F 1 thanks to the homomorphism π 2 = {x → y 1 }, which would produce p(y 1 , y 2 ) ∧ c(y 2 ) (and we could go on like this since each added c-atom allows for a new application of R).

A sequence of rule applications is called a derivation and is defined as follows.

Definition 1.28 (Derivation) Given a set of facts F and a set of rules R,

a derivation of F w.r.t. R (also called R-derivation) is a (potentially infinite) sequence D of triples of the form (R i , π i , F i ) such that D 0 = (∅, ∅, F 0 = F), and ∀i > 0 in dom(D), R i = (B i , H i ) ∈ R, π i is a homomorphism from B i to F i-1 and F i = α(F i-1 , R i , π i ).
When D is of length k ∈ N, we say that it is a derivation from F to F k . A derivation D of F with respect to R could be:

i R i π i F i 0 ∅ ∅ F 1 R {x → a} F ∪ {p(a, y 1 ), c(y 1 )}) . . . . . . . . . . . . k R {x → y k-1 } F k-1 ∪ {p(y k-1 , y k ), c(y k )} . . . . . . . . . . . .

Note that in this example

, only a single derivation (not using the same homomorphism twice) is possible, but in general, this is not the case.

The next theorem states that derivations are a sound and complete way to "solve" the CQ entailment problem.

Let F be a set of facts, R be a set of rules, and Q be a Boolean conjunctive query; then, (F, R) |= Q if and only if there exists a (finite) R-derivation

from F to F k such that F k |= Q. Theorem 1.2 ([BLMS11])
Chapter 3 is devoted to the family of forward chaining algorithms and to rule classes for which some of these algorithms always halt.

Backward Chaining

In contrast with forward chaining, backward chaining mecanisms start from the query. In Prolog and other logic programming languages, facts are ground atoms (which possibly involve functional symbols) and are seen as rules with an empty body. The aim is then to "erase" the query by iteratively rewriting it with the rules. In knowledge representation, we clearly distinguish between rules and facts, hence we decompose the backward chaining into two processes: rewriting the query using the rules, and mapping a rewritten query to the set of facts (by homomorphism). The OBDA approach goes one step further by completing the rewriting process before trying to map the obtained query (or set of queries) to the set of facts. The aim is to come back to a classical database query answering problem.

Differently from classical unifiers used in logic programming which unify an atom from the query with the head atom, piece-unifiers do not consider a single atom of the query but a subset of the query. This allows to correctly process existential variables as illustrated by the next example.

Example 1.7 (Classical Unifier) Consider the rule R = person(x) → hasP arent(x, z) which says that every person has a parent, and the set of facts F = person(Bob) ∧ painter(M ax). Assume one asks if someone has a parent who is a painter with the following query Q = ∃u, v(hasP arent(u, v) ∧ painter(v)). With a classical (most general) unifier of Q with the head of R, for instance {x → u, z → v}, we obtain the direct rewriting Q 1 = ∃u, v(person(u) ∧ painter(v)) (in which the connection between u and v has been lost). We then have that F |= Q 1 while (F, R) |= Q. Hence, this rewriting is unsound. Here the "piece condition" from the following definition of a piece-unifier has been violated.

Piece-unifiers can be seen as generalised unifiers, in the sense that they unify two sets of atoms. Moreoever they process existential variables in a special way.

The following definition of a piece-unifier considers the partition on terms induced by a (generalised) unifier: the terms unified together are in the same class of the partition. Partitions have nice properties that are convenient in proofs.

Definition 1.29 (Piece-unifier) Given a rule R = (B, H) and a set of atoms Q, a piece-unifier of Q with H is a triple µ = (Q ′ , H ′ , P µ ) where Q ′ ⊆ Q, H ′ ⊆ H and P µ is a partition of terms of Q ′ ∪ H ′ such that:
(i) Admissibility: there is at most one single constant or existential variable from H ′ in each class of P µ , and if a class contains an existential variable, it cannot contain a frontier variable from R (hence, the other terms in the class are from Q ′ );

(ii) Unifiability:

σ µ (Q ′ ) = σ µ (H ′ )
, where σ µ is a substitution associated with the partition P µ (formally defined below);

(iii) Piece condition: if there is an existential variable z occurring in H ′ then no atom from Q \ Q ′ may contain a variable x occurring in the same class as z.

Definition 1.30 (Substitution Associated with a Partition) Given an admissible partition of a set of terms P µ , a substitution associated with P µ is obtained as follows: for each class

C ∈ P µ , choose a term t C ∈ C (if C contains a constant, then t C must be that constant); then σ µ = C∈P {t → t C | ∀t ∈ C}.
The terms t C are said to be preserved by the substitution.

Note that when a class contains only variables, one can choose to give priority to variables occurring in the query or in the rule.

Example 1.8 (Piece-unifier) Consider the rule R = p(x, y) → s(x, z) and the conjunctive query

Q = s(a, u) ∧ s(v, u) ∧ r(v)
, where a is a constant. There is the following piece-unifier of Q with H:

{Q ′ = {s(a, u), s(v, u)}, H ′ = {s(x, z)}, P µ = {{a, v, x}, {u, z}}}
Indeed, no class of P µ contains more than one existential variable from H ′ or constant, and the class that contains an existential variable does not contain any frontier variable, thus admissibility is satisfied. One can choose for instance the substitution

σ µ = {v → a, x → a, u → z}. We then check that σ µ (Q ′ ) = σ µ (H ′ ).
Finally all atoms of Q using variable u (which is unified with the existential variable z) belong to Q ′ , hence the piece condition is satisfied. Note that no smaller piece-unifier of Q with H exists since u is necessarily unified with z, hence the piece condition requires that both atoms of Q are part of Q ′ .

Given this extended notion of unifier, we can now define a direct query rewriting as follows.

Definition 1.31 (Direct Query Rewriting) Given a rule R = (B, H), a conjunctive query Q, a piece-unifier µ = (Q ′ , H ′ , P µ ) of Q with H and a substitution σ µ associated with P µ , the direct query rewriting of Q according to µ is the following CQ:

β(Q, R, µ) = σ µ (Q \ Q ′ ) ∪ σ µ (B).
Note that in the above definition any substitution associated with µ can be used, as they all give isomorphic results.

Example 1.9 (Direct Rewriting) Consider the rule R, the query Q and the piece-unifier µ from Example 1.8. The direct rewriting of Q according to µ is:

β(Q, R, µ) = r(a) ∧ p(a, y).
Then a rewriting sequence is defined as a sequence of direct rewriting steps.

Definition 1.32 (Rewriting Sequence) Given a CQ Q, and a set of rules R, a rewriting sequence of Q w.r.t. R (also called an R-rewriting sequence) is a (potentially infinite) sequence S of triples

(R i , µ i , Q i ) such that S 0 = (∅, ∅, Q) and ∀i > 0, R i = (B i , H i ) ∈ R, µ i is a piece-unifier of Q i-1 with H i and Q i = β(Q i-1 , R i , µ i ).
When S is of length k ∈ N, we say that it is a rewriting sequence from Q to Q k .

Similarily to derivations, rewriting sequences are a sound and complete way to "solve" the CQ entailment problem as stated by the next theorem.

Let F be a set of facts, R be a set of rules and Q be a Boolean conjunctive query; then, (F, R) |= Q if and only if there exists a rewriting sequence from

Q to Q k such that F |= Q k . Theorem 1.3 ([BLMS11])
This notion gives naturally rise to an algorithm that reads: let Q = {Q}, for all queries Q i ∈ Q, rewrite Q i according to some unifier, then add the result to Q if it is not equivalent to another query. If at some point no new query is added, end the process and evaluate the union of conjunctive queries on the knowledge base.

While both of these scheme families seem quite different, they are actually strongly related in the sense that given a knowledge base K = (F, R) and a Boolean conjunctive query Q, if there exists a derivation of F w.r.t. R of length k such that F k entails Q, then there exists a rewriting sequence of at most length k leading to a query Q ′ entailed by F; and if there exists a rewriting sequence of length k such that F entails Q k , then there exists a derivation of same length leading to a set of facts F k such that F k entails Q, as stated by the next theorem.

Note that the derivation may be longer than the rewriting sequence, since in the former one can add rule applications that are useless to answer Q.

Let F be a set of facts, R be a set of rules and Q be a conjunctive query. If there exists a derivation from

F to F k such that F k |= Q, then there exists k ′ ≤ k and a rewriting sequence from Q to Q k ′ such that F |= Q k ′ . Furthermore, if there exists a rewriting sequence from Q to Q k such that F |= Q k , then there exists a derivation from F to F k such that F k |= Q. Theorem 1.4 ([BLMS11])

Some Useful Translations

In this section we define several transformations of sets of rules (with one of them also involving a translation of the set of facts), mostly used to simplify the shape of the rules we need to consider.

The first translation is used to convert rules into single-piece headed rules. We define first the "piece graph" of a rule that allows us to easily define the notion of piece.

Definition 1.33 (Piece Graph)

Given a rule R = (B, H) its piece graph is defined as the undirected graph whose set of vertices is the set of atoms occurring in H, and where there is an edge between two vertices corresponding to atoms h 1 and h 2 in H if there is an existential variable z such that z ∈ var(h 1 ) and z ∈ var(h 2 ).

Definition 1.34 (Rule Piece, Single-piece Headed Rule) Given a rule R = (B, H), a rule piece of R is the set of atoms corresponding to a connected component of the piece graph of R.

A rule R is a single-piece headed rule if H is a single rule piece of R.

Intuitively, a rule piece corresponds to the minimal unit of information contained in a rule head. Indeed, any rule can be decomposed into an equivalent set of rules with the same body and a head restricted to a single rule piece as performed by the following translation.

Definition 1.35 (Single-piece Translation)

Given a set of rules R, its single-piece translation sp(R) is defined as follows. For each rule R = (B, H) ∈ R, for each rule piece

H i of R, add in sp(R) the rule B → H i .
This transformation is without loss of generality, hence, we can always assume that all rules we consider are single-piece.

Given a set of rules R, R and sp(R) are logically equivalent.

Proposition 1.1 Example 1.10 (Single-piece Translation) Consider the following rule (where c is a constant and every other term a variable): R = p(x, y, c) → q(y, z 1 ) ∧ r(z 1 ) ∧ s(x, c, z 2 ).

The piece graph of R is depicted on Figure 1.2. The single-piece translation of {R} is the following set of rules R ′ :

q(y, z 1 ) r(z 1 ) s(x, c, z 2 ) Figure 1.2: Piece Graph of rule R from Example 1.10 • R 1 = p(x, y, c) → q(y, z 1 ) ∧ r(z 1 ) • R 2 = p(x, y, c) → s(x, c, z 2 )
The next translation further simplifies the shape of rules we consider.

Definition 1.36 (Atomic-headed Translation) Given a set of rules R its atomic-headed translation ah(R) is defined as follows.

For each rule R = (B, H) ∈ sp(R) where |H| > 1, perform the following:

1. create a new predicate r R of arity |var(H)|, 2. add to ah(R) the rule B → r R ( t)
where t is the set of variables occurring in H,

for each atom h

i ∈ H, add the rule r R ( t) → h i to ah(R).
This translation creates new predicates with arity depending on the size of a rule head, and thus is not suitable in a context where we consider that the arity is bounded. However, if the arity is not assumed to be bounded, it will prove useful to be able to simplify rule heads into single atoms.

Example 1.11 (Atomic-headed Translation) Consider again the rule R from Example 1.10, and its single-piece translation sp(R) = {R 1 , R 2 }. Its atomic-headed translation is the following set of rules:

• R 1,a = p(x, y, c) → r R 1 (y, z 1 ) • R 1,b 1 = r R 1 (y, z 1 ) → q(y, z 1 ) • R 1,b 2 = r R 1 (y, z 1 ) → r(z 1 ) • R 2 = p(x, y, c) → s(x, c, z 2 )
Note that this translation could be defined on any set of rules R without first decomposing it into sp(R), however it would potentially create predicates with an arity larger than needed.

Let R be a set of rules. For any CQ Q and knowledge base (F, R) on a logical language L, (F,

R) |= Q iff (F, ah(R)) |= Q. Proposition 1.2
The last translation we consider is used to get rid of constants occurring in rules. As for the atomic-headed translation, this cannot be used without loss of generality in the case where the arity is bounded. Furthermore, this translation not only modifies the rules, but also the set of facts. The idea is to totally order the constants, say from c 1 to c n , and increase the arity of each predicate by creating a placeholder for each constant. Then rules are translated in such a way that p(. . . , c, . . . ) where c is the i th constant becomes p ′ (. . . , x i , . . . , x 1 , . . . , x n ), where x i stands for the i th constant. Hence the occurrence of the i th constant in an atom is replaced by the double occurrence of the variable x i . Facts are translated by adding c 1 , . . . , c n at the end of each atom.

Definition 1.37 (No-constant Translation) Given a knowledge base K = (F, R), its no-constant translation nc(K) is defined as follows. For each predicate p of arity k, create a new predicate p ′ with arity k + |cst(K)|, where cst(K) = {c 1 , . . . , c n } is the set of all constants occurring either in F or in some rule R ∈ R.

Then for each atom α = p(t 1 , . . . , t k ) in some rule R ∈ R, replace α by an atom p ′ (t ′ 1 , . . . , t ′ k , . . . , t ′ k+n ) where (all x j being distinct fresh variables):

t ′ i =      t i if i ≤ k and t i is a variable, x j if i ≤ k and t i = c j , x j if i = k + j.
Now for each atom α = p(t 1 , . . . , t k ) in F, replace α by an atom p ′ (t 1 , . . . , t k , c 1 , . . . , c n ).

Finally, for each predicate p create the rule p ′ (y 1 , . . . , y k , x 1 , . . . , x n ) → p(y 1 , . . . , y k ), where all variables are distinct.

Example 1.12 (No-constant Translation) Consider again rule R = p(x, y, c) → q(y, z 1 ) ∧ r(z 1 ) ∧ s(x, c, z 2 ) from Example 1.10, and let F = p(b, b, b) ∧ p(b, b, c) be a set of facts, where b is a constant. The no-constant translation of K = (F, {R}) is obtained as follows. The set of constants is {b, c}, hence n = 2. First we create four new predicates p ′ , q ′ , r ′ and s ′ of arity 5, 4, 3 and 5 respectively. Now we update rule R into:

R ′ = p ′ (x, y, x 2 , x 1 , x 2 ) → q ′ (y, z 1 , x 1 , x 2 ) ∧ r ′ (z 1 , x 1 , x 2 ) ∧ s ′ (x, x 2 , z 2 , x 1 , x 2 )
Then the set of facts becomes F ′ = p(b, b, b, b, c) ∧ p(b, b, c, b, c). Finally we add the following four rules (one for each predicate):

• R p = p ′ (y 1 , y 2 , y 3 , x 1 , x 2 ) → p(y 1 , y 2 , y 3 ),

• R q = q ′ (y 1 , y 2 , x 1 , x 2 ) → q(y 1 , y 2 ),

• R r = r ′ (y 1 , x 1 , x 2 ) → r(y 1 ),

• R s = s ′ (y 1 , y 2 , y 3 , x 1 , x 2 ) → s(y 1 , y 2 , y 3 ).

These four rules allow to transfer facts from the new vocabulary to the original one.

Let R be a set of rules. For any CQ Q and knowledge base (F, R) on a logical language L, (F,

R) |= Q iff nc(F, R) |= Q. Proposition 1.3
In particular, in Section 4.2, we will make the assumption that all rules are singleheaded rules and contain no constant, and this will allow for simpler decidability proofs.

Furthermore, note that both the atomic-headed and the no-constant translations only preserve answers on the original vocabulary. Indeed, new predicates are created, and thus, queries that would involve these new predicates may have a positive answer in the translation but not in the original knowledge base.

Conclusion

The next chapters will rely on the fundamental notions we have introduced here:

• Chapter 2: this chapter is devoted to rule classes for which the CQ entailment problem is decidable. Derivations and rewriting sequences are the fundamental mechanisms that underly these classes.

• Chapter 3: several forward chaining (or "chase") mechanisms can be based on the derivation notion, and after recalling most of them, we study the various acyclicity conditions that ensure the finiteness of some forward chaining variant.

• Chapter 4: we study the compatibility of transitivity rules with other known decidable classes of rules. The algorithm we develop for the case of linear rules is based on backward chaining techniques.

In this chapter we review various decidability and complexity results from the literature for the CQ entailment problem. More specifically, we recall the main classes of rules C such that entailment over knowledge bases where the set of rules belongs to C is decidable. For brevity reasons, we often refer to them as "decidable classes of rules". We end this chapter by pointing out the relationships between description logics and the existential rule framework.

Abstract Rule Classes

First, we recall three abstract rule classes, "abstract" in the sense that we cannot decide in general whether a set of rules belongs to one of them [START_REF] Baget | On rules with existential variables: Walking the decidability line[END_REF]. These classes ensure a specific behaviour of either some forward or some backward chaining algorithm.

Definition 2.1 (Finite Expansion Set (FES) [START_REF] Baget | On rules with existential variables: Walking the decidability line[END_REF]) Given a set of rules R, we say that R satisfies the Finite Expansion Set (FES) property if for any set of facts F, there exists some k ∈ N such that for any query Q, there exists a (finite) derivation from

F to F k such that F k |= Q if and only if (F, R) |= Q.
The Finite Expansion Set property ensures that for any set of facts F, the knowledge base (F, R) has a finite universal model. Hence a forward chaining algorithm that applies rules in a "breadth-first" manner (also known as the "chase"), and after each rule application (or after each breadth-first step) considers the core of the obtained set of facts halts on any knowledge base built with a set of rules satisfying the FES property. Then, the isomorphic model of the saturated set is finite. More details on the different kinds of chase and their properties are given in Section 3.1.

Example 2.1 (Non-FES)

The set of rules composed of the single rule R = q(x) → p(x, y) ∧ q(y) is not FES. Indeed, consider the set of facts q(a). Then one can apply rule R according to homomorphism π 1 = {x → a} and obtain F 1 = q(a) ∧ p(a, y 0 ) ∧ q(y 0 ). A core of F 1 if F 1 itself. The rule R can be applied again, this time using the homomorphism π 2 = {x → y 0 } and the resulting set of facts is F 2 = q(a)∧p(a, y 0 )∧q(y 0 )∧p(y 0 , y 1 )∧q(y 1 ). One can see that this rule can be applied again, and this process will never halt.

The second abstract property relies on query rewriting. A set of rewritings Q of a query Q with a set of rules R is said to be sound and complete if for any set of facts F, it holds that (F, R) |= Q if and only if there is Q i ∈ Q such that F |= Q i (the direction ⇒ expresses the soundness while the direction ⇐ the completeness). When Q is finite, it can be seen as a union of conjunctive queries. Then the previous condition can be recast as:

(F, R) |= Q iff F |= Q.
Definition 2.2 (Finite Unification Set [START_REF] Baget | On rules with existential variables: Walking the decidability line[END_REF]) Given a set of rules R, we say that R satisfies the Finite Unification Set (FUS) property if for any query Q, there is a finite sound and complete set of rewritings of Q with R.

This set is clearly computed independently from any set of facts. Note that the FUS property can also be expressed as follows: a set of rules R is FUS if and only if for any conjunctive query Q, there is some k ∈ N such that the set of all (sound) rewritings of Q with R that can be obtained by a rewriting sequence of length less than or equal to k is complete. In other words, Q is "UCQ-rewritable".

This property ensures that given a set of rules R that satisfies it, any conjunctive query Q can be rewritten into a (finite) union of conjunctive queries Q such that for any set of facts F, (F, R) entails Q if and only if there is a rewriting Q ′ ∈ Q, such that F entails Q ′ . Note that a FUS set of rules may have an infinite sound set of rewritings. However this set always has a finite complete subset obtained by ignoring redundant queries, i.e., queries Q 2 that are contained in another query Q 1 (which can be checked by exhibiting a homomorphism from Q 1 to Q 2 ). In other words, for any query Q there exists some k ∈ N such that the set Q of all sound rewritings of Q obtained by a sequence of length less than or equal to k is complete. Hence, if a knowledge-base is built on a finite unification set of rules, then a query rewriting algorithm that would after each rewriting only keeps the queries that are not contained in another one halts, see [START_REF] König | Sound, complete and minimal ucq-rewriting for existential rules[END_REF] for such an algorithm.

It has been shown in [START_REF] Leclère | On bounded positive existential rules[END_REF] that FUS is equivalent to the Bounded Derivation Depth Property (BDDP) [START_REF] Calì | A general datalog-based framework for tractable query answering over ontologies[END_REF] defined as follows: for any query Q, there exists some k ∈ N such that for any set of facts F, (F, R) |= Q if and only if there exists a (finite) derivation from F to F k such that F k |= Q. This allows to relate the notions of derivations and rewriting sequences for FUS rules: for any query Q there exists some k ∈ N such that for any set of facts F, (F, R) |= Q if and only if there is a (finite) derivation from F to F k such that F k |= Q if and only if there is a (finite) rewriting sequence from

Q to Q k such that F |= Q k .
Furthermore, in [GKK + 14], it is shown that the BDDP is equivalent to Firstorder Rewritability, i.e., to the existence of a first-order formula ϕ(Q) such that (F, R) |= Q if and only if F |= ϕ(Q). While a UCQ rewriting is already a specific kind of first-order rewriting, there may exist a first-order rewriting exponentially smaller than all UCQ rewritings. In turn, every first-order rewriting can be translated into an equivalent UCQ-rewriting (which, however, can be exponentially larger). Such rewriting can thus be useful from a practical point of view, since most databases query languages (such as SQL) allows for first-order querying.

Example 2.2 (Non-FUS)

The following set of rules {p(x, y) ∧ p(y, z) → p(x, z)} is not FUS. For instance the query Q = p(a, b) does not admit a finite sound and complete set of rewritings. Indeed, any sound and complete set of rewritings of Q contains p(a, b) and the queries p(a, y 0 ) ∧ p(y 0 , y 1 ) ∧ . . . p(y k , b) for all k ∈ N. Note that all these queries are pairwise incomparable with respect to containment.

The last abstract property relies on the notion of treewidth of a set of facts. To compute such treewidth, we use the primal graph of a set of facts F, which is the undirected graph defined as follows: the set of vertices is the set of terms occurring in F and there is an edge between two vertices u and v if there is an atom α ∈ F such that the terms corresponding to u and v occur both in α. Then the treewidth of F is the treewidth of the primal graph of F.

Definition 2.3 (Bounded Treewidth Set (BTS) [CGK08, BLMS11])

A set of rules R is a bounded treewidth set (BTS) if for any set of facts F, there exists b ∈ N such that for any derivation from F to F k the core of F k has treewidth at most b.

This property can also be expressed in terms of models: a set of rules R is BTS if and only if there exists a (potentially infinite) universal model of the knowledge base whose treewidth is bounded.

Example 2.3 (Non-BTS)

Consider the following set of rules R:

• R 1 = q(x) → p(x, y) ∧ q(y)

• R 2 = p(x, y) ∧ p(y, z) → p(x, z)
The set of rules R is not BTS. Indeed, the first rule creates an infinite path, while the second computes the transitive closure of this path. Consider for instance the set of facts restricted to a single atom q(a). For any k ∈ N, the set of facts obtained from q(a) by all derivations of length at most k "encodes" a clique of size k (more precisely, its primal graph contains such a clique), hence its treewidth is at least k. Furthermore, it is not possible to suppress this clique by considering the core of the set of facts (actually, under reasonable assumptions on the forward chaining mechanism, the generated set of facts is itself a core). It follows that any universal model of this knowledge base has unbounded treewidth.

Obviously, any FES set of rules is also a BTS set of rules, indeed it suffices to consider the number of terms occurring in a finite universal model as the bound on its treewidth. The decidability relies on Courcelle's Theorem [START_REF] Courcelle | The monadic second-order logic of graphs, II: infinite graphs of bounded width[END_REF], which states that for any logical fragment in which the existence of a model implies the existence of a bounded treewidth model, then the satisfiability of a property that can be expressed in monadic second-order logic is decidable. However this does not provide explicitly an algorithm to answer the entailment problem. Though, there exists an expressive subclass of BTS called Greedy Bounded Treewidth Set (GBTS), for which we do not give a formal definition. Since we will not study it in this thesis, see [START_REF] Baget | Walking the complexity lines for generalized guarded existential rules[END_REF][START_REF] Rudolph | Mixing materialization and query rewriting for existential rules[END_REF][START_REF] Thomazo | Conjunctive Query Answering Under Existential Rules -Decidability, Complexity, and Algorithms[END_REF] for more details. Intuitively, this class ensures that one can build a bounded width tree decomposition of the saturated set of facts greedily, and furthermore compute a finite structure that encodes this tree decomposition. We do not know yet if this class is concrete or abstract, i.e., whether the associated recognition problem is decidable; though, this class is very interesting since on the one hand, a practical algorithm is provided, and on the other hand, to our knowledge, it includes all but one concrete known rule classes belonging to BTS but not to FES.

For each of these abstract rule classes, various concrete rule subclasses have been exhibited. In the following, we detail the main ones, and Figure 2.1 pictures the relations between them: an upwards edge going from a rule class C to a rule class C ′ means that any set of rules in class C is also in class C ′ .

Finite Expansion Set

Regarding FES rule classes, most of them can be classified in two different subfamilies (Section 3.2 is dedicated to them). The first family relies on how existential variables interact with each others, while the second one on how rules are triggered. In the first family, the simplest of all classes is that of range-restricted, or Datalog rules (as it corresponds exactly to the rules in Datalog queries). In these rules, no existential variable appears.

Definition 2.4 (Range-restricted (rr) [AHV95])

A set of rules R is range-restricted if no existential variable occurs in a rule from R.

This rule class, while it seems really simple, allows to already express various interesting ontological properties, such that symmetry, transitivity, ...

Example 2.4 (Range-restricted)

Consider the set of rules R composed of the following rules:

• p(x, y) ∧ p(y, z) → p(x, z) • p(x, y) → p(y, x)
These rules assert that p is a transitive and symmetric binary relation. The set of rules R is range-restricted.

This class has been first extended to allow for existential variables while limiting the way they propagate during the forward chaining, in order to avoid infinite creation of new variables. This constraint relies on a graph of predicate positions as defined below, where to ease the reading we denote by (p, i) the i th position in predicate p. Definition 2.5 (Predicate Position Graph) Given a set of rules R, its predicate position graph, denoted by P P G(R) is the directed labelled graph whose set of vertices is the set of predicate positions of R. Then for each rule R ∈ R and each frontier variable x in B occurring in some position (p, i), edges with origin (p, i) are built as follows: there is an edge from (p, i) to each position (q, j) in H where x occurs, and there is a special edge from (p, i) to each position (q, j) in H where some existential variable y appears.

Then we say that the rank of a predicate position (p, i) is infinite in a set of rules R if (p, i) belongs to a cycle going through a special edge in P P G(R), and is finite otherwise.

The intuition behind this graph is that edges translate how terms can move from a position to another. Furthermore, its special edges mark the generation of existential variables, and if a cycle contains a special edge then an existential variable may lead to generate a new existential variable in the same position, hence may lead to infinitely many new existential variables. Definition 2.6 (Weak-acyclicity (wa) [START_REF] Fagin | Data exchange: semantics and query answering[END_REF]) A set of rules R is weakly-acyclic if its predicate position graph does not contain any cycle going through a predicate position in which an existential variable occurs, i.e., if all predicate positions have finite rank.

Example 2.5 (Weak-acyclicity) Consider rules R 1 = p(x, y) → s(y, z) and R 2 = s(x, y) → p(y, x). The set of rules {R 1 , R 2 } is weakly-acyclic as its predicate position graph does not contain any "special cycle" (i.e., a cycle going through a special edge), hence, all positions are of finite rank as can be seen on Figure 2.2.

(p, 1) (p, 2) (s, 1) (s, 2) Figure 2.2: Predicate Position Graph of {R 1 , R 2 } from Example 2.5
Weak-acyclicity has been further extended to joint-acyclicity by shifting the focus to existential variables instead of predicate positions [START_REF] Krötzsch | Extending decidable existential rules by joining acyclicity and guardedness[END_REF]. This property relies on the notion of "move sets" attached to existential variables. To define them we use the following notation: given a set of atoms A and a term t, P os A (t) is the set of predicate positions in the set A in which t occurs. Intuitively, the move set of a given existential variable contains all predicate positions in which it can appear, i.e., if some rule generates an existential variable z in some position (p, i), and another rule "moves" the variable in position (p, i) to a position (q, j), (as for instance for rule p(x) → q(x), with i = j = 1) then (q, j) is also in the move set of z.

The formal definition of a move set is given next.

Definition 2.7 (Move Set) Given a set of rules R, and an existential variable z occurring in some rule R = (B, H) ∈ R, the move set of z, denoted by M ove(z) is the smallest set of predicate positions such that:

• P os H (z) ⊆ M ove(z),
• for each rule R ′ = (B ′ , H ′ ) and each frontier variable y occurring in R ′ , if P os B ′ (y) ⊆ M ove(z), then P os H ′ (y) ⊆ M ove(z).

From this definition one can build another graph, called the joint-acyclicity graph.

Definition 2.8 (Joint-acyclicity Graph) Given a set of rules R, the joint-acyclicity graph of R, denoted by JA(R) is the directed graph whose set of vertices is the set of all existential variables in R, and where there is an edge from z 1 to z 2 whenever the rule R = (B, H) that contains z 2 also contains a frontier variable y such that P os B (y) ⊆ M ove(z 1 ).

In this graph, an edge from z 1 to z 2 intuitively means that variable z 1 may lead to create another existential variable z 2 . Then a set of rules is jointly-acyclic if its joint-acyclicity graph contains no cycle, since the absence of such cycle ensures that no infinite "loop" of existential variable creation can happen. Definition 2.9 (Joint-acyclicity [START_REF] Krötzsch | Extending decidable existential rules by joining acyclicity and guardedness[END_REF]) A set of rules R is jointly-acyclic if JA(R) does not contain any cycle.

Example 2.6 (ja wa) Let R be the set composed of the following two rules:

• R 1 = p(x 1 , y 1 ) → r(y 1 , z 1 ),

• R 2 = r(y 3 , y 4 ) ∧ r(y 4 , y 3 ) → p(y 3 , y 4 ). Then one can check that M ove(z 1 ) = {(r, 2)} and thus that JA(R) does not contain any edge (hence no cycle), therefore R is jointly-acyclic.

However, it can be observed that R is not weakly-acyclic. Indeed its predicate position graph depicted in Figure 2.3 contains the cycle {(p, 2), (r, 2)} that uses the special edge between those two positions.

Joint-acyclicity can be generalised to super weak-acyclicity by looking at atom positions instead of predicate positions. We do not recall here its formal definition since it would require more technical notions, but this class and others are more deeply studied in Section 3.2, and all formal definitions can be found there.

The other subfamily relies on the notion of rule dependency, which intuitively, is a tool that allows to know if a rule may be triggered after another. Definition 2.10 (Rule Dependency [Bag04, GHK + 13])

Given two rules R 1 = B 1 → H 1 and R 2 = B 2 → H 2 , R 2 depends on R 1 if
there exists a set of facts F such that:

(i) there is a homomorphism π 1 from B 1 to F, (ii) there is a homomorphism π 2 from B 2 to F ′ = α(F, R 1 , π 1 ),

(iii) π 2 is not a homomorphism from B 2 to F, (iv) α(F ′ , R 2 , π 2 ) = F ′ .
Hence, R 2 depends on R 1 if there exists a set of facts F such that R 1 can be applied to F (point (i)) which yields a set of facts F ′ such that R 2 can be applied to F ′ (point (ii)), in a "useful" way (point (iv)), i.e., leading to actually add new atoms, and moreover, R 2 could not be applied on F (point (iii)) according to this homomorphism.

This notion of dependency may seem too abstract to be computed, however piece-unifiers can be used to actually compute it without considering all sets of facts (more details are given in Section 3.2).

Then given a set of rules R, one can build a directed graph whose vertices are the rules, and where there is an edge from R 1 to R 2 if R 2 depends on R 1 (i.e., if an application of R 1 may lead to trigger a new application of R 2 ). We call such a graph, the Graph of Rule Dependencies of R.

Definition 2.11 (Acyclic Graph of Rule Dependencies (aGRD) [Bag04])

A set of rules R is aGRD if its graph of rule dependencies contains no cycle.

The following example shows that aGRD and wa are incomparable.

Example 2.7 (aGRD and wa are incomparable) First, we observe that the weakly-acyclic set of rules from Example 2.5 is not aGRD, since its graph of rule dependencies depicted on Figure 2.4 does contain a cycle. Hence, wa aGRD.

R 1 R 2 Figure 2.4: Graph of Rule Dependencies of {R 1 , R 2 } from Example 2.5
Now, consider the set of rules composed of the following single rule R = p(x, y) ∧ q(y) → p(y, z). Rule R does not depend on itself. Hence, {R} is aGRD. Indeed, this rule does not generate the atom q(z) that would be necessary to apply it again. However its predicate position graph contains a special edge loop on position (p, 2), and thus contains a position of infinite rank, therefore {R} is not weakly-acyclic.

Two other rule classes that deserve to be mentioned are Model Faithful Acyclicity (MFA) and Model Summarizing Acyclicity (MSA), the latter one being an approximation of the first one at a lower complexity cost [GHK + 13]. Both rely on effectively running a forward chaining algorithm (the skolem chase, see Section 3.1 for details) on a specific set of facts (called a critical instance), and with a modified set of rules. This critical instance has the nice property that if the forward chaining algorithm proposed in the paper halts on it, then it halts on any set of facts. Furthermore, after each rule application, the obtained set of facts is queried to check if some "cycle" has been found. Either the query finds a positive answer at some point, then the set of rules is not MFA (respectively MSA), or the forward chaining halts, then the set of rules is MFA (respectively MSA). These classes are precisely defined in Section 3.5.

Bounded Treewidth Set

Regarding BTS but not FES rules, the fundamental class is that of guarded rules [START_REF] Calì | Taming the infinite chase: Query answering under expressive relational constraints[END_REF][START_REF] Calì | Taming the infinite chase: Query answering under expressive relational constraints[END_REF].

Definition 2.12 (Guarded [CGK13])

A rule R = (B, H) is guarded if its body contains an atom α such that for any variable x occurring in B, x appears in α (such an atom is called a guard). By extension, a set of rules is guarded if all its rules are.

Example 2.8 (Guarded) Consider the rule R = p(x, y) ∧ s(y) → q(x, y, z), R is guarded since the atom p(x, y) contains all variables from its body.

Another well-known BTS class is that of rules that have a frontier of size one. Definition 2.13 (Frontier-one (fr1) [START_REF] Baget | On rules with existential variables: Walking the decidability line[END_REF]) A rule R is frontier-one if |f r(R)| = 1. By extension, a set of rules is frontierone if all its rules are.

To any derivation from a set of facts F with a set of guarded and/or frontier-one rules R can be associated a tree decomposition of width |terms(F)| + h, where h is the maximal number of terms in the head of a rule from R. Hence these classes are BTS. Furthermore, they are GBTS since such a tree decomposition can be built in a greedy way [START_REF] Baget | Walking the complexity lines for generalized guarded existential rules[END_REF].

Example 2.9 (Guarded and Frontier-one are incomparable) First, note that the guarded rule R from Example 2.8 is not frontier-one. Hence guarded fr1. Now consider the rule R ′ = p(x 1 , y) ∧ s(x 2 , y) → q(y, z). Rule R ′ is frontier-one, but is not guarded, since no atom contains all variables from its body. Hence fr1 guarded.

The guarded family has been widely studied, and a first generalisation of both guarded and frontier-one rules is the class of frontier-guarded rules, where only the frontier needs to be guarded. Indeed, the structure of the set of facts generated through forward chaining only depends on the way the frontier of rules is mapped during the forward chaining. Therefore, to ensure the (G)BTS property, only the frontier of each rule needs to be guarded.

Definition 2.14 (Frontier-guarded (fg) [BLM10, BMRT11])

A rule R = (B, H) is guarded if its body contains an atom α such that for any variable x occurring in the frontier of R, x appears in α. By extension, a set of rules is frontier-guarded if all its rules are.

Example 2.10 (Frontier-guarded) Consider the following three rules:

• R 1 = q(x 1 , x 2 ) → p(x 1 , z 1 , z 2 ) • R 2 = p(x 1 , x 2 , x 3 ) → q(z 1 , z 2 ) ∧ r(z 1 , x 3 ) • R 3 = r(x 2 , x 1 ) ∧ q(x 1 , x 3 ) → s(x 2 )
The set of rules {R 1 , R 2 , R 3 } is frontier-guarded, indeed, the first two rules are guarded since they contain only a single atom. Regarding the third rule, the only frontier variable is x 2 , and therefore atom r(x 2 , x 1 ) guards all frontier variables.

Guarded rules have been extended in another direction, by restricting the guard to variables that are "affected". Intuitively, an affected predicate position is a position in which some existential variable may be generated during the forward chaining, and an affected variable is a variable that occurs in some affected position. This generalisation has been called weakly-guarded [START_REF] Calì | Taming the infinite chase: Query answering under expressive relational constraints[END_REF].

The idea behind this rule class, is that if a predicate position is not affected, then it is not dangerous for the construction of a tree decomposition of bounded width, since only constants (and variables already present in the initial set of facts if any) may occur in this position.

Definition 2.15 (Affected Position and Variable)

Given a set of rules R, a predicate position (p, i) is affected, if there exists an existential variable occurring in position (p, i) or if there is a frontier variable x on position (p, i) in the head of a rule occurring in an affected position in its body.

A variable from a rule body is said to be affected if it occurs in some affected position.

Definition 2.16 (Weakly-guarded (wg) [CGK08, CGK13])

A set of rules R is weakly-guarded if for any rule R = (B, H) ∈ R, its body contains an atom α such that for any affected variable x occurring in B, x appears in α.

Example 2.11 (fg and wg are incomparable) First, notice that the set of rules from Example 2.10 is not weakly-guarded, since in rule R 3 , all x 1 , x 2 and x 3 are affected, and no atom contains all of them. Indeed, positions (p, 2) and (p, 3) are affected because of rule R 1 , and positions (q, 1), (q, 2) and (r, 1) because of rule R 2 . Furthermore, in rule R 3 , x 1 occurs in position (q, 1), x 2 in position (r, 1) and x 3 in position (q, 2). Hence, fg wg. Now, consider rules R 4 = p(x) → q(x, z) and R 5 = r(y, x 1 )∧q(y, x 2 ) → s(x 1 , x 2 ). The set of rules {R 4 , R 5 } is not frontier-guarded since rule R 5 is not. However it is weakly-guarded, since its set of affected positions is {(q, 2), (s, 2)} and atom q(y, x 2 ) in R 5 guards x 2 , the only variable occurring in an affected position. Hence, wg fg.

Both of these generalisations of guardedness can be combined together, defining a more general rule class: namely, weakly-frontier-guarded.

Definition 2.17 (Weakly-frontier-guarded (wfg) [BMRT11])

A set of rules R is weakly-frontier-guarded if for any rule R = (B, H) ∈ R, its body contains an atom α such that for any affected variable x occurring in the frontier of R, x appears in α.

Example 2.12 (Weakly-frontier-guarded) Consider the rules R 1 = p(x) → q(x, z) and R 2 = r(y, x 1 ) ∧ q(y, x 2 ) ∧ q(y, x 3 ) → s(x 1 , x 2 ) The set of rules {R 1 , R 2 } is not weakly-guarded since position (q, 2) is affected and thus rule R 2 would need to have an atom guarding both x 2 and x 3 . It is not frontier-guarded either, since both x 1 and x 2 occur in the frontier of R 2 , and no atom contains both of them. However it is weakly-frontier-guarded as atom q(y, x 2 ) guards x 2 , the only affected variable occurring in the frontier.

This rule class has been further generalised by refining the notion of affected variable thanks to the use of the move set of a given variable. Roughly, the same idea of propagation is used, but the condition on the propagation is more accurate.

Definition 2.18 (Jointly-affected Position and Variable) Given a set of rules R, a predicate position (p, i) is a jointly-affected position if there is an existential variable z such that (p, i) ∈ M ove(z).

A variable x from a rule body is a jointly-affected variable if it occurs only in jointly-affected positions.

Definition 2.19 (Jointly-weakly-frontier-guarded (j-wfg) [KR11])

A set of rules R is jointly-weakly-frontier-guarded if for any rule R = (B, H) ∈ R, its body contains an atom α such that for any jointly-affected variable x occurring in the frontier of R, x appears in α.

Example 2.13 (Jointly-weakly-frontier-guarded) Consider the following two rules:

• R 1 = p(x) → q(x, z) • R 2 = r(x, x 1 ) ∧ q(y, x 1 ) ∧ q(y, x 2 ) → s(x 1 , x 2 )
The set of rules {R 1 , R 2 } is not weakly-frontier-guarded, indeed, position (q, 2) is affected, and the frontier of R 2 is {x 1 , x 2 }. Both variables occur in position (q, 2) and thus should be guarded, however no atom contains both of them.

However, it is jointly-weakly-frontier-guarded, since M ove(z) = {(q, 2)} and thus the only jointly-affected variable in R 2 is x 2 (since x 1 also occurs in the non jointlyaffected position (r, 2)). Therefore, atom q(y, x 2 ) guards all jointly-affected variables.

Interestingly, all those rule classes are not only BTS but also GBTS, and to the best of our knowledge, only a single rule class is known to be BTS but neither FES nor GBTS, namely glut-frontier-guarded defined next.

Definition 2.20 (Glut Variable)

Given a set of rules R and a variable x, x is a glut variable if there exists an existential variable z such that z occurs in some cycle in JA(R) and x appears in a position in M ove(z).

Once again, the idea behind this rule class is to guard only dangerous variables, and the notion of glut variable refines that of jointly-affected variable by furthermore looking at the joint-acyclicity graph of the set of rules to determine if the suspicious variable occurs in a position where an existential variable that belongs to a dangerous cycle may also occur.

Definition 2.21 (Glut-frontier-guarded (glut-fg) [KR11])

A set of rules R is glut-frontier-guarded if for any rule R = (B, H) ∈ R, its body contains an atom α such that for any glut variable x occurring in the frontier of R, x appears in α.

Example 2.14 (Glut-frontier-guarded) Consider the set of rules R composed of the following two rules:

• p(x) → q(x, z) • q(y, x 1 ) ∧ q(y, x 2 ) → s(x 1 , x 2 )
The set R is not jointly-weakly-frontier-guarded since M ove(z) contains position (q, 2), and thus in rule R 2 frontier variables x 1 and x 2 occur only at jointly-affected positions, and hence need to be guarded.

On the other hand, JA(R) contains no edge, and thus no cycle. Hence, no variable from R is a glut variable, therefore, R is glut-frontier-guarded.

Finite Unification Set

Regarding FUS classes, the first one we recall is a specialisation of guarded rules that enjoys the FUS property: namely, the linear rules [START_REF] Calì | Taming the infinite chase: Query answering under expressive relational constraints[END_REF], they are called "atomic-hypothesis" in [START_REF] Baget | Extending decidable cases for rules with existential variables[END_REF].

Definition 2.22 (Linear [CGK08, BLMS09]) A rule R = (B, H) is linear if |B| = 1.
By extension, a set of rules is linear if all its rules are.

While linear rules may seem quite inexpressive, they are actually enough to express many common ontological properties such as subclass, domain, range, inverse relations, ... Furthermore, Section 4.2 is devoted to combining linear rules with transitivity rules and more details are given there.

Two other FUS classes that are incomparable both with linear and with each other are sticky and domain-restricted rules. Both classes impose constraints that can be understood by considering a query rewriting step. The direct rewriting of a query Q with a rule R involves the creation of a new variable if some variable from the body does not occur in the unified atoms from the head. Since not all atoms from a rule head may be part of the unification, by imposing that all variables from a rule body occur in all atoms from a rule head, we are sure that no new variable is generated during query rewriting. The sticky and domain-restricted classes relax this constraint by allowing the generation of new variables, but controlling their occurrences in order to ensure the finiteness of the query rewriting process. Note that linear and sticky rules have been generalised by an abstract property named "backward shyness" [START_REF] Thomazo | Conjunctive Query Answering Under Existential Rules -Decidability, Complexity, and Algorithms[END_REF], which roughly says that a variable generated during a query rewriting sequence does not occur in two atoms of the obtained rewriting.

The sticky rule class relies on the notion of marked variable set.

Definition 2.23 (Marked Variable Set)

Given a set of rules R, the marked variable set of R is built by the following marking procedure.

(i) for each rule in R and for each variable v occurring in its body, if v does not occur in all its head atoms, mark (each occurrence of ) v in its body, (ii) apply until fixpoint: for each rule R i , if a marked variable v appears in the k th position of an atom using predicate p in its body, then for each rule R j (including i = j), and for each variable x occurring in the k th position of an atom using predicate p in the head of R j , mark (each occurrence of ) x in the body of R j .

Definition 2.24 (Sticky [CGP10a])

A set of rules R is sticky if given the marked variable set of R, each marked variable occurs at most once in a rule body.

Definition 2.25 (Domain-restricted (dr) [BLM10])

A rule R = (B, H) is domain-restricted if every atom h ∈ H, either h contains no variable from B, or it contains them all. By extension, a set of rules is domainrestricted if all its rules are.

The idea behind the domain-restricted rule class is that for each rule either no new variable is generated during the rewriting step, or these new variables are "disconnected" from the others.

Example 2.15 (sticky dr) Consider the set of rules composed of the following single rule: R = p(x 1 , y 1 ) → q(y 1 , z 1 ) ∧ s(x 1 , z 1 ). This set of rules is sticky, since no marked variable occurs twice in a rule body (indeed, even if both x 1 and y 1 are marked, neither occurs twice in the rule body), but it is not domain-restricted as atom q(y 1 , z 1 ) contains the variable y 1 but not the variable x 1 (similarly, atom s(x 1 , z 1 ) contains the variable x 1 but not the variable y 1 ).

Example 2.16 (dr sticky) Consider the set of rules composed of the following single rule: R = p(x 1 , y 1 ) ∧ p(y 1 , x 1 ) → s(x 1 , y 1 , z 1 ) ∧ q(z 1 , z 2 ). This set of rules is domain-restricted, but is not sticky: indeed, variable x 1 is marked since it does not occur in atom q(z 1 , z 2 ) and occurs twice in the same rule body.

While these two rule classes are incomparable, an interesting intersection of them is that of rules where every atom in their head contains all the variables from the body. Indeed, they are obviously domain-restricted, and no variable is ever marked by the sticky marking procedure.

Then, several generalisations of sticky rules have been obtained by refining the way variables are marked. Weakly-sticky rules generalise both sticky and weaklyacyclic rules, while sticky-join rules generalise sticky and linear rules. Furthermore, those two rule classes are incomparable, but have a common generalisation, namely, weakly-sticky-join.

Definition 2.26 (Weakly-sticky (w-sticky) [START_REF] Calì | Query answering under non-guarded rules in datalog+[END_REF]) A set of rules R is weakly-sticky if given the marked variable set of R and its predicate position graph, all marked variables that occur more than once in a rule body appear at some position of finite rank in this body.

Example 2.17 (Weakly-sticky) Consider the set of rules R composed of the following rules:

• R 1 = q(x 1 , x 2 ) → p(x 2 , x 1 , z 1 , z 2 ) • R 2 = p(x 1 , x 2 , x 3 , x 4 ) → q(x 2 , z 1 ) ∧ r(x 2 , x 4 ) • R 3 = r(x 1 , x 2 ) ∧ q(x 1 , x 3 ) → s(x 2 , x 3 )
This set of rules is not weakly-acyclic: indeed, one can see on Figure 2.5 that positions (q, 2) and (p, 4) are of infinite rank.

(q, 1)

(q, 2) (p, 1) (p, 2) (p, 3) (p, 4) (r, 1) (r, 2) (s, 1) (s, 2) Figure 2.5: Predicate Position Graph of R from Example 2.17
Furthermore it is not sticky as variable x 1 in rule R 3 is marked in the first step of the marking procedure and occurs twice in the body of this rule.

However it is weakly-sticky: indeed even if the variable x 1 is marked in rule R 3 , it occurs in position (r, 1) which is of finite rank (note that x 1 also occurs in position (q, 1) which is also of finite rank, though, a single finite rank position is enough).

Defining sticky-join sets of rules requires more notions.

Definition 2.27 (Sticky Applicability)

Given two rules R 1 = (B 1 , H 1 ) and R 2 = (B 2 , H 2 ), we say that R 1 is sticky applicable to R 2 if there exist atoms a ∈ H 1 and b ∈ B 2 such that a and b unify (i.e., there exists a piece-unifier of {b} with the rule B 1 → a), From there, we can define the notion of an expanded set of rules.

Definition 2.28 (Expanded Set of Rules) Given a set of rules R, its expanded set R * is obtained as follows. Initially, for each rule R ∈ R, the rule R labelled by ∅ is added to R * . Then we apply the following step until a fixpoint is reached: for each pair of rules

(R = (B, H), R ′ = (B ′ , H ′ )) ∈ R × R * (including the case R = R ′ ), if R is sticky applicable to R ′ due to atoms a ∈ H and b ∈ B ′ , then let R + be the rule σ µ (B) → σ µ (a)
, where µ is the piece-unifier for a and b. If R * already contains a labelled rule R ′′ isomorphic to R + , then the pair (R ′ , b) is added to the label set of R ′′ ; otherwise the rule R + labelled by {(R ′ , b)} is added to R * . Note that each time the above step is applied, we assume (as usual) that the two rules do not share any variable name.

Then, the marking procedure used for sticky set of rules can be improved as follows.

Definition 2.29 (Expanded Marked Variable Set) Given a set of rules R, the expanded marked variable set of R is built by the following marking procedure. Let R * be the expanded set of R. For each rule R = (B, H) ∈ R * and each non-frontier variable x occurring in B, (each occurrence of ) x in B is marked. Then the following step is applied until fixpoint. For each rule R = (B, H) ∈ R * , and for each pair (R ′ = (B ′ , H ′ ), α) in the label set of R, if a universal variable x occurs in H at positions p 1 , . . . , p k (with k ≥ 1), and at each position p 1 , . . . , p k in α ∈ B ′ a marked variable occurs, then (each occurrence of ) x in B is marked.

Thanks to this expanded marked variable set, we are now ready to define the sticky-join class of rules.

Definition 2.30 (Sticky-join (sticky-j) [CGP10b])

A set of rules R is sticky-join if given its expanded marked variable set, each marked variable occurs at most once in a rule body.

In the same way as sticky can be generalised to weakly-sticky, sticky-join can be generalised to weakly-sticky-join, which yields a common generalisation of the whole sticky family.

Definition 2.31 (Weakly-sticky-join (w-sticky-j) [CGP10b])

A set of rules R is weakly-sticky-join if given the expanded marked variable set of R and its predicate position graph, all marked variables that occur more than once in a rule body appear at some position of finite rank.

It should be pointed out that weakly-sticky rules (hence, their generalisation weakly-sticky-join rules) are neither BTS nor FUS, though they are provided with an algorithm able to handle them to solve the entailment problem [START_REF] Calì | Query answering under non-guarded rules in datalog+[END_REF].

Finally, the last rule class we define here is that of disconnected rules, which are GBTS, FES and FUS.

Definition 2.32 (Disconnected (disc) [BLM10]) A rule R = (B, H) is disconnected if var(B) ∩ var(H) = ∅.
By extension, a set of rules is disconnected if all its rules are.

All those rule classes fulfil various properties that are for the most part incomparable, however they can be combined thanks to the graph of rule dependencies as stated by the next theorem. We recall that an edge from R 1 to R 2 means that R 2 depends on R 1 .

Let R be a set of rules. Conjunctive query entailment is decidable if there exists a tri-partition (S F ES , S BT S , S F U S ) of the strongly connected components (S.C.C.) of the graph of rule dependencies of R such that there is no edge from a rule in a S.C.C. in S F U S or S BT S to a rule from another S.C.C. in S F ES or S BT S .

Theorem 2.1 (Combined Rule Classes [BLMS09, BLMS11])

The above theorem means that we can safely combine rule classes provided that it is possible to first apply all FES rules to F thanks to some forward chaining algorithm which yields a saturated set of facts F * , and on the other hand rewrite the query with the FUS rules obtaining a rewriting set Q, and finally use a BTS algorithm with F * and Q on the subset of rules that satisfies the BTS property.

Example 2.18 (Combining Rule Classes)

Let R be the set of rules composed of the following rules:

• R 0 = p(x, y) ∧ p(y, z) → p(x, z) • R 1 = p(x, y) → p(y, x) ∧ q(x, y, x) • R 2 = r(x, y) → q(x, z, t) • R 3 = q(x, y, z) → r(z, t) • R 4 = p(x, x) ∧ r(y, u) ∧ s(t, y, x) → s(z, z, z) • R 5 = s(x, x, x) ∧ s(y, y, y) → s(z, x, y)
The set of rules R does not belong to any concrete decidable class. As shown in Figure 2.6, the graph of rule dependencies of R contains three strongly connected components. Each one satisfies some concrete properties : C 0 is range-restricted, hence FES; C 1 is linear and thus FUS and BTS (actually GBTS); C 2 is domainrestricted therefore FUS.

R 0 R 1 R 3 R 2 R 4 R 5 C 0 C 1 C 2 fes bts/fus fus Figure 2.6: Graph of Rule Dependencies of R from Example 2.18
There are two interesting different safe combinations of these SCC, which differ on how C 1 is considered (obviously, C 0 could also be considered as BTS since any set of rules satisfying the FES property is also a BTS). If C 1 is considered as a BTS, then one could first apply all rules from C 0 until fixpoint in order to obtain a set of facts F * , then rewrite C 2 until fixpoint to obtain a UCQ Q, then, use some BTS algorithm with input knowledge base (F * , C 1 ) and query Q. Otherwise, if C 1 is considered as FUS, then the query can be first rewritten according to C 1 ∪ C 2 and then evaluated against F * .

One way or the other, CQ entailment over any knowledge base using this set of rules is decidable.

Note that weakly-sticky and weakly-sticky-join (defined previously) are actually another way to combine paradigms (in this case, FES and FUS).

We conclude the presentation of these rule classes by recalling the complexities of the CQ entailment problem over knowledge bases where rules belong to some known decidable rule class (Table 2.1). As usual, two different measures of complexity are considered: the combined complexity, where the input contains the set of rules, the set of facts and the query; and the data complexity, where the input contains only the set of facts since the set of rules and the query are assumed to be fixed. This complexity is often considered more relevant because the query and the rules are usually far smaller than the set of facts in practical applications. However, both complexities can help to understand where the difficulties lie. Indeed, for instance, guarded and weakly-guarded rules have both the same (worst-case) combined complexity, however, entailment over guarded rules can be solved in P T ime in data complexity, while it is ExpT ime-hard over weakly-guarded rules. On the other hand, all FUS classes are by definition in AC 0 in data complexity (the same complexity as conjunctive query entailment without rule), while ranging from P Space for linear rules to ExpT ime for sticky-join rules in combined complexity. Finally, note that for some classes the complexity bounds are not tight (combined complexity for aGRD as well as data complexity for glut-fg, and both for MSA and MFA).

Description Logics

Description Logics (DLs) are the prominent family of formalisms to represent and do reasoning with ontologies [BCM + 03].We will not provide here a detailed presentation of DLs but rather point out their relationships with the existential rule framework.

In description logics, a knowledge base is composed of an ABox (for "assertion" component), which is a set of ground facts; and a TBox (for "terminological" component), which is a set of axioms. An axiom is a logical statement which expresses an inclusion between concepts (or classes) or roles (or properties). With a specific description logic is associated a set of operators (or constructors) which allows to build complex concepts and roles from atomic ones. The expressivity of a description logic depends on the set of allowed operators and the form of the concepts and roles that may occur on each side of the inclusion.

The semantics of a description logic knowledge base can be given by a translation into first-order logic. To each atomic concept is assigned a unary predicate and to each atomic role a binary predicate. Concept inclusions of the form C 1 ⊑ C 2 , where C 1 and C 2 are (possibly complex) concepts are logically translated into formulae of the form ∀x(φ C 1 (x) → φ C 2 (x)), where φ C (x) is the logical translation of C, i.e., C(x) if C is an atomic concept, otherwise it is more generally a formula with a single free variable x. Similarity, role inclusions of the form r 1 ⊑ r 2 , where r 1 and r 2 are (possibly complex) roles, are logical translated into formulae of the form ∀x∀y(φ r 1 (x, y) → φ r 2 (x, y)), where φ r (x, y) is the logical translation of r, i.e., r(x, y)

Rule Class Combined Data agrd ? AC 0 f g 2ExpT ime-c [BMRT11] P T ime-c [BMRT11] f r-1 2ExpT ime-c [BMRT11] P T ime-c [BMRT11] guarded 2ExpT ime-c [CGK08] P T ime-c [CGL09] gbts 2ExpT ime-c [BMRT11, Tho13, BMRT14] ExpT ime-c [BMRT11] glut-f g 3ExpT ime-c [KR11] ≥ExpT ime ja 2ExpT ime-c [KR11] P T ime-c [KR11] j-f g 2ExpT ime-c [KR11] ExpT ime-c [KR11] linear P Space-c [CGL10a] AC 0 [CGL09] msa 2ExpT ime-c [ZZY15] P T ime-c [Mar09] mf a 2ExpT ime-c [ZZY15] P T ime-c [Mar09] rr ExpT ime-c [CLM81] P T ime-c [DEGV01] sticky ExpT ime-c [CGP10a] AC 0 [CGP10a] sticky-j ExpT ime-c [CGP10b] AC 0 [CGP10b] swa 2ExpT ime-c [Mar09] P T ime-c [Mar09] wa 2ExpT ime-c [FKMP05, CGP10b] P T ime-c [FKMP05, DEGV01] w-f g 2ExpT ime-c [BMRT11] ExpT ime-c [BMRT11] wg 2ExpT ime-c [CGK08] ExpT ime-c [CGL10a] w-sticky 2ExpT ime-c [CGP10b] P T ime-c [CGP10b] w-sticky-j 2ExpT ime-c [CGP10b] P T ime-c [CGP10b]
Table 2.1: Complexity of CQ entailment if r is an atomic role, otherwise it is more generally a formula with exactly two free variables x and y. An element of the ABox is of the form C(a) where C is a concept or r(a, b) where r is a role (and a and b are individuals, i.e., constants). To simplify the presentation we will assume that C and r are atomic, hence each element of the ABox can be seen as a ground atom.

Example 2.19 (Description Logics)

Let K = (A, T ) where A is an ABox and T is a TBox. The ABox is composed of the following ground atoms: A = {A(a), B(a), r(b, a)}. The TBox contains the following axioms:

• A ⊑ B, • B ⊓ C ⊑ ∃r.D • ¬r ⊑ s - • B ⊑ ≥ 2r.B
The logical translation of A is A itself (where a and b are constants). The logical translation of T is:

• ∀x(A(x) → B(x)) • ∀x(B(x) ∧ C(x) → ∃y(r(x, y) ∧ D(y)))
• ∀x∀y(¬r(x, y) → s(y, x))

• ∀x(B(x) → ∃y∃z(r(x, y) ∧ r(x, z) ∧ y = z))
General description logics and existential rules are incomparable with respect to expressivity. On the one hand, description logics allow for a variety of operators expressing disjunction, negation and cardinalities that are generally not translatable into the existential rule framework (e.g., axiom 3 from Example 2.19 is equivalent to the negative constraint ∀x∀y(r(x, y) ∧ s(y, x) → ⊥)), while axiom 4 is not expressible). On the other hand, most description logics are restricted to unary and binary predicates. Furthermore, the axioms can only express "tree-shape" binary relations among variables, while in existential rules there is no constraint on the interactions between variables. For instance the rule p(x, y) ∧ q(x, z) → p(y, z) is not expressible in description logics.

Since the pioneer work on the CARIN language which combined description logics and positive range-restricted rules (i.e., Datalog rules) and was the first to mention the problem of answering conjunctive queries [START_REF] Levy | CARIN: A representation language combining horn rules and description logics[END_REF], several approaches have been developed to combine description logics and different kinds of (positive) rules. One can cite in particular DL-safe rules [START_REF] Motik | Query answering for OWL-DL with rules[END_REF], which ensure decidability of reasoning by restricting the application of rules to individuals from the ABox (in other words, variables in rules are "non-affected"); and nominal schemas [START_REF] Krötzsch | Complexities of nominal schemas[END_REF] which can be used to encode DL-safe rules. Nominal schemas are concepts of the form {x} which can be used in axioms. However, these extensions tend to lose the readable aspect of the description logics. Very recently, it has been shown that frontier-one rules under the restriction that their heads are "non-looping" (no cycle of length greater than 1 in the corresponding graph) can be combined with any description logic that can be expressed in GC 2 (the two-variable guarded fragment with counting quantifiers) while preserving decidability of the CQ entailment problem [START_REF] Amarilli | Combining existential rules and description logics[END_REF].

Historically, the work on description logics focused on the ontological part (the TBox) and queries were restricted to instance queries, i.e., ground atoms. These last ten years, the focus was shifted to dealing with databases and answering conjunctive queries. Since CQ answering appeared to be very complex with classical description logics, new description logics with a restricted use of operators have been introduced. These description logics are known as lightweight description logics. One major lightweight description logic family is the DL-lite family [CDL + 05, CDL + 07], a very simple DL designed for query answering on large databases. Another well-known description logic family is the EL family [START_REF] Baader | Terminological cycles in a description logic with existential restrictions[END_REF] designed for dealing with very large ontologies. These DLs, and more generally the so-called "Horn-DLs" correspond to fragments of existential rules (including possibly negative constraints to translate inclusions of the form C 1 ⊑ ¬C 2 and equality rules to translate declarations of functional roles). In particular, DL-lite R corresponds to a subclass of linear rules and EL (and ELHI) to a subclass of frontier-guarded rules. More generally, Horn-DLs are translated into frontier-one rules when there is no role inclusion, otherwise into frontier-guarded rules.

Kiabora

To conclude this chapter, we mention that we have developed a software named Kiabora [START_REF] Leclère | Kiabora: An analyzer of existential rule bases[END_REF], which given a set of rules as input provides different useful features: first, it is able to translate the set of rules to either single-piece headed rules or atomic-headed rules. More importantly, it is able to recognise most of the rule classes we have presented here, and it also tries to determine if the set of rules belongs to a decidable case by combining decidable rule classes via the graph of rule dependencies. It has been implemented in a way that allows one to easily add his own new decidable rule classes, and its source code is available under CeCILL (compatible with GPL) licensing. A simple web interface built on the first version of Kiabora is available on its website at www.lirmm.fr/kiabora. The second version of Kiabora, which is more efficient and considers further decidable classes has been integrated into the Graal toolkit (website: http://graphik-team.github.io/graal/). A mechanism taking into account a set of rules while querying data is that of forward chaining. It can be seen as a two-steps process: it first repeatedly applies rules to the set of facts, process also known as the chase in database theory; then it looks for an answer to the query in this saturated set of facts.

Intuitively, this mechanism can be seen as completing initial data by exploiting the knowledge described by the rules, until one can query the saturated data as a database.

This saturated set of facts encodes a universal model of the knowledge base, and since the problem of CQ entailment is undecidable, this process may not halt, that is, it may be the case that all universal models of the knowledge base are infinite.

Then a question naturally arises: can we know beforehand if the knowledge base has a finite universal model?

It appears that answering this question is also undecidable. However, various syntactic conditions on sets of rules that ensure the finiteness of a universal model have been exhibited, most of them relying on some notion of acyclicity. Informally, these conditions ensure that either at some point no rule can be applied while still adding some new knowledge, or that there is a bound on the number of fresh existential variables that need to be created.

In this chapter, we first define formally the notion of breadth-first derivation, from which follows a general definition of chase, then we study different chase variants, which differ in how they deal with redundancies potentially appearing in the sets of facts between each rule application (Section 3.1). We then examine in Section 3.2 the various existing acyclicity conditions which we group into two families: the "dependency-based" approach [Bag04, GHK + 13], and the "position-based" family which goes from weak-acyclicity [START_REF] Dantsin | Complexity and expressive power of logic programming[END_REF] to super-weak-acylicity [START_REF] Marnette | Generalized schema-mappings: from termination to tractability[END_REF]. In Section 3.3, we propose a new tool that allows to unify these different notions, and to extend them as detailed in Section 3.4. Finally, Section 3.5 is devoted to another kind of acyclicity conditions, that does not fit in any of these two families.

Different kinds of chase

In this section, we consider the different chase variants. Intuitively, given a knowledge base (F, R), all chase variants proceed in the following steps: first choose a rule R = (B, H) in R, then look for a homomorphism π from B to the current set of facts, and add π saf e (H) to it provided that some conditions hold. We recall that π saf e is an extension of π that gives a new "name" to all existential variables occurring in H (see Definition 1.27).

These conditions are what distinguishes the different kinds of chase. For instance, in the oblivious chase (also called naive chase) [CGK08], a rule is applied according to some homomorphism π if it has not been already applied according to the exact same homomorphism.

This process can be slightly improved, in the sense that it can avoid some rule applications without compromising the construction of a universal model. If we consider two homomorphisms π and π ′ of the same rule body, they lead to add the "same" atoms if they map the frontier variables identically. In the frontier-restricted chase [START_REF] Baget | Revisiting chase termination for existential rules and their extension to nonmonotonic negation[END_REF], also known as semi-oblivious chase [GO13], a rule is not applied according to π if it has already been applied with a homomorphism π ′ that maps the frontier in the same way as π.

It already shows some distinctions with respect to finiteness; indeed if we consider the rule p(x, y) → p(x, z) and the set of facts F = p(a, b), the oblivious chase adds infinitenely many atoms (as the rule can be infinitely applied according to a homomorphism that maps y differently each time), which yields the infinite set of facts p(a, b) ∧ p(a, z 1 ) ∧ p(a, z 2 ) ∧ . . . . However in the case of the frontier-restricted chase, the rule is applied only once, since after that, the frontier is always mapped in the same way (x is mapped to a), hence the finite set of atoms p(a, b) ∧ p(a, z 1 ) is obtained. The skolem chase [START_REF] Marnette | Generalized schema-mappings: from termination to tractability[END_REF] relies on a skolemisation of the rules: first, each rule R is transformed by replacing each occurrence of an existential variable z with a functional term f R z ( x), where x are the frontier variables of R. Then the oblivious chase is run on the skolemised rules. It can be easily checked that the skolem chase and the frontier-restricted chase yield isomorphic results (up to the renaming of the created existential variables by the corresponding skolem terms).

The restricted chase (which is also known as standard chase) [START_REF] Fagin | Data exchange: semantics and query answering[END_REF] is a bit more involved. A rule R = (B, H) is applied to F according to a homomorphism π if π cannot be extended to a homomorphism from B ∪ H to F (in which case we say that the application of R according to π is useful), otherwise F ∪ π saf e (H) would be equivalent to F. A rule such as p(x) → r(x, y) ∧ r(y, y) ∧ p(y) shows the distinction between the restricted chase and the frontier-restricted chase with respect to finiteness. Indeed, in the former case, the rule is applied only once since no further application is useful, while all applications map the frontier differently, and thus the frontier-restricted chase is infinite (p(a)∧r(a, y 1 )∧r(y 1 , y 1 )∧p(y 1 ) . .

. r(y k-1 ∧ r(y k , y k ) ∧ p(y k ) ∧ . . . ).
The core chase [START_REF] Deutsch | The chase revisited[END_REF] avoids the strongest possible form of redundancy: after each rule application it reduces the obtained set of facts by computing its core. Hence, it may remove atoms obtained from a previous rule application in a later step, as illustrated by the next example (Example 3.1). A nice property of the core chase is that if there exists a finite universal model of the knowledge base, then the core chase will halt.

While our contribution does not include a direct way to handle the core chase, we are able to consider the equivalent chase. This chase does not perform a rule application if the set of facts that would be obtained is equivalent to the current set of facts. In other words, if the core of the current set of facts is equal (i.e., isomorphic) to the obtained set of facts. We point out that the core chase is finite if and only if the equivalent chase is.

Example 3.1 Consider the set of facts s(a), where a is a constant, and the set of rules composed of the following two rules:

• R 1 = s(x) → p(x, z) • R 2 = s(x) ∧ p(x, y) → p(x, x)
In this example, we first apply R 1 according to the homomorphism {x → a} and we create F 1 = s(a) ∧ p(a, z 0 ). At this step, Core(F 1 ) = F 1 . Note that we could not have applied R 2 before R 1 . Then, we apply R 2 according to the homomorphism {x → a, y → z 0 }, and we add the atom p(a, a) and obtain F 2 = s(a) ∧ p(a, z 0 ) ∧ p(a, a). The atom p(a, z 0 ) is redundant with p(a, a), and therefore, the core of F 2 is Core(F 2 ) = s(a) ∧ p(a, a). Observe that the atom p(a, z 0 ), which comes from the core of F 1 , does not occur in the core of F 2 , and thus has been "removed" at this step.

Our aim is to provide a general chase notion that is then specialised by each chase variant. This general chase is seen as a greedy process that adds more and more atoms to the initial set of facts. Hence it is intrinsically a monotonic process. That is why it does not include the core chase, but instead the equivalent chase which behaves in the same way with respect to finiteness.

As previously mentionned, all chase variants heavily rely on the notion of derivation, but not all derivations behave the same. Indeed consider the following example.

Example 3.2 Let F = {p(a, b)} be a set of facts, R 1 = p(x, y) → p(y, z) and R 2 = p(x, y) → p(y, y) be two rules. One can see that applying rule R 1 over and over leads to an infinite derivation (therefore a universal model cannot be found since R 2 will never be applied) where at each rank k of the derivation, the following set of facts is obtained:

F k = {p(a, b), p(b, z 1 ), . . . , p(z k-1 , z k )}
If both rules were to be applied, R 2 would create something more specific that anything we could generate with R 1 . Indeed if we applied R 2 after a single application of R 1 we would obtain:

F 2 = {p(a, b), p(b, z 1 ), p(b, b)}
Then, further applications of rule R 1 would only add redundant knowledge.

The previous example shows that some derivations are more adapted to find a universal model than others, which leads to consider the notion of breadth-first derivation. A breadth-first derivation is obtained by considering at each "breadthfirst step" all possible rule applications on the current set of facts, then applying them all, before moving to the next step, which will look for new applications on the resulting set of facts.

.r.t. R is a derivation D = (∅, ∅, F 0 = F), . . . , (R i = (B i , H i ), π i , F i ), . . . such that for all i ≤ j ∈ dom(D), if (F i \ F i-1 ) ∩ π j (B j ) = ∅ then for all k > j, π k (B k ) F i-1 .
The previous definition ensures that if at some point we use some atoms occurring for the first time in F i to map a rule body, then we cannot use "only" F i-1 later. Intuitively, this ensures that once going to the next "breadth step", we cannot apply a rule that could have been applied in a previous breadth step according to the same homomorphism.

Definition 3.2 (Exhaustive Breadth-first Derivation) Given F a set of facts, and R a set of rules, a (potentially infinite) breadth-first derivation D = (∅, ∅, F), . . . , (R i , π i , F i ), . . . of F w.r.t. R is said to be exhaustive if for all i ∈ dom(D), for all R = (B, H) ∈ R, and for all homomorphisms π from B to F i there is some k ∈ dom(D) such that π k = π and R k = R.

An exhaustive breadth-first derivation ensures that all rules have been applied according to all homomorphisms. It means that no other rule application can be found on any of the F i . Note that the corresponding derivation may have to be infinite to satisfy this criterion.

Example 3.3

Consider the set of facts F = c(a) and the following rules:

• R 1 = c(x) → p(x, y) ∧ c(y) • R 2 = c(x) ∧ p(x, y) → p(x, x)
An exhaustive breadth-first derivation for this example would be:

i R i π i F i 0 ∅ ∅ F 1 R 1 {x → a} F ∪ {p(a, y 1 ), c(y 1 )}) 2 R 2 {x → a, y → y 1 } F ∪ {p(a, y 1 ), c(y 1 ), p(a, a)}) . . . . . . . . . . . . 2k R 1 {x → y 2k-1 } F 2k-1 ∪ {p(y 2k-1 , y 2k ), c(y 2k )} 2k + 1 R 2 {x → y 2k-1 , y → y 2k } F 2k ∪ {p(y 2k-1 , y 2k-1 )} . . . . . . . . . . . .
From the notion of exhaustive breadth-first derivation, one can strengthen Theorem 1.2 (soundness and completeness of derivations) as stated by the next proposition (which follows, e.g., from [START_REF] Baget | On rules with existential variables: Walking the decidability line[END_REF]). Intuitively, it ensures that if a Boolean conjunctive query is a logical consequence of the knowledge base, then any breadthfirst derivation finds it in finitely many steps (while, of course, this may not be the case for all derivations). Let F be a set of facts, R be a set of rules, and Q be a Boolean conjunctive query. Let D = (∅, ∅, F), . . . , (R i , π i , F i ), . . . be any exhaustive breadth-first derivation; then, (F, R) |= Q iff there exists some k ∈ N such that F k |= Q.

Proposition 3.1

As already mentioned, the chase variants differ in how they "filter" the rule applications to consider (except for the core chase which simplifies the set of facts). In the following we unify these different variants with the notion of a derivation filter, that intuitively filters rule applications that will be preserved in the chase. Indeed, some of these applications may create redundant knowledge, and may be ignored.

Definition 3.3 (Derivation Filter)

Let F be a set of facts and R be a set of rules. A derivation filter σ is a function that given a derivation D = (∅, ∅, F 0 = F), . . . , (R i , π i , F i ), . . . of F w.r.t. R returns a sequence (with the same domain as D) of Boolean values such that

• σ(D) 0 = 1; • if σ(D) i = 0 then F i ≡ F i-1 • if σ(D) i = 1 then there is some j < i such that π i (B i ) ⊆ F j and σ(D) j = 1.
We are now ready to define the σ-chase, which can be seen as the result of applying rules in a breadth-first manner, and ignoring some useless rule applications.

Definition 3.4 (σ-Chase)

Given F a set of facts, R a set of rules and σ a derivation filter, let D be any exhaustive breadth-first derivation of F w.r.t. R. The σ-chase of F w.r.t. R is the set of atoms defined as:

σ-chase(F, R) = i∈dom(D) | σ(D) i =1 F i
Note that the above definition considers that the σ-chase of a given set of facts w.r.t. a given set of rules is unique. While it might not be the case, whatever the exhaustive breadth-first derivation one chooses, all possible σ-chases are equivalent and behave the same with respect to finiteness.

An important property of any chase variant built upon a given filter is that its result can be used to give all correct answers to a given query as stated by the next theorem.

Let F be a set of facts, R be a set of rules, Q be a Boolean conjunctive query, and σ be a derivation filter.

(F, R) |= Q ⇔ σ-chase(F, R) |= Q Theorem 3.1 Proof: (⇒) Assume that (F, R) |= Q. Let D = (∅, ∅, F 0 = F), . . . , (R i , π i , F i ), . . . be an exhaustive breadth-first derivation of F w.r.t. R. By Proposition 3.1 there exists k ∈ N such that F k |= Q. Then, if F k σ-chase(F, R
) it means that σ(D) k = 0. In this case, there is some j < k such that F k ≡ F j and σ(D) j = 1, thus there exists a homomorphism π from F k to F j . Furthermore, since σ(D) j = 1,

F j ⊆ σ-chase(F, R). Therefore σ-chase(F, R) |= Q.
(⇐) Suppose now that σ-chase(F, R) |= Q. Then, there exists a homomorphism π from Q to some finite part π(Q) of σ-chase(F, R). From Definition 3.4, there is an exhaustive breadth-first derivation D from F to F j such that π(Q) ⊆ F j . We conclude with Proposition 3.1 that (F, R) |= Q. ✷

Obviously, the finiteness of the σ-chase and the computability of the i th element of the sequence obtained from a filter (note that this is the case for all filters we present in this section) are enough to ensure one can compute it, therefore, guarantee decidability of the CQ entailment problem.

Given a set of facts F, a set of rules R and a derivation filter σ, if σ-chase(F, R) is finite and for any derivation

D = (∅, ∅, F 0 = F), . . . , (R i , π i , F i ), . . . and any i ∈ dom(D), σ(D) i is computable, then σ-chase(F, R) is computable. Proposition 3.2
We now define several derivation filters that correspond to the chase variants we have introduced at the beginning of this section.

The equivalent filter considers only rule applications that lead to generate a set of facts that is not equivalent to the current set of facts.

Definition 3.5 (Equivalent Filter)

The equivalent filter, denoted by σ equiv , is the derivation filter defined for any derivation D = (∅, ∅, F 0 = F), . . . , (R i , π i , F i ), . . . as:

∀0 < i ∈ dom(D), σ equiv (D) i = 1 if F i-1 ≡ F i 0 otherwise
The restricted filter checks redundancy locally as opposed to the global view of the equivalent filter.

Definition 3.6 (Restricted Filter)

The restricted filter, denoted by σ restricted , is the derivation filter defined for any derivation D = (∅, ∅,

F 0 = F), . . . , (R i , π i , F i ), . . . as: ∀0 < i ∈ dom(D), σ restricted (D) i =      1 if π i cannot be extended to a homomorphism f rom B i ∪ H i to F i-1 0 otherwise
As already mentioned, the skolem chase has the same behaviour as the frontierrestricted chase, which considers only rule applications that map the frontier of the rule in different ways.

Definition 3.7 (Frontier-Restricted Filter)

The frontier-restricted filter, denoted by σ f r , is the derivation filter defined for any derivation D = (∅, ∅, F 0 = F), . . . , (R i , π i , F i ), . . . as:

∀0 < i ∈ dom(D), σ f r (D) i = 1 if ∀j < i with R i = R j , π j | f r(R j ) = π i | f r(R i ) 0 otherwise
Finally, the oblivious filter consider all rules, and ignores only applications based upon a previously used homomorphism.

Definition 3.8 (Oblivious Filter)

The oblivious filter, denoted by σ obl , is the derivation filter defined for any derivation

D = (∅, ∅, F 0 = F), . . . , (R i , π i , F i ), . . . as: ∀0 < i ∈ dom(D), σ obl (D i ) = 1 if ∀j < i with R i = R j , π j = π i 0 otherwise
From these different filters, and since they all are sound and complete (indeed from Theorem 3.1, they all compute a set of facts that corresponds to a universal model), it is natural to ask whether they are comparable with respect to finiteness. To this end, we first define an order relation on the filters to be able to compare them. Definition 3.9 (Filter Order Relation) Given two derivation filters σ 1 and σ 2 we say that σ 1 is weaker than σ 2 , denoted by σ 1 σ 2 , if for any set of rules R and set of facts F, σ 1 -chase(F, R) is finite implies that σ 2 -chase(F, R) also is.

Furthermore, we say that σ 1 is strictly weaker than σ 2 , denoted by σ 1 ≺ σ 2 if σ 1 σ 2 and σ 2 σ 1 .

One can observe that the equivalent filter is the "strongest" of all possible chase variants as stated in Proposition 3.3: indeed, from its definition, it does not impose any restriction on which rule applications can be ignored but the equivalence between the sets of facts.

The σ equiv filter is maximal for the filter order relation .

Proposition 3.3

Proof: Let σ be a derivation filter. Given a set of rules R, assume that for some set of facts F, σ-chase(F, R) is finite. Let D = (∅, ∅, F 0 = F), . . . , (R i , π i , F i ), . . . be an exhaustive breadth-first derivation of F w.r.t. R. From the second point of the definition of a derivation filter (Definition 3.3), for any i ∈ dom(D), if σ(D) i = 0 then F i ≡ F i-1 . Since for any j, σ equiv (D) j = 0 if and only if F j ≡ F j-1 , σ equiv (D) i = 0. Then, for any i such that σ(D) i = 0, σ equiv (D) i is also equal to 0. This concludes the proof. ✷ Furthermore, the next proposition states that all filters defined above are comparable and even totally ordered with respect to the filter order relation.

The following relations hold:

σ obl ≺ σ f r ≺ σ restricted ≺ σ equiv .
Proposition 3.4

Proof: Inclusion between σ obl and σ f r follows immediately from their definitions, while the one between σ restricted and σ equiv follows from Proposition 3.3. It is wellknown that σ f r σ restricted , see, for instance [START_REF] Onet | The chase procedure and its applications in data exchange[END_REF]. First, let us compute the oblivious chase, it is infinite, since all rule applications of the only rule use a homomorphism with a different image for the variable y. Indeed in the first application it is mapped to b, then to the generated fresh variable z 1 , then to z 2 , and so on...

σ obl -chase(F, R) = {p(a, b), p(a, z 1 ), . . . , p(a, z k ), . . . }
While if we consider the frontier-restricted chase, all homomorphisms restricted to the single frontier variable x are the same, and then, a single application is necessary.

σ f r -chase(F, R) = {p(a, b), p(a, z 1 )} Example 3.5 (σ restricted σ f r )
Consider the set of rules R = {p(x) → r(x, y) ∧ r(y, y) ∧ p(y)}, and the set of facts F = {p(a)}.

In this example, the frontier is differently mapped for each rule application. Thus, the frontier-restricted chase (and the skolem chase since they are equivalent), is infinite.

σ f r -chase(F, R) = {p(a)
, r(a, y 1 ), r(y 1 , y 1 ), p(y 1 ) . . . , r(y k-1 , y k ), r(y k , y k ), p(y k ) . . . } However the generated set of facts is quite redundant: indeed, the "loop" p(y, y) when applied to the fresh variable y 1 leads to something more specific than any other applications. Therefore the restricted chase is finite. σ restricted -chase(F, R) = {p(a), r(a, y 1 ), r(y 1 , y 1 ), p(y 1 )} Example 3.6 (σ equiv σ restricted ) Consider the set of facts F = q(a) and the set of rules R composed of the following rules:

• R 1 = q(x) → r(x, y) ∧ p(x, z) • R 2 = p(x, y) → p(y, z) • R 3 = r(x, y) → p(x, x)
In this example, the restricted chase first applies the first rule according to π 1 = {x → a} and adds the atoms p(a, z 1 ) and r(a, y 1 ) to F 0 = F yielding F 1 .

Then rule R 2 can be applied to F 1 according to

π 2 = {x → a, y → z 1 } adding p(z 1 , z 2 ) to F 1 yielding F 2 .
Rule R 3 can be applied to F 2 with homomorphism π 3 = {x → a, y → y 1 } adding atom p(a, a) and yielding F 3 = q(a) ∧ p(a, z 1 ) ∧ r(a, y 1 ) ∧ p(z 1 , z 2 ) ∧ p(a, a). Now, rule R 2 can be applied again, this time according to homomorphism π 4 = {x → z 1 , y → z 2 }, indeed this homomorphism cannot be extended to p(x, y) ∧ p(y, z), and thus we add the atom p(z 2 , z 3 ).

In the end, the restricted chase of F and R is infinite and is as follows:

q(a) ∧ r(a, y 1 ) ∧ p(a, a) ∧ p(a, z 1 ) ∧ p(z 1 , z 2 ) ∧ • • • ∧ p(z k , z k+1 ) ∧ . . .
Now let us consider the equivalent chase instead. While F 1 , F 2 and F 3 are the same as with the restricted chase, any rule application to F 3 yields an equivalent set of facts. Indeed, F 3 is already redundant, the homomorphism that maps z 1 and z 2 to a, and y 1 to itself maps F 3 to its subset q(a) ∧ r(a, y 1 ) ∧ p(a, a), then every p(z i , z i+1 ) added by an application of R 2 is also redundant. Therefore we obtain the finite set of facts σ equiv -chase(F, R) = F 3 .

Acyclicity notions

In this section, we study the various acyclicity notions ensuring a finite chase that have been proposed in the literature. As a matter of fact, all these conditions ensure the finiteness of the frontier-restricted chase (or the skolem chase), except for one (aGRD) that also ensures the finiteness of the oblivious chase. These properties can be divided in two big families relying respectively on dependency-based and position-based conditions. The former contains properties that look at how rules are triggered, while the latter contains those that look at how existential variables are propagated along predicate positions. Note that some classes of rules and associated notions have already been defined in Chapter 2, but we define them again to ease the reading.

From there, we propose a new tool unifying both approaches, and show that it can be used to extend the decidability recognition based on existing acyclicity conditions. Two other properties that also ensure chase termination, namely Model Faithful Acyclicity and Model Summarizing Acyclicity are neither dependency nor position-based. These properties are discussed in Section 3.5, where we show that the second one can be integrated into our framework while the first one cannot.

It has been shown in [START_REF] Zhang | Existential rule languages with finite chase: Complexity and expressiveness[END_REF] that any set of rules which ensures the finiteness of the frontier-restricted chase can be rewritten into an equivalent weakly-acyclic set of rules. This means that with respect to expressivity, all those classes are equivalent. However, this rewriting can be arbitrarily larger than the initial set of rules, and thus, studying these classes is still interesting from a succintness point of view.

Dependency-based Approach

The dependency-based approach aims at avoiding cyclic triggering of rules. It relies on a directed graph called the Graph of Rule Dependencies, first defined in [START_REF] Baget | Improving the forward chaining algorithm for conceptual graphs rules[END_REF], and makes use of the notion of dependency between rules. Intuitively, a rule R 2 depends on a rule R 1 if there is some set of facts F such that an application of R 1 on F will lead to trigger a "new" and "useful" application of R 2 . Definition 3.10 (Rule Dependency [Bag04, GHK + 13]) Given R 1 = B 1 → H 1 and R 2 = B 2 → H 2 two rules, R 2 depends on R 1 if there exists some set of facts F such that:

(i) there is a homomorphism π 1 from B 1 to F, (ii) there is a homomorphism π 2 from B 2 to F ′ = α(F, R 1 , π 1 ), (iii) π 2 is not a homomorphism from B 2 to F, (iv) α(F ′ , R 2 , π 2 ) = F ′ .
In the previous definition, point (ii) and (iii) ensure that after the application of R 1 there is a new homomorphism from B 2 , while point (iv) ensures this homomorphism is useful.

Example 3.7 Consider rules R 1 = r(x 1 , y 1 ) ∧ q(y 1 ) → p(y 1 , z 1 ) and R 2 = p(x 2 , y 2 ) → r(y 2 , z 2 ). Rule R 2 depends on rule R 1 , indeed, let F = r(a, b), q(a), there is a homomor- phism π 1 = {(x 1 , a), (y 1 , b)} from B 1 to F (condition (i)), there is a homomorphism π 2 = {(x 2 , b), (y 2 , z 1 )} from B 2 to F ′ = α(F, R 1 , π 1 ) (condition (ii))
, which is not a homomorphism from B 2 to F (condition (iii)), and F ′ = {r(a, b), q(a), p(b, z 1 )} = {r(a, b), q(a), p(b, z 1 ), r(z 1 , z 2 )} = α(F ′ , R 2 , π 2 ) (condition (iv)).

However rule R 1 does not depend on rule R 2 , indeed, it can be shown that no set of facts can be built such that all conditions are verified.

While this definition is not really operational, the existence of a dependency between two rules can be computed thanks to piece-unifiers as stated by the next proposition (we do not recall the definition of atom erasing since it is not needed later).

Let R 1 = B 1 → H 1 and R 2 = B 2 → H 2 be two rules; R 2 depends on R 1 if and only if there exists an atom-erasing piece-unifier of B 2 with H 1 .

Proposition 3.5 ([BLMS11])

Example 3.8 Consider again rules R 1 and R 2 from Example 3.7. There is a piece-unifier

µ 1 = {{p(x 2 , y 2 )}, {p(y 1 , z 1 )}, {{x 2 , y 1 }, {y 2 , z 1 }}} of B 2 with H 1 , but there is no piece-unifier of B 1 with H 2 . Indeed the unifier µ 2 = {{r(x 1 , y 1 )}, {r(y 2 , z 2 )}, {{x 1 , y 2 }, {y 1 , z 2 }}}
does not satisfy the piece condition of a piece-unifier since variable y 1 is unified with the existential variable z 2 and therefore q(y 1 ) must be in the unified part of the piece-unifier.

Definition 3.11 (Graph of Rule Dependencies)

Given a set of rules R, its graph of rule dependencies denoted by GRD(R) is the labelled directed graph whose set of vertices is the set of rules and where there is an edge from

R 1 to R 2 if R 2 depends on R 1 .
Intuitively, this graph encodes whether a rule can lead to trigger another. As pointed out in Proposition 3.5, one can check whether a rule depends on another by finding a particular piece-unifier of the body of the latter with the head of the former.

Example 3.9 (Graph of Rule Dependencies) Consider the rules R 1 = p(x 1 , y 1 ) → q(y 1 ), R 2 = q(x 2 ) → r(x 2 , y 2 ). There is a unifier ({q(x 2 )}, {{y 1 , x 2 }}, {q(y 1 )}) of B 2 with H 1 , hence an edge from rule R 1 to R 2 but neither a unifier of B 1 with H 2 , nor of B 1 with H 1 nor B 2 with H 2 ; hence, the resulting graph of rule dependencies is acyclic.

If we add the rule R 3 = r(x 3 , y 3 ) → p(x 3 , y 3 ), there is a unifier of B 1 with H 3 and of B 3 with H 2 . Therefore, there is a cycle in the graph of rule dependencies as shown in Figure 3.1.

R 1 R 2 R 1 R 2 R 3 Figure 3.1: GRD of {R 1 , R 2 } (left) and {R 1 , R 2 , R 3 } (right) from Example 3.9
Definition 3.12 (Acyclic Graph of Rule Dependencies) Let R be a set of rules. We say that R is aGRD if GRD(R) is acyclic.

Let R be a set of rules. If R is aGRD, then for any set of facts F, the oblivious chase halts on (F, R).

Proposition 3.6 ([Bag04])
From a complexity point of view, it has been shown that recognising set of rules satisfying aGRD is a coN P -complete problem.

Given a set of rules R, checking if R is aGRD is coN P -complete.

Position-based Approach

In the position-based approach, the way existential variables are "propagated" through predicate positions is analysed. The idea is to check that no generated variable appearing in some predicate position can lead to generate another one in the same position.

Various conditions based on this idea have been proposed, we will show later that all of these can be seen as acyclicity conditions. The simplest condition (and first to be defined) is that of weak-acyclicity which relies on the predicate position graph.

For the following we denote by (p, i) the i th position of predicate p.

Definition 3.13 (Predicate Position Graph)

Given a set of rules R, its predicate position graph, denoted by P P G(R) is the directed labelled graph whose set of vertices is the set of predicate positions of R.

Then for each rule R ∈ R and each frontier variable x in B occuring in some position (p, i), edges with origin (p, i) are built as follows: there is an edge from (p, i) to each position (q, j) in H where x occurs, and there is a special edge from (p, i) to each position (q, j) in H where some existential variable y appears.

Note that in this graph, both vertices and edges are labelled. The set of rules {R 1 , R 2 } from Example 3.10 is not weakly-acyclic, indeed there is a cycle going through a special edge: ((p, 2), (s, 2), (p, 2)). If we replace R 2 by R ′ 2 = s(x, y) → p(y, x), the predicate position graph of {R 1 , R ′ 2 } does not contain a special cycle anymore, as can be seen on Figure 3.3; thus this set of rules is weaklyacyclic.

(p, 1)

(p, 2) (s, 1) (s, 2) Figure 3.3: Predicate Position Graph of {R 1 , R ′ 2 } from Example 3.11
Let R be a set of rules. If R is weakly-acyclic, then for any set of facts F,

σ f r -chase(F, R) is finite. Proposition 3.8 ([FKMP05])
Following this idea, several extensions to weak-acyclicity have been proposed, by shifting the focus either from positions to existential variables (ja, [START_REF] Krötzsch | Extending decidable existential rules by joining acyclicity and guardedness[END_REF]), or to positions in atoms instead of predicates (swa, [START_REF] Marnette | Generalized schema-mappings: from termination to tractability[END_REF]). Other related notions can be imported from logic programming, e.g., finite domain [START_REF] Calimeri | Computable functions in ASP: theory and implementation[END_REF].

We recall here their definitions before unifying them in Section 3.3 and extending them in Section 3.4.

Given a set of atoms A, we denote by P os A (x) the set of predicate positions where the variable x occurs in A.

We first consider the notion of finite domain [START_REF] Calimeri | Computable functions in ASP: theory and implementation[END_REF]. It relies on the fact that if all positions are only "populated" by a finite number of individuals, then there is a finite universal model of the knowledge base; indeed, by considering only rule applications that are different with respect to the frontier of the rule, there can be only finitely many rule applications. Here we use the definition from [GHK + 13], which has been shown to be equivalent to the original definition, since it uses a vocabulary closer to ours.

Definition 3.15 (Finite Domain Positions)

Let R be a set of rules. A predicate position (p, i) is R-recursive with a position (q, j) if the predicate position graph P P G(R) contains a cycle going through (p, i) and (q, j). The set P os f d (R) of finite domain positions of R is the largest set of positions in R such that: for each position (p, i) ∈ P os f d (R), each rule R = (B, H) ∈ R, and each head atom of H of the form a( t), the following conditions hold:

• if the i th component of t is a variable y ∈ f r(R), then P os B (y)∩P os f d (R) = ∅
• if the i th component of t is an existential variable of R, then, for each variable y ∈ f r(R), some position (q, j) ∈ P os B (y) ∩ P os f d (R) exists that is not Rrecursive with (p, i).

Then, it remains to check whether all positions in a set of rules are of finite domain.

Definition 3.16 (Finite Domain [CCIL08])

A set of rules R is of finite domain (f d), if P os f d (R) coincides with the set of all predicate positions in R.

This notion captures the notion of weak-acyclicity, since instead of just checking that no cycle occurs in the predicate position graph, this condition checks that even if there is a cycle for an existential variable, there may be some frontier variable (therefore used by the rule application) that does not occur in some cycle (and thus can be used only finitely many times).

Example 3.12 (Finite Domain) Let R 1 = p(x, y) ∧ q(y) → r(y, z) and R 2 = r(y 1 , y 2 ) → p(y 1 , y 2 ) be two rules. The set of rules R = {R 1 , R 2 } is of finite domain. Indeed for each predicate position, the first point in Definition 3.15 is easily verified since no predicate occurring in a rule head also appears in the same rule body. Then the only predicate position where an existential variable occurs is (r, 2) in rule R 1 , and the only frontier variable is y, it remains to check that y occurs at some predicate position which is not R-recursive with (r, 2). As can be observed on Figure 3.4, (q, 1) is not R-recursive with (r, 2). Therefore, the second point of the definition is also satisfied.

It should be noted that R is not weakly-acyclic as there is a cycle ((p, 2), (r, 2), (p, 2)) that goes through a special edge.

(p, 1) (p, 2) (s, 1) (s, 2) (q, 1) Figure 3.4: P P G(R) from Example 3.12 Let R be a set of rules. If R is of finite domain, then for any set of facts F,

σ f r -chase(F, R) is finite. Proposition 3.9 ([CCIL08])
On the other hand, weak-acyclicity has also been generalised by shifting the focus to existential variables (instead of predicate positions). Indeed, only existential variables do matter when we consider finiteness. It makes use of another graph, that shows which existential variable can lead to create another one; then by checking that there is no cycle in this graph, we ensure that no variable can create another, and thus, that we only need finitely many fresh variables. Definition 3.17 (Joint-acyclicity Graph) Given a set of rules R, and an existential variable z occuring in some rule R = (B, H) of R, let M ove(z) be the smallest set of predicate positions such that:

• P os H (z) ⊆ M ove(z); • for each rule R ′ = (B ′ , H ′ ) and each frontier variable y occuring in R ′ , if P os B ′ (y) ⊆ M ove(z), then P os H ′ (y) ⊆ M ove(z).
The joint-acyclicity graph of R, denoted by JA(R) is the directed graph whose set of vertices is the set of all existential variables in R, and where there is an edge from z 1 to z 2 whenever the rule R = (B, H) that contains z 2 also contains a frontier variable y such that P os B (y) ⊆ M ove(z 1 ).

Definition 3.18 (Joint-acyclicity [KR11])

A set of rules R is jointly-acyclic if JA(R) does not contain a cycle.

Example 3.13 (Joint-acyclicity) Let R be the set composed of the following four rules:

• R 1 = p(x, y) → r(y, z 1 ),

• R 2 = p(x, y) → r(z 2 , y),

• R 3 = r(y 1 , y 2 ) → s(y 1 , y 2 ),

• R 4 = s(y 1 , y 2 ) ∧ s(y 2 , y 1 ) → p(y 1 , y 2 ).

Then one can check that M ove(z 1 ) = {(r, 2), (s, 2)} and M ove(z 2 ) = {(r, 1), (s, 1)}, and thus that JA(R) does not contain any cycle (therefore R is jointly-acyclic). It can be observed that R is not of finite-domain. Indeed, observe that all predicate positions but [p, 1] are R-recursive with each position but [p, 1]. Furthermore, in rule R 1 for instance, position [p, 2] is the only position in B 1 in which the variable y occurs, but it is R-recursive with [r, 2] which holds an existential variable. Thus, position [r, 2] cannot belong to the set P os f d (R) and therefore R is not of finite-domain.

Let R be a set of rules. If R is jointly-acyclic, then for any set of facts F, σ f r -chase(F, R) is finite.

Proposition 3.10 ([KR11])

To define the notion of super weak-acyclicity (that shifts the focus to positions in atoms) we make use of the following notations: [a, i] denotes the i th position of atom a, and if p is an atom position, term(p) denotes its term, and pred(p) denotes its predicate. Super weak-acyclicity relies on yet another graph, and this graph uses the notion of covering between atom positions sets as defined below.

Definition 3.19 (Atom positions covering)

Given two sets of atom positions A 1 and A 2 , we say that A 1 covers A 2 if for each atom position [p 2 , i 2 ] ∈ A 2 , there is a position [p 1 , i 1 ] ∈ A 1 and there exist two substitutions σ 1 and σ 2 such that σ 1 (p 1 ) = σ 2 (p 2 ) and i 1 = i 2 . Definition 3.20 (Super Weak-acyclicity Graph) Given a set of rules R, and a variable x occuring in some rule R, we define the following three sets:

• In(x) contains each atom position [p, i] such that p ∈ B and x = term([p, i]);

• Out(x) contains each atom position [p, i] such that p ∈ H and x = term([p, i]);

• M ove(x) is the smallest set of atom positions such that:

-Out(x) ⊆ M ove(x); -for each variable x ′ that is universally quantified in some rule in R, if M ove(x) covers In(x ′ ), then Out(x ′ ) ⊆ M ove(x).

The super weak-acyclicity graph of R, denoted by SW A(R) is the directed graph whose set of vertices is the set of rules, and in which there is an edge from a rule R to a rule R ′ if there exist a frontier variable y ′ from R ′ and an existential variable z from R, such that M ove(z) covers In(y ′ ).

Once the super weak acyclicity graph is built, it remains to check for its acyclicity.

Definition 3.21 (Super Weak-acyclicity [Mar09])

A set of rules R is super weakly-acyclic (swa), if SW A(R) does not contain any cycle.

Example 3.14 (Super Weak-acyclicity)

Let R 1 = q(y 1 ) → p(y 1 , z 1 ) ∧ p(z 1 , y 1 ) ∧ p(y 1 , y 1 ), R 2 = p(y 2 , y 2 ) → s(y 2 ), and R 3 = s(y 3 ) → q(y 3 ) be rules. It can be checked that the set of rules

R = {R 1 , R 2 , R 3 } is super weakly-acyclic.
Let R be a set of rules. If R is super weakly-acyclic, then for any set of facts F, σ f r -chase(F, R) is finite.

Proposition 3.11 ([Mar09])

First combination

It appears that aGRD and weak-acyclicity are incomparable, as shown by the two next examples.

Example 3.15 (wa aGRD) Consider rules R 1 = p(x 1 , y 1 ) → q(x 1 , y 1 ) and R 2 = q(x 2 , y 2 ) → p(y 2 , x 2 ). There is a piece-unifier:

µ 1 = {{p(x 1 , y 1 )}, {p(y 2 , x 2 )}, {{x 1 , y 2 }, {y 1 , x 2 }}}
of B 1 with H 2 , therefore R 1 depends on R 2 , and a piece-unifier:

µ 2 = {{q(x 2 , y 2 )}, {q(x 1 , y 1 )}, {{x 2 , x 1 }, {y 2 , y 1 }}} of B 2 with H 1 , thus R 2 depends on R 1 . It follows that R = {R 1 , R 2 } is not aGRD.
However, since no existential variable occurs in the rules, R is trivially weaklyacyclic.

Thus, the set of rules R satisfies wa, but not aGRD.

Example 3.16 (aGRD wa) Consider the single rule R = p(x, y) ∧ q(y) → p(y, z). There is no unifier of B with H, thus this rule does not depend on itself, inducing an acyclic graph of rule dependencies. However its predicate position graph contains a special edge loop on position (p, 2), and thus is cyclic. Therefore, R = {R} satisfies aGRD but not wa.

Therefore, a first attempt to combine both approaches has been made in [BLMS11, GHK + 13]. The proposed idea was to check for position-based acyclicity conditions on each strongly connected component of the GRD. In a way, this was a "modular" approach which led to new sufficient conditions for chase termination, as states the next proposition.

Let R be a set of rules, and σ some derivation filter. If for any set of facts F, the σ-chase of F w.r.t. each strongly connected component of GRD(R) is finite, then for any set of facts F, σ-chase(F, R) is finite. Proposition 3.12 ([BLMS09, BLMS11])

In the next section, we devise a tool that combines these two approaches in a more powerful way, allowing us to not only express all these acyclicity properties in a unified way, but also to extend them.

Unifying both Approaches

In this section, we propose a new graph that encodes both atom positions and rule dependencies.

We recall that we write [a, i] to denote the i th position of atom a, and if p is an atom position, term(p) to denote its term, and pred(p) to denote its predicate. We also say that [a, i] is an existential position (resp. frontier position) if term([a, i]) is an existential (resp. frontier) variable.

Definition 3.22 (Basic Position Graph)

Given a rule R, the individual position graph of R, denoted by P G(R), is the directed graph whose vertices are the atom positions in R and there is an edge from position [a, i] to [b, j] if term([a, i]) is a frontier variable x and term([b, j]) is either x or some existential variable. Given a set of rules R, the basic position graph of R, denoted by P G(R), is the disjoint union of P G(R i ) for all R i ∈ R.

Example 3.17 (Basic Position Graph) Consider the rules R 1 = q(x 1 ) → p(x 1 , y 1 ) and R 2 = p(x 2 , y 2 ), s(y 2 ) → q(y 2 ), the basic position graph of {R 1 , R 2 } is depicted in Figure 3.5 (existential positions are colored in red).

q(x 1 ) p(x 1 , y 1 ) p(x 1 , y 1 ) p(x 2 , y 2 ) p(x 2 , y 2 ) s(y 2 ) q(y 2 ) R 1 R 2 Figure 3.5: Basic Position Graph of {R 1 , R 2 } from Example 3.17
An existential position [a, i] is said to be infinite if there is a set of atoms F, such that running the chase on F produces an unbounded number of instantiations of term([a, i]). Since we aim at detecting these infinite existential positions, we encode how variables may be "propagated" among rules by adding edges to P G(R), called transition edges, which go from vertices corresponding to atom positions occurring in rule heads to vertices corresponding to atom positions in rule bodies. If X is a set of transition edges, we denote by P G X (R) the position graph P G(R) in which are added the edges of X. Furthermore, we say that a set of transition edges is correct if it satisfies the following condition: if an existential position [a, i] is infinite, then there a cycle going through [a, i] in the resulting graph.

To define more formally the notion of correct sets of transition edges, we make use of the support graph of a derivation. Definition 3.23 (Supports) Let F be a set of facts, R be a set of rules and D = (∅, ∅, F 0 = F), . . . , (R k , π k , F k ) be a (finite) breadth-first derivation. Let h be an atom occuring in the head of some rule R i and b be an atom occuring in the body of some rule R j . We say that (h,

π i ) is a support for (b, π j ) in D if π saf e i (h) = π j (b). If there is an atom f ∈ F 0 = F such that f = π j (b)
, we also say that (f, init) is a support of (b, π j ). Among all possible supports for (b, π j ), its first supports are the supports (h, π i ) such that either i is minimal or π i = init. By extension we say that (R i , π i ) is a support for (R j , π j ) in D when there exist an atom h ∈ R i and an atom b ∈ R j such that (h, π i ) is a support for (b, π j ) in D. Among all possible supports for (R j , π j ) its last support is the support (R i , π i ) such that i is maximal. Definition 3.24 (Support Graph) Given a set of facts F, a set of rules R and a breadth-first derivation D = (∅, ∅, F 0 = F), . . . , (R k , π k , F k ), the support graph of D is the directed graph with k + 1 vertices: F 0 and the (R i , π i ). There is an edge from a vertex v i to v j = (R j , π j ) if v i is a support of v j . Such an edge is called last support edge (LS edge) when v i is a last support of v j . It is called non-transitive edge (NT edge), if it is not a transitivity edge. A path in which all edges are either LS or NT is called a triggering path.

We now define the notion of triggering derivation sequence from an atom h to an atom b as follows.

Definition 3.25 (Triggering Derivation Sequence) Given a knowledge base (F, R) and two atoms h and b, a triggering derivation sequence from h to b, denoted as h → b triggering sequence, is a (finite) breadth-first derivation from F to F k such that (h, π 1 ) is a first support of (b, π k ).

We are now able to define formally the notion of correct set of transition edges.

Definition 3.26 (Correct Set of Transition Edges)

Let R be a set of rules. A set of transition edges X is correct if, whenever there exists an h → b triggering derivation sequence, P G X (R) contains a transition from (h, i) to (b, i) for all 1 ≤ i ≤ r where r is the arity of the predicate of h (and b).

Let R be a set of rules, and X a set of transition edges. If X is correct, and P G X (R) is acyclic, then for any set of facts F, σ f r -chase(F, R) is finite.

Theorem 3.2

Proof: Observe that if there is no cycle in a correct P G X , then no existential variable generated by a rule R can be "used" to generate a fresh existential variable in the same position by another application of R. Thus, only a finite number of fresh existential variables is needed in σ f r -chase(F, R), and therefore, σ f r -chase(F, R) is finite. ✷

In the following we propose different position graphs that have correct sets of transition edges. First, the full position graph corresponds to the case where all rules are supposed to depend on all rules. It is used to check for position-based acyclicity conditions without taking into account the "true" dependencies between rules.

Definition 3.27 (Full Position Graph)

Given a set of rules R, the full position graph of R, denoted by P G F (R), is obtained from P G(R) by adding a transition edge from each position [h, k] in a rule head H i to each position [b, k] in a rule body B j with the same predicate. q(x 1 ) p(x 1 , y 1 ) The set of transition edges of P G F (R) is correct for any set of rules R.

p(x 1 , y 1 ) p(x 2 , y 2 ) p(x 2 , y 2 ) s(y 2 ) q(y 2 ) R 1 R 2 Figure 3.6: Full Position Graph of {R 1 , R 2 } from Example 3.17

Proposition 3.13

Proof: Follows immediately from the definitions. ✷

The full position graph is sufficient to encode all position-based acyclicity conditions defined in Section 3.2.2. To this end, we define marking functions, that intuitively assign to each atom position a subset of positions reachable from it, according to some propagation constraints depending on the acyclicity property we want to express. Then, we say that the property is fulfilled when no existential position can be reached from itself.

Definition 3.28 (Marking Function)

A marking function Y assigns to each vertex [a, i] in some position graph P G X a subset of its (direct or indirect) successors, called its marking.

Definition 3.29 (Marked Cycle)

Given a set of rules R, a marking function Y , a set of transition edges X, and an atom position

[a, i] occuring in R, a marked cycle for [a, i] w.r.t. X, Y and R is a cycle C in P G X (R) such that [a, i] ∈ C and for all [a ′ , i ′ ] ∈ C, [a ′ , i ′ ] belongs to the marking of [a, i].
Obviously, the less situations there are in which the marking may "propagate" in a position graph, the stronger the acyclicity property is.

Definition 3.30 (Acyclicity Property)

Given a marking function Y and a set of transition edges X, the acyclicity property associated with Y in P G X , denoted by Y X , is satisfied by a set of rules R if there is no marked cycle for an existential position in P G X (R).

Let R be a set of rules and Y be an acyclicity property such that if R satisfies Y then for any set of facts F σ f r -chase(F, R) is finite, and X be a correct set of transition edges. If R satisfies Y X , then for any set of facts F, σ f r -chase(F, R) is finite.

Theorem 3.3

Proof: Let us say that a transition edge from [a, i] in R 1 to [a ′ , i] in R 2 is useful if there are a set of facts F and a homomorphism π 1 from B 1 to F such that there is a homomorphism π 2 from B 2 to F ′ = α(F, R 1 , π 1 ) and π saf e 1 (a) = π 2 (a ′ ). Furthermore we say that the application of R 2 uses edge ([a, i], [a ′ , i]).

One can see that a useful edge exactly corresponds to an h → b triggering derivation sequence where [a, i] occurs in h and [a ′ , i] occurs in b. It follows from the correctness of X that no useful edge is removed. Now let Y be an acyclicity property ensuring the finiteness of the frontierrestricted chase. Assume there is a a set of rules R that satisfies Y X and there is a set of facts F such that σ f r -chase(F, R) is infinite. Then there is a rule application in this (infinite) derivation that uses a transition edge ([a, i], [a ′ , i]) which does not appear in P G X (R). This edge is then useful, and thus P G X (R) does not use a correct set of edges.

✷

We now define marking functions corresponding to acyclicity conditions defined in Section 3.2.

We first define three properties of a marking M ([a, i]) that may be fulfilled by the different marking functions, which allows us to easily compare them:

• (P 1 ) Γ([a, i]) ⊆ M ([a, i]); • (P 2 ) for all [a ′ , i ′ ] ∈ M ([a, i]) such that [a ′ , i ′ ] occurs in some rule head: Γ([a ′ , i ′ ]) ⊆ M ([a, i]);
• (P 3 ) for all variable v in a rule body, such that for all positions [a

′ , i ′ ] with term([a ′ , i ′ ]) = v, there is a position [a ′′ , i ′ ] ∈ M ([a, i]) with pred([a ′ , i ′ ]) = pred([a ′′ , i ′ ]) and term([a ′′ , i ′ ]) = v: Γ(v) ⊆ M ([a, i])
, where Γ(v) is the union of all Γ(p) where p is an atom position in which v occurs.

Property (P 1 ) states that the neighbourhood of the position we are considering must be in the marking; then property (P 2 ) that if a position belonging to the marking occurs in some rule head, then its neighbourhood must also belong to it; finally property (P 3 ) states that if for all positions in which some variable v occurs in a rule body, there is a position belonging to the marking with the same predicate position in which v occurs, then the neighbourhood of variable v (that is all neighbours of all positions in which v occurs) must also belong to the marking.

The first position-based acyclicity condition is weak-acyclicity (see Definition 3.14 for its original wording).

Definition 3.31 (Weakly-acyclic Marking)

A marking M is a weakly-acyclic marking with respect to some transition edge condition X, if for any set of rules R and any position [a, i] ∈ P G X (R), M ([a, i]) is the minimal set such that:

• (P 1 ) holds, • ∀[a ′ , i ′ ] ∈ M ([a, i]), Γ([a ′ , i ′ ]) ⊆ M ([a, i]).
Observe that the latter condition implies (P 2 ) and (P 3 ).

Example 3.19

Consider the set of rules R composed of rule R 1 = p(x 1 , y 1 ) → s(y 1 , z 1 ) and rule R 2 = s(x 2 , y 2 ) → p(x 2 , y 2 ) from Example 3.10 whose predicate position graph is pictured on Figure 3.2.

The full position graph P G F (R) is depicted by Figure 3.7.

There is a single existential position [s(y 1 , z 1 ), 2] (from rule R 1 ) whose marking M is the following: first M contains all neighbours of [s(y 1 , z 1 ), 2], that is [s(x 2 , y 2 ), 2] from rule R 2 . Then, the second condition of the weakly-acyclic marking forces all neighbours of each element of the marking to also be in the marking. Therefore [p(x 2 , y 2 ), 2] also belongs to M , and for the same reason [p(x 1 , y 1 ), 2] and [s(y 1 , z 1 ), 2] Hence, we have:

M ([s(y 1 , z 1 ), 2]) = {[s(x 2 , y 2 ), 2], [p(x 2 , y 2 ), 2], [p(x 1 , y 1 ), 2], [s(y 1 , z 1 ), 2]}
and since M contains the existential variable from which we build it, R is not weaklyacyclic.

The following lemma will be of great use in the different proofs of equivalence between the original acyclicity conditions and their markings in the full position graph. It exhibits the link between the edges in the predicate position graph of a set of rules, and those in its full position graph. p(x 1 , y 1 )

p(x 1 , y 1 ) s(y 1 , z 1 ) s(y 1 , z 1 ) s(x 2 , y 2 ) s(x 2 , y 2 ) p(x 2 , y 2 ) p(x 2 , y 2 ) Figure 3.7: P G F (R) from Example 3.19
Let R be a set of rules. For each edge ((p, i), (q, j)) in the predicate position graph of R, there is the following non-empty set of edges in P G F (R):

E (p,i),(q,i) = {([a, i], [b, j]) | pred([a, i]) = p and pred([b, j]) = q}
Furthermore, the set of all E (p,i),(q,j) for all positions (p, i) and (q, j) forms a partition of all edges in P G F (R).

Lemma 3.1

Proof: Follows immediately from the construction of P G F . ✷

A set of rules R is wa iff P G F (R) satisfies the acyclicity property associated with the wa marking (formally defined in Definition 3.31).

Proposition 3.14

Proof: If R is not wa, then there is some cycle in the graph of predicate positions going through a special edge. Let (p, i) be the predicate position where this edge ends, and z be an existential variable which occurs in (p, i). Let M be the wamarking of any existential position [a, i] with pred([a, i]) = p and term([a, i]) = z. Condition (P 1 ) ensures that the successors of [a, i] are marked; then the propagation can be seen as performing a classic breadth-first traversal of the graph. By Lemma 3.1, to each cycle in the graph of predicate positions of R corresponds a set of cycles in P G F (R). Since (p, i) belongs to a cycle, [a, i] is obviously marked by the propagation. Hence P G F (R) does not satisfy the acyclicity property associated with the wa-marking.

Definition 3.34 (Super-weakly-acyclic Marking)

A marking M is a super-weakly-acyclic marking with respect to some transition edge condition X, if for any set of rules R and any position [a, i] ∈ P G X (R), M ([a, i]) is the minimal set such that:

• (P 1 ) and (P 3 ) hold,

• for all [a ′ , i ′ ] ∈ M ([a, i]) occuring in a rule head, {[a ′′ , i ′ ] ∈ Γ([a ′ , i ′ ]) | a ′ and a ′′ unify} ⊆ M ([a, i]).
A set of rules R is swa iff P G F (R) satisfies the acyclicity property associated with the swa marking (Definition 3.34).

Proposition 3.17

Proof: Similarily to the proof of Proposition 3.16, observe that the swa marking is defined in the same way as the move set of Definition 3.20. ✷

We synthesise here propositions 3.14 to 3.17.

A set of rules R is wa (resp. f d, ja, swa) iff P G F (R) satisfies the acyclicity property associated with the wa (resp. f d, ja, swa) marking.

Theorem 3.4

Proof: Follows immediately from Propositions 3.14 to 3.17. ✷

As already mentioned in Section 3.2, all acyclicity properties can be safely combined with the GRD (initially proposed in [START_REF] Baget | On rules with existential variables: Walking the decidability line[END_REF]). More formally, we recall the definition from [GHK + 13] in which the previous definition is slightly improved:

Definition 3.35 (Y ≺ [BLMS11, GHK + 13])
Given an acyclicity property Y , a set of rules R satisfies Y ≺ if each strongly connected component of GRD(R) satisfies Y , except for those composed of a single rule and no loop.

The "no loop" condition is here to ensure that if GRD(R) is acyclic, then R satisfies Y ≺ for any Y .

To capture these conditions, we define a second transition edge condition for position graphs.

Definition 3.36 (Dependency Position Graph)

Given a set of rules R, the dependency position graph of R, denoted by P G D (R), is obtained from P G(R) by adding a transition edge from each position [h, k] in a rule head H i to each position [b, k] in a rule body B j with the same predicate if there is a path from R i to R j in GRD(R), i.e., if R j depends directly or indirectly on R i .

Example 3.20 (Dependency Position Graph)

Let R 1 = r(x 1 , y 1 ) → p(z 1 , y 1 ) ∧ q(y 1 ) and R 2 = p(x 2 , y 2 ) ∧ q(x 2 ) → p(y 2 , z 2 ) be two rules. The dependency position graph of R = {R 1 , R 2 } is depicted on Figure 3.8. Note that there is a piece-unifier of B 2 with H 1 : µ 1 = {{q(x 2 )}, {{x 2 , y 1 }}, {q(y 1 )}} and a piece-unifier of B 1 with H 2 : µ 2 = {{r(x 1 , y 1 )}, {{x 1 , y 2 }, {y 1 , z 2 }}, {p(y 2 , z 2 }}.

r(x 1 , y 1 ) r(x 1 , y 1 ) p(z 1 , y 1 ) p(z 1 y 1 ) q(y 1 ) p(x 2 , y 2 ) p(x 2 , y 2 ) q(x 2 ) r(y 2 , z 2 ) r(y 2 , z 2 ) R 1 R 2 Figure 3.8: P G D (R) from Example 3.20
The first thing to notice is that for any set of rules the dependency position graph is a subgraph of the full position graph.

Let R be a set of rules, E(P G D (R)) ⊆ E(P G F (R)).

Proposition 3.18

Proof: Follows immediately from the definitions. ✷ However, the correctness of its set of edges still holds.

The set of transition edges of P G D (R) is correct for any set of rules R.

Proposition 3.19

The proof of this proposition relies on the following two lemmas.

If D is an h → b triggering derivation sequence of length k, then there is a triggering path from (R 1 , π 1 ) to (R k , π k ) in the support graph of D.

Lemma 3.2

Proof: There is an edge from (R 1 , π 1 ) to (R k , π k ) in the support graph of D. By removing transitivity edges, it remains a path from (R 1 , π 1 ) to (R k , π k ) for which all edges are either LS or NT. ✷

If there is an edge from (R i , π i ) to (R j , π j ) that is either LS or NT in the support graph of D, then R j depends on R i .

Lemma 3.3

Proof: Assume there is a LS edge from (R i , π i ) to (R j , π j ) in the support graph of D. Then the applicatin of R i according to π i on F i-1 produces F i on which all atoms required to map B j are present (or it would not have been a last support). Since it is a support there is also an atom required to map B j that appeared on F i-1 . It follows that R j depends on R i . Suppose now that the edge is NT. Consider F ℓ such that there is a LS edge from (R ℓ , π ℓ ) to (R j , π j ). See that there is no path from (R i , π i ) to (R ℓ , π ℓ ) (otherwise there would be a path from (R i , π i ) to (R j , π j ) and the edge would be a transitive edge). Thus we can consider the set of facts F ℓ\i that would have been created by the following derivation sequence:

1. first apply from F 0 all rule applications of the initial sequence until (R i-1 , π i-1 ), 2. then apply all possible applications of this sequence from i + 1 until ℓ.

We can apply (R i , π i ) on the set of facts F ℓ\i thus obtained (since it contains all atoms from F i-1 . Let us now consider the set of facts F ′ obtained after this rule application. We must now check that (R j , π j ) can be applied on F ′ . This stems from the fact that there is no support path from (R i , π i ) to (R j , π j ). This last rule application relies upon an atom that is introduced by the application of (R i , π i ), thus R j depends on R i . ✷

We can now conclude by the proof of Proposition 3.19: Proof: If there is an h → b triggering derivation sequence, then by Lemma 3.2, we can exhibit a triggering path that corresponds to a path in the graph of rule dependencies (Lemma 3.3). ✷

The next proposition states that checking acyclicity properties in the dependency position graph is equivalent to checking acyclicity properties on each strongly connected component of the graph of rule dependencies.

Given an acyclicity property Y and a set of rules R, R satisfies Y ≺ if and only if R satisfies Y D ; i.e., Y D = Y ≺ .

Proposition 3.20

Proof: Let R be a set of rules and Y be an acyclicity property.

We first show that if R is not Y D then it is not Y ≺ . Suppose that R does not satisfy Y D . We then have an existential position [a, i] in P G D (R) such that [a, i] ∈ M ([a, i]), where M is the marking associated with Y . Specifically, this means that there is a cycle going through [a, i] in P G D (R). Then all rules from this cycle belong to the same strongly connected component of GRD(R). Consider the restriction of R to the set of rules R ′ that correspond to the S.C.C. in which the rules from this cycle appear. If we build P G F (R), we see that R ′ does not satisfy Y F , hence Y . We have then exhibit a S.C.C. of the GRD(R) that does not satisfy Y , hence R is not Y ≺ . Now we show that if R is not Y ≺ , then it is not Y D . Assume that R does not satisfy Y ≺ . Since it does not satisfy Y ≺ there is at least one S.C.C. that does not satisfy Y . Call it R ′ . Hence P G F (R ′ ) contains an existential position [a, i] belonging to a cycle. Since R (hence R ′ ) is Y D , this cycle does not occur anymore in P G D (R ′ ). However, the only edges we are allowed to remove in P G D (R ′ ) are edges between rules R i and R j for which there is no path from R i to R j in GRD(R). Thus, we cannot remove any edge (from the definition of a S.C.C.). Hence, R ′ is not Y D . ✷

From the definition of an acyclicity property that we proposed earlier (Definition 3.30), we can prove in a generic way that some properties are stronger (or weaker) than others. In the following, given two acyclicity properties Y 1 and Y 2 we say that

Y 1 is weaker than Y 2 , denoted by Y 1 ⊆ Y 2 if for any set of rules R, R satisfies Y 1 implies that R satisfies Y 2 . If, furthermore, Y 2 Y 1 , we write Y 1 ⊂ Y 2 .
First, we can prove that if an acyclicity property does not generalise aGRD, the acyclicity property obtained by checking it on P G D instead of P G F is strictly stronger than the original one. The idea is that by switching to P G D , we take into account dependencies between rules, which is why if the property already generalises aGRD (and thus already takes dependencies into account in some way), it may not become strictly stronger.

Let Y be an acyclicity property, if aGRD Y , then Y ⊂ Y D .

Proposition 3.21

Proof: Let R be a set of rules that does not satisfy Y but satisfies aGRD. From the definition of aGRD, GRD(R) is composed of |R| strongly connected components with no loop. Thanks to Proposition 3.20, R trivially satisfies Y D . Therefore, R is a set of rules satisfying Y D but not Y . ✷

The next proposition states that if two acyclicity properties are comparable, then the properties obtained by extending them to take into account dependencies also are.

Let Y 1 and Y 2 be two acyclicity properties, if

Y 1 ⊆ Y 2 then Y D 1 ⊆ Y D 2 . Proposition 3.22 Proof: Consider a set of rules R that satisfies Y D 1 . From Proposition 3.20, each strongly connected component of GRD(R) satisfies Y 1 . Since Y 1 ⊆ Y 2 , each S.C.C. of GRD(R) also satisfies Y 2 , therefore R satisfies Y D 2 . ✷
Then, we can check that a strict inclusion of two acyclicity properties is preserved (under some minor constraints) while shifting to the dependency version.

Let Y 1 and Y 2 be two acyclicity properties such that

Y 1 ⊂ Y 2 , wa ⊆ Y 1 and Y 1 ⊂ Y D 1 . Then, Y D 1 ⊂ Y D 2 .
Proposition 3.23

Proof: From Proposition 3.22, we know that Y D 1 ⊆ Y D 2 ; it remains to exhibit a set of rules that satisfies

Y D 2 but not Y D 1 . Let R be a set of rules that satisfies Y 2 but neither Y 1 nor aGRD. Rewrite R into R ′ by replacing each rule R i = (B i , H i ) with a new rule R ′ i = (B i ∪ {p(x)}, H i ∪ {p(x)})
, where p is a fresh predicate and x a fresh variable. Each rule can now be unified with each rule, but the only created cycles are those which contain only atom positions [p(x), 1], hence none of those cycles go through existential positions. Since wa ⊆ Y 1 (and so wa ⊆ Y 2 ), the added cycles do not change the behaviour of R with respect to properties Y 1 or Y 2 . Hence R ′ satisfies Y 2 and not Y 1 , and since

GRD(R ′ ) is a complete graph, P G D (R ′ ) = P G F (R ′ ). We can conclude that R ′ satisfies Y D 2 but not Y D 1 . ✷
In this section we have presented a new graph that allows to encode most existing acyclicity notions. Next, we make use of this new tool to extend them in a generic way.

Extensions

In this section, we present two other sets of transition edges for the position graph, and show that this allows us to extend the acyclicity notions detailed previously.

First, we need to define the notion of agglomerated rule, which allows us to encode information about unifiers in the position graph.

While technical, the intuition behind this definition is quite simple: we want the agglomerated rule to limit the number of existential variables from a rule. The idea is to relax the notion of piece-unifier; indeed, through a derivation, it may happen that the atoms needed to trigger a rule have actually been found, as illustrated by the next example.

Example 3.21

Let R 1 = p(x 1 , y 1 ) → r(y 1 , z 1 ) ∧ q(z 1 ), R 2 = q(x 2 ) → s(x 2 ) and R 3 = r(x 3 , y 3 ) ∧ s(y 3 ) → p(x 3 , y 3 ). We want to have a transition edge from [r(y 1 , z 1 ), 2] to [r(x 3 , y 3 ), 2] since the fresh variable generated after an application of rule R 1 can be used for a new application of rule R 3 . It we only consider piece-unifiers of B 3 with H 1 , this edge does not appear; indeed, there is no such piece-unifier. Thus, the idea is to "relax" the piece-unifiers, and to this purpose, we weaken which variables are existentially quantified by "moving" the frontier along the path (in this example, this path goes through rule R 2 ).

Then we build an agglomerated rule, that contains both R 1 and R 2 information about which variables could be unified later. In this case, the agglomerated rule of R 1 relatively to R 3 would be: R 3 1 = p(x 1 , y 1 ) ∧ f r(y 1 ) ∧ f r(z 1 ) → r(y 1 , z 1 ) ∧ q(z 1 ). Since z 1 is not existentially quantified anymore, there is a piece-unifier of B 3 with R 3 1 .

Definition 3.37 (Agglomerated Rule) Given R a set of rules and R i , R j ∈ R, an agglomerated rule associated with (R i , R j ) has the following form:

R k i = B i t∈T ⊆terms(H i ) f r(t) → H i
where f r is a new unary predicate that does not appear in R, and the atoms f r(t) are built as follows. Let P be a non-empty set of paths from R i to direct predecessors of R j in GRD(R). Let P = (R 1 , . . . , R n ) be a path in P. One can associate a rule R P with P by building a sequence R 1 = R P 1 , . . . , R P n such that ∀1 ≤ l ≤ n, there is a piece-unifier µ l of B l+1 with the head of R P l , where the body of R p l+1 is B P l ∪ {f r(t) | t is a term of H P l unified in µ l }, and the head of R P l+1 is H 1 . Note that for all l, H P l = H 1 , however, for l = 1, R P l may have less existential variables than R l due to the added atoms. The agglomerated rule R j i built from

{R P | P ∈ P} is R j i = P ∈P R P .
Definition 3.38 (Position Graph with Unifiers) Given a set of rules R, the position graph with unifiers of R, denoted by P G U (R), is obtained from P G(R) by adding a transition edge from each position [h, k] in a rule head H i to each position [b, k] in a rule body B j with the same predicate if there is a piece-unifier µ of B j with the head of an agglomerated rule

R j i such that σ µ (term([b, k])) = σ µ (term([h, k])).
Example 3.22 (Position Graph with Unifiers) Remember rules R 1 = r(x 1 , y 1 ) → p(z 1 , y 1 ) ∧ q(y 1 ) and R 2 = p(x 2 , y 2 ) ∧ q(x 2 ) → p(y 2 , z 2 ) from Example 3.20. The position graph with unifiers of R = {R 1 , R 2 } is shown on Figure 3.9. Note that differently from its dependency position graph (see Figure 3.8), the position graph with unifiers does not contain any cycle.

r(x 1 , y 1 ) r(x 1 , y 1 ) p(z 1 , y 1 ) p(z 1 y 1 ) q(y 1 ) p(x 2 , y 2 ) p(x 2 , y 2 ) q(x 2 ) r(y 2 , z 2 ) r(y 2 , z 2 ) R 1 R 2 Figure 3.9: P G U (R) from Example 3.22
One can observe that the set of edges of the position graph with unifiers is a subset of the edges of the dependency position graph.

Let R be a set of rules, E(P G U ) ⊆ E(P G D ).

Proposition 3.24

Proof: Follows immediately from the fact that in P G U we only consider paths in the graph of rule dependencies to create the agglomerated rule. ✷

The set of transition edges of P G U (R) is correct for any set of rules R.

Proposition 3.25

Proof: Consider a h → b triggering derivation sequence from F to F k . We note

H P = π k (B k ) ∩ π saf e
1 (H 1 ) the atoms of F k that are introduced by the application (R 1 , π 1 ) and are used for the application (R k , π k ). Note that this set of atoms is not empty, since it contains at least the atom produced from h. Now consider the set of terms T P = terms(H P ) ∩ terms(π k (B k ) \ H P ) that separate the atoms of H P from the other atoms of π k (B k ). Now we consider the rule R P = B 1 ∪ {f r(t) | t is a variable of R 1 and π saf e 1 (t) ∈ T P } → H 1 . Consider the set of facts F P = F k \H P ∪{f r(t) | t ∈ T P }. Consider the mapping π P 1 from the variables of the body of R P to those of F P defined as follows: it v is a variable from B 1 then π P 1 (v) = π 1 (v), otherwise v is a variable in an fr-atom and π P 1 (v) = π k (v). This mapping is a homomorphism, thus we can consider the set of facts F P ′ = α(F P , R P , π P 1 ). This application produces a new application of R k that maps b to the atom produced from h. Indeed, consider the mapping π P k from the variables of B k to those of

F P ′ defined as follows: if v is a variable of B k such that π k (v) ∈ terms(H P ) \ T P , then π P k (v) = π P saf e 1 (v ′ ), where v ′ is the variable of H 1 that produced π k (v), otherwise π P k (v) = π P saf e 1 (v)
. This mapping is a homomorphism. Thus, there is a piece-unifier of B k with the head of R P that unifies h and b.

It remains now to prove that for each atom f r(t) in the body of R P there exists a triggering path

P i = (R ′ 1 , π ′ 1 ) = (R 1 , π 1 ) to (R ′ ℓ , π ′ ℓ ) = (R k , π k )
in the support graph such that f r(t) appears in the agglomerted rule R A i along R 1 , . . . , R k-1 . For a contradiction, let v be a variable occurring in some fr-atom in R P . Suppose that f r(v) does not appear in any agglomerated rule corresponding to a triggering path between (R 1 , π 1 ) and (R k , π k ). Since π 1 (v) is an existential variable generated by the application of R 1 and there is no unifier on the GRD paths that correspond to these triggering paths that unify v, π 1 (v) may only occur in atoms that are not used (even transitively) by (R k , π k ), i.e., π 1 (v) ∈ T P . There, v does not appear in an fr-atom in R P , which leads to a contradiction. Since R P and R A = R A i have the same head and the frontier of R P is a subset of the frontier of R A , any unifier with R P is also a unifier with R A . Thus there is a unifier of R k with R A that unifies h and b, and there are the corresponding correct transition edges in P G U . ✷

The next theorem states that the position graph with unifiers is strictly more powerful than the dependency position graph; furthermore, the "gap" from Y D to Y U is at least "as large" as from Y to Y D .

Let Y be an acyclicity property; then,

Y D ⊆ Y U and if Y ⊂ Y D then Y D ⊂ Y U . Furthermore,
R i = B i [ x, y] → H i [ x, y], let R i,1 = B i [ x, y] → p i ( x, y)
where p i is a fresh predicate ; and

R i,2 = p i ( x, y) → H i [ y][ z]. Then for each rule R i,1 , let R ′ i,1 = (B ′ i,1 , H i,1 ) such that B ′ i,1 = B i,1 ∪ {p ′ j,i (x j,i ) | ∀R j ∈ R},
where each p ′ j,i is a fresh predicate and each x j,i a fresh variable. Now for each rule

R i,2 , let R ′ i,2 = (B i,2 , H ′ i,2
) where

H ′ i,2 = H i,2 ∪ {p ′ i,j (z i,j ) | ∀R j ∈ R}, where z i,j are fresh existential variables. Let R ′ = R i ∈R {R ′ i,1 , R ′ i,2 }.
This construction ensures that each R ′ i,2 depends on R ′ i,1 , and each R ′ i,1 depends on each R ′ j,2 ; thus there is a transition edge from each

R ′ i,1 to R ′ i,2 and from each R ′ j,2 to each R ′ i,1 in P G D (R ′ ). Hence, P G D (R ′ ) contains exactly one cycle for each cycle in P G F (R). Furthermore, P G D (R ′ ) contains at least one marked cycle w.r.t. Y and then R ′ is not Y D . Now each cycle in P G U (R ′ ) is also a cycle in P G D (R), and since P G D (R) satisfies Y , P G U (R ′ ) also does. Therefore, R ′ does not satisfy Y D but satisfies Y U . ✷
We also prove that strict inclusions between dependency-based conditions lead to strict inclusions between piece-unifier-based conditions.

Let Y 1 and Y 2 be two acyclicity properties. If

Y D 1 ⊂ Y D 2 and Y D 2 ⊂ Y U 2 , then Y U 1 ⊂ Y U 2 .
Theorem 3.6

Proof: Let R be a set of rules such that R satisfies Y D 2 but not Y D 1 . We rewrite R into R ′ as follows. For each pair of rules R i , R j ∈ R such that R j depends on R i , for each variable x in the frontier of R j , and each variable y in the head of R i ; if x and y occur both in a given predicate position, we add to the body of R j a new atom p i,j,x,y (x) and to the head of R i a new atom p i,j,x,y (y) where p i,j,x,y denotes a fresh predicate. This construction allows each term from the head of R i to propagate to each term from the body of R j if they shared some predicate position in R. Thus, any cycle in P G D (R) is also a cycle in P G U (R ′ ), without modifying behaviour w.r.t. the acyclicity properties. Hence R ′ satisfies Y U 2 but does not satisfy Y U 1 . ✷

A further extension we can make is by doing a finer analysis of unifiers and marked cycles. We first define the notion of "incompatible" sequence of unifiers, which ensures that a given sequence of rule applications is impossible. Then, a cycle for which all sequence of unifiers are incompatible can be safely ignored. Though, we point out that the notion of piece-unifier is (again) not appropriate to such a purpose, hence we have to weaken it. Definition 3.39 (Weak Unifier) Given two rules R 1 = (B 1 , H 1 ) and R 2 = (B 2 , H 2 ), a weak unifier µ of B 2 with H 1 is a piece-unifier as defined in Definition 1.29 that satisfies point (i) and (ii) but does not impose the piece condition of point (iii).

Example 3.23 (Weak Unifier)

Consider rules R 1 = r(x 1 , y 1 ) → p(z 1 , y 1 ) and R 2 = p(x 2 , y 2 ) ∧ q(x 2 ) → H 2 [x 2 , y 2 ].
There is a weak-unifier of B 2 with H 1 : µ w = {{p(x 2 , y 2 )}, {{z 1 , x 2 }, {y 1 , y 2 }}, {p(z 1 , y 1 }}, but this is not a piece-unifier. Indeed, x 2 also occurs in q(x 2 ) and it is unified with the existential variable z 1 , thus, {p(x 2 , y 2 )} is not a piece.

Definition 3.40 (Compatible Unifier)

Given a set of rules R and two rules

R 1 = (B 1 , H 1 ) and R 2 = (B 2 , H 2 ) in R, a weak unifier µ = (B ′ 2 , P µ , H ′ 1 ) of B 2 with H 1 is compatible w.r.t. R if for each po- sition [a, i] in B ′ 2 such that σ µ (term([a, i])
) is an existential variable z, P G U (R) contains a path from a position in which z occurs to [a, i], without going through another existential position. Otherwise µ is incompatible. Note that in a set of rules R, any piece-unifier of some rule body B i with some rule head H j is necessarily compatible with respect to R.

Let R be a set of rules, R 1 , R 2 ∈ R, and µ be a weak unifier of B 2 with H 1 . If µ is incompatible w.r.t. R, then no application of R 2 can use an atom in σ µ (H 1 ).

Proposition 3.26

Proof: We first formalise the sentence "no application of R 2 can use an atom in σ µ (H 1 )" by the following sentence: "no application π ′ of R 2 can map an atom a ∈ B 2 to an atom b produced by an application (R 1 , π) such that b = π(b ′ ), where π and π ′ are more specific than µ".

Consider the application of R 1 to a set of facts F according to a homomorphism π ′ such that for an atom a ∈ B 2 , π ′ (a) = b = π(b ′ ), where both π and π ′ are more specific than µ. Note that this implies that µ(a) = µ(b ′ ). Assume that b contains a fresh variable z i produced from an existential variable z in H 1 . Let z ′ be the variable from a such that π ′ (z ′ ) = z i . Since the domain of π ′ is the variables of B 2 , all atoms from B 2 in which z ′ occurs at a given position [p, j] are also mapped by π ′ to atom containing z i in the same position [p, j]. Since z i is a fresh variable, these atoms have been produced by sequences of rule applications starting from (R 1 , π). Such a sequence of rule applications exists only if there is a path in P G U from a position of z in H 1 to [p, j]; moreover, this path cannot go through an existential position, otherwise z i cannot be propagated. Hence µ is necessarily compatible. ✷ Definition 3.41 (Unified Rule) Given a set of rules R and two rules R 1 , R 2 ∈ R such that there is a compatible unifier µ of B 2 with H 1 , the unified rule associated with µ, denoted by

R µ = R 1 ⋄ µ R 2 , is defined by H µ = σ µ (H 1 ) ∪ σ µ (H 2 ) and B µ = σ µ (B 1 ) ∪ (σ µ (B 2 ) \ σ µ (H 1 )).
Example 3.24 (Unified Rule) Let R be the set of rules composed of the following: R 1 = p(x 1 , y 1 ) → q(y 1 , z 1 ), R 2 = q(x 2 , y 2 ) → r(x 2 , y 2 ), R 3 = r(x 3 , y 3 ) ∧ s(x 3 , y 3 ) → p(x 3 , y 3 ), and R 4 = q(x 4 , y 4 ) → s(x 4 , y 4 ).

Let µ be the following compatible unifier of B 2 with H 1 :

µ = {{q(x 2 , y 2 )}, {q(y 1 , z 1 )}, {{x 2 , y 1 }, {y 2 , z 1 }}}
Then we obtain the unified rule associated with µ: R 1 ⋄ µ R 2 = p(x 1 , y 1 ) → q(y 1 , z 1 ) ∧ r(y 1 , z 1 ). This means that while R 3 cannot be applied right after an application of R 1 ⋄ µ R 2 . However the atoms needed to apply s(x 3 , y 3 ) can be brought by a sequence of rule applications (R 1 , R 4 ). We thus relax the notion of piece-unifier to take into account arbitrary long sequences of rule applications.

Definition 3.42 (Compatible Sequence of Unifiers)

Given a set of rules R, and a sequence of rules

(R 1 , . . . , R k+1 ) in R, a sequence s = (R 1 , µ 1 , R 2 , . . . , µ k R k+1 ), where for 1 ≤ i ≤ k, µ i is a weak unifier of B i+1 with H i , is a compatible sequence of unifiers w.r.t. R if: (i) µ 1 is a compatible unifier of B 2 with H 1 w.r.t. R, and
(ii) if k > 0, the sequence obtained from s by replacing (R 1 , µ 1 , R 2 ) with R 1 ⋄ µ 1 R 2 is a compatible sequence of unifiers.

Example 3.25

In Example 3.24, the sequence (R 1 , µ 1 , R 2 , µ 2 , R 3 , µ 3 , R 1 ) with the obvious µ i is compatible.

We can now improve previous acyclicity properties as we did previously.

Definition 3.43 (Compatible Cycle)

Given an acyclicity property Y , and a set of rules R, the compatible cycles for [a, i] ∈ P G U (R) are all marked cycles C for [a, i] such that there is a compatible sequence of unifiers induced by C. We say that property Y U + is satisfied by R if for each existential position [a, i], there is no compatible cycle for [a, i].

Similary results to those obtained for P G U can be proved for P G U + as state the next theorems.

Let Y be an acylicity property. Then,

Y U ⊆ Y U + . Moreover, if Y D ⊂ Y U then Y U ⊂ Y U + .
Theorem 3.7

Proof: Inclusion follows immediately from the definitions.

We now show that this inclusion is strict. Let R be a set of rules satisfying Y U but not Y D . We build a set of rules R ′ that satisfies Y U + but not Y U . To this aim, we first increase the arity of each predicate of R by two, and in each rule body and head, we put two fresh variables t 1 and t 2 in those positions. E.g., a rule s(x, y) → t(y, z) would become s(x, y, t 1 , t 2 ) → t(y, z, t 1 , t 2 ). Then, for each rule R = (B, H), we create four fresh predicates p, q 1 , q 2 , r whose arity is respectively |var(H)|, 2, 2 and 2, and five fresh variables z 1 , z 2 , z 3 , z 4 and z 5 . Then we "split" R into four rules (where x is a list of all variables from H):

• R 1 = B → p( x, z 1 , z 2 ), • R 2 = p( x, z 1 , z 2 ) → q 1 (z 1 , z 3 ), • R 3 = q 1 (z 1 , z 3 ) → s(z 3 , z 5 ), • R 4 = p( x, z 1 , z 2 ) ∧ q 1 (z 1 , z 3 ) ∧ q 2 (z 1 , z 4 ) ∧ s(z 3 , z 5 ) ∧ s(z 4 , z 5 ) → H.
The graph of rule dependencies of those four rules contains the following edges: (R 1 , R 2 ), (R 2 , R 3 ), (R 3 , R 4 ). It can be observed that in particular, in P G U (R ′ ) there is a transition edge going from the last position of the atom p( x, z 1 , z 2 ) in rule R 1 to the last position of the "same" atom in rule R 4 . The same holds for the penultimate position of these atoms. However, it can be seen that given any set of facts, rule R 4 can never be applied. But the definition of P G U does not take this "complicated" interactions into account. Specifically, the set of rules is not Y U anymore.

Let us now consider Y U + . There is no compatible cycle in P G U since the existential variable z 1 in rule R 1 has to go through new existential positions before reaching the position of

z 1 in rule R 4 . Thus, R ′ is Y U + . ✷ Let Y 1 and Y 2 be two acyclicity properties. If Y D 1 ⊂ Y D 2 , and Y D 2 ⊂ Y U + 2 , then Y U + 1 ⊂ Y U + 2 .
Theorem 3.8

Proof:

Observe that the transformation we used in the proof of Theorem 3.6 actually guarantees that all cycles which are present are compatible cycles. Thus, for the obtained set of rules R ′ and any acyclicity property

Y , R ′ satisfies Y U if and only if R ′ satisfies Y U + .
✷

We now prove that if the complexity of recognition of an acyclicity property Y is in coN P , then, checking that a set of rules satifies one of the extended properties

Y D , Y U or Y U + is coN P -complete.
To this end, we make use of the following proposition.

Given a set of rules R and a set of facts, if there is an h → b triggering derivation sequence (with h ∈ H and b ∈ B ′ , where R = (B, H) and R ′ = (B ′ , H ′ ) are two rules from R), then there exist a non-empty set of paths

P = {P 1 , . . . , P k } from R in GRD(R) such that 1≤i≤k |P i | ≤ |R| ×
|terms(H)| and a piece-unifier of B ′ with the head of an agglomerated rule along P that unifies h and b.

Proposition 3.27

Proof: The piece-unifier is entirely determined by the terms that are forced into the frontier by an fr-atom. Hence, we need to consider at most one path for each term in H. Moreover, each (directed) cycle in the GRD (that is of length at most |R|) needs to be traversed at most |terms(H)| times, since going through such a cycle without creating a new frontier variable cannot create any new unifier. Hence we need to consider only paths of polynomial length. ✷

We are now ready to prove the complexity of recognition.

Let Y be an acyclicity property. If checking that a set of rules R satisfies Y is in coN P , then checking that R satisfies Y D , Y U or Y U + is coN P -complete.

Theorem 3.9 (Complexity of Recognition)

Proof: One can guess a cycle in P G D (R) (or P G U (R), or P G U + (R)) such that the property Y is not satisfied by this cycle. From the previous property, each edge of the cycle has a polynomial certificate, and checking if a given substitution is a piece-unifier can also be done in polynomial time. Since Y is in coN P , we have a polynomial certificate that this cycle does not satisfy Y . Membership to coN P follows.

The completeness part is proved by a simple reduction from the co-problem of rule dependency checking (which is thus a coNP-complete problem). Let R 1 and R 2 be two rules. We first define two fresh predicates p and s of arity |var(B 1 )| and two fresh predicates q and r of arity |var(H 2 )|. We build R 0 = p( x) → s( x) where x is a list of all variables in B 1 , and R 3 = r( x) → p( z)∧q( x), where z = (z, z, . . . , z), where z is a variable which does not appear in H 2 . We rewrite

R 1 into R ′ 1 = B 1 ∧s( x) → H 1 and R 2 into R ′ 2 = B 2 → H 2 ∧ r( x), where x is a list of all variables in H 2 . One can check that R = {R 0 , R ′ 1 , R ′ 2 , R 3 } contains a cycle going through an existential variable (thus, it is not wa D ) iff R 2 depends on R 1 . ✷ Figure 3
.10 summarises relationships between the different acyclicity properties. Edges are oriented from bottom to top, and an edge from an acyclicity property C 1 to an acyclicity property C 2 means that C 1 ⊂ C 2 . All inclusions are strict. Furthermore, the figure is complete, that is, if there is no path between two properties, then they are incomparable.

Other Acyclicity Conditions

We now consider two other acyclicity conditions, namely MFA and MSA, that do not fit well with our framework. However, we show that MSA can be recast in our terms, hence generalised in the same way as the previously mentioned classes.

Model Summarizing Acyclicity and Model Faithful Acyclicity

Model Faithful Acyclicity (MFA) and Model Summarizing Acyclicity (MSA) are two properties of a set of rules ensuring the finiteness of the frontier-restricted chase [GHK + 13]. Originally they were defined using the skolem chase, but as mentioned in Section 3.1, the skolem chase and the frontier-restricted chase yield isomorphic results.

The ideas underlying the verification of these properties are the following:

1. Build the critical instance Crit(R) of the set of rules R. It is a set of facts which ensures that any rule of R can be applied, and is formally defined in Definition 3.44.

2. Consider a set of rules R ′ which is either R (in the case of MFA) or a specialisation of R (in the case of MSA), where every existential variable in R is replaced by a fresh constant (note that those constants do not occur in Crit(R)).

3. Run the frontier-restricted chase on Crit(R) w.r.t. R ′ until either it halts or some "existential variable cycle" (see below) is detected. This procedure is ensured to halt.

The set of rules is then MFA (resp. MSA) if this algorithm halts without detecting any existential variable cycle.

Initially, MSA has been thought as an approximation to MFA that enjoys a lower recognition (and reasoning) complexity.

Critical Instance

Definition 3.44 (Critical Instance) Let R be a set of rules. The critical instance of R, denoted by Crit(R) is built as follows. Consider C the set of all constants occurring in some rule R ∈ R (if no constant occur in the set of rules C = { * }, where * is a special fresh constant). For every predicate p of arity r appearing in R, for every tuple of constants (c 1 , . . . , c r ) ∈ C r , add the atom p(c 1 , . . . , c r ) to Crit(R).

The critical instance is sufficient to check the universal termination of the frontierrestricted chase w.r.t. a given set of rules.

Let R be a set of rules. If σ f r -chase(Crit(R), R) is finite then for any set of facts F, σ f r -chase(F, R) is finite.

Proposition 3.28 ([Mar09])

We now define MFA and MSA in a way that differs from their original definitions but which is more adapted to our purpose.

Model Faithful Acyclicity

When building the σ f r -chase(Crit(R), R), we maintain a graph of existential variables that we denote by Evg(R). Vertices of this graph are the existential variables in R (without loss of generality, we assume that no two different existential variables share the same name). When we apply a rule B → H according to a homomorphism π, if H contains an existential variable z, then z is replaced in π saf e (H) by a fresh variable t. We say that t is generated and originates from z. When we apply a rule B → H according to a homomorphism π, if π maps a term of B to a generated variable that originates from z, and there is an existential variable z ′ in H, then we add an edge from z to z ′ in Evg(R).

Example 3.26 (MFA)

Consider the set of rules R composed of the single rule R = p(x, y) → q(y, z)∧p(z, t). Then Crit(R) = p( * , * ) ∧ q( * , * ). The two vertices of Evg(R) are z and t. With the first application of R on Crit(R), we add the atoms q( * , z 0 ) and p(z 0 , t 0 ), and add no edge to Evg(R), since the body of R is not mapped to any generated variable. With the second application of R (according to the homomorphism {x → z 0 , y → t 0 }), we add the atoms q(t 0 , z 1 ) and p(z 1 , t 1 ) to the set of facts, and add the edges (z, z), (z, t), (t, z) and (t, t) to Evg(R), which is now cyclic. Noe that the chase would actually be infinite.

A set of rules R is MFA when the frontier-restricted chase of Crit(R) w.r.t. R is finite and the corresponding existential variable graph does not contain any cycle. Hence, in the previous example R is not MFA. When R is MFA, Proposition 3.28 ensures that R is FES. Verifying if R is M F A is decidable: indeed, either the frontier-restricted chase is finite, or a cycle will be generated in Evg(R) in finite time.

Let R be a set of rules. Recognising if R is MFA is 2ExpTime-complete.

Proposition 3.29 ([GHK + 13])

Model Summarizing Acyclicity

When checking if a set of rules R is MSA, we also consider the critical instance Crit(R). Then we consider a set of rules M SA(R) which is built by replacing each rule R ∈ R by a rule M SA(R) in which each existential variable z is replaced by a fresh constant c z . As for MFA, we consider the graph Evg(R) in which vertices are existential variables in R. If an existential variable z has been replaced by a fresh constant c z , when c z appears in σ f r -chase(Crit(R), M SA(R)), we say that c z is generated and originates from z. Up to these modifications, edges are added to Evg(R) as for MFA.

Example 3.27 (MSA)

Consider again the set of rules R from Example 3.26, and its critical instance Crit(R). The set of rules M SA(R) contains the following single rule: M SA(R) = p(x, y) → q(y, c z ) ∧ p(c z , c t ). With the first application of M SA(R) on Crit(R) we add the atoms q( * , c z ) and p(c z , c t ), and we add no edge to Evg(R). With the second application, we add the atoms q(t z , c z ) ∧ p(t z , c z ) and the edges (z, z), (z, t), (t, z) and (t, t). Though the frontier-restricted chase is finite (as opposed to Example 3.26), R is not MSA because of these cycles.

A set of rules R is MSA if when running the frontier-restricted chase of Crit(R) w.r.t. M SA(R) we do not generate any cycle in Evg(R).

It has been shown in [GHK

+ 13] that if R is MSA then R is MFA. Example 3.28
shows that this inclusion is strict.

As intended, checking MSA is simpler than checking MFA.

Let R be a set of rules. Recognising if R is MSA is ExpTime-complete.

Proposition 3.30 ([GHK + 13])

Example 3.28 (MFA MSA) Consider the set of rules R composed of the following rules:

• R 1 = a(x) → r(x, u) ∧ b(u) • R 2 = b(x) → s(x, v) ∧ t(v, x) • R 3 = a(z) ∧ s(z, x) → c(x) • R 4 = c(z) ∧ t(z, x) → a(x)
The critical instance of R is the following:

Crit(R) = a( * ) ∧ b( * ) ∧ c( * ) ∧ r( * , * ) ∧ s( * , * ) ∧ t( * , * )
The vertices of Evg(R) are u and v. Let us check that R is MFA. At the first breadth-first step of the frontier-restricted chase, we apply R 1 and produce r( * , u 1 ) and b(u 1 ), and we apply R 2 and produce s( * , v 1 ) and t(v 1 , * ). No edge is generated in Evg(R). In the second breadth-first step, we apply R 2 and produce s(u 1 , v 2 ) and t(v 2 , u 1 ), adding the edge (u, v) to Evg(R). Then we apply R 3 and produce c(v 1 ), adding no edge.

The chase then halts, and therefore σ f r -chase(Crit(R), R) is finite. No cycle has been generated in Evg(R), thus R is MFA. Now we check that R is not MSA. The translation of the rules is the following:

• M SA(R 1 ) = a(x) → r(x, c u ) ∧ b(c u ) • M SA(R 2 ) = b(x) → s(x, c v ) ∧ t(c v , x) • M SA(R 3 ) = R 3 • M SA(R 4 ) = R 4
Vertices of Evg(R) are the same, and we consider the same critical instance as for MFA.

In the first breadth-first step, we apply R 1 and produce r( * , c u ) and b(c u ), and apply R 2 and produce s( * , c v ) and t(c v , * ). As for MFA, no edge is added to Evg(R) yet. During the second breadth-first step, we apply R 2 and produce s(c u , c v ) and t(c v , c u ), and we add the edge (u, v) to Evg(R). We also apply R 3 and produce c(c v ). Now, there is a third breadth-first step, in which we apply rule R 4 and produce a(c u ). Finally, in the fourth breadth-first step, we apply rule R 1 again, adding the atoms r(c u , c u ) and b(c u ), and creating the edge (u, u) in Evg(R), thus Evg(R) is cyclic. Thus, R is not MSA.

Extending Model Summarizing Acyclicity

We first point out that no marking for MFA is possible. Indeed our definition of marking function (Definition 3.28) relies on a "local" propagation, and MFA does not rely on local behaviour. However, we are able to "force" MSA into our definitions. Note that this definition is not natural, and is provided only to be able to handle MSA as the other acyclicity-based decidable rule classes.

Intuitively, the idea is to run the frontier-restricted chase on the critical instance Crit(R) with the modified set of rules M SA(R) as previously, but with the exception that we only add the atoms from rule applications that correspond to edges in P G X . Definition 3.45 (Model Summarizing Acyclicity Marking) Given a set of rules R, the MSA marking M of a position [a, i] in R with respect to some transition edge condition X is the marking obtained as follows.

First, consider the critical instance Crit(R) of R and translate R into M SA(R). Now, run a modified frontier-restricted chase, which, when applying a rule R = (B, H) according to a homomorphism π, adds each atom h ∈ π saf e (H) only if P G X (R) contains an edge from an atom h ′ in the head of a rule R ′ such that there is some b ∈ π(B) where b has been obtained from h ′ to the atom of H from which h is obtained. Then, the marking of an existential position [a, i] in which variable z occurs is the set of existential positions corresponding to the existential variables z ′ in Evg(R) such that there is a path from z to z ′ .

A set of rules R is MSA iff P G F (R) satisfies the acyclicity property associated with the MSA marking.

Proposition 3.31

Proof: In the case of P G F (R), all positions i in atoms a and b with the same predicate are linked. Thus the condition for adding a head atom in the MSA marking is always satisfied. Therefore, the frontier-restricted chase we run in the MSA marking is exactly the same as for MSA. Since the marking of each existential position [a, i] (with variable z) is exactly the set of direct or indirect successors of z in Evg(R), the marking of [a, i] contains [a, i] if and only if Evg(R) contains a cycle going through z. ✷

From the above proposition, Proposition 3.21 and Theorems 3.5 and 3.7, we know that

M SA ⊂ M SA D ⊂ M SA U ⊂ M SA U + .
Furthermore, it is easy to see that the complexity of recognition of these variants of MSA is still in ExpTime.

Given a set of rules R, checking that R satisfies M SA D , M SA U or M SA U + is in ExpTime.

Proposition 3.32

Proof: Checking MSA consists in running a Datalog engine while building the Evg(R) graph. Furthermore, we can build the P G X (for X = D, U or U + ) and we have shown in Theorem 3.9 that checking if an edge if present or not in this graph is in coN P . Membership to ExpT ime follows. ✷

Conclusion

In this chapter, we have first formally defined the notion of chase in a generic way. Since the CQ entailment problem is undecidable, the chase of a set of facts with respect to a set of rules may be infinite.

We have then recalled various sufficient syntactic conditions that ensure finiteness of some chase variant. Thanks to a new tool, we have rewritten all these conditions in a unified way, before extending them through a finer analysis of interactions between rules.

Furthermore, since we have abstracted from the details of each condition independently, our results will also carry over new acyclicity conditions, may they be found.

Finally, the (worst-case) complexity of recognition of these new generalisations is the same as either the original condition, or the rule dependency checking, providing larger rule classes at no additional cost. Known decidable classes of existential rules are able to express many useful properties of binary relations (for instance, inverses, symmetry,...), but most of them lack the ability to define a frequently required property, namely transitivity. This limits their applicability in key application areas like biology and medecine, for which transitivity of binary relations (especially the "part of" relation) is an essential modelling construct. Hence, in this chapter we investigate the following questions: is transitivity compatible with known decidable classes of existential rules? For the cases where the answer is positive, what is the complexity of the entailment problem?

D ja D swa D msa D wa U f d U ar U ja U swa U msa U wa U + f d U + ar U + ja U + swa U + msa U + mf a
To answer these questions, we first recall various positive and negative results from the litterature, in the context of both description logics and existential rules.

Our contribution is then twofold. On the one hand we provide a general undecidability result, which in particular allows us to clarify the landscape of FES rule classes. On the other hand, we devise an algorithm that shows that transitivity and linear existential rules (which are GBTS and FUS) are compatible up to a minor safety condition, and analyse the complexity of the CQ entailment problem in this case.

Let us first introduce some terminology: a predicate p is said to be transitive in a set of rules R if there is some rule R ∈ R, such that R = p(x, y) ∧ p(y, z) → p(x, z). Such a rule is called a transitivity rule. Furthermore, given a rule class C, we denote by C+trans, the rule class that contains all sets of rules that can be built from rules in C and transitivity rules. We extend this notation to knowledge-base and call a C+trans knowledge-base a knowledge-base where the set of rules belongs to the class C+trans. Finally, an atom using predicate p is called a p-atom.

Let us now explain intuitively why transitivity rules may be dangerous when added to a BTS or a FUS set of rules. With respect to BTS rules, adding transitivity may destroy the tree-like structure of the universal models. Indeed, transitivity rules may create links between vertices arbitrarily far away.

With respect to FUS rules, a single transitivity rule is enough to prevent the use of classical backward chaining algorithms: if an atom using a transitive predicate occurs at some point in a query rewriting, this atom can be rewritten into a path of unbounded length. Thus, FUS rules and transitivity may not be compatible (we show in Theorem 4.4 that, indeed, they are not).

Example 4.1 (Backward Chaining with Transitivity) Consider a Boolean conjunctive query Q = ∃x∃y(s(x) ∧ p(x, y) ∧ t(y)), that could be read as "is there an s and a t linked by a p". Now if we add the transitivity rule R = p(x, y) ∧ p(y, z) → p(x, z), the query could be read as "is there a path from an s to a t that goes only through p-atoms". If we rewrite Q with R, we obtain the following rewriting: Q 1 = s(x) ∧ p(x, z 0 ) ∧ p(z 0 , y) ∧ t(y), which is incomparable with Q. Then we can keep going by extending the length of the path, and obviously, we will not be able to rewrite Q with R into a (finite) UCQ.

The behaviour of transitivity regarding FES rules, is not that obvious, and we give later an almost complete picture of its effects on known FES classes.

Transitivity and BTS/FES rules

Overview of Known Results

While many decidable fragments of existential rules cannot express transitivity, this feature is offered by several description logics. As a matter of fact, adding transitivity to description logics often does not increase the complexity of conjunctive query entailment (exceptions are given in [START_REF] Eiter | Query answering in description logics with transitive roles[END_REF]). Though, it is known to complicate the design of query answering procedures due to the fact that it destroys the tree structure of the logical models upon which description logics reasoning algorithms typically rely.

More specifically, in [START_REF] Horrocks | A description logic with transitive and inverse roles and role hierarchies[END_REF], the description logic ALCH has been extended to allow for transitivity axioms. More recently, in [EOS + 12], the Horn-SHIQ description logic has been shown to be compatible with transitivity. While worst-case complexities are the same as without transitivity, the algorithms are more involved. We do not give details about the exact procedure since it would require to introduce many formal notions about description logics. It appears that these techniques heavily exploit the particular shape of DL axioms, hence do not seem to be translatable to existential rules.

At the beginning of our study (2014), little was known about combining existential rules and transitivity. Though, inclusion dependencies, which are a subclass of linear rules, and functional dependencies, which are known to "destroy" tree structures as transitivity rules do, were known to be incompatible [START_REF] Ashok | The implication problem for functional and inclusion dependencies is undecidable[END_REF].

In what follows, we recall various results from the literature which are all relative to the combination of GBTS rule classes with transitivity.

The first rule class of interest is that of guarded rules [CGK08, CGK13], which ensures that the chase of any set of facts with these rules has a tree-like shape.

Definition 4.1 (Guarded [CGK13])

A rule R = (B, H) is said to be guarded if its body contains an atom α such that for any variable x occurring in B, x appears in α (such an atom is called a guard). By extension, a set of rules is said to be guarded if all its rules are.

It has recently been shown that combining guarded rules with transitivity leads to undecidability, even under strong syntactic restrictions [START_REF] Gottlob | Querying the guarded fragment with transitivity[END_REF]. The theorem we state below is not exactly formulated as in this paper, but the restrictions we add can be easily derived from their proof. Atomic conjunctive query entailment over guarded+trans knowledge bases is undecidable, even when the guarded rules are restricted to the two-variable fragment of first-order logic, using only unary and binary predicates and only two transitive predicates.

Theorem 4.1 ([GPT13])

In their proof, they show that it is possible to simulate a Turing Machine with only guarded and transitivity rules: the guarded rules are used to implement the transition table, and to "draw" a grid, which corresponds to the space-time diagram of the Turing Machine tape. With guarded rules alone it is not possible to "reconnect" this grid, that is, if from a given cell c we consider the cell above the cell at the right of c, it is not the same as the cell which is at the right of the cell above c. This is where transitivity rules are used: they allow to reconnect correctly the grid. However, some positive results have also been achieved regarding a generalisation of guarded rules, namely frontier-guarded rules, provided that a restriction is fulfilled [START_REF] Amarilli | Query answering with transitive and linear-ordered data[END_REF]. Informally, in a frontier-guarded rule, the guard needs not to contain all the variables from the body, but only those occurring in the frontier. Definition 4.2 (Frontier-guarded [BLM10, BLMS11]) A rule R is said to be frontier-guarded if its body contains an atom α such that for any variable x in the frontier of R, x occurs in α. By extension, a set of rules is said to be frontier-guarded if all its rules are.

The class frontier-guarded+trans, and thus guarded+trans, with the restriction that no guard uses a transitive predicate, ensures the decidability of the CQ entailment problem, as stated in the next theorem.

Conjunctive query entailment over frontier-guarded+trans knowledge bases, where no guard uses a transitive predicate, is decidable.

Theorem 4.2 ([ABBV16])

Another specialisation of frontier-guarded rules is that of frontier-1, where the frontier of each rule must be of size lesser than one.

Definition 4.3 (Frontier-1 [BLMS11])

A rule R is said to be frontier-1 if |f r(R)| ≤ 1. By extension, a set of rules is said to be frontier-1 if all its rules are.

Entailment over frontier-1+trans knowledge bases has been recently proven to be decidable, without any restriction, as stated by the next theorem.

Conjunctive query entailment over frontier-1+trans knowledge bases is decidable and is 2ExpTime-complete in combined complexity and PTimecomplete in data complexity.

Theorem 4.3 ([ABBV16])

These results provide a first view of the landscape of known BTS rule classes, except for the case of linear rules. Before considering this case, we investigate the case of FES rules.

A General Undecidability Result

In the following, we show that FES+trans (hence BTS+trans) and FUS+trans is undecidable. More precisely, the next theorem states that aGRD+trans is undecidable even for atomic Boolean conjunctive queries. Since aGRD is both FES and FUS, this negative result holds for FES+trans and FUS+trans.

Atomic conjunctive query entailment over aGRD+trans knowledge bases is undecidable, even with a single transitivity rule.

Theorem 4.4

Proof: The proof is by reduction from atomic conjunctive query entailment with general existential rules (which is known to be undecidable, see Section 1.2). Let R be a set of rules. We first translate R into an aGRD set of rules R a . We consider the following new predicates: p (which will be the transitive predicate) and, for each rule R i ∈ R, predicates a i and b i . Each rule R i = (B i , H i ) is translated into the following two rules:

• R 1 i = B i → a i ( x, z 1 ) ∧ p(z 1 , z 2 ) ∧ p(z 2 , z 3 ) ∧ b i (z 3 ) • R 2 i = a i ( x, z 1 ) ∧ p(z 1 , z 2 ) ∧ b i (z 2 ) → H i
where z 1 ,z 2 and z 3 are existential variables and x are the variables in

B i . Let R a = {R 1 i , R 2 i | R i ∈ R}
, and let GRD(R a ) be the graph of rule dependencies of R a , defined as follows: the vertices of GRD(R a ) are in bijection with R a , and there is an edge from a vertex R 1 to a vertex R 2 if the rule R 2 depends on the rule R 1 , i.e., if there is a piece-unifier of the body of R 2 seen as a CQ with the head of R 1 (see Proposition 3.5).

We check that for any R i ∈ R, R 1 i has no outgoing edge and R 2 i has no incoming edge (indeed since the z j are existential variables, no piece-unifier exists). Hence, in GRD(R a ) all (directed) paths are of length less or equal to one. It follows that GRD(R a ) has no cycle, i.e., R a is aGRD.

Let R t be the rule stating that p is transitive. Let R ′ = R a ∪ {R t }. The idea is that R t allows to "reconnect" rules in R a that correspond to the same rule in R. For any set of facts F (on the original vocabulary), for any sequence of rule applications from F using rules in R, one can build a sequence of rule applications from F using rules from R ′ , and reciprocally, such that both sequences produce the same set of facts (restricted to atoms on the original vocabulary). Hence, for any F and Q (both on the original vocabulary), we have that

F, R |= Q iff F, R ′ |= Q. ✷
Atomic conjunctive query entailment over FUS+trans or FES+trans knowledge bases is undecidable.

Corollary 4.1

Clarifying the FES Landscape

In Chapter 3, we defined various acyclicity conditions divided into two families, based on the graph of rule dependencies and on graphs of positions respectively. Figure 4.1 recalls the relations between those classes: an edge going up from a rule class C to a rule class C ′ means that C is more specific than C ′ .

Since the members of the first family generalise aGRD, they are all incompatible with transitivity. Regarding the second family, super weak-acyclicity is one of its most general member, and one can check that adding transitivity rules to a super weakly-acyclic set of rules R does not create new cycles in the SWA graph of R, hence swa and swa+trans coincide as stated by the next proposition.

The classes super weak-acyclicity and super weak-acyclicity+trans coincide. Hence, entailment over super weak-acyclicity+trans knowledge bases is decidable.

Proposition 4.1 Proof: We do not recall the definition of super weak-acyclicity (see Definition 3.20).

Consider a super weakly-acyclic set of rules R, and suppose we let a predicate p be transitive with a rule R T = p(t 0 , t 1 ) ∧ p(t 1 , t 2 ) → p(t 0 , t 2 ). Now assume that R ∪ {R T } is not super weakly-acyclic. It means that there is a cycle in SWA(R ∪ {R T }) that is not present in SWA(R). In particular some new edge must have been added because of the transitive rule. Let us notice that this rule is represented as a vertex in SWA(R), but does not have any outgoing edge (indeed, only rules with existential variables may have outgoing edges). Therefore, this vertex is not used by any cycle. Hence, an edge must have been added between two rules from R, meaning that the addition of R T must have changed the "Move" set of some variable x. If M ove(x) covers t 0 (resp. t 2 ) then that atom position [p(t 0 , t 2 ), 1] (resp. [p(t 0 , t 2 ), 2]) also belongs to M ove(x). Furthermore, to cover t 0 (resp. t 2 ), M ove(x) must contain some atom position [p(x 0 , x 1 ), 1] (resp. [p(x 0 , x 1 ), 2]). Then, it can be observed that p(x 0 , x 1 ) and p(t 0 , t 2 ) are isomorphic; therefore, if there exists an atom q in some rule, and substitutions σ 1 , σ 2 such that σ 1 (q) = σ 2 (p(t 0 , t 2 )), then the substitution covered by M ove(x) in R. Hence the set of edges between rules from R in R ∪ {R T } is the same as in R. ✷

σ 3 = {x 0 → t 0 , x 1 → t 2 } • σ 2 is such that σ 1 (q) = σ 3 (p(x 0 , x 1 )). Therefore for any variable t from q such that In(t) is covered by M ove(x) in R ∪ {R T }, In(t) is also wa aGRD fd ar ja swa msa wa D f d D ar D ja D swa D msa D wa U f d U ar U ja U swa U msa U wa U + f d U + ar U + ja U + swa U + msa U + mf a
To complete the picture (see Figure 4.1), it remains to study the case of MSA, that generalises swa but not aGRD. We show below that MSA+trans is indeed undecidable even for atomic queries.

Atomic conjunctive query entailment over MSA+trans knowledge bases is undecidable, even with a single transitivity rule.

Theorem 4.5

Proof: The proof is by reduction from atomic conjunctive query entailment with general existential rules (which is known to be undecidable, see Section 1.2). Let F be a set of facts, R be a set of rules and Q be an atomic conjunctive query.

First we consider a new transitive predicate p, which is the only transitive predicate we use.

We rewrite F into F ′ as follows. For each term t ∈ terms(F), we add the atoms p(t, a t ) and p(a t , t) to F ′ , where a t is a fresh constant.

Then, we rewrite R into a MSA set of rules R m . For each rule R = B → H, we consider the rule R ′ = B ′ → H ′ obtained as follows. Its body B ′ is composed of the atoms of B as well as the atoms p(t, t) for each term t ∈ terms(B). Its head H ′ contains the atoms of H as well as two atoms p(z, x z ) and p(x z , z), where x z is a fresh variable, for each existential variable z in H.

We check that R m is MSA. Consider the set of rules M SA(R m ) as defined in Section 3.5.1 (i.e., each existential variable z in a rule head is replaced by a fresh constant c z ). If z is an existential variable of a rule R ∈ R, the head of the corresponding rule R ′ in R m contains the atoms p(z, x z ) and p(x z , z), and thus the head of M SA(R ′ ) contains the atoms p(c z , c xz ) and p(c xz , c z ). We point out that, during the chase, no term t in any rule body can be mapped to c z (because p(c z , c z ) will never appear). So the existential variable graph Evg(R) does not contain any edge. Thus R m is MSA. Now, let R T be the rule expressing the transitivity of p.

It is clear that (F, R) |= Q if and only if (F ′ , R m ∪ {R T }) |= Q.
We conclude that atomic conjunctive query entailment over MSA+trans knowledge bases is undecidable. ✷

These three results give us a clear picture of the combination of FES sets of rules with transitivity for all classes pictured in Figure 4.1. Indeed, either the class C generalises aGRD or MSA and entailment over C+trans knowledge-bases is undecidable even in the case of atomic queries, or C+trans = C.

In contrast, the behaviour of concrete FUS classes when combined with transitivity is still unknown (except for aGRD), and in the next section, we study the particular case of linear rules, a subclass of guarded rules, that also enjoys the FUS property.

Linear Rules and Transitivity

In this section we focus on combining transitivity with linear existential rules. We first recall the definition of linear rules. Without loss of generality (if the predicate arity is unbounded) we consider rules with atomic head and no constant, and to avoid any misunderstanding, the following definition takes this into account.

Definition 4.4 (Linear Rule) Given a rule R = (B, H), we say that R is a linear rule if |B| = |H| = 1, and R contains no constant. By extension, a set of rules is said to be linear if all its rules are.

Linear rules are a subclass of guarded rules, and as such, are BTS. Moreover they are FUS, and thus are typically handled through backward chaining. Unfortunately, transitivity rules immediately break this property, therefore classical query rewriting is not possible. However, in this section, we propose a rewriting algorithm, that does not produce a union of conjunctive queries, but a Datalog program (i.e., a finite set of Datalog rules added with a union of conjunctive queries). This algorithm shows that, up to a minor safety condition, entailment over linear+trans knowledge bases is decidable. We also point out that this restriction can be lifted if we only consider atomic conjunctive queries or binary predicates.

Framework

In order to obtain finite representations of sets of rewritings, we first define a framework based on the notion of pattern.

To each transitive predicate, we assign a pattern name. Each pattern name has an associated pattern definition P := a 1 | . . . |a k where each a i is an atom that contains the special variables #1 and #2. These variables are placeholders for the real terms that will occur in the set of atoms that use this pattern. A pattern is either a standard pattern, denoted by P [t 1 , t 2 ], or a repeatable pattern, denoted by P + [t 1 , t 2 ], where P is a pattern name, and t 1 and t 2 are terms.

Definition 4.5 (UPCQ and PCQ)

A union of patterned conjunctive queries (UPCQ) is a pair (Q, P), where Q is a disjunction of conjunctions of atoms and patterns, and P is a set of pattern definitions that gives a unique definition to each pattern name occurring in Q.

If there is a single conjunction of atoms Q ∈ Q, (Q, P) is simply called a patterned conjunctive query (PCQ).

Example 4.2 (UPCQ and PCQ)

The pair (Q, P) with

Q = Q 1 ∨ Q 2 , Q 1 = P + 1 [a, b] ∧ s 1 (a, b), Q 2 = P + 1 [a, z] ∧ P + 2 [z, b] ∧ s 1 (a, b)
, and where P contains the following pattern definitions:

• P 1 := p 1 (#1, #2)|s 2 (#1, y, #2) • P 2 := p 2 (#1, #2)|s 2 (#2, y, #1);
is a UPCQ. The pairs (Q 1 , P) and (Q 2 , P) are PCQs.

In the following we use three different styles to distinguish between a UPCQ (Q), a PCQ (Q) and a (U)CQ (Q). Furthermore, for the sake of simplicity, we will often denote a (U)PCQ by its first component Q, leaving the pattern definitions implicit.

With UPCQs, we are able to represent a set of rewritings in a compact way, but to this end, we first need to define the notion of an instantiation of a UPCQ. Definition 4.6 (Instantiation of a UPCQ) Given a UPCQ (Q, P), an instantiation T of (Q, P) is a rooted vertex-labelled tree that satisfies the following four conditions:

(i) the root of T if labelled by Q ∈ Q;

(ii) the children of the root are labelled by the patterns and atoms occurring in Q;

(iii) each vertex that is labelled by a repeatable pattern P + [t 1 , t 2 ] may be expanded into k ≥ 1 children labelled respectively by P [t 1 , x 1 ], P [x 1 , x 2 ], . . . , P [x k-1 , t 2 ] where all x i are fresh variables;

(iv) each vertex labelled by a standard pattern P [t 1 , t 2 ] may be expanded into a single child whose label is obtained from an atom in the pattern definition of P in P by substituting #1 (resp. #2) by t 1 (resp. t 2 ), and freshly renaming the other variables.

The instance associated with an instantiation is the PCQ obtained by taking the conjunction of its leaves. An instance of a UPCQ is an instance associated with one of its instantiations. We say that an instance is full when it does not contain any pattern, and we denote by f ull(Q, P) the set of all full instances of (Q, P).

Example 4.3 (Instantiations and instances)

Consider the UPCQ (Q, P) from Example 4.2. Figure 4.2 depicts a first possible instantiation T 1 of (Q, P) that gives rise to the (non-full) instance

Q 1 = P 1 [a, z] ∧ P 2 [z, x 1 ] ∧ P 2 [x 1 , b] ∧ s 1 (a, b).
Q 2 = s 2 (a, y 0 , z) ∧ s 2 (x 1 , y 1 , z) ∧ p 2 (x 1 , b) ∧ s 1 (a, b)
is a full instance of (Q, P). A UPCQ (Q, P) can be translated into a set of Datalog rules Π P and a UCQ Q Q as follows. For each definition P := a 1 ( t 1 )| . . . |a k ( t k ), we create the transitivity rule p + (x, y) ∧ p + (y, z) → p + (x, z) and the rules a i ( t i ) → p + (#1, #2). The UCQ Q Q is obtained from Q by replacing each repeatable pattern P + [t 1 , t 2 ] by the atom p + (t 1 , t 2 ). Observe that Π P is non-recursive except for the transitivity rules. Moreover, for any set of facts F, the saturation of F with Π P can be decomposed into two steps:

Q 2 P + 1 [a, z] P + 2 [z, b] s 1 (a, b) P 1 [a, z] P 2 [z, x 1 ] P 2 [x 1 , b]
Q 2 P + 1 [a, z] P + 2 [z, b] s 1 (a, b) P 1 [a, z] P 2 [z, x 1 ] P 2 [x 1 , b] s 2 (a, y 0 , z) s 2 (x 1 , y 1 , z) p 2 (x 1 , b)
1. Saturation with the rules of form a i ( t i ) → p + (#1, #2); 2. Saturation with the transitivity rules (i.e., computation of the transitive closure for each transitive predicate).

Note that these two steps only produce atoms with predicates p + .

Example 4.4 (Translation to Datalog and UCQ) Consider the UPCQ from Example 4.2. The pattern definitions are translated into the following rules:

• p 1 (#1, #2) → p + 1 (#1, #2)
be the obtained set of facts. Repeat this procedure for every vertex of T labelled by a repeatable pattern. Now the root of T is labelled by some Q ∈ Q. The UCQ Q Q contains a CQ Q that was obtained from Q by replacing each repeatable pattern P + [t 1 , t 2 ] by p + (t 1 , t 2 ). Observe that the restriction of π to the terms of Q is a homomorphism from Q to F ′′ . (⇒) Conversely, let us consider a set of facts F ′′ obtained by saturating the initial set of facts F with the rules of Π P , and a homomorphism π from some CQ Q ′ in the UCQ Q to F ′′ . Let us now build an instantiation T of (Q, P) whose full instance can be mapped to F thanks to a homomorphism π ′ . The root vertex of T is labelled by the PCQ Q in Q from which Q ′ was obtained. Its children are labelled by the atoms and patterns of Q. For all terms x from Q, we define π ′ (x) = π(x). Let us consider a child of the root labelled by a repeatable pattern P + [t, t ′ ]. It follows that p + (π(t), π(t ′ )) is an atom of F ′′ . Since this atom is not in the initial set of facts, it has been obtained either by a rule associated with a pattern definition or by a sequence of applications of the rule expressing the transitivity of p + . In this latter case, consider a path of p + -atoms π(t) = t 1 , . . . , t k = π(t ′ ) such that no atom p + (t i , t i+1 ) in F ′ has been obtained by a transitivity rule. Then the vertex labelled by P + [t, t ′ ] has k +1 children respectively labelled by

P [t = x 1 , x 2 ], . . . , P [x k-1 , x k = t ′ ].
For the fresh variables x 2 , . . . , x k-1 , we define π ′ (x i ) = t i . Repeat this procedure for every repeatable pattern in T . Let us next consider a vertex of T labelled by a standard pattern P [x, x ′ ]. Since that vertex was obtained in the previous phase, we know that the atom p + (π ′ (x), π ′ (x ′ )) is in F ′′ , and that it was not obtained from the application of a transitivity rule. Thus, the Datalog rule used to produce that atom is necessarily a rule obtained from the definition of the pattern P . Let r( t) → p + (#1, #2), where #1, #2 ∈ t, be that rule. According to that pattern definition, we can add to the vertex labelled by P [x, x ′ ] a child labelled by r(ρ( t)). Since the Datalog rule was applied according to a homomorphism π ′′ , we define, for every fresh variable ρ(t), π ′ (ρ(t)) = π ′′ (t). Do the same for every standard pattern of T . The instance associated with T is full, and π ′ is a homomorphism from this full instance to the initial set of facts F. ✷

We then extend the definition of piece-unifier (see Definition 1.29) to PCQs (and simply call it "unifier").

Definition 4.7 (Unifier)

A unifier µ = (Q ′ , H, P µ ) of a PCQ with a rule R = (B, H) is a single-piece unifier of one of its (possibly non-full) instances such that Q ′ is a set of (usual) atoms.

Note that since in this section we only consider atomic-headed rules, H is composed of a single atom. Furthermore, since we consider only single-piece unifiers, Q ′ is ensured to be connected, which will be important in the following proofs.

We distinguish between two types of unifiers (internal and external), defined next.

Let T be an instantiation whose associated instance is Q, and µ = (Q ′ , H, P µ ) be a unifier of Q with some rule R = (B, H). Assume T contains a repeatable pattern P + [t 1 , t 2 ] expanded into P [u 0 , u 1 ], . . . , P [u k , u k+1 ], where u 0 = t 1 and u k+1 = t 2 . We call P [u i , u i+1 ] relevant for µ if it is expanded into an atom from Q ′ . Because we consider only single-piece unifiers, it follows that if such relevant patterns exist, they form a "connected" sequence P [u i , u i+1 ], . . . , P [u j-1 , u j ]. Terms u i and u j are called external to P + [t 1 , t 2 ] with respect to µ; the other terms occurring in the sequence are called internal.

Definition 4.8 (Internal/External Unifier) Given a unifier µ = (Q ′ , H, P µ ) of a PCQ Q with some rule R = (B, H), we say that µ is internal if all atoms from Q ′ are expanded from a single repeatable pattern, and no external terms are unified together or with an existential variable; otherwise µ is called external.

Q 2 = s 2 (a, y 0 , z) ∧ s 2 (x 1 , y 1 , z) ∧ p 2 (x 1 , b) ∧ s 1 (a, b) from Example 4.
3 and the rules:

• R 1 = s 1 (x ′ , y ′ ) → p 2 (x ′ , y ′ ), • R 2 = s 1 (x ′ , y ′ ) → s 2 (x ′ , y ′ , z ′ ).
The unifier of Q 2 with R 1 that unifies p 2 (x 1 , b) with p 2 (x ′ , y ′ ) is internal; whereas the unifier of Q 2 with R 2 that unifies {s 2 (a, y 0 , z), s 2 (x 1 , y 1 , z)} with s 2 (x ′ , y ′ , z ′ ) is external because it involves two repeatable patterns.

We point out that when Q is composed only of usual atoms, i.e., its single (full) instance is the query itself, the notions of external unifiers and single piece-unifiers coincide since no pattern is involved.

It is crucial for the following to understand that unifiers of PCQs are not performed on the PCQs themselves but on instances of PCQs (actually, we will consider so-called "minimally-unifiable instances" which may not be "instances" strictly speaking but are still obtained by developing PCQs).

Hence, we distinguish between a "classical direct rewriting" of an instance of a PCQ (with respect to a single-piece unifier, which is a unifier of the PCQ), and a "direct rewriting" of a PCQ (with respect to an internal or external unifier), which involves selecting a particular instance and computing a classical direct rewriting of this instance.

Moreover, as detailed in the two next sections, internal and external unifiers will be used in two different ways. Internal unifiers will be used to rewrite pattern definitions: in this case, the considered PCQ will be the atomic query P + [x, y] for a pattern name P . Hence, this kind of rewriting will be performed independently from the actual input query, which will be rewritten using only external unifiers.

Finally, in order to later "ignore" some queries during the rewriting steps, we need a way to compare unifiers, and the next definition provide us such a tool. Definition 4.9 (Comparison between Unifiers) Given two unifiers µ 1 = (Q 1 , H, P µ 1 ) and µ 2 = (Q 2 , H, P µ 2 ), we say that µ 2 is more general than µ 1 , denoted by µ 2 ≥ µ 1 , if there is a substitution π from σ 2 (Q 2 ) to σ 1 (Q 1 ) such that h(σ 2 (Q 2 )) ⊆ σ 1 (Q 1 ) (i.e., π is a homomorphism from σ 2 (Q 2 ) to σ 1 (Q 1 )), and for all terms x and y in Q 2 ∪ H, if σ 2 (x) = σ 2 (y) then σ 1 (π(x)) = σ 1 (π(y)), where σ 1 and σ 2 are substitutions respectively associated with P µ 1 and P µ 2 .

Overview of the Algorithm

The framework being defined, we can now present the global algorithm, which takes as input a Boolean conjunctive query Q and a set of rules R = R L ∪ R T , where R L is a set of (atomic-headed) linear rules (with no constant), and R T a set of transitivity rules; and builds a finite set of Datalog rules and a (possibly infinite) set of conjunctive queries.

The main steps of the algorithm are outlined below. The notions of internal and external rewritings will be defined in the next section.

Step 1 For each predicate p that appears in R T , create a pattern definition P := p(#1, #2), where P is a fresh pattern name. The resulting set of definitions is called P 0 .

Step 2 Let R + L be the set of rules obtained from R L by replacing each body atom p(t 1 , t 2 ) in a rule such that p is a transitive predicate by the repeatable pattern

P + [t 1 , t 2 ].
Step 3 (Internal Rewriting) Initialise P to P 0 , and repeat the following operation until fixpoint: select a pattern definition P ∈ P and a rule R ∈ R + L and compute the direct rewriting of P with respect to P , R and an internal unifier.

Step 4 Replace in Q all atoms p(t 1 , t 2 ) such that p is a transitive predicate by the repeatable pattern P + [t 1 , t 2 ] and denote the result by Q + .

Step 5 (External Rewriting) Initialise Q to {Q + } and repeat the following operation until fixpoint: select Q i ∈ Q, compute a direct rewriting of Q i with respect to P, a rule from R + L and an external unifier; and add the result to Q if it is not isomorphic to some Q j ∈ Q.

Step 6 Let Π P be the Datalog translation of P and Q Q be the possibly infinite set of conjunctive queries obtained by replacing each repeatable pattern

P + [t 1 , t 2 ] in Q by p + (t 1 , t 2 ).
In a nutshell, Step 3 is always guaranteed to terminate, while Step 5 is not, however in Section 4.2.4, we propose a modification to Step 5 that ensures termination and formulate sufficient conditions that preserve completeness. When Q Q is finite (i.e., it is a UCQ), it can be evaluated over the set of facts saturated by Π P , or alternatively translated into a set of Datalog rules and passed to a Datalog engine for evaluation. Observe that the construction of Π P is query-independent and can be executed as a preprocessing step.

Rewriting Steps

A PCQ that contains a repeatable pattern has an infinite number of instances. Instead of considering all instances of a PCQ, we consider a finite set of "instances of interest" with respect to a given rule. Such instances will be used for both the internal and external rewriting steps. Definition 4.10 (Instantiation and Instance of Interest) Given a PCQ (Q, P) and rule R ∈ R + L with head predicate p, the instantiations of interest of (Q, P) w.r.t. R are constructed as follows. For each repeatable pattern

P + i [t 1 , t 2 ] in Q, let a i 1 , .
. . , a i n i be the atoms in the definition of P i with predicate p. If n i > 0, then expand P + i [t 1 , t 2 ] into k standard patterns, where 0 ≤ k ≤ min(arity(p), n i ) + 2, and expand each of these standard patterns in turn into some a i

ℓ . An instance of interest is the instance associated with an instantiation of interest.

Hence, in an instance of interest with respect to a rule with head predicate p, repeatable patterns with p-atoms occurring in their definitions may have been expanded into standard p-atoms. Since the aim is to unify this instance of interest with a p-atom from a rule head, only p-atoms from the pattern definitions are considered. The upper bound on the size of these instances of interest is explained in the proof of Proposition 4.3.

R 2 = s 1 (x ′ , y ′ ) → s 2 (x ′ , y ′ , z ′ ) from Example 4.5. The instance Q 2 associated with T 2 is not an instance of interest of Q 2 w.r.t. R 2 , since P 2 [x 1 , b] is expanded into p 2 (#1, #2) whereas the head predicate of R 2 is s 2 (see the pattern definition P 2 in Example 4.2). If we expand P 2 [x 1 , b] with s 2 (#2, y, #1) instead, we obtain the instance of interest Q 3 = s 2 (a, y 0 , z) ∧ s 2 (x 1 , y 1 , z) ∧ s 2 (b, y 2 , x 1 ) ∧ s 1 (a, b).
Note that while in this example, the instances of interest we build are full, it is not always the case, in particular it is possible to have an instantiation of interest that does not expand any repeatable pattern.

We next show that the set of unifiers computed on the instances of interest of a PCQ "captures" the set of unifiers associated with all its instances. Let (Q, P) be a PCQ and R ∈ R + L . For every instance Q of (Q, P) and unifier µ of Q with R, there exist an instance of interest Q ′ of (Q, P) w.r.t. R and a unifier µ ′ of Q ′ with R such that µ ′ is more general than µ.

Proposition 4.3

Proof: Let (Q, P) be a PCQ, R ∈ R + L be a rule with head p( t), Q be an instance of (Q, P), and µ = (Q 2 , p( t), P u ) be a unifier of Q with R.

Consider a repeatable pattern P + [t 1 , t 2 ] in the instantiation associated with Q from which some atoms in Q 2 are expanded. If P + [t 1 , t 2 ] is expanded into k ≤ arity(p) + 2 standard patterns in Q,1 then there is an instance of interest Q ′ that expands P + [t 1 , t 2 ] into exactly k standard patterns such that there is an isomorphism π between the atoms expanded under P + [t 1 , t 2 ] in Q and in Q ′ . Assume instead that P + [t 1 , t 2 ] is expanded in Q into k > arity(p) + 2 standard patterns. We denote by σ a substitution associated with P u , and by

P [t 1 = x 0 , x 1 ], P [x 1 , x 2 ], . . . , P [x k-2 , x k-1 ], P [x k-1 , x k = t 2 ]
the sequence of standard patterns expanded from P + [t 1 , t 2 ] in Q, and let x s and x e (s < e) be the external terms of P + [t 1 , t 2 ] w.r.t. µ. The unifier is single-piece, thus, for every s < i < e, σ(x i ) = σ(z i ) for some existential variable z i from the head of R.

We construct an instance of interest Q ′ and function π as follows. Starting from Q, we expand every repeatable pattern P + [t 1 , t 2 ] that is relevant for µ into es standard patterns (where e and s are defined as above and depend on the particular pattern):

P [t 1 = x ′ s , x ′ s+1 ], P [x ′ s+1 , x ′ s+2 ], . . . , P [x ′ e-1 ,
x ′ e = t 2 ]. Then for every s ≤ i ≤ e, we set π(x ′ i ) = x i , and we expand P [x ′ i , x ′ i+1 ] into the atom a ′ i that is obtained from the atom a i expanded under P [x i , x i+1 ] in Q by replacing every x j with x ′ j . If es ≤ arity(p) + 2, we are done. Otherwise, we will need to remove some standard patterns in order to satisfy the definition of instances of interest. To this end, we define a sequence s < i 1 < j 1 < • • • < i m < j m < e of indices as follows:

• We call i < j, with s < i < j < e, a matching pair in a i and in a j , x ′ i+1 and x ′ j occur at the same position of p (hence, σ(x i+1 ) = σ(x j ));

• We say that a matching pair i < j is maximal w.r.t. index ℓ if the following conditions hold:

-i ≥ ℓ,
-there is no matching pair i ′ < j ′ with ℓ ≤ i ′ < i a constant c, then the corresponding class C in P u will contain both z and c, i.e., C is not a valid class. Next suppose that C ′ contains a variable x that occurs in Q ′ \ Q ′ 2 , which means that the corresponding class C in P u contains π(x). Since x occurs in Q ′ \ Q ′ 2 , it must either appear in a standard atom of Q ′ that does not appear under any repeatable pattern or in a repeatable pattern that is not developed in Q ′ . In the former case, the same atom appears in Q \ Q 2 , and in the latter case, since Q is full, there is an atom in Q that is developed from the repeatable pattern and contains π(x), but which does not participate in Q 2 . In both cases, we obtain a contradiction.

Finally, we show that µ ′ is more general than µ:

• σ ′ (Q ′ 2 ) ⊆ σ(Q 2 ): proven above. • if σ ′ (u 1 ) = σ ′ (u 2
), then u 1 , u 2 belong to the same class in P ′ u , and so π(u 1 ) and π(u 2 ) must belong to the same class in P u .

We have thus shown that Q ′ is an instance of interest of (Q, P) w.r.t. R such that there is a unifier µ ′ of Q ′ with R with µ ′ ≥ µ. ✷

Rewriting with respect to internal unifiers is performed "inside" a repeatable pattern, independently from the other patterns and atoms in the query. We will therefore handle this kind of rewriting in a query-independent manner by updating the pattern definitions.

To find all internal unifiers of instances under a repeatable pattern P + [t 1 , t 2 ] with a rule head H = p( x), one may think that it is sufficient to consider each atom a i in P 's definition and check if there is an internal unifier of a i with H. Indeed, this suffices when predicates are binary: in an internal unifier, t 1 and t 2 are unified with distinct variables, which cannot be existential; thus, the variables in H are frontier variables, and a piece necessarily consists of a single atom. However, if the arity of p is greater than 2, the other variables can be existential, so it may be possible to unify a path of atoms from P 's definition, while it is not for a single atom. The next example illustrates this case.

Example 4.7 Let R = s(x, y) → r(z 1 , x, z 2 , y) be a rule and

P := r(#2, #1, x 0 , x 1 )|r(#1, x 2 , #2, x 3 )|r(x 4 , x 5 , #1, #2)
be a pattern definition. There is no internal unifier of an atom in P 's definition with H = r(z 1 , x, z 2 , y), since in all cases t 1 or t 2 is unified with an existential variable. However, if we expand P + [t 1 , t 2 ] into a path P [t 1 , y 0 ], P [y 0 , y 1 ], P [y 1 , t 2 ], then expand each i th pattern of this path into the i th atom in P 's definition, the resulting instance r(y 0 , t 1 , x 0 , x 1 ), r(y 0 , x 2 , y 1 , x 3 ), r(x 4 , x 5 , y 1 , t 2 ) can be unified with H by an internal unifier with the following partition: {{z 1 , y 0 , x 4 }, {x, t 1 , x 2 , x 5 }, {z 2 , x 0 , y 1 }, {y, x 1 , x 3 , t 2 }} Fortunately, we can bound the length of paths to be considered using both the arity of the predicate p and the number of atoms with predicate p in P 's definition, allowing us to use the instances of interest defined earlier.

Definition 4.11 (Internal Direct Rewriting) An (internal) direct rewriting P ′ of a set of pattern definitions P w.r.t. a pattern name P and a rule R = (B, H) ∈ R + L is the set of pattern definitions obtained from P by updating P 's definition as follows. We consider the PCQ (Q = P + [x, y], P). We select an instance of interest Q of Q w.r.t. R, an internal unifier µ of Q with H, and a substitution σ associated with µ that preserves the external terms. Let B ′ be obtained from σ(B) by substituting the first (resp. second) external term by #1 (resp. #2). If B ′ is an atom, we add it to P 's definition. Otherwise, B ′ is a repeatable pattern of the form S + [#1, #2] or S + [#2, #1]. Let f be the bijection on {#1, #2} defined as follows: if B ′ is of the form S + [#1, #2], f is the identity, otherwise f permutes #1 and #2. For all atoms s i in the definition of S, we add f (s i ) to P 's definition.

Note that the addition of an atom to a pattern definition is up to isomorphism (with #1 and #2 treated as distinguished variables, i.e., #1 and #2 are mapped to themselves).

The following example illustrates Step 3 of the algorithm.

Example 4.8 Assume R + L contains the following rules:

• R 1 : P + 2 [x, y] → s 1 (x, y)

• R 2 : s 1 (x, y) → p 1 (x, y)

• R 3 : s 2 (x, y) → p 2 (y, x)

• R 4 :

P + 1 [x, y] → p 2 (y, x)
Note that the transitive predicates p 1 and p 2 are recursive. Also, since rules contain no existential variable, each single-piece unifier unifies a single atom from the queries P + 1 [x, y] and P + 2 [x, y], therefore the only useful instances of interest have a single atom.

Starting from P = P 0 the following set of pattern definitions:

• P 1 := p 1 (#1, #2) • P 2 := p 2 (#1, #2)
the computations of Step 3 may, for instance, be decomposed as follows:

1. P 1 is rewritten with R 2 and P 2 with R 3 obtaining the following definitions:

• P 1 := p 1 (#1, #2) | s 1 (#1, #2) • P 2 := p 2 (#1, #2) | s 2 (#2, #1)
2. P 1 is rewritten with R 1 , which leads to "copy" the definition of P 2 into that of P 1 :

• P 1 := p 1 (#1, #2) | s 1 (#1, #2) | p 2 (#1, #2) | s 2 (#2, #1) • P 2 := p 2 (#1, #2) | s 2 (#2, #1)
3. P 2 is rewritten with R 4 which leads to copy the definition of P 1 into that of P 2 (with f permuting #1 and #2):

• P 1 := p 1 (#1, #2) | s 1 (#1, #2) | p 2 (#1, #2) | s 2 (#2, #1) • P 2 := p 2 (#1, #2) | s 2 (#2, #1) | p 1 (#2, #1) | s 1 (#2, #1) | p 2 (#2, #1) | s 2 (#1, #2)
4. P 1 can be enriched again, which leads in turn to enrich P 2 and we finally obtain the same definitions for P 1 and P 2 :

• P 1 := p 1 (#1, #2) | s 1 (#1, #2) | p 2 (#1, #2) | s 2 (#2, #1) | p 1 (#2, #1) | s 1 (#2, #1) | p 2 (#2, #1) | s 2 (#1, #2) • P 2 = P 1
Let (Q, P) be a PCQ where a repeatable pattern P + [t 1 , t 2 ] occurs and R ∈ R + L . For any instance Q of (Q, P), any classical direct rewriting Q ′ of Q with R w.r.t. a unifier internal to P + [t 1 , t 2 ], and any Q ′ ∈ f ull(Q ′ , P), there exists a direct rewriting P ′ of P w.r.t. P and R such that (Q, P ′ ) has a full instance that is isomorphic to Q ′ .

Proposition 4.4

Proof: Let (Q, P) be a PCQ where P + [t 1 , t 2 ] occurs, R = (B, H) ∈ R + L , Q be an instance of (Q, P), µ = (Q 2 , H, P u ) be a unifier internal to P + [t 1 , t 2 ] of Q with R, Q ′ be the classical direct rewriting of Q with R w.r.t. µ, and Q ′ be a full instance of (Q ′ , P).

Since µ is internal to P + [t 1 , t 2 ], all atoms in Q 2 are expanded from P + [t 1 , t 2 ] in Q, and do not unify t 1 with t 2 , nor t 1 (resp. t 2 ) with an existential variable from H. We denote by P [t 1 = x 0 , x 1 ], P [x 1 , x 2 ], . . . , P [x k-1 , x k = t 2 ] the sequence of standard patterns expanded under P + [t 1 , t 2 ] in Q, x s and x e (s < e) the external terms of P + [t 1 , t 2 ] w.r.t. µ, and a i the atom expanded under P [x i , x i+1 ]. From Proposition 4.3, there is a unifier µ ′ of an instance of interest Q 3 of Q with R with µ ′ ≥ µ. Since x s and x e are not unified with existential variables, let Q 4 be the CQ obtained from

• Q 2 = P + 1 [a, b]∧ s 1 (b, y ′ )∧ ∧ s 1 (a, b) • Q ′ 3 = s 1 (a, y ′ )∧ P + 2 [a, b]∧ s 1 (a, b)
Let (Q, P) be a PCQ and R ∈ R + L . For every Q ∈ f ull(Q, P) and every classical direct rewriting Q ′ of Q with R w.r.t. an external unifier, there is a direct rewriting Q ′ of Q w.r.t. P and R that has an instance isomorphic to Q ′ . Proposition 4.5

Proof: Let (Q, P) be a PCQ, R = (B, H) ∈ R + L , Q ∈ f ull(Q, P), µ = (Q u , H, P u ) be an external unifier of Q with R, and Q ′ be the classical direct rewriting of Q with R w.r.t. µ.
From Proposition 4.3, there is an instance of interest Q 2 of (Q, P) such that there is a unifier µ ′ = (Q u ′ , H, P u ′ ) ≥ µ of Q 2 with R. We denote by σ (resp. σ ′ ) a substitution associated with µ (resp. µ ′ ).

For any repeatable pattern P + [t 1 , t 2 ] in Q, build A, A l , A m and A r as in the proof of Proposition 4.4 using the instance Q 2 and unifier µ ′ . Assume t 1 (or t 2 ) is unified with an existential variable, then from the condition on external unifiers, A l (or A r ) is empty. Consider the minimally-unifiable instance

Q M of Q w.r.t. µ ′ that replaces P + [t 1 , t 2 ] by: (i) A m if A l = A r = ∅; (ii) P + [t 1 , x s ], A m if A r = ∅ and A l = ∅; or (iii) A m , P + [x e , t 2 ] if A l = ∅ and A r = ∅.
In case (ii) (resp. (iii)), since no atom in A l (resp. A r ) is involved in µ ′ , x s (resp. x e ) is not unified with an existential variable (or the piece condition on unifiers would not be satisfied). Therefore, µ ′ is a unifier of Q M with R. We let Q ′ be the direct rewriting of Q M w.r.t. µ ′ and R.

Note that each repeatable pattern P + [t 1 , t 2 ] in Q ′ expands into A l ∧ σ(B) ∧ A r , and in Q ′ there is a P + [t 1 , x s ] (resp. P + [x e , t 2 ]) iff A l (resp. A r ) is not empty. Thus consider Q ′′ obtained from Q ′ by expanding P + [t 1 , x s ] (resp. P + [x e , t 2 ]) into k standard patterns where k = |A l | (resp. k = |A r |), and choose the same atoms as in A ′ l (resp. A ′ r ). Since µ ′ ≥ µ, there is a homomorphism π from σ ′ (Q u ′ ) to σ(Q u ). Note that if we restrict the domain of π to terms in σ ′ (B), π is an isomorphism. Furthermore, we can extend the domain ofπ to Q ′′ in the same way as we did in the previous proof. Thus Q ′′ is isomorphic to Q ′ . ✷

Termination and Correctness

Our algorithm, while not being guaranteed to terminate, is correct: indeed, if the query Q is entailed by the knowledge base then the algorithm produces a set of Datalog rules Π P (always finite) and a CQ Q ′ (from a possibly infinite set Q Q ) such that the evaluation of Π P ∪ {Q ′ } (as a Datalog query) on the set of facts yields a positive answer, and reciprocally, as precisely stated by the next theorem.

[u = x 0 , x 1 ], . . . , P [x k-1 , x k = v] be the children of P + [u, v] in Q ′
, and a ℓ be the atom expanded under P [x ℓ , x ℓ+1 ] (0 ≤ ℓ < k). In place of the child

P + i [u, v] in Q + , we will add k children to P + i [t 1 , t 2 ] in Q ′′ : P i [u = x 0 , x 1 ], . . . , P i [x k-1 , x k = v],
and expand P i [x j , x j+1 ] into a j . Note that we may assume that the terms x i (0 < i < k) are fresh, i.e., they do not already appear in Q ′′ .

It can be verified that the resulting full instance Q ′′ is isomorphic to Q ′ . Indeed, all atoms in Q ′ that are also in Q are present in Q ′′ . All other atoms belong to a sequence of transitive atoms, which we have reproduced (up to renaming of variables) in Q ′′ . ✷

Let Q be a CQ and R be a set of linear+trans rules, and let (Q, P) be the output of the algorithm. For any Q ′ obtained from a sequence of classical direct rewritings of Q with R, there is a PCQ (Q, P) with Q ∈ Q and a full instance

Q ′′ of (Q, P) such that Q ′′ is isomorphic to Q ′ . Lemma 4.3 Proof: Let Q = Q 0 , µ 1 , Q 1 , µ 2 , Q 2 , . . . , µ k , Q k = Q ′ be a sequence of classical direct rewritings from Q to Q ′ ,
and let R 1 , . . . , R k be the associated sequence of rules from R.

We show the desired property, by induction on 0 ≤ i ≤ k. For the base case (i = 0), we can set

Q 0 = Q + , since Q 0 = Q is clearly a full instance of (Q 0 , P).
For the induction step, suppose that we have

Q i-1 ∈ Q and a full instance Q ′′ i-1 of (Q i-1 , P) that is isomorphic to the CQ Q i-1 .
There are two cases to consider, depending on the type of the rule R i . If R i is a transitivity rule, then from Lemma 4.1, we know that Q + i-1 (obtained from Q i-1 by replacing every transitive predicate p by pattern P + ) is such that there is a full instance Q + i-1 of (Q + i-1 , P) that is isomorphic to Q i . Furthermore, we know that Q i-1 cannot contain any standard atom with a transitive predicate, since every PCQ produced in Step 5 contains patterns for the transitive predicates. Thus, we may apply Lemma 4.2 and infer that Q

+ i-1 is isomorphic to some full instance Q ′′ i-1 of (Q i-1 , P). Therefore, Q ′′ i-1 is isomorphic to Q i . If R i is not a transitive rule, since Q i-1 is isomorphic to some full instance Q ′′ i-1 of (Q i-1 , P), let µ ′′ i be the unifier of Q ′′ i-1 with R i obtained from µ i and the isomorphism between Q i-1 and Q ′′ i-1 . If µ ′′
i is internal to some repeatable pattern, then from Proposition 4.4, we know that there is an instance Q ′ i of (Q i-1 , P) that is isomorphic to Q i . Otherwise, from Proposition 4.5, there exist µ ′ i and a direct rewriting

Q i of Q i-1 with µ ′ i such that there is an instance Q ′ i of (Q i , P) that is isomorphic to Q i .
We have thus completed the inductive argument and can conclude that there is a PCQ (Q, P) with Q ∈ Q and a full instance

Q ′′ of (Q, P) such that Q ′′ is isomorphic to Q ′ = Q k . ✷
Let Q be a CQ, (F, R) be a linear+trans KB, and (Π P ,Q Q ) be the output of the algorithm.

If (F, R) |= Q then (F, Π P ) |= Q ′ for some Q ′ ∈ Q Q . Lemma 4.4 Proof: Since (F, R) |= Q, there is a (finite) classical rewriting Q ′ of Q with R such that F |= Q ′ . From Lemma 4.3, there is a PCQ (Q, P) with Q ∈ Q and a full instance Q ′′ of (Q, P) such that Q ′′ is isomorphic to Q ′ . Therefore, F |= Q ′′ .
Claim 4.1 If F, Π P |= Q ++ , then F, R |= Q.
Proof of claim. Let P 0 , P 1 , . . . , P k = P be the sequence of sets of pattern definitions that led to P in Step 3, with P i+1 being obtained from P i by a single direct (internal) rewriting step. We prove by induction two distinct properties expressed at rank 0 ≤ j ≤ k:

P1 every rule in Π P j is a semantic consequence of Π P 0 ∪ R.

P2 for every set of facts F ′ and CQ Q ′ (over the original vocabulary):

F ′ , Π P j |= (Q ′ ) ++ ⇒ F ′ , R |= Q ′
In the second property, (Q ′ ) ++ denotes the CQ obtained by replacing every atom p(t 1 , t 2 ) such that p is transitive by the atom p + (t 1 , t 2 ). Observe that P2 at rank k yields the claim: we simply take F ′ = F and Q ′ = Q.

Base case (i = 0): property P1 is obviously verified. For property P2, we note that P 0 consists of the following rules for every transitive predicate p: the transitivity rule p + (x, y) ∧ p + (y, z) → p + (x, z) and the initialization rule p(x, y) → p + (x, y). Clearly, if F, Π P 0 |= (Q ′ ) ++ , then we have F, R |= Q ′ , since if we can derive p + (a, b) using F, Π P 0 , then we can also derive p(a, b) from F, R using the transitivity rule for p in R.

Induction step for P1: we assume property P1 holds for some rank 0 ≤ i < k and show that it holds also for i + 1.

Suppose that P i+1 is obtained from P i by a single direct rewriting step w.r.t. pattern name P and the rule R

= B → H ∈ R + L . Let Q = P + [x, y], Q be the considered instance of interest of Q w.r.t. R, µ = (Q ′ ,
H, P u ) be the considered internal unifier of Q with H, and σ be the considered substitution associated with µ that preserves the external terms. Finally, let B ′ be obtained from σ(B) by substituting the first (resp. second) external term by #1 (resp. #2).

Since we know that µ is an internal unifier, the external terms of Q ′ cannot be unified together or with an existential variable. Thus by considering Q ′′ and P u ′ obtained from Q ′ and P u by substituting the first (resp. second) external term by #1 (resp. #2), it is clear that µ ′ = (Q ′′ , H, P u ′ ) is a unifier of Q ′′ with R such that σ ′ (B) = B ′ , where σ ′ is the substitution associated with µ ′ that preserves the special terms #1 and #2.

We consider two cases depending on the nature of B ′ .

Case 1: The first possibility is that B ′ is an atom (as opposed to a repeatable pattern), in which case we add the following rule to Π P i :

B ′ → p + (#1, #2).
Let a 1 , . . . , a k be the atoms of Q ′′ , and let a ′ j be the atom in P 's definition from which a j is obtained. Since there is a rewriting of {a j | 0 < j ≤ k} with R into B ′ (using the unifier µ ′ ), and the rule R appears in the original set of rules R, it follows that

R |= B ′ → a 1 ∧ • • • ∧ a k
From the induction hypothesis, we know that the rules a ′ j → p + (#1, #2) (0 < j ≤ k) are entailed by Π P 0 , R. We also know that for all 1 < j ≤ k, the atoms a j-1 and a j share a variable corresponding respectively to #2 in a ′ j-1 and to #1 in a ′ j . Thus, by applying the rules a

′ j → p + (#1, #2) (0 < j ≤ k) to the conjunction a 1 ∧ • • • ∧ a k , we obtain p + (#1, x 1 ) ∧ p + (x 1 , x 2 ) ∧ • • • ∧ p + (x k-1 , #2)
. Hence:

Π P 0 , R |= k j=0 a j → p + (#1, x 1 ) ∧ p + (x 1 , x 2 ) ∧ • • • ∧ p + (x k-1 , #2)
Since Π P 0 contains a transitivity rule for p + , we can further infer that

Π P 0 |= p + (x 1 , x 2 ) ∧ • • • ∧ p + (x k-1 , #2) → p + (#1, #2)
By chaining together the preceding entailments, we obtain Π P 0 , R |= (B ′ → p + (#1, #2)), as desired.

Case 2: The other possibility is that B ′ is a repeatable pattern of the form

S + [#1, #2] or S + [#2, #1]. Let f be a bijection on {#1, #2}: if B ′ is of the form S + [#1, #2],
f is the identity, otherwise f permutes #1 and #2. Then for all s ℓ in the definition of S, we add f (s ℓ ) to P 's definition, and we add the corresponding rules f (s ℓ ) → p + (#1, #2) to Π P i . Consider one such rule rule f (s ℓ ) → p + (#1, #2). Let a 1 , . . . , a k and a ′ 1 , . . . , a ′ k be defined as in Case 1. Since there is a rewriting of {a j | 0 < j ≤ k} with R ∈ R + L into B ′ , and since the rule R was obtained from a rule R ′ in R by replacing the transitive predicate s in the rule head by the repeatable pattern S + , it follows that

R |= f (s(#1, #2)) → a 1 ∧ • • • ∧ a k
Arguing as in Case 1, we obtain

Π P 0 , R |= f (s(#1, #2)) → p + (#1, #2)
From the induction hypothesis, we know that that the rules s ℓ → s + (#1, #2) are entailed from Π P 0 , R, and the same obviously holds for the rules f (s ℓ ) → f (s + (#1, #2)). By combining the preceding entailments, we obtain Π P 0 , R |= f (s ℓ ) → p + (#1, #2).

Induction step for property P2: we assume P2 holds for some rank 0 ≤ i < k and show that it holds also for i + 1.

Suppose now that F ′ , Π P i+1 |= (Q ′ ) ++ , for some set of facts F ′ and CQ Q ′ (over the original predicates). This means that there is a finite derivation sequence

F ′ = F ++ 0 , . . . , F ++ m such that F ++ m |= (Q ′ ) ++ and such that for all 0 ≤ ℓ < m, F ++ ℓ+1 is obtained from F ++ ℓ either (
i) by a sequence of applications of rules from Π P i or (ii) by a sequence of applications of rules from Π P i+1 \ Π P i .

In case (i), we have F ++ ℓ , Π P i |= F ℓ+1 ++ . Letting F r be the set of facts obtained by replacing every predicate p + in F ++ r by the corresponding predicate p, and recalling that Π P i contains the rule p(x, y) → p + (x, y), we have F ℓ , Π P i |= F ++ ℓ+1 . Applying the induction hypothesis (treating F ++ ℓ+1 as a CQ), we obtain F ℓ , R |= F ℓ+1 . In case (ii), we have F ++ ℓ , (Π P i+1 \ Π P i ) |= F ++ ℓ+1 . From property P1, we obtain F ++ ℓ , Π P 0 , R |= F ++ ℓ+1 . Using the rule p(x, y) → p + (x, y) (that is present in Π P 0 ), the latter yields F ℓ , Π P 0 , R |= F ++ ℓ+1 . Finally, we note that if we can derive p + (a, b) from F ℓ , Π P 0 , R, then we can also infer p(a, b) from F ℓ , R by using the transitivity rule for p instead of using p(x, y) → p + (x, y) and the transitivity rule for p + . Thus, we have F ℓ , R |= F ℓ+1 .

We have thus shown that for every 0 ≤ ℓ < m, F ℓ , R |= F ℓ+1 . Since F ′ = F 0 , by chaining these implications together, we obtain F ′ , R |= F m . Using the same reasoning as above, we can infer

F m |= Q ′ from F ++ m |= (Q ′ ) ++ .
Then, by combining these statements, we obtain F ′ , R |= Q ′ . (end proof of claim) Now let Q be the set of queries computed in Step 5 by performing all possible external direct rewritings w.r.t. P and rules from R + L , starting from Q + , and let Q Q be the set of CQs associated with Q (defined as in Step 6). We start by proving the following claim, which relates external direct rewriting steps to sequences of classical direct rewritings.

Claim 4.2 Let Q i+1 be a direct rewriting of Q i w.r.t. P. Then every full instance of (Q i+1 , P) is obtained from a sequence of (classical) direct rewritings of some full instance of (Q i , P).

Proof of claim. Let (Q i+1 , P) be obtained from an external rewriting of (Q i , P) with rule R = B → H. This means that there is a minimally unifiable instance Q e and a unifier µ = (X, H, P u ) of Q e with H (with associated substitution σ) such that

Q i+1 = σ(Q e \ X) ∪ σ(B).
Let us consider a partial instance Q P i+1 of (Q i+1 , P) that fully instantiates σ(Q e \ X) but does not instantiate σ(B) (we say that it is a σ(B)excluding instance). Note that Q P i+1 can be built equivalently by choosing a full instance Q e of (Q e , P), removing the atoms of X, then by applying the substitution σ and adding σ(B). We can see that the classical direct rewriting of Q e according to µ produces Q P i+1 . Moreover, since every full instance of (Q e , P) is a full instance of (Q i , P), we know that Q e is an instance of (Q i , P). Now consider any full instance Q i+1 of (Q i+1 , P). Note that it is a full instance of some σ(B)-excluding instance (Q P i+1 , P). There are two cases to consider:

• If σ(B) is an atom, then Q i+1 = Q P i+1
and thus Q i+1 is obtained from a classical direct rewriting of an instance of (Q i , P).

• Otherwise, if σ(B) is a repeatable pattern, then Q i+1 is obtained from (Q P i+1 , P) by expanding σ(B) into a sequence of k standard patterns, and expanding each of them into some atom a ℓ . Let B k = {a ℓ | 1 ≤ ℓ ≤ k}. Then, σ(B) is generated in forward chaining from B k with a sequence of applications of rules: k applications of transitivity rules, and k applications of the rules encoded in P, each one stemming from a finite sequence of applications of rules of R (see Claim 4.1). Thus from the completeness of classical rewriting, B k can be obtained from a sequence of classical direct rewritings from σ(B), and thus Q i+1 is obtained from a sequence of classical direct rewritings of an instance of (Q i , P).

1. Q ′ is composed of atoms expanded from a single repeatable pattern P + [t 1 , t 2 ], σ µ ′ (t 1 ) = σ µ ′ (t 2 ), and P + [t 1 , t 2 ] is replaced as in case (i), (ii) or (iii).

2. Q ′ is completely obtained from the expansion of one or more repeatable patterns (i.e., there is no standard atom involved in the unifier), a term t of Q is unified with an existential variable of the head of the rule, t appears only in repeatable patterns of the form P + i [t i , t] (resp. P + i [t, t i ]), and all these repeatable patterns are rewritten as in case (ii)

P + i [t i , t ′ i ] ∧ X[t ′ i , t] (resp. as in case (iii) X[t, t ′ i ] ∧ P + i [t ′ i , t i ]).
Note that in Point 2, we need not to exclude rewritings in which Q ′ contains at least one standard atom, since such atoms will be erased by the rewriting process.

We call a direct rewriting excluded if it is based on such a minimally-unifiable instance; otherwise, it is non-excluded.

Example 4.10

The rewriting Q ′ 1 from Example 4.9 is excluded because it is obtained from the minimally-unifiable instance Q 1 in which the repeatable pattern P + 1 [a, z] is expanded as in case (ii) and P + 2 [z, b] as in case (iii), and z is unified with the existential variable z ′ .

In the following we first show that using only non-excluded direct rewritings ensures termination (Proposition 4.6). Then, we show that ignoring direct rewritings based on a minimally-unifiable instance as in Point 1 never compromises the completeness of our algorithm. Indeed the query obtained is always more specific than the rewritten query (Lemma 4.6). Finally, we show that under a safety condition, ignoring the direct rewritings based on a minimally-unifiable instance as in Point 2 also preserves completeness (Lemma 4.7).

Let (Q, P) be a PCQ and

R ∈ R + L . If Q ′ is a non-excluded direct rewriting of Q with R, then |Q ′ | ≤ |Q|. Proposition 4.6 Proof: Let (Q, P) be a PCQ, R = (B, H) ∈ R +
L , Q be a non-excluded minimallyunifiable instance of (Q, P), µ = (Q ′ , H, P µ ) be an external unifier of Q with R, and σ µ be a substitution induced by P u .

Note that all repeatable patterns P + [t 1 , t 2 ] are either untouched by the unifier, or replaced by the sequence X needed by the unifier (i.e., X ⊆ Q ′ ), plus potentially a single repeatable pattern P + [t 1 , x 1 ] (or P + [x k , t 2 ]). Indeed, the only situation that would lead us to introduce more than one repeatable pattern (i.e., as in External Rewriting case (i)) is when either t 1 or t 2 is unified with an existential variable.

However, if t 1 (or t 2 ) is unified with an existential variable, because of the piece condition on unifiers, no unifier of P + [t 1 , x 1 ] ∧ X ∧ P + [x k , t 2 ] can be found.

Since |B| = 1, we have to show that all atoms that were introduced when replacing a repeatable pattern are erased by the direct rewriting of Q w.r.t. µ.

If Q ′ consists of at least one atom that is not expanded from a pattern, the direct rewriting of Q w.r.t. µ erases this atom as well as the X sequence.

Next assume Q ′ consists only of atoms expanded from repeatable patterns. If Q ′ = {P + [t 1 , t 2 ]} and neither t 1 nor t 2 is unified with an existential variable, then σ µ (t 1 ) = σ µ (t 2 ), so the only non-excluded minimally-unifiable instance of Q w.r.t. µ replaces P + [t 1 , t 2 ] only by the sequence X needed by the unifier (see the first condition on non-excluded minimally-unifiable instances). Thus, the direct rewriting erases

P + [t 1 , t 2 ].
Otherwise, we know that at least one P + [t 1 , t 2 ] from Q is replaced by the sequence X involved in the unifier (see the second condition on non-excluded minimallyunifiable instances), thus there is at least one P + [t 1 , t 2 ] erased by the direct rewriting. ✷

Let us consider the "modified query rewriting algorithm" that is obtained by only performing non-excluded direct rewritings in Step 5 (External Rewriting). This modification ensures termination but may comprise completeness. However, we can show that the modified algorithm is complete in the following key cases: when the conjunctive query is atomic, when there is no specialisation of a transitive predicate, or when all predicates have arity at most two. These cases rely on the following different observations. In the first case, completeness cannot be compromise since there is a single problematic case detailed in Lemma 4.7, and it cannot happen for atomic query since it involves two different repeatable patterns. In the second case, there is no rewriting of transitive atoms. Finally in the third case, the external terms t 1 and t 2 from each repeatable pattern are always unified together, ensuring that for each excluded rewriting, the obtained PCQ is more specific than the rewritten query. By further analyzing the latter case, we can formulate a safety condition, defined next, that guarantees completeness for a much wider class of rule sets.

We begin by defining a specialisation relationship between predicates. A predicate q is a direct specialisation of a binary predicate p on positions { i, j} ( i = ∅, j = ∅) if there is a rule of the form q( u) → p(x, y) such that i (resp. j) contains those positions of u that contain the term x (resp. y). It is a specialisation of p on positions { i, j} if (a) it is a direct specialisation of p on positions { i, j}, or (b) there is a rule of the form q( u) → r( v) such that r( v) is a specialisation of p on positions { k, l} and the terms occurring in positions { k, l} of v occur in positions { i, j} of u with i = ∅ and j = ∅. We say that q is a pseudo-transitive predicate if it is a specialisation of at least one transitive predicate.

Definition 4.13 (Safe Rule Set)

We call a linear+trans rule set safe if it satisfies the following safety condition: for every pseudo-transitive predicate q, there exists a pair of positions {i, j} with i = j such that for all transitive predicates p of which q is a specialisation on positions { i, j}, either i ∈ i and j ∈ j, or i ∈ j and j ∈ i.

Note that if we consider binary predicates, the safety condition is always fulfilled. Then, specialisations correspond exactly to the subroles extended to inverses considered in Description Logics.

Example 4.11

Let R 1 = s 1 (x, x, y) → p 1 (x, y), R 2 = s 2 (x, y, z) → p 2 (x, y), R 3 = s 1 (x, y, z) → s 2 (z, x, y), and p 1 and p 2 be two transitive predicates.

The following specialisations have to be considered: s 1 is a direct specialisation of p 1 on positions {{1, 2}, {3}}, s 2 is a direct specialisation of p 2 on positions {{1}, {2}}, s 1 is a specialisation of p 2 on positions {{3}, {1}}. We then have two pseudo-transitive predicates: s 1 and s 2 . By choosing the pair {1, 3} for s 1 and {1, 2} for s 2 , we observe that {R 1 , R 2 , R 3 } satisfies the safety condition.

If we replace R 3 by R 4 = s 1 (x, y, z) → s 2 (x, y, z), s 1 is a specialisation of p 2 on positions {{1}, {2}}, and {R 1 , R 2 , R 4 } is not safe.

The modified query rewriting algorithm halts. Moreover, Theorem 4.6 (soundness and completeness) holds for the modified algorithm if either the input conjunctive query is atomic, or the input rule set is safe.

Theorem 4.7

We show this theorem with the help of the following two lemmas that ensure that the excluded rewritings are not necessary in the case of safe rule sets, or atomic conjunctive queries.

Let (Q, P) be a PCQ, R ∈ R + L , Q be an instance of interest of (Q, P) and µ = (Q ′ , H, P u ) be an external unifier of Q with R such that two external terms w.r.t. µ from a given pattern P + [t 1 , t 2 ] are unified together and with no existential variable. Every minimally-unifiable instance (Q, P) w.r.t. µ that replaces P + [t 1 , t 2 ] as in the External Rewriting cases (i), (ii), or (iii) leads to a direct rewriting (Q ′ i , P) that is more specific than (Q, P). Furthermore, for any classical direct rewriting

Q ′′ i of Q ′ i with R, either (Q, P) ≥ (Q ′′ i , P) or there is a classical direct rewriting Q ′ of the minimally- unifiable instance of Q that replaces P + [t 1 , t 2 ] as in case (iv) with R such that (Q ′ , P) ≥ (Q ′′ i , P).
Lemma 4.6 atoms p( t) occurring in a pattern definition the terms #1 and #2 occurs in positions {p 1 , p 2 }. We further note that the external terms in the concerned patterns are t 2 (which unifies with an existential variable in H) and the terms x i s (which unify with a non-existential variable), and each of these external terms must be obtained by instantiating term #1 or #2. Since the A i [x i s , t 2 ] are unified together, and share the same predicate p, it follows that all of the x i s must occur in the same position (either p 1 or p 2 ) of p; t 2 occurs in the other position among p 1 and p 2 . We therefore obtain;

σ(x 1 s ) = σ(x 2 s ) = • • • = σ(x k s ) = x ′ ,
where x ′ is the term in B that unifies with all of the x i s . (Note that if Q is an atomic query, there is a single A i , so the previous statement obviously holds, even without the safety condition.) Thus, Q M becomes:

q[t 1 1 , . . . , t k 1 ] ∧ 1≤i≤k (P + i [t i 1 , x ′ ] ∧ A i [x ′ , t 2 ]).
There is an isomorphism from Q to Q M \ {A i | 1 ≤ i ≤ k} that maps t 2 to x ′ . We then observe that {A i | 1 ≤ i ≤ k} is exactly the set of atoms that will be erased in the direct rewriting

Q ′ M = Q M \ {A i | 1 ≤ i ≤ k} ∪ σ(B)
, where σ is a substitution associated with µ. Therefore, Q is isomorphic to Q ′ M \ σ(B), hence (Q, P) ≥ (Q ′ M , P). One can see that the same reasoning as in the previous proof can be applied here to show that any further direct rewriting Q ′′ M of Q ′ M will lead to more specific queries. ✷

We are now ready to prove Theorem 4.7. Proof: Termination is a direct consequence of Proposition 4.6, indeed, since during the rewriting process we only keep PCQs that are not isomorphic to others, and Proposition 4.6 ensures that the size of each rewriting is bounded by the size of the initial query, there will be only finitely many such rewritings.

Regarding correctness, we know from Lemma 4.4 that if we do not exclude any rewriting the algorithm is sound and complete, and Lemma 4.6 and 4.7 show that for any rewriting Q that we exclude, there is another rewriting Q ′ obtainable using only non-excluded direct rewritings that is more general than Q. Therefore, the modified algorithm (in case of an atomic CQ, or a safe rule set) is complete. Furthermore, excluding rewritings cannot compromise the soundness of the rewriting mechanism. ✷

Complexity

A careful analysis of our query rewriting algorithm allows us to compute the worstcase complexity of atomic conjunctive query entailment over linear+trans knowledge bases, and general conjunctive query entailment over safe linear+trans knowledge bases (with still an open question as explained later). We consider two different complexity measures: combined complexity (that considers the size of the whole input, i.e., the knowledge base and the query), and data complexity (that assumes that only the set of facts is part of the input). The latter is often considered more relevant since the set of facts is typically significantly larger than the rest of the input.

Let us first recall that the complexity of entailment over linear knowledge bases is P Space-complete in combined complexity (even with atomic CQs) [CGL + 10b] and in AC 0 in data complexity (since they are FUS); while regarding entailment over transitivity knowledge bases (i.e., where all the rules are transitivity rules), it is complete for non-deterministic logarithmic space (N L) in data complexity (see, e.g., [START_REF] Papadimitriou | Computational complexity[END_REF] for the problem of reachability in directed graph), and N P -complete in combined complexity (see Table 4.1).

We show that the complexity of the combination is the best that we could hope with regards to data complexity. Indeed, we show completeness for N L, hence the same complexity as in the presence of transitivity rules alone. The situation is different for combined complexity, where the complexity for atomic CQ entailment increases from P Space for linear rules alone to ExpT ime for linear rules with transitivity.

Both atomic conjunctive query entailment over linear+trans knowledge bases, and conjunctive query entailment over safe linear+trans knowledge bases are N L-complete in data complexity. Proof: Consider a CQ Q, a linear+trans rule set R, and a set of facts F. Suppose that either Q is atomic or R satisfies the safety condition. Using Theorem 4.7, we can compute a finite set Π P of Datalog rules and a finite set Q Q of CQs with the property that (F, R) |= Q iff (F, Π P ) |= Q ′ for some Q ′ ∈ Q Q . As Π P and Q Q do not depend on the set of facts F, they can be computed and stored using constant space w.r.t. |F|.

To test whether (F, Π P ) |= Q ′ for some Q ′ ∈ Q Q , we proceed as follows. For each rewriting Q ′ ∈ Q Q , we can consider every possible mapping π from the variables of Q ′ to the terms of F. We then check whether the facts in π(Q ′ ) are entailed from (F, Π P ). For every atom α ∈ Q ′ over one of the original predicates, we can directly check if π(α) ∈ F, since the rules in Π P can only be used to derive facts over the new predicates p + . For every atom p + [t 1 , t 2 ] ∈ Q ′ where p + is a new predicate, we need to check whether (F, Π P ) |= p + (π(t 1 ), π(t 2 )). Because of the shape of the rules in Π P , the latter holds just in the case that there is a path of constants c 1 , . . . , c n with c 1 = π(t 1 ) and c n = π(t 2 ) such that for every 1 ≤ i < n, there is a rule ρ i = B i → p + (#1, #2) and substitution σ i of the variables in B i by constants in F such that σ i (#1) = c i , σ i (#2) = c i+1 , and σ i (B i ) ∈ F. To check for the existence of such a path, we guess the constants c i in the path one at a time, together with the witnessing rule ρ i and substitution σ i , using a counter to ensure that the number of guessed constants does not exceed the number of constants in F. Note that we need only logarithmically many bits for the counter, so the entire procedure runs in non-deterministic logarithmic space.

Hardness for N L can be shown by an easy reduction from the N L-complete directed reachability problem (using only transitivity rules) to atomic conjunctive query entailment over safe (linear+)trans knowledge bases. We recall the definition of Reachability from [START_REF] Papadimitriou | Computational complexity[END_REF]: given a (directed) graph G = (V, E) and two vertices s, t ∈ V , is there a path from s to t in G?

The reduction is as follows. Regarding the vocabulary, we consider for each vertex u ∈ V the constant c u ; and a single binary predicate e, that is used to first represent initial edges, and then paths. Now, for each (directed) edge (u, v) ∈ E, we add an atom e(c u , c v ) to F. Next, R contains the single transitivity rule e(x, y) ∧ e(y, z) → e(x, z). Intuitively, this rule "propagates" the relation e on all accessible vertices, i.e., if this rule were to be applied until fixpoint, there would be e(c u , c v ) in the saturated set of facts if and only if the vertex v is reachable from the vertex u. Therefore, the query e(c s , c t ) is entailed by (F, R) if and only if there is a path from s to t in G. Moreover R is trivially safe. ✷ Both (i) atomic conjunctive query entailment over linear+trans knowledge bases, and (ii) conjunctive query entailment over safe linear+trans knowledge bases are in ExpT ime in combined complexity.

Theorem 4.9 (Combined Complexity Upper Bound)

Proof: Consider a CQ Q, a linear+trans rule set R = R L ∪ R T , with R L a set of linear rules and R T a set of transitivity rules, and a set of facts F. Suppose that either condition (i) or (ii) of the theorem statement holds. It follows from Theorem 4.7 that the modified query rewriting algorithm halts and returns a finite set Π P of Datalog rules and a finite set

Q Q of CQs such that (F, R) |= Q iff (F, Π P ) |= Q ′ for some Q ′ ∈ Q Q .
To prove membership in ExpT ime, we show that:

(i) Π P is of exponential size and can be built in exponential time;

(ii) Q Q is a set of exponential size, that can be built in exponential time, and any Q ′ ∈ Q Q is of linear size in Q;

(iii) we can saturate F with Π P into F * in polynomial time in the size of Π P and F, and the resulting set of facts is of polynomial size in F;

(iv) Q Q can be evaluated over F * in exponential time.

We denote by r the maximum arity of a predicate in R, by p the number of predicates occurring in R and by t the number of transitive predicates.

Let us consider the construction of Π P . Since all rules generated in this step are linear rules and given a predicate s the number of non-isomorphic atoms using s is bounded by an exponential in r, for each transitive predicate there can be only exponentially many generated rules. Thus |Π P | = O(t × p × r r ). For the first point, it remains to show that Π P can be built in exponential time. Consider the following algorithm: for each pattern definition P , repeat until fixpoint: choose a rule R = (B, H) ∈ R L , compute all instances of interest of P w.r.t. R, and if there is an internal unifier, add the corresponding rewriting to P 's definition. The repeatable pattern P + [t 1 , t 2 ] can be expanded into at most r + 2 standard patterns (see Definition 4.10), and thus there are r + 2 possible sizes for the instances of interest. Then for each of these standard patterns, we can choose an atom from P ′ s definition that uses the predicate of H. Since there are at most r r possible choices for instantiating a standard pattern and there are at most r + 2 standard patterns to expand, we obtain the following bound: there are O((r + 2) × (r r ) r+2 ) = O(r r 2 ) different instances of interest for a given pattern definition and a given rule. Therefore each step of the algorithm can be processed in exponential time. Since there are only exponentially many different possible rewritings, the fixpoint is reached in at most exponential time. Hence, Point (i) runs in exponential time.

The argument for Point (ii) proceeds similarly. The only difference comes from the fact that since Q might not be atomic, we apply the rewriting step to conjunctive queries. However, from Proposition 4.6, we know that all rewritten queries have size bounded by the size of Q. Therefore, by using the same argument as for Point (i), we know that this step is exponential in both the maximum arity and in the size of the initial query Q.

Regarding Point (iii), a single breadth-first step with all non-transitive rules in Π P followed by the computation of the transitive closure is enough to build F * . While there are exponentially many non-transitive rules, each can be applied in polynomial time (since the body of each rule is atomic). Since each rule only creates atoms with transitive predicates, the resulting set of facts is of size |terms(F)| 2 × p. Now the transitive closure adds at most a quadratic number of atoms (for each transitive predicate), and can be computed in polynomial time in the size of F. Therefore, Π P can be built in exponential time in r and is of polynomial size in |F|.

It remains to show that point (iv) can be done in exponential time. Observe that since each query Q ′ ∈ Q Q is of size bounded by the initial query Q (Proposition 4.6), its evaluation can be computed in N P , thus in exponential time. Since there are only exponentially many queries in Q Q , this step is also done in exponential time.

Therefore, we can conclude that the entailment problem over linear+trans sets of rules with atomic query, and over safe linear+trans sets of rules is in ExpT ime.

Conclusion

In this chapter we have studied the decidability of entailment over knowledge bases built with some well-known decidable rule classes combined with transitivity rules. We first have recalled several known results from the litterature, in particular regarding specific cases of BTS rules, namely guarded, frontier-guarded and frontier-1 rules. Then, we have shown that aGRD rules are not compatible with transitivity rules and thus neither FES nor FUS rules are. Furthermore, by also proving that MSA is not compatible with transitivity, we have drawn a complete picture of decidability results when combining known FES rule classes with transitivity. Then we have studied the case of linear rules, one of the simplest FUS rule classes, showing that they are compatible with transitivity up to a minor safety condition, and have provided complexity bounds in terms of data and combined complexities. These bounds are tight for data complexity (NL-complete). Concerning combined complexity, we have tight bounds in the case of atomic queries, namely ExpTimecompleteness (in this case, the safety condition is not needed), and a membership result for conjunctive queries (up to the safety condition). Figure 4.6 synthetises all those decidability results: rule classes that can be safely combined with transitivity are pictured in bold green, while those that cannot in red. In italic black font, we have classes of rules for which the question is still open. Furthermore, Table 4.1 describes the complexity of entailment for the positive cases.

Finally, some open questions still remain:

• What is the exact complexity of CQ entailment over safe linear+trans knowl- • Can we combine linear rules with transitivity without the safety condition while preserving decidability?

Rule

• What happens for sticky or domain-restricted rules, that also enjoy the FUS property, yet are incomparable with linear rules?

Beside these remaining decidability issues, the question of a practical algorithm for query answering with linear+trans knowledge bases deserves to be studied. Indeed, despite their simplicity, linear rules are an important class that allows to represent frequently used knowledge. Our algorithm for linear+trans is worst-case optimal with respect to complexity theory but would clearly not be efficient in practice.

Conclusion

In this thesis we considered the problem of querying data while exploiting general background knowledge, called an ontology. Ontological knowledge can be represented under different formalisms, and we have considered the existential rule framework.

In this setting, knowledge bases are composed of data, that can be abstracted as a conjunction of atoms, and ontological knowledge, represented thanks to existential rules, which are rules that have the specificity of having existentially quantified variables in their head. These variables allow to infer the existence of individuals not present in the initial data. This specificity has been considered as highly important in the context of Ontology-Mediated Query Answering (OMQA). Furthermore, these rules enjoy a great expressivity. Unsurprisingly, this expressivity has a cost: the main problem we consider, namely the conjunctive query entailment problem (CQ entailment), which asks whether a knowledge base entails a conjunctive query, is undecidable. However, many restrictions on the set of rules are known to restore decidability.

Summary of our Contributions

The contributions of this thesis can be split into two parts. On the one hand, we have recalled the various forward chaining algorithms, also known as chase variants, and proposed a uniform definition for all of them, pointing out their differences regarding finiteness. Then we have considered known rule classes for which some forward chaining algorithm halts. We observed that most of them rely on some acyclicity condition, and we have proposed a tool that has allowed us to unify their definitions. Then, thanks to this new tool, we have extended them, without increasing the (worst-case) complexity of the recognition. On the other hand, we have been interested in combining transitivity rules with known decidable classes of existential rules. Transitivity is acknowledged to be a fundamental property in ontological design, hence being able to take transitivity into account is important in this context. However, the previous results from the literature were not optimistic, as guarded rules (a well-known decidable class) were not compatible with transitivity. We first clarified the picture regarding FES rule classes (those for which the strongest forward chaining algorithm halts). Our undecidability result also shows that FUS classes (which ensure that there exists a sound and complete UCQ rewriting of 139 any query) are generally not compatible with transitivity. We have then focused on combining linear rules with transitivity. Linear rules are a subclass of guarded rules, but they are also FUS. We have shown that up to a minor safety condition, this combination is possible while preserving decidability. Finally, we have analysed the complexity of the CQ entailment over linear+trans knowledge bases, and have obtained tight results for the data complexity, as well as for the combined complexity in the case of atomic queries.

Perspectives

We have contributed to a better understanding of the landscape of decidable classes of rules. However, some interesting theoretical issues remain open.

With regard to the new acyclicity conditions, the complexity of their recognition has been characterised, but what about the complexity of CQ entailment with these rules? Do weaker acyclicity notions allow for a smaller complexity of reasoning? Another point is that the strongest acyclicity notion ensures the finiteness of the frontier-restricted (or skolem) chase, and no condition allows to ensure the finiteness of the core chase on knowledge bases for which the frontier-restricted chase may not halt. In other words, the acyclicity notions do not take the notion of redundancy into account.

Concerning transitivity, taking these rules into account appeared to be much more difficult than expected. Whether the safety condition on linear+trans set of rules is really needed is not clear. Moreover, the exact combined complexity of CQ entailment over safe linear+trans knowledge bases remains unknown. The compatibility of transitivity with other FUS classes is also still an open issue. Beyond transitivity, it could be nice to consider the composition of binary relations. Is it harder to process than transitivity? On the practical side, it is not clear how our algorithm for CQ entailment over linear+trans knowledge bases could be refined in order to lead to a practical algorithm. Notions like the instances of interest have been defined with worst-case complexity in mind, but clearly, the bounds on pattern expansions could be tighten. Furthermore, there is no need to generate all instances of interest each time we want to find a unifier with a PCQ, and we could try to build the needed instances of interest on the fly.

More generally, combining several paradigms seems promising, from both decidability and complexity points of view. The central idea is to use the rules on the one hand to rewrite the query and on the other hand to modify the set of facts, which may lead to new decidability results or to better complexity (typically, ensure that both processes can be performed in polynomial time). The so-called combined approach was introduced in the context of description logics, first for DL-lite knowledge bases [KLT + 09] (also [KLT + 10, LSTW13]), then for EL knowledge bases [KLT + 11, HLSW15]. The set of facts is "saturated" in a finite way (even when all universal models are infinite), which may lead to false positive answers to the query. Then the query is rewritten to avoid unwanted answers. Alternatively, false positive answers to the initial query can be filtered out. The question of whether polynomial combination techniques are possible for various BTS existential rules is studied in [START_REF] Gottlob | Polynomial combined rewritings for existential rules[END_REF][START_REF] Gottlob | Polynomial rewritings for linear existential rules[END_REF]. While most results regarding guarded rules (and their generalisations) are negative, positive results are provided for linear rules and first-order query rewriting (instead of UCQ rewriting). Even if the proposed algorithm does not seem to be implementable, it is a first step that lets us hope for the best.

Finally, our work can also been extended with respect to the kinds of handled queries. Conjunctive queries (and unions of conjunctive queries) are usually considered in the OMQA setting. However, to make OMQA systems usable in practice, we have to consider more complex queries, like conjunctive queries integrating regular expressions (as e.g., in [START_REF] Bienvenu | On the complexity of evaluating regular path queries over linear existential rules[END_REF]), or more powerful relational queries.

In this thesis we investigate the issue of querying knowledge bases composed of data and general background knowledge, called an ontology. Ontological knowledge can be represented under different formalisms and we consider here a fragment of firstorder logic called existential rules (also known as tuple-generating dependencies and Datalog+/-). The fundamental entailment problem at the core of this thesis asks if a conjunctive query is entailed by an existential rule knowledge base. General existential rules are highly expressive, however at the cost of undecidability. Various restrictions on sets of rules have been proposed to regain the decidability of the entailment problem. Our specific contribution is two-fold. First, we propose a new tool that allows to unify and extend most of the known existential rule classes that rely on acyclicity conditions to tame infinite forward chaining, without increasing the complexity of the acyclicity recognition. Second, we study the compatibility of known decidable rule classes with a frequently required modeling construct, namely transitivity of binary relations. We help clarifying the picture of negative and positive results on this question, and provide a technique to safely combine transitivity with one of the simplest, yet useful, decidable rule classes, namely linear rules.

Keywords:

Artificial Intelligence, Knowledge Representation and Reasoning, Datalog+/-, Existential Rules, Conjunctive Queries Résumé Dans cette thèse, nous nous intéressons au problème d'interrogation de bases de connaissances composées de données et d'une ontologie, qui représente des connaissances générales sur le domaine d'application. Parmi les différents formalismes permettant de représenter les connaissances ontologiques, nous considérons ici un fragment de la logique du premier ordre appelé règles existentielles (aussi connues sous le nom de "tuple generating dependencies" et Datalog+/-). Le problème fondamental de conséquence logique au coeur de cette thèse demande si une requête conjonctive est conséquence d'une base de connaissances. Les règles existentielles étant très expressives, ce problème est indécidable. Toutefois, différentes restrictions sur les ensembles de règles ont été proposées afin d'obtenir sa décidabilité. La contribution de cette thèse est double. Premièrement, nous proposons un outil qui nous permet d'unifier puis d'étendre la plupart des classes de règles connues reposant sur des notions d'acyclicité assurant la finitude du chaînage avant. Deuxièmement, nous étudions la compatibilité des classes décidables de règles existentielles connues avec un type de connaissance souvent nécessaire dans les ontologies: la transitivité de relations binaires. Nous aidons à clarifier le paysage des résultats positifs et négatifs liés à cette question et fournissons une approche permettant de combiner la transitivité avec les règles existentielles linéaires.

  Mathematical Notions . . . . . . . . . . . . . . . 7 1.1.1 Basic Notations . . . . . . . . . . . . . . . . . . . . . . . . 7 1.1.2 Graph Notions . . . . . . . . . . . . . . . . . . . . . . . . 8 1.1.3 Logical Notions . . . . . . . . . . . . . . . . . . . . . . . . 9 1.1.4 Complexity Classes . . . . . . . . . . . . . . . . . . . . . . 11 1.2 Existential Rule Framework . . . . . . . . . . . . . . . . . 11 1.2.1 Forward Chaining . . . . . . . . . . . . . . . . . . . . . . 16 1.2.2 Backward Chaining . . . . . . . . . . . . . . . . . . . . . 18 1.3 Some Useful Translations . . . . . . . . . . . . . . . . . . . 21

Figure 1 . 1 :

 11 Figure 1.1: Graphical representation of the set of facts F from Example 1.1

  Definition 1.23 (Existential Rule) An existential rule (or simply rule) on a logical language L is a closed formula of form ∀x 1 , . . . , ∀x b (B → ∃z 1 , . . . , z h H), where B and H are two finite conjunctions of atoms on L, var(B) = {x 1 , . . . , x b } and var(H) \ var(B) = {z 1 , . . . , z k }. The sets of atoms B and H are respectively called the body and the head of R. Variables occurring in var(B) ∩ var(H) are called the frontier variables of R and denoted by f r(R). Variables occurring in var(H) \ var(B) are called existential variables.

  Example 1.6 (Derivation) Consider again the set of facts F = c(a), and the set of rules R composed of a single rule R = c(x) → p(x, y), c(y) from Example 1.5.

Figure 2 . 1 :

 21 Figure 2.1: Relations between known decidable rule classes

Figure 2

 2 Figure 2.3: Predicate Position Graph of R from Example 2.6

  Definition 3.1 (Breadth-first Derivation) Given F a set of facts and R a set of rules, a breadth-first derivation of F w

  Examples 3.4 to 3.6 show that these inclusions are strict. ✷ Example 3.4 (σ f r σ obl ) Consider the set of rules R = {p(x, y) → p(x, z)}, and the set of facts F = {p(a, b)}.

  Proposition 3.7 (Complexity of aGRD Recognition [Bag04])

Example 3 .Figure 3

 33 Figure 3.2: Predicate Position Graph of {R 1 , R 2 } from Example 3.10

Example 3 .

 3 18 (Full Position Graph) Consider rules {R 1 , R 2 } from Example 3.17. The full position graph of {R 1 , R 2 } is represented on Figure 3.6.

  there is an injective mapping from the sets of rules satisfying Y D but not Y to the sets of rules satisfying Y U but not Y D . Theorem 3.5 Proof: From Proposition 3.24, it follows immediately that Y D ⊆ Y U . Now, it remains to exhibit a set of rules satisfying Y U but not Y D . Assume Y ⊂ Y D and R satisfies Y D but not Y . Rewrite R into R ′ by applying the following steps. First for each rule

Figure 3 .

 3 Figure 3.10: Relations between acyclicity properties with complexities of recognition

Figure 4 . 1 :

 41 Figure 4.1: The landscape of C+trans classes for C ∈ F ES. Decidable C+trans are in bold. All the other C+trans classes are undecidable even for atomic CQs.

  By expanding the three vertices labelled by patterns according to their definitions in P, we may obtain the instantiation T 2 depicted by Figure 4.3, whose associated instance

Figure 4 . 2 :

 42 Figure 4.2: Instantiation T 1 from Example 4.3

Figure 4 . 3 :

 43 Figure 4.3: Instantiation T 2 from Example 4.3

  Example 4.5 (Internal/External Unifiers) Consider T 2 (depicted by Figure 4.3) whose associated instance is

  Example 4.6 (Instance of Interest) Consider again the instantiation T 2 of Q 2 pictured in Figure 4.3, and the rule

  Theorem 4.8 (Data Complexity)

Figure 4

 4 Figure 4.6: Decidability of Entailment over C+trans Knowledge Bases

  ExpTime-complete for atomic CQ entailment

  Mots clefs: Intelligence Artificielle, Représentation des Connaissances et Raisonnement, Datalog+/-, Règles Existentielles, Requêtes Conjonctives

  Different kinds of chase . . . . . . . . . . . . . . . . . . . . 3.2 Acyclicity notions . . . . . . . . . . . . . . . . . . . . . . . 3.2.1 Dependency-based Approach . . . . . . . . . . . . . . . . 3.2.2 Position-based Approach . . . . . . . . . . . . . . . . . . 3.2.3 First combination . . . . . . . . . . . . . . . . . . . . . . 3.3 Unifying both Approaches . . . . . . . . . . . . . . . . . . 3.4 Extensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.5 Other Acyclicity Conditions . . . . . . . . . . . . . . . . .

	Chapter 3
	Acyclicity Conditions for Chase
	Termination
	Contents
	3.1

3.5.1 Model Summarizing Acyclicity and

Model Faithful Acyclicity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Critical Instance . . . . . . . . . . . . . . . . . . . . . . . Model Faithful Acyclicity . . . . . . . . . . . . . . . . . . Model Summarizing Acyclicity . . . . . . . . . . . . . . . 3.5.2 Extending Model Summarizing Acyclicity . . . . . . . . .

  instantiation underlying Q consider each of the atom that is expanded from a child of P + i [t 1 , t 2 ] in turn, working from left to right. If the atom p( t) under P i [u, v] is being considered, then do the following: • if p is not a transitive predicate, then add a single child P i [u, v] to P + i [t 1 , t 2 ], and expand it into p( t). • if p is transitive, then p( t) has been replaced in Q + by P + [ t]. We also know that t consists of the terms u, v from P i [u, v]. We suppose that p( t) = p(u, v) (hence P + [ t] = P + [u, v]); a similar argument can be used if the positions are reversed. Let P

  Proof: Let P be the set of pattern definitions computed in Step 3 of the algorithm, and Π P the corresponding set of Datalog rules. Consider the CQ Q ++ obtained from Q by replacing every atom p(t 1 , t 2 ) such that p is transitive by the atom p + (t 1 , t 2 ). The following claim establishes the soundness of the internal rewriting mechanism in Step 3:

	Lemma 4.5

We conclude by Proposition 4.2. ✷

Let Q be a CQ, (F, R) be a linear+trans KB, and (Π P ,Q Q ) be the output of the algorithm. If (F, Π P ) |= Q Q then (F, R) |= Q.

Table 4

 4 .1: Complexity of CQ Entailment over C+trans Knowledge Bases edge bases? In particular, is it ExpTime-complete?

Strictly speaking, we mean the instantiation underlying Q, but to simplify the notation, here and later in the various proofs, we will often refer to instances, leaving the instantiation implicit.

Remerciements

Conversely, if R is wa, there is no cycle going through a special edge in P P G(R). By Lemma 3.1, no cycle in P G F (R) goes through an existential position; therefore P G F (R) satisfies the acyclicity property associated with the wa-marking. ✷ Definition 3.32 (Finite Domain Marking) A marking M is a finite domain marking with respect to some transition edge condition X, if for any set of rules R and any position [a, i] ∈ P G X (R), M ([a, i]) is the minimal set such that:

• (P 1 ) and (P 3 ) hold,

It should be pointed out that the latter condition implies (P 2 ).

A set of rules R is f d iff P G F (R) satisfies the acyclicity property associated with the fd marking (Definition 3.32).

Proposition 3.15

Proof: Let R be a set of rules that is f d. Then, for each existential position [p, i] there exists a position [p, j] for each variable of the frontier in the predicate positions graph such [p, j] does not belong to a cycle. Given P G F (R), we can see that Condition (P 3 ) ensures that R is f d. ✷ Definition 3.33 (Joint-acyclicity Marking) A marking M is a joint-acyclicity marking with respect to some transition edge condition X, if for any set of rules R and any position [a, i] ∈ P G X (R), M ([a, i]) is the minimal set such that: (P 1 ), (P 2 ) and (P 3 ) hold.

A set of rules R is ja iff P G F (R) satisfies the acyclicity property associated with the ja marking (Definition 3.33).

Proposition 3.16

Proof: Note that the definition of the ja marking is defined in the same way as the Move set from Definition 3.17. Furthermore, by Lemma 3.1, for any predicate position (p, i) in the JA graph of a set of rules R, there is a cycle going through (p, i) iff for any existential position [a, i] such that pred([a, i]) = p we have [a, i] ∈ M ([a, i]). ✷

• s 2 (#1, y, #2) → p + 1 (#1, #2)

• p 2 (#1, #2) → p + 2 (#1, #2)

• s 2 (#2, y, #1) → p + 2 (#1, #2)

These four rules together with transitivity rules on p + 1 and p + 2 form Π P . Moreover,

We are now able to summarise informally the main ideas underlying our framework:

1. A PCQ (Q, P) represents an infinite number of CQs, i.e., all the full instances that can be obtained from Q using the pattern definitions in P. A UPCQ represents all instances associated with its PCQs.

2. A UPCQ is considered entailed by a set of facts if one of its full instances is.

3. Given a UPCQ (Q, P), the pattern definitions in P can be translated into a set of Datalog rules Π P and the query Q itself into a UCQ Q Q such that Q is entailed by the set of facts F if the UCQ Q Q is entailed by F saturated with rules from Π P , or equivalently if Q Q is entailed by the knowledge-base (F, Π P ).

These ideas are formally stated by the next proposition.

Let F be a set of facts and (Q, P) be a UPCQ; then, (F,

Proof: We successively prove the two directions. (⇐) Let T be an instantiation of (Q, P) such that there exists a homomorphism π from its associated full instance to the set of facts F. Let us consider a vertex of T labelled by a standard pattern P [t 1 , t 2 ]. The label r(ρ( t)) of its child was obtained by choosing an atom r( t) in the pattern definition of P (with ρ being the substitution used to create this child). Thus the Datalog program Π P contains the rule r( t) → p + (#1, #2) where #1, #2 ∈ t. By applying the rule according to the homomorphism π • ρ, we can add the atom p + (t 1 , t 2 ) to F, and let F ′ be the obtained set of facts. Let us repeat this procedure for every vertex of T labelled by a standard pattern. Consider next a repeatable pattern labelled by P + [t, t ′ ] whose children are respectively labelled by

According to the previous rule applications, F ′ contains the atoms p + (t = t 1 , t 2 ), p + (t 2 , t 3 ), . . . , p + (t k-1 , t k = t ′ ). Then, by successive applications of the rule in Π P expressing the transitivity of p + , we finally add to F ′ the atom p + (t, t ′ ). Let F ′′ -there is no matching pair i < j ′ with j ′ > j

• We let i 1 < j 1 be the matching pair that is maximal w.r.t. index s + 1

• For any k, if i k < j k is already defined, then we let i k+1 < j k+1 be the matching pair that is maximal w.r.t. index j k , if such a pair exists (otherwise, i k < j k is the final pair in the sequence). Now remove from Q ′ all the patterns P [x ′ ℓ , x ′ ℓ+1 ] such that i g < ℓ < j g for some 1 ≤ g ≤ m, as well as the atoms that are expanded from such patterns. We claim that there are now at most arity(p)

Indeed, if this were not the case, we could find a matching pair i < j among the remaining patterns. Since i 1 < j 1 is maximal w.r.t. index s + 1, and there are no further matching pairs starting from j m , we know that i ≥ i 1 and i < j m . Moreover, since a i is still present in Q ′ , it must be the case that j g < i < i g+1 for some 1 ≤ g < m. But this contradicts the fact that i g+1 < j g+1 is maximal w.r.t. j g .

In order for the different remaining patterns to form a sequence, we will need to perform a renaming of terms. If there are n patterns left under P + [t 1 , t 2 ], we rename these patterns from left to right by:

and rename the atoms underneath these patterns accordingly. We will also update π by setting π(x ′′ i ) = π(x ′ j ) if x ′ j was renamed into x ′′ i and there is no x ′ j ′ with j ′ < j that was also renamed into x ′′ i . Let Q ′ be the instance obtained in this manner. We note that by construction, it is an instance of interest of (Q, P) w.r.t. R, as we only expand patterns into atoms that use the predicate p from the rule head, and the number of patterns generated from any repeatable pattern is at most arity(p) + 2.

Regarding π, note that a term may be shared among several repeatable patterns that are relevant for µ. However, we can show that if a term is shared by multiple relevant patterns, then the (partial) mapping associated with those patterns will agree on the shared term, i.e., π is well-defined. First note if a term is shared by two repeatable patterns, then it must appear as one of the distinguished terms (t 1 , t 2 ) in both patterns. Moreover, by tracing the above construction, we find that π is the identity on such terms.

To complete the definition of π, we extend it to all of the terms of Q ′ by letting π be the identity on all terms that do not occur underneath a developed repeatable pattern (i.e., terms that appear in a repeatable pattern that is not expanded, or in one of the standard atoms of Q). Observe that π is an injective function, so its inverse π -1 is well-defined. Now let Q ′ 2 consist of all atoms in Q ′ ∩Q 2 that are not expanded from a repeatable pattern (i.e., they are standard atoms from Q) as well as all atoms in Q ′ that lie under a repeatable pattern.

Note that by construction every term t in Q ′ 2 is such that π(t) appears in Q 2 . We can thus define a partition P ′ u of the terms in Q ′ 2 ∪ H by taking every class C in P u and replacing every term t from Q 2 by π -1 (t), if such a term exists, and otherwise deleting t; terms from p( t) are left untouched. Moreover, by the injectivity of π, every term appears in at most one class, i.e., P ′ u is indeed a partition. We aim to show that µ ′ = (Q ′ 2 , p( t), P ′ u ) is the desired unifier. We first show that µ ′ is a unifier of Q ′ with R. In what follows, it will prove convenient to extend π to the terms in the head atom p( t), by letting π be the identity on such terms. We will let σ be a substitution associated with µ, and let σ ′ be the corresponding substitution for µ ′ defined by setting σ ′ (t) = σ(π(t)).

• P ′ u is admissible: since π is the identity on constants, if a class in P ′ u contains two constants c, d, then the corresponding class in P u must also contain c, d (a contradiction).

and each

The final possibility is that es > arity(p) + 2, in which case some of the patterns will be removed and the remaining patterns will be renamed (as will be their corresponding atoms). Suppose that α is the atom a ′′ h below the pattern P [x ′′ ℓ , x ′′ ℓ+1 ], which was obtained from renaming the pattern P

. By examining the way renaming is performed, there are two situations that can occur:

π(x ′′ ℓ ) = x h : in this case, there must exist a matching pair i g < j g such that h = j g , π(x ′′ ℓ ) = x ig+1 , and π(x ′′ ℓ+1 ) = x h+1 . From the definition of matching pairs, we know that σ(

). We can thus conclude that σ ′ (α) = σ(a h ).

• for a contradiction, suppose the class C ′ in P ′ u contains an existential variable z from H and either a constant or a variable that occurs in

Q 3 by removing all atoms and patterns that are not relevant for µ ′ . Obviously Q 4 is an instance of interest of a PCQ of the form P + [t 1 , t 2 ]. Let P ′ be the direct rewriting of P w.r.t. µ ′ , obtained from Q 4 . Let us consider the following notations:

One can see that Q ′′ is an instance of both (Q, P) and (Q, P ′ ). If B is a not a repeatable pattern, let ℓ = 1, otherwise let S be the name of the repeatable pattern in B, and

Let π be the function defined as follows:

. Note that π is injective, so its inverse is also a function. Expand all

Finally, for all terms u in Q ′′ for which π is not defined (i.e., those terms appearing in atoms that were not expanded from the pattern P + [t 1 , t 2 ]), we set π(u) = u.

By construction, Q ′′ is still an instance of (Q, P ′ ) and π is an isomorphism from

Now that internal direct rewritings are covered, we detail how we handle the case of external direct rewritings. Given a PCQ and a rule, the idea is to consider all instances of interest of the PCQ w.r.t. the rule and all associated external unifiers. This is sufficient to "cover" (in the sense of Proposition 4.3) all external unifiers with respect the rule. However, to be complete, we have to keep in mind that a repeatable pattern P + [t 1 , t 2 ] can be expanded into any number of atoms in full instances. Hence, each repeatable pattern P + [t 1 , t 2 ] in an instance of interest is actually seen as a sequence

is the sequence of atoms (from the subtree of P + [t 1 , t 2 ]) involved in the unifier, and each of the surrounding P + pattern may be present or not, which yields four cases for each pattern. Moreover, we have to check that each of these cases (which will at most be four to the power of the number of repeatable patterns in the query) is actually possible, i.e., that the unifier still satisfies the conditions for being a unifier. Definition 4.12 (External Direct Rewriting) Let (Q, P) be a PCQ, R ∈ R + L , T be an instantiation of interest of (Q, P) w.r.t. R, Q be the instance associated with T , and µ = (Q ′ , H, P µ ) be an external unifier of Q with R. From this, several direct rewritings of Q w.r.t. P and R can be built. First, we mark all leaves in T that are labelled by an atom in Q ′ , and we restrict T to branches leading to a marked leaf. Then, we consider each instantiation T i that can be obtained from Q as follows. Replace each repeatable pattern P + [t 1 , t 2 ] that has k > 0 children in T by one of the following paths (using fresh variables x i ):

where

(the y i being fresh variables). Let Q i be the instance associated with T i .

If

Example 4.9 Consider again R 2 = s 1 (x ′ , y ′ ) → s 2 (x ′ , y ′ , z ′ ) and

from Examples 4.5 and 4.6 respectively, and let µ = ({s 2 (a, y 0 , z), s 2 (x 1 , y 1 , z)}, H 2 , {{a, x 1 , x ′ }, {y 0 , y 1 , y ′ }, {z, z ′ }})

Figure 4.4 depicts the instantiation of the PCQ leading to Q 3 . First, we consider the instantiation that generated Q 3 , and we remove the vertex labelled by P 2 [x 1 , b] and its child s 2 (b, y 2 , x 1 ), since the latter atom is not involved in µ. Next we replace the repeatable pattern P + 1 [a, z] (resp. P + 2 [z, b]) using one of the four cases detailed above, and we check whether µ ′ (obtained from µ) is still a unifier. Concerning P + 1 [a, z], the four following cases are to be considered:

(iv) s 2 (a, y 0 , z)

Figure 4.4: Instantiation of Q 3 from Example 4.9

In case (i), t 2 is unified with the existential variable z ′ , hence P + 1 [t 2 , z] should be unified as well, which is not possible. The same holds for case (iii). Finally only cases (ii) and (iv) are suitable to replace

the four following cases are to be considered:

Case (i) and (ii) are excluded for the same reason as above (v 1 is unified with z ′ ). Now let us consider the PCQs obtained by combining all considered possible expansions of P + 1 and P + 2 :

We observe that no unifier exists when we choose case (iv) for both patterns, indeed {s 2 (a, y 0 , z), s 2 (b, y 1 , z)} cannot be unified with s 2 (x ′ , y ′ , z ′ ) since it would mean to unify constants a and b together.

By considering the three minimally-unifiable instances Q 1 , Q 2 and Q 3 we obtain the following rewritings:

Let Q be a CQ, (F, R) be a linear+trans knowledge base, and (Π P , Q Q ) be the (possibly infinite) output of the algorithm; then:

The proof of this theorem is quite technical, and thus is split into the following five lemmas.

Let Q be a CQ, R ∈ R T , P 0 be the initial set of pattern definitions relative to R T (see Step 1 of the algorithm overview), and Q + be obtained from Q by replacing all atoms p(t 1 , t 2 ) such that p is a transitive predicate by

Lemma 4.1

Proof: Let p(t 1 , t 2 ) be the atom of Q that is rewritten to obtain Q ′ . Since p is a transitive predicate, it occurs in a pattern definition P 0 in P, and Q + contains the atom P + [t 1 , t 2 ]. In Q ′ , p(t 1 , t 2 ) is rewritten into p(t 1 , x 1 )∧p(x 1 , t 2 ). Let Q ′′ be the full instance of (Q + , P 0 ) that expands all repeatable patterns but P + [t 1 , t 2 ] into a single standard pattern, expands P + [t 1 , t 2 ] into two standard patterns P [t 1 , x ′ 1 ], P [x ′ 1 , t 2 ], and then further expands the standard patterns using the unique atom in each of the pattern definitions. It is clear that Q ′′ is isomorphic to Q ′ (simply map x ′ 1 to x 1 and all other terms to themselves). ✷

Let P be a set of pattern definitions, P 0 ⊆ P be the initial set of pattern definitions built from the set R T of transitivity rules, (Q, P) be a PCQ that does not contain any standard atom using a transitive predicate, Q be a full instance of (Q, P), and Q + be obtained from Q by replacing all atoms p(t 1 , t 2 ) with p transitive by

Then, for every full instance

Lemma 4.2

Proof: We build the instance Q ′′ as follows. Initialize Q ′′ to the atoms and repeatable patterns occurring in Q. Next, for all repeatable patterns

The following claim shows the soundness of the external rewriting in Step 5 and completes the proof of the lemma.

that for all 0 ≤ j < k, (Q j+1 , P) is a direct external rewriting of (Q j , P). We will show by induction on j that F,

The base case (j = 0) is a direct consequence of Claim 4.1. For the induction step, we assume the property is true at rank i, and we show that it is true at rank i + 1.

Suppose that F, Π P |= Q Q i+1 . From Proposition 4.2, it follows that there is a full instance Q i+1 of (Q i+1 , P) such that F |= Q i+1 . By Claim 4.2, there is a full instance Q i of (Q i , P) such that Q i+1 is obtained from a sequence of classical rewritings from Q i . Thus (from the correctness of the classical rewriting), there is a set of facts

We can now immediately conclude with the proof of Theorem 4.6: Proof: Follows from Lemma 4.4 and 4.5. ✷

Regarding termination, we observe that Step 3 (internal rewriting) must halt since every direct rewriting step adds a new atom (using a predicate from R + L ) to a pattern definition, and there are finitely many such atoms (up to isomorphism).

By contrast, Step 5 (external rewriting) may not halt, as the rewritings may grow unboundedly in size (where the size is the number of atoms and patterns). Thus, to ensure termination, we will modify Step 5 to exclude direct rewritings that increase the rewriting size. We first recall the four possible replacements of a repeatable pattern P + [t 1 , t 2 ] when computing the minimally-unifiable instances (see Definition 4.12):

We identify the following "problematic" minimally-unifiable instances, problematic in the sense that they may lead to direct rewritings larger than the original query:

Proof: Without loss of generality, let us write Q = q[t 1 , t 2 ]∧P + [t 1 , t 2 ] where q[t 1 , t 2 ] denotes a set of atoms where t 1 and t 2 may occur. We denote by x s and x e (s < e) the external terms of P + [t 1 , t 2 ] w.r.t. µ, and by A[x s , x e ] the sequence of atoms expanded from P + [t 1 , t 2 ] involved in the unifier. Since we assume that no existential variable is unified with variables x s and x e , no atom from q[t 1 , t 2 ] can be part of the unifier. Consider the following minimally-unifiable instances:

By unifying x s and x e together, we obtain the following instances:

(where σ is the substitution associated with µ), then, let µ ′′ = {Q ′′ , H ′ , P ′′ u } where Q ′′ = Q ′ \ σ(B) and P ′′ u is the restriction of P ′ u to terms occurring in Q ′′ ∪ H ′ . Since Q ′′ = ∅ and all terms from σ(B) cannot connect two different terms from q[t 1 , t 2 ] (indeed, the only term shared between σ(B) and q[t 1 , t 2 ] is either t 1 or t 2 ), σ(B) can be seen as a loop on t 1 (or t 2 ), therefore we can remove σ(B) while preserving the unifier, i.e., µ ′′ is a unifier of Q with R ′ . Moreover, since P ′′ u and Q ′′ are only restrictions of P ′ u and Q ′ respectively, it holds that µ ′′ ≥ µ ′ . Then, we denote by Q ′′ the direct rewriting of Q with R ′ w.r.t. µ ′′ and obtain

The other possibility is that all atoms involved in µ ′ occur in σ(B), then,

, one can easily build an instance Q ′ of Q in the same way as above, and see that Q ′ ≥ Q ′′ 1 . Thus, we have (Q, P) ≥ (Q ′′ i , P). ✷

Let (Q, P) be a PCQ, R ∈ R + L , Q be an instance of interest of (Q, P) and µ = (Q ′ , H, P u ) be an external unifier of Q with R such that one external term w.r.t. µ from a given pattern P + [t 1 , t 2 ] is unified with an existential variable, and where all atoms in Q ′ are obtained from the expansion of a repeatable pattern. If Q is atomic, or if R L is a set of safe linear rules, then every minimallyunifiable instance of (Q, P) w.r.t. µ that replaces all P + i [t 1 , t 2 ] as in the External Rewriting cases (ii) or (iii) leads to a direct rewriting (Q ′ i , P) that is more specific than (Q, P). Furthermore, for any direct rewriting

µ that replaces at least one repeatable pattern as in case (iv) and is such that

Lemma 4.7

Proof: Let (Q, P), R, Q and µ be as in the lemma statement, and let

be the repeatable patterns that are relevant for µ. For each 1 ≤ i ≤ k, we denote by

the sequence of standard patterns expanded from P + i [t i 1 , t i 2 ], and we let x i s i and x i e i (s i < e i ) be the external terms of

We assume without loss of generality that it is x i e i that is unified with an existential variable, and let A i [x i s i , x i e i = t i 2 ] denote the atoms expanded from P i [x i j , x i j+1 ] with s i ≤ j < e i . Since the unifier µ is single-piece, and no pattern is expanded as in case (iv) all repeatable patterns relevant for µ have to share some variable. For simplicity, we assume that they all share their second term, i.e. t i 2 = t j 2 for all 1 ≤ i, j ≤ k. (The argument is entirely similar, just more notationally involved, if this assumption is not made.) Let us use t 2 for this shared term. Then we can write Q as follows:

Note that t 2 cannot occur in q.

Because we have chosen the second term to be shared in all repeatable patterns, we only need to consider the minimally-unifiable instance Q M of (Q, P) w.r.t. µ that replaces each

i.e. External Rewriting case (ii). Thus, we have

Let σ be the substitution associated with µ. From the safety condition, we know that there is a pair of positions {p 1 , p 2 } for the predicate p of H, such that for all Concerning ExpT ime-hardness, we prove it for atomic CQ entailment over lin-ear+trans knowledge bases, but the question is not solved yet for CQ entailment over safe linear+trans knowledge bases. Atomic conjunctive query entailment over linear+trans knowledge bases is ExpT ime-hard in combined complexity. Proof: To prove hardness, we can rely on a proof from [START_REF] Bienvenu | On the complexity of evaluating regular path queries over linear existential rules[END_REF]. In this paper, they prove that Regular-Path Query (RPQ) entailment over linear knowledge bases is ExpT ime-hard. The problem is not a subproblem of ours, nor the contrary. However the proof uses only a particular RPQ of the form p + (t 1 , t 2 ). This RPQ is entailed from (F, R L ) if and only if the atomic CQ p(t 1 , t 2 ) is entailed from (F, R L ∪ {trans(p)}). Nevertheless, we recall below the main lines of the proof, while reformulating it in terms of our problem. Note that the linear rules have a non-atomic head to simplify the explanations, but can be decomposed into atomicheaded rules as detailed in Section 1.3.

The reduction is from the simulation of any Alternating Turing Machine (ATM) that runs in polynomial space. More specifically, the problem they consider is the following ExpTime-complete problem: given a PSpace ATM M , and a word x, does M accept x? Without loss of generality, they consider ATM where each nonfinal universal state has exactly two existential state successors, and each non-final existential state has exactly two universal state successors.

The proof uses a single transitive predicate that we call p. Given an ATM M with input x, we create a predicate of arity polynomial in x and M , that encodes the current configuration of the machine (its tape and the current state and head position). Furthermore, each atom encoding a configuration also uses a term as a "begin" and another as an "end" (respectively the first and last position of the predicate), these are used later by the transitivity rules. Linear rules are used to generate the transitions of the ATM. First, for each transition in the ATM, there is a linear rule that generates the two next configurations, and depending on the type of the current state different transitive atoms are generated as illustrated by Figure 4.5.

The initial configuration contains two special constants b and e as begin and end, and the set of facts contains only the atom encoding this configuration.

When the state of the current configuration s is existential, four atoms using predicate p are generated in the next step, the first two being used to link the begin of s to the begin of the two next configurations (since the ATM is non-deterministic by nature), and the last two atoms being used to link the end of the two next configurations to the end of s. When the state of the current configuration s is universal, three atoms using p are generated, the first one links the begin of s to the begin of the first next configuration, the second one links the end of the first next configuration to the begin of the second next configuration, and finally the last one links the end of the last next configuration to the end of s.

Finally, when the state of the current configuration s is accepting, an atom using p linking the begin of s with the end of s is generated.

The idea is that linear rules simulate the run of the machine, and that transitivity rules connect the initial begin to the initial end if and only if M accepts x.

Then, the query just asks whether the begin of the initial configuration can be linked to the end of the initial configuration (i.e., Q = p(b, e)).

This reduction shows that atomic CQ entailment over linear+trans sets of rules is ExpT ime-hard. ✷

From Theorems 4.9 and 4.10, we conclude that atomic CQ entailment over lin-ear+trans knowledge bases is ExpT ime-complete in combined complexity.

The previous reduction cannot be used to prove the ExpTime-hardness of CQ entailment over safe linear+trans knowledge bases. Indeed, the decomposition of the rules into atomic-headed rules produces unsafe linear rules. We point out that the rewriting of the set of linear+trans rules built in the previous reduction involves only internal rewritings. Since the safety condition was introduced to ensure the termination of the external rewriting step, one may conjecture that CQ entailment over safe linear+trans knowledge bases is ExpTime-hard. However it is not excluded that the safety condition reduces the complexity of the internal rewriting step. Note that the problem is at least PSpace-hard because it is already the case for linear rules alone (which are in this case, trivially safe).