Documentation

Provenance.HavingProbability

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:

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.

theorem BoolFunc.DependsOn.zero {X : Type} {S : Finset X} :

The constant 0 Boolean function depends on the empty support (equivalently on any support).

Dependency graph
theorem BoolFunc.DependsOn.one {X : Type} {S : Finset X} :

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
theorem BoolFunc.DependsOn.mul {X : Type} [DecidableEq X] {f g : BoolFunc X} {S T : Finset X} (hf : f.DependsOn S) (hg : g.DependsOn T) :
(f * g).DependsOn (S T)

f * g depends on S ∪ T whenever f depends on S and g on T. Multiplication in BoolFunc X is pointwise &&.

Dependency graph
theorem BoolFunc.DependsOn.add {X : Type} [DecidableEq X] {f g : BoolFunc X} {S T : Finset X} (hf : f.DependsOn S) (hg : g.DependsOn T) :
(f + g).DependsOn (S T)

f + g depends on S ∪ T. Addition in BoolFunc X is pointwise ||.

Dependency graph
theorem BoolFunc.DependsOn.one_sub {X : Type} {f : BoolFunc X} {S : Finset X} (hf : f.DependsOn S) :
(1 - f).DependsOn S

1 - f depends on the same support as f. Subtraction here is pointwise (1 v) && !(f v) = !(f v).

Dependency graph
theorem BoolFunc.DependsOn.mono {X : Type} {f : BoolFunc X} {S T : Finset X} (hf : f.DependsOn S) (hST : ST) :

Enlarging the support preserves DependsOn.

Dependency graph
theorem BoolFunc.DependsOn.prod {X : Type} [DecidableEq X] {ι : Type} [DecidableEq ι] {β : ιBoolFunc X} {S : ιFinset X} (h : ∀ (i : ι), (β i).DependsOn (S i)) (J : Finset ι) :
(∏ iJ, β i).DependsOn (J.biUnion S)

Finset.prod of BoolFuncs depends on the biUnion of the per-factor supports.

Dependency graph
theorem ProbAssignment.funcProb_prod_disjoint {X : Type} [Fintype X] [DecidableEq X] (P : ProbAssignment X) {ι : Type} [DecidableEq ι] (β : ιBoolFunc X) (S : ιFinset X) (hdep : ∀ (i : ι), (β i).DependsOn (S i)) (hdisj : Set.univ.Pairwise fun (i j : ι) => Disjoint (S i) (S j)) (J : Finset ι) :
P.funcProb (∏ iJ, β i) = iJ, P.funcProb (β i)

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
theorem ProbAssignment.funcProb_sum_incompatible {X : Type} [Fintype X] [DecidableEq X] (P : ProbAssignment X) {ι : Type} [DecidableEq ι] (β : ιBoolFunc X) (J : Finset ι) (hpair : iJ, jJ, i jβ i * β j = 0) :
P.funcProb (∑ iJ, β i) = iJ, P.funcProb (β i)

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).

theorem HavingProbability.prod_eval_eq_true_iff {X : Type} [Fintype X] [DecidableEq X] {ι : Type} [DecidableEq ι] (J : Finset ι) (β : ιBoolFunc X) (v : XBool) :
(∏ iJ, β i) v = true iJ, β i v = true

Pointwise evaluation of a Finset product of BoolFuncs: the product evaluates to true iff every factor does.

Dependency graph

MAX factorization #

def HavingProbability.maxNoneAbove {X ι : Type} [Fintype ι] (α : ιBoolFunc X) {V : Type} [LinearOrder V] (t : ιV) (C : V) :

