Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Theorem 4:2 — the cd-method reaches the solution in m ≤ n steps

Proved
ConjGrad.Termination.cd_terminates

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

conjugate-directionsfinite-terminationnumerical-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∈Rnk \in \mathbb{R}^nk∈Rn, and let hhh be the solution of Ah=kAh = kAh=k. Let xix_ixi​, rir_iri​, pip_ipi​ (i=0,1,…i = 0, 1, \dotsi=0,1,…) be a run of the method of conjugate directions for Ax=kAx = kAx=k (with an arbitrary initial estimate x0x_0x0​ and arbitrary initial direction p0p_0p0​), and suppose the directions p0,p1,…,pn−1p_0, p_1, \dots, p_{n-1}p0​,p1​,…,pn−1​ are all nonzero. Then there is an mmm with

m≤nandxm=h.m \le n \qquad\text{and}\qquad x_m = h.m≤nandxm​=h.

In the paper's words, the cd-method is an mmm-step method (m≤nm \le nm≤n): at the mmm-th step the estimate xmx_mxm​ is the desired solution hhh. Applied to the conjugate gradient method through Theorem 5:2, this gives the finite termination of that method.

Formalization Note The hypothesis that p0,…,pn−1p_0, \dots, p_{n-1}p0​,…,pn−1​ are nonzero is implicit in the paper's proof ("the vectors p0,p1,…p_0, p_1, \dotsp0​,p1​,… are linearly independent"); without it the statement fails (take p0=0p_0 = 0p0​=0). The solution may be reached before step nnn, after which the remaining directions may still be nonzero; the statement only requires them nonzero, not the residuals.

Preamble
import Mathlib
import Definitions.Def_ConjGrad_Termination_IsCDRun

open Matrix
Formal statement
namespace ConjGrad.Termination

/-- Theorem 4:2 (Hestenes–Stiefel 1952, p. 412). The cd-method is an `m`-step method with
`m ≤ n`: for a symmetric positive definite `n × n` matrix `A`, the solution `h` of `Ah = k`,
and every run of the cd-method whose directions `p₀, …, pₙ₋₁` are nonzero, some estimate
`xₘ` with `m ≤ n` equals `h`. -/
theorem cd_terminates {n : ℕ} (A : Matrix (Fin n) (Fin n) ℝ) (hA : A.PosDef)
    (k h : Fin n → ℝ) (hh : A *ᵥ h = k) (x r p : ℕ → Fin n → ℝ) (hcd : IsCDRun A k x r p)
    (hp : ∀ i < n, p i ≠ 0) :
    ∃ m ≤ n, x m = h := by sorry

end ConjGrad.Termination
Source
Hestenes & Stiefel, Methods of Conjugate Gradients for Solving Linear Systems, J. Res. Natl. Bur. Stand. 49(6) (1952), https://doi.org/10.6028/jres.049.044, p. 412, Theorem 4:2 and its proof; standing assumption (A symmetric positive definite) p. 410
Read-back

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

Setting. Let n∈Nn \in \mathbb{N}n∈N and let AAA be a real n×nn\times nn×n matrix that is positive definite in this sense:

  • AAA is symmetric, A⊤=AA^\top = AA⊤=A;
  • ⟨v,Av⟩>0\langle v, A v\rangle > 0⟨v,Av⟩>0 for every nonzero v∈Rnv \in \mathbb{R}^nv∈Rn.

Here ⟨u,v⟩=∑lulvl\langle u,v\rangle = \sum_l u_l v_l⟨u,v⟩=∑l​ul​vl​. Let k,h∈Rnk, h \in \mathbb{R}^nk,h∈Rn satisfy Ah=kA h = kAh=k.

Let (xi)(x_i)(xi​), (ri)(r_i)(ri​), (pi)(p_i)(pi​), for i∈Ni \in \mathbb{N}i∈N, be sequences in Rn\mathbb{R}^nRn that satisfy all of these conditions:

  • ri=k−Axir_i = k - A x_iri​=k−Axi​ for every iii;
  • xi+1=xi+⟨pi,ri⟩⟨pi,Api⟩ pix_{i+1} = x_i + \dfrac{\langle p_i, r_i\rangle}{\langle p_i, A p_i\rangle}\, p_ixi+1​=xi​+⟨pi​,Api​⟩⟨pi​,ri​⟩​pi​ for every iii, where the quotient is 000 if its denominator is 000;
  • ⟨pi+1,Apj⟩=0\langle p_{i+1}, A p_j\rangle = 0⟨pi+1​,Apj​⟩=0 for every iii and every j≤ij \le ij≤i.

Assume further that pi≠0p_i \ne 0pi​=0 for every iii with i<ni < ni<n, that is, for p0,…,pn−1p_0, \dots, p_{n-1}p0​,…,pn−1​. Nothing is assumed about pip_ipi​ for i≥ni \ge ni≥n, and x0x_0x0​ and p0p_0p0​ are otherwise arbitrary.

Conclusion. There exists a natural number mmm with m≤nm \le nm≤n such that

xm=h.x_m = h .xm​=h.

The statement only asserts that some such mmm exists. It does not name mmm and does not say what happens to xix_ixi​ for i>mi > mi>m.

Degenerate cases.

  • n=0n = 0n=0. The nonzero-direction hypothesis is vacuous, all vectors are empty, the empty matrix satisfies positive definiteness vacuously, and x0=hx_0 = hx0​=h holds trivially, so m=0m = 0m=0 works.
  • n=1n = 1n=1. The hypotheses require p0≠0p_0 \ne 0p0​=0.
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