ProbeCliff.lean
Lean 4 source, lean/DataMiningAsObservation/ProbeCliff.lean at commit bccca4f. Appendix C, Machine-checked statements, says what each file proves. All Lean files.
/-
ProbeCliff.lean. Chapter 11 section 11.4, equation 11.4, the blind probe and its budget cliff.
A blind probe reads a consumer by central differences along chosen directions, two calls per
direction. For an affine consumer a central difference along a direction returns the
gradient's inner product with that direction exactly, at any step, so probing the standard
basis recovers the gradient in two calls per coordinate. A probe confined to fewer directions
than the dimension has a blind direction, a nonzero vector orthogonal to every probe
direction, and two consumers whose gradients differ by that vector return identical readings
on every probe call at every input. Recovery is therefore a cliff at the full dimension.
-/
import Mathlib
namespace DMO.ProbeCliff
open Matrix
variable {d k : ℕ}
/-- The central difference of a consumer `f` at `x` along `u` with step `ε`, the two-call
sensitivity estimate of chapter 11. -/
noncomputable def centralDiff (f : (Fin d → ℝ) → ℝ) (x u : Fin d → ℝ) (ε : ℝ) : ℝ :=
(f (x + ε • u) - f (x - ε • u)) / (2 * ε)
/-- An affine consumer. -/
def affine (a : Fin d → ℝ) (b : ℝ) (x : Fin d → ℝ) : ℝ := a ⬝ᵥ x + b
/-- For an affine consumer the central difference along `u` is the gradient's inner product
with `u`, exactly, at every input and every nonzero step. -/
theorem centralDiff_affine (a : Fin d → ℝ) (b : ℝ) (x u : Fin d → ℝ) {ε : ℝ} (hε : ε ≠ 0) :
centralDiff (affine a b) x u ε = a ⬝ᵥ u := by
unfold centralDiff affine
simp only [dotProduct_add, dotProduct_sub, dotProduct_smul, smul_eq_mul]
field_simp
ring
/-- **Recovery at the full dimension.** Probing the standard basis returns each coordinate of
the gradient, two calls per coordinate. -/
theorem centralDiff_basis (a : Fin d → ℝ) (b : ℝ) (x : Fin d → ℝ) {ε : ℝ} (hε : ε ≠ 0)
(i : Fin d) : centralDiff (affine a b) x (Pi.single i 1) ε = a i := by
rw [centralDiff_affine a b x _ hε]
simp [dotProduct_single]
/-- The probe map, which reads the inner products with the `k` probe directions. -/
def probeMap (u : Fin k → Fin d → ℝ) : (Fin d → ℝ) →ₗ[ℝ] (Fin k → ℝ) where
toFun x := fun i => u i ⬝ᵥ x
map_add' x y := by ext i; simp [dotProduct_add]
map_smul' c x := by ext i; simp [dotProduct_smul]
/-- **A blind direction.** Fewer probe directions than the dimension leave a nonzero direction
orthogonal to all of them. -/
theorem exists_blind_direction (hk : k < d) (u : Fin k → Fin d → ℝ) :
∃ v : Fin d → ℝ, v ≠ 0 ∧ ∀ i, u i ⬝ᵥ v = 0 := by
have h : LinearMap.ker (probeMap u) ≠ ⊥ := by
apply LinearMap.ker_ne_bot_of_finrank_lt
simpa using hk
obtain ⟨v, hv, hv0⟩ := (Submodule.ne_bot_iff _).1 h
refine ⟨v, hv0, fun i => ?_⟩
have := congrFun (LinearMap.mem_ker.1 hv) i
simpa [probeMap] using this
/-- Two affine consumers whose gradients differ by a direction orthogonal to every probe
direction return the same reading on every probe call, at every input and step. -/
theorem indistinguishable (a v : Fin d → ℝ) (b : ℝ) (u : Fin k → Fin d → ℝ)
(hv : ∀ i, u i ⬝ᵥ v = 0) (x : Fin d → ℝ) {ε : ℝ} (hε : ε ≠ 0) (i : Fin k) :
centralDiff (affine (a + v) b) x (u i) ε = centralDiff (affine a b) x (u i) ε := by
rw [centralDiff_affine _ _ _ _ hε, centralDiff_affine _ _ _ _ hε, add_dotProduct,
dotProduct_comm v, hv, add_zero]
/-- **The budget cliff, equation 11.4.** A probe confined to fewer than `d` directions cannot
tell some pair of distinct affine consumers apart, whatever inputs and steps it uses. -/
theorem budget_cliff (hk : k < d) (u : Fin k → Fin d → ℝ) (a : Fin d → ℝ) (b : ℝ) :
∃ v : Fin d → ℝ, v ≠ 0 ∧ ∀ (x : Fin d → ℝ) (ε : ℝ), ε ≠ 0 → ∀ i,
centralDiff (affine (a + v) b) x (u i) ε = centralDiff (affine a b) x (u i) ε := by
obtain ⟨v, hv0, hv⟩ := exists_blind_direction hk u
exact ⟨v, hv0, fun x ε hε i => indistinguishable a v b u hv x hε i⟩
end DMO.ProbeCliff