Stat.Nonparametric.Moment­Problems.Residual­Quadratic

Residual-quadratic moment problems: moment-coordinate formulas, measure-level L² projection residuals, and projection residual orthogonality identities.

Moment­Algebra 15 core · 7 supporting This is the measure-free algebra layer for the MomentProblems folder. ★ residualQuad_optimalCoeff★ momentResidual_le_envelope

Moment-coordinate algebra for residual quadratic moment problems

This is the measure-free algebra layer for the MomentProblems folder. It works only with raw moments m₁, m₂, m₃, m₄, and proves the identities used by the measure-level L² projection and bounded-outcome envelope files.

The central residual is the squared L²(μ)-distance of to span{1, y}, i.e. the residual variance of regressing on 1 and y:

r(μ) = min_{b₀, b₁} ∫ (y² − b₀ − b₁ y)² dμ.

For any law with moments m₁, m₂, m₃, m₄ (and m₀ = 1) this residual has the closed form momentResidual m₁ m₂ m₃ m₄, the ratio of the two leading Hankel determinants. This file proves, purely at the level of moments (no measure theory):

* residualQuad_ge_momentResidual / residualQuad_optimalCoeffmomentResidual is exactly the minimum over (b₀, b₁) of the regression objective, whenever the design is nondegenerate (m₁² < m₂, i.e. positive variance). This is the reusable residual-variance formula. * extremalResidual_eq_envelope — the extremal three-point law on {0, xᵥ, 1} with second moment q, encoded through its moments M₁ = t, M₂ = q, M₃, M₄ (single fractions of the free support parameter t and q), has residual exactly the closed form momentEnvelope t q = ((t − q)(q − t²)) / (4 t (1 − t)), for every admissible t. * momentEnvelope_hasDerivAt / momentEnvelope_stationary_of_quartic — as a function of the support parameter t, the family residual momentEnvelope t q has derivative envelopeQuartic t q / (4 t² (t − 1)²), so its stationary points are exactly the roots of the quartic t⁴ − 2t³ + 2q t² − 2q² t + q² = 0. The maximizing root t = μᵥ ∈ (q, √q) therefore selects the value ρ(v) = momentEnvelope μᵥ q of the envelope. * momentResidual_le_momentEnvelope / momentEnvelope_le_root / momentResidual_le_envelope — the sharp upper bound r(μ) ≤ ρ(v) for every admissible law μ on [0,1] with ∫ y² = q, proved by an explicit dual (SOS) certificate rather than general moment-problem machinery: a pointwise polynomial identity whose right side y(1−y)(y−xᵥ)² is manifestly nonnegative on [0,1], plus the quartic-root maximality of the envelope over admissible first moments.

The existence/uniqueness of the maximizing root (u = μᵥ, taken here as a hypothesis of the sharp bound) is packaged at the measure/envelope layer in MomentProblems.BoundedOutcomeEnvelope.QuarticRoot.

def residualQuad reviewed
Causalean.Stat.MomentProblems.ResidualQuadratic.MomentAlgebra

The regression objective, in moment coordinates: the second moment about the linear fit b₀ + b₁ y of , i.e. ∫ (y² − b₀ − b₁ y)² dμ expressed through the raw moments m₁ = ∫ y, m₂ = ∫ y², m₃ = ∫ y³, m₄ = ∫ y⁴ (with m₀ = 1).

Definition (Lean source)
def residualQuad (m1 m2 m3 m4 b0 b1 : ℝ) : ℝ := m4 - 2 * b1 * m3 - 2 * b0 * m2 + b1 ^ 2 * m2 + 2 * b0 * b1 * m1 + b0 ^ 2
Causalean.Stat.MomentProblems.ResidualQuadratic.MomentAlgebra.residualQuad · Causalean/Stat/Nonparametric/MomentProblems/ResidualQuadratic/MomentAlgebra.lean:57
def momentResidual reviewed
Causalean.Stat.MomentProblems.ResidualQuadratic.MomentAlgebra

The closed-form residual variance of regressing on {1, y}: the value at the optimal coefficients of residualQuad, equal to the ratio of the two leading Hankel determinants det [[1,m₁,m₂],[m₁,m₂,m₃],[m₂,m₃,m₄]] / det [[1,m₁],[m₁,m₂]].

Definition (Lean source)
noncomputable def momentResidual (m1 m2 m3 m4 : ℝ) : ℝ := (m1 ^ 2 * m4 - 2 * m1 * m2 * m3 + m2 ^ 3 - m2 * m4 + m3 ^ 2) / (m1 ^ 2 - m2)
Causalean.Stat.MomentProblems.ResidualQuadratic.MomentAlgebra.momentResidual · Causalean/Stat/Nonparametric/MomentProblems/ResidualQuadratic/MomentAlgebra.lean:63
def optIntercept reviewed
Causalean.Stat.MomentProblems.ResidualQuadratic.MomentAlgebra

The optimal intercept b₀* in the regression of on {1, y}.

Definition (Lean source)
noncomputable def optIntercept (m1 m2 m3 : ℝ) : ℝ := (m1 * m3 - m2 ^ 2) / (m1 ^ 2 - m2)
Causalean.Stat.MomentProblems.ResidualQuadratic.MomentAlgebra.optIntercept · Causalean/Stat/Nonparametric/MomentProblems/ResidualQuadratic/MomentAlgebra.lean:69
def optSlope reviewed
Causalean.Stat.MomentProblems.ResidualQuadratic.MomentAlgebra

