=Paper= {{Paper |id=Vol-3203/paper6 |storemode=property |title=Dyadic Existential Rules |pdfUrl=https://ceur-ws.org/Vol-3203/paper6.pdf |volume=Vol-3203 |authors=Georg Gottlob,Marco Manna,Cinzia Marte |dblpUrl=https://dblp.org/rec/conf/datalog/GottlobMM22 }} ==Dyadic Existential Rules== https://ceur-ws.org/Vol-3203/paper6.pdf
Dyadic Existential Rules
Georg Gottlob1,2,โ€  , Marco Manna3,โ€  and Cinzia Marte3,*,โ€ 
1
  Department of Computer Science, University of Oxford, United Kingdom
2
  Faculty of Informatics, TU Wien, Austria
3
  Department of Mathematics and Computer Science, University of Calabria, Italy


                                         Abstract
                                         In the field of ontology-based query answering, existential rules (a.k.a. tuple-generating dependencies)
                                         form an expressive Datalog-based language to specify implicit knowledge. The presence of existential
                                         quantification in rule-heads, however, makes the main reasoning tasks undecidable. To overcome this
                                         limitation, in the last two decades, a number of classes of existential rules guaranteeing the decidability
                                         of query answering have been proposed. Unfortunately, such classes are typically based on different
                                         syntactic conditions imposing the development of different ad hoc reasoners. This paper introduces a
                                         novel general condition that allows to define, systematically, from any decidable class ๐ถ of existential
                                         rules, a new class called Dyadic-๐ถ that enjoys the following properties: (๐‘–) it is decidable; (๐‘–๐‘–) it
                                         generalizes ๐ถ; (๐‘–๐‘–๐‘–) it keeps the same data complexity as ๐ถ; and (๐‘–๐‘ฃ) it can exploit any reasoner for
                                         query answering over ๐ถ. Additionally, the paper proposes a simple and elegant syntactic condition that
                                         gives rise to the class Ward+ generalizing the well-known decidable classes Shy and Ward, and being
                                         included in Dyadic-Shy.

                                         Keywords
                                         Existential rules, Datalog, ontology-based query answering, tuple-generating dependencies, computa-
                                         tional complexity.




1. Introduction
In ontology-based query answering, a conjunctive query is typically evaluated over a logical
theory consisting of a relational database paired with an ontology. Description Logics [1] and
Existential Rules (a.k.a. tuple generating dependencies) [2] are the main languages used to
specify ontologies. In particular, the latter are essentially classical datalog rules extended with
existential quantified variables in rule-heads. The presence of existential quantification in the
head of rules, however, makes query answering undecidable in the general case. To overcome
this limitation, in the last two decades, a number of classes of existential rules โ€”based on
both semantic and syntactic conditionsโ€” that guarantee the decidability of query answering
have been proposed. Concerning the semantic conditions, we recall finite expansions sets, finite
treewidth sets, finite unification sets, and strongly parsimonious sets [3, 2, 4]. Each of these classes

Datalog 2.0 2022: 4th International Workshop on the Resurgence of Datalog in Academia and Industry, September 05,
2022, Genova - Nervi, Italy
*
  Corresponding author.
โ€ 
  These authors contributed equally.
$ georg.gottlob@cs.ox.ac.uk (G. Gottlob); manna@mat.unical.it (M. Manna); marte@mat.unical.it (C. Marte)
 0000-0002-2353-5230 (G. Gottlob); 0000-0003-3323-9328 (M. Manna); 0000-0003-3920-8186 (C. Marte)
                                       ยฉ 2022 Copyright for this paper by its authors. Use permitted under Creative Commons License Attribution 4.0 International (CC BY 4.0).
    CEUR
    Workshop
    Proceedings
                  http://ceur-ws.org
                  ISSN 1613-0073
                                       CEUR Workshop Proceedings (CEUR-WS.org)



                                                                                                          83
Georg Gottlob et al. CEUR Workshop Proceedings                                                83โ€“96


           Main syntactic classes         Data Complexity         Combined Complexity
           Weakly-(Fr)-Guarded [5, 6]      ExpTime-complete           2ExpTime-complete
           (Fr)-Guarded [6]                 PTime-complete            2ExpTime-complete
           Weakly-Acyclic [7]               PTime-complete            2ExpTime-complete
           Jointly-Acyclic [8]              PTime-complete            2ExpTime-complete
           Datalog [9]                      PTime-complete             ExpTime-complete
           Shy, Ward [4, 10]                PTime-complete             ExpTime-complete
           Protected [11]                   PTime-complete             ExpTime-complete
           Sticky-(Join) [12, 13]                AC0                   ExpTime-complete
           Linear, Joinless [14, 15]             AC0                    PSpace-complete
           Inclusion-Dependencies [16]           AC0                    PSpace-complete
Table 1
Computational complexity of query answering over the main concrete classes of existential rules.


encompasses a number of concrete classes based on syntactic conditions. Table 1 summarizes
them and their computational complexity with respect to query answering. Unfortunately,
the fact that such classes are typically based on different syntactic conditions imposes the
development of different ad hoc reasoners.
   This paper introduces a novel general condition that allows to define, systematically, from
any class ๐’ž of existential rules for which conjunctive query answering is decidable, a new class
called Dyadic-๐’ž that enjoys the following properties: (๐‘–) it is decidable; (๐‘–๐‘–) it generalizes ๐’ž;
(๐‘–๐‘–๐‘–) it keeps the same data complexity as ๐’ž; and (๐‘–๐‘ฃ) it can exploit any reasoner for query
answering over ๐’ž. The key idea behind this new class is the existence of a dyadic decomposition
of an ontology ฮฃ consisting of a pair (ฮฃHG , ฮฃ๐’ž ) such that: (๐‘–) ฮฃHG โˆช ฮฃ๐’ž is equivalent to ฮฃ with
respect to query answering; (๐‘–๐‘–) ฮฃ๐’ž โˆˆ ๐’ž; and (๐‘–๐‘–๐‘–) ฮฃHG is a set of โ€œhead-groundโ€ rules, which
intuitively are rules generating only ground atoms when paired with ฮฃ๐’ž . In analogy with the
existing semantic classes, the union of all Dyadic-๐’ž classes are called dyadic decomposable sets.
   Finally, the paper proposes a simple and elegant syntactic condition that gives rise to the
concrete class Ward+ generalizing the well-known decidable classes Shy and Ward, and being
included in Dyadic-Shy.


2. Preliminaries
2.1. Basics on Relational Structures
Fix three pairwise disjoint lexicographically enumerable infinite sets ฮ”๐ถ of constants, ฮ”๐‘
of nulls (๐œ™, ๐œ™0 , ๐œ™1 , ...), and ฮ”๐‘‰ of variables (๐‘ฅ, ๐‘ฆ, ๐‘ง, and variations thereof). Their union is
denoted by ฮ” and its elements are called terms. For any integer ๐‘˜ โ‰ฅ 0, we may write [๐‘˜] for
the set {1, ..., ๐‘˜}; in particular, as usual, if ๐‘˜ = 0, then [๐‘˜] = โˆ…. An atom ๐‘Ž is an expression
of the form ๐‘ƒ (t), where ๐‘ƒ = pred(๐‘Ž) is a (relational) predicate, t = ๐‘ก1 , ..., ๐‘ก๐‘˜ is a tuple of
terms ๐‘˜ = arity(๐‘Ž) = arity(๐‘ƒ ) โ‰ฅ 0 is the arity of both ๐‘Ž and ๐‘ƒ , and ๐‘Ž[๐‘–] denotes the ๐‘–-th
term t[๐‘–] = ๐‘ก๐‘– of ๐‘Ž, for each ๐‘– โˆˆ [๐‘˜]. In particular, if ๐‘˜ = 0, then t is the empty tuple and
๐‘Ž = ๐‘ƒ (). By const(๐‘Ž) (resp., vars(๐‘Ž)) we denote the set of constants (resp., variables) occurring
in ๐‘Ž. A fact is an atom that contains only constants. A (relational) schema S is a finite set
of predicates, each with its own arity. The set of positions of S, denoted pos(S), is defined



                                                 84
Georg Gottlob et al. CEUR Workshop Proceedings                                               83โ€“96


as {๐‘ƒ [๐‘–] | ๐‘ƒ โˆˆ S โˆง 1 โ‰ค ๐‘– โ‰ค arity(๐‘ƒ )}, where each ๐‘ƒ [๐‘–] denotes the ๐‘–-th position of ๐‘ƒ . A
(relational) structure over S is any (possibly infinite) set of atoms using only predicates from
S. The domain of a structure ๐‘†, denoted dom(๐‘†), is the set of all the terms occurring in ๐‘†.
An instance over S is any structure ๐ผ over S such that dom(๐ผ) โІ ฮ”๐ถ โˆช ฮ”๐‘ . A database over
S is any finite instance over S containing only facts. Consider a map ๐œ‡ : ๐‘‡1 โ†’ ๐‘‡2 where
๐‘‡1 โІ ฮ” and ๐‘‡2 โІ ฮ”. Given a set ๐‘‡ of terms, the restriction of ๐œ‡ with respect to ๐‘‡ is the map
๐œ‡|๐‘‡ = {๐‘ก โ†ฆโ†’ ๐œ‡(๐‘ก) : ๐‘ก โˆˆ ๐‘‡1 โˆฉ ๐‘‡ }. An extension of ๐œ‡ is any map ๐œ‡โ€ฒ between terms, denoted by
๐œ‡โ€ฒ โЇ ๐œ‡, such that ๐œ‡โ€ฒ |๐‘‡1 = ๐œ‡. A homomorphism from a structure ๐‘†1 to a structure ๐‘†2 is any map
โ„Ž : dom(๐‘†1 ) โ†’ dom(๐‘†2 ) such that both the following hold: (๐‘–) if ๐‘ก โˆˆ ฮ”๐ถ โˆฉ dom(๐‘†1 ), then
โ„Ž(๐‘ก) = ๐‘ก; and (๐‘–๐‘–) โ„Ž(๐‘†1 ) = {๐‘ƒ (โ„Ž(t)) : ๐‘ƒ (t) โˆˆ ๐‘†1 } โІ ๐‘†2 .

2.2. Conjunctive Queries
A conjunctive query (CQ) ๐‘ž over a schema S is a (first-order) formula of the form

                                       โŸจxโŸฉ โ† โˆƒ y ฮฆ(x, y),                                       (1)

where x and y are tuples (often seen as sets) of variables such that x โˆฉ y = โˆ…, and ฮฆ(x, y)
is a conjunction (often seen as a set) of atoms using only predicates from S. In particular, (๐‘–)
dom(ฮฆ) โІ x โˆช y โˆช ฮ”๐ถ , (๐‘–๐‘–) ๐‘ง โˆˆ x โˆช y implies that ๐‘ง occurs in some atom of ฮฆ, (๐‘–๐‘–๐‘–) x are
the output variables of ๐‘ž, and (๐‘–๐‘ฃ) y are the existential variables of ๐‘ž. To highlight the output
variables, we may write ๐‘ž(x) instead of ๐‘ž. The evaluation of ๐‘ž over an instance ๐ผ is the set
๐‘ž(๐ผ) of every tuple t of constants admitting a homomorphism โ„Žt from ฮฆ(x, y) to ๐ผ such that
โ„Žt (x) = t. A Boolean conjunctive query (BCQ) is a CQ with no output variable, namely an
expression of the form โŸจโŸฉ โ† โˆƒ y ฮฆ(y). An instance ๐ผ satisfies a BCQ ๐‘ž, denoted ๐ผ |= ๐‘ž, if ๐‘ž(๐ผ)
is nonempty, namely ๐‘ž(๐ผ) contains only the empty tuple โŸจโŸฉ.

2.3. Tuple-Generating Dependencies
A tuple-generating dependency (TGD) ๐œŽ โ€”also known as (existential) ruleโ€” over a schema S is a
(first-order) formula of the form

                                    ฮฆ(x, y) โ†’ โˆƒ z ฮจ(x, z),                                      (2)

where x, y, and z are pairwise disjoint tuples of variables, and both ฮฆ(x, y) and ฮจ(x, z) are
conjunctions (often seen as a sets) of atoms using only predicates from S. In particular, (๐‘–)
ฮฆ (resp., ฮจ) contains all and only the variables in x โˆช y (resp., x โˆช z), (๐‘–๐‘–) constants (but not
nulls) may also occur in ๐œŽ, (๐‘–๐‘–๐‘–) x โˆช y are the universal variables of ๐œŽ, (๐‘–๐‘ฃ) z are the existential
variables of ๐œŽ denoted by varโˆƒ (๐œŽ), and (๐‘ฃ) x are the frontier variables of ๐œŽ denoted by front(๐œŽ).
In particular, if varโˆƒ (๐œŽ) = โˆ… and |head(๐œŽ)| = 1, then ๐œŽ is called datalog rule. We refer to
body(๐œŽ) = ฮฆ and head(๐œŽ) = ฮจ as the body and head of ๐œŽ, respectively. With hp(๐œŽ) (resp.,
bp(๐œŽ)) we denote the set of predicates in head(๐œŽ) (resp., body(๐œŽ)). An ontology ฮฃ is a set of
rules. Without loss of generality, we assume that vars(๐œŽ1 ) โˆฉ vars(๐œŽ2 ) = โˆ…, for each pair ๐œŽ1 , ๐œŽ2
of rules in ฮฃ. Operators varโˆƒ , hp, and bp (defined for rules) naturally extend on ontologies. A
class ๐’ž of ontologies is any (typically infinite) set of TGDs fulfilling some syntactic or semantic



                                                 85
Georg Gottlob et al. CEUR Workshop Proceedings                                                 83โ€“96


conditions (see, for example, the classes shown in Table 1, some of which will be formally
defined in the subsequent sections). In particular, Datalog is the class of ontologies containing
only datalog rules. The schema of ฮฃ, denoted sch(ฮฃ), is the subset of S containing all and
only the predicates occurring in ฮฃ, whereas arity(ฮฃ) = max๐‘ƒ โˆˆsch(ฮฃ) arity(๐‘ƒ ). For simplicity
of exposition, we write pos(ฮฃ) instead of pos(sch(ฮฃ)). An instance ๐ผ satisfies a rule ๐œŽ as in
Equation 2, written ๐ผ |= ๐œŽ, if the existence of a homomorphism โ„Ž from ฮฆ to ๐ผ implies the
existence of a homomorphism โ„Žโ€ฒ โЇ โ„Ž|x from ฮจ to ๐ผ. An instance ๐ผ satisfies a set ฮฃ of TGDs,
written ๐ผ |= ฮฃ, if ๐ผ |= ๐œŽ for each ๐œŽ โˆˆ ฮฃ.

2.4. Ontological Query Answering
Consider a database ๐ท and a set ฮฃ of TGDs. A model of ๐ท and ฮฃ is an instance ๐ผ such that
๐ผ โЇ ๐ท and ๐ผ |= ฮฃ. Let mods(๐ท, ฮฃ) be the set of all models of ๐ท and ฮฃ.โ‹‚๏ธ€The certain answers
to a CQ ๐‘ž w.r.t. ๐ท and ฮฃ are defined as the set of tuples cert(๐‘ž, ๐ท, ฮฃ) = ๐‘€ โˆˆmods(๐ท,ฮฃ) ๐‘ž(๐‘€ ).
Accordingly, for any fixed schema S, two ontologies ฮฃ1 and ฮฃ2 over S are said S-equivalent (in
symbols ฮฃ1 โ‰กS ฮฃ2 ) if, for each ๐ท and ๐‘ž over S, it holds that cert(๐‘ž, ๐ท, ฮฃ1 ) = cert(๐‘ž, ๐ท, ฮฃ2 ).
The pair ๐ท and ฮฃ satisfies a BCQ ๐‘ž, written ๐ท โˆช ฮฃ |= ๐‘ž, if cert(๐‘ž, ๐ท, ฮฃ) = โŸจโŸฉ, namely ๐‘€ |= ๐‘ž
for each ๐‘€ โˆˆ mods(๐ท, ฮฃ). Fix a class ๐’ž of ontologies. The computational problem studied in
this work โ€”called CQAns(๐’ž)โ€” can be schematized as follows: given a database ๐ท, a set ฮฃ โˆˆ ๐’ž of
TGDs, a CQ ๐‘ž(x), and a tuple c โˆˆ ๐‘‘๐‘œ๐‘š(๐ท)|x| , does c โˆˆ cert(๐‘ž, ๐ท, ฮฃ) hold? In what follows, we
informally say that ๐’ž is decidable whenever CQAns(๐’ž) is decidable. Note that c โˆˆ cert(๐‘ž, ๐ท, ฮฃ)
if, and only if, ๐ท โˆช ฮฃ |= ๐‘ž(c), where ๐‘ž(c) is the BCQ obtained from ๐‘ž(x) by replacing, for each
๐‘– โˆˆ {1, ..., |x|}, every occurrence x[๐‘–] with c[๐‘–]. Actually, the former problem is AC0 reducible
to the latter. Finally, while considering the computational complexity of CQAns(๐’ž), we recall
the following convention: (๐‘–) combined complexity means that ๐ท, ฮฃ, ๐‘ž, and c are given in input;
and (๐‘–๐‘–) data complexity means that only ๐ท and c are given in input, whereas ฮฃ and ๐‘ž are
considered fixed.

2.5. The Chase Procedure
The chase procedure [17] is a tool exploited for reasoning with TGDs. Consider a database ๐ท and
a set ฮฃ of TGDs. Given an instance ๐ผ โЇ ๐ท, a trigger for ๐ผ is any pair โŸจ๐œŽ, โ„ŽโŸฉ, where ๐œŽ โˆˆ ฮฃ is a rule
as in Equation 2 and โ„Ž is a homomorphism from body(๐œŽ) to ๐ผ. Let ๐ผ โ€ฒ = ๐ผ โˆช โ„Žโ€ฒ (head(๐œŽ)), where
โ„Žโ€ฒ โЇ โ„Ž|x maps each ๐‘ง โˆˆ varโˆƒ (๐œŽ) to a โ€œfreshโ€ null โ„Žโ€ฒ (๐‘ง) not occurring in ๐ผ such that ๐‘ง1 ฬธ= ๐‘ง2 in
varโˆƒ (๐œŽ) implies โ„Žโ€ฒ (๐‘ง1 ) ฬธ= โ„Žโ€ฒ (๐‘ง2 ). Such an operation which constructs ๐ผ โ€ฒ from ๐ผ is called chase
step and denoted โŸจ๐œŽ, โ„ŽโŸฉ(๐ผ) = ๐ผ โ€ฒ . The chase procedure of ๐ท โˆช ฮฃ is an exhaustive application of
chase steps, starting from ๐ท, which produce a sequence ๐ผ0 = ๐ท โŠ‚ ๐ผ1 โŠ‚ ๐ผ2 โŠ‚ ยท ยท ยท โŠ‚ ๐ผ๐‘š โŠ‚ . . .
of instances in such a way that: (๐‘–) for each ๐‘– โ‰ฅ 0, ๐ผ๐‘–+1 = โŸจ๐œŽ, โ„ŽโŸฉ(๐ผ๐‘– ) is a chase step obtained via
some trigger โŸจ๐œŽ, โ„ŽโŸฉ for ๐ผ๐‘– ; (๐‘–๐‘–) for each ๐‘– โ‰ฅ 0, if there exists a trigger โŸจ๐œŽ, โ„ŽโŸฉ for ๐ผ๐‘– , then there
exists some ๐‘— > ๐‘– such that ๐ผ๐‘— = โŸจ๐œŽ, โ„ŽโŸฉ(๐ผ๐‘—โˆ’1 ) is a chase step; and (๐‘–๐‘–๐‘–) any trigger โŸจ๐œŽ, โ„ŽโŸฉ is used
only once. We define chase(๐ท, ฮฃ) = โˆช๐‘–โ‰ฅ0 ๐ผ๐‘– . It is well know that chase(๐ท, ฮฃ) is a universal
model of ๐ท โˆช ฮฃ, that is, for each ๐‘€ โˆˆ mods(๐ท, ฮฃ) there is a homomorphism from chase(๐ท, ฮฃ)
to ๐‘€ . Hence, given a BCQ ๐‘ž it holds that chase(๐ท, ฮฃ) |= ๐‘ž โ‡” ๐ท โˆช ฮฃ |= ๐‘ž. Finally, we recall
that chase(๐ท, ฮฃ) can be decomposed into levels [12]: each atom of ๐ท has level ๐›พ = 0; an atom



                                                 86
Georg Gottlob et al. CEUR Workshop Proceedings                                             83โ€“96


of chase(๐ท, ฮฃ) has level ๐›พ + 1 if, during its generation, the exploited trigger โŸจ๐œŽ, โ„ŽโŸฉ maps the
body of ๐œŽ via โ„Ž to atoms whose maximum level is ๐›พ. We refer to the part of the chase up to
level ๐›พ as chase๐›พ (๐ท, ฮฃ). Clearly, chase(๐ท, ฮฃ) = โˆช๐›พ>0 chase๐›พ (๐ท โˆช ฮฃ).


3. Dyadic Decomposable Sets
In this section we introduce a novel general condition that allows to define, from any decidable
class ๐’ž of ontologies, a new decidable class called Dyadic-๐’ž enjoying desirable properties. We
start with some preliminary notions. Then, we present the new notion of dyadic decomposition.
Finally, we conclude with a computational analysis.

3.1. Preliminary Notions
This section fixes the basics that are needed to define dyadic decomposable sets, by providing
a uniform notation for key existing notions: affected/invaded positions and attacked/protect-
ed/harmless/harmful/dangerous variables [4, 6, 18, 19]. Basically, these notions serve to separate
positions in which the chase can introduce only constants from those where nulls might appear.

Definition 1. Consider an ontology ฮฃ and a variable ๐‘ง โˆˆ varโˆƒ (ฮฃ). A position ๐œ‹ โˆˆ pos(ฮฃ) is
said to be ๐‘ง-affected (or invaded by ๐‘ง) if one of the following two properties holds:
   1. there exists ๐œŽ โˆˆ ฮฃ such that ๐‘ง appears in the head of ๐œŽ at position ๐œ‹;
   2. there exist ๐œŽ โˆˆ ฮฃ and ๐‘ฅ โˆˆ front(๐œŽ) such that ๐‘ฅ occurs both in head(๐œŽ) at position ๐œ‹ and
      in body(๐œŽ) at ๐‘ง-affected positions only.
Moreover, a position ๐œ‹ โˆˆ pos(ฮฃ) is ๐‘†-affected, where ๐‘† โІ varโˆƒ (ฮฃ), if:
   1. for each ๐‘ง โˆˆ ๐‘†, ๐œ‹ is ๐‘ง-affected; and
   2. for each ๐‘ง โˆˆ varโˆƒ (ฮฃ), if ๐œ‹ is ๐‘ง-affected, then ๐‘ง โˆˆ ๐‘†.

Note that for every position ๐œ‹ there exists a unique set ๐‘† such that ๐œ‹ is ๐‘†-affected. We
write aff(๐œ‹) for this set ๐‘†. Moreover, aff(ฮฃ) = {๐œ‹ โˆˆ pos(ฮฃ) | aff(๐œ‹) ฬธ= โˆ…}, and nonaff(ฮฃ) =
pos(ฮฃ) โˆ– aff(ฮฃ). We can now categorize the variables occurring in a conjunction of atoms with
the following definition.

Definition 2. Given a TGD ๐œŽ โˆˆ ฮฃ and a variable ๐‘ฅ in body(๐œŽ):

   โˆ™ if ๐‘ฅ occurs at positions ๐œ‹1 , . . . , ๐œ‹๐‘› and ๐‘›๐‘–=1 aff(๐œ‹๐‘– ) = โˆ…, then ๐‘ฅ is harmless,
                                                 โ‹‚๏ธ€
                                            โ‹‚๏ธ€๐‘›
   โˆ™ if ๐‘ฅ is not harmless, placed ๐‘† = ๐‘–=1 aff(๐œ‹๐‘– ), then it is ๐‘†-harmful,
   โˆ™ if ๐‘ฅ is ๐‘†-harmful and belongs to front(๐œŽ), then ๐‘ฅ is ๐‘†-dangerous.

Given a variable ๐‘ฅ that is ๐‘†-dangerous, we write dang(๐‘ฅ) for the set ๐‘†. Hereinafter, the prefix
๐‘†- is omitted when it is not necessary. Consider an ontology ฮฃ. Given a rule ๐œŽ โˆˆ ฮฃ, we denote
by dang(๐œŽ) (resp., harmless(๐œŽ) and harmful(๐œŽ)) the dangerous (resp., harmless and harmful)
variables in ๐œŽ. These sets of variables naturally extend to the whole ฮฃ by taking, for each of
them, the union over all the rules of ฮฃ.




                                                 87
Georg Gottlob et al. CEUR Workshop Proceedings                                                            83โ€“96


3.2. Dyadic TGDs
In order to define the notion of Dyadic TGDs, we now introduce the concept of head-ground set
of rules, being roughly โ€œnon-recursiveโ€ rules in which nulls are neither created nor propagated.
Definition 3. Consider a set ฮฃ of TGDs. A set ฮฃโ€ฒ โІ ฮฃ is head-ground w.r.t. ฮฃ if:
   1. ฮฃโ€ฒ โˆˆ Datalog;
   2. each head atom of ฮฃโ€ฒ contains only harmless variables w.r.t. ฮฃ;
   3. hp(ฮฃโ€ฒ ) โˆฉ bp(ฮฃโ€ฒ ) = โˆ…;
   4. hp(ฮฃโ€ฒ ) โˆฉ hp(ฮฃ โˆ– ฮฃโ€ฒ ) = โˆ….
The following example is given to better understand the above definition.
Example 1. Consider the next set of rules:

                        ๐œŽ1 :              ๐‘…(๐‘ฅ1 , ๐‘ฆ1 )       โ†’    โˆƒ ๐‘ง1 , ๐‘ค1 ๐‘„(๐‘ง1 , ๐‘ค1 )
                        ๐œŽ2 :    ๐ถ(๐‘ฆ2 ), ๐‘…(๐‘ฅ2 , ๐‘ง2 )         โ†’    ๐‘†(๐‘ฆ2 , ๐‘ง2 )
                        ๐œŽ3 : ๐ท(๐‘ฆ3 , ๐‘ง3 ), ๐‘…(๐‘ฅ3 , ๐‘ค3 )       โ†’    ๐‘‡ (๐‘ฅ3 , ๐‘ฆ3 )
                        ๐œŽ4 :              ๐‘„(๐‘ฅ4 , ๐‘ฆ4 )       โ†’    โˆƒ ๐‘ง4 ๐ด(๐‘ฅ4 , ๐‘ง4 )
                        ๐œŽ5 : ๐ด(๐‘ฅ5 , ๐‘ง5 ), ๐ท(๐‘ฆ5 , ๐‘ง5 )       โ†’    ๐‘„(๐‘ฅ5 , ๐‘ฆ5 )

A subset of head ground rule w.r.t. ฮฃ is given by ฮฃHG = {๐œŽ2 , ๐œŽ3 }. In fact, harmless(ฮฃ) is the
set {๐‘ฅ1 , ๐‘ฆ1 , ๐‘ฆ2 , ๐‘ฅ2 , ๐‘ง2 , ๐‘ฅ3 , ๐‘ฆ3 , ๐‘ง3 , ๐‘ฆ5 , ๐‘ง5 }; hence, it is easy to check that (๐‘–) ๐œŽ2 and ๐œŽ3 are datalog
rules; (๐‘–๐‘–) the head atoms of ๐œŽ2 and ๐œŽ3 contain only harmless variables; (๐‘–๐‘–๐‘–) both predicates
that appear in head(๐œŽ2 ) and head(๐œŽ3 ) do not occur in any body of ฮฃHG , (๐‘–๐‘ฃ) nor in the head of
rules ๐œŽ1 , ๐œŽ4 and ๐œŽ5 . To the contrary, rules ๐œŽ1 , ๐œŽ4 and ๐œŽ5 could not be in ฮฃHG , since they violate
Properties 2 and 3 of Definition 3. Hence, we observe that the set ฮฃHG is maximal.
   We are now ready to formally introduce the class Dyadic-๐’ž.
Definition 4. Consider a class ๐’ž of TGDs, and a set ฮฃ of TGDs. Let S = sch(ฮฃ). A pair
(ฮฃHG , ฮฃ๐’ž ) of TGDs is a dyadic decomposition of ฮฃ w.r.t. ๐’ž if:
   1. ฮฃHG โˆช ฮฃ๐’ž โ‰กS ฮฃ;
   2. ฮฃ๐’ž โˆˆ ๐’ž;
   3. ฮฃHG is head-ground w.r.t. ฮฃHG โˆช ฮฃ๐’ž ; and
   4. the head atoms of ฮฃHG do not occur in ฮฃ.
Dyadic-๐’ž is the class of all sets of TGDs that admit a dyadic decomposition w.r.t. ๐’ž.
The union of all Dyadic-๐’ž, with ๐’ž being any decidable class of TGDs, forms what we call dyadic
decomposable sets, which encompass and generalize any other existing decidable class, including
those based on semantic conditions.
   We now provide an example of a Dyadic-Shy ontology, where Shy [4] is a known decidable
class. Before that, we recall the syntactic conditions underlying this class. A set ฮฃ of TGDs is
shy if, for each ๐œŽ โˆˆ ฮฃ the following conditions both hold: (๐‘–) if a variable ๐‘ฅ occurs in more
than one body atom, then ๐‘ฅ is harmless; (๐‘–๐‘–) for every pair of distinct dangerous variable ๐‘ง and
๐‘ค in different atoms, dang(๐‘ง) โˆฉ dang(๐‘ค) = โˆ…. The class of all shy ontologies is called Shy.



                                                       88
Georg Gottlob et al. CEUR Workshop Proceedings                                                83โ€“96


Example 2. Let consider the following set ฮฃ of TGDs:

                      ๐œŽ1 :                       ๐‘…(๐‘ฅ1 , ๐‘ฆ1 )     โ†’    โˆƒ ๐‘ง1 ๐‘‡ (๐‘ง1 )
                      ๐œŽ2 :                       ๐‘…(๐‘ฅ2 , ๐‘ฆ2 )     โ†’    โˆƒ ๐‘ง2 ๐‘‰ (๐‘ง2 )
                      ๐œŽ3 :                       ๐‘†(๐‘ฅ3 , ๐‘ฆ3 )     โ†’    โˆƒ ๐‘ง3 ๐‘ƒ (๐‘ง3 )
                      ๐œŽ4 :                           ๐‘‰ (๐‘ฅ4 )     โ†’    ๐‘„(๐‘ฅ4 )
                      ๐œŽ5 : ๐‘‡ (๐‘ฅ5 ), ๐‘ƒ (๐‘ฆ5 ), ๐‘‰ (๐‘ง5 ), ๐‘„(๐‘ง5 )     โ†’    ๐‘ˆ (๐‘ฅ5 , ๐‘ฆ5 )

where harmless(ฮฃ) = {๐‘ฅ1 , ๐‘ฆ1 , ๐‘ฅ2 , ๐‘ฆ2 , ๐‘ฅ3 , ๐‘ฆ3 }, harmful(ฮฃ) = {๐‘ฅ4 , ๐‘ฅ5 , ๐‘ฆ5 , ๐‘ง5 }, and dang(ฮฃ) =
{๐‘ฅ4 , ๐‘ฅ5 , ๐‘ฆ5 }. A dyadic decomposition of ฮฃ w.r.t. Shy is given by (ฮฃHG , ฮฃ๐’ฎ ), where ฮฃHG is:

                                              ๐‘…(๐‘ฅ1 , ๐‘ฆ1 )   โ†’    ๐ด๐‘ข๐‘ฅ1 (๐‘ฅ1 , ๐‘ฆ1 )
                                              ๐‘…(๐‘ฅ2 , ๐‘ฆ2 )   โ†’    ๐ด๐‘ข๐‘ฅ2 (๐‘ฅ2 , ๐‘ฆ2 )
                                              ๐‘†(๐‘ฅ3 , ๐‘ฆ3 )   โ†’    ๐ด๐‘ข๐‘ฅ3 (๐‘ฅ3 , ๐‘ฆ3 )
                                                  ๐‘‰ (๐‘ฅ4 )   โ†’    ๐ด๐‘ข๐‘ฅ4 ()
                        ๐‘‡ (๐‘ฅ5 ), ๐‘ƒ (๐‘ฆ5 ), ๐‘‰ (๐‘ง5 ), ๐‘„(๐‘ง5 )   โ†’    ๐ด๐‘ข๐‘ฅ5 ()

and ฮฃ๐’ฎ is:
                                      ๐ด๐‘ข๐‘ฅ1 (๐‘ฅ1 , ๐‘ฆ1 )       โ†’   โˆƒ ๐‘ง1 ๐‘‡ (๐‘ง1 )
                                      ๐ด๐‘ข๐‘ฅ2 (๐‘ฅ2 , ๐‘ฆ2 )       โ†’   โˆƒ ๐‘ง2 ๐‘‰ (๐‘ง2 )
                                      ๐ด๐‘ข๐‘ฅ3 (๐‘ฅ3 , ๐‘ฆ3 )       โ†’   โˆƒ ๐‘ง3 ๐‘ƒ (๐‘ง3 )
                                    ๐‘‰ (๐‘ฅ4 ), ๐ด๐‘ข๐‘ฅ4 ()        โ†’   ๐‘„(๐‘ฅ4 )
                            ๐‘‡ (๐‘ฅ5 ), ๐‘ƒ (๐‘ฆ5 ), ๐ด๐‘ข๐‘ฅ5 ()       โ†’   ๐‘ˆ (๐‘ฅ5 , ๐‘ฆ5 )
According to the above decomposition, the considered set ฮฃ is Dyadic-Shy.
  Note that, in general, without any assumption on the specific class ๐’ž, we do not have
any concrete means to construct a dyadic decomposition for an arbitrary Dyadic-๐’ž ontology.
Concerning Dyadic-Shy, however, in Section 4, we define a syntactic subclass โ€”called Ward+ โ€”
for which a dyadic decomposition is (easily) computable.

3.3. Decidability and Complexity
To provide an algorithm for computing the answers to a query ๐‘ž over a database ๐ท paired with
a set ฮฃ โˆˆ Dyadic-๐’ž, we are going to exploit the dyadic decomposition (ฮฃHG , ฮฃ๐’ž ) of ฮฃ w.r.t.
๐’ž. Our idea is to reduce query answering over Dyadic-๐’ž to query answering over ๐’ž, the latter
being decidable by assumption. To this aim, we first โ€œcomplete" ๐ท by adding all the โ€œauxiliaryโ€
ground consequences of ๐ท โˆช ฮฃHG โˆช ฮฃ๐’ž , contained in the set

                    ๐ทโ€ฒ = {๐‘Ž โˆˆ chase(๐ท, ฮฃHG โˆช ฮฃ๐’ž ) | pred(๐‘Ž) โˆˆ hp(ฮฃHG )}.                         (3)

Let ๐’Ÿ = ๐ท โˆช ๐ทโ€ฒ be the result of this completion operation. We point out that ๐ทโ€ฒ actually
contains only ground atoms, since the atoms generated during the chase procedure that derive
from the head rules of ฮฃHG cannot contain nulls by definition of head-ground rules. Accordingly,
we evaluate the query ๐‘ž over ๐’Ÿ โˆช ฮฃ๐’ž . Therefore, to show that Dyadic-๐’ž is decidable, it suffices
to prove that ๐ทโ€ฒ is computable and also that cert(๐‘ž, ๐ท, ฮฃ) = cert(๐‘ž, ๐’Ÿ, ฮฃ๐’ž ) holds for any CQ ๐‘ž.
We start by showing the correctness of our reduction.



                                                   89
Georg Gottlob et al. CEUR Workshop Proceedings                                             83โ€“96


 Algorithm 1: Database Completion w.r.t. a fixed decidable class ๐’ž of TGDs
  Input: A dyadic decomposition (ฮฃHG , ฮฃ๐’ž ) of ฮฃ w.r.t. ๐’ž
          A database ๐ท
  Output: The completed database ๐’Ÿ
1 ๐’Ÿ := ๐ท
2 ๐ทหœ := โˆ…
3 for each rule of the form ฮฆ(x, y) โ†’ Aux ๐‘– (x) in ฮฃHG do
4     ๐‘ž := โŸจxโŸฉ โ† ฮฆ(x, y)
5     หœ =๐ท
      ๐ท     หœ โˆช {Aux ๐‘– (t) | t โˆˆ cert(๐‘ž, ๐’Ÿ, ฮฃ๐’ž )}
6 if (๐ท โˆช ๐ทหœ โŠƒ ๐’Ÿ) then
7     ๐’Ÿ := ๐ท โˆช ๐ท หœ
8     go to instruction 2
9 return ๐’Ÿ




Lemma 1. Fix a decidable class ๐’ž of TGDs. Consider a database ๐ท, a set ฮฃ โˆˆ Dyadic-๐’ž and
a conjunctive query ๐‘ž(x). Let (ฮฃHG , ฮฃ๐’ž ) be a dyadic decomposition of ฮฃ w.r.t. ๐’ž and let
๐’Ÿ = ๐ท โˆช ๐ทโ€ฒ , where ๐ทโ€ฒ = {๐‘Ž โˆˆ chase(๐ท, ฮฃHG โˆช ฮฃ๐’ž ) | pred(๐‘Ž) โˆˆ hp(ฮฃHG )}. Then, it holds that
cert(๐‘ž, ๐ท, ฮฃ) = cert(๐‘ž, ๐’Ÿ, ฮฃ๐’ž ).

Proof. Let S = sch(ฮฃ). Since, by hypothesis, (ฮฃHG , ฮฃ๐’ž ) is a dyadic decomposition of ฮฃ, by
Definition 4, it holds that ฮฃ โ‰กS ฮฃHG โˆช ฮฃ๐’ž . Hence, by definition of S-equivalence, we have

                            cert(๐‘ž, ๐ท, ฮฃ) = cert(๐‘ž, ๐ท, ฮฃHG โˆช ฮฃ๐’ž )                             (4)

Fix any arbitrary |x|-ary tuple c of constants. From Equation 4, we immediately get that
c โˆˆ cert(๐‘ž, ๐ท, ฮฃ) if, and only if, c โˆˆ cert(๐‘ž, ๐ท, ฮฃHG โˆช ฮฃ๐’ž ). Thus, let ๐‘ž โ€ฒ = ๐‘ž(c), we now have

                             ๐ท โˆช ฮฃ |= ๐‘ž โ€ฒ โ‡” ๐ท โˆช ฮฃHG โˆช ฮฃ๐’ž |= ๐‘ž โ€ฒ .                             (5)

  To show cert(๐‘ž, ๐ท, ฮฃ) โІ cert(๐‘ž, ๐’Ÿ, ฮฃ๐’ž ), it suffices to prove that ๐ท โˆช ฮฃ |= ๐‘ž โ€ฒ implies
๐’Ÿ โˆช ฮฃ๐’ž |= ๐‘ž โ€ฒ . Assume ๐ท โˆช ฮฃ |= ๐‘ž โ€ฒ holds. By Equation 5, we know that ๐ท โˆช ฮฃHG โˆช ฮฃ๐’ž |= ๐‘ž โ€ฒ
holds too. Hence, chase(๐ท, ฮฃHG โˆช ฮฃ๐’ž ) |= ๐‘ž โ€ฒ . Since ๐ทโ€ฒ โŠ‚ chase(๐ท, ฮฃHG โˆช ฮฃ๐’ž ), it holds that
chase(๐ท โˆช ๐ทโ€ฒ , ฮฃHG โˆช ฮฃ๐’ž ) |= ๐‘ž โ€ฒ . Since ๐ทโ€ฒ contains all the auxiliary ground consequences of
ฮฃHG , the latter becomes equivalent to chase(๐ท โˆช ๐ทโ€ฒ , ฮฃ๐’ž ) |= ๐‘ž โ€ฒ . Hence, ๐ท โˆช ๐ทโ€ฒ โˆช ฮฃ๐’ž |= ๐‘ž โ€ฒ .
Since, by hypothesis, ๐’Ÿ = ๐ท โˆช ๐ทโ€ฒ , we finally get that ๐’Ÿ โˆช ฮฃ๐’ž |= ๐‘ž โ€ฒ .
   To show that cert(๐‘ž, ๐ท, ฮฃ) โЇ cert(๐‘ž, ๐’Ÿ, ฮฃ๐’ž ) it suffices to prove that if ๐’Ÿ โˆช ฮฃ๐’ž |= ๐‘ž โ€ฒ , then
๐ท โˆช ฮฃ |= ๐‘ž โ€ฒ . Assume that ๐’Ÿ โˆช ฮฃ๐’ž |= ๐‘ž โ€ฒ , hence chase(๐’Ÿ, ฮฃ๐’ž ) |= ๐‘ž โ€ฒ . Since ฮฃ๐’ž โІ ฮฃHG โˆช ฮฃ๐’ž ,
it holds that chase(๐’Ÿ, ฮฃHG โˆช ฮฃ๐’ž ) |= ๐‘ž โ€ฒ . By hypothesis, ๐ทโ€ฒ โІ chase(๐ท, ฮฃHG โˆช ฮฃ๐’ž ); hence
chase(๐ท, ฮฃHG โˆช ฮฃ๐’ž ) |= ๐‘ž โ€ฒ , that is ๐ท โˆช ฮฃHG โˆช ฮฃ๐’ž |= ๐‘ž โ€ฒ . Applying Equation 5, it holds that
๐ท โˆช ฮฃ |= ๐‘ž โ€ฒ , and hence the thesis.

  With Lemma 1 in place, we now design Algorithm 1 in order to iteratively construct the
set ๐’Ÿ = ๐ท โˆช ๐ทโ€ฒ , with ๐ทโ€ฒ being the set defined by Equation 3. Roughly speaking, the first



                                                 90
Georg Gottlob et al. CEUR Workshop Proceedings                                                83โ€“96


two instructions are required, respectively, to add ๐ท to ๐’Ÿ and to initialize a temporary set
๐ทหœ used to store ground consequences derived from ฮฃHG . The rest of the algorithm is an
iterative procedure that computes the answers (instruction 5) to the queries constructed from
the rules of ฮฃHG (instruction 4) and completes the initial database ๐ท (instruction 7) until no
more auxiliary ground atoms can be produced (instruction 6). We point out that, in general,
๐ทหœ โІ ๐ทโ€ฒ holds; in particular, ๐ท
                              หœ = ๐ทโ€ฒ holds in the last execution of instruction 7 or, equivalently,
when the condition ๐ท โˆช ๐ท หœ โŠƒ ๐’Ÿ examined at instruction 6 is false, since all the auxiliary ground
atoms have been added to ๐’Ÿ. We now prove that Algorithm 1 always terminates and correctly
constructs ๐’Ÿ.
Lemma 2. Fix a decidable class ๐’ž of TGDs. Consider a database ๐ท and a set ฮฃ of Dyadic-๐’ž TGDs.
Let (ฮฃHG , ฮฃ๐’ž ) be a dyadic decomposition of ฮฃ, and ๐ทโ€ฒ be the set of ground auxiliary atoms
defined as {๐‘Ž โˆˆ chase(๐ท, ฮฃHG โˆช ฮฃ๐’ž ) | pred(๐‘Ž) โˆˆ hp(ฮฃHG )}. Then, Algorithm 1 both terminates
and computes ๐ท โˆช ๐ทโ€ฒ .
Proof sketch. We split the proof in two parts.
Termination. To prove the termination of Algorithm 1, it suffices to show that each instruction
alone always terminates and that the overall procedure never falls into an infinite loop. First,
observe that |๐ทโ€ฒ | โ‰ค |hp(ฮฃHG )| ยท ๐‘‘๐œ‡ , where ๐‘‘ = |const(๐ท)| and ๐œ‡ = max๐‘ƒ โˆˆhp(ฮฃHG ) arity(๐‘ƒ ).
                                                                                               หœ โІ ๐ทโ€ฒ
Instructions 1, 2, 4, 8 and 9 trivially terminates. Instructions 6 and 7 both terminate, since ๐ท
always holds (see correctness below). Each time instruction 3 is reached, the for-loop simply
scans the set ฮฃHG , which is finite by definition. Concerning instruction 5, it suffices to observe
that its termination relies on the termination of CQAns(๐’ž) โ€”which is true by hypothesisโ€”
and on the fact that, for each query ๐‘ž, to construct the set {Aux ๐‘– (t) | t โˆˆ cert(๐‘ž, ๐’Ÿ, ฮฃ๐’ž )}, the
problem CQAns(๐’ž) must be solved at most ๐‘‘๐œ‡ times, being the maximum number of tuples
t for which the check t โˆˆ cert(๐‘ž, ๐’Ÿ, ฮฃ๐’ž ) has to be performed. Since each instruction alone
terminates, it remains to analyze the overall procedure. It contains two loops. The first, namely
the for-loop at instruction 3, is not problematic; indeed, we shown that it locally terminates.
The second one, namely the go to-loop, depends on the evaluation of the if-instruction, which
can be executed at most |๐ทโ€ฒ | times. Thus, also the go to-loop does the same.
Correctness. We now claim that Algorithm 1 correctly completes the database. Let ๐’Ÿ be the
output of Algorithm 1. Our claim is that ๐’Ÿ = ๐ท โˆช ๐ทโ€ฒ .
  Inclusion 1 (๐ท โˆช ๐ทโ€ฒ โІ ๐’Ÿ). Assume, by contradiction, that ๐ท โˆช ๐ทโ€ฒ contains some atom
that does not belong to ๐’Ÿ. This means that there exists some ๐‘— > 0 such that both ๐ท      ยฏ =
        โ€ฒ          ๐‘—โˆ’1                                    โ€ฒ         ๐‘—
((๐ท โˆช ๐ท ) โˆฉ chase (๐ท, ฮฃHG โˆช ฮฃ๐’ž )) โІ ๐’Ÿ and ((๐ท โˆช ๐ท ) โˆฉ chase (๐ท, ฮฃHG โˆช ฮฃ๐’ž )) โˆ– ๐’Ÿ =         ฬธ โˆ…
                                         ๐‘—
hold. Thus, there exists some ๐›ผ โˆˆ chase (๐ท, ฮฃHG โˆช ฮฃ๐’ž ) whose level is exactly ๐‘— and that does
not belong to ๐’Ÿ. Let โŸจ๐œŽ, โ„ŽโŸฉ be the trigger used by the chase to generate ๐›ผ, where ๐œŽ is of the
form ฮฆ(x, y) โ†’ Aux (x). Clearly, โ„Ž maps ฮฆ(x, y) to chase๐‘—โˆ’1 (๐ท, ฮฃHG โˆช ฮฃ๐’ž ), and we also
have that ๐›ผ = Aux (โ„Ž(x)). Consider now the query ๐‘ž = โŸจxโŸฉ โ† ฮฆ(x, y) constructed from ๐œŽ by
                                                                                    ยฏ โІ ๐’Ÿ, we
Algorithm 1 at instruction 4. Thus, chase๐‘—โˆ’1 (๐ท, ฮฃHG โˆช ฮฃ๐’ž ) |= ๐‘ž(โ„Ž(x)) holds. Since ๐ท
                ๐‘—โˆ’1                           ยฏ
have that chase (๐ท, ฮฃHG โˆช ฮฃ๐’ž ) โІ chase(๐ท, ฮฃ๐’ž ) โІ chase(๐’Ÿ, ฮฃ๐’ž ). Hence, chase(๐’Ÿ, ฮฃ๐’ž ) |=
๐‘ž(โ„Ž(x)), namely โ„Ž(x) โˆˆ cert(๐‘ž, ๐’Ÿ, ฮฃ๐’ž ) and, thus, ๐›ผ โˆˆ ๐’Ÿ, which is a contradiction.
  Inclusion 2 (๐’Ÿ โІ ๐ท โˆช ๐ทโ€ฒ ). An argument analogous for the fist inclusion can be provided also
for this second case. Here we assume, by contradiction, that ๐’Ÿ contains some atom that does



                                                 91
Georg Gottlob et al. CEUR Workshop Proceedings                                                 83โ€“96


not belong to ๐ท โˆช ๐ทโ€ฒ . Let โ„“ be the number of time instruction 7 of Algorithm 1 is executed. Let
๐ทหœ 0 = ๐ท and, for each ๐‘– โˆˆ [โ„“], ๐ท
                                หœ ๐‘– denote the specific ๐ท หœ appearing at instruction 7 the ๐‘–-th time
                         หœ    หœ
it is executed. Let ๐ผ๐‘– = ๐ท๐‘– โˆ– ๐ท๐‘–โˆ’1 , for each ๐‘– โˆˆ [โ„“]. It can be shown that there exists a sequence
of chase applications leading to chase(๐ท, ฮฃHG โˆช ฮฃ๐’ž ) such that, for each ๐‘– โˆˆ [โ„“] and for each
atom ๐›ผ โˆˆ ๐ผ๐‘– , ๐›ผ is generated via such a chase sequence at a certain level (in general, different
from ๐‘–) being strictly greater than the level of every other atom contained in ๐ท    หœ ๐‘–โˆ’1 . This is a
contradiction since ๐’Ÿ = ๐ท โˆช ๐ทโ„“ .หœ

   It remains to show that Dyadic-๐’ž is decidable. We rely on Algorithm 1 together with Lemma
2 and Lemma 1 to state the following:

Theorem 1. Let ๐’ž be a decidable class of TGDs. Then, Dyadic-๐’ž is decidable.

  We point out that Algorithm 1 does not depend on the technique exploited for performing
query answering over the class ๐’ž; hence, such external techniques can be used like a โ€œblack
boxโ€. We can now study the complexity of CQAns(๐’ž) for an arbitrary decidable class ๐’ž.

Theorem 2. Consider a decidable class ๐’ž of TGDs. Assume that CQAns(๐’ž) is complete in data
complexity for a certain complexity class C. The following are true:
   1. If C โІ PTime, then CQAns(Dyadic-๐’ž) is in PTime in data complexity;
   2. If C โЇ PTime, then CQAns(Dyadic-๐’ž) is in PTimeC in data complexity;
   3. If C โЇ PTime is deterministic, then CQAns(Dyadic-๐’ž) is C-complete in data complexity.

Proof sketch. To prove the memberships of point 1 and 2, we rely on the complexity of Al-
gorithm 1. In particular, let ๐ท be a database, ฮฃ โˆˆ ๐’ž an ontology, (ฮฃHG , ฮฃ๐’ž ) a dyadic de-
composition of ฮฃ, and ๐ทโ€ฒ the set defined in Equation 3. Moreover, let ๐‘‘ = |const(๐ท)| and
๐œ‡ = max๐‘ƒ โˆˆhp(ฮฃHG ) arity(๐‘ƒ ). Via Lemma 2, we shown that Algorithm 1 always terminates and
it correctly constructs the completed database ๐’Ÿ = ๐ท โˆช ๐ทโ€ฒ . In particular, by neglecting the
computational cost of the โ€œtrivialโ€ instructions (i.e., 1โ€“4 and 6โ€“9), Algorithm 1 overall calls
|ฮฃHG | ยท |hp(ฮฃHG )| ยท ๐‘‘2๐œ‡ times the problem CQAns(๐’ž). To reach the claimed bounds, first, we
observe that ๐’Ÿ is polynomial in ๐ท. Moreover, since we are in data complexity, the following
parameters are bounded: the maximum arity ๐œ‡, the size of both ฮฃHG and ฮฃ๐’ž , as well as the
size and the number of each query ๐‘ž constructed at instruction 4. Hence, Algorithm 1 calls
polynomially many times CQAns(๐’ž). Finally, hardnesses of point 3 follow from the fact that for
any deterministic class C โЇ PTime, we know that PTimeC = C, and from the fact that Dyadic-๐’ž
includes the class ๐’ž.

  A similar analysis can be performed in combined complexity. Here, however, we need further
assumptions on: (๐‘–) the size of dyadic decompositions being equivalent to the ontologies of
Dyadic-๐’ž; and (๐‘–๐‘–) both the data and combined complexity of the class ๐’ž under consideration.


4. Ward+
We start this section recalling the syntactic condition of the class Ward [10, 19], useful for
the comprehension of the new class Ward+ that we will introduce below. We point out that



                                                 92
Georg Gottlob et al. CEUR Workshop Proceedings                                             83โ€“96




                             (a)                                      (b)

Figure 1: (a)Structure of a ward+ rule. (b)Syntactical relation among classes.


we state the wardedness condition according to Definition 2; hence, the class Ward presented
here is actually larger than the original one. A set ฮฃ of TGDs is warded if, for each ๐œŽ โˆˆ ฮฃ,
there are no dangerous variables in body(๐œŽ), or there exists an atom ๐›ผ โˆˆ body(๐œŽ), called a
ward, such that:(๐‘–) all the dangerous variables in body(๐œŽ) occur in ๐›ผ, and (๐‘–๐‘–) each variable of
vars(๐›ผ) โˆฉ vars(body(๐œŽ) โˆ– {๐›ผ}) is harmless. The class of all warded ontologies is called Ward.
   We now formally introduce the syntactic condition that gives rise to the class Ward+ gen-
eralizing the well-known decidable classes Shy and Ward, and being included in Dyadic-Shy.
Intuitively, the condition can be explained as follows. If ๐œŽ is a ward+ rule, then body(๐œŽ) can be
partitioned into two sets of atoms, ๐ต1 and ๐ต2 , that share only harmless variables (see Figure
1(a)). Having in mind the notion of wardedness, the set ๐ต1 can be seen as a โ€œmulti-ward" that
contains all the dangerous variables and that, at the same time, satisfies the shyness conditions.
The set ๐ต2 , instead, is any atoms conjunction that can share with ๐ต1 only harmless variables.
More formally, a set of ward+ TGDs is defined as follows.
Definition 5. A set ฮฃ of TGDs is ward+ if, for each TGD ๐œŽ โˆˆ ฮฃ, there are no dangerous
variables in body(๐œŽ), or there exists a partition {๐ต1 , ๐ต2 } of body(๐œŽ) such that:
   1. ๐ต1 contains all the dangerous variables
   2. vars(๐ต1 ) โˆฉ vars(๐ต2 ) are harmless variables
   3. for every pair of distinct dangerous variable ๐‘ง and ๐‘ค in different atoms, dang(๐‘ง) โˆฉ
      dang(๐‘ค) = โˆ…
   4. for every pair of distinct atoms ๐‘Ž, ๐‘ โˆˆ ๐ต1 , vars(๐‘Ž) โˆฉ vars(๐‘) are harmless variables.
We write Ward+ for the class of all finite ward+ sets of TGDs.
  Below we propose an example of an ontology that is in Ward+ and an example of one that
does not belong to Ward+ , respectively.
Example 3. Consider the ontology ฮฃ of Example 2. It easy to see that ๐œŽ1 , ๐œŽ2 , ๐œŽ3 and ๐œŽ4 are
trivially ward+ rules w.r.t. ฮฃ, since they are rules with one single body atom, which cannot
violate any conditions of Definition 5. Let us focus on rule ๐œŽ5 . Since dang(๐œŽ5 ) = {๐‘ฅ5 , ๐‘ฆ5 },
harmful(๐œŽ5 ) = {๐‘ง5 } and harmless(๐œŽ5 ) = โˆ…, there exists a partition of body(๐œŽ5 ) into two set
๐ต1 , ๐ต2 , that satisfies Definition 5, where, ๐ต1 = {๐‘‡ (๐‘ฅ5 ), ๐‘ƒ (๐‘ฆ5 )} and ๐ต2 = {๐‘‰ (๐‘ง5 ), ๐‘„(๐‘ง5 )}.
Hence, ฮฃ โˆˆ Ward+ .



                                                  93
Georg Gottlob et al. CEUR Workshop Proceedings                                             83โ€“96


Example 4. Let ฮฃ be the following set of TGDs:
                    ๐œŽ1 :                    ๐‘ƒ (๐‘ฅ1 ) โ†’ โˆƒ ๐‘ฆ1 ๐‘†(๐‘ฆ1 )
                    ๐œŽ2 :                     ๐‘†(๐‘ฅ2 ) โ†’ โˆƒ ๐‘ฆ2 , ๐‘ง2 ๐‘…(๐‘ฆ2 , ๐‘ฅ2 , ๐‘ง2 )
                    ๐œŽ3 :   ๐‘…(๐‘ฅ3 , ๐‘ฆ3 , ๐‘ง3 ), ๐‘†(๐‘ฆ3 ) โ†’ ๐‘‡ (๐‘ฅ3 , ๐‘ฆ3 , ๐‘ง3 )
We pay particular attention to rule ๐œŽ3 , since as previously explained, rules ๐œŽ1 and ๐œŽ2 , that
have only one body atom, do not go against the definition of ward+ rule. Here, Condition 4 of
Definition 5 is violated, since there is a join on variable ๐‘ฆ3 that appears at positions ๐‘…[2] and
๐‘†[1], both ๐‘ฆ1 -affected.
  Now we show that Ward+ strictly includes both Shy and Ward. According to Definition 5,
the class Ward trivially coincides with the class Ward+ if |๐ต1 | = 1; thus, Ward โІ Ward+ . On
the other hand, if |๐ต2 | = โˆ…, we have that Shy โІ Ward+ , since the โ€œmulti-ward" satisfies the
shyness conditions. We show that the latter relations are strict inclusions presenting a set of
TGDs that belongs to Ward+ , but it is not both in Shy and Ward.
Example 5. Let ฮฃ be the ontology introduced in Example 2. It is easy to see that ๐œŽ1 , ๐œŽ2 , ๐œŽ3
and ๐œŽ4 are both shy and warded rules w.r.t. ฮฃ, since they are rules with one single body atom,
which cannot violate any condition of the classes under consideration. However, rule ๐œŽ5 โˆˆ      /
Ward, since the dangerous variables ๐‘ฅ5 and ๐‘ฆ5 are not contained in a single ward, and ๐œŽ5 โˆˆ     /
Shy, since there is a join on the variable ๐‘ง5 that is ๐‘ง2 -harmful. Hence, ฮฃ โˆˆ Ward+ (see Example
3), but ฮฃ ฬธโˆˆ Shy and ฮฃ ฬธโˆˆ Ward.
  Accordingly, it follows the next result.
Theorem 3. Ward+ โŠƒ Shy โˆช Ward.
   To show that Ward+ โŠ‚ Dyadic-Shy, we have to prove the existence of a dyadic decomposition
(ฮฃHG , ฮฃ๐’ฎ ) for every set ฮฃ of ward+ TGDs. Intuitively, the construction of a dyadic decompo-
sition for a ward+ set of TGDs takes advantage of the structure of a ward+ rule. Indeed, by
definition, a ward+ rule can be always partitioned into two sets ๐ต1 and ๐ต2 of atoms, where ๐ต1
is a conjunction of atoms that satisfies the shyness conditions, and ๐ต2 is any atom conjunction.
Roughly speaking, starting from a rule ๐œŽ โˆˆ Ward+ , a rule in ฮฃHG has the same body of ๐œŽ, while
the head contains a โ€œfresh" atom in which are propagated only harmless variables; this last
atom, with the set ๐ต1 , is used to construct the body of a rule in ฮฃ๐’ฎ , while the head contains
the same atoms of head(๐œŽ) (see Example 2). Now, we formally prove the existence of a dyadic
decomposition for a ward+ set ฮฃ of TGDs with respect to Shy.
Theorem 4. For every ฮฃ โˆˆ Ward+ , there is a dyadic decomposition (ฮฃHG , ฮฃ๐’ฎ ) of ฮฃ w.r.t. Shy.
Proof. Let ฮฃ be a set of ward+ TGDs. To show the existence of a dyadic decomposition
(ฮฃHG , ฮฃ๐’ฎ ) of ฮฃ w.r.t. Shy, we propose the following procedure. Consider a ward+ rule
                           ๐œŽ : ฮฆ(x, y, z), ฮจ(z, u) โ†’ โˆƒ w ฮž(x, w, z),
where x, y, z, u are pairwise disjoint, ฮฆ(x, y, z), ฮจ(z, u) and ฮž(x, w, z) are conjunctions of
atoms such that ฮฆ(x, y, z) = ๐ต1 and ฮจ(z, u) = ๐ต2 (according to Definition 5). Moreover,
dang(๐œŽ) = {x}, harmless(๐œŽ) = {z} and harmful(๐œŽ) = {x, u, y}. Let ๐‘š๐œŽ = |head(๐œŽ)|, then
we produce ๐‘š๐œŽ + 2 rules ๐œŒโ€ฒ (๐œŽ), ๐œŒโ€ฒโ€ฒ0 (๐œŽ), . . . , ๐œŒโ€ฒโ€ฒ๐‘š๐œŽ (๐œŽ) such that:



                                                 94
Georg Gottlob et al. CEUR Workshop Proceedings                                                  83โ€“96


                     ๐œŒโ€ฒ (๐œŽ) : ฮฆ(x, y, z), ฮจ(z, u) โ†’ ๐ด๐‘ข๐‘ฅโ€ฒ๐œŽ (z)
                     ๐œŒโ€ฒโ€ฒ0 (๐œŽ) : ฮฆ(x, y, z), ๐ด๐‘ข๐‘ฅโ€ฒ๐œŽ (z) โ†’ โˆƒ w ๐ด๐‘ข๐‘ฅโ€ฒโ€ฒ๐œŽ (x, w, z)
                     ๐œŒโ€ฒโ€ฒ1 (๐œŽ) :      ๐ด๐‘ข๐‘ฅโ€ฒโ€ฒ๐œŽ (x, w, z) โ†’ ๐‘Ž1 (v1 )
                            ..
                             .
                   ๐œŒโ€ฒโ€ฒ๐‘š๐œŽ (๐œŽ) :            ๐ด๐‘ข๐‘ฅโ€ฒโ€ฒ๐œŽ (x, w, z) โ†’ ๐‘Ž๐‘š๐œŽ (v๐‘š๐œŽ )
where v๐‘– โІ {x, w, z} for each ๐‘– โˆˆ {1, . . . , ๐‘š๐œŽ }, {๐‘Ž1 (v1 ), . . . , ๐‘Ž๐‘š๐œŽ (v๐‘š๐œŽ )} = ฮž(x, w, z) and
๐ด๐‘ข๐‘ฅโ€ฒ๐œŽ , ๐ด๐‘ข๐‘ฅโ€ฒโ€ฒ๐œŽ are fresh auxiliary predicates.
  Now, we prove that (ฮฃHG , ฮฃ๐’ฎ ) is a dyadic decomposition for any ward+ set of TGDs w.r.t.
Shy, where
                                 โ‹ƒ๏ธ                               โ‹ƒ๏ธ
                     ฮฃHG =             ๐œŒโ€ฒ (๐œŽ)   and    ฮฃ๐’ฎ =                  ๐œŒโ€ฒโ€ฒ๐‘— (๐œŽ).
                                 ๐œŽโˆˆฮฃ                          ๐œŽโˆˆฮฃ โˆง 0โ‰ค๐‘—โ‰ค๐‘š๐œŽ

    According to Definition 4, the pair (ฮฃHG , ฮฃ๐’ฎ ) has to satisfies four properties. Property 4 is
trivially fulfilled: head predicates of ฮฃHG do not occur in ฮฃ, since, by construction, ๐ด๐‘ข๐‘ฅโ€ฒ๐œŽ is
a fresh auxiliary predicate introduced for each ๐œŽ โˆˆ ฮฃ. Property 3 states that the set ฮฃHG is
head-ground w.r.t. ฮฃHG โˆช ฮฃ๐’ฎ . This is true since, by construction, we have that: for each ๐œŽ โˆˆ ฮฃ,
๐œŒโ€ฒ (๐œŽ) is a datalog rule; hp(ฮฃHG ) = {๐ด๐‘ข๐‘ฅโ€ฒ๐œŽ : ๐œŽ โˆˆ ฮฃ}, where each ๐ด๐‘ข๐‘ฅโ€ฒ๐œŽ is a predicate that
does not occur neither in any body of ฮฃHG nor in any head of ฮฃ๐’ฎ (i.e., hp(ฮฃโ€ฒ ) โˆฉ bp(ฮฃโ€ฒ ) = โˆ…,
and hp(ฮฃโ€ฒ ) โˆฉ hp(ฮฃ โˆ– ฮฃโ€ฒ ) = โˆ…), and it contains only harmless variable. Now, we have to prove
that Property 2 holds, i.e., ฮฃ๐’ฎ โˆˆ Shy. This is ensured by the fact that rule ๐œŒโ€ฒโ€ฒ0 (๐œŽ) is made by
joining the set ๐ต1 of ๐œŽ (that has to satisfy the shyness conditions by definition), and the atom
๐ด๐‘ข๐‘ฅโ€ฒ๐œŽ , which contains only harmless variables, and hence, cannot violate any of the shyness
conditions; moreover, each rule ๐œŒโ€ฒโ€ฒ๐‘— (๐œŽ), for ๐‘— = 1, . . . , ๐‘š, is linear, and therefore is a shy rule.
Finally, Property 1, that is ฮฃHG โˆช ฮฃ๐’ฎ โ‰กsch(ฮฃ) ฮฃ, follows by construction.

  Finally โ€”by combining Theorem 2, Theorem 4, the fact that CQAns is PTime-complete (resp.,
ExpTime-complete) for both Shy and Ward in data (resp., combined) complexity, and the fact
that Ward+ admits dyidic decompositions of polynomial sizeโ€” we can state the following result.

Theorem 5. The following are true:
   1. Ward+ โІ Dyadic-Shy;
   2. CQAns is PTime-complete in data complexity over Ward+ , Dyadic-Shy and Dyadic-Ward;
   3. CQAns is ExpTime-complete in combined complexity over Ward+ .


5. Conclusion
Dyadic decomposable sets form a novel decidable class of TGDs that encompasses and general-
izes all the existing (syntactic and semantic) decidable classes of TGDs. In the near feature, it
would be interesting to identify more syntactic Dyadic-๐’ž fragments โ€”such as Ward+ with re-
spect to Dyadic-Shyโ€” for which a dyadic decomposition can be easily computed. Moreover, our
plan is to implement Algorithm 1 to perform query answering by exploiting existing reasoners.




                                                      95
Georg Gottlob et al. CEUR Workshop Proceedings                                                83โ€“96


References
 [1] F. Baader, D. Calvanese, D. L. McGuinness, D. Nardi, P. F. Patel-Schneider (Eds.), The
     Description Logic Handbook: Theory, Implementation, and Applications, Cambridge
     University Press, 2003.
 [2] J. Baget, M. Leclรจre, M. Mugnier, E. Salvat, On rules with existential variables: Walking
     the decidability line, Artif. Intell. 175 (2011) 1620โ€“1654.
 [3] J. Baget, M. Leclรจre, M. Mugnier, E. Salvat, Extending decidable cases for rules with
     existential variables, in: IJCAI, 2009, pp. 677โ€“682.
 [4] N. Leone, M. Manna, G. Terracina, P. Veltri, Fast query answering over existential rules,
     ACM Trans. Comput. Log. 20 (2019) 12:1โ€“12:48.
 [5] J.-F. Baget, M. Leclรจre, M.-L. Mugnier, Walking the decidability line for rules with existential
     variables., KR 10 (2010) 466โ€“476.
 [6] A. Calรฌ, G. Gottlob, M. Kifer, Taming the infinite chase: Query answering under expressive
     relational constraints, J. Artif. Intell. Res. 48 (2013) 115โ€“174.
 [7] R. Fagin, P. G. Kolaitis, R. J. Miller, L. Popa, Data exchange: semantics and query answering,
     Theoretical Computer Science 336 (2005) 89โ€“124.
 [8] M. Krรถtzsch, S. Rudolph, Extending decidable existential rules by joining acyclicity and
     guardedness, in: IJCAI, IJCAI/AAAI, 2011, pp. 963โ€“968.
 [9] S. Ceri, G. Gottlob, L. Tanca, What you always wanted to know about datalog (and never
     dared to ask), IEEE Trans. Knowl. Data Eng. 1 (1989) 146โ€“166.
[10] G. Gottlob, A. Pieris, Beyond SPARQL under OWL 2 QL entailment regime: Rules to the
     rescue, in: IJCAI, AAAI Press, 2015, pp. 2999โ€“3007.
[11] T. Baldazzi, L. Bellomarini, M. Favorito, E. Sallinger, On the relationship between shy and
     warded datalog+/-, CoRR abs/2202.06285 (2022).
[12] A. Calรฌ, G. Gottlob, A. Pieris, Advanced processing for ontological queries, Proceedings of
     the VLDB Endowment 3 (2010) 554โ€“565.
[13] A. Calรฌ, G. Gottlob, A. Pieris, Query answering under non-guarded rules in datalog+/-, in:
     RR, volume 6333 of LNCS, Springer, 2010, pp. 1โ€“17.
[14] A. Calรฌ, G. Gottlob, T. Lukasiewicz, A general datalog-based framework for tractable query
     answering over ontologies, J. Web Semant. 14 (2012) 57โ€“83.
[15] T. Gogacz, J. Marcinkowski, Converging to the chase - A tool for finite controllability,
     volume 83, 2017, pp. 180โ€“206.
[16] D. S. Johnson, A. C. Klug, Testing containment of conjunctive queries under functional
     and inclusion dependencies, J. Comput. Syst. Sci. 28 (1984) 167โ€“189.
[17] A. Deutsch, A. Nash, J. B. Remmel, The chase revisited, in: PODS, ACM, 2008, pp. 149โ€“158.
[18] M. Krรถtzsch, S. Rudolph, Extending decidable existential rules by joining acyclicity and
     guardedness, in: IJCAI, IJCAI/AAAI, 2011, pp. 963โ€“968.
[19] G. Berger, G. Gottlob, A. Pieris, E. Sallinger, The space-efficient core of vadalog, volume 47,
     2022, pp. 1:1โ€“1:46.




                                                 96