<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Tuple-Generating Dependencies Capture Complex Values</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Extended Abstract</string-name>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Maximilian Marx</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Markus Krötzsch</string-name>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Knowledge-Based Systems Group, TU Dresden</institution>
          ,
          <addr-line>Dresden</addr-line>
          ,
          <country country="DE">Germany</country>
        </aff>
      </contrib-group>
      <fpage>97</fpage>
      <lpage>103</lpage>
      <abstract>
        <p>We review a recently introduced extension of Datalog that allows complex values constructed by nesting elements of the input database in sets and tuples. We study its complexity and show that it can be translated into existential rules for which the standard chase terminates on every input database. We identify a tractable fragment, for which membership is undecidable and propose decidable suficient conditions for membership.</p>
      </abstract>
      <kwd-group>
        <kwd>eol&gt;tuple-generating dependencies</kwd>
        <kwd>standard chase</kwd>
        <kwd>universal termination</kwd>
        <kwd>high data complexity</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>1. Introduction</title>
    </sec>
    <sec id="sec-2">
      <title>2. Preliminaries</title>
      <p>An atom is of the form (1, . . . , ar()), where  ∈ P and 1, . . . , ar() ∈ C ∪ V ∪ N are
terms. An atom is ground if it contains neither variables nor labelled nulls. An existential
rule (also called Tuple-Generating Dependency)  is a formula of first-order logic of the form
∀, .  [, ] → ∃.  [, ], where (i) , , and  are mutually disjoint lists of variables, (ii)
 and  are conjunctions of null-free atoms, (iii)  contains only variables from  ∪ , and (iv)
 contains only variables from  ∪ . If  is empty, then  is a Datalog rule. We call  the body
and  the head of  .</p>
      <p>
        A boolean conjunctive query (BCQ)  is a first-order sentence of the form ∃.  [] with  a
conjunction of atoms. A rule set Σ is a finite set of existential rules. Σ is a Datalog program if
each rule  ∈ Σ is a Datalog rule. An EDB schema is a finite set PEDB ⊊ P of predicate names;
Σ is compatible with PEDB if no predicate name  ∈ PEDB occurs in the head of a rule in Σ . A
database  over PEDB is a finite set of ground atoms using only predicate names from PEDB.
We always assume that  is over an EDB schema compatible with Σ . A database instance is a
set of variable-free atoms. We consider the usual first-order semantics: a database instance ℐ is
a model of  and Σ if  ⊆ ℐ and ℐ |= Σ as a first-order theory. Σ and  entail BCQ  (written
Σ ,  |= ) if ℐ |=  for every model ℐ of Σ and . A model ℐ of Σ and  is universal if ℐ |= 
if Σ ,  |=  for all BCQ . The standard chase is a well-known algorithm for computing (finite)
universal models; in general, it need not terminate. It terminates universally for a rule set if it
terminates on any database over a compatible EDB schema.
3. DatalogCV
Before defining DatalogCV formally, we can already gain some intuition for complex values and
the additional expressive power they ofer by looking at the following example.
Example 1 Consider a database encoding a directed graph using facts edge(, ) to denote
edges from vertex  to vertex . In our proposed formalism DatalogCV, we can query for paths
(represented as sets of edges, i.e., as sets of pairs of vertices) from  to  as follows:
edge(, ) → path(, , {⟨, ⟩})
path(, ,  ) ∧ edge(, ) → path(, ,  ∪ {⟨, ⟩})
(
        <xref ref-type="bibr" rid="ref1">1</xref>
        )
(
        <xref ref-type="bibr" rid="ref2">2</xref>
        )
Intuitively, rule (
        <xref ref-type="bibr" rid="ref1">1</xref>
        ) states that whenever there is an edge from  to , there is also a path going
along that edge. Rule (
        <xref ref-type="bibr" rid="ref2">2</xref>
        ) extends a path from  to  along an edge from  to .
      </p>
      <p>Consider a database with the following facts:
edge(, )
edge(, )
edge(, )
edge(, )
edge(, )
edge(, )
Then we can derive the following three paths from  to :
path(, , {⟨, ⟩})
path(, , {⟨, ⟩, ⟨, ⟩})
path(, , {⟨, ⟩, ⟨, ⟩})</p>
    </sec>
    <sec id="sec-3">
      <title>3.1. Syntax of DatalogCV</title>
      <p>The set S of sorts is defined inductively; it contains (i) the domain sort ∆ , (ii) for all  ∈ S, the set
