<!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>Computing the Why-Provenance for Datalog Queries via SAT Solvers⋆</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>(Discussion Paper)</string-name>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Marco Calautti</string-name>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Ester Livshits</string-name>
          <xref ref-type="aff" rid="aff2">2</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Andreas Pieris</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
          <xref ref-type="aff" rid="aff2">2</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Markus Schneider</string-name>
          <xref ref-type="aff" rid="aff2">2</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Department of Computer Science, University of Cyprus</institution>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>Department of Computer Science, University of Milan</institution>
        </aff>
        <aff id="aff2">
          <label>2</label>
          <institution>School of Informatics, University of Edinburgh</institution>
        </aff>
      </contrib-group>
      <abstract>
        <p>Explaining an answer to a Datalog query is an essential task towards Explainable AI, especially nowadays where Datalog plays a critical role in the development of ontology-based applications. A well-established approach for explaining a query answer is the so-called why-provenance, which essentially collects all the subsets of the input database that can be used to obtain that answer via some derivation process, typically represented as a proof tree. It is well known, however, that computing the why-provenance for Datalog queries is computationally expensive, and thus, very few attempts can be found in the literature. The goal of this work is to demonstrate how of-the-shelf SAT solvers can be exploited towards an eficient computation of the why-provenance for Datalog queries. Interestingly, our SAT-based approach allows us to build the why-provenance in an incremental fashion, that is, one explanation at a time, which is much more useful in a practical context than the one-shot computation of the whole set of explanations as done by existing approaches.</p>
      </abstract>
      <kwd-group>
        <kwd>eol&gt;Datalog queries</kwd>
        <kwd>explainability</kwd>
        <kwd>why-provenance</kwd>
        <kwd>computational complexity</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>1. Introduction</title>
      <p>
        Datalog has emerged in the 1980s as a logic-based query language from Logic Programming and
has been extensively studied since then [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ]. The name Datalog reflects the intention of devising
a counterpart of Prolog for data processing. It essentially extends the language of unions of
conjunctive queries, which corresponds to the select-project-join-union fragment of relational
algebra, with the important feature of recursion, much needed to express some natural queries.
      </p>
      <p>
        As for any other query language, explaining why a result to a Datalog query is obtained
is crucial towards transparent data-intensive applications. A well-established approach for
providing such explanations to query answers is the so-called why-provenance [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ]. Its essence
is to collect all the subsets of the input database that as a whole can be used to derive a certain
answer. More precisely, for Datalog queries, the why-provenance of an answer tuple ¯ is obtained
by considering all the possible proof trees  of the fact Ans(¯), with Ans being the answer
predicate of the Datalog query in question, and then collecting all the database facts that label
the leaves of  . Recall that a proof tree of a fact  w.r.t. a database  and a set Σ of Datalog
rules forms a tree-like representation of a way for deriving  by starting from  and executing
the rules occurring in Σ [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ].
      </p>
      <p>
        Despite its wide acceptance, why-provenance for Datalog queries comes with two weaknesses:
it is computationally very expensive, and it may provide counterintuitive explanations. The
ifrst weakness is manifested by the fact that, although why-provenance for Datalog queries
has been around for decades, only a couple of works have considered implementing it for
recursive queries [
        <xref ref-type="bibr" rid="ref4 ref5">4, 5</xref>
        ]. An attempt to change this state of afairs was made in [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ] by focusing
on the more practical setting of computing the why-provenance of a given query answer
(a.k.a. on-demand why-provenance), instead of computing the why-provenance for all the query
answers. Concerning the second weakness, it has been observed that there are proof trees that
correspond to unnatural derivation processes, e.g., derivations where an atom is derived from
itself [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ]. Now, an explanation witnessed via such an unnatural proof tree, might be classified
as a counterintuitive one as it does not correspond to an intuitive derivation process that can
be extracted from the proof tree; this is further discussed in Section 3.
      </p>
      <p>The main goal of this work is to tackle the two weaknesses of why-provenance for Datalog
queries discussed above. In particular, we place our work in the more practical setting of
on-demand why-provenance, and target an eficient implementation that provides conceptually
meaningful explanations for the given query answer.</p>
    </sec>
    <sec id="sec-2">
      <title>2. Preliminaries</title>
      <p>We consider the disjoint countably infinite sets C and V of constants and variables, respectively.
We may refer to constants and variables as terms. For brevity, given an integer  &gt; 0, we may
write [] for the set of integers {1, . . . , }.</p>
      <p>Relational Databases. A schema S is a finite set of relation names (or predicates) with
