Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Theorem 6:1, eq. (6:2) — f(xi)−f(xj)=ai∣ri∣2+⋯+aj−1∣rj−1∣2f(x_i)-f(x_j)=a_i|r_i|^2+\cdots+a_{j-1}|r_{j-1}|^2f(xi​)−f(xj​)=ai​∣ri​∣2+⋯+aj−1​∣rj−1​∣2

Proved
ConjGrad.ErrorDecrease.error_diff_6_2

by mikedeng1 · Sep 26, 2026 · Mathlib 0df444a (Lean v4.33.1)

conjugate-gradientnumerical-linear-algebrap2o-batch-p100ap2o-gran-per-chapterp2o-plan-paperp2o-v1

Let AAA be a real symmetric positive definite n×nn\times nn×n matrix, let k,x0∈Rnk,x_0\in\mathbb{R}^nk,x0​∈Rn, and let hhh solve Ah=kAh=kAh=k. Let xlx_lxl​, rlr_lrl​ and ala_lal​ be the estimates, residuals and step lengths of the cg-method (5:1) started at x0x_0x0​, and let f(x)=(h−x,A(h−x))f(x)=(h-x,A(h-x))f(x)=(h−x,A(h−x)) be the error function (4:5). Then for all indices i<ji<ji<j,

f(xi)−f(xj)=ai∣ri∣2+ai+1∣ri+1∣2+⋯+aj−1∣rj−1∣2=∑l=ij−1al ∣rl∣2.f(x_i) - f(x_j) = a_i|r_i|^2 + a_{i+1}|r_{i+1}|^2 + \cdots + a_{j-1}|r_{j-1}|^2 = \sum_{l=i}^{j-1} a_l\,|r_l|^2 .f(xi​)−f(xj​)=ai​∣ri​∣2+ai+1​∣ri+1​∣2+⋯+aj−1​∣rj−1​∣2=l=i∑j−1​al​∣rl​∣2.

The identity gives the total decrease of the error function over several steps of the method. With j=mj=mj=m and xm=hx_m=hxm​=h, it expresses f(xi)f(x_i)f(xi​) itself as a sum of computable quantities, which is how it enters the proof of Theorem 6:3.

Preamble
import Mathlib
import Definitions.Def_ConjGrad_ErrorDecrease_cgIter
import Definitions.Def_ConjGrad_ErrorDecrease_errorFun

open Matrix
Formal statement
namespace ConjGrad.ErrorDecrease

theorem error_diff_6_2 {n : ℕ} (A : Matrix (Fin n) (Fin n) ℝ) (hA : A.PosDef)
    (k x₀ h : Fin n → ℝ) (hh : A *ᵥ h = k) (i j : ℕ) (hij : i < j) :
    errorFun A h (cgIter A k x₀ i).x - errorFun A h (cgIter A k x₀ j).x =
      ∑ l ∈ Finset.Ico i j,
        cgAlpha A (cgIter A k x₀ l) * ((cgIter A k x₀ l).r ⬝ᵥ (cgIter A k x₀ l).r) := by sorry

end ConjGrad.ErrorDecrease
Source
Hestenes & Stiefel, Methods of Conjugate Gradients for Solving Linear Systems, J. Res. Natl. Bur. Stand. 49(6) (1952), p. 416, Theorem 6:1, eq. (6:2)
Read-back

What the Lean code literally says, in plain math · claude-opus-5-5

Setting and hypotheses.

  • nnn is a natural number.
  • AAA is a positive definite real n×nn\times nn×n matrix: symmetric, with z⋅Az>0z\cdot Az>0z⋅Az>0 for z≠0z\neq 0z=0.
  • k,x0∈Rnk, x_0\in\mathbb{R}^nk,x0​∈Rn are arbitrary.
  • hhh satisfies Ah=kAh=kAh=k.
  • i<ji<ji<j are natural numbers, with strict inequality.

The sequence. (xl,rl,pl)(x_l, r_l, p_l)(xl​,rl​,pl​) is generated from AAA, kkk and x0x_0x0​ as follows:

  • Start with r0=p0=k−Ax0r_0=p_0=k-Ax_0r0​=p0​=k−Ax0​.
  • Set al=(rl⋅rl)/(pl⋅Apl)a_l=(r_l\cdot r_l)/(p_l\cdot Ap_l)al​=(rl​⋅rl​)/(pl​⋅Apl​), then xl+1=xl+alplx_{l+1}=x_l+a_lp_lxl+1​=xl​+al​pl​ and rl+1=rl−alAplr_{l+1}=r_l-a_lAp_lrl+1​=rl​−al​Apl​.
  • Set bl=(rl+1⋅rl+1)/(rl⋅rl)b_l=(r_{l+1}\cdot r_{l+1})/(r_l\cdot r_l)bl​=(rl+1​⋅rl+1​)/(rl​⋅rl​) and pl+1=rl+1+blplp_{l+1}=r_{l+1}+b_lp_lpl+1​=rl+1​+bl​pl​.
  • Division by zero yields 000.

Function used. The error function is f(x)=(h−x)⋅A(h−x)f(x)=(h-x)\cdot A(h-x)f(x)=(h−x)⋅A(h−x).

Conclusion. The statement asserts

f(xi)−f(xj)  =  ∑l=ij−1al ∣rl∣2,f(x_i) - f(x_j) \;=\; \sum_{l=i}^{j-1} a_l\,|r_l|^2,f(xi​)−f(xj​)=l=i∑j−1​al​∣rl​∣2,

where the sum runs over l=i,i+1,…,j−1l = i, i+1, \dots, j-1l=i,i+1,…,j−1 and ∣v∣2=v⋅v|v|^2 = v\cdot v∣v∣2=v⋅v.

Degenerate cases.

  • i=ji = ji=j: excluded by the hypothesis. The statement says nothing about it.
  • rl=0r_l = 0rl​=0 or pl=0p_l = 0pl​=0: the corresponding summand is 000, because either ∣rl∣2=0|r_l|^2=0∣rl​∣2=0 or al=0a_l=0al​=0 by the division convention.
  • n=0n=0n=0: both sides are 000.
Human review
  • Endorsed by Shuze Chen · Sep 27, 2026

    Confirmed by the moderator at approval.

  • Endorsed by mikedeng1 · Sep 27, 2026

    Confirmed by the mission captain (proposal self-audit).

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