import OAI.Probability.InvariantIsing.Gaussian.CountableGaussianComparison import OAI.Probability.IsingPerceptron.MonomialGgAtMinimum import OAI.Probability.IsingPerceptron.JointGGClosure namespace OAI /-! Stability of the actual Gaussian partition under bounded base-energy changes. -/ noncomputable section open MeasureTheory ProbabilityTheory IsingPerceptron namespace InvariantIsing /-- An independent Gaussian perturbation changes the mean pressure by at most half its maximal variance, including after a fixed base-energy tilt. -/ theorem countable_cylinder_log_mean_cost {X : Type*} [MeasurableSpace X] [Countable X] [MeasurableSingletonClass X] (ν : Measure X) [IsProbabilityMeasure ν] (H : X → ℝ) (hH : Integrable (fun x => Real.exp (H x)) ν) (A : X → ℕ →₀ ℝ) {B : ℝ} (hA : ∀ x, (A x).sum (fun _ c => c ^ 2) ≤ B) : let d := (∫ g : ℕ → ℝ, Real.log (∫ x, Real.exp (H x + cylinderField (A x) g) ∂ν) ∂gaussianCoordinates) - Real.log (∫ x, Real.exp (H x) ∂ν) 0 ≤ d ∧ d ≤ B / 2 := by have : IsProbabilityMeasure (ν.tilted H) := isProbabilityMeasure_tilted hH dsimp only rw [cylinder_log_partition_mean_base ν H hH A hA, add_sub_cancel_left] simpa only [one_pow, one_mul] using cylinder_cgf_mean_bounds (ν.tilted H) A hA 1 lemma cylinder_partition_exp_integrable_ae {X : Type*} [MeasurableSpace X] [Countable X] [MeasurableSingletonClass X] (ν : Measure X) [IsProbabilityMeasure ν] (H : X → ℝ) (hH : Integrable (fun x => Real.exp (H x)) ν) (A : X → ℕ →₀ ℝ) {B : ℝ} (hA : ∀ x, (A x).sum (fun _ c => c ^ 2) ≤ B) : ∀ᵐ g : ℕ → ℝ ∂gaussianCoordinates, Integrable (fun x => Real.exp (H x + cylinderField (A x) g)) ν := by have : IsProbabilityMeasure (ν.tilted H) := isProbabilityMeasure_tilted hH have hv (x : X) : (((A x).sum (fun _ c => c ^ 2)).toNNReal : ℝ) ≤ B := by rw [Real.coe_toNNReal _ (show 0 ≤ (A x).sum (fun _ c => c ^ 2) from Finset.sum_nonneg (fun _ _ => sq_nonneg _))] exact hA x have he := (gaussian_field_exp_integrable (ν := ν.tilted H) (measurable_cylinderFields A) (fun x => cylinderField_law (A x)) hv 1).1.prod_right_ae filter_upwards [he] with g hg simpa only [one_mul, smul_eq_mul, ← Real.exp_add] using (integrable_tilted_iff hH (fun x => Real.exp (1 * cylinderField (A x) g))).mp hg /-- A uniform deterministic energy change bounds the mean logpartition change, for every countable prior and bounded-variance Gaussian field. -/ theorem countable_cylinder_log_mean_base_compare {X : Type*} [MeasurableSpace X] [Countable X] [MeasurableSingletonClass X] (ν : Measure X) [IsProbabilityMeasure ν] (H J : X → ℝ) (hH : Integrable (fun x => Real.exp (H x)) ν) (hJ : Integrable (fun x => Real.exp (J x)) ν) (A : X → ℕ →₀ ℝ) {B K : ℝ} (hA : ∀ x, (A x).sum (fun _ c => c ^ 2) ≤ B) (hK : ∀ x, |H x - J x| ≤ K) : |(∫ g : ℕ → ℝ, Real.log (∫ x, Real.exp (H x + cylinderField (A x) g) ∂ν) ∂gaussianCoordinates) - ∫ g : ℕ → ℝ, Real.log (∫ x, Real.exp (J x + cylinderField (A x) g) ∂ν) ∂gaussianCoordinates| ≤ K := by have hiH := (cylinder_log_partition_memLp_two ν H hH A hA 1).integrable (by norm_num) have hiJ := (cylinder_log_partition_memLp_two ν J hJ A hA 1).integrable (by norm_num) simp only [one_mul] at hiH hiJ rw [← integral_sub hiH hiJ, ← Real.norm_eq_abs] apply (norm_integral_le_of_norm_le_const (μ := gaussianCoordinates) (C := K) ?_).trans_eq (by simp) filter_upwards [cylinder_partition_exp_integrable_ae ν H hH A hA, cylinder_partition_exp_integrable_ae ν J hJ A hA] with g hgH hgJ have h := logMean_abs_sub_le ν (b := 1) (by norm_num) (by simpa only [one_mul] using hgH) (by simpa only [one_mul] using hgJ) (fun x => by simpa only [add_sub_add_right_eq_sub] using hK x) simpa only [logMean, div_one, one_mul, Real.norm_eq_abs] using h end InvariantIsing end end OAI