Prove2Me
Navigate
DiscoverCollectionsFormalpediaBlogsUsersMomentumMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

Theorem 5:5, eq. (5:10) — ai=∣ri∣2/(pi,Api)=(pi,ri)/(pi,Api)=(pi,r0)/(pi,Api)a_i=|r_i|^2/(p_i,Ap_i)=(p_i,r_i)/(p_i,Ap_i)=(p_i,r_0)/(p_i,Ap_i)ai​=∣ri​∣2/(pi​,Api​)=(pi​,ri​)/(pi​,Api​)=(pi​,r0​)/(pi​,Api​)

Proved
ConjGrad.Termination.cg_stepLength_formulas

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 xix_ixi​, rir_iri​, pip_ipi​ be produced by the conjugate gradient method (3:1) started at x0x_0x0​, with step lengths ai=∣ri∣2/(pi,Api)a_i = |r_i|^2/(p_i, Ap_i)ai​=∣ri​∣2/(pi​,Api​) as in (3:1b). Then for every iii

ai=∣ri∣2(pi,Api)=(pi,ri)(pi,Api)=(pi,r0)(pi,Api).a_i = \frac{|r_i|^2}{(p_i, Ap_i)} = \frac{(p_i, r_i)}{(p_i, Ap_i)} = \frac{(p_i, r_0)}{(p_i, Ap_i)}.ai​=(pi​,Api​)∣ri​∣2​=(pi​,Api​)(pi​,ri​)​=(pi​,Api​)(pi​,r0​)​.

The middle expression is the step length (4:1a) of the method of conjugate directions, so this identity is one half of the statement that the cg-method is a cd-method; the last expression is (4:4).

Formalization Note The first equality is the definition of aia_iai​ (cgA); the statement asserts the other two. It covers only formula (5:10) of Theorem 5:5; the formulas (5:11) for bib_ibi​ and the Rayleigh quotient bounds (5:12) are not part of it. After the method reaches the solution both sides are 000.

Preamble
import Mathlib
import Definitions.Def_ConjGrad_Termination_cgIter

open Matrix
Formal statement
namespace ConjGrad.Termination

/-- Theorem 5:5, eq. (5:10) (Hestenes–Stiefel 1952, p. 416). For a symmetric positive
definite `A`, the step length `aᵢ = |rᵢ|²/(pᵢ, Apᵢ)` of the cg-method (3:1b) also equals
`(pᵢ, rᵢ)/(pᵢ, Apᵢ)` and `(pᵢ, r₀)/(pᵢ, Apᵢ)`. -/
theorem cg_stepLength_formulas {n : ℕ} (A : Matrix (Fin n) (Fin n) ℝ) (hA : A.PosDef)
    (k x₀ : Fin n → ℝ) (i : ℕ) :
    cgA A (cgIter A k x₀ i) =
        ((cgIter A k x₀ i).p ⬝ᵥ (cgIter A k x₀ i).r) /
          ((cgIter A k x₀ i).p ⬝ᵥ (A *ᵥ (cgIter A k x₀ i).p)) ∧
      cgA A (cgIter A k x₀ i) =
        ((cgIter A k x₀ i).p ⬝ᵥ (cgIter A k x₀ 0).r) /
          ((cgIter A k x₀ i).p ⬝ᵥ (A *ᵥ (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. 416, Theorem 5:5, eq. (5:10)
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 and fix an index i∈Ni \in \mathbb{N}i∈N.

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.

Conclusion. For the fixed iii, the step length aia_iai​ satisfies both

ai=⟨pi,ri⟩⟨pi,Api⟩andai=⟨pi,r0⟩⟨pi,Api⟩,a_i = \frac{\langle p_i, r_i\rangle}{\langle p_i, A p_i\rangle} \qquad\text{and}\qquad a_i = \frac{\langle p_i, r_0\rangle}{\langle p_i, A p_i\rangle},ai​=⟨pi​,Api​⟩⟨pi​,ri​⟩​andai​=⟨pi​,Api​⟩⟨pi​,r0​⟩​,

with all quotients read as 000 when their denominator is 000.

Degenerate cases.

  • ⟨pi,Api⟩=0\langle p_i, A p_i\rangle = 0⟨pi​,Api​⟩=0. By positive definiteness this happens exactly when pi=0p_i = 0pi​=0. Then all three expressions are 000 by the division convention, so the statement holds trivially at that index.
  • Arbitrary iii. The index is any natural number, including values beyond nnn.
  • n=0n = 0n=0. Everything is 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 paper
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me