sort { }, and (iii) for all ℓ ≥ 2 and  1, . . . ,  ℓ ∈ S, the tuple sort ⟨ 1,  2, . . . ,  ℓ⟩. Every variable
 ∈ V has a sort sort() =  such that the set V = {′ ∈ V | sort(′) =  } is countably
infinite. The sets T of terms of sort  are defined as follows:</p>
      <p>TΔ ::=  | 
T⟨ 1,..., ℓ⟩ ::= ⟨1, . . . , ℓ⟩ |</p>
      <p>T{ } ::= {1, . . . , }
| ( ∩ ′) | ( ∪ ′) | 
 ∈ C,  ∈ VΔ
 ∈ T  for 1 ≤  ≤ ℓ,  ∈ V⟨ 1,..., ℓ⟩
 ∈ T for 1 ≤  ≤ 
, ′ ∈ T{ },  ∈ V{ }</p>
      <p>Terms are constants (of the domain sort), tuples (over the individual component sorts), set
literals (over an element sort), intersections or unions of set terms (of a set sort), or variables (of
any sort). We also write {} as ∅, and we may emphasise the sort for overloaded symbols with a
subscript, as in ∅{ }. Basic terms do not contain ∪ or ∩ ; ground terms are variable-free.</p>
      <p>A predicate  ∈ P has associated sort sort(). A schema S = ⟨PEDB, PIDB⟩ is a partition of P
into EDB predicates PEDB and IDB predicates PIDB. An atom for predicate  ∈ P is an expression
() where  ∈ Tsort(). For tuple-sorted predicates, we write the usual (1, . . . , ℓ) instead of
(⟨1, . . . , ℓ⟩); for set terms, we may omit the outermost parentheses, writing, e.g., 1 ∪ 2 for
(1 ∪ 2). A fact is an atom (), where  contains only basic ground terms. A rule is a sentence
of the form ∀.  [] →  [], where body  (possibly empty) and head  (non-empty) are
conjunctions of atoms. Universal quantifiers are usually omitted. A DatalogCV program for
schema S is a finite set of rules, where no rule head contains an EDB predicate. A database D
for schema S is a finite set of facts using only EDB predicates. A DatalogCV BCQ is a sentence
of the form ∃.  [] with  a conjunction af atoms containing only basic terms.</p>
      <p>Some useful predicates and operations can be defined in DatalogCV.</p>
      <p>
        Example 2 The following rules express the powerset function – we interpret PS (,  ) as “
(of sort  = { }) has powerset  (of sort { } = {{ }}) – and predicates ⊆  , ∈ , ∈/ , ̸= ,
and ⊂  for a set sort  and an arbitrary sort  , which we write infix 1 ◇ 2 instead of ◇ (1, 2)
for better readability.
(
        <xref ref-type="bibr" rid="ref3">3</xref>
        )
(
        <xref ref-type="bibr" rid="ref4">4</xref>
        )
(
        <xref ref-type="bibr" rid="ref5">5</xref>
        )
(
        <xref ref-type="bibr" rid="ref6">6</xref>
        )
(7)
(8)
(9)
(10)
(11)
(12)
(13)
(14)
PSU (, , ) → PSU (,  ∪ {},  ∪ { ∪ {}})
      </p>
      <p>→ PS (∅, {∅})
PS (,  ) ∧ PSU (, , ) → PS ( ∪ {},  ∪ )
→ PSU (, ∅, ∅)
→  ⊆   ∪ 
 ∪ {} ⊆   →  ∈ 
 ∩ {} ⊆  ∅ →  ∈/ 
{} ∩ {} ⊆ { } ∅ →  ̸= 
 ⊆   ∧  ∈  ∧  ∈/  →  ⊂</p>
      <p>
        Rule (8) states that the powerset of ∅ is {∅} and rule (9) states that, given the powerset  of
