Pratik Patil

GaussianFrechet.lean

1module23public import SubentropyCertificates.GaussianEntropyDerivative4import all SubentropyCertificates.GaussianEntropyDerivative5import Mathlib.Analysis.Calculus.ParametricIntegral6import Mathlib.Analysis.Calculus.LineDeriv.Basic78/-! The real Fréchet derivative of the Gaussian entropy functional. -/9@[expose] public section10noncomputable section11set_option backward.isDefEq.respectTransparency false12open Matrix MeasureTheory Set Filter13open scoped ComplexOrder MatrixOrder Matrix.Norms.L2Operator Topology BigOperators1415namespace SubentropyCertificates.ConditionalContinuity16open SubentropyCertificates.Representations1718variable {D : Type*} [Fintype D] [DecidableEq D]1920/-- The real linear functional induced by the trace pairing with `A`. -/21def gradientPairingCLM (A : Matrix D D ℂ) : Matrix D D ℂ →L[ℝ] ℝ :=22  LinearMap.toContinuousLinearMap23    { toFun := fun H ↦ (A * H).trace.re24      map_add' := fun _ _ ↦ by simp [Matrix.mul_add, Matrix.trace_add]25      map_smul' := fun _ _ ↦ by simp [Matrix.trace_smul, Complex.real_smul] }2627@[simp] theorem gradientPairingCLM_apply (A H : Matrix D D ℂ) :28    gradientPairingCLM A H = (A * H).trace.re := rfl2930private def pairingAsMap :31    Matrix D D ℂ →L[ℝ] (Matrix D D ℂ →L[ℝ] ℝ) :=32  LinearMap.toContinuousLinearMap33    { toFun := gradientPairingCLM34      map_add' := fun A B ↦ by ext H; simp [Matrix.add_mul, Matrix.trace_add]35      map_smul' := fun c A ↦ by ext H; simp [Matrix.trace_smul, Complex.real_smul] }3637private theorem pairing_outer (g : V D) (H : Matrix D D ℂ) :38    gradientPairingCLM (gaussianOuter g) H = quadraticForm H g := outer_trace g H3940private theorem pairing_outer_bound (g : V D) : ‖gradientPairingCLM (gaussianOuter g)‖ ≤ ‖g‖^2 := by41  apply ContinuousLinearMap.opNorm_le_bound _ (sq_nonneg _)42  intro H43  rw [pairing_outer, Real.norm_eq_abs, mul_comm]44  exact quadratic_bound H g4546/-- At a positive definite matrix, the Gaussian functional is Fréchet differentiable47on the full real space of complex matrices. Its derivative pairs a perturbation with48the Gaussian slope by taking the real part of the trace. -/49theorem gaussianF_hasFDerivAt {M : Matrix D D ℂ} (hp : M.PosDef) :50    HasFDerivAt gaussianF (gradientPairingCLM (gaussianSlope M)) M := by51  obtain ⟨a, ha, hlow⟩ := quadratic_lower hp52  let r := a/253  have hr : 0 < r := by dsimp [r]; positivity54  let b := ‖M‖+r55  have hball (N : Matrix D D ℂ) (hN : N ∈ Metric.ball M r) (g : V D) :56      r * ‖g‖^2 ≤ quadraticForm N g ∧ quadraticForm N g ≤ b * ‖g‖^2 := by57    have hd : ‖N-M‖ < r := by simpa [Metric.mem_ball, dist_eq_norm] using hN58    have hq : quadraticForm (N-M) g = quadraticForm N g - quadraticForm M g := by59      simp only [← pairing_outer, map_sub]60    have hpq := quadratic_bound (N-M) g61    rw [hq] at hpq62    have hdiff := (abs_le.mp hpq).163    have hN' : ‖N‖ ≤ b := by64      dsimp [b]65      have := norm_add_le (N-M) M66      rw [sub_add_cancel] at this67      linarith68    constructor69    · dsimp [r] at hd ⊢70      nlinarith only [hlow g, hdiff, mul_le_mul_of_nonneg_right hd.le (sq_nonneg ‖g‖)]71    · exact (le_abs_self _).trans ((quadratic_bound N g).trans72        (mul_le_mul_of_nonneg_right hN' (sq_nonneg _)))73  let f (N : Matrix D D ℂ) (g : V D) := quadraticForm N g * Real.log (quadraticForm N g)74  let z (N : Matrix D D ℂ) (g : V D) := (1+Real.log (quadraticForm N g)) •75    gradientPairingCLM (gaussianOuter g)76  have hm (N : Matrix D D ℂ) : Measurable (fun g : V D ↦ quadraticForm N g) := by77    unfold quadraticForm; fun_prop78  have hfm (N : Matrix D D ℂ) : Measurable (f N) :=79    (hm N).mul (Real.measurable_log.comp (hm N))80  have hmeas : AEStronglyMeasurable (z M) (circularGaussian D) := by81    have ho : Continuous (gaussianOuter (D := D)) := by unfold gaussianOuter Matrix.vecMulVec; fun_prop82    exact ((measurable_const.add (Real.measurable_log.comp (hm M))).smul83      ((pairingAsMap (D := D)).continuous.comp ho).measurable).aestronglyMeasurable84  have hprob := circular_probability (D := D)85  have hf : Integrable (f M) (circularGaussian D) := by86    apply ((integrable_const (1:ℝ)).add ((circular_pow 4 (D := D) (by decide)).const_mul87      (b^2))).mono' (hfm M).aestronglyMeasurable88    filter_upwards with g89    obtain ⟨hl,hu⟩ := hball M (Metric.mem_ball_self hr) g90    have hq : 0 ≤ quadraticForm M g := (mul_nonneg hr.le (sq_nonneg _)).trans hl91    change |quadraticForm M g * Real.log (quadraticForm M g)| ≤ 1 + b^2 * ‖g‖^492    rw [abs_mul, abs_of_nonneg hq]93    nlinarith only [weighted_log_bound hq, pow_le_pow_left₀ hq hu 2]94  have hmain := hasFDerivAt_integral_of_dominated_of_fderiv_le95    (μ := circularGaussian D) (F := f) (F' := z) (bound := envelope r b)96    (Metric.ball_mem_nhds M hr) (.of_forall fun N ↦ (hfm N).aestronglyMeasurable) hf hmeas97    (by98      filter_upwards with g99      intro N hN100      obtain ⟨hl,hu⟩ := hball N hN g101      dsimp only [z]102      rw [norm_smul, Real.norm_eq_abs]103      exact (mul_le_mul_of_nonneg_left (pairing_outer_bound g) (abs_nonneg _)).trans104        (slope_bound hr g hl hu))105    (envelope_integrable r b) (by106      filter_upwards with g107      intro N hN108      by_cases hg : g = 0109      · subst g110        have ho : gaussianOuter (0 : V D) = 0 := by ext; simp [gaussianOuter, Matrix.vecMulVec]111        have hz : gradientPairingCLM (0 : Matrix D D ℂ) = 0 := by ext; simp112        simpa [f, z, quadraticForm, ho, hz] using113          (hasFDerivAt_const (c := (0 : ℝ)) N)114      · have hq : quadraticForm N g ≠ 0 := (lt_of_lt_of_le115          (mul_pos hr (sq_pos_of_pos (norm_pos_iff.mpr hg))) (hball N hN g).1).ne'116        have hquad : HasFDerivAt (fun U ↦ quadraticForm U g)117            (gradientPairingCLM (gaussianOuter g)) N := by118          simpa only [← pairing_outer] using (gradientPairingCLM (gaussianOuter g)).hasFDerivAt (x := N)119        simpa [f, z, Function.comp_def, add_comm] using120          (Real.hasDerivAt_mul_log hq).comp_hasFDerivAt N hquad)121  have hlin : (∫ g, pairingAsMap ((1+Real.log (quadraticForm M g)) • gaussianOuter g)122      ∂circularGaussian D) = gradientPairingCLM (gaussianSlope M) :=123    ContinuousLinearMap.integral_comp_comm (𝕜 := ℝ) (Fₗ := Matrix D D ℂ →L[ℝ] ℝ)124      (pairingAsMap (D := D)) (gaussianSlope_integrable hp)125  rw [← hlin]126  apply hmain.congr_fderiv127  apply integral_congr_ae128  filter_upwards with g129  exact ((pairingAsMap (D := D)).map_smul (1+Real.log (quadraticForm M g)) (gaussianOuter g)).symm130131/-- The line derivative follows by evaluating the Fréchet derivative in the direction H. -/132theorem gaussianF_hasDerivAt {M : Matrix D D ℂ} (hp : M.PosDef) (H : Matrix D D ℂ) :133    HasDerivAt (fun s : ℝ ↦ gaussianF (M + s • H)) ((gaussianSlope M * H).trace.re) 0 :=134  (gaussianF_hasFDerivAt hp).hasLineDerivAt H135136end SubentropyCertificates.ConditionalContinuity137

Axioms used

Choose a statement to see which axioms its proof uses.