File size: 6,371 Bytes
7d9f027
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
import Mathlib
import OAI.Probability.SKGap.Localization.DiagonalHessianJoined
import OAI.Probability.SKGap.Localization.ConditionalEmpiricalLaw
import OAI.Probability.SKGap.Entropy.ConditionalBadSet

namespace OAI

section
noncomputable section
namespace SKGap
open Matrix Real Set MeasureTheory ProbabilityTheory
open scoped BigOperators Matrix.Norms.Frobenius

lemma scalarQMoment_empirical_overlap {n : ℕ} [NeZero n] (y : Fin n → ℝ) :
    scalarQMoment (empiricalLaw y)=overlap y := by
  simp only [scalarQMoment,integral_empiricalLaw,Fintype.card_fin,overlap,magnetization,
    div_eq_mul_inv,mul_comm]

lemma empirical_columns_zero_outer {n : ℕ} [NeZero n] (y : Fin n → ℝ) (d s j : ℝ) :
    j • vecMulVec (empiricalGramColumns y d s 0).ofLp (empiricalGramColumns y d s 0).ofLp=
      (j/(n:ℝ)) • vecMulVec (fun _=>1) (fun _=>1) := by
  have hnR : (n:ℝ) ≠ 0 := by exact_mod_cast NeZero.ne n
  have hn : sqrt (n:ℝ) ≠ 0 := (sqrt_pos.mpr (by exact_mod_cast NeZero.pos n)).ne'
  ext i k
  simp only [empiricalGramColumns,gramCoordinates,Matrix.cons_val,WithLp.ofLp_toLp,
    Matrix.smul_apply,smul_eq_mul,vecMulVec_apply,mul_one]
  field_simp
  rw [Real.sq_sqrt (Nat.cast_nonneg n)]

lemma empirical_unit_outer {n : ℕ} [NeZero n] (y : Fin n → ℝ) {q : ℝ} (hq : 0 < q) (j : ℝ) :
    (2*j*q) • vecMulVec (empiricalUnit y q).ofLp (empiricalUnit y q).ofLp=
      (2*j/(n:ℝ)) • vecMulVec (magnetization y) (magnetization y) := by
  have hn : (n:ℝ) ≠ 0 := by exact_mod_cast NeZero.ne n
  have hc : sqrt ((n:ℝ)*q) ≠ 0 := (sqrt_pos.mpr (mul_pos (by exact_mod_cast NeZero.pos n) hq)).ne'
  ext i k
  simp only [empiricalUnit,WithLp.ofLp_toLp,Matrix.smul_apply,smul_eq_mul,vecMulVec_apply,magnetization]
  field_simp
  rw [Real.sq_sqrt (mul_nonneg hq.le (Nat.cast_nonneg n))]
  ring

lemma empiricalConditionalMiddle_literal {n : ℕ} [NeZero n] (j t σ : ℝ) (y : Fin n → ℝ)
    (hq : 0 < scalarQMoment (empiricalLaw y)) (g : MatrixCoordinates (Fin n) → ℝ) :
    empiricalConditionalMiddle j t σ y g=
      plantedInteraction j (empiricalConditionalGoe j t σ y g)+
      (2*j/(n:ℝ)) • vecMulVec (magnetization y) (magnetization y)-
      onsager j y • (1 : Matrix (Fin n) (Fin n) ℝ) := by
  dsimp only [empiricalConditionalMiddle,empiricalConditionalGoe,plantedInteraction]
  rw [empirical_columns_zero_outer,empirical_unit_outer y hq,
    scalarBMoment,scalarQMoment_empirical_overlap]
  rfl

lemma fieldHessian_diagonalHessian {n : ℕ} (j : ℝ) (W : Matrix (Fin n) (Fin n) ℝ)
    (y a : Fin n → ℝ) :
    fieldHessian j (plantedInteraction j W) y a = diagonalHessian a
      (plantedInteraction j W+(2*j/(n:ℝ)) • vecMulVec (magnetization y) (magnetization y)-
        onsager j y • (1 : Matrix (Fin n) (Fin n) ℝ)) := by
  ext i k
  simp only [fieldHessian,hessianCore,diagonalHessian,diagonalRoot,Matrix.sub_apply,
    Matrix.one_apply,Matrix.diagonal_mul,Matrix.mul_diagonal,Matrix.add_apply,
    Matrix.smul_apply,smul_eq_mul,vecMulVec_apply]
  ring