associated arity. We write / to say that  has arity  ≥ 0; we may write ar() for . A
(relational) atom  over S is an expression of the form (¯), where / ∈ S and ¯ is an -tuple
of terms. By abuse of notation, we may treat tuples as the set of their elements. A fact is an
atom that mentions only constants. A database over S is a finite set of facts over S. The active
domain of a database , denoted dom(), is the set of constants in .</p>
      <p>Syntax and Semantics of Datalog Programs. A (Datalog) rule  over a schema S is an
expression of the form</p>
      <p>0(¯0) :– 1(¯1), . . . , (¯)
for  ≥ 1, where (¯) is a (constant-free) relational atom over S for  ∈ {0, . . . , }, and each
variable in ¯0 occurs in ¯ for some  ∈ []. We refer to 0(¯0) as the head of  , denoted
head( ), and to the expression that appears on the right of the :– symbol as the body of  ,
denoted body( ), which we may treat as the set of its atoms.</p>
      <p>A Datalog program over a schema S is defined as a finite set Σ of Datalog rules over S. A
predicate  occurring in Σ is called extensional if there is no rule in Σ having  in its head, and
intensional if there exists at least one rule in Σ with  in its head. The extensional (database)
schema of Σ , denoted edb(Σ) , is the set of all extensional predicates in Σ , while the intensional
schema of Σ , denoted idb(Σ) , is the set of all intensional predicates in Σ . Note that, by definition,
edb(Σ) ∩ idb(Σ) = ∅. The schema of Σ , denoted sch(Σ) , is the set edb(Σ) ∪ idb(Σ) , which is
in general a subset of S since some predicates of S may not appear in Σ .</p>
      <p>
        An elegant property of Datalog programs is that they have three equivalent semantics:
model-theoretic, fixpoint, and proof-theoretic [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ]. We recall the proof-theoretic semantics
of Datalog programs since it is closer to the notion of why-provenance. To this end, we
need the key notion of proof tree of a fact. For a database  and a Datalog program Σ , let
base(, Σ) = {(¯) |  ∈ sch(Σ) and ¯ ∈ dom()ar()}, the facts that can be formed using
predicates of sch(Σ) and constants of dom().
      </p>
      <p>Definition 2.1. (Proof Tree) Consider a Datalog program Σ , a database  over edb(Σ) , and a
fact  over sch(Σ) . A proof tree of  w.r.t.  and Σ is a finite labeled rooted tree  = (, ,  ),
with  :  → base(, Σ) , such that:
1. If  ∈  is the root, then  () =  .
2. If  ∈  is a leaf, then  () ∈ .
3. If  ∈  is a node with  ≥ 1 children 1, . . . , , then there is a rule
0(¯0) :– 1(¯1), . . . , (¯) ∈ Σ and a function ℎ : ⋃︀∈[] ¯ → C such that
 () = 0(ℎ(¯0)), and  () = (ℎ(¯)) for each  ∈ [].</p>
      <p>Essentially, a proof tree of a fact  w.r.t.  and Σ indicates that we can derive  starting from
 end executing the rules of Σ . Now, given a Datalog program Σ and a database  over sch(Σ) ,
the semantics of Σ on  is Σ( ) = { | there is a proof tree of  w.r.t.  and Σ }. That is, the
set of facts that can be proven using  and Σ .</p>
      <p>Datalog Queries. It is now straightforward to recall the syntax and the semantics of Datalog
queries. A Datalog query is a pair  = (Σ , ), where Σ is a Datalog program and  a predicate
of idb(Σ) . Now, for a database  over edb(Σ) , the answer to  over  is defined as the set
() = {︁¯ ∈ dom()ar() | (¯) ∈ Σ( )}︁ ,
that is, the set of tuples ¯ of dom()ar() such that the fact (¯) can be derived using  and Σ .
Why-Provenance for Datalog Queries. As discussed in the introduction, why-provenance is
a standard way of explaining query results. It essentially collects all the subsets of the database
(without unnecessary atoms) that allow to prove (or derive) a query result. We now formalize
this simple idea.</p>
      <p>Given a proof tree  = (, ,  ) (of some fact w.r.t. some database and Datalog program),
the support of  is the set support( ) = { () |  ∈  is a leaf of  }, which is essentially the
set of facts that label the leaves of the proof tree  . Note that support( ) is a subset of the
underlying database since, by definition, the leaves of a proof tree are labeled with database
atoms. The formal definition of why-provenance for Datalog queries follows.
Definition 2.2. (Why-Provenance for Datalog) Consider a Datalog query  = (Σ , ), a
database  over edb(Σ) , and a tuple ¯ ∈ dom()ar(). The why-provenance of ¯ w.r.t.  and 
is defined as the family of sets of facts</p>
      <p>why(¯, , ) = {support( ) |  is a proof tree of (¯) w.r.t.  and Σ }.</p>
      <p>Intuitively speaking, a set of facts ′ ⊆  that belongs to why(¯, , ) should be understood
