Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

The weighted Pythagorean identity for finite conditional expectation

Proved
NarrowDNF.ConditionalExpectation.squaredError_decomposition

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

combinatoricsnarrow-dnf-authors-importprobabilitystoc-2027

Let A,BA,BA,B be finite, ϕ:A→B\phi:A\to Bϕ:A→B, and let w(a)>0w(a)>0w(a)>0 for every a∈Aa\in Aa∈A. For F:A→RF:A\to\mathbb RF:A→R, let M(a)M(a)M(a) be the www-weighted mean of FFF on the fiber containing aaa. Define ∥H∥w2=∑aw(a)H(a)2\|H\|_w^2=\sum_a w(a)H(a)^2∥H∥w2​=∑a​w(a)H(a)2. For every readout G:B→RG:B\to\mathbb RG:B→R,

∥F−G∘ϕ∥w2=∥F−M∥w2+∥M−G∘ϕ∥w2.\|F-G\circ\phi\|_w^2=\|F-M\|_w^2+\|M-G\circ\phi\|_w^2.∥F−G∘ϕ∥w2​=∥F−M∥w2​+∥M−G∘ϕ∥w2​.

No normalization of the positive weights is required. This decomposition exhibits conditional expectation as the least-squares projection onto functions that are constant on each partition atom.

Preamble
import Mathlib.Algebra.BigOperators.Ring.Finset
import Mathlib.Algebra.Order.BigOperators.Ring.Finset
import Mathlib.Data.Bool.Basic
import Mathlib.Data.Finset.Lattice.Fold
import Mathlib.Data.Fintype.BigOperators
import Mathlib.Data.Fintype.Pi
import Mathlib.Data.Real.Basic
import Mathlib.Logic.Equiv.Prod
import Mathlib.Order.Monotone.Basic
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.Ring
import Definitions.Def_NarrowDNF_ConditionalExpectation
import Theorems.Thm_NarrowDNF_ConditionalExpectation_residual_orthogonal

namespace NarrowDNF.ConditionalExpectation
end NarrowDNF.ConditionalExpectation
noncomputable section
open scoped BigOperators
open NarrowDNF
open NarrowDNF.ConditionalExpectation
variable {α β : Type*} [Fintype α] [Fintype β] [DecidableEq β]
Formal statement
theorem NarrowDNF.ConditionalExpectation.squaredError_decomposition (φ : α → β) (w F : α → ℝ)
    (hw : ∀ a, 0 < w a) (G : β → ℝ) :
    squaredError w F (fun a => G (φ a)) =
      squaredError w F (conditional φ w F) +
        squaredError w (conditional φ w F) (fun a => G (φ a)) := by sorry
Source
https://github.com/liuchliuch/narrow-dnf-lean/blob/eecadd6a5ea0a331d6cf9fd5cb39fc6ec854b372/NarrowDNF/ConditionalExpectation.lean#L118-L135

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