File size: 7,613 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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
import Mathlib
import OAI.Probability.SKGap.Localization.SampledFlatCLM
import OAI.Probability.SKGap.Matrix.DoublePlantLogNorm

namespace OAI

section
open scoped BigOperators
open scoped BigOperators
open scoped BigOperators
open scoped BigOperators
open scoped BigOperators
open scoped BigOperators NNReal
open MeasureTheory ProbabilityTheory
open MeasureTheory ProbabilityTheory Filter
open scoped BigOperators NNReal
open MeasureTheory ProbabilityTheory
open scoped BigOperators NNReal ENNReal
open MeasureTheory ProbabilityTheory Filter
open scoped BigOperators NNReal ENNReal
open MeasureTheory ProbabilityTheory
open scoped BigOperators Matrix Matrix.Norms.Elementwise
open scoped BigOperators
open MeasureTheory ProbabilityTheory
open scoped BigOperators Matrix Matrix.Norms.Elementwise
open scoped BigOperators
open scoped BigOperators NNReal ENNReal
open MeasureTheory Metric Set
open scoped BigOperators NNReal ENNReal
open MeasureTheory ProbabilityTheory Filter Set
open scoped BigOperators NNReal ENNReal Matrix.Norms.L2Operator
open MeasureTheory ProbabilityTheory Filter Set
open scoped BigOperators Matrix.Norms.L2Operator
open MeasureTheory ProbabilityTheory Filter Set
open scoped BigOperators Matrix Matrix.Norms.Elementwise
open MeasureTheory ProbabilityTheory Filter Set
open MeasureTheory ProbabilityTheory Filter
open scoped BigOperators ENNReal NNReal
open MeasureTheory ProbabilityTheory Filter
open scoped BigOperators NNReal ENNReal Matrix
open MeasureTheory ProbabilityTheory Filter
open scoped BigOperators ENNReal NNReal
open MeasureTheory ProbabilityTheory Filter
open scoped BigOperators NNReal ENNReal
open scoped BigOperators
open MeasureTheory ProbabilityTheory
open scoped BigOperators Matrix Matrix.Norms.Elementwise NNReal ENNReal
open scoped BigOperators
open Filter Topology
open MeasureTheory ProbabilityTheory Filter
open scoped NNReal ENNReal BigOperators Topology
open MeasureTheory ProbabilityTheory Filter
open Matrix
open scoped NNReal ENNReal BigOperators Topology Matrix.Norms.Elementwise
open MeasureTheory ProbabilityTheory Filter
open scoped BigOperators NNReal ENNReal Topology
open MeasureTheory ProbabilityTheory Filter Matrix
open scoped NNReal ENNReal BigOperators Topology
open MeasureTheory ProbabilityTheory Filter
open scoped BigOperators NNReal ENNReal Topology
open MeasureTheory ProbabilityTheory Filter
open scoped NNReal ENNReal BigOperators Topology
open MeasureTheory ProbabilityTheory Filter
open scoped NNReal ENNReal BigOperators Topology
open MeasureTheory ProbabilityTheory Filter
open scoped NNReal ENNReal BigOperators Topology
open MeasureTheory ProbabilityTheory Filter
open scoped NNReal ENNReal BigOperators Topology
open MeasureTheory ProbabilityTheory Filter
open scoped ENNReal Topology
open MeasureTheory ProbabilityTheory Filter
open scoped ENNReal NNReal Topology BigOperators
open MeasureTheory ProbabilityTheory Filter
open scoped ENNReal NNReal Topology BigOperators
namespace SKGapCutoff.Regression

noncomputable def doublePlantedGOEArray {n : ℕ} (β : ℝ) (x y : Spin n)
    (g : GaussianCoordinates n) : GaussianCoordinates n :=
  plantedGOEArray β x g + fun p => if p.1=p.2 then 0 else β^2/(n:ℝ)*spin y p.1*spin y p.2

lemma doublePlantedGOEArray_gaussian {n : ℕ} (β : ℝ) (x y : Spin n) :
    HasGaussianLaw (doublePlantedGOEArray β x y) (standardArrayLaw (Fin n × Fin n)) :=
  gaussian_add_constant (plantedGOEArray_gaussian β x) _

lemma sampled_double_planted_gaussian (β : ℝ) {n : ℕ} (hn : 0 < n) (x y : Spin n) :
    HasGaussianLaw (fun g : GaussianCoordinates n => fun p : Fin n × Fin n =>
      sampledInteraction g p.1 p.2) (doubleSpinPlantedLaw β x y) := by
  rw [doubleSpinPlantedLaw_eq_gaussianPi β hn]
  have hh := (piGaussian_coordinates (fun p => β^2/(n:ℝ)*(upperCoefficient x p + upperCoefficient y p))
    (Real.toNNReal (β^2/(n:ℝ)))).map_fun (sampledFlatCLM n)
  exact hh.congr (Eventually.of_forall fun g => funext fun p => sampledFlatCLM_apply g p)