as a reason why the tuple ¯ is an answer to the query  over the database , i.e., ′ explains
why ¯ ∈ (). In particular, all the facts of ′ are used in order to derive ¯ as an answer.</p>
    </sec>
    <sec id="sec-3">
      <title>3. Unambiguous Proof Trees</title>
      <p>
        The standard notion of why-provenance defined above relies on arbitrary proof trees. However,
as discussed in [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ], there are proof trees that are counterintuitive. For example, such a proof tree
is one where a fact is derived from itself, that is, it contains two nodes labeled with the same
fact and one is a descendant of the other. Now, a member of why(¯, , ), witnessed via such
an unnatural proof tree, might be classified as a counterintuitive explanation of ¯ as it does not
correspond to a natural derivation process that can be extracted from the proof tree. Therefore,
we need refined classes of proof trees that overcome the conceptual limitations of arbitrary proof
trees. Some refined classes of proof trees have been recently discussed in [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ]: non-recursive proof
trees, minimal-depth proof trees, and hereditary minimal-depth proof trees. Roughly speaking, a
non-recursive proof tree is a proof tree that does not contain two nodes labeled with the same
fact and one is a descendant of the other, a minimal-depth proof tree is a proof tree that has the
minimum depth among all the proof trees of the same fact, and a hereditary minimal-depth proof
tree is minimizing the depth of each of its subtrees. Although non-recursive and (hereditary)
minimal-depth proof trees form well-justified notions that deserve our attention, there are still
proof trees from those classes that can be classified as counterintuitive. In fact, there are proof
trees that are non-recursive and (hereditary) minimal-depth, but they are ambiguous in the way
some facts are derived. Here is a simple example that illustrates this phenomenon.
Example 3.1. Consider the Datalog program Σ
() :– ()
() :– (), (),  (, , )
that encodes the path accessibility problem [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ]. The predicate  represents source nodes, 
represents nodes that are accessible from the source nodes, and  represents accessibility
conditions, that is,  (, , ) means that if both  and  are accessible from the source nodes,
then so is . We further consider the database
      </p>
      <p>= {(), (),  (, , ),  (, , ),  (, , )}.</p>
      <p>The following is a proof tree of the fact () w.r.t.  and Σ that is non-recursive and (hereditary)
minimal-depth, but it sufers from the ambiguity issue described above:</p>
      <p>A(d)
A(c)</p>
      <p>A(c)</p>
      <p>T (c, c, d)
A(a) A(a) T (a, a, c)</p>
      <p>A(b) A(b) T (b, b, c)
S(a) S(a)</p>
      <p>S(b) S(b)
Indeed, there are two nodes labeled with the fact (), but their subtrees difer, and thus, it is
ambiguous how () is derived. Hence, the database , which belongs to the why-provenance
of () w.r.t.  and  due to the above proof tree, might be classified as a counterintuitive
explanation since it does not correspond to an intuitive derivation process where each fact is
derived once due to a unique reason. Indeed, the intuitive explanations that one expects are the
following:  is accessible from  via  (i.e., the subset {(),  (, , ),  (, , )} of ), or 
is accessible from  via  (i.e., the subset {(),  (, , ),  (, , )} of ).</p>
      <p>This leads to the class of unambiguous proof trees, where all occurrences of a fact must be
proved via the same derivation. Two rooted trees  = (, ,  ) and  ′ = ( ′, ′,  ′) are
isomorphic, denoted  ≈  ′, if there exists a bijection ℎ :  →  ′ such that, for each  ∈  ,
 () =  ′(ℎ()), and for each ,  ∈  , (, ) ∈  if (ℎ(), ℎ()) ∈ ′. Let  [] be the
subtree of the proof tree  rooted at node . The formal definition of unambiguous proof trees
follows.</p>
      <p>Definition 3.2. (Unambiguous Proof Tree) Consider a Datalog program Σ , a database 
over edb(Σ) , and a fact  over sch(Σ) . An unambiguous proof tree of  w.r.t.  and Σ is a
proof tree  = (, ,  ) of  w.r.t.  and Σ such that, for all ,  ∈  ,  () =  () implies
 [] ≈  [].</p>
      <p>Why-provenance relative to unambiguous proof trees is defined in the obvious way: for
a Datalog query  = (Σ , ), a database  over edb(Σ) , and a tuple ¯ ∈ dom()ar(), the
why-provenance of ¯ w.r.t.  and  relative to unambiguous proof trees is the family of sets of
facts</p>
      <p>{support( ) |  is an unambiguous proof tree of (¯) w.r.t.  and Σ },
