Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Explicit finite Bernoulli product weights, probabilities, and errors

Definition
NarrowDNF_ProductMeasure

by chenghua.liu · Nov 13, 2026 · Mathlib 0df444a (Lean v4.33.1)

combinatoricsnarrow-dnf-authors-importprobabilitystoc-2027

Let ι\iotaι be a finite coordinate set. For a real parameter ppp, a bit has weight ppp when it is one and 1−p1-p1−p when it is zero. A cube point x∈{0,1}ιx\in\{0,1\}^{\iota}x∈{0,1}ι has product weight

wp(x)=∏i∈ι(p if xi=1, else 1−p).w_p(x)=\prod_{i\in\iota}\bigl(p\ \text{if }x_i=1,\ \text{else }1-p\bigr).wp​(x)=i∈ι∏​(p if xi​=1, else 1−p).

For a real-valued FFF, an event EEE, and Boolean functions f,gf,gf,g, define

EpF=∑xwp(x)F(x),Pr⁡p(E)=Ep1E,err⁡p(f,g)=Pr⁡p[f≠g].\mathbb E_pF=\sum_x w_p(x)F(x),\qquad\Pr_p(E)=\mathbb E_p\mathbf1_E,\qquad\operatorname{err}_p(f,g)=\Pr_p[f\ne g].Ep​F=x∑​wp​(x)F(x),pPr​(E)=Ep​1E​,errp​(f,g)=pPr​[f=g].

When 0≤p≤10\le p\le10≤p≤1, these are the finite Bernoulli product law and its expectation; the underlying algebraic sums are defined for all real ppp.

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
https://github.com/liuchliuch/narrow-dnf-lean/blob/eecadd6a5ea0a331d6cf9fd5cb39fc6ec854b372/NarrowDNF/ProductMeasure.lean#L34-L36 https://github.com/liuchliuch/narrow-dnf-lean/blob/eecadd6a5ea0a331d6cf9fd5cb39fc6ec854b372/NarrowDNF/ProductMeasure.lean#L38-L40 https://github.com/liuchliuch/narrow-dnf-lean/blob/eecadd6a5ea0a331d6cf9fd5cb39fc6ec854b372/NarrowDNF/ProductMeasure.lean#L299-L301 https://github.com/liuchliuch/narrow-dnf-lean/blob/eecadd6a5ea0a331d6cf9fd5cb39fc6ec854b372/NarrowDNF/ProductMeasure.lean#L42-L44 https://github.com/liuchliuch/narrow-dnf-lean/blob/eecadd6a5ea0a331d6cf9fd5cb39fc6ec854b372/NarrowDNF/ProductMeasure.lean#L146-L148 https://github.com/liuchliuch/narrow-dnf-lean/blob/eecadd6a5ea0a331d6cf9fd5cb39fc6ec854b372/NarrowDNF/ProductMeasure.lean#L25-L26 https://github.com/liuchliuch/narrow-dnf-lean/blob/eecadd6a5ea0a331d6cf9fd5cb39fc6ec854b372/NarrowDNF/ProductMeasure.lean#L31-L32

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paperProve2Me Team
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me