, the powerset of  ∪ {} is obtained from  by adding  ∪ {} for every  ∈  , which
is computed by rules (
        <xref ref-type="bibr" rid="ref6">6</xref>
        ) and (7). Intuitively, the auxiliary atom PSU (, , ) expresses that
 = { ∪ {} |  ∈  }. On a database containing only the constant , the following facts are
entailed:
      </p>
      <p>PSU (, ∅, ∅)
PS (∅, {∅})</p>
      <p>PSU (, {∅}, {{}})</p>
      <p>PS ({}, {∅, {}})</p>
      <p>PSU (, {{∅}}, {∅})</p>
      <p>
        Note that rules like (
        <xref ref-type="bibr" rid="ref6">6</xref>
        ) or (10) are “unsafe”, i.e., they use variables in the head that do not
occur in the body. As the scope of variables is always restricted to a finite active domain, such
rules can be made safe by axiomatising an active domain predicate.
      </p>
      <p>We assume that these shortcuts are always available in DatalogCV programs, and that
databases are flat , i.e., they contain only facts of the domain sort ∆ or of some tuple sort
⟨∆ , . . . , ∆ ⟩ over domain elements; all other facts can be constructed using appropriate rules.</p>
    </sec>
    <sec id="sec-4">
      <title>3.2. Semantics of DatalogCV</title>
      <p>Similar to Datalog, we base our semantics on an Herbrand interpretation with the set of constants
syntactically occurring in a given program and database as domain, where we interpret constants
as themselves (unique name assumption). For sorts and ground terms, we define the interpretation
using a function eval(· ). For sorts, let eval(∆) := C, eval(⟨ 1, . . . ,  ℓ⟩) := eval( 1) × · · · ×
eval( ℓ), and eval({ }) := (eval( )) = { |  ⊆ eval( )}. For ground terms , we define
eval() as follows:</p>
      <p>eval() := 
eval(⟨1, . . . , ℓ⟩) := ⟨eval(1), . . . , eval(ℓ)⟩
eval({1, . . . , }) := {eval(1), . . . , eval()}
eval(1 ∩ 2) := eval(1) ∩ eval(2)
eval(1 ∪ 2) := eval(1) ∪ eval(2)
 ∈ C
(15)
(16)
(17)
(18)
(19)</p>
      <p>The domain dom(P, D) of a DatalogCV program P and database D is the set of all constants
occurring in P or D. An interpretation for P and D maps every predicate  to a set ℐ ⊆
eval(sort()) containing only constants from dom(P, D). ℐ satisfies a ground atom (), written
ℐ |= (), if eval() ∈ ℐ ; it satisfies a conjunction  of such atoms, written ℐ |=  , if ℐ |= 
for all  ∈  ; and it satisfies a variable-free rule  →  , written ℐ |=  →  , if ℐ ̸|=  or
ℐ |=  . ℐ satisfies D if ℐ |=  for all  ∈ D. If ℐ satisfies , we also call ℐ a model of .</p>
      <p>As usual, we obtain a notion of entailment from this model theory: a ground fact  is entailed
by P and D, written P, D |=  , if ℐ |=  for all models ℐ of P and D. We can reduce BCQ
entailment to ground fact entailment by using BCQs as bodies of a rule with some ground head
atom not derived by any other rule.</p>
      <p>As for Datalog, entailment can be decided by considering a single least model, which can also
be computed by a chase-like process.</p>
    </sec>
    <sec id="sec-5">
      <title>3.3. Complexity of DatalogCV</title>
      <p>The complexity of reasoning for program P depends on the nesting of sorts occurring in P.
The set-height of a sort is the maximal nesting level of sets within, e.g., s-height(∆) = 0 and
s-height({{0}}) = 2.</p>
      <p>Theorem 1 Let P be a DatalogCV program and D be a database for schema S, and let  be a
ground fact. Deciding P, D |=  is ExpTime-complete for data complexity and ( +
2)ExpTimecomplete for combined complexity, where  is the largest set-height of a sort in S.
For hardness, we extend a linear order encoded in D to  levels of nested powersets, obtaining
a -exponentially long Turing tape. For the additional exponent (over Datalog) in combined
complexity, we first obtain a doubly-exponential chain by ordering nested tuples, which forms
the new basis for the powerset construction.</p>
    </sec>
    <sec id="sec-6">
      <title>3.4. Translating DatalogCV into Existential Rules</title>
      <p>DatalogCV programs, databases, and BCQs admit a translation into sets of existential rules such
