cfahlgren1's picture
download
raw
10.2 kB
import Mathlib
import OAI.Probability.SphericalField.Poisson.Mecke
namespace OAI
section
noncomputable section
open MeasureTheory ProbabilityTheory Filter Set
open scoped ENNReal NNReal Topology BigOperators BoundedContinuousFunction
namespace SphericalPerceptron
open Matrix
open scoped InnerProductSpace
variable {H : Type*} [SeminormedAddCommGroup H] [InnerProductSpace ℝ H]
section Tilt
variable {S : Type*} [MeasurableSpace S] (μ : Measure S) [IsProbabilityMeasure μ]
def tiltIntegral (v F : S → ℝ) (t : ℝ) : ℝ := ∫ x, Real.exp (t * v x) * F x ∂μ
def tiltPartition (v : S → ℝ) (t : ℝ) : ℝ := ∫ x, Real.exp (t * v x) ∂μ
def tiltMean (v F : S → ℝ) (t : ℝ) : ℝ := tiltIntegral μ v F t / tiltPartition μ v t
lemma tilt_integrable {v F : S → ℝ} (hv : Measurable v) (hF : Measurable F)
{C D : ℝ} (_hC : 0 ≤ C) (_hD : 0 ≤ D)
(hvC : ∀ x, |v x| ≤ C) (hFD : ∀ x, |F x| ≤ D) (t : ℝ) :
Integrable (fun x => Real.exp (t * v x) * F x) μ := by
refine Integrable.of_bound (hv.const_mul t |>.exp.mul hF).aestronglyMeasurable
(Real.exp (|t| * C) * D) (ae_of_all _ fun x => ?_)
rw [Real.norm_eq_abs,abs_mul,abs_of_pos (Real.exp_pos _)]
apply mul_le_mul _ (hFD x) (abs_nonneg _) (Real.exp_pos _).le
apply Real.exp_le_exp.mpr
exact (le_abs_self (t * v x)).trans (by rw [abs_mul]; gcongr; exact hvC x)
lemma tilt_integral_deriv {v F : S → ℝ} (hv : Measurable v) (hF : Measurable F)
{C D : ℝ} (hC : 0 ≤ C) (hD : 0 ≤ D)
(hvC : ∀ x, |v x| ≤ C) (hFD : ∀ x, |F x| ≤ D) (t : ℝ) :
HasDerivAt (tiltIntegral μ v F)
(∫ x, Real.exp (t * v x) * v x * F x ∂μ) t := by
apply (hasDerivAt_integral_of_dominated_loc_of_deriv_le
(s := Metric.ball t 1) (bound := fun _ => Real.exp ((|t|+1)*C) * C * D)
(F' := fun u x => Real.exp (u * v x) * v x * F x) (Metric.ball_mem_nhds t zero_lt_one)
(Filter.Eventually.of_forall fun u => (hv.const_mul u |>.exp.mul hF).aestronglyMeasurable)
(tilt_integrable μ hv hF hC hD hvC hFD t)
(by fun_prop) (ae_of_all _ fun x u hu => ?_) (integrable_const _)
(ae_of_all _ fun x u _ => ?_)).2
· have hu' : |u| ≤ |t|+1 := by
have hh : |u-t| < 1 := by simpa only [Metric.mem_ball,Real.dist_eq] using hu
calc
|u| = |(u-t)+t| := by congr 1; ring
_ ≤ |u-t|+|t| := abs_add_le _ _
_ ≤ |t|+1 := by linarith
rw [Real.norm_eq_abs,abs_mul,abs_mul,abs_of_pos (Real.exp_pos _)]
have hexp : Real.exp (u * v x) ≤ Real.exp ((|t|+1)*C) := by
apply Real.exp_le_exp.mpr
apply (le_abs_self (u * v x)).trans
rw [abs_mul]
exact mul_le_mul hu' (hvC x) (abs_nonneg _) (by positivity)
exact mul_le_mul (mul_le_mul hexp (hvC x) (abs_nonneg _) (Real.exp_pos _).le)
(hFD x) (abs_nonneg _) (mul_nonneg (Real.exp_pos _).le hC)
· convert! (((hasDerivAt_id u).mul_const (v x)).exp.mul_const (F x)) using 1
simp only [one_mul,id_eq]
lemma tilt_partition_pos {v : S → ℝ} (hv : Measurable v)
{C : ℝ} (hC : 0 ≤ C) (hvC : ∀ x, |v x| ≤ C) (t : ℝ) :
0 < tiltPartition μ v t := by
have hi : Integrable (fun x => Real.exp (t * v x)) μ := by
simpa only [mul_one] using tilt_integrable μ (F := fun _ => 1) hv measurable_const hC (by norm_num : (0:ℝ) ≤ 1)
hvC (fun _ => by norm_num) t
have he : Real.exp (- |t| * C) ≤ tiltPartition μ v t := by
calc
Real.exp (- |t| * C) = ∫ _ : S, Real.exp (- |t| * C) ∂μ := by simp
_ ≤ tiltPartition μ v t := integral_mono_ae (integrable_const _) hi (ae_of_all _ fun x => by
apply Real.exp_le_exp.mpr
have hh : |t*v x| ≤ |t| * C := by rw [abs_mul]; gcongr; exact hvC x
nlinarith [neg_abs_le (t*v x)])
exact (Real.exp_pos _).trans_le he
lemma tilt_partition_deriv {v : S → ℝ} (hv : Measurable v)
{C : ℝ} (hC : 0 ≤ C) (hvC : ∀ x, |v x| ≤ C) (t : ℝ) :
HasDerivAt (tiltPartition μ v) (tiltIntegral μ v v t) t := by
have hd := tilt_integral_deriv μ (F := fun _ => 1) hv measurable_const hC
(by norm_num : (0:ℝ) ≤ 1) hvC (fun _ => by norm_num) t
change HasDerivAt (fun u => ∫ x, Real.exp (u * v x) * 1 ∂μ)
(∫ x, Real.exp (t*v x) * v x * 1 ∂μ) t at hd
change HasDerivAt (fun u => ∫ x, Real.exp (u * v x) ∂μ)
(∫ x, Real.exp (t * v x) * v x ∂μ) t
simpa only [mul_one] using hd
lemma tilt_mean_deriv {v F : S → ℝ} (hv : Measurable v) (hF : Measurable F)
{C D : ℝ} (hC : 0 ≤ C) (hD : 0 ≤ D)
(hvC : ∀ x, |v x| ≤ C) (hFD : ∀ x, |F x| ≤ D) (t : ℝ) :
HasDerivAt (tiltMean μ v F)
(tiltMean μ v (fun x => v x * F x) t - tiltMean μ v F t * tiltMean μ v v t) t := by
have hp := (tilt_partition_pos μ hv hC hvC t).ne'
have hd := (tilt_integral_deriv μ hv hF hC hD hvC hFD t).div
(tilt_partition_deriv μ hv hC hvC t) hp
convert! hd using 1
simp only [tiltMean,tiltIntegral,mul_assoc]
field_simp
lemma tilt_mean_bound {v F : S → ℝ} (hv : Measurable v) (hF : Measurable F)
{C D : ℝ} (hC : 0 ≤ C) (hD : 0 ≤ D)
(hvC : ∀ x, |v x| ≤ C) (hFD : ∀ x, |F x| ≤ D) (t : ℝ) :
|tiltMean μ v F t| ≤ D := by
have hp := tilt_partition_pos μ hv hC hvC t
have hi := tilt_integrable μ hv hF hC hD hvC hFD t
have hiExp : Integrable (fun x => Real.exp (t * v x)) μ := by
simpa only [mul_one] using tilt_integrable μ (F := fun _ => 1) hv measurable_const hC
(by norm_num : (0:ℝ) ≤ 1) hvC (fun _ => by norm_num) t
rw [tiltMean,abs_div,abs_of_pos hp,div_le_iff₀ hp]
calc
|tiltIntegral μ v F t| ≤ ∫ x, |Real.exp (t * v x) * F x| ∂μ := by
simpa only [tiltIntegral,Real.norm_eq_abs] using norm_integral_le_integral_norm
(fun x => Real.exp (t * v x) * F x)
_ ≤ ∫ x, Real.exp (t * v x) * D ∂μ := by
apply integral_mono_ae hi.norm (hiExp.mul_const D)
exact ae_of_all _ fun x => by
simp only [Real.norm_eq_abs]
rw [abs_mul,abs_of_pos (Real.exp_pos _)]
exact mul_le_mul_of_nonneg_left (hFD x) (Real.exp_pos _).le
_ = D * tiltPartition μ v t := by rw [integral_mul_const]; exact mul_comm _ _
def tiltLaw (v : S → ℝ) (t : ℝ) : Measure S :=
(ENNReal.ofReal (tiltPartition μ v t))⁻¹ •
μ.withDensity (fun x => ENNReal.ofReal (Real.exp (t * v x)))
lemma tilt_law_probability {v : S → ℝ} (hv : Measurable v)
{C : ℝ} (hC : 0 ≤ C) (hvC : ∀ x, |v x| ≤ C) (t : ℝ) :
IsProbabilityMeasure (tiltLaw μ v t) := by
have hp := tilt_partition_pos μ hv hC hvC t
have hi : Integrable (fun x => Real.exp (t * v x)) μ := by
simpa only [mul_one] using tilt_integrable μ (F := fun _ => 1) hv measurable_const hC
(by norm_num : (0:ℝ) ≤ 1) hvC (fun _ => by norm_num) t
constructor
rw [tiltLaw,Measure.smul_apply,smul_eq_mul,withDensity_apply _ .univ,
Measure.restrict_univ,← ofReal_integral_eq_lintegral_ofReal hi (ae_of_all _ fun x => (Real.exp_pos _).le)]
exact ENNReal.inv_mul_cancel (ne_of_gt (ENNReal.ofReal_pos.mpr hp)) ENNReal.ofReal_ne_top
lemma tilt_law_integral {v F : S → ℝ} (hv : Measurable v)
{C : ℝ} (hC : 0 ≤ C) (hvC : ∀ x, |v x| ≤ C) (t : ℝ) :
∫ x, F x ∂tiltLaw μ v t = tiltMean μ v F t := by
rw [tiltLaw,integral_smul_measure,integral_withDensity_eq_integral_toReal_smul
(show Measurable (fun x => ENNReal.ofReal (Real.exp (t * v x))) from (hv.const_mul t).exp.ennreal_ofReal)
(ae_of_all _ fun _ => ENNReal.ofReal_lt_top)]
simp only [ENNReal.toReal_inv,ENNReal.toReal_ofReal (tilt_partition_pos μ hv hC hvC t).le,
ENNReal.toReal_ofReal (Real.exp_pos _).le,smul_eq_mul,tiltMean,tiltIntegral]
exact (div_eq_inv_mul _ _).symm
lemma tilt_mean_continuous {v F : S → ℝ} (hv : Measurable v) (hF : Measurable F)
{C D : ℝ} (hC : 0 ≤ C) (hD : 0 ≤ D)
(hvC : ∀ x, |v x| ≤ C) (hFD : ∀ x, |F x| ≤ D) :
Continuous (tiltMean μ v F) :=
continuous_iff_continuousAt.mpr fun t => (tilt_mean_deriv μ hv hF hC hD hvC hFD t).continuousAt
lemma gaussian_tilt_integrationByParts {v F : S → ℝ} (hv : Measurable v) (hF : Measurable F)
{C D : ℝ} (hC : 0 ≤ C) (hD : 0 ≤ D)
(hvC : ∀ x, |v x| ≤ C) (hFD : ∀ x, |F x| ≤ D) :
(∫ t, t * tiltMean μ v F t ∂gaussianReal 0 1) =
∫ t, tiltMean μ v (fun x => v x * F x) t -
tiltMean μ v F t * tiltMean μ v v t ∂gaussianReal 0 1 := by
have hvF : ∀ x, |v x * F x| ≤ C * D := fun x => by
rw [abs_mul]; exact mul_le_mul (hvC x) (hFD x) (abs_nonneg _) hC
apply standardGaussian_integrationByParts
(fun t => tilt_mean_deriv μ hv hF hC hD hvC hFD t)
((tilt_mean_continuous μ hv (hv.mul hF) hC (mul_nonneg hC hD) hvC hvF).measurable.sub
((tilt_mean_continuous μ hv hF hC hD hvC hFD).measurable.mul
(tilt_mean_continuous μ hv hv hC hC hvC hvC).measurable))
(fun t => tilt_mean_bound μ hv hF hC hD hvC hFD t)
(D := 2*C*D)
intro t
calc
|tiltMean μ v (fun x => v x * F x) t - tiltMean μ v F t * tiltMean μ v v t| ≤
|tiltMean μ v (fun x => v x * F x) t| + |tiltMean μ v F t * tiltMean μ v v t| := abs_sub _ _
_ ≤ C*D + D*C := add_le_add (tilt_mean_bound μ hv (hv.mul hF) hC (mul_nonneg hC hD) hvC hvF t)
(by
rw [abs_mul]
exact mul_le_mul (tilt_mean_bound μ hv hF hC hD hvC hFD t)
(tilt_mean_bound μ hv hv hC hC hvC hvC t) (abs_nonneg _) hD)
_ = 2*C*D := by ring
end Tilt
def replicaPotential {S : Type*} (v : S → ℝ) (n : ℕ) (x : Fin n → S) : ℝ := ∑ i, v (x i)
lemma replicaPotential_measurable {S : Type*} [MeasurableSpace S]
{v : S → ℝ} (hv : Measurable v) (n : ℕ) : Measurable (replicaPotential v n) := by
exact Finset.measurable_sum _ fun i _ => hv.comp (measurable_pi_apply i)
lemma replicaPotential_bound {S : Type*} {v : S → ℝ} {C : ℝ}
(hv : ∀ x, |v x| ≤ C) (n : ℕ) (x : Fin n → S) :
|replicaPotential v n x| ≤ n*C := by
calc
|∑ i, v (x i)| ≤ ∑ i, |v (x i)| := Finset.abs_sum_le_sum_abs _ _
_ ≤ ∑ _ : Fin n, C := Finset.sum_le_sum (fun i _ => hv (x i))
_ = n*C := by simp
end SphericalPerceptron
end
end
end OAI

Xet Storage Details

Size:
10.2 kB
·
Xet hash:
b0fa276d5509fe578475ee4983e7f32f4f9751ea1b585111ee52f3dea2133d08

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.