The optimal slope b₁* in the regression of on {1, y}.

Definition (Lean source)
noncomputable def optSlope (m1 m2 m3 : ℝ) : ℝ := (m1 * m2 - m3) / (m1 ^ 2 - m2)
Causalean.Stat.MomentProblems.ResidualQuadratic.MomentAlgebra.optSlope · Causalean/Stat/Nonparametric/MomentProblems/ResidualQuadratic/MomentAlgebra.lean:72
theorem residualQuad_optimalCoeff reviewed
Causalean.Stat.MomentProblems.ResidualQuadratic.MomentAlgebra

Attainment at the optimal coefficients. For raw moments m1, m2, m3, m4 of a law with first moment squared strictly below the second moment (positive variance), the regression objective, evaluated at the optimal intercept and slope (optIntercept m1 m2 m3, optSlope m1 m2 m3), equals the closed-form residual momentResidual m1 m2 m3 m4.

Formal statement
m1 m2 m3 m4 :
h :
m1 ^ 2 < m2
residualQuad m1 m2 m3 m4 (optIntercept m1 m2 m3) (optSlope m1 m2 m3)
= momentResidual m1 m2 m3 m4
Proof (Lean source)
theorem residualQuad_optimalCoeff (m1 m2 m3 m4 : ℝ) (h : m1 ^ 2 < m2) : residualQuad m1 m2 m3 m4 (optIntercept m1 m2 m3) (optSlope m1 m2 m3) = momentResidual m1 m2 m3 m4 := by have hd : m1 ^ 2 - m2 ≠ 0 := by nlinarith unfold residualQuad optIntercept optSlope momentResidual field_simp ring
Causalean.Stat.MomentProblems.ResidualQuadratic.MomentAlgebra.residualQuad_optimalCoeff · Causalean/Stat/Nonparametric/MomentProblems/ResidualQuadratic/MomentAlgebra.lean:75 · uses momentResidual , optIntercept , optSlope , residualQuad
def momentEnvelope reviewed
Causalean.Stat.MomentProblems.ResidualQuadratic.MomentAlgebra

The envelope value ρ, as a function of the support parameter t = μᵥ and q = v²: ρ = ((t − q)(q − t²)) / (4 t (1 − t)).

Definition (Lean source)
noncomputable def momentEnvelope (t q : ℝ) : ℝ := ((t - q) * (q - t ^ 2)) / (4 * t * (1 - t))
Causalean.Stat.MomentProblems.ResidualQuadratic.MomentAlgebra.momentEnvelope · Causalean/Stat/Nonparametric/MomentProblems/ResidualQuadratic/MomentAlgebra.lean:113
def extremalM1 reviewed
Causalean.Stat.MomentProblems.ResidualQuadratic.MomentAlgebra

First moment M₁ = ∫ y of the extremal three-point law: the support parameter t = μᵥ.

Definition (Lean source)
def extremalM1 (t : ℝ) : ℝ := t
Causalean.Stat.MomentProblems.ResidualQuadratic.MomentAlgebra.extremalM1 · Causalean/Stat/Nonparametric/MomentProblems/ResidualQuadratic/MomentAlgebra.lean:117
def extremalM3 reviewed
Causalean.Stat.MomentProblems.ResidualQuadratic.MomentAlgebra

Third moment M₃ = ∫ y³ of the extremal three-point law.

Definition (Lean source)
noncomputable def extremalM3 (t q : ℝ) : ℝ := (2 * q ^ 2 * t - q ^ 2 - q * t ^ 2 - q * t + t ^ 3) / (2 * t * (t - 1))
Causalean.Stat.MomentProblems.ResidualQuadratic.MomentAlgebra.extremalM3 · Causalean/Stat/Nonparametric/MomentProblems/ResidualQuadratic/MomentAlgebra.lean:120
def extremalM4 reviewed
Causalean.Stat.MomentProblems.ResidualQuadratic.MomentAlgebra

Fourth moment M₄ = ∫ y⁴ of the extremal three-point law.

Definition (Lean source)
noncomputable def extremalM4 (t q : ℝ) : ℝ := (4 * q ^ 3 * t ^ 2 - 4 * q ^ 3 * t + q ^ 3 - 4 * q ^ 2 * t ^ 3 + q ^ 2 * t + 3 * q * t ^ 4 - 2 * q * t ^ 3 + 2 * q * t ^ 2 + t ^ 5 - 2 * t ^ 4) / (4 * t ^ 2 * (t - 1) ^ 2)
Causalean.Stat.MomentProblems.ResidualQuadratic.MomentAlgebra.extremalM4 · Causalean/Stat/Nonparametric/MomentProblems/ResidualQuadratic/MomentAlgebra.lean:124
def envelopeQuartic reviewed
Causalean.Stat.MomentProblems.ResidualQuadratic.MomentAlgebra

The quartic whose stationary root in (q, √q) is the envelope maximizer t = μᵥ.

Definition (Lean source)
def envelopeQuartic (t q : ℝ) : ℝ := t ^ 4 - 2 * t ^ 3 + 2 * q * t ^ 2 - 2 * q ^ 2 * t + q ^ 2
Causalean.Stat.MomentProblems.ResidualQuadratic.MomentAlgebra.envelopeQuartic · Causalean/Stat/Nonparametric/MomentProblems/ResidualQuadratic/MomentAlgebra.lean:130
def extremalMid reviewed
Causalean.Stat.MomentProblems.ResidualQuadratic.MomentAlgebra