denoted whyUN(¯, , ). The main concern of this work is to eficiently compute the
whyprovenance of a tuple relative to unambiguous proof trees. To this end, we are going to exploit
of-the-shelf SAT solvers and report encouraging results; this is the subject of the next two
sections. To the best of our knowledge, this is the first time that SAT solvers are used for
computing the why-provenance. Let us stress that focusing on unambiguous proof trees, apart
from their conceptual advantage discussed above, was crucial towards our encouraging results
as it is unclear how a SAT-based implementation can be made practical for arbitrary proof trees.</p>
    </sec>
    <sec id="sec-4">
      <title>4. From Why-Provenance to SAT</title>
      <p>In this section, we show that the why-provenance of a tuple relative to unambiguous proof
trees can be extracted from the satisfying truth assignments of a Boolean formula.
Compactly Representing Unambiguous Proof Trees. The construction of the Boolean
formula relies on a characterization of the existence of an unambiguous proof tree of a fact
 w.r.t.  and Σ via the existence of a so-called compressed directed acyclic graph (DAG) of 
w.r.t.  and Σ , which, intuitively speaking, is a compact representation of an unambiguous
proof tree of  w.r.t.  and Σ ; this is needed, as an unambiguous proof tree can be exponentially
large in the size of . We proceed to formalize the notion of compressed DAG and give the
characterization in question. Recall that a DAG  is rooted if it has exactly one node, the root,
with no incoming edges. A node of  is a leaf if it has no outgoing edges.</p>
      <p>Definition 4.1. (Compressed DAG) Consider a Datalog program Σ , a database  over edb(Σ) ,
and a fact  over sch(Σ) . A compressed DAG of  w.r.t.  and Σ is a rooted DAG  = (, ),
with  ⊆ base(, Σ) , such that:
1. The root of  is  .
2. If  ∈  is a leaf node, then  ∈ .
3. If  ∈  has  ≥ 1 outgoing edges (,  1), . . . , (,  ), then there is a rule
0(¯0) :– 1(¯1), . . . , (¯) ∈ Σ and a function ℎ : ⋃︀∈[] ¯ → C such that
 = 0(ℎ(¯0)) and { }∈[] = {(ℎ(¯)) |  ∈ []}.</p>
      <p>For a compressed DAG  = (, ), the support of  is defined analogously to the support
of a proof tree, that is, support() = { ∈  |  is a leaf of }. The desired characterization
follows.</p>
      <p>Proposition 4.2. For a Datalog program Σ , a database  over edb(Σ) , a fact  over sch(Σ) , and
a database ′ ⊆ , the following are equivalent:
1. There exists an unambiguous proof tree  of  w.r.t.  and Σ such that support( ) = ′.
2. There exists a compressed DAG  of  w.r.t.  and Σ such that support() = ′.</p>
      <p>Note that the above characterization relies on the fact that we focus on unambiguous proof
trees. More precisely, unambiguity allows us to use a single node in the compressed DAG as a
representative for all the (possibly exponentially many) nodes in the proof tree labelled with
the same fact.</p>
      <p>The Boolean Formula. Fix a Datalog query  = (Σ , ), a database  over edb(Σ) , and
a tuple ¯ ∈ dom()ar(). We construct in polynomial time in  a Boolean formula (¯,,)
such that the why-provenance of ¯ w.r.t.  and  relative to unambiguous proof trees can be
computed from the truth assignments that make (¯,,) true.</p>
      <p>Among the Boolean variables of (¯,,), we also have the disjoint sets of variables  and
 , where each variable in  corresponds to a possible node of some compressed DAG of (¯)
w.r.t.  and Σ , while each variable in  corresponds to a possible edge between two nodes
of some compressed DAG of (¯) w.r.t.  and Σ . The key idea is that the variables of  and
 that become true via a satisfying truth assignment of (¯,,), induce the nodes and the
edges of a compressed DAG  for (¯) w.r.t.  and Σ , which, by Proposition 4.2, implies that
support() ∈ whyUN(¯, , ). The Boolean formula (¯,,) is a conjunction of the form
graph ∧ root ∧ proof ∧ acyclic ,
where graph is in charge of guaranteeing consistency between the truth assignments of the
variables in  and the variables in  , i.e., if an edge between two nodes is part of , then the
two nodes must belong to  as well. The formula root guarantees that the atom (¯) is a node
of , is the root of , and no other node  of  can be the root (i.e.,  must have at least one
incoming edge). The formula proof is in charge of guaranteeing that, whenever an intensional
atom  is a node of , then it must have the correct children in . Finally, acyclic is in charge
of checking that , namely the graph whose edges correspond to the true variables in  , is
acyclic. We can prove the following crucial result about the above Boolean formula:</p>
      <p>
        Scenario
