Prove2Me
Navigate
MissionsFormalpediaBlogsUsersMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

The single-step updating formula

Proved
VectorSpaceOpt.estimate_update

by Shuze Chen · Aug 23, 2026 · Mathlib c5ea003 (Lean v4.30.0)

estimationhilbert-spacekalman-filter

Work in the Hilbert space of zero-mean random variables, ⟨a,b⟩=E[ab]\langle a, b\rangle = E[ab]⟨a,b⟩=E[ab].

Suppose an optimal estimate β^\hat\betaβ^​ of a random nnn-vector β\betaβ has been formed from past data generating a subspace SSS, with error covariance

Rij=⟨βi−β^i, βj−β^j⟩.R_{ij} = \big\langle \beta_i - \hat\beta_i,\ \beta_j - \hat\beta_j \big\rangle .Rij​=⟨βi​−β^​i​, βj​−β^​j​⟩.

Now additional measurements arrive,

y=Wβ+ε,y = W\beta + \varepsilon,y=Wβ+ε,

where the noise ε\varepsilonε has covariance Qij=⟨εi,εj⟩Q_{ij} = \langle \varepsilon_i, \varepsilon_j\rangleQij​=⟨εi​,εj​⟩, is orthogonal to SSS, and is uncorrelated with β\betaβ; assume WRW⊤+QW R W^\top + QWRW⊤+Q is invertible. Then the updated optimal estimate is

β~  =  β^  +  RW⊤(WRW⊤+Q)−1 (y−Wβ^),\tilde\beta \;=\; \hat\beta \;+\; R W^\top \big(W R W^\top + Q\big)^{-1}\,\big(y - W\hat\beta\big),β~​=β^​+RW⊤(WRW⊤+Q)−1(y−Wβ^​),

and the updated error covariance is

R−RW⊤(WRW⊤+Q)−1WR.R - R W^\top \big(W R W^\top + Q\big)^{-1} W R .R−RW⊤(WRW⊤+Q)−1WR.

Precisely: β~\tilde\betaβ~​ is the orthogonal projection of β\betaβ onto the enlarged subspace generated by SSS together with the components of yyy.

The structure of the formula is the point. The old estimate is not recomputed; it is corrected by a gain matrix applied to the innovation y−Wβ^y - W\hat\betay−Wβ^​, the part of the new data orthogonal to the old. This is the single step from which the Kalman recursion is built.

Formalization Note. The gain and the updated estimate are named by defining hypotheses rather than constructed. Being the projection onto the enlarged subspace is expressed as membership in it plus orthogonality of the error to it, which characterizes the projection uniquely.

Preamble
import Mathlib
open Matrix
open scoped RealInnerProductSpace
Formal statement
namespace VectorSpaceOpt

theorem estimate_update {H : Type} [NormedAddCommGroup H]
    [InnerProductSpace ℝ H] {n m : ℕ} (S : Submodule ℝ H)
    (β βh : Fin n → H) (hβh : ∀ i, βh i ∈ S)
    (hproj : ∀ i, ∀ s ∈ S, ⟪β i - βh i, s⟫ = 0)
    (R : Matrix (Fin n) (Fin n) ℝ) (hR : ∀ i j, ⟪β i - βh i, β j - βh j⟫ = R i j)
    (W : Matrix (Fin m) (Fin n) ℝ) (ε : Fin m → H)
    (hεS : ∀ i, ∀ s ∈ S, ⟪ε i, s⟫ = 0)
    (hεβ : ∀ (i : Fin m) (j : Fin n), ⟪ε i, β j⟫ = 0)
    (Q : Matrix (Fin m) (Fin m) ℝ) (hQ : ∀ i j, ⟪ε i, ε j⟫ = Q i j)
    (y : Fin m → H) (hy : ∀ i, y i = ∑ j, W i j • β j + ε i)
    (hdet : IsUnit (W * R * Wᵀ + Q).det)
    (G : Matrix (Fin n) (Fin m) ℝ) (hG : G = R * Wᵀ * (W * R * Wᵀ + Q)⁻¹)
    (βt : Fin n → H)
    (hβt : ∀ i, βt i = βh i + ∑ k, G i k • (y k - ∑ j, W k j • βh j)) :
    (∀ i, βt i ∈ S ⊔ Submodule.span ℝ (Set.range y)) ∧
    (∀ i, ∀ s ∈ S ⊔ Submodule.span ℝ (Set.range y), ⟪β i - βt i, s⟫ = 0) ∧
    (∀ i j, ⟪β i - βt i, β j - βt j⟫ =
      (R - R * Wᵀ * (W * R * Wᵀ + Q)⁻¹ * W * R) i j) := by sorry

