import Mathlib namespace OAI section section noncomputable section namespace LogConcaveSampling.RMSIntegral open MeasureTheory variable {Ω E : Type*} [MeasurableSpace Ω] {ν : Measure Ω} [NormedAddCommGroup E] lemma norm_sub_sq_le_two (x y : E) : ‖x-y‖^2≤2*‖x‖^2+2*‖y‖^2 := by have h := pow_le_pow_left₀ (norm_nonneg (x-y)) (norm_sub_le x y) 2 nlinarith [sq_nonneg (‖x‖-‖y‖)] lemma sub_sq_bound {f g : Ω → E} (hf : AEStronglyMeasurable f ν) (hg : AEStronglyMeasurable g ν) (hfi : Integrable (fun z => ‖f z‖^2) ν) (hgi : Integrable (fun z => ‖g z‖^2) ν) {A B : ℝ} (hA : (∫z,‖f z‖^2 ∂ν)≤A) (hB : (∫z,‖g z‖^2 ∂ν)≤B) : Integrable (fun z => ‖f z-g z‖^2) ν ∧ (∫z,‖f z-g z‖^2 ∂ν)≤2*A+2*B := by have hi : Integrable (fun z => 2*‖f z‖^2+2*‖g z‖^2) ν := (hfi.const_mul 2).add (hgi.const_mul 2) have hm : AEStronglyMeasurable (fun z => ‖f z-g z‖^2) ν := (hf.sub hg).norm.pow 2 have hs : Integrable (fun z => ‖f z-g z‖^2) ν := hi.mono' hm (Filter.Eventually.of_forall (fun z => by simpa only [Real.norm_eq_abs,abs_sq] using norm_sub_sq_le_two (f z) (g z))) refine ⟨hs,(integral_mono hs hi (fun z => norm_sub_sq_le_two (f z) (g z))).trans ?_⟩ rw [integral_add (hfi.const_mul 2) (hgi.const_mul 2),integral_const_mul,integral_const_mul] linarith end LogConcaveSampling.RMSIntegral end end end end OAI