The interior support point xᵥ = (m² − 2 m q + q) / (2 m (1 − m)) of the extremal three-point law realizing first moment m and second moment q.

Definition (Lean source)
noncomputable def extremalMid (m q : ℝ) : ℝ := (m ^ 2 - 2 * m * q + q) / (2 * m * (1 - m))
Causalean.Stat.MomentProblems.ResidualQuadratic.MomentAlgebra.extremalMid · Causalean/Stat/Nonparametric/MomentProblems/ResidualQuadratic/MomentAlgebra.lean:216
def extremalCoeff0 reviewed
Causalean.Stat.MomentProblems.ResidualQuadratic.MomentAlgebra

The intercept b₀ of the certificate's linear fit: the regression coefficient of on 1 for the extremal three-point law at first moment m, second moment q.

Definition (Lean source)
noncomputable def extremalCoeff0 (m q : ℝ) : ℝ := (m * extremalM3 m q - q ^ 2) / (m ^ 2 - q)
Causalean.Stat.MomentProblems.ResidualQuadratic.MomentAlgebra.extremalCoeff0 · Causalean/Stat/Nonparametric/MomentProblems/ResidualQuadratic/MomentAlgebra.lean:220
def extremalCoeff1 reviewed
Causalean.Stat.MomentProblems.ResidualQuadratic.MomentAlgebra

The slope b₁ of the certificate's linear fit: the regression coefficient of on y for the extremal three-point law at first moment m, second moment q.

Definition (Lean source)
noncomputable def extremalCoeff1 (m q : ℝ) : ℝ := (m * q - extremalM3 m q) / (m ^ 2 - q)
Causalean.Stat.MomentProblems.ResidualQuadratic.MomentAlgebra.extremalCoeff1 · Causalean/Stat/Nonparametric/MomentProblems/ResidualQuadratic/MomentAlgebra.lean:224
def crossMoment reviewed
Causalean.Stat.MomentProblems.ResidualQuadratic.MomentAlgebra

The certificate cross moment ∫ y (1 − y) (y − xᵥ)² dμ of a law with moments (1, m, q, m₃, m₄), expanded in the moments (xᵥ = extremalMid m q). It is nonnegative for every law supported in [0,1] — the integral of a nonnegative polynomial — and equals the certificate slack momentEnvelope m q − residualQuad m q m₃ m₄ b₀ b₁.

Definition (Lean source)
noncomputable def crossMoment (m q m3 m4 : ℝ) : ℝ := -m4 + (1 + 2 * extremalMid m q) * m3 - (2 * extremalMid m q + extremalMid m q ^ 2) * q + extremalMid m q ^ 2 * m
Causalean.Stat.MomentProblems.ResidualQuadratic.MomentAlgebra.crossMoment · Causalean/Stat/Nonparametric/MomentProblems/ResidualQuadratic/MomentAlgebra.lean:228
theorem momentResidual_le_envelope reviewed
Causalean.Stat.MomentProblems.ResidualQuadratic.MomentAlgebra

Conditional moment-level envelope bound. Consider raw moments m, q, m3, m4 of a law and a candidate root u. If the second moment q lies strictly between 0 and 1, if the first moment m is at least q while still lies below q, i.e. the design has positive variance, if a supplied cross-moment combination of m, q, m3, m4 is nonnegative, and if u satisfies q < u, u² < q, and solves the envelope's stationarity quartic exactly, then the moment-level residual variance of regressing on {1, y} under moments (m, q, m3, m4) is at most the envelope value momentEnvelope u q.