“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
Instances For
    Dependency graph
    def HavingProbability.someAtMost {X ι : Type} [Fintype ι] (α : ιBoolFunc X) {V : Type} [LinearOrder V] (t : ιV) (C : V) :

    “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
    Instances For
      Dependency graph
      def HavingProbability.maxLeOnNonempty {X ι : Type} [Fintype ι] (α : ιBoolFunc X) {V : Type} [LinearOrder V] (t : ιV) (C : V) :

      “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
        theorem HavingProbability.maxNoneAbove_eval_iff {X : Type} [Fintype X] [DecidableEq X] {ι : Type} [Fintype ι] [DecidableEq ι] (α : ιBoolFunc X) {V : Type} [LinearOrder V] (t : ιV) (C : V) (v : XBool) :
        maxNoneAbove α t C v = true ∀ (i : ι), α i v = truet i C

        Semantic reading of maxNoneAbove.

        Dependency graph
        theorem HavingProbability.someAtMost_eval_iff {X : Type} [Fintype X] [DecidableEq X] {ι : Type} [Fintype ι] [DecidableEq ι] (α : ιBoolFunc X) {V : Type} [LinearOrder V] (t : ιV) (C : V) (v : XBool) :
        someAtMost α t C v = true ∃ (i : ι), t i C α i v = true

        Semantic reading of someAtMost.

        Dependency graph
        theorem HavingProbability.maxLeOnNonempty_eval_iff {X : Type} [Fintype X] [DecidableEq X] {ι : Type} [Fintype ι] [DecidableEq ι] (α : ιBoolFunc X) {V : Type} [LinearOrder V] (t : ιV) (C : V) (v : XBool) :
        maxLeOnNonempty α t C v = true (∃ (i : ι), α i v = true) ∀ (i : ι), α i v = truet i C

        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
        theorem HavingProbability.funcProb_maxNoneAbove {X : Type} [Fintype X] [DecidableEq X] {ι : Type} [Fintype ι] [DecidableEq ι] (P : ProbAssignment X) (α : ιBoolFunc X) {V : Type} [LinearOrder V] (t : ιV) (S : ιFinset X) (hdep : ∀ (i : ι), (α i).DependsOn (S i)) (hdisj : Set.univ.Pairwise fun (i j : ι) => Disjoint (S i) (S j)) (C : V) :
        P.funcProb (maxNoneAbove α t C) = i : ι with C < t i, (1 - P.funcProb (α i))

        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
        theorem HavingProbability.funcProb_someAtMost {X : Type} [Fintype X] [DecidableEq X] {ι : Type} [Fintype ι] [DecidableEq ι] (P : ProbAssignment X) (α : ιBoolFunc X) {V : Type} [LinearOrder V] (t : ιV) (S : ιFinset X) (hdep : ∀ (i : ι), (α i).DependsOn (S i)) (hdisj : Set.univ.Pairwise fun (i j : ι) => Disjoint (S i) (S j)) (C : V) :
        P.funcProb (someAtMost α t C) = 1 - i : ι with t i C, (1 - P.funcProb (α i))

        Probability of someAtMost: the complement of the product.

        Dependency graph
        theorem HavingProbability.funcProb_maxLeOnNonempty {X : Type} [Fintype X] [DecidableEq X] {ι : Type} [Fintype ι] [DecidableEq ι] (P : ProbAssignment X) (α : ιBoolFunc X) {V : Type} [LinearOrder V] (t : ιV) (S : ιFinset X) (hdep : ∀ (i : ι), (α i).DependsOn (S i)) (hdisj : Set.univ.Pairwise fun (i j : ι) => Disjoint (S i) (S j)) (C : V) :
        P.funcProb (maxLeOnNonempty α t C) = (∏ i : ι with C < t i, (1 - P.funcProb (α i))) * (1 - i : ι with t i C, (1 - P.funcProb (α i)))

        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 #

        def HavingProbability.minNoneBelow {X ι : Type} [Fintype ι] (α : ιBoolFunc X) {V : Type} [LinearOrder V] (t : ιV) (C : V) :

        “Random world contains no contributor with value < C”: the AND over the indicators 1 - α i for all contributors with t i < C.

        Equations
        Instances For
          Dependency graph
          def HavingProbability.someAtLeast {X ι : Type} [Fintype ι] (α : ιBoolFunc X) {V : Type} [LinearOrder V] (t : ιV) (C : V) :

          “Random world contains some contributor with value ≥ C”.

          Equations
          Instances For
            Dependency graph
            def HavingProbability.minGeOnNonempty {X ι : Type} [Fintype ι] (α : ιBoolFunc X) {V : Type} [LinearOrder V] (t : ιV) (C : V) :

            “Random world is nonempty and min_{i ∈ world} t i ≥ C”.

            Equations
            Instances For
              Dependency graph
              theorem HavingProbability.minNoneBelow_eval_iff {X : Type} [Fintype X] [DecidableEq X] {ι : Type} [Fintype ι] [DecidableEq ι] (α : ιBoolFunc X) {V : Type} [LinearOrder V] (t : ιV) (C : V) (v : XBool) :
              minNoneBelow α t C v = true ∀ (i : ι), α i v = trueC t i
              Dependency graph
              theorem HavingProbability.someAtLeast_eval_iff {X : Type} [Fintype X] [DecidableEq X] {ι : Type} [Fintype ι] [DecidableEq ι] (α : ιBoolFunc X) {V : Type} [LinearOrder V] (t : ιV) (C : V) (v : XBool) :
              someAtLeast α t C v = true ∃ (i : ι), C t i α i v = true
              Dependency graph
              theorem HavingProbability.minGeOnNonempty_eval_iff {X : Type} [Fintype X] [DecidableEq X] {ι : Type} [Fintype ι] [DecidableEq ι] (α : ιBoolFunc X) {V : Type} [LinearOrder V] (t : ιV) (C : V) (v : XBool) :
              minGeOnNonempty α t C v = true (∃ (i : ι), α i v = true) ∀ (i : ι), α i v = trueC t i
              Dependency graph
              theorem HavingProbability.funcProb_minNoneBelow {X : Type} [Fintype X] [DecidableEq X] {ι : Type} [Fintype ι] [DecidableEq ι] (P : ProbAssignment X) (α : ιBoolFunc X) {V : Type} [LinearOrder V] (t : ιV) (S : ιFinset X) (hdep : ∀ (i : ι), (α i).DependsOn (S i)) (hdisj : Set.univ.Pairwise fun (i j : ι) => Disjoint (S i) (S j)) (C : V) :
              P.funcProb (minNoneBelow α t C) = i : ι with t i < C, (1 - P.funcProb (α i))
              Dependency graph
              theorem HavingProbability.funcProb_someAtLeast {X : Type} [Fintype X] [DecidableEq X] {ι : Type} [Fintype ι] [DecidableEq ι] (P : ProbAssignment X) (α : ιBoolFunc X) {V : Type} [LinearOrder V] (t : ιV) (S : ιFinset X) (hdep : ∀ (i : ι), (α i).DependsOn (S i)) (hdisj : Set.univ.Pairwise fun (i j : ι) => Disjoint (S i) (S j)) (C : V) :
              P.funcProb (someAtLeast α t C) = 1 - i : ι with C t i, (1 - P.funcProb (α i))
              Dependency graph
              theorem HavingProbability.funcProb_minGeOnNonempty {X : Type} [Fintype X] [DecidableEq X] {ι : Type} [Fintype ι] [DecidableEq ι] (P : ProbAssignment X) (α : ιBoolFunc X) {V : Type} [LinearOrder V] (t : ιV) (S : ιFinset X) (hdep : ∀ (i : ι), (α i).DependsOn (S i)) (hdisj : Set.univ.Pairwise fun (i j : ι) => Disjoint (S i) (S j)) (C : V) :
              P.funcProb (minGeOnNonempty α t C) = (∏ i : ι with t i < C, (1 - P.funcProb (α i))) * (1 - i : ι with C t i, (1 - P.funcProb (α i)))

              MIN factorization under independence.

              Dependency graph

              COUNT (Poisson-binomial) recurrence #

              def HavingProbability.countEqIndicator {X ι : Type} (α : ιBoolFunc X) (J : Finset ι) (j : ) :

              Indicator BoolFunc: evaluates to true at a valuation v iff exactly j of the indices i ∈ J have α i v = true.

              Equations
              Instances For
                Dependency graph
                theorem HavingProbability.countEqIndicator_dependsOn {X : Type} [Fintype X] [DecidableEq X] {ι : Type} [Fintype ι] [DecidableEq ι] (α : ιBoolFunc X) (S : ιFinset X) (hdep : ∀ (i : ι), (α i).DependsOn (S i)) (J : Finset ι) (j : ) :

                countEqIndicator α J j depends on ⋃ i ∈ J, S i: its value at v only references α i v for i ∈ J.

                Dependency graph
                theorem HavingProbability.countEqIndicator_insert_zero {X : Type} [Fintype X] [DecidableEq X] {ι : Type} [Fintype ι] [DecidableEq ι] (α : ιBoolFunc X) {i : ι} {J : Finset ι} (hi : iJ) :
                countEqIndicator α (insert i J) 0 = (1 - α i) * countEqIndicator α J 0

                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
                theorem HavingProbability.countEqIndicator_insert_succ {X : Type} [Fintype X] [DecidableEq X] {ι : Type} [Fintype ι] [DecidableEq ι] (α : ιBoolFunc X) {i : ι} {J : Finset ι} (hi : iJ) (j : ) :
                countEqIndicator α (insert i J) (j + 1) = α i * countEqIndicator α J j + (1 - α i) * countEqIndicator α J (j + 1)

                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
                theorem HavingProbability.countMass_insert_succ {X : Type} [Fintype X] [DecidableEq X] {ι : Type} [Fintype ι] [DecidableEq ι] (P : ProbAssignment X) (α : ιBoolFunc X) (S : ιFinset X) (hdep : ∀ (i : ι), (α i).DependsOn (S i)) (hdisj : Set.univ.Pairwise fun (i j : ι) => Disjoint (S i) (S j)) {i : ι} {J : Finset ι} (hi : iJ) (j : ) :
                P.funcProb (countEqIndicator α (insert i J) (j + 1)) = (1 - P.funcProb (α i)) * P.funcProb (countEqIndicator α J (j + 1)) + P.funcProb (α i) * P.funcProb (countEqIndicator α J j)

                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
                theorem HavingProbability.countMass_insert_zero {X : Type} [Fintype X] [DecidableEq X] {ι : Type} [Fintype ι] [DecidableEq ι] (P : ProbAssignment X) (α : ιBoolFunc X) (S : ιFinset X) (hdep : ∀ (i : ι), (α i).DependsOn (S i)) (hdisj : Set.univ.Pairwise fun (i j : ι) => Disjoint (S i) (S j)) {i : ι} {J : Finset ι} (hi : iJ) :
                P.funcProb (countEqIndicator α (insert i J) 0) = (1 - P.funcProb (α i)) * P.funcProb (countEqIndicator α J 0)

                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 #

                def HavingProbability.sumEqIndicator {X ι : Type} (α : ιBoolFunc X) (t : ι) (J : Finset ι) (s : ) :

                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.

                Equations
                Instances For
                  Dependency graph
                  theorem HavingProbability.sumEqIndicator_dependsOn {X : Type} [Fintype X] [DecidableEq X] {ι : Type} [Fintype ι] [DecidableEq ι] (α : ιBoolFunc X) (t : ι) (S : ιFinset X) (hdep : ∀ (i : ι), (α i).DependsOn (S i)) (J : Finset ι) (s : ) :

                  Support lemma for sumEqIndicator.

                  Dependency graph
                  theorem HavingProbability.sumEqIndicator_insert_of_lt {X : Type} [Fintype X] [DecidableEq X] {ι : Type} [Fintype ι] [DecidableEq ι] (α : ιBoolFunc X) (t : ι) {i : ι} {J : Finset ι} (hi : iJ) {s : } (hs : s < t i) :
                  sumEqIndicator α t (insert i J) s = (1 - α i) * sumEqIndicator α t J s

                  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
                  theorem HavingProbability.sumEqIndicator_insert_of_le {X : Type} [Fintype X] [DecidableEq X] {ι : Type} [Fintype ι] [DecidableEq ι] (α : ιBoolFunc X) (t : ι) {i : ι} {J : Finset ι} (hi : iJ) {s : } (hs : t i s) :
                  sumEqIndicator α t (insert i J) s = α i * sumEqIndicator α t J (s - t i) + (1 - α i) * sumEqIndicator α t J s

                  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
                  theorem HavingProbability.sumMass_insert_of_le {X : Type} [Fintype X] [DecidableEq X] {ι : Type} [Fintype ι] [DecidableEq ι] (P : ProbAssignment X) (α : ιBoolFunc X) (t : ι) (S : ιFinset X) (hdep : ∀ (i : ι), (α i).DependsOn (S i)) (hdisj : Set.univ.Pairwise fun (i j : ι) => Disjoint (S i) (S j)) {i : ι} {J : Finset ι} (hi : iJ) {s : } (hs : t i s) :
                  P.funcProb (sumEqIndicator α t (insert i J) s) = (1 - P.funcProb (α i)) * P.funcProb (sumEqIndicator α t J s) + P.funcProb (α i) * P.funcProb (sumEqIndicator α t J (s - t i))

                  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
                  theorem HavingProbability.sumMass_insert_of_lt {X : Type} [Fintype X] [DecidableEq X] {ι : Type} [Fintype ι] [DecidableEq ι] (P : ProbAssignment X) (α : ιBoolFunc X) (t : ι) (S : ιFinset X) (hdep : ∀ (i : ι), (α i).DependsOn (S i)) (hdisj : Set.univ.Pairwise fun (i j : ι) => Disjoint (S i) (S j)) {i : ι} {J : Finset ι} (hi : iJ) {s : } (hs : s < t i) :
                  P.funcProb (sumEqIndicator α t (insert i J) s) = (1 - P.funcProb (α i)) * P.funcProb (sumEqIndicator α t J s)

                  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:

                  and dually for MIN.

                  theorem HavingProbability.one_sub_eval {X : Type} [Fintype X] [DecidableEq X] (f : BoolFunc X) (v : XBool) :
                  (1 - f) v = !f v

                  Pointwise evaluation of 1 - f: Boolean negation.

                  Dependency graph
                  def HavingProbability.noneOf {X ι : Type} [Fintype ι] (α : ιBoolFunc X) (r : ιProp) [DecidablePred r] :

                  “No present contributor satisfies r”: AND of the negated indicators over the contributors satisfying r.

                  Equations
                  Instances For
                    Dependency graph
                    def HavingProbability.someOf {X ι : Type} [Fintype ι] (α : ιBoolFunc X) (q : ιProp) [DecidablePred q] :

                    “Some present contributor satisfies q”: OR of the indicators over the contributors satisfying q, expressed as 1 - ∏ (1 - α i).

                    Equations
                    Instances For
                      Dependency graph
                      def HavingProbability.guardedSome {X ι : Type} [Fintype ι] (α : ιBoolFunc X) (r q : ιProp) [DecidablePred r] [DecidablePred q] :

                      “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
                        theorem HavingProbability.noneOf_eval_iff {X : Type} [Fintype X] [DecidableEq X] {ι : Type} [Fintype ι] [DecidableEq ι] (α : ιBoolFunc X) (r : ιProp) [DecidablePred r] (v : XBool) :
                        noneOf α r v = true ∀ (i : ι), r iα i v = false

                        Semantic reading of noneOf.

                        Dependency graph
                        theorem HavingProbability.someOf_eval_iff {X : Type} [Fintype X] [DecidableEq X] {ι : Type} [Fintype ι] [DecidableEq ι] (α : ιBoolFunc X) (q : ιProp) [DecidablePred q] (v : XBool) :
                        someOf α q v = true ∃ (i : ι), q i α i v = true

                        Semantic reading of someOf.

                        Dependency graph
                        theorem HavingProbability.guardedSome_eval_iff {X : Type} [Fintype X] [DecidableEq X] {ι : Type} [Fintype ι] [DecidableEq ι] (α : ιBoolFunc X) (r q : ιProp) [DecidablePred r] [DecidablePred q] (v : XBool) :
                        guardedSome α r q v = true (∀ (i : ι), r iα i v = false) ∃ (i : ι), q i α i v = true

                        Semantic reading of guardedSome.

                        Dependency graph
                        theorem HavingProbability.funcProb_noneOf {X : Type} [Fintype X] [DecidableEq X] {ι : Type} [Fintype ι] [DecidableEq ι] (P : ProbAssignment X) (α : ιBoolFunc X) (r : ιProp) [DecidablePred r] (S : ιFinset X) (hdep : ∀ (i : ι), (α i).DependsOn (S i)) (hdisj : Set.univ.Pairwise fun (i j : ι) => Disjoint (S i) (S j)) :
                        P.funcProb (noneOf α r) = i : ι with r i, (1 - P.funcProb (α i))

                        Probability of noneOf under independence.

                        Dependency graph
                        theorem HavingProbability.funcProb_someOf {X : Type} [Fintype X] [DecidableEq X] {ι : Type} [Fintype ι] [DecidableEq ι] (P : ProbAssignment X) (α : ιBoolFunc X) (q : ιProp) [DecidablePred q] (S : ιFinset X) (hdep : ∀ (i : ι), (α i).DependsOn (S i)) (hdisj : Set.univ.Pairwise fun (i j : ι) => Disjoint (S i) (S j)) :
                        P.funcProb (someOf α q) = 1 - i : ι with q i, (1 - P.funcProb (α i))

                        Probability of someOf under independence.

                        Dependency graph
                        theorem HavingProbability.funcProb_guardedSome {X : Type} [Fintype X] [DecidableEq X] {ι : Type} [Fintype ι] [DecidableEq ι] (P : ProbAssignment X) (α : ιBoolFunc X) (r q : ιProp) [DecidablePred r] [DecidablePred q] (S : ιFinset X) (hdep : ∀ (i : ι), (α i).DependsOn (S i)) (hdisj : Set.univ.Pairwise fun (i j : ι) => Disjoint (S i) (S j)) (hrq : ∀ (i : ι), r iq iFalse) :
                        P.funcProb (guardedSome α r q) = (∏ i : ι with r i, (1 - P.funcProb (α i))) * (1 - i : ι with q i, (1 - P.funcProb (α i)))

                        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
                        def HavingProbability.maxLtOnNonempty {X ι : Type} [Fintype ι] (α : ιBoolFunc X) {V : Type} [LinearOrder V] (t : ιV) (C : V) :

                        “Non-empty random world with MAX(t) < C”.

                        Equations
                        Instances For
                          Dependency graph
                          def HavingProbability.maxEqOnNonempty {X ι : Type} [Fintype ι] (α : ιBoolFunc X) {V : Type} [LinearOrder V] (t : ιV) (C : V) :

                          “Non-empty random world with MAX(t) = C”.

                          Equations
                          Instances For
                            Dependency graph
                            def HavingProbability.someAbove {X ι : Type} [Fintype ι] (α : ιBoolFunc X) {V : Type} [LinearOrder V] (t : ιV) (C : V) :

                            “Random world with MAX(t) > C” (such a world is non-empty).

                            Equations
                            Instances For
                              Dependency graph
                              def HavingProbability.someBelow {X ι : Type} [Fintype ι] (α : ιBoolFunc X) {V : Type} [LinearOrder V] (t : ιV) (C : V) :

                              “Random world with MAX(t) < C” (such a world is non-empty).

                              Equations
                              Instances For
                                Dependency graph
                                def HavingProbability.maxNeOnNonempty {X ι : Type} [Fintype ι] (α : ιBoolFunc X) {V : Type} [LinearOrder V] (t : ιV) (C : V) :

                                “Non-empty random world with MAX(t) ≠ C”: disjoint union of MAX < C and MAX > C.

                                Equations
                                Instances For
                                  Dependency graph
                                  def HavingProbability.minGtOnNonempty {X ι : Type} [Fintype ι] (α : ιBoolFunc X) {V : Type} [LinearOrder V] (t : ιV) (C : V) :

                                  “Non-empty random world with MIN(t) > C”.

                                  Equations
                                  Instances For
                                    Dependency graph
                                    def HavingProbability.minEqOnNonempty {X ι : Type} [Fintype ι] (α : ιBoolFunc X) {V : Type} [LinearOrder V] (t : ιV) (C : V) :

                                    “Non-empty random world with MIN(t) = C”.

                                    Equations
                                    Instances For
                                      Dependency graph
                                      def HavingProbability.minNeOnNonempty {X ι : Type} [Fintype ι] (α : ιBoolFunc X) {V : Type} [LinearOrder V] (t : ιV) (C : V) :

                                      “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
                                        theorem HavingProbability.maxLtOnNonempty_eval_iff {X : Type} [Fintype X] [DecidableEq X] {ι : Type} [Fintype ι] [DecidableEq ι] (α : ιBoolFunc X) {V : Type} [LinearOrder V] (t : ιV) (C : V) (v : XBool) :
                                        maxLtOnNonempty α t C v = true (∃ (i : ι), α i v = true) ∀ (i : ι), α i v = truet i < C

                                        Semantic reading of maxLtOnNonempty.

                                        Dependency graph
                                        theorem HavingProbability.maxEqOnNonempty_eval_iff {X : Type} [Fintype X] [DecidableEq X] {ι : Type} [Fintype ι] [DecidableEq ι] (α : ιBoolFunc X) {V : Type} [LinearOrder V] (t : ιV) (C : V) (v : XBool) :
                                        maxEqOnNonempty α t C v = true (∀ (i : ι), α i v = truet i C) ∃ (i : ι), t i = C α i v = true

                                        Semantic reading of maxEqOnNonempty: no present contributor exceeds C and some present contributor attains it.

                                        Dependency graph
                                        theorem HavingProbability.minGtOnNonempty_eval_iff {X : Type} [Fintype X] [DecidableEq X] {ι : Type} [Fintype ι] [DecidableEq ι] (α : ιBoolFunc X) {V : Type} [LinearOrder V] (t : ιV) (C : V) (v : XBool) :
                                        minGtOnNonempty α t C v = true (∃ (i : ι), α i v = true) ∀ (i : ι), α i v = trueC < t i

                                        Semantic reading of minGtOnNonempty.

                                        Dependency graph
                                        theorem HavingProbability.minEqOnNonempty_eval_iff {X : Type} [Fintype X] [DecidableEq X] {ι : Type} [Fintype ι] [DecidableEq ι] (α : ιBoolFunc X) {V : Type} [LinearOrder V] (t : ιV) (C : V) (v : XBool) :
                                        minEqOnNonempty α t C v = true (∀ (i : ι), α i v = trueC t i) ∃ (i : ι), t i = C α i v = true

                                        Semantic reading of minEqOnNonempty: no present contributor is below C and some present contributor attains it.

                                        Dependency graph
                                        theorem HavingProbability.funcProb_maxLtOnNonempty {X : Type} [Fintype X] [DecidableEq X] {ι : Type} [Fintype ι] [DecidableEq ι] (P : ProbAssignment X) (α : ιBoolFunc X) {V : Type} [LinearOrder V] (t : ιV) (S : ιFinset X) (hdep : ∀ (i : ι), (α i).DependsOn (S i)) (hdisj : Set.univ.Pairwise fun (i j : ι) => Disjoint (S i) (S j)) (C : V) :
                                        P.funcProb (maxLtOnNonempty α t C) = (∏ i : ι with C t i, (1 - P.funcProb (α i))) * (1 - i : ι with t i < C, (1 - P.funcProb (α i)))

                                        MAX < C factorization under independence.

                                        Dependency graph
                                        theorem HavingProbability.funcProb_maxEqOnNonempty {X : Type} [Fintype X] [DecidableEq X] {ι : Type} [Fintype ι] [DecidableEq ι] (P : ProbAssignment X) (α : ιBoolFunc X) {V : Type} [LinearOrder V] (t : ιV) (S : ιFinset X) (hdep : ∀ (i : ι), (α i).DependsOn (S i)) (hdisj : Set.univ.Pairwise fun (i j : ι) => Disjoint (S i) (S j)) (C : V) :
                                        P.funcProb (maxEqOnNonempty α t C) = (∏ i : ι with C < t i, (1 - P.funcProb (α i))) * (1 - i : ι with t i = C, (1 - P.funcProb (α i)))

                                        MAX = C factorization under independence.

                                        Dependency graph
                                        theorem HavingProbability.funcProb_someAbove {X : Type} [Fintype X] [DecidableEq X] {ι : Type} [Fintype ι] [DecidableEq ι] (P : ProbAssignment X) (α : ιBoolFunc X) {V : Type} [LinearOrder V] (t : ιV) (S : ιFinset X) (hdep : ∀ (i : ι), (α i).DependsOn (S i)) (hdisj : Set.univ.Pairwise fun (i j : ι) => Disjoint (S i) (S j)) (C : V) :
                                        P.funcProb (someAbove α t C) = 1 - i : ι with C < t i, (1 - P.funcProb (α i))

                                        MAX > C under independence: the complement of “every contributor above C is absent”.

                                        Dependency graph
                                        theorem HavingProbability.funcProb_someBelow {X : Type} [Fintype X] [DecidableEq X] {ι : Type} [Fintype ι] [DecidableEq ι] (P : ProbAssignment X) (α : ιBoolFunc X) {V : Type} [LinearOrder V] (t : ιV) (S : ιFinset X) (hdep : ∀ (i : ι), (α i).DependsOn (S i)) (hdisj : Set.univ.Pairwise fun (i j : ι) => Disjoint (S i) (S j)) (C : V) :
                                        P.funcProb (someBelow α t C) = 1 - i : ι with t i < C, (1 - P.funcProb (α i))

                                        MIN < C (equivalently MAX-dual) under independence: the complement of “every contributor below C is absent”.

                                        Dependency graph
                                        theorem HavingProbability.funcProb_minGtOnNonempty {X : Type} [Fintype X] [DecidableEq X] {ι : Type} [Fintype ι] [DecidableEq ι] (P : ProbAssignment X) (α : ιBoolFunc X) {V : Type} [LinearOrder V] (t : ιV) (S : ιFinset X) (hdep : ∀ (i : ι), (α i).DependsOn (S i)) (hdisj : Set.univ.Pairwise fun (i j : ι) => Disjoint (S i) (S j)) (C : V) :
                                        P.funcProb (minGtOnNonempty α t C) = (∏ i : ι with t i C, (1 - P.funcProb (α i))) * (1 - i : ι with C < t i, (1 - P.funcProb (α i)))

                                        MIN > C factorization under independence.

                                        Dependency graph
                                        theorem HavingProbability.funcProb_minEqOnNonempty {X : Type} [Fintype X] [DecidableEq X] {ι : Type} [Fintype ι] [DecidableEq ι] (P : ProbAssignment X) (α : ιBoolFunc X) {V : Type} [LinearOrder V] (t : ιV) (S : ιFinset X) (hdep : ∀ (i : ι), (α i).DependsOn (S i)) (hdisj : Set.univ.Pairwise fun (i j : ι) => Disjoint (S i) (S j)) (C : V) :
                                        P.funcProb (minEqOnNonempty α t C) = (∏ i : ι with t i < C, (1 - P.funcProb (α i))) * (1 - i : ι with t i = C, (1 - P.funcProb (α i)))

                                        MIN = C factorization under independence.

                                        Dependency graph
                                        theorem HavingProbability.maxLt_mul_someAbove_eq_zero {X : Type} [Fintype X] [DecidableEq X] {ι : Type} [Fintype ι] [DecidableEq ι] (α : ιBoolFunc X) {V : Type} [LinearOrder V] (t : ιV) (C : V) :
                                        maxLtOnNonempty α t C * someAbove α t C = 0

                                        The events MAX < C (on non-empty worlds) and MAX > C are incompatible: their product is the 𝟘 function.

                                        Dependency graph
                                        theorem HavingProbability.minGt_mul_someBelow_eq_zero {X : Type} [Fintype X] [DecidableEq X] {ι : Type} [Fintype ι] [DecidableEq ι] (α : ιBoolFunc X) {V : Type} [LinearOrder V] (t : ιV) (C : V) :
                                        minGtOnNonempty α t C * someBelow α t C = 0

                                        The events MIN > C (on non-empty worlds) and MIN < C are incompatible: their product is the 𝟘 function.

                                        Dependency graph
                                        theorem HavingProbability.funcProb_maxNeOnNonempty {X : Type} [Fintype X] [DecidableEq X] {ι : Type} [Fintype ι] [DecidableEq ι] (P : ProbAssignment X) (α : ιBoolFunc X) {V : Type} [LinearOrder V] (t : ιV) (S : ιFinset X) (hdep : ∀ (i : ι), (α i).DependsOn (S i)) (hdisj : Set.univ.Pairwise fun (i j : ι) => Disjoint (S i) (S j)) (C : V) :

                                        MAX ≠ C on non-empty worlds under independence: probabilities of the two disjoint cases MAX < C and MAX > C add.

                                        Dependency graph
                                        theorem HavingProbability.funcProb_minNeOnNonempty {X : Type} [Fintype X] [DecidableEq X] {ι : Type} [Fintype ι] [DecidableEq ι] (P : ProbAssignment X) (α : ιBoolFunc X) {V : Type} [LinearOrder V] (t : ιV) (S : ιFinset X) (hdep : ∀ (i : ι), (α i).DependsOn (S i)) (hdisj : Set.univ.Pairwise fun (i j : ι) => Disjoint (S i) (S j)) (C : V) :

                                        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.

                                        theorem HavingProbability.sum_eval_eq_true_iff {X : Type} [Fintype X] [DecidableEq X] {ι' : Type} [DecidableEq ι'] (J : Finset ι') (β : ι'BoolFunc X) (v : XBool) :
                                        (∑ iJ, β i) v = true iJ, β i v = true

                                        Pointwise evaluation of a Finset.sum of BoolFuncs: the sum (OR) evaluates to true iff some summand does.

                                        Dependency graph
                                        theorem HavingProbability.countEqIndicator_mul_eq_zero {X : Type} [Fintype X] [DecidableEq X] {ι : Type} [Fintype ι] [DecidableEq ι] (α : ιBoolFunc X) (J : Finset ι) {j j' : } (h : j j') :

                                        Distinct count indicators are incompatible.

                                        Dependency graph
                                        theorem HavingProbability.funcProb_count_filter {X : Type} [Fintype X] [DecidableEq X] {ι : Type} [Fintype ι] [DecidableEq ι] (P : ProbAssignment X) (α : ιBoolFunc X) (J : Finset ι) (g : Prop) [DecidablePred g] :
                                        (P.funcProb fun (v : XBool) => decide (g {iJ | α i v = true}.card)) = jFinset.range (J.card + 1) with g j, P.funcProb (countEqIndicator α J j)

                                        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
                                        theorem HavingProbability.countMass_zero {X : Type} [Fintype X] [DecidableEq X] {ι : Type} [Fintype ι] [DecidableEq ι] (P : ProbAssignment X) (α : ιBoolFunc X) (S : ιFinset X) (hdep : ∀ (i : ι), (α i).DependsOn (S i)) (hdisj : Set.univ.Pairwise fun (i j : ι) => Disjoint (S i) (S j)) (J : Finset ι) :
                                        P.funcProb (countEqIndicator α J 0) = iJ, (1 - P.funcProb (α i))

                                        Empty-world mass. The probability that no contributor of J is present is ∏_{i ∈ J} (1 - p i).

                                        Dependency graph
                                        theorem HavingProbability.count_ge_eq_absent_le {X : Type} [Fintype X] [DecidableEq X] {ι : Type} [Fintype ι] [DecidableEq ι] (α : ιBoolFunc X) (J : Finset ι) {C : } (hC : C J.card) :
                                        (fun (v : XBool) => decide (C {iJ | α i v = true}.card)) = fun (v : XBool) => decide ({iJ | (1 - α i) v = true}.card J.card - C)

                                        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
                                        theorem HavingProbability.funcProb_count_ge_eq_absent_le {X : Type} [Fintype X] [DecidableEq X] {ι : Type} [Fintype ι] [DecidableEq ι] (P : ProbAssignment X) (α : ιBoolFunc X) (J : Finset ι) {C : } (hC : C J.card) :
                                        (P.funcProb fun (v : XBool) => decide (C {iJ | α i v = true}.card)) = P.funcProb fun (v : XBool) => decide ({iJ | (1 - α i) v = true}.card J.card - C)

                                        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.

                                        def HavingProbability.realizedWorld {X T : Type} {m : } (U : List (AnnotatedTuple T (BoolFunc X) m)) (v : XBool) :

                                        The world realized by a valuation v: the positions of the group sequence whose annotation evaluates to true under v.

                                        Equations
                                        Instances For
                                          Dependency graph
                                          theorem HavingProbability.worldAnn_eval_iff {X : Type} [Fintype X] [DecidableEq X] {N : } (α : Fin NBoolFunc X) (W : Finset (Fin N)) (v : XBool) :
                                          Having.worldAnn α W v = true W = {i : Fin N | α i v = true}

                                          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
                                          theorem HavingProbability.chi_eval_iff {X : Type} [Fintype X] [DecidableEq X] {T : Type} [ValueType T] (op : CompOp) (a c : T) (v : XBool) :
                                          Having.chi op a c v = true op.eval a c

                                          Evaluation of the comparison characteristic χ_op.

                                          Dependency graph
                                          theorem HavingProbability.havingProv_eval_iff {X : Type} [Fintype X] [DecidableEq X] {T : Type} [ValueType T] {m : } (U : List (AnnotatedTuple T (BoolFunc X) m)) (t : Term T m) (f : SeqAggFunc T) (op : CompOp) (c : T) (v : XBool) :

                                          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
                                          theorem HavingProbability.multiset_sum_eval_eq_true_iff {X : Type} [Fintype X] [DecidableEq X] (s : Multiset (BoolFunc X)) (v : XBool) :
                                          s.sum v = true fs, f v = true

                                          Pointwise evaluation of a Multiset.sum of BoolFuncs: the sum (OR) evaluates to true iff some summand does.

                                          Dependency graph
                                          theorem HavingProbability.seqOf_filter_positions {β : Type} (P : βBool) (U : List β) :
                                          Having.seqOf U {i : Fin U.length | P (U.get i) = true} = List.filter P U

                                          Selecting the positions whose element satisfies a Boolean predicate yields the filtered list.

                                          Dependency graph
                                          theorem HavingProbability.seqOf_realizedWorld {X : Type} [Fintype X] [DecidableEq X] {T : Type} [ValueType T] {m : } (U : List (AnnotatedTuple T (BoolFunc X) m)) (v : XBool) :
                                          Having.seqOf U (realizedWorld U v) = List.filter (fun (p : AnnotatedTuple T (BoolFunc X) m) => p.2 v) U

                                          The subsequence selected by the realized world is the sublist of occurrences whose annotation is true under the valuation.

                                          Dependency graph
                                          theorem HavingProbability.realizedWorld_nonempty_iff {X : Type} [Fintype X] [DecidableEq X] {T : Type} [ValueType T] {m : } (U : List (AnnotatedTuple T (BoolFunc X) m)) (v : XBool) :
                                          (realizedWorld U v).Nonempty pU, p.2 v = true

                                          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
                                          theorem HavingProbability.randomWorld_key_mem_iff {X : Type} [Fintype X] [DecidableEq X] {T : Type} [ValueType T] {m n₁ : } [HasAltLinearOrder (BoolFunc X)] (is : Tuple (Fin m) n₁) (r : AnnotatedRelation T (BoolFunc X) m) (g : Tuple T n₁) (v : XBool) :
                                          g Multiset.map (fun (u : Tuple T m) (k : Fin n₁) => u (is k)) (randomWorld v r) (realizedWorld (Having.havingGroup is r g) v).Nonempty

                                          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
                                          theorem HavingProbability.HavingPred.prov_eval_iff {X : Type} [Fintype X] [DecidableEq X] {T : Type} [ValueType T] {m n₁ : } (U : List (AnnotatedTuple T (BoolFunc X) m)) (g : Tuple T n₁) (v : XBool) (ψ : HavingPred T m n₁) :

                                          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
                                          theorem HavingProbability.HavingPred.booleanProv_eval_iff {X : Type} [Fintype X] [DecidableEq X] {T : Type} [ValueType T] [HasAltLinearOrder (BoolFunc X)] {m n₁ : } (q : Query T m) (hq : q.source) (Î : AnnotatedDatabase T (BoolFunc X)) (is : Tuple (Fin m) n₁) (ψ : HavingPred T m n₁) (v : XBool) :

                                          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
                                          noncomputable def HavingProbability.booleanHavingProb {X : Type} [Fintype X] [DecidableEq X] (P : ProbAssignment X) {T : Type} [ValueType T] {m n₁ : } (q : Query T m) (Î : AnnotatedDatabase T (BoolFunc X)) (is : Tuple (Fin m) n₁) (ψ : HavingPred T m n₁) :

                                          Probability that a random world of Î satisfies a Boolean HAVING query: the sum of Pr(v) over the valuations whose possible world does.

                                          Equations
                                          Instances For
                                            Dependency graph
                                            theorem HavingProbability.booleanHaving_pqe {X : Type} [Fintype X] [DecidableEq X] (P : ProbAssignment X) {T : Type} [ValueType T] [HasAltLinearOrder (BoolFunc X)] {m n₁ : } (q : Query T m) (hq : q.source) (Î : AnnotatedDatabase T (BoolFunc X)) (is : Tuple (Fin m) n₁) (ψ : HavingPred T m n₁) :
                                            booleanHavingProb P q Î is ψ = P.funcProb (HavingPred.booleanProv q hq Î is ψ)

                                            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.

                                            Dependency graph