33
arXiv:2202.10766v2 [cs.DB] 5 May 2022 Revisiting Semiring Provenance for Datalog Camille Bourgaux 1 , Pierre Bourhis 2 , Liat Peterfreund 3 , Micha¨ el Thomazo 1 1 DI ENS, ENS, CNRS, PSL University & Inria, Paris, France 2 CRIStAL, CNRS, University of Lille, Inria, Lille, France 3 LIGM, CNRS, Universit´ e Gustave Eiffel, ENPC, Paris, France 1,2 {first.last}@inria.fr, 3 {first.last}@univ-eiffel.fr Abstract Data provenance consists in bookkeeping meta information during query evaluation, in order to enrich query results with their trust level, likelihood, evaluation cost, and more. The framework of semiring provenance abstracts from the spe- cific kind of meta information that annotates the data. While the definition of semiring provenance is uncontroversial for unions of conjunctive queries, the picture is less clear for Dat- alog. Indeed, the original definition might include infinite computations, and is not consistent with other proposals for Datalog semantics over annotated data. In this work, we pro- pose and investigate several provenance semantics, based on different approaches for defining classical Datalog semantics. We study the relationship between these semantics, and intro- duce properties that allow us to analyze and compare them. 1 Introduction Datalog is a rule language widely studied both in the database community, where it is seen as a query language, and in the KR community, as an ontology language. In relational databases, the framework of semiring prove- nance was introduced to generalize computations over annotated databases, e.g., the semantics of probabilistic databases (Senellart 2017), the bag semantics, lineage or why-provenance (Cheney, Chiticariu, and Tan 2009). In this framework, the semantics of positive relational algebra queries over databases annotated with elements of any commutative semiring is inductively defined on the struc- ture of the query (Green, Karvounarakis, and Tannen 2007; Green and Tannen 2017). Provenance semirings are expres- sions (such as polynomials) built from variables associated to each tuple of the database (Green 2009). A provenance expression provides a general representation of how tuples have been used to derive a query result, and can be faithfully evaluated in any semiring in which the considered prove- nance semiring can be homomorphically embedded. Semiring provenance has also been studied for Datalog queries, for which it was defined based on the set of all derivation trees for the query (Green, Karvounarakis, and Tannen 2007; Deutch et al. 2014; Deutch, Gilad, and Moskovitch 2018). However, this definition seems less axiomatic than in the case of relational databases. Indeed, there may be infinitely many derivation trees, leading to infinite provenance expres- sions, while Datalog programs have finite models that can be computed efficiently (Abiteboul, Hull, and Vianu 1995). A consequence is that this definition is valid only for a restricted class of semirings, namely ω-continuous. Re- cently, Dannert et al. (2021) restrict the semiring even further by considering fully-chain complete semirings in order to extend provenance definition to logical languages featuring negation and fixed-point. Even if numerous useful semirings are ω-continuous, or can be extended to a such semiring, infinite provenance expressions may be considered unintuitive in some cases. Consider, for example, the counting semiring (i.e., natural numbers with standard operations) for which provenance of positive relational algebra queries corresponds to their bag seman- tics. This semiring can be extended to an ω-continuous one by adding to the natural numbers, hence pro- viding a way to capture the bag semantics for Datalog queries (Mumick, Pirahesh, and Ramakrishnan 1990; Green, Karvounarakis, and Tannen 2007). However, query answers having infinite multiplicities may not seem very natural or informative. Moreover, alternative bag semantics for languages close to Datalog have been defined, and would not lead to such infinite multiplicities when applied to Datalog. This is in particular the case of the bag seman- tics for ontology-based data access (Nikolaou et al. 2017; Nikolaou et al. 2019), which corresponds to one of the two semantics proposed for source-to-target tuple gen- erating dependencies in the context of data exchange (Hernich and Kolaitis 2017). Interestingly, these bag semantics are not based on derivation trees but are model-theoretic semantics: they define annotated inter- pretations, and conditions for rules satisfaction over such interpretations. Such model-theoretic semantics have also been used in other contexts to evaluate Datalog and variants over annotated databases, such as fuzzy Datalog (Achs and Kiss 1995) or description logic knowledge bases annotated with provenance tokens (Calvanese et al. 2019; Bourgaux et al. 2020). Finally, yet other semantics defini- tions have been proposed for some use cases. For instance, Zhao, Subotic, and Scholz (2020) consider minimal depth proof trees, which correspond to a Datalog evaluation algorithm, with the intended use of understanding the computation of the result, and guiding debugging. The fact that the above semantics are not encompassed

arXiv:2202.10766v2 [cs.DB] 5 May 2022

Embed Size (px)

Citation preview

arX

iv:2

202.

1076

6v2

[cs

.DB

] 5

May

202

2

Revisiting Semiring Provenance for Datalog

Camille Bourgaux1 , Pierre Bourhis2 , Liat Peterfreund3 , Michael Thomazo1

1DI ENS, ENS, CNRS, PSL University & Inria, Paris, France2CRIStAL, CNRS, University of Lille, Inria, Lille, France

3LIGM, CNRS, Universite Gustave Eiffel, ENPC, Paris, France1,2{first.last}@inria.fr, 3{first.last}@univ-eiffel.fr

Abstract

Data provenance consists in bookkeeping meta informationduring query evaluation, in order to enrich query results withtheir trust level, likelihood, evaluation cost, and more. Theframework of semiring provenance abstracts from the spe-cific kind of meta information that annotates the data. Whilethe definition of semiring provenance is uncontroversial forunions of conjunctive queries, the picture is less clear for Dat-alog. Indeed, the original definition might include infinitecomputations, and is not consistent with other proposals forDatalog semantics over annotated data. In this work, we pro-pose and investigate several provenance semantics, based ondifferent approaches for defining classical Datalog semantics.We study the relationship between these semantics, and intro-duce properties that allow us to analyze and compare them.

1 Introduction

Datalog is a rule language widely studied both in thedatabase community, where it is seen as a query language,and in the KR community, as an ontology language.

In relational databases, the framework of semiring prove-nance was introduced to generalize computations overannotated databases, e.g., the semantics of probabilisticdatabases (Senellart 2017), the bag semantics, lineage orwhy-provenance (Cheney, Chiticariu, and Tan 2009). In thisframework, the semantics of positive relational algebraqueries over databases annotated with elements of anycommutative semiring is inductively defined on the struc-ture of the query (Green, Karvounarakis, and Tannen 2007;Green and Tannen 2017). Provenance semirings are expres-sions (such as polynomials) built from variables associatedto each tuple of the database (Green 2009). A provenanceexpression provides a general representation of how tupleshave been used to derive a query result, and can be faithfullyevaluated in any semiring in which the considered prove-nance semiring can be homomorphically embedded.

Semiring provenance has also been studiedfor Datalog queries, for which it was definedbased on the set of all derivation trees for thequery (Green, Karvounarakis, and Tannen 2007;Deutch et al. 2014; Deutch, Gilad, and Moskovitch 2018).However, this definition seems less axiomatic than in thecase of relational databases. Indeed, there may be infinitelymany derivation trees, leading to infinite provenance expres-

sions, while Datalog programs have finite models that canbe computed efficiently (Abiteboul, Hull, and Vianu 1995).A consequence is that this definition is valid only for arestricted class of semirings, namely ω-continuous. Re-cently, Dannert et al. (2021) restrict the semiring evenfurther by considering fully-chain complete semirings inorder to extend provenance definition to logical languagesfeaturing negation and fixed-point. Even if numeroususeful semirings are ω-continuous, or can be extendedto a such semiring, infinite provenance expressions maybe considered unintuitive in some cases. Consider, forexample, the counting semiring (i.e., natural numbers withstandard operations) for which provenance of positiverelational algebra queries corresponds to their bag seman-tics. This semiring can be extended to an ω-continuousone by adding ∞ to the natural numbers, hence pro-viding a way to capture the bag semantics for Datalogqueries (Mumick, Pirahesh, and Ramakrishnan 1990;Green, Karvounarakis, and Tannen 2007). However, queryanswers having infinite multiplicities may not seem verynatural or informative. Moreover, alternative bag semanticsfor languages close to Datalog have been defined, andwould not lead to such infinite multiplicities when appliedto Datalog. This is in particular the case of the bag seman-tics for ontology-based data access (Nikolaou et al. 2017;Nikolaou et al. 2019), which corresponds to one of thetwo semantics proposed for source-to-target tuple gen-erating dependencies in the context of data exchange(Hernich and Kolaitis 2017). Interestingly, these bagsemantics are not based on derivation trees but aremodel-theoretic semantics: they define annotated inter-pretations, and conditions for rules satisfaction over suchinterpretations. Such model-theoretic semantics havealso been used in other contexts to evaluate Datalog andvariants over annotated databases, such as fuzzy Datalog(Achs and Kiss 1995) or description logic knowledge basesannotated with provenance tokens (Calvanese et al. 2019;Bourgaux et al. 2020). Finally, yet other semantics defini-tions have been proposed for some use cases. For instance,Zhao, Subotic, and Scholz (2020) consider minimal depthproof trees, which correspond to a Datalog evaluationalgorithm, with the intended use of understanding thecomputation of the result, and guiding debugging.

The fact that the above semantics are not encompassed

by the definition of semiring provenance for Datalog, alongwith the need of handling infinite computations which areentailed by this definition, motivate us to investigate alterna-tive natural semantics that might be a better fit in differentcontexts.

In this paper we introduce several natural provenance se-mantics for Datalog over annotated data. Our definitionsare based on different classical approaches: model-theoretic,execution-based and proof tree-based. They capture thesemantics mentioned previously, and are inspired by prac-tical needs. For instance, our semantics definition basedon minimal depth derivation trees capture the behavior ofDatalog engines, such as Souffle (Souffle 2020), that storeonly minimal depth derivation trees instead of storing themall (which might be impossible in case there are infinitelymany); Our semantics based on non-recursive derivationtrees (in which a fact is not derived from itself) resem-bles the approach taken by some graph query languages,e.g., SPARQL and Cypher, to handle queries with possiblyinfinite outputs by allowing to explicitly restrict the outputto include only simple paths. In addition, some of the seman-tics suggested in the paper are closely related to paradigmsfor weighted reasoning in the context of words and trees(Esparza and Luttenberger 2011; Stuber and Vogler 2008).

After defining these different semantics, we study underwhich conditions they coincide and investigate their connec-tions. We then provide a general framework for definingsuch provenance semantics, and present several propertiesrelevant for provenance semantics that allow us to comparethem. We briefly discuss some complexity issues in conclu-sion. Proofs and additional discussion are available in theappendix.

2 Preliminaries

2.1 Datalog

We use the standard Datalog settings(cf. (Abiteboul, Hull, and Vianu 1995) part D).

Syntax Let P, C, and V be mutually disjoint, possiblyinfinite sets of predicates, constants, and variables respec-tively. Elements of C ∪ V are called terms. An atom hasthe form p(t1, . . . , tn) where p ∈ P is an n-ary predicate,and ti’s are terms. A fact (or ground atom) is a variable-freeatom. A (Datalog) rule is an expression: ∀~x∀~y(φ(~x, ~y) →ψ(~x)) where ~x and ~y are tuples of variables and φ(~x, ~y) andψ(~x) are conjunctions of atoms whose variables are ~x ∪ ~yand ~x respectively. We call φ(~x, ~y) and ψ(~x) the body andhead of the rule, respectively. From now on, we assumethat rules are in normalized form, i.e., the head consists of asingle atom H(~x), and quantifiers are implicit. The domainD(A) of a set A of atoms is the set of terms that appear inits atoms.

A database D is a finite set of facts, and a Datalog pro-gram (or ontology) Σ is a finite set of Datalog rules. Theschema of D (resp. Σ) denoted S(D) (resp. S(Σ)) is the setof predicates that appear in its atoms.1

1Note that we do not require the set of predicates of atoms ap-pearing in heads of rules to be disjoint from S(D); naturally, all of

Semantics The semantics of Datalog can classically be de-fined in three ways: through models, fixpoints or derivationtrees. All three definitions rely on the notion of homomor-phism: a homomorphism from a set A of atoms to a setB of atoms is a function h : D(A) → D(B) such thath(t) = t for all t ∈ C, and p(t1, . . . , tn) ∈ A impliesh(p(t1, · · · , tn)) := p(h(t1), . . . , h(tn)) ∈ B. We denoteby h(A) the set {h(p(t1, . . . , tn)) | p(t1, . . . , tn) ∈ A}.The homomorphism definition is extended to conjunctionsof atoms by viewing them as the sets of atoms they contain.

A set I of facts is a model of a rule r := φ(~x, ~y) → ψ(~x),denoted by I |= r, if every homomorphism h from φ(~x, ~y)to I is also a homomorphism from ψ(~x) to I; it is a model ofa Datalog program Σ if I |= r for every r ∈ Σ; it is a modelof a database D if D ⊆ I . A fact α is entailed by D and Σ,denoted Σ, D |= α, if α ∈ I for every model I of Σ and D.

Example 1. Let Σ contain the rules B(x) → A(x),R(x, y) ∧ A(y) → B(x), and R(x, y) → R(y, x), andD := {B(a), B(b), R(a, b), R(b, a)}. Each model of D andΣ contains all facts in D as well as A(a) and A(b), whichare thus entailed by Σ, D.

An equivalent way to define the entailment of a fact α byD and Σ is to check if there is a homomorphism from α toa specific model, defined as the least fixpoint containing Dof the immediate consequence operator: An immediate con-sequence for D and Σ is either α ∈ D, or α such that thereexists a rule r := φ(~x, ~y) → ψ(~x) and a homomorphism hfrom φ(~x, ~y) to D such that h(ψ(~x)) = α.

Finally, a third definition relies on derivation trees.

Definition 1 (Derivation Tree). A derivation tree t of a factα w.r.t. a databaseD and a program Σ is a finite tree whoseleaves are labeled by facts from D and non-leaf nodes arelabeled by triples (p(t1, . . . , tm), r, h) where

• p(t1, . . . , tm) is a fact over the schema S(Σ);

• r is a rule from Σ of the form φ(~x, ~y) → p(~x);

• h is a homomorphism from φ(~x, ~y) to the facts ofthe labels of the node children, such that h(p(~x)) =p(t1, . . . , tm);

• there is a bijection f between the node children and theatoms of φ(~x, ~y), such that for every q(~z) ∈ φ(~x, ~y),f(q(~z)) is of the form (h(q(~z)), r′, h′) or is a leaf labeledby h(q(~z)).

Moreover, if (p(t1, · · · , tm), r, h) or p(t1, · · · , tm) is theroot of t, then p(t1, · · · , tm) = α.

Example 2. Let Σ contain r1 := R(x, y) → H(x, x), r2 :=R(x, y) → H(x, y) and r3 := S(x, y, z) ∧ S(x, z, y) →H(x, x). If D = {R(a, a), S(a, b, c), S(a, c, b)}, thenthe fact α := H(a, a) has the following derivation trees

(α, r1, h)

R(a, a)

(α, r2, h)

R(a, a)

(α, r3, h3)

S(a, b, c)S(a, c, b)

(α, r3, h′3)

S(a, c, b)S(a, b, c)

where h(x) = h(y) = a, h3(x) = a, h3(y) = b, h3(z) = cand h′3(x) = a, h′3(y) = c, h′3(z) = b.

our results are valid under this assumption as well.

A(a)

B(a)

A(a)

B(a)

R(a, b) A(b)

B(b)

A(a)

B(a)

R(a, b)

R(b, a)

A(b)

B(b)

Figure 1: Some derivation trees of A(a) in Example 1.

Note that when the program at hand is recursive (i.e., thedependency graph of its predicates contains cycles) a factmay have infinitely many derivation trees. Figure 1 depictssome of the infinitely many derivation trees of A(a) fromExample 1. In this example, and from this point on, weomit rules and homomorphisms from trees when there is noambiguity.

Queries A conjunctive query (CQ) is an existentially quan-tified formula ∃~y φ(~x, ~y) where φ(~x, ~y) is a conjunction ofatoms with variables in ~x∪~y; a union of conjunctive queries(UCQ) is a disjunction of CQs (over the same free variables).A query is Boolean if it has no free-variables. A set offacts I satisfies a Boolean CQ (BCQ) q := ∃~y φ(~y), writ-ten I |= q, if and only if there is a homomorphism fromφ(~y) to I . A BCQ q is entailed by a Datalog program Σand database D, written Σ, D |= q, if and only if I |= q forevery model I of Σ and D. Note that Σ, D |= q if and onlyif Σ ∪ {φ(~y) → goal}, D |= goal, where goal is a nullarypredicate such that goal /∈ S(Σ) ∪ S(D). A tuple of con-stants ~a is an answer to a CQ q(~x) := ∃~y φ(~x, ~y) over Σ andD if ~a and ~x have the same arity and Σ, D |= q(~a) whereq(~a) is the BCQ obtained by replacing the variables from~x with the corresponding constants from ~a. When Σ = ∅,it amounts to the existence of a homomorphism from q(~a)to D, which corresponds to the semantics of CQs over rela-tional databases.

2.2 Annotated Databases

To equip databases with extra information, their facts mightbe annotated with, e.g., trust levels, clearance degree re-quired to access them, or identifiers to track how they areused.

In the framework of semiring provenance, annotationsare elements of algebraic structures known as commutativesemirings. A semiring K = (K,+K,×K, 0K, 1K) is a set Kwith distinguished elements 0K and 1K, equipped with twobinary operators: +K, called the addition, which is an asso-ciative and commutative operator with identity 0K, and ×K,called the multiplication, which is an associative operatorwith identity 1K. It also holds that ×K distributes over +K,and 0K is annihilating for ×K. When multiplication is com-mutative, the semiring is said to be commutative. We use theconvention according to which multiplication is applied be-fore addition to omit parentheses. We omit the subscript ofoperators and distinguished elements when there is no ambi-guity.

Definition 2. An annotated database is a triple (D,K, λ)

where D is a database, K = (K,+K,×K, 0K, 1K) is a semir-ing, and λ : D 7→ K \ {0K} maps facts into semiring ele-ments different from 0K.

Example 3 (Ex. 1 cont’d). The semiring N =(N,+,×, 0, 1) of the natural numbers equipped with theusual operations is used for bag semantics. The tropi-cal semiring T = (R∞

+ ,min,+,∞, 0) is used to computeminimal-cost paths. We define λN : D 7→ N \ {0}by λN(B(a)) = 3, λN(B(b)) = 1, λN(R(a, b)) = 2,λN(R(b, a)) = 1; And λT : D 7→ R+ by λT(B(a)) = 10,λT(B(b)) = 1, λT(R(a, b)) = 5, λT(R(b, a)) = 2.

We next list some possible properties of semirings. Asemiring is + -idempotent (resp. ×-idempotent) if for everya ∈ K , a+a = a (resp. a×a = a). It is absorptive if for ev-ery a, b ∈ K , a× b+ a = a. It is positive if for every a, b ∈K , a× b = 0 if and only if (a = 0 or b = 0), and a+ b = 0if and only if a = b = 0. Finally, an important class isthat of ω-continuous commutative semirings in which infi-nite sums are well-defined. Given a semiring, we define thebinary relation ⊑ such that a ⊑ b if and only if there existsc ∈ K such that a + c = b. A commutative semiring isω-continuous if ⊑ is a partial order, every (infinite) ω-chaina0 ⊑ a1 ⊑ a2 . . . has a least upper bound sup((ai)i∈N),and for every a, a+ sup((ai)i∈N) = sup((a + ai)i∈N) anda× sup((ai)i∈N) = sup((a× ai)i∈N).

The semantics of queries from the positive relational al-gebra, and in particular of UCQs, over annotated databasesis defined inductively on the structure of the query(Green, Karvounarakis, and Tannen 2007). Intuitively, jointuse of data (conjunction) corresponds to multiplication, andalternative use of data (union or projection) corresponds toaddition.

Example 4 (Ex. 3 cont’d). The BCQ ∃xy (R(x, y) ∧B(y)) is entailed from (D,N, λN) with multiplicityλN(R(a, b)) × λN(B(b)) + λN(R(b, a)) × λN(B(a)) = 5,and from (D,T, λT) with minimal cost min(λT(R(a, b)) +λT(B(b)), λT(R(b, a)) + λT(B(a))) = 6.

A semantics of Datalog over annotated databases has beendefined by Green, Karvounarakis, and Tannen (2007) usingderivation trees, that we shall name the all-tree semantics.It associates to each fact α entailed by Σ and D the follow-ing sum, where TΣ

D(α) is the set of all derivation trees forα w.r.t. Σ and D and Λ(t) :=

v is a leaf of t λ(v) is the K-annotation of the derivation tree t (since K is commutative,the result of the product is well-defined).

PAT(Σ, D,K, λ, α) :=∑

t∈TΣD(α)

Λ(t).

Since TΣD(α) may be infinite, PAT is well-defined for all Σ,

(D,K, λ) and α only in the case where K is ω-continuous.

Example 5 (Ex. 3 cont’d). The fact α := A(a)is entailed with minimal cost: PAT(Σ, D,T, λT, α) =mint∈TΣ

D(α)Σv is a leaf of tλT(v) = 3. Since N is not ω-

continuous, PAT(Σ, D,N, λN, α) is not defined.

2.3 Provenance Semirings

Provenance semirings have been introduced to abstract froma particular semiring by associating a unique provenance to-

ken to each fact of the database, and building expressionsthat trace their use. Given a set X of variables that annotatethe database, a provenance semiring Prov (X) is a semir-ing over a space of provenance expressions with variablesfrom X .

