File size: 12,361 Bytes
c4cdbbd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
import OAI.Probability.InvariantIsing.Fields.FieldScalarComposition
import OAI.Probability.InvariantIsing.Fields.FieldTerminalOrder

namespace OAI

/-! Exact single-height derivatives of the finite Gaussian field value.
An interior height changes its two adjacent covariance increments with
opposite signs. The final height includes the diagonal subtraction. -/

noncomputable section
open MeasureTheory ProbabilityTheory IsingPerceptron Set
open scoped NNReal

namespace InvariantIsing

def fieldFixedAffine (S : List (ℝ × ℝ≥0)) : List FieldAffineStep :=
  S.map fun av => ⟨av.2, 0, av.1⟩

lemma fieldFixedAffine_base (S : List (ℝ × ℝ≥0))
    (hS : ∀ av ∈ S, 0 < (av.2 : ℝ)) :
    ∀ av ∈ fieldFixedAffine S, 0 < av.base := by
  intro av hav
  obtain ⟨bv, hb, rfl⟩ := List.mem_map.mp hav
  exact hS bv hb

lemma fieldFixedAffine_slope (S : List (ℝ × ℝ≥0)) :
    ∀ av ∈ fieldFixedAffine S, av.slope = 0 := by
  intro av hav
  obtain ⟨bv, _, rfl⟩ := List.mem_map.mp hav
  rfl

lemma fieldFixedAffine_increments (S : List (ℝ × ℝ≥0)) (t : ℝ) :
    fieldAffineIncrements (fieldFixedAffine S) t = S := by
  simp only [fieldAffineIncrements, fieldFixedAffine, List.map_map, Function.comp_def]
  have he : (fun av : ℝ × ℝ≥0 =>
      (((⟨av.2, 0, av.1⟩ : FieldAffineStep).exponent),
        Real.toNNReal ((⟨av.2, 0, av.1⟩ : FieldAffineStep).base +
          (⟨av.2, 0, av.1⟩ : FieldAffineStep).slope * t))) = id := by
    funext av
    simp
  rw [he, List.map_id]

/-- Actual increment list when a single nonterminal height is varied. -/
def fieldAdjacentIncrements (P S : List (ℝ × ℝ≥0)) (a b ζ η t : ℝ) :
    List (ℝ × ℝ≥0) :=
  P ++ (ζ, Real.toNNReal (a + t)) :: (η, Real.toNNReal (b - t)) :: S

def fieldAdjacentLevel (P S : List (ℝ × ℝ≥0)) (a b ζ η t : ℝ) :
    Fin ((fieldAdjacentIncrements P S a b ζ η t).length + 1) :=
  fieldAppendIndex P ((ζ, Real.toNNReal (a + t)) ::
    (η, Real.toNNReal (b - t)) :: S) 1

private lemma adjacent_value (a b ζ η : ℝ) (S : List (ℝ × ℝ≥0))
    (hS : ∀ av ∈ S, 0 < (av.2 : ℝ)) (t : ℝ) :
    (fun z => (fieldAdjacentFamily a b ζ η (fieldFixedAffine S)
      (fieldFixedAffine_base S hS) (fieldFixedAffine_slope S)).U (t, z)) =
    fieldScalarValue ((ζ, Real.toNNReal (a + t)) ::
      (η, Real.toNNReal (b - t)) :: S) (fun z => Real.log (Real.cosh z)) := by
  change gaussianTransform (a + 1 * t) ζ
    (fun y => gaussianTransform (b + -1 * t) η
      (fun z => (fieldAdjacentTail a b (fieldFixedAffine S)
        (fieldFixedAffine_base S hS) (fieldFixedAffine_slope S)).U (t, z)) y) = _
  rw [one_mul, neg_one_mul, ← sub_eq_add_neg, field_gaussianTransform_eq_operator]
  have he : (fun y => gaussianTransform (b - t) η
      (fun z => (fieldAdjacentTail a b (fieldFixedAffine S)
        (fieldFixedAffine_base S hS) (fieldFixedAffine_slope S)).U (t, z)) y) =
      gaussianOperator η (Real.toNNReal (b - t))
        (fieldScalarValue S (fun z => Real.log (Real.cosh z))) := by
    rw [field_gaussianTransform_eq_operator]
    rw [show (fun z => (fieldAdjacentTail a b (fieldFixedAffine S)
      (fieldFixedAffine_base S hS) (fieldFixedAffine_slope S)).U (t, z)) =
      (fun z => fieldAffineValue (fieldFixedAffine S) (t, z)) from
      congrArg (fun f => fun z => f (t, z))
        (fieldAffineFamily_value _ _ _ _),
      fieldAffineValue_scalar, fieldFixedAffine_increments]
  rw [he]
  rfl

