Possible-world foundations for the general evaluator #
The token-level ingredients of the random-world commutation for
AggQuery.evaluate over πΉ[X] (the general-evaluator counterpart of
randomWorld_evaluateAnnotated, whose target statement is
genRandomWorld v (q.evaluate d) = q.evaluatePlain (d.randomWorld v)
β under a valuation v, specializing the general evaluation's surviving
rows is the plain evaluation of the realized world):
AggValue.realizedβ the positions of a token's occurrences realized by a valuation, andAggValue.specialize_evalconnecting the world-faithful readingspecializeto the per-world readingvalOnat the realized world;AggValue.predProv_eval_iffβ the token-level PQE bridge: under a valuation, the predicate provenance of a comparison against a token is true iff the realized group is non-empty and its aggregate value satisfies the comparison. This ishavingProv_eval_ifftransported to tokens; the Ο-aggregate case of the commutation reduces to it;GenRow.specializeTupleandgenRandomWorldβ the specialized reading of a row and the realized world of a general evaluation: the rows whose finalized annotation is true, with tokens specialized.
The positions of a token's occurrences realized by a valuation.
Instances For
Dependency graph
The world-faithful reading under a valuation is the per-world reading at the realized world.
Dependency graph
The token-level PQE bridge. Under a valuation v, the predicate
provenance of β¨tokenβ© op c is true iff the token's realized group is
non-empty and its specialized aggregate value satisfies the comparison.
The Ο-aggregate case of the random-world commutation reduces to this.
Dependency graph
The specialized reading of a lifted value: regular values are themselves, a token aggregates its realized occurrences.
Equations
- GenValue.specializeAt v = Sum.elim id fun (a : AggValue T (BoolFunc X)) => a.specialize fun (Ξ± : BoolFunc X) => Ξ± v
Instances For
Dependency graph
The specialized reading of a row's tuple.
Equations
- GenRow.specializeTuple v u k = GenValue.specializeAt v (u k)
Instances For
Dependency graph
The realized world of a general evaluation: the rows whose finalized annotation is true under the valuation, with tokens specialized.
Equations
- genRandomWorld v R = Multiset.map (fun (r : GenRow T (BoolFunc X) n) => GenRow.specializeTuple v r.1) (Multiset.filter (fun (r : GenRow T (BoolFunc X) n) => r.2.finalize v = true) R)
Instances For
Dependency graph
Evaluation of factored annotations #
Truth of a group's existence guard under a valuation: some occurrence annotation is realized.
Instances For
Dependency graph
Equations
Dependency graph
Pointwise truth of a finalized factored annotation: the concrete part
holds and every pending group is realized non-empty (Ξ΄ is the identity
on πΉ[X]).
Dependency graph
A token's existence guard is the non-emptiness of its realized world.
Dependency graph
Specialized readings under kind conformance #
A regular-kinded value is a left injection.
Dependency graph
A token-kinded value is a right injection.
Dependency graph
On a kind-conformant tuple, a term's lifted evaluation is its plain evaluation on the specialized tuple (regular columns hold regular values, on which both readings are the identity).
Dependency graph
On a kind-conformant tuple, an aggregate-atom-free predicate holds iff its plain reading holds on the specialized tuple.
Dependency graph
The Ο-aggregate row lemma #
The annotation lists of the tokens compared by a predicate on a row
(the evaluator's compared).
Equations
- Ο.selCompared u = Multiset.filterMap (fun (k : Fin n) => match u k with | Sum.inl val => none | Sum.inr a => some (List.map Prod.snd a.occs)) Ο.comparedCols.val
Instances For
Dependency graph
The pending factors after a Ο with aggregate atoms (the evaluator's update, definitionally).
Equations
- Ο.selPending u p = if Ο.entailsExistence false = true then Multiset.filter (fun (l : List K') => Β¬(Ο.selCompared u β 0 β§ β l' β Ο.selCompared u, l' = l)) p else p
Instances For
Dependency graph
Predicate provenance evaluation, under existence guards. On a kind-conformant row all of whose compared groups are realized non-empty, the predicate provenance is true iff the (polarity-adjusted) plain predicate holds on the specialized tuple.
Dependency graph
Existence entailment extracts the guard. When a predicate entails
existence and all its compared tokens carry the annotation list ββ, a
true predicate provenance realizes ββ.
Dependency graph
Finalize algebra (any m-semiring) #
Cashing pending factors into the concrete part preserves the finalized annotation (the projection case of the evaluator).
Dependency graph
The finalized annotation of a product row is the product of the finalized annotations.
Dependency graph
The row-level Ο lemmas #
A Ο with aggregate atoms only strengthens the annotation: the finalized updated annotation implies the finalized original one (the superseded factors are recovered from the predicate provenance through existence entailment).
Dependency graph
The Ο-aggregate row lemma. On a kind-conformant, guarded row, the updated annotation is realized iff the original annotation is realized and the plain predicate holds on the specialized tuple.
Dependency graph
The guardedness invariant #
Guardedness of the general evaluator: on any row it produces, whenever the finalized annotation is realized, every token's group is realized non-empty β the group-existence guard of each token is carried either by a pending factor or by a predicate provenance in the concrete part.
Dependency graph
Realized-world plumbing #
The Gamma case helpers #
The random-world commutation #
Random-world commutation for the general evaluator (over πΉ[X]):
specializing the realized rows of the general annotated evaluation is the
plain evaluation of the realized world. The Ο-aggregate case is the row
lemma GenPred.sel_finalize_eval_iff under the conformance and
guardedness invariants; the Gamma case rests on
groupSeq_randomWorld.
Dependency graph
Unrestricted probabilistic query evaluation (PQE) #
The Boolean provenance of a general query: the β-sum of the
finalized annotations of its rows β true in a world iff some row is
realized.
Equations
- q.booleanProv d = (Multiset.map (fun (r : GenRow T (BoolFunc X) n) => r.2.finalize) (q.evaluate d)).sum
Instances For
Dependency graph
Pointwise PQE bridge, general form: the Boolean provenance of a general query is true in a world iff the plain evaluation of that world is non-empty. Immediate from the random-world commutation.
Dependency graph
Probability that a random world of d satisfies the Boolean query
q (non-empty answer), over a tuple-independent probabilistic
database.
Equations
- AggQuery.booleanProb P q d = β v : X β Bool, if Multiset.card (q.evaluatePlain (AnnotatedDatabase.randomWorld v d)) = 0 then 0 else P.valProb v
Instances For
Dependency graph
Unrestricted probabilistic query evaluation. For any general
query β aggregate comparisons anywhere, through joins, projections,
unions and further selections β over a tuple-independent probabilistic
database, the probability that a random world satisfies the Boolean
query equals the probability of its Boolean provenance. This removes the
top-level restriction of the fused booleanHaving_pqe.
Dependency graph
The provenance of a tuple t in a general query with all-regular
output: the β-sum of the finalized annotations of the rows whose data
part is t.
Equations
- q.tupleProv d t = (Multiset.map (fun (r : GenRow T (BoolFunc X) n) => r.2.finalize) (Multiset.filter (fun (r : GenRow T (BoolFunc X) n) => GenRow.plainTuple r.1 = t) (q.evaluate d))).sum
Instances For
Dependency graph
Pointwise tuple-marginal bridge: the provenance of t is true in
a world iff t belongs to the plain evaluation of that world.
Dependency graph
The marginal probability that t belongs to a random world's
answer.
Equations
- AggQuery.tupleProb P q d t = β v : X β Bool, if t β q.evaluatePlain (AnnotatedDatabase.randomWorld v d) then P.valProb v else 0
Instances For
Dependency graph
Unrestricted tuple-marginal PQE: for a general query with
all-regular output over a tuple-independent probabilistic database, the
marginal probability of an answer tuple is the probability of its
provenance. This is the general-evaluator counterpart of the classical
intensional-PQE theorem ProbAssignment.theorem_12, with aggregate
comparisons allowed anywhere in the query.