math / data /lean /OAI /Probability /Perceptron /Variational /CompactGGDensity.lean
introvoyz045's picture
Migrated from GitHub
4a56cd6 verified
Raw History Blame Contribute Delete
8.74 kB
import Mathlib
import OAI.Probability.Perceptron.Interpolation.PerturbationContact
namespace OAI
noncomputable section
namespace SphericalPerceptronFreeEnergy
open MeasureTheory ProbabilityTheory Filter Set
open scoped Topology NNReal ENNReal BigOperators BoundedContinuousFunction
section
variable {X : Type*} [TopologicalSpace X] [MeasurableSpace X] [OpensMeasurableSpace X]
def boundedTestIntegral (ΞΌ : Measure X) [IsProbabilityMeasure ΞΌ] : (X →ᡇ ℝ) β†’L[ℝ] ℝ :=
LinearMap.mkContinuous
{ toFun := fun f => ∫ x, f x βˆ‚ΞΌ
map_add' := fun f g => integral_add (f.integrable ΞΌ) (g.integrable ΞΌ)
map_smul' := fun c f => by simpa using integral_const_mul c (fun x => f x) }
1 (fun f => by simpa using f.norm_integral_le_norm ΞΌ)
def compactGGTestCLM {K : Type*} [TopologicalSpace K] [MeasurableSpace K]
[BorelSpace K] [SecondCountableTopology K]
(ΞΌ : ProbabilityMeasure (CompactArray K)) (n : β„•) (i : Fin n)
(f : CompactBlock K n →ᡇ ℝ) : (K →ᡇ ℝ) β†’L[ℝ] ℝ := by
classical
let I := boundedTestIntegral (ΞΌ : Measure (CompactArray K))
let F := f.compContinuous ⟨compactBlock n,compactBlock_continuous n⟩
let E (a b : β„•) := BoundedContinuousFunction.compContinuousCLM ℝ ℝ
(⟨fun Q : CompactArray K => Q a b,by fun_prop⟩ : C(CompactArray K,K))
let L (a b : β„•) := I.comp ((ContinuousLinearMap.mul ℝ (CompactArray K →ᡇ ℝ) F).comp (E a b))
exact (n:ℝ) β€’ L i n - (I F) β€’ (I.comp (E 0 1)) - βˆ‘ j ∈ Finset.univ.erase i, L i j
lemma compactGGTestCLM_apply {K : Type*} [TopologicalSpace K] [MeasurableSpace K]
[BorelSpace K] [SecondCountableTopology K]
(ΞΌ : ProbabilityMeasure (CompactArray K)) (n : β„•) (i : Fin n)
(f : CompactBlock K n →ᡇ ℝ) (g : K →ᡇ ℝ) :
compactGGTestCLM ΞΌ n i f g = compactGGDefect ΞΌ n i f g := by
classical
simp [compactGGTestCLM,compactGGDefect,boundedTestIntegral]
lemma compactJoint_monomials_total (L : (CompactJointOverlap →ᡇ ℝ) β†’L[ℝ] ℝ)
(hL : βˆ€ p d, L (compactJointMonomial p d)=0) : L=0 := by
let e := ContinuousMap.linearIsometryBoundedOfCompact CompactJointOverlap ℝ ℝ
let L' := L.comp e.toContinuousLinearEquiv.toContinuousLinearMap
let m (a : β„•Γ—β„•) : C(CompactJointOverlap,ℝ) := (compactJointMonomial a.1 a.2).toContinuousMap
have hm0 : m 0=1 := by ext x; simp [m]
have hmadd (a b : β„•Γ—β„•) : m (a+b)=m a*m b := by
ext x
exact congrArg (fun f : CompactJointOverlap →ᡇ ℝ => f x) (compactJointMonomial_add _ _ _ _)
let M : Submonoid C(CompactJointOverlap,ℝ) :=
{ carrier := Set.range m
one_mem' := ⟨0,hm0⟩
mul_mem' := by rintro _ _ ⟨a,rfl⟩ ⟨b,rfl⟩; exact ⟨a+b,hmadd a b⟩ }
let A := Algebra.adjoin ℝ (M : Set C(CompactJointOverlap,ℝ))
have hsep : A.SeparatesPoints := by
intro x y hxy
obtain ⟨p,d,hpd⟩ := compactJointMonomial_separates x y hxy
have hmem : m (p,d) ∈ A :=
Algebra.subset_adjoin (show m (p,d) ∈ M from ⟨(p,d),rfl⟩)
exact ⟨m (p,d),⟨m (p,d),hmem,rfl⟩,hpd⟩
have hA : (A : Set C(CompactJointOverlap,ℝ)) βŠ† (L'.ker : Set C(CompactJointOverlap,ℝ)) := by
have hspan : Submodule.span ℝ (M : Set C(CompactJointOverlap,ℝ)) ≀ L'.ker := by
apply Submodule.span_le.mpr
rintro _ ⟨⟨p,d⟩,rfl⟩
change L (e ((compactJointMonomial p d).toContinuousMap)) = 0
have he : e ((compactJointMonomial p d).toContinuousMap) = compactJointMonomial p d := by
ext x; rfl
rw [he]
exact hL p d
intro f hf
apply hspan
change f ∈ A.toSubmodule at hf
simpa only [A,Algebra.adjoin_eq_span,Submonoid.closure_eq] using hf
have hclosed := L'.isClosed_ker
have hc := closure_minimal hA hclosed
have htop := ContinuousMap.subalgebra_topologicalClosure_eq_top_of_separatesPoints A hsep
have hall (f : C(CompactJointOverlap,ℝ)) : L' f=0 := by
apply hc
change f ∈ A.topologicalClosure
rw [htop]
trivial
ext g
have h := hall (e.symm g)
simpa [L'] using h
lemma compactGG_of_joint_monomials (ΞΌ : ProbabilityMeasure (CompactArray CompactJointOverlap))
(n : β„•) (i : Fin n) (f : CompactBlock CompactJointOverlap n →ᡇ ℝ)
(h : βˆ€ p d, compactGGDefect ΞΌ n i f (compactJointMonomial p d)=0)
(g : CompactJointOverlap →ᡇ ℝ) : compactGGDefect ΞΌ n i f g=0 := by
have hz := compactJoint_monomials_total (compactGGTestCLM ΞΌ n i f)
(fun p d => (compactGGTestCLM_apply ΞΌ n i f _).trans (h p d))
rw [← compactGGTestCLM_apply,hz]
rfl
end
lemma compactGGDefect_one (ΞΌ : ProbabilityMeasure (CompactArray CompactJointOverlap))
(r : β„•) (i : Fin r) (G : CompactBlock CompactJointOverlap r →ᡇ ℝ) :
compactGGDefect ΞΌ r i G 1=0 := by
have hr : 1≀r := by have := i.isLt; omega
simp only [compactGGDefect,BoundedContinuousFunction.coe_one,Pi.one_apply,mul_one,
integral_const,probReal_univ,smul_eq_mul,Finset.sum_const,Finset.card_erase_of_mem
(Finset.mem_univ i),Finset.card_univ,Fintype.card_fin,nsmul_eq_mul,Nat.cast_sub hr,Nat.cast_one]
ring
variable (k : β„•) (f : ℝ →ᡇ ℝ) (p d : β„•β†’β„•) (z : Fin k→ℝ)
variable (hz : StrictMono z) (hz0 : βˆ€ i, 0<z i) (hz1 : βˆ€ i, z i<1)
variable (t : ℕ→ℝβ‰₯0) (h : β„•β†’Fin (k+1)→ℝ)
variable (hh0 : βˆ€ n l, 0≀h n l) (hh : βˆ€ n, Monotone (h n))
variable (u : (n : β„•)β†’Fin (n+1)→ℝ) (hu : βˆ€ n, u n∈Icc (fun _=>1) (fun _=>2))
variable (hmin : βˆ€ n, IsMinOn (fun v => quadraticBoxPenalty (sourcePenaltyWeight (n+1)) v-
sourceExpectedPressure n k f (fun j=>p j.val) (fun j=>d j.val) (h n) z (t n) v)
(Icc (fun _ : Fin (n+1)=>1) (fun _=>2)) (u n))
variable {H T : ℝ} (hH : 0≀H) (hhH : βˆ€ n, h n 0≀H) (ht : βˆ€ n, (t n:ℝ)≀T)
include hz hz0 hz1 hh0 hh hu hmin hH hhH ht in
lemma source_contact_monomial_tendsto (j r : β„•) (i : Fin r)
(G : CompactBlock CompactJointOverlap r →ᡇ ℝ) :
Tendsto (fun n => compactGGDefect (sourceGibbsArrayLaw n k f (fun a=>p a.val)
(fun a=>d a.val) (h n) (u n) z (t n)) r i G (compactJointMonomial (p j) (d j))) atTop (𝓝 0) := by
let c : ℝ := (2:ℝ)^(-((j+1:β„•):β„€))
have hc : 0<c := by dsimp [c]; positivity
have hN : Tendsto (fun n : β„• => ((n+1:β„•):ℝ)) atTop atTop :=
tendsto_natCast_atTop_atTop.comp (tendsto_add_atTop_nat 1)
have he : Tendsto (fun n : β„• => perturbationScale (n+1)) atTop (𝓝 0) := by
convert (tendsto_rpow_neg_atTop (by norm_num : (0:ℝ)<1/16)).comp hN using 1
simp only [perturbationScale,neg_div]; rfl
have he' : Tendsto (fun n : β„• => 8*perturbationScale (n+1)^2) atTop (𝓝 0) := by
simpa using (he.pow 2).const_mul 8
have hs : Tendsto (fun n : β„• => ((n+1:β„•):ℝ)^(-(1:ℝ)/4)) atTop (𝓝 0) := by
convert (tendsto_rpow_neg_atTop (by norm_num : (0:ℝ)<1/4)).comp hN using 1
simp only [neg_div,Function.comp_def]
apply squeeze_zero_norm' (a := fun n => β€–Gβ€–/c^2*(Real.sqrt (2*c)*((n+1:β„•):ℝ)^(-(3:ℝ)/8)+
(c+4*Real.sqrt (enrichedVarianceConstant k z f H T))*((n+1:β„•):ℝ)^(-(1:ℝ)/8)))
Β· filter_upwards [eventually_ge_atTop j,he'.eventually (gt_mem_nhds (by positivity : (0:ℝ)<c/16)),
hs.eventually (gt_mem_nhds (by norm_num : (0:ℝ)<1/4))] with n hn he hs
have hj : j<n+1 := by omega
simpa only [Real.norm_eq_abs,sourcePenaltyWeight,c] using
source_contact_compact_gg_rate n k f (fun a=>p a.val) (fun a=>d a.val) (h n)
(hh0 n) (hh n) z hz hz0 hz1 (t n) (hu n) (hmin n) ⟨j,hj⟩ hH (hhH n) (ht n)
he hs.le r i G
Β· exact (contact_gg_rate_tendsto c (enrichedVarianceConstant k z f H T) β€–Gβ€– c).comp hN
include hz hz0 hz1 hh0 hh hu hmin hH hhH ht in
lemma source_contact_limit_joint_gg
{Ξ½ : ProbabilityMeasure (CompactArray CompactJointOverlap)} {s : β„•β†’β„•} (hs : StrictMono s)
(hlim : Tendsto (fun n=>sourceGibbsArrayLaw (s n) k f (fun a=>p a.val) (fun a=>d a.val)
(h (s n)) (u (s n)) z (t (s n))) atTop (𝓝 Ξ½))
(hcover : βˆ€ a b : β„•, 1≀a+b β†’ βˆƒ j, p j=a ∧ d j=b)
(r : β„•) (i : Fin r) (G : CompactBlock CompactJointOverlap r →ᡇ ℝ)
(g : CompactJointOverlap →ᡇ ℝ) : compactGGDefect Ξ½ r i G g=0 := by
apply compactGG_of_joint_monomials Ξ½ r i G
intro a b
by_cases hab : a+b=0
Β· have ha : a=0 := by omega
have hb : b=0 := by omega
subst a b
simpa only [compactJointMonomial_zero] using compactGGDefect_one Ξ½ r i G
obtain ⟨j,hp,hd⟩ := hcover a b (by omega)
apply compactGGDefect_limit hlim
simpa only [hp,hd,Function.comp_def] using
(source_contact_monomial_tendsto k f p d z hz hz0 hz1 t h hh0 hh u hu hmin hH hhH ht j r i G).comp hs.tendsto_atTop
end SphericalPerceptronFreeEnergy
end
end OAI