lemma doublePlantedGOEArray_mean {n : ℕ} (β : ℝ) (x y : Spin n) (p : Fin n × Fin n) :
    (∫ g, doublePlantedGOEArray β x y g p ∂standardArrayLaw (Fin n × Fin n)) =
      if p.1=p.2 then 0 else β^2/(n:ℝ)*(spin x p.1*spin x p.2+spin y p.1*spin y p.2) := by
  change (∫ g, plantedGOEArray β x g p + _ ∂standardArrayLaw (Fin n × Fin n)) = _
  rw [integral_add ((plantedGOEArray_gaussian β x).eval p).integrable
    (integrable_const _), plantedGOEArray_mean, integral_const]
  by_cases h : p.1=p.2
  · simp [h]
  · simp [h]
    ring

lemma sampled_double_planted_mean (β : ℝ) {n : ℕ} (hn : 0 < n) (x y : Spin n)
    (p : Fin n × Fin n) :
    (∫ g, sampledInteraction g p.1 p.2 ∂doubleSpinPlantedLaw β x y) =
      if p.1=p.2 then 0 else β^2/(n:ℝ)*(spin x p.1*spin x p.2+spin y p.1*spin y p.2) := by
  rw [doubleSpinPlantedLaw_eq_gaussianPi β hn]
  by_cases h : p.1=p.2
  · simp [sampledInteraction, h]
  · simp only [sampledInteraction, h, ite_false]
    rw [piGaussian_coordinate_mean, upperCoefficient_min_max x _ _ h,
      upperCoefficient_min_max y _ _ h]

lemma doublePlantedGOEArray_covariance {n : ℕ} (hn : 0 < n) (β : ℝ) (x y : Spin n)
    (p q : Fin n × Fin n) :
    cov[fun g => doublePlantedGOEArray β x y g p, fun g => doublePlantedGOEArray β x y g q;
      standardArrayLaw (Fin n × Fin n)] =
      if p.1=p.2 ∨ q.1=q.2 then 0 else
        (β^2/(n:ℝ)) * ((if p.1=q.1 ∧ p.2=q.2 then 1 else 0) +
          (if p.1=q.2 ∧ p.2=q.1 then 1 else 0)) := by
  change cov[fun g => plantedGOEArray β x g p + _, fun g => plantedGOEArray β x g q + _; _] = _
  rw [covariance_add_const_left ((plantedGOEArray_gaussian β x).eval p).integrable,
    covariance_add_const_right ((plantedGOEArray_gaussian β x).eval q).integrable,
    plantedGOEArray_covariance hn]

lemma sampled_double_planted_covariance (β : ℝ) {n : ℕ} (hn : 0 < n) (x y : Spin n)
    (p q : Fin n × Fin n) :
    cov[fun g => sampledInteraction g p.1 p.2, fun g => sampledInteraction g q.1 q.2;
        doubleSpinPlantedLaw β x y] =
      if p.1=p.2 ∨ q.1=q.2 then 0 else
        (β^2/(n:ℝ)) * ((if p.1=q.1 ∧ p.2=q.2 then 1 else 0) +
          (if p.1=q.2 ∧ p.2=q.1 then 1 else 0)) := by
  rw [doubleSpinPlantedLaw_eq_gaussianPi β hn]
  by_cases hp : p.1=p.2
  · simp [sampledInteraction, hp]
  by_cases hq : q.1=q.2
  · simp [sampledInteraction, hq]
  simp only [sampledInteraction, hp, hq, false_or, ite_false]
  rw [piGaussian_coordinate_covariance, Real.coe_toNNReal _ (by positivity)]
  simp only [minmax_pair_eq_iff]
  by_cases h1 : p.1=q.1 ∧ p.2=q.2
  · have h2 : ¬ (p.1=q.2 ∧ p.2=q.1) := by omega
    rw [ite_eq_left (Or.inl h1), ite_eq_left h1, ite_eq_right h2, add_zero, mul_one]
  by_cases h2 : p.1=q.2 ∧ p.2=q.1
  · rw [ite_eq_left (Or.inr h2), ite_eq_right h1, ite_eq_left h2, zero_add, mul_one]
  · rw [ite_eq_right (not_or.mpr ⟨h1,h2⟩), ite_eq_right h1, ite_eq_right h2, add_zero, mul_zero]

lemma double_planted_matrix_representation (β : ℝ) {n : ℕ} (hn : 0 < n) (x y : Spin n) :
    (doubleSpinPlantedLaw β x y).map (fun g : GaussianCoordinates n =>
      fun p : Fin n × Fin n => sampledInteraction g p.1 p.2) =
    (standardArrayLaw (Fin n × Fin n)).map (doublePlantedGOEArray β x y) := by
  apply gaussian_vector_law_ext (sampled_double_planted_gaussian β hn x y)
    (doublePlantedGOEArray_gaussian β x y)
  · intro p
    rw [sampled_double_planted_mean β hn, doublePlantedGOEArray_mean]
  · intro p q
    rw [sampled_double_planted_covariance β hn, doublePlantedGOEArray_covariance hn]

end SKGapCutoff.Regression

end

end OAI