that query entailment over the translation has the same answers and the same complexity. This
requires additional rules and also additional facts for every fact  ∈ D:
Theorem 2 Let P be a DatalogCV program and D be a database for P. Then there is a set tr(P)
of existential rules and a set of facts tr(D) such that: (i) for every DatalogCV BCQ , there is tr()
with P, D |=  if tr(P), tr(D) |= tr(); (ii) tr(P), tr(D), and tr() can be computed in logarithmic
space; and (iii) every standard chase sequence for tr(P) over tr(D) terminates in a number of steps
that is -exponential in the size of D and ( + 2)-exponential in the size of P.
4. Tractable reasoning with DatalogCV
We now identify a fragment of DatalogCV for which reasoning is still data-tractable. As
0ExpTime is PTime, one such fragment is set-free DatalogCV. By flattening nested tuples,
set-free DatalogCV programs can be translated into Datalog programs with exponentially larger
arities. We can do this even in the presence of sets, as long as we can bound the cardinality of
all sets that might be derived.</p>
      <p>A program P has -bounded cardinality if, for any database D for P, all ground facts  with
P, D |=  are of the form {1, . . . , } with  ≤ . It has bounded cardinality if it has -bounded
cardinality for some . A -bounded cardinality DatalogCV program can be transformed into a
set-free DatalogCV program by replacing set sorts  = { } with -tuples ⟨, . . . ,  ⟩ and filling
up empty positions with placeholders □  .</p>
      <p>Theorem 3 Entailment for bounded cardinality DatalogCV programs is PTime-complete for data
complexity and 2ExpTime-complete for combined complexity.</p>
      <p>While bounded cardinality is undecidable, we can check for -bounded cardinality by
considering a variant of the critical instance with ( + 1) elements.
Theorem 4 It is undecidable whether a program P has bounded cardinality; given  ≥ 0, deciding
if P has -bounded cardinality is 2ExpTime-complete.</p>
      <p>Weak set acyclicity tracks the propagation of sets along positions of the program and ensures
the absence of cycles involving set unions. The cardinality constraints problem is a system
of inequalities estimating the minimal cardinality of sets. Both approaches lead to suficient
conditions for bounded cardinality:
Theorem 5 Let P be a DatalogCV program. Deciding if P is weakly set-acyclic is NL-complete;
checking if the cardinality constraints problem for P has an optimal value is in PTime. Both
conditions imply bounded cardinality.</p>
    </sec>
    <sec id="sec-7">
      <title>5. Discussion</title>
      <p>Many syntactic criteria guarantee universal termination of the chase, but all fragments identified
so far exhibit PTime data complexity. Yet rule sets with universally terminating chases can
express arbitrarily complex queries [5, 4]. This makes DatalogCV the first structured approach
for obtaining such rule sets, and it puts complex values within reach of reasoners such as
VLog [6].</p>
    </sec>
    <sec id="sec-8">
      <title>Acknowledgments</title>
      <p>The authors thank Stephan Mennicke for feedback on an earlier draft of this paper. This work is