private lemma adjacent_inner_mean (a b η : ℝ) (S : List (ℝ × ℝ≥0))
    (hS : ∀ av ∈ S, 0 < (av.2 : ℝ)) (t : ℝ) :
    (fun z => (fieldAdjacentInner a b η (fieldFixedAffine S)
      (fieldFixedAffine_base S hS) (fieldFixedAffine_slope S)).X (t, z)) =
    fieldScalarMean ((η, Real.toNNReal (b - t)) :: S)
      (fun z => Real.log (Real.cosh z)) Real.tanh := by
  let av : FieldAffineStep := ⟨b, -1, η⟩
  have hv : ∀ v ∈ av :: fieldFixedAffine S, ∀ q ∈ Ioo (-a) b,
      0 < v.base + v.slope * q := by
    intro v hv q hq
    rcases List.mem_cons.mp hv with rfl | hv
    · dsimp only [av]
      linarith [hq.2]
    · rw [fieldFixedAffine_slope S v hv, zero_mul, add_zero]
      exact fieldFixedAffine_base S hS v hv
  have h := fieldAffineFamily_mean (Ioo (-a) b) isOpen_Ioo
    (av :: fieldFixedAffine S) hv t
  change (fun z => (fieldAffineFamily (Ioo (-a) b) isOpen_Ioo
    (av :: fieldFixedAffine S) hv).X (t, z)) = _
  rw [h]
  simp only [fieldAffineIncrements, List.map_cons]
  rw [← fieldAffineIncrements, fieldFixedAffine_increments]
  simp only [av, neg_one_mul, ← sub_eq_add_neg]