Formal statement
m q m3 m4 u :
hq0 :
0 < q
hq1 :
q < 1
hqm :
q ≤ m
hmq :
m ^ 2 < q
hcross :
0 ≤ crossMoment m q m3 m4
hqu :
q < u
huq :
u ^ 2 < q
hroot :
momentResidual m q m3 m4 ≤ momentEnvelope u q
Proof (Lean source)
theorem momentResidual_le_envelope (m q m3 m4 u : ℝ) (hq0 : 0 < q) (hq1 : q < 1) (hqm : q ≤ m) (hmq : m ^ 2 < q) (hcross : 0 ≤ crossMoment m q m3 m4) (hqu : q < u) (huq : u ^ 2 < q) (hroot : envelopeQuartic u q = 0) : momentResidual m q m3 m4 ≤ momentEnvelope u q := by have hm0 : 0 < m := lt_of_lt_of_le hq0 hqm have hm1 : m < 1 := by nlinarith exact le_trans (momentResidual_le_momentEnvelope m q m3 m4 hm0 hm1 hmq hcross) (momentEnvelope_le_root m q u hq0 hq1 hqm hmq hqu huq hroot)
Causalean.Stat.MomentProblems.ResidualQuadratic.MomentAlgebra.momentResidual_le_envelope · Causalean/Stat/Nonparametric/MomentProblems/ResidualQuadratic/MomentAlgebra.lean:328 · uses crossMoment , envelopeQuartic , momentEnvelope , momentResidual
7 supporting declarations (lemmas, instances)
  • residualQuad_ge_momentResidual theorem — The closed-form residual momentResidual is a lower bound for the regression objective at every choice of coefficients, when the design is nondegenerate (m₁² < m₂, positive variance). Together with residualQuad_optimalCoeff this shows momentResidual is the minimum min_{b₀,b₁} ∫ (y² − b₀ − b₁ y)² dμ.
    m1 m2 m3 m4 b0 b1 :
    h :
    m1 ^ 2 < m2
    momentResidual m1 m2 m3 m4 ≤ residualQuad m1 m2 m3 m4 b0 b1
    Proof (Lean source)
    theorem residualQuad_ge_momentResidual (m1 m2 m3 m4 b0 b1 : ℝ) (h : m1 ^ 2 < m2) : momentResidual m1 m2 m3 m4 ≤ residualQuad m1 m2 m3 m4 b0 b1 := by have hd : m1 ^ 2 - m2 ≠ 0 := by nlinarith have key : residualQuad m1 m2 m3 m4 b0 b1 - momentResidual m1 m2 m3 m4 = (b0 - optIntercept m1 m2 m3 + m1 * (b1 - optSlope m1 m2 m3)) ^ 2 + (m2 - m1 ^ 2) * (b1 - optSlope m1 m2 m3) ^ 2 := by unfold residualQuad momentResidual optIntercept optSlope field_simp ring nlinarith [sq_nonneg (b0 - optIntercept m1 m2 m3 + m1 * (b1 - optSlope m1 m2 m3)), sq_nonneg (b1 - optSlope m1 m2 m3), key, h]
    Causalean.Stat.MomentProblems.ResidualQuadratic.MomentAlgebra.residualQuad_ge_momentResidual · Causalean/Stat/Nonparametric/MomentProblems/ResidualQuadratic/MomentAlgebra.lean:88
  • extremalResidual_eq_envelope theorem — Family residual identity. For every nondegenerate support parameter t (with t ≠ 0, t ≠ 1, and second moment q ≠ t²), the residual variance of regressing y² on {1, y} under the three-point law with moments (t, q, M₃, M₄) equals the closed form momentEnvelope t q. In particular ρ(v) is attained by an admissible law at second moment q = v².
    t q :
    ht0 :
    t ≠ 0
    ht1 :
    t ≠ 1
    htq :
    t ^ 2 ≠ q
    Proof (Lean source)
    theorem extremalResidual_eq_envelope (t q : ℝ) (ht0 : t ≠ 0) (ht1 : t ≠ 1) (htq : t ^ 2 ≠ q) : momentResidual (extremalM1 t) q (extremalM3 t q) (extremalM4 t q) = momentEnvelope t q := by unfold momentResidual momentEnvelope extremalM1 extremalM3 extremalM4 have h1 : t - 1 ≠ 0 := sub_ne_zero.mpr ht1 have h1' : (1 : ℝ) - t ≠ 0 := by intro h apply ht1 linarith have h2 : (t : ℝ) ^ 2 - q ≠ 0 := sub_ne_zero.mpr htq have h2' : q - t ^ 2 ≠ 0 := by intro h apply h2 linarith field_simp [ht0, h1, h1', h2, h2'] ring
    Causalean.Stat.MomentProblems.ResidualQuadratic.MomentAlgebra.extremalResidual_eq_envelope · Causalean/Stat/Nonparametric/MomentProblems/ResidualQuadratic/MomentAlgebra.lean:133
  • momentEnvelope_hasDerivAt theorem — Stationarity / envelope FOC. As a function of the support parameter t, the family residual momentEnvelope t q has derivative envelopeQuartic t q / (4 t² (t − 1)²). Hence the quartic is exactly the numerator of dρ/dt, and the envelope's stationary points are its roots.
    t q :
    ht0 :
    t ≠ 0
    ht1 :
    t ≠ 1
    HasDerivAt (fun s => momentEnvelope s q) (envelopeQuartic t q / (4 * t ^ 2 * (t - 1) ^ 2)) t
    Proof (Lean source)
    theorem momentEnvelope_hasDerivAt (t q : ℝ) (ht0 : t ≠ 0) (ht1 : t ≠ 1) : HasDerivAt (fun s => momentEnvelope s q) (envelopeQuartic t q / (4 * t ^ 2 * (t - 1) ^ 2)) t := by have hN : HasDerivAt (fun s : ℝ => (s - q) * (q - s ^ 2)) (1 * (q - t ^ 2) + (t - q) * (-(2 * t))) t := by have h1 : HasDerivAt (fun s : ℝ => s - q) 1 t := (hasDerivAt_id t).sub_const q have h2 : HasDerivAt (fun s : ℝ => q - s ^ 2) (-(2 * t)) t := by have hp : HasDerivAt (fun s : ℝ => s ^ 2) (2 * t) t := by simpa using (hasDerivAt_pow 2 t) exact HasDerivAt.const_sub q hp exact h1.fun_mul h2 have hD : HasDerivAt (fun s : ℝ => 4 * s * (1 - s)) (4 * (1 - t) + 4 * t * (-1)) t := by have h3 : HasDerivAt (fun s : ℝ => 4 * s) 4 t := by simpa using (hasDerivAt_id t).const_mul (4 : ℝ) have h4 : HasDerivAt (fun s : ℝ => 1 - s) (-1) t := HasDerivAt.const_sub (1 : ℝ) (hasDerivAt_id t) exact h3.fun_mul h4 have hDne : 4 * t * (1 - t) ≠ 0 := by have ht1' : (1 : ℝ) - t ≠ 0 := by intro h apply ht1 linarith exact mul_ne_zero (mul_ne_zero (by norm_num) ht0) ht1' have hderiv := hN.fun_div hD hDne have hval : envelopeQuartic t q / (4 * t ^ 2 * (t - 1) ^ 2) = ((1 * (q - t ^ 2) + (t - q) * (-(2 * t))) * (4 * t * (1 - t)) - (t - q) * (q - t ^ 2) * (4 * (1 - t) + 4 * t * (-1))) / (4 * t * (1 - t)) ^ 2 := by unfold envelopeQuartic field_simp [ht0, ht1] ring unfold momentEnvelope rw [hval] exact hderiv
    Causalean.Stat.MomentProblems.ResidualQuadratic.MomentAlgebra.momentEnvelope_hasDerivAt · Causalean/Stat/Nonparametric/MomentProblems/ResidualQuadratic/MomentAlgebra.lean:157
  • momentEnvelope_stationary_of_quartic theorem — At a root t of the quartic, the family residual momentEnvelope · q is stationary. The maximizing root t = μᵥ ∈ (q, √q) therefore realizes the envelope value ρ(v).
    t q :
    ht0 :
    t ≠ 0
    ht1 :
    t ≠ 1
    hquar :
    deriv (fun s => momentEnvelope s q) t = 0
    Proof (Lean source)
    theorem momentEnvelope_stationary_of_quartic (t q : ℝ) (ht0 : t ≠ 0) (ht1 : t ≠ 1) (hquar : envelopeQuartic t q = 0) : deriv (fun s => momentEnvelope s q) t = 0 := by rw [(momentEnvelope_hasDerivAt t q ht0 ht1).deriv, hquar, zero_div]
    Causalean.Stat.MomentProblems.ResidualQuadratic.MomentAlgebra.momentEnvelope_stationary_of_quartic · Causalean/Stat/Nonparametric/MomentProblems/ResidualQuadratic/MomentAlgebra.lean:195
  • residualQuad_extremalCoeff_eq theorem — Dual-certificate identity (integrated). For the certificate's linear-fit coefficients, the regression objective equals the envelope value minus the cross moment: residualQuad m q m₃ m₄ b₀ b₁ = momentEnvelope m q − crossMoment m q m₃ m₄. This is the moment-level form of the pointwise SOS certificate, a pure algebraic identity (ring) valid for m ≠ 0, m ≠ 1, m² ≠ q.
    m q m3 m4 :
    hm0 :
    m ≠ 0
    hm1 :
    m ≠ 1
    hmq :
    m ^ 2 ≠ q
    residualQuad m q m3 m4 (extremalCoeff0 m q) (extremalCoeff1 m q)
    = momentEnvelope m q - crossMoment m q m3 m4
    Proof (Lean source)
    theorem residualQuad_extremalCoeff_eq (m q m3 m4 : ℝ) (hm0 : m ≠ 0) (hm1 : m ≠ 1) (hmq : m ^ 2 ≠ q) : residualQuad m q m3 m4 (extremalCoeff0 m q) (extremalCoeff1 m q) = momentEnvelope m q - crossMoment m q m3 m4 := by have h1m : (1 : ℝ) - m ≠ 0 := by intro h apply hm1 linarith have hm1' : m - 1 ≠ 0 := sub_ne_zero.mpr hm1 have hmq' : m ^ 2 - q ≠ 0 := sub_ne_zero.mpr hmq unfold residualQuad momentEnvelope crossMoment extremalCoeff0 extremalCoeff1 extremalM3 extremalMid field_simp [hm0, hm1', h1m, hmq'] ring
    Causalean.Stat.MomentProblems.ResidualQuadratic.MomentAlgebra.residualQuad_extremalCoeff_eq · Causalean/Stat/Nonparametric/MomentProblems/ResidualQuadratic/MomentAlgebra.lean:236
  • momentResidual_le_momentEnvelope theorem — Sharp per-instance bound. For an admissible moment tuple (1, m, q, m₃, m₄) of a law on [0,1] with positive variance (m² < q) and nonnegative cross moment (0 ≤ crossMoment m q m₃ m₄, automatic for any law on [0,1]), the residual variance of regressing y² on {1, y} is at most the envelope value at the law's own first moment: momentResidual m q m₃ m₄ ≤ momentEnvelope m q.
    m q m3 m4 :
    hm0 :
    0 < m
    hm1 :
    m < 1
    hmq :
    m ^ 2 < q
    hcross :
    0 ≤ crossMoment m q m3 m4
    momentResidual m q m3 m4 ≤ momentEnvelope m q
    Proof (Lean source)
    theorem momentResidual_le_momentEnvelope (m q m3 m4 : ℝ) (hm0 : 0 < m) (hm1 : m < 1) (hmq : m ^ 2 < q) (hcross : 0 ≤ crossMoment m q m3 m4) : momentResidual m q m3 m4 ≤ momentEnvelope m q := by have hmq' : m ^ 2 ≠ q := ne_of_lt hmq have hlb := residualQuad_ge_momentResidual m q m3 m4 (extremalCoeff0 m q) (extremalCoeff1 m q) hmq have heq := residualQuad_extremalCoeff_eq m q m3 m4 (ne_of_gt hm0) (ne_of_lt hm1) hmq' rw [heq] at hlb linarith
    Causalean.Stat.MomentProblems.ResidualQuadratic.MomentAlgebra.momentResidual_le_momentEnvelope · Causalean/Stat/Nonparametric/MomentProblems/ResidualQuadratic/MomentAlgebra.lean:256
  • momentEnvelope_le_root theorem — Envelope maximality. Among admissible first moments the envelope momentEnvelope · q is maximized at a quartic root u = μᵥ: if q < u, u² < q, and envelopeQuartic u q = 0, then for every admissible first moment m with q ≤ m, m² < q, one has momentEnvelope m q ≤ momentEnvelope u q.
    m q u :
    hq0 :
    0 < q
    hq1 :
    q < 1
    hqm :
    q ≤ m
    hmq :
    m ^ 2 < q
    hqu :
    q < u
    huq :
    u ^ 2 < q
    hroot :
    Proof (Lean source)
    theorem momentEnvelope_le_root (m q u : ℝ) (hq0 : 0 < q) (hq1 : q < 1) (hqm : q ≤ m) (hmq : m ^ 2 < q) (hqu : q < u) (huq : u ^ 2 < q) (hroot : envelopeQuartic u q = 0) : momentEnvelope m q ≤ momentEnvelope u q := by have hm0 : 0 < m := lt_of_lt_of_le hq0 hqm have hu0 : 0 < u := lt_trans hq0 hqu have hm1 : m < 1 := by nlinarith have hu1 : u < 1 := by nlinarith have hDpos : 0 < 4 * m * u * (m - 1) * (u - 1) := by nlinarith [mul_pos hm0 hu0] have hLneg : m * u ^ 2 - m * u - q ^ 2 + 2 * q * u + u ^ 3 - 2 * u ^ 2 < 0 := by nlinarith [mul_nonneg (sub_nonneg.mpr hqm) (le_of_lt (sub_pos.mpr hqu)), mul_nonneg (le_of_lt hu0) (le_of_lt (sub_pos.mpr hqu)), mul_nonneg (le_of_lt hm0) (le_of_lt (sub_pos.mpr huq)), mul_nonneg (le_of_lt hu0) (le_of_lt (sub_pos.mpr huq))] have hmne : m ≠ 0 := ne_of_gt hm0 have hune : u ≠ 0 := ne_of_gt hu0 have hm1ne : m - 1 ≠ 0 := by intro h nlinarith have hu1ne : u - 1 ≠ 0 := by intro h nlinarith have h1mne : (1 : ℝ) - m ≠ 0 := by intro h nlinarith have h1une : (1 : ℝ) - u ≠ 0 := by intro h nlinarith have key : momentEnvelope u q - momentEnvelope m q = (u - m) ^ 2 * (-(m * u ^ 2 - m * u - q ^ 2 + 2 * q * u + u ^ 3 - 2 * u ^ 2)) / (4 * m * u * (m - 1) * (u - 1)) + (u - m) / (4 * m * u * (m - 1) * (u - 1)) * envelopeQuartic u q := by unfold momentEnvelope envelopeQuartic field_simp [hmne, hune, hm1ne, hu1ne, h1mne, h1une] ring rw [hroot, mul_zero, add_zero] at key have hpos : 0 ≤ (u - m) ^ 2 * (-(m * u ^ 2 - m * u - q ^ 2 + 2 * q * u + u ^ 3 - 2 * u ^ 2)) / (4 * m * u * (m - 1) * (u - 1)) := by apply div_nonneg _ (le_of_lt hDpos) exact mul_nonneg (sq_nonneg _) (by linarith) linarith [key, hpos]
    Causalean.Stat.MomentProblems.ResidualQuadratic.MomentAlgebra.momentEnvelope_le_root · Causalean/Stat/Nonparametric/MomentProblems/ResidualQuadratic/MomentAlgebra.lean:271