partly supported by Deutsche Forschungsgemeinschaft (DFG, German Research Foundation) in
project number 389792660 (TRR 248, Center for Perspicuous Systems), by the Bundesministerium
für Bildung und Forschung (BMBF, Federal Ministry of Education and Research) in the Center
for Scalable Data Analytics and Artificial Intelligence (ScaDS.AI), and by BMBF and DAAD
(German Academic Exchange Service) in project 57616814 (SECAI, School of Embedded and
Composite AI).</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>M.</given-names>
            <surname>Marx</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Krötzsch</surname>
          </string-name>
          ,
          <article-title>Tuple-generating dependencies capture complex values</article-title>
          , in: D.
          <string-name>
            <surname>Olteanu</surname>
          </string-name>
          , N. Vortmeier (Eds.),
          <source>Proc. 25th Int. Conf. on Database Theory (ICDT'22)</source>
          , volume
          <volume>220</volume>
          of LIPIcs,
          <source>Schloss Dagstuhl - Leibniz-Zentrum für Informatik</source>
          ,
          <year>2022</year>
          , pp.
          <volume>13</volume>
          :
          <fpage>1</fpage>
          -
          <lpage>13</lpage>
          :
          <fpage>20</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <given-names>S.</given-names>
            <surname>Abiteboul</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R.</given-names>
            <surname>Hull</surname>
          </string-name>
          ,
          <string-name>
            <given-names>V.</given-names>
            <surname>Vianu</surname>
          </string-name>
          , Foundations of Databases, Addison Wesley,
          <year>1994</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <given-names>D.</given-names>
            <surname>Carral</surname>
          </string-name>
          , I. Dragoste,
          <string-name>
            <given-names>M.</given-names>
            <surname>Krötzsch</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C.</given-names>
            <surname>Lewe</surname>
          </string-name>
          ,
          <article-title>Chasing sets: How to use existential rules for expressive reasoning</article-title>
          , in: S. Kraus (Ed.),
          <source>Proc. 28th Int. Joint Conf. on Artificial Intelligence (IJCAI'19)</source>
          , ijcai.org,
          <year>2019</year>
          , pp.
          <fpage>1624</fpage>
          -
          <lpage>1631</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <given-names>C.</given-names>
            <surname>Bourgaux</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Carral</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Krötzsch</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Rudolph</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Thomazo</surname>
          </string-name>
          ,
          <article-title>Capturing homomorphismclosed decidable queries with existential rules</article-title>
          , in: M.
          <string-name>
            <surname>Bienvenu</surname>
            ,
            <given-names>G.</given-names>
          </string-name>
          <string-name>
            <surname>Lakemeyer</surname>
          </string-name>
          , E. Erdem (Eds.),
          <source>Proc. 18th Int. Conf. on Principles of Knowledge Representation and Reasoning (KR'21)</source>
          ,
          <year>2021</year>
          , pp.
          <fpage>141</fpage>
          -
          <lpage>150</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <given-names>M.</given-names>
            <surname>Krötzsch</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Marx</surname>
          </string-name>
          ,
          <string-name>
            <surname>S. Rudolph,</surname>
          </string-name>
          <article-title>The power of the terminating chase</article-title>
          ,
          <source>in: Proc. 22nd Int. Conf. on Database Theory (ICDT'19)</source>
          , volume
          <volume>127</volume>
          of LIPIcs, Schloss Dagstuhl - LeibnizZentrum
          <source>fuer Informatik</source>
          ,
          <year>2019</year>
          , pp.
          <volume>3</volume>
          :
          <fpage>1</fpage>
          -
          <lpage>3</lpage>
          :
          <fpage>17</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <given-names>D.</given-names>
            <surname>Carral</surname>
          </string-name>
          ,
          <string-name>
            <surname>I. Dragoste</surname>
          </string-name>
          ,
          <string-name>
            <given-names>L.</given-names>
            <surname>González</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C. J. H.</given-names>
            <surname>Jacobs</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Krötzsch</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Urbani</surname>
          </string-name>
          ,
          <article-title>Vlog: A rule engine for knowledge graphs</article-title>
          , in: C.
          <string-name>
            <surname>Ghidini</surname>
            ,
            <given-names>O.</given-names>
          </string-name>
          <string-name>
            <surname>Hartig</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          <string-name>
            <surname>Maleshkova</surname>
            ,
            <given-names>V.</given-names>
          </string-name>
          <string-name>
            <surname>Svátek</surname>
            ,
            <given-names>I. F.</given-names>
          </string-name>
          <string-name>
            <surname>Cruz</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          <string-name>
            <surname>Hogan</surname>
            ,
            <given-names>J.</given-names>
          </string-name>
          <string-name>
            <surname>Song</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          <string-name>
            <surname>Lefrançois</surname>
            ,
            <given-names>F.</given-names>
          </string-name>
          <string-name>
            <surname>Gandon</surname>
          </string-name>
          (Eds.),
          <source>Proc. 18th Int. Semantic Web Conf. (ISWC'19)</source>
          ,
          <string-name>
            <surname>Part</surname>
            <given-names>II</given-names>
          </string-name>
          , volume
          <volume>11779</volume>
          <source>of LNCS</source>
          , Springer,
          <year>2019</year>
          , pp.
          <fpage>19</fpage>
          -
          <lpage>35</lpage>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>