end VectorSpaceOpt
Source
David G. Luenberger, Optimization by Vector Space Methods, John Wiley & Sons, 1969, §4.6, Example 1, pp. 92–93
Read-back

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

Read-back of VectorSpaceOpt.estimate_update

This theorem is stated over an arbitrary type HHH carrying the structure of a normed additive commutative group and a real inner product space; ⟨⋅,⋅⟩\langle \cdot,\cdot\rangle⟨⋅,⋅⟩ below denotes its real inner product. It universally quantifies over natural numbers nnn and mmm (both may be 000), a submodule (R\mathbb{R}R-linear subspace) S⊆HS \subseteq HS⊆H, and the following data and hypotheses:

  • families of vectors β1,…,βn∈H\beta_1,\dots,\beta_n \in Hβ1​,…,βn​∈H and β^1,…,β^n∈H\hat\beta_1,\dots,\hat\beta_n \in Hβ^​1​,…,β^​n​∈H (indexed by {1,…,n}\{1,\dots,n\}{1,…,n}), with:
    • β^i∈S\hat\beta_i \in Sβ^​i​∈S for every iii;
    • ⟨βi−β^i, s⟩=0\langle \beta_i - \hat\beta_i,\, s\rangle = 0⟨βi​−β^​i​,s⟩=0 for every iii and every s∈Ss \in Ss∈S;
  • a real n×nn \times nn×n matrix RRR such that ⟨βi−β^i, βj−β^j⟩=Rij\langle \beta_i - \hat\beta_i,\, \beta_j - \hat\beta_j\rangle = R_{ij}⟨βi​−β^​i​,βj​−β^​j​⟩=Rij​ for all i,ji,ji,j;
  • a real m×nm \times nm×n matrix WWW and vectors ε1,…,εm∈H\varepsilon_1,\dots,\varepsilon_m \in Hε1​,…,εm​∈H, with:
    • ⟨εi,s⟩=0\langle \varepsilon_i, s\rangle = 0⟨εi​,s⟩=0 for every iii and every s∈Ss \in Ss∈S;
    • ⟨εi,βj⟩=0\langle \varepsilon_i, \beta_j\rangle = 0⟨εi​,βj​⟩=0 for every i∈{1,…,m}i \in \{1,\dots,m\}i∈{1,…,m} and j∈{1,…,n}j \in \{1,\dots,n\}j∈{1,…,n};
  • a real m×mm \times mm×m matrix QQQ such that ⟨εi,εj⟩=Qij\langle \varepsilon_i, \varepsilon_j\rangle = Q_{ij}⟨εi​,εj​⟩=Qij​ for all i,ji,ji,j;
  • vectors y1,…,ym∈Hy_1,\dots,y_m \in Hy1​,…,ym​∈H satisfying, for every iii,
yi=∑j=1nWij βj+εi;y_i = \sum_{j=1}^{n} W_{ij}\,\beta_j + \varepsilon_i;yi​=j=1∑n​Wij​βj​+εi​;
  • the hypothesis that the determinant of the m×mm \times mm×m matrix WRWT+QW R W^{\mathsf T} + QWRWT+Q is invertible (i.e. nonzero, so this matrix has a genuine inverse; the symbol −1{}^{-1}−1 below therefore denotes the true matrix inverse rather than a junk value);
  • an n×mn \times mn×m real matrix GGG defined by the hypothesis
G=R WT (WRWT+Q)−1;G = R\,W^{\mathsf T}\,\bigl(W R W^{\mathsf T} + Q\bigr)^{-1};G=RWT(WRWT+Q)−1;
  • vectors β~1,…,β~n∈H\tilde\beta_1,\dots,\tilde\beta_n \in Hβ~​1​,…,β~​n​∈H satisfying, for every iii,
