Solution of the recursive estimation problem (Kalman)
ProvedVectorSpaceOpt.kalman_recursionWork in the Hilbert space of zero-mean random variables, , in which uncorrelated means orthogonal.
Consider the -dimensional dynamic model: a state evolving linearly with noise, observed through a linear measurement with noise,
with , known matrices. The process noises are white — and with each positive definite — mutually uncorrelated and uncorrelated with the initial state .
Write for the estimate of given the measurements up to time . Starting from and , generate estimates and matrices by the recursions
Then for every :
- each component of lies in the span of the past measurement components ;
- each error component is orthogonal to every past measurement component;
- the error covariance is .
By the projection theorem, claims 1 and 2 say exactly that is the linear minimum-variance estimate of given the past data — so the recursion computes the optimal estimate, and tracks its error covariance. This is the discrete-time Kalman filter, obtained here with no Gaussian assumption anywhere: only second-order statistics enter, and optimality is among linear estimates.
Formalization Note. The two recursions are supplied as hypotheses defining and , so the conclusions assert precisely the optimality and covariance claims. Being the optimal estimate is expressed as span membership plus orthogonality of the error rather than through a projection operator. Zero means are implicit in the Hilbert-space-of-random-variables representation, so expectations appear only as inner products.
import Mathlib open Matrix open scoped RealInnerProductSpace
namespace VectorSpaceOpt
theorem kalman_recursion {H : Type} [NormedAddCommGroup H]
[InnerProductSpace ℝ H] {n m : ℕ}
(Φ : ℕ → Matrix (Fin n) (Fin n) ℝ) (M : ℕ → Matrix (Fin m) (Fin n) ℝ)
(Q : ℕ → Matrix (Fin n) (Fin n) ℝ) (R : ℕ → Matrix (Fin m) (Fin m) ℝ)
(hR : ∀ k, (R k).PosDef)
(x u : ℕ → Fin n → H) (w v : ℕ → Fin m → H)
(hdyn : ∀ k i, x (k + 1) i = ∑ j, Φ k i j • x k j + u k i)
(hmeas : ∀ k i, v k i = ∑ j, M k i j • x k j + w k i)
(hQcov : ∀ k l i j, ⟪u k i, u l j⟫ = if k = l then Q k i j else 0)
(hRcov : ∀ k l i j, ⟪w k i, w l j⟫ = if k = l then R k i j else 0)
(huw : ∀ k l i j, ⟪u k i, w l j⟫ = 0)
(hux0 : ∀ k i j, ⟪u k i, x 0 j⟫ = 0)
(hwx0 : ∀ k i j, ⟪w k i, x 0 j⟫ = 0)
(P : ℕ → Matrix (Fin n) (Fin n) ℝ) (xh : ℕ → Fin n → H)
(hP0 : ∀ i j, P 0 i j = ⟪x 0 i, x 0 j⟫)
(hxh0 : ∀ i, xh 0 i = 0)
(hrec : ∀ k i, xh (k + 1) i =
∑ j, (Φ k * P k * (M k)ᵀ * (M k * P k * (M k)ᵀ + R k)⁻¹) i j •
(v k j - ∑ l, M k j l • xh k l) +
∑ j, Φ k i j • xh k j)
(hPrec : ∀ k, P (k + 1) =
Φ k * P k * (1 - (M k)ᵀ * (M k * P k * (M k)ᵀ + R k)⁻¹ * M k * P k) *
(Φ k)ᵀ + Q k) :
(∀ k i, xh k i ∈ Submodule.span ℝ {a : H | ∃ l < k, ∃ j, a = v l j}) ∧
(∀ k, ∀ l < k, ∀ i j, ⟪x k i - xh k i, v l j⟫ = 0) ∧
(∀ k i j, ⟪x k i - xh k i, x k j - xh k j⟫ = P k i j) := by sorry
end VectorSpaceOpt