Explicit finite Bernoulli product weights, probabilities, and errors
DefinitionNarrowDNF_ProductMeasurecombinatoricsnarrow-dnf-authors-importprobabilitystoc-2027
Let be a finite coordinate set. For a real parameter , a bit has weight when it is one and when it is zero. A cube point has product weight
For a real-valued , an event , and Boolean functions , define
When , these are the finite Bernoulli product law and its expectation; the underlying algebraic sums are defined for all real .
The bundle also supplies insertion of a specified bit into the one-coordinate complement and extension of a partial assignment by zeros outside a coordinate predicate. These operations let later proofs state fiber decompositions, marginalization, resampling, and adaptive restrictions directly in the same finite probability model.
Definition code
import Mathlib.Algebra.BigOperators.Ring.Finset
import Mathlib.Algebra.Order.BigOperators.Ring.Finset
import Mathlib.Data.Fintype.BigOperators
import Mathlib.Data.Fintype.Pi
import Mathlib.Data.Real.Basic
import Mathlib.Logic.Equiv.Prod
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.Ring
namespace NarrowDNF.ProductMeasure
end NarrowDNF.ProductMeasure
/-!
# Finite Bernoulli product probability
The probability model is an explicit finite sum of product weights. Algebraic
identities hold for every real parameter; positivity claims state `0 ≤ p ≤ 1`.
No theorem here assumes a probability law or an analytic input without proof.
-/
noncomputable section
open scoped BigOperators
namespace NarrowDNF.ProductMeasure
variable {ι : Type*} [Fintype ι] [DecidableEq ι]
/-- Bernoulli mass of one bit. -/
def bitWeight (p : ℝ) (b : Bool) : ℝ := if b then p else 1 - p
/-- Probability mass of a cube point. -/
def weight (p : ℝ) (x : ι → Bool) : ℝ := ∏ i, bitWeight p (x i)
/-- Expectation under the finite product weights. -/
def expectation (p : ℝ) (F : (ι → Bool) → ℝ) : ℝ :=
∑ x, weight p x * F x
/-- Probability of an arbitrary decidable predicate. -/
def probability (p : ℝ) (P : (ι → Bool) → Prop) [DecidablePred P] : ℝ :=
expectation p (fun x => if P x then 1 else 0)
/-- Disagreement probability of two Boolean functions. -/
def error (p : ℝ) (f g : (ι → Bool) → Bool) : ℝ :=
probability p (fun x => f x ≠ g x)
/-- Insert a bit into the missing coordinate of a smaller cube. -/
def insertBit (i : ι) (b : Bool) (z : {j // j ≠ i} → Bool) : ι → Bool :=
(Equiv.funSplitAt i Bool).symm (b,z)
/-- Extend a partial cube input by zero outside its coordinate predicate. -/
def extendFalse (P : ι → Prop) [DecidablePred P] (z : {i // P i} → Bool) : ι → Bool :=
fun i => if h : P i then z ⟨i,h⟩ else false
end NarrowDNF.ProductMeasure
Source