Drift.lean
Lean 4 source, lean/DataMiningAsObservation/Drift.lean at commit bccca4f. Appendix C, Machine-checked statements, says what each file proves. All Lean files.
/-
Drift.lean. Equation 13.1, drift as the consumer reads it.
The damage a drift does is the read distortion of the drift, the trace of the read operator
times the drift's second moment, so it is consumer-relative. The same drift is read as its
full squared size by a consumer that reads the direction it moves along and as nothing by a
consumer that reads an orthogonal direction. A drift confined to a consumer's nuisance is
read as zero however large it is, and no drift is read as less than zero.
-/
import Mathlib
import DataMiningAsObservation.ReadDistortion
import DataMiningAsObservation.ReadOperator
namespace DMO.Drift
open Matrix DMO.ReadDistortion DMO.ReadOperator
variable {n : ℕ}
/-- The damage of a single drift vector `δ` under the read operator `P`, its quadratic form. -/
def damage (P : Matrix (Fin n) (Fin n) ℝ) (δ : Fin n → ℝ) : ℝ := quad P δ
/-- A consumer that reads one direction `g` reads a drift as the squared projection on it. -/
theorem damage_rank_one (g δ : Fin n → ℝ) : damage (vecMulVec g g) δ = (g ⬝ᵥ δ) ^ 2 := by
unfold damage quad
rw [rank_one_reads_one_direction, dotProduct_smul, smul_eq_mul, dotProduct_comm]
ring
/-- **The same drift, two consumers.** A drift along the first axis is read as its full
squared size by the consumer that reads the first axis and as nothing by the consumer that
reads the second. -/
theorem same_drift_two_consumers (c : ℝ) (h : 2 ≤ n) :
damage (vecMulVec (Pi.single ⟨0, by omega⟩ 1) (Pi.single ⟨0, by omega⟩ 1))
(c • Pi.single (⟨0, by omega⟩ : Fin n) 1) = c ^ 2 ∧
damage (vecMulVec (Pi.single ⟨1, by omega⟩ 1) (Pi.single ⟨1, by omega⟩ 1))
(c • Pi.single (⟨0, by omega⟩ : Fin n) 1) = 0 := by
constructor
· rw [damage_rank_one]
simp [dotProduct_smul, dotProduct_single]
· rw [damage_rank_one]
simp [dotProduct_smul, dotProduct_single]
/-- **A drift in the nuisance is read as zero**, whatever its size. -/
theorem damage_eq_zero_of_nuisance {Ω : Type*} [Fintype Ω] (w : Ω → ℝ) (g : Ω → Fin n → ℝ)
(δ : Fin n → ℝ) (h : ∀ ω, g ω ⬝ᵥ δ = 0) : damage (readOp w g) δ = 0 := by
unfold damage quad
rw [quad_readOp]
exact Finset.sum_eq_zero fun ω _ => by rw [h ω]; ring
/-- **No drift is read as less than zero** by a consumer with nonnegative row weights. -/
theorem damage_nonneg {Ω : Type*} [Fintype Ω] (w : Ω → ℝ) (hw : ∀ ω, 0 ≤ w ω)
(g : Ω → Fin n → ℝ) (δ : Fin n → ℝ) : 0 ≤ damage (readOp w g) δ :=
quad_readOp_nonneg w hw g δ
end DMO.Drift