Measure­Bridge 7 core · 4 supporting This file is the measure bridge for the MomentProblems stack. ★ iInf_residualQuad

Measure-level L² projection residual of y ↦ y² onto span{1, y}

This file is the measure bridge for the MomentProblems stack. MomentAlgebra.lean proves the closed-form residual purely in moment coordinates; this file turns that algebra into the actual L²(μ) projection residual for probability measures on with finite fourth moment:

r(μ) = ⨅_{b₀,b₁} ∫ (y² − b₀ − b₁ y)² dμ.

Writing mₖ = ∫ yᵏ dμ for the raw moments, the closed form is the Hankel-determinant ratio

r(μ) = (m₄ − m₂²) − (m₃ − m₁ m₂)² / (m₂ − m₁²) = det H₃ / det H₂,

attained at the least-squares optimal coefficients b₁* = (m₃ − m₁ m₂)/(m₂ − m₁²), b₀* = m₂ − b₁* m₁ (here written optIntercept, optSlope).

Design

The moment-level algebra — that the quadratic objective residualQuad m₁ m₂ m₃ m₄ b₀ b₁ in (b₀, b₁) has minimum the Hankel ratio, via a completed-square / SOS certificate — is proven, measure-free, in Causalean.Stat.MomentProblems.ResidualQuadratic.MomentAlgebra (residualQuad_optimalCoeff, residualQuad_ge_momentResidual). This module supplies the measure-theoretic bridge:

