Documentation

Provenance

Provenance in databases #

This Lean 4 library provides formal definitions and proofs relevant for provenance in databases, following the semiring framework of Green, Karvounarakis & Tannen and Green & Tannen.

One of the goals of this library is to provide a formal, machine-checked semantics for the provenance-aware relational database system ProvSQL described in Sen, Maniu & Senellart.

Contents #

Core theory

The kind-indexed general syntax is the library's primary query framework. Its three column kinds – regular values, aggregate tokens, provenance values – mirror the three data types through which ProvSQL enforces its own discipline (regular SQL values, agg_token, uuid), so the system's scope restrictions on aggregate results (no deduplication, difference or re-grouping over them) are static typing here, not a formalization convenience. The classical query layer below remains the proven engine several general results reuse internally.

The classical rewriting layer

Algorithms

Complexity

Concrete m-semirings (Provenance.Semirings.*)

Published papers

See Provenance.Example for an example annotated database computation.

Benzaken, Cohen-Boulakia, Contejean, Keller & Zucchini formalize K-relations in Coq/Rocq, for the positive relational algebra extended with a single top-level aggregate, and prove an adequacy theorem: at K = ℕ, the annotated semantics computes exactly the standard bag semantics of the relational algebra. Their positivity restriction is essential to that theorem: -adequacy fails as soon as monus-based difference interacts with duplicate elimination (Nat.counterexample_diff_adequacy in Provenance.QueryAdequacy). This library covers the non-monotone m-semiring extension instead – monus difference, duplicate elimination, compositional aggregation – and therefore anchors correctness differently: through homomorphism commutation (Provenance.QueryAnnotatedDatabaseHom), the rewriting correctness theorems (Query.rewriting_valid, AggQuery.rewritesTo_valid), the possible-worlds adequacy of the Boolean-function annotated semantics (randomWorld_evaluateAnnotated in Provenance.Probability), the 𝔹-support adequacy and its transfer along monus homomorphisms (Provenance.SupportAdequacy), and the data-part adequacy results of Provenance.QueryAdequacy. Conversely, this library does not treat NULL values, correlated subqueries, or a SQL surface syntax, which the Coq/Rocq development inherits from Datacert.

References #