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 VectorSpaceOptRead-back
What the Lean code literally says, in plain math · claude-fable-5
Read-back — kalman_recursion
Let be a real inner product space (a normed additive commutative group equipped with a real inner product ; may be any such space, including the zero space), and let be natural numbers, both allowed to be . All "vectors" below are families of elements of : for each time , the state and the quantity are families , of elements of (indices ranging over an -element set), while and are families of elements of . The data also includes, for every : an real matrix , an real matrix , an real matrix , and an real matrix , with each assumed positive definite (in particular symmetric).
The hypotheses are:
- Dynamics: for all and ,
- Measurement: for all and ,
- Inner-product structure (stated with inner products in , not with any probabilistic expectation; no zero-mean or distributional assumption appears anywhere):
for all ; moreover for all , and , for all . Note these force and to be Gram matrices of vectors in ; combined with positive definiteness of , the hypotheses can only be satisfied when the vectors are linearly independent in (so, e.g., if the hypotheses are unsatisfiable and the theorem is vacuous). is not assumed positive definite or even semidefinite as a matrix hypothesis.
- Given recursions: two further data, a sequence of real matrices and families of elements of , are hypothesized (not constructed) to satisfy: initial conditions
the estimate recursion, for all ,
and the matrix recursion, for all ,
Here is the total matrix-inverse operation: if is invertible it is the usual inverse, but if it is singular the operation silently returns the zero matrix, and the recursions are then hypotheses about that degenerate expression. No hypothesis asserts that is invertible.
Under all of these hypotheses, the theorem asserts the conjunction of three claims:
- Span membership: for every and every , the element lies in the linear span (over ) of the set of all observation components taken at times strictly before :
For this set is empty, so the claim says (i.e. lies in the zero subspace).
- Orthogonality of the error to past observations: for every , every , and all indices ,
For this is vacuous (there is no ).
- Error Gram identity: for every and all ,
If or , the corresponding index sets are empty: sums over them are , and all statements quantified over those indices hold vacuously. The proof is not given (the statement ends in sorry), so this records only what is claimed.
Confirmed by the mission captain (proposal self-audit).