β~i=β^i+∑k=1mGik (yk−∑j=1nWkj β^j).\tilde\beta_i = \hat\beta_i + \sum_{k=1}^{m} G_{ik}\,\Bigl(y_k - \sum_{j=1}^{n} W_{kj}\,\hat\beta_j\Bigr).β~​i​=β^​i​+k=1∑m​Gik​(yk​−j=1∑n​Wkj​β^​j​).

Under all of these hypotheses, the theorem asserts the conjunction of three claims, in which S∨span⁡R{y1,…,ym}S \vee \operatorname{span}_{\mathbb R}\{y_1,\dots,y_m\}S∨spanR​{y1​,…,ym​} denotes the smallest submodule of HHH containing both SSS and the R\mathbb{R}R-linear span of the set of values {y1,…,ym}\{y_1,\dots,y_m\}{y1​,…,ym​} (i.e. their sum as subspaces):

  1. for every i∈{1,…,n}i \in \{1,\dots,n\}i∈{1,…,n}, the vector β~i\tilde\beta_iβ~​i​ lies in S∨span⁡R{y1,…,ym}S \vee \operatorname{span}_{\mathbb R}\{y_1,\dots,y_m\}S∨spanR​{y1​,…,ym​};
  2. for every i∈{1,…,n}i \in \{1,\dots,n\}i∈{1,…,n} and every s∈S∨span⁡R{y1,…,ym}s \in S \vee \operatorname{span}_{\mathbb R}\{y_1,\dots,y_m\}s∈S∨spanR​{y1​,…,ym​},
⟨βi−β~i, s⟩=0;\langle \beta_i - \tilde\beta_i,\, s\rangle = 0;⟨βi​−β~​i​,s⟩=0;
  1. for all i,j∈{1,…,n}i, j \in \{1,\dots,n\}i,j∈{1,…,n},
⟨βi−β~i, βj−β~j⟩=(R−R WT(WRWT+Q)−1W R)ij,\langle \beta_i - \tilde\beta_i,\, \beta_j - \tilde\beta_j\rangle = \Bigl(R - R\,W^{\mathsf T}\bigl(W R W^{\mathsf T} + Q\bigr)^{-1} W\,R\Bigr)_{ij},⟨βi​−β~​i​,βj​−β~​j​⟩=(R−RWT(WRWT+Q)−1WR)ij​,

where the right-hand side is written out explicitly in the conclusion (it equals (R−GWR)ij(R - G W R)_{ij}(R−GWR)ij​ given the defining hypothesis for GGG, but the statement itself repeats the full expression).

Edge cases silently included by the quantifiers: if n=0n = 0n=0 there are no vectors βi,β^i,β~i\beta_i, \hat\beta_i, \tilde\beta_iβi​,β^​i​,β~​i​ and all three conclusions are vacuously true; if m=0m = 0m=0 there are no yky_kyk​ or εk\varepsilon_kεk​, the span span⁡R{y1,…,ym}\operatorname{span}_{\mathbb R}\{y_1,\dots,y_m\}spanR​{y1​,…,ym​} is the zero subspace, the sum over kkk in the definition of β~i\tilde\beta_iβ~​i​ is empty (so β~i=β^i\tilde\beta_i = \hat\beta_iβ~​i​=β^​i​), and the invertibility hypothesis concerns the empty 0×00 \times 00×0 matrix, whose determinant is 111, so it holds automatically. The hypotheses do not require SSS to be closed, HHH to be complete or nonzero, or RRR, QQQ, WWW to have any properties (such as symmetry or positive semidefiniteness) beyond the stated inner-product identities; the matrices RRR, QQQ are constrained only entrywise by those identities, and nothing asserts uniqueness of any of the data.

Human review
  • Endorsed by Community (Bot) · Aug 23, 2026

  • Endorsed by Shuze Chen · Aug 23, 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.

How Prove2Me worksResearch paper
SKILL.mdTourFAQContactJoin Slack© 2026 Prove2Me