/-- The manuscript's finite interior-height gradient before the fixed
normalizing diagonal term. The derivative is minus half the cell width
multiplied by its actual conditional squared spin mean. -/
theorem hasDerivAt_fieldAdjacentValue
    (P S : List (ℝ × ℝ≥0))
    (hP : ∀ av ∈ P, 0 < (av.2 : ℝ))
    (hS : ∀ av ∈ S, 0 < (av.2 : ℝ))
    (a b ζ η t z : ℝ) (ht : t ∈ Ioo (-a) b) :
    HasDerivAt (fun q => fieldScalarValue (fieldAdjacentIncrements P S a b ζ η q)
      (fun y => Real.log (Real.cosh y)) z)
      (-(η - ζ) / 2 * fieldScalarSquares (fieldAdjacentIncrements P S a b ζ η t)
        (fun y => Real.log (Real.cosh y)) Real.tanh
        (fieldAdjacentLevel P S a b ζ η t) z) t := by
  let L := fieldFixedAffine S
  let hb := fieldFixedAffine_base S hS
  let hs := fieldFixedAffine_slope S
  let F := fieldAdjacentTail a b L hb hs
  let G := fieldAdjacentInner a b η L hb hs
  let H := fieldAdjacentFamily a b ζ η L hb hs
  let K := fieldConstantPrefix isOpen_Ioo H P hP
  have hval (q : ℝ) : (fun y => K.U (q, y)) =
      fieldScalarValue (fieldAdjacentIncrements P S a b ζ η q)
        (fun y => Real.log (Real.cosh y)) := by
    rw [show (fun y => K.U (q, y)) =
      fieldScalarValue P (fun y => H.U (q, y)) from
        fieldConstantPrefix_value isOpen_Ioo H P hP q,
      adjacent_value a b ζ η S hS q]
    exact (fieldScalarValue_append P _ _).symm
  have htan : (fun y => H.T (t, y)) = fun y =>
      -(η - ζ) / 2 * gaussianTiltAverage (a + t) ζ
        (fun x => G.U (t, x)) (fun x => (G.X (t, x)) ^ 2) y := by
    funext y
    exact F.adjacent_tangent isOpen_Ioo a b ζ η
      (fun q hq => by linarith [hq.1]) (fun q hq => by linarith [hq.2])
      (p := (t, y)) ht (fun x => fieldAdjacentTail_stationary a b L hb hs (t, x))
  have hsquare : gaussianTiltAverage (a + t) ζ
      (fun x => G.U (t, x)) (fun x => (G.X (t, x)) ^ 2) =
      fieldScalarSquares ((ζ, Real.toNNReal (a + t)) ::
        (η, Real.toNNReal (b - t)) :: S)
        (fun y => Real.log (Real.cosh y)) Real.tanh 1 := by
    have hm : Measurable (fun x => (G.X (t, x)) ^ 2) :=
      (G.mX.comp (by fun_prop)).pow_const 2
    have hmG : Measurable (fun x => G.U (t, x)) := G.mU.comp (by fun_prop)
    have htrans : gaussianTiltAverage (a + t) ζ
        (fun x => G.U (t, x)) (fun x => (G.X (t, x)) ^ 2) =
        fieldSpinTransition ζ (Real.toNNReal (a + t))
          (fun x => G.U (t, x)) (fun x => (G.X (t, x)) ^ 2) := by
      exact field_gaussianTiltAverage_eq_transition _ _ hmG hm
    rw [htrans]
    have hG : (fun x => G.U (t, x)) = fieldScalarValue
        ((η, Real.toNNReal (b - t)) :: S) (fun y => Real.log (Real.cosh y)) := by
      change gaussianTransform (b + -1 * t) η
        (fun x => F.U (t, x)) = _
      rw [neg_one_mul, ← sub_eq_add_neg, field_gaussianTransform_eq_operator]
      congr 1
      rw [show (fun x => F.U (t, x)) = (fun x => fieldAffineValue L (t, x)) from
        congrArg (fun f => fun x => f (t, x)) (fieldAffineFamily_value _ _ _ _),
        fieldAffineValue_scalar, fieldFixedAffine_increments]
      rfl
    rw [hG]
    have hGX : (fun x => G.X (t, x)) = fieldScalarMean
        ((η, Real.toNNReal (b - t)) :: S)
        (fun y => Real.log (Real.cosh y)) Real.tanh := adjacent_inner_mean a b η S hS t
    have hpow : (fun x => (G.X (t, x)) ^ 2) = fun x => (fieldScalarMean
        ((η, Real.toNNReal (b - t)) :: S)
        (fun y => Real.log (Real.cosh y)) Real.tanh x) ^ 2 := by
      funext x
      rw [congrFun hGX x]
    rw [hpow]
    rfl
  have hd := K.parameter_derivative t z ht
  have hfun : (fun q => K.U (q, z)) = fun q =>
      fieldScalarValue (fieldAdjacentIncrements P S a b ζ η q)
        (fun y => Real.log (Real.cosh y)) z := by
    funext q
    exact congrFun (hval q) z
  rw [hfun] at hd
  convert hd using 1
  rw [show K.T (t, z) = fieldScalarMean P (fun y => H.U (t, y))
      (fun y => H.T (t, y)) z from
      congrFun (fieldConstantPrefix_tangent isOpen_Ioo H P hP t) z,
    htan, fieldScalarMean_const_mul, hsquare, adjacent_value a b ζ η S hS t]
  simp only [fieldAdjacentLevel, fieldAdjacentIncrements]
  rw [fieldScalarSquares_append]

/-- The terminal height changes the final variance and the normalizing
subtraction by the same amount. -/
def fieldTerminalIncrements (P : List (ℝ × ℝ≥0)) (a ζ t : ℝ) :
    List (ℝ × ℝ≥0) := P ++ [(ζ, Real.toNNReal (a + t))]

def fieldTerminalLevel (P : List (ℝ × ℝ≥0)) (a ζ t : ℝ) :
    Fin ((fieldTerminalIncrements P a ζ t).length + 1) :=
  fieldAppendIndex P [(ζ, Real.toNNReal (a + t))] 1

