Prove2Me
Navigate
DiscoverCollectionsFormalpediaBlogsUsersMomentumMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

Theorem 5:3, eq. (5:6a) — (pi,pj)=∣rj∣2∣pi∣2/∣ri∣2(p_i,p_j)=|r_j|^2|p_i|^2/|r_i|^2(pi​,pj​)=∣rj​∣2∣pi​∣2/∣ri​∣2 for i≤ji\le ji≤j

Proved
ConjGrad.ErrorDecrease.direction_inner_5_6a

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 r0,r1,…r_0,r_1,\dotsr0​,r1​,… and p0,p1,…p_0,p_1,\dotsp0​,p1​,… be the residuals and direction vectors of the cg-method (5:1) started at x0x_0x0​. Then for all indices i≤ji\le ji≤j,

(pi,pj)=∣rj∣2 ∣pi∣2∣ri∣2.(p_i,p_j) = \frac{|r_j|^2\,|p_i|^2}{|r_i|^2}.(pi​,pj​)=∣ri​∣2∣rj​∣2∣pi​∣2​.

In particular (pi,pj)≥0(p_i,p_j)\ge 0(pi​,pj​)≥0 for all i≤ji\le ji≤j: the direction vectors never make an obtuse angle with each other. In the proof of Theorem 6:3 this relation expresses the inner products (pl,pi−1)(p_l,p_{i-1})(pl​,pi−1​) through the squared residuals.

Formalization Note The identity is stated for all i≤ji\le ji≤j, without the restriction to steps before termination. After termination the recursion gives rj=pj=0r_j=p_j=0rj​=pj​=0, and both sides are 000 (the right side through Lean's convention t/0=0t/0=0t/0=0 when ri=0r_i=0ri​=0).

Preamble
import Mathlib
import Definitions.Def_ConjGrad_ErrorDecrease_cgIter

open Matrix
Formal statement
namespace ConjGrad.ErrorDecrease

theorem direction_inner_5_6a {n : ℕ} (A : Matrix (Fin n) (Fin n) ℝ) (hA : A.PosDef)
    (k x₀ : Fin n → ℝ) (i j : ℕ) (hij : i ≤ j) :
    (cgIter A k x₀ i).p ⬝ᵥ (cgIter A k x₀ j).p =
      ((cgIter A k x₀ j).r ⬝ᵥ (cgIter A k x₀ j).r) *
        ((cgIter A k x₀ i).p ⬝ᵥ (cgIter A k x₀ i).p) /
        ((cgIter A k x₀ i).r ⬝ᵥ (cgIter A k x₀ i).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. 415, Theorem 5:3, eq. (5:6a)
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 all z≠0z\ne0z=0.
  • k,x0∈Rnk, x_0\in\mathbb{R}^nk,x0​∈Rn are arbitrary. No solution vector hhh is involved.
  • i≤ji \le ji≤j are natural numbers.

The sequence. (xi,ri,pi)(x_i, r_i, p_i)(xi​,ri​,pi​) 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 ai=(ri⋅ri)/(pi⋅Api)a_i = (r_i\cdot r_i)/(p_i\cdot Ap_i)ai​=(ri​⋅ri​)/(pi​⋅Api​), then xi+1=xi+aipix_{i+1} = x_i + a_ip_ixi+1​=xi​+ai​pi​ and ri+1=ri−aiApir_{i+1} = r_i - a_iAp_iri+1​=ri​−ai​Api​.
  • Set bi=(ri+1⋅ri+1)/(ri⋅ri)b_i = (r_{i+1}\cdot r_{i+1})/(r_i\cdot r_i)bi​=(ri+1​⋅ri+1​)/(ri​⋅ri​) and pi+1=ri+1+bipip_{i+1} = r_{i+1}+b_ip_ipi+1​=ri+1​+bi​pi​.
  • Division by zero yields 000.

Conclusion. The statement asserts

pi⋅pj  =  ∣rj∣2 ∣pi∣2∣ri∣2,p_i\cdot p_j \;=\; \frac{|r_j|^2\,|p_i|^2}{|r_i|^2},pi​⋅pj​=∣ri​∣2∣rj​∣2∣pi​∣2​,

where ∣v∣2=v⋅v|v|^2 = v\cdot v∣v∣2=v⋅v is the squared Euclidean norm.

Degenerate cases.

  • ri=0r_i = 0ri​=0: the right-hand side is 000 by the division convention, so the claim becomes pi⋅pj=0p_i\cdot p_j = 0pi​⋅pj​=0.
  • i=ji = ji=j: the claim is ∣pi∣2=∣pi∣2|p_i|^2 = |p_i|^2∣pi​∣2=∣pi​∣2 when ri≠0r_i\ne0ri​=0. When ri=0r_i = 0ri​=0 it asserts ∣pi∣2=0|p_i|^2 = 0∣pi​∣2=0, i.e. pi=0p_i = 0pi​=0.
  • 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 paper
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me