Stationary Gaussian model and standard DKF recursion
DefinitionDKFAsymptotics_FilterThe model consists of with positive-definite noise and stationary covariances and . It defines the stationary density, Gaussian transition, prediction integral, and discriminative update normalized by its norm. Update validity means a measurable weight with finite, strictly positive normalizer. The standard DKF matrix step uses prediction covariance , updated precision , its inverse covariance, and the corresponding precision-weighted mean. The recursive DKF starts at mean zero and covariance and incorporates the observation functions at each positive time. Matrix expressions are total; a separate validity predicate requires invertible precision and positive-definite updated covariance. No universal step-validity condition is imposed by the recursion.
import Definitions.Def_DKFAsymptotics_Densities
noncomputable section
open MeasureTheory Filter Matrix
open scoped Topology ENNReal
namespace DKFAsymptotics
structure Model (d : ℕ) where
A : Covariance d
Γ : Covariance d
S : Covariance d
Γ_posDef : Γ.PosDef
S_posDef : S.PosDef
stationary : S = A * S * A.transpose + Γ
variable {d : ℕ}
def prior (M : Model d) : Density d := gaussianPDF 0 M.S
def transition (M : Model d) (y z : State d) : ℝ :=
gaussianPDF (M.A *ᵥ y) M.Γ z
def predictDensity (M : Model d) (s : Density d) : Density d :=
fun z => ∫ y, transition M y z * s y ∂volume
def updateWeight (M : Model d) (s u : Density d) : Density d :=
fun z => u z * predictDensity M s z / prior M z
def UpdateDefined (M : Model d) (s u : Density d) : Prop :=
AEStronglyMeasurable (updateWeight M s u) volume ∧
0 < l1Norm (updateWeight M s u) ∧ l1Norm (updateWeight M s u) < ⊤
def updateDensity (M : Model d) (s u : Density d) : Density d :=
fun z => updateWeight M s u z / (l1Norm (updateWeight M s u)).toReal
structure GaussianState (d : ℕ) where
mean : State d
covariance : Covariance d
def predictedCovariance (M : Model d) (V : Covariance d) : Covariance d :=
M.A * V * M.A.transpose + M.Γ
def updatePrecision (M : Model d) (V U : Covariance d) : Covariance d :=
U⁻¹ + (predictedCovariance M V)⁻¹ - M.S⁻¹
def dkfStep (M : Model d) (previous observation : GaussianState d) : GaussianState d :=
let G := predictedCovariance M previous.covariance
let T := (updatePrecision M previous.covariance observation.covariance)⁻¹
⟨T *ᵥ (observation.covariance⁻¹ *ᵥ observation.mean +
G⁻¹ *ᵥ (M.A *ᵥ previous.mean)), T⟩
def ValidStep (M : Model d) (previous observation : GaussianState d) : Prop :=
IsUnit (updatePrecision M previous.covariance observation.covariance).det ∧
(dkfStep M previous observation).covariance.PosDef
def dkf {X : Type} (M : Model d) (f : X → State d) (Q : X → Covariance d)
(observations : ℕ+ → X) : ℕ → GaussianState d
| 0 => ⟨0, M.S⟩
| t + 1 => dkfStep M (dkf M f Q observations t)
⟨f (observations ⟨t + 1, Nat.succ_pos t⟩), Q (observations ⟨t + 1, Nat.succ_pos t⟩)⟩
end DKFAsymptotics
Read-back
What the Lean code literally says, in plain math · GPT-6 (Codex independent sub-agent)
Independent read-back: filter declarations
Scope: the thirteen source declarations in Definitions/Def_DKFAsymptotics_Filter.lean. Only that file, its imported density definitions, and relevant Mathlib definitions were used. In the paragraphs below, vectors have coordinates indexed by the finite set with elements, matrices are real matrices, and is product Lebesgue measure on . A “positive definite” real matrix is symmetric and has strictly positive quadratic form on every nonzero vector. Dimension is allowed; its vector space is a singleton of Lebesgue mass one and its unique empty matrix has determinant one. Matrix inversion means the ordinary inverse for an invertible matrix and the zero matrix otherwise. Real division by zero is zero. These conventions are also stated where they affect a declaration's domain or result.
Model
For each natural number , a model consists of three real matrices , proofs that and are symmetric and satisfy and for every nonzero , and a proof of the exact matrix equality . There are no separately imposed symmetry, invertibility, or positive definiteness conditions on , and the matrix type itself imposes none on any of the three matrices; the two positivity conditions are the explicit additional fields. No random variables, probability measures, observation space, or observation law are fields of this structure. For , all three matrices are the unique empty matrix, symmetry and the displayed equality hold, and the strict quadratic-form conditions are vacuous because there are no nonzero vectors.
prior
For every natural number and every model consisting of real matrices with symmetric positive definite and , the prior is the real-valued function on given by . This is a definition of a function, with no additional probability-density predicate bundled into its return value. Matrix inversion is total, being zero on singular matrices, and the real square root is zero on nonpositive arguments, but the model's positive definiteness of gives positive determinant and therefore prevents a zero denominator in this formula. If , the unique input vector has quadratic form zero, the determinant is one, and the function value is one.
transition
For every natural number , every model of real matrices with symmetric positive definite and , and every pair of vectors , the transition value is the real number . The arguments are arbitrary vectors, and this declaration returns a real number rather than a probability measure or a proof about an integral. Positive definiteness of gives a positive determinant and a nonzero normalizing denominator, despite the underlying total conventions that matrix inverses of singular matrices and real reciprocals of zero are zero. For , there is one pair of vectors and its transition value is one.
predictDensity
For every natural number , every model with symmetric positive definite real matrices satisfying , and every real-valued function , the predicted function is . The integral is the real-valued Bochner integral with respect to Lebesgue measure: at any fixed where the displayed integrand is not integrable, its value is defined to be zero. There is no hypothesis that is measurable, integrable, nonnegative, normalized, or Gaussian, and no such property is included in the return type. Thus the definition accepts signed and nonmeasurable functions as well as probability densities. When , the space contains a single point of mass one, the kernel equals one, and .
updateWeight
For every natural number , every model with symmetric positive definite real matrices satisfying , and arbitrary real-valued functions , the weight function is , where and . The latter is a Bochner integral defined to be zero when its integrand is not integrable. No measurability, sign, normalization, or Gaussian assumption is made on either input function, and neither an update-defined condition nor any other condition is required to form this weight. Real division is total and gives zero for a zero denominator, although for the model matrices here. In dimension zero, at the unique point , the formula is .
UpdateDefined
For every natural number , every model with symmetric positive definite real matrices satisfying , and arbitrary real-valued functions , this proposition holds exactly when the real function is equal Lebesgue-almost everywhere to a strongly measurable function and its extended nonnegative integral satisfies ; here , and , with the inner real Bochner integral set to zero if its integrand is not integrable. The notation for the outer integral embeds the nonnegative real number into the extended nonnegative reals before integration. Strong measurability here means representability as a pointwise limit of measurable simple functions; only an almost-everywhere equality with such a representative is required of . The proposition does not require nonnegativity of , integral one, Gaussian form, or integrability of each inner prediction integrand; its norm condition concerns the absolute value of the resulting weight. Zero weights fail the strict lower bound, and an infinite absolute-value integral fails the strict upper bound. For , every function on the singleton is measurable and finite-valued, so the proposition is exactly .
updateDensity
For every natural number , every model with symmetric positive definite real matrices satisfying , and arbitrary real-valued functions , the updated function is , where , , , and , with any nonintegrable inner Bochner integral defined to be zero. The extended integral defining uses the nonnegative real absolute value embedded into the extended nonnegative reals. The conversion returns the corresponding real for a finite and returns zero when ; real division by zero is zero. Consequently, and both make identically zero, including at any exceptional points where . No update-defined, measurability, integrability, sign, or normalization assumption is a parameter of this definition, and absolute-value normalization does not remove negative values of . For , the value at the unique point is , with value zero when the product is zero.
GaussianState
For every natural number , a Gaussian state is exactly a pair consisting of a vector , called its mean, and an arbitrary real matrix , called its covariance. The structure imposes no symmetry, positivity, positive definiteness, invertibility, or probability-distribution condition on the matrix, and contains no density, measure, random variable, or assertion linking the two fields to a probability law. In particular, singular, nonsymmetric, and indefinite matrices are allowed whenever their dimensions permit them. For , both fields are unique, so there is exactly one such pair.
predictedCovariance
For every natural number , every model of real matrices with symmetric positive definite and , and every real matrix , this definition returns . There is no positivity, symmetry, or invertibility hypothesis on , and the return value is an unrestricted matrix rather than a matrix bundled with positive definiteness. The formula uses matrix multiplication in the indicated order and the transpose of . For , it returns the unique empty matrix.
updatePrecision
For every natural number , every model with symmetric positive definite real matrices satisfying , and arbitrary real matrices , the precision expression is the matrix . Each matrix inverse is the usual inverse if its determinant is nonzero and the zero matrix otherwise. The model assumption ensures that is invertible, but no positivity, symmetry, or invertibility hypothesis is made on , on , on , or on the resulting precision expression. Thus a singular or a singular predicted matrix contributes a zero inverse term, and the definition still returns a matrix. For , it returns the unique empty matrix, whose determinant is one.
dkfStep
For every natural number , every model with symmetric positive definite real matrices satisfying , and every two pairs and of a vector in and an arbitrary real matrix, called the previous and observation states respectively, define , , and ; the step returns the pair . All matrix inverses are ordinary inverses at invertible matrices and zero at singular matrices. No positive definiteness, symmetry, invertibility, or validity condition is imposed on either input state, on , on , or on the output; this is a total definition on all the stated inputs. If is singular, then and the returned vector and matrix are both zero. The term involving appears only in ; the formula contains no additional vector term using . For , the result is the unique pair of an empty vector and an empty matrix.
ValidStep
For every natural number , every model with symmetric positive definite real matrices satisfying , and arbitrary previous and observation pairs , of vectors and real matrices, this proposition is the conjunction that is a unit in , equivalently , and that is symmetric positive definite, where . The latter matrix is the covariance field of the pair returned by the step. Matrix inverses use zero at singular inputs, so and remain allowed to be singular; the proposition imposes no separate positive definiteness or invertibility condition on them or on . It imposes no condition on the two mean vectors, and neither a probability density nor a normalization integral occurs in it. In dimension zero, , symmetry holds, and strict positivity on nonzero vectors is vacuous, so the proposition holds for the unique state pairs.
dkf
For every natural number , every type , every model with symmetric positive definite real matrices satisfying , every two functions and , and every sequence indexed by strictly positive natural numbers, this definition returns a sequence of vector-matrix pairs for all natural times . Its initial value is . For every natural , put , , and ; then and . The observation at index exists because that index is positive; there is no observation at index zero used in the initialization. All matrix inverses are total and become zero for singular matrices, and no positivity or symmetry of , valid-step condition, measurability, probabilistic assumption, or regularity assumption on is required. In particular, the recursion still returns values if a precision expression is singular, in which case that step's vector and covariance are zero. Although itself is unrestricted, supplying entails that is inhabited, since ; no complete input tuple exists when is empty. In dimension zero, the sequence is constantly the unique pair of empty vector and empty matrix.
Confirmed by the mission captain (proposal self-audit).