<?xml-model href='http://www.tei-c.org/release/xml/tei/custom/schema/relaxng/tei_all.rng' schematypens='http://relaxng.org/ns/structure/1.0'?><TEI xmlns="http://www.tei-c.org/ns/1.0">
	<teiHeader>
		<fileDesc>
			<titleStmt><title level='a'>PUG: a framework and practical implementation for why and why-not provenance</title></titleStmt>
			<publicationStmt>
				<publisher></publisher>
				<date>2018 3rd Quarter (CY)</date>
			</publicationStmt>
			<sourceDesc>
				<bibl> 
					<idno type="par_id">10082094</idno>
					<idno type="doi">10.1007/s00778-018-0518-5</idno>
					<title level='j'>The VLDB Journal</title>
<idno>1066-8888</idno>
<biblScope unit="volume"></biblScope>
<biblScope unit="issue"></biblScope>					

					<author>Seokki Lee</author><author>Bertram Ludäscher</author><author>Boris Glavic</author>
				</bibl>
			</sourceDesc>
		</fileDesc>
		<profileDesc>
			<abstract><ab><![CDATA[Explaining why an answer is (or is not) returned by a query is important for many applications including auditing, debugging data and queries, and answering hypothetical questions about data. In this work, we present the first practical approach for answering such questions for queries with negation (first-order queries). Specifically, we introduce a graph-based provenance model that, while syntactic in nature, supports reverse reasoning and is proven to encode a wide range of provenance models from the literature. The implementation of this model in our PUG (Provenance Unification through Graphs) system takes a provenance question and Datalog query as an input and generates a Datalog program that computes an explanation, i.e., the part of the provenance that is relevant to answer the question. Furthermore, we demonstrate how a desirable factorization of provenance can be achieved by rewriting an input query. We experimentally evaluate our approach demonstrating its efficiency.]]></ab></abstract>
		</profileDesc>
	</teiHeader>
	<text><body xmlns="http://www.tei-c.org/ns/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink">
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="1">Introduction</head><p>Provenance for relational queries records how results of a query depend on the query's inputs. This type of information can be used to explain why (and how ) a result is derived by a query over a given database. Recently, provenance-like techniques have been used to explain why a tuple (or a set of tuples described declaratively by a pattern) is missing from the query result (see <ref type="bibr">[19]</ref>  for a survey covering both provenance and missing answer techniques). However, the two problems have been treated mostly in isolation. Consider the following observation from <ref type="bibr">[24]</ref>: asking why a tuple t is absent from the result of a query Q is equivalent to asking why t is present in &#172;Q (i.e., the complement of the result of Q wrt. the active domain). Thus, a unification of why and why-not provenance is naturally achieved by developing a provenance model for queries with negation. The approach for provenance and missing answers from <ref type="bibr">[43]</ref> is based on the same observation.</p><p>In this paper, we introduce a graph model for provenance of first-order (FO) queries expressed as nonrecursive Datalog queries with negation<ref type="foot">foot_0</ref> (or Datalog for short) and an efficient method for explaining a (missing) answer using SQL. Our approach is based on the observation that typically only a part of the provenance, which we call explanation in this work, is actually relevant for answering the user's provenance question about the existence or absence of a result.  <ref type="figure">1</ref> that stores train connections. Datalog rule r 1 in Fig. <ref type="figure">1</ref> computes which cities can be reached with exactly one transfer, but not directly. We use the following abbreviations in provenance graphs: T = Train; n = New York; s = Seattle; w = Washington DC and c = Chicago. Given the result of this query, the user may be interested to know why he/she is able to reach Seattle from New York (Why Q(n, s)) with one intermediate stop but not directly or why it is not possible to reach New York from Seattle in the same fashion (Whynot Q(s, n)).</p><p>An explanation for either type of question should justify the existence (absence) of a result as the success (failure) to derive the result through the rules of the query. Furthermore, it should explain how the existence (absence) of tuples in the database caused the derivation to succeed (fail). Provenance graphs providing this type of justification for Why Q(n, s) and Whynot Q(s, n) are shown in Fig. <ref type="figure">2</ref> and Fig. <ref type="figure">3</ref>, respectively. These graphs contain three types of nodes: rule nodes (boxes labeled with a rule identifier and the constant arguments of a rule derivation), goal nodes (rounded boxes labeled with a rule identifier and the goal's position in the rule's body), and tuple nodes (ovals). In these provenance graphs, nodes are either colored in light green (successful/existing) or dark red (failed/missing).</p><p>Example 2. Consider the explanation (provenance graph in Fig. <ref type="figure">2</ref>) for question Why Q(n, s). Seattle can be reached from New York by stopping in Washington DC or Chicago and there is no direct connection between these two cities. These options correspond to two successful derivations using rule r 1 with X=n, Y =s, and Z=w (or Z=c, respectively). In the provenance graph, there are two rule nodes representing these derivations of Q(n, s) based on rule r 1 . A derivation is successful if all goals in the body evaluate to true, i.e., a successful rule node is connected to successful goal nodes (e.g., r 1 is connected to g 1  1 , the 1 st goal in the rule's body). A positive (negated) goal is successful if the corresponding tuple is (is not) in the database. Thus, a successful goal node is connected to the node corresponding to the existing (green) or missing (red) tuple justifying the goal, respectively.</p><p>Supporting negation and missing answers is challenging, because we need to enumerate all potential ways of deriving a missing answer (or intermediate result corresponding to a negated subgoal) and explain why each of these derivations has failed. For that, we have to decide how to bound the set of missing answers to be considered. Using the closed world assumption, only values that exist in the database or are postulated by the query are used to construct missing tuples. As is customary, we refer to this set of values as the active domain adom(I) of a database instance I.</p><p>Example 3. Fig. <ref type="figure">3</ref> shows the explanation for Whynot Q(s, n), i.e., why it is not true that New York is reachable from Seattle with exactly one transfer, but not directly. The tuple Q(s, n) is missing from the result because all potential ways of deriving this tuple through rule r 1 have failed. In this example, adom(I)={c, n, s, w} and, thus, there exist four failed derivations of Q(s, n) choosing either of these cities as the intermediate stop between Seattle and New York. A rule derivation fails if at least one goal in the body evaluates to false. Failed positive goals in the body of a failed rule are explained by missing tuples (red tuple nodes). For instance, we cannot reach New York from Seattle with an intermediate stop in Washington DC (the first failed rule derivation from the left in Fig. <ref type="figure">3</ref>) because there exists no connection from Seattle to Washington DC ( tuple node T(s, w) in red), and Washington DC to New York ( tuple node T(w, n) in red). The successful goal &#172; T(s, n) (there is no direct connection from Seattle to New York) does not contribute to the failure of this derivation and, thus, is not part of the explanation.</p><p>Observe that nodes for missing tuples and successful rule derivations are conjunctive in nature (they depend on all their children) while existing tuples and failed rule derivations are disjunctive (they only require at least one of their children to be present).</p><p>Provenance Model. By recording which rule derivations justify the existence or absence of a query result, our model is suited well for debugging both data and queries. However, simpler provenance types, e.g., only tracking data dependencies, are sufficient for some applications. For example, assume that we record for each train connection from which webpage we retrieved information about this train connection. A user may be interested in knowing based on which webpages a query answer was computed. This question can be answered using a simpler provenance type called Lineage (semiring Which(X) <ref type="bibr">[18]</ref>) which records the set of input tuples a result depends on. For such applications, we prefer simpler provenance types, because they are easier to interpret and more efficient to compute. Importantly, only minor modifications to our framework were required to support such provenance types.</p><p>Relationship to Other Provenance Models. In comparison to other provenance models, our model is more syntax-driven. We argue that this is actually a feature (not a bug). An important question is what is the semantic justification of our model, i.e., how do we know whether it correctly models Datalog query evaluation semantics and whether all (and only) relevant provenance is captured. First, we observe that our model encodes Datalog query semantics by construction. We justify that all relevant provenance is captured indirectly by demonstrating that our model captures sufficient information to derive provenance according to well-established models. Specifically, we demonstrate that our model is equivalent to provenance games <ref type="bibr">[24]</ref> which also support FO queries. It was proven in <ref type="bibr">[24]</ref> that provenance polynomials, the most general form of provenance in the semiring model <ref type="bibr">[18,</ref><ref type="bibr">22]</ref>, for a result of a positive query can be "read out" from a provenance game. By being equivalent to provenance games, our provenance model also enjoys this property. We extend this result to queries with negation by relating our model to semiring provenance for FO model checking <ref type="bibr">[13,</ref><ref type="bibr">39,</ref><ref type="bibr">43]</ref>. We prove that, for any FO formula &#981;, we can generate a query Q &#981; such that the semiring provenance annotation of the formula &#960;(&#981;) according to a K-interpretation &#960; (annotation of positive and negated literals <ref type="bibr">[13]</ref>) can be extracted efficiently from our provenance graph for Q &#981; . Note that non-recursive Datalog queries with negation and FO formulas under the closed world assumption have the same expressive power and, thus, we use these languages interchangeably.</p><p>Reverse Reasoning (How-to Queries). For some applications, a user may not be interested in how a result was derived, but wants to understand how a result of interest can be achieved through updates to the database (see e.g., <ref type="bibr">[30,</ref><ref type="bibr">39,</ref><ref type="bibr">31]</ref>). We extend our approach to support such "reverse reasoning" by introducing a third possible state of nodes in a provenance graph reserved for facts and derivations whose truth is undetermined. The provenance graph generated over an instance with undetermined facts represents a set of provenance graphs -one for each instance that is derived by assigning a truth value to each undetermined fact. We demonstrate that these graphs can be used to compute the semiring provenance of an FO formula under a provenance tracking interpretation as defined in <ref type="bibr">[39]</ref>.</p><p>Computing Explanations. We utilize Datalog to generate provenance graphs that explain a (missing) query result. Specifically, we instrument the input Datalog program to compute provenance bottom-up. Evaluated over an instance I, the instrumented program returns the edge relation of an explanation (provenance graph).</p><p>The main driver of our approach is a rewriting of Datalog rules (so-called firing rules) that captures successful and failed rule derivations. Firing rules for positive queries were first introduced in <ref type="bibr">[23]</ref>. We have generalized this concept to negation and failed rule derivations. Firing rules provide sufficient information for constructing any of the provenance graph types we support. To make provenance capture efficient, we avoid capturing derivations that will not contribute to an explanation. We achieve this by propagating information from a user's provenance question throughout the query to prune derivations that 1) do not agree with the constants of the question or 2) cannot be part of the explanation based on their success/failure status. For instance, in the running example, Q(n, s) is only connected to derivations of rule r 1 with X=n and Y =s.</p><p>We implemented our approach in PUG <ref type="bibr">[26]</ref> (Provenance Unification through Graphs), an extension of our GProM <ref type="bibr">[1]</ref> system. Using PUG, we compile rewritten Datalog programs into relational algebra, and translate such algebra expressions into SQL code that can be executed by a standard relational database backend.</p><p>Factorizing Provenance. Nodes in our provenance graphs are uniquely identified by their label. Thus, common subexpressions are shared leading to more compact graphs. For instance, observe that g 3 1 (n, s) in Fig. <ref type="figure">2</ref> is shared by two rule nodes. We exploit this fact by rewriting the input program to generate more concise, but equivalent, provenance. This is akin to factorization of provenance polynomials in the semiring model and utilizes factorized databases techniques <ref type="bibr">[33,</ref><ref type="bibr">34]</ref>.</p><p>Contributions. This paper extends our previous work <ref type="bibr">[26]</ref> in the following ways: we extend our model to support less informative, but more concise, provenance types; we extend our provenance model to support reverse reasoning <ref type="bibr">[13]</ref> where the truth of some facts in the database is left undetermined; we demonstrate that our provenance graphs (explanations) are equivalent to provenance games <ref type="bibr">[24]</ref> and how semiring provenance and its FO extension as presented in <ref type="bibr">[39]</ref> can be extracted from our provenance model; we demonstrate how to rewrite an input program to generate a desirable (concise) factorization of provenance and evaluate the performance impact of this technique; finally, we present an experimental comparison with the language-integrated provenance techniques implemented in Links <ref type="bibr">[9]</ref>. The remainder of this paper is organized as follows. We discuss related work in Sec. 2 and review Datalog in Sec. 3. We define our model in Sec. 4 and prove it to be equivalent to provenance games <ref type="bibr">[24]</ref> in Sec. 5. We, then, show how our approach relates to semiring provenance for positive queries and FO model checking in Sec. 6 and 7, respectively. We present our approach for computing explanations in Sec. 8, and factorization in Sec. 9. Sec. 10 covers our implementation in PUG which we evaluate in Sec. 11. We conclude in Sec. 12.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="2">Related Work</head><p>Our provenance graphs have strong connections to other provenance models for relational queries and to approaches for explaining missing answers.</p><p>Provenance Games. Provenance games <ref type="bibr">[24]</ref> model the evaluation of a given query (input program) P over an instance I as a 2-player game in a way that resembles SLD(NF) resolution. By virtue of supporting negation, provenance games can uniformly answer why and whynot questions. We prove our approach to be equivalent to provenance games in Sec. 5. K&#246;hler et al. <ref type="bibr">[24]</ref> present an algorithm that computes the provenance game for a program P and database I. However, this approach requires instantiation of the full game graph (which enumerates all existing and missing tuples) and evaluation of a recursive Datalog &#172; program over this graph using the well-founded semantics <ref type="bibr">[10]</ref>. In constrast, our approach directly computes succinct explanations that contain only relevant provenance.</p><p>Database Provenance. Several provenance models for database queries have been introduced in related work, e.g., see <ref type="bibr">[5,</ref><ref type="bibr">22]</ref>. The semiring annotation framework generalizes these models for positive relational algebra (and, thus, positive non-recursive Datalog). An essential property of the K-relational model is that the semiring of provenance polynomials N[X] generalizes all other semirings. It has been shown in <ref type="bibr">[24]</ref> that provenance games generalize N[X] for positive queries. Since our graphs are equivalent to provenance games in the sense that there exist lossless transformations between both models (see Sec. 5), our graphs also encode N[X] and, thus, all other provenance models expressible as semirings (see Sec. 6.2). Provenance graphs which are similar to our graphs restricted to positive queries have been used as graph representations of semiring provenance (e.g., see <ref type="bibr">[7,</ref><ref type="bibr">8,</ref><ref type="bibr">22]</ref>). Both our graphs and the boolean circuits representation of semiring provenance <ref type="bibr">[8]</ref> explicitly share common subexpressions in the provenance. While these circuits support recursive queries, they do not support negation. Recently, extension of circuits for semirings with monus (supporting set difference) have been discussed <ref type="bibr">[38]</ref>. The semiring model has also been applied to record provenance of model checking for first-order (FO) logic formulas <ref type="bibr">[39,</ref><ref type="bibr">13,</ref><ref type="bibr">43]</ref>. This work also supports missing answers using the observation made earlier in <ref type="bibr">[24]</ref>. Support for negation relies on 1) translating formulas into negation normal form (nnf ), i.e., pushing all negations down to literals, and 2) annotating both positive and negative literals using a separate set X and X of indeterminates in provenance expressions where variables from X are reserved for positive literals and variables from X for negated literals. This idea of using dual (positive and negative) indeterminates is an independent rediscovery of the approach from <ref type="bibr">[6]</ref> which applied this idea for FO queries. The main differences between these approaches are 1) that the results from <ref type="bibr">[6]</ref> where only shown for one particular semiring (Bool(X &#8746; X), the semiring of boolean expressions over dual indeterminates) and 2) that <ref type="bibr">[6]</ref> supports recursion in the form of well-founded Datalog and answer set programming (disjunctive Datalog). We prove that our model encompasses the model from <ref type="bibr">[13]</ref>. The notion of causality is also closely related to provenance. Meliou et al. <ref type="bibr">[29]</ref> compute causes for answers and non-answers. However, the approach requires the user to specify which missing inputs are considered as causes for a missing output. Roy et al. <ref type="bibr">[36,</ref><ref type="bibr">37]</ref> employ causality to compute explanations for high or low outcomes of aggregation queries as sets of input tuples which have a large impact on the result. Such sets of tuples are represented compactly through selection queries. A similar method was developed independently by Wu et al. <ref type="bibr">[41]</ref>.</p><p>Why-not and Missing Answers. Approaches for explaining missing answers are either based on the query <ref type="bibr">[2,</ref><ref type="bibr">3,</ref><ref type="bibr">4,</ref><ref type="bibr">40]</ref> (i.e., which operators filter out tuples that would have contributed to the missing answer) or based on the instance <ref type="bibr">[20,</ref><ref type="bibr">21]</ref> (i.e., what tuples need to be inserted into the database to turn the missing answer into an answer). The missing answer problem was first stated for query-based explanations in the seminal paper by Chapman et al. <ref type="bibr">[4]</ref>. Huang et al. <ref type="bibr">[21]</ref> first introduced an instance-based approach. Since then, several techniques have been developed to exclude spurious explanations, to support larger classes of queries <ref type="bibr">[20]</ref>, and to support distributed Datalog systems in Y! <ref type="bibr">[42]</ref>. The approaches for instance-based explanations (with the exception of Y!) have in common that they treat the missing answer problem as a view update problem: the missing answer is a tuple that should be inserted into a view corresponding to the query and this insertion has to be translated as an insertion into the database instance. An explanation is then one particular solution to this view update problem. In contrast to these previous works, our provenance graphs explain missing answers by enumerating all failed rule derivations that justify why the answer is not in the result. Thus, they are arguably a better fit for use cases such as debugging queries, where in addition to determining which missing inputs justify a missing answer, the user also needs to understand why derivations have failed. Furthermore, we do support queries with negation. Importantly, solutions for view update missing answer problems can be extracted from our provenance graphs. Thus, in a sense, provenance graphs with our approach generalize some of the previous approaches (for the class of queries supported, e.g., we do not support aggregation yet). Interestingly, recent work has shown that it may be possible to generate more concise summaries of provenance games <ref type="bibr">[11,</ref><ref type="bibr">35]</ref> and provenance graphs <ref type="bibr">[28]</ref> that are particularly useful for negation and missing answers to deal with the potentially large size of the resulting provenance. Similarly, some missing answer approaches <ref type="bibr">[20]</ref> use ctables to compactly represent sets of missing answers. These approaches are complementary to our work.</p><p>Computing Provenance Declaratively. The concept of rewriting a Datalog program using firing rules to capture provenance as variable bindings of derivations was introduced by K&#246;hler et al. <ref type="bibr">[23]</ref>. They apply this idea for provenance-based debugging of positive Datalog. Firing rules are also similar to relational implementations of provenance capture in Perm <ref type="bibr">[12]</ref>, LogicBlox <ref type="bibr">[16]</ref>, Orchestra <ref type="bibr">[17]</ref>, and GProM <ref type="bibr">[1]</ref>. Zhou et al. <ref type="bibr">[44]</ref> leverage such rules for the distributed ExSPAN system using either full propagation or reference based provenance. The extension of firing rules for negation is the main enabler of our approach.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="3">Datalog</head><p>A Datalog program P consists of a finite set of rules r i : R( X) :-R 1 ( X 1 ), . . . , R n ( X n ) where X j denotes a tuple of variables and/or constants. We assume that the rules of a program are labeled r 1 to r m . R( X) is the head of the rule, denoted as head(r i ), and R 1 ( X 1 ), . . . , R n ( X n ) is the body (each R j ( X j ) is a goal ). We use vars(r i ) to denote the set of variables in r i . In this paper, consider non-recursive Datalog with negation (FO queries), so goals R j ( X j ) in the body are literals, i.e., atoms L( X j ) or their negation &#172;L( X j ), and recursion is not allowed. All rules r of a program have to be safe, i.e., every variable in r must occur positively in r's body (thus, head variables and variables in negated goals must also occur in a positive goal). For example, Fig. <ref type="figure">1</ref> shows a Datalog query with a single rule r 1 . Here, head(r 1 ) is Q(X, Y ) and vars(r 1 ) is {X, Y, Z}. The rule is safe since the head variables ({X, Y }) and the variables in the negated goal ({X, Y }) also occur positively in the body. The set of relations in the schema over which P is defined is referred to as the extensional database (EDB), while relations defined through rules in P form the intensional database (IDB), i.e., the IDB relations are those defined in the head of rules. We require that P has a distinguished IDB relation Q, called the answer relation. Given P and instance I, we use P (I) to denote the result of P evaluated over I. Note that P (I) includes the instance I, i.e., all EDB atoms that are true in I. For an EDB or IDB predicate R, we use R(I) to denote the instance of R computed by P and R(t) &#8712; P (I) to denote that t &#8712; R(I) according to P .</p><p>We use adom(I) to denote the active domain of instance I, i.e., the set of all constants that occur in I. Similarly, we use adom(R.A) to denote the active domain of attribute A of relation R. In the following, we make use of the concept of a rule derivation. A derivation of a rule r is an assignment of variables in r to constants from adom(I). For a rule with n variables, we use r(c 1 , . . . , c n ) to denote the derivation that is the result of binding X i =c i . We call a derivation successful wrt. an instance I if each atom in the body of the rule is true in I and failed otherwise.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="4">Provenance Model</head><p>We now introduce our provenance model and formalize the problem addressed in this work: compute the subgraph of a provenance graph for a given query (input program) P and instance I that explains existence/absence of a tuple in/from the result of P .</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="4.1">Negation and Domains</head><p>To be able to explain why a tuple is missing, we have to enumerate all failed derivations of this tuple and, for each such derivation, explain why it failed. As mentioned in Sec. 1, we have to decide how to bound the set of missing answers. We propose a simple, yet general, solution by assuming that each attribute of an IDB or EDB relation has an associated domain.</p><p>Definition 1 (Domain Assignment). Let S = {R 1 , . . . , R n } be a database schema where each R i (A 1 , . . . , A m ) is a relation. Given an instance I of S, a domain assignment dom is a function that associates with each attribute R.A a domain of values. We require dom(R.A) &#8839; adom(R.A).</p><p>In our approach, the user specifies each dom(R.A) as a query dom R.A that returns the set of admissible values for the domain of attribute R.A. These associated domains fulfill two purposes: 1) to reduce the size of explanations and 2) to avoid semantically meaningless answers. For instance, if there exists another attribute Price in the relation Train in Fig. <ref type="figure">1</ref>, then adom(I) would also include all the values that appear in this attribute. Thus, some failed rule derivations for r 1 would assign prices as intermediate stops. Different attributes may represent the same type of entity (e.g., fromCity and toCity in our example) and, thus, it would make sense to use their combined domain values when constructing missing answers. For now, we leave it up to the user to specify attribute domains.</p><p>When defining provenance graphs in the following, we are only interested in rule derivations that use constants from the associated domains of attributes accessed by the rule. Given a rule r and variable X used in this rule, let attrs(r, X) denote the set of attributes that variable X is bound to in the body of the rule. In Fig. <ref type="figure">1</ref>, attrs(r 1 , Z)={Train.fromCity, Train.toCity}. We say a rule derivation r(c 1 , . . . , c n ) is domain grounded iff c i &#8712; A&#8712;attrs(r,Xi) dom(A) for all i &#8712; {1, . . . , n}. For a relation R(A 1 , . . . , A n ), we use Tup(R) to denote the set of all possible tuples for R, i.e., Tup(R) = dom(R.A 1 ) &#215; . . . &#215; dom(R.A n ).</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="4.2">Provenance Graphs</head><p>Provenance graphs justify the existence (or absence) of a query result based on the success (or failure) to derive it using a query's rules. They also explain how the existence or absence of tuples in the database caused derivations to succeed or fail, respectively. Here, we present a constructive definition of provenance graphs that provide this type of justification. Nodes in these graphs carry two types of labels: 1) a label that determines the node type (tuple, rule, or goal) and additional information, e.g., the arguments and rule identifier of a derivation; 2) the success/failure status of nodes. Note that the first type of labels uniquely identifies nodes.</p><p>Definition 2 (Provenance Graph). Let P be a Datalog program, I a database instance, dom a domain assignment for I, and L the domain of strings. The provenance graph PG(P, I) is a graph (V, E, L, S) with nodes V , edges E, and node labelling functions L : V &#8594; L and S : V &#8594; {T , F } (T for true/success and F for false/failure). We require that &#8704;v, v &#8242; &#8712; V : -Rule nodes: For every successful domain grounded derivation r i (c 1 , . . . , c n ), there exists a node v in V labeled r i (c 1 , . . . , c n ) with S(v) = T . For every failed domain grounded derivation r i (c 1 , . . . , c n ) where head (r i (c 1 , . . . , c n )) &#8712; P (I), there exists a node v as above but with S(v) = F . In both cases, v is connected to the tuple node head(r i (c 1 , . . . , c n )). -Goal nodes: Let v be the node corresponding to a derivation r i (c 1 , . . . , c n ) with m goals. If S(v) = T , then for all j &#8712; {1, . . . , m}, v is connected to a goal node v j labeled g j i with S(v j ) = T . If S(v) = F , then for all j &#8712; {1, . . . , m}, v is connected to a goal node v j with S(v j ) = F if the j th goal is failed in r i (c 1 , . . . , c n ). Each goal is connected to the corresponding tuple node.</p><p>Our provenance graphs model query evaluation by construction. A tuple node R(t) is successful in PG(P, I) iff R(t) &#8712; P (I). This is guaranteed, because each tuple built from values of the associated domain exists as a node v in the graph and its label S(v) is decided based on R(t) &#8712; P (I). Furthermore, there exists a successful rule node r( c) &#8712; PG(P, I) iff the derivation r( c) succeeds for I. Likewise, a failed rule node r( c) exists iff the derivation r( c) is failed over I and head(r( c)) &#8712; P (I). Fig. <ref type="figure">2</ref> and<ref type="figure">3</ref> show subgraphs of PG(P, I) for the query from Fig. <ref type="figure">1</ref>. Since Q(n, s) &#8712; P (I) (Fig. <ref type="figure">2</ref>), this tuple node is connected to all successful derivations with Q(n, s) in the head which in turn are connected to goal nodes for each of the three goals of rule r 1 . Q(s, n) / &#8712; P (I) (Fig. <ref type="figure">3</ref>) and, thus, its node is connected to all failed derivations with Q(s, n) as a head. Here, we have assumed that all cities can be considered as start and end points of missing train connections, i.e., both dom(T.fromCity) and dom(T.toCity) are defined as adom(T.fromCity)&#8746;adom(T.toCity). Thus, we have considered derivations r 1 (s, n, Z) for Z &#8712; {c, n, s, w}.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="4.3">Provenance Questions and Explanations</head><p>Recall that the problem we address in this work is how to explain the existence or absence of (sets of) tuples using provenance graphs. Such a set of tuples specified as a pattern and paired with a qualifier (Why /Whynot ) is called a provenance question (PQ) in this paper. The two questions presented in Example 1 use constants only, but we also support provenance questions with variables, e.g., for a question Whynot Q(n, X) we return all explanations for missing tuples where the first attribute is n, i.e., why it is not the case that a city X can be reached from New York with one transfer, but not directly. We say a tuple t &#8242; of constants matches a tuple t of variables and constants written as t &#8242; t if we can unify t &#8242; with t, i.e., we can equate t &#8242; with t by applying a valuation that substitutes variables in t with constants from t &#8242; .</p><p>Definition 3 (Provenance Question). Let P be a query, I an instance, Q an IDB predicate, and dom a domain assignment for I. A provenance question &#968; is of the form Why Q(t) or Whynot Q(t) where t = (v 1 , . . . , v n ) consists of variables and domain constants (dom(Q.A) for each attribute Q.A). We define:</p><p>In Example 2 and 3, we have presented subgraphs of PG(P, I) as explanations for PQs, implicitly claiming that these subgraphs are sufficient for explaining these PQs. We now formally define this type of explanation.</p><p>Definition 4 (Explanation). The explanation Expl(P, &#968;, I, dom) for a PQ &#968; according to P , I, and dom is the subgraph of PG(P, I) containing only nodes that are connected to at least one node in Match(&#968;).</p><p>In the following we will drop dom from Expl(P, &#968;, I, dom) if it is clear from the context or irrelevant for the discussion. Given this definition of explanation, note that 1) all nodes connected to a tuple node matching the PQ are relevant for computing this tuple and 2) only nodes connected to this node are relevant for the outcome. Consider Q(t &#8242; ) &#8712; Match(&#968;) for a question Why Q(t). Since Q(t &#8242; ) &#8712; P (I), all successful derivations with head Q(t &#8242; ) justify the existence of t &#8242; and these are precisely the rule nodes connected to Q(t &#8242; ) in PG(P, I). For Whynot Q(t) and matching Q(t &#8242; ) we have Q(t &#8242; ) &#8712; P (I) which is the case if all derivations with head Q(t &#8242; ) have failed. In this case, all such derivations are connected to Q(t &#8242; ) in the provenance graph. Each such derivation is connected to all of its failed goals which are responsible for the failure. Now, if a rule body references IDB predicates, then the same argument can be applied to reason that all rules directly connected to these tuples explain why they (do not) exist. Thus, by induction, the explanation contains all relevant tuple and rule nodes that explain the PQ.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="5">Provenance Graphs and Provenance Games</head><p>We now prove that provenance graphs according to Def. 2 are equivalent to provenance games. Thus, our model inherits the semantic foundation of provenance games. Specifically, provenance games were shown to encode Datalog query evaluation. Furthermore, the interpretation of provenance game graphs as 2-player games provides a strong justification for why the nodes reachable from a tuple node justify the existence/absence of the tuple. We show how to transform a provenance game &#915;(P, &#968;, I) into an explanation Expl(P, &#968;, I) and vice versa to demonstrate that both are equivalent representations of provenance. We define a function Tr &#915;&#8594;Expl that maps provenance games to graphs and its inverse Tr Expl&#8594;&#915; . Before that, we first give an overview of provenance games (see <ref type="bibr">[24]</ref> for more details). Provenance Games. Similar to our provenance graphs, provenance games are graphs that record successful and failed rule derivations. Provenance games consist of four types of nodes (e.g. Fig. <ref type="figure">4d</ref>): rule nodes (boxes labeled with a rule identifier and the constant arguments of a rule derivation), goal nodes (boxes labeled with a rule identifier and the goal's position in the rule's body), tuple nodes (ovals), and EDB fact nodes (boxes labeled with an EDB relation name and the constants of a tuple). Every tuple node in a provenance game appears both positively and negatively, i.e., for every tuple node R(t), there exists a tuple node &#172;R(t). Given a program P and database instance I, a provenance game is constructed by creating a positive and negative tuple node R(c 1 , &#8226; &#8226; &#8226; , c n ) for each n-ary predicate R and for all combinations of constants c i from the active domain adom(I). Similarly, nodes are created for rule derivations, i.e., a rule where variables have been replaced with constants from adom(I) and each goal in the body of a rule (similar to Def. 2). In the game, a derivation of rule r for a vector of constants c is labeled as r( c), e.g., a derivation Q 3hop (s, s) :-T(s, c), T(c, s), T(s, s) of r 2 in Fig. <ref type="figure">4a</ref> is represented as a rule node labeled with r 2 (s, s, c, s). Finally, EDB fact nodes are added for each tuple in I, e.g., r T (s, s) for the tuple (seattle, seattle) in the Train relation (Fig. <ref type="figure">4a</ref>). Tuple nodes are connected to the grounded rule nodes that derive them (have the tuple in their head), rule nodes to goal nodes for the grounded goals in their body, and goal nodes to negated tuple nodes corresponding to the goal (positive goals) or positive tuple nodes (negated goals). Such a game is interpreted as a 2-player game where the players argue for/against the existence of a tuple in the result of evaluating P over I. The existence of strategies for a player in this game determines tuple existence and success of rule derivations. A solved game is one where each node in the game graph is labeled as either won W (there exists a strategy for the player starting in this position) or lost L (no such strategy exists). A tuple node R(t) is labeled as W iff the tuple R(t) exists. A corollary of this is that a rule is labelled L if the corresponding derivation is successful and W otherwise. <ref type="foot">2</ref> Given such a solved  (+)</p><p>[(p, p, p), (q, r, p), (p, q, r)]</p><p>T (c, s)</p><p>(e) Provenance graph (Expl) for Q3hop(s, s)</p><p>Fig. <ref type="figure">4</ref>: Transformations exemplified using the provenance graph for Q 3hop (s, s). For each graph, we show the structure of the provenance encoded by this graph and the corresponding semiring annotation where applicable.</p><p>game (denoted as &#915;(P, I)), we can extract a subgraph rooted at an IDB tuple Q(t) as the provenance of Q(t).</p><p>Similar to how we derive an explanation for a PQ with Pattern(&#968;) = Q(t) where t may contain variables as the subgraph of the provenance graph PG(P, I) containing all IDB tuple nodes matching t and nodes reachable from these nodes, we can derive the corresponding subgraph in the provenance game &#915;(P, I) and denote it as &#915;(P, &#968;, I) (we call such subgraphs game explanations).</p><p>Translating between Provenance Graphs and Provenance Games. The translation Tr Expl&#8594;&#915; of a provenance graph into the corresponding game and the reverse transformation Tr &#915;&#8594;Expl are straightforward. Thus, we only sketch Tr Expl&#8594;&#915; here. EDB tuple nodes are expanded to subgraphs &#172;R(t) &#8594; R(t) &#8594; r R (t) for existing tuples and &#172;R(t) &#8594; R(t) for missing tuples. IDB tuple nodes are always expanded to subgraphs of the later form. Rule and goal nodes and their interconnections are preserved. Goal nodes are connected to negated tuple nodes (positive goals) and to positive tuple nodes (negated goals). For positive tuple and goal nodes, we translate T to W (won) and F to L (lost).</p><p>For negated tuple nodes and rule nodes, this mapping is reversed, i.e., T to L and F to W .</p><p>Theorem 1. Let P be a program, I a database instance, and &#968; a PQ. We have:</p><p>Tr &#915;&#8594;Expl (&#915;(P, &#968;, I)) = Expl(P, &#968;, I)</p><p>Tr Expl&#8594;&#915; (Expl(P, &#968;, I)) = &#915;(P, &#968;, I)</p><p>Proof. See our accompanying technical report <ref type="bibr">[27]</ref>.</p><p>Example 4. Consider rule r 2 in Fig. <ref type="figure">4a</ref> computing which cities can be reached from another city through a path of length 3. The provenance game and provenance graph for Q 3hop (s, s) are shown in Fig. <ref type="figure">4d</ref> and Fig. <ref type="figure">4e</ref>, respectively. In the provenance graph, goal nodes are directly connected to tuple nodes. In the game, they are represented as positive and negative tuple nodes and EDB fact nodes (the lower three levels). That is, every</p><p>is equivalently encoded as a single tuple node T (X, Y ) in Fig. <ref type="figure">4e</ref>. Both graphs record the 3 paths of length 3 which start and end in Seattle:</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="6">Semiring Provenance for Positive Queries</head><p>The semiring annotation model <ref type="bibr">[22,</ref><ref type="bibr">15,</ref><ref type="bibr">18]</ref> is widely accepted as a provenance model for positive queries. An interesting question is how our model compares to provenance polynomials (semiring N[X]), the most general form of annotation in the semiring model. It was shown in <ref type="bibr">[24]</ref> that, for positive queries, the result of a query annotated with semiring N[X] can be extracted from the provenance game by applying a graph transformation. The equivalence shown in Sec. 5 extends this result to our provenance graph model. That being said, we develop simplified versions of our graph model to directly support less informative provenance semirings such as Lineage which only tracks data-dependencies between input and output tuples. We now introduce the semiring annotation framework for positive queries and its use in provenance tracking and, then, explain our simplified provenance graph types.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="6.1">K-relations</head><p>In the semiring framework, relations are annotated with elements from a commutative semiring. A commutative semiring is a structure K = (K, + K , &#8226; K , 0 K , 1 K ) over a set K where the addition and multiplication operations are associative, commutative, and have a neutral element (0 K and 1 K , respectively). Furthermore, multiplication with zero yields zero and multiplication distributes over addition. A relation annotated with the elements of a semiring K is called a K-relation. Operators of positive relational algebra (RA + ) for K-relations compute annotations for tuples in their output by combining annotations from their input using the operations of the semiring. Intuitively, multiplication represents conjunctive use of inputs (as in a join) whereas addition represents alternative use of inputs (as in a union or projection). We are interested in K-relations, because it was shown that many provenance types can be expressed as semiring annotations.</p><p>Semiring homomorphisms are important for our purpose since they allow us to translate between different provenance semirings and understand their relative informativeness. A semiring homomorphism h : K 1 &#8594; K 2 is a function from K 1 to K 2 that respects the operations of semirings, e.g., h(k</p><p>As shown in <ref type="bibr">[14]</ref>, if there exists a surjective homomorphism between one provenance semiring K 1 and another semiring K 2 , then K 1 is more informative than K 2 (see <ref type="bibr">[18]</ref> for the technical details justifying this argument). We introduce several provenance semirings below and explain the homomorphisms that link the most informative semiring (N[X]) to less informative semirings.</p><p>(N[X], +, &#8226;, 0, 1): The elements of semiring N[X] are polynomials with natural number coefficients and exponents over a set of variables X representing tuples. Any polynomial can be written as a sum of products by applying the equational laws of semirings, e.g., the provenance polynomial for query result Q 3hop (s, s) is p 3 +2pqr (Fig. <ref type="figure">4a</ref>). An important property of N[X] is that there exist homomorphisms from N[X] to any other semiring.</p><p>(PosBool(X), +, &#8226;, 0, 1): The elements of PosBool(X) are derived from N[X] by making both addition and multiplication idempotent and applying an additional equational law: x + x &#8226; y = x. An element from PosBool(X) can be encoded as a set of sets of variables with the restriction that every inner set k is minimal, i.e., there is no other inner set k &#8242; that is a subset of k. For example, the provenance polynomial p 3 + 2pqr of Q 3hop (s, s) is simplified as follows: p 3 + 2pqr = p + pqr = p.</p><p>(Which(X), +, &#8226;, 0, 1): In the Which(X) semiring, addition is equivalent to multiplication: x + y = x &#8226; y for x, y &#8712; {0, 1}, and both addition and multiplication are idempotent. This semiring has sometimes also be called the Lineage semiring. Alternatively, the semiring can be defined over the powerset of the set of variables X <ref type="bibr">[5]</ref>.</p><p>Other semirings of interest are (B[X], +, &#8226;, 0, 1) which is derived from N[X] by making addition idempotent (x+x &#8801; x), semiring (Trio(X), +, &#8226;, 0, 1) where multiplication is idempotent (x&#8226;x &#8801; x), and (Why(X), +, &#8226;, 0, 1) where both addition and multiplication are idempotent.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="6.2">K-explanations</head><p>We now introduce simplified versions of our provenance graphs that each corresponds to a certain provenance semiring. Given a positive query P , PQ &#968;, and database I, we use Expl K (P, &#968;, I) to denote a K-explanation for &#968;. A K-explanation is a provenance graph that encodes the K-provenance of all query results from Match(&#968;), i.e., the set of answers the user is interested in. In the following, we first show how to extract N[X] from our provenance graph. Then, for each homomorphism implementing the derivation of a less informative provenance model from a more informative provenance model in the semiring framework, there is a corresponding graph transformation over our provenance graphs that maps Expl N[X] (P, &#968;, I) to Expl K (P, &#968;, I). The following theorem shows that we can reuse the existing mapping from provenance games to provenance polynomials by composing it with the mapping Tr Expl&#8594;&#915; .</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>Theorem 2. Let Tr Expl&#8594;N[X] denote the function</head><p>Tr &#915;&#8594;N[X] &#8226; Tr Expl&#8594;&#915; . Given a positive input program P , database instance I, and tuple t &#8712; P (I), denote by N[X](P, I, t) the N[X] annotation of t over an abstractly tagged version of I (each tuple t is annotated with a unique variable x t ). Then,</p><p>Proof. The proof is shown in <ref type="bibr">[27]</ref>. Consider the explanation for Why Q 3hop (s, s) shown in Fig. <ref type="figure">4e</ref>. Recall that there are three options for reaching Seattle from Seattle with two intermediate stops corresponding to three derivations of Q 3hop using rule r 2 . These three derivations are shown in the provenance graph, e.g., r 2 (s, s, s, s) is the derivation that uses the local train connection inside Seattle three times. Annotating the train connections with variables p, q, and r as shown in Fig. <ref type="figure">4a</ref> and ignoring rule information encoded in the graph, the provenance encoded by our model is a bag (denoted as [ ]) of lists (denoted as ( )) of these variables. Each list corresponds to a rule derivation where variables are ordered according to the order of their occurrence in the body of the rule. For instance, (q, r, p) corresponds to taking a train from Seattle to Chicago (q), then from Chicago to Seattle (r), and finally a local connection inside Seattle (p). We now illustrate the graph transformations yielding K-explanations from Expl N[X] based on this example.</p><p>Semiring N[X]. In Fig. <ref type="figure">4e</ref>, we (1) replace rule nodes with multiplication (i.e., r 2 (s, s, s, s) &#8594; &#8226;) and ( <ref type="formula">2</ref>) replace goal nodes with addition (e.g., g 1 4 (s, s) &#8594; +) to generate a graph that encodes N[X] as shown in Fig. <ref type="figure">4b</ref> (denoted as Expl N[X] ). Applying this transformation, the rule instantiation r 2 (s, s, c, s) deriving result tuple Q 3hop (s, s) can no longer be distinguished from r 2 (s, s, s, c), because they are connected to the same tuple nodes. The only information retained is which arguments are used how often by a rule (labelled with &#8226;). To extract N[X], we (1) replace labels of leaf nodes with their annotations from Fig. <ref type="figure">4a</ref> (e.g., T (s, s) is replaced with p) and ( <ref type="formula">2</ref>) replace IDB tuple nodes with addition. Semiring PosBool(X). Expl PosBool(X) (Fig. <ref type="figure">4f</ref>) is computed from Expl N[X] by first collapsing rule nodes if the subgraphs rooted at these rule nodes are isomorphic and dropping all the goal nodes. Then, "&#8226;" nodes are removed if one or more subgraphs rooted at children of such a node is isomorphic to the subgraphs rooted at the children of another "&#8226;" node. Applying this process to our example, after the first step, two "&#8226;" nodes (one connects Q 3hop (s, s) to p and the other for each p, q, and r) exist in the graph corresponding to p and p &#8226; q &#8226; r. In the second step, p &#8226; q &#8226; r is removed because it contains p (T(s, s)) as a subgraph. Semiring Which(X). The semiring Which(X) (aka Lineage) is reached by collapsing all intermediate nodes and directly connecting tuple nodes (e.g., Q 3hop (s, s)) with other tuple nodes (e.g., T(s, s)) as shown in Fig. <ref type="figure">4c</ref>.</p><p>Expl B[X] and Expl Trio(X) are derived from Expl N[X] by collapsing isomorphic subgraphs rooted at rule nodes and by dropping all the goal nodes, respectively. The combination of these transformations achieves Expl Why(X) .</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="7">Semiring Provenance for FO Model Checking</head><p>The semiring framework was recently extended for capturing provenance of first-order (FO) model checking <ref type="bibr">[39,</ref><ref type="bibr">13]</ref>. We now study the relationship of our model to semiring provenance for FO queries. Based on the observation first stated in <ref type="bibr">[24]</ref> (provenance for FO queries and, thus, also FO logic, naturally supports missing answers), the authors explain missing answers based on FO provenance <ref type="bibr">[43]</ref>. Another interesting aspect of <ref type="bibr">[13]</ref> is that it allows some facts to be left undetermined (their truth is undecided). This enables how-to queries <ref type="bibr">[31]</ref>, i.e., given an expected outcome, which possible world compatible with the undecided facts would produce this outcome. In this section, we first introduce the model from <ref type="bibr">[13]</ref>, then demonstrate how our approach can be extended to support undetermined truth values. Finally, we show how the annotation computed by the approach presented in <ref type="bibr">[13]</ref> for a FO formula &#981; can be efficiently extracted from the provenance graph generated by our approach for a query Q &#981; which is derived from &#981; through a translation Tl &#981;&#8594;Q .</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="7.1">K-Interpretations and Dual Polynomials</head><p>In <ref type="bibr">[39,</ref><ref type="bibr">18]</ref>, the authors define semiring provenance for formulas in FO logic. Let A be a domain of values. We use &#957; to denote an assignment of the free variables of &#981; to values from A. Given a so-called K-interpretation &#960; which is a function mapping positive and negative literals to annotations from K, the annotation of a formula &#960; &#981; &#957; for a given valuation &#957; is derived using the rules below. For sentences, i.e., formulas without free variables, we omit the valuation and write &#960;(&#981;) to denote &#960; &#981; &#957; for the empty valuation &#957;. Furthermore, op is used to denote a comparison operator (either = or =).</p><p>Both conjunction and universal quantification correspond to multiplication, and annotations of positive and negative literals are read from &#960;. This model deals with negation as follows. A negated formula is first translated into negation normal form (nnf ). A formula in nnf does not contain negation except for negated literals. Any formula can be translated into this form using DeMorgan rules, e.g., &#172; (&#8704;x &#981;) &#8801; (&#8707;x &#172; &#981;). By pushing negation to the literal level using nnf , and annotating both positive and negative literals, the approach avoids extending the semiring structure with an explicit negation operation.</p><p>Provenance tracking for FO formula has to take into account the dual nature of the literals. The solution presented in <ref type="bibr">[13,</ref><ref type="bibr">39]</ref> is to use polynomials over two sets of variables: variables from X and X are exclusively used to annotate positive and negative literals, respectively. For any variable x &#8712; X, there exists a corresponding variable x &#8712; X and vice versa. Furthermore, if x annotates R(a), then x can only annotate &#172; R(a) (and vice versa). The semiring of dual indeterminate polynomials is then defined as the structure generated by applying the congruence x &#8226; x = 0 to the polynomials from N[X &#8746; X]. The resulting structure is denoted by N[X, X]. Intuitively, this congruence encodes the standard logic equivalence R(a) &#8743; &#172; R(a) &#8801; f alse. Importantly, in a N[X, X]-interpretation &#960;, we can decide which facts are true/false and whether to track provenance for these facts. Furthermore, we can leave the truth of some literals undetermined. Below, we show all feasible combinations for annotating R(a) and &#172; R(a) in &#960; and their meaning. For instance, if we annotate R(a) with 1 or 0, this corresponds to asserting the fact R(a), but not tracking provenance for it. By setting R(a) = x and &#172; R(a) = x, we leave the truth of R(a) undecided. Note that R(a) = 0 and &#172; R(a) = 0 (as well as R(a) = 1 and &#172; R(a) = 1) are not considered here since they lead to incompleteness (inconsistency).</p><p>Consider a sentence &#981;. 3 The annotation &#960;(&#981;) computed for &#981; over &#960; with undetermined facts represents a set of possible models for &#981;. By choosing for each undetermined fact R(a) in &#960;(&#981;) whether it is true or not, we "instantiate" one possible model for &#981;. By encoding a set of possible models, &#960;(&#981;) allows for reverse reasoning: we can find models that fulfill certain properties from the set of models encoded by &#960;(&#981;).</p><p>Example 5. Reconsider query r 1 from Fig. <ref type="figure">1</ref>. Assume that we want to determine what effect building a direct train connection from New York to Seattle would have on the query result Q(n, s). Thus, we make the assumption that the database instance is as in Fig. <ref type="figure">1</ref> with the exception that we keep T(n, s) undetermined. In first-order logic, r 1 is expressed as: only2hop(x, y) &#8801; &#8707;z(T(x, z) &#8743; T(z, y) &#8743; &#172;T(x, y)) and fact Q(n, s) as: &#981; &#8801; only2hop(n, s). The database when keeping T(n, s) undetermined is encoded as a N[X, X]-interpretations &#960; which assigns variables to positive literals as shown in Fig. <ref type="figure">1</ref> (the corresponding negated literals are annotated with 0). &#960;(T (n, s)) = v, &#960;(&#172; T (n, s)) = v, and we annotate all remaining positive literals with 0 and negative 3 We only restrict the discussion to sentences for simplicity. The arguments here also hold for formulas with free variables.</p><p>Fig. <ref type="figure">5</ref>: Provenance graph for Why Q(n, s) when T (n, s) is left undetermined literals with 1. Computing &#960;(&#981;) using the rules above, we get (t</p><p>There are two ways of deriving the query result Q(n, s) which both depend on the absence of a direct train connection from New York to Seattle (v). Now if we decide to introduce such a connection, we can evaluate the effect of this choice by setting v = 0 in the provenance polynomial above (the absence of this connection has been refuted), i.e., we get</p><p>Thus, if we were to introduce such a connection, then Q(n, s) would no longer be a result.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="7.2">Supporting Undeterminism in Provenance Graphs</head><p>Supporting undetermined facts in our provenance model is surprisingly straightforward. We introduce a new label U which is used to label nodes whose success/failure (existence/absence) is undetermined. To account for this new label, we amend the rules for determining connectivity and node labeling as follows:</p><p>-For a goal node v g (no matter whether positive or negative) that is connected to a tuple node v t with S(v t ) = U , we set S(v g ) = U (goals corresponding to undetermined tuples are undetermined). -A rule node is succesful (T ) if all its goals are successful, a rule node is failed if some of its goals are failed (F ), and finally a rule node is undetermined (U ) if at least one of its goals is undetermined and none of its goals are failed. Successful rule nodes are connected to all goals, failed rule nodes to failed and undetermined goals (these may provide further justification for the failure), and undetermined rule nodes to all goals (successful and undetermined goals will determine success of the rule nodes under choices). -An IDB tuple exists (T ) if at least one of its rule derivation is successful. It is connected to all successful and undetermined rule derivations (these may provide additional justifications under certain choices for undetermined facts). An IDB tuple is absent (F ) if all of its rule derivations fail. Finally, an IDB tuple is undetermined (U ) if at least one of its rule derivations is undetermined and none is successful.</p><p>&#981; : = &#8707;x : &#981; 1 Q&#981; (free(&#981;)) :-Dom(x), Q&#981; 1 (free(&#981; 1 ))</p><p>(1) </p><p>&#981; : = x op y Q&#981; (x, y) :-Dom(x), Dom(y), x op y (5) &#981; : = &#8704;x : &#981; 1 , free(&#981;) = {x 1 , . . . , xn} Q&#981; (free(&#981;)) :-Dom(x 1 ), . . . , Dom(x k ), &#172; Q&#981; &#8242; (free(&#981;))</p><p>Q&#981; &#8242; (free(&#981;)) :-Dom(x), Dom(x 1 ), . . . , Dom(xn), &#172;Q&#981; 1 (free(&#981; 1 ))</p><p>&#981; : = &#981; 1 &#8743; &#981; 2 Q&#981; (free(&#981;)) :-Q&#981; 1 (free(&#981; 1 )), Q&#981; 2 (free(&#981; 2 )) <ref type="bibr">(7)</ref> Fig. <ref type="figure">6</ref>: Translating a first-order formula &#981; into a first-order query Q &#981; Undetermined tuple nodes are connected to all their rule derivations (failed ones may be additional justifications for absence while undetermined ones may justify either existence or absence).</p><p>Example 6. Consider Example 5 in our extended provenance graph model. Let v n,s be the node corresponding to T(n, s). If we set S(v n,s ) = U to indicate that T(n, s) should be considered as undetermined, then we get the provenance graph in Fig. <ref type="figure">5</ref>. Our approach correctly determines that under this assumption the truth of Q(n, s) is undetermined and that there are two potential derivations of this result which also are undetermined, because they depend on existing tuples as well as the undetermined tuple T(n, s). To evaluate the effect of choosing T(n, s) to be true or false, we would set S(v n,s ) = T or S(v n,s ) = F and propagate the effect of this change bottom-up through-out the provenance graph.</p><p>Importantly, the provenance graph captured for an instance with undetermined facts is sufficient for evaluating the effect of setting any of these undetermined facts to false or true. That is, just like it is not necessary to reevaluate the semiring annotation of a formula to evaluate the impact of such a choice, it is also not necessary to recapture provenance in our model to evaluate a choice. For lack of space, we are not discussing the details of a corresponding extension for provenance games, but still would like to remark that undetermined facts correspond to draws in the game (neither player has a winning strategy). In the type of two-player games employed in provenance games, draws are caused by cycles in the game graph. To leave the existence of an EDB tuple undetermined, we introduce an EDB fact node for the tuple and add a self-edge to this node which causes the tuple node to be a draw in the game.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="7.3">From First-order Formulas to Datalog</head><p>We now present a translation Tl &#981;&#8594;Q from FO formulas &#981; to boolean Datalog queries Q &#981; . The query generated based on a formula &#981; is equivalent to the formula in the following sense: if &#981; evaluates to true for a model, then Q &#981; (I) returns true. Here, I is the instance that contains precisely the tuples corresponding to literals that are true in the model. We assume that the free variables of a formula (the variables not bound by any quantifier) are distinct from variable names bound by quantifiers and that no two quantifiers bind a variable of the same name. This can be achieved by renaming variables in a formula that does not fulfill this condition. For example, (&#8704;x R(x, y)) &#8743; (&#8707;y S(y)) does not fulfill this condition, but the equivalent formula (&#8704;x R(x, y))&#8743;(&#8707;z S(z)) does. We also assume an arbitrary, but fixed, total order &lt; V ar over variables that appear in formulas. We use free(&#981;) to denote the list of free variables of a formula &#981; ordered increasingly by &lt; V ar . For instance, for &#981; : = &#8704;x : R(x, y) we have free(&#981;) = {y}. Our translation Tl &#981;&#8594;Q takes as input a formula &#981; and outputs a Datalog program with an answer predicate Q &#981; . The translation rules are shown in Fig. <ref type="figure">6</ref>. Each rule translates one construct (e.g., a quantifier) and outputs one or more Datalog rules. The Datalog program generated by the translation for an input &#981; is the set of Datalog rules generated by applying the rules from Fig. <ref type="figure">6</ref> to all sub-formulas of &#981;. Here, we assume the existence of a unary predicate Dom whose extension is the domain A. Most translation rules are straightforward and standard. Logical operators are translated into their obvious counterpart in Datalog, e.g., a conjunction &#981; 1 &#8743; &#981; 2 is translated into a rule with two body atoms Q &#981;1 and Q &#981;2 . The rules generated for a formula &#981; return the formula's free variables to make them available to formulas that use &#981;. For instance, since Datalog does not support universal quantification directly, we have to simulate it using double negation (&#8704;x &#981; is rewritten as &#172; &#8707;x &#172; &#981;). Disjunctions are turned into unions. The complexity of the rule for disjunction stems from the fact that, in &#981; 1 &#8744; &#981; 2 , the sets of free variables for &#981; 1 and &#981; 2 may not be the same. To make them union compatible, use free(&#981;) as the arguments of the heads of the rules for both &#981; 1 and &#981; 2 , and add additional goals Dom to ensure that these rules are safe. (1)</p><p>(1) whether all nodes in the graph have outgoing edges. Let &#981; 1 = &#8707;y R(x, y) and &#981; 2 = R(x, y). Translating this formula, we get: Next, we generate the provenance graph PG(Q &#981; , I &#960; ). If the formula has free variables, then the provenance graph will contain multiple tuple nodes Q &#981; (&#957;(free(&#981;))), one for each valuation &#957; of the free variables, and the subgraph rooted at one such tuple node encodes &#960; &#981; &#957; . By applying a function Tr Expl&#8594;N[X, X] (defined in the following), we translate the subgraph rooted at tuple</p><p>The function Tr Expl&#8594;N[X, X] replaces nodes in the provenance graph with nodes labeled as "+", "&#8226;", and annotations of literals. The polynomial &#960; &#981; &#957; can then be read from the graph generated by Tr Expl&#8594;N[X, X] through a top-down traversal. Intuitively, the translation can be explained as follows. Datalog rules are a conjunction of atoms and, thus, are replaced with multiplication. There may exist multiple ways that derive an IDB tuple through the rules of query. That is, IDB tuple nodes represent addition. The exception is IDB tuples that are used in a negated fashion which are replaced with multiplication, because, for the goal to succeed, all derivations of the tuple have to fail. Note that a tuple is used in a negated way if there is an odd number of negated goals on the path between the root of the provenance graph and IDB tuple node. In a program produced by our translation rules, this can only be the case for tuples that correspond to head predicate of a rule computing the &#172; &#8707; part of the translation of a universal quantification.</p><p>Tr Expl&#8594;N[X, X] consists of the following steps:</p><p>1. Replace tuple nodes Dom(x) with 1. </p><p>We are now ready to state the main result of this section: our provenance graphs extended for undetermined facts can encode semiring provenance for firstorder (FO) model checking. For simplicity, we only consider sentences, i.e., formulas &#981; without free variables, but the result also holds for formulas with free variables by only translating a subgraph of the provenance rooted at the IDB tuple node Q &#981; (&#957;(free(&#981;))) which corresponds to the formula &#957;(&#981;). Theorem 3. Let &#981; be a formula, &#960; a N[X, X]-interpretation, Q : = Tl &#981;&#8594;Q (&#981;), and I &#960; the instance corresponding to &#960; as defined above. Then</p><p>Proof. prove the theorem by induction over the structure of the input formula &#981; for a given valuation &#957; of free(&#981;). For the full proof, see <ref type="bibr">[27]</ref>.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="8">Computing Explanations</head><p>We now present our approach for computing explanations using Datalog. Our approach generates a Datalog program GP P,&#968; by rewriting a given query (input program) P to return the edge relation of the explanation Expl(P, &#968;, I) for a provenance question (PQ) &#968;. Recall that a PQ is a pattern describing existing/missing outputs of interest and that an explanation for a PQ is a subgraph of the provenance which contains the provenance of all tuples described by the pattern.</p><p>Our approach for computing GP P,&#968; consists of the following steps that we describe in detail in the following subsections: 1) we unify the input program P with the PQ &#968; by propagating constants from &#968; top-down to prune derivations of outputs that do not match the PQ; 2) we determine for each IDB predicate whether the explanation may contain existing, missing, or both types of tuples from this predicate. Similarly, for each rule we determine whether successful, failed, all, or no derivations of this rule may occur in the provenance graph; 3) based on restricted and annotated version of the input program produced by the first two steps, we then generate firing rules which capture the variable bindings of successful and failed derivations of the input program's rules; 4) The result of the firing rules is a superset of the set of relevant provenance fragments. We introduce additional rules that enforce connectivity to remove spurious fragments; 5) finally, we create rules that generate the edge relation of the explanation. This is the only step that depends on what provenance type (e.g., Fig. <ref type="figure">4</ref>) is requested.</p><p>In the following, we will illustrate our approach using the provenance question &#968; n,s = Why Q(n, s) from Example 1, i.e., why New York is connected to Seattle via train with one intermediate stop, but there is no direct connection.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="8.1">Unifying the Program with the PQ</head><p>The node Q(n, s) in the provenance graph (Fig. <ref type="figure">2</ref>) is only connected to derivations which return Q(n, s). For instance, if variable X is bound to another city x (e.g., Chicago) in a derivation of the rule r 1 , then this rule cannot return the tuple (n, s). This reasoning can be applied recursively to replace variables in rules with constants. That is, we unify the rules in the program top-down with the PQ. This process corresponds to selection push-down for relational algebra expressions. We may create multiple partially unified versions of a rule or predicate. For example, to explore successful derivations of Q(n, s), we are interested in both train connections from New York to some city (T(n, Z)) and from any city to Seattle (T(Z, s)). Furthermore, we need to know whether there is a direct connection from New York to Seattle (T(n, s)). We store variable bindings as superscripts to distinguish multiple copies of a rule generated based on different bindings.</p><p>Example 9. Given the question &#968; n,s , we unify the single rule r 1 using the assignment (X=n, Y =s):</p><p>This approach is correct because if we bind a variable in the head of rule, then only rule derivations that agree with this binding can derive tuples that agree with this binding. Based on this unification step, we know which bindings may produce fragments of PG(P, I) that are relevant for explaining the PQ (the pseudocode for the algorithm is presented in <ref type="bibr">[25]</ref>). For an input P , we use P U nif ied to denote the result of this unification.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="8.2">Add Annotations based on Success/Failure</head><p>For Why Q(t) (Whynot Q(t)), we are only interested in subgraphs of the provenance rooted at existing (missing) tuple nodes for Q. With this information, we can infer restrictions for the success/failure state of nodes in the provenance graph that are directly or indirectly connected to PQ node(s) (belong to the explanation). We store these restrictions as annotations T , F , and F /T on heads and goals of rules and use these annotations to guide the generation of rules that capture derivations in step 3. Here, T (F ) indicates that we are only interested in successful (failed) nodes, and F /T that we are interested in both.</p><p>Example 10. Continuing with our running example question &#968; n,s , we know that Q(n, s) is in the result (Fig. <ref type="figure">1</ref>). This implies that only successful rule nodes and their successful goal nodes can be connected to this tuple node. Note that this annotation only indicates that it is sufficient to focus on successful rule derivations since failed ones cannot be connected to Q(n, s). r (X=n,Y =s),T 1</p><p>We now propagate the annotations of the goals in r 1 throughout the program. That is, for any goal that is an IDB predicate, we propagate its annotation to the head of all rules deriving the goal's predicate and, then, propagate these annotations to the corresponding rule bodies. Note that the inverted annotation is propagated for negated goals (e.g., &#172; T(n, s) T ). For instance, if T would be an IDB predicate, then we would annotate the head of all rules deriving T(n, s) with F , because Q(n, s) can only exist if T(n, s) does not exist.</p><p>Partially unified atoms such as T(n, Z) may occur in both negative and positive goals. We annotate such atoms with F /T . The algorithm generating the annotation consists of the steps shown below (the pseudocode is presented in <ref type="bibr">[25]</ref>). We use P Annot to denote the result of this algorithm for P U nif ied (input to this step).</p><p>1. Annotate the head of all rules deriving tuples matching the question with T (why) or F (why-not). 2. Repeat the following steps until a fixpoint is reached:</p><p>(a) Propagate the annotation of a rule head to goals in the rule body as follows: propagate for T annotated heads and F /T for F annotated heads. (b) For each annotated positive goal in the rule body, we propagate its annotation (F , T , or F /T ) to all rules that have this atom in the head. For negated goals, we propagate the inverted annotation (e.g., F for T ) unless the annotation is F /T in which case we propagate F /T .</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="8.3">Creating Firing Rules</head><p>To compute the relevant subgraph of PG(P, I) (the explanation) for a PQ, we need to determine successful and/or failed rule derivations. Each derivation paired</p><p>Fig. <ref type="figure">8</ref> (the second rule from the top) is derived from the rule r 1 by adding Z (the only existential variable) to the head, renaming the head predicate as F r1,T , and replacing each goal with its firing version (e.g., F T,T for the two positive goals and F T,F for the negated goal). Note that negated goals are replaced with firing rules that have inverted annotations (e.g., the goal &#172; T(n, s) T is replaced with F T,F (n, s)). Furthermore, we introduce firing rules for EDB tuples (three rules at the bottom).</p><p>We, now, extend firing rules to support queries with negation and capture missing answers. To construct a PG(P, I) fragment corresponding to a missing tuple, we need to find failed rule derivations with the tuple in the head and ensure that no successful derivations with this head exist (otherwise, we may capture irrelevant failed derivations of existing tuples). In addition, we need to determine which goals are failed for a failed rule derivation because only failed goals are connected to the node representing the failed rule derivation in the provenance graph. To capture this information, we add additional</p><p>F T,F (s, Z) :-domT.toCity(Z), &#172; T(s, Z) Fig. <ref type="figure">9</ref>: Example firing rules for Whynot Q(s, n) boolean variables -V i for goal g i -to the head of a firing rule that record for each goal whether it failed or not. The body of a firing rule for failed rule derivations is created by replacing every goal in the body with its F /T firing version, and adding the firing version of the negated head to the body (to ensure that only bindings for missing tuples are captured). Firing rules capturing failed derivations use the F /T firing versions of their goals because not all goals of a failed derivation have to be failed and the failure status determines whether the corresponding goal node is part of the explanation. A firing rule capturing missing tuples may not be safe, i.e., it may contain variables that only occur in negated goals. These variables should be restricted to the associated domains for the attributes the variables are bound to. Recall that associated domain dom(R.A) for an attribute R.A is given as an unary query dom R.A . We use these queries in firing rules to restrict the values a variable is bound to. Thus, we ensure that only missing answers formed from the associated domains are considered and that firing rules are safe.</p><p>Example 12. Consider the question Whynot Q(s, n) from Example 1. The firing rules generated for this question are in Fig. <ref type="figure">9</ref>. We exclude the rules for the second goal T(Z, n) and the negated goal &#172; T(s, n) which are analogous to the rules for the first goal T(s, Z). New York cannot be reached from Seattle with exactly one transfer, i.e., Q(s, n) is not in the result. Thus, we are only interested in failed derivations of rule r 1 with X=s and Y =n. Furthermore, each rule node in the provenance graph corresponding to such a derivation will only be connected to failed subgoals. Thus, we need to capture which goals are successful or failed for each such failed derivation. We model this using boolean variables V 1 , V 2 , and V 3 (one for each goal) that are set to true iff the tuple corresponding to the goal exists. The firing version F r1,F (s, n, Z, V 1 , V 2 , &#172; V 3 ) of r 1 returns all variable bindings for derivations of r 1 such that Q(s, n) is the head (i.e., guaranteed by adding F Q,F (s, n) to the body), the rule derivations are failed, and the tuple cor-responding to the i th goal exists for this binding iff V i is true. The failure status of the i th goal is V i for positive goals and &#172;V i for negated goals. To produce all these bindings, we need rules capturing successful and failed tuple nodes for each subgoal of the rule r 1 . We annotate such rules with F /T and use a boolean variable (true or false) to record whether a tuple exists (e.g., F T,F /T (s, Z, true) :-F T,T (s, Z) is one of these rules). Similarly, F T,F /T (s, n, f alse) represents the fact that tuple T(s, n) (connection from Seattle to New York) is missing. This causes the third goal of r 1 to succeed for any derivation where X=s and Y =n. For each unified EDB atom annotated with F /T , we create four rules: one for existing tuples (e.g., F T,T (s, Z) :-T(s, Z)), one for the failure case (e.g., F T,F (s, Z) :dom T.toCity (Z), &#172; T(s, Z)), and two for the F /T version. For the failure case, we use predicate dom T.toCity to only consider missing tuples (s, Z) where Z is a value from the associated domain.</p><p>Algorithm 1 takes as input the program P Annot produced by step 2 and outputs a program P F ire containing firing rules. The pseudocode for the subprocedures is presented in <ref type="bibr">[25]</ref>. The algorithm maintains a queue todo of annotated atoms that have to be processed which is initialized with Pattern(&#968;), i.e., the provenance question atom. Furthermore, we maintain a set done of atoms that have been processed already. Variables todo, done, and P F ire are global variables that are shared with the subprocedures of this algorithm. For each atom R(t) &#963; (line 8) from the queue (here &#963; is the annotation of the atom, e.g., F ), we mark the atom as done (line 9). We then consider two cases: R is an EDB atom or an IDB atom in which case we have to create firing rules for the predicate (relation) and the rules deriving it. The firing rules for EDB predicates check whether the tuples do or do not exist. These rules allow us to determine the success or failure of goals corresponding EDB predicates in rule derivations. For IDB predicates, we create firing rules that determine their existance based on successful or failed rule derivations captured by firing rules for the rules of the program. Consider a given program P with two rules: 1)</p><p>where R and S are EDB relations and Q and Q 1 are IDB predicates. To capture provenance for the predicate Q(X), we create firing rules for R and S to check existence or absence of tuples matching t in R and S. Moreover, we also generate firing rules for rules r 1 and r 2 to explain how derivations of Q(X) through these rules have succeeded or failed. The firing rule for r 1 uses the firing rule for IDB predicate Q 1 which in turn uses the firing rule for r 2 since head(r 2 ) = Q 1 . We describe these two cases in the following.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>Algorithm 1 Create Firing Rules</head><p>1: procedure CreateFiringRules(P Annot , &#968;)  if isEDB(R) then 11:</p><p>CreateEDBFiringRule(P F ire , R(t) &#963; ) 12: else 13:</p><p>CreateIDBNegRule(P F ire , R(t) &#963; ) 14:</p><p>for all r &#8712; rules do &#8882; create firing rule for r 16:</p><p>args &#8592; args(head(r)) 17:</p><p>args &#8592; args :: (args(body(r)) -args(head(r)))</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>18:</head><p>CreateIDBPosRule(P F ire , R(t) &#963; , r, args) 19:</p><p>CreateIDBFiringRule(P F ire , R(t) &#963; , r, args) 20: return P F ire EDB atoms (line 13). For an EDB atom R(t) T , we use procedure createEDBFiringRule to create one rule F R,T (t) :-R(t) that returns tuples from relation R that match t. For missing tuples (R(t) F ), we extract all variables from t (some arguments may be constants propagated during unification) and create a rule that returns all tuples that can be formed from values of the associated domains of the attributes these variables are bound to and do not exist in R. This is achieved by adding goals dom(X i ) as explained in Example 12.</p><p>IDB atoms (lines <ref type="bibr">[13]</ref><ref type="bibr">[14]</ref><ref type="bibr">[15]</ref><ref type="bibr">[16]</ref><ref type="bibr">[17]</ref><ref type="bibr">[18]</ref><ref type="bibr">[19]</ref>. IDB atoms with F or F /T annotations are handled in the same way as EDB atoms with these annotations. If the atom is R(t) F (line 13), we create a rule with &#172; F R,T (t) in the body using the associated domain queries to restrict variable bindings. Similarly, for R(t) F /T , the procedure called in line 13 adds two additional rules as shown in Fig. <ref type="figure">9</ref> (5 th and 6 th rule) for EDB atoms. Both types of rules only use the positive firing version for R(t) and domain predicates in their body. Thus, these rules are independent of which rules derive R. Now, for any R, we create positive firing rules that correspond to the derivation of R through one particular rule. For that, we iterate over the annotated versions of all rules deriving R (lines 14+15). For each rule r with head R(t), we create a rule F R,T (t) :-F r,T ( X) where X is the concatenation of t with all existential variables from the body of r.</p><p>Rules (line <ref type="bibr">[15]</ref><ref type="bibr">[16]</ref><ref type="bibr">[17]</ref><ref type="bibr">[18]</ref><ref type="bibr">[19]</ref>. Consider a rule r : R(t) :-g 1 ( X 1 ), . . . , g n ( X n ). If the head of r is annotated with T , then we create a rule with head F r,T ( X) where X = vars(r) (stored in variable args, lines 16+17) and the same body as r except that each goal is replaced with its firing version with appropriate annotation (e.g., for</p><p>Fig. <ref type="figure">10</ref>: Example firing rules with connectivity checks positive goals). For rules annotated with or F /T , we create one additional rule with head F r,F ( X, V ) where X is defined as above, and V contains V i if the i th goal of r is positive and &#172; V i otherwise. The body of this rule contains the F /T version of every goal in r's body plus an additional goal F R,F to ensure that the head atom is failed. As an example for this type of rule, consider the third rule from the top in Fig. <ref type="figure">9</ref>.</p><p>Theorem 4 (Correctness of Firing Rules). Let P be an input program, r denote a rule of P with m goals, and P F ire be the firing version of P . We use r(t) |= P (I) to denote that the rule derivation r(t) is successful in the evaluation of program P over I. The firing rules for P correctly determine existence of tuples, successful derivations, and failed derivations for missing answers:</p><p>P (I) and for i &#8712; {1, . . . , m} we have that V i is false iff i th goal fails in r(t).</p><p>Proof. We prove Theorem 4 by induction over the structure of a program. For the proof, see <ref type="bibr">[26]</ref> or <ref type="bibr">[27]</ref>.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="8.4">Connectivity Joins</head><p>To be in the result of a firing rule is a necessary, but not sufficient, condition for the corresponding rule node to be connected to a node Q(t &#8242; ) &#8712; Match(&#968;) in the explanation. Thus, we have to check connectivity of intermediate results explicitly.</p><p>Example 13. Consider the firing rules for &#968; n,s shown in Fig. <ref type="figure">8</ref>. The corresponding rules with connectivity checks are shown in Fig. <ref type="figure">10</ref>. All rule nodes corresponding to F r1,T (n, s, Z) are guaranteed to be connected to the node Q(n, s) (corresponding to the only atom in Match(&#968; n,s )).</p><p>Note that connectivity joins are also required for negative firing rules (e.g., F r1,F (s, n, Z, V 1 , V 2 , &#172; V 3 ) in Fig. <ref type="figure">9</ref> is used for Whynot ). For sake of example, assume that instead of using T, rule r 1 uses an IDB relation R which is computed using a rule r 2 : R(X, Y ) :-T(X, Y ).</p><p>Consider the firing rule F r2,T (n, Z) :-T(n, Z) created based on the 1 st goal of r 1 . Some provenance fragments computed by this rule may not be connected to Q(n, s).</p><p>A tuple node R(n, c) for a constant c is only connected to the node Q(n, s) iff it is part of a successful binding of r 1 . That is, for the node R(n, c), there has to exist a tuple R(c, s). Connectivity is achieved by adding the head of the firing rule for r 1 to the body of the firing rule for r 2 as shown in Fig. <ref type="figure">10</ref> (the 3 rd and 4 th rule).</p><p>Our algorithm traverses the query's rules starting from PQ atom(s) to find all combinations of rules r i and r j such that the head of r j can be unified with a goal in r i 's body. For each such pair (r i , r j ) where the head of r j corresponds to the k th goal in the body of r i , we create a rule FC rj,r k i ,T ( X) as follows. We unify the variables of the k th goal in the firing rule for r i with the head variables of the firing rule for r j . All remaining variables of r i are renamed to avoid name clashes. We add the unified head of r i to the body of r j . These rules check whether rule nodes in the provenance graph are connected to nodes in Match(&#968;).</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="8.5">Computing the Edge Relation</head><p>The program created so far captures sufficient information for generating the edge relation of the explanation for a PQ (which is used when rendering graphs). We make this step part of the program to offload this work to database backend. To compute the edge relation, we use Skolem functions to create node identifiers. An identifier records the type of the node (tuple, rule, or goal), variables assignments, and the success/failure status of the node, e.g., a tuple node T(n, s) that is successful would be represented as f T T (n, s). Each rule firing corresponds to a fragment of PG(P, I). For example, one such fragment is shown in Fig. <ref type="figure">11</ref> (left). Such a substructure is created through a set of rules:</p><p>One rule creating edges between tuple nodes for the head predicate and rule nodes -One rule for each goal connecting a rule node to that goal node (only failed goals for failed rules) -One rule creating edges between each goal node and the corresponding EDB tuple node Example 14. Consider the firing rules with connectivity joins from Example 13. Some of the rules for creating the edge relation of the explanation sought by the user are shown in Fig. <ref type="figure">11</ref> (right). For example, each edge connecting the tuple node Q(n, s) to a successful rule node r 1 (n, s, Z) is created by the top-most rule, and the 2 nd rule creates an edge between r 1 (n, s, Z) and</p><p>Fig. <ref type="figure">11</ref>: Fragment of an explanation corresponding to a derivation of rule r 1 (left) and the rules generating the edge relation for such a fragment (right)</p><p>Edges for failed derivations are created by considering the corresponding node identifiers and a failure pattern (e.g., F r1,F (s, n, Z, V 1 , V 2 , &#172; V 3 )).</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="8.6">K-Explanations</head><p>To compute one of the K-explanation types introduced in Sec. 6.2, we only have to adapt the rules generating the edge relation. As an example, we present the modifications for computing Expl Which(X) (e.g., Fig. <ref type="figure">4c</ref>). Recall that semiring Which(X) models provenance as a set of contributing tuples and we encode this as a graph by connecting a head of a rule derivation to the atoms in its body. That is, for the Expl Which(X) , we create only one type of rule that connects tuple nodes for the head predicate to EDB tuple nodes. We use GP Which(X) P,&#968; to denote the program generated in this way for an input program P , and a PQ &#968;.</p><p>Example 15. Consider the graph fragment for r 1 in Fig. <ref type="figure">11</ref> (left) without rule and goal nodes. The rule that creates the edge between Q(n, s) and T(n, Z) is edge(f T Q (n, s), f T T (n, Z)) :-F r1,T (n, s, Z) For each successful derivation of result Q(n, s) using rule r 1 , a subgraph replacing Z with bindings from the derivation is included in Expl Which(X) .</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="8.7">Correctness</head><p>We now prove that our approach is correct. Proof. To prove Theorem 5, we have to show that 1) only edges from PG(P, I) are in GP P,&#968; (I) and 2) the program returns precisely the set of edges of explanation Expl(P, &#968;, I). The full proof is presented in <ref type="bibr">[26]</ref> and in our accompanying report <ref type="bibr">[27]</ref>. Theorem 6. Let P be a positive program, I be a database instance, and &#968; a PQ. The result of program GP Which(X) P,&#968; is the edge relation of Expl Which(X) (P, &#968;, I).</p><p>Proof. We prove Theorem 6 by induction over the structure of a program as in the proof of Theorem 4. The full proof is presented in our technical report <ref type="bibr">[27]</ref>.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="9">Factorization</head><p>For provenance polynomials, we can exploit the distributivity law of semirings to generate factorizations of provenance <ref type="bibr">[33]</ref> which are exponentially more concise in the best case. For instance, consider a query r 3 returning the end points of paths of length 2 evaluated over the edge-labelled graph in Fig. <ref type="figure">12a</ref>. The provenance polynomial for the query result Q 2hop (d) using the annotations from Fig. <ref type="figure">12a</ref> is shown in Fig. <ref type="figure">12d</ref>. Each monomial in the polynomial corresponds to one of the derivations of the result using r 3 . Each of these 2 &#8226; (2 2 ) (we have two options as starting points and, for each hop, we have two options) derivations corresponds to one path of length 2 ending in d. When generating provenance graphs for provenance polynomials, we create "&#8226;" nodes for rule derivations and "+" nodes for IDB tuples. Fig. <ref type="figure">12b</ref> is the factorized representation of this polynomial. We can exploit the fact that our approach shares common subexpressions to produce a particular factorization. This is achieved by rewriting the input program to partition a query by materializing joins and projections as new IDB relations which can then be shared. We first review f-trees and d-trees as introduced in <ref type="bibr">[34]</ref> which encode possible nesting "schemas" for factorized representations of provenance (or query results), the size bounds for factorized representations based on d-trees proven in <ref type="bibr">[34]</ref>, and how to chose a dtree for a query that results in the optimal worst-case size bound for the factorized representation of the provenance according to this d-tree. Then, we introduce a query transformation for conjunctive queries which, given an input query and the d-tree for this query, generates a rewritten query which returns a provenance graph factorized corresponding to this d-tree. We employ this rewriting to produce more concise provenance in PUG (experiments are shown in Sec. 11). Factorized Representations. In <ref type="bibr">[33,</ref><ref type="bibr">34]</ref>, a factorized representation (f-rep for short) of a relation is defined as an algebraic expression constructed using singleton relations (one tuple with one value) and the relational operators union and product. Any f-rep over a set of attributes from a schema S can be interpreted as a relation over S by evaluating the algebraic expression, e.g., {(a)}&#215;({(b)}&#8746;{(c)}) is a factorized representation of the relation {(a, b), (a, c)}. Following the convention from <ref type="bibr">[33]</ref>, we denote a singleton {(a)} as a. Factorization can be applied to compactly represent relations and query results as well as provenance (e.g., Fig. <ref type="figure">12b</ref>). We will factorize representations of provenance which encode variables of provenance polynomials as the tuples annotated by these variables and show how to extract provenance polynomials from provenance graphs generated in this way. F-trees for F-reps. Olteanu et al. <ref type="bibr">[34]</ref> introduce ftrees to encode the nesting structure of f-reps. At first, let us consider only f-trees which encode the nesting structure of a boolean query <ref type="bibr">[33]</ref>. An f-tree for a boolean query Q (e.g., r 4 in Fig. <ref type="figure">12a</ref>) is a rooted forest with one node for every variable of Q. <ref type="foot">4</ref> An f-rep according to an f-tree T nests values according to T : a node labelled with X corresponds to a union of values from the attributes bound to X by the query. The values of attributes bound to children of a node X corresponding to a single value x bound to X are grouped under x. If a node has multiple children, then their f-reps are connected via &#215;. For example, consider an f-tree T with root X and a single child Y for a query Q() :-R(X, Y ). An f-rep of Q according to T would be of the form x 1 &#215; (y 11 &#8746; . . . &#8746; y n1 ) &#8746; . . . &#8746; x m &#215; (y 1m &#8746; . . . &#8746; y nm ), i.e., the Y values co-occurring with a given X value x are grouped as a union and then paired with x. An ftree encodes (conditional) independence of the variables of a query in the sense that the values of one variable do not depend on the values of another variable. For instance, two siblings X and Y in an f-tree have to be independent since a union of X values is paired (crossproduct) with a union of Y values. This is only correct if the values of X and Y are independent. The independence assumptions encoded in an f-tree may not hold for every possible query with the same schema as the f-tree. Thus, only some f-trees with a particular schema may be applicable for a query with this schema. It was shown in <ref type="bibr">[34]</ref>, that a query has an f-rep over an f-tree T for any database iff for each relation in Q the variables assigned to attributes of this relation (these variables are called dependent) are on the same root-to-leaf path in the f-tree. This is called the path condition. Note that multiple references to the same relation in a query are considered as separate relations when checking this condition. For instance, consider the boolean query r 4 in Fig. <ref type="figure">12a</ref> which checks if there are paths of length 2 ending in the node d. Fig. <ref type="figure">12c</ref> shows two f-trees T 1 and T 2 for this query (ignore the sets on the side of nodes for now). An f-rep according to T 2 for r 4 would encode a union of Y values paired (&#215;) with a union of Z values for this Y value. Each Z value nested under a Y value is then paired with a cross-product of L 1 and L 2 values. </p><p>(a) 2hop queries (r 3 and r 4 ), rewriting (r 5 , r &#8242; 5 , r &#8242;&#8242; 5 ) according to d-tree T 1 , and example database (graph) D-trees for D-reps. The size of a factorized representation can be further reduced by allowing subexpressions to be shared through definitions, i.e., using algebra graphs instead of trees. In <ref type="bibr">[34]</ref>, such representations are called d-representations (d-rep). Analogous to how f-trees define the structure of f-reps, d-trees were introduced to define the structure of d-reps. A d-tree is an f-tree where each node X is annotated with a set key(X), a subset of its ancestors in the f-tree on which the node and any of its dependents depend on. The f-rep of the subtree rooted in X is unique for each combination of values from key(X). That is, if key(X) is a strict subset of the ancestors of X, then the same d-rep for the subtree at X can be shared by multiple ancestors, reducing the size of the representation. In Fig. <ref type="figure">12c</ref>, the set key is shown beside each node, e.g., in T 2 , the variable L 2 depends only on Z, but not on Y . An important result proven in <ref type="bibr">[34]</ref> is that, for a given d-tree T for a query Q, the size of d-rep of Q over a database I is bound by |I| s &#8593; (T ) where s &#8593; (T ) is a rational number computed based on T alone (see <ref type="bibr">[34]</ref> for details of how to compute s &#8593; (T )). This bound can be used to determine the d-tree for a query Q which will yield the d-rep of worst-case optimal size by enumerating the valid dtrees for Q and, then, chosing the one with the lowest value of s &#8593; .</p><p>Example 16. Consider the d-rep for r 4 (Fig. <ref type="figure">12a</ref>) over the example instance of relation H (Fig. <ref type="figure">12a</ref>) according to d-tree T 2 (Fig. <ref type="figure">12c</ref>). Variable Y at the root of T 2 is bound to the attribute S from the first reference of H, i.e., the starting point of paths of length 2 ending in d.</p><p>There are two such starting points a and b. Now each of these are paired with the only valid intermediate node c on these paths (variable Z). Finally, for this node, we compute the cross-product of the L 1 and L 2 values connected to c. Since the L 2 values only depend on Z,</p><p>we share these values when the same Z value is paired with multiple Y values. The final result is</p><p>Factorization of Provenance. For the provenance of a conjunctive query Q that is not a boolean query, i.e., it has one or more variables in the head (e.g., r 3 in Fig. <ref type="figure">12a</ref>), we have to compute a provenance polynomial for each result of Q. We would like the factorization of the provenance of Q to clearly associate the provenance polynomial of a result t with the tuple t. That is, we want to avoid factorizations where head variables of Q are nested below variables that store provenance (appear only in the body) since reconstructing the provenance polynomial for t would require enumeration of the full provenance from the factorized representation in the worst case. For example, consider a query with head variable X and body variable Y . If Y is the root of a d-tree T , then the d-rep of Q according to T would be of the form y 1 &#215; (x 11 + . . . + x n1 ) + . . . + y m &#215; (x 1m + . . . + x nm ). To extract the provenance polynomial for a result x i , we may have to traverse all y values since there is no indication, for which y values, x i appears in the sum x 1i + . . . + x ni . We ensure this by constructing d-trees which do not include the head variables, but treat those as ancestors of every node in the d-tree when computing key for the nodes. For instance, to make T 1 (Fig. <ref type="figure">12c</ref>) a valid d-tree for capturing the provenance of r 3 (Fig. <ref type="figure">12a</ref>), we treat the head variable X as a virtual ancestor of all nodes and get key(Z) = {X} and key(L 2 ) = {Z, X}. Furthermore, if we are computing an explanation to a provenance question (PQ) &#968; that binds one or more head variables to constants, then we can propagate these bindings before constructing a dtree for the query. For example, to explain Q 2hop (d), we would propagate the binding X = d resulting in rule r 4 (Fig. <ref type="figure">12a</ref>). Thus, any d-tree for r 4 can be used to cre-ate a factorized Expl N[X] graph for the user question Why (Q 2hop (d)).</p><p>Rewriting Queries for Factorization. We now explain how, given a d-tree T for a conjunctive query Q and positive PQ &#968; : = Why Q(t), to generate a Datalog query Q rewr such that, for any database I, we have that Expl N[X] (Q rewr , &#968;, I) encodes N[X](Q rewr , I, t) for each t &#8712; Match(&#968;) factorized according to T . We first unify the query with the PQ as described in Sec. 8.1. Given a unified input query Q and a d-tree T , we compute Q rewr as follows.</p><p>1. Assume a total order among the variables of Q (e.g., the lexicographical order). For every node X with children Y 1 , . . . , Y n in the d-tree T , we generate</p><p>2. Now for every atom R(Z 1 , . . . , Z m ) in the body of Q, we find the shortest path starting in a root node that contains all nodes Z 1 to Z m . Let Y = Z i for some i be the last node on this path. Then, we add atom R(Z 1 , . . . , Z m ) to the body of rule r Y created in the previous step. 3. Let X 1 , . . . , X n be the roots of the d-tree T (being a forest, a d-tree may have multiple roots). Furthermore, let Y 1 , . . . , Y m denote the head variables of the unified input query Q with the PQ. We create</p><p>The rewriting above creates a factorization according to a d-tree T . However, it may contain rules which cannot potentially lead to reuse and, thus, result in overhead that could be avoided if we were able to identify such rules. We now present an optimization that removes such rules to further reduce the size of the generated provenance graphs. Consider two nodes X and Y in a d-tree where Y is the only child of X, i.e., key(Y ) = key(X) &#8746; {X}. We would generate rules</p><p>In this case, the intermediate result Q Y does not lead to further factorization (we have a union of unions). Thus, we can merge the rules by substituting the atom Q Y (X &#8746; key(X)) in r X with the body of r Y . A similar situation may arise with the rule r Q deriving the final query result. In general, we can merge any rule of the form Q 1 (X 1 , . . . , X n ) :-Q 2 (X 1 , . . . , X n ) with the rule deriving Q 2 (in our translation, there will be exactly one rule with head Q 2 ). To rewrite the query according to the d-tree T 1 from Fig. <ref type="figure">12c</ref>, we apply the above algorithm to create rules:</p><p>Applying the optimizations introduced above, we merge the rules r Q 2hop with r Z (the head Q Z is the body of r Q 2hop ). Since key(Y ) = key(L 1 ) &#8746; {L 1 } and L 1 has only one child, we merge r Y into r L1 . The resulting program is shown as rules r 5 , r 5 &#8242; and r 5 &#8242;&#8242; in Fig. <ref type="figure">12a</ref>.</p><p>Factorized Explanations. To generate a concise factorization of provenance for a PQ &#968; over a conjunctive query Q, we first find a d-tree T with minimal s &#8593; among all d-trees for Q (such a d-tree T guarantees worst-case optimal size bounds for the generated factorization). Then, we rewrite the input query according to T (explained above) and use the approach in Sec. 8 to generate Expl N[X] (Q rewr , &#968;, I) encoding the d-rep of N[X](Q rewr , I, t) for each t &#8712; Match(&#968;).</p><p>Example 18. Continuing with Example 17, assume we compute the N[X] explanation using the rewritten query (r 5 , r 5 &#8242; , and r 5 &#8242;&#8242; ). The result over the example database is shown in Fig. <ref type="figure">12b</ref>. The top-most addition and multiplication correspond to the successful derivation using rule r 5 (using c as an intermediate hop from some node to d). The left branch below the multiplication encodes the four possible derivations of Q L1 (c) (s 1 + s 2 + t 1 + t 2 ) and the right branch corresponds to the two derivations of Q L2 (c) (u 1 + u 2 ). The polynomial captured by this graph is (s 1 + s 2 + t 1 + t 2 ) &#8226; (u 1 + u 2 ). That is, there are 4 ways to reach c from any starting node and two ways of reaching d from c leading to a total of 4 &#8226; 2 = 8 paths of length two ending in the node d.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="10">Implementation</head><p>We have implemented the approach presented in this paper in a system called PUG (Provenance Unification through Graphs). PUG is an extension of GProM <ref type="bibr">[1]</ref>, a middleware that executes provenance requests using a relational database backend (shown in Fig. <ref type="figure">13</ref>).</p><p>We have extended the system to support Datalog enriched with syntax for stating provenance questions.</p><p>The user provides a why or why-not question and the corresponding Datalog query as an input. Our system parses and semantically analyzes this input. Schema information is gathered by querying the catalog of the backend database (e.g., to determine whether an EDB predicate exists). Modules for accessing schema information are already part of the GProM system, but a  nodes of the constructed graph) and 2) recursive Datalog queries have to be evaluated over this graph using the well-founded semantics. The results for different instance sizes and number of variables are shown in Fig. <ref type="figure">15</ref>. Even for only 2 variables, DM did not finish for datasets of more than 10K tuples within the allocated 10 min timeslot. For queries with more than 4 variables, DM did not even finish for the smallest dataset.</p><p>Why Questions. The runtime of generating explanations for why questions over the queries r 1 , r 2 , r 4 , and r 5 (Fig. <ref type="figure">14</ref>) is shown in Fig. <ref type="figure">16</ref>. For the evaluation, we consider the effect of different binding patterns on performance. Fig. <ref type="figure">16c</ref> and 16f show which variables are bound by the provenance questions (PQs). Fig. <ref type="figure">16a</ref> and<ref type="figure">16b</ref> show the runtime for DBLP queries r 1 and r 2 , respectively. We also provide the number of rule nodes in the explanation for each binding pattern below the X axis.</p><p>If only variable X is bound (BindingX), then the queries determine authors that occur together with the author we have bound to X in the query result. For instance, the explanation for only2hop with BindingX explains why persons are indirect, but not direct, co-authors of "Tore Risch". If both X and Y are bound (BindingXY), then the provenance for r 1 and r 2 is limited to a particular indirect and direct co-author, respectively. The runtime for generating explanations grows roughly linear in the dataset size and outperforms DM even for small instances. Furthermore, Fig. <ref type="figure">16d</ref> and 16e (for r 4 and r 5 , respectively) show that our approach can handle queries with many variables (attributes in TPC-H) where DM times out even for the smallest dataset we have considered. Binding one variable (BindingY) in queries r 4 and r 5 expresses a condition, e.g., Y = '1-URGENT' in r 4 requires the order priority to be urgent. If both variables are bound, then the PQ verifies the existence of orders for a certain customer (e.g., why "Customer16" has at least one urgent order). Runtimes exhibit the same trend as for the DBLP queries.</p><p>Why-not Provenance. We use queries r 1 and r 2 from Fig. <ref type="figure">14</ref> to evaluate the performance of computing explanations for failed derivations. When binding all variables in the PQ (BindingXY) using the bindings from Fig. <ref type="figure">17c</ref>, these queries check if a particular set of authors do not appear together in the result. For instance, for only2hop (r 1 ), the query checks why "Tore Risch" is either not an indirect co-author or is a direct co-author of "Svein Johannessen". The results for queries r 1 and r 2 (DBLP) are shown in Fig. <ref type="figure">17a</ref> and 17b, respectively. The number of tuples produced by the provenance computation (the number of rule nodes is shown below the X axis) is quadratic in the database size resulting in a quadratic increase in runtime. DM only finishes within the allocated time for very small datasets while our approach scales to larger instances.</p><p>Queries with Negation. Recall that our approach also handles queries with negation. We choose rules r 3 (multiple negated goals) and r 6 (one negated goal) from Fig. <ref type="figure">14</ref> to evaluate the performance of answering why questions over such queries. We use the bindings shown in Fig. <ref type="figure">18c</ref>. The results for r 3 and r 6 are shown in Fig. <ref type="figure">18a</ref> and 18b, respectively. These results demonstrate that our approach efficiently computes explana-  tions for such queries. When increasing the database size, the runtimes of PQs for these queries exhibit the same trend as observed for other why (why-not) questions and significantly outperform DM. For instance, the performance of partNotAsia (Fig. <ref type="figure">18b</ref>), which contains many variables and negation exhibits the same trend as queries that have no negation (i.e., r 4 and r 5 in Fig. <ref type="figure">16d</ref> and Fig. <ref type="figure">16e</ref>, respectively).</p><p>Comparison with Links. In this experiment, we compare the runtime of computing Expl Which(X) (e.g., Fig. <ref type="figure">4c</ref>) with computation of Lineage in Links L from <ref type="bibr">[9]</ref>. We show relative runtimes where PUG is normalized to 1. For this particular evaluation, we use Postgres as a backend since it is supported by both PUG and Links. Note that Expl Which(X) contains a full description of each tuple unlike Links L which returns tuple identifiers (OIDs in Postgres). To get a nuanced understanding of the system's performance, we show three runtimes for Links: 1) Links is the actual implementation in Links which computes Lineage (only OIDs) and where the runtime includes the construction of in-memory Links types from the provenance fetched from Postgres; 2) LinksQ is the runtime of the queries that Links uses to capture Lineage; and 3) LinksQasEXPL which joins the output of LinksQ with the base tables (i.e., as informative as Expl Which(X) ). We choose two queries from <ref type="bibr">[9]</ref>. The query Q7 applies a range condition to the result of a two-way join. QF3 is a self-join on equality with an additional inequality condition (see <ref type="bibr">[9]</ref> for more details). The queries are expressed over two tables dept and emp.</p><p>The number of departments is varied from 4 to 2048 (by The runtimes of queries Q7 and QF3 are shown in Fig. <ref type="figure">19a</ref> and<ref type="figure">19b</ref>, respectively. Links performs better on smaller instances. The gap between Links and PUG shrinks with increasing dataset size. PUG outperforms Links and LinksQasEXPL on larger datasets. Factorized Explanations. We now compare the performance of generating provenance for a query (EXPL) and a factorized representation of provenance (Fact) by rewriting the input query (Sec. 9). Factorization techniques perform best for many-to-many joins (e.g., the query r 7 in Fig. <ref type="figure">14</ref>). The rewritten version of suppCust (r 7 ) producing factorized provenance is shown below. For this experiments, we use a 15 minute time-out. The runtimes for r 7 (yellow bars) and r 8 (red bars) are shown in Fig. <ref type="figure">20a</ref>. We show the total result size in bytes below the X axis. The runtime of Fact grows roughly linear unlike EXPL whose growth is quadratic in dataset size. We also evaluate query r 5 which includes one-to-many joins to see how Fact performs for a query (Fig. <ref type="figure">20b</ref>) where factorization only reduces size by a constant factor. This is confirmed by the measurements: the performance of Fact for r 5 is &#8764; 30% that of EXPL independent of dataset size.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="12">Conclusions</head><p>We present a provenance model and unified framework for explaining answers and non-answers over first-order queries expressed in Datalog. Our efficient middleware implementation generates a Datalog program that computes the explanation for a provenance question and compiles this program into SQL. We prove that our model is expressive enough to encode a wide range of provenance models from the literature and extend our approach to produce concise, factorized representations of provenance. In future work, we will investigate summarization of provenance (we did present a proof-ofconcept in <ref type="bibr">[28]</ref>) to deal with the large size of explanations for missing answers. We plan to also support query-based explanations <ref type="bibr">[2,</ref><ref type="bibr">3,</ref><ref type="bibr">4,</ref><ref type="bibr">40]</ref> and more expressive query languages (e.g., aggregation).</p></div><note xmlns="http://www.tei-c.org/ns/1.0" place="foot" n="1" xml:id="foot_0"><p>or, equivalently, queries in full relational algebra (without aggregation), formulas in FO logic under the closed world assumption, and SPJUD-queries (select, project, join, union, difference).</p></note>
			<note xmlns="http://www.tei-c.org/ns/1.0" place="foot" n="2" xml:id="foot_1"><p>This follows from the semantics of the type of 2-player game used here. The details are beyond the scope of this paper.</p></note>
			<note xmlns="http://www.tei-c.org/ns/1.0" place="foot" n="4" xml:id="foot_2"><p>In<ref type="bibr">[34]</ref>, relational algebra is used to express queries and nodes of f-trees represent equivalence classes of attributes which in Datalog correspond to query variables.</p></note>
		</body>
		</text>
</TEI>