* residualQuad_eq — the bridge: expanding the square and integrating term by term, ∫ (y² − b₀ − b₁ y)² dμ equals the moment polynomial MomentAlgebra.residualQuad m₁ m₂ m₃ m₄ b₀ b₁ (uses IsProbabilityMeasure for the constant term ∫ b₀² = b₀² and integrability of y, …, y⁴ to split the integral). * residualQuad_opt_eq, l2ResidualQuadratic_le, l2ResidualQuadratic_nonneg, iInf_residualQuad — the optimality / infimum bridge transporting the moment-level minimum to the -form and the conditional infimum ⨅ b₀ b₁.

Finite fourth moment is packaged as FiniteMoment4 μ (integrability of y, y², y³, y⁴); for a probability measure with ∫ y⁴ < ∞ all these lower moments are finite, so this is exactly the "finite 4th moment" hypothesis. Non-degeneracy is m₁² < m₂ (positive variance).

def moment reviewed
Causalean.Stat.MomentProblems.ResidualQuadratic.MeasureBridge

The raw k-th moment mₖ = ∫ yᵏ ∂μ of a measure μ on .

Definition (Lean source)
noncomputable def moment (μ : Measure ℝ) (k : ℕ) : ℝ := ∫ y, y ^ k ∂μ
Causalean.Stat.MomentProblems.ResidualQuadratic.MeasureBridge.moment · Causalean/Stat/Nonparametric/MomentProblems/ResidualQuadratic/MeasureBridge.lean:54
structure FiniteMoment4 reviewed
Causalean.Stat.MomentProblems.ResidualQuadratic.MeasureBridge

