Prove2Me
Navigate
DiscoverCollectionsFormalpediaBlogsUsersMomentumMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

Theorem 5:2, first sentence — the cg-method is a cd-method

Proved
ConjGrad.Termination.cg_isCDRun

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

conjugate-directionsconjugate-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 and let k,x0∈Rnk, x_0 \in \mathbb{R}^nk,x0​∈Rn. The estimates xix_ixi​, residuals rir_iri​ and directions pip_ipi​ produced by the conjugate gradient method (3:1) started at x0x_0x0​ form a run of the method of conjugate directions for Ax=kAx = kAx=k: for all i≥0i \ge 0i≥0,

  1. ri=k−Axir_i = k - Ax_iri​=k−Axi​;
  2. xi+1=xi+aipix_{i+1} = x_i + a_i p_ixi+1​=xi​+ai​pi​ with ai=(pi,ri)(pi,Api)a_i = \dfrac{(p_i, r_i)}{(p_i, Ap_i)}ai​=(pi​,Api​)(pi​,ri​)​;
  3. (pi+1,Apj)=0(p_{i+1}, Ap_j) = 0(pi+1​,Apj​)=0 for j=0,1,…,ij = 0, 1, \dots, ij=0,1,…,i.

In the paper's words: the cg-method is a cd-method. Together with Theorem 4:2 this yields the finite termination of the cg-method.

Formalization Note Only the first sentence of Theorem 5:2 is formalized. The second sentence (the pip_ipi​ are obtained by AAA-orthogonalization of the residuals) and the converse ("a cd-method in which the residuals are mutually orthogonal is essentially a cg-method", which the paper qualifies by an informal continuity assumption) are not part of this statement.

Preamble
import Mathlib
import Definitions.Def_ConjGrad_Termination_cgIter
import Definitions.Def_ConjGrad_Termination_IsCDRun

open Matrix
Formal statement
namespace ConjGrad.Termination

/-- Theorem 5:2, first sentence (Hestenes–Stiefel 1952, p. 415): the cg-method is a
cd-method. For a symmetric positive definite `A`, the estimates, residuals and directions
produced by the cg-method (3:1) form a run of the cd-method (4:1)–(4:2): `rᵢ = k − Axᵢ`,
`xᵢ₊₁ = xᵢ + ((pᵢ,rᵢ)/(pᵢ,Apᵢ)) pᵢ`, and each `pᵢ₊₁` is conjugate to `p₀, …, pᵢ`. -/
theorem cg_isCDRun {n : ℕ} (A : Matrix (Fin n) (Fin n) ℝ) (hA : A.PosDef)
    (k x₀ : Fin n → ℝ) :
    IsCDRun A k (fun i => (cgIter A k x₀ i).x) (fun i => (cgIter A k x₀ i).r)
      (fun i => (cgIter A k x₀ i).p) := 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. 415, Theorem 5:2, first sentence
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,x0∈Rnk, x_0 \in \mathbb{R}^nk,x0​∈Rn be arbitrary.

The iteration. Let (xi,ri,pi)i∈N(x_i, r_i, p_i)_{i \in \mathbb{N}}(xi​,ri​,pi​)i∈N​ be the sequence defined recursively as follows. Start with

r0=p0=k−Ax0.r_0 = p_0 = k - A x_0 .r0​=p0​=k−Ax0​.

Then, for every i≥0i \ge 0i≥0,

ai=⟨ri,ri⟩⟨pi,Api⟩,xi+1=xi+aipi,ri+1=ri−aiApi,a_i = \frac{\langle r_i, r_i\rangle}{\langle p_i, A p_i\rangle}, \quad x_{i+1} = x_i + a_i p_i, \quad r_{i+1} = r_i - a_i A p_i,ai​=⟨pi​,Api​⟩⟨ri​,ri​⟩​,xi+1​=xi​+ai​pi​,ri+1​=ri​−ai​Api​, bi=⟨ri+1,ri+1⟩⟨ri,ri⟩,pi+1=ri+1+bipi.b_i = \frac{\langle r_{i+1}, r_{i+1}\rangle}{\langle r_i, r_i\rangle}, \quad p_{i+1} = r_{i+1} + b_i p_i .bi​=⟨ri​,ri​⟩⟨ri+1​,ri+1​⟩​,pi+1​=ri+1​+bi​pi​.

Every quotient with a zero denominator is 000, and the recursion never stops. Only r0r_0r0​ is defined as k−Ax0k - A x_0k−Ax0​; later residuals come from the recursive update.

Conclusion. The three sequences satisfy all of the following:

  1. For every i∈Ni \in \mathbb{N}i∈N,
ri=k−Axi.r_i = k - A x_i .ri​=k−Axi​.
  1. For every i∈Ni \in \mathbb{N}i∈N,
xi+1=xi+⟨pi,ri⟩⟨pi,Api⟩ pi,x_{i+1} = x_i + \frac{\langle p_i, r_i\rangle}{\langle p_i, A p_i\rangle}\, p_i ,xi+1​=xi​+⟨pi​,Api​⟩⟨pi​,ri​⟩​pi​,

with the quotient read as 000 when ⟨pi,Api⟩=0\langle p_i, A p_i\rangle = 0⟨pi​,Api​⟩=0. 3. For every i∈Ni \in \mathbb{N}i∈N and every j≤ij \le ij≤i,

⟨pi+1,Apj⟩=0.\langle p_{i+1}, A p_j\rangle = 0 .⟨pi+1​,Apj​⟩=0.

Degenerate cases.

  • Unbounded indices. All indices range over all natural numbers, including those beyond nnn.
  • n=0n = 0n=0. Every vector is empty and all three conditions hold trivially.
  • k=Ax0k = A x_0k=Ax0​. Then ri=pi=0r_i = p_i = 0ri​=pi​=0 and xi=x0x_i = x_0xi​=x0​ for all iii, so conditions 2 and 3 read xi+1=xix_{i+1} = x_ixi+1​=xi​ and 0=00 = 00=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 paper
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me