theorem hasDerivAt_fieldTerminalValue
    (P : List (ℝ × ℝ≥0)) (hP : ∀ av ∈ P, 0 < (av.2 : ℝ))
    (a ζ d t z : ℝ) (ht : t ∈ Ioi (-a)) :
    HasDerivAt (fun q => fieldScalarValue (fieldTerminalIncrements P a ζ q)
      (fun y => Real.log (Real.cosh y)) z - (d + q) / 2)
      (-(1 - ζ) / 2 * fieldScalarSquares (fieldTerminalIncrements P a ζ t)
        (fun y => Real.log (Real.cosh y)) Real.tanh (fieldTerminalLevel P a ζ t) z) t := by
  let H := fieldTerminalFamily a ζ
  let K := fieldConstantPrefix isOpen_Ioi H P hP
  let A : ℝ → ℝ := fun y => gaussianTiltAverage (a + t) ζ
    (fun x => Real.log (Real.cosh x)) (fun x => (Real.tanh x) ^ 2) y
  have hm : Measurable (fun x : ℝ => (Real.tanh x) ^ 2) := by
    simp only [Real.tanh_eq]
    fun_prop
  have hA : Measurable A :=
    measurable_gaussianTiltAverage_param (measurable_logCosh.comp measurable_snd)
      (hm.comp measurable_snd) measurable_const measurable_id ζ
  have hAb : ∀ y, |A y| ≤ 1 := by
    intro y
    apply field_gaussianTiltAverage_bound _ _ measurable_logCosh logCosh_linearGrowth hm
    intro x
    rw [abs_pow]
    nlinarith [field_abs_tanh_le_one x, abs_nonneg (Real.tanh x)]
  have hval (q : ℝ) : (fun y => K.U (q, y)) =
      fieldScalarValue (fieldTerminalIncrements P a ζ q)
        (fun y => Real.log (Real.cosh y)) := by
    rw [show (fun y => K.U (q, y)) =
      fieldScalarValue P (fun y => H.U (q, y)) from
        fieldConstantPrefix_value isOpen_Ioi H P hP q,
      fieldTerminalFamily_value_eq_operator]
    change fieldScalarValue P (fieldScalarValue [(ζ, Real.toNNReal (a + q))]
      (fun y => Real.log (Real.cosh y))) = _
    exact (fieldScalarValue_append P [(ζ, Real.toNNReal (a + q))]
      (fun y => Real.log (Real.cosh y))).symm
  have htangent : (fun y => H.T (t, y)) = fun y => 1 / 2 + (-(1 - ζ) / 2) * A y := by
    funext y
    rw [fieldTerminalFamily_tangent]
    dsimp only [A]
    ring
  have hsquare : A = fieldScalarSquares [(ζ, Real.toNNReal (a + t))]
      (fun y => Real.log (Real.cosh y)) Real.tanh 1 := by
    dsimp only [A]
    rw [field_gaussianTiltAverage_eq_transition _ _ measurable_logCosh hm]
    rfl
  have hd := (K.parameter_derivative t z ht).sub
    (((hasDerivAt_const t d).add (hasDerivAt_id t)).div_const 2)
  change HasDerivAt (fun q => K.U (q, z) - (d + q) / 2)
    (K.T (t, z) - (0 + 1) / 2) t at hd
  have hfun : (fun q => K.U (q, z) - (d + q) / 2) = fun q =>
      fieldScalarValue (fieldTerminalIncrements P a ζ q)
        (fun y => Real.log (Real.cosh y)) z - (d + q) / 2 := by
    funext q
    rw [congrFun (hval q) z]
  rw [hfun] at hd
  convert hd using 1
  rw [show K.T (t, z) = fieldScalarMean P (fun y => H.U (t, y))
      (fun y => H.T (t, y)) z from
      congrFun (fieldConstantPrefix_tangent isOpen_Ioi H P hP t) z,
    htangent, fieldConstantPrefix_test_affine isOpen_Ioi H P hP t hA hAb,
    hsquare, fieldTerminalFamily_value_eq_operator]
  simp only [fieldTerminalLevel, fieldTerminalIncrements]
  rw [fieldScalarSquares_append]
  change _ = (1 / 2 + -(1 - ζ) / 2 * _) - (0 + 1) / 2
  simp only [fieldScalarValue, List.foldr_cons, List.foldr_nil]
  ring

end InvariantIsing

end

end OAI