Stat.Nonparametric.MomentProblems.ResidualQuadratic
Residual-quadratic moment problems: moment-coordinate formulas, measure-level L² projection residuals, and projection residual orthogonality identities.
MomentAlgebra 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 y² to span{1, y}, i.e. the residual
variance of regressing y² 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_optimalCoeff — momentResidual 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.
Given four real numbers representing the first through fourth raw moments and an intercept and slope, the moment-coordinate regression objective is the polynomial obtained by expanding the squared residual from fitting by .
Definition (Lean source)
Given four real numbers representing the first through fourth raw moments, the closed-form residual variance is the ratio of the leading third- and second-order Hankel determinants formed from those moments.
Definition (Lean source)
Given three real numbers representing the first three raw moments, the optimal regression intercept is .
Definition (Lean source)
Given three real numbers representing the first three raw moments, the optimal regression slope is .
Definition (Lean source)
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
Proof (Lean source)
Given a real support parameter and a real second-moment value, the envelope value is .
Definition (Lean source)
Given a real support parameter, the first moment of the extremal three-point law is that support parameter itself.
Definition (Lean source)
Given a real support parameter and a real second-moment value, the third moment of the extremal three-point law is .
Definition (Lean source)
Given a real support parameter and a real second-moment value, the fourth moment of the extremal three-point law is .
Definition (Lean source)
Given a real support parameter and a real second-moment value, the envelope first-order quartic is .
Definition (Lean source)
Given a real first-moment value and a real second-moment value, the interior support point of the extremal three-point law is .
Definition (Lean source)
Given a real first-moment value and a real second-moment value, the intercept of the dual-certificate linear fit is , where is the extremal third moment at first moment and second moment .
Definition (Lean source)
Given a real first-moment value and a real second-moment value, the slope of the dual-certificate linear fit is , where is the extremal third moment at first moment and second moment .
Definition (Lean source)
Given real numbers representing the first through fourth raw moments, the dual-certificate cross moment is , where .
Definition (Lean source)
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 m² 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 y² on {1, y} under moments (m, q, m3, m4) is at most the envelope value momentEnvelope u q.
Formal statement
Proof (Lean source)
7 supporting declarations (lemmas, instances)
-
residualQuad_ge_momentResidualtheorem — 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μ.hypothesesm1 m2 m3 m4 b0 b1 :ℝh :m1 ^ 2 < m2conclusionmomentResidual m1 m2 m3 m4 ≤ residualQuad m1 m2 m3 m4 b0 b1Proof (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] -
extremalResidual_eq_envelopetheorem — 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².hypothesest q :ℝht0 :t ≠ 0ht1 :t ≠ 1htq :t ^ 2 ≠ qconclusionProof (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 -
momentEnvelope_hasDerivAttheorem — 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.hypothesest q :ℝht0 :t ≠ 0ht1 :t ≠ 1conclusionProof (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 -
momentEnvelope_stationary_of_quartictheorem — 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).hypothesesconclusionderiv (fun s => momentEnvelope s q) t = 0Proof (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] -
residualQuad_extremalCoeff_eqtheorem — 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.hypothesesm q m3 m4 :ℝhm0 :m ≠ 0hm1 :m ≠ 1hmq :m ^ 2 ≠ qconclusionresidualQuad m q m3 m4 (extremalCoeff0 m q) (extremalCoeff1 m q)= momentEnvelope m q - crossMoment m q m3 m4Proof (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 -
momentResidual_le_momentEnvelopetheorem — 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.hypothesesconclusionmomentResidual m q m3 m4 ≤ momentEnvelope m qProof (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 -
momentEnvelope_le_roottheorem — 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.hypothesesm q u :ℝhq0 :0 < qhq1 :q < 1hqm :q ≤ mhmq :m ^ 2 < qhqu :q < uhuq :u ^ 2 < qhroot :envelopeQuartic u q = 0conclusionmomentEnvelope m q ≤ momentEnvelope u qProof (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]
MeasureBridge 6 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ₖ = rawMoment μ k = ∫ yᵏ dμ for the raw moments (the shared MomentProblems.rawMoment), 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).
Finite-fourth-moment hypothesis bundle: integrability of y, of y², of y³, 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)
Given a measure on the real line, an intercept, and a slope, the quadratic regression objective is the integral of the squared residual from fitting by the affine function .
Definition (Lean source)
Given a measure on the real line, the moment-defined quadratic residual is the closed-form residual-variance expression calculated from its first four raw moments.
Given a measure on the real line, the least-squares optimal intercept is the moment-based coefficient for fitting by an affine function.
Definition (Lean source)
Given a measure on the real line, the least-squares optimal slope is the moment-based coefficient for fitting by an affine function.
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 y² equals the closed-form Hankel-determinant residual l2ResidualQuadratic μ, attained at the least-squares-optimal coefficients (optIntercept μ, optSlope μ):
Formal statement
Proof (Lean source)
4 supporting declarations (lemmas, instances)
-
residualQuad_eqtheorem — Bridge (integral → moments). For a probability measure with finite fourth moment, the integral objective equals the moment polynomial: expanding (y² − b₀ − b₁ y)² = y⁴ − 2b₁ y³ + (b₁² − 2b₀) y² + 2b₀b₁ y + b₀² and integrating term by term (using ∫ 1 ∂μ = 1),hypothesesconclusionresidualQuad μ b₀ b₁Proof (Lean source)
theorem residualQuad_eq (μ : Measure ℝ) [IsProbabilityMeasure μ] (h : FiniteMoment4 μ) (b₀ b₁ : ℝ) : residualQuad μ b₀ b₁ = Causalean.Stat.MomentProblems.ResidualQuadratic.MomentAlgebra.residualQuad (rawMoment μ 1) (rawMoment μ 2) (rawMoment μ 3) (rawMoment μ 4) b₀ b₁ := by unfold residualQuad rawMoment Causalean.Stat.MomentProblems.ResidualQuadratic.MomentAlgebra.residualQuad have hpoly : (fun y : ℝ => (y ^ 2 - b₀ - b₁ * y) ^ 2) = fun y : ℝ => (((((y ^ 4 + (-(2 * b₁)) * y ^ 3) + (-(2 * b₀)) * y ^ 2) + (b₁ ^ 2) * y ^ 2) + (2 * b₀ * b₁) * y) + b₀ ^ 2) := by funext y ring rw [hpoly] have hi3 : Integrable (fun y : ℝ => (-(2 * b₁)) * y ^ 3) μ := h.int3.const_mul _ have hi2a : Integrable (fun y : ℝ => (-(2 * b₀)) * y ^ 2) μ := h.int2.const_mul _ have hi2b : Integrable (fun y : ℝ => (b₁ ^ 2) * y ^ 2) μ := h.int2.const_mul _ have hi1 : Integrable (fun y : ℝ => (2 * b₀ * b₁) * y) μ := h.int1.const_mul _ have hic : Integrable (fun _ : ℝ => b₀ ^ 2) μ := integrable_const _ have hs1 : Integrable (fun y : ℝ => y ^ 4 + (-(2 * b₁)) * y ^ 3) μ := h.int4.add hi3 have hs2 : Integrable (fun y : ℝ => (y ^ 4 + (-(2 * b₁)) * y ^ 3) + (-(2 * b₀)) * y ^ 2) μ := hs1.add hi2a have hs3 : Integrable (fun y : ℝ => ((y ^ 4 + (-(2 * b₁)) * y ^ 3) + (-(2 * b₀)) * y ^ 2) + (b₁ ^ 2) * y ^ 2) μ := hs2.add hi2b have hs4 : Integrable (fun y : ℝ => (((y ^ 4 + (-(2 * b₁)) * y ^ 3) + (-(2 * b₀)) * y ^ 2) + (b₁ ^ 2) * y ^ 2) + (2 * b₀ * b₁) * y) μ := hs3.add hi1 integral_linearity simp [MeasureTheory.integral_const_mul, MeasureTheory.integral_mul_const, MeasureTheory.integral_neg, MeasureTheory.integral_const, mul_assoc, mul_left_comm, mul_comm] ring -
residualQuad_opt_eqtheorem — Attainment. At the optimal coefficients (optIntercept μ, optSlope μ) the integral objective attains the closed-form residual l2ResidualQuadratic μ, whenever the design is non-degenerate (m₁² < m₂).hypothesesconclusionresidualQuad μ (optIntercept μ) (optSlope μ) = l2ResidualQuadratic μProof (Lean source)
theorem residualQuad_opt_eq (μ : Measure ℝ) [IsProbabilityMeasure μ] (h : FiniteMoment4 μ) (hnd : rawMoment μ 1 ^ 2 < rawMoment μ 2) : residualQuad μ (optIntercept μ) (optSlope μ) = l2ResidualQuadratic μ := by rw [residualQuad_eq μ h] exact residualQuad_optimalCoeff (rawMoment μ 1) (rawMoment μ 2) (rawMoment μ 3) (rawMoment μ 4) hnd -
l2ResidualQuadratic_letheorem — Lower bound (infimum). The closed-form residual is a lower bound of the integral objective at every choice of coefficients, when the design is non-degenerate. Together with residualQuad_opt_eq this identifies l2ResidualQuadratic μ as the minimum ⨅ b₀ b₁, ∫ (y² − b₀ − b₁ y)² ∂μ.Proof (Lean source)
theorem l2ResidualQuadratic_le (μ : Measure ℝ) [IsProbabilityMeasure μ] (h : FiniteMoment4 μ) (hnd : rawMoment μ 1 ^ 2 < rawMoment μ 2) (b₀ b₁ : ℝ) : l2ResidualQuadratic μ ≤ residualQuad μ b₀ b₁ := by rw [residualQuad_eq μ h] exact residualQuad_ge_momentResidual (rawMoment μ 1) (rawMoment μ 2) (rawMoment μ 3) (rawMoment μ 4) b₀ b₁ hnd -
l2ResidualQuadratic_nonnegtheorem — Non-negativity. The closed-form residual is non-negative (it is the value at the optimum of an integral of a square), for a non-degenerate design.hypothesesconclusion0 ≤ l2ResidualQuadratic μProof (Lean source)
theorem l2ResidualQuadratic_nonneg (μ : Measure ℝ) [IsProbabilityMeasure μ] (h : FiniteMoment4 μ) (hnd : rawMoment μ 1 ^ 2 < rawMoment μ 2) : 0 ≤ l2ResidualQuadratic μ := by rw [← residualQuad_opt_eq μ h hnd] exact integral_nonneg (fun y => sq_nonneg _)
ProjectionResidual 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 y² onto span{1,y}:
integral_projResidual:∫ q dμ = 0(orthogonal to the constant1)integral_id_mul_projResidual:∫ y·q dμ = 0(orthogonal toy)integral_sq_projResidual:∫ q² dμ = r(its own L² norm² is the residualr)integral_sq_mul_projResidual:∫ y²·q dμ = r(y²-moment ofqequalsr)
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.
For a measure on the real line, let denote its -th raw moment. The projection-residual function assigns to each real value the value , where and .
Definition (Lean source)
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
Proof (Lean source)
7 supporting declarations (lemmas, instances)
-
memL2_idtheorem — y ↦ y is in L²(μ) when the second moment is finite.Proof (Lean source)
theorem memL2_id (μ : Measure ℝ) [IsFiniteMeasure μ] (h : FiniteMoment4 μ) : MemLp (fun y : ℝ => y) 2 μ := by refine (memLp_two_iff_integrable_sq (continuous_id.aestronglyMeasurable)).2 ?_ simpa using h.int2 -
memL2_sqtheorem — y ↦ y² is in L²(μ) when the fourth moment is finite.Proof (Lean source)
theorem memL2_sq (μ : Measure ℝ) [IsFiniteMeasure μ] (h : FiniteMoment4 μ) : MemLp (fun y : ℝ => y ^ 2) 2 μ := by refine (memLp_two_iff_integrable_sq ((continuous_pow 2).aestronglyMeasurable)).2 ?_ simpa [pow_mul] using h.int4.congr (by filter_upwards with y; ring) -
projResidual_memL2theorem — The residual function q is square-integrable (q ∈ L²(μ)): it is a degree-2 polynomial in y and μ has a finite fourth moment.Proof (Lean source)
theorem projResidual_memL2 (μ : Measure ℝ) [IsFiniteMeasure μ] (h : FiniteMoment4 μ) : MemLp (projResidual μ) 2 μ := by -- `q = y² − b₁·y − b₀` is a linear combination of the L²-functions `y²`, `y`, `1`. have hsq := memL2_sq μ h have hid := memL2_id μ h have hconst : MemLp (fun _ : ℝ => optIntercept μ) 2 μ := memLp_const _ have : MemLp (fun y : ℝ => y ^ 2 - (optIntercept μ + optSlope μ * y)) 2 μ := by have h1 : MemLp (fun y : ℝ => optSlope μ * y) 2 μ := hid.const_mul _ exact (hsq.sub (hconst.add h1)) exact this -
integrable_projResidualtheorem — q is integrable (finite measure + q ∈ L²).Proof (Lean source)
@[fun_prop] theorem integrable_projResidual (μ : Measure ℝ) [IsFiniteMeasure μ] (h : FiniteMoment4 μ) : Integrable (projResidual μ) μ := (projResidual_memL2 μ h).integrable (by norm_num) -
integral_projResidualtheorem — Orthogonality to the constant. ∫ q dμ = 0.hypothesesconclusion∫ y, projResidual μ y ∂μ = 0Proof (Lean source)
theorem integral_projResidual (μ : Measure ℝ) [IsProbabilityMeasure μ] (h : FiniteMoment4 μ) (hnd : rawMoment μ 1 ^ 2 < rawMoment μ 2) : ∫ y, projResidual μ y ∂μ = 0 := by have hsq : Integrable (fun y : ℝ => y ^ 2) μ := (memL2_sq μ h).integrable (by norm_num) have hid : Integrable (fun y : ℝ => y) μ := (memL2_id μ h).integrable (by norm_num) have hlin : Integrable (fun y : ℝ => optIntercept μ + optSlope μ * y) μ := (integrable_const (optIntercept μ)).add (hid.const_mul (optSlope μ)) unfold projResidual rw [MeasureTheory.integral_sub hsq hlin] rw [MeasureTheory.integral_add (integrable_const (optIntercept μ)) (hid.const_mul (optSlope μ))] rw [MeasureTheory.integral_const_mul] simp only [MeasureTheory.integral_const, smul_eq_mul] rw [show μ.real univ = 1 by simp] rw [show (∫ a : ℝ, a ∂μ) = rawMoment μ 1 by simp [rawMoment]] change rawMoment μ 2 - (1 * optIntercept μ + optSlope μ * rawMoment μ 1) = 0 ring_nf have hd : rawMoment μ 1 ^ 2 - rawMoment μ 2 ≠ 0 := by nlinarith unfold optIntercept optSlope optIntercept optSlope field_simp [hd] ring -
integral_id_mul_projResidualtheorem — Orthogonality to y. ∫ y·q dμ = 0.hypothesesconclusion∫ y, y * projResidual μ y ∂μ = 0Proof (Lean source)
theorem integral_id_mul_projResidual (μ : Measure ℝ) [IsProbabilityMeasure μ] (h : FiniteMoment4 μ) (hnd : rawMoment μ 1 ^ 2 < rawMoment μ 2) : ∫ y, y * projResidual μ y ∂μ = 0 := by have hid : Integrable (fun y : ℝ => y) μ := (memL2_id μ h).integrable (by norm_num) have hsq : Integrable (fun y : ℝ => y ^ 2) μ := (memL2_sq μ h).integrable (by norm_num) have hfun : (fun y : ℝ => y * projResidual μ y) = fun y : ℝ => y ^ 3 - optIntercept μ * y - optSlope μ * y ^ 2 := by funext y simp [projResidual] ring rw [hfun] have hterm1 : Integrable (fun y : ℝ => y ^ 3 - optIntercept μ * y) μ := h.int3.sub (hid.const_mul (optIntercept μ)) have hterm2 : Integrable (fun y : ℝ => optSlope μ * y ^ 2) μ := hsq.const_mul (optSlope μ) rw [MeasureTheory.integral_sub hterm1 hterm2] rw [MeasureTheory.integral_sub h.int3 (hid.const_mul (optIntercept μ))] rw [MeasureTheory.integral_const_mul] rw [MeasureTheory.integral_const_mul] rw [show (∫ a : ℝ, a ∂μ) = rawMoment μ 1 by simp [rawMoment]] change rawMoment μ 3 - optIntercept μ * rawMoment μ 1 - optSlope μ * rawMoment μ 2 = 0 have hd : rawMoment μ 1 ^ 2 - rawMoment μ 2 ≠ 0 := by nlinarith unfold optIntercept optSlope optIntercept optSlope field_simp [hd] ring -
integral_sq_mul_projResidualtheorem — y²-moment. ∫ y²·q dμ = r.hypothesesconclusion∫ y, y ^ 2 * projResidual μ y ∂μ = l2ResidualQuadratic μProof (Lean source)
theorem integral_sq_mul_projResidual (μ : Measure ℝ) [IsProbabilityMeasure μ] (h : FiniteMoment4 μ) (hnd : rawMoment μ 1 ^ 2 < rawMoment μ 2) : ∫ y, y ^ 2 * projResidual μ y ∂μ = l2ResidualQuadratic μ := by have hfun : (fun y : ℝ => y ^ 2 * projResidual μ y) = fun y : ℝ => projResidual μ y ^ 2 + optIntercept μ * projResidual μ y + optSlope μ * (y * projResidual μ y) := by funext y simp [projResidual] ring rw [hfun] have hq : Integrable (projResidual μ) μ := integrable_projResidual μ h have hq2 : Integrable (fun y : ℝ => projResidual μ y ^ 2) μ := (projResidual_memL2 μ h).integrable_sq have hyq : Integrable (fun y : ℝ => y * projResidual μ y) μ := (memL2_id μ h).integrable_mul (projResidual_memL2 μ h) have hbq : Integrable (fun y : ℝ => optIntercept μ * projResidual μ y) μ := hq.const_mul (optIntercept μ) have hcyq : Integrable (fun y : ℝ => optSlope μ * (y * projResidual μ y)) μ := hyq.const_mul (optSlope μ) have hsplit1 : (∫ y, (projResidual μ y ^ 2 + optIntercept μ * projResidual μ y) + optSlope μ * (y * projResidual μ y) ∂μ) = (∫ y, projResidual μ y ^ 2 + optIntercept μ * projResidual μ y ∂μ) + ∫ y, optSlope μ * (y * projResidual μ y) ∂μ := by simpa using MeasureTheory.integral_add (hq2.add hbq) hcyq have hsplit2 : (∫ y, projResidual μ y ^ 2 + optIntercept μ * projResidual μ y ∂μ) = (∫ y, projResidual μ y ^ 2 ∂μ) + ∫ y, optIntercept μ * projResidual μ y ∂μ := by simpa using MeasureTheory.integral_add hq2 hbq rw [hsplit1, hsplit2] rw [MeasureTheory.integral_const_mul] rw [MeasureTheory.integral_const_mul] rw [integral_sq_projResidual μ h hnd] rw [integral_projResidual μ h hnd] rw [integral_id_mul_projResidual μ h hnd] ring