TClosure [
        <xref ref-type="bibr" rid="ref10 ref9">9, 10</xref>
        ]
      </p>
      <p>
        Doctors [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ]
      </p>
      <p>
        Galen [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ]
Andersen [
        <xref ref-type="bibr" rid="ref11">11</xref>
        ]
      </p>
      <p>
        CSDA [
        <xref ref-type="bibr" rid="ref11">11</xref>
        ]
      </p>
      <p>Databases
bitcoin(235K), facebook(88.2K)</p>
      <p>1(100K)
1(26.5K), 2(30.5K), 3(67K), 4(82K)
1(68K), 2(340K), 3(680K), 4(3.4M), 5(6.8M)
httpd(10M), postgresql(34.8M), linux(44M)</p>
      <p>Recursive #Rules
✓ 2
✗ 6
✓ 14
✓ 2
✓ 2
Proposition 4.3. Consider a Datalog query  = (Σ , ), a database  over edb(Σ) , and a tuple
¯ ∈ dom()ar(). It holds that:
• (¯,,) is in CNF and can be constructed in polynomial time w.r.t. .
• There is a one-to-one correspondence between the members of whyUN(¯, , ) and the
satisfying assignments of (¯,,).
• Each member of whyUN(¯, , ) can be recovered from a satisfying assignment of (¯,,)
in polynomial time w.r.t. the size of (¯,,).</p>
    </sec>
    <sec id="sec-5">
      <title>5. Implementation and Experimental Evaluation</title>
      <p>Proposition 4.3 provides a way for computing the why-provenance of a tuple relative to
unambiguous proof trees via of-the-shelf SAT solvers. But how does this machinery behave when
applied in a practical context? In particular, we are interested in the incremental computation
of the why-provenance by enumerating its members, which is more useful in practice than
computing the whole set at once.</p>
      <p>This is achieved by adapting a standard technique from the SAT literature for enumerating
the satisfying assignments of a Boolean formula, called blocking clause. After asking the
SAT solver for an arbitrary satisfying assignment  of (¯,,), we output the member of
whyUN(¯, , ), denoted db( ), corresponding to  , and then construct a “blocking” clause
db( ) which expresses that no other satisfying assignment  ′ should give rise to the same
member of the why-provenance. This will exclude the previously computed explanations from
the computation. We keep adding such blocking clauses each time we get a new member of the
why-provenance until the formula is unsatisfiable.</p>
      <p>We now proceed to experimentally evaluate the SAT-based approach discussed above. To
this end, we consider a variety of scenarios from the Datalog literature consisting of a query
 = (Σ , ) and a family of databases  over edb(Σ) . All the scenarios are summarized in
Table 1.</p>
      <p>
        Experimental Setup. For each scenario  consisting of the query  = (Σ , ) and the family of
databases , and for each  ∈ , we have computed () using DLV [
        <xref ref-type="bibr" rid="ref12">12</xref>
        ], version 2.1.1, and
selected 100 tuples ¯1,, . . . , ¯1,00 from () uniformly at random. Then, for each  ∈ [100],
we constructed the Boolean formula (¯,,,) via a C++ implementation. Finally, we ran
the state-of-the-art SAT solver Glucose [
        <xref ref-type="bibr" rid="ref13">13</xref>
        ], version 4.2.1, with the above formula as input, to
enumerate the members of whyUN(¯,, , ). All the experiments have been conducted on
a laptop with an Intel(R) Core(TM) i7-10750H CPU @ 2.60GHz, and 32GB of RAM, running
Fedora Linux 37.
      </p>
      <p>Experimental Results and Take-Home Messages. Concerning the construction of the
formula, in most of the scenarios, the runtime is in the order of some seconds, and we have
observed that almost all the time is spent for computing the intermediate data structures, needed
to build the formula. Considering the more demanding scenarios Andersen and CSDA, the total
time is in the order of some minutes. Note, however, that it would be similarly demanding even
for query answering.</p>
      <p>For the incremental computation of the why-provenance, we considered the time between
the current member of the why-provenance and the next (the delay). All delays are in the order
of milliseconds. Hence, once the formula is built, incrementally computing the members of the
why-provenance is extremely fast.</p>
      <p>
        We also compared our SAT-based approach with the one of [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ], which is the only one