Finite-fourth-moment hypothesis bundle: integrability of y, of , of , and of y⁴ against μ. For a probability measure with ∫ y⁴ ∂μ < ∞ all four hold, so this is exactly "μ has a finite fourth moment".

Definition (Lean source)
μ :
`y ↦ y` is integrable (finite first moment).
int1 :
Integrable (fun y : ℝ => y) μ
`y ↦ y²` is integrable (finite second moment).
int2 :
Integrable (fun y : ℝ => y ^ 2) μ
`y ↦ y³` is integrable (finite third moment).
int3 :
Integrable (fun y : ℝ => y ^ 3) μ
`y ↦ y⁴` is integrable (finite fourth moment).
int4 :
Integrable (fun y : ℝ => y ^ 4) μ
Causalean.Stat.MomentProblems.ResidualQuadratic.MeasureBridge.FiniteMoment4 · Causalean/Stat/Nonparametric/MomentProblems/ResidualQuadratic/MeasureBridge.lean:57
def residualQuad reviewed
Causalean.Stat.MomentProblems.ResidualQuadratic.MeasureBridge

The quadratic regression objective in L²(μ): the mean squared residual of the linear fit b₀ + b₁ y to , i.e. ∫ (y² − b₀ − b₁ y)² ∂μ.

Definition (Lean source)
noncomputable def residualQuad (μ : Measure ℝ) (b₀ b₁ : ℝ) : ℝ := ∫ y, (y ^ 2 - b₀ - b₁ * y) ^ 2 ∂μ
Causalean.Stat.MomentProblems.ResidualQuadratic.MeasureBridge.residualQuad · Causalean/Stat/Nonparametric/MomentProblems/ResidualQuadratic/MeasureBridge.lean:70
def l2ResidualQuadratic reviewed
Causalean.Stat.MomentProblems.ResidualQuadratic.MeasureBridge

The closed-form minimal residual r(μ) = (m₄ − m₂²) − (m₃ − m₁ m₂)² / (m₂ − m₁²), expressed as the Hankel-determinant ratio MomentAlgebra.momentResidual of the raw moments m₁, m₂, m₃, m₄.

Definition (Lean source)
noncomputable def l2ResidualQuadratic (μ : Measure ℝ) : ℝ := momentResidual (moment μ 1) (moment μ 2) (moment μ 3) (moment μ 4)
Causalean.Stat.MomentProblems.ResidualQuadratic.MeasureBridge.l2ResidualQuadratic · Causalean/Stat/Nonparametric/MomentProblems/ResidualQuadratic/MeasureBridge.lean:75
def optIntercept reviewed
Causalean.Stat.MomentProblems.ResidualQuadratic.MeasureBridge

The least-squares optimal intercept b₀* = (m₁ m₃ − m₂²)/(m₁² − m₂) = m₂ − b₁* m₁.

Definition (Lean source)
noncomputable def optIntercept (μ : Measure ℝ) : ℝ := optIntercept (moment μ 1) (moment μ 2) (moment μ 3)
Causalean.Stat.MomentProblems.ResidualQuadratic.MeasureBridge.optIntercept · Causalean/Stat/Nonparametric/MomentProblems/ResidualQuadratic/MeasureBridge.lean:81
def optSlope reviewed
Causalean.Stat.MomentProblems.ResidualQuadratic.MeasureBridge

The least-squares optimal slope b₁* = (m₃ − m₁ m₂)/(m₂ − m₁²).

Definition (Lean source)
noncomputable def optSlope (μ : Measure ℝ) : ℝ := optSlope (moment μ 1) (moment μ 2) (moment μ 3)
Causalean.Stat.MomentProblems.ResidualQuadratic.MeasureBridge.optSlope · Causalean/Stat/Nonparametric/MomentProblems/ResidualQuadratic/MeasureBridge.lean:86
theorem iInf_residualQuad reviewed
Causalean.Stat.MomentProblems.ResidualQuadratic.MeasureBridge

Headline infimum identity. For a probability measure μ on with a finite fourth moment and first moment squared strictly below the second moment (positive variance), the infimum, over every intercept and slope, of the mean squared residual of fitting b₀ + b₁y to equals the closed-form Hankel-determinant residual l2ResidualQuadratic μ, attained at the least-squares-optimal coefficients (optIntercept μ, optSlope μ):

