Modeladvanced
Provenance semirings
Also called K-relations, how-provenance.
Annotate tuples with elements of a commutative semiring and carry them through positive queries; provenance polynomials are the most general.
Provenance semirings are a model of query evaluation in which each tuple carries an annotation from a commutative semiring, and the operators of the positive relational algebra combine the annotations by the semiring operations: alternative use of data adds them, and joint use multiplies them. Green, Karvounarakis and Tannen introduced the model in 2007. With the Boolean semiring it is set semantics, with the natural numbers it is bag semantics, and with the semiring of polynomials it records how each output was derived. That last case, the provenance polynomials, is the most general one: every other annotation is obtained from it by evaluating the polynomials.
The machine
Semirings. A commutative semiring is a set with two operations and and two elements and such that and are associative and commutative, is the identity of , is the identity of , distributes over , and for all . There is no subtraction or division in general. The examples used here:
| Semiring | Set | Use | ||||
|---|---|---|---|---|---|---|
| or | and | false | true | set semantics | ||
| sum | product | bag semantics | ||||
| tropical | min | sum | cost of the cheapest derivation | |||
| Viterbi | max | product | confidence of the best derivation | |||
| sets of subsets of | union | pairwise union | why-provenance | |||
| polynomials over with coefficients in | sum | product | provenance polynomials |
In , the pairwise union of and is .
K-relations. Fix a commutative semiring . A K-relation over a set of attributes is a function from the tuples over to whose support is finite. The value is the annotation of ; a tuple with annotation is absent. A K-instance gives a K-relation to each relation name. For provenance, each input tuple gets its own variable as its annotation, from a set of tuple identifiers.
The positive algebra on K-relations (Green, Karvounarakis and Tannen 2007). For K-relations over , over , and a selection predicate that returns or :
- empty relation: for every ;
- union: ;
- projection: ;
- selection: ;
- natural join: , for over ;
- renaming: moves the annotation with the tuple.
The sums are finite, because supports are finite. So means "derived in another way" and means "derived by using both". Union and projection, which merge tuples, add; join, which needs both inputs, multiplies.
Datalog. A recursive rule can derive a tuple in infinitely many ways, so its annotation is an infinite sum. Green, Karvounarakis and Tannen use omega-continuous semirings: is ordered by if for some , every increasing chain has a least upper bound, and and preserve these bounds. Then the immediate consequence operator of a Datalog program on K-instances is omega-continuous, and the program's meaning is its least fixed point, the limit of the rounds of naive evaluation starting from the empty instance, as in the Kleene fixed-point theorem. , and the tropical semiring are omega-continuous; is not, since has no bound in .
What it counts
The model assigns to each output tuple an element of , computed from the annotations of the input tuples. What the element means depends on : presence (), multiplicity (), the cost or confidence of the best derivation (tropical, Viterbi), the sets of tuples that witness it (), or the full derivation record (). In , each monomial is one derivation: its variables are the input tuples it uses, and an exponent counts how many times it uses a tuple. The coefficient counts the derivations that use the same tuples the same number of times.
Example. Let have the three edges , , , annotated , , . The query
returns each node with edges and , that is, each node on a cycle of length 1 or 2. Node has two derivations, with edges and , and with the edge used twice. Node has one, with and . So in
Each other semiring gives its value by substitution:
- with : both nodes are in the answer, as in set semantics.
- with , , , that is, two copies of and three of in a bag: and . Evaluating the same query on the bag directly gives 11 copies of and 2 of .
- Tropical with edge costs , , : and .
- with and so on: . Deleting keeps in the answer, through ; deleting also keeps it, through .
A recursive example. With two edges and , annotated and , the transitive closure program , derives by the paths , , , and so on. Its annotation is the formal power series in . In with this is , the number of derivations; in it is true; in the tropical semiring with costs and it is , the cost of the shortest path.
Relation to other models
- Set and bag semantics. A -relation is an ordinary relation, and the positive algebra on -relations is the relational algebra under set semantics. An -relation is a bag, and the positive algebra on -relations is bag semantics, as in SQL without DISTINCT. The model puts the two under one definition.
- Why-provenance and lineage. Why-provenance is the semiring; lineage and the minimal witness basis are two further semirings. Each is a homomorphic image of , so how-provenance contains strictly more information than each of them: and have the same why-provenance, , but are different polynomials.
- Conditional tables and probabilistic databases. The conditional tables of Imielinski and Lipski (1984) annotate tuples with Boolean conditions; for positive queries this is a K-relation over the semiring of positive Boolean expressions. A probabilistic database evaluates a query by computing such an expression for each answer, its lineage formula, and then its probability. Turning the formula into a form where the probability is easy is knowledge compilation.
- Program analysis and path problems. A Datalog program over an omega-continuous semiring is a system of fixpoint equations over that semiring, as in Datalog-based program analysis and the algebraic path problems: all-pairs shortest paths, as in Floyd-Warshall, is the transitive closure program over the tropical semiring. The equations over the semiring of regular languages are those of Kleene algebra.
- Incremental maintenance. Counting the derivations of each tuple, the annotation, is the counting algorithm of incremental view maintenance: a deletion subtracts the derivations it removes, and the tuple disappears when its count reaches 0.
Known results in the model
All results are from Green, Karvounarakis and Tannen (2007) and are for the positive relational algebra (union of conjunctive queries) unless they say Datalog.
- Commutation with homomorphisms. If is a semiring homomorphism (it preserves , , and ) and is a positive algebra query, then , where applies to every annotation. Proof. Each operator computes its output annotations by and from its inputs, and commutes with both; induction on .
- is the most general. is the free commutative semiring generated by : every map into a commutative semiring extends to exactly one homomorphism , which substitutes for each . With the previous result, for every K-instance whose tuples are annotated for tuple variables , the K-annotation of each answer is of its provenance polynomial. So one evaluation in serves every semiring.
- Equivalence. Two positive queries return the same -relation on every -instance if and only if they return the same K-relation on every K-instance, for every commutative semiring . This follows from the previous result, so equivalence under is the strongest notion of equivalence in the model, stronger than bag equivalence, which is stronger than set equivalence.
- Which identities hold. The usual identities of the positive algebra, associativity and commutativity of union and join, distributivity of join over union, and the pushing of selections and projections, hold on K-relations because is a commutative semiring; Green, Karvounarakis and Tannen showed that the semiring laws are what these identities need. Identities such as need to be idempotent, so they hold in but not in or .
- Datalog. Over omega-continuous semirings the least fixed point exists and is reached as the limit of the rounds of naive evaluation. The most general annotation domain for Datalog is the semiring of formal power series with coefficients in : the coefficient of a monomial is the number of derivation trees of the tuple that use exactly those tuples, and it can be . Green, Karvounarakis and Tannen gave algorithms that decide, for each output tuple, whether its series is a polynomial, and compute it when it is.
- Limits. Difference and negation are not covered: a commutative semiring has no subtraction, and does not fit the "derived in another way, derived by using both" reading. Aggregation is not covered either. Both need extensions of the model with more structure on .
References
- Todd J. Green, Grigoris Karvounarakis and Val Tannen, Provenance semirings, Proceedings of the 26th ACM Symposium on Principles of Database Systems (PODS), 31 to 40 (2007), K-relations and the positive algebra on them, commutation with homomorphisms, the provenance polynomials N[X] as the most general annotations, and Datalog over omega-continuous semirings with formal power series
- Tomasz Imielinski and Witold Lipski, Incomplete information in relational databases, Journal of the ACM 31(4), 761 to 791 (1984), conditional tables, whose tuples carry Boolean conditions through the algebra, an early case of annotated relations
- James Cheney, Laura Chiticariu and Wang-Chiew Tan, Provenance in databases, why, how, and where, Foundations and Trends in Databases 1(4), 379 to 474 (2009), how-provenance and its relation to lineage and why-provenance
About this page
The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H0 no proof |
|
| Lean | L0 no Lean part |
|
| Visual | V0 none |
|
| Writing | W4 complete |
|
Tag JN7WRZ Edit this page History Report an error Markdown