in the literature for constructing the why-provenance of a given tuple. We point out that
for a query , a database , and a tuple ¯ ∈ (), the technique of [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ], which we call
rule-based, constructs the set why(¯, , ) via a rewriting of  into a set of existential rules.
Since whyUN(¯, , ) ⊆ why(¯, , ), one may think that computing why(¯, , ) is more
demanding. However, computing whyUN(¯, , ) requires checking for unambiguity. We use
VLog [
        <xref ref-type="bibr" rid="ref14">14</xref>
        ], version 0.9.0, for the rule-based implementation, and we perform the comparison
over the Galen and Doctors-based scenarios as these are the only ones considered in [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ], and
thus, we have access to the rewritten set of existential rules. For the comparison, since the
approach of [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ] does not support incremental computation, we considered the end-to-end
runtime for constructing whyUN(¯, , ) and why(¯, , ) using the SAT-based and the
rulebased implementation, respectively; we set a 5 minutes timeout for both approaches.
      </p>
      <p>We observed that our SAT-based implementation consistently outperforms the rule-based
one. In particular, for the Galen scenario, in most cases, the rule-based implementation does not
ifnish in less than 5 minutes, with the worst case occurring with the largest database, where 41
out of the 100 runs time out.</p>
    </sec>
    <sec id="sec-6">
      <title>6. Future Steps</title>
      <p>
        From our analysis, it is clear that our future eforts should focus on improving the construction
of the Boolean formula. Since proof trees describe a finite reasoning process, it will be interesting
to understand how they can be adapted to other rule-based formalisms with finite reasoning, in
order to apply our SAT-based approach, such as logic programs with finite stable models [
        <xref ref-type="bibr" rid="ref15 ref16 ref17">15, 16,
17</xref>
        ], and ontology-mediated queries that guarantee the termination of the chase (e.g., see [
        <xref ref-type="bibr" rid="ref18 ref19 ref20 ref21 ref22">18,
19, 20, 21, 22, 23</xref>
        ]). Finally, it would be interesting to see how to adapt our approach to explain
answers obtained over uncertain data, such as inconsistent databases (e.g., see [24, 25, 26, 27, 28]).
      </p>
    </sec>
    <sec id="sec-7">
      <title>Acknowledgments</title>
      <p>This work was funded by the European Union - Next Generation EU under the MUR PRIN-PNRR
grant P2022KHTX7 “DISTORT”, and by the EPSRC grant EP/S003800/1 “EQUID”.
rules: An experimental study, VLDB 16 (2023) 2858–2870.
[23] M. Calautti, G. Gottlob, A. Pieris, Chase termination for guarded existential rules, in:</p>
      <p>PODS, 2015, pp. 91–103.
