Probability identities for HAVING aggregate comparisons under independence #
This file formalizes the algebraic identities for evaluating
HAVING-style aggregate comparisons when the contributors are
independent. Given a B[X]-instance in which each contributor
i : ι carries an annotation α i : BoolFunc X and the annotations
have pairwise disjoint variable supports (so the contributors are
independent Bernoullis with marginals p i = P.funcProb (α i)), we
give closed-form / recurrence expressions for the probability that the
aggregate-comparison atom holds on the contributors of a single group:
- MAX / MIN factorization
(
funcProb_maxLeOnNonempty,funcProb_minGeOnNonempty):Pr[max ≤ C on nonempty] = (∏_{t i > C}(1 - p i)) · (1 - ∏_{t i ≤ C}(1 - p i))and the dual formin. - COUNT (Poisson-binomial) recurrence
(
countMass_insert_succ,countMass_insert_zero):ρ_{J ⊔ {i}}(j+1) = (1 - p i) · ρ_J(j+1) + p i · ρ_J(j),ρ_{J ⊔ {i}}(0) = (1 - p i) · ρ_J(0). - SUM (weighted Poisson-binomial) recurrence
(
sumMass_insert):σ_{J ⊔ {i}}(s) = (1 - p i) · σ_J(s) + p i · σ_J(s - t i)(with the convention thatσ_Jat a negative-shifted index is0).
All four results follow the same template: the underlying event factors
as a Boolean combination of the per-contributor indicators, and the
disjoint-supports hypothesis turns that combination into a product of
marginal probabilities via ProbAssignment.funcProb_mul_disjoint.
The constant 0 Boolean function depends on the empty support
(equivalently on any support).
Dependency graph
The constant 1 Boolean function depends on the empty support
(equivalently on any support).
Dependency graph
A variable depends on the singleton of its index.
Dependency graph
f * g depends on S ∪ T whenever f depends on S and g on T.
Multiplication in BoolFunc X is pointwise &&.
Dependency graph
f + g depends on S ∪ T. Addition in BoolFunc X is pointwise ||.
Dependency graph
1 - f depends on the same support as f. Subtraction here is pointwise
(1 v) && !(f v) = !(f v).
Dependency graph
Enlarging the support preserves DependsOn.
Dependency graph
Finset.prod of BoolFuncs depends on the biUnion of the per-factor
supports.
Dependency graph
Iterated independence: if (β i) depends on S i and the supports are
pairwise disjoint, then the probability of ∏ i ∈ J, β i factors as the
product of the marginal probabilities P.funcProb (β i).
Dependency graph
Additivity over pairwise-incompatible events: the probability of a
⊕-sum (pointwise OR) of Boolean functions whose pairwise products vanish
is the sum of the probabilities.
Dependency graph
Common setup for the four results #
We fix a probability assignment P over Boolean variables X, a finite
type ι of contributors, an annotation α : ι → BoolFunc X, supports
S : ι → Finset X that are pairwise disjoint, and a hypothesis
hdep : ∀ i, (α i).DependsOn (S i). The contributor marginal is
p i := P.funcProb (α i).
Pointwise evaluation of a Finset product of BoolFuncs: the product
evaluates to true iff every factor does.
Dependency graph
MAX factorization #
“Random world contains no contributor with value > C”: the AND over the
indicators 1 - α i for all contributors with t i > C. Evaluates to true
iff every such contributor's annotation is false.
Equations
- HavingProbability.maxNoneAbove α t C = ∏ i : ι with C < t i, (1 - α i)
Instances For
Dependency graph
“Random world contains some contributor with value ≤ C”: the OR over
the indicators α i for all contributors with t i ≤ C, expressed as
1 - ∏ (1 - α i).
Equations
- HavingProbability.someAtMost α t C = 1 - ∏ i : ι with t i ≤ C, (1 - α i)
Instances For
Dependency graph
“Random world is nonempty and max_{i ∈ world} t i ≤ C”: the conjunction
of the two pieces above. The semantic meaning is recorded in
maxLeOnNonempty_eval_iff.
Equations
Instances For
Dependency graph
Semantic reading of maxNoneAbove.
Dependency graph
Semantic reading of someAtMost.
Dependency graph
Full semantic reading: the BoolFunc maxLeOnNonempty α t C evaluates to
true at v iff the random world {i : α i v = true} is nonempty and its
maximum-of-t is at most C.
Dependency graph
Probability of maxNoneAbove: by iterated independence applied to
(1 - α i)'s, this is the product of (1 - p i) over contributors above C.
Dependency graph
Probability of someAtMost: the complement of the product.
Dependency graph
MAX factorization under independence. The probability of the
“max ≤ C on a nonempty world” event factors as a product of an “all
above-C contributors are absent” term and a “some at-most-C contributor
is present” term.
Dependency graph
MIN factorization #
“Random world contains no contributor with value < C”: the AND over the
indicators 1 - α i for all contributors with t i < C.
Equations
- HavingProbability.minNoneBelow α t C = ∏ i : ι with t i < C, (1 - α i)
Instances For
Dependency graph
“Random world contains some contributor with value ≥ C”.
Equations
- HavingProbability.someAtLeast α t C = 1 - ∏ i : ι with C ≤ t i, (1 - α i)
Instances For
Dependency graph
“Random world is nonempty and min_{i ∈ world} t i ≥ C”.
Equations
Instances For
Dependency graph
Dependency graph
Dependency graph
Dependency graph
Dependency graph
Dependency graph
MIN factorization under independence.
Dependency graph
COUNT (Poisson-binomial) recurrence #
Indicator BoolFunc: evaluates to true at a valuation v iff exactly
j of the indices i ∈ J have α i v = true.
Instances For
Dependency graph
countEqIndicator α J j depends on ⋃ i ∈ J, S i: its value at v
only references α i v for i ∈ J.
Dependency graph
Decomposition for j = 0: at most 0 of the indices in insert i J
have α k v = true iff α i v = false and at most 0 of the indices in
J have α k v = true.
Dependency graph
Decomposition for j = j' + 1: exactly j' + 1 indices in insert i J
have α k v = true iff either α i v = true and exactly j' indices in
J do, or α i v = false and exactly j' + 1 indices in J do.
Dependency graph
COUNT Poisson-binomial recurrence (succ case). For i ∉ J and
j : ℕ, the probability that exactly j + 1 of the contributors in
insert i J are present factors as (1 − p i) · ρ_J(j+1) + p i · ρ_J(j).
Dependency graph
COUNT Poisson-binomial recurrence (zero case). For i ∉ J, the
probability that exactly 0 contributors in insert i J are present is
(1 − p i) · ρ_J(0).
Dependency graph
SUM (weighted Poisson-binomial) recurrence #
Indicator BoolFunc: evaluates to true at a valuation v iff the
sum of t i over indices i ∈ J with α i v = true equals s.
Instances For
Dependency graph
Support lemma for sumEqIndicator.
Dependency graph
Decomposition when the new contributor's weight exceeds the target: if
t i > s, the sum cannot reach s once i is included, so the only way to
hit s is to leave i out.
Dependency graph
Decomposition when the new contributor's weight fits: if t i ≤ s, the
target sum is reachable either without i (target stays s) or with i
(target becomes s − t i on the remaining contributors).
Dependency graph
SUM weighted Poisson-binomial recurrence (weight fits). For i ∉ J
and t i ≤ s, the probability that the weighted sum over insert i J
equals s factors as (1 − p i) · σ_J(s) + p i · σ_J(s − t i).
Dependency graph
SUM weighted Poisson-binomial recurrence (weight too large). For
i ∉ J and s < t i, the probability collapses to the keep-out branch:
σ_{insert i J}(s) = (1 − p i) · σ_J(s).
Dependency graph
The remaining MIN / MAX comparison operators #
funcProb_maxLeOnNonempty and funcProb_minGeOnNonempty treat MAX ≤ C
and MIN ≥ C. The remaining comparisons all follow from two generic
events: guardedSome r q – “no present contributor satisfies r, and
some present contributor satisfies q” – and its unguarded special case
someOf q. Under the disjoint-supports hypothesis, their probabilities
factor exactly as before, and each remaining comparison is an instance:
MAX < C– guardr i := C ≤ t i, witnessq i := t i < C;MAX = C– guardr i := C < t i, witnessq i := t i = C;MAX ≥ C/MAX > C– unguarded witnessq i := C ≤ t i/C < t i(non-emptiness is implied by the witness);MAX ≠ Con non-empty worlds – the disjoint union ofMAX < CandMAX > C, whose probabilities add;
and dually for MIN.
Pointwise evaluation of 1 - f: Boolean negation.
Dependency graph
“No present contributor satisfies r”: AND of the negated indicators
over the contributors satisfying r.
Equations
- HavingProbability.noneOf α r = ∏ i : ι with r i, (1 - α i)
Instances For
Dependency graph
“Some present contributor satisfies q”: OR of the indicators over the
contributors satisfying q, expressed as 1 - ∏ (1 - α i).
Equations
- HavingProbability.someOf α q = 1 - ∏ i : ι with q i, (1 - α i)
Instances For
Dependency graph
“No present contributor satisfies r, and some present contributor
satisfies q”. Every MIN/MAX aggregate comparison on non-empty random
worlds is an instance of this event.
Equations
Instances For
Dependency graph
Semantic reading of noneOf.
Dependency graph
Semantic reading of someOf.
Dependency graph
Semantic reading of guardedSome.
Dependency graph
Probability of noneOf under independence.
Dependency graph
Probability of someOf under independence.
Dependency graph
Factorization of guardedSome under independence. When the guard
r and the witness q are mutually exclusive, the probability of
guardedSome r q is the product of an “every r-contributor is absent”
term and a “some q-contributor is present” term.
Dependency graph
“Non-empty random world with MAX(t) < C”.
Equations
- HavingProbability.maxLtOnNonempty α t C = HavingProbability.guardedSome α (fun (i : ι) => C ≤ t i) fun (i : ι) => t i < C
Instances For
Dependency graph
“Non-empty random world with MAX(t) = C”.
Equations
- HavingProbability.maxEqOnNonempty α t C = HavingProbability.guardedSome α (fun (i : ι) => C < t i) fun (i : ι) => t i = C
Instances For
Dependency graph
“Random world with MAX(t) > C” (such a world is non-empty).
Equations
- HavingProbability.someAbove α t C = HavingProbability.someOf α fun (i : ι) => C < t i
Instances For
Dependency graph
“Random world with MAX(t) < C” (such a world is non-empty).
Equations
- HavingProbability.someBelow α t C = HavingProbability.someOf α fun (i : ι) => t i < C
Instances For
Dependency graph
“Non-empty random world with MAX(t) ≠ C”: disjoint union of
MAX < C and MAX > C.
Equations
Instances For
Dependency graph
“Non-empty random world with MIN(t) > C”.
Equations
- HavingProbability.minGtOnNonempty α t C = HavingProbability.guardedSome α (fun (i : ι) => t i ≤ C) fun (i : ι) => C < t i
Instances For
Dependency graph
“Non-empty random world with MIN(t) = C”.
Equations
- HavingProbability.minEqOnNonempty α t C = HavingProbability.guardedSome α (fun (i : ι) => t i < C) fun (i : ι) => t i = C
Instances For
Dependency graph
“Non-empty random world with MIN(t) ≠ C”: disjoint union of
MIN < C (i.e., some contributor below C is present) and MIN > C.
Equations
Instances For
Dependency graph
Semantic reading of maxLtOnNonempty.
Dependency graph
Semantic reading of maxEqOnNonempty: no present contributor exceeds
C and some present contributor attains it.
Dependency graph
Semantic reading of minGtOnNonempty.
Dependency graph
Semantic reading of minEqOnNonempty: no present contributor is below
C and some present contributor attains it.
Dependency graph
MAX < C factorization under independence.
Dependency graph
MAX = C factorization under independence.
Dependency graph
MAX > C under independence: the complement of “every contributor
above C is absent”.
Dependency graph
MIN < C (equivalently MAX-dual) under independence: the
complement of “every contributor below C is absent”.
Dependency graph
MIN > C factorization under independence.
Dependency graph
MIN = C factorization under independence.
Dependency graph
The events MAX < C (on non-empty worlds) and MAX > C are
incompatible: their product is the 𝟘 function.
Dependency graph
The events MIN > C (on non-empty worlds) and MIN < C are
incompatible: their product is the 𝟘 function.
Dependency graph
MAX ≠ C on non-empty worlds under independence: probabilities of
the two disjoint cases MAX < C and MAX > C add.
Dependency graph
MIN ≠ C on non-empty worlds under independence: probabilities of
the two disjoint cases MIN > C and MIN < C add.
Dependency graph
CDF assembly for COUNT #
The recurrences countMass_insert_zero / countMass_insert_succ compute
the point masses ρ_J(j). The results below assemble them into the
probability of an arbitrary comparison: the satisfying counts form a
subset of {0, …, |J|} (an interval, for the six comparison operators)
and the corresponding point masses add; the empty-world mass is
∏ (1 - p i); and the upper tail can be computed as a lower tail of the
complemented contributors (Pr[B ≥ C] = Pr[B' ≤ N − C]), which is the
shorter of the two summations when C > N/2.
Pointwise evaluation of a Finset.sum of BoolFuncs: the sum (OR)
evaluates to true iff some summand does.
Dependency graph
Distinct count indicators are incompatible.
Dependency graph
CDF assembly. For any predicate g on counts, the probability that
the number of present contributors satisfies g is the sum of the point
masses ρ_J(j) over the satisfying counts j ∈ {0, …, |J|}. For the six
comparison operators the satisfying set is an interval.
Dependency graph
Empty-world mass. The probability that no contributor of J is
present is ∏_{i ∈ J} (1 - p i).
Dependency graph
Shorter-tail identity, event form. Counting the present
contributors down from C is counting the absent contributors up to
|J| - C: the two indicator functions coincide.
Dependency graph
Shorter-tail identity, probability form: Pr[B ≥ C] = Pr[B' ≤ N − C]
where B counts the present contributors and B' the absent ones. The
right-hand side assembles from the point masses of the complemented
contributors (1 - α i, marginals 1 - p i), which is the shorter
summation when C exceeds N/2.
Dependency graph
The possible-world HAVING provenance under a valuation #
The predicate provenance of an aggregate comparison
(Having.havingProv, over 𝔹[X]) is a ⊕-sum of one disjunct per
non-empty possible world. Under a fixed valuation of the Boolean
variables, exactly one disjunct survives: the one of the realized
world, formed of the occurrences whose annotation is true. Consequently
the predicate provenance evaluates to true exactly when the realized
world is non-empty and satisfies the comparison – the bridge between the
intensional possible-world semantics and probabilistic query evaluation:
the probability of the predicate provenance is the probability that the
realized world is non-empty and satisfies the comparison.
The section culminates in booleanHaving_pqe: for a Boolean query made
of a Boolean combination of aggregate comparisons (HavingPred) applied
on top of a non-aggregation query over a tuple-independent probabilistic
database, the probability that a random world satisfies the query
(booleanHavingProb, via the plain semantics HavingPred.modelsBoolean)
equals the probability of its Boolean provenance
(HavingPred.booleanProv). The non-aggregation operators are handled by
randomWorld_evaluateAnnotated and the comparisons by the
exactly-one-disjunct bridge, composed through the sorted-sublist
identity groupSeq_randomWorld between the plain group sequence of a
random world and the realized subsequence of the annotated group
sequence.
The world realized by a valuation v: the positions of the group
sequence whose annotation evaluates to true under v.
Instances For
Dependency graph
Exactly one world annotation survives: under a valuation v, the
factored world annotation of W is true iff W is the realized world.
Dependency graph
Evaluation of the comparison characteristic χ_op.
Dependency graph
PQE bridge for aggregate comparisons. Under a valuation v, the
predicate provenance of f(t) op c on the group sequence U evaluates to
true iff the realized world is non-empty and its aggregate value satisfies
the comparison. Composed with the probability semantics, the probability
of the predicate provenance is the probability, over random worlds, that a
non-empty realized group satisfies the HAVING comparison.
Dependency graph
Pointwise evaluation of a Multiset.sum of BoolFuncs: the sum (OR)
evaluates to true iff some summand does.
Dependency graph
Selecting the positions whose element satisfies a Boolean predicate yields the filtered list.
Dependency graph
The subsequence selected by the realized world is the sublist of occurrences whose annotation is true under the valuation.
Dependency graph
The realized world of a group is non-empty iff some occurrence of the group survives the valuation.
Dependency graph
The plain group sequence of a random world is the realized
subsequence of the annotated group sequence: both are lists of the same
multiset (the realized occurrences of the group), sorted along ≼.
Dependency graph
A key is realized in the random world iff the realized world of its group sequence is non-empty.
Dependency graph
PQE bridge for Boolean combinations, with polarity. Under a
valuation, the polarity-aware predicate provenance of ψ is true iff the
realized world of the group is non-empty and ψ (negated according to
the polarity) holds classically on the realized occurrence sequence.
Dependency graph
PQE bridge for Boolean combinations of aggregate comparisons.
Under a valuation, the predicate provenance of ψ on the group sequence
U is true iff the realized world is non-empty and ψ holds classically
on the realized occurrence sequence.
Dependency graph
Characteristic property of the Boolean provenance. Under a
valuation, the Boolean provenance of a Boolean HAVING query is true iff
the query holds on the corresponding possible world.
Dependency graph
Probability that a random world of Î satisfies a Boolean HAVING
query: the sum of Pr(v) over the valuations whose possible world does.
Equations
- HavingProbability.booleanHavingProb P q Î is ψ = ∑ v : X → Bool, if HavingPred.modelsBoolean (AnnotatedDatabase.randomWorld v Î) q is ψ then P.valProb v else 0
Instances For
Dependency graph
Probabilistic query evaluation through the HAVING provenance.
For a Boolean query made of a Boolean combination ψ of aggregate
comparisons applied on top of a non-aggregation query q grouped by
is, over a tuple-independent probabilistic database, the probability
that a random world satisfies the query equals the probability of its
Boolean provenance (the ⊕-sum, over the group keys, of the predicate
provenance of ψ). The non-aggregation operators of q are handled by
the correctness of intensional probabilistic query evaluation
(ProbAssignment.theorem_12 machinery via
randomWorld_evaluateAnnotated), and the aggregate comparison by the
exactly-one-disjunct bridge HavingPred.prov_eval_iff.