GaussianEntropyDerivative.lean
1module23public import SubentropyCertificates.GaussianSignBound4import Mathlib.Analysis.Calculus.ParametricIntegral5import Mathlib.Probability.Distributions.Gaussian.Fernique67/-! Differentiation of the Gaussian entropy functional on positive definite matrices. -/8@[expose] public section9noncomputable section10set_option backward.isDefEq.respectTransparency false11open Matrix MeasureTheory ProbabilityTheory Set Filter12open scoped ComplexOrder MatrixOrder Matrix.Norms.L2Operator Topology BigOperators ENNReal13namespace SubentropyCertificates.ConditionalContinuity14open SubentropyCertificates.Representations1516variable {D : Type*} [Fintype D] [DecidableEq D]1718omit [DecidableEq D] in19private theorem circular_probability : IsProbabilityMeasure (circularGaussian D) :=20 by unfold circularGaussian; infer_instance2122omit [DecidableEq D] in23private theorem circular_pow (k : ℕ) (hk : k ≠ 0) :24 Integrable (fun g : V D ↦ ‖g‖ ^ k) (circularGaussian D) := by25 unfold circularGaussian26 rw [integrable_map_measure (by fun_prop) (by unfold normalizeGaussian; fun_prop)]27 have hh := (IsGaussian.memLp_id (stdGaussian (V D)) (k : ℝ≥0∞) (by simp)).integrable_norm_pow hk28 simpa [Function.comp_def, normalizeGaussian, norm_smul, mul_pow] using29 hh.const_mul (‖(Real.sqrt 2)⁻¹‖ ^ k)3031private theorem quadratic_bound (A : Matrix D D ℂ) (g : V D) :32 |quadraticForm A g| ≤ ‖A‖ * ‖g‖ ^ 2 := by33 unfold quadraticForm34 calc35 _ ≤ _ := Complex.abs_re_le_norm _36 _ ≤ _ := norm_inner_le_norm _ _37 _ ≤ ‖g‖ * (‖A‖ * ‖g‖) := by38 apply mul_le_mul_of_nonneg_left _ (norm_nonneg _)39 exact (Matrix.toEuclideanCLM (𝕜 := ℂ) (n := D) A).le_opNorm g40 _ = _ := by ring4142private theorem quadratic_lower {M : Matrix D D ℂ} (hp : M.PosDef) :43 ∃ a : ℝ, 0 < a ∧ ∀ g : V D, a * ‖g‖ ^ 2 ≤ quadraticForm M g := by44 classical45 cases isEmpty_or_nonempty D with46 | inl he => exact ⟨1, one_pos, fun g ↦ by simp [Subsingleton.elim g 0, quadraticForm]⟩47 | inr he =>48 obtain ⟨a, ha, hl⟩ := (CFC.exists_pos_algebraMap_le_iff M).249 (fun x hx ↦ hp.isStrictlyPositive.spectrum_pos hx)50 refine ⟨a, ha, fun g ↦ ?_⟩51 rw [Algebra.algebraMap_eq_smul_one] at hl52 have h := D5.S3.Quantum.Subentropy.GaussianQuadratic.quadratic_nonnegative53 (Matrix.le_iff.mp hl) g54 change 0 ≤ (inner ℂ g (Matrix.toEuclideanLin (M - (a:ℂ) • (1 : Matrix D D ℂ)) g)).re / 2 at h55 have hone : Matrix.toEuclideanLin (1 : Matrix D D ℂ) = LinearMap.id := Matrix.toLpLin_one _56 rw [map_sub, map_smul, hone, LinearMap.sub_apply, LinearMap.smul_apply, LinearMap.id_apply,57 inner_sub_right, inner_smul_right] at h58 simp only [Complex.sub_re, Complex.mul_re, Complex.ofReal_re, Complex.ofReal_im,59 zero_mul, sub_zero] at h60 have hself : (inner ℂ g g).re = ‖g‖ ^ 2 := (norm_sq_eq_re_inner (𝕜 := ℂ) g).symm61 rw [hself] at h62 unfold quadraticForm63 linarith only [h]6465private theorem quadratic_line (M H : Matrix D D ℂ) (s : ℝ) (g : V D) :66 quadraticForm (M + s • H) g = quadraticForm M g + s * quadraticForm H g := by67 change (inner ℂ g ((Matrix.toEuclideanLin (M + s • H)) g)).re = _68 change (inner ℂ g (Matrix.toEuclideanLin (M + (s : ℂ) • H) g)).re = _69 rw [map_add, map_smul, LinearMap.add_apply, LinearMap.smul_apply, inner_add_right,70 inner_smul_right]71 simp only [quadraticForm, Complex.add_re, Complex.mul_re, Complex.ofReal_re,72 Complex.ofReal_im, zero_mul, sub_zero]7374/-- A scalar bound uniform down to zero. The linear factor cancels the logarithmic singularity. -/75private theorem weighted_log_bound {t : ℝ} (ht : 0 ≤ t) :76 t * |Real.log t| ≤ 1 + t^2 := by77 rcases eq_or_lt_of_le ht with rfl | h78 · simp79 rcases le_total 1 t with h₁ | h₁80 · rw [abs_of_nonneg (Real.log_nonneg h₁)]81 nlinarith [mul_le_mul_of_nonneg_left (Real.log_le_sub_one_of_pos h) ht]82 · rw [abs_of_nonpos (Real.log_nonpos ht h₁)]83 have hi := Real.log_le_sub_one_of_pos (inv_pos.mpr h)84 rw [Real.log_inv] at hi85 have := mul_le_mul_of_nonneg_left hi ht86 rw [mul_sub, mul_inv_cancel₀ h.ne', mul_one] at this87 nlinarith [sq_nonneg t]8889private theorem line_bounds {M : Matrix D D ℂ} (hp : M.PosDef) (H : Matrix D D ℂ) :90 ∃ a b ε : ℝ, 0 < a ∧ 0 < b ∧ 0 < ε ∧ ∀ s : ℝ, |s| < ε → ∀ g : V D,91 a * ‖g‖^2 ≤ quadraticForm (M+s•H) g ∧ quadraticForm (M+s•H) g ≤ b * ‖g‖^2 := by92 obtain ⟨a, ha, hl⟩ := quadratic_lower hp93 let r := a / (2*(1+‖H‖))94 refine ⟨a/2, 1+‖M‖+‖H‖, min 1 r, by positivity, by positivity,95 lt_min one_pos (by dsimp [r]; positivity), ?_⟩96 intro s hs g97 have hs₁ := (lt_min_iff.mp hs).198 have hs₂ := (lt_div_iff₀ (by positivity : 0 < 2*(1+‖H‖))).mp (lt_min_iff.mp hs).299 have hsH : |s| * ‖H‖ ≤ a/2 := by nlinarith [abs_nonneg s]100 have hsH' : |s| * ‖H‖ ≤ ‖H‖ := by nlinarith [mul_le_mul_of_nonneg_right hs₁.le (norm_nonneg H)]101 have hterm : |s * quadraticForm H g| ≤ (|s| * ‖H‖)*‖g‖^2 := by102 rw [abs_mul, mul_assoc]103 exact mul_le_mul_of_nonneg_left (quadratic_bound H g) (abs_nonneg s)104 rw [quadratic_line]105 constructor106 · nlinarith only [hl g, neg_abs_le (s*quadraticForm H g), hterm,107 mul_le_mul_of_nonneg_right hsH (sq_nonneg ‖g‖)]108 · nlinarith only [le_abs_self (quadraticForm M g), quadratic_bound M g, le_abs_self109 (s*quadraticForm H g), hterm, mul_le_mul_of_nonneg_right hsH' (sq_nonneg ‖g‖),110 sq_nonneg ‖g‖]111112private def envelope (a b : ℝ) (g : V D) : ℝ := ‖g‖^2 + (1+b^2*‖g‖^4)/a113114omit [DecidableEq D] in115private theorem slope_bound {a b t : ℝ} (ha : 0 < a) (g : V D)116 (hl : a * ‖g‖^2 ≤ t) (hu : t ≤ b * ‖g‖^2) :117 |1 + Real.log t| * ‖g‖^2 ≤ envelope a b g := by118 have ht := (mul_nonneg ha.le (sq_nonneg ‖g‖)).trans hl119 have hh := mul_le_mul_of_nonneg_right hl (abs_nonneg (Real.log t))120 have hsq := pow_le_pow_left₀ ht hu 2121 have hlog : |Real.log t| * ‖g‖^2 ≤ (1+b^2*‖g‖^4)/a := by122 apply (le_div_iff₀ ha).2123 nlinarith only [hh, weighted_log_bound ht, hsq]124 unfold envelope125 nlinarith only [hlog, mul_le_mul_of_nonneg_right (abs_add_le 1 (Real.log t)) (sq_nonneg ‖g‖),126 (abs_one : |(1:ℝ)| = 1)]127128omit [DecidableEq D] in129private theorem envelope_integrable (a b : ℝ) : Integrable (envelope (D := D) a b)130 (circularGaussian D) := by131 have := circular_probability (D := D)132 exact (circular_pow 2 (by decide)).add133 (((integrable_const (1 : ℝ)).add ((circular_pow 4 (by decide)).const_mul (b^2))).div_const a)134135private theorem outer_trace (g : V D) (H : Matrix D D ℂ) :136 ((gaussianOuter g * H).trace).re = quadraticForm H g := by137 rw [Matrix.trace_mul_comm, gaussianOuter, Matrix.mul_vecMulVec, Matrix.trace_vecMulVec]138 rfl139140/-- The Gaussian matrix moment defining the slope is absolutely integrable. -/141theorem gaussianSlope_integrable {M : Matrix D D ℂ} (hp : M.PosDef) :142 Integrable (fun g : V D ↦ (1+Real.log (quadraticForm M g)) • gaussianOuter g)143 (circularGaussian D) := by144 obtain ⟨a,b,ε,ha,_,he,hr⟩ := line_bounds hp 0145 have hm : Measurable (fun g : V D ↦ 1+Real.log (quadraticForm M g)) :=146 measurable_const.add (Real.measurable_log.comp (by unfold quadraticForm; fun_prop))147 have ho : Continuous (gaussianOuter (D := D)) := by148 unfold gaussianOuter Matrix.vecMulVec149 fun_prop150 apply (envelope_integrable a b).mono' ((hm.smul ho.measurable).aestronglyMeasurable)151 filter_upwards with g152 change ‖(1 + Real.log (quadraticForm M g)) • gaussianOuter g‖ ≤ _153 rw [norm_smul, Real.norm_eq_abs, gaussianOuter_norm]154 have h := hr 0 (by simpa) g155 simp at h156 exact slope_bound ha g h.1 h.2157158private theorem coord_log_integrable (i : D) :159 Integrable (fun g : V D ↦ Real.log (Complex.normSq (g i))) (circularGaussian D) := by160 -- The integral is Γ′(1) = −γ, so it cannot equal the zero value of an undefined integral.161 by_contra hn162 have he := circular_coordinate_integral i Real.log Real.measurable_log163 rw [integral_undef hn, unit_exponential_integral] at he164 simp_rw [mul_comm (Real.exp _) _] at he165 rw [← Real.deriv_Gamma_one_eq_integral_log, Real.hasDerivAt_Gamma_one.deriv] at he166 linarith [Real.one_half_lt_eulerMascheroniConstant]167168/-- The scalar Gaussian logarithmic moment exists at each positive definite matrix. -/169theorem gaussianLogMean_integrable {M : Matrix D D ℂ} (hp : M.PosDef) :170 Integrable (fun g : V D ↦ Real.log (quadraticForm M g)) (circularGaussian D) := by171 obtain ⟨a, ha, hl⟩ := quadratic_lower hp172 have := circular_probability (D := D)173 have hz := integrable_finsetSum Finset.univ fun i _ ↦ (coord_log_integrable (D := D) i).abs174 apply ((((circular_pow 2 (D := D) (by decide)).const_mul ‖M‖).add175 (integrable_const |Real.log a|)).add hz).mono'176 ((Real.measurable_log.comp (by unfold quadraticForm; fun_prop)).aestronglyMeasurable)177 filter_upwards with g178 let z := fun i ↦ Complex.normSq (g i)179 have hSum : 0 ≤ ∑ i, |Real.log (z i)| := Finset.sum_nonneg fun i _ ↦ abs_nonneg _180 change |Real.log (quadraticForm M g)| ≤ ‖M‖*‖g‖^2 + |Real.log a| + ∑ i, |Real.log (z i)|181 by_cases hg : g = 0182 · subst g183 simp only [quadraticForm, map_zero, inner_zero_right, Complex.zero_re, Real.log_zero, abs_zero]184 positivity185 obtain ⟨i, hi⟩ : ∃ i, g i ≠ 0 := by186 by_contra! h187 exact hg (PiLp.ext fun i ↦ h i)188 have hi' : 0 < z i := Complex.normSq_pos.mpr hi189 have hu : z i ≤ ‖g‖^2 := by190 rw [EuclideanSpace.norm_sq_eq]191 simpa [z, Complex.sq_norm] using192 Finset.single_le_sum (fun j _ ↦ sq_nonneg ‖g j‖) (Finset.mem_univ i)193 have hpos : 0 < quadraticForm M g := (mul_pos ha (sq_pos_of_pos (norm_pos_iff.mpr hg))).trans_le194 (hl g)195 have hlo := Real.log_le_log (mul_pos ha hi') ((mul_le_mul_of_nonneg_left hu ha.le).trans (hl g))196 rw [Real.log_mul ha.ne' hi'.ne'] at hlo197 have hiSum := Finset.single_le_sum (s := Finset.univ)198 (fun j _ ↦ abs_nonneg (Real.log (z j))) (Finset.mem_univ i)199 apply abs_le.mpr200 constructor201 · nlinarith only [hlo, hiSum, neg_abs_le (Real.log a), neg_abs_le (Real.log (z i)),202 mul_nonneg (norm_nonneg M) (sq_nonneg ‖g‖)]203 · linarith only [le_abs_self (quadraticForm M g), quadratic_bound M g,204 Real.log_le_sub_one_of_pos hpos, abs_nonneg (Real.log a), hSum]205206/-- Every sufficiently small Hermitian line perturbation stays positive definite. -/207theorem eventually_posDef_line {M H : Matrix D D ℂ} (hp : M.PosDef) (hH : H.IsHermitian) :208 ∀ᶠ s : ℝ in 𝓝 0, (M+s•H).PosDef := by209 obtain ⟨a,_,ε,ha,_,he,hr⟩ := line_bounds hp H210 filter_upwards [Metric.ball_mem_nhds (0:ℝ) he] with s hs211 have hh := hp.isHermitian.add (hH.smul (show IsSelfAdjoint s from IsSelfAdjoint.all _))212 apply hh.posDef_iff_eigenvalues_pos.mpr213 intro i214 let v := hh.eigenvectorBasis i215 have act : Matrix.toEuclideanLin (M+s•H) v = (hh.eigenvalues i : ℂ) • v := by216 apply PiLp.ext217 intro j218 exact congrFun (hh.mulVec_eigenvectorBasis i) j219 have hv : ‖v‖ = 1 := hh.eigenvectorBasis.orthonormal.norm_eq_one i220 have hq := (hr s (by simpa [Real.dist_eq] using hs) v).1221 have hpv := lt_of_lt_of_le (mul_pos ha (by rw [hv]; norm_num : 0 < ‖v‖ ^ 2)) hq222 unfold quadraticForm at hpv223 rw [act, inner_smul_right, inner_self_eq_norm_sq_to_K, hv] at hpv224 simpa using hpv225226end SubentropyCertificates.ConditionalContinuity
Axioms used
Choose a statement to see which axioms its proof uses.