lemma empiricalConditionalGoe_hessian {n : ℕ} [NeZero n] (j t σ : ℝ) (y a : Fin n → ℝ)
    (hq : 0 < scalarQMoment (empiricalLaw y)) (g : MatrixCoordinates (Fin n) → ℝ) :
    fieldHessian j (plantedInteraction j (empiricalConditionalGoe j t σ y g)) y a=
      diagonalHessian a (empiricalConditionalMiddle j t σ y g) := by
  rw [empiricalConditionalMiddle_literal j t σ y hq g,fieldHessian_diagonalHessian]

lemma quadraticForm_dotProduct {n : ℕ} (M : Matrix (Fin n) (Fin n) ℝ) (x : Fin n → ℝ) :
    quadraticForm M x=x⬝ᵥ(M*ᵥx) := by
  simp only [quadraticForm,dotProduct,Matrix.mulVec,Finset.mul_sum]
  apply Finset.sum_congr rfl; intro i _
  apply Finset.sum_congr rfl; intro k _; ring

lemma quadraticForm_margin {n : ℕ} {M : Matrix (Fin n) (Fin n) ℝ} {m : ℝ}
    (hM : (M-m • (1 : Matrix (Fin n) (Fin n) ℝ)).PosSemidef)
    (x : EuclideanSpace ℝ (Fin n)) (hx : ‖x‖=1) : m ≤ quadraticForm M x.ofLp := by
  have hh := hM.dotProduct_mulVec_nonneg x.ofLp
  have hxx : x.ofLp⬝ᵥx.ofLp=1 := by
    have he := EuclideanSpace.real_norm_sq_eq x
    rw [hx,one_pow] at he
    simpa only [dotProduct,pow_two] using he.symm
  simp only [star_trivial,Matrix.sub_mulVec,Matrix.smul_mulVec,Matrix.one_mulVec,
    dotProduct_sub,dotProduct_smul,smul_eq_mul,hxx,mul_one] at hh
  rw [quadraticForm_dotProduct]
  linarith

end SKGap
end
end

section
noncomputable section
namespace SKGap
open Matrix Real Set MeasureTheory ProbabilityTheory
open scoped BigOperators Matrix.Norms.Frobenius ENNReal

lemma measurable_conditionalGoe_map {n : ℕ} [NeZero n] (j t σ : ℝ) (y : Fin n → ℝ) :
    Measurable (fun g (p : Fin n × Fin n) => empiricalConditionalGoe j t σ y g p.1 p.2) := by
  dsimp [empiricalConditionalGoe,conditionalBlockMatrix,goeBlockResidual,goeBilinear,
    Matrix.mulVec,dotProduct,goeMatrix]
  fun_prop

lemma measurable_badField_fiber {n : ℕ} (j A ε c : ℝ) (y : Fin n → ℝ) :
    MeasurableSet {W : (Fin n × Fin n) → ℝ | ((fun i k=>W (i,k)),y) ∈ badFieldSet n j A ε c} :=
  ((isClosed_badFieldSet n j A ε c).preimage (by fun_prop)).measurableSet

lemma conditional_bad_le_freshbad {n : ℕ} [NeZero n] {j t σ A ε c m : ℝ}
    (hj : 0 ≤ j) (ht : 0 < t) (hcm : c < m) (y : Fin n → ℝ)
    (hq : 0 < scalarQMoment (empiricalLaw y)) :
    (conditionalGoeLaw (j/(n:ℝ)) (t+σ^2) (magnetization y) (empiricalObservation j t σ y)).real
      {W | ((fun i k=>W (i,k)),y) ∈ badFieldSet n j A ε c} ≤
    (gaussianCoordinates (MatrixCoordinates (Fin n))).real
      {g | ∃ a, (∀ i,a i ∈ Icc 0 A) ∧
        (∑ i,(a i-(1-tanh (y i)^2))^2) ≤ ε^2*(n:ℝ) ∧
        ¬(diagonalHessian a (empiricalConditionalMiddle j t σ y g)-
          m • (1 : Matrix (Fin n) (Fin n) ℝ)).PosSemidef} := by
  rw [show magnetization y=(fun i=>tanh (y i)) from rfl,empirical_conditional_law hj ht y hq]
  unfold Measure.real
  rw [Measure.map_apply (measurable_conditionalGoe_map j t σ y) (measurable_badField_fiber j A ε c y)]
  apply ENNReal.toReal_mono (by finiteness)
  apply measure_mono
  intro g hg
  obtain ⟨a,ha,hclose,x,hx,hquad⟩ := hg
  refine ⟨a,ha,hclose,?_⟩
  intro hpsd
  rw [empiricalConditionalGoe_hessian j t σ y a hq g] at hquad
  exact (not_le_of_gt hcm) ((quadraticForm_margin hpsd x hx).trans hquad)

end SKGap
end
end

end OAI