[24] M. Arenas, L. E. Bertossi, J. Chomicki, Consistent query answers in inconsistent databases,
in: PODS, 1999, pp. 68–79.
[25] M. Calautti, M. Console, A. Pieris, Counting database repairs under primary keys revisited,
in: PODS, 2019, pp. 104–118.
[26] M. Calautti, S. Greco, C. Molinaro, I. Trubitsyna, Preference-based inconsistency-tolerant
query answering under existential rules, AI 312 (2022) 103772.
[27] M. Calautti, L. Caroprese, S. Greco, C. Molinaro, I. Trubitsyna, E. Zumpano, Existential
active integrity constraints, ESWA 168 (2021) 114297.
[28] M. Calautti, M. Console, A. Pieris, Benchmarking approximate consistent query answering,
in: PODS, 2021, pp. 233–246.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>M.</given-names>
            <surname>Calautti</surname>
          </string-name>
          ,
          <string-name>
            <given-names>E.</given-names>
            <surname>Livshits</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Pieris</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Schneider</surname>
          </string-name>
          ,
          <article-title>Computing the why-provenance for datalog queries via SAT solvers</article-title>
          , in: AAAI,
          <year>2024</year>
          , pp.
          <fpage>10459</fpage>
          -
          <lpage>10466</lpage>
          .
        </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>1995</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <given-names>P.</given-names>
            <surname>Buneman</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Khanna</surname>
          </string-name>
          , W. C.
          <article-title>Tan, Why and where: A characterization of data provenance</article-title>
          ,
          <source>in: ICDT</source>
          ,
          <year>2001</year>
          , pp.
          <fpage>316</fpage>
          -
          <lpage>330</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <given-names>D.</given-names>
            <surname>Zhao</surname>
          </string-name>
          ,
          <string-name>
            <given-names>P.</given-names>
            <surname>Subotic</surname>
          </string-name>
          ,
          <string-name>
            <given-names>B.</given-names>
            <surname>Scholz</surname>
          </string-name>
          ,
          <article-title>Debugging large-scale datalog: A scalable provenance evaluation strategy</article-title>
          ,
          <source>ACM Trans. Program. Lang. Syst</source>
          .
          <volume>42</volume>
          (
          <year>2020</year>
          ) 7:
          <fpage>1</fpage>
          -
          <lpage>7</lpage>
          :
          <fpage>35</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <given-names>J.</given-names>
            <surname>Esparza</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Luttenberger</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Schlund</surname>
          </string-name>
          ,
          <article-title>Fpsolve: A generic solver for fixpoint equations over semirings</article-title>
          ,
          <source>in: CIAA</source>
          ,
          <year>2014</year>
          , pp.
          <fpage>1</fpage>
          -
          <lpage>15</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <given-names>A.</given-names>
            <surname>Elhalawati</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Krötzsch</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Mennicke</surname>
          </string-name>
          ,
          <article-title>An existential rule framework for computing why-provenance on-demand for datalog</article-title>
          , in: RuleML+RR,
          <year>2022</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          [7]
          <string-name>
            <given-names>C.</given-names>
            <surname>Bourgaux</surname>
          </string-name>
          ,
          <string-name>
            <given-names>P.</given-names>
            <surname>Bourhis</surname>
          </string-name>
          ,
          <string-name>
            <given-names>L.</given-names>
            <surname>Peterfreund</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Thomazo</surname>
          </string-name>
          ,
          <article-title>Revisiting semiring provenance for datalog</article-title>
          ,
          <source>in: KR</source>
          ,
          <year>2022</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          [8]
          <string-name>
            <given-names>S. A.</given-names>
            <surname>Cook</surname>
          </string-name>
          ,
          <article-title>An observation on time-storage trade of</article-title>
          ,
          <source>J. Comput. Syst. Sci. 9</source>
          (
          <year>1974</year>
          )
          <fpage>308</fpage>
          -
          <lpage>316</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          [9]
          <string-name>
            <given-names>M.</given-names>
            <surname>Weber</surname>
          </string-name>
          ,
          <string-name>
            <given-names>G.</given-names>
            <surname>Domeniconi</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Chen</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D. K. I.</given-names>
            <surname>Weidele</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C.</given-names>
            <surname>Bellei</surname>
          </string-name>
          ,
          <string-name>
            <given-names>T.</given-names>
            <surname>Robinson</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C. E.</given-names>
            <surname>Leiserson</surname>
          </string-name>
          ,
          <article-title>Anti-money laundering in bitcoin: Experimenting with graph convolutional networks for ifnancial forensics</article-title>
          , CoRR abs/
          <year>1908</year>
          .02591 (
          <year>2019</year>
          ). URL: http://arxiv.org/abs/
          <year>1908</year>
          .02591.
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          [10]
          <string-name>
            <surname>J. McAuley</surname>
            ,
            <given-names>J.</given-names>
          </string-name>
          <string-name>
            <surname>Leskovec</surname>
          </string-name>
          ,
          <article-title>Learning to discover social circles in ego networks</article-title>
          ,
          <source>in: NIPS</source>
          ,
          <year>2012</year>
          , p.
          <fpage>539</fpage>
          -
          <lpage>547</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          [11]
          <string-name>
            <given-names>Z.</given-names>
            <surname>Fan</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Mallireddy</surname>
          </string-name>
          ,
          <string-name>
            <given-names>P.</given-names>
            <surname>Koutris</surname>
          </string-name>
          ,
          <article-title>Towards better understanding of the performance and design of datalog systems</article-title>
          ,
          <source>in: Datalog 2.0</source>
          ,
          <issue>2022</issue>
          , pp.
          <fpage>166</fpage>
          -
          <lpage>180</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref12">
        <mixed-citation>
          [12]
          <string-name>
            <given-names>N.</given-names>
            <surname>Leone</surname>
          </string-name>
          , G. Pfeifer,
          <string-name>
            <given-names>W.</given-names>
            <surname>Faber</surname>
          </string-name>
          ,
          <string-name>
            <given-names>T.</given-names>
            <surname>Eiter</surname>
          </string-name>
          , G. Gottlob,
          <string-name>
            <given-names>S.</given-names>
            <surname>Perri</surname>
          </string-name>
          ,
          <string-name>
            <given-names>F.</given-names>
            <surname>Scarcello</surname>
          </string-name>
          ,
          <article-title>The DLV system for knowledge representation and reasoning</article-title>
          ,
          <source>ACM Trans. Comput. Log</source>
          .
          <volume>7</volume>
          (
          <year>2006</year>
          )
          <fpage>499</fpage>
          -
          <lpage>562</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref13">
        <mixed-citation>
          [13]
          <string-name>
            <given-names>G.</given-names>
            <surname>Audemard</surname>
          </string-name>
          ,
          <string-name>
            <given-names>L.</given-names>
            <surname>Simon</surname>
          </string-name>
          ,
          <article-title>On the glucose SAT solver</article-title>
          ,
          <source>Int. J. Artif. Intell. Tools</source>
          <volume>27</volume>
          (
          <year>2018</year>
          )
          <volume>1840001</volume>
          :
          <fpage>1</fpage>
          -
          <lpage>1840001</lpage>
          :
          <fpage>25</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref14">
        <mixed-citation>
          [14]
          <string-name>
            <given-names>J.</given-names>
            <surname>Urbani</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C.</given-names>
            <surname>Jacobs</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Krötzsch</surname>
          </string-name>
          ,
          <article-title>Column-oriented datalog materialization for large knowledge graphs</article-title>
          ,
          <source>in: AAAI</source>
          ,
          <year>2016</year>
          , pp.
          <fpage>258</fpage>
          -
          <lpage>264</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref15">
        <mixed-citation>
          [15]
          <string-name>
            <given-names>M.</given-names>
            <surname>Calautti</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Greco</surname>
          </string-name>
          ,
          <string-name>
            <given-names>F.</given-names>
            <surname>Spezzano</surname>
          </string-name>
          ,
          <string-name>
            <surname>I. Trubitsyna</surname>
          </string-name>
          ,
          <article-title>Checking termination of bottom-up evaluation of logic programs with function symbols</article-title>
          ,
          <source>TPLP</source>
          <volume>15</volume>
          (
          <year>2015</year>
          )
          <fpage>854</fpage>
          -
          <lpage>889</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref16">
        <mixed-citation>
          [16]
          <string-name>
            <given-names>M.</given-names>
            <surname>Calautti</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Greco</surname>
          </string-name>
          ,
          <string-name>
            <surname>I. Trubitsyna</surname>
          </string-name>
          ,
          <article-title>Detecting decidable classes of finitely ground logic programs with function symbols</article-title>
          ,
          <source>in: PPDP</source>
          ,
          <year>2013</year>
          , pp.
          <fpage>239</fpage>
          -
          <lpage>250</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref17">
        <mixed-citation>
          [17]
          <string-name>
            <given-names>M.</given-names>
            <surname>Calautti</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Greco</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C.</given-names>
            <surname>Molinaro</surname>
          </string-name>
          ,
          <string-name>
            <surname>I. Trubitsyna</surname>
          </string-name>
          ,
          <article-title>Logic program termination analysis using atom sizes</article-title>
          ,
          <source>in: IJCAI</source>
          ,
          <year>2015</year>
          , pp.
          <fpage>2833</fpage>
          -
          <lpage>2839</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref18">
        <mixed-citation>
          [18]
          <string-name>
            <given-names>T.</given-names>
            <surname>Gogacz</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Marcinkowski</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Pieris</surname>
          </string-name>
          ,
          <article-title>Uniform restricted chase termination</article-title>
          ,
          <source>SIAM J. Comput</source>
          .
          <volume>52</volume>
          (
          <year>2023</year>
          )
          <fpage>641</fpage>
          -
          <lpage>683</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref19">
        <mixed-citation>
          [19]
          <string-name>
            <given-names>M.</given-names>
            <surname>Calautti</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Pieris</surname>
          </string-name>
          ,
          <article-title>Semi-oblivious chase termination: The sticky case</article-title>
          ,
          <source>ToCS</source>
          <volume>65</volume>
          (
          <year>2021</year>
          )
          <fpage>84</fpage>
          -
          <lpage>121</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref20">
        <mixed-citation>
          [20]
          <string-name>
            <given-names>M.</given-names>
            <surname>Calautti</surname>
          </string-name>
          ,
          <string-name>
            <given-names>G.</given-names>
            <surname>Gottlob</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Pieris</surname>
          </string-name>
          ,
          <article-title>Non-uniformly terminating chase: Size and complexity</article-title>
          , in: PODS,
          <year>2022</year>
          , pp.
          <fpage>369</fpage>
          -
          <lpage>378</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref21">
        <mixed-citation>
          [21]
          <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 (invited talk)</article-title>
          ,
          <source>in: ICDT</source>
          , volume
          <volume>127</volume>
          ,
          <year>2019</year>
          , pp.
          <volume>3</volume>
          :
          <fpage>1</fpage>
          -
          <lpage>3</lpage>
          :
          <fpage>17</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref22">
        <mixed-citation>
          [22]
          <string-name>
            <given-names>M.</given-names>
            <surname>Calautti</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Milani</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Pieris</surname>
          </string-name>
          ,
          <article-title>Semi-oblivious chase termination for linear existential</article-title>
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>