Formal statement
h :
hnd :
moment μ 1 ^ 2 < moment μ 2
⨅ b₀, ⨅ b₁, residualQuad μ b₀ b₁ = l2ResidualQuadratic μ
Proof (Lean source)
theorem iInf_residualQuad (μ : Measure ℝ) [IsProbabilityMeasure μ] (h : FiniteMoment4 μ) (hnd : moment μ 1 ^ 2 < moment μ 2) : ⨅ b₀, ⨅ b₁, residualQuad μ b₀ b₁ = l2ResidualQuadratic μ := by apply le_antisymm · calc ⨅ b₀, ⨅ b₁, residualQuad μ b₀ b₁ ≤ ⨅ b₁, residualQuad μ (optIntercept μ) b₁ := by exact ciInf_le (⟨l2ResidualQuadratic μ, by rintro x ⟨b₀, rfl⟩ exact le_ciInf (fun b₁ => l2ResidualQuadratic_le μ h hnd b₀ b₁)⟩ : BddBelow (range fun b₀ => ⨅ b₁, residualQuad μ b₀ b₁)) (optIntercept μ) _ ≤ residualQuad μ (optIntercept μ) (optSlope μ) := by exact ciInf_le (⟨l2ResidualQuadratic μ, by rintro x ⟨b₁, rfl⟩ exact l2ResidualQuadratic_le μ h hnd (optIntercept μ) b₁⟩ : BddBelow (range fun b₁ => residualQuad μ (optIntercept μ) b₁)) (optSlope μ) _ = l2ResidualQuadratic μ := residualQuad_opt_eq μ h hnd · exact le_ciInf (fun b₀ => le_ciInf (fun b₁ => l2ResidualQuadratic_le μ h hnd b₀ b₁))
4 supporting declarations (lemmas, instances)
Projection­Residual 2 core · 7 supporting This file is the functional bridge between MomentProblems.ResidualQuadratic.MeasureBridge and the constrained score program. ★ integral_sq_projResidual

Projection residual function for the moment score program

This file is the functional bridge between MomentProblems.ResidualQuadratic.MeasureBridge and the constrained score program. For a probability measure μ on with finite fourth moment and positive variance (m₁² < m₂), MeasureBridge.lean computes the closed-form residual value r(μ) = l2ResidualQuadratic μ; this file identifies the residual function that attains that value,

q(y) := y² − (optIntercept μ + optSlope μ · y),

and proves the four facts that make it the orthogonal projection residual of onto span{1,y}:

  • integral_projResidual : ∫ q dμ = 0 (orthogonal to the constant 1)
  • integral_id_mul_projResidual : ∫ y·q dμ = 0 (orthogonal to y)
  • integral_sq_projResidual : ∫ q² dμ = r (its own L² norm² is the residual r)
  • integral_sq_mul_projResidual : ∫ y²·q dμ = r (-moment of q equals r)

The first two are the normal equations of least squares; here they reduce, after splitting the integral into raw moments mₖ = ∫ yᵏ, to pure moment algebra in the definitions of optIntercept/optSlope (division by m₁² − m₂ ≠ 0). The last two reuse MeasureBridge.residualQuad_opt_eq, the attainment lemma for the closed-form residual.

These are the ingredients consumed by ScoreProgram.lean to solve the constrained minimum-norm "score program" dual to this projection.

def projResidual reviewed
Causalean.Stat.MomentProblems.ResidualQuadratic.ProjectionResidual

The L² projection residual function of y ↦ y² onto span{1, y}: q(y) = y² − (optIntercept μ + optSlope μ · y), i.e. minus its least-squares linear fit.

Definition (Lean source)
noncomputable def projResidual (μ : Measure ℝ) : ℝ → ℝ := fun y => y ^ 2 - (optIntercept μ + optSlope μ * y)
Causalean.Stat.MomentProblems.ResidualQuadratic.ProjectionResidual.projResidual · Causalean/Stat/Nonparametric/MomentProblems/ResidualQuadratic/ProjectionResidual.lean:43
theorem integral_sq_projResidual reviewed
Causalean.Stat.MomentProblems.ResidualQuadratic.ProjectionResidual

Self L²-norm of the projection residual. For a probability measure μ on with a finite fourth moment and first moment squared strictly below the second moment (positive variance), the squared L² norm of the projection residual q(y) = y² − (optIntercept μ + optSlope μ · y) equals the closed-form residual l2ResidualQuadratic μ: ∫ q² dμ = l2ResidualQuadratic μ.

Formal statement
h :
hnd :
moment μ 1 ^ 2 < moment μ 2
∫ y, projResidual μ y ^ 2 ∂μ = l2ResidualQuadratic μ
Proof (Lean source)
theorem integral_sq_projResidual (μ : Measure ℝ) [IsProbabilityMeasure μ] (h : FiniteMoment4 μ) (hnd : moment μ 1 ^ 2 < moment μ 2) : ∫ y, projResidual μ y ^ 2 ∂μ = l2ResidualQuadratic μ := by rw [← residualQuad_opt_eq μ h hnd] unfold projResidual residualQuad congr 1 funext y ring
Causalean.Stat.MomentProblems.ResidualQuadratic.ProjectionResidual.integral_sq_projResidual · Causalean/Stat/Nonparametric/MomentProblems/ResidualQuadratic/ProjectionResidual.lean:144 · uses FiniteMoment4 , l2ResidualQuadratic , moment , projResidual
7 supporting declarations (lemmas, instances)