Various such semirings were introduced in the context ofrelational databases (Green 2009): The most expressive an-notations are provided by the provenance polynomials semir-ing N[X ] := (N[X ],+,×, 0, 1) of polynomials with coef-ficients from N and variables from X , and the usual opera-tions. Less general provenance semirings include, for exam-ple, the semiring B[X ] := (B[X ],+,×, 0, 1) of polynomialswith Boolean coefficients, and the semiringPosBool (X) :=(PosBool (X),∨,∧, false, true) of positive Boolean expres-sions.

In the Datalog context, it is important to allow for in-finite provenance expressions, as there can be infinitelymany derivation trees. A formal power series with vari-ables from X and coefficients from K is a mapping thatassociates to each monomial over X a coefficient in K . Aformal power series S can be written as a possibly infinitesum S = Σm∈mon(X)S(m)m where mon(X) is the set

of monomials over X and S(m) is the coefficient of themonomial m. The set of formal power series with vari-ables from X and coefficients from K is denoted KJXK.Green, Karvounarakis, and Tannen (2007) define the Data-log provenance semiring as the semiring N

∞JXK of formalpower series with coefficients from N

∞ = N ∪ {∞}.

A semiring homomorphism from K =(K,+K,×K, 0K, 1K) to K

′ = (K ′,+K′ ,×K′ , 0K′ , 1K′) is amapping h : K → K ′ such that h(0K) = 0K′ , h(1K) = 1K′ ,and for all a, b ∈ K , h(a +K b) = h(a) +K′ h(b)and h(a ×K b) = h(a) ×K′ h(b). A semiring ho-momorphism between ω-continuous semirings isω-continuous if it preserves least upper bounds:h(sup((ai)i∈N)) = sup((h(ai))i∈N).

Following Deutch et al. (2014), we say that a provenancesemiring Prov (X) specializes correctly to a semiring K,if any valuation ν : X → K extends uniquely to a (ω-continuous if Prov (X) and K are ω-continuous) semiringhomomorphism h : Prov (X) → K , allowing the computa-tions for K to factor through the computations for Prov(X).A provenance semiring Prov(X) is universal for a set ofsemirings if it specializes correctly to each semiring of thisset. Green, Karvounarakis, and Tannen (2007) showed thatN[X ] is universal for commutative semirings, and N

∞JXKis universal for commutative ω-continuous semirings.

3 Alternative Semantics

In this section we propose several natural ways of definingthe semantics of Datalog over annotated databases, and in-vestigate their connections. We have seen that the semanticsof Datalog can equivalently be defined through models, fix-points or derivation trees. The semantics we propose alsofall into these three approaches. For presentation purposes,we see each semantics as a partial function P that associatesto a Datalog program Σ, annotated database (D,K, λ), andfact α, a semiring element P(Σ, D,K, λ, α).

3.1 Model-Based Semantics

We first investigate two provenance semantics based on Dat-alog’s model-theoretic semantics. In both cases, we will de-fine interpretations (I, µI) where I is a set of facts and µI

is a function that annotates facts of I , and formulate require-ments for them to be models of Σ and (D,K, λ), extendingstandard models of Σ and D with fact annotations.

Annotated Model-based Hernich and Kolaitis (2017) de-fine two bag semantics in the context of data exchange: theincognizant and cognizant semantics. The difference be-tween them arise from the two different semantics of bagunion: the incognizant semantics uses the maximum-basedunion, while the cognizant semantics uses the sum-basedunion.

In more details, both semantics are based on the follow-ing semantics for source-to-target tuple generating depen-dencies (s-t tgds): a pair (I, J) of source and target instancessatisfies an s-t tgd q1(~x) → q2(~x) if for every answer ~a to q1over I ,~a is an answer to q2 over J with at least the same mul-tiplicity. Given a set of s-t tgds Σ and a source I , a target Jis an incognizant solution for I w.r.t. Σ if (I, J) satisfies ev-ery s-t tgd in Σ. It is a cognizant solution if for every r ∈ Σ,there is a target instance Jr such that (I, Jr) satisfies r and⊎Jr ⊆ J , where ⊎ denotes the sum-union of bags (i.e., themultiplicity of each element of the sum-union is equal to thesum of its multiplicities). The incognizant (resp. cognizant)certain answers to a query q w.r.t. Σ on I are defined usingbag intersection of the answers over the incognizant (resp.cognizant) solutions for I w.r.t. Σ, i.e., the multiplicity ofan answer is the minimum of its multiplicities over the solu-tions. Note that for BCQs, the only possible certain answeris the empty tuple.

For example, consider Σ = {B(x) → A(x), C(x) →A(x)} and D = {(B(a), 1), (C(a), 1)}. Under the incog-nizant semantics, the multiplicity of the certain answer ofthe Boolean query A(a) w.r.t. Σ and D is 1 while under thecognizant semantics it is 2. Indeed, J = {(A(a), 1)} is anincognizant solution forD w.r.t. Σ as it satisfies both s-t tgds,but is not a cognizant solution as the sum of multiplicitiesthat arise from the two rules is 2.

It is easy to show that the cognizant semantics isequivalent to PAT on the counting semiring N =(N,+,×, 0, 1), and thus coincides with the classical bagsemantics for Datalog. However, we have seen thatthe incognizant and cognizant semantics differ. More-over, note that in the field of ontology-based data ac-cess, the bag semantics defined by Nikolaou et al. forDL-LiteR (2017; 2019) coincides with the incognizantsemantics, thus disagrees with the classical Datalogbag semantics (Mumick, Pirahesh, and Ramakrishnan 1990;Green, Karvounarakis, and Tannen 2007).

We hence define a provenance semantics that coincideswith these semantics when used with the counting semiring.Since it is based on greatest lower bounds, it is defined on arestricted class of semirings.

Let K = (K,+,×, 0, 1) be a commutative ω-continuoussemiring such that for every K ′ ⊆ K , the greatest lowerbound inf(K ′) of K ′ is well defined (i.e., there exists a

unique z ∈ K such that z ⊑ x for every x ∈ K ′ and every z′

such that z′ ⊑ x for every x ∈ K ′ is such that z′ ⊑ z), Σ bea Datalog program, and (D,K, λ) be an annotated database.We define K-annotated interpretations as pairs (I, µI) whereI is a set of facts, and µI is a function from I to K . We saythat a K-annotated interpretation (I, µI) is a model of Σ and(D,K, λ), denoted by (I, µI) |= (Σ, D,K, λ), if

1. D ⊆ I , and for every α ∈ D, λ(α) ⊑ µI(α);

2. for every φ(~x, ~y) → H(~x) in Σ, whenever there is ahomomorphism h : φ(~x, ~y) 7→ I , then h(H(~x)) ∈ I and

h′:φ(~x,~y) 7→I,h′(~x)=h(~x)

β∈h′(φ(~x,~y))

µI(β) ⊑ µI(h(H(~x))).

The annotated model-based provenance semantics PAM isdefined by

PAM(Σ, D,K, λ, α) := inf({µI(α)|(I, µI)|=(Σ, D,K, λ)}).

Proposition 1. If the Datalog rules in Σ are (1) s-t tgds, or(2) formulated in DL-LiteR, then for every BCQ q, PAM(Σ∪{q → goal}, D,N, λN, goal) is equal to the multiplicity ofthe empty tuple in (1) the incognizant certain answers or (2)the bag certain answers to q w.r.t. Σ and (D,N, λN).

Set-Annotated Model-based We adapt the work onprovenance for the description logics DL-LiteR and ELHr

(Calvanese et al. 2019; Bourgaux et al. 2020), where thesemiring is assumed to be a ×-idempotent provenance semir-ing Prov(X) and rules are also annotated. Annotated mod-els of annotated knowledge bases are defined as set of factsannotated with sets of monomials from Prov (X). Given afact α and a monomial m over X , (Σ, D,Prov (X), λX) |=(α,m) holds when m belongs to the annotation set of α inevery models of Σ and (D,Prov (X), λX).

To obtain an analog provenance semantics for Datalog,we define interpretations which associate facts with (possi-bly infinite) sets of annotations, and formulate the require-ments for them to be models of Σ and (D,K, λ).

Let K = (K,+,×, 0, 1) be a commutative ω-continuoussemiring, Σ be a Datalog program, and (D,K, λ) be an an-notated database. We define K-set-annotated interpretationsas pairs (I, µI) where I is a set of facts, and µI is a functionfrom I to the power-set of K . We say that a K-set-annotatedinterpretation (I, µI) is a model of Σ and (D,K, λ), denotedby (I, µI) |= (Σ, D,K, λ), if

1. D ⊆ I , and for every α ∈ D, λ(α) ∈ µI(α);

2. for every φ(~x, ~y) → H(~x) in Σ, whenever there is a ho-momorphism h : φ(~x, ~y) 7→ I , then h(H(~x)) ∈ I and ifh(φ(~x, ~y)) = β1 ∧ · · · ∧ βn, {Πn

i=1ki | (k1, . . . , kn) ∈µI(β1)× · · · × µI(βn)} ⊆ µI(h(H(~x))).

The set-annotated model-based provenance semanticsPSAM is defined by

PSAM(Σ, D,K, λ, α) :=∑

k∈⋂

(I,µI )|=(Σ,D,K,λ) µI (α)

k.

Connections between semantics Let ⊑ be the binary re-lation between provenance semantics such that P ⊑ P ′ ifand only if P(Σ, D,K, λ, α) ⊑ P ′(Σ, D,K, λ, α) for everyΣ, (D,K, λ) and α on which P and P ′ are well-defined.

Proposition 2. The following holds:

PAM ⊑ PAT and PSAM ⊑ PAT.

Next examples show that PAM and PSAM are incomparable.

Example 6. Let Σ = {A(x) → goal, B(x) → goal}, D ={A(a), B(a)}, λN(A(a)) = 2 and λN(B(a)) = 3.

Annotated models of Σ and (D,N, λN) are such thatµI(goal) ≥ 3, so PAM(Σ, D,N, λN, goal) = 3.

Set-annotated models of Σ and (D,N, λN) are such that{2, 3} ⊆ µI(goal), so PSAM(Σ, D,N, λN, goal) = 5.

Hence PAM(Σ, D,N, λN, goal)<PSAM(Σ, D,N, λN, goal).

Example 7. Let Σ = {R(x, y) → goal}, D ={R(a, b), R(a, c)}, λN(R(a, b)) = 2 and λN(R(a, c)) = 2.

Annotated models of Σ and (D,N, λN) are such thatµI(goal) ≥ 4, so PAM(Σ, D,N, λN, goal) = 4.

Set-annotated models of Σ and (D,N, λN) are such that{2} ⊆ µI(goal), so PSAM(Σ, D,N, λN, goal) = 2.

Hence PAM(Σ, D,N, λN, goal)>PSAM(Σ, D,N, λN, goal).

Despite of their inherently different approaches, PAM,PSAM and PAT coincide on a large class of semirings.

Proposition 3. If K is a commutative + -idempotentω-continuous semiring, then for every Σ, (D,K, λ),and α, PAM(Σ, D,K, λ, α) = PSAM(Σ, D,K, λ, α) =PAT(Σ, D,K, λ, α).

Additional insights on the connection between defini-tions can be gained by considering the provenance semir-ing N

∞JXK: the monomials with non-zero coefficients arethe same with all semantics but their coefficients may differ(PAT leading to the highest coefficients by Proposition 2).

Proposition 4. Let λX be an injective function from D toX .

• A monomial occurs in PAT(Σ, D,N∞JXK, λX , α) if andonly if it occurs in PAM(Σ, D,N∞JXK, λX , α).

• PSAM(Σ, D,N∞JXK, λX , α) is obtained by setting allnon-zero coefficients to 1 in PAT(Σ, D,N∞JXK, λX , α).

An example where PAT and PAM or PSAM differ onN

∞JXK is the following: Let Σ contain A(x) → B(x),B(x) → A(x), D = {A(a)} and λX(A(a)) = x.Since there are infinitely many derivation trees forA(a), PAT(Σ, D,K, λX , A(a)) = ∞x while for P ∈{PAM,PSAM}, P(Σ, D,N∞JXK, λX , A(a)) = x, as{A(a), B(a)} with both facts annotated with x (resp. {x})is a (resp. set-)annotated model for Σ and (D,N∞JXK, λX).

Note that PAM and PSAM can still lead to infinite prove-nance expressions: Let Σ = {A(x) ∧ B(x) → A(x)},D = {A(a), B(a)}, λX(A(a)) = x and λX(B(a)) = y.For P ∈ {PAM,PSAM}, P(Σ, D,N∞JXK, λX , A(a)) = x +xy + xy2 + xy3 + . . . .

3.2 Execution- and Tree-Based Semantics

We saw that when annotations are present there is more thanone way to define a model-based semantics for Datalog andthat it differs from the all-tree semantics. We now investigatedefinitions based on classical Datalog evaluation algorithms.

We extend the notion of immediate consequence opera-tor describing the application of rules onto facts, with the

computation of annotation. To this end, we introduce theannotation aware immediate consequence operator TΣ. Ap-plying TΣ on a set of annotated facts (I,K, λ) results in(ITΣ ,K, λTΣ) where ITΣ is the result of applying the imme-diate consequence operator to Σ and I , and λTΣ annotatesfacts in ITΣ with the relational provenance (over (I,K, λ))of the UCQ formed by the bodies of the rules that createthem. Formally,

ITΣ := {H(~a) | I |= ∃~y φ(~a, ~y) , φ(~x, ~y) → H(~x) ∈ Σ}

λTΣ(H(~a)) :=∑

h(~x)=~a, I|=h(φ(~x,~y))φ(~x,~y)→H(~x)∈Σ

β∈h(φ(~x,~y))

λ(β)

We define a union operator for annotated databases (overthe same semiring): (I,K, λ) ∪ (I ′,K, λ′) := (I ∪ I ′,K, λ′′)where λ′′(α) := λ(α)+λ′(α) where we slightly abuse nota-tion by setting λ(α) = 0 if α /∈ I , and λ′(α) = 0 if α /∈ I ′.

Naive Evaluation / All Trees In the naive evaluation al-gorithm, all rules are applied in parallel until a fixpoint isreached. The ‘annotation aware’ version of it is as follows:We set I0n (Σ, D,K, λ) := (D,K, λ), and define inductivelyIi+1n (Σ, D,K, λ) := TΣ(I

in(Σ, D,K, λ)) ∪ (D,K, λ). Note

that the subscript n of In is an abbreviation for ‘naive’, andthe superscript i indicates how many times TΣ was applied.

Let (Iin,K, λin) denote Iin(Σ, D,K, λ). We say that

Iin(Σ, D,K, λ) converges if there is some k such that Iℓn =Ikn for every ℓ ≥ k, and sup(λin(α)) exists for every α ∈ Ikn .

Proposition 5. For every Σ, D,K, λ, if K is ω-continuousthen Iin(Σ, D,K, λ) converges.

In this case, we define I∞n := Ikn and λ∞n := supi→∞ λin.The naive execution provenance semantics PNE is definedby

PNE(Σ, D,K, λ, α) :=

{λ∞n (α) α ∈ I∞n

0 otherwise

and is equivalent to the all-tree semantics.

Proposition 6. It holds that PNE = PAT.

Optimized Naive Evaluation / Minimal Depth Trees Weconsider an optimized version of the naive algorithm thatstops as soon as the desired fact is derived. We de-fine the ‘annotation aware’ version of this algorithm byI0o,α(Σ, D,K, λ) := (D,K, λ), and

Ii+1o,α (Σ, D,K, λ) :=

{TΣ(I

io,α(Σ, D,K, λ)) ∪ (D,K, λ) α /∈ Iio,α

Iio,α(Σ, D,K, λ) otherwise

where Iio,α is such that Iio,α(Σ, D,K, λ) := (Iio,α,K, λio,α).

Proposition 7. For every Σ, D,K, λ, and α such thatΣ, D |= α , there exists k ≥ 0 such that Iko,α(Σ, D,K, λ) =

Iℓo,α(Σ, D,K, λ) for every ℓ ≥ k.

With k as provided by Proposition 7, we define the opti-mized execution provenance semantics POE by:

POE(Σ, D,K, λ, α) :=

{

λko,α(α) α ∈ Iko,α0 otherwise

We show that an equivalent tree-based semantics can beobtained by considering only minimal depth trees for thedesired fact. This approach has been considered use-ful, for example to present a ‘small proof’ for debugging(Zhao, Subotic, and Scholz 2020). Formally, let depth(t)denote the depth of tree t. We say that t ∈ TΣ

D(α) is

of minimal depth if for every t′ ∈ TΣD(α) it holds that

depth(t) ≤ depth(t′). The minimal depth tree prove-nance semantics PMDT is defined by

PMDT(Σ, D,K, λ, α) :=∑

t∈TΣD(α)

is of minimal depth

Λ(t)

and is equivalent to the optimized naive execution.

Proposition 8. It holds that POE = PMDT.

Seminaive Evaluation / Hereditary Minimal Depth TreesIn the seminaive evaluation algorithm, facts are derivedonly once. We introduce a new consequence operator∆Σ that derives only new facts and is defined as fol-lows: ∆Σ(I,K, λ) := (I∆Σ ,K, λ∆Σ) where TΣ(I,K, λ) :=(ITΣ ,K, λTΣ), I∆Σ := ITΣ \ I , and λ∆Σ is the restrictionof λTΣ to I∆Σ . We can now define the annotation awareversion of the seminaive evaluation: I0sn(Σ, D,K, λ) :=(D,K, λ) and Ii+1

sn (Σ, D,K, λ) := Iisn(Σ, D,K, λ) ∪∆Σ(I

isn(Σ, D,K, λ)).

Proposition 9. For every Σ, D,K, λ, there exists k ≥ 0 suchthat Iksn(Σ, D,K, λ) = Iℓsn(Σ, D,K, λ) for every ℓ ≥ k.

Note that, unlike in Proposition 5, we do not require K tobe ω-continuous. With k provided by Proposition 9, the sem-inaive execution provenance semantics PSNE is defined by

PSNE(Σ, D,K, λ, α) :=

{

λksn α ∈ Iksn0 otherwise

To capture this with the tree-based approach we need tofurther restrict all subtrees to be of minimal depth. Formally,a derivation tree t ∈ TΣ

D(α) is a hereditary minimal-depth(derivation) tree if for every node n of t labeled by (β, r, h),the subtree tβ with root n is a minimal-depth derivation treefor β. The hereditary minimal depth tree provenance seman-tics PHMDT is defined by

PHMDT(Σ, D,K, λ, α) :=∑

t∈TΣD(α)

is hereditary minimal-depth

Λ(t)

and is equivalent to the seminaive execution.

Proposition 10. It holds that PSNE = PHMDT.

3.3 Non-Recursive Tree-Based Semantics

Both execution-based semantics POE and PSNE take into ac-count finite subsets of derivation trees (and hence converge).Is there a more informative tree-based semantics (i.e., onethat takes into account a bigger subset of derivation trees)that still converges? We present such a semantics based onthe intuition that deriving a fact from itself is redundant.

Formally, a non-recursive (derivation) tree is a derivationtree that does not contain two nodes labeled with the same

fact and such that one is the descendant of the other. Thenon-recursive tree provenance semantics PNRT is defined by

PNRT(Σ, D,K, λ, α) :=∑

t∈TΣD(α)

is non-recursive

Λ(t).

Connections between semantics Next proposition fol-lows from the fact that hereditary minimal-depth trees areof minimal-depth and non recursive. The sets of minimaldepth trees and non-recursive trees are incomparable, so thatPNRT 6⊑ PMDT and PMDT 6⊑ PNRT.

Proposition 11. The following hold:

PHMDT ⊑ PNRT ⊑ PAT and PHMDT ⊑ PMDT ⊑ PAT

Moreover PNRT and PAT coincide on specific semirings.

Proposition 12. For every Σ, D,K, λ and α, if K isa commutative absorptive ω-continuous semiring, thenPNRT(Σ, D,K, λ, α) = PAT(Σ, D,K, λ, α).

If K is not absorptive, there exists Σ, (D,K, λ) and αsuch that PNRT(Σ, D,K, λ, α) 6= PAT(Σ, D,K, λ, α), evenin the case where K is + -idempotent and ×-idempotent:Let Σ consist of the rule A(x) ∧ B(x) → A(x) and D ={A(a), B(a)}. Then PNRT(Σ, D,K, λ, A(a)) = λ(A(a))while PAT(Σ, D,K, λ, A(a)) = λ(A(a)) + λ(A(a)) ×λ(B(a)).

The other semantics differ even under strong restrictions.

Example 8. This example shows thatPNRT, PMDT andPHMDT

differ even if K is + and ×-idempotent and absorptive.

Let Σ ={B(x) ∧ C(x) → A(x), D(x) → B(x),

E(x) → C(x), F (x) → E(x)}

D ={C(a), D(a), E(a), F (a)}

The three derivation trees of A(a) w.r.t. Σ and D are non-recursive, but only the first two are of minimal depth andonly the first one is a hereditary minimal-depth tree.

A(a)

B(a)

D(a)

C(a)

A(a)

B(a)

D(a)

C(a)

E(a)

A(a)

B(a)

D(a)

C(a)

E(a)

F (a)

Thus, if (D,K, λ) is such that λ(C(a)) = c, λ(D(a)) = d,λ(E(a)) = e, and λ(F (a)) = f then

PNRT(Σ, D,K, λ, A(a)) =c× d+ d× e+ d× f

PMDT(Σ, D,K, λ, A(a)) =c× d+ d× e

PHMDT(Σ, D,K, λ, A(a)) =c× d

4 Basics Properties

In this section, we provide a framework allowing to comparethe provenance semantics presented in the previous section.It is clear that they all fulfill the following definition.

Definition 3 (Provenance semantics). A provenance seman-tics is a partial function that assigns to a Datalog programΣ, annotated database (D,K, λ) and fact α, an elementP(Σ, D,K, λ, α) in K such that:

1. Σ, D 6|= α implies P(Σ, D,K, λ, α) = 0K.

2. If K is positive, P(Σ, D,K, λ, α) = 0K implies Σ, D 6|= α.

We call the semiring domain of P the maximal set S of semir-ings such that P(Σ, D,K, λ, α) is defined for every K ∈ S,and every Σ, (D,K, λ) and α.

Intuitively, Definition 3 means that the semantics reflectsfact (non)-entailment. It is extremely permissive: We coulddefine such a semantics that associates to each entailed facta random semiring element different from zero, and doesnot bring any information beyond facts entailment. In thesequel, we state and discuss a number of properties that maybe expected to be satisfied by a provenance semantics.

Throughout this section, when not stated otherwise, P , Σ,D, K, λ and α denote respectively an arbitrary provenancesemantics, Datalog program, database, commutative semir-ing (K,+,×, 0, 1), function from D to K \ {0}, and fact.We phrase properties as conditions, and say that P satisfiesa property if it satisfies the condition. We also denote byλX an injective function λX : D 7→ X .

4.1 Compatibility with Classical Notions

Property 1 is a sanity check: if a Datalog pro-gram amounts to a UCQ, the provenance should bethe same as the one defined for relational databases(Green, Karvounarakis, and Tannen 2007). A Datalog pro-gramΣ is UCQ-defined if its rules are of the form φ(~x, ~y) →H(~x) whereH is a predicate that does not occur in the bodyof any rule. In this case, the equivalent UCQ QΣ of Σ is⋃

φ(~x,~y)→H(~x)∈Σ ∃~yφ(~x, ~y).

Property 1 (Algebra Consistency). If Σ is UCQ-definedwith rule head H(~x) and H /∈ S(D), then for every tuple~a of same arity as ~x, the relational provenance of QΣ(~a) isequal to P(Σ, D,K, λ,H(~a)).

While Property 1 considers the behavior of a prove-nance semantics on a restricted class of queries, wecan alternatively consider its behavior on a specificsemiring. Boolean provenance has a very natural def-inition, based on the database subsets that entail thequery, and is widely used, notably for probabilisticdatabases (Senellart 2017), but also for ontology-mediated

query explanation (e.g., in Datalog+/− or description log-ics (Ceylan et al. 2019; Ceylan et al. 2020)). It is formalizedwith the semiring PosBool (X).

Property 2 (Boolean Compatibility).

P(Σ, D,PosBool (X), λX , α) =∨

D′⊆DΣ,D′|=α

β∈D′

λX(β)

Property 2 expresses ‘insensibility’ to syntax, that is, ev-ery provenance semantics that satisfies Property 2 agreeson equivalent programs (i.e., those that have the same mod-els) for the semiring PosBool (X). This is related to ideasfrom (Green 2009) on the provenance of equivalent UCQs.

4.2 Compatibility with Specialization

Semiring provenance has been introduced to abstract fromthe particular semiring at hand, and factor the computationsin some provenance semiring which specializes correctly toany semiring of interest. The next property allows one to doso (Appendix B.1), and is thus highly desirable.

Property 3 (Commutation with Homomorphisms). If thereis a semiring homomorphism h from K1 to K2, thenh(P(Σ, D,K1, λ, α)) = P(Σ, D,K2, h ◦ λ, α).

We call Property 3 restricted to ω-continuous homomor-phisms Commutation with ω-Continuous Homomorphisms.

Specializing correctly is all the more useful when P iswell-defined for a lot of semirings, in particular on all com-mutative or at least all commutative ω-continuous semirings.

Property 4 (Any (ω-Continuous) Semiring). P satisfies theAny Semiring Property (resp. Any ω-Continuous SemiringProperty) if the semiring domain of P contains the set of allcommutative (resp. commutative ω-continuous) semirings.

4.3 Joint and Alternative Use of the Data

How is the actual usage of the data reflected in the prove-nance semantics? The next property formalizes that multipli-cation reflects joint use of the data, and addition alternativeuse. For the rest of this section, we set goal to be a nullarypredicate not in S(Σ) ∪ S(D).

Property 5 (Joint and Alternative Use). For all tuples offacts (α1

1, · · · , α1n1), . . . , (αm

1 , · · · , αmnm

), it holds that

P(Σ′, D,K, λ, goal) = Σmi=1Π

ni

j=1P(Σ, D,K, λ, αij)

where Σ′ = Σ ∪ {∧ni

j=1 αij → goal | 1 ≤ i ≤ m}.

We weaken the above by referring to each mode sepa-rately:

Property 6 (Joint Use). For all facts α1, · · · , αn,

P(Σ′, D,K, λ, goal) = Πnj=1P(Σ, D,K, λ, αj)

where Σ′ = Σ ∪ {∧n

j=1 αj → goal}.

Property 7 (Alternative Use). For all facts α1, · · · , αm,

P(Σ′, D,K, λ, goal) = Σmi=1P(Σ, D,K, λ, αi)

where Σ′ = Σ ∪ {αi → goal | 1 ≤ i ≤ m}.

4.4 Fact Roles in Entailment.

After considering how facts can be combined or used al-ternatively to entail a result, we ponder their possible rolesw.r.t. the entailment. Property 8 asserts that the original an-notation of a fact takes part in the provenance of its entail-ment.

Property 8 (Self). If α ∈ D, then λ(α) ⊑ P(Σ, D,K, λ, α).

Moreover, if a database fact cannot be alternatively de-rived using the rules, then its provenance should be ex-actly its original annotation. To phrase this property weuse the grounding ΣD of Σ w.r.t. D, defined by ΣD ={h(φ(~x, ~y)) → h(H(~x)) | φ(~x, ~y) → H(~x) ∈ Σ, h :~x ∪ ~y 7→ D(D)}. It holds that Σ, D |= α if and only ifΣD, D |= α.

Property 9 (Parsimony). If α ∈ D does not occur in anyrule head in ΣD then P(Σ, D,K, λ, α) = λ(α).

Parsimony Property together with other constraints guar-antee Algebra Consistency Property.

Proposition 13. If P satisfies Properties 5 (Joint and Alter-native Use) and 9 (Parsimony), and is such that for everyΣ, D,K, λ, α, P(Σ, D,K, λ, α) = P(ΣD, D,K, λ, α), thenit satisfies Property 1 (Algebra Consistency).

Property 10 states that P reflects the necessity of a fact forthe entailment. We say that β ∈ D is necessary to Σ, D |= αif Σ, D \ {β} 6|= α, and denote by Nec the set of such facts.

Property 10 (Necessary Facts). There exists e ∈ K suchthat P(Σ, D,K, λ, α) = Πβ∈Necλ(β)× e.

A fact is usable to Σ, D |= α if it occurs in some deriva-tion tree in TΣ

D(α). Usable facts are related to the notionof lineage (Cui, Widom, and Wiener 2000) and can be de-fined without resorting to derivation trees (cf. Appendix B.3).Intuitively, if a fact is not usable to derive another fact, itshould not have any influence on its provenance.

Property 11 (Non-Usable Facts). For every λ′ that differsfrom λ only on facts that are not usable to Σ, D |= α, itholds that P(Σ, D,K, λ, α) = P(Σ, D,K, λ′, α).

4.5 Data Modification

The last two properties indicate how provenance is impactedwhen facts are inserted or deleted.

Property 12 (Insertion). For every (D′,K, λ′) such thatD∩D′ = ∅,P(Σ, D,K, λ, α) + P(Σ, D′,K, λ′, α)

⊑ P(Σ, D ∪D′,K, λ ∪ λ′, α).

Maintaining provenance upon fact deletion is very usefulin practice. We formalize this using a provenance semiring,which allows us to keep track of the facts. A partial evalu-ation of a provenance expression p(X) over variables X isan expression obtained from p(X) by replacing some of thevariables by a given value.

Property 13 (Deletion). For every provenance semiringProv (X) and D′ ⊆ D, if λ′ is the restriction of λX toD′ and ∆ = D \ D′, then P(Σ, D′,Prov(X), λ′, α) isequal to the partial evaluation of P(Σ, D,Prov(X), λX , α)obtained by setting the annotations of facts in ∆ to 0:P(Σ, D,Prov(X), λX , α)[{λX(x) = 0}x∈∆].

5 Semantics Analysis w.r.t. Properties

In this section, we analyze the semantics proposed in Sec-tion 3 w.r.t. the properties introduced in Section 4. The prop-erties each semantics satisfies are summarized in Table 1.Proofs of the positive cases are given in Appendices C and Dand we discuss the negative cases, which may be more char-acteristic, in the sequel.

5.1 Tree- and Execution-Based Semantics Cases

We first discuss PMDT and PHMDT, which have not been muchinvestigated and stand out compared to PAT and PNRT. Thenext example shows that they do not satisfy the Boolean

PAT PNRT PMDT PHMDT PAM PSAM

Algebra Consistency X X X X

Boolean Compat. X X X X

Com. with Hom. X X X

Com. with ω-Cont. X X X X

Any Semiring X X X

Any ω-Cont. Sem. X X X X X

Joint and Alt. Use X X

Joint Use X X X X

Alternative Use X X

Self X X X X X X

Parsimony X X X X X X

Necessary Facts X X X X X

Non-Usable Facts X X X X X X

Insertion X X

Deletion X X X X

Table 1: Does a property hold for a provenance semantics?

Compatibility, Joint and Alternative Use, Alternative Use,Insertion and Deletion Properties.

Example 9. Consider Σ and (D,Prov (X), λX) as follows.

Σ ={A(x) → goal, B(x) → goal, C(x) → B(x)}

D ={A(a), C(a)} with λX(A(a)) = a, λX(C(a)) = c

It holds that both PMDT(Σ, D,Prov (X), λX , goal) andPHMDT(Σ, D,Prov (X), λX , goal) are equal to a. For P ∈{PMDT,PHMDT} we then have the following:(i) The Boolean provenance of goal is a ∨ c, hence P doesnot satisfy the Boolean Compatibility Property.(ii) Since P(∅, D,Prov(X), λX , A(a)) = a andP(∅, D,Prov(X), λX , C(a)) = c, P does not satisfythe Alternative Use, nor the Joint and Alternative UseProperty.(iii) Let D′ = {goal} and λ′(goal) = g. Itholds that P(Σ, D ∪ D′,Prov (X), λX ∪ λ′X , goal) =g, which is different from P(Σ, D,Prov(X), λX , goal) +P(Σ, D′,Prov (X), λ′X , goal) + e for every e ∈ Prov(X).Hence P does not satisfy the Insertion Property.(iv) LetD′ = D\{A(a)} = {C(a)}. The partial evaluationof P(Σ, D,Prov(X), λX , goal) where a is set to 0 is equalto 0 while P(Σ, D′,Prov(X), λX , goal) = c. HenceP doesnot satisfy the Deletion Property.

We now illustrate the difference between PHMDT and PMDT:PHMDT satisfies the Joint Use Property while PMDT does not.

Example 10. Let Σ = {C(x) → B(x), D(x) → A(x)},D = {B(a), C(a), D(a)} and λ(B(a)) = b, λ(C(a)) = c,λ(D(a)) = d, and consider Σ′ = Σ ∪ {A(a) ∧ B(a) →goal}. PMDT(Σ′, D,K, λ, goal) = b × d + c × d whilePMDT(Σ, D,K, λ, A(a)) = d and PMDT(Σ, D,K, λ, B(a)) =b. Hence PMDT does not satisfy the Joint Use Property.

We conclude this discussion with the remark that PAT

satisfies the Commutation with ω-Continuous Homomor-phisms but not the Commutation with HomomorphismsProperty.

Example 11. Consider the semiring N∞ with the classical

operations, and define N∞,∞′

as its extension by an element∞′ such that for every n ∈ N ∪ {∞}, n + ∞′ = ∞′,and n × ∞′ = ∞′ if n 6= 0, and 0 otherwise. Both

semirings are ω-continuous and h : N∞ 7→ N

∞,∞′

de-fined by h(n) = n for every n ∈ N, h(∞) = ∞′

is a semiring homomorphism (which is not ω-continuous).Assume that PAT(Σ, D,N∞, λ, goal) = Σi∈N1 = ∞.Then h(PAT(Σ, D,N∞, λ, goal)) = ∞′ is different from

PAT(Σ, D,N∞,∞′

, h ◦ λ, goal) = Σi∈Nh(1) = ∞.

5.2 Model-Based Semantics Cases

On + -idempotent semirings, PAM and PSAM coincide withPAT so verify the same properties, and the semiring BJXKof formal power series with Boolean coefficients can be usedto compute them in any + -idempotent semiring (AppendixE.1). However, on non-idempotent semirings, they do notsatisfy several properties, and in particular the Commutationwith (ω-Continuous) Homomorphisms Properties.

Example 12. Let Σ = {A(x) → goal, B(x) → goal} andD = {A(a), B(a)} and consider the provenance semiringN

∞JXK with λX(A(a)) = x and λX(B(a)) = y.

It holds that both PAM(Σ, D,N∞JXK, λX , goal) andPSAM(Σ, D,N∞JXK, λX , goal) are equal to x+ y.

Consider now the semiring N∞, λN(A(a)) = 2 and

λN(B(a)) = 2. Both PAM(Σ, D,N∞, λN, goal) andPSAM(Σ, D,N∞, λN, goal) are equal to 2.

For P ∈ {PAM,PSAM} we then have the following:

(i) Let h be a ω-continuous homomorphism from N∞JXK to

N∞ such that h(x) = 2 and h(y) = 2. Since h(x + y) =

h(x) + h(y) = 4, P does not satisfy the Commutation withω-Continuous Homomorphisms Property.

(ii) The relational provenance of QΣ() w.r.t. N∞ and λN is

4 so P does not satisfy the Algebra Consistency Property.

(iii) P(∅, D,N∞, λN, A(a)) +P(∅, D,N∞, λN, B(a)) = 4so P does not satisfy the Alternative Use nor the Joint andAlternative Use Property.

(iv) Since P(Σ, {A(a)},N∞, λN, goal) +P(Σ, {B(a)},N∞, λN, goal) = 4 is strictly greaterthan P(Σ, D,N∞, λN, goal), P does not satisfy theInsertion Property.

Moreover, PSAM does not satisfy the Joint Use Property.

Example 13. Let

Σ = {A(x) → g1, A(x) → g2, B(x) → g1, B(x) → g2}

D = {A(a), B(a)} with λX(A(a)) = x, λX(B(a)) = y.

Both PSAM(Σ, D,N∞JXK, λX , g1) andPSAM(Σ, D,N∞JXK, λX , g2) are equal to x + y butPSAM(Σ ∪ {g1 ∧ g2 → goal}, D,N∞JXK, λX , goal) =x2 + y2 + xy 6= (x+ y)2.

We show that PAM does not satisfy the Necessary FactsProperty in Appendix D.1 because we needed to craft a spe-cific semiring to get a counter-example.

6 Complexity Considerations and

Conclusion

In this paper, we present alternative provenance semanticsfor Datalog based on models, execution algorithms andderivation trees, and compare them through the lens of dif-ferent properties. PNRT is the only one that satisfies all thestudied properties but does not coincide with an executionbased semantics contrary to the other tree-based semanticsPAT, PMDT, and PHMDT. The equivalence between the tree-based PAT, PNRT and model-basedPAM and PSAM definitionson absorptive semirings may also indicates a robust prove-nance on this restricted setting.

One of the main complexity sources of Datalog prove-nance stems from its infinite representation. Deutch et al.(2014) studied semirings for which the provenance expres-sions given by PAT are finite, and showed that they canbe represented by polynomial size circuits. We show (Ap-pendix F) that the annotations produced at each iteration ofour execution algorithms can be represented by arithmeticcircuits of polynomial size in the data. Consequently, bothPMDT and PHMDT can be represented by polynomial size cir-cuits regardless of the semiring. On the contrary, we showthat (assuming P 6= NP) there is no polynomially com-putable circuit that computes PNRT on N

∞JXK, by a re-duction from a result by Arenas, Conca, and Perez (2012).Whether it is possible to polynomially compute circuits forPNRT on provenance semirings less expressive than N

∞JXKbut non-absorptive remains open.

Acknowledgements

This work is supported by the ANR project CQFD (ANR-18-CE23-0003).

References

Abiteboul, S.; Hull, R.; and Vianu, V. 1995. Foundations ofDatabases. Addison-Wesley.

Achs, A., and Kiss, A. 1995. Fuzzy extension of datalog.Acta Cybern. 12(2):153–166.

Arenas, M.; Conca, S.; and Perez, J. 2012. Counting beyonda yottabyte, or how SPARQL 1.1 property paths will preventadoption of the standard. In Mille, A.; Gandon, F.; Misselis,J.; Rabinovich, M.; and Staab, S., eds., Proceedings of the21st World Wide Web Conference 2012, WWW 2012, Lyon,France, April 16-20, 2012, 629–638. ACM.

Bourgaux, C.; Ozaki, A.; Penaloza, R.; and Predoiu, L.2020. Provenance for the description logic elhr. In Bessiere,C., ed., Proceedings of the Twenty-Ninth International JointConference on Artificial Intelligence, IJCAI 2020, 1862–1869. ijcai.org.

Calvanese, D.; Lanti, D.; Ozaki, A.; Penaloza, R.; and Xiao,G. 2019. Enriching ontology-based data access with prove-nance. In Kraus, S., ed., Proceedings of the Twenty-EighthInternational Joint Conference on Artificial Intelligence, IJ-CAI 2019, Macao, China, August 10-16, 2019, 1616–1623.ijcai.org.

Ceylan, I. I.; Lukasiewicz, T.; Malizia, E.; and Vaicenavi-cius, A. 2019. Explanations for query answers under exis-tential rules. In Kraus, S., ed., Proceedings of the Twenty-Eighth International Joint Conference on Artificial Intelli-gence, IJCAI 2019, Macao, China, August 10-16, 2019,1639–1646. ijcai.org.

Ceylan, I. I.; Lukasiewicz, T.; Malizia, E.; and Vaicenavi-cius, A. 2020. Explanations for ontology-mediated queryanswering in description logics. In Giacomo, G. D.; Catala,A.; Dilkina, B.; Milano, M.; Barro, S.; Bugarın, A.; andLang, J., eds., ECAI 2020 - 24th European Conference on Ar-tificial Intelligence, 29 August-8 September 2020, Santiagode Compostela, Spain, volume 325 of Frontiers in ArtificialIntelligence and Applications, 672–679. IOS Press.

Cheney, J.; Chiticariu, L.; and Tan, W. C. 2009. Prove-nance in databases: Why, how, and where. Found. TrendsDatabases 1(4):379–474.

Cui, Y.; Widom, J.; and Wiener, J. L. 2000. Tracing thelineage of view data in a warehousing environment. ACMTrans. Database Syst. 25(2):179–227.

Dannert, K. M.; Gradel, E.; Naaf, M.; and Tannen, V. 2021.Semiring provenance for fixed-point logic. In Baier, C.,and Goubault-Larrecq, J., eds., 29th EACSL Annual Confer-ence on Computer Science Logic, CSL 2021, January 25-28,2021, Ljubljana, Slovenia (Virtual Conference), volume 183of LIPIcs, 17:1–17:22. Schloss Dagstuhl - Leibniz-Zentrumfur Informatik.

Deutch, D.; Milo, T.; Roy, S.; and Tannen, V. 2014. Circuitsfor datalog provenance. In Schweikardt, N.; Christophides,V.; and Leroy, V., eds., Proc. 17th International Conferenceon Database Theory (ICDT), Athens, Greece, March 24-28,2014, 201–212. OpenProceedings.org.

Deutch, D.; Gilad, A.; and Moskovitch, Y. 2018. Efficientprovenance tracking for datalog using top-k queries. VLDBJ. 27(2):245–269.

Esparza, J., and Luttenberger, M. 2011. Solving fixed-pointequations by derivation tree analysis. In Corradini, A.; Klin,B.; and Cırstea, C., eds., Algebra and Coalgebra in Com-puter Science, 19–35. Berlin, Heidelberg: Springer BerlinHeidelberg.

Green, T. J., and Tannen, V. 2017. The semiring frameworkfor database provenance. In Sallinger, E.; den Bussche, J. V.;and Geerts, F., eds., Proceedings of the 36th ACM SIGMOD-SIGACT-SIGAI Symposium on Principles of Database Sys-tems, PODS 2017, Chicago, IL, USA, May 14-19, 2017, 93–99. ACM.

Green, T. J.; Karvounarakis, G.; and Tannen, V. 2007. Prove-nance semirings. In Libkin, L., ed., Proceedings of theTwenty-Sixth ACM SIGACT-SIGMOD-SIGART Symposiumon Principles of Database Systems, June 11-13, 2007, Bei-jing, China, 31–40. ACM.

Green, T. J. 2009. Containment of conjunctive queries on an-notated relations. In Fagin, R., ed., Database Theory - ICDT2009, 12th International Conference, St. Petersburg, Russia,March 23-25, 2009, Proceedings, volume 361 of ACM Inter-national Conference Proceeding Series, 296–309. ACM.

Hernich, A., and Kolaitis, P. G. 2017. Foundations of in-formation integration under bag semantics. In 32nd AnnualACM/IEEE Symposium on Logic in Computer Science, LICS2017, Reykjavik, Iceland, June 20-23, 2017, 1–12. IEEEComputer Society.

Mumick, I. S.; Pirahesh, H.; and Ramakrishnan, R. 1990.The magic of duplicates and aggregates. In McLeod, D.;Sacks-Davis, R.; and Schek, H., eds., 16th InternationalConference on Very Large Data Bases, August 13-16, 1990,Brisbane, Queensland, Australia, Proceedings, 264–277.Morgan Kaufmann.

Nikolaou, C.; Kostylev, E. V.; Konstantinidis, G.; Kaminski,M.; Grau, B. C.; and Horrocks, I. 2017. The bag seman-tics of ontology-based data access. In Sierra, C., ed., Pro-ceedings of the Twenty-Sixth International Joint Conferenceon Artificial Intelligence, IJCAI 2017, Melbourne, Australia,August 19-25, 2017, 1224–1230. ijcai.org.

Nikolaou, C.; Kostylev, E. V.; Konstantinidis, G.; Kaminski,M.; Grau, B. C.; and Horrocks, I. 2019. Foundations ofontology-based data access under bag semantics. Artif. Intell.274:91–132.

Senellart, P. 2017. Provenance and probabilities in relationaldatabases. SIGMOD Rec. 46(4):5–15.

Souffle. 2020. https://souffle-lang.github.io/index.html.

Stuber, T., and Vogler, H. 2008. Weighted monadic datalog.Theoretical Computer Science 403(2):221–238.

Zhao, D.; Subotic, P.; and Scholz, B. 2020. Debugginglarge-scale datalog: A scalable provenance evaluation strat-egy. ACM Trans. Program. Lang. Syst. 42(2):7:1–7:35.

Appendices

A Discussion and Proofs for Section 3 12A.1 Relationships between Provenance Semantics and Different Bag Semantics . . . . . . . . . . . . . . . . . . . 12A.2 Model-Based Semantics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15A.3 Execution- and Tree-Based Semantics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18A.4 Non-Recursive Tree-Based Semantics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

B Discussion and Proofs for Section 4 20B.1 Commutation with Homomorphisms and Universal Semirings . . . . . . . . . . . . . . . . . . . . . . . . . . 20B.2 Proof of Proposition 13 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20B.3 Usable Facts Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

C Proofs of Table 1 Results, PAT, PNRT, PMDT and PHMDT Cases 21C.1 Algebra Consistency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21C.2 Boolean Compatibility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22C.3 Commutation with Homomorphisms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22C.4 Commutation with ω-Continuous Homomorphisms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22C.5 Joint and Alternative Use . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22C.6 Joint Use . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23C.7 Alternative Use . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24C.8 Self . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24C.9 Parsimony . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24C.10 Necessary Facts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24C.11 Non-Usable Facts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24C.12 Insertion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25C.13 Deletion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

D Proofs of Table 1 Results, PAM and PSAM Cases 25D.1 PAM Case . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26D.2 PSAM Case . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30

E Other Proofs for Section 5 31E.1 PAM and PSAM on BJXK . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31

F Provenance Computation 32F.1 PMDT and PHMDT Cases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32F.2 PNRT Case . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33

A Discussion and Proofs for Section 3

A.1 Relationships between Provenance Semantics and Different Bag Semantics

Connection between Incognizant and Cognizant Bag Semantics and Provenance Semantics To compare the bag se-mantics defined by Hernich and Kolaitis (2017) in the context of information integration and a provenance semantics P withcounting semiring N, we consider the case where Σ is a set of Datalog rules (in normalized form with a single atom in thehead) which are also s-t tgds, i.e., such that the predicates used in the rule heads and bodies are disjoint. For a provenancesemantics P , we want to know whether for every such Σ, D over the source schema (i.e., predicates that occur in the Data-log rule bodies), λN : D 7→ N \ {0} and BCQ q over the target schema (i.e., predicates that occur in Datalog rule heads),P(Σ ∪ {q → goal}, D,N, λN, goal) is equal to the multiplicity of the empty tuple in the the incognizant or cognizant certainanswers of q w.r.t. Σ and D. Note that in this context, all derivation trees of goal w.r.t. D and Σ are non-recursive and of depth2. Hence, all derivation tree-based (and execution-based) semantics coincide. We show below that they are in line with thecognizant bag semantics. We have shown in Section 3.1 that this is not the case for the incognizant semantics, i.e., only thecognizant bag semantics for information integration agrees with the traditional bag semantics for Datalog.

Proposition 14. For P ∈ {PAT,PNRT,PHMDT,PMDT,PNE,PSNE,POE}, Σ, D, λN, and q as required, P(Σ ∪ {q →goal}, D,N, λN, goal) is equal to the multiplicity of the empty tuple in the cognizant certain answers of q w.r.t. Σ and D.

Proof. We first show that for every fact α = p(~a) over the target schema such that Σ, D |= α, P(Σ, D,N, λN, α) is equal tothe multiplicity nα of the empty tuple in the cognizant certain answers of the Boolean query α w.r.t. Σ and D.

• The set of derivation trees for α correspond precisely to the set of pairs (r, h) such that r ∈ Σ is of the form φ(~x, ~y) → p(~x)and h is an homomorphism from φ(~x, ~y) to D such that h(~x) = ~a. Hence P(Σ, D,N, λN, α) is equal to the sum over all s-ttgd r := φ(~x, ~y) → p(~x) in Σ of the multiplicity of ~a in the answer to φ(~x, ~y) on D.

• Let J be a cognizant solution forD w.r.t. Σ. The multiplicity of α in J is at least the sum over the rules r := φ(~x, ~y) → p(~x)in Σ of the multiplicities of ~a in the answers of φ(~x, ~y) on D. Hence the multiplicity of α in J is greater or equal toP(Σ, D,N, λN, α). Since this is true for every cognizant solution J , it follows that P(Σ, D,N, λN, α) ≤ nα.

• If J is a cognizant solution for D w.r.t. Σ, then J ′ obtained from J by setting the multiplicity of α to P(Σ, D,N, λN, α)

is also a cognizant solution. Indeed, for each r := φ(~x, ~y) → p(~x) in Σ, Jr = {(p(~b), nr,~b) | h : φ(~x, ~y) 7→ D,h(~x) =

~b, nr,~b multiplicity of~b in answers to φ(~x, ~y) on D} satisfies r, and∑

r:=φ(~x,~y)→p(~x)∈Σ nr,~a = P(Σ, D,N, λN, α). It fol-

lows that P(Σ, D,N, λN, α) ≥ nα.

Hence, the multiplicity nα of the empty tuple in the cognizant certain answers of the Boolean query α w.r.t. Σ and D is equalto P(Σ, D,N, λN, α). We now show that P(Σ ∪ {q → goal}, D,N, λN, goal) is equal to the multiplicity nq of the empty tuplein the cognizant certain answers of q w.r.t. Σ and D. Let q = ∃~x

∧ni=1 pi(~x).

• Let J = {α | Σ, D |= α}. For each homomorphism h :∧n

i=1 pi(~x) 7→ J , the derivation trees for goal with root labeled by(goal, q → goal, h) have children h(p1(~x)) = α1, . . . , h(pn(~x)) = αn ∈ J and correspond to the choice of t1, . . . , tn whereeach ti is a derivation tree for αi. Hence,

P(Σ ∪ {q → goal}, D,N, λN, goal) =∑

h:∧

ni=1 pi(~x) 7→J

(t1,...,tn)∈TΣD(α1)×···×TΣ

D(αn)

Λ(ti)

=∑

h:∧

ni=1 pi(~x) 7→J

n∏

i=1

P(Σ, D,N, λN, αi).

• Let J be a cognizant solution for D w.r.t. Σ. The multiplicity of the empty tuple in the answers of q over J is the sum overthe homomorphisms h : q 7→ J of the product of the multiplicities of αi = h(pi(~x)) in J . Moreover, every such αi is suchthat Σ, D |= αi so its multiplicity in J is at least P(Σ, D,N, λN, αi). Since this holds for any cognizant solution J , it followsthat nq ≥ P(Σ ∪ {q → goal}, D,N, λN, goal).

• A cognizant solution J for D w.r.t. Σ can be obtained by setting the multiplicity of each fact on the target schema α toP(Σ, D,N, λN, α). It follows that nq ≤

h:∧

ni=1 pi(~x) 7→J

∏ni=1 P(Σ, D,N, λN, αi) = P(Σ ∪ {q → goal}, D,N, λN, goal).

Hence the multiplicity nq of the empty tuple in the cognizant certain answers of q w.r.t. Σ and D is equal to P(Σ ∪ {q →goal}, D,N, λN, goal).

We show below that the incognizant semantics coincides with PAM with the counting semiring. The examples we gave inSection 3.1 to show that PAM and PSAM differ show that this is not the case of PSAM.

Proposition 15. For every Σ, D, λN, and q as required, PAM(Σ ∪ {q → goal}, D,N, λN, goal) is equal to the multiplicity ofthe empty tuple in the incognizant certain answers of q w.r.t. Σ and D.

Proof. We first show that for every fact α = p(~a) over the target schema such that Σ, D |= α, PAM(Σ, D,N, λN, α) is equal tothe multiplicity nα of the empty tuple in the incognizant certain answers of the Boolean query α w.r.t. Σ and D.

• We show that PAM(Σ, D,N, λN, α) is equal to the maximum over all s-t tgd φ(~x, ~y) → p(~x) in Σ of the multiplic-ity of ~a in the answer to φ(~x, ~y) on D. Let φ(~x, ~y) → p(~x) in Σ. For every model (I, µI) of (Σ, D,N, λN),Σh′:φ(~x,~y) 7→I,h′(~x)=~aΠβ∈h′(φ(~x,~y))µ

I(β) ≤ µI(α) and for every β ∈ h′(φ(~x, ~y)), β ∈ D because φ(~x, ~y) → p(~x) is a

s-t tgd, so µI(β) ≥ λN(β). Hence µI(α) is greater or equal to the multiplicity of ~a in the answer to φ(~x, ~y) on D. Moreover,the interpretation that annotates each β ∈ D by λN(β) and each γ produced by applying some s-t tgd by such maximalmultiplicity is a model of (Σ, D,N, λN).

• We now show that nα is precisely the maximum over all s-t tgd φ(~x, ~y) → p(~x) in Σ of the multiplicity of ~a in the answer toφ(~x, ~y) on D. Every incognizant solution J for D w.r.t. Σ is such that the multiplicity of α is at least the multiplicity of ~a inthe answer of φ(~x, ~y) on D for every φ(~x, ~y) → p(~x) in Σ. Moreover, if J is a incognizant solution for D w.r.t. Σ, then J ′

obtained from J by setting the multiplicity of α to this maximal multiplicity is also a incognizant solution, as it still satisfiesall s-t tgds.

Hence, nα = PAM(Σ, D,N, λN, α).

PAM(Σ ∪ {q → goal}, D,N, λN, goal) is the minimal µI(goal) over the models (I, µI) of Σ ∪ {q → goal} and(D,N, λN). Since such models are models of Σ and (D,N, λN), PAM(Σ ∪ {q → goal}, D,N, λN, goal) is equal to the sum of∏

αi∈h(q) PAM(Σ, D,N, λN, αi) where h ranges over the homomorphisms from q to the set J of facts entailed by Σ and D.

The multiplicity of the empty tuple in the incognizant certain answers of q w.r.t. Σ andD is the minimum over the incognizantsolutions of the multiplicity of the empty tuple in the answers of q. Given a incognizant solution J , the multiplicity of theempty tuple in the answers of q over J is the sum over the homomorphisms h : q 7→ J of the product of the multiplicities ofαi = h(pi(~x)). Moreover, such αi are such that Σ, D |= αi so their minimal multiplicities in some incognizant solution arenαi

= PAM(Σ, D,N, λN, αi).It follows that the multiplicity of the empty tuple in the incognizant certain answers of the BCQ α w.r.t. Σ and D is equal to

PAM(Σ ∪ {q → goal}, D,N, λN, goal).

Connection between Description Logics Bag Semantics and Provenance Semantics Nikolaou et al. (2017) defined a bagsemantics for the description logic DL-Lite then extended it to the full ontology-based data access setting (2019). We fo-cus on the DL-Lite case with unique name assumption considered in (Nikolaou et al. 2017) for simplicity, but mapping rulescompatible with our setting could be added.

A bag ABox corresponds to a database annotated with integers (D,N∞, λN). A bag interpretation I = 〈∆I , ·I〉 can also beseen as a (possibly infinite) set of facts annotated with elements from N

∞. The interpretation function extends to concepts androles as follows: (P−)I(u, v) = P I(v, u) and (∃R)I(u) =

v∈∆I RI(u, v). I is a model of a bag ABox if the multiplicityof every fact in I is at least its multiplicity in the ABox; it is a model of a TBox if it satisfies all its concept and role inclusionswhere C ⊑ D is satisfied iff CI(~x) ≤ DI(~x) for every ~x.

The bag answers of a CQ q = ∃~yφ(~x, ~y) over a bag interpretation I are defined by qI(~a) =∑

ν∈V

S(~t)∈φ(~x,~y) SI(ν(~t))

where V is the set of all valuations ν : ~x ∪ ~y 7→ ∆I such that ν(~x) = ~aI and ν(a) = aI for every constant a. Finally thebag certain answers to q is the bag-intersection of qI over all models I of the ABox and TBox, i.e., the multiplicity of a certainanswer is the minimum of its multiplicities over the models.

To compare the bag semantics defined by Nikolaou et al. (2017) for DL-Lite and a provenance P with the extended countingsemiring N

∞, we consider the case where Σ is a set of Datalog rules which are formulated in DL-Lite, i.e., use only unary andbinary predicates and contains a single atom in body and head.

We show below that the DL-Lite bag semantics coincides with PAM with the (extended) counting semiring. The exampleswe gave in Section 3.1 to show that PAM and PSAM differ can be easily adapted to show that PSAM does not coincide with theDL-Lite bag semantics (just replace goal by H(x) in Σ and consider BCQ q = ∃xH(x)), and the example we gave in Section3.1 to show that the cognizant and incognizant semantics differ shows that the execution/derivation-tree based semantics do notcoincide with the DL-Lite bag semantics either.

Proposition 16. For every set Σ of Datalog rules which are formulated in DL-Lite, D, λN, and BCQ q, PAM(Σ ∪ {q →goal}, D,N∞, λN, goal) is equal to the multiplicity of the empty tuple in the bag certain answers to q over (Σ, D,N∞, λN).

Proof. Let n be the multiplicity of the empty tuple in the bag certain answers to q over (Σ, D,N∞, λN).Let I = 〈∆I , ·I〉 be a model of Σ and (D,N∞, λN) seen as a DL-Lite TBox and bag ABox. Assume w.l.o.g. that D(D) ⊆ ∆

and that for every a ∈ D(D), aI = a. Let (I, µI) be the annotated interpretation defined by I = {S(~a) | SI(~a) >0} ∪ {goal} and µI(S(~a)) = SI(~a) for every S(~a) ∈ I , µI(goal) = qI(). We show that (I, µI) is an annotated model of Σand (D,N∞, λN).

• Since I is a model of (D,N∞, λN), then for every S(~a) ∈ D, SI(~aI) ≥ λN(S(~a)). Hence I fulfills point (1) of the definitionof annotated models.

• Let r := φ(~x, ~y) → H(~x) be in Σ and h : φ(~x, ~y) 7→ I . We are in one of the following cases.

– r = A(x) → B(x), h(x) = a, A(a) ∈ I: since I satisfies A ⊑ B, AI(a) ≤ BI(a), so B(a) ∈ I and µI(A(a)) ≤µI(B(a)).

– r = R(x, y) → S(x, y), h(x) = a, h(y) = b, R(a, b) ∈ I: since I satisfies R ⊑ S, RI(a, b) ≤ SI(a, b), so S(a, b) ∈ Iand µI(R(a, b)) ≤ µI(S(a, b)).

– r = R(x, y) → S(y, x), h(x) = a, h(y) = b, R(a, b) ∈ I: since I satisfies R ⊑ S−, RI(a, b) ≤ (S−)I(a, b) = SI(b, a),so S(b, a) ∈ I and µI(R(a, b)) ≤ µI(S(b, a)).

– r = R(x, y) → B(x), h(x) = a, h(y) = b, R(a, b) ∈ I: since I satisfies ∃R ⊑ B, (∃R)I(a) ≤ BI(a) with(∃R)I(a) =

v∈∆I RI(a, v), so B(a) ∈ I and∑

R(a,v)∈I µI(R(a, v)) ≤ µI(B(a)).

– r = R(y, x) → B(x), h(x) = a, h(y) = b, R(b, a) ∈ I: since I satisfies ∃R− ⊑ B, (∃R−)I(a) ≤ BI(a) with(∃R−)I(a) =

v∈∆I RI(v, a), so B(a) ∈ I and∑

R(v,a)∈I µI(R(v, a)) ≤ µI(B(a)).

In all cases, we have shown that h(H(~x)) ∈ I and∑

h′:φ(~x,~y) 7→I,h′(~x)=h(~x)

β∈h′(φ(~x,~y)) µI(β) ⊑ µI(h(H(~x))).

• Finally, consider q → goal and assume that there is a homomorphism h from q to I . Since µI(goal) = qI() =∑

ν∈V

S(~t)∈q SI(ν(~t)) where V is the set of all valuations ν : ~x 7→ ∆I such that ν(a) = aI for every constant a,

µI(goal) ≥∑

h′:q 7→I

S(~t)∈q SI(h′(~t)) =

h′:q 7→I

β∈h′(q) µI(β).

Hence I fulfills point (2) of the definition of annotated models.

By definition of PAM(Σ ∪ {q → goal}, D,N∞, λN, goal), it follows that PAM(Σ ∪ {q → goal}, D,N∞, λN, goal) ≤ µI(goal).Hence PAM(Σ ∪ {q → goal}, D,N∞, λN, goal) ≤ qI(). Since this is true for any model I and n is the minimal qI() over allmodels, it follows that PAM(Σ ∪ {q → goal}, D,N∞, λN, goal) ≤ n.

In the other direction, let (I, µI) be an annotated model of Σ ∪ {q → goal} and (D,N∞, λN). Let I = 〈∆I , ·I〉 be definedby ∆I = D(D) and SI(~x) = µI(S(~x)) if S(~x) ∈ I , SI(~x) = 0 otherwise. We show that I is a model of Σ and (D,N∞, λN)seen as a DL-Lite TBox and bag ABox.

• Since for every α ∈ D, λN(α) ≤ µI(α), the multiplicity of α in I is at least its multiplicity λN(α) in the ABox, so I is amodel of (D,N∞, λN) seen as a bag ABox.

• We show that I satisfies all concept and role inclusions corresponding to rules in Σ.

– For simple concept inclusionA ⊑ B, i.e.,A(x) → B(x), since for every a ∈ ∆I ,AI(a) = µI(A(a)), BI(a) = µI(B(a))and (I, µI) is a model of Σ, AI(a) ≤ BI(a) so I satisfies A ⊑ B.

– The role inclusion cases R ⊑ S and R ⊑ S− are similar to A ⊑ B.

– For the case ∃R ⊑ B, i.e., R(x, y) → B(x), for every a ∈ ∆I , (∃R)I(a) =∑

v∈∆I RI(a, v) =∑

R(a,v)∈I µI(R(a, v))

and since (I, µI) is a model of Σ,∑

R(a,v)∈I µI(R(a, v)) ≤ µI(B(a)) so (∃R)I(a) ≤ BI(a) and I satisfies ∃R ⊑ B.

– The case ∃R− ⊑ B is similar.

qI() =∑

ν∈V

S(~t)∈q SI(ν(~t)) where V is the set of all valuations ν : ~x 7→ ∆I such that ν(a) = aI for every constant

a, so qI() =∑

h:q 7→I

β∈h(q) µI(β). Since (I, µI) is a model of Σ ∪ {q → goal}, it follows that qI() ≤ µI(goal). Hence,

by definition of n, n ≤ qI() ≤ µI(goal). Since this is true for any model (I, µI), it follows that n ≤ PAM(Σ ∪ {q →goal}, D,N∞, λN, goal), so that n = PAM(Σ ∪ {q → goal}, D,N∞, λN, goal).

Proof of Proposition 1 Proposition 1 follows from Propositions 15 and 16. In particular, note that in the DL-Lite case,if the database facts are annotated with elements from N rather than N

∞, then PAM(Σ ∪ {q → goal}, D,N∞, λN, goal) =PAM(Σ ∪ {q → goal}, D,N, λN, goal) since there exist finite models of Σ and D (because Σ contains only Datalog rules) suchthat all facts annotations are in N.

Proposition 1. If the Datalog rules in Σ are (1) s-t tgds, or (2) formulated in DL-LiteR, then for every BCQ q, PAM(Σ ∪ {q →goal}, D,N, λN, goal) is equal to the multiplicity of the empty tuple in (1) the incognizant certain answers or (2) the bag certainanswers to q w.r.t. Σ and (D,N, λN).

A.2 Model-Based Semantics

We start by showing a few lemmas that will be useful to prove results from Section 3.1 as well as later in the proofs of theresults in Table 1.

Lemma 1. The annotated interpretation (I0, µI0) defined by I0 = {α | Σ, D |= α} and µI0(α) = PAT(Σ, D,K, λ, α) for

every α ∈ I0 is a model of Σ and (D,K, λ). It follows that PAM(Σ, D,K, λ, α) ⊑ PAT(Σ, D,K, λ, α).

Proof. It is easy to check point (1) of the definition: D ⊆ I0 and for every α ∈ D, there exists a derivation tree in TΣD(α) that

consists of a single root node labelled α, so λ(α) ⊑ µI0(α).For point (2), let φ(~x, ~y) → H(~x) be a rule in Σ and h be a homomorphism from φ(~x, ~y) to I0. By construction of I0, for

every β ∈ h(φ(~x, ~y)), Σ, D |= β. Hence Σ, D |= h(φ(~x, ~y)) so Σ, D |= h(H(~x)). It follows that h(H(~x)) ∈ I0 by definitionof I0.

Let h(H(~x)) = α, and let S be the set of all homomorphisms h′ : φ(~x, ~y) 7→ I0 such that h′(~x) = h(~x). For each such

h′ ∈ S, let γh′

1 , . . . , γh′

kh′be the set of facts from I0 such that h′(φ(~x, ~y)) = γh

1 ∧ · · · ∧ γh′

kh′.

1. By definition of (I0, µI0), µI0(α) = Σt∈TΣ

D(α)Λ(t).

2. For every h′ ∈ S, and every (t1, . . . , tkh′ ) ∈ TΣD(γh

1 ) × · · · × TΣD(γh

kh′), there is a derivation tree t ∈ TΣ

D(α) whose root is

(α, r, h′) and has subtrees t1, . . . , tkh′ .

3. It follows that Σh′∈SΣ(t1,...,tkh′ )∈TΣ

D(γh′

1 )×···×TΣD(γh′

kh′

)Πkh′

i=1Λ(ti) ⊑ µI0(α).

4. By definition of (I0, µI0), for every h′ ∈ S and 1 ≤ i ≤ kh′ , µI0(γh

i ) = Σt∈TΣD(γh′

i)Λ(t).

5. Hence for every h′ ∈ S, Πβ∈h′(φ(~x,~y))µI0(β) = Π

kh′

i=1Σt∈TΣD(γh′

i)Λ(t) = Σ(t1,...,tk

h′ )∈TΣD(γh′

1 )×···×TΣD(γh′

kh′

)Πkh′

i=1Λ(ti).

It follows from (3) and (5) that Σh′:φ(~x,~y) 7→I0,h′(~x)=h(~x)Πβ∈h′(φ(~x,~y))µI0(β) ⊑ µI0(h(H(~x))). Hence (I0, µ

I0) is a model of

Σ and (D,K, λ).

Lemma 2. The set-annotated interpretation (I0, µI0) defined by I0 = {α | Σ, D |= α} and µI0(α) = {Λ(t) | t ∈ TΣ

D(α)} forevery α ∈ I0 is a model of Σ and (D,K, λ).

Proof. Let I0 = {α | Σ, D |= α} and µI0(α) = {Λ(t) | t ∈ TΣD(α)} for every α ∈ I0. We show that (I0, µ

I0) is a model of Σand (D,K, λ).

It is easy to check point (1) of the definition: D ⊆ I0 and for every α ∈ D, there exists a derivation tree in TΣD(α) that

consists of a single root node labelled α, so λ(α) ∈ µI0(α).For point (2), let φ(~x, ~y) → H(~x) be a rule in Σ and h be a homomorphism from φ(~x, ~y) to I0. By construction of I0,

for every β ∈ h(φ(~x, ~y)), Σ, D |= β. Hence Σ, D |= h(φ(~x, ~y)) so Σ, D |= h(H(~x)). It follows that h(H(~x)) ∈ I0. Leth(H(~x)) = α and h(φ(~x, ~y)) = γ1 ∧ · · · ∧ γk.

1. By definition of (I0, µI0), µI0(α) = {Λ(t) | t ∈ TΣ

D(α)}.

2. For every (t1, . . . , tk) ∈ TΣD(γ1)×· · ·×TΣ

D(γk), there is a derivation tree t ∈ TΣD(α) whose root is (α, r, h′) and has subtrees

t1, . . . , tk.

3. It follows that {Πki=1Λ(ti) | (t1, . . . , tk) ∈ TΣ

D(γ1)× · · · × TΣD(γk)} ⊆ µI0(α).

4. By definition of (I0, µI0), for every 1 ≤ i ≤ k, µI0(γi) = {Λ(t) | t ∈ TΣ

D(γi)}.

It follows from (3) and (4) that {Πki=1mi | (m1, . . . ,mk) ∈ µI0(γ1) × · · · × µI0(γk)} ⊆ µI0(h(H(~x)). Hence (I0, µ

I0) is a

model of Σ and (D,K, λ) and⋂

(I,µI)|=(Σ,D,K,λ) µI(α) = {Λ(t) | t ∈ TΣ

D(α)}.

Lemma 3. For both annotated interpretations and set-annotated interpretations, Σ, D |= α if and only if α ∈ I for everymodel (I, µI) of Σ and (D,K, λ).

Proof. This follows from the facts that

1. every (set-)annotated model (I, µI) of Σ and (D,K, λ) is such that I is a model of Σ and D by definition of annotated andset-annotated models; and

2. for every model I of Σ and D, there exists a (set-)annotated model (I, µI) of Σ and (D,K, λ):

• For PAM such a model can be obtained by setting µI(α) = PAT(Σ, D,K, λ, α) by Lemma 1.

• For PSAM such a model can be obtained by setting µI(α) = {Λ(t) | t ∈ TΣD(α)} by Lemma 2.

Lemma 4. If K = (K,+,×, 0, 1) is a commutative ω-continuous semiring such that for every x, y ∈ K , the greatest lowerbound of x and y is well defined (i.e., there exists a unique element z ∈ K such that z ⊑ x, z ⊑ y and every z′ such that z′ ⊑ xand z′ ⊑ y is such that z′ ⊑ z), then for every a, b ∈ K , a ⊑ b and b ⊑ a implies that a = b. In particular, a ⊑ 0 implies thata = 0.

Proof. Let a, b ∈ K such a ⊑ b and b ⊑ a. Since

• a ⊑ a, a ⊑ b and every z′ such that z′ ⊑ a and z′ ⊑ b is such that z′ ⊑ a; and

• b ⊑ a, b ⊑ b and every z′ such that z′ ⊑ a and z′ ⊑ b is such that z′ ⊑ b,

then both a and b are the (unique) greatest lower bound of a and b.

Lemma 5. For every α such that Σ, D |= α and t ∈ TΣD(α), for every annotated model (I, µI) of Σ and (D,K, λ), Λ(t) ⊑

µI(α), where Λ(t) = Πβ is a leaf of tλ(β). It follows that for every t ∈ TΣD(α), Λ(t) ⊑ PAM(Σ, D,K, λ, α).

Proof. We show by induction that for every n ∈ N, for every α such that Σ, D |= α and t ∈ TΣD(α) which contains at most n

inner nodes (i.e., nodes that have children), for every model (I, µI) of Σ and (D,K, λ), Λ(t) ⊑ µI(α).

• Base case: n = 0. Let α be such that Σ, D |= α and let t ∈ TΣD(α) do not contain any inner node. In this case, t consists

of a single node labeled with α. Thus Λ(t) = λ(α). Moreover, α ∈ D so for every model (I, µI) of Σ and (D,K, λ),λ(α) ⊑ µI(α).

• Induction step: assume that the property is true for some n and let α be such that Σ, D |= α and t ∈ TΣD(α) contain at most

n+ 1 inner nodes. By definition of a derivation tree, the root of t is of the form (α, r, h) for some rule r = φ(~x, ~y) → H(~x)that belongs to Σ and its children are of the form (γ1, r1, h1), . . . , (γk, r,k , hk) where γ1 ∧ · · · ∧ γk = h(φ(~x, ~y)) andα = h(H(~x)). For 1 ≤ i ≤ k, let ti be the subtree of t rooted in (γi, ri, hi). ti is a derivation tree of γi w.r.t. Σ, D soΣ, D |= γi. Moreover ti contains at most n inner nodes. Let (I, µI) be a model of Σ and (D,K, λ). For 1 ≤ i ≤ k,γi ∈ I by Lemma 3 and by induction hypothesis, Λ(ti) ⊑ µI(γi). Moreover, since h is a homomorphism from the bodyof r to {γ1, . . . , γk} such that h(H(~x)) = α, then Πk

i=1µI(γi) ⊑ µI(α). It follows that Πk

i=1Λ(ti) ⊑ µI(α), hence

Λ(t) ⊑ µI(α).

Lemma 6. PSAM(Σ, D,K, λ, α) =∑

{Λ(t)|t∈TΣD(α)} Λ(t), where Λ(t) = Πβ is a leaf of tλ(β).

Proof. We show by induction that for every n ∈ N, for every α such that Σ, D |= α and t ∈ TΣD(α) which contains at most n

inner nodes (i.e., nodes that have children), for every set-annotated model (I, µI) of Σ and (D,K, λ), Λ(t) ∈ µI(α).

• Base case: n = 0. Let α be such that Σ, D |= α and let t ∈ TΣD(α) do not contain any inner node. In this case, t consists

of a single node labeled with α. Thus Λ(t) = λ(α). Moreover, α ∈ D so for every model (I, µI) of Σ and (D,K, λ),λ(α) ∈ µI(α).

• Induction step: assume that the property is true for some n and let α be such that Σ, D |= α and t ∈ TΣD(α) contain at most

n+ 1 inner nodes. By definition of a derivation tree, the root of t is of the form (α, r, h) for some rule r = φ(~x, ~y) → H(~x)that belongs to Σ and its children are of the form (γ1, r1, h1), . . . , (γk, r,k , hk) where γ1 ∧ · · · ∧ γk = h(φ(~x, ~y)) andα = h(H(~x)). For 1 ≤ i ≤ k, let ti be the subtree of t rooted in (γi, ri, hi). ti is a derivation tree of γi w.r.t. Σ, D soΣ, D |= γi. Moreover ti contains at most n inner nodes. Let (I, µI) be a model of Σ and (D,K, λ). For 1 ≤ i ≤ k, γi ∈ Iby Lemma 3 and by induction hypothesis, Λ(ti) ∈ µI(γi). Moreover, since h is a homomorphism from the body of r to{γ1, . . . , γk} such that h(H(~x)) = α, then {Πk

i=1mi | (m1, . . . ,mk) ∈ µI(γ1) × · · · × µI(γk)} ⊆ µI(α). It follows that

Πki=1Λ(ti) ∈ µI(α), hence Λ(t) ∈ µI(α).

Hence for every α such that Σ, D |= α and t ∈ TΣD(α), for every model (I, µI) of Σ and (D,K, λ), Λ(t) ∈ µI(α). Therefore

{Λ(t) | t ∈ TΣD(α)} ⊆

(I,µI )|=(Σ,D,K,λ) µI(α).

Since by Lemma 2 the set-annotated interpretation (I0, µI0) defined by I0 = {α | Σ, D |= α} and µI0(α) = {Λ(t) | t ∈

TΣD(α)} for every α ∈ I0 is a model of Σ and (D,K, λ), it follows that

(I,µI )|=(Σ,D,K,λ) µI(α) = {Λ(t) | t ∈ TΣ

D(α)}.

Proposition 2. The following holds:PAM ⊑ PAT and PSAM ⊑ PAT.

Proof. PAM ⊑ PAT follows from Lemma 1 and PAM ⊑ PAT follows from Lemma 6.

Proposition 3. If K is a commutative + -idempotent ω-continuous semiring, then for every Σ, (D,K, λ), and α,PAM(Σ, D,K, λ, α) = PSAM(Σ, D,K, λ, α) = PAT(Σ, D,K, λ, α).

Proof. Let K be a commutative + -idempotent ω-continuous semiring. In this case,

PAT(Σ, D,K, λ, α) =Σt∈TΣD(α)Λ(t)

=∑

{Λ(t)|t∈TΣD(α)}

Λ(t)

By Lemma 6, it follows that PSAM(Σ, D,K, λ, α) = PAT(Σ, D,K, λ, α).Moreover, by Lemma 1, it follows that PAM(Σ, D,K, λ, α) ⊑

{Λ(t)|t∈TΣD(α)} Λ(t), and by Lemma 5, for every t ∈ TΣ

D(α),

Λ(t) ⊑ PAM(Σ, D,K, λ, α), i.e., PAM(Σ, D,K, λ, α) = Λ(t) + St for some St ∈ K. Since K is + -idempotent,

PAM(Σ, D,K, λ, α) =∑

{Λ(t)|t∈TΣD(α)}

PAM(Σ, D,K, λ, α)

=∑

{Λ(t)|t∈TΣD(α)}

(Λ(t) + St)

=∑

{Λ(t)|t∈TΣD(α)}

Λ(t) +∑

{Λ(t)|t∈TΣD(α)}

St

Hence∑

{Λ(t)|t∈TΣD(α)} Λ(t) ⊑ PAM(Σ, D,K, λ, α). Since PAM is defined for K such that for every x, y ∈ K , the greatest

lower bound of x and y is well defined, by Lemma 4,∑

{Λ(t)|t∈TΣD(α)} Λ(t) ⊑ PAM(Σ, D,K, λ, α) and PAM(Σ, D,K, λ, α) ⊑

{Λ(t)|t∈TΣD(α)} Λ(t) implies that PAM(Σ, D,K, λ, α) =

{Λ(t)|t∈TΣD(α)} Λ(t) = PAT(Σ, D,K, λ, α).

Proposition 4. Let λX be an injective function from D to X .

• A monomial occurs in PAT(Σ, D,N∞JXK, λX , α) if and only if it occurs in PAM(Σ, D,N∞JXK, λX , α).

• PSAM(Σ, D,N∞JXK, λX , α) is obtained by setting all non-zero coefficients to 1 in PAT(Σ, D,N∞JXK, λX , α).

Proof. By Lemma 1, PAM(Σ, D,N∞JXK, λX , α) ⊑ PAT(Σ, D,N∞JXK, λX , α), i.e., PAT(Σ, D,N∞JXK, λX , α) =PAM(Σ, D,N∞JXK, λX , α) + S for some S ∈ N

∞JXK. Moreover, for every monomial m in S, m occurs inPAT(Σ, D,N∞JXK, λX , α) so there exists t ∈ TΣ

D(α) such that m = Λ(t). By Lemma 5, m ⊑ PAM(Σ, D,N∞JXK, λX , α).By Lemma 6, PSAM(Σ, D,N∞JXK, λX , α) =

{Λ(t)|t∈TΣD(α)} Λ(t) where Λ(t) = Πβ is a leaf of tλX(β). It is easy to see that

this is exactly the sum of monomials that occur in PAT(Σ, D,N∞JXK, λX , α).

This final lemma shows that PAM and PSAM fulfill the conditions of Definition 3.

Lemma 7. If Σ, D 6|= α then PAM(Σ, D,K, λ, α) = PSAM(Σ, D,K, λ, α) = 0.If K is positive, for P = PAM and P = PSAM, P(Σ, D,K, λ, α) = 0 implies Σ, D 6|= α.

Proof. In PAM case, by Lemma 1, PAM(Σ, D,K, λ, α) ⊑ PAT(Σ, D,K, λ, α). If Σ, D 6|= α, PAT(Σ, D,K, λ, α) = 0 so byLemma 4, PAM(Σ, D,K, λ, α) = 0. By Lemma 5, for every t ∈ TΣ

D(α), Λ(t) ⊑ PAM(Σ, D,K, λ, α). Hence, if K is positive,

PAM(Σ, D,K, λ, α) = 0 implies that Λ(t) = 0 for every t ∈ TΣD(α). Since databse facts cannot be annotated with 0, this means

that TΣD(α) = ∅ and Σ, D 6|= α.

In PSAM case, by Lemma 3, Σ, D 6|= α if and only if there exists a set-annotated model (I, µI) of Σ and (D,K, λ) such thatα /∈ I . Hence,

• Σ, D 6|= α implies that⋂

(I,µI)|=(Σ,D,K,λ) µI(α) = ∅ and PSAM(Σ, D,K, λ, α) = Σk∈

⋂(I,µI )|=(Σ,D,K,λ)

µI (α)k = 0; and

• if K is positive, PSAM(Σ, D,K, λ, α) = 0 implies that⋂

(I,µI)|=(Σ,D,K,λ) µI(α) = ∅ and Σ, D 6|= α.

A.3 Execution- and Tree-Based Semantics

Naive Evaluation / All Trees We denote (D,K, λn) by (I0n ,K, λ0n), and for i ≥ 1 we denote Iin(Σ, D,K, λn) by (Iin,K, λ

in).

Lemma 8. For every fact α ∈ Iin, it holds that

λin(α) =∑

t∈TΣD(α)

is of depth≤i

Λ(t)

Proof. We prove the claim by induction on i.

Induction Basis If i = 0 then λ0n = D and the claim holds since λ0n(α) = λ(α) if α ∈ D, or 0 otherwise. And, by definition,∑

t∈TΣD(α)

is of depth≤0

Λ(t) = λ(α) if α ∈ D, or 0 otherwise.

Induction Step By definition we have

λin(α) =∑

t∈TΣD(α)

is of depth≤i

Λ(t) =∑

t∈TΣD(α)

is of depth ≤i−1

Λ(t)⊕∑

t∈TΣD(α)

is of depth i

Λ(t)

By definition,∑

t∈TΣD(α)

is of depth ≤i

Λ(t) =∑

t∈TΣD(α)

is of depth ≤i−1

Λ(t)⊕∑

t∈TΣD(α)

is of depth i

Λ(t)

By induction hypothesis,∑

t∈TΣD(α)

is of depth ≤i

Λ(t) = λi−1n (α) ⊕

t∈TΣD(α)

is of depth i

Λ(t)

Note that from the definition Iin(Σ, D,K, λ) := TΣ(Ii−1n (Σ, D,K, λ))∪(D,K, λ) we can conclude (using a simple induction)

that

Iin(Σ, D,K, λ) = TΣ(· · ·TΣ(︸ ︷︷ ︸

i times

I0n (Σ, D,K, λ) ) · · · )⊕ TΣ(· · ·TΣ(︸ ︷︷ ︸

i−1 times

I0n (Σ, D,K, λ) ) · · · )⊕ · · · ⊕ I0n (Σ, D,K, λ)

By the definition of TΣ and the above we conclude the desired equivalence.

Proposition 5. For every Σ, D,K, λ, if K is ω-continuous then Iin(Σ, D,K, λ) converges.

Proof. Let us denote Iin(Σ, D,K, λ) by (Iin,K, λin). From the convergence of the naive Datalog evalutaion algo-

ritm (Abiteboul, Hull, and Vianu 1995), we can conclude that there is a k such that Iℓn = Ikn for every ℓ ≥ k. Let α ∈ Ikn .It suffices to show that λin(α) converges. By Lemma 8,

λin(α) =∑

t∈TΣD(α)

is of depth 0

Λ(t)⊕ · · · ⊕∑

t∈TΣD(α)

is of depth i

Λ(t).

Since K is ω-continuous this sum converges, and therefore supi λin(α) exists, which concludes the proof.

Proposition 6. It holds that PNE = PAT.

Proof. By Lemma 8, the sequence of provenance of a fact α over the Iin(Σ, D,K, λ) converge to the sum of the deriva-tion trees of α. Thus, we can conclude that the sequence of Iin(Σ, D,K, λ) converge to an annotated database that theTΣ(I

∞n (Σ, D,K, λ)) ∪ (D,K, λ) is equal to I∞n (Σ, D,K, λ) and therefore, PNE is equal to PAT.

Optimized Naive Evaluation / Minimal Depth Trees

Proposition 7. For every Σ, D,K, λ, and α such that Σ, D |= α , there exists k ≥ 0 such that Iko,α(Σ, D,K, λ) =

Iℓo,α(Σ, D,K, λ) for every ℓ ≥ k.

Proof. The existence of k such that Iℓo,α = Iko,α for every ℓ ≥ k is a consequence of the convergence of the original seminaive

Datalog algorithm (Abiteboul, Hull, and Vianu 1995). It suffices to show that for the same k and for every fact β ∈ Iko,α if holds

that λksn(β) = λℓsn(α) whenever ℓ ≥ k. This, indeed, follows directly from the definition of the operator ∆Σ.

Lemma 9. For every fact β ∈ Iio,α where (Iio,α,K, Iio,α) := Iio,α(Σ, D,K, λ), the following holds

Iio,α(β) =∑

t∈TΣD(α)

is of minimal depth with depth ≤i

Λ(t)

Proof. The proof is a direct proof by induction on i.

Proposition 8. It holds that POE = PMDT.

Proof. The proof is straightforward from Lemma 9.

Seminaive Evaluation / Hereditary Minimal Depth Trees We denote (D,K, λsn) by (I0sn,K, λ0sn), and for i ≥ 1 we denote

Iin(Σ, D,K, λsn) by (Iisn,K, λisn).

Proposition 9. For every Σ, D,K, λ, there exists k ≥ 0 such that Iksn(Σ, D,K, λ) = Iℓsn(Σ, D,K, λ) for every ℓ ≥ k.

Proof. The existence of k such that Iℓsn = Iksn for every ℓ ≥ k is a consequence of the convergence of the original seminaiveDatalog algorithm (Abiteboul, Hull, and Vianu 1995). It suffices to show that for the same k and for every fact α ∈ Iksn if holdsthat λksn(α) = λℓsn(α) whenever ℓ ≥ k. This, indeed, follows directly from the definition of the operator ∆Σ.

Lemma 10. For every fact α ∈ Iisn where (Iisn,K, λi) := Iisn(Σ, D,K, λ), the following holds

λi(α) =∑

t∈TΣD(α)

is of hereditary minimal depth with depth ≤i

Λ(t)

Proof. The proof is a direct proof by induction on i.

Proposition 10. It holds that PSNE = PHMDT.

Proof. The proof is straightforward from Lemma 10.

Proposition 11. The following hold:

PHMDT ⊑ PNRT ⊑ PAT and PHMDT ⊑ PMDT ⊑ PAT

Proof. It is straightforward that PNRT ⊑ PAT and PMDT ⊑ PAT. Since every hereditary minimal depth tree is also non-recursive, we have PHMDT ⊑ PNRT. Since every hereditary minimal depth tree is also a minimal depth tree, we have PMDT ⊑PAT.

A.4 Non-Recursive Tree-Based Semantics

Proposition 12. For every Σ, D,K, λ and α, if K is a commutative absorptive ω-continuous semiring, thenPNRT(Σ, D,K, λ, α) = PAT(Σ, D,K, λ, α).

Proof. Assume that K is a commutative absorptive ω-continuous semiring. The sum PAT(Σ, D,K, λ, α) of the annotations ofthe (possibly infinitely many) derivations trees in TΣ

D(α) is defined as the supremum of the set of the sums of the annotations

of any finite subset of TΣD(α). We show that this supremum coincides with PNRT(Σ, D,K, λ, α).

It is clear that PNRT(Σ, D,K, λ, α) is a lower bound of the supremum, since the set of non-recursive trees is a subset ofTΣD(α).

Conversely, let {t1, . . . , tn} be a finite subset of TΣD(α). Let us assume that {t1, . . . , tn} contains all the non-recursive trees

of TΣD(α). Let us define a non-recursive version t′i of ti as follows. A simplification of ti is obtained from ti by picking a

node (β, r, h) which has a descendant n of the form (β, r′, h′) or β, and by replacing the subtree rooted in (β, r, h) by thesubtree rooted in n. t′i is any tree obtained from ti on which no simplification is performable. It holds that Λ(ti) = Λ(t′i) × efor some e ∈ K , which is the product of the labels of the leaves that have been removed from ti through successive steps ofsimplification. Hence, by absorptivity of (K,+K,×K, 0K, 1K), Σ

ni=1Λ(ti) = Σn

i=1Λ(t′i) = PNRT(Σ, D,K, λ, α). Since this is

true for any finite subset {t1, . . . , tn} of TΣD(α) that contains the non-recursive trees of TΣ

D(α), this concludes the proof.

B Discussion and Proofs for Section 4

B.1 Commutation with Homomorphisms and Universal Semirings

The following proposition explicits the connection between the satisfaction of the Commutation with Homomorphisms Propertyor Commutation with ω-Continuous Homomorphisms Property by a provenance semantics P and the ability to use a provenancesemiring universal for its semiring domain to factor the computations.

Proposition 17. If P satisfies the Commutation with (resp. ω-Continuous) Homomorphisms Property and Prov(X) is universalfor its semiring domain (resp. which contains only ω-continuous semirings), P(Σ, D,K, λ, α) = h(P(Σ, D,Prov (X), λX , α))where h is the unique (resp. ω-continuous) semiring homomorphism that extends ν : X → K where ν(x) = λ(λ−X (x)) forevery x ∈ X .

Conversely, if S is a set of (resp. ω-continuous) semirings such that Prov (X) is universal for S and for every K ∈ S, it holdsthat P(Σ, D,K, λ, α) = h(P(Σ, D,Prov (X), λX , α)) where h is the unique (resp. ω-continuous) semiring homomorphism

that extends ν : X → K where ν(x) = λ(λ−X(x)) for every x ∈ X , then the restriction PS of P to the semiring domain Ssatisfies the Commutation with (resp. ω-Continuous) Homomorphisms Property.

Proof. Assume that P satisfies the Commutation with Homomorphisms Property and let Prov(X) be a universal semiringfor the semiring domain of P . Let Σ be a Datalog program, (D,K, λ) be an annotated database and α be a fact. Let λXassociate a distinct variable from X to each fact of D and h : Prov(X) → K be the unique semiring homomorphism that

extends ν : X → K where ν(x) = λ(λ−X(x)) for every x ∈ X (the existence of h is guaranteed by the fact that Prov (X)specializes correctly to K by definition of a universal semiring). By the Commutation with Homomorphisms Property, wehave h(P(Σ, D,Prov(X), λX , α)) = P(Σ, D,K, h ◦ λX , α). Moreover, for every β ∈ D, h ◦ λX(β) = ν(λX(β)) =λ(λ−X(λX(β))) = λ(β), so h ◦ λX = λ. Hence h(P(Σ, D,Prov(X), λX , α)) = P(Σ, D,K, λ, α).

Assume that S is a set of semirings such that Prov (X) is universal for S and for every K ∈ S, it holds thatP(Σ, D,K, λ, α) = h(P(Σ, D,Prov(X), λX , α)) where h is the unique semiring homomorphism that extends ν : X → Kwhere ν(x) = λ(λ−X(x)) for every x ∈ X , and let PS be the restriction of P to the semiring domain S. Let K1 and K2

be two commutative semirings in S such that there is a semiring homomorphism h from K1 to K2. Let Σ be a Datalogprogram, (D,K1, λ) be an annotated database and α be a fact. Let h1 : Prov (X) → K1 (resp. h2 : Prov (X) → K2)

be the unique semiring homomorphism that extends ν1 : X → K1 (resp. ν2 : X → K2) where ν1(x) = λ(λ−X(x))

for every x ∈ X and ν2(x) = h(ν1(x)) = h(λ(λ−X (x))). Applying the hypothesis with K1 gives PS(Σ, D,K1, λ, α) =h1(PS(Σ, D,Prov (X), λX , α)). Hence h(PS(Σ, D,K1, λ, α)) = h(h1(PS(Σ, D,Prov (X), λX , α))). Since for everyx ∈ X , h(h1(x)) = h(ν1(x)) = ν2(x), and h2 is the unique semiring homomorphism that extends ν2, it follows thath ◦ h1 = h2. Thus h(PS(Σ, D,K1, λ, α)) = h2(PS(Σ, D,Prov (X), λX , α)). Moreover, applying the hypothesis with K2

gives h2(PS(Σ, D,Prov(X), λX , α)) = PS(Σ, D,K2, h ◦ λ, α). Hence h(PS(Σ, D,K1, λ, α)) = PS(Σ, D,K2, h ◦ λ, α) andPS satisfies the Commutation with Homomorphisms Property.

The proof for the ω-continuous case is similar, but all semirings are assumed to be ω-continuous.

B.2 Proof of Proposition 13

Proposition 13. If P satisfies Properties 5 (Joint and Alternative Use) and 9 (Parsimony), and is such that for everyΣ, D,K, λ, α, P(Σ, D,K, λ, α) = P(ΣD, D,K, λ, α), then it satisfies Property 1 (Algebra Consistency).

Proof. Assume that P satisfies Properties 5 and 9, and is such that P(Σ, D,K, λ, α) = P(ΣD, D,K, λ, α) where ΣD is thegrounding of Σ w.r.t.D. Let Σ be a UCQ defined Datalog program with nullary predicate goal in rule heads, and (D,K, λ) be anannotated database that does not contain goal. By assumption, P(Σ, D,K, λ, goal) = P(ΣD, D,K, λ, goal). Since Σ is UCQdefined, ΣD = {

∧ni

j=1 αij → goal | 1 ≤ i ≤ m}. By Property 5, P(ΣD, D,K, λ, goal) = Σm

i=1Πni

j=1P(∅, D,K, λ, αij). Either

(i) αij ∈ D and by Property 9 P(∅, D,K, λ, αi

j) = λ(αij), or (ii) ∅, D 6|= αi

j and P(∅, D,K, λ, αij) = 0 by point (1) of Definition

3. Each product Πni

j=1P(∅, D,K, λ, αij) is then either equal to 0 is some of the αi

j does not belong to D, or equal to Πni

j=1λ(αij).

Note that since∧ni

j=1 αij → goal is an instantiation of some rule φ(~y) → goal ∈ Σ, it is the case that all αi

j in such a product

belong to D exactly when there exists a homomorphism h from φ(~y) to D such that h(φ(~y)) =∧ni

j=1 αij . It follows that

P(Σ, D,K, λ, goal) = Σφ(~y)→goal∈Σ,h:φ(~y)→DΠp(~y)∈φ(~y)λ(h(p(~y))) where h : φ(~y) → D denotes that h is a homomorphism

from φ(~y) to D. This is precisely the relational database provenance of the equivalent UCQ Q(Σ) =∨

φ(~y)→goal∈Σ ∃~yφ(~y)

over (D,K, λ).

B.3 Usable Facts Definition

We formalize usability of a fact with the following construction. The adornment of a predicate p by α is the (fresh) predicatepα. The adornment of an atom p(t1, . . . , tn) by α is pα(t1, . . . , tn). An adornment of a rule φ(~x, ~y) → p(~x) by α is a rule ofthe shape φα(~x, ~y) → p(~x) or of the shape φα(~x, ~y) → pα(~x),where φα(~x, ~y) is equal to φ(~x, ~y), except for one atom whichhas been replaced by its adornment by α. A fact α is adornment-usable to derive β w.r.t. Σ and D if Dα,Σ ∪Σα |= βα whereDα = D ∪ {αα} and Σα is the set of adornment of rules from Σ by α.

Proposition 18. A fact α is usable to derive β w.r.t. Σ and D if and only if it is adornment-usable to derive β w.r.t. Σ and D.

Proof. Let us assume that α is usable to derive β w.r.t. Σ and D, and let t be a derivation tree for β having a leaf equal to α.We proof that α is adornment-usable to derive β w.r.t. Σ and D by induction on the depth of t.

• Depth 0: the derivation tree is restricted to α = β. Hence βα = αα, and the derivation tree restricted to a single node αα

witnesses that Dα,Σ ∪ Σα |= βα

• Depth k ≥ 1: we assume the result to be true for any derivation tree of depth up to k − 1. Let us consider a child (γ, rγ , hγ)(or α) of (β, rβ , hβ) in t that has α as a descendant. By induction assumption, there exists a derivation tree of γα w.r.t. Σ andD. Let p(t1, . . . , tn) be an antecedent of γ by hβ , and let rαβ be the adornment of rβ replacing p(t1, . . . , tn) by pα(t1, . . . , tn).

The structure obtained from t by modifying the root to (β, rαβ , hβ), leaving descendants unchanged, except for the subtree

rooted in γ that is replaced by the derivation tree of γα is a derivation tree for βα w.r.t. Dα and Σ ∪Σα, hence showing thatDα,Σ ∪Σα |= βα.

We now show that any adornment-usable fact is usable, thanks to the following two observations:

• removing adornments from facts and rules in a derivation tree of βα w.r.t. Dα and Σ ∪ Σα results in a derivation tree of βw.r.t. D and Σ;

• any derivation tree of βα contains αα as a leaf: indeed, a node can have an adorned atom only if one of its child has anadorned atom, or if it is a leaf and is adorned. As αα is the only adorned atom of Dα, this concludes the proof.

C Proofs of Table 1 Results, PAT, PNRT, PMDT and PHMDT Cases

We prove here the positive results in the PAT, PNRT, PMDT and PHMDT columns in Table 1. Counter-examples are given inSection 5 for the properties not satisfied by some of these provenance semantics. We go over all the properties and analyze eachwith respect to PAT, PNRT, PMDT and PHMDT.

C.1 Algebra Consistency

If Σ is UCQ-defined with rule head H(~x) and H /∈ S(D), then for every tuple ~a of same arity as ~x, the relational provenanceof QΣ(~a) is equal to P(Σ, D,K, λ,H(~a)).

Proposition 19. PAT, PMDT, PHMDT and PNRT satisfy the Algebra Consistency Property.

Proof. It is shown by (Green and Tannen 2017) that PAT satisfies the Algebra Consistency Property. Note that all possiblederivation trees of H(~a) w.r.t. Σ and D are of depth one. Hence they are of minimal depth, hereditary minimal depth, and arenon-recursive, which completes the proof for PMDT, PHMDT, and PNRT, respectively.

C.2 Boolean Compatibility

Proposition 20. PAT satisfies the Boolean Compatibility Property.

Proof. It is shown in (Green and Tannen 2017) that PAT satisfies the Boolean Compatibility Property.

Proposition 21. PNRT satisfies the Boolean Compatibility Property.

Proof. As PosBool (X) is absorptive,PNRT andPAT coincide on PosBool (X). Hence PNRT satisfies the Boolean CompatibilityProperty.

C.3 Commutation with Homomorphisms

If there is a semiring homomorphism h from K1 to K2, then h(P(Σ, D,K1, λ, α)) = P(Σ, D,K2, h ◦ λ, α).

Proposition 22. PNRT,PMDT and PHMDT satisfy the Commutation with Homomorphisms Property.

Proof. By definition, we have

PNRT(Σ, D,K1, λ, α) =∑

t∈TΣD(α)

Λ(t)

By definition of Λ(t) we have

PNRT(Σ, D,K1, λ, α) =∑

t∈TΣD(α)

v is a leaf of t

λ(v)

Since h is a homomorphism and since the sum is finite, we have

h(PNRT(Σ, D,K1, λ, α)) =∑

t∈TΣD(α)

v is a leaf of t

h(λ(v))

which is, in turn, equal to P(Σ, D,K2, h ◦ λ, α). In a similar way one can proof the same claim also for PMDT,PHMDT.

C.4 Commutation with ω-Continuous Homomorphisms

Proposition 23. PAT,PNRT,PMDT and PHMDT satisfy the Commutation with ω-Continuous Homomorphisms.

Proof. The case of PNRT,PMDT and PHMDT is a direct consequence of Proposition 22. The case of PAT has been proved in(Green and Tannen 2017).

C.5 Joint and Alternative Use

P satisfies the Joint and Alternative Use Property if for all tuples of facts (α11, · · · , α

1n1), . . . , (αm

1 , · · · , αmnm

),

P(Σ′, D,K, λ, goal) = Σmi=1Π

ni

j=1P(Σ, D,K, λ, αij) where Σ′ = Σ ∪ {

∧ni

j=1 αij → goal|1 ≤ i ≤ m} and goal is a nullary

predicate such that goal /∈ S(Σ) ∪ S(D).

Proposition 24. PAT satisfies the Joint and Alternative Use Property.

Proof. For αij let us denote the set of its derivation trees w.r.t. Σ′ and D by T (j, i). The derivation trees for goal w.r.t. Σ′ and

D are exactly those of the following form:

goal

αi1

t(1,i)

. . .αini

t(ni,i)

where 1 ≤ i ≤ m, and t(1,i) ∈ T (1, i), · · · , t(ni,i) ∈ T (ni, i). Therefore, by definition we have:

PAT(Σ′, D,K, λ, goal) = Σmi=1Π

ni

j=1

t∈T (j,i)

Λ(t).

In addition, by definition of PAT it holds that

PAT(Σ′, D,K, λ, αij) =

t∈T (j,i)

Λ(t)

for every i and j. By definition of Σ′, we can conclude that

PAT(Σ, D,K, λ, αij) =

t∈T (j,i)

Λ(t)

for every i and j. This concludes the proof.

Proposition 25. PNRT satisfies the Joint and Alternative Use Property.

Proof. We use similar notation as those used in the proof of Proposition 24. Let T ′(j, i) ⊆ T (j, i) be the set of non-recursivetrees in T (j, i) (those in which a fact is not a descendant of itself). Note that if each t(j,i) is non-recursive then so is the treethat is depicted in the proof of Proposition 24, and therefore we have

PNRT(Σ′, D,K, λ, goal) = Σmi=1Π

ni

j=1

t∈T ′(j,i)

Λ(t).

In addition, by definition of PNRT it holds that

PNRT(Σ′, D,K, λ, αij) =

t∈T ′(j,i)

Λ(t)

for every i and j. By definition of Σ′, we can conclude that

PNRT(Σ, D,K, λ, αij) =

t∈T ′(j,i)

Λ(t)

for every i and j. This concludes the proof.

C.6 Joint Use

P satisfies the Joint Use Property if for all facts α1, · · · , αn, P(Σ′, D,K, λ, goal) = Πnj=1P(Σ, D,K, λ, αj) where Σ′ =

Σ ∪ {∧n

j=1 αj → goal} and goal is a nullary predicate such that goal /∈ S(Σ) ∪ S(D).The next propositions are a consequence of the following straightforward observation:

Proposition 26. A provenance semantics that satisfies the Joint and Alternative Use Property satisfies also the Joint UseProperty.

Proposition 27. PAT satisfies the Joint Use Property.

Proof. This is a straightforward consequence of Proposition 24.

Proposition 28. PNRT satisfies the Joint Use Property.

Proof. This is a straightforward consequence of Proposition 25.

Proposition 29. PHMDT satisfies the Joint Use Property.

Proof. A key observation that is based on the definition of (hereditary) minimal depth trees is that all minimal depth derivationtrees of a fact αi are of the same depth; we denote this depth by di. Note that the derivation trees of goal w.r.t. Σ′ and D are ofthe form

goal

α1

ti

. . .

αn

tn

where ti ∈ TΣD(αi). Since we are interested in PHMDT(Σ′, D,K, λ, goal), we restrict the discussion only to those derivation

trees of goal which are of hereditary minimal depth. Notice that these are exactly those trees for which each ti is a derivationtree of αi of hereditary minimal depth. Let us denote by Ti the set of derivation trees for αi of hereditary minimal depth. Thenthe derivation trees that we take into account in computing PHMDT(Σ′, D,K, λ, goal) are of those depicted above with ti ∈ Ti.Thus, we get PHMDT(Σ′, D,K, λ, goal) = Πn

j=1PHMDT(Σ, D,K, λ, αj), which completes the proof.

C.7 Alternative Use

P satisfies the Alternative Use Property if for all facts α1, · · · , αm, P(Σ′, D,K, λ, goal) = Σmi=1P(Σ, D,K, λ, αi) where

Σ′ = Σ ∪ {αi → goal|1 ≤ i ≤ m} and goal is a nullary predicate such that goal /∈ S(Σ) ∪ S(D).The next propositions are a consequence of the following straightforward observation:

Proposition 30. A provenance semantics that satisfies the Joint and Alternative Use Property satisfies also the Alternative UseProperty.

Proposition 31. PAT satisfies the Alternative Use Property.

Proof. This is a straightforward consequence of Proposition 24.

Proposition 32. PNRT satisfies the Alternative Use Property.

Proof. This is a straightforward consequence of Proposition 25.

C.8 Self

P satisfies the Self Property if for every α ∈ D, there exists e ∈ K such that P(Σ, D,K, λ, α) = λ(α) + e.

Proposition 33. PAT,PNRT,PMDT and PHMDT satisfy the Self Property.

Proof. Since α ∈ D, it holds that there exists a derivation tree of α w.r.t. Σ and D that consists of a single node α. The claimfollows directly.

C.9 Parsimony

P satisfies the Parsimony Property if when α belongs to D and does not occur in any rule head in the grounding ΣD of Σw.r.t. D, then P(Σ, D,K, λ, α) = λ(α).

Proposition 34. PAT,PNRT,PMDT and PHMDT satisfy the Parsimony Property.

Proof. It holds, by the definition of a derivation tree, that all derivation trees of α must consist of a single node α (which is bothroot and leaf). That is, there is a single derivation tree for α. Hence, the claim follows directly.

C.10 Necessary Facts

P satisfies the Necessary Facts Property if P(Σ, D,K, λ, α) = Πβ∈Necλ(β)× e for some e ∈ K , where Nec is the set of factsnecessary to Σ, D |= α.

Proposition 35. PAT,PNRT,PMDT and PHMDT satisfy the Necessary Facts Property.

Proof. We start by showing that if β is necessary to Σ, D |= α then all derivation trees of α has β as a leaf. Assume to thecontrary that this is not the case, and let t be a derivation tree whose leaves α1, · · · , αn are such that for every i it holds thatαi 6= β. By definition, it holds that Σ, {α1, · · · , αn} |= α, which contradicts β being a necessary fact. We can conclude thateach Necessary Facts appear in every derivation tree of α. Therefore, by definition we haveP(Σ, D,K, λ, α) = Πβ∈Necλ(β)×efor some e ∈ K , for P ∈ {PAT,PNRT,PMDT,PHMDT}.

C.11 Non-Usable Facts

P satisfies the Non-Usable Facts Property if for every λ′ that differs from λ only on facts that are not usable to Σ, D |= α,P(Σ, D,K, λ, α) = P(Σ, D,K, λ′, α).

Proposition 36. PAT,PNRT,PMDT and PHMDT satisfy the Non-Usable Facts Property.

Proof. A fact is not usable if it does not occur in every derivation tree. To put it the other way around, for every derivation treet it holds that if β occurs in t it is usable. By definition, for every derivation tree t we have

Λ(t) :=∏

v is a leaf of t

λ(v)

By the previous observation and the way λ′ is defined, it holds that for every t,

Λ(t) :=∏

v is a leaf of t

λ′(v)

Therefore, we have the desired equivalence P(Σ, D,K, λ, α) = P(Σ, D,K, λ′, α) for P ∈ {PAT,PNRT,PMDT,PHMDT}.

C.12 Insertion

P satisfies the Insertion Property if for every (D′,K, λ′) such thatD∩D′ = ∅, there exists e ∈ K such that P(Σ, D∪D′,K, λ∪λ′, α) = P(Σ, D,K, λ, α) + P(Σ, D′,K, λ′, α) + e.

Proposition 37. PAT satisfies the Insertion Property.

Proof. Let us analyze the derivation trees of αw.r.t. (D∪D′,K, λ∪λ′). We divide the derivation trees of αw.r.t. (D∪D′,K, λ∪λ′) to three groups according to their leaves:

(i) all leaves are elements in D,

(ii) all leaves are elements in D′,

(iii) at least one leaf is from D and at least one is from D′.

We denote class (i) by TD, class (ii) by TD′ , and class (iii) by TD,D′ . We can change the order of summation to obtain

PAT(Σ, D,K, λ, α) =∑

t∈TΣD(α)∩TD

Λ(t) +∑

t∈TΣD(α)∩TD′

Λ(t) +∑

t∈TΣD(α)∩TD,D′

Λ(t) (1)

Notice that for t ∈ TD it holds that Λ(t) w.r.t. (D ∪D′,K, λ ∪ λ′) is the same as Λ(t) w.r.t. (D,K, λ); for t ∈ TD′ it holdsthat Λ(t) w.r.t. (D ∪D′,K, λ∪ λ′) is the same as Λ(t) w.r.t. (D′,K, λ′); Using the definition of PAT, we can replace the partialsums in equation 1 and obtain

PAT(Σ, D ∪D′,K, λ ∪ λ′, α) = PAT(Σ, D,K, λ, α) + PAT(Σ, D′,K, λ′, α) +∑

t∈TΣD(α)∩TD,D′

Λ(t) (2)

which completes the proof.

Proposition 38. PNRT satisfies the Insertion Property.

Proof. We use here the same notations as used in the proof of Proposition 37. By similar arguments we have

PNRT(Σ, D,K, λ, α) =∑

t∈TΣD(α)∩TD

is non-recursive

Λ(t) +∑

t∈TΣD(α)∩TD′

is non-recursive

Λ(t) +∑

t∈TΣD(α)∩TD,D′

is non-recursive

Λ(t) (3)

We note that this holds because of the non-recursiveness of trees that are taken into account and since D ∩D′ = ∅. The rest ofthe proof is similar to that of Proposition 37.

C.13 Deletion

P satisfies the Deletion Property if for every provenance semiring Prov (X) and D′ ⊆ D, if λ′ is the restriction of λX to D′

and ∆ = D \ D′, then P(Σ, D′,Prov(X), λ′, α) is equal to the partial evaluation of P(Σ, D,Prov(X), λX , α) obtained bysetting the annotations of facts in ∆ to 0: P(Σ, D,Prov (X), λX , α)[{λX(x) = 0}x∈∆].

Proposition 39. PAT satisfies the Deletion Property.

Proof. Let us denote the set of derivation trees of α w.r.t. Σ and D whose has at least one leaf from ∆ by T∆, and all otherderivation trees of α (i.e., those which have all their leaves in D′) by T . Then, by definition, we have

PAT(Σ, D,Prov(X), λX , α) =∑

t∈TΣD(α)∩T∆

Λ(t) +∑

t∈TΣD(α)∩T

Λ(t) (4)

Therefore, the partial evaluation would result in∑

t∈TΣD(α)∩T Λ(t) which is, by definition, equals to

PAT(Σ, D′,Prov(X), λ′, α).

Proposition 40. PNRT satisfies the Deletion Property.

Proof. The proof is obtained similarly to that of 39.

D Proofs of Table 1 Results, PAM and PSAM Cases

We prove here the positive results in the PAM and PSAM columns in Table 1 and give counter-examples to show that PAM doesnot satisfy the Necessary Facts Property and the Any ω-Continuous Semiring Property. Counter-examples are given in Section5 for the other properties not satisfied by PAM or PSAM. We will make use of the lemmas shown in Appendix A.2.

D.1 PAM Case

Proposition 41. PAM satisfies the Boolean Compatibility Property.

Proof. Since PosBool (X) is a commutative ω-continuous +K-idempotent semiring, by Proposition 3,PAM(Σ, D,PosBool (X), λ, α) = PAT(Σ, D,PosBool (X), λ, α). It follows by Proposition 20 thatPAM(Σ, D,PosBool (X), λX , α) =

D′⊆D,Σ,D′|=α

β∈D′ λX(β).

Proposition 42. PAM satisfies the Self Property.

Proof. If α ∈ D, for every model (I, µI) of (D,K, λ), λ(α) ⊑ µI(α) so it follows straightforwardly from the definition ofPAM that λ(α) ⊑ PAM(Σ, D,K, λ, α).

Proposition 43. PAM satisfies the Parsimony Property.

Proof. Assume that α ∈ D and does not occur in any rule head in the grounding ΣD of Σ w.r.t. D. By Proposition 42,λ(α) ⊑ PAM(Σ, D,K, λ, α). Moreover, by Lemma 1, the interpretation (I0, µ

I0) defined by I0 = {β | Σ, D |= β} andµI0(β) = PAT(Σ, D,K, λ, β) for every β ∈ I0 is a model of Σ and (D,K, λ), and by Proposition 34 PAT(Σ, D,K, λ, α) = λ(α)so µI0(α) = λ(α). It follows that PAM(Σ, D,K, λ, α) = λ(α).

Lemma 11. The interpretation (I0, µI0) defined by I0 = {α | Σ, D |= α} and µI0(α) = PAM(Σ, D,K, λ, α) for every α ∈ I0

is a model of Σ and (D,K, λ).

Proof. Point (1) of the definition is easy to check: D ⊆ I0 and for every α ∈ D, λ(α) ⊑ µI0(α) = PAM(Σ, D,K, λ, α) byProposition 42.

For point (2), let φ(~x, ~y) → H(~x) be a rule in Σ and h be a homomorphism from φ(~x, ~y) to I0. By construction of I0, forevery β ∈ h(φ(~x, ~y)), Σ, D |= β. Hence Σ, D |= h(φ(~x, ~y)) so Σ, D |= h(H(~x)). It follows that h(H(~x)) ∈ I0.

Let h(H(~x)) = α, and let S be the set of all homomorphisms h′ : φ(~x, ~y) 7→ I0 such that h′(~x) = h(~x). For each such

h′ ∈ S, let γh′

1 , . . . , γh′

kh′be the set of facts from I0 such that h′(φ(~x, ~y)) = γh

1 ∧ · · · ∧ γh′

kh′. Let (I, µI) be a model of Σ and

(D,K, λ).

1. By definition of PAM, for every h′ and i, PAM(Σ, D,K, λ, γh′

i ) ⊑ µI(γh′

i ).

2. Since (I, µI) is a model of Σ and (D,K, λ), by definition of I0 and Lemma 3, I0 ⊆ I . It follows in particular that all

homomorphisms from S are also homomorphisms from φ(~x, ~y) to I . Thus Σh′∈SΠkh′

i=1µI(γh

i ) ⊑ µI(α).

3. (1) and (2) imply that Σh′∈SΠkh′

i=1PAM(Σ, D,K, λ, γh

i ) ⊑ µI(α).

Hence Σh′∈SΠkh′

i=1PAM(Σ, D,K, λ, γh

i ) ⊑ PAM(Σ, D,K, λ, α), i.e., Σh′:φ(~x,~y) 7→I0,h′(~x)=h(~x)Πβ∈h′(φ(~x,~y))µI0(β) ⊑

µI0(h(H(~x)).

Proposition 44. PAM satisfies the Joint Use Property.

Proof. Let (α1, . . . , αn) be a tuple of facts and Σ′ = Σ ∪ {∧n

j=1 αj → goal}. If Σ, D 6|= αj for some αj , then Σ, D 6|= goal,

and by Lemma 7 PAM(Σ, D,K, λ, αj) = 0 and PAM(Σ′, D,K, λ, goal) = 0. We next assume that Σ, D |= αj for every αj .

Let (I, µI) be a model of Σ′ and (D,K, λ). Since (I, µI) is also a model of Σ, then by Lemma 3, {α1, . . . , αn} ⊆ I , and bydefinition of PAM, for every αj , it holds that PAM(Σ, D,K, λ, αj) ⊑ µI(αj). Moreover, since there is a homomorphism from

the body of∧n

j=1 αj → goal to I , then goal ∈ I , and Πnj=1µ

I(αj) ⊑ µI(goal). Hence Πnj=1P

AM(Σ, D,K, λ, αj) ⊑ µI(goal).

Let (I0, µI0) be the model of Σ and (D,K, λ) defined in Lemma 11 and (I1, µ

I1) be such that I1 = I0 ∪ {goal} andµI1(goal) = Πn

j=1PAM(Σ, D,K, λ, αj). It is easy to check that (I1, µ

I1) is a model of Σ′ and (D,K, λ) as it satisfies point (2) of

the definition for rule∧n

j=1 αj → goal by construction. It follows that PAM(Σ′, D,K, λ, goal) = Πnj=1P

AM(Σ, D,K, λ, αj).

Proposition 45. PAM satisfies the Non-Usable Facts Property.

Proof. By Lemma 11, the interpretation (I0, µI0) defined by I0 = {α | Σ, D |= α} and µI0(α) = PAM(Σ, D,K, λ, α) for every

α ∈ I0 is a model of Σ and (D,K, λ). We show that for every α such that Σ, D |= α, µI0(α) does not depend on non-usablefacts, in the sense that none of the constraints of the form ‘X ⊑ µI0(α)’ that µI0(α) has to fulfill according to the definitionof annotated models involves non-usable facts. This will show that PAM(Σ, D,K, λ, α) is not impacted by the annotations ofnon-usable facts.

Let α be a fact such that Σ, D |= α. Assume for a contradiction that there exists a constraint C on µI0(α) such that C involvessome non-usable fact.

1. C cannot be of the form ‘λ(α) ⊑ µI0(α)’, because it would mean that α ∈ D and hence is usable to Σ, D |= α, so that Cdoes not involved any non-usable fact.

2. Hence C is of the form ‘∑

h′:φ(~x,~y) 7→I0,h′(~x)=h(~x)

β∈h′(φ(~x,~y)) µI0(β) ⊑ µI0(α)’ with r := φ(~x, ~y) → H(~x) a rule in Σ

and h a homomorphism from φ(~x, ~y) to I0.

3. By assumption, there exists h′ : φ(~x, ~y) 7→ I0, h′(~x) = h(~x) and β0 ∈ h′(φ(~x, ~y)) such that µI0(β0) depends on non-usable

facts.

4. We can choose such β0 6= α. Otherwise, if the only β ∈ h′(φ(~x, ~y)) such that µI0(β) depends on non-usable facts is α itself,the constraint C does not add any dependance on non-usable facts to µI0(α).

5. For every β ∈ h′(φ(~x, ~y)), since β ∈ I0, then Σ, D |= β by construction of (I0, µI0). Hence there exists a derivation

tree t0 of α with root (α, r, h′) having children of the form (β, ρ, g) with β ∈ h′(φ(~x, ~y)) (including β0), ρ ∈ Σ, and ghomomorphism.

6. By (3), there is a constraint C0 on µI0(β0) involving non-usable facts.

7. C0 cannot be of the form ‘λ(β0) ⊑ µI0(β0)’ because in this case β0 would be in D and hence usable as a leaf of t0 ∈ TΣD(α)

by (5).

8. Thus C0 is of the form ‘∑

h′0:φ0(~x,~y) 7→I0,h′

0(~x)=h0(~x)

β∈h′0(φ(~x,~y))

µI0(β) ⊑ µI0(β0)’ with r0 := φ0(~x, ~y) → H0(~x) a rule

in Σ and h0 a homomorphism from φ0(~x, ~y) to I0.

9. It follows that there exists h′0 : φ0(~x, ~y) 7→ I0, h′0(~x) = h0(~x) and β1 ∈ h′0(φ0(~x, ~y)) such that µI0(β1) depends on

non-usable facts.

10. We can choose such β1 such that β1 6= β0 and β1 6= α. Indeed, if the only β ∈ h′0(φ0(~x, ~y)) such that µI0(β) depends onnon-usable facts is equal to β0 or α, C0 does not add any dependance on non-usable facts to µI0(β0).

11. For every β ∈ h′0(φ0(~x, ~y)), since β ∈ I0, then Σ, D |= β by construction of (I0, µI0). Hence there exists a derivation tree

t1 of α with root (α, r, h′) having children of the form (β, ρ, g) with β ∈ h′(φ(~x, ~y)), among which (β0, r0, h′0) has children

of the form (β, ρ, g) with β ∈ h′0(φ0(~x, ~y)) (including β1).

12. By (9), there is a constraint C1 on µI0(β1) involving non-usable facts.

13. By repeating this process, we can build an infinite sequence of distinct facts α, β0, β1, β2, . . . that are all in I0. This is acontradiction because I0 is finite.

We conclude that there is no constraint C on µI0(α) such that C involves some non-usable fact.It follows that if λ′ differs from λ only on facts that are not usable to Σ, D |= α, PAM(Σ, D,K, λ, α) = PAM(Σ, D,K, λ′, α).

Proposition 46. PAM satisfies the Deletion Property.

Proof. Let Prov (X) be a provenance semiring, D′ ⊆ D, λ′X be the restriction of λX to D′ and ∆ = D \D′.If Prov(X) is + -idempotent, by Proposition 3, PAM(Σ, D,Prov(X), λX , α) = PAT(Σ, D,Prov (X), λX , α) and

PAM(Σ, D,Prov (X), λ′X , α) = PAT(Σ, D,Prov (X), λ′X , α) so by Proposition 39, PAM(Σ, D′,Prov(X), λ′X , α) is equal tothe partial evaluation of PAM(Σ, D,Prov (X), λX , α) obtained by setting the annotations of facts in ∆ to 0.

If Prov(X) is not + -idempotent, then PAM(Σ, D,Prov(X), λX , α) is a sum of monomials m such that there exists t ∈TΣD(α) such that m = Λ(t). Indeed, by Lemma 1, PAT(Σ, D,Prov (X), λX , α) = PAM(Σ, D,Prov (X), λX , α) + S for

some S ∈ Prov (X), and by Lemma 5, for every monomial m in S, m ⊑ PAM(Σ, D,Prov (X), λX , α) because m occurs inPAT(Σ, D,Prov (X), λX , α) so there exists t ∈ TΣ

D(α) such that m = Λ(t). It follows that PAM(Σ, D,Prov(X), λX , α) =PAM(Σ, D′,Prov(X), λ′X , α) + e where e is a sum of products of the form Πβ is a leaf of tλX(β) for some t ∈ TΣ

D(α) \ TΣD′(α).

Moreover, by definition of ∆ and the sets of derivation trees TΣD(α) and TΣ

D′(α), it holds that TΣD(α) \TΣ

D′(α) = {t ∈ TΣD(α) |

∃β leaf of t, β ∈ ∆}. Hence PAM(Σ, D′,Prov (X), λ′X , α) is equal to the partial evaluation of PAM(Σ, D,Prov (X), λX , α)obtained by setting the annotations of facts in ∆ to 0, which makes e evaluate to 0.

The following example shows that PAM does not satisfy the Necessary Facts Property.

Example 14. Let K = (K,+K,×K, 0K, 1K) be defined as follows. We show in Lemma 12 that K is a commutative ω-continuoussemiring such that the greatest lower bound of every pair of elements is well-defined.

• K = {0, 1,∞, a, b, c, d, e, f};

• 0K = 0, 1K = 1;

• +K is defined by

– for every x ∈ K , 0 + x = x+ 0 = x;

– b+ 1 = 1 + b = a;

– c+ 1 = 1 + c = a;

– in every other cases, x+ y = ∞.

• × is defined by

– for every x ∈ K , 1× x = x× 1 = x;

– for every x ∈ K , 0× x = x× 0 = 0;

– d× e = e× d = b;

– d× f = f × d = c;

– in every other cases, x× y = ∞.

Let Σ = {A(x) ∧ B(x) → goal, A(x) ∧ C(x) → goal} and D = {A(a), B(a), C(a)} with λ(A(a)) = d, λ(B(a)) = e,λ(C(a)) = f . A(a) is the only necessary fact. We can show that PAM(Σ, D,N∞JXK, λX , goal) = a. Indeed, the models(I, µI) of Σ and (D,K, λ) are such that d × e = b ⊑ µI(goal) and d × f = c ⊑ µI(goal), so that the possible values forµI(goal) are a = b+ 1 = c+ 1, and ∞ = b+ c, and a ⊑ ∞. Hence PAM(Σ, D,N∞JXK, λX , goal) 6= d× x for every x ∈ Kand PAM does not satisfy the Necessary Facts Property.

Lemma 12. K = (K,+K,×K, 0K, 1K) defined in Example 14 is a commutative ω-continuous semiring such that the greatestlower bound of every pair of elements is well-defined.

Proof. First, K is a commutative semiring:

• +K is associative: Let x, y, z ∈ K and consider x + (y + z). If x = 0, x + (y + z) = y + z = (x + y) + z no matter thevalue of y and z. If y = 0, x+ (y+ z) = x+ z = (x+ y) + z no matter the value of x and z, and similarly if z = 0. If x, yand z are all distinct from 0, (y + z) is equal to a or ∞ and in all cases x+ (y + z) = ∞. The same holds for (x + y) and(x+ y) + z, so x+ (y + z) = ∞ = (x+ y) + z.

• It is clear from the construction that +K is commutative and has identity 0K.

• ×K is associative: Let x, y, z ∈ K and consider x × (y × z). If x = 0, x × (y × z) = 0 = (x × y) × z. If y = 0,x× (y × z) = x× 0 = 0 = 0× z = (x× y)× z, and similarly for z = 0. If x = 1, x× (y × z) = y × z = (x× y)× z. Ify = 1, x× (y× z) = x× z = (x× y)× z, and similarly for z = 1. If x, y, z are all different from 0 and 1, y× z and x× ycan both be equal to b, c or ∞ and in all cases, x× (y × z) = ∞ = (x× y)× z.

• It is clear from the construction that ×K is commutative and has identity 1K.

• ×K distributes over +K: Let x, y, z ∈ K and consider x× (y+ z). If x = 0, x× (y+ z) = 0 = (x× y) + (x× z). If y = 0,x× (y + z) = x× z = (x× y) + (x× z) and similarly for z = 0. If x = 1, x× (y + z) = y + z = (x × y) + (x× z). Ifx, y, z are all different from 0 and x 6= 1, then y+ z is equal to a or ∞ and in both cases x× (y+ z) = ∞. Moreover, x× yand x× z can be equal to ∞, a, b, c, d, e or f and in all cases (x× y) + (x× z) = ∞

• It is clear from the construction that 0K is annihilating for ×K.

Second, K is ω-continuous. The ⊑ relation defined by x ⊑ y if and only if there exists z such that x+ z = y is as follows:

• x ⊑ x for every x ∈ K;

• 0 ⊑ x for every x ∈ K;

• x ⊑ ∞ for every x ∈ K;

• b ⊑ a, c ⊑ a, 1 ⊑ a.

It is easy to check that ⊑ is a partial order and every ω-chain x0 ⊑ x1 ⊑ . . . has a least upper bound sup((xi)i∈N). Moreover,for every x ∈ K , we show that x+ sup((xi)i∈N) = sup((x+ xi)i∈N) and x× sup((xi)i∈N) = sup((x× xi)i∈N).

• If x = 0, x+ sup((xi)i∈N) = sup((xi)i∈N) = sup((x+ xi)i∈N) and x× sup((xi)i∈N) = 0 = sup((x× xi)i∈N).

• If x = 1, x× sup((xi)i∈N) = sup((xi)i∈N) = sup((x× xi)i∈N). Moreover,

– if xi = 0 for every i ∈ N, then x+ sup((xi)i∈N) = 1 + 0 = 1 = sup((1)i∈N) = sup((x+ xi)i∈N),

– if there exists xi0 such that xi = b (resp. c) for every i ≥ i0, then (i) x+xi = a for every i ≥ i0 so sup((x+ xi)i∈N) = aand (ii) sup((xi)i∈N) = b (resp. c) so x+ sup((xi)i∈N) = a = sup((x+ xi)i∈N),

– if there exists xi0 such that xi ∈ {1,∞, a, d, e, f} for every i ≥ i0, then (i) x + xi = ∞ for every i ≥ i0 so sup((x +xi)i∈N) = ∞ and (ii) sup((xi)i∈N) ∈ {1,∞, a, d, e, f} so x+ sup((xi)i∈N) = ∞ = sup((x+ xi)i∈N).

• If x 6= 0 and x 6= 1: consider first the case x× sup((xi)i∈N):

– if xi = 0 for every i ∈ N, then x× sup((xi)i∈N) = x× 0 = 0 = sup((x × xi)i∈N);

– if there exists xi0 such that xi = 1 for every i ≥ i0, then x× sup((xi)i∈N) = x× 1 = x = sup((x × xi)i∈N);

– if there exists xi0 such that xi = d for every i ≥ i0 and x 6= e, x 6= f , then x × sup((xi)i∈N) = x × d = ∞ =sup((x × xi)i∈N);

– if there exists xi0 such that xi = d for every i ≥ i0 and x = e, then x× sup((xi)i∈N) = e× d = b = sup((x × xi)i∈N);

– if there exists xi0 such that xi = d for every i ≥ i0 and x = f , then x× sup((xi)i∈N) = f × d = c = sup((x× xi)i∈N);

– if there exists xi0 such that xi = e for every i ≥ i0 and x 6= d, then x× sup((xi)i∈N) = x× e = ∞ = sup((x× xi)i∈N);

– if there exists xi0 such that xi = e for every i ≥ i0 and x = d, then x× sup((xi)i∈N) = d× e = b = sup((x × xi)i∈N);

– if there exists xi0 such that xi = f for every i ≥ i0 and x 6= d, then x× sup((xi)i∈N) = x× f = ∞ = sup((x×xi)i∈N);

– if there exists xi0 such that xi = f for every i ≥ i0 and x = d, then x× sup((xi)i∈N) = d× f = c = sup((x× xi)i∈N);

– if there exists xi1 different from 0, 1, d, e, f , then sup((xi)i∈N) is different from 0, 1, d, e, f and x× sup((xi)i∈N) = ∞ =sup((x × xi)i∈N).

• If x 6= 0 and x 6= 1: consider now the case x+ sup((xi)i∈N):

– if xi = 0 for every i ∈ N, then x+ sup((xi)i∈N) = x+ 0 = x = sup((x + xi)i∈N);

– if there exists xi0 6= 0:

* if there exists xi1 different from 1, b, c, sup((xi)i∈N) can be equal to ∞, a, d, e, f and in all cases, x+sup((xi)i∈N) = ∞and x+ xi1 = ∞ so sup((x+ xi)i∈N) = ∞.

* else, all xi are either equal to 0 or to xi1 ∈ {1, b, c} (since 1, b, c are not comparable they cannot occur in the sameω-chains) and sup((xi)i∈N) = xi1 .

· Assume xi1 = 1. Then if x /∈ {b, c}, x+ xi1 = ∞ so x+ sup((xi)i∈N) = ∞ = sup((x + xi)i∈N). If x = b or x = c,then x+ xi1 = a so x+ sup((xi)i∈N) = a = sup((x + xi)i∈N).

· Assume xi1 = b. Then if x 6= 1, x + xi1 = ∞ so x + sup((xi)i∈N) = ∞ = sup((x + xi)i∈N). If x = 1, thenx+ xi1 = a so x+ sup((xi)i∈N) = a = sup((x+ xi)i∈N).

· The case xi1 = c is similar.

Hence K is ω continuous.Finally, for every x, y ∈ K , the greatest lower bound of x, y exists.

• If x = y, the greatest lower bound of x, y is x.

• If x = ∞, the greatest lower bound of x, y is y.

• If x = a and y = b, y = c or y = 1, the greatest lower bound of x, y is y.

• Otherwise, the greatest lower bound of x, y is 0.

The following example shows that the greatest lower bound of a pair of elements is not guaranteed to exists, even for ω-continuous semirings, so that PAM does not satisfy the Any ω-Continuous Semiring Property.

Example 15. Let K = (K,+K,×K, 0K, 1K) be defined as follows. We show in Lemma 13 that K is a commutative ω-continuoussemiring.

• K = {0, 1,∞, a, b, c, d, e};

• 0K = 0, 1K = 1;

• +K is defined by

– for every x ∈ K , 0 + x = x+ 0 = x;

– c+ d = d+ c = a;

– d+ e = e+ d = a;

– c+ e = e+ c = b;

– in every other cases, x+ y = ∞.

• × is defined by

– for every x ∈ K , 1× x = x× 1 = x;

– for every x ∈ K , 0× x = x× 0 = 0;

– in every other cases, x× y = ∞.

According to the ⊑ relation defined by x ⊑ y if and only if there exists z such that x+ z = y, a and b have two lower boundse and c (since c ⊑ a, e ⊑ a, c ⊑ b, e ⊑ b) which are not comparable (since c 6⊑ e and e 6⊑ c).

Lemma 13. The semiring K of Example 15 is a commutative ω-continuous semiring.

Proof. First, K is a commutative semiring:

• +K is associative: Let x, y, z ∈ K and consider x + (y + z). If x = 0, x + (y + z) = y + z = (x + y) + z no matter thevalue of y and z. If y = 0, x+ (y+ z) = x+ z = (x+ y) + z no matter the value of x and z, and similarly if z = 0. If x, yand z are all distinct from 0, (y+ z) is equal to a, b or ∞ and in all cases x+ (y+ z) = ∞. The same holds for (x+ y) and(x+ y) + z, so x+ (y + z) = ∞ = (x+ y) + z.

• It is clear from the construction that +K is commutative and has identity 0K.

• ×K is associative: Let x, y, z ∈ K and consider x × (y × z). If x = 0, x × (y × z) = 0 = (x × y) × z. If y = 0,x × (y × z) = x × 0 = 0 = 0 × z = (x × y)× z, and similarly for z = 0. If x = 1, x × (y × z) = y × z = (x × y) × z.If y = 1, x × (y × z) = x × z = (x × y) × z, and similarly for z = 1. If x, y, z are all different from 0 and 1,x× (y × z) = x×∞ = ∞ = ∞× z = (x × y)× z.

• It is clear from the construction that ×K is commutative and has identity 1K.

• ×K distributes over +K: Let x, y, z ∈ K and consider x × (y + z). If x = 0, x × (y + z) = 0 = (x × y) + (x × z).If y = z = 0, x × (y + z) = 0 = (x × y) + (x × z). Note that this is the only case where y + z = 0. If x = 1,x × (y + z) = y + z = (x × y) + (x × z). If y = 0 and z = 1, x × (y + z) = x × 1 = x = (x × y) + (x × z), andsimilarly in the case where y = 1 and z = 0. Note that these two cases cover the case y+ z = 1. If x is different from 0 and1, y + z 6= 1, and y + z 6= 0, then x× (y + z) = ∞ = ∞+∞ = (x× y) + (x× z).

• It is clear from the construction that 0K is annihilating for ×K.

Second, K is ω-continuous. The ⊑ relation defined by x ⊑ y if and only if there exists z such that x+ z = y is as follows:

• x ⊑ x for every x ∈ K;

• 0 ⊑ x for every x ∈ K;

• c ⊑ a; d ⊑ a; e ⊑ a;

• c ⊑ b; e ⊑ b;

• x ⊑ ∞ for every x ∈ K .

It is easy to check that ⊑ is a partial order and every ω-chain x0 ⊑ x1 ⊑ . . . has a least upper bound sup((xi)i∈N). Moreover,for every x ∈ K , we show that x+ sup((xi)i∈N) = sup((x+ xi)i∈N) and x× sup((xi)i∈N) = sup((x× xi)i∈N).

• If x = 0, x+ sup((xi)i∈N) = sup((xi)i∈N) = sup((x+ xi)i∈N) and x× sup((xi)i∈N) = 0 = sup((x× xi)i∈N).

• If x = 1, x× sup((xi)i∈N) = sup((xi)i∈N) = sup((x× xi)i∈N). Moreover,

– if xi = 0 for every i ∈ N, then x+ sup((xi)i∈N) = 1 + 0 = 1 = sup((1)i∈N) = sup((x+ xi)i∈N),

– if there exists xi0 such that xi0 6= 0, then (i) x + xi0 = ∞ so sup((x + xi)i∈N) = ∞ and (ii) sup((xi)i∈N) 6= 0 sox+ sup((xi)i∈N) = ∞ = sup((x + xi)i∈N).

• If x 6= 0 and x 6= 1: consider first the case x× sup((xi)i∈N):

– if xi = 0 for every i ∈ N, then x× sup((xi)i∈N) = x× 0 = 0 = sup((x × xi)i∈N);

– if there exists xi0 6= 0 and xi = 1 for every i ≥ i0, then x× sup((xi)i∈N) = x× 1 = x = sup((x× xi)i∈N);

– if there exists xi1 different from 0 and 1, then sup((xi)i∈N) is different from 0 and from 1 and x× sup((xi)i∈N) = ∞ =sup((x × xi)i∈N).

• If x 6= 0 and x 6= 1: consider now the case x+ sup((xi)i∈N):

– if xi = 0 for every i ∈ N, then x+ sup((xi)i∈N) = x+ 0 = x = sup((x + xi)i∈N);

– if there exists xi0 6= 0:

* if there exists xi1 different from c, d, e (i.e., xi1 is equal to 1, a, b, or ∞), sup((xi)i∈N) can be equal to 1, a, b, or ∞ andin all cases, x+ sup((xi)i∈N) = ∞ and x+ xi1 = ∞ so sup((x+ xi)i∈N) = ∞.

* else, all xi are either equal to 0 or to xi1 ∈ {c, d, e} (since c, d, e are not comparable they cannot occur in the sameω-chains) and sup((xi)i∈N) = xi1 .

· Assume xi1 = c. Then if x /∈ {d, e}, x + xi1 = ∞ so x + sup((xi)i∈N) = ∞ = sup((x + xi)i∈N). If x = d, thenx+xi1 = a so x+sup((xi)i∈N) = a = sup((x+xi)i∈N). Similarly if x = e, x+sup((xi)i∈N) = b = sup((x+xi)i∈N).

· The cases xi1 = d and xi1 = e are similar.

Hence K is ω continuous.

D.2 PSAM Case

Proposition 47. PSAM satisfies the Boolean Compatibility Property.

Proof. Since PosBool (X) is a commutative ω-continuous +K-idempotent semiring, by Proposition 3,PSAM(Σ, D,PosBool (X), λ, α) = PAT(Σ, D,PosBool (X), λ, α). It follows by Proposition 20 thatPSAM(Σ, D,PosBool (X), λX , α) =

D′⊆D,Σ,D′|=α

β∈D′ λX(β).

Proposition 48. PSAM satisfies the Self Property.

Proof. If α ∈ D, for every model (I, µI) of (D,K, λ), λ(α) ∈ µI(α) so it follows straightforwardly from the definition ofPSAM that λ(α) ⊑ PSAM(Σ, D,K, λ, α).

Proposition 49. PSAM satisfies the Parsimony Property.

Proof. Assume that α ∈ D and does not occur in any rule head in the grounding ΣD of Σ w.r.t. D. By Lemma 6PSAM(Σ, D,K, λ, α) =

{Λ(t)|t∈TΣD(α)} Λ(t), where Λ(t) = Πβ is a leaf of tλ(β) and it follows from the assumptions on α

that TΣD(α) contains a single derivation tree which consists of a single root node. Hence PSAM(Σ, D,K, λ, α) = λ(α).

Proposition 50. PSAM satisfies the Necessary Facts Property.

Proof. Let Nec be the set of facts necessary to Σ, D |= α. By Lemma 6 PSAM(Σ, D,K, λ, α) =∑

{Λ(t)|t∈TΣD(α)} Λ(t), where

Λ(t) = Πβ is a leaf of tλ(β). Hence, PSAM(Σ, D,K, λ, α) = Πβ∈Necλ(β) × e for some e ∈ K .

Proposition 51. PSAM satisfies the Non-Usable Facts Property.

Proof. Let λ′ that differs from λ only on facts that are not usable to Σ, D |= α. By Lemma 6 PSAM(Σ, D,K, λ, α) =∑

{Λ(t)|t∈TΣD(α)} Λ(t), where Λ(t) = Πβ is a leaf of tλ(β). Since λ and λ′ coincide on all facts usable to Σ, D |= α and only such

facts occur in leaves of trees from TΣD(α), it follows that Πβ is a leaf of tλ(β) = Πβ is a leaf of tλ

′(β). Hence PSAM(Σ, D,K, λ, α) =PSAM(Σ, D,K, λ′, α).

Proposition 52. PSAM satisfies the Deletion Property.

Proof. Let Prov (X) be a provenance semiring, D′ ⊆ D, λ′X be the restriction of λX to D′ and ∆ = D \D′. By Lemma 6PSAM(Σ, D′,Prov(X), λ′X , α) =

{Λ(t)|t∈TΣD′ (α)}

Λ′(t) with Λ′(t) = Πβ is a leaf of tλ′X(β) = Πβ is a leaf of tλX(β).

Let us denote the set of derivation trees of α w.r.t. Σ andD whose has at least one leaf from ∆ by T∆, and all other derivationtrees of α (i.e., those which have all their leaves in D′) by T . Note that T = TΣ

D′(α). Then, by Lemma 6, we have

PSAM(Σ, D,Prov (X), λX , α) =∑

{Λ(t)|t∈TΣD(α)}

Λ(t) with Πβ is a leaf of tΛ(t) = λX(β)

=∑

{Λ(t)|t∈T}

Λ(t) +∑

{Λ(t)|t∈T∆}

Λ(t)

=PSAM(Σ, D′,Prov(X), λ′X , α) +∑

{Λ(t)|t∈T∆}

Λ(t)

Hence PSAM(Σ, D′,Prov (X), λ′X , α) is equal to the partial evaluation of PSAM(Σ, D,Prov (X), λX , α) obtained by setting theannotations of facts in ∆ to 0, which makes

{Λ(t)|t∈T∆} Λ(t) evaluate to 0.

E Other Proofs for Section 5

E.1 PAM and PSAM on BJXK

Proposition 53. The semiring BJXK of formal power series with Boolean coefficients is such that for every ω-continuous+ -idempotent semiring K and Σ, (D,K, λ) and α, for P ∈ {PAM,PSAM},

P(Σ, D,K, λ, α) = h(P(Σ, D,BJXK, λX , α))

where λX associates a distinct variable from X to each fact of D and h is the unique semiring homomorphism that extendsν : X → K where ν(x) = λ(λ−X(x)) for every x ∈ X .

Proof. Let K be a ω-continuous + -idempotent semiring. Let Σ be a Datalog program, (D,K, λ) be an annotated database andα be a fact.

• By Proposition 3, since K is ω-continuous and + -idempotent, PAM(Σ, D,K, λ, α) = PSAM(Σ, D,K, λ, α) =PAT(Σ, D,K, λ, α).

• Since PAT satisfies the Commutation with ω-Continuous Property and N∞JXK is universal for ω-continuous semirings,

PAT(Σ, D,K, λ, α) = Evalν(PAT(Σ, D,N∞JXK, λX , α)) where Evalν is the unique semiring homomorphism from N∞JXK

to K that extends ν : X → K where ν(x) = λ(λ−X (x)) for every x ∈ X .

• Let f : N∞JXK 7→ BJXK be the function that replaces all coefficients different from 0 by 1. Since K is + -idempotent,

for every s ∈ N∞JXK, Evalν(s) = Evalν(f(s)). Moreover, it is easy to check that f is actually the unique ω-continuous

homomorphism of semirings such that for the one-variable monomials we have f(x) = x. Hence since PAT satisfies theCommutation with ω-Continuous Property and N

∞JXK is universal for ω-continuous semirings, PAT(Σ, D,BJXK, λX , α) =f(PAT(Σ, D,N∞JXK, λX , α)).

• By Proposition 3, since BJXK is ω-continuous and + -idempotent,PAM(Σ, D,BJXK, λX , α) = PSAM(Σ, D,BJXK, λX , α) =PAT(Σ, D,BJXK, λX , α).

• Finally, note that for every s ∈ BJXK, Evalν(s) = h(s).

To sum up, for P ∈ {PAM,PSAM} we have

P(Σ, D,K, λ, α) =PAT(Σ, D,K, λ, α)

=Evalν(PAT(Σ, D,N∞JXK, λX , α))

=Evalν(f(PAT(Σ, D,N∞JXK, λX , α)))

=Evalν(PAT(Σ, D,BJXK, λX , α))

=Evalν(P(Σ, D,BJXK, λX , α))

=h(P(Σ, D,BJXK, λX , α))

F Provenance Computation

The problem of computing the provenance of a fact or query answer has been studied in different manners for PAT. Aspresented before, in this case the provenance expressions can be infinite. Deutch et al. (2014) study different semirings forwhich the provenance is finite and can be computed in a finite time. They also show that it is possible to represent PAT withthese semirings through a polynomial structure: circuits. We show how to adapt the classical semi-naive evaluation algorithmfor the different provenance semantics studied in this paper.

F.1 PMDT and PHMDT Cases

We show that both PMDT and PHMDT can be represented by polynomial size circuits regardless of the semiring. We use ageneralization of the algorithm presented by Deutch et al. (2014) for which we will use arithmetic circuits and not Booleancircuits to represent the provenance expressions.

Definition 4. Let X be a set of annotations. An arithmetic circuit C is a pair of a directed acyclic graph G and a labelingfunction γ from the nodes ofG toX ∪{+, ∗}∪{0, 1}. The nodes without outgoing edges are called leaves and the other nodesinternal nodes. The labeling function associates each internal node to + or ∗ and the leaves to variables in X or 1 or 0. Theroot of circuit is the only node without incoming edges.

In the next proposition, we consider the semiring N∞JXK. Thanks to the property of commutation with ω-continuous

homomorphisms, it can be extended to another semiring K by applying the homormophism from N∞JXK to K to the obtained

circuit.

Proposition 54. For every fact α and every i ≥ 0, the annotation λin(α) of α in (Iin,N∞JXK, λin) = Iin(Σ, D,N

∞JXK, λ)can be represented by a circuit of size polynomial in the size of D and i. Moreover, PMDT(Σ, D,N∞JXK, λ, α) andPHMDT(Σ, D,N∞JXK, λ, α) can be computed in a polynomial time in the size of D.

Proof. We generalize the algorithm proposed by Deutch et al. (2014) to construct Boolean circuits for PosBool (X) of sizepolynomial in the database by using arithmetic circuits instead of Boolean circuits to represent the provenance.

We inductively describe an algorithm that constructs polynomial circuits C(i, α,Σ, D,N∞JXK, λ) representing λin(α) forevery α.

• Base case: i = 0. In this case, for every α, λin(α) = λ(α) if α ∈ D and λin(α) = 0 otherwise. HenceC(i, α,Σ, D,N∞JXK, λ) consists of a single node labeled by λ(α) or 0.

• Induction step: Assume that for every α, we have built C(i, α,Σ, D,N∞JXK, λ) polynomial in the size of D and i thatrepresents λin(α).We apply TΣ over the database (Iin,N

∞JXK, λ′) where λ′ is a function associating to each fact in Iin a new variable in a newset of variables X ′, and get a new annotated database denoted by (ITΣ ,N

∞JX ′K, λTΣ).To compute C(i+1, α,Σ, D,N∞JXK, λ), we use λTΣ(α). It is known that there is a circuit representation of λTΣ(α) polyno-mial in ITΣ . We replace each variable in λTΣ(α) that represents some fact β by the root of the circuit C(i, β,Σ, D,N∞JXK, λ).Note that we add only a polynomial number of nodes and edges to the previous circuit. This conclude our induction.

Our proof can be easily adapted in the context of Iksn(Σ, D,N∞JXK, λ) and Iko,α(Σ, D,N

∞JXK, λ). Moreover, the an-

notation of a fact in Iksn(Σ, D,N∞JXK, λ) is not modified after the its creation, and the annotation of the goal fact in

Iko,α(Σ, D,N∞JXK, λ) is not modified after its creation. Therefore,Iksn(Σ, D,N

∞JXK, λ) and Iko,α(Σ, D,N∞JXK, λ) termi-

nates in a number of steps polynomial in the size of the database and we can conclude that PMDT(Σ, D,N∞JXK, λ, α) andPHMDT(Σ, D,N∞JXK, λ, α) can be computed in polynomial time in the size of the database.

F.2 PNRT Case

We show that there is no polynomially computable circuit that computes PNRT on N∞[X ], by a reduction from the problem of

counting the number of simle paths for the RPQ a∗, which is #P - hard (Arenas, Conca, and Perez 2012). We hence start bydefining these notions.

RPQ queries are binary queries over labeled-edge graphs. They are based on a regular language that can be defined by adeterministic automaton. A deterministic automaton is a tuple A = (s0, S, F,A, δ), where S is a set of states, F ⊆ S a set offinal states, A is a finite set called alphabet, and δ is a complete function from S ×A to S. We extend δ to a complete functionfrom S ×A∗ to S.

A path predicate is a binary predicate Λ given by a regular expression over binary predicates. A path atom is an atom of theshape Λ(t1, t2), where Λ is a path predicate and t1, t2 are terms. A regular path query is a query q(t1, t2) := Λ(t1, t2), whereΛ(t1, t2) is a path atom. Let I be an interpretation. We call path (from e0 to en) in I a (finite) sequence p = e0r1e1 . . . rnenwith n ≥ 0 such that e0 ∈ ∆I , and for any i ≥ 1, ei ∈ ∆I , ri is a binary predicate and (ei−1, ei) ∈ rI , and denote by w(p)the word r1 . . . rn . We extend interpretations by interpreting path predicates as follows:

ΛI = {(e0, en) | there exists a path p from e0 to enin I such that w(p) ∈ L(Λ)}

A path is simple if for any i 6= j, ei 6= ej . Given a deterministic automaton A, a path is A-simple if for any i 6= j,(ei, δ(s0, r1 . . . ri−1)) 6= (ej , δ(s0, r1 . . . rj−1)).

There is a straightforward translation of an RPQ in a Datalog program, in particular for the RPQ a∗.

Definition 5. Let A be a deterministic automaton. The Datalog program ΣA canonically associated with A contains, for eachtransition δ(s, a) = s′, the following Datalog rule:

s(x) ∧ a(x, y) → s′(y).

Moreover, for each final state sf ∈ F , one Datalog rule is added:

sf (x) → accept(x)

Given a databse D, there is a strong connection between the non recursive proof trees of accept(a2) w.r.t. ΣA and D and thesimple paths between a1 and a2 in D.

Proposition 55. There is a bijection between:

1. the set of all derivation trees of accept(a2) w.r.t. D ∪ {s0(a1)} and ΣA,

2. the set of L(A) paths from a1 to a2 in D.

There is also a bijection between:

(3) the set of non recursive derivation trees of accept(a2) w.r.t. D ∪ {s0(a1)} and ΣA,

(4) the set of A-simple L(A)-paths from a1 to a2 in D.

Therefore, PNRT(ΣA, D ∪ {s0(a1)},N, λ, accept(a2)) where λ(α) = 1 for every α gives the exact number of simple pathsfrom a1 to a2 in D satisfying a∗.

We are now ready to proof our result.

Proposition 56. Under the assumption that P 6= NP , there exist Σ, D and α such that PNRT(Σ, D,N∞JXK, λX , α) cannotbe represented by a circuit computable in polynomial time and of polynomial size in D.

Proof. Suppose by contradiction that for every Σ, D and α we can compute in a polynomial time an arithmetic circuit repre-senting PNRT(Σ, D,N∞JXK, λX , α). It implies that the circuit has a polynomial size. By applying this assumption to computePNRT(ΣA, D ∪ {s0(a1)},N

∞JXK, λX , accept(a2)) and using the homomorphism from N∞JXK into (N∞,+,×, 0, 1) that as-

sociate each variable to 1 over this circuit, since PNRT satisfies the commutation with ω-continuous homomorphisms, it ispossible to compute the number of simple paths from a1 to a2 in D satisfying a∗ by Proposition 55. This contradicts the resultby Arenas, Conca, and Perez (2012), which concludes our proof.