roseking commited on
Commit
a89d282
·
verified ·
1 Parent(s): c4cdbbd

Add lean source and binary files (part 124)

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. lean/OAI/Probability/InvariantIsing/Fields/FieldScalarLogCoshSecond.lean +62 -0
  2. lean/OAI/Probability/InvariantIsing/Fields/FieldScalarOrder.lean +101 -0
  3. lean/OAI/Probability/InvariantIsing/Fields/FieldScalarOverlap.lean +114 -0
  4. lean/OAI/Probability/InvariantIsing/Fields/FieldScalarSampling.lean +105 -0
  5. lean/OAI/Probability/InvariantIsing/Fields/FieldScalarScaling.lean +152 -0
  6. lean/OAI/Probability/InvariantIsing/Fields/FieldScalarSecondDerivative.lean +71 -0
  7. lean/OAI/Probability/InvariantIsing/Fields/FieldScalarSquareOrder.lean +111 -0
  8. lean/OAI/Probability/InvariantIsing/Fields/FieldSecondBounds.lean +103 -0
  9. lean/OAI/Probability/InvariantIsing/Fields/FieldSecondCovariance.lean +50 -0
  10. lean/OAI/Probability/InvariantIsing/Fields/FieldSecondFamily.lean +136 -0
  11. lean/OAI/Probability/InvariantIsing/Fields/FieldSecondMeanBounds.lean +131 -0
  12. lean/OAI/Probability/InvariantIsing/Fields/FieldSecondMeanDerivative.lean +123 -0
  13. lean/OAI/Probability/InvariantIsing/Fields/FieldSecondMeasurable.lean +74 -0
  14. lean/OAI/Probability/InvariantIsing/Fields/FieldSecondRecursion.lean +67 -0
  15. lean/OAI/Probability/InvariantIsing/Fields/FieldSecondTangentDerivative.lean +139 -0
  16. lean/OAI/Probability/InvariantIsing/Fields/FieldShiftMoments.lean +63 -0
  17. lean/OAI/Probability/InvariantIsing/Fields/FieldSimpleApproximation.lean +53 -0
  18. lean/OAI/Probability/InvariantIsing/Fields/FieldSmoothFamily.lean +170 -0
  19. lean/OAI/Probability/InvariantIsing/Fields/FieldSpatialParameterOrder.lean +65 -0
  20. lean/OAI/Probability/InvariantIsing/Fields/FieldSpinDerivative.lean +77 -0
  21. lean/OAI/Probability/InvariantIsing/Fields/FieldSpinEvaluation.lean +54 -0
  22. lean/OAI/Probability/InvariantIsing/Fields/FieldSpinFolding.lean +62 -0
  23. lean/OAI/Probability/InvariantIsing/Fields/FieldSpinKernelOrder.lean +110 -0
  24. lean/OAI/Probability/InvariantIsing/Fields/FieldSpinLinear.lean +64 -0
  25. lean/OAI/Probability/InvariantIsing/Fields/FieldSpinLipschitz.lean +35 -0
  26. lean/OAI/Probability/InvariantIsing/Fields/FieldSpinMeasurability.lean +74 -0
  27. lean/OAI/Probability/InvariantIsing/Fields/FieldSpinPairConditioning.lean +68 -0
  28. lean/OAI/Probability/InvariantIsing/Fields/FieldSpinProduct.lean +72 -0
  29. lean/OAI/Probability/InvariantIsing/Fields/FieldSpinProductLaw.lean +42 -0
  30. lean/OAI/Probability/InvariantIsing/Fields/FieldSpinProjectionEnergy.lean +61 -0
  31. lean/OAI/Probability/InvariantIsing/Fields/FieldSpinSampling.lean +123 -0
  32. lean/OAI/Probability/InvariantIsing/Fields/FieldSpinSecondDerivative.lean +86 -0
  33. lean/OAI/Probability/InvariantIsing/Fields/FieldSpinTransition.lean +159 -0
  34. lean/OAI/Probability/InvariantIsing/Fields/FieldSpinVariance.lean +119 -0
  35. lean/OAI/Probability/InvariantIsing/Fields/FieldSquarePrefix.lean +54 -0
  36. lean/OAI/Probability/InvariantIsing/Fields/FieldTail.lean +61 -0
  37. lean/OAI/Probability/InvariantIsing/Fields/FieldTailMgf.lean +62 -0
  38. lean/OAI/Probability/InvariantIsing/Fields/FieldTangentOrder.lean +97 -0
  39. lean/OAI/Probability/InvariantIsing/Fields/FieldTerminalGenerator.lean +57 -0
  40. lean/OAI/Probability/InvariantIsing/Fields/FieldTerminalOne.lean +116 -0
  41. lean/OAI/Probability/InvariantIsing/Fields/FieldTerminalOrder.lean +128 -0
  42. lean/OAI/Probability/InvariantIsing/Fields/FieldTiltAverageDerivative.lean +130 -0
  43. lean/OAI/Probability/InvariantIsing/Fields/FieldTiltDerivative.lean +46 -0
  44. lean/OAI/Probability/InvariantIsing/Fields/FieldTiltedFamilyDerivative.lean +102 -0
  45. lean/OAI/Probability/InvariantIsing/Fields/FieldTiltedPairDerivative.lean +63 -0
  46. lean/OAI/Probability/InvariantIsing/Fields/FieldVaryingContinuity.lean +139 -0
  47. lean/OAI/Probability/InvariantIsing/Fields/FieldVaryingRecursion.lean +158 -0
  48. lean/OAI/Probability/InvariantIsing/Fields/FieldVectorPairSampling.lean +139 -0
  49. lean/OAI/Probability/InvariantIsing/Fields/FieldVectorSampling.lean +121 -0
  50. lean/OAI/Probability/InvariantIsing/Fields/FieldWasserstein.lean +58 -0
lean/OAI/Probability/InvariantIsing/Fields/FieldScalarLogCoshSecond.lean ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Probability.InvariantIsing.Fields.FieldScalarSecondDerivative
2
+
3
+ namespace OAI
4
+
5
+ /-! Bounded first and second spatial derivatives for the scalar Ising
6
+ backward recursion, including degenerate covariance increments. -/
7
+
8
+ noncomputable section
9
+ open MeasureTheory ProbabilityTheory IsingPerceptron
10
+ open scoped NNReal
11
+
12
+ namespace InvariantIsing
13
+
14
+ lemma field_hasDerivAt_tanh (z : ℝ) :
15
+ HasDerivAt Real.tanh (1 / (Real.cosh z) ^ 2) z := by
16
+ have h := (Real.hasDerivAt_sinh z).div (Real.hasDerivAt_cosh z) (Real.cosh_pos z).ne'
17
+ have hrel := Real.cosh_sq_sub_sinh_sq z
18
+ convert h using 1
19
+ · funext x
20
+ exact Real.tanh_eq_sinh_div_cosh x
21
+ · rw [← pow_two, ← pow_two, hrel]
22
+
23
+ lemma field_tanh_second_bound (z : ℝ) : |1 / (Real.cosh z) ^ 2| ≤ 1 := by
24
+ rw [abs_of_nonneg (by positivity : 0 ≤ 1 / (Real.cosh z) ^ 2)]
25
+ apply (div_le_one (sq_pos_of_pos (Real.cosh_pos z))).mpr
26
+ nlinarith [Real.one_le_cosh z]
27
+
28
+ theorem fieldScalarLogCoshSecond_regular (L : List (ℝ × ℝ≥0))
29
+ (hL : ∀ av ∈ L, 0 < av.1) :
30
+ Measurable (fieldScalarSecond L (fun x => Real.log (Real.cosh x)) Real.tanh
31
+ (fun x => 1 / (Real.cosh x) ^ 2)) ∧
32
+ ∀ z, |fieldScalarSecond L (fun x => Real.log (Real.cosh x)) Real.tanh
33
+ (fun x => 1 / (Real.cosh x) ^ 2) z| ≤ fieldScalarSecondCap L 1 1 := by
34
+ have ht : Measurable Real.tanh := by
35
+ change Measurable (fun x : ℝ => Real.tanh x)
36
+ simp only [Real.tanh_eq]
37
+ fun_prop
38
+ apply fieldScalarSecond_regular L hL measurable_logCosh logCosh_linearGrowth
39
+ ht
40
+ (by fun_prop) zero_le_one field_abs_tanh_le_one field_tanh_second_bound
41
+
42
+ theorem hasDerivAt_fieldScalarLogCoshMean (L : List (ℝ × ℝ≥0))
43
+ (hL : ∀ av ∈ L, 0 < av.1) (z : ℝ) :
44
+ HasDerivAt (fieldScalarMean L (fun x => Real.log (Real.cosh x)) Real.tanh)
45
+ (fieldScalarSecond L (fun x => Real.log (Real.cosh x)) Real.tanh
46
+ (fun x => 1 / (Real.cosh x) ^ 2) z) z := by
47
+ have ht : Measurable Real.tanh := by
48
+ change Measurable (fun x : ℝ => Real.tanh x)
49
+ simp only [Real.tanh_eq]
50
+ fun_prop
51
+ apply hasDerivAt_fieldScalarMean L hL measurable_logCosh logCosh_linearGrowth ht
52
+ (by fun_prop) zero_le_one field_abs_tanh_le_one field_tanh_second_bound
53
+ · intro x
54
+ simpa only [Real.tanh_eq_sinh_div_cosh] using
55
+ (Real.hasDerivAt_cosh x).log (Real.cosh_pos x).ne'
56
+ · exact field_hasDerivAt_tanh
57
+
58
+ end InvariantIsing
59
+
60
+ end
61
+
62
+ end OAI
lean/OAI/Probability/InvariantIsing/Fields/FieldScalarOrder.lean ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Probability.InvariantIsing.Fields.FieldScalarChain
2
+
3
+ namespace OAI
4
+
5
+ /-! Radial order of the actual scalar backward values and physical spin
6
+ means, with covariance increments fixed. -/
7
+
8
+ noncomputable section
9
+ open MeasureTheory ProbabilityTheory IsingPerceptron Set
10
+ open scoped NNReal
11
+
12
+ namespace InvariantIsing
13
+
14
+ lemma fieldScalarValue_even (L : List (ℝ × ℝ≥0))
15
+ (hL : ∀ av ∈ L, 0 < av.1) {F : ℝ → ℝ}
16
+ (hF : Measurable F) (hG : HasLinearGrowth F) (he : Function.Even F) :
17
+ Function.Even (fieldScalarValue L F) := by
18
+ induction L with
19
+ | nil => exact he
20
+ | cons av L ih =>
21
+ have ht (bv) (hb : bv ∈ L) := hL bv (List.mem_cons_of_mem av hb)
22
+ have hr := fieldScalarValue_regular L ht hF hG
23
+ exact gaussianOperator_even av.1 av.2 hr.1 (ih ht)
24
+
25
+ lemma fieldScalarValue_difference_monotone (L : List (ℝ × ℝ≥0))
26
+ (hL : ∀ av ∈ L, 0 < av.1) {F G : ℝ → ℝ}
27
+ (hF : Measurable F) (hG : Measurable G)
28
+ (hFg : HasLinearGrowth F) (hGg : HasLinearGrowth G)
29
+ (hFe : Function.Even F) (hGe : Function.Even G)
30
+ (hFG : MonotoneOn (fun z => G z - F z) (Ici 0)) :
31
+ MonotoneOn (fun z => fieldScalarValue L G z - fieldScalarValue L F z) (Ici 0) := by
32
+ induction L with
33
+ | nil => exact hFG
34
+ | cons av L ih =>
35
+ have ht (bv) (hb : bv ∈ L) := hL bv (List.mem_cons_of_mem av hb)
36
+ have hFr := fieldScalarValue_regular L ht hF hFg
37
+ have hGr := fieldScalarValue_regular L ht hG hGg
38
+ exact gaussianOperator_difference_monotone av.2 (hL av List.mem_cons_self).le
39
+ _ _ hFr.1 hGr.1 (fieldScalarValue_even L ht hF hFg hFe)
40
+ (fieldScalarValue_even L ht hG hGg hGe) hFr.2 hGr.2 (ih ht)
41
+
42
+ lemma fieldScalarMean_shape (L : List (ℝ × ℝ≥0))
43
+ (hL : ∀ av ∈ L, 0 < av.1) {F a : ℝ → ℝ}
44
+ (hF : Measurable F) (hG : HasLinearGrowth F) (hFe : Function.Even F)
45
+ (ha : Measurable a) (hao : Function.Odd a)
46
+ (ham : MonotoneOn a (Ici 0)) (hap : ∀ z ∈ Ici (0 : ℝ), 0 ≤ a z)
47
+ {K : ℝ} (haB : ∀ z, |a z| ≤ K) :
48
+ Function.Odd (fieldScalarMean L F a) ∧
49
+ MonotoneOn (fieldScalarMean L F a) (Ici 0) ∧
50
+ ∀ z ∈ Ici (0 : ℝ), 0 ≤ fieldScalarMean L F a z := by
51
+ induction L with
52
+ | nil => exact ⟨hao, ham, hap⟩
53
+ | cons av L ih =>
54
+ have ht (bv) (hb : bv ∈ L) := hL bv (List.mem_cons_of_mem av hb)
55
+ have hr := fieldScalarValue_regular L ht hF hG
56
+ have hm := fieldScalarMean_regular L ht hF hG ha haB
57
+ have hs := ih ht
58
+ have he := fieldScalarValue_even L ht hF hG hFe
59
+ refine ⟨fieldSpinTransition_odd av.1 av.2 hr.1 he hm.1 hs.1, ?_, ?_⟩
60
+ · exact fieldSpinTransition_monotone (hL av List.mem_cons_self).le av.2
61
+ hr.1 he hr.2 hm.1 hs.1 hs.2.1 hs.2.2 hm.2
62
+ · intro z hz
63
+ exact fieldSpinTransition_nonneg av.1 av.2 hr.1 he hr.2 hm.1 hs.1 hs.2.2 hm.2 hz
64
+
65
+ lemma fieldScalarMean_order (L : List (ℝ × ℝ≥0))
66
+ (hL : ∀ av ∈ L, 0 < av.1) {F G a b : ℝ → ℝ}
67
+ (hF : Measurable F) (hG : Measurable G)
68
+ (hFg : HasLinearGrowth F) (hGg : HasLinearGrowth G)
69
+ (hFe : Function.Even F) (hGe : Function.Even G)
70
+ (hFG : MonotoneOn (fun z => G z - F z) (Ici 0))
71
+ (ha : Measurable a) (hb : Measurable b)
72
+ (hao : Function.Odd a) (hbo : Function.Odd b)
73
+ (ham : MonotoneOn a (Ici 0)) (hbm : MonotoneOn b (Ici 0))
74
+ (hap : ∀ z ∈ Ici (0 : ℝ), 0 ≤ a z) (hbp : ∀ z ∈ Ici (0 : ℝ), 0 ≤ b z)
75
+ {K : ℝ} (haB : ∀ z, |a z| ≤ K) (hbB : ∀ z, |b z| ≤ K)
76
+ (hab : ∀ z ∈ Ici (0 : ℝ), a z ≤ b z) :
77
+ ∀ z ∈ Ici (0 : ℝ), fieldScalarMean L F a z ≤ fieldScalarMean L G b z := by
78
+ induction L with
79
+ | nil => exact hab
80
+ | cons av L ih =>
81
+ have ht (bv) (hc : bv ∈ L) := hL bv (List.mem_cons_of_mem av hc)
82
+ have hFr := fieldScalarValue_regular L ht hF hFg
83
+ have hGr := fieldScalarValue_regular L ht hG hGg
84
+ have hmr := fieldScalarMean_regular L ht hF hFg ha haB
85
+ have hnr := fieldScalarMean_regular L ht hG hGg hb hbB
86
+ have hms := fieldScalarMean_shape L ht hF hFg hFe ha hao ham hap haB
87
+ have hns := fieldScalarMean_shape L ht hG hGg hGe hb hbo hbm hbp hbB
88
+ intro z hz
89
+ by_cases hv : av.2 = 0
90
+ · simpa only [fieldScalarMean, hv, fieldSpinTransition_zero_variance] using ih ht z hz
91
+ · exact field_gaussian_spin_transition_order av.2 hv (hL av List.mem_cons_self).le
92
+ _ _ _ _ hFr.1 hGr.1 (fieldScalarValue_even L ht hF hFg hFe)
93
+ (fieldScalarValue_even L ht hG hGg hGe) hFr.2 hGr.2
94
+ (fieldScalarValue_difference_monotone L ht hF hG hFg hGg hFe hGe hFG)
95
+ hmr.1 hnr.1 hms.1 hns.1 hms.2.1 hms.2.2 (ih ht) hmr.2 hnr.2 hz le_rfl
96
+
97
+ end InvariantIsing
98
+
99
+ end
100
+
101
+ end OAI
lean/OAI/Probability/InvariantIsing/Fields/FieldScalarOverlap.lean ADDED
@@ -0,0 +1,114 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Probability.InvariantIsing.Fields.FieldScalarChain
2
+
3
+ namespace OAI
4
+
5
+ /-! The scalar field's actual level overlaps. Their ordering is the
6
+ conditional Jensen inequality, and zero increments give exact ties. -/
7
+
8
+ noncomputable section
9
+ open MeasureTheory ProbabilityTheory IsingPerceptron Set
10
+ open scoped NNReal
11
+
12
+ namespace InvariantIsing
13
+
14
+ lemma fieldScalarSquares_monotone (L : List (ℝ × ℝ≥0))
15
+ (hL : ∀ av ∈ L, 0 < av.1) {F a : ℝ → ℝ}
16
+ (hF : Measurable F) (hG : HasLinearGrowth F)
17
+ (ha : Measurable a) (haB : ∀ u, |a u| ≤ 1) (z : ℝ) :
18
+ Monotone (fun i => fieldScalarSquares L F a i z) := by
19
+ induction L generalizing z with
20
+ | nil =>
21
+ intro i j _
22
+ exact le_rfl
23
+ | cons av L ih =>
24
+ have htail (bv) (hb : bv ∈ L) := hL bv (List.mem_cons_of_mem av hb)
25
+ have hval := fieldScalarValue_regular L htail hF hG
26
+ have hmean := fieldScalarMean_regular L htail hF hG ha haB
27
+ have hreg := fieldScalarSquares_regular L htail hF hG ha haB
28
+ apply Fin.monotone_iff_le_succ.mpr
29
+ intro i
30
+ refine Fin.cases ?_ (fun j => ?_) i
31
+ · change (fieldSpinTransition av.1 av.2 (fieldScalarValue L F) (fieldScalarMean L F a) z) ^ 2 ≤
32
+ fieldSpinTransition av.1 av.2 (fieldScalarValue L F) (fieldScalarSquares L F a 0) z
33
+ have he : fieldScalarSquares L F a 0 = fun u => (fieldScalarMean L F a u) ^ 2 := by
34
+ funext u
35
+ exact fieldScalarSquares_zero L F a u
36
+ rw [he]
37
+ exact fieldSpinTransition_square_le av.1 av.2 hval.1 hval.2 hmean.1 hmean.2 z
38
+ · change fieldSpinTransition av.1 av.2 (fieldScalarValue L F)
39
+ (fieldScalarSquares L F a j.castSucc) z ≤
40
+ fieldSpinTransition av.1 av.2 (fieldScalarValue L F)
41
+ (fieldScalarSquares L F a j.succ) z
42
+ apply fieldSpinTransition_mono_test av.1 av.2 (fieldScalarValue L F)
43
+ (hreg j.castSucc).1 (hreg j.succ).1
44
+ (fun u => by rw [abs_of_nonneg ((hreg j.castSucc).2 u).1]; exact ((hreg j.castSucc).2 u).2)
45
+ (fun u => by rw [abs_of_nonneg ((hreg j.succ).2 u).1]; exact ((hreg j.succ).2 u).2)
46
+ intro u
47
+ exact ih htail u (by change j.val ≤ j.val + 1; omega)
48
+
49
+ lemma fieldScalarSquares_tied_increment (L : List (ℝ × ℝ≥0))
50
+ (F a : ℝ → ℝ) (i : Fin L.length) (hi : (L.get i).2 = 0) :
51
+ fieldScalarSquares L F a i.castSucc = fieldScalarSquares L F a i.succ := by
52
+ induction L with
53
+ | nil => exact Fin.elim0 i
54
+ | cons av L ih =>
55
+ revert hi
56
+ refine Fin.cases ?_ (fun j => ?_) i
57
+ · intro hi
58
+ have hav : av.2 = 0 := by simpa only [List.get_cons_zero] using hi
59
+ funext z
60
+ simp only [Fin.castSucc_zero, fieldScalarSquares, Fin.cons_zero, Fin.cons_succ, fieldScalarMean,
61
+ hav, fieldSpinTransition_zero_variance, fieldScalarSquares_zero]
62
+ · intro hi
63
+ have hj : (L.get j).2 = 0 := by
64
+ change (L.get j).2 = 0 at hi
65
+ exact hi
66
+ funext z
67
+ change fieldSpinTransition av.1 av.2 (fieldScalarValue L F)
68
+ (fieldScalarSquares L F a j.castSucc) z =
69
+ fieldSpinTransition av.1 av.2 (fieldScalarValue L F)
70
+ (fieldScalarSquares L F a j.succ) z
71
+ rw [ih j hj]
72
+
73
+ /-- Root Gaussian averaging produces the level second moments `B_i`. -/
74
+ def fieldScalarOverlaps (L : List (ℝ × ℝ≥0)) (root : ℝ≥0)
75
+ (F a : ℝ → ℝ) (i : Fin (L.length + 1)) : ℝ :=
76
+ ∫ z, fieldScalarSquares L F a i z ∂gaussianReal 0 root
77
+
78
+ lemma fieldScalarOverlaps_mem_unit (L : List (ℝ × ℝ≥0)) (root : ℝ≥0)
79
+ (hL : ∀ av ∈ L, 0 < av.1) {F a : ℝ → ℝ}
80
+ (hF : Measurable F) (hG : HasLinearGrowth F)
81
+ (ha : Measurable a) (haB : ∀ u, |a u| ≤ 1) (i : Fin (L.length + 1)) :
82
+ fieldScalarOverlaps L root F a i ∈ Icc (0 : ℝ) 1 := by
83
+ have hr := fieldScalarSquares_regular L hL hF hG ha haB i
84
+ have hi : Integrable (fieldScalarSquares L F a i) (gaussianReal 0 root) :=
85
+ Integrable.of_bound hr.1.aestronglyMeasurable 1
86
+ (Filter.Eventually.of_forall (fun z => by rw [Real.norm_eq_abs, abs_of_nonneg (hr.2 z).1]; exact (hr.2 z).2))
87
+ refine ⟨integral_nonneg (fun z => (hr.2 z).1), ?_⟩
88
+ have h := integral_mono hi (integrable_const (1 : ℝ)) (fun z => (hr.2 z).2)
89
+ simpa only [fieldScalarOverlaps, integral_const, measureReal_def, measure_univ, ENNReal.toReal_one,
90
+ one_smul] using h
91
+
92
+ lemma fieldScalarOverlaps_monotone (L : List (ℝ × ℝ≥0)) (root : ℝ≥0)
93
+ (hL : ∀ av ∈ L, 0 < av.1) {F a : ℝ → ℝ}
94
+ (hF : Measurable F) (hG : HasLinearGrowth F)
95
+ (ha : Measurable a) (haB : ∀ u, |a u| ≤ 1) :
96
+ Monotone (fieldScalarOverlaps L root F a) := by
97
+ have hi (i : Fin (L.length + 1)) : Integrable (fieldScalarSquares L F a i) (gaussianReal 0 root) := by
98
+ have hr := fieldScalarSquares_regular L hL hF hG ha haB i
99
+ exact Integrable.of_bound hr.1.aestronglyMeasurable 1
100
+ (Filter.Eventually.of_forall (fun z => by rw [Real.norm_eq_abs, abs_of_nonneg (hr.2 z).1]; exact (hr.2 z).2))
101
+ intro i j hij
102
+ exact integral_mono (hi i) (hi j) (fun z => fieldScalarSquares_monotone L hL hF hG ha haB z hij)
103
+
104
+ lemma fieldScalarOverlaps_tied_increment (L : List (ℝ × ℝ≥0)) (root : ℝ≥0)
105
+ (F a : ℝ → ℝ) (i : Fin L.length) (hi : (L.get i).2 = 0) :
106
+ fieldScalarOverlaps L root F a i.castSucc = fieldScalarOverlaps L root F a i.succ := by
107
+ unfold fieldScalarOverlaps
108
+ rw [fieldScalarSquares_tied_increment L F a i hi]
109
+
110
+ end InvariantIsing
111
+
112
+ end
113
+
114
+ end OAI
lean/OAI/Probability/InvariantIsing/Fields/FieldScalarSampling.lean ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Probability.InvariantIsing.Fields.FieldSpinSampling
2
+ import OAI.Probability.InvariantIsing.Fields.FieldMagnetization
3
+
4
+ namespace OAI
5
+
6
+ /-! Common-prefix sampling of two scalar Ising spins. After the split
7
+ the two tails are independent; before the split they use the same actual
8
+ tilted Gaussian transition. -/
9
+
10
+ noncomputable section
11
+ open MeasureTheory ProbabilityTheory IsingPerceptron
12
+ open scoped NNReal
13
+
14
+ namespace InvariantIsing
15
+
16
+ def fieldPairSpinKernel : (L : List (ℝ × ℝ≥0)) →
17
+ (∀ av ∈ L, 0 < av.1) → Fin (L.length + 1) → Kernel ℝ (Bool × Bool)
18
+ | [], _, _ => scalarSpinKernel ×ₖ scalarSpinKernel
19
+ | av :: L, hL, i =>
20
+ let ht := fun bv hb => hL bv (List.mem_cons_of_mem av hb)
21
+ let hreg := fieldScalarValue_regular L ht measurable_logCosh logCosh_linearGrowth
22
+ Fin.cases (fieldTailSpinKernel (av :: L) hL ×ₖ fieldTailSpinKernel (av :: L) hL)
23
+ (fun j => fieldPairSpinKernel L ht j ∘ₖ
24
+ fieldTransitionKernel av.1 av.2 (fieldScalarValue L (fun z => Real.log (Real.cosh z)))
25
+ hreg.1) i
26
+
27
+ instance fieldPairSpinKernel_markov (L : List (ℝ × ℝ≥0))
28
+ (hL : ∀ av ∈ L, 0 < av.1) (i : Fin (L.length + 1)) :
29
+ IsMarkovKernel (fieldPairSpinKernel L hL i) := by
30
+ induction L with
31
+ | nil => change IsMarkovKernel (scalarSpinKernel ×ₖ scalarSpinKernel); infer_instance
32
+ | cons av L ih =>
33
+ refine Fin.cases ?_ (fun j => ?_) i
34
+ · change IsMarkovKernel (fieldTailSpinKernel (av :: L) hL ×ₖ
35
+ fieldTailSpinKernel (av :: L) hL)
36
+ infer_instance
37
+ · have ht := fun bv hb => hL bv (List.mem_cons_of_mem av hb)
38
+ let _ := ih ht j
39
+ change IsMarkovKernel (_ ∘ₖ _)
40
+ infer_instance
41
+
42
+ theorem fieldPairSpinKernel_mean (L : List (ℝ × ℝ≥0))
43
+ (hL : ∀ av ∈ L, 0 < av.1) (i : Fin (L.length + 1)) (z : ℝ) :
44
+ (∫ σ, spinValue σ.1 * spinValue σ.2 ∂fieldPairSpinKernel L hL i z) =
45
+ fieldScalarSquares L (fun u => Real.log (Real.cosh u)) Real.tanh i z := by
46
+ induction L generalizing z with
47
+ | nil =>
48
+ simp only [fieldPairSpinKernel, Kernel.prod_apply, integral_prod_mul,
49
+ scalarSpinKernel_mean, fieldScalarSquares, pow_two]
50
+ | cons av L ih =>
51
+ refine Fin.cases ?_ (fun j => ?_) i
52
+ · change (∫ σ, spinValue σ.1 * spinValue σ.2
53
+ ∂(fieldTailSpinKernel (av :: L) hL ×ₖ fieldTailSpinKernel (av :: L) hL) z) = _
54
+ rw [Kernel.prod_apply, integral_prod_mul, fieldTailSpinKernel_mean]
55
+ rw [fieldScalarSquares_zero, pow_two]
56
+ · have ht := fun bv hb => hL bv (List.mem_cons_of_mem av hb)
57
+ have hreg := fieldScalarValue_regular L ht measurable_logCosh logCosh_linearGrowth
58
+ change (∫ σ, spinValue σ.1 * spinValue σ.2
59
+ ∂(fieldPairSpinKernel L ht j ∘ₖ
60
+ fieldTransitionKernel av.1 av.2 (fieldScalarValue L (fun u => Real.log (Real.cosh u)))
61
+ hreg.1) z) = _
62
+ rw [Kernel.integral_comp (Integrable.of_finite)]
63
+ simp_rw [ih ht]
64
+ exact fieldTransitionKernel_integral av.1 av.2 _ hreg.1 hreg.2 _ z
65
+
66
+ /-- The field's root is shared by the two replicas. -/
67
+ def fieldLevelSpinPair (h : FieldStep) (i : Fin (h.depth + 1)) : Measure (Bool × Bool) :=
68
+ fieldPairSpinKernel (scalarFieldIncrements h) (scalarFieldIncrements_positive h)
69
+ (Fin.cast (by rw [scalarFieldIncrements_length]) i) ∘ₘ
70
+ gaussianReal 0 (NNReal.mk (h.height 0) (h.nonneg 0))
71
+
72
+ instance fieldLevelSpinPair_probability (h : FieldStep) (i : Fin (h.depth + 1)) :
73
+ IsProbabilityMeasure (fieldLevelSpinPair h i) := by
74
+ unfold fieldLevelSpinPair
75
+ infer_instance
76
+
77
+ theorem fieldLevelSpinPair_mean (h : FieldStep) (i : Fin (h.depth + 1)) :
78
+ (∫ σ, spinValue σ.1 * spinValue σ.2 ∂fieldLevelSpinPair h i) =
79
+ fieldMagnetizationLevel h i := by
80
+ unfold fieldLevelSpinPair
81
+ rw [Measure.comp_eq_comp_const_apply, Kernel.integral_comp (Integrable.of_finite)]
82
+ simp only [Kernel.const_apply, fieldPairSpinKernel_mean]
83
+ rfl
84
+
85
+ /-- The common-level spin test in the evaluated cavity law. -/
86
+ theorem fieldLevelSpinPair_test (h : FieldStep) (q : OverlapPath) (Φ : ℝ → ℝ) :
87
+ (∫ s, ∫ σ, Φ (q s) * (spinValue σ.1 * spinValue σ.2)
88
+ ∂fieldLevelSpinPair h (fieldLevelIndex h s) ∂pathMeasure) =
89
+ ∫ s, Φ (q s) * fieldMagnetizationPath h s ∂pathMeasure := by
90
+ apply integral_congr_ae
91
+ filter_upwards [] with s
92
+ rw [integral_const_mul, fieldLevelSpinPair_mean]
93
+ rfl
94
+
95
+ /-- Sampling the spin pair leaves every common-level observable unchanged. -/
96
+ theorem fieldLevelSpinPair_level_test (h : FieldStep) (q : OverlapPath) (Φ : ℝ → ℝ) :
97
+ (∫ s, ∫ _σ, Φ (q s) ∂fieldLevelSpinPair h (fieldLevelIndex h s) ∂pathMeasure) =
98
+ ∫ s, Φ (q s) ∂pathMeasure := by
99
+ simp only [integral_const, probReal_univ, one_smul]
100
+
101
+ end InvariantIsing
102
+
103
+ end
104
+
105
+ end OAI
lean/OAI/Probability/InvariantIsing/Fields/FieldScalarScaling.lean ADDED
@@ -0,0 +1,152 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Probability.InvariantIsing.Fields.FieldScalarOverlap
2
+ import OAI.Probability.InvariantIsing.Fields.FieldCovarianceScaling
3
+
4
+ namespace OAI
5
+
6
+ /-! Change of position units for the actual finite conditional spin
7
+ chain. The spin observable acquires no multiplicative derivative factor. -/
8
+
9
+ noncomputable section
10
+ open MeasureTheory ProbabilityTheory IsingPerceptron
11
+ open scoped NNReal
12
+
13
+ namespace InvariantIsing
14
+
15
+ def fieldScaleIncrements (c : ℝ≥0) (L : List (ℝ × ℝ≥0)) : List (ℝ × ℝ≥0) :=
16
+ L.map (fun av => (av.1, c ^ 2 * av.2))
17
+
18
+ lemma fieldScaleIncrements_length (c : ℝ≥0) (L : List (ℝ × ℝ≥0)) :
19
+ (fieldScaleIncrements c L).length = L.length := by
20
+ simp only [fieldScaleIncrements, List.length_map]
21
+
22
+ private lemma scalar_value_measurable (L : List (ℝ × ℝ≥0))
23
+ {F : ℝ → ℝ} (hF : Measurable F) : Measurable (fieldScalarValue L F) := by
24
+ induction L with
25
+ | nil => exact hF
26
+ | cons av L ih =>
27
+ change Measurable (gaussianOperator av.1 av.2 (fieldScalarValue L F))
28
+ rw [gaussianOperator_eq_transform]
29
+ exact measurable_gaussianTransform ih _ _
30
+
31
+ private lemma scalar_mean_measurable (L : List (ℝ × ℝ≥0))
32
+ {F a : ℝ → ℝ} (hF : Measurable F) (ha : Measurable a) :
33
+ Measurable (fieldScalarMean L F a) := by
34
+ induction L with
35
+ | nil => exact ha
36
+ | cons av L ih =>
37
+ exact measurable_fieldSpinTransition av.1 av.2 (scalar_value_measurable L hF) ih
38
+
39
+ private lemma scalar_squares_measurable (L : List (ℝ × ℝ≥0))
40
+ {F a : ℝ → ℝ} (hF : Measurable F) (ha : Measurable a) :
41
+ ∀ i, Measurable (fieldScalarSquares L F a i) := by
42
+ induction L with
43
+ | nil => intro i; exact ha.pow_const 2
44
+ | cons av L ih =>
45
+ intro i
46
+ refine Fin.cases ?_ (fun j => ?_) i
47
+ · exact (scalar_mean_measurable (av :: L) hF ha).pow_const 2
48
+ · exact measurable_fieldSpinTransition av.1 av.2 (scalar_value_measurable L hF) (ih j)
49
+
50
+ lemma fieldSpinTransition_scale_position (ζ : ℝ) (v c : ℝ≥0)
51
+ {F a : ℝ → ℝ} (hF : Measurable F) (ha : Measurable a) (z : ℝ) :
52
+ fieldSpinTransition ζ v (fun u => F (c * u)) (fun u => a (c * u)) z =
53
+ fieldSpinTransition ζ (c ^ 2 * v) F a (c * z) := by
54
+ have hFc : Measurable (fun u => F ((c : ℝ) * u)) := hF.comp (measurable_id.const_mul _)
55
+ have hac : Measurable (fun u => a ((c : ℝ) * u)) := ha.comp (measurable_id.const_mul _)
56
+ rw [fieldSpinTransition_eq_standard ζ v hFc hac,
57
+ fieldSpinTransition_eq_standard ζ (c ^ 2 * v) hF ha,
58
+ gaussianTiltAverage_eq_div, gaussianTiltAverage_eq_div]
59
+ have hs : Real.sqrt ((c ^ 2 * v : ℝ≥0) : ℝ) = c * Real.sqrt (v : ℝ) := by
60
+ rw [NNReal.coe_mul, NNReal.coe_pow, Real.sqrt_mul (sq_nonneg _),
61
+ Real.sqrt_sq c.coe_nonneg]
62
+ have he (u : ℝ) : (c : ℝ) * (z + Real.sqrt (v : ℝ) * u) =
63
+ c * z + (c * Real.sqrt (v : ℝ)) * u := by ring
64
+ simp only [hs, he]
65
+
66
+ lemma fieldScalarValue_scale_position (c : ℝ≥0) (L : List (ℝ × ℝ≥0))
67
+ (F : ℝ → ℝ) (z : ℝ) :
68
+ fieldScalarValue L (fun u => F (c * u)) z =
69
+ fieldScalarValue (fieldScaleIncrements c L) F (c * z) := by
70
+ induction L generalizing z with
71
+ | nil => rfl
72
+ | cons av L ih =>
73
+ have he : fieldScalarValue L (fun u => F (c * u)) =
74
+ fun u => fieldScalarValue (fieldScaleIncrements c L) F (c * u) := funext ih
75
+ change gaussianOperator av.1 av.2 (fieldScalarValue L (fun u => F (c * u))) z =
76
+ gaussianOperator av.1 (c ^ 2 * av.2 : ℝ≥0) (fieldScalarValue (fieldScaleIncrements c L) F) (c * z)
77
+ rw [he]
78
+ simpa only [NNReal.coe_mul, NNReal.coe_pow] using
79
+ gaussianOperator_scale_position av.1 av.2 c c.coe_nonneg _ z
80
+
81
+ lemma fieldScalarMean_scale_position (c : ℝ≥0) (L : List (ℝ × ℝ≥0))
82
+ {F a : ℝ → ℝ} (hF : Measurable F) (ha : Measurable a) (z : ℝ) :
83
+ fieldScalarMean L (fun u => F (c * u)) (fun u => a (c * u)) z =
84
+ fieldScalarMean (fieldScaleIncrements c L) F a (c * z) := by
85
+ induction L generalizing z with
86
+ | nil => rfl
87
+ | cons av L ih =>
88
+ have hv : fieldScalarValue L (fun u => F (c * u)) =
89
+ fun u => fieldScalarValue (fieldScaleIncrements c L) F (c * u) :=
90
+ funext (fieldScalarValue_scale_position c L F)
91
+ have hm : fieldScalarMean L (fun u => F (c * u)) (fun u => a (c * u)) =
92
+ fun u => fieldScalarMean (fieldScaleIncrements c L) F a (c * u) := funext ih
93
+ change fieldSpinTransition av.1 av.2 (fieldScalarValue L (fun u => F (c * u)))
94
+ (fieldScalarMean L (fun u => F (c * u)) (fun u => a (c * u))) z =
95
+ fieldSpinTransition av.1 (c ^ 2 * av.2) (fieldScalarValue (fieldScaleIncrements c L) F)
96
+ (fieldScalarMean (fieldScaleIncrements c L) F a) (c * z)
97
+ rw [hv, hm]
98
+ exact fieldSpinTransition_scale_position av.1 av.2 c
99
+ (scalar_value_measurable _ hF) (scalar_mean_measurable _ hF ha) z
100
+
101
+ lemma fieldScalarSquares_scale_position (c : ℝ≥0) (L : List (ℝ × ℝ≥0))
102
+ {F a : ℝ → ℝ} (hF : Measurable F) (ha : Measurable a)
103
+ (i : Fin (L.length + 1)) (z : ℝ) :
104
+ fieldScalarSquares L (fun u => F (c * u)) (fun u => a (c * u)) i z =
105
+ fieldScalarSquares (fieldScaleIncrements c L) F a
106
+ (Fin.cast (by rw [fieldScaleIncrements_length]) i) (c * z) := by
107
+ induction L generalizing z with
108
+ | nil => rfl
109
+ | cons av L ih =>
110
+ refine Fin.cases ?_ (fun j => ?_) i
111
+ · simpa only [Fin.cast_zero, fieldScalarSquares_zero] using
112
+ congrArg (fun x : ℝ => x ^ 2) (fieldScalarMean_scale_position c (av :: L) hF ha z)
113
+ · have hv : fieldScalarValue L (fun u => F (c * u)) =
114
+ fun u => fieldScalarValue (fieldScaleIncrements c L) F (c * u) :=
115
+ funext (fieldScalarValue_scale_position c L F)
116
+ have hq : fieldScalarSquares L (fun u => F (c * u)) (fun u => a (c * u)) j =
117
+ fun u => fieldScalarSquares (fieldScaleIncrements c L) F a
118
+ (Fin.cast (by simp only [fieldScaleIncrements_length, List.length_cons]) j) (c * u) := funext (ih j)
119
+ change fieldSpinTransition av.1 av.2 (fieldScalarValue L (fun u => F (c * u)))
120
+ (fieldScalarSquares L (fun u => F (c * u)) (fun u => a (c * u)) j) z =
121
+ fieldSpinTransition av.1 (c ^ 2 * av.2) (fieldScalarValue (fieldScaleIncrements c L) F)
122
+ (fieldScalarSquares (fieldScaleIncrements c L) F a
123
+ (Fin.cast (by simp only [fieldScaleIncrements_length, List.length_cons]) j)) (c * z)
124
+ rw [hv, hq]
125
+ exact fieldSpinTransition_scale_position av.1 av.2 c
126
+ (scalar_value_measurable _ hF) (scalar_squares_measurable _ hF ha _) z
127
+
128
+ lemma fieldScalarOverlaps_scale_position (c : ℝ≥0) (L : List (ℝ × ℝ≥0))
129
+ (root : ℝ≥0) {F a : ℝ → ℝ} (hF : Measurable F) (ha : Measurable a)
130
+ (i : Fin (L.length + 1)) :
131
+ fieldScalarOverlaps L root (fun u => F (c * u)) (fun u => a (c * u)) i =
132
+ fieldScalarOverlaps (fieldScaleIncrements c L) (c ^ 2 * root) F a
133
+ (Fin.cast (by rw [fieldScaleIncrements_length]) i) := by
134
+ have hs : NNReal.mk ((c : ℝ) ^ 2) (sq_nonneg _) = c ^ 2 := by
135
+ apply Subtype.ext
136
+ rfl
137
+ have hm : (gaussianReal 0 root).map (fun u : ℝ => (c : ℝ) * u) =
138
+ gaussianReal 0 (c ^ 2 * root) := by
139
+ simpa only [mul_zero, hs] using
140
+ gaussianReal_map_const_mul (μ := 0) (v := root) (c : ℝ)
141
+ unfold fieldScalarOverlaps
142
+ simp_rw [fieldScalarSquares_scale_position c L hF ha i]
143
+ rw [← hm]
144
+ have hc : Measurable (fun u : ℝ => (c : ℝ) * u) := measurable_const.mul measurable_id
145
+ exact (integral_map hc.aemeasurable
146
+ (scalar_squares_measurable _ hF ha _).aestronglyMeasurable).symm
147
+
148
+ end InvariantIsing
149
+
150
+ end
151
+
152
+ end OAI
lean/OAI/Probability/InvariantIsing/Fields/FieldScalarSecondDerivative.lean ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Probability.InvariantIsing.Fields.FieldSpinSecondDerivative
2
+ import OAI.Probability.InvariantIsing.Fields.FieldScalarDerivative
3
+
4
+ namespace OAI
5
+
6
+ /-! Bounded second derivatives through the actual finite scalar recursion. -/
7
+
8
+ noncomputable section
9
+ open MeasureTheory ProbabilityTheory IsingPerceptron
10
+ open scoped NNReal
11
+
12
+ namespace InvariantIsing
13
+
14
+ def fieldScalarSecond : List (ℝ × ℝ≥0) → (ℝ → ℝ) → (ℝ → ℝ) → (ℝ → ℝ) → ℝ → ℝ
15
+ | [], _, _, b => b
16
+ | av :: L, F, a, b => fun z =>
17
+ fieldSpinTransition av.1 av.2 (fieldScalarValue L F) (fieldScalarSecond L F a b) z +
18
+ av.1 * (fieldSpinTransition av.1 av.2 (fieldScalarValue L F)
19
+ (fun u => (fieldScalarMean L F a u) ^ 2) z -
20
+ (fieldScalarMean (av :: L) F a z) ^ 2)
21
+
22
+ def fieldScalarSecondCap (L : List (ℝ × ℝ≥0)) (K C : ℝ) : ℝ :=
23
+ L.foldr (fun av c => c + 2 * |av.1| * K ^ 2) C
24
+
25
+ theorem fieldScalarSecond_regular (L : List (ℝ × ℝ≥0))
26
+ (hL : ∀ av ∈ L, 0 < av.1) {F a b : ℝ → ℝ}
27
+ (hF : Measurable F) (hG : HasLinearGrowth F) (ha : Measurable a) (hb : Measurable b)
28
+ {K C : ℝ} (hK : 0 ≤ K) (haB : ∀ z, |a z| ≤ K) (hbB : ∀ z, |b z| ≤ C) :
29
+ Measurable (fieldScalarSecond L F a b) ∧
30
+ ∀ z, |fieldScalarSecond L F a b z| ≤ fieldScalarSecondCap L K C := by
31
+ induction L with
32
+ | nil => exact ⟨hb, hbB⟩
33
+ | cons av L ih =>
34
+ have htail (bv) (h : bv ∈ L) := hL bv (List.mem_cons_of_mem av h)
35
+ obtain ⟨hm, hB⟩ := ih htail
36
+ have hval := fieldScalarValue_regular L htail hF hG
37
+ have hmean := fieldScalarMean_regular L htail hF hG ha haB
38
+ have hnew := fieldScalarMean_regular (av :: L) hL hF hG ha haB
39
+ refine ⟨?_, ?_⟩
40
+ · exact (measurable_fieldSpinTransition av.1 av.2 hval.1 hm).add
41
+ (((measurable_fieldSpinTransition av.1 av.2 hval.1 (hmean.1.pow_const 2)).sub
42
+ (hnew.1.pow_const 2)).const_mul av.1)
43
+ · intro z
44
+ have h := fieldSpinTransition_derivative_bound av.1 av.2 hval.1 hval.2
45
+ hK hK hmean.2 hmean.2 hB z
46
+ simpa only [fieldScalarSecond, fieldScalarSecondCap, List.foldr_cons,
47
+ fieldScalarMean, pow_two, mul_assoc] using h
48
+
49
+ theorem hasDerivAt_fieldScalarMean (L : List (ℝ × ℝ≥0))
50
+ (hL : ∀ av ∈ L, 0 < av.1) {F a b : ℝ → ℝ}
51
+ (hF : Measurable F) (hG : HasLinearGrowth F) (ha : Measurable a) (hb : Measurable b)
52
+ {K C : ℝ} (hK : 0 ≤ K) (haB : ∀ z, |a z| ≤ K) (hbB : ∀ z, |b z| ≤ C)
53
+ (hd : ∀ z, HasDerivAt F (a z) z) (hdd : ∀ z, HasDerivAt a (b z) z) (z : ℝ) :
54
+ HasDerivAt (fieldScalarMean L F a) (fieldScalarSecond L F a b z) z := by
55
+ induction L generalizing z with
56
+ | nil => exact hdd z
57
+ | cons av L ih =>
58
+ have htail (bv) (h : bv ∈ L) := hL bv (List.mem_cons_of_mem av h)
59
+ have hval := fieldScalarValue_regular L htail hF hG
60
+ have hmean := fieldScalarMean_regular L htail hF hG ha haB
61
+ have hsecond := fieldScalarSecond_regular L htail hF hG ha hb hK haB hbB
62
+ have h := hasDerivAt_fieldSpinTransition av.1 av.2 hval.1 hval.2 hmean.1 hmean.1
63
+ hsecond.1 hK hK hmean.2 hmean.2 hsecond.2
64
+ (hasDerivAt_fieldScalarValue L htail hF hG ha hK haB hd) (ih htail) z
65
+ simpa only [fieldScalarMean, fieldScalarSecond, pow_two] using h
66
+
67
+ end InvariantIsing
68
+
69
+ end
70
+
71
+ end OAI
lean/OAI/Probability/InvariantIsing/Fields/FieldScalarSquareOrder.lean ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Probability.InvariantIsing.Fields.FieldScalarOrder
2
+ import OAI.Probability.InvariantIsing.Fields.FieldScalarOverlap
3
+ import OAI.Probability.InvariantIsing.Fields.FieldEvenTransition
4
+
5
+ namespace OAI
6
+
7
+ /-! Ordered even second-moment tests propagated through the actual
8
+ finite tilted position chain. -/
9
+
10
+ noncomputable section
11
+ open MeasureTheory ProbabilityTheory IsingPerceptron Set
12
+ open scoped NNReal
13
+
14
+ namespace InvariantIsing
15
+
16
+ lemma fieldScalarSquares_shape (L : List (ℝ × ℝ≥0))
17
+ (hL : ∀ av ∈ L, 0 < av.1) {F a : ℝ → ℝ}
18
+ (hF : Measurable F) (hG : HasLinearGrowth F) (hFe : Function.Even F)
19
+ (ha : Measurable a) (hao : Function.Odd a)
20
+ (ham : MonotoneOn a (Ici 0)) (hap : ∀ z ∈ Ici (0 : ℝ), 0 ≤ a z)
21
+ (haB : ∀ z, |a z| ≤ 1) :
22
+ ∀ i, Function.Even (fieldScalarSquares L F a i) ∧
23
+ MonotoneOn (fieldScalarSquares L F a i) (Ici 0) := by
24
+ have hsq (f : ℝ → ℝ) (ho : Function.Odd f)
25
+ (hm : MonotoneOn f (Ici 0)) (hp : ∀ z ∈ Ici (0 : ℝ), 0 ≤ f z) :
26
+ Function.Even (fun z => (f z) ^ 2) ∧ MonotoneOn (fun z => (f z) ^ 2) (Ici 0) := by
27
+ refine ⟨fun z => by dsimp only; rw [ho z, neg_sq], ?_⟩
28
+ intro x hx y hy hxy
29
+ exact pow_le_pow_left₀ (hp x hx) (hm hx hy hxy) 2
30
+ induction L with
31
+ | nil => intro i; exact hsq a hao ham hap
32
+ | cons av L ih =>
33
+ have ht (bv) (hb : bv ∈ L) := hL bv (List.mem_cons_of_mem av hb)
34
+ have hv := fieldScalarValue_regular L ht hF hG
35
+ have he := fieldScalarValue_even L ht hF hG hFe
36
+ have hs := fieldScalarMean_shape (av :: L) hL hF hG hFe ha hao ham hap haB
37
+ have hr := fieldScalarSquares_regular L ht hF hG ha haB
38
+ intro i
39
+ refine Fin.cases ?_ (fun j => ?_) i
40
+ · exact hsq _ hs.1 hs.2.1 hs.2.2
41
+ · have hj := ih ht j
42
+ have hb (z : ℝ) : |fieldScalarSquares L F a j z| ≤ 1 := by
43
+ rw [abs_of_nonneg ((hr j).2 z).1]
44
+ exact ((hr j).2 z).2
45
+ exact ⟨fieldSpinTransition_even av.1 av.2 hv.1 he (hr j).1 hj.1,
46
+ fieldSpinTransition_even_monotone av.1 av.2 hv.1 he hv.2
47
+ (hr j).1 hj.1 hj.2 hb⟩
48
+
49
+ lemma fieldScalarSquares_order (L : List (ℝ × ℝ≥0))
50
+ (hL : ∀ av ∈ L, 0 < av.1) {F G a b : ℝ → ℝ}
51
+ (hF : Measurable F) (hG : Measurable G)
52
+ (hFg : HasLinearGrowth F) (hGg : HasLinearGrowth G)
53
+ (hFe : Function.Even F) (hGe : Function.Even G)
54
+ (hFG : MonotoneOn (fun z => G z - F z) (Ici 0))
55
+ (ha : Measurable a) (hb : Measurable b)
56
+ (hao : Function.Odd a) (hbo : Function.Odd b)
57
+ (ham : MonotoneOn a (Ici 0)) (hbm : MonotoneOn b (Ici 0))
58
+ (hap : ∀ z ∈ Ici (0 : ℝ), 0 ≤ a z) (hbp : ∀ z ∈ Ici (0 : ℝ), 0 ≤ b z)
59
+ (haB : ∀ z, |a z| ≤ 1) (hbB : ∀ z, |b z| ≤ 1)
60
+ (hab : ∀ z ∈ Ici (0 : ℝ), a z ≤ b z) :
61
+ ∀ i z, fieldScalarSquares L F a i z ≤ fieldScalarSquares L G b i z := by
62
+ induction L with
63
+ | nil =>
64
+ intro i z
65
+ have heF : (a z) ^ 2 = (a |z|) ^ 2 := by
66
+ rcases le_total 0 z with hz | hz
67
+ · rw [abs_of_nonneg hz]
68
+ · rw [abs_of_nonpos hz, hao z, neg_sq]
69
+ have heG : (b z) ^ 2 = (b |z|) ^ 2 := by
70
+ rcases le_total 0 z with hz | hz
71
+ · rw [abs_of_nonneg hz]
72
+ · rw [abs_of_nonpos hz, hbo z, neg_sq]
73
+ change (a z) ^ 2 ≤ (b z) ^ 2
74
+ rw [heF, heG]
75
+ exact pow_le_pow_left₀ (hap _ (abs_nonneg z)) (hab _ (abs_nonneg z)) 2
76
+ | cons av L ih =>
77
+ have ht (bv) (hc : bv ∈ L) := hL bv (List.mem_cons_of_mem av hc)
78
+ have hFr := fieldScalarValue_regular L ht hF hFg
79
+ have hGr := fieldScalarValue_regular L ht hG hGg
80
+ have hFs := fieldScalarSquares_shape (av :: L) hL hF hFg hFe ha hao ham hap haB
81
+ have hGs := fieldScalarSquares_shape (av :: L) hL hG hGg hGe hb hbo hbm hbp hbB
82
+ have hms := fieldScalarMean_shape (av :: L) hL hF hFg hFe ha hao ham hap haB
83
+ have hmorder := fieldScalarMean_order (av :: L) hL hF hG hFg hGg hFe hGe hFG
84
+ ha hb hao hbo ham hbm hap hbp haB hbB hab
85
+ have hFreg := fieldScalarSquares_regular L ht hF hFg ha haB
86
+ have hGreg := fieldScalarSquares_regular L ht hG hGg hb hbB
87
+ intro i z
88
+ refine Fin.cases ?_ (fun j => ?_) i
89
+ · rw [← field_even_abs (hFs 0).1 z, ← field_even_abs (hGs 0).1 z]
90
+ simp only [fieldScalarSquares_zero]
91
+ exact pow_le_pow_left₀ (hms.2.2 _ (abs_nonneg z)) (hmorder _ (abs_nonneg z)) 2
92
+ · have hshape := fieldScalarSquares_shape L ht hF hFg hFe ha hao ham hap haB j
93
+ have hgshape := fieldScalarSquares_shape L ht hG hGg hGe hb hbo hbm hbp hbB j
94
+ have hFb (u : ℝ) : |fieldScalarSquares L F a j u| ≤ 1 := by
95
+ rw [abs_of_nonneg ((hFreg j).2 u).1]
96
+ exact ((hFreg j).2 u).2
97
+ have hGb (u : ℝ) : |fieldScalarSquares L G b j u| ≤ 1 := by
98
+ rw [abs_of_nonneg ((hGreg j).2 u).1]
99
+ exact ((hGreg j).2 u).2
100
+ exact fieldSpinTransition_even_order av.2 (hL av List.mem_cons_self).le
101
+ hFr.1 hGr.1 (fieldScalarValue_even L ht hF hFg hFe)
102
+ (fieldScalarValue_even L ht hG hGg hGe) hFr.2 hGr.2
103
+ (fieldScalarValue_difference_monotone L ht hF hG hFg hGg hFe hGe hFG)
104
+ (hFreg j).1 (hGreg j).1 hshape.1 hgshape.1 hshape.2 hFb hGb
105
+ (fun u _ => ih ht j u) z
106
+
107
+ end InvariantIsing
108
+
109
+ end
110
+
111
+ end OAI
lean/OAI/Probability/InvariantIsing/Fields/FieldSecondBounds.lean ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Probability.InvariantIsing.Fields.FieldSecondFamily
2
+
3
+ namespace OAI
4
+
5
+ /-! Local bounds for the explicit first and second derivatives of the
6
+ affine Gaussian mark in the finite scalar recursion. -/
7
+
8
+ noncomputable section
9
+ open MeasureTheory ProbabilityTheory IsingPerceptron Set
10
+
11
+ namespace InvariantIsing
12
+ namespace FieldSecondFamily
13
+
14
+ variable {I : Set ℝ} (F : FieldSecondFamily I)
15
+
16
+ def shiftedMixed (a v u : ℝ) (p : ℝ × ℝ) : ℝ :=
17
+ F.TX (p.1, p.2 + Real.sqrt (a + v * p.1) * u) +
18
+ F.XX (p.1, p.2 + Real.sqrt (a + v * p.1) * u) *
19
+ (fieldAmplitudeSlope a v p.1 * u)
20
+
21
+ def shiftedSecond (a v u : ℝ) (p : ℝ × ℝ) : ℝ :=
22
+ F.TT (p.1, p.2 + Real.sqrt (a + v * p.1) * u) +
23
+ 2 * F.TX (p.1, p.2 + Real.sqrt (a + v * p.1) * u) *
24
+ (fieldAmplitudeSlope a v p.1 * u) +
25
+ F.XX (p.1, p.2 + Real.sqrt (a + v * p.1) * u) *
26
+ (fieldAmplitudeSlope a v p.1 * u) ^ 2 +
27
+ F.X (p.1, p.2 + Real.sqrt (a + v * p.1) * u) *
28
+ (fieldAmplitudeCurvature a v p.1 * u)
29
+
30
+ lemma shiftedTangent_bound (a v u : ℝ) {p : ℝ × ℝ} (hp : p.1 ∈ I)
31
+ {R : ℝ} (hR : 0 ≤ R) (hc : |fieldAmplitudeSlope a v p.1| ≤ R) :
32
+ |F.shiftedTangent a v u p| ≤ (F.KT + F.KX * R) * (1 + |u|) := by
33
+ have hT0 : 0 ≤ F.KT := (abs_nonneg _).trans (F.bT (p.1, 0) hp)
34
+ have hX0 := F.kx_nonneg
35
+ unfold shiftedTangent
36
+ calc
37
+ _ ≤ |F.T _| + |F.X _ * (fieldAmplitudeSlope a v p.1 * u)| := abs_add_le _ _
38
+ _ ≤ F.KT + F.KX * (R * |u|) := by
39
+ rw [abs_mul, abs_mul]
40
+ gcongr
41
+ · exact F.bT _ hp
42
+ · exact F.bX _
43
+ _ ≤ (F.KT + F.KX * R) * (1 + |u|) := by
44
+ nlinarith [mul_nonneg hT0 (abs_nonneg u), mul_nonneg hX0 hR]
45
+
46
+ lemma shiftedMixed_bound (a v u : ℝ) {p : ℝ × ℝ} (hp : p.1 ∈ I)
47
+ {R : ℝ} (hR : 0 ≤ R) (hc : |fieldAmplitudeSlope a v p.1| ≤ R) :
48
+ |F.shiftedMixed a v u p| ≤ (F.KTX + F.KXX * R) * (1 + |u|) := by
49
+ have hT0 : 0 ≤ F.KTX := (abs_nonneg _).trans (F.bTX (p.1, 0) hp)
50
+ have hX0 : 0 ≤ F.KXX := (abs_nonneg _).trans (F.bXX (0, 0))
51
+ unfold shiftedMixed
52
+ calc
53
+ _ ≤ |F.TX _| + |F.XX _ * (fieldAmplitudeSlope a v p.1 * u)| := abs_add_le _ _
54
+ _ ≤ F.KTX + F.KXX * (R * |u|) := by
55
+ rw [abs_mul, abs_mul]
56
+ gcongr
57
+ · exact F.bTX _ hp
58
+ · exact F.bXX _
59
+ _ ≤ (F.KTX + F.KXX * R) * (1 + |u|) := by
60
+ nlinarith [mul_nonneg hT0 (abs_nonneg u), mul_nonneg hX0 hR]
61
+
62
+ lemma shiftedSecond_bound (a v u : ℝ) {p : ℝ × ℝ} (hp : p.1 ∈ I)
63
+ {R D : ℝ} (hR : 0 ≤ R) (hD : 0 ≤ D)
64
+ (hc : |fieldAmplitudeSlope a v p.1| ≤ R)
65
+ (hd : |fieldAmplitudeCurvature a v p.1| ≤ D) :
66
+ |F.shiftedSecond a v u p| ≤
67
+ (F.KTT + 2 * F.KTX * R + F.KXX * R ^ 2 + F.KX * D) * (1 + |u|) ^ 2 := by
68
+ have hTT0 : 0 ≤ F.KTT := (abs_nonneg _).trans (F.bTT (p.1, 0) hp)
69
+ have hTX0 : 0 ≤ F.KTX := (abs_nonneg _).trans (F.bTX (p.1, 0) hp)
70
+ have hXX0 : 0 ≤ F.KXX := (abs_nonneg _).trans (F.bXX (0, 0))
71
+ have hX0 := F.kx_nonneg
72
+ have h1 : 1 ≤ (1 + |u|) ^ 2 := by nlinarith [abs_nonneg u]
73
+ have hu : |u| ≤ (1 + |u|) ^ 2 := by nlinarith [sq_nonneg |u|, abs_nonneg u]
74
+ have hu2 : |u| ^ 2 ≤ (1 + |u|) ^ 2 := by nlinarith [abs_nonneg u]
75
+ let w : ℝ × ℝ := (p.1, p.2 + Real.sqrt (a + v * p.1) * u)
76
+ have hTT := F.bTT w hp
77
+ have hTX := F.bTX w hp
78
+ have hXX := F.bXX w
79
+ have hX := F.bX w
80
+ unfold shiftedSecond
81
+ calc
82
+ _ ≤ |F.TT w| + |2 * F.TX w * (fieldAmplitudeSlope a v p.1 * u)| +
83
+ |F.XX w * (fieldAmplitudeSlope a v p.1 * u) ^ 2| +
84
+ |F.X w * (fieldAmplitudeCurvature a v p.1 * u)| := by
85
+ refine (abs_add_le _ _).trans (add_le_add ?_ le_rfl)
86
+ exact (abs_add_le _ _).trans (add_le_add (abs_add_le _ _) le_rfl)
87
+ _ ≤ F.KTT + 2 * F.KTX * (R * |u|) + F.KXX * (R * |u|) ^ 2 +
88
+ F.KX * (D * |u|) := by
89
+ simp only [abs_mul, abs_pow, abs_of_nonneg (by norm_num : (0 : ℝ) ≤ 2)]
90
+ gcongr
91
+ _ = F.KTT * 1 + (2 * F.KTX * R) * |u| +
92
+ (F.KXX * R ^ 2) * |u| ^ 2 + (F.KX * D) * |u| := by ring
93
+ _ ≤ F.KTT * (1 + |u|) ^ 2 + (2 * F.KTX * R) * (1 + |u|) ^ 2 +
94
+ (F.KXX * R ^ 2) * (1 + |u|) ^ 2 + (F.KX * D) * (1 + |u|) ^ 2 := by
95
+ gcongr
96
+ _ = _ := by ring
97
+
98
+ end FieldSecondFamily
99
+ end InvariantIsing
100
+
101
+ end
102
+
103
+ end OAI
lean/OAI/Probability/InvariantIsing/Fields/FieldSecondCovariance.lean ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Probability.InvariantIsing.Fields.FieldAffineAverageDerivative
2
+
3
+ namespace OAI
4
+
5
+ /-! The two-coordinate covariance algebra for second derivatives of
6
+ the scalar Gaussian recursion. -/
7
+
8
+ noncomputable section
9
+ open MeasureTheory ProbabilityTheory IsingPerceptron
10
+
11
+ namespace InvariantIsing
12
+
13
+ lemma field_pair_covariance (ν : Measure ℝ) (ζ : ℝ)
14
+ (α A B L M : ℝ → ℝ)
15
+ (hA : Integrable A ν) (hB : Integrable B ν)
16
+ (hL : Integrable L ν) (hM : Integrable M ν)
17
+ (hαL : Integrable (fun u => α u * L u) ν)
18
+ (hαM : Integrable (fun u => α u * M u) ν) :
19
+ (∫ u, pairLinear (A u) (B u) + (ζ * α u) • pairLinear (L u) (M u) ∂ν) -
20
+ (∫ u, α u ∂ν) • (∫ u, ζ • pairLinear (L u) (M u) ∂ν) =
21
+ pairLinear
22
+ ((∫ u, A u ∂ν) + ζ * ((∫ u, α u * L u ∂ν) - (∫ u, α u ∂ν) * (∫ u, L u ∂ν)))
23
+ ((∫ u, B u ∂ν) + ζ * ((∫ u, α u * M u ∂ν) - (∫ u, α u ∂ν) * (∫ u, M u ∂ν))) := by
24
+ have he : (fun u => pairLinear (A u) (B u) + (ζ * α u) • pairLinear (L u) (M u)) =
25
+ fun u => pairLinear (A u + ζ * (α u * L u)) (B u + ζ * (α u * M u)) := by
26
+ funext u
27
+ apply ContinuousLinearMap.ext
28
+ intro v
29
+ simp only [add_apply, smul_apply, pairLinear_apply, smul_eq_mul]
30
+ ring
31
+ have hiA : Integrable (fun u => A u + ζ * (α u * L u)) ν := hA.add (hαL.const_mul ζ)
32
+ have hiB : Integrable (fun u => B u + ζ * (α u * M u)) ν := hB.add (hαM.const_mul ζ)
33
+ have heA : (∫ u, A u + ζ * (α u * L u) ∂ν) =
34
+ (∫ u, A u ∂ν) + ζ * ∫ u, α u * L u ∂ν := by
35
+ rw [integral_add hA (hαL.const_mul ζ), integral_const_mul]
36
+ have heB : (∫ u, B u + ζ * (α u * M u) ∂ν) =
37
+ (∫ u, B u ∂ν) + ζ * ∫ u, α u * M u ∂ν := by
38
+ rw [integral_add hB (hαM.const_mul ζ), integral_const_mul]
39
+ rw [he, integral_pairLinear ν hiA hiB, heA, heB, integral_smul,
40
+ integral_pairLinear ν hL hM]
41
+ apply ContinuousLinearMap.ext
42
+ intro v
43
+ simp only [sub_apply, smul_apply, pairLinear_apply, smul_eq_mul]
44
+ ring
45
+
46
+ end InvariantIsing
47
+
48
+ end
49
+
50
+ end OAI
lean/OAI/Probability/InvariantIsing/Fields/FieldSecondFamily.lean ADDED
@@ -0,0 +1,136 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Probability.InvariantIsing.Fields.FieldAffineRecursion
2
+ import OAI.Probability.InvariantIsing.Fields.FieldTiltedFamilyDerivative
3
+
4
+ namespace OAI
5
+
6
+ /-! Second-derivative data for the actual two-coordinate scalar recursion.
7
+ The first coordinate is a finite covariance variation; the second is the
8
+ scalar field. All bounds are local in the covariance coordinate. -/
9
+
10
+ noncomputable section
11
+ open MeasureTheory ProbabilityTheory IsingPerceptron Set
12
+
13
+ namespace InvariantIsing
14
+
15
+ structure FieldSecondFamily (I : Set ℝ) extends FieldSmoothFamily I where
16
+ TX : ℝ × ℝ → ℝ
17
+ TT : ℝ × ℝ → ℝ
18
+ KTX : ℝ
19
+ KTT : ℝ
20
+ mTX : Measurable TX
21
+ mTT : Measurable TT
22
+ bTX : ∀ p, p.1 ∈ I → |TX p| ≤ KTX
23
+ bTT : ∀ p, p.1 ∈ I → |TT p| ≤ KTT
24
+ derivativeX : ∀ p, p.1 ∈ I → HasFDerivAt X (pairLinear (TX p) (XX p)) p
25
+ derivativeT : ∀ p, p.1 ∈ I → HasFDerivAt T (pairLinear (TT p) (TX p)) p
26
+
27
+ /-- The actual log-cosh terminal has zero covariance derivatives. -/
28
+ def fieldLogCoshSecondFamily (I : Set ℝ) : FieldSecondFamily I where
29
+ toFieldSmoothFamily := fieldLogCoshFamily I
30
+ TX := fun _ => 0
31
+ TT := fun _ => 0
32
+ KTX := 0
33
+ KTT := 0
34
+ mTX := measurable_const
35
+ mTT := measurable_const
36
+ bTX := fun _ _ => by simp
37
+ bTT := fun _ _ => by simp
38
+ derivativeX := fun p _ => by
39
+ have h := (field_hasDerivAt_tanh p.2).hasFDerivAt.comp p hasFDerivAt_snd
40
+ convert h using 1
41
+ · rfl
42
+ · apply ContinuousLinearMap.ext
43
+ intro q
44
+ simp [pairLinear, mul_comm, fieldLogCoshFamily]
45
+ derivativeT := fun p _ => by
46
+ convert hasFDerivAt_const (0 : ℝ) p using 1
47
+ · rfl
48
+ · apply ContinuousLinearMap.ext
49
+ intro q
50
+ simp [pairLinear]
51
+
52
+ /-- First derivative of the square-root amplitude. -/
53
+ def fieldAmplitudeSlope (a v t : ℝ) : ℝ := v / (2 * Real.sqrt (a + v * t))
54
+
55
+ /-- Its second derivative, written in the chain-rule product form. -/
56
+ def fieldAmplitudeCurvature (a v t : ℝ) : ℝ :=
57
+ -(v / 2) * (Real.sqrt (a + v * t) ^ 2)⁻¹ * fieldAmplitudeSlope a v t
58
+
59
+ lemma fieldAmplitudeSlope_hasDerivAt (a v t : ℝ) (hv : 0 < a + v * t) :
60
+ HasDerivAt (fieldAmplitudeSlope a v) (fieldAmplitudeCurvature a v t) t := by
61
+ have hs : HasDerivAt (fun q => Real.sqrt (a + v * q)) (fieldAmplitudeSlope a v t) t := by
62
+ have hinner : HasDerivAt (fun q : ℝ => a + v * q) v t := by
63
+ convert ((hasDerivAt_id t).const_mul v).const_add a using 1 <;> simp
64
+ convert (Real.hasDerivAt_sqrt hv.ne').comp t hinner using 1
65
+ · rfl
66
+ · dsimp only [fieldAmplitudeSlope]
67
+ ring
68
+ have hi := ((hasDerivAt_inv (Real.sqrt_pos.mpr hv).ne').comp t hs).const_mul (v / 2)
69
+ convert hi using 1
70
+ · funext q
71
+ dsimp only [fieldAmplitudeSlope, Function.comp_def]
72
+ ring
73
+ · dsimp only [fieldAmplitudeCurvature]
74
+ ring
75
+
76
+ namespace FieldSecondFamily
77
+
78
+ variable {I : Set ℝ} (F : FieldSecondFamily I)
79
+
80
+ /-- The affine-noise image of the physical spin mean. -/
81
+ def shiftedMean (a v u : ℝ) (p : ℝ × ℝ) : ℝ :=
82
+ F.X (p.1, p.2 + Real.sqrt (a + v * p.1) * u)
83
+
84
+ /-- The raw covariance tangent of the affine-noise image of the value. -/
85
+ def shiftedTangent (a v u : ℝ) (p : ℝ × ℝ) : ℝ :=
86
+ F.T (p.1, p.2 + Real.sqrt (a + v * p.1) * u) +
87
+ F.X (p.1, p.2 + Real.sqrt (a + v * p.1) * u) * (fieldAmplitudeSlope a v p.1 * u)
88
+
89
+ lemma shiftedMean_hasFDerivAt (a v u : ℝ) {p : ℝ × ℝ} (hp : p.1 ∈ I)
90
+ (hv : 0 < a + v * p.1) :
91
+ HasFDerivAt (F.shiftedMean a v u)
92
+ (pairLinear
93
+ (F.TX (p.1, p.2 + Real.sqrt (a + v * p.1) * u) +
94
+ F.XX (p.1, p.2 + Real.sqrt (a + v * p.1) * u) *
95
+ (fieldAmplitudeSlope a v p.1 * u))
96
+ (F.XX (p.1, p.2 + Real.sqrt (a + v * p.1) * u))) p := by
97
+ exact affine_gaussian_shift_hasFDerivAt F.derivativeX a v u hp hv
98
+
99
+ lemma shiftedTangent_hasFDerivAt (a v u : ℝ) {p : ℝ × ℝ} (hp : p.1 ∈ I)
100
+ (hv : 0 < a + v * p.1) :
101
+ HasFDerivAt (F.shiftedTangent a v u)
102
+ (pairLinear
103
+ (F.TT (p.1, p.2 + Real.sqrt (a + v * p.1) * u) +
104
+ 2 * F.TX (p.1, p.2 + Real.sqrt (a + v * p.1) * u) *
105
+ (fieldAmplitudeSlope a v p.1 * u) +
106
+ F.XX (p.1, p.2 + Real.sqrt (a + v * p.1) * u) *
107
+ (fieldAmplitudeSlope a v p.1 * u) ^ 2 +
108
+ F.X (p.1, p.2 + Real.sqrt (a + v * p.1) * u) *
109
+ (fieldAmplitudeCurvature a v p.1 * u))
110
+ (F.TX (p.1, p.2 + Real.sqrt (a + v * p.1) * u) +
111
+ F.XX (p.1, p.2 + Real.sqrt (a + v * p.1) * u) *
112
+ (fieldAmplitudeSlope a v p.1 * u))) p := by
113
+ have hT := affine_gaussian_shift_hasFDerivAt F.derivativeT a v u hp hv
114
+ have hX := F.shiftedMean_hasFDerivAt a v u hp hv
115
+ have hc : HasFDerivAt (fun q : ℝ × ℝ => fieldAmplitudeSlope a v q.1 * u)
116
+ (pairLinear (fieldAmplitudeCurvature a v p.1 * u) 0) p := by
117
+ have h := ((fieldAmplitudeSlope_hasDerivAt a v p.1 hv).mul_const u).hasFDerivAt.comp p
118
+ hasFDerivAt_fst
119
+ convert h using 1
120
+ · rfl
121
+ · apply ContinuousLinearMap.ext
122
+ intro q
123
+ simp [pairLinear, mul_comm]
124
+ convert hT.add (hX.mul hc) using 1
125
+ · rfl
126
+ · apply ContinuousLinearMap.ext
127
+ intro q
128
+ simp [pairLinear, shiftedMean, fieldAmplitudeSlope]
129
+ ring
130
+
131
+ end FieldSecondFamily
132
+ end InvariantIsing
133
+
134
+ end
135
+
136
+ end OAI
lean/OAI/Probability/InvariantIsing/Fields/FieldSecondMeanBounds.lean ADDED
@@ -0,0 +1,131 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Probability.InvariantIsing.Fields.FieldSecondMeasurable
2
+
3
+ namespace OAI
4
+
5
+ /-! Uniform second-derivative bounds on a positive-variance interval.
6
+ The constants depend on the interval bounds but not on the spatial bias. -/
7
+
8
+ noncomputable section
9
+ open MeasureTheory ProbabilityTheory IsingPerceptron Set
10
+
11
+ namespace InvariantIsing
12
+
13
+ private lemma affine_linear_integral_bound {I : Set ℝ} (F : FieldSmoothFamily I)
14
+ (a v ζ : ℝ) (p : ℝ × ℝ) {V : ℝ} (hV : a + v * p.1 ≤ V)
15
+ {A : ℝ → ℝ} (hA : Measurable A) {C : ℝ} (hC : 0 ≤ C)
16
+ (hB : ∀ u, |A u| ≤ C * (1 + |u|)) :
17
+ |∫ u, A u ∂F.affineLaw a v ζ p| ≤ C * F.affineMomentCap ζ V := by
18
+ apply F.affineLaw_integral_bound a v ζ p hV hA hC
19
+ intro u
20
+ exact (hB u).trans (mul_le_mul_of_nonneg_left (field_mark_one_add_le_sq u) hC)
21
+
22
+ namespace FieldSecondFamily
23
+
24
+ variable {I : Set ℝ} (F : FieldSecondFamily I)
25
+
26
+ def mixedMeanCap (R ζ V : ℝ) : ℝ :=
27
+ (F.KTX + F.KXX * R + 2 * |ζ| * F.KX * (F.KT + F.KX * R)) *
28
+ F.toFieldSmoothFamily.affineMomentCap ζ V
29
+
30
+ def secondMeanCap (R D ζ V : ℝ) : ℝ :=
31
+ (F.KTT + 2 * F.KTX * R + F.KXX * R ^ 2 + F.KX * D) *
32
+ F.toFieldSmoothFamily.affineMomentCap ζ V +
33
+ |ζ| * ((F.KT + F.KX * R) ^ 2 * F.toFieldSmoothFamily.affineMomentCap ζ V +
34
+ ((F.KT + F.KX * R) * F.toFieldSmoothFamily.affineMomentCap ζ V) ^ 2)
35
+
36
+ lemma mixedMean_bound (a v ζ : ℝ) {p : ℝ × ℝ} (hp : p.1 ∈ I)
37
+ {R V : ℝ} (hR : 0 ≤ R) (hc : |fieldAmplitudeSlope a v p.1| ≤ R)
38
+ (hV : a + v * p.1 ≤ V) : |F.mixedMean a v ζ p| ≤ F.mixedMeanCap R ζ V := by
39
+ let A := F.KT + F.KX * R
40
+ let B := F.KTX + F.KXX * R
41
+ let M := F.toFieldSmoothFamily.affineMomentCap ζ V
42
+ let ν := F.toFieldSmoothFamily.affineLaw a v ζ p
43
+ have hX := F.kx_nonneg
44
+ have hXX : 0 ≤ F.KXX := (abs_nonneg _).trans (F.bXX (0, 0))
45
+ have hT : 0 ≤ F.KT := (abs_nonneg _).trans (F.bT (p.1, 0) hp)
46
+ have hTX : 0 ≤ F.KTX := (abs_nonneg _).trans (F.bTX (p.1, 0) hp)
47
+ have hA : 0 ≤ A := by dsimp only [A]; positivity
48
+ have hB : 0 ≤ B := by dsimp only [B]; positivity
49
+ have hiA : |∫ u, F.shiftedTangent a v u p ∂ν| ≤ A * M :=
50
+ affine_linear_integral_bound F.toFieldSmoothFamily a v ζ p hV
51
+ (F.measurable_shiftedTangent a v p) hA (fun u => F.shiftedTangent_bound a v u hp hR hc)
52
+ have hiB : |∫ u, F.shiftedMixed a v u p ∂ν| ≤ B * M :=
53
+ affine_linear_integral_bound F.toFieldSmoothFamily a v ζ p hV
54
+ (F.measurable_shiftedMixed a v p) hB (fun u => F.shiftedMixed_bound a v u hp hR hc)
55
+ have hiXA : |∫ u, F.shiftedMean a v u p * F.shiftedTangent a v u p ∂ν| ≤ F.KX * A * M := by
56
+ apply affine_linear_integral_bound F.toFieldSmoothFamily a v ζ p hV
57
+ ((F.measurable_shiftedMean a v p).mul (F.measurable_shiftedTangent a v p)) (mul_nonneg hX hA)
58
+ intro u
59
+ change |F.shiftedMean a v u p * F.shiftedTangent a v u p| ≤ _
60
+ rw [abs_mul]
61
+ calc
62
+ _ ≤ F.KX * (A * (1 + |u|)) := mul_le_mul (F.bX _)
63
+ (F.shiftedTangent_bound a v u hp hR hc) (abs_nonneg _) hX
64
+ _ = _ := by ring
65
+ have hiMean := F.bound_mean a v ζ p
66
+ unfold mixedMean
67
+ calc
68
+ _ ≤ |∫ u, F.shiftedMixed a v u p ∂ν| +
69
+ |ζ * ((∫ u, F.shiftedMean a v u p * F.shiftedTangent a v u p ∂ν) -
70
+ F.mean a v ζ p * ∫ u, F.shiftedTangent a v u p ∂ν)| := abs_add_le _ _
71
+ _ ≤ B * M + |ζ| * ((F.KX * A * M) + F.KX * (A * M)) := by
72
+ apply add_le_add hiB
73
+ rw [abs_mul]
74
+ apply mul_le_mul_of_nonneg_left _ (abs_nonneg ζ)
75
+ refine (abs_sub _ _).trans (add_le_add hiXA ?_)
76
+ rw [abs_mul]
77
+ exact mul_le_mul hiMean hiA (abs_nonneg _) hX
78
+ _ = F.mixedMeanCap R ζ V := by
79
+ dsimp only [mixedMeanCap, A, B, M]
80
+ ring
81
+
82
+ lemma secondMean_bound (a v ζ : ℝ) {p : ℝ × ℝ} (hp : p.1 ∈ I)
83
+ {R D V : ℝ} (hR : 0 ≤ R) (hD : 0 ≤ D)
84
+ (hc : |fieldAmplitudeSlope a v p.1| ≤ R)
85
+ (hd : |fieldAmplitudeCurvature a v p.1| ≤ D) (hV : a + v * p.1 ≤ V) :
86
+ |F.secondMean a v ζ p| ≤ F.secondMeanCap R D ζ V := by
87
+ let A := F.KT + F.KX * R
88
+ let C := F.KTT + 2 * F.KTX * R + F.KXX * R ^ 2 + F.KX * D
89
+ let M := F.toFieldSmoothFamily.affineMomentCap ζ V
90
+ let ν := F.toFieldSmoothFamily.affineLaw a v ζ p
91
+ have hX := F.kx_nonneg
92
+ have hXX : 0 ≤ F.KXX := (abs_nonneg _).trans (F.bXX (0, 0))
93
+ have hT : 0 ≤ F.KT := (abs_nonneg _).trans (F.bT (p.1, 0) hp)
94
+ have hTX : 0 ≤ F.KTX := (abs_nonneg _).trans (F.bTX (p.1, 0) hp)
95
+ have hTT : 0 ≤ F.KTT := (abs_nonneg _).trans (F.bTT (p.1, 0) hp)
96
+ have hA : 0 ≤ A := by dsimp only [A]; positivity
97
+ have hC : 0 ≤ C := by dsimp only [C]; positivity
98
+ have hiA : |∫ u, F.shiftedTangent a v u p ∂ν| ≤ A * M :=
99
+ affine_linear_integral_bound F.toFieldSmoothFamily a v ζ p hV
100
+ (F.measurable_shiftedTangent a v p) hA (fun u => F.shiftedTangent_bound a v u hp hR hc)
101
+ have hiC : |∫ u, F.shiftedSecond a v u p ∂ν| ≤ C * M :=
102
+ F.toFieldSmoothFamily.affineLaw_integral_bound a v ζ p hV
103
+ (F.measurable_shiftedSecond a v p) hC (fun u => F.shiftedSecond_bound a v u hp hR hD hc hd)
104
+ have hiAA : |∫ u, (F.shiftedTangent a v u p) ^ 2 ∂ν| ≤ A ^ 2 * M := by
105
+ apply F.toFieldSmoothFamily.affineLaw_integral_bound a v ζ p hV
106
+ ((F.measurable_shiftedTangent a v p).pow_const 2) (sq_nonneg A)
107
+ intro u
108
+ rw [abs_pow]
109
+ have h := pow_le_pow_left₀ (abs_nonneg _) (F.shiftedTangent_bound a v u hp hR hc) 2
110
+ nlinarith
111
+ have hsquare : |(∫ u, F.shiftedTangent a v u p ∂ν) ^ 2| ≤ (A * M) ^ 2 := by
112
+ rw [abs_pow]
113
+ exact pow_le_pow_left₀ (abs_nonneg _) hiA 2
114
+ unfold secondMean
115
+ calc
116
+ _ ≤ |∫ u, F.shiftedSecond a v u p ∂ν| +
117
+ |ζ * ((∫ u, (F.shiftedTangent a v u p) ^ 2 ∂ν) -
118
+ (∫ u, F.shiftedTangent a v u p ∂ν) ^ 2)| := abs_add_le _ _
119
+ _ ≤ C * M + |ζ| * (A ^ 2 * M + (A * M) ^ 2) := by
120
+ apply add_le_add hiC
121
+ rw [abs_mul]
122
+ exact mul_le_mul_of_nonneg_left ((abs_sub _ _).trans (add_le_add hiAA hsquare)) (abs_nonneg ζ)
123
+ _ = F.secondMeanCap R D ζ V := by
124
+ dsimp only [secondMeanCap, A, C, M]
125
+
126
+ end FieldSecondFamily
127
+ end InvariantIsing
128
+
129
+ end
130
+
131
+ end OAI
lean/OAI/Probability/InvariantIsing/Fields/FieldSecondMeanDerivative.lean ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Probability.InvariantIsing.Fields.FieldSecondCovariance
2
+ import OAI.Probability.InvariantIsing.Fields.FieldAffineMoments
3
+
4
+ namespace OAI
5
+
6
+ /-! The actual mixed derivative of one scalar Gaussian recursion step.
7
+ The formula uses the affine-noise tangent, so it needs no third spatial
8
+ derivative of the incoming scalar payoff. -/
9
+
10
+ noncomputable section
11
+ open MeasureTheory ProbabilityTheory IsingPerceptron Set
12
+
13
+ namespace InvariantIsing
14
+ namespace FieldSecondFamily
15
+
16
+ variable {I : Set ℝ} (F : FieldSecondFamily I)
17
+
18
+ def mixedMean (a v ζ : ℝ) (p : ℝ × ℝ) : ℝ :=
19
+ (∫ u, F.shiftedMixed a v u p ∂F.toFieldSmoothFamily.affineLaw a v ζ p) + ζ *
20
+ ((∫ u, F.shiftedMean a v u p * F.shiftedTangent a v u p
21
+ ∂F.toFieldSmoothFamily.affineLaw a v ζ p) -
22
+ F.toFieldSmoothFamily.mean a v ζ p *
23
+ (∫ u, F.shiftedTangent a v u p ∂F.toFieldSmoothFamily.affineLaw a v ζ p))
24
+
25
+ lemma measurable_shiftedMean (a v : ℝ) (p : ℝ × ℝ) :
26
+ Measurable (fun u => F.shiftedMean a v u p) := F.mX.comp (by fun_prop)
27
+
28
+ lemma measurable_shiftedTangent (a v : ℝ) (p : ℝ × ℝ) :
29
+ Measurable (fun u => F.shiftedTangent a v u p) :=
30
+ (F.mT.comp (by fun_prop)).add ((F.mX.comp (by fun_prop)).mul (by fun_prop))
31
+
32
+ lemma measurable_shiftedMixed (a v : ℝ) (p : ℝ × ℝ) :
33
+ Measurable (fun u => F.shiftedMixed a v u p) :=
34
+ (F.mTX.comp (by fun_prop)).add ((F.mXX.comp (by fun_prop)).mul (by fun_prop))
35
+
36
+ lemma mean_hasFDerivAt (hI : IsOpen I) (a v ζ : ℝ) {m V : ℝ} (hm : 0 < m)
37
+ (hlo : ∀ t ∈ I, m ≤ a + v * t) (hhi : ∀ t ∈ I, a + v * t ≤ V)
38
+ {p : ℝ × ℝ} (hp : p.1 ∈ I) :
39
+ HasFDerivAt (F.toFieldSmoothFamily.mean a v ζ)
40
+ (pairLinear (F.mixedMean a v ζ p) (F.toFieldSmoothFamily.curvature a v ζ p)) p := by
41
+ let R := |v| / (2 * Real.sqrt m)
42
+ let B := F.KTX + F.KXX * R
43
+ let A := F.KT + F.KX * R
44
+ let α : (ℝ × ℝ) → ℝ → ℝ := fun q u => F.shiftedMean a v u q
45
+ let Dα : (ℝ × ℝ) → ℝ → (ℝ × ℝ) →L[ℝ] ℝ := fun q u =>
46
+ pairLinear (F.shiftedMixed a v u q) (F.XX (q.1, q.2 + Real.sqrt (a + v * q.1) * u))
47
+ let ν := F.toFieldSmoothFamily.affineLaw a v ζ p
48
+ have hR : 0 ≤ R := by dsimp only [R]; positivity
49
+ have hX := F.kx_nonneg
50
+ have hXX : 0 ≤ F.KXX := (abs_nonneg _).trans (F.bXX (0, 0))
51
+ have hTX : 0 ≤ F.KTX := (abs_nonneg _).trans (F.bTX (p.1, 0) hp)
52
+ have hT : 0 ≤ F.KT := (abs_nonneg _).trans (F.bT (p.1, 0) hp)
53
+ have hB : 0 ≤ B := by dsimp only [B]; positivity
54
+ have hA : 0 ≤ A := by dsimp only [A]; positivity
55
+ have hc (q : ℝ × ℝ) (hq : q.1 ∈ I) : |fieldAmplitudeSlope a v q.1| ≤ R :=
56
+ abs_div_two_sqrt_le hm (hlo q.1 hq) v
57
+ have hd := F.toFieldSmoothFamily.affine_average_hasFDerivAt hI α Dα a v ζ hm hlo hhi
58
+ hX (show 0 ≤ B + F.KXX by positivity)
59
+ (fun q => F.measurable_shiftedMean a v q)
60
+ (fun q => (measurable_pairLinear (F.measurable_shiftedMixed a v q)
61
+ (F.mXX.comp (by fun_prop))).aestronglyMeasurable)
62
+ (fun q _ u => (F.bX _).trans (le_mul_of_one_le_right hX (by linarith [abs_nonneg u])))
63
+ (fun q hq u => by
64
+ refine (norm_pairLinear_le _ _).trans ?_
65
+ calc
66
+ _ ≤ B * (1 + |u|) + F.KXX := add_le_add (F.shiftedMixed_bound a v u hq hR (hc q hq)) (F.bXX _)
67
+ _ ≤ (B + F.KXX) * (1 + |u|) ^ 2 := by
68
+ have hq1 : 1 ≤ (1 + |u|) ^ 2 := by nlinarith [abs_nonneg u]
69
+ have hq2 := field_mark_one_add_le_sq u
70
+ nlinarith [mul_le_mul_of_nonneg_left hq1 hXX,
71
+ mul_le_mul_of_nonneg_left hq2 hB])
72
+ (fun q hq u => F.shiftedMean_hasFDerivAt a v u hq (hm.trans_le (hlo q.1 hq))) hp
73
+ have hiX : Integrable (fun u => F.shiftedMean a v u p) ν :=
74
+ F.toFieldSmoothFamily.affineLaw_bounded_integrable a v ζ p
75
+ (F.measurable_shiftedMean a v p) F.KX (fun u => F.bX _)
76
+ have hiXX : Integrable (fun u => F.XX (p.1, p.2 + Real.sqrt (a + v * p.1) * u)) ν :=
77
+ F.toFieldSmoothFamily.affineLaw_bounded_integrable a v ζ p
78
+ (F.mXX.comp (by fun_prop)) F.KXX (fun u => F.bXX _)
79
+ have hiA : Integrable (fun u => F.shiftedTangent a v u p) ν :=
80
+ F.toFieldSmoothFamily.affineLaw_linear_integrable a v ζ p
81
+ (F.measurable_shiftedTangent a v p) hA (fun u => F.shiftedTangent_bound a v u hp hR (hc p hp))
82
+ have hiB : Integrable (fun u => F.shiftedMixed a v u p) ν :=
83
+ F.toFieldSmoothFamily.affineLaw_linear_integrable a v ζ p
84
+ (F.measurable_shiftedMixed a v p) hB (fun u => F.shiftedMixed_bound a v u hp hR (hc p hp))
85
+ have hiXA : Integrable (fun u => F.shiftedMean a v u p * F.shiftedTangent a v u p) ν := by
86
+ apply F.toFieldSmoothFamily.affineLaw_linear_integrable a v ζ p
87
+ ((F.measurable_shiftedMean a v p).mul (F.measurable_shiftedTangent a v p))
88
+ (mul_nonneg hX hA)
89
+ intro u
90
+ change |F.shiftedMean a v u p * F.shiftedTangent a v u p| ≤ (F.KX * A) * (1 + |u|)
91
+ rw [abs_mul]
92
+ calc
93
+ _ ≤ F.KX * (A * (1 + |u|)) := mul_le_mul (F.bX _)
94
+ (F.shiftedTangent_bound a v u hp hR (hc p hp)) (abs_nonneg _) hX
95
+ _ = _ := by ring
96
+ have hiXXprod : Integrable (fun u => F.shiftedMean a v u p * F.shiftedMean a v u p) ν := by
97
+ apply F.toFieldSmoothFamily.affineLaw_bounded_integrable a v ζ p
98
+ ((F.measurable_shiftedMean a v p).mul (F.measurable_shiftedMean a v p)) (F.KX ^ 2)
99
+ intro u
100
+ change |F.shiftedMean a v u p * F.shiftedMean a v u p| ≤ F.KX ^ 2
101
+ rw [abs_mul]
102
+ simpa only [pow_two, shiftedMean] using mul_self_le_mul_self (abs_nonneg _)
103
+ (F.bX (p.1, p.2 + Real.sqrt (a + v * p.1) * u))
104
+ change HasFDerivAt (F.toFieldSmoothFamily.mean a v ζ)
105
+ ((∫ u, Dα p u + (ζ * α p u) • F.toFieldSmoothFamily.affineDifferential a v p u ∂ν) -
106
+ (∫ u, α p u ∂ν) • (∫ u, ζ • F.toFieldSmoothFamily.affineDifferential a v p u ∂ν)) p at hd
107
+ have he := field_pair_covariance ν ζ (α p) (fun u => F.shiftedMixed a v u p)
108
+ (fun u => F.XX (p.1, p.2 + Real.sqrt (a + v * p.1) * u))
109
+ (fun u => F.shiftedTangent a v u p) (fun u => F.shiftedMean a v u p)
110
+ hiB hiXX hiA hiX hiXA hiXXprod
111
+ change ((∫ u, Dα p u + (ζ * α p u) • F.toFieldSmoothFamily.affineDifferential a v p u ∂ν) -
112
+ (∫ u, α p u ∂ν) • (∫ u, ζ • F.toFieldSmoothFamily.affineDifferential a v p u ∂ν)) = _ at he
113
+ rw [he] at hd
114
+ simpa only [mixedMean, FieldSmoothFamily.curvature, FieldSmoothFamily.mean,
115
+ gaussianTiltAverage, FieldSmoothFamily.affineLaw, FieldSmoothFamily.affineShift,
116
+ α, Dα, ν, shiftedMean, pow_two] using hd
117
+
118
+ end FieldSecondFamily
119
+ end InvariantIsing
120
+
121
+ end
122
+
123
+ end OAI
lean/OAI/Probability/InvariantIsing/Fields/FieldSecondMeasurable.lean ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Probability.InvariantIsing.Fields.FieldSecondTangentDerivative
2
+
3
+ namespace OAI
4
+
5
+ /-! Measurability of the explicit second derivatives of the scalar
6
+ Gaussian recursion, including their affine Gaussian weights. -/
7
+
8
+ noncomputable section
9
+ open MeasureTheory ProbabilityTheory IsingPerceptron Set
10
+
11
+ namespace InvariantIsing
12
+
13
+ lemma FieldSmoothFamily.measurable_affine_average {I : Set ℝ} (F : FieldSmoothFamily I)
14
+ (a v ζ : ℝ) {A : (ℝ × ℝ) → ℝ → ℝ}
15
+ (hA : Measurable (fun p : (ℝ × ℝ) × ℝ => A p.1 p.2)) :
16
+ Measurable (fun p => ∫ u, A p u ∂F.affineLaw a v ζ p) := by
17
+ have hU : Measurable (fun p : (ℝ × ℝ) × ℝ => F.affineShift a v p.1 p.2) :=
18
+ F.mU.comp (by fun_prop)
19
+ simp only [FieldSmoothFamily.affineLaw, integral_tilted_eq_div]
20
+ exact ((hU.const_mul ζ).exp.mul hA).stronglyMeasurable.integral_prod_right'.measurable.div
21
+ ((hU.const_mul ζ).exp.stronglyMeasurable.integral_prod_right'.measurable)
22
+
23
+ namespace FieldSecondFamily
24
+
25
+ variable {I : Set ℝ} (F : FieldSecondFamily I)
26
+
27
+ lemma joint_measurable_shiftedMean (a v : ℝ) :
28
+ Measurable (fun p : (ℝ × ℝ) × ℝ => F.shiftedMean a v p.2 p.1) :=
29
+ F.mX.comp (by fun_prop)
30
+
31
+ lemma joint_measurable_shiftedTangent (a v : ℝ) :
32
+ Measurable (fun p : (ℝ × ℝ) × ℝ => F.shiftedTangent a v p.2 p.1) := by
33
+ exact (F.mT.comp (by fun_prop)).add ((F.mX.comp (by fun_prop)).mul (by
34
+ dsimp only [fieldAmplitudeSlope]
35
+ fun_prop))
36
+
37
+ lemma joint_measurable_shiftedMixed (a v : ℝ) :
38
+ Measurable (fun p : (ℝ × ℝ) × ℝ => F.shiftedMixed a v p.2 p.1) := by
39
+ exact (F.mTX.comp (by fun_prop)).add ((F.mXX.comp (by fun_prop)).mul (by
40
+ dsimp only [fieldAmplitudeSlope]
41
+ fun_prop))
42
+
43
+ lemma joint_measurable_shiftedSecond (a v : ℝ) :
44
+ Measurable (fun p : (ℝ × ℝ) × ℝ => F.shiftedSecond a v p.2 p.1) := by
45
+ exact (((F.mTT.comp (by fun_prop)).add
46
+ (((F.mTX.comp (by fun_prop)).const_mul 2).mul (by
47
+ dsimp only [fieldAmplitudeSlope]; fun_prop))).add
48
+ ((F.mXX.comp (by fun_prop)).mul (by
49
+ dsimp only [fieldAmplitudeSlope]; fun_prop))).add
50
+ ((F.mX.comp (by fun_prop)).mul (by
51
+ dsimp only [fieldAmplitudeCurvature, fieldAmplitudeSlope]; fun_prop))
52
+
53
+ lemma measurable_mixedMean (a v ζ : ℝ) : Measurable (F.mixedMean a v ζ) := by
54
+ exact (F.toFieldSmoothFamily.measurable_affine_average a v ζ
55
+ (F.joint_measurable_shiftedMixed a v)).add
56
+ (((F.toFieldSmoothFamily.measurable_affine_average a v ζ
57
+ ((F.joint_measurable_shiftedMean a v).mul (F.joint_measurable_shiftedTangent a v))).sub
58
+ ((F.measurable_mean a v ζ).mul (F.toFieldSmoothFamily.measurable_affine_average a v ζ
59
+ (F.joint_measurable_shiftedTangent a v)))).const_mul ζ)
60
+
61
+ lemma measurable_secondMean (a v ζ : ℝ) : Measurable (F.secondMean a v ζ) := by
62
+ exact (F.toFieldSmoothFamily.measurable_affine_average a v ζ
63
+ (F.joint_measurable_shiftedSecond a v)).add
64
+ (((F.toFieldSmoothFamily.measurable_affine_average a v ζ
65
+ ((F.joint_measurable_shiftedTangent a v).pow_const 2)).sub
66
+ ((F.toFieldSmoothFamily.measurable_affine_average a v ζ
67
+ (F.joint_measurable_shiftedTangent a v)).pow_const 2)).const_mul ζ)
68
+
69
+ end FieldSecondFamily
70
+ end InvariantIsing
71
+
72
+ end
73
+
74
+ end OAI
lean/OAI/Probability/InvariantIsing/Fields/FieldSecondRecursion.lean ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Probability.InvariantIsing.Fields.FieldSecondMeanBounds
2
+
3
+ namespace OAI
4
+
5
+ /-! Closure of the actual finite scalar recursion under two derivatives
6
+ on every interval with positive, bounded affine variances. -/
7
+
8
+ noncomputable section
9
+ open MeasureTheory ProbabilityTheory IsingPerceptron Set
10
+
11
+ namespace InvariantIsing
12
+ namespace FieldSecondFamily
13
+
14
+ variable {I : Set ℝ} (F : FieldSecondFamily I)
15
+
16
+ def secondTransform (hI : IsOpen I) (a v ζ : ℝ) {m V : ℝ} (hm : 0 < m)
17
+ (hlo : ∀ t ∈ I, m ≤ a + v * t) (hhi : ∀ t ∈ I, a + v * t ≤ V) :
18
+ FieldSecondFamily I :=
19
+ let R := |v| / (2 * Real.sqrt m)
20
+ let D := (|v| / 2) * m⁻¹ * R
21
+ { toFieldSmoothFamily := F.toFieldSmoothFamily.transform hI a v ζ
22
+ (fun t ht => hm.trans_le (hlo t ht))
23
+ TX := F.mixedMean a v ζ
24
+ TT := F.secondMean a v ζ
25
+ KTX := F.mixedMeanCap R ζ V
26
+ KTT := F.secondMeanCap R D ζ V
27
+ mTX := F.measurable_mixedMean a v ζ
28
+ mTT := F.measurable_secondMean a v ζ
29
+ bTX := fun p hp => F.mixedMean_bound a v ζ hp (by dsimp only [R]; positivity)
30
+ (abs_div_two_sqrt_le hm (hlo p.1 hp) v) (hhi p.1 hp)
31
+ bTT := fun p hp => F.secondMean_bound a v ζ hp (by dsimp only [R]; positivity)
32
+ (by dsimp only [D]; positivity) (abs_div_two_sqrt_le hm (hlo p.1 hp) v)
33
+ (fieldAmplitudeCurvature_abs_le a v p.1 hm (hlo p.1 hp)) (hhi p.1 hp)
34
+ derivativeX := fun p hp => F.mean_hasFDerivAt hI a v ζ hm hlo hhi hp
35
+ derivativeT := fun p hp => F.tangent_hasFDerivAt hI a v ζ hm hlo hhi hp }
36
+
37
+ end FieldSecondFamily
38
+
39
+ def fieldAffineSecondFamily (I : Set ℝ) (hI : IsOpen I) (m V : ℝ) (hm : 0 < m) :
40
+ (L : List FieldAffineStep) →
41
+ (∀ av ∈ L, ∀ t ∈ I, m ≤ av.base + av.slope * t ∧ av.base + av.slope * t ≤ V) →
42
+ FieldSecondFamily I
43
+ | [], _ => fieldLogCoshSecondFamily I
44
+ | av :: L, hL =>
45
+ (fieldAffineSecondFamily I hI m V hm L
46
+ (fun bv hb => hL bv (List.mem_cons_of_mem av hb))).secondTransform
47
+ hI av.base av.slope av.exponent hm
48
+ (fun t ht => (hL av List.mem_cons_self t ht).1)
49
+ (fun t ht => (hL av List.mem_cons_self t ht).2)
50
+
51
+ theorem fieldAffineSecondFamily_value (I : Set ℝ) (hI : IsOpen I) (m V : ℝ) (hm : 0 < m)
52
+ (L : List FieldAffineStep)
53
+ (hL : ∀ av ∈ L, ∀ t ∈ I, m ≤ av.base + av.slope * t ∧ av.base + av.slope * t ≤ V) :
54
+ (fieldAffineSecondFamily I hI m V hm L hL).U = fieldAffineValue L := by
55
+ induction L with
56
+ | nil => rfl
57
+ | cons av L ih =>
58
+ funext p
59
+ simp only [fieldAffineSecondFamily, FieldSecondFamily.secondTransform,
60
+ FieldSmoothFamily.transform, FieldSmoothFamily.value, fieldAffineValue]
61
+ rw [ih]
62
+
63
+ end InvariantIsing
64
+
65
+ end
66
+
67
+ end OAI
lean/OAI/Probability/InvariantIsing/Fields/FieldSecondTangentDerivative.lean ADDED
@@ -0,0 +1,139 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Probability.InvariantIsing.Fields.FieldSecondMeanDerivative
2
+ import OAI.Probability.InvariantIsing.Fields.FieldRawTangent
3
+
4
+ namespace OAI
5
+
6
+ /-! The second covariance derivative of the actual scalar Gaussian
7
+ value, obtained by differentiating its raw affine-noise tangent. -/
8
+
9
+ noncomputable section
10
+ open MeasureTheory ProbabilityTheory IsingPerceptron Filter Set
11
+ open scoped Topology
12
+
13
+ namespace InvariantIsing
14
+ namespace FieldSecondFamily
15
+
16
+ variable {I : Set ℝ} (F : FieldSecondFamily I)
17
+
18
+ def secondMean (a v ζ : ℝ) (p : ℝ × ℝ) : ℝ :=
19
+ (∫ u, F.shiftedSecond a v u p ∂F.toFieldSmoothFamily.affineLaw a v ζ p) + ζ *
20
+ ((∫ u, (F.shiftedTangent a v u p) ^ 2 ∂F.toFieldSmoothFamily.affineLaw a v ζ p) -
21
+ (∫ u, F.shiftedTangent a v u p ∂F.toFieldSmoothFamily.affineLaw a v ζ p) ^ 2)
22
+
23
+ lemma measurable_shiftedSecond (a v : ℝ) (p : ℝ × ℝ) :
24
+ Measurable (fun u => F.shiftedSecond a v u p) := by
25
+ exact (((F.mTT.comp (by fun_prop)).add
26
+ (((F.mTX.comp (by fun_prop)).const_mul 2).mul (by fun_prop))).add
27
+ ((F.mXX.comp (by fun_prop)).mul (by fun_prop))).add
28
+ ((F.mX.comp (by fun_prop)).mul (by fun_prop))
29
+
30
+ lemma tangent_hasFDerivAt (hI : IsOpen I) (a v ζ : ℝ) {m V : ℝ} (hm : 0 < m)
31
+ (hlo : ∀ t ∈ I, m ≤ a + v * t) (hhi : ∀ t ∈ I, a + v * t ≤ V)
32
+ {p : ℝ × ℝ} (hp : p.1 ∈ I) :
33
+ HasFDerivAt (F.toFieldSmoothFamily.tangent a v ζ)
34
+ (pairLinear (F.secondMean a v ζ p) (F.mixedMean a v ζ p)) p := by
35
+ let R := |v| / (2 * Real.sqrt m)
36
+ let D := (|v| / 2) * m⁻¹ * R
37
+ let A := F.KT + F.KX * R
38
+ let B := F.KTX + F.KXX * R
39
+ let C := F.KTT + 2 * F.KTX * R + F.KXX * R ^ 2 + F.KX * D
40
+ let α : (ℝ × ℝ) → ℝ → ℝ := fun q u => F.shiftedTangent a v u q
41
+ let Dα : (ℝ × ℝ) → ℝ → (ℝ × ℝ) →L[ℝ] ℝ := fun q u =>
42
+ pairLinear (F.shiftedSecond a v u q) (F.shiftedMixed a v u q)
43
+ let ν := F.toFieldSmoothFamily.affineLaw a v ζ p
44
+ have hR : 0 ≤ R := by dsimp only [R]; positivity
45
+ have hD : 0 ≤ D := by dsimp only [D]; positivity
46
+ have hX := F.kx_nonneg
47
+ have hXX : 0 ≤ F.KXX := (abs_nonneg _).trans (F.bXX (0, 0))
48
+ have hTX : 0 ≤ F.KTX := (abs_nonneg _).trans (F.bTX (p.1, 0) hp)
49
+ have hTT : 0 ≤ F.KTT := (abs_nonneg _).trans (F.bTT (p.1, 0) hp)
50
+ have hT : 0 ≤ F.KT := (abs_nonneg _).trans (F.bT (p.1, 0) hp)
51
+ have hA : 0 ≤ A := by dsimp only [A]; positivity
52
+ have hB : 0 ≤ B := by dsimp only [B]; positivity
53
+ have hC : 0 ≤ C := by dsimp only [C]; positivity
54
+ have hc (q : ℝ × ℝ) (hq : q.1 ∈ I) : |fieldAmplitudeSlope a v q.1| ≤ R :=
55
+ abs_div_two_sqrt_le hm (hlo q.1 hq) v
56
+ have hd2 (q : ℝ × ℝ) (hq : q.1 ∈ I) : |fieldAmplitudeCurvature a v q.1| ≤ D :=
57
+ fieldAmplitudeCurvature_abs_le a v q.1 hm (hlo q.1 hq)
58
+ have hd := F.toFieldSmoothFamily.affine_average_hasFDerivAt hI α Dα a v ζ hm hlo hhi
59
+ hA (show 0 ≤ C + B by positivity)
60
+ (fun q => F.measurable_shiftedTangent a v q)
61
+ (fun q => (measurable_pairLinear (F.measurable_shiftedSecond a v q)
62
+ (F.measurable_shiftedMixed a v q)).aestronglyMeasurable)
63
+ (fun q hq u => F.shiftedTangent_bound a v u hq hR (hc q hq))
64
+ (fun q hq u => by
65
+ refine (norm_pairLinear_le _ _).trans ?_
66
+ calc
67
+ _ ≤ C * (1 + |u|) ^ 2 + B * (1 + |u|) := add_le_add
68
+ (F.shiftedSecond_bound a v u hq hR hD (hc q hq) (hd2 q hq))
69
+ (F.shiftedMixed_bound a v u hq hR (hc q hq))
70
+ _ ≤ (C + B) * (1 + |u|) ^ 2 := by
71
+ have hh := mul_le_mul_of_nonneg_left (field_mark_one_add_le_sq u) hB
72
+ nlinarith)
73
+ (fun q hq u => F.shiftedTangent_hasFDerivAt a v u hq (hm.trans_le (hlo q.1 hq))) hp
74
+ have hq := (F.toFieldSmoothFamily.affineLaw_quadratic_moment a v ζ p).1
75
+ have hiX : Integrable (fun u => F.shiftedMean a v u p) ν :=
76
+ F.toFieldSmoothFamily.affineLaw_bounded_integrable a v ζ p
77
+ (F.measurable_shiftedMean a v p) F.KX (fun u => F.bX _)
78
+ have hiA : Integrable (fun u => F.shiftedTangent a v u p) ν :=
79
+ F.toFieldSmoothFamily.affineLaw_linear_integrable a v ζ p
80
+ (F.measurable_shiftedTangent a v p) hA (fun u => F.shiftedTangent_bound a v u hp hR (hc p hp))
81
+ have hiB : Integrable (fun u => F.shiftedMixed a v u p) ν :=
82
+ F.toFieldSmoothFamily.affineLaw_linear_integrable a v ζ p
83
+ (F.measurable_shiftedMixed a v p) hB (fun u => F.shiftedMixed_bound a v u hp hR (hc p hp))
84
+ have hiC : Integrable (fun u => F.shiftedSecond a v u p) ν :=
85
+ field_integrable_of_quadratic_bound ν hq (F.measurable_shiftedSecond a v p) C
86
+ (fun u => F.shiftedSecond_bound a v u hp hR hD (hc p hp) (hd2 p hp))
87
+ have hiAA : Integrable (fun u => F.shiftedTangent a v u p * F.shiftedTangent a v u p) ν := by
88
+ apply field_integrable_of_quadratic_bound ν hq
89
+ ((F.measurable_shiftedTangent a v p).mul (F.measurable_shiftedTangent a v p)) (A ^ 2)
90
+ intro u
91
+ change |F.shiftedTangent a v u p * F.shiftedTangent a v u p| ≤ A ^ 2 * (1 + |u|) ^ 2
92
+ rw [abs_mul]
93
+ have hh := mul_self_le_mul_self (abs_nonneg _) (F.shiftedTangent_bound a v u hp hR (hc p hp))
94
+ nlinarith
95
+ have hiAX : Integrable (fun u => F.shiftedTangent a v u p * F.shiftedMean a v u p) ν := by
96
+ apply F.toFieldSmoothFamily.affineLaw_linear_integrable a v ζ p
97
+ ((F.measurable_shiftedTangent a v p).mul (F.measurable_shiftedMean a v p))
98
+ (mul_nonneg hA hX)
99
+ intro u
100
+ change |F.shiftedTangent a v u p * F.shiftedMean a v u p| ≤ (A * F.KX) * (1 + |u|)
101
+ rw [abs_mul]
102
+ calc
103
+ _ ≤ (A * (1 + |u|)) * F.KX := mul_le_mul
104
+ (F.shiftedTangent_bound a v u hp hR (hc p hp)) (F.bX _) (abs_nonneg _) (by positivity)
105
+ _ = _ := by ring
106
+ change HasFDerivAt (fun q => ∫ u, F.shiftedTangent a v u q
107
+ ∂F.toFieldSmoothFamily.affineLaw a v ζ q)
108
+ ((∫ u, Dα p u + (ζ * α p u) • F.toFieldSmoothFamily.affineDifferential a v p u ∂ν) -
109
+ (∫ u, α p u ∂ν) • (∫ u, ζ • F.toFieldSmoothFamily.affineDifferential a v p u ∂ν)) p at hd
110
+ have he := field_pair_covariance ν ζ (α p) (fun u => F.shiftedSecond a v u p)
111
+ (fun u => F.shiftedMixed a v u p) (fun u => F.shiftedTangent a v u p)
112
+ (fun u => F.shiftedMean a v u p) hiC hiB hiA hiX hiAA hiAX
113
+ change ((∫ u, Dα p u + (ζ * α p u) • F.toFieldSmoothFamily.affineDifferential a v p u ∂ν) -
114
+ (∫ u, α p u ∂ν) • (∫ u, ζ • F.toFieldSmoothFamily.affineDifferential a v p u ∂ν)) = _ at he
115
+ rw [he] at hd
116
+ have hcov : (∫ u, F.shiftedTangent a v u p * F.shiftedMean a v u p ∂ν) =
117
+ ∫ u, F.shiftedMean a v u p * F.shiftedTangent a v u p ∂ν := by
118
+ apply integral_congr_ae
119
+ exact ae_of_all _ fun u => mul_comm _ _
120
+ have hf : F.toFieldSmoothFamily.tangent a v ζ =ᶠ[𝓝 p]
121
+ (fun q => ∫ u, F.shiftedTangent a v u q ∂F.toFieldSmoothFamily.affineLaw a v ζ q) := by
122
+ filter_upwards [(hI.preimage continuous_fst).mem_nhds hp] with q hqI
123
+ exact (F.rawTangent_eq a v ζ hqI (hm.trans_le (hlo q.1 hqI))).symm
124
+ have hout := hd.congr_of_eventuallyEq hf
125
+ rw [hcov] at hout
126
+ convert hout using 1
127
+ apply ContinuousLinearMap.ext
128
+ intro w
129
+ simp only [secondMean, mixedMean, FieldSmoothFamily.mean, gaussianTiltAverage,
130
+ FieldSmoothFamily.affineLaw, FieldSmoothFamily.affineShift, α, ν,
131
+ shiftedMean, pairLinear_apply, pow_two]
132
+ ring
133
+
134
+ end FieldSecondFamily
135
+ end InvariantIsing
136
+
137
+ end
138
+
139
+ end OAI
lean/OAI/Probability/InvariantIsing/Fields/FieldShiftMoments.lean ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Probability.InvariantIsing.Fields.FieldSmoothFamily
2
+ import OAI.Probability.InvariantIsing.Fields.FieldGaussianTiltMoments
3
+
4
+ namespace OAI
5
+
6
+ /-! Uniform polynomial moments for the actual shifted Gaussian weights
7
+ of the finite scalar field. The bound is independent of the spatial bias. -/
8
+
9
+ noncomputable section
10
+ open MeasureTheory ProbabilityTheory IsingPerceptron Set
11
+
12
+ namespace InvariantIsing
13
+
14
+ lemma FieldSmoothFamily.spatial_abs_sub_le {I : Set ℝ} (F : FieldSmoothFamily I)
15
+ (t x y : ℝ) : |F.U (t, x) - F.U (t, y)| ≤ F.KX * |x - y| := by
16
+ simpa only [Real.norm_eq_abs] using
17
+ Convex.norm_image_sub_le_of_norm_hasDerivWithin_le
18
+ (fun z (_ : z ∈ (univ : Set ℝ)) => (F.spatial t z).hasDerivWithinAt)
19
+ (fun z _ => by simpa only [Real.norm_eq_abs] using F.bX (t, z))
20
+ convex_univ (mem_univ y) (mem_univ x)
21
+
22
+ lemma FieldSmoothFamily.shifted_second_moment {I : Set ℝ} (F : FieldSmoothFamily I)
23
+ (t z r ζ R : ℝ) (hr : |r| ≤ R) :
24
+ Integrable (fun u : ℝ => (1 + |u|) ^ 2)
25
+ ((gaussianReal 0 1).tilted (fun u => ζ * F.U (t, z + r * u))) ∧
26
+ (∫ u : ℝ, (1 + |u|) ^ 2
27
+ ∂(gaussianReal 0 1).tilted (fun u => ζ * F.U (t, z + r * u))) ≤
28
+ fieldGaussianMomentCap (|ζ| * F.KX * R) := by
29
+ let H : ℝ → ℝ := fun u => ζ * F.U (t, z + r * u)
30
+ let U : ℝ → ℝ := fun u => H u - ζ * F.U (t, z)
31
+ have hmH : Measurable H := (F.mU.comp (by fun_prop)).const_mul ζ
32
+ have hmU : Measurable U := hmH.sub_const _
33
+ have hb : ∀ u, |U u| ≤ (|ζ| * F.KX * R) * |u| := by
34
+ intro u
35
+ have hsp := F.spatial_abs_sub_le t (z + r * u) z
36
+ have hdiff : z + r * u - z = r * u := by ring
37
+ rw [hdiff, abs_mul] at hsp
38
+ calc
39
+ |U u| = |ζ| * |F.U (t, z + r * u) - F.U (t, z)| := by
40
+ dsimp only [U, H]
41
+ rw [← mul_sub, abs_mul]
42
+ _ ≤ |ζ| * (F.KX * (|r| * |u|)) := mul_le_mul_of_nonneg_left hsp (abs_nonneg ζ)
43
+ _ ≤ |ζ| * (F.KX * (R * |u|)) :=
44
+ mul_le_mul_of_nonneg_left
45
+ (mul_le_mul_of_nonneg_left
46
+ (mul_le_mul_of_nonneg_right hr (abs_nonneg u)) F.kx_nonneg) (abs_nonneg ζ)
47
+ _ = _ := by ring
48
+ have hExp : Integrable (fun u => Real.exp (H u)) (gaussianReal 0 1) :=
49
+ integrable_exp_of_linearGrowth _ (gaussianReal_exponentialNormMoments 0 1)
50
+ (F.mU.comp (by fun_prop)) ((F.growth t).add_left z |>.scale_argument r) ζ
51
+ have hprob : IsProbabilityMeasure ((gaussianReal 0 1).tilted H) :=
52
+ isProbabilityMeasure_tilted hExp
53
+ have he : (gaussianReal 0 1).tilted U = (gaussianReal 0 1).tilted H := by
54
+ have hh := tilted_tilted hExp (fun _ => -(ζ * F.U (t, z)))
55
+ simpa only [tilted_const, Pi.add_def, sub_eq_add_neg, U] using hh.symm
56
+ have h := field_centered_tilt_second_moment hmU hb
57
+ rwa [he] at h
58
+
59
+ end InvariantIsing
60
+
61
+ end
62
+
63
+ end OAI
lean/OAI/Probability/InvariantIsing/Fields/FieldSimpleApproximation.lean ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Probability.InvariantIsing.Fields.SimpleFieldComparison
2
+
3
+ namespace OAI
4
+
5
+ /-! Canonical finite field approximations in first absolute moment. -/
6
+ noncomputable section
7
+ open MeasureTheory ProbabilityTheory Filter Set
8
+ open scoped Topology
9
+ namespace InvariantIsing
10
+
11
+ def fieldSimpleApproximation (n : ℕ) : SimpleFunc ℝ ℝ :=
12
+ SimpleFunc.approxOn id measurable_id (range (id : ℝ → ℝ) ∪ {0}) 0 (by simp) n
13
+
14
+ lemma fieldSimpleApproximation_tendsto (μ : Measure ℝ)
15
+ (hi : Integrable (fun x : ℝ => x) μ) :
16
+ Tendsto (fun n => ∫ x, |fieldSimpleApproximation n x-x| ∂μ) atTop (𝓝 0) := by
17
+ simpa only [fieldSimpleApproximation,Real.norm_eq_abs,id_eq] using
18
+ tendsto_integral_norm_approxOn_sub measurable_id hi
19
+
20
+ lemma simpleFieldValue_cauchy {Ω : Type*} [MeasurableSpace Ω]
21
+ (P : Measure Ω) [IsProbabilityMeasure P] (s : ℕ → SimpleFunc Ω ℝ)
22
+ (f : Ω → ℝ) (hf : Integrable f P)
23
+ (hs : Tendsto (fun n => ∫ x, |s n x-f x| ∂P) atTop (𝓝 0))
24
+ (ν : ProbabilityMeasure ℝ) (a b : ℝ)
25
+ (hcompact : IsCompact (ν : Measure ℝ).support)
26
+ (hbound : (ν : Measure ℝ).support ⊆ Icc a b)
27
+ (ha : a∈(ν : Measure ℝ).support) (hb : b∈(ν : Measure ℝ).support) :
28
+ CauchySeq (fun n => simpleFieldValue P (s n) (measureR (ν : Measure ℝ) b)) := by
29
+ apply Metric.cauchySeq_iff.mpr
30
+ intro ε hε
31
+ obtain ⟨N,hN⟩ := eventually_atTop.mp (hs.eventually (Iio_mem_nhds (half_pos hε)))
32
+ refine ⟨N,fun m hm n hn => ?_⟩
33
+ have hm' := hN m hm
34
+ have hn' := hN n hn
35
+ have ht : (∫ x, |s m x-s n x| ∂P) ≤ (∫ x, |s m x-f x| ∂P)+(∫ x, |s n x-f x| ∂P) := by
36
+ have he := integral_add ((simpleField_integrable P (s m)).sub hf).abs
37
+ ((simpleField_integrable P (s n)).sub hf).abs
38
+ dsimp only [Pi.add_apply,Pi.sub_apply] at he
39
+ rw [← he]
40
+ apply integral_mono ((simpleField_integrable P (s m)).sub (simpleField_integrable P (s n))).abs
41
+ (((simpleField_integrable P (s m)).sub hf).abs.add ((simpleField_integrable P (s n)).sub hf).abs)
42
+ intro x
43
+ change |s m x-s n x| ≤ |s m x-f x|+|s n x-f x|
44
+ simpa only [abs_sub_comm (f x) (s n x)] using abs_sub_le (s m x) (f x) (s n x)
45
+ rw [Real.dist_eq]
46
+ exact (simpleFieldValue_abs_sub_le ν a b hcompact hbound ha hb P (s m) (s n)).trans_lt
47
+ (ht.trans_lt (by linarith))
48
+
49
+ end InvariantIsing
50
+
51
+ end
52
+
53
+ end OAI
lean/OAI/Probability/InvariantIsing/Fields/FieldSmoothFamily.lean ADDED
@@ -0,0 +1,170 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Probability.InvariantIsing.Fields.FieldRealVariance
2
+
3
+ namespace OAI
4
+
5
+ /-! The scalar field family carrying exactly the derivatives needed for
6
+ finite covariance-coordinate differentiation. No bound on the value is
7
+ required: bounded spatial derivative supplies its Gaussian moments. -/
8
+
9
+ noncomputable section
10
+ open MeasureTheory ProbabilityTheory IsingPerceptron
11
+ open scoped NNReal
12
+
13
+ namespace InvariantIsing
14
+
15
+ structure FieldSmoothFamily (I : Set ℝ) where
16
+ U : ℝ × ℝ → ℝ
17
+ X : ℝ × ℝ → ℝ
18
+ XX : ℝ × ℝ → ℝ
19
+ T : ℝ × ℝ → ℝ
20
+ KX : ℝ
21
+ KXX : ℝ
22
+ KT : ℝ
23
+ mU : Measurable U
24
+ mX : Measurable X
25
+ mXX : Measurable XX
26
+ mT : Measurable T
27
+ bX : ∀ p, |X p| ≤ KX
28
+ bXX : ∀ p, |XX p| ≤ KXX
29
+ bT : ∀ p, p.1 ∈ I → |T p| ≤ KT
30
+ derivative : ∀ p, p.1 ∈ I → HasFDerivAt U (pairLinear (T p) (X p)) p
31
+ spatial : ∀ t y, HasDerivAt (fun z => U (t, z)) (X (t, y)) y
32
+ second : ∀ t y, HasDerivAt (fun z => X (t, z)) (XX (t, y)) y
33
+
34
+ namespace FieldSmoothFamily
35
+
36
+ variable {I : Set ℝ} (F : FieldSmoothFamily I)
37
+
38
+ lemma kx_nonneg : 0 ≤ F.KX := (abs_nonneg _).trans (F.bX (0, 0))
39
+
40
+ lemma growth (t : ℝ) : HasLinearGrowth (fun y => F.U (t, y)) :=
41
+ field_spatial_linearGrowth F.kx_nonneg (fun y => F.bX (t, y)) (F.spatial t)
42
+
43
+ def value (a v ζ : ℝ) (p : ℝ × ℝ) : ℝ :=
44
+ gaussianTransform (a + v * p.1) ζ (fun y => F.U (p.1, y)) p.2
45
+
46
+ def mean (a v ζ : ℝ) (p : ℝ × ℝ) : ℝ :=
47
+ gaussianTiltAverage (a + v * p.1) ζ (fun y => F.U (p.1, y))
48
+ (fun y => F.X (p.1, y)) p.2
49
+
50
+ def curvature (a v ζ : ℝ) (p : ℝ × ℝ) : ℝ :=
51
+ gaussianTiltAverage (a + v * p.1) ζ (fun y => F.U (p.1, y))
52
+ (fun y => F.XX (p.1, y)) p.2 + ζ *
53
+ (gaussianTiltAverage (a + v * p.1) ζ (fun y => F.U (p.1, y))
54
+ (fun y => (F.X (p.1, y)) ^ 2) p.2 - (F.mean a v ζ p) ^ 2)
55
+
56
+ def tangent (a v ζ : ℝ) (p : ℝ × ℝ) : ℝ :=
57
+ gaussianTiltAverage (a + v * p.1) ζ (fun y => F.U (p.1, y))
58
+ (fun y => F.T (p.1, y)) p.2 + v / 2 *
59
+ gaussianTiltAverage (a + v * p.1) ζ (fun y => F.U (p.1, y))
60
+ (fun y => F.XX (p.1, y) + ζ * (F.X (p.1, y)) ^ 2) p.2
61
+
62
+ lemma measurable_value (a v ζ : ℝ) : Measurable (F.value a v ζ) :=
63
+ measurable_gaussianTransform_param (F.mU.comp (by fun_prop)) (by fun_prop) (by fun_prop) ζ
64
+
65
+ lemma measurable_mean (a v ζ : ℝ) : Measurable (F.mean a v ζ) :=
66
+ measurable_gaussianTiltAverage_param (F.mU.comp (by fun_prop))
67
+ (F.mX.comp (by fun_prop)) (by fun_prop) (by fun_prop) ζ
68
+
69
+ lemma measurable_curvature (a v ζ : ℝ) : Measurable (F.curvature a v ζ) := by
70
+ exact (measurable_gaussianTiltAverage_param (F.mU.comp (by fun_prop))
71
+ (F.mXX.comp (by fun_prop)) (by fun_prop) (by fun_prop) ζ).add
72
+ (((measurable_gaussianTiltAverage_param (F.mU.comp (by fun_prop))
73
+ ((F.mX.pow_const 2).comp (by fun_prop)) (by fun_prop) (by fun_prop) ζ).sub
74
+ ((F.measurable_mean a v ζ).pow_const 2)).const_mul ζ)
75
+
76
+ lemma measurable_tangent (a v ζ : ℝ) : Measurable (F.tangent a v ζ) := by
77
+ exact (measurable_gaussianTiltAverage_param (F.mU.comp (by fun_prop))
78
+ (F.mT.comp (by fun_prop)) (by fun_prop) (by fun_prop) ζ).add
79
+ ((measurable_gaussianTiltAverage_param (F.mU.comp (by fun_prop))
80
+ ((F.mXX.add ((F.mX.pow_const 2).const_mul ζ)).comp (by fun_prop))
81
+ (by fun_prop) (by fun_prop) ζ).const_mul (v / 2))
82
+
83
+ lemma bound_mean (a v ζ : ℝ) (p : ℝ × ℝ) : |F.mean a v ζ p| ≤ F.KX :=
84
+ field_gaussianTiltAverage_bound _ _ (F.mU.comp (by fun_prop)) (F.growth p.1)
85
+ (F.mX.comp (by fun_prop)) (fun y => F.bX (p.1, y)) p.2
86
+
87
+ lemma bound_curvature (a v ζ : ℝ) (p : ℝ × ℝ) :
88
+ |F.curvature a v ζ p| ≤ F.KXX + 2 * |ζ| * F.KX ^ 2 := by
89
+ have hXX := field_gaussianTiltAverage_bound (a + v * p.1) ζ
90
+ (F.mU.comp (by fun_prop)) (F.growth p.1) (F.mXX.comp (by fun_prop))
91
+ (fun y => F.bXX (p.1, y)) p.2
92
+ have hsq : ∀ y, |(F.X (p.1, y)) ^ 2| ≤ F.KX ^ 2 := fun y => by
93
+ rw [abs_pow]
94
+ exact pow_le_pow_left₀ (abs_nonneg _) (F.bX (p.1, y)) 2
95
+ have hsqavg := field_gaussianTiltAverage_bound (a + v * p.1) ζ
96
+ (F.mU.comp (by fun_prop)) (F.growth p.1) ((F.mX.pow_const 2).comp (by fun_prop)) hsq p.2
97
+ have hmean : |(F.mean a v ζ p) ^ 2| ≤ F.KX ^ 2 := by
98
+ rw [abs_pow]
99
+ exact pow_le_pow_left₀ (abs_nonneg _) (F.bound_mean a v ζ p) 2
100
+ unfold curvature
101
+ refine (abs_add_le _ _).trans (add_le_add hXX ?_)
102
+ rw [abs_mul]
103
+ calc
104
+ _ ≤ |ζ| * (|gaussianTiltAverage (a + v * p.1) ζ (fun y => F.U (p.1, y))
105
+ (fun y => (F.X (p.1, y)) ^ 2) p.2| + |(F.mean a v ζ p) ^ 2|) :=
106
+ mul_le_mul_of_nonneg_left (abs_sub _ _) (abs_nonneg ζ)
107
+ _ ≤ |ζ| * (F.KX ^ 2 + F.KX ^ 2) :=
108
+ mul_le_mul_of_nonneg_left (add_le_add hsqavg hmean) (abs_nonneg ζ)
109
+ _ = _ := by ring
110
+
111
+ lemma bound_tangent (a v ζ : ℝ) {p : ℝ × ℝ} (hp : p.1 ∈ I) :
112
+ |F.tangent a v ζ p| ≤ F.KT + |v| / 2 * (F.KXX + |ζ| * F.KX ^ 2) := by
113
+ have hT := field_gaussianTiltAverage_bound (a + v * p.1) ζ
114
+ (F.mU.comp (by fun_prop)) (F.growth p.1) (F.mT.comp (by fun_prop))
115
+ (fun y => F.bT (p.1, y) hp) p.2
116
+ have hgen : ∀ y, |F.XX (p.1, y) + ζ * (F.X (p.1, y)) ^ 2| ≤
117
+ F.KXX + |ζ| * F.KX ^ 2 :=
118
+ bounded_generator (fun y => F.bX (p.1, y)) (fun y => F.bXX (p.1, y)) ζ
119
+ have hQ := field_gaussianTiltAverage_bound (a + v * p.1) ζ
120
+ (F.mU.comp (by fun_prop)) (F.growth p.1)
121
+ ((F.mXX.add ((F.mX.pow_const 2).const_mul ζ)).comp (by fun_prop)) hgen p.2
122
+ unfold tangent
123
+ refine (abs_add_le _ _).trans (add_le_add hT ?_)
124
+ rw [abs_mul, abs_div, abs_of_pos (by norm_num : (0 : ℝ) < 2)]
125
+ exact mul_le_mul_of_nonneg_left hQ (by positivity)
126
+
127
+ lemma spatial_value (a v ζ t y : ℝ) :
128
+ HasDerivAt (fun z => F.value a v ζ (t, z)) (F.mean a v ζ (t, y)) y := by
129
+ exact field_gaussianTransform_hasDerivAt (a + v * t) ζ
130
+ (F.mU.comp (by fun_prop)) (F.growth t) (F.mX.comp (by fun_prop))
131
+ F.kx_nonneg (fun z => F.bX (t, z)) (F.spatial t) y
132
+
133
+ lemma spatial_mean (a v ζ t y : ℝ) :
134
+ HasDerivAt (fun z => F.mean a v ζ (t, z)) (F.curvature a v ζ (t, y)) y := by
135
+ have h := field_gaussianTiltAverage_hasDerivAt (a + v * t) ζ
136
+ (F := fun u => F.U (t, u)) (D := fun u => F.X (t, u))
137
+ (a := fun u => F.X (t, u)) (b := fun u => F.XX (t, u))
138
+ (F.mU.comp (by fun_prop)) (F.growth t) (F.mX.comp (by fun_prop))
139
+ (F.mX.comp (by fun_prop)) (F.mXX.comp (by fun_prop)) F.kx_nonneg F.kx_nonneg
140
+ (fun z => F.bX (t, z)) (fun z => F.bX (t, z)) (fun z => F.bXX (t, z))
141
+ (F.spatial t) (F.second t) y
142
+ simpa only [mean, curvature, pow_two, Function.comp_apply] using h
143
+
144
+ def transform (hI : IsOpen I) (a v ζ : ℝ) (hv : ∀ t ∈ I, 0 < a + v * t) :
145
+ FieldSmoothFamily I where
146
+ U := F.value a v ζ
147
+ X := F.mean a v ζ
148
+ XX := F.curvature a v ζ
149
+ T := F.tangent a v ζ
150
+ KX := F.KX
151
+ KXX := F.KXX + 2 * |ζ| * F.KX ^ 2
152
+ KT := F.KT + |v| / 2 * (F.KXX + |ζ| * F.KX ^ 2)
153
+ mU := F.measurable_value a v ζ
154
+ mX := F.measurable_mean a v ζ
155
+ mXX := F.measurable_curvature a v ζ
156
+ mT := F.measurable_tangent a v ζ
157
+ bX := F.bound_mean a v ζ
158
+ bXX := F.bound_curvature a v ζ
159
+ bT := fun _ hp => F.bound_tangent a v ζ hp
160
+ derivative := fun p hp => field_gaussianFamily_local_hasFDerivAt hI F.mU F.mT F.mX F.mXX
161
+ F.bT F.bX F.bXX F.derivative F.spatial F.second a v ζ hp (hv p.1 hp)
162
+ spatial := F.spatial_value a v ζ
163
+ second := F.spatial_mean a v ζ
164
+
165
+ end FieldSmoothFamily
166
+ end InvariantIsing
167
+
168
+ end
169
+
170
+ end OAI
lean/OAI/Probability/InvariantIsing/Fields/FieldSpatialParameterOrder.lean ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Probability.InvariantIsing.Fields.FieldAdjacentDerivative
2
+ import OAI.Probability.InvariantIsing.Fields.FieldScalarSquareOrder
3
+ import OAI.Probability.InvariantIsing.Fields.FieldParameterOrder
4
+
5
+ namespace OAI
6
+
7
+ /-! The spatial consequence of the backward covariance derivative.
8
+ Radial antitonicity of that derivative gives ordering of the physical
9
+ conditional means, and hence ordering of all earlier squared means. -/
10
+
11
+ noncomputable section
12
+ open MeasureTheory ProbabilityTheory IsingPerceptron Set
13
+ open scoped NNReal
14
+
15
+ namespace InvariantIsing
16
+
17
+ theorem field_spatial_derivative_order {F : ℝ → ℝ} {f g : ℝ}
18
+ (hF : HasDerivAt F f g) {H : ℝ → ℝ} {h : ℝ}
19
+ (hH : HasDerivAt H h g) (hg : 0 ≤ g)
20
+ (hmono : MonotoneOn (fun y => F y - H y) (Ici 0)) : h ≤ f := by
21
+ have hd : HasDerivAt (fun y => F y - H y) (f - h) g := hF.sub hH
22
+ have hn := hmono.derivWithin_nonneg (x := g)
23
+ rw [hd.hasDerivWithinAt.derivWithin (uniqueDiffOn_Ici 0 g hg)] at hn
24
+ exact sub_nonneg.mp hn
25
+
26
+ namespace FieldSmoothFamily
27
+
28
+ theorem physical_mean_antitone_parameter {I : Set ℝ} (F : FieldSmoothFamily I)
29
+ (hI : Convex ℝ I) (hD : ∀ t ∈ I, AntitoneOn (fun z => F.T (t, z)) (Ici 0))
30
+ {t s : ℝ} (ht : t ∈ I) (hs : s ∈ I) (hts : t ≤ s) :
31
+ ∀ z ∈ Ici (0 : ℝ), F.X (s, z) ≤ F.X (t, z) := by
32
+ have hp := field_parameter_difference_order hI
33
+ (fun q hq z => F.parameter_derivative q z hq) hD ht hs hts
34
+ intro z hz
35
+ exact field_spatial_derivative_order (F.spatial t z) (F.spatial s z) hz hp
36
+
37
+ theorem earlier_squares_antitone_parameter {I : Set ℝ} (F : FieldSmoothFamily I)
38
+ (hI : Convex ℝ I) (hD : ∀ t ∈ I, AntitoneOn (fun z => F.T (t, z)) (Ici 0))
39
+ (hUe : ∀ t ∈ I, Function.Even (fun z => F.U (t, z)))
40
+ (hXo : ∀ t ∈ I, Function.Odd (fun z => F.X (t, z)))
41
+ (hXm : ∀ t ∈ I, MonotoneOn (fun z => F.X (t, z)) (Ici 0))
42
+ (hXp : ∀ t ∈ I, ∀ z ∈ Ici (0 : ℝ), 0 ≤ F.X (t, z))
43
+ (hXb : ∀ p, |F.X p| ≤ 1)
44
+ (L : List (ℝ × ℝ≥0)) (hL : ∀ av ∈ L, 0 < av.1)
45
+ {t s : ℝ} (ht : t ∈ I) (hs : s ∈ I) (hts : t ≤ s) :
46
+ ∀ i z, fieldScalarSquares L (fun y => F.U (s, y)) (fun y => F.X (s, y)) i z ≤
47
+ fieldScalarSquares L (fun y => F.U (t, y)) (fun y => F.X (t, y)) i z := by
48
+ have hp := field_parameter_difference_order hI
49
+ (fun q hq z => F.parameter_derivative q z hq) hD ht hs hts
50
+ exact fieldScalarSquares_order L hL
51
+ (F := fun y => F.U (s, y)) (G := fun y => F.U (t, y))
52
+ (a := fun y => F.X (s, y)) (b := fun y => F.X (t, y))
53
+ (F.mU.comp (by fun_prop)) (F.mU.comp (by fun_prop)) (F.growth s) (F.growth t)
54
+ (hUe s hs) (hUe t ht) hp
55
+ (F.mX.comp (by fun_prop)) (F.mX.comp (by fun_prop))
56
+ (hXo s hs) (hXo t ht) (hXm s hs) (hXm t ht) (hXp s hs) (hXp t ht)
57
+ (fun z => hXb (s, z)) (fun z => hXb (t, z))
58
+ (F.physical_mean_antitone_parameter hI hD ht hs hts)
59
+
60
+ end FieldSmoothFamily
61
+ end InvariantIsing
62
+
63
+ end
64
+
65
+ end OAI
lean/OAI/Probability/InvariantIsing/Fields/FieldSpinDerivative.lean ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Probability.InvariantIsing.Fields.FieldSpinTransition
2
+ import OAI.Probability.InvariantIsing.Arrays.NSpinTensorBackwardDerivative
3
+
4
+ namespace OAI
5
+
6
+ /-! Spatial differentiation of the scalar Gaussian operator. The payoff
7
+ may grow linearly; only its derivative is bounded. -/
8
+
9
+ noncomputable section
10
+ open MeasureTheory ProbabilityTheory IsingPerceptron Filter Set
11
+ open scoped NNReal Topology
12
+
13
+ namespace InvariantIsing
14
+
15
+ lemma fieldSpinTransition_eq_shifted (ζ : ℝ) (v : ℝ≥0) {F a : ℝ → ℝ}
16
+ (hF : Measurable F) (ha : Measurable a) (z : ℝ) :
17
+ fieldSpinTransition ζ v F a z =
18
+ ∫ u, a (z + u) ∂(gaussianReal 0 v).tilted (fun u => ζ * F (z + u)) := by
19
+ rw [fieldSpinTransition, integral_tilted_eq_div, integral_tilted_eq_div]
20
+ have hm : Measurable (fun u => Real.exp (ζ * F u) * a u) :=
21
+ (hF.const_mul ζ).exp.mul ha
22
+ rw [field_gaussian_integral_shift v z hm,
23
+ field_gaussian_integral_shift v z (hF.const_mul ζ).exp]
24
+
25
+ lemma gaussianOperator_eq_logMean_shift {ζ : ℝ} (hζ : ζ ≠ 0)
26
+ (v : ℝ≥0) {F : ℝ → ℝ} (hF : Measurable F) (z : ℝ) :
27
+ gaussianOperator ζ v F z =
28
+ logMean ζ (gaussianReal 0 v) (fun u => F (z + u)) := by
29
+ rw [gaussianOperator_eq_gaussian_exp_integral hζ v hF,
30
+ field_gaussian_integral_shift v z (hF.const_mul ζ).exp, logMean]
31
+ ring
32
+
33
+ lemma hasDerivAt_gaussianOperator (ζ : ℝ) (v : ℝ≥0) {F D : ℝ → ℝ}
34
+ (hF : Measurable F) (hG : HasLinearGrowth F) (hD : Measurable D)
35
+ {K : ℝ} (hK : 0 ≤ K) (hbound : ∀ u, |D u| ≤ K)
36
+ (hd : ∀ u, HasDerivAt F (D u) u) (z : ℝ) :
37
+ HasDerivAt (gaussianOperator ζ v F) (fieldSpinTransition ζ v F D z) z := by
38
+ have hshift (s u : ℝ) :
39
+ HasDerivAt (fun q => F (q + u)) (D (s + u)) s := by
40
+ convert (hd (s + u)).comp s ((hasDerivAt_id s).add_const u) using 1 <;>
41
+ first | rfl | simp only [mul_one]
42
+ have hm (s : ℝ) : Measurable (fun u => F (s + u)) :=
43
+ hF.comp (measurable_const.add measurable_id)
44
+ have hDm (s : ℝ) : Measurable (fun u => D (s + u)) :=
45
+ hD.comp (measurable_const.add measurable_id)
46
+ by_cases hζ : ζ = 0
47
+ · subst ζ
48
+ have hi := field_gaussian_linear_integrable v 0 (hm z) (hG.add_left z)
49
+ obtain ⟨_, hI⟩ := hasDerivAt_integral_of_dominated_loc_of_deriv_le
50
+ (Ioo_mem_nhds (by linarith : z - 1 < z) (by linarith : z < z + 1))
51
+ (Eventually.of_forall fun s => (hm s).aestronglyMeasurable) hi
52
+ (hDm z).aestronglyMeasurable
53
+ (ae_of_all _ fun u s _ => by simpa only [Real.norm_eq_abs] using hbound (s + u))
54
+ (integrable_const K) (ae_of_all _ fun u s _ => hshift s u)
55
+ have he : gaussianOperator 0 v F = fun s => ∫ u, F (s + u) ∂gaussianReal 0 v := by
56
+ funext s
57
+ rw [gaussianOperator_eq_gaussian_integral v hF,
58
+ field_gaussian_integral_shift v s hF]
59
+ rw [he, fieldSpinTransition_eq_shifted 0 v hF hD]
60
+ simpa only [zero_mul, tilted_const] using hI
61
+ · have hi := integrable_exp_of_linearGrowth (gaussianReal 0 v)
62
+ (gaussianReal_exponentialNormMoments 0 v) (hm z) (hG.add_left z) ζ
63
+ have h := hasDerivAt_logMean_of_bounded_derivative (gaussianReal 0 v)
64
+ (fun s u => F (s + u)) (fun s u => D (s + u)) hm hDm hK
65
+ (fun s u => hbound (s + u)) hshift hζ z hi
66
+ have he : gaussianOperator ζ v F =
67
+ fun s => logMean ζ (gaussianReal 0 v) (fun u => F (s + u)) := by
68
+ funext s
69
+ exact gaussianOperator_eq_logMean_shift hζ v hF s
70
+ rw [he, fieldSpinTransition_eq_shifted ζ v hF hD]
71
+ exact h
72
+
73
+ end InvariantIsing
74
+
75
+ end
76
+
77
+ end OAI
lean/OAI/Probability/InvariantIsing/Fields/FieldSpinEvaluation.lean ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Probability.InvariantIsing.Fields.FieldEnergyCoordinates
2
+ import OAI.Probability.InvariantIsing.Fields.FieldSpinPairConditioning
3
+
4
+ namespace OAI
5
+
6
+ /-! The actual finite vector-spin common-depth test under the published
7
+ marking input. Both the spin conditioning and exponential integrability
8
+ are derived for this model. -/
9
+
10
+ noncomputable section
11
+ open MeasureTheory ProbabilityTheory IsingPerceptron
12
+
13
+ namespace InvariantIsing
14
+
15
+ def fieldVectorSpinPairMean (N : ℕ) (h : FieldStep) (z : Fin N → ℝ)
16
+ (q : Fin (h.depth + 1) → ℝ) (Φ : ℝ → ℝ) (j : Fin N) : ℝ :=
17
+ ∫ p, referenceReplicaMean
18
+ ((uniformSpinPrior N : Measure (Spin N)).prod (labeledLeafLaw h.depth p.1))
19
+ (fun s : Spin N × LabeledLeaf h.depth =>
20
+ fieldEnergy (fieldVectorEndpoint N h p z s.2) s.1)
21
+ (fun σ : Fin 2 → Spin N × LabeledLeaf h.depth =>
22
+ Φ (q (fieldDepthLevel h (labeledCommonDepth h.depth (σ 0).2 (σ 1).2))) *
23
+ (spinValue ((σ 0).1 j) * spinValue ((σ 1).1 j)))
24
+ ∂fieldVectorCoordinateLaw N h
25
+
26
+ theorem field_vector_spin_pair_reduce (N : ℕ) (hN : 0 < N) (h : FieldStep)
27
+ (z : Fin N → ℝ) (q : Fin (h.depth + 1) → ℝ) (Φ : ℝ → ℝ) (j : Fin N)
28
+ {C : ℝ} (hΦ : ∀ x, |Φ x| ≤ C) :
29
+ fieldVectorSpinPairMean N h z q Φ j =
30
+ fieldVectorTiltedPairMean N h z (fieldEndpointCoordinateTest N h q Φ j) := by
31
+ unfold fieldVectorSpinPairMean fieldVectorTiltedPairMean
32
+ apply integral_congr_ae
33
+ filter_upwards [field_vector_spin_exp_integrable N hN h z] with p hp
34
+ exact field_leaf_spin_pair_conditioning (labeledLeafLaw h.depth p.1)
35
+ (fieldVectorEndpoint N h p z) hp (fun d => Φ (q (fieldDepthLevel h d)))
36
+ (fun d => hΦ _) j
37
+
38
+ /-- The finite-cascade identity `cav:spin-test`, for the scalar field
39
+ representation, conditional only on the published endpoint marking law. -/
40
+ theorem field_vector_spin_pair_evaluation (hpub : PanchenkoTalagrandFieldPairInput)
41
+ (N : ℕ) (hN : 0 < N) (h : FieldStep)
42
+ (q : Fin (h.depth + 1) → ℝ) (Φ : ℝ → ℝ) (j : Fin N)
43
+ {C : ℝ} (hΦ : ∀ x, |Φ x| ≤ C) :
44
+ (∫ z, fieldVectorSpinPairMean N h z q Φ j
45
+ ∂(vectorGaussianLaw N (NNReal.mk (h.height 0) (h.nonneg 0)) : Measure (Fin N → ℝ))) =
46
+ ∫ s, Φ (q (fieldLevelIndex h s)) * fieldMagnetizationPath h s ∂pathMeasure := by
47
+ simp_rw [field_vector_spin_pair_reduce N hN h _ q Φ j hΦ]
48
+ exact field_published_rooted_coordinate_test hpub N hN h q Φ j hΦ
49
+
50
+ end InvariantIsing
51
+
52
+ end
53
+
54
+ end OAI
lean/OAI/Probability/InvariantIsing/Fields/FieldSpinFolding.lean ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Probability.InvariantIsing.Fields.FieldGaussianTransformLaw
2
+
3
+ namespace OAI
4
+
5
+ /-! Exact odd-observable law for an even Gaussian tilt. This is the
6
+ conditional-spin kernel in the radial field comparison. -/
7
+
8
+ noncomputable section
9
+ open MeasureTheory ProbabilityTheory IsingPerceptron Set
10
+ open scoped NNReal
11
+
12
+ namespace InvariantIsing
13
+
14
+ lemma field_abs_tanh_le_one (x : ℝ) : |Real.tanh x| ≤ 1 := by
15
+ rw [Real.tanh_eq, abs_div, abs_of_pos (add_pos (Real.exp_pos _) (Real.exp_pos _))]
16
+ apply (div_le_one (add_pos (Real.exp_pos _) (Real.exp_pos _))).mpr
17
+ exact abs_sub_le_iff.mpr ⟨by linarith [Real.exp_pos (-x)], by linarith [Real.exp_pos x]⟩
18
+
19
+ lemma field_gaussian_odd_folded_integral (v : ℝ≥0) (hv : v ≠ 0) (z ζ : ℝ)
20
+ (F a : ℝ → ℝ) (hF : Function.Even F) (ha : Function.Odd a)
21
+ (hi : Integrable (fun u => Real.exp (ζ * F u) * a u) (gaussianReal z v)) :
22
+ (∫ u, Real.exp (ζ * F u) * a u ∂gaussianReal z v) =
23
+ (2 * (Real.sqrt (2 * Real.pi * v))⁻¹ * Real.exp (-z ^ 2 / (2 * v))) *
24
+ ∫ u in Ici (0 : ℝ), (a u * Real.tanh ((z / v) * u)) * fieldFoldedWeight v ζ F z u := by
25
+ let C := 2 * (Real.sqrt (2 * Real.pi * v))⁻¹ * Real.exp (-z ^ 2 / (2 * (v : ℝ)))
26
+ let g := fun u => gaussianPDFReal z v u * (Real.exp (ζ * F u) * a u)
27
+ have hg : Integrable g volume := field_gaussian_density_integrable v hv z _ hi
28
+ rw [integral_gaussianReal_eq_integral_smul hv]
29
+ change (∫ u, g u) = _
30
+ rw [field_integral_fold g hg, ← integral_const_mul]
31
+ apply setIntegral_congr_fun measurableSet_Ici
32
+ intro u _hu
33
+ dsimp only [g]
34
+ rw [hF u, ha u]
35
+ have he := field_gaussian_pair_sign v hv z u
36
+ have hp := field_gaussian_pair_sum v hv z u
37
+ calc
38
+ _ = (gaussianPDFReal z v u - gaussianPDFReal z v (-u)) *
39
+ (Real.exp (ζ * F u) * a u) := by ring
40
+ _ = _ := by rw [he, hp]; dsimp only [C, fieldFoldedWeight]; ring
41
+
42
+ /-- The physical odd conditional spin observable equals the folded
43
+ observable multiplied by the exact conditional sign. -/
44
+ theorem field_gaussian_tilt_odd_integral_eq_folded (v : ℝ≥0) (hv : v ≠ 0) (z ζ : ℝ)
45
+ (F a : ℝ → ℝ) (hF : Function.Even F) (ha : Function.Odd a)
46
+ (hi : Integrable (fun u => Real.exp (ζ * F u) * a u) (gaussianReal z v))
47
+ (hweight : Integrable (fun u => Real.exp (ζ * F u)) (gaussianReal z v)) :
48
+ (∫ u, a u ∂(gaussianReal z v).tilted (fun u => ζ * F u)) =
49
+ (∫ u in Ici (0 : ℝ), (a u * Real.tanh ((z / v) * u)) * fieldFoldedWeight v ζ F z u) /
50
+ (∫ u in Ici (0 : ℝ), fieldFoldedWeight v ζ F z u) := by
51
+ rw [integral_tilted_eq_div]
52
+ have hn := field_gaussian_odd_folded_integral v hv z ζ F a hF ha hi
53
+ have hd := field_gaussian_folded_integral v hv z ζ F (fun _ => 1) hF
54
+ (by simpa only [mul_one] using hweight)
55
+ simp only [mul_one, one_mul] at hd
56
+ rw [hn, hd, mul_div_mul_left _ _ (field_folded_constant_pos v hv z).ne']
57
+
58
+ end InvariantIsing
59
+
60
+ end
61
+
62
+ end OAI
lean/OAI/Probability/InvariantIsing/Fields/FieldSpinKernelOrder.lean ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Probability.InvariantIsing.Fields.FieldSpinFolding
2
+
3
+ namespace OAI
4
+
5
+ /-! Monotonicity of the physical conditional-spin transition. This keeps
6
+ the spin observable, rather than the derivative in rescaled coordinates. -/
7
+
8
+ noncomputable section
9
+ open MeasureTheory ProbabilityTheory IsingPerceptron Set
10
+ open scoped NNReal
11
+
12
+ namespace InvariantIsing
13
+
14
+ lemma field_spin_test_measurable {a : ℝ → ℝ} (ha : Measurable a) (v z : ℝ) :
15
+ Measurable (fun u => a u * Real.tanh ((z / v) * u)) := by
16
+ simp only [Real.tanh_eq]
17
+ fun_prop
18
+
19
+ lemma field_spin_test_bound {a : ℝ → ℝ} {B : ℝ} (ha : ∀ u, |a u| ≤ B) (v z u : ℝ) :
20
+ |a u * Real.tanh ((z / v) * u)| ≤ B := by
21
+ rw [abs_mul]
22
+ exact (mul_le_mul_of_nonneg_left (field_abs_tanh_le_one _) (abs_nonneg _)).trans
23
+ (by simpa only [mul_one] using ha u)
24
+
25
+ lemma field_spin_test_monotone {a : ℝ → ℝ} (ha : MonotoneOn a (Ici 0))
26
+ (hapos : ∀ u ∈ Ici (0 : ℝ), 0 ≤ a u) {v z : ℝ} (hv : 0 < v) (hz : 0 ≤ z) :
27
+ MonotoneOn (fun u => a u * Real.tanh ((z / v) * u)) (Ici 0) := by
28
+ intro x hx y hy hxy
29
+ exact mul_le_mul (ha hx hy hxy)
30
+ (field_tanh_monotone (mul_le_mul_of_nonneg_left hxy (div_nonneg hz hv.le)))
31
+ (field_tanh_nonneg (mul_nonneg (div_nonneg hz hv.le) hx)) (hapos y hy)
32
+
33
+ private lemma field_spin_exp_integrable (v : ℝ≥0) (z ζ : ℝ)
34
+ (F a : ℝ → ℝ) (hF : Measurable F) (hgrowth : HasLinearGrowth F)
35
+ (ha : Measurable a) {B : ℝ} (hbound : ∀ u, |a u| ≤ B) :
36
+ Integrable (fun u => Real.exp (ζ * F u) * a u) (gaussianReal z v) := by
37
+ have hi := (integrable_exp_of_linearGrowth _ (gaussianReal_exponentialNormMoments z v)
38
+ hF hgrowth ζ).bdd_mul ha.aestronglyMeasurable
39
+ (Filter.Eventually.of_forall (fun u => by simpa only [Real.norm_eq_abs] using hbound u))
40
+ simpa only [mul_comm] using hi
41
+
42
+ lemma field_gaussian_tilt_odd_eq_abs (v : ℝ≥0) (hv : v ≠ 0) (z ζ : ℝ)
43
+ (F a : ℝ → ℝ) (hF : Measurable F) (hFeven : Function.Even F)
44
+ (hgrowth : HasLinearGrowth F) (ha : Measurable a) (haodd : Function.Odd a)
45
+ {B : ℝ} (hbound : ∀ u, |a u| ≤ B) :
46
+ (∫ u, a u ∂(gaussianReal z v).tilted (fun u => ζ * F u)) =
47
+ ∫ u, a |u| * Real.tanh ((z / v) * |u|)
48
+ ∂(gaussianReal z v).tilted (fun u => ζ * F u) := by
49
+ let f := fun u => a u * Real.tanh ((z / (v : ℝ)) * u)
50
+ have hf : Measurable f := field_spin_test_measurable ha v z
51
+ have hb : ∀ u, |f u| ≤ B := field_spin_test_bound hbound v z
52
+ have hw := integrable_exp_of_linearGrowth _ (gaussianReal_exponentialNormMoments z v)
53
+ hF hgrowth ζ
54
+ rw [field_gaussian_tilt_odd_integral_eq_folded v hv z ζ F a hFeven haodd
55
+ (field_spin_exp_integrable v z ζ F a hF hgrowth ha hbound) hw]
56
+ rw [integral_tilted_eq_div]
57
+ exact (field_gaussian_folded_ratio v hv z ζ F f hFeven
58
+ (field_spin_exp_integrable v z ζ F (fun u => f |u|) hF hgrowth
59
+ (hf.comp measurable_abs) (fun u => hb |u|)) hw).symm
60
+
61
+ /-- Parent, payoff and physical spin-observable comparisons in one actual
62
+ Gaussian transition. This is the backward induction step in fld:radial. -/
63
+ theorem field_gaussian_spin_transition_order (v : ℝ≥0) (hv : v ≠ 0) {ζ : ℝ} (hζ : 0 ≤ ζ)
64
+ (F G a b : ℝ → ℝ) (hF : Measurable F) (hG : Measurable G)
65
+ (hFeven : Function.Even F) (hGeven : Function.Even G)
66
+ (hFgrowth : HasLinearGrowth F) (hGgrowth : HasLinearGrowth G)
67
+ (hFG : MonotoneOn (fun u => G u - F u) (Ici 0))
68
+ (ha : Measurable a) (hb : Measurable b) (haodd : Function.Odd a) (hbodd : Function.Odd b)
69
+ (hamono : MonotoneOn a (Ici 0)) (hapos : ∀ u ∈ Ici (0 : ℝ), 0 ≤ a u)
70
+ (hab : ∀ u ∈ Ici (0 : ℝ), a u ≤ b u)
71
+ {B : ℝ} (haB : ∀ u, |a u| ≤ B) (hbB : ∀ u, |b u| ≤ B)
72
+ {z₀ z₁ : ℝ} (hz₀ : 0 ≤ z₀) (hzz : z₀ ≤ z₁) :
73
+ (∫ u, a u ∂(gaussianReal z₀ v).tilted (fun u => ζ * F u)) ≤
74
+ ∫ u, b u ∂(gaussianReal z₁ v).tilted (fun u => ζ * G u) := by
75
+ let f := fun u => a u * Real.tanh ((z₀ / (v : ℝ)) * u)
76
+ let g := fun u => b u * Real.tanh ((z₁ / (v : ℝ)) * u)
77
+ have hf : Measurable f := field_spin_test_measurable ha v z₀
78
+ have hg : Measurable g := field_spin_test_measurable hb v z₁
79
+ have hfB : ∀ u, |f u| ≤ B := field_spin_test_bound haB v z₀
80
+ have hgB : ∀ u, |g u| ≤ B := field_spin_test_bound hbB v z₁
81
+ have hvp : (0 : ℝ) < v := by exact_mod_cast (pos_iff_ne_zero.mpr hv)
82
+ have hfmono : MonotoneOn f (Ici 0) := field_spin_test_monotone hamono hapos hvp hz₀
83
+ have hp := field_gaussian_tilt_abs_parent_order v hv ζ F f hF hFeven hFgrowth
84
+ hf hfmono hfB hz₀ hzz
85
+ have hq := field_gaussian_tilt_abs_payoff_order v hv hζ F G f hF hG hFeven hGeven
86
+ hFgrowth hGgrowth hFG hf hfmono hfB z₁
87
+ have htest : ∀ u, f |u| ≤ g |u| := by
88
+ intro u
89
+ have hu : |u| ∈ Ici (0 : ℝ) := abs_nonneg u
90
+ exact mul_le_mul (hab |u| hu)
91
+ (field_tanh_monotone (mul_le_mul_of_nonneg_right
92
+ ((div_le_div_iff_of_pos_right hvp).mpr hzz) (abs_nonneg u)))
93
+ (field_tanh_nonneg (mul_nonneg (div_nonneg hz₀ hvp.le) (abs_nonneg u)))
94
+ ((hapos |u| hu).trans (hab |u| hu))
95
+ have hfg : (∫ u, f |u| ∂(gaussianReal z₁ v).tilted (fun u => ζ * G u)) ≤
96
+ ∫ u, g |u| ∂(gaussianReal z₁ v).tilted (fun u => ζ * G u) := by
97
+ apply integral_mono
98
+ (Integrable.of_bound (hf.comp measurable_abs).aestronglyMeasurable B
99
+ (Filter.Eventually.of_forall (fun u => by simpa only [Function.comp_apply, Real.norm_eq_abs] using hfB |u|)))
100
+ (Integrable.of_bound (hg.comp measurable_abs).aestronglyMeasurable B
101
+ (Filter.Eventually.of_forall (fun u => by simpa only [Function.comp_apply, Real.norm_eq_abs] using hgB |u|))) htest
102
+ have he₀ := field_gaussian_tilt_odd_eq_abs v hv z₀ ζ F a hF hFeven hFgrowth ha haodd haB
103
+ have he₁ := field_gaussian_tilt_odd_eq_abs v hv z₁ ζ G b hG hGeven hGgrowth hb hbodd hbB
104
+ exact he₀.trans_le ((hp.trans hq).trans (hfg.trans_eq he₁.symm))
105
+
106
+ end InvariantIsing
107
+
108
+ end
109
+
110
+ end OAI
lean/OAI/Probability/InvariantIsing/Fields/FieldSpinLinear.lean ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Probability.InvariantIsing.Fields.FieldSpinSecondDerivative
2
+
3
+ namespace OAI
4
+
5
+ /-! Linear identities for the actual tilted scalar transition. -/
6
+
7
+ noncomputable section
8
+ open MeasureTheory ProbabilityTheory IsingPerceptron
9
+ open scoped NNReal
10
+
11
+ namespace InvariantIsing
12
+
13
+ lemma fieldSpinTransition_const_mul (ζ : ℝ) (v : ℝ≥0) (F a : ℝ → ℝ)
14
+ (c z : ℝ) :
15
+ fieldSpinTransition ζ v F (fun u => c * a u) z = c * fieldSpinTransition ζ v F a z := by
16
+ exact integral_const_mul c _
17
+
18
+ lemma fieldSpinTransition_add (ζ : ℝ) (v : ℝ≥0) {F a b : ℝ → ℝ}
19
+ (hF : Measurable F) (hg : HasLinearGrowth F) (ha : Measurable a) (hb : Measurable b)
20
+ {A B : ℝ} (haB : ∀ u, |a u| ≤ A) (hbB : ∀ u, |b u| ≤ B) (z : ℝ) :
21
+ fieldSpinTransition ζ v F (fun u => a u + b u) z =
22
+ fieldSpinTransition ζ v F a z + fieldSpinTransition ζ v F b z := by
23
+ have he := integrable_exp_of_linearGrowth _ (gaussianReal_exponentialNormMoments z v) hF hg ζ
24
+ have : IsProbabilityMeasure ((gaussianReal z v).tilted (fun u => ζ * F u)) :=
25
+ MeasureTheory.isProbabilityMeasure_tilted he
26
+ exact integral_add
27
+ (Integrable.of_bound ha.aestronglyMeasurable A
28
+ (Filter.Eventually.of_forall fun u => by simpa only [Real.norm_eq_abs] using haB u))
29
+ (Integrable.of_bound hb.aestronglyMeasurable B
30
+ (Filter.Eventually.of_forall fun u => by simpa only [Real.norm_eq_abs] using hbB u))
31
+
32
+ lemma fieldSpinTransition_const (ζ : ℝ) (v : ℝ≥0) {F : ℝ → ℝ}
33
+ (hF : Measurable F) (hg : HasLinearGrowth F) (c z : ℝ) :
34
+ fieldSpinTransition ζ v F (fun _ => c) z = c := by
35
+ have he := integrable_exp_of_linearGrowth _ (gaussianReal_exponentialNormMoments z v) hF hg ζ
36
+ have : IsProbabilityMeasure ((gaussianReal z v).tilted (fun u => ζ * F u)) :=
37
+ MeasureTheory.isProbabilityMeasure_tilted he
38
+ simp only [fieldSpinTransition, integral_const, measureReal_def, measure_univ,
39
+ ENNReal.toReal_one, one_smul]
40
+
41
+ lemma fieldSpinTransition_generator_difference (ζ η : ℝ) (v : ℝ≥0)
42
+ {F D DD : ℝ → ℝ} (hF : Measurable F) (hg : HasLinearGrowth F)
43
+ (hD : Measurable D) (hDD : Measurable DD)
44
+ {K C : ℝ} (hDb : ∀ u, |D u| ≤ K) (hDDb : ∀ u, |DD u| ≤ C) (z : ℝ) :
45
+ -(fieldSpinTransition ζ v F (fun u => DD u + η * (D u) ^ 2) z) / 2 +
46
+ fieldSpinTransition ζ v F (fun u => DD u + ζ * (D u) ^ 2) z / 2 =
47
+ (ζ - η) / 2 * fieldSpinTransition ζ v F (fun u => (D u) ^ 2) z := by
48
+ have hs : ∀ u, |(D u) ^ 2| ≤ K ^ 2 := fun u => by
49
+ rw [abs_pow]
50
+ exact pow_le_pow_left₀ (abs_nonneg _) (hDb u) 2
51
+ have hm (r : ℝ) : Measurable (fun u => r * (D u) ^ 2) := (hD.pow_const 2).const_mul r
52
+ have hb (r : ℝ) : ∀ u, |r * (D u) ^ 2| ≤ |r| * K ^ 2 := fun u => by
53
+ rw [abs_mul]
54
+ exact mul_le_mul_of_nonneg_left (hs u) (abs_nonneg r)
55
+ rw [fieldSpinTransition_add ζ v hF hg hDD (hm η) hDDb (hb η),
56
+ fieldSpinTransition_add ζ v hF hg hDD (hm ζ) hDDb (hb ζ),
57
+ fieldSpinTransition_const_mul, fieldSpinTransition_const_mul]
58
+ ring
59
+
60
+ end InvariantIsing
61
+
62
+ end
63
+
64
+ end OAI
lean/OAI/Probability/InvariantIsing/Fields/FieldSpinLipschitz.lean ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Probability.InvariantIsing.Magnetic.MagneticCurvatureBound
2
+
3
+ namespace OAI
4
+
5
+ /-! The actual conditional spin mean is spatially one-Lipschitz,
6
+ uniformly in the number and variances of the finite field levels. -/
7
+
8
+ noncomputable section
9
+ open MeasureTheory ProbabilityTheory IsingPerceptron Set
10
+ open scoped NNReal
11
+
12
+ namespace InvariantIsing
13
+
14
+ lemma fieldScalarLogCoshMean_dist_le (L : List (ℝ × ℝ≥0))
15
+ (hL : ∀ av ∈ L, 0 < av.1) (hζ : ∀ av ∈ L, av.1 ≤ 1) (x y : ℝ) :
16
+ |fieldScalarMean L (fun z => Real.log (Real.cosh z)) Real.tanh x -
17
+ fieldScalarMean L (fun z => Real.log (Real.cosh z)) Real.tanh y| ≤ |x - y| := by
18
+ have hd z := hasDerivAt_fieldScalarLogCoshMean L hL z
19
+ have hb (z : ℝ) :
20
+ ‖fieldScalarSecond L (fun z => Real.log (Real.cosh z)) Real.tanh
21
+ (fun z => 1 / (Real.cosh z) ^ 2) z‖ ≤ 1 := by
22
+ rw [Real.norm_eq_abs, abs_of_pos (fieldScalarLogCoshSecond_pos L hL z)]
23
+ exact (fieldScalarLogCoshSecond_le_spin_variance L hL hζ z).trans
24
+ (sub_le_self _ (sq_nonneg _))
25
+ have hh := Convex.norm_image_sub_le_of_norm_hasDerivWithin_le
26
+ (s := (univ : Set ℝ)) (C := 1)
27
+ (fun z _ => (hd z).hasDerivWithinAt) (fun z _ => hb z)
28
+ convex_univ (mem_univ y) (mem_univ x)
29
+ simpa only [Real.norm_eq_abs, one_mul] using hh
30
+
31
+ end InvariantIsing
32
+
33
+ end
34
+
35
+ end OAI
lean/OAI/Probability/InvariantIsing/Fields/FieldSpinMeasurability.lean ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Probability.InvariantIsing.Fields.FieldSpinEvaluation
2
+
3
+ namespace OAI
4
+
5
+ /-! Measurability of the actual scalar-field spin test before averaging
6
+ the Gaussian root and the labeled forest. -/
7
+
8
+ noncomputable section
9
+ open MeasureTheory ProbabilityTheory IsingPerceptron
10
+
11
+ namespace InvariantIsing
12
+
13
+ instance fieldVectorCoordinateLaw_isProbabilityMeasure (N : ℕ) (h : FieldStep) :
14
+ IsProbabilityMeasure (fieldVectorCoordinateLaw N h) := by
15
+ unfold fieldVectorCoordinateLaw
16
+ infer_instance
17
+
18
+ def fieldSpinPairIntegrand (N : ℕ) (h : FieldStep) (z : Fin N → ℝ)
19
+ (p : LabeledTree h.depth × (ForestVertex h.depth → Fin N → ℝ))
20
+ (q : Fin (h.depth + 1) → ℝ) (Φ : ℝ → ℝ) (j : Fin N) : ℝ :=
21
+ referenceReplicaMean
22
+ ((uniformSpinPrior N : Measure (Spin N)).prod (labeledLeafLaw h.depth p.1))
23
+ (fun s : Spin N × LabeledLeaf h.depth =>
24
+ fieldEnergy (fieldVectorEndpoint N h p z s.2) s.1)
25
+ (fun σ : Fin 2 → Spin N × LabeledLeaf h.depth =>
26
+ Φ (q (fieldDepthLevel h (labeledCommonDepth h.depth (σ 0).2 (σ 1).2))) *
27
+ (spinValue ((σ 0).1 j) * spinValue ((σ 1).1 j)))
28
+
29
+ lemma measurable_fieldSpinPairIntegrand (N : ℕ) (h : FieldStep)
30
+ (q : Fin (h.depth + 1) → ℝ) (Φ : ℝ → ℝ) (j : Fin N) :
31
+ Measurable (fun p : (Fin N → ℝ) ×
32
+ (LabeledTree h.depth × (ForestVertex h.depth → Fin N → ℝ)) =>
33
+ fieldSpinPairIntegrand N h p.1 p.2 q Φ j) := by
34
+ let D : (Fin 2 → Spin N × LabeledLeaf h.depth) → ℝ := fun σ =>
35
+ Φ (q (fieldDepthLevel h (labeledCommonDepth h.depth (σ 0).2 (σ 1).2))) *
36
+ (spinValue ((σ 0).1 j) * spinValue ((σ 1).1 j))
37
+ have hm := measurable_cascadeCoordinateReplicaMean h.depth
38
+ (uniformSpinPrior N : Measure (Spin N)) (measurable_fieldEnergy_map N) D
39
+ have hc : Measurable (fun p : (Fin N → ℝ) ×
40
+ (LabeledTree h.depth × (ForestVertex h.depth → Fin N → ℝ)) =>
41
+ (p.1, fieldEnergyCoordinates N h p.2)) :=
42
+ measurable_fst.prodMk ((measurable_fieldEnergyCoordinates N h).comp measurable_snd)
43
+ have he (z : Fin N → ℝ)
44
+ (p : LabeledTree h.depth × (ForestVertex h.depth → Fin N → ℝ)) :
45
+ cascadeCoordinateEnergy h.depth (fieldEnergy z) (fieldEnergyCoordinates N h p) =
46
+ fun s => fieldEnergy (fieldVectorEndpoint N h p z s.2) s.1 :=
47
+ funext (fieldEnergyCoordinates_energy N h p z)
48
+ have hh := hm.comp hc
49
+ simp only [Function.comp_def] at hh
50
+ simp_rw [he] at hh
51
+ simpa only [labeledSpinReference, fieldEnergyCoordinates,
52
+ fieldSpinPairIntegrand, D] using hh
53
+
54
+ lemma fieldSpinPairIntegrand_abs_le (N : ℕ) (h : FieldStep)
55
+ (q : Fin (h.depth + 1) → ℝ) (Φ : ℝ → ℝ) (j : Fin N)
56
+ {C : ℝ} (hΦ : ∀ x, |Φ x| ≤ C) (z : Fin N → ℝ)
57
+ (p : LabeledTree h.depth × (ForestVertex h.depth → Fin N → ℝ)) :
58
+ |fieldSpinPairIntegrand N h z p q Φ j| ≤ C := by
59
+ have hC : 0 ≤ C := (abs_nonneg (Φ 0)).trans (hΦ 0)
60
+ apply referenceReplicaMean_abs_le _ _ _ (measurable_of_countable _) hC
61
+ intro σ
62
+ simpa only [abs_mul, abs_spinValue, mul_one, one_mul] using
63
+ hΦ (q (fieldDepthLevel h (labeledCommonDepth h.depth (σ 0).2 (σ 1).2)))
64
+
65
+ lemma measurable_fieldVectorSpinPairMean (N : ℕ) (h : FieldStep)
66
+ (q : Fin (h.depth + 1) → ℝ) (Φ : ℝ → ℝ) (j : Fin N) :
67
+ Measurable (fun z => fieldVectorSpinPairMean N h z q Φ j) :=
68
+ (measurable_fieldSpinPairIntegrand N h q Φ j).stronglyMeasurable.integral_prod_right'.measurable
69
+
70
+ end InvariantIsing
71
+
72
+ end
73
+
74
+ end OAI
lean/OAI/Probability/InvariantIsing/Fields/FieldSpinPairConditioning.lean ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Probability.InvariantIsing.Fields.FieldPublishedEvaluation
2
+ import OAI.Probability.InvariantIsing.Arrays.NSpinTensorPairConditioning
3
+
4
+ namespace OAI
5
+
6
+ /-! Physical spins conditional on the two scalar-field endpoints. -/
7
+
8
+ noncomputable section
9
+ open MeasureTheory ProbabilityTheory IsingPerceptron
10
+ open scoped BigOperators
11
+
12
+ namespace InvariantIsing
13
+
14
+ lemma field_two_gibbs_coordinate_mean {N : ℕ} (z : Fin 2 → Fin N → ℝ) (j : Fin N) :
15
+ (∫ σ : Fin 2 → Spin N, spinValue (σ 0 j) * spinValue (σ 1 j)
16
+ ∂Measure.pi (fun i => gibbsProbability (uniformSpinPrior N : Measure (Spin N))
17
+ (fieldEnergy (z i)))) = Real.tanh (z 0 j) * Real.tanh (z 1 j) := by
18
+ let μ := fun i : Fin 2 => gibbsProbability (uniformSpinPrior N : Measure (Spin N))
19
+ (fieldEnergy (z i))
20
+ have hm : Measurable (fun p : Spin N × Spin N => spinValue (p.1 j) * spinValue (p.2 j)) :=
21
+ measurable_of_finite _
22
+ have hp := (measurePreserving_piFinTwo μ).hasLaw.integral_comp hm.aestronglyMeasurable
23
+ simp only [Function.comp_apply, MeasurableEquiv.piFinTwo_apply] at hp
24
+ change (∫ σ : Fin 2 → Spin N, spinValue (σ 0 j) * spinValue (σ 1 j) ∂Measure.pi μ) = _
25
+ rw [hp, integral_prod_mul (fun σ : Spin N => spinValue (σ j))
26
+ (fun σ : Spin N => spinValue (σ j))]
27
+ exact congrArg₂ (fun a b : ℝ => a * b)
28
+ (fieldSpinGibbs_coordinate_mean (z 0) j) (fieldSpinGibbs_coordinate_mean (z 1) j)
29
+
30
+ theorem field_leaf_spin_pair_conditioning {N n : ℕ}
31
+ (ν : Measure (LabeledLeaf n)) [IsProbabilityMeasure ν]
32
+ (Y : LabeledLeaf n → Fin N → ℝ)
33
+ (he : Integrable (fun p : Spin N × LabeledLeaf n => Real.exp (fieldEnergy (Y p.2) p.1))
34
+ ((uniformSpinPrior N : Measure (Spin N)).prod ν))
35
+ (ψ : ℕ → ℝ) {C : ℝ} (hψ : ∀ d, |ψ d| ≤ C) (j : Fin N) :
36
+ referenceReplicaMean ((uniformSpinPrior N : Measure (Spin N)).prod ν)
37
+ (fun p => fieldEnergy (Y p.2) p.1)
38
+ (fun σ : Fin 2 → Spin N × LabeledLeaf n =>
39
+ ψ (labeledCommonDepth n (σ 0).2 (σ 1).2) *
40
+ (spinValue ((σ 0).1 j) * spinValue ((σ 1).1 j))) =
41
+ referenceReplicaMean ν (fun α => ∑ i, Real.log (Real.cosh (Y α i)))
42
+ (fun α : Fin 2 → LabeledLeaf n => ψ (labeledCommonDepth n (α 0) (α 1)) *
43
+ (Real.tanh (Y (α 0) j) * Real.tanh (Y (α 1) j))) := by
44
+ let H := fun p : Spin N × LabeledLeaf n => fieldEnergy (Y p.2) p.1
45
+ have ht : spinLeafTerminal H = (fun α => ∑ i, Real.log (Real.cosh (Y α i))) := by
46
+ funext α
47
+ change finiteLogIntegral (uniformSpinPrior N : Measure (Spin N)) (fieldEnergy (Y α)) = _
48
+ rw [finiteLogIntegral_uniformSpinPrior, logPartition_fieldEnergy]
49
+ have hb : ∃ C : ℝ, ∀ σ : Fin 2 → Spin N × LabeledLeaf n,
50
+ |ψ (labeledCommonDepth n (σ 0).2 (σ 1).2) *
51
+ (spinValue ((σ 0).1 j) * spinValue ((σ 1).1 j))| ≤ C := by
52
+ refine ⟨C, fun σ => ?_⟩
53
+ simpa only [abs_mul, abs_spinValue, one_mul, mul_one] using
54
+ hψ (labeledCommonDepth n (σ 0).2 (σ 1).2)
55
+ rw [spinLeafPair_conditioning ν H he _ hb, ht]
56
+ congr 1
57
+ funext α
58
+ change (∫ σ : Fin 2 → Spin N,
59
+ ψ (labeledCommonDepth n (α 0) (α 1)) * (spinValue (σ 0 j) * spinValue (σ 1 j))
60
+ ∂Measure.pi (fun i => gibbsProbability (uniformSpinPrior N : Measure (Spin N))
61
+ (fieldEnergy (Y (α i))))) = _
62
+ rw [integral_const_mul, field_two_gibbs_coordinate_mean]
63
+
64
+ end InvariantIsing
65
+
66
+ end
67
+
68
+ end OAI
lean/OAI/Probability/InvariantIsing/Fields/FieldSpinProduct.lean ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Probability.InvariantIsing.Fields.FieldSpinSampling
2
+ import OAI.Probability.InvariantIsing.Fields.SpinFactorization
3
+
4
+ namespace OAI
5
+
6
+ /-! The finite Ising spin law with a scalar field at each site factors
7
+ into the actual one-site Gibbs kernels, including its two-spin tests. -/
8
+
9
+ noncomputable section
10
+ open MeasureTheory ProbabilityTheory IsingPerceptron
11
+ open scoped BigOperators ENNReal
12
+
13
+ namespace InvariantIsing
14
+
15
+ lemma uniformSpinPrior_eq_product (N : ℕ) :
16
+ (uniformSpinPrior N : Measure (Spin N)) =
17
+ Measure.pi (fun _ : Fin N => (PMF.uniformOfFintype Bool).toMeasure) := by
18
+ apply Measure.ext_of_singleton
19
+ intro σ
20
+ rw [Measure.pi_singleton]
21
+ simp only [uniformSpinPrior, PMF.toMeasure_apply_singleton _ _ (measurableSet_singleton _),
22
+ PMF.uniformOfFintype_apply, Fintype.card_bool, Finset.prod_const, Finset.card_univ,
23
+ Fintype.card_fin]
24
+ simp [Spin, ENNReal.inv_pow]
25
+
26
+ theorem fieldSpinGibbs_eq_product {N : ℕ} (z : Fin N → ℝ) :
27
+ gibbsProbability (uniformSpinPrior N : Measure (Spin N)) (fieldEnergy z) =
28
+ Measure.pi (fun i => scalarSpinKernel (z i)) := by
29
+ let π : Measure Bool := (PMF.uniformOfFintype Bool).toMeasure
30
+ have hz (i : Fin N) : 0 < ∫ σ, Real.exp (z i * spinValue σ) ∂π :=
31
+ integral_exp_pos Integrable.of_finite
32
+ have hZ : referencePartition (uniformSpinPrior N : Measure (Spin N)) (fieldEnergy z) =
33
+ ∏ i, ∫ σ, Real.exp (z i * spinValue σ) ∂π := by
34
+ rw [referencePartition, uniformSpinPrior_eq_product]
35
+ simp only [fieldEnergy, Real.exp_sum]
36
+ exact integral_fintype_prod_eq_prod (fun i σ => Real.exp (z i * spinValue σ))
37
+ rw [gibbsProbability_eq_tilted _ _ Integrable.of_finite]
38
+ apply Measure.ext_of_singleton
39
+ intro σ
40
+ rw [tilted_singleton, hZ, uniformSpinPrior_eq_product, Measure.pi_singleton,
41
+ Measure.pi_singleton]
42
+ have hi (i : Fin N) : scalarSpinKernel (z i) = π.tilted (fun σ => z i * spinValue σ) :=
43
+ gibbsProbability_eq_tilted π _ Integrable.of_finite
44
+ simp_rw [hi, tilted_singleton]
45
+ simp only [referencePartition]
46
+ rw [Finset.prod_mul_distrib,
47
+ ← ENNReal.ofReal_prod_of_nonneg
48
+ (fun i _ => div_nonneg (Real.exp_pos _).le (hz i).le),
49
+ Finset.prod_div_distrib, fieldEnergy, Real.exp_sum]
50
+
51
+ theorem fieldSpinGibbs_coordinate_mean {N : ℕ} (z : Fin N → ℝ) (j : Fin N) :
52
+ (∫ σ, spinValue (σ j)
53
+ ∂gibbsProbability (uniformSpinPrior N : Measure (Spin N)) (fieldEnergy z)) =
54
+ Real.tanh (z j) := by
55
+ rw [fieldSpinGibbs_eq_product, integral_comp_eval]
56
+ · exact scalarSpinKernel_mean (z j)
57
+ · exact (measurable_of_finite spinValue).aestronglyMeasurable
58
+
59
+ theorem fieldSpinGibbs_pair_mean {N : ℕ} (z₁ z₂ : Fin N → ℝ) (j : Fin N) :
60
+ (∫ σ, spinValue (σ.1 j) * spinValue (σ.2 j)
61
+ ∂(gibbsProbability (uniformSpinPrior N : Measure (Spin N)) (fieldEnergy z₁)).prod
62
+ (gibbsProbability (uniformSpinPrior N : Measure (Spin N)) (fieldEnergy z₂))) =
63
+ Real.tanh (z₁ j) * Real.tanh (z₂ j) := by
64
+ rw [integral_prod_mul (fun σ : Spin N => spinValue (σ j))
65
+ (fun σ : Spin N => spinValue (σ j)),
66
+ fieldSpinGibbs_coordinate_mean, fieldSpinGibbs_coordinate_mean]
67
+
68
+ end InvariantIsing
69
+
70
+ end
71
+
72
+ end OAI
lean/OAI/Probability/InvariantIsing/Fields/FieldSpinProductLaw.lean ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Probability.InvariantIsing.Core.ProductKernelSampling
2
+
3
+ namespace OAI
4
+
5
+ /-! Exact product law of the canonical terminal spins after all Gaussian
6
+ transitions. -/
7
+
8
+ noncomputable section
9
+ open MeasureTheory ProbabilityTheory IsingPerceptron
10
+ open scoped NNReal
11
+
12
+ namespace InvariantIsing
13
+
14
+ theorem fieldVectorTailSpinKernel_product (N : ℕ) (L : List (ℝ × ℝ≥0))
15
+ (hL : ∀ av ∈ L, 0 < av.1) (z : Fin N → ℝ) :
16
+ fieldVectorTailSpinKernel N L hL z = Measure.pi (fun i => fieldTailSpinKernel L hL (z i)) := by
17
+ induction L generalizing z with
18
+ | nil => exact fieldSpinGibbs_eq_product z
19
+ | cons av L ih =>
20
+ have ht := fun bv hb => hL bv (List.mem_cons_of_mem av hb)
21
+ have hreg := fieldScalarValue_regular L ht measurable_logCosh logCosh_linearGrowth
22
+ change (fieldVectorTailSpinKernel N L ht ∘ₖ
23
+ fieldVectorTransitionKernel N av.1 av.2 _ hreg.1) z = _
24
+ rw [Kernel.comp_apply]
25
+ change fieldVectorTailSpinKernel N L ht ∘ₘ
26
+ Measure.pi (fun i => fieldTransitionKernel av.1 av.2 _ hreg.1 (z i)) = _
27
+ rw [product_kernel_comp_general (fieldTailSpinKernel L ht)
28
+ (fieldVectorTailSpinKernel N L ht) (ih ht)]
29
+ rfl
30
+
31
+ lemma paired_product_reorder {X : Type*} [MeasurableSpace X] (N : ℕ)
32
+ (ν : Fin N → Measure X) [∀ i, IsProbabilityMeasure (ν i)] :
33
+ ((Measure.pi ν).prod (Measure.pi ν)).map
34
+ (MeasurableEquiv.arrowProdEquivProdArrow X X (Fin N)).symm =
35
+ Measure.pi (fun i => (ν i).prod (ν i)) :=
36
+ (measurePreserving_arrowProdEquivProdArrow X X (Fin N) ν ν).symm.map_eq
37
+
38
+ end InvariantIsing
39
+
40
+ end
41
+
42
+ end OAI
lean/OAI/Probability/InvariantIsing/Fields/FieldSpinProjectionEnergy.lean ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Probability.InvariantIsing.Core.FiniteWeightedCauchy
2
+ import OAI.Probability.InvariantIsing.Fields.SpinHammingEnergy
3
+
4
+ namespace OAI
5
+
6
+ /-! Energy lost by projection in a possibly unbounded external field.
7
+ The Euclidean estimate is suited to averaging under Gaussian path laws. -/
8
+
9
+ noncomputable section
10
+ open scoped BigOperators
11
+
12
+ namespace InvariantIsing
13
+
14
+ lemma fieldEnergy_projection_sq {N : ℕ} (z : Fin N → ℝ) (σ τ : Spin N) :
15
+ (fieldEnergy z σ - fieldEnergy z τ) ^ 2 ≤
16
+ 4 * (∑ i, z i ^ 2) * (hammingDist σ τ : ℝ) := by
17
+ have he : fieldEnergy z σ - fieldEnergy z τ =
18
+ ∑ i, z i * (spinValue (σ i) - spinValue (τ i)) := by
19
+ simp only [fieldEnergy, mul_sub, Finset.sum_sub_distrib]
20
+ have hd : (∑ i, (spinValue (σ i) - spinValue (τ i)) ^ 2) =
21
+ 4 * (hammingDist σ τ : ℝ) := by
22
+ have h := spinVector_sub_norm_sq σ τ
23
+ rw [EuclideanSpace.real_norm_sq_eq] at h
24
+ exact h
25
+ rw [he]
26
+ have hc := Finset.sum_mul_sq_le_sq_mul_sq Finset.univ z
27
+ (fun i => spinValue (σ i) - spinValue (τ i))
28
+ rw [hd] at hc
29
+ nlinarith
30
+
31
+ theorem fieldEnergy_projection_mean_le {N : ℕ} (z : Fin N → ℝ)
32
+ (f : Spin N → Spin N) (p : Spin N → ℝ)
33
+ (hp : ∀ σ, 0 ≤ p σ) (hpSum : ∑ σ, p σ = 1) :
34
+ |∑ σ, p σ * (fieldEnergy z σ - fieldEnergy z (f σ))| ≤
35
+ 2 * Real.sqrt ((∑ i, z i ^ 2) *
36
+ (∑ σ, p σ * (hammingDist σ (f σ) : ℝ))) := by
37
+ have hz : 0 ≤ ∑ i, z i ^ 2 := Finset.sum_nonneg (fun i _ => sq_nonneg _)
38
+ have hd : 0 ≤ ∑ σ, p σ * (hammingDist σ (f σ) : ℝ) :=
39
+ Finset.sum_nonneg (fun σ _ => mul_nonneg (hp σ) (Nat.cast_nonneg _))
40
+ have he : (∑ σ, p σ * (fieldEnergy z σ - fieldEnergy z (f σ)) ^ 2) ≤
41
+ 4 * (∑ i, z i ^ 2) * (∑ σ, p σ * (hammingDist σ (f σ) : ℝ)) := by
42
+ calc
43
+ _ ≤ ∑ σ, p σ * (4 * (∑ i, z i ^ 2) * (hammingDist σ (f σ) : ℝ)) :=
44
+ Finset.sum_le_sum (fun σ _ => mul_le_mul_of_nonneg_left
45
+ (fieldEnergy_projection_sq z σ (f σ)) (hp σ))
46
+ _ = _ := by
47
+ conv_rhs => rw [Finset.mul_sum]
48
+ apply Finset.sum_congr rfl
49
+ intros
50
+ ring
51
+ apply (sq_le_sq₀ (abs_nonneg _) (by positivity)).mp
52
+ rw [sq_abs, mul_pow, Real.sq_sqrt (mul_nonneg hz hd)]
53
+ norm_num
54
+ exact (finite_weighted_sum_sq_le p
55
+ (fun σ => fieldEnergy z σ - fieldEnergy z (f σ)) hp hpSum).trans (by nlinarith [he])
56
+
57
+ end InvariantIsing
58
+
59
+ end
60
+
61
+ end OAI
lean/OAI/Probability/InvariantIsing/Fields/FieldSpinSampling.lean ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Probability.InvariantIsing.Fields.FieldScalarOverlap
2
+ import OAI.Probability.InvariantIsing.Arrays.NSpinTensorLabeled
3
+ import Mathlib.Probability.Kernel.Composition.IntegralCompProd
4
+
5
+ namespace OAI
6
+
7
+ /-! Actual spin sampling and Gaussian transitions for the scalar Ising
8
+ recursion. The transition kernels remain probabilities at zero variance. -/
9
+
10
+ noncomputable section
11
+ open MeasureTheory ProbabilityTheory IsingPerceptron
12
+ open scoped BigOperators NNReal
13
+
14
+ namespace InvariantIsing
15
+
16
+ def scalarSpinKernel : Kernel ℝ Bool :=
17
+ ⟨fun z => gibbsProbability (PMF.uniformOfFintype Bool).toMeasure
18
+ (fun σ => z * spinValue σ),
19
+ measurable_gibbsProbability
20
+ (ν := fun _ : ℝ => (PMF.uniformOfFintype Bool).toMeasure)
21
+ (H := fun p : ℝ × Bool => p.1 * spinValue p.2) measurable_const
22
+ (measurable_fst.mul ((measurable_of_finite spinValue).comp measurable_snd))⟩
23
+
24
+ instance scalarSpinKernel_markov : IsMarkovKernel scalarSpinKernel := by
25
+ constructor
26
+ intro z
27
+ change IsProbabilityMeasure (gibbsProbability (PMF.uniformOfFintype Bool).toMeasure
28
+ (fun σ => z * spinValue σ))
29
+ infer_instance
30
+
31
+ private lemma integral_uniformBool (f : Bool → ℝ) :
32
+ (∫ σ, f σ ∂(PMF.uniformOfFintype Bool).toMeasure) =
33
+ (2 : ℝ)⁻¹ * (f false + f true) := by
34
+ rw [integral_fintype (Integrable.of_finite)]
35
+ simp only [measureReal_def,
36
+ PMF.toMeasure_apply_singleton _ _ (measurableSet_singleton _),
37
+ PMF.uniformOfFintype_apply, Fintype.card_bool, ENNReal.toReal_inv,
38
+ smul_eq_mul, Fintype.sum_bool]
39
+ norm_num
40
+ ring
41
+
42
+ theorem scalarSpinKernel_mean (z : ℝ) :
43
+ (∫ σ, spinValue σ ∂scalarSpinKernel z) = Real.tanh z := by
44
+ change (∫ σ, spinValue σ ∂gibbsProbability
45
+ (PMF.uniformOfFintype Bool).toMeasure (fun σ => z * spinValue σ)) = _
46
+ rw [gibbsProbability_eq_tilted _ _ Integrable.of_finite,
47
+ integral_tilted_eq_div, integral_uniformBool, integral_uniformBool]
48
+ simp only [spinValue, Bool.false_eq_true, ite_false, ite_true, mul_neg_one, mul_one]
49
+ rw [Real.tanh_eq_sinh_div_cosh, Real.sinh_eq, Real.cosh_eq]
50
+ ring
51
+
52
+ def fieldTransitionKernel (ζ : ℝ) (v : ℝ≥0) (F : ℝ → ℝ) (hF : Measurable F) :
53
+ Kernel ℝ ℝ := by
54
+ have hν : Measurable (fun z : ℝ => gaussianReal z v) :=
55
+ measurable_gaussianReal.comp (measurable_id.prodMk measurable_const)
56
+ have hW : Measurable (fun p : ℝ × ℝ => ENNReal.ofReal (Real.exp (ζ * F p.2))) :=
57
+ (((hF.comp measurable_snd).const_mul ζ).exp.ennreal_ofReal)
58
+ have hm := measurable_normalizeMass.comp
59
+ (measurable_random_withDensity (ν := fun z : ℝ => gaussianReal z v) hν hW)
60
+ exact ⟨fun z => normalizeMass ((gaussianReal z v).withDensity
61
+ (fun u => ENNReal.ofReal (Real.exp (ζ * F u)))),
62
+ hm⟩
63
+
64
+ instance fieldTransitionKernel_markov (ζ : ℝ) (v : ℝ≥0)
65
+ (F : ℝ → ℝ) (hF : Measurable F) :
66
+ IsMarkovKernel (fieldTransitionKernel ζ v F hF) :=
67
+ ⟨fun _ => normalizeMass_probability _⟩
68
+
69
+ lemma fieldTransitionKernel_eq_tilted (ζ : ℝ) (v : ℝ≥0)
70
+ (F : ℝ → ℝ) (hF : Measurable F) (hG : HasLinearGrowth F) (z : ℝ) :
71
+ fieldTransitionKernel ζ v F hF z = (gaussianReal z v).tilted (fun u => ζ * F u) := by
72
+ exact normalizeMass_exp _ _ (hF.const_mul ζ)
73
+ (integrable_exp_of_linearGrowth _ (gaussianReal_exponentialNormMoments z v) hF hG ζ)
74
+
75
+ lemma fieldTransitionKernel_integral (ζ : ℝ) (v : ℝ≥0)
76
+ (F : ℝ → ℝ) (hF : Measurable F) (hG : HasLinearGrowth F)
77
+ (a : ℝ → ℝ) (z : ℝ) :
78
+ (∫ u, a u ∂fieldTransitionKernel ζ v F hF z) = fieldSpinTransition ζ v F a z := by
79
+ rw [fieldTransitionKernel_eq_tilted ζ v F hF hG z]
80
+ rfl
81
+
82
+ /-- Spin law at the end of the actual successive tilted Gaussian
83
+ transitions, starting from the given scalar field. -/
84
+ def fieldTailSpinKernel : (L : List (ℝ × ℝ≥0)) →
85
+ (∀ av ∈ L, 0 < av.1) → Kernel ℝ Bool
86
+ | [], _ => scalarSpinKernel
87
+ | av :: L, hL =>
88
+ let ht := fun bv hb => hL bv (List.mem_cons_of_mem av hb)
89
+ let hreg := fieldScalarValue_regular L ht measurable_logCosh logCosh_linearGrowth
90
+ fieldTailSpinKernel L ht ∘ₖ
91
+ fieldTransitionKernel av.1 av.2 (fieldScalarValue L (fun z => Real.log (Real.cosh z))) hreg.1
92
+
93
+ instance fieldTailSpinKernel_markov (L : List (ℝ × ℝ≥0))
94
+ (hL : ∀ av ∈ L, 0 < av.1) : IsMarkovKernel (fieldTailSpinKernel L hL) := by
95
+ induction L with
96
+ | nil => exact scalarSpinKernel_markov
97
+ | cons av L ih =>
98
+ have ht := fun bv hb => hL bv (List.mem_cons_of_mem av hb)
99
+ let _ := ih ht
100
+ change IsMarkovKernel (_ ∘ₖ _)
101
+ infer_instance
102
+
103
+ theorem fieldTailSpinKernel_mean (L : List (ℝ × ℝ≥0))
104
+ (hL : ∀ av ∈ L, 0 < av.1) (z : ℝ) :
105
+ (∫ σ, spinValue σ ∂fieldTailSpinKernel L hL z) =
106
+ fieldScalarMean L (fun u => Real.log (Real.cosh u)) Real.tanh z := by
107
+ induction L generalizing z with
108
+ | nil => exact scalarSpinKernel_mean z
109
+ | cons av L ih =>
110
+ have ht := fun bv hb => hL bv (List.mem_cons_of_mem av hb)
111
+ have hreg := fieldScalarValue_regular L ht measurable_logCosh logCosh_linearGrowth
112
+ change (∫ σ, spinValue σ ∂(fieldTailSpinKernel L ht ∘ₖ
113
+ fieldTransitionKernel av.1 av.2 (fieldScalarValue L (fun u => Real.log (Real.cosh u)))
114
+ hreg.1) z) = _
115
+ rw [Kernel.integral_comp (Integrable.of_finite)]
116
+ simp_rw [ih ht]
117
+ exact fieldTransitionKernel_integral av.1 av.2 _ hreg.1 hreg.2 _ z
118
+
119
+ end InvariantIsing
120
+
121
+ end
122
+
123
+ end OAI
lean/OAI/Probability/InvariantIsing/Fields/FieldSpinSecondDerivative.lean ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Probability.InvariantIsing.Fields.FieldTiltAverageDerivative
2
+
3
+ namespace OAI
4
+
5
+ /-! The derivative of the actual scalar spin transition, with a
6
+ linearly growing potential. -/
7
+
8
+ noncomputable section
9
+ open MeasureTheory ProbabilityTheory IsingPerceptron Filter Set
10
+ open scoped NNReal Topology
11
+
12
+ namespace InvariantIsing
13
+
14
+ theorem hasDerivAt_fieldSpinTransition (ζ : ℝ) (v : ℝ≥0)
15
+ {F D a b : ℝ → ℝ} (hF : Measurable F) (hG : HasLinearGrowth F)
16
+ (hD : Measurable D) (ha : Measurable a) (hb : Measurable b)
17
+ {C M L : ℝ} (hC : 0 ≤ C) (hM : 0 ≤ M)
18
+ (hDb : ∀ u, |D u| ≤ C) (hab : ∀ u, |a u| ≤ M) (hbb : ∀ u, |b u| ≤ L)
19
+ (hd : ∀ u, HasDerivAt F (D u) u) (had : ∀ u, HasDerivAt a (b u) u)
20
+ (z : ℝ) :
21
+ HasDerivAt (fieldSpinTransition ζ v F a)
22
+ (fieldSpinTransition ζ v F b z + ζ *
23
+ (fieldSpinTransition ζ v F (fun u => a u * D u) z -
24
+ fieldSpinTransition ζ v F a z * fieldSpinTransition ζ v F D z)) z := by
25
+ have hi := integrable_exp_of_linearGrowth (gaussianReal 0 v)
26
+ (gaussianReal_exponentialNormMoments 0 v)
27
+ (hF.comp (measurable_const.add measurable_id)) (hG.add_left z) ζ
28
+ have hd' (s u : ℝ) : HasDerivAt (fun q => F (q + u)) (D (s + u)) s := by
29
+ convert (hd (s + u)).comp s ((hasDerivAt_id s).add_const u) using 1 <;>
30
+ first | rfl | simp only [mul_one]
31
+ have ha' (s u : ℝ) : HasDerivAt (fun q => a (q + u)) (b (s + u)) s := by
32
+ convert (had (s + u)).comp s ((hasDerivAt_id s).add_const u) using 1 <;>
33
+ first | rfl | simp only [mul_one]
34
+ have h := hasDerivAt_tiltAverage_of_bounded_derivatives (gaussianReal 0 v)
35
+ (fun s u => F (s + u)) (fun s u => a (s + u))
36
+ (fun s u => D (s + u)) (fun s u => b (s + u))
37
+ (fun s => hF.comp (measurable_const.add measurable_id))
38
+ (fun s => ha.comp (measurable_const.add measurable_id))
39
+ (fun s => hD.comp (measurable_const.add measurable_id))
40
+ (fun s => hb.comp (measurable_const.add measurable_id))
41
+ hC hM (fun s u => hDb (s + u)) (fun s u => hab (s + u))
42
+ (fun s u => hbb (s + u)) hd' ha' ζ z hi
43
+ have he : fieldSpinTransition ζ v F a =
44
+ fun s => ∫ u, a (s + u) ∂(gaussianReal 0 v).tilted (fun u => ζ * F (s + u)) := by
45
+ funext s
46
+ exact fieldSpinTransition_eq_shifted ζ v hF ha s
47
+ have hADm : Measurable (fun u => a u * D u) := ha.mul hD
48
+ rw [he, fieldSpinTransition_eq_shifted ζ v hF hb,
49
+ fieldSpinTransition_eq_shifted ζ v hF hADm,
50
+ fieldSpinTransition_eq_shifted ζ v hF hD]
51
+ exact h
52
+
53
+ lemma fieldSpinTransition_derivative_bound (ζ : ℝ) (v : ℝ≥0)
54
+ {F D a b : ℝ → ℝ} (hF : Measurable F) (hG : HasLinearGrowth F)
55
+ {C M L : ℝ} (_hC : 0 ≤ C) (hM : 0 ≤ M)
56
+ (hDb : ∀ u, |D u| ≤ C) (hab : ∀ u, |a u| ≤ M) (hbb : ∀ u, |b u| ≤ L)
57
+ (z : ℝ) :
58
+ |fieldSpinTransition ζ v F b z + ζ *
59
+ (fieldSpinTransition ζ v F (fun u => a u * D u) z -
60
+ fieldSpinTransition ζ v F a z * fieldSpinTransition ζ v F D z)| ≤
61
+ L + 2 * |ζ| * M * C := by
62
+ have hAD : ∀ u, |a u * D u| ≤ M * C := fun u => by
63
+ rw [abs_mul]
64
+ exact mul_le_mul (hab u) (hDb u) (abs_nonneg _) hM
65
+ have hb' := fieldSpinTransition_bound ζ v hF hG hbb z
66
+ have ha' := fieldSpinTransition_bound ζ v hF hG hab z
67
+ have hd' := fieldSpinTransition_bound ζ v hF hG hDb z
68
+ have had' := fieldSpinTransition_bound ζ v hF hG hAD z
69
+ refine (abs_add_le _ _).trans (add_le_add hb' ?_)
70
+ rw [abs_mul]
71
+ calc
72
+ _ ≤ |ζ| * (|fieldSpinTransition ζ v F (fun u => a u * D u) z| +
73
+ |fieldSpinTransition ζ v F a z * fieldSpinTransition ζ v F D z|) :=
74
+ mul_le_mul_of_nonneg_left (abs_sub _ _) (abs_nonneg ζ)
75
+ _ ≤ |ζ| * (M * C + M * C) := by
76
+ apply mul_le_mul_of_nonneg_left _ (abs_nonneg ζ)
77
+ apply add_le_add had'
78
+ rw [abs_mul]
79
+ exact mul_le_mul ha' hd' (abs_nonneg _) hM
80
+ _ = _ := by ring
81
+
82
+ end InvariantIsing
83
+
84
+ end
85
+
86
+ end OAI
lean/OAI/Probability/InvariantIsing/Fields/FieldSpinTransition.lean ADDED
@@ -0,0 +1,159 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Probability.InvariantIsing.Fields.FieldSpinKernelOrder
2
+ import Mathlib.Probability.Moments.Variance
3
+
4
+ namespace OAI
5
+
6
+ /-! The scalar physical-spin transition and its bounded martingale
7
+ properties, including degenerate covariance increments. -/
8
+
9
+ noncomputable section
10
+ open MeasureTheory ProbabilityTheory IsingPerceptron Set
11
+ open scoped NNReal
12
+
13
+ namespace InvariantIsing
14
+
15
+ def fieldSpinTransition (ζ : ℝ) (v : ℝ≥0) (F a : ℝ → ℝ) (z : ℝ) : ℝ :=
16
+ ∫ u, a u ∂(gaussianReal z v).tilted (fun u => ζ * F u)
17
+
18
+ lemma fieldSpinTransition_zero_variance (ζ : ℝ) (F a : ℝ → ℝ) (z : ℝ) :
19
+ fieldSpinTransition ζ 0 F a z = a z := by
20
+ rw [fieldSpinTransition, integral_tilted_eq_div, gaussianReal_zero_var]
21
+ simp only [integral_dirac]
22
+ exact mul_div_cancel_left₀ (a z) (Real.exp_ne_zero _)
23
+
24
+ lemma fieldSpinTransition_eq_standard (ζ : ℝ) (v : ℝ≥0) {F a : ℝ → ℝ}
25
+ (hF : Measurable F) (ha : Measurable a) (z : ℝ) :
26
+ fieldSpinTransition ζ v F a z = gaussianTiltAverage v ζ F a z := by
27
+ rw [fieldSpinTransition, integral_tilted_eq_div, gaussianTiltAverage_eq_div]
28
+ have hnum : Measurable (fun u => Real.exp (ζ * F u) * a u) := (hF.const_mul ζ).exp.mul ha
29
+ have hden : Measurable (fun u => Real.exp (ζ * F u)) := (hF.const_mul ζ).exp
30
+ rw [field_gaussian_integral_shift v z hnum, field_gaussian_integral_shift v z hden]
31
+ have hnums : Measurable (fun u => Real.exp (ζ * F (z + u)) * a (z + u)) :=
32
+ hnum.comp (measurable_const.add measurable_id)
33
+ have hdens : Measurable (fun u => Real.exp (ζ * F (z + u))) :=
34
+ hden.comp (measurable_const.add measurable_id)
35
+ rw [integral_gaussianReal_zero_eq_standard v
36
+ (F := fun u => Real.exp (ζ * F (z + u)) * a (z + u)) hnums,
37
+ integral_gaussianReal_zero_eq_standard v
38
+ (F := fun u => Real.exp (ζ * F (z + u))) hdens]
39
+
40
+ lemma measurable_fieldSpinTransition (ζ : ℝ) (v : ℝ≥0) {F a : ℝ → ℝ}
41
+ (hF : Measurable F) (ha : Measurable a) :
42
+ Measurable (fieldSpinTransition ζ v F a) := by
43
+ have hnum : Measurable (fun p : ℝ × ℝ =>
44
+ Real.exp (ζ * F (p.1 + Real.sqrt (v : ℝ) * p.2)) *
45
+ a (p.1 + Real.sqrt (v : ℝ) * p.2)) := by fun_prop
46
+ have hden : Measurable (fun p : ℝ × ℝ =>
47
+ Real.exp (ζ * F (p.1 + Real.sqrt (v : ℝ) * p.2))) := by fun_prop
48
+ have he : fieldSpinTransition ζ v F a = fun z =>
49
+ (∫ u, Real.exp (ζ * F (z + Real.sqrt (v : ℝ) * u)) *
50
+ a (z + Real.sqrt (v : ℝ) * u) ∂gaussianReal 0 1) /
51
+ (∫ u, Real.exp (ζ * F (z + Real.sqrt (v : ℝ) * u)) ∂gaussianReal 0 1) := by
52
+ funext z
53
+ rw [fieldSpinTransition_eq_standard ζ v hF ha z, gaussianTiltAverage_eq_div]
54
+ rw [he]
55
+ exact hnum.stronglyMeasurable.integral_prod_right'.measurable.div
56
+ hden.stronglyMeasurable.integral_prod_right'.measurable
57
+
58
+ lemma fieldSpinTransition_bound (ζ : ℝ) (v : ℝ≥0) {F a : ℝ → ℝ}
59
+ (hF : Measurable F) (hgrowth : HasLinearGrowth F)
60
+ {B : ℝ} (haB : ∀ u, |a u| ≤ B) (z : ℝ) :
61
+ |fieldSpinTransition ζ v F a z| ≤ B := by
62
+ have hw := integrable_exp_of_linearGrowth _ (gaussianReal_exponentialNormMoments z v) hF hgrowth ζ
63
+ have : IsProbabilityMeasure ((gaussianReal z v).tilted (fun u => ζ * F u)) :=
64
+ MeasureTheory.isProbabilityMeasure_tilted hw
65
+ have hb := norm_integral_le_of_norm_le_const (f := a) (C := B)
66
+ (μ := (gaussianReal z v).tilted (fun u => ζ * F u))
67
+ (Filter.Eventually.of_forall (fun u => by simpa only [Real.norm_eq_abs] using haB u))
68
+ simpa only [fieldSpinTransition, Real.norm_eq_abs, measureReal_def, measure_univ,
69
+ ENNReal.toReal_one, mul_one] using hb
70
+
71
+ lemma fieldSpinTransition_square_le (ζ : ℝ) (v : ℝ≥0) {F a : ℝ → ℝ}
72
+ (hF : Measurable F) (hgrowth : HasLinearGrowth F) (ha : Measurable a)
73
+ {B : ℝ} (haB : ∀ u, |a u| ≤ B) (z : ℝ) :
74
+ (fieldSpinTransition ζ v F a z) ^ 2 ≤
75
+ fieldSpinTransition ζ v F (fun u => (a u) ^ 2) z := by
76
+ have hw := integrable_exp_of_linearGrowth _ (gaussianReal_exponentialNormMoments z v) hF hgrowth ζ
77
+ have : IsProbabilityMeasure ((gaussianReal z v).tilted (fun u => ζ * F u)) :=
78
+ MeasureTheory.isProbabilityMeasure_tilted hw
79
+ have hm : MemLp a 2 ((gaussianReal z v).tilted (fun u => ζ * F u)) :=
80
+ MemLp.of_bound ha.aestronglyMeasurable B
81
+ (Filter.Eventually.of_forall (fun u => by simpa only [Real.norm_eq_abs] using haB u))
82
+ have hv := variance_nonneg a ((gaussianReal z v).tilted (fun u => ζ * F u))
83
+ rw [variance_eq_sub hm] at hv
84
+ change 0 ≤ fieldSpinTransition ζ v F (fun u => (a u) ^ 2) z -
85
+ (fieldSpinTransition ζ v F a z) ^ 2 at hv
86
+ linarith
87
+
88
+ lemma fieldSpinTransition_odd (ζ : ℝ) (v : ℝ≥0) {F a : ℝ → ℝ}
89
+ (hF : Measurable F) (hEven : Function.Even F)
90
+ (ha : Measurable a) (hOdd : Function.Odd a) :
91
+ Function.Odd (fieldSpinTransition ζ v F a) := by
92
+ intro z
93
+ rw [fieldSpinTransition, fieldSpinTransition, integral_tilted_eq_div, integral_tilted_eq_div]
94
+ have hnum : Measurable (fun u => Real.exp (ζ * F u) * a u) := (hF.const_mul ζ).exp.mul ha
95
+ have hn : (∫ u, Real.exp (ζ * F u) * a u ∂gaussianReal (-z) v) =
96
+ -(∫ u, Real.exp (ζ * F u) * a u ∂gaussianReal z v) := by
97
+ rw [← gaussianReal_map_neg (μ := z) (v := v),
98
+ integral_map measurable_neg.aemeasurable hnum.aestronglyMeasurable]
99
+ calc
100
+ _ = ∫ u, -(Real.exp (ζ * F u) * a u) ∂gaussianReal z v := by
101
+ apply integral_congr_ae
102
+ exact Filter.Eventually.of_forall (fun u => by
103
+ change Real.exp (ζ * F (-u)) * a (-u) = -(Real.exp (ζ * F u) * a u)
104
+ rw [hEven u, hOdd u]
105
+ ring)
106
+ _ = _ := integral_neg _
107
+ have hd := field_gaussian_integral_reflect v z (hF.const_mul ζ).exp
108
+ (fun u => by rw [hEven u])
109
+ rw [hn, hd, neg_div]
110
+
111
+ lemma fieldSpinTransition_nonneg (ζ : ℝ) (v : ℝ≥0)
112
+ {F a : ℝ → ℝ} (hF : Measurable F) (hEven : Function.Even F)
113
+ (hgrowth : HasLinearGrowth F) (ha : Measurable a) (hOdd : Function.Odd a)
114
+ (hapos : ∀ u ∈ Ici (0 : ℝ), 0 ≤ a u)
115
+ {B : ℝ} (haB : ∀ u, |a u| ≤ B) {z : ℝ} (hz : 0 ≤ z) :
116
+ 0 ≤ fieldSpinTransition ζ v F a z := by
117
+ by_cases hv : v = 0
118
+ · subst v
119
+ rw [fieldSpinTransition_zero_variance]
120
+ exact hapos z hz
121
+ have he := field_gaussian_tilt_odd_eq_abs v hv z ζ F a hF hEven hgrowth ha hOdd haB
122
+ rw [fieldSpinTransition, he]
123
+ apply integral_nonneg
124
+ intro u
125
+ exact mul_nonneg (hapos |u| (abs_nonneg u))
126
+ (field_tanh_nonneg (mul_nonneg (div_nonneg hz v.coe_nonneg) (abs_nonneg u)))
127
+
128
+ lemma fieldSpinTransition_monotone {ζ : ℝ} (hζ : 0 ≤ ζ) (v : ℝ≥0)
129
+ {F a : ℝ → ℝ} (hF : Measurable F) (hEven : Function.Even F)
130
+ (hgrowth : HasLinearGrowth F) (ha : Measurable a) (hOdd : Function.Odd a)
131
+ (hamono : MonotoneOn a (Ici 0)) (hapos : ∀ u ∈ Ici (0 : ℝ), 0 ≤ a u)
132
+ {B : ℝ} (haB : ∀ u, |a u| ≤ B) :
133
+ MonotoneOn (fieldSpinTransition ζ v F a) (Ici 0) := by
134
+ by_cases hv : v = 0
135
+ · subst v
136
+ intro x hx y hy hxy
137
+ rw [fieldSpinTransition_zero_variance, fieldSpinTransition_zero_variance]
138
+ exact hamono hx hy hxy
139
+ intro x hx y _hy hxy
140
+ exact field_gaussian_spin_transition_order v hv hζ F F a a hF hF hEven hEven hgrowth hgrowth
141
+ (by intro u _ w _ _; simp only [sub_self, le_refl])
142
+ ha ha hOdd hOdd hamono hapos (fun _ _ => le_rfl) haB haB hx hxy
143
+
144
+ lemma fieldSpinTransition_mono_test (ζ : ℝ) (v : ℝ≥0) (F : ℝ → ℝ)
145
+ {a b : ℝ → ℝ} (ha : Measurable a) (hb : Measurable b) {A B : ℝ}
146
+ (haB : ∀ u, |a u| ≤ A) (hbB : ∀ u, |b u| ≤ B)
147
+ (hab : ∀ u, a u ≤ b u) (z : ℝ) :
148
+ fieldSpinTransition ζ v F a z ≤ fieldSpinTransition ζ v F b z := by
149
+ exact integral_mono
150
+ (Integrable.of_bound ha.aestronglyMeasurable A
151
+ (Filter.Eventually.of_forall (fun u => by simpa only [Real.norm_eq_abs] using haB u)))
152
+ (Integrable.of_bound hb.aestronglyMeasurable B
153
+ (Filter.Eventually.of_forall (fun u => by simpa only [Real.norm_eq_abs] using hbB u))) hab
154
+
155
+ end InvariantIsing
156
+
157
+ end
158
+
159
+ end OAI
lean/OAI/Probability/InvariantIsing/Fields/FieldSpinVariance.lean ADDED
@@ -0,0 +1,119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Probability.InvariantIsing.Fields.FieldSpinLipschitz
2
+ import OAI.Probability.InvariantIsing.Fields.FieldGaussianTiltMoments
3
+
4
+ namespace OAI
5
+
6
+ /-! A quantitative conditional-variance bound for a Lipschitz spin
7
+ mean. The constant depends only on an upper bound for the Gaussian
8
+ variance, rather than on the depth of the scalar recursion. -/
9
+
10
+ noncomputable section
11
+ open MeasureTheory ProbabilityTheory IsingPerceptron Set
12
+ open scoped NNReal
13
+
14
+ namespace InvariantIsing
15
+
16
+ lemma fieldGaussianMomentCap_nonneg {C : ℝ} (hC : 0 ≤ C) : 0 ≤ fieldGaussianMomentCap C := by
17
+ have hb := (field_centered_tilt_second_moment (U := fun _ => 0) measurable_const
18
+ (C := C) (fun u => by simpa using mul_nonneg hC (abs_nonneg u))).2
19
+ exact (integral_nonneg (fun u => sq_nonneg (1 + |u|))).trans hb
20
+
21
+ lemma field_centered_spin_variance {U M : ℝ → ℝ}
22
+ (hU : Measurable U) (hM : Measurable M)
23
+ (hMb : ∀ z, |M z| ≤ 1) (hML : ∀ x y, |M x - M y| ≤ |x - y|)
24
+ {C : ℝ} (hUb : ∀ u, |U u| ≤ C * |u|) (x : ℝ) (v : ℝ≥0) :
25
+ variance (fun u => M (x + Real.sqrt (v : ℝ) * u)) ((gaussianReal 0 1).tilted U) ≤
26
+ (v : ℝ) * fieldGaussianMomentCap C := by
27
+ let μ := (gaussianReal 0 1).tilted U
28
+ have he : Integrable (fun u => Real.exp (U u)) (gaussianReal 0 1) := by
29
+ apply (gaussianReal_exponentialNormMoments 0 1 C).mono' hU.exp.aestronglyMeasurable
30
+ exact ae_of_all _ fun u => by
31
+ rw [Real.norm_eq_abs, abs_of_pos (Real.exp_pos _), Real.norm_eq_abs]
32
+ exact Real.exp_le_exp.mpr ((le_abs_self _).trans (hUb u))
33
+ let : IsProbabilityMeasure μ := isProbabilityMeasure_tilted he
34
+ let X := fun u => M (x + Real.sqrt (v : ℝ) * u)
35
+ have hmX : Measurable X := hM.comp (by fun_prop)
36
+ have hmD : AEStronglyMeasurable (fun u => X u - M x) μ :=
37
+ (hmX.sub_const _).aestronglyMeasurable
38
+ have hLp : MemLp (fun u => X u - M x) 2 μ :=
39
+ MemLp.of_bound hmD 2 (ae_of_all _ fun u => by
40
+ rw [Real.norm_eq_abs]
41
+ exact (abs_sub _ _).trans (by dsimp only [X]; linarith [hMb (x + Real.sqrt (v : ℝ) * u), hMb x]))
42
+ obtain ⟨hi, hb⟩ := field_centered_tilt_second_moment hU hUb
43
+ have hp (u : ℝ) : (X u - M x)^2 ≤ (v : ℝ) * (1 + |u|)^2 := by
44
+ have hl : |X u - M x| ≤ Real.sqrt (v : ℝ) * |u| := by
45
+ simpa only [X, add_sub_cancel_left, abs_mul, abs_of_nonneg (Real.sqrt_nonneg _)] using
46
+ hML (x + Real.sqrt (v : ℝ) * u) x
47
+ have hs := pow_le_pow_left₀ (abs_nonneg _) hl 2
48
+ rw [sq_abs, mul_pow, Real.sq_sqrt v.coe_nonneg] at hs
49
+ exact hs.trans (mul_le_mul_of_nonneg_left
50
+ (pow_le_pow_left₀ (abs_nonneg u) (by linarith : |u| ≤ 1 + |u|) 2) v.coe_nonneg)
51
+ calc
52
+ variance X μ = variance (fun u => X u - M x) μ :=
53
+ (variance_sub_const hmX.aestronglyMeasurable (M x)).symm
54
+ _ ≤ ∫ u, (X u - M x)^2 ∂μ := variance_le_expectation_sq hmD
55
+ _ ≤ ∫ u, (v : ℝ) * (1 + |u|)^2 ∂μ := integral_mono hLp.integrable_sq (hi.const_mul _) hp
56
+ _ = (v : ℝ) * ∫ u, (1 + |u|)^2 ∂μ := integral_const_mul _ _
57
+ _ ≤ (v : ℝ) * fieldGaussianMomentCap C := mul_le_mul_of_nonneg_left hb v.coe_nonneg
58
+
59
+ lemma fieldSpinTransition_centered_standard (ζ : ℝ) (v : ℝ≥0) {F M : ℝ → ℝ}
60
+ (hF : Measurable F) (hM : Measurable M) (x : ℝ) :
61
+ fieldSpinTransition ζ v F M x =
62
+ ∫ u, M (x + Real.sqrt (v : ℝ) * u)
63
+ ∂(gaussianReal 0 1).tilted (fun u => ζ * (F (x + Real.sqrt (v : ℝ) * u) - F x)) := by
64
+ rw [fieldSpinTransition_eq_standard ζ v hF hM, gaussianTiltAverage_eq_div,
65
+ integral_tilted_eq_div]
66
+ simp_rw [mul_sub, Real.exp_sub, div_mul_eq_mul_div]
67
+ rw [integral_div, integral_div, div_div_div_cancel_right₀ (Real.exp_ne_zero _)]
68
+
69
+ lemma fieldSpinTransition_variance_bound (ζ : ℝ) (v : ℝ≥0) {F M : ℝ → ℝ}
70
+ (hF : Measurable F) (hM : Measurable M)
71
+ (hMb : ∀ z, |M z| ≤ 1) (hML : ∀ x y, |M x - M y| ≤ |x - y|)
72
+ (x : ℝ) {C : ℝ}
73
+ (hUb : ∀ u, |ζ * (F (x + Real.sqrt (v : ℝ) * u) - F x)| ≤ C * |u|) :
74
+ fieldSpinTransition ζ v F (fun z => (M z)^2) x -
75
+ (fieldSpinTransition ζ v F M x)^2 ≤ (v : ℝ) * fieldGaussianMomentCap C := by
76
+ let U := fun u => ζ * (F (x + Real.sqrt (v : ℝ) * u) - F x)
77
+ have hU : Measurable U := by dsimp only [U]; fun_prop
78
+ have he : Integrable (fun u => Real.exp (U u)) (gaussianReal 0 1) := by
79
+ apply (gaussianReal_exponentialNormMoments 0 1 C).mono' hU.exp.aestronglyMeasurable
80
+ exact ae_of_all _ fun u => by
81
+ rw [Real.norm_eq_abs, abs_of_pos (Real.exp_pos _), Real.norm_eq_abs]
82
+ exact Real.exp_le_exp.mpr ((le_abs_self _).trans (hUb u))
83
+ let μ := (gaussianReal 0 1).tilted U
84
+ let : IsProbabilityMeasure μ := isProbabilityMeasure_tilted he
85
+ have hm : Measurable (fun u => M (x + Real.sqrt (v : ℝ) * u)) := hM.comp (by fun_prop)
86
+ have hLp : MemLp (fun u => M (x + Real.sqrt (v : ℝ) * u)) 2 μ :=
87
+ MemLp.of_bound hm.aestronglyMeasurable 1 (ae_of_all _ fun u => by
88
+ simpa only [Real.norm_eq_abs] using hMb (x + Real.sqrt (v : ℝ) * u))
89
+ rw [fieldSpinTransition_centered_standard ζ v hF (hM.pow_const 2),
90
+ fieldSpinTransition_centered_standard ζ v hF hM]
91
+ change (∫ u, (M (x + Real.sqrt (v : ℝ) * u))^2 ∂μ) -
92
+ (∫ u, M (x + Real.sqrt (v : ℝ) * u) ∂μ)^2 ≤ _
93
+ have heq := variance_eq_sub hLp
94
+ simp only [Pi.pow_apply] at heq
95
+ rw [← heq]
96
+ exact field_centered_spin_variance hU hM hMb hML hUb x v
97
+
98
+ lemma fieldSpinTransition_variance_le (ζ : ℝ) (hζ : ζ ∈ Icc 0 1) (v : ℝ≥0)
99
+ {V : ℝ} (hv : (v : ℝ) ≤ V) {F M : ℝ → ℝ}
100
+ (hF : Measurable F) (hFL : ∀ x y, |F x - F y| ≤ |x - y|)
101
+ (hM : Measurable M) (hMb : ∀ z, |M z| ≤ 1)
102
+ (hML : ∀ x y, |M x - M y| ≤ |x - y|) (x : ℝ) :
103
+ fieldSpinTransition ζ v F (fun z => (M z)^2) x -
104
+ (fieldSpinTransition ζ v F M x)^2 ≤ (v : ℝ) * fieldGaussianMomentCap (Real.sqrt V) := by
105
+ apply fieldSpinTransition_variance_bound ζ v hF hM hMb hML x
106
+ intro u
107
+ rw [abs_mul, abs_of_nonneg hζ.1]
108
+ have hf : |F (x + Real.sqrt (v : ℝ) * u) - F x| ≤ Real.sqrt V * |u| := by
109
+ have hh := hFL (x + Real.sqrt (v : ℝ) * u) x
110
+ simp only [add_sub_cancel_left, abs_mul, abs_of_nonneg (Real.sqrt_nonneg _)] at hh
111
+ exact hh.trans (mul_le_mul_of_nonneg_right (Real.sqrt_le_sqrt hv) (abs_nonneg u))
112
+ exact (mul_le_mul_of_nonneg_left hf hζ.1).trans
113
+ (mul_le_of_le_one_left (mul_nonneg (Real.sqrt_nonneg _) (abs_nonneg _)) hζ.2)
114
+
115
+ end InvariantIsing
116
+
117
+ end
118
+
119
+ end OAI
lean/OAI/Probability/InvariantIsing/Fields/FieldSquarePrefix.lean ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Probability.InvariantIsing.Fields.FieldScalarComposition
2
+
3
+ namespace OAI
4
+
5
+ /-! Composition of an earlier conditional spin square with an unchanged
6
+ later scalar recursion. This keeps the ordinary Gaussian root separate. -/
7
+
8
+ noncomputable section
9
+ open IsingPerceptron
10
+ open scoped NNReal
11
+
12
+ namespace InvariantIsing
13
+
14
+ def fieldPrefixIndex (P S : List (ℝ × ℝ≥0)) (i : Fin (P.length + 1)) :
15
+ Fin ((P ++ S).length + 1) :=
16
+ ⟨i.val, by simp only [List.length_append]; omega⟩
17
+
18
+ lemma fieldScalarSquares_append_prefix (P S : List (ℝ × ℝ≥0)) (F a : ℝ → ℝ)
19
+ (i : Fin (P.length + 1)) :
20
+ fieldScalarSquares (P ++ S) F a (fieldPrefixIndex P S i) =
21
+ fieldScalarSquares P (fieldScalarValue S F) (fieldScalarMean S F a) i := by
22
+ induction P with
23
+ | nil =>
24
+ have hi : i = 0 := by
25
+ apply Fin.ext
26
+ change i.val = 0
27
+ have hi := i.isLt
28
+ simp only [List.length_nil, zero_add] at hi
29
+ omega
30
+ subst i
31
+ have he : fieldPrefixIndex [] S 0 = 0 := by apply Fin.ext; rfl
32
+ rw [he]
33
+ funext z
34
+ simp only [List.nil_append, fieldScalarSquares_zero, fieldScalarSquares]
35
+ | cons av P ih =>
36
+ refine Fin.cases ?_ (fun j => ?_) i
37
+ · have he : fieldPrefixIndex (av :: P) S 0 = 0 := by apply Fin.ext; rfl
38
+ rw [he]
39
+ funext z
40
+ rw [fieldScalarSquares_zero, fieldScalarSquares_zero, fieldScalarMean_append]
41
+ · have he : fieldPrefixIndex (av :: P) S j.succ = (fieldPrefixIndex P S j).succ := by
42
+ apply Fin.ext
43
+ rfl
44
+ rw [he]
45
+ change fieldSpinTransition av.1 av.2 (fieldScalarValue (P ++ S) F)
46
+ (fieldScalarSquares (P ++ S) F a (fieldPrefixIndex P S j)) = _
47
+ rw [fieldScalarValue_append, ih]
48
+ rfl
49
+
50
+ end InvariantIsing
51
+
52
+ end
53
+
54
+ end OAI
lean/OAI/Probability/InvariantIsing/Fields/FieldTail.lean ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Probability.InvariantIsing.Fields.FieldLipschitzTransport
2
+
3
+ namespace OAI
4
+
5
+ /-! The excess of the absolute field above a cutoff is a one-Lipschitz tail test. -/
6
+ noncomputable section
7
+ open MeasureTheory ProbabilityTheory Filter Set
8
+ open scoped Topology
9
+ namespace InvariantIsing
10
+
11
+ def fieldTail (M x : ℝ) : ℝ := max (|x|-M) 0
12
+
13
+ lemma fieldTail_lipschitz (M : ℝ) : LipschitzWith 1 (fieldTail M) := by
14
+ apply LipschitzWith.of_dist_le_mul
15
+ intro x y
16
+ simp only [Real.dist_eq,NNReal.coe_one,one_mul,fieldTail]
17
+ have hh := abs_max_sub_max_le_max (|x|-M) 0 (|y|-M) 0
18
+ simp only [sub_sub_sub_cancel_right,sub_self,abs_zero] at hh
19
+ rw [max_eq_left (abs_nonneg (|x|-|y|))] at hh
20
+ exact hh.trans (abs_abs_sub_abs_le_abs_sub x y)
21
+
22
+ lemma fieldTail_nonneg (M x : ℝ) : 0 ≤ fieldTail M x := le_max_right _ _
23
+
24
+ lemma fieldTail_le_abs {M : ℝ} (hM : 0 ≤ M) (x : ℝ) : fieldTail M x ≤ |x| :=
25
+ max_le (by linarith) (abs_nonneg _)
26
+
27
+ lemma fieldTail_integral_tendsto (μ : Measure ℝ)
28
+ (hμ : Integrable (fun x : ℝ => x) μ) :
29
+ Tendsto (fun n : ℕ => ∫ x, fieldTail n x ∂μ) atTop (𝓝 0) := by
30
+ have ht : Tendsto (fun n : ℕ => ∫ x, fieldTail n x ∂μ) atTop (𝓝 (∫ _x : ℝ, (0 : ℝ) ∂μ)) := by
31
+ apply tendsto_integral_of_dominated_convergence (fun x : ℝ => |x|)
32
+ · intro n
33
+ exact (fieldTail_lipschitz n).continuous.measurable.aestronglyMeasurable
34
+ · exact hμ.abs
35
+ · intro n
36
+ exact ae_of_all _ fun x => by
37
+ rw [Real.norm_eq_abs,abs_of_nonneg (fieldTail_nonneg _ _)]
38
+ exact fieldTail_le_abs (Nat.cast_nonneg n) x
39
+ · apply ae_of_all
40
+ intro x
41
+ have he : ∀ᶠ n : ℕ in atTop, |x| ≤ (n : ℝ) :=
42
+ tendsto_natCast_atTop_atTop.eventually (eventually_ge_atTop |x|)
43
+ apply tendsto_const_nhds.congr'
44
+ filter_upwards [he] with n hn
45
+ exact (max_eq_right (sub_nonpos.mpr hn)).symm
46
+ simpa only [integral_zero] using ht
47
+
48
+ lemma fieldTail_integral_tendsto_of_wasserstein
49
+ (μ : ProbabilityMeasure ℝ) (μs : ℕ → ProbabilityMeasure ℝ)
50
+ (hμ : Integrable (fun x : ℝ => x) (μ : Measure ℝ))
51
+ (hμs : ∀ n, Integrable (fun x : ℝ => x) (μs n : Measure ℝ))
52
+ (hw : Tendsto (fun n => fieldWassersteinOne (μs n) μ) atTop (𝓝 0)) (M : ℝ) :
53
+ Tendsto (fun n => ∫ x, fieldTail M x ∂(μs n : Measure ℝ)) atTop
54
+ (𝓝 (∫ x, fieldTail M x ∂(μ : Measure ℝ))) :=
55
+ integral_tendsto_of_fieldWasserstein μ μs hμ hμs hw (fieldTail_lipschitz M)
56
+
57
+ end InvariantIsing
58
+
59
+ end
60
+
61
+ end OAI
lean/OAI/Probability/InvariantIsing/Fields/FieldTailMgf.lean ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Probability.InvariantIsing.Core.KernelExponentialBound
2
+ import OAI.Probability.InvariantIsing.Fields.FieldIncrementMgf
3
+
4
+ namespace OAI
5
+
6
+ /-! Canonical endpoint exponential moments depend only on the sum of
7
+ increment variances. Arbitrarily small positive exponents and arbitrarily
8
+ many levels are allowed. -/
9
+
10
+ noncomputable section
11
+ open MeasureTheory ProbabilityTheory IsingPerceptron
12
+ open scoped NNReal
13
+
14
+ namespace InvariantIsing
15
+
16
+ def fieldTailVariance (L : List (ℝ × ℝ≥0)) : ℝ :=
17
+ (L.map (fun av => (av.2 : ℝ))).sum
18
+
19
+ lemma fieldTransitionKernel_integrable_exp (v : ℝ≥0) (z b t : ℝ)
20
+ (F : ℝ → ℝ) (hF : Measurable F) (hG : HasLinearGrowth F) :
21
+ Integrable (fun y => Real.exp (t * y)) (fieldTransitionKernel b v F hF z) := by
22
+ rw [fieldTransitionKernel_eq_tilted b v F hF hG]
23
+ apply integrable_exp_of_linearGrowth _
24
+ (exponentialNormMoments_tilted (gaussianReal z v)
25
+ (gaussianReal_exponentialNormMoments z v) F hF hG b) measurable_id
26
+ refine ⟨0, 1, le_rfl, zero_le_one, ?_⟩
27
+ intro x
28
+ simp [Real.norm_eq_abs]
29
+
30
+ theorem fieldTailEndpointKernel_mgf (L : List (ℝ × ℝ≥0))
31
+ (hL : ∀ av ∈ L, 0 < av.1) (hB : ∀ av ∈ L, av.1 ≤ 1) (t z : ℝ) :
32
+ Integrable (fun y => Real.exp (t * y)) (fieldTailEndpointKernel L hL z) ∧
33
+ (∫ y, Real.exp (t * y) ∂fieldTailEndpointKernel L hL z) ≤
34
+ Real.exp (t * z + (t ^ 2 / 2 + |t|) * fieldTailVariance L) := by
35
+ induction L generalizing z with
36
+ | nil =>
37
+ constructor
38
+ · change Integrable (fun y => Real.exp (t * y)) (Measure.dirac z)
39
+ exact integrable_dirac (by simp)
40
+ · simp [fieldTailEndpointKernel, Kernel.id_apply, fieldTailVariance]
41
+ | cons av L ih =>
42
+ have ht := fun bv hb => hL bv (List.mem_cons_of_mem av hb)
43
+ have hBt := fun bv hb => hB bv (List.mem_cons_of_mem av hb)
44
+ have hreg := fieldScalarValue_regular L ht measurable_logCosh logCosh_linearGrowth
45
+ have hκ (x : ℝ) := And.intro
46
+ (fieldTransitionKernel_integrable_exp av.2 x av.1 t _ hreg.1 hreg.2)
47
+ (fieldScalarTransition_mgf L ht av.2 x av.1 t
48
+ (hL av (List.mem_cons_self)).le (hB av (List.mem_cons_self)))
49
+ have he := kernel_exp_bound_comp
50
+ (fieldTransitionKernel av.1 av.2 (fieldScalarValue L (fun y => Real.log (Real.cosh y))) hreg.1)
51
+ (fieldTailEndpointKernel L ht) t ((t ^ 2 / 2 + |t|) * av.2)
52
+ ((t ^ 2 / 2 + |t|) * fieldTailVariance L) hκ (ih ht hBt) z
53
+ refine ⟨he.1, he.2.trans_eq ?_⟩
54
+ congr 1
55
+ simp only [fieldTailVariance, List.map_cons, List.sum_cons]
56
+ ring
57
+
58
+ end InvariantIsing
59
+
60
+ end
61
+
62
+ end OAI
lean/OAI/Probability/InvariantIsing/Fields/FieldTangentOrder.lean ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Probability.InvariantIsing.Fields.FieldConstantPrefix
2
+ import OAI.Probability.InvariantIsing.Fields.FieldEvenTransition
3
+
4
+ namespace OAI
5
+
6
+ /-! Evenness and radial antitonicity of a backward covariance derivative
7
+ are preserved by each unchanged earlier Gaussian transition. -/
8
+
9
+ noncomputable section
10
+ open MeasureTheory ProbabilityTheory IsingPerceptron Set
11
+ open scoped NNReal
12
+
13
+ namespace InvariantIsing
14
+
15
+ lemma field_gaussianTiltAverage_even (s ζ : ℝ) {F A : ℝ → ℝ}
16
+ (hF : Measurable F) (hFe : Function.Even F)
17
+ (hA : Measurable A) (hAe : Function.Even A) :
18
+ Function.Even (gaussianTiltAverage s ζ F A) := by
19
+ rw [field_gaussianTiltAverage_eq_transition s ζ hF hA]
20
+ exact fieldSpinTransition_even ζ (Real.toNNReal s) hF hFe hA hAe
21
+
22
+ lemma field_gaussianTiltAverage_even_monotone (s ζ : ℝ) {F A : ℝ → ℝ}
23
+ (hF : Measurable F) (hFe : Function.Even F) (hFg : HasLinearGrowth F)
24
+ (hA : Measurable A) (hAe : Function.Even A) (hAm : MonotoneOn A (Ici 0))
25
+ {K : ℝ} (hAb : ∀ y, |A y| ≤ K) :
26
+ MonotoneOn (gaussianTiltAverage s ζ F A) (Ici 0) := by
27
+ rw [field_gaussianTiltAverage_eq_transition s ζ hF hA]
28
+ exact fieldSpinTransition_even_monotone ζ (Real.toNNReal s) hF hFe hFg hA hAe hAm hAb
29
+
30
+ lemma field_gaussianTiltAverage_even_antitone (s ζ : ℝ) {F A : ℝ → ℝ}
31
+ (hF : Measurable F) (hFe : Function.Even F) (hFg : HasLinearGrowth F)
32
+ (hA : Measurable A) (hAe : Function.Even A) (hAm : AntitoneOn A (Ici 0))
33
+ {K : ℝ} (hAb : ∀ y, |A y| ≤ K) :
34
+ AntitoneOn (gaussianTiltAverage s ζ F A) (Ici 0) := by
35
+ have hm : Measurable (fun y => -A y) := hA.neg
36
+ have he : Function.Even (fun y => -A y) := fun y => by
37
+ dsimp only
38
+ rw [hAe y]
39
+ have hb : ∀ y, |-A y| ≤ K := fun y => by simpa only [abs_neg] using hAb y
40
+ have hn : MonotoneOn (fun y => -A y) (Ici 0) :=
41
+ fun _ hx _ hy hxy => neg_le_neg (hAm hx hy hxy)
42
+ have h := field_gaussianTiltAverage_even_monotone s ζ hF hFe hFg hm he hn hb
43
+ have hneg (z : ℝ) : gaussianTiltAverage s ζ F (fun y => -A y) z =
44
+ -gaussianTiltAverage s ζ F A z := by
45
+ simpa only [neg_one_mul] using field_gaussianTiltAverage_const_mul s ζ hF hA (-1) z
46
+ intro x hx y hy hxy
47
+ have hh := h hx hy hxy
48
+ rw [hneg, hneg] at hh
49
+ exact neg_le_neg_iff.mp hh
50
+
51
+ lemma field_negative_square_average_shape (s ζ k : ℝ) (hk : 0 ≤ k)
52
+ {F X : ℝ → ℝ} (hF : Measurable F) (hFe : Function.Even F)
53
+ (hFg : HasLinearGrowth F) (hX : Measurable X) (hXo : Function.Odd X)
54
+ (hXm : MonotoneOn X (Ici 0)) (hXp : ∀ y ∈ Ici (0 : ℝ), 0 ≤ X y)
55
+ {K : ℝ} (hXb : ∀ y, |X y| ≤ K) :
56
+ Function.Even (fun z => -k * gaussianTiltAverage s ζ F (fun y => (X y) ^ 2) z) ∧
57
+ AntitoneOn (fun z => -k * gaussianTiltAverage s ζ F (fun y => (X y) ^ 2) z) (Ici 0) := by
58
+ have he : Function.Even (fun y => (X y) ^ 2) := by
59
+ intro y
60
+ dsimp only
61
+ rw [hXo y, neg_sq]
62
+ have hm : MonotoneOn (fun y => (X y) ^ 2) (Ici 0) := by
63
+ intro x hx y hy hxy
64
+ exact pow_le_pow_left₀ (hXp x hx) (hXm hx hy hxy) 2
65
+ have hb : ∀ y, |(X y) ^ 2| ≤ K ^ 2 := fun y => by
66
+ rw [abs_pow]
67
+ exact pow_le_pow_left₀ (abs_nonneg _) (hXb y) 2
68
+ have hJ := field_gaussianTiltAverage_even s ζ hF hFe (hX.pow_const 2) he
69
+ have hJm := field_gaussianTiltAverage_even_monotone s ζ hF hFe hFg
70
+ (hX.pow_const 2) he hm hb
71
+ refine ⟨fun z => by dsimp only; rw [hJ z], ?_⟩
72
+ intro x hx y hy hxy
73
+ exact mul_le_mul_of_nonpos_left (hJm hx hy hxy) (neg_nonpos.mpr hk)
74
+
75
+ namespace FieldSmoothFamily
76
+
77
+ theorem zero_slope_tangent_shape {I : Set ℝ} (F : FieldSmoothFamily I)
78
+ (a ζ t : ℝ) (ht : t ∈ I)
79
+ (hUe : Function.Even (fun z => F.U (t, z)))
80
+ (hTe : Function.Even (fun z => F.T (t, z)))
81
+ (hTa : AntitoneOn (fun z => F.T (t, z)) (Ici 0)) :
82
+ Function.Even (fun z => F.tangent a 0 ζ (t, z)) ∧
83
+ AntitoneOn (fun z => F.tangent a 0 ζ (t, z)) (Ici 0) := by
84
+ have hU : Measurable (fun z => F.U (t, z)) := F.mU.comp (by fun_prop)
85
+ have hT : Measurable (fun z => F.T (t, z)) := F.mT.comp (by fun_prop)
86
+ simp only [tangent, zero_mul, zero_div, add_zero]
87
+ exact ⟨field_gaussianTiltAverage_even a ζ hU hUe hT hTe,
88
+ field_gaussianTiltAverage_even_antitone a ζ hU hUe (F.growth t) hT hTe hTa
89
+ (fun z => F.bT (t, z) ht)⟩
90
+
91
+ end FieldSmoothFamily
92
+
93
+ end InvariantIsing
94
+
95
+ end
96
+
97
+ end OAI
lean/OAI/Probability/InvariantIsing/Fields/FieldTerminalGenerator.lean ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Probability.InvariantIsing.Fields.FieldSpinLinear
2
+ import OAI.Probability.InvariantIsing.Fields.FieldScalarLogCoshSecond
3
+
4
+ namespace OAI
5
+
6
+ /-! The terminal Ising identity gives the constant term at the last
7
+ covariance level of the backward derivative. -/
8
+
9
+ noncomputable section
10
+ open MeasureTheory ProbabilityTheory IsingPerceptron
11
+ open scoped NNReal
12
+
13
+ namespace InvariantIsing
14
+
15
+ lemma field_tanh_generator_one (z : ℝ) :
16
+ 1 / (Real.cosh z) ^ 2 + (Real.tanh z) ^ 2 = 1 := by
17
+ rw [Real.tanh_eq_sinh_div_cosh]
18
+ have h := Real.cosh_sq_sub_sinh_sq z
19
+ field_simp [(Real.cosh_pos z).ne']
20
+ nlinarith
21
+
22
+ lemma field_tanh_generator (ζ z : ℝ) :
23
+ 1 / (Real.cosh z) ^ 2 + ζ * (Real.tanh z) ^ 2 =
24
+ 1 + (ζ - 1) * (Real.tanh z) ^ 2 := by
25
+ have h := field_tanh_generator_one z
26
+ nlinarith
27
+
28
+ lemma fieldSpinTransition_terminal_generator (ζ : ℝ) (v : ℝ≥0) (z : ℝ) :
29
+ fieldSpinTransition ζ v (fun x => Real.log (Real.cosh x))
30
+ (fun x => 1 / (Real.cosh x) ^ 2 + ζ * (Real.tanh x) ^ 2) z =
31
+ 1 + (ζ - 1) * fieldSpinTransition ζ v (fun x => Real.log (Real.cosh x))
32
+ (fun x => (Real.tanh x) ^ 2) z := by
33
+ have ht : Measurable (fun x : ℝ => (Real.tanh x) ^ 2) := by
34
+ simp only [Real.tanh_eq]
35
+ fun_prop
36
+ have hB : ∀ x : ℝ, |(ζ - 1) * (Real.tanh x) ^ 2| ≤ |ζ - 1| := by
37
+ intro x
38
+ rw [abs_mul, abs_pow]
39
+ have hsq : |Real.tanh x| ^ 2 ≤ 1 := by
40
+ simpa only [one_pow] using pow_le_pow_left₀ (abs_nonneg _) (field_abs_tanh_le_one x) 2
41
+ exact (mul_le_mul_of_nonneg_left hsq (abs_nonneg _)).trans_eq (mul_one _)
42
+ have he : (fun x => 1 / (Real.cosh x) ^ 2 + ζ * (Real.tanh x) ^ 2) =
43
+ (fun x => (1 : ℝ) + (ζ - 1) * (Real.tanh x) ^ 2) := by
44
+ funext x
45
+ exact field_tanh_generator ζ x
46
+ have hm : Measurable (fun x : ℝ => (ζ - 1) * (Real.tanh x) ^ 2) :=
47
+ ht.const_mul (ζ - 1)
48
+ rw [he, fieldSpinTransition_add (A := 1) ζ v measurable_logCosh logCosh_linearGrowth
49
+ measurable_const hm (fun _ => by norm_num) hB,
50
+ fieldSpinTransition_const ζ v measurable_logCosh logCosh_linearGrowth,
51
+ fieldSpinTransition_const_mul]
52
+
53
+ end InvariantIsing
54
+
55
+ end
56
+
57
+ end OAI
lean/OAI/Probability/InvariantIsing/Fields/FieldTerminalOne.lean ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Probability.InvariantIsing.Fields.FieldGaussianTerminal
2
+
3
+ namespace OAI
4
+
5
+ /-! Appending an exponent-one terminal increment changes the scalar
6
+ value by its Gaussian constant and preserves every earlier spin moment. -/
7
+
8
+ noncomputable section
9
+ open MeasureTheory ProbabilityTheory IsingPerceptron
10
+ open scoped NNReal
11
+
12
+ namespace InvariantIsing
13
+
14
+ private lemma squares_cons_succ (av : ℝ × ℝ≥0) (L : List (ℝ × ℝ≥0))
15
+ (F a : ℝ → ℝ) (i : Fin (L.length + 1)) :
16
+ fieldScalarSquares (av :: L) F a i.succ =
17
+ fieldSpinTransition av.1 av.2 (fieldScalarValue L F) (fieldScalarSquares L F a i) := rfl
18
+
19
+ lemma fieldScalarValue_const_add (L : List (ℝ × ℝ≥0))
20
+ (hL : ∀ av ∈ L, 0 < av.1) {F : ℝ → ℝ}
21
+ (hF : Measurable F) (hG : HasLinearGrowth F) (c : ℝ) :
22
+ fieldScalarValue L (fun z => c + F z) = fun z => c + fieldScalarValue L F z := by
23
+ induction L with
24
+ | nil => rfl
25
+ | cons av L ih =>
26
+ have ht := fun bv hb => hL bv (List.mem_cons_of_mem av hb)
27
+ have hv := fieldScalarValue_regular L ht hF hG
28
+ change gaussianOperator av.1 av.2 (fieldScalarValue L (fun z => c + F z)) = _
29
+ rw [ih ht]
30
+ funext z
31
+ exact gaussianOperator_const_add hv.1 hv.2 c av.1 av.2 z
32
+
33
+ lemma fieldScalarMean_const_add (L : List (ℝ × ℝ≥0))
34
+ (hL : ∀ av ∈ L, 0 < av.1) {F a : ℝ → ℝ}
35
+ (hF : Measurable F) (hG : HasLinearGrowth F) (c : ℝ) :
36
+ fieldScalarMean L (fun z => c + F z) a = fieldScalarMean L F a := by
37
+ induction L with
38
+ | nil => rfl
39
+ | cons av L ih =>
40
+ have ht := fun bv hb => hL bv (List.mem_cons_of_mem av hb)
41
+ change fieldSpinTransition av.1 av.2 (fieldScalarValue L (fun z => c + F z))
42
+ (fieldScalarMean L (fun z => c + F z) a) = _
43
+ rw [fieldScalarValue_const_add L ht hF hG c, ih ht]
44
+ funext z
45
+ exact fieldSpinTransition_const_add av.1 av.2 (fieldScalarValue L F) _ c z
46
+
47
+ lemma fieldScalarValue_terminal_one (L : List (ℝ × ℝ≥0))
48
+ (hL : ∀ av ∈ L, 0 < av.1) (v : ℝ≥0) :
49
+ fieldScalarValue (L ++ [(1, v)]) (fun z => Real.log (Real.cosh z)) =
50
+ fun z => v / 2 + fieldScalarValue L (fun z => Real.log (Real.cosh z)) z := by
51
+ have he : fieldScalarValue (L ++ [(1, v)]) (fun z => Real.log (Real.cosh z)) =
52
+ fieldScalarValue L (fun z => v / 2 + Real.log (Real.cosh z)) := by
53
+ simp only [fieldScalarValue, List.foldr_append, List.foldr_cons, List.foldr_nil]
54
+ congr 1
55
+ funext z
56
+ exact gaussianOperator_one_logCosh v z
57
+ rw [he]
58
+ exact fieldScalarValue_const_add L hL measurable_logCosh logCosh_linearGrowth _
59
+
60
+ lemma fieldScalarMean_terminal_one (L : List (ℝ × ℝ≥0))
61
+ (hL : ∀ av ∈ L, 0 < av.1) (v : ℝ≥0) :
62
+ fieldScalarMean (L ++ [(1, v)]) (fun z => Real.log (Real.cosh z)) Real.tanh =
63
+ fieldScalarMean L (fun z => Real.log (Real.cosh z)) Real.tanh := by
64
+ induction L with
65
+ | nil =>
66
+ funext z
67
+ exact fieldSpinTransition_one_tanh v z
68
+ | cons av L ih =>
69
+ have ht := fun bv hb => hL bv (List.mem_cons_of_mem av hb)
70
+ simp only [List.cons_append, fieldScalarMean]
71
+ rw [fieldScalarValue_terminal_one L ht v, ih ht]
72
+ funext z
73
+ exact fieldSpinTransition_const_add av.1 av.2 _ _ (v / 2) z
74
+
75
+ lemma fieldScalarSquares_terminal_one (L : List (ℝ × ℝ≥0))
76
+ (hL : ∀ av ∈ L, 0 < av.1) (v : ℝ≥0) (i : ℕ) (hi : i ≤ L.length) :
77
+ fieldScalarSquares (L ++ [(1, v)]) (fun z => Real.log (Real.cosh z)) Real.tanh
78
+ ⟨i, by simp only [List.length_append, List.length_singleton]; omega⟩ =
79
+ fieldScalarSquares L (fun z => Real.log (Real.cosh z)) Real.tanh
80
+ ⟨i, by omega⟩ := by
81
+ induction L generalizing i with
82
+ | nil =>
83
+ have hi0 : i = 0 := by simpa using hi
84
+ subst i
85
+ funext z
86
+ change (fieldSpinTransition 1 v (fun z => Real.log (Real.cosh z)) Real.tanh z) ^ 2 =
87
+ (Real.tanh z) ^ 2
88
+ rw [fieldSpinTransition_one_tanh]
89
+ | cons av L ih =>
90
+ have ht := fun bv hb => hL bv (List.mem_cons_of_mem av hb)
91
+ cases i with
92
+ | zero =>
93
+ funext z
94
+ change (fieldScalarMean ((av :: L) ++ [(1, v)]) (fun z => Real.log (Real.cosh z))
95
+ Real.tanh z) ^ 2 = (fieldScalarMean (av :: L) (fun z => Real.log (Real.cosh z))
96
+ Real.tanh z) ^ 2
97
+ rw [fieldScalarMean_terminal_one (av :: L) hL v]
98
+ | succ i =>
99
+ have hiL : i ≤ L.length := Nat.le_of_succ_le_succ hi
100
+ simp only [List.cons_append]
101
+ have hleft : (⟨i + 1, by simp only [List.length_cons, List.length_append]; omega⟩ :
102
+ Fin ((av :: (L ++ [(1, v)])).length + 1)) =
103
+ (⟨i, by simp only [List.length_append, List.length_singleton]; omega⟩ :
104
+ Fin ((L ++ [(1, v)]).length + 1)).succ := rfl
105
+ have hright : (⟨i + 1, by simp only [List.length_cons]; omega⟩ : Fin ((av :: L).length + 1)) =
106
+ (⟨i, by omega⟩ : Fin (L.length + 1)).succ := rfl
107
+ rw [hleft, hright, squares_cons_succ, squares_cons_succ]
108
+ rw [fieldScalarValue_terminal_one L ht v, ih ht i hiL]
109
+ funext z
110
+ exact fieldSpinTransition_const_add av.1 av.2 _ _ (v / 2) z
111
+
112
+ end InvariantIsing
113
+
114
+ end
115
+
116
+ end OAI
lean/OAI/Probability/InvariantIsing/Fields/FieldTerminalOrder.lean ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Probability.InvariantIsing.Fields.FieldAdjacentOrder
2
+ import OAI.Probability.InvariantIsing.Fields.FieldTerminalGenerator
3
+
4
+ namespace OAI
5
+
6
+ /-! The final covariance coordinate has the same mixed monotonicity;
7
+ its backward derivative has the additional constant one half. -/
8
+
9
+ noncomputable section
10
+ open MeasureTheory ProbabilityTheory IsingPerceptron Set
11
+ open scoped NNReal
12
+
13
+ namespace InvariantIsing
14
+
15
+ def fieldTerminalFamily (a ζ : ℝ) : FieldSmoothFamily (Ioi (-a)) :=
16
+ (fieldLogCoshFamily (Ioi (-a))).transform isOpen_Ioi a 1 ζ (fun t ht => by
17
+ have h : -a < t := ht
18
+ linarith)
19
+
20
+ lemma fieldTerminalFamily_value_eq_operator (a ζ t : ℝ) :
21
+ (fun z => (fieldTerminalFamily a ζ).U (t, z)) =
22
+ gaussianOperator ζ (Real.toNNReal (a + t)) (fun y => Real.log (Real.cosh y)) := by
23
+ funext z
24
+ change gaussianTransform (a + 1 * t) ζ (fun y => Real.log (Real.cosh y)) z = _
25
+ rw [one_mul, field_gaussianTransform_eq_operator]
26
+
27
+ lemma fieldTerminalFamily_mean_eq_transition (a ζ t : ℝ) :
28
+ (fun z => (fieldTerminalFamily a ζ).X (t, z)) =
29
+ fieldSpinTransition ζ (Real.toNNReal (a + t))
30
+ (fun y => Real.log (Real.cosh y)) Real.tanh := by
31
+ have hm : Measurable (fun y : ℝ => Real.tanh y) := by
32
+ simp only [Real.tanh_eq]
33
+ fun_prop
34
+ funext z
35
+ change gaussianTiltAverage (a + 1 * t) ζ (fun y => Real.log (Real.cosh y)) Real.tanh z = _
36
+ rw [one_mul, field_gaussianTiltAverage_eq_transition _ _ measurable_logCosh hm]
37
+
38
+ theorem fieldTerminalFamily_tangent (a ζ t z : ℝ) :
39
+ (fieldTerminalFamily a ζ).T (t, z) = (1 : ℝ) / 2 - (1 - ζ) / 2 *
40
+ gaussianTiltAverage (a + t) ζ (fun y => Real.log (Real.cosh y))
41
+ (fun y => (Real.tanh y) ^ 2) z := by
42
+ have hm : Measurable (fun y : ℝ => 1 / (Real.cosh y) ^ 2 + ζ * (Real.tanh y) ^ 2) := by
43
+ simp only [Real.tanh_eq]
44
+ fun_prop
45
+ have hx : Measurable (fun y : ℝ => (Real.tanh y) ^ 2) := by
46
+ simp only [Real.tanh_eq]
47
+ fun_prop
48
+ have hgen := fieldSpinTransition_terminal_generator ζ (Real.toNNReal (a + t)) z
49
+ rw [← field_gaussianTiltAverage_eq_transition (a + t) ζ measurable_logCosh hm,
50
+ ← field_gaussianTiltAverage_eq_transition (a + t) ζ measurable_logCosh hx] at hgen
51
+ change gaussianTiltAverage (a + 1 * t) ζ (fun y => Real.log (Real.cosh y)) (fun _ => 0) z +
52
+ (1 : ℝ) / 2 * gaussianTiltAverage (a + 1 * t) ζ
53
+ (fun y => Real.log (Real.cosh y))
54
+ (fun y => 1 / (Real.cosh y) ^ 2 + ζ * (Real.tanh y) ^ 2) z = _
55
+ rw [one_mul, field_gaussianTiltAverage_const _ _ measurable_logCosh logCosh_linearGrowth,
56
+ hgen]
57
+ ring
58
+
59
+ theorem fieldTerminalFamily_tangent_antitone (a ζ : ℝ) (hζ : ζ ≤ 1) (t : ℝ) :
60
+ AntitoneOn (fun z => (fieldTerminalFamily a ζ).T (t, z)) (Ici 0) := by
61
+ have he : Function.Even (fun y : ℝ => Real.log (Real.cosh y)) := by
62
+ intro y
63
+ simp only [Real.cosh_neg]
64
+ have hm : Measurable (fun y : ℝ => Real.tanh y) := by
65
+ simp only [Real.tanh_eq]
66
+ fun_prop
67
+ have h := field_negative_square_average_shape (a + t) ζ ((1 - ζ) / 2) (by linarith)
68
+ measurable_logCosh he logCosh_linearGrowth hm Real.tanh_neg
69
+ (field_tanh_monotone.monotoneOn _) (fun _ hy => field_tanh_nonneg hy)
70
+ field_abs_tanh_le_one
71
+ intro x hx y hy hxy
72
+ dsimp only
73
+ rw [fieldTerminalFamily_tangent, fieldTerminalFamily_tangent]
74
+ have hh := h.2 hx hy hxy
75
+ dsimp only at hh
76
+ linarith
77
+
78
+ theorem fieldTerminalFamily_shape (a ζ : ℝ) (hζ : 0 ≤ ζ) (t : ℝ) :
79
+ Function.Even (fun z => (fieldTerminalFamily a ζ).U (t, z)) ∧
80
+ Function.Odd (fun z => (fieldTerminalFamily a ζ).X (t, z)) ∧
81
+ MonotoneOn (fun z => (fieldTerminalFamily a ζ).X (t, z)) (Ici 0) ∧
82
+ (∀ z ∈ Ici (0 : ℝ), 0 ≤ (fieldTerminalFamily a ζ).X (t, z)) ∧
83
+ (∀ z, |(fieldTerminalFamily a ζ).X (t, z)| ≤ 1) := by
84
+ have he : Function.Even (fun y : ℝ => Real.log (Real.cosh y)) := by
85
+ intro y
86
+ simp only [Real.cosh_neg]
87
+ have hm : Measurable (fun y : ℝ => Real.tanh y) := by
88
+ simp only [Real.tanh_eq]
89
+ fun_prop
90
+ have hval := fieldTerminalFamily_value_eq_operator a ζ t
91
+ have hmean := fieldTerminalFamily_mean_eq_transition a ζ t
92
+ have hmeanPoint (z : ℝ) := congrFun hmean z
93
+ refine ⟨?_, ?_, ?_, ?_, ?_⟩
94
+ · rw [hval]
95
+ exact gaussianOperator_even ζ _ measurable_logCosh he
96
+ · rw [hmean]
97
+ exact fieldSpinTransition_odd ζ _ measurable_logCosh he hm Real.tanh_neg
98
+ · rw [hmean]
99
+ exact fieldSpinTransition_monotone hζ _ measurable_logCosh he logCosh_linearGrowth
100
+ hm Real.tanh_neg (field_tanh_monotone.monotoneOn _)
101
+ (fun _ hz => field_tanh_nonneg hz) field_abs_tanh_le_one
102
+ · intro z hz
103
+ rw [hmeanPoint]
104
+ exact fieldSpinTransition_nonneg ζ _ measurable_logCosh he logCosh_linearGrowth
105
+ hm Real.tanh_neg (fun _ hy => field_tanh_nonneg hy) field_abs_tanh_le_one hz
106
+ · intro z
107
+ rw [hmeanPoint]
108
+ exact fieldSpinTransition_bound ζ _ measurable_logCosh logCosh_linearGrowth
109
+ field_abs_tanh_le_one z
110
+
111
+ theorem fieldTerminal_earlier_squares_antitone (a ζ : ℝ) (hζ0 : 0 ≤ ζ) (hζ1 : ζ ≤ 1)
112
+ (P : List (ℝ × ℝ≥0)) (hP : ∀ av ∈ P, 0 < av.1)
113
+ {t s : ℝ} (ht : t ∈ Ioi (-a)) (hs : s ∈ Ioi (-a)) (hts : t ≤ s) :
114
+ let G := fieldTerminalFamily a ζ
115
+ ∀ i z, fieldScalarSquares P (fun y => G.U (s, y)) (fun y => G.X (s, y)) i z ≤
116
+ fieldScalarSquares P (fun y => G.U (t, y)) (fun y => G.X (t, y)) i z := by
117
+ have hshape (q : ℝ) := fieldTerminalFamily_shape a ζ hζ0 q
118
+ exact (fieldTerminalFamily a ζ).earlier_squares_antitone_parameter (convex_Ioi (-a))
119
+ (fun q _ => fieldTerminalFamily_tangent_antitone a ζ hζ1 q)
120
+ (fun q _ => (hshape q).1) (fun q _ => (hshape q).2.1)
121
+ (fun q _ => (hshape q).2.2.1) (fun q _ => (hshape q).2.2.2.1)
122
+ (fun p => (hshape p.1).2.2.2.2 p.2) P hP ht hs hts
123
+
124
+ end InvariantIsing
125
+
126
+ end
127
+
128
+ end OAI
lean/OAI/Probability/InvariantIsing/Fields/FieldTiltAverageDerivative.lean ADDED
@@ -0,0 +1,130 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Probability.InvariantIsing.Fields.FieldTiltDerivative
2
+
3
+ namespace OAI
4
+
5
+ /-! Differentiation of the scalar tilted spin average. The potential
6
+ needs an exponential moment at the base point, rather than a global bound. -/
7
+
8
+ noncomputable section
9
+ open MeasureTheory ProbabilityTheory IsingPerceptron Filter Set
10
+ open scoped NNReal Topology
11
+
12
+ namespace InvariantIsing
13
+
14
+ private lemma parameter_exp_bound (U DU : ℝ → ℝ → ℝ) {C : ℝ}
15
+ (hC : 0 ≤ C) (hDU : ∀ s u, |DU s u| ≤ C)
16
+ (hd : ∀ s u, HasDerivAt (fun q => U q u) (DU s u) s)
17
+ (ζ x s u : ℝ) (hs : s ∈ Ioo (x - 1) (x + 1)) :
18
+ Real.exp (ζ * U s u) ≤ Real.exp (|ζ| * C) * Real.exp (ζ * U x u) := by
19
+ have hdiff : |U s u - U x u| ≤ C * |s - x| := by
20
+ simpa only [Real.norm_eq_abs] using
21
+ Convex.norm_image_sub_le_of_norm_hasDerivWithin_le
22
+ (fun q (_ : q ∈ (univ : Set ℝ)) => (hd q u).hasDerivWithinAt)
23
+ (fun q _ => by simpa only [Real.norm_eq_abs] using hDU q u)
24
+ convex_univ (mem_univ x) (mem_univ s)
25
+ have hdist : |s - x| ≤ 1 := abs_le.mpr ⟨by linarith [hs.1], by linarith [hs.2]⟩
26
+ have h1 := hdiff.trans (mul_le_of_le_one_right hC hdist)
27
+ have h2 : ζ * (U s u - U x u) ≤ |ζ| * C :=
28
+ (le_abs_self _).trans (by
29
+ rw [abs_mul]
30
+ exact mul_le_mul_of_nonneg_left h1 (abs_nonneg ζ))
31
+ rw [← Real.exp_add]
32
+ exact Real.exp_le_exp.mpr (by nlinarith)
33
+
34
+ theorem hasDerivAt_tiltAverage_of_bounded_derivatives
35
+ (μ : Measure ℝ) [IsProbabilityMeasure μ]
36
+ (U A DU DA : ℝ → ℝ → ℝ)
37
+ (hU : ∀ s, Measurable (U s)) (hA : ∀ s, Measurable (A s))
38
+ (hDU : ∀ s, Measurable (DU s)) (hDA : ∀ s, Measurable (DA s))
39
+ {C M L : ℝ} (hC : 0 ≤ C) (hM : 0 ≤ M)
40
+ (hbDU : ∀ s u, |DU s u| ≤ C) (hbA : ∀ s u, |A s u| ≤ M)
41
+ (hbDA : ∀ s u, |DA s u| ≤ L)
42
+ (dU : ∀ s u, HasDerivAt (fun q => U q u) (DU s u) s)
43
+ (dA : ∀ s u, HasDerivAt (fun q => A q u) (DA s u) s)
44
+ (ζ x : ℝ) (hi : Integrable (fun u => Real.exp (ζ * U x u)) μ) :
45
+ HasDerivAt (fun s => ∫ u, A s u ∂μ.tilted (fun u => ζ * U s u))
46
+ ((∫ u, DA x u ∂μ.tilted (fun u => ζ * U x u)) +
47
+ ζ * ((∫ u, A x u * DU x u ∂μ.tilted (fun u => ζ * U x u)) -
48
+ (∫ u, A x u ∂μ.tilted (fun u => ζ * U x u)) *
49
+ (∫ u, DU x u ∂μ.tilted (fun u => ζ * U x u)))) x := by
50
+ have hS : Ioo (x - 1) (x + 1) ∈ 𝓝 x :=
51
+ Ioo_mem_nhds (by linarith) (by linarith)
52
+ have hE (s u : ℝ) (hs : s ∈ Ioo (x - 1) (x + 1)) :=
53
+ parameter_exp_bound U DU hC hbDU dU ζ x s u hs
54
+ have hAD (s u : ℝ) : |A s u * DU s u| ≤ M * C := by
55
+ rw [abs_mul]
56
+ exact mul_le_mul (hbA s u) (hbDU s u) (abs_nonneg _) hM
57
+ have hprod {G : ℝ → ℝ} (hm : Measurable G) {K : ℝ} (hb : ∀ u, |G u| ≤ K) :
58
+ Integrable (fun u => Real.exp (ζ * U x u) * G u) μ :=
59
+ hi.mul_bdd hm.aestronglyMeasurable
60
+ (ae_of_all _ fun u => by simpa only [Real.norm_eq_abs] using hb u)
61
+ have hiA := hprod (hA x) (hbA x)
62
+ have hiDA := hprod (hDA x) (hbDA x)
63
+ have hiAD := hprod ((hA x).mul (hDU x)) (hAD x)
64
+ change Integrable (fun u => Real.exp (ζ * U x u) * (A x u * DU x u)) μ at hiAD
65
+ have hdDen (s u : ℝ) := ((dU s u).const_mul ζ).exp
66
+ have hdNum (s u : ℝ) :
67
+ HasDerivAt (fun q => Real.exp (ζ * U q u) * A q u)
68
+ (Real.exp (ζ * U s u) * DA s u +
69
+ ζ * (Real.exp (ζ * U s u) * (A s u * DU s u))) s := by
70
+ convert (hdDen s u).mul (dA s u) using 1
71
+ ring
72
+ obtain ⟨_, hden⟩ := hasDerivAt_integral_of_dominated_loc_of_deriv_le hS
73
+ (Eventually.of_forall fun s => ((hU s).const_mul ζ).exp.aestronglyMeasurable) hi
74
+ (((hU x).const_mul ζ).exp.mul ((hDU x).const_mul ζ)).aestronglyMeasurable
75
+ (ae_of_all _ fun u s hs => by
76
+ change |Real.exp (ζ * U s u) * (ζ * DU s u)| ≤ _
77
+ rw [abs_mul, abs_of_pos (Real.exp_pos _), abs_mul]
78
+ calc
79
+ _ ≤ (Real.exp (|ζ| * C) * Real.exp (ζ * U x u)) * (|ζ| * C) :=
80
+ mul_le_mul (hE s u hs) (mul_le_mul_of_nonneg_left (hbDU s u) (abs_nonneg ζ))
81
+ (mul_nonneg (abs_nonneg _) (abs_nonneg _)) (by positivity)
82
+ _ = (Real.exp (|ζ| * C) * (|ζ| * C)) * Real.exp (ζ * U x u) := by ring)
83
+ (hi.const_mul (Real.exp (|ζ| * C) * (|ζ| * C)))
84
+ (ae_of_all _ fun u s _ => hdDen s u)
85
+ obtain ⟨_, hnum⟩ := hasDerivAt_integral_of_dominated_loc_of_deriv_le hS
86
+ (Eventually.of_forall fun s => (((hU s).const_mul ζ).exp.mul (hA s)).aestronglyMeasurable)
87
+ hiA ((((hU x).const_mul ζ).exp.mul (hDA x)).add
88
+ ((((hU x).const_mul ζ).exp.mul ((hA x).mul (hDU x))).const_mul ζ)).aestronglyMeasurable
89
+ (ae_of_all _ fun u s hs => by
90
+ change |Real.exp (ζ * U s u) * DA s u +
91
+ ζ * (Real.exp (ζ * U s u) * (A s u * DU s u))| ≤ _
92
+ refine (abs_add_le _ _).trans ?_
93
+ rw [abs_mul, abs_of_pos (Real.exp_pos _), abs_mul, abs_mul,
94
+ abs_of_pos (Real.exp_pos _)]
95
+ calc
96
+ _ ≤ (Real.exp (|ζ| * C) * Real.exp (ζ * U x u)) * L +
97
+ |ζ| * ((Real.exp (|ζ| * C) * Real.exp (ζ * U x u)) * (M * C)) :=
98
+ add_le_add (mul_le_mul (hE s u hs) (hbDA s u) (abs_nonneg _) (by positivity))
99
+ (mul_le_mul_of_nonneg_left
100
+ (mul_le_mul (hE s u hs) (hAD s u) (abs_nonneg _) (by positivity)) (abs_nonneg ζ))
101
+ _ = (Real.exp (|ζ| * C) * (L + |ζ| * (M * C))) *
102
+ Real.exp (ζ * U x u) := by ring)
103
+ (hi.const_mul (Real.exp (|ζ| * C) * (L + |ζ| * (M * C))))
104
+ (ae_of_all _ fun u s _ => hdNum s u)
105
+ have hp := IsingPerceptron.integral_exp_pos μ (U x) hi
106
+ simp only [Pi.mul_apply] at hnum
107
+ have hde : (∫ u, Real.exp (ζ * U x u) * (ζ * DU x u) ∂μ) =
108
+ ζ * ∫ u, Real.exp (ζ * U x u) * DU x u ∂μ := by
109
+ rw [← integral_const_mul]
110
+ congr 1
111
+ funext u
112
+ ring
113
+ have hne : (∫ u, Real.exp (ζ * U x u) * DA x u +
114
+ ζ * (Real.exp (ζ * U x u) * (A x u * DU x u)) ∂μ) =
115
+ (∫ u, Real.exp (ζ * U x u) * DA x u ∂μ) +
116
+ ζ * ∫ u, Real.exp (ζ * U x u) * (A x u * DU x u) ∂μ := by
117
+ rw [integral_add hiDA (hiAD.const_mul ζ), integral_const_mul]
118
+ convert hnum.div hden hp.ne' using 1
119
+ · funext s
120
+ exact integral_tilted_eq_div _ _ _
121
+ · simp only [integral_tilted_eq_div]
122
+ rw [hde, hne]
123
+ field_simp
124
+ ring
125
+
126
+ end InvariantIsing
127
+
128
+ end
129
+
130
+ end OAI
lean/OAI/Probability/InvariantIsing/Fields/FieldTiltDerivative.lean ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Probability.InvariantIsing.Fields.FieldSpinDerivative
2
+
3
+ namespace OAI
4
+
5
+ /-! A local integrable envelope permits covariance derivatives of a
6
+ Gaussian logarithmic mean without a bounded-payoff assumption. -/
7
+
8
+ noncomputable section
9
+ open MeasureTheory ProbabilityTheory IsingPerceptron Filter Set
10
+ open scoped Topology
11
+
12
+ namespace InvariantIsing
13
+
14
+ lemma hasDerivAt_logMean_of_integrable_envelope
15
+ {A : Type*} [MeasurableSpace A] (μ : Measure A) [IsProbabilityMeasure μ]
16
+ (F D : ℝ → A → ℝ) (hF : ∀ s, Measurable (F s))
17
+ {ζ t : ℝ} (hζ : ζ ≠ 0) {S : Set ℝ} (hS : S ∈ 𝓝 t)
18
+ (hD : Measurable (D t))
19
+ (hi : Integrable (fun u => Real.exp (ζ * F t u)) μ)
20
+ (hd : ∀ s ∈ S, ∀ u, HasDerivAt (fun q => F q u) (D s u) s)
21
+ (M : A → ℝ) (hM : Integrable M μ)
22
+ (hbound : ∀ᵐ u ∂μ, ∀ s ∈ S, ‖Real.exp (ζ * F s u) * (ζ * D s u)‖ ≤ M u) :
23
+ HasDerivAt (fun s => logMean ζ μ (F s))
24
+ (∫ u, D t u ∂μ.tilted (fun u => ζ * F t u)) t := by
25
+ obtain ⟨_, hI⟩ := hasDerivAt_integral_of_dominated_loc_of_deriv_le hS
26
+ (Eventually.of_forall fun s => ((hF s).const_mul ζ).exp.aestronglyMeasurable) hi
27
+ (((hF t).const_mul ζ).exp.mul (hD.const_mul ζ)).aestronglyMeasurable
28
+ hbound hM (ae_of_all _ fun u s hs => ((hd s hs u).const_mul ζ).exp)
29
+ have hpos := IsingPerceptron.integral_exp_pos μ (F t) hi
30
+ convert (hI.log hpos.ne').div_const ζ using 1
31
+ · rfl
32
+ · rw [integral_tilted_eq_div]
33
+ have he : (∫ u, Real.exp (ζ * F t u) * (ζ * D t u) ∂μ) =
34
+ ζ * ∫ u, Real.exp (ζ * F t u) * D t u ∂μ := by
35
+ rw [← integral_const_mul]
36
+ congr 1
37
+ funext u
38
+ ring
39
+ rw [he]
40
+ field_simp
41
+
42
+ end InvariantIsing
43
+
44
+ end
45
+
46
+ end OAI
lean/OAI/Probability/InvariantIsing/Fields/FieldTiltedFamilyDerivative.lean ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Probability.InvariantIsing.Fields.FieldGaussianFamilyEnvelope
2
+ import OAI.Probability.InvariantIsing.Fields.FieldGaussianTiltMoments
3
+
4
+ namespace OAI
5
+
6
+ /-! Differentiating a normalized scalar Gaussian average with a varying
7
+ observable. The local envelopes allow the affine-noise quadratic terms
8
+ needed in the second derivative of the finite Ising recursion. -/
9
+
10
+ noncomputable section
11
+ open MeasureTheory ProbabilityTheory IsingPerceptron Filter Set
12
+ open scoped Topology
13
+
14
+ namespace InvariantIsing
15
+
16
+ /-- Derivative of the unnormalized Gaussian weight. -/
17
+ def fieldWeightDifferential (U : (ℝ × ℝ) → ℝ → ℝ)
18
+ (DU : (ℝ × ℝ) → ℝ → (ℝ × ℝ) →L[ℝ] ℝ) (ζ : ℝ)
19
+ (p : ℝ × ℝ) (u : ℝ) : (ℝ × ℝ) →L[ℝ] ℝ :=
20
+ Real.exp (ζ * U p u) • (ζ • DU p u)
21
+
22
+ /-- Derivative of the weighted observable. -/
23
+ def fieldObservableDifferential (U A : (ℝ × ℝ) → ℝ → ℝ)
24
+ (DU DA : (ℝ × ℝ) → ℝ → (ℝ × ℝ) →L[ℝ] ℝ) (ζ : ℝ)
25
+ (p : ℝ × ℝ) (u : ℝ) : (ℝ × ℝ) →L[ℝ] ℝ :=
26
+ Real.exp (ζ * U p u) • (DA p u + (ζ * A p u) • DU p u)
27
+
28
+ lemma field_tiltedFamily_hasFDerivAt
29
+ (μ : Measure ℝ) [IsProbabilityMeasure μ]
30
+ (U A : (ℝ × ℝ) → ℝ → ℝ)
31
+ (DU DA : (ℝ × ℝ) → ℝ → (ℝ × ℝ) →L[ℝ] ℝ)
32
+ {p : ℝ × ℝ} {S : Set (ℝ × ℝ)} (hS : S ∈ 𝓝 p) (ζ : ℝ)
33
+ (hU : ∀ q, Measurable (U q)) (hA : ∀ q, Measurable (A q))
34
+ (hDU : AEStronglyMeasurable (DU p) μ) (hDA : AEStronglyMeasurable (DA p) μ)
35
+ (hE : Integrable (fun u => Real.exp (ζ * U p u)) μ)
36
+ (hEA : Integrable (fun u => Real.exp (ζ * U p u) * A p u) μ)
37
+ (MD MN : ℝ → ℝ) (hMD : Integrable MD μ) (hMN : Integrable MN μ)
38
+ (hDen : ∀ q ∈ S, ∀ u, ‖fieldWeightDifferential U DU ζ q u‖ ≤ MD u)
39
+ (hNum : ∀ q ∈ S, ∀ u, ‖fieldObservableDifferential U A DU DA ζ q u‖ ≤ MN u)
40
+ (dU : ∀ q ∈ S, ∀ u, HasFDerivAt (fun r => U r u) (DU q u) q)
41
+ (dA : ∀ q ∈ S, ∀ u, HasFDerivAt (fun r => A r u) (DA q u) q) :
42
+ let Z := ∫ u, Real.exp (ζ * U p u) ∂μ
43
+ let N := ∫ u, Real.exp (ζ * U p u) * A p u ∂μ
44
+ HasFDerivAt (fun q => ∫ u, A q u ∂μ.tilted (fun u => ζ * U q u))
45
+ (Z⁻¹ • (∫ u, fieldObservableDifferential U A DU DA ζ p u ∂μ) -
46
+ (N * (Z ^ 2)⁻¹) • (∫ u, fieldWeightDifferential U DU ζ p u ∂μ)) p := by
47
+ let Z := ∫ u, Real.exp (ζ * U p u) ∂μ
48
+ let N := ∫ u, Real.exp (ζ * U p u) * A p u ∂μ
49
+ let DZ := ∫ u, fieldWeightDifferential U DU ζ p u ∂μ
50
+ let DN := ∫ u, fieldObservableDifferential U A DU DA ζ p u ∂μ
51
+ have hZD : HasFDerivAt (fun q => ∫ u, Real.exp (ζ * U q u) ∂μ) DZ p := by
52
+ apply hasFDerivAt_integral_of_dominated_of_fderiv_le hS
53
+ (Eventually.of_forall fun q => ((hU q).const_mul ζ).exp.aestronglyMeasurable)
54
+ hE (((hU p).const_mul ζ).exp.aestronglyMeasurable.smul (hDU.const_smul ζ))
55
+ (ae_of_all _ fun u q hq => hDen q hq u) hMD
56
+ exact ae_of_all _ fun u q hq => ((dU q hq u).const_mul ζ).exp
57
+ have hND : HasFDerivAt (fun q => ∫ u, Real.exp (ζ * U q u) * A q u ∂μ) DN p := by
58
+ have hDM : AEStronglyMeasurable (fieldObservableDifferential U A DU DA ζ p) μ :=
59
+ ((hU p).const_mul ζ).exp.aestronglyMeasurable.smul
60
+ (hDA.add (((hA p).const_mul ζ).aestronglyMeasurable.smul hDU))
61
+ apply hasFDerivAt_integral_of_dominated_of_fderiv_le hS
62
+ (Eventually.of_forall fun q => (((hU q).const_mul ζ).exp.mul (hA q)).aestronglyMeasurable)
63
+ hEA hDM (ae_of_all _ fun u q hq => hNum q hq u) hMN
64
+ refine ae_of_all _ fun u q hq => ?_
65
+ convert (((dU q hq u).const_mul ζ).exp).mul (dA q hq u) using 1
66
+ apply ContinuousLinearMap.ext
67
+ intro v
68
+ simp only [fieldObservableDifferential, smul_apply,
69
+ add_apply, smul_eq_mul]
70
+ ring
71
+ have hZ : Z ≠ 0 := (integral_exp_pos μ (U p) hE).ne'
72
+ have hInv : HasFDerivAt (fun q => (∫ u, Real.exp (ζ * U q u) ∂μ)⁻¹)
73
+ (-(Z ^ 2)⁻¹ • DZ) p := by
74
+ convert (hasDerivAt_inv hZ).hasFDerivAt.comp p hZD using 1
75
+ · rfl
76
+ · apply ContinuousLinearMap.ext
77
+ intro v
78
+ simp only [smul_apply, ContinuousLinearMap.comp_apply,
79
+ smul_eq_mul]
80
+ change -(Z ^ 2)⁻¹ * DZ v = DZ v * -(Z ^ 2)⁻¹
81
+ ring
82
+ have hquot := hND.mul hInv
83
+ have he : (fun q => ∫ u, A q u ∂μ.tilted (fun u => ζ * U q u)) =
84
+ fun q => (∫ u, Real.exp (ζ * U q u) * A q u ∂μ) *
85
+ (∫ u, Real.exp (ζ * U q u) ∂μ)⁻¹ := by
86
+ funext q
87
+ rw [integral_tilted_eq_div, div_eq_mul_inv]
88
+ rw [he]
89
+ convert hquot using 1
90
+ apply ContinuousLinearMap.ext
91
+ intro v
92
+ simp only [sub_apply, smul_apply,
93
+ add_apply, smul_eq_mul]
94
+ change Z⁻¹ * DN v - N * (Z ^ 2)⁻¹ * DZ v =
95
+ N * (-(Z ^ 2)⁻¹ * DZ v) + Z⁻¹ * DN v
96
+ ring
97
+
98
+ end InvariantIsing
99
+
100
+ end
101
+
102
+ end OAI
lean/OAI/Probability/InvariantIsing/Fields/FieldTiltedPairDerivative.lean ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Probability.InvariantIsing.Fields.FieldTiltedFamilyDerivative
2
+
3
+ namespace OAI
4
+
5
+ /-! Covariance form of the derivative of an actual normalized average.
6
+ This is the two-coordinate formula used by the finite scalar recursion. -/
7
+
8
+ noncomputable section
9
+ open MeasureTheory ProbabilityTheory IsingPerceptron Filter Set
10
+ open scoped Topology
11
+
12
+ namespace InvariantIsing
13
+
14
+ lemma field_tilted_integral_normalize {E : Type*} [NormedAddCommGroup E]
15
+ [NormedSpace ℝ E] [CompleteSpace E] (μ : Measure ℝ) (U : ℝ → ℝ)
16
+ (B : ℝ → E) (ζ : ℝ) :
17
+ (∫ u, B u ∂μ.tilted (fun u => ζ * U u)) =
18
+ (∫ u, Real.exp (ζ * U u) ∂μ)⁻¹ •
19
+ (∫ u, Real.exp (ζ * U u) • B u ∂μ) := by
20
+ rw [integral_tilted, ← integral_smul]
21
+ congr 1
22
+ funext u
23
+ rw [smul_smul]
24
+ congr 1
25
+ ring
26
+
27
+ lemma field_tiltedFamily_covariance_hasFDerivAt
28
+ (μ : Measure ℝ) [IsProbabilityMeasure μ]
29
+ (U A : (ℝ × ℝ) → ℝ → ℝ)
30
+ (DU DA : (ℝ × ℝ) → ℝ → (ℝ × ℝ) →L[ℝ] ℝ)
31
+ {p : ℝ × ℝ} {S : Set (ℝ × ℝ)} (hS : S ∈ 𝓝 p) (ζ : ℝ)
32
+ (hU : ∀ q, Measurable (U q)) (hA : ∀ q, Measurable (A q))
33
+ (hDU : AEStronglyMeasurable (DU p) μ) (hDA : AEStronglyMeasurable (DA p) μ)
34
+ (hE : Integrable (fun u => Real.exp (ζ * U p u)) μ)
35
+ (hEA : Integrable (fun u => Real.exp (ζ * U p u) * A p u) μ)
36
+ (MD MN : ℝ → ℝ) (hMD : Integrable MD μ) (hMN : Integrable MN μ)
37
+ (hDen : ∀ q ∈ S, ∀ u, ‖fieldWeightDifferential U DU ζ q u‖ ≤ MD u)
38
+ (hNum : ∀ q ∈ S, ∀ u, ‖fieldObservableDifferential U A DU DA ζ q u‖ ≤ MN u)
39
+ (dU : ∀ q ∈ S, ∀ u, HasFDerivAt (fun r => U r u) (DU q u) q)
40
+ (dA : ∀ q ∈ S, ∀ u, HasFDerivAt (fun r => A r u) (DA q u) q) :
41
+ HasFDerivAt (fun q => ∫ u, A q u ∂μ.tilted (fun u => ζ * U q u))
42
+ ((∫ u, DA p u + (ζ * A p u) • DU p u
43
+ ∂μ.tilted (fun u => ζ * U p u)) -
44
+ (∫ u, A p u ∂μ.tilted (fun u => ζ * U p u)) •
45
+ (∫ u, ζ • DU p u ∂μ.tilted (fun u => ζ * U p u))) p := by
46
+ have h := field_tiltedFamily_hasFDerivAt μ U A DU DA hS ζ hU hA hDU hDA
47
+ hE hEA MD MN hMD hMN hDen hNum dU dA
48
+ convert h using 1
49
+ rw [field_tilted_integral_normalize, field_tilted_integral_normalize,
50
+ field_tilted_integral_normalize]
51
+ simp only [smul_eq_mul, fieldObservableDifferential, fieldWeightDifferential,
52
+ pow_two, smul_smul]
53
+ congr 1
54
+ apply ContinuousLinearMap.ext
55
+ intro v
56
+ simp only [smul_apply, smul_eq_mul]
57
+ ring
58
+
59
+ end InvariantIsing
60
+
61
+ end
62
+
63
+ end OAI
lean/OAI/Probability/InvariantIsing/Fields/FieldVaryingContinuity.lean ADDED
@@ -0,0 +1,139 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Probability.InvariantIsing.Fields.FieldVaryingRecursion
2
+
3
+ namespace OAI
4
+
5
+ /-! Joint continuity of the actual finite scalar recursion and its
6
+ physical-spin second moments, including zero variance increments. -/
7
+
8
+ noncomputable section
9
+ open MeasureTheory ProbabilityTheory IsingPerceptron Filter
10
+ open scoped NNReal
11
+
12
+ namespace InvariantIsing
13
+
14
+ lemma field_continuous_tanh : Continuous Real.tanh := by
15
+ change Continuous (fun z : ℝ => Real.tanh z)
16
+ simp only [Real.tanh_eq]
17
+ exact (Real.continuous_exp.sub (Real.continuous_exp.comp continuous_neg)).div
18
+ (Real.continuous_exp.add (Real.continuous_exp.comp continuous_neg))
19
+ (fun z => (add_pos (Real.exp_pos z) (Real.exp_pos (-z))).ne')
20
+
21
+ theorem continuous_fieldVaryingValue {E : Type*} [TopologicalSpace E]
22
+ [FirstCountableTopology E] (L : List (ℝ × (E → ℝ≥0)))
23
+ (hL : ∀ av ∈ L, 0 < av.1) (hc : ∀ av ∈ L, Continuous av.2)
24
+ {V : ℝ} (hV : 0 ≤ V) (hv : ∀ av ∈ L, ∀ t, (av.2 t : ℝ) ≤ V) :
25
+ Continuous (fun p : E × ℝ => fieldVaryingValue L p.1 p.2) := by
26
+ induction L with
27
+ | nil =>
28
+ change Continuous (fun p : E × ℝ => Real.log (Real.cosh p.2))
29
+ exact (Real.continuous_cosh.comp continuous_snd).log (fun p => (Real.cosh_pos p.2).ne')
30
+ | cons av L ih =>
31
+ have hLt : ∀ bv ∈ L, 0 < bv.1 := fun bv hb => hL bv (List.mem_cons_of_mem av hb)
32
+ have hct := fun bv hb => hc bv (List.mem_cons_of_mem av hb)
33
+ have hvt := fun bv hb t => hv bv (List.mem_cons_of_mem av hb) t
34
+ have hval := ih hLt hct hvt
35
+ obtain ⟨hcap, hb⟩ := fieldVaryingValue_bound L hLt hV hvt
36
+ change Continuous (fun p : E × ℝ => gaussianOperator av.1 (av.2 p.1)
37
+ (fieldVaryingValue L p.1) p.2)
38
+ simp_rw [gaussianOperator_eq_transform]
39
+ exact continuous_field_gaussian_transform (E := E × ℝ)
40
+ (U := fun p y => fieldVaryingValue L p.1 y)
41
+ (hval.comp (continuous_fst.fst.prodMk continuous_snd))
42
+ ((NNReal.continuous_coe.comp (hc av List.mem_cons_self)).comp continuous_fst) continuous_snd
43
+ hcap zero_le_one (fun p y => by simpa only [one_mul] using hb p.1 y) av.1
44
+
45
+ theorem continuous_fieldVaryingMean {E : Type*} [TopologicalSpace E]
46
+ [FirstCountableTopology E] (L : List (ℝ × (E → ℝ≥0)))
47
+ (hL : ∀ av ∈ L, 0 < av.1) (hc : ∀ av ∈ L, Continuous av.2)
48
+ {V : ℝ} (hV : 0 ≤ V) (hv : ∀ av ∈ L, ∀ t, (av.2 t : ℝ) ≤ V) :
49
+ Continuous (fun p : E × ℝ => fieldVaryingMean L p.1 p.2) := by
50
+ induction L with
51
+ | nil =>
52
+ change Continuous (fun p : E × ℝ => Real.tanh p.2)
53
+ exact field_continuous_tanh.comp continuous_snd
54
+ | cons av L ih =>
55
+ have hLt : ∀ bv ∈ L, 0 < bv.1 := fun bv hb => hL bv (List.mem_cons_of_mem av hb)
56
+ have hct := fun bv hb => hc bv (List.mem_cons_of_mem av hb)
57
+ have hvt := fun bv hb t => hv bv (List.mem_cons_of_mem av hb) t
58
+ have hval := continuous_fieldVaryingValue L hLt hct hV hvt
59
+ have hmean := ih hLt hct hvt
60
+ obtain ⟨hcap, hb⟩ := fieldVaryingValue_bound L hLt hV hvt
61
+ have hcont := continuous_field_gaussian_tilt_average (E := E × ℝ)
62
+ (U := fun p y => fieldVaryingValue L p.1 y)
63
+ (A := fun p y => fieldVaryingMean L p.1 y)
64
+ (hval.comp (continuous_fst.fst.prodMk continuous_snd))
65
+ (hmean.comp (continuous_fst.fst.prodMk continuous_snd))
66
+ ((NNReal.continuous_coe.comp (hc av List.mem_cons_self)).comp continuous_fst) continuous_snd
67
+ hcap zero_le_one zero_le_one (fun p y => by simpa only [one_mul] using hb p.1 y)
68
+ (fun p y => (fieldVaryingMean_regular L hLt p.1).2 y) av.1
69
+ convert hcont using 1
70
+ funext p
71
+ exact fieldSpinTransition_eq_standard av.1 (av.2 p.1)
72
+ (fieldVaryingValue_regular L hLt p.1).1 (fieldVaryingMean_regular L hLt p.1).1 p.2
73
+
74
+ theorem continuous_fieldVaryingSquares {E : Type*} [TopologicalSpace E]
75
+ [FirstCountableTopology E] (L : List (ℝ × (E → ℝ≥0)))
76
+ (hL : ∀ av ∈ L, 0 < av.1) (hc : ∀ av ∈ L, Continuous av.2)
77
+ {V : ℝ} (hV : 0 ≤ V) (hv : ∀ av ∈ L, ∀ t, (av.2 t : ℝ) ≤ V)
78
+ (i : Fin (L.length + 1)) :
79
+ Continuous (fun p : E × ℝ => fieldVaryingSquares L p.1 i p.2) := by
80
+ induction L with
81
+ | nil =>
82
+ change Continuous (fun p : E × ℝ => (Real.tanh p.2) ^ 2)
83
+ exact (field_continuous_tanh.comp continuous_snd).pow 2
84
+ | cons av L ih =>
85
+ have hLt : ∀ bv ∈ L, 0 < bv.1 := fun bv hb => hL bv (List.mem_cons_of_mem av hb)
86
+ have hct := fun bv hb => hc bv (List.mem_cons_of_mem av hb)
87
+ have hvt := fun bv hb t => hv bv (List.mem_cons_of_mem av hb) t
88
+ refine Fin.cases ?_ (fun j => ?_) i
89
+ · exact (continuous_fieldVaryingMean (av :: L) hL hc hV hv).pow 2
90
+ · have hval := continuous_fieldVaryingValue L hLt hct hV hvt
91
+ have hsq := ih hLt hct hvt j
92
+ obtain ⟨hcap, hb⟩ := fieldVaryingValue_bound L hLt hV hvt
93
+ have hcont := continuous_field_gaussian_tilt_average (E := E × ℝ)
94
+ (U := fun p y => fieldVaryingValue L p.1 y)
95
+ (A := fun p y => fieldVaryingSquares L p.1 j y)
96
+ (hval.comp (continuous_fst.fst.prodMk continuous_snd))
97
+ (hsq.comp (continuous_fst.fst.prodMk continuous_snd))
98
+ ((NNReal.continuous_coe.comp (hc av List.mem_cons_self)).comp continuous_fst) continuous_snd
99
+ hcap zero_le_one zero_le_one (fun p y => by simpa only [one_mul] using hb p.1 y)
100
+ (fun p y => by
101
+ have hr := (fieldVaryingSquares_regular L hLt p.1 j).2 y
102
+ rw [abs_of_nonneg hr.1]
103
+ exact hr.2) av.1
104
+ convert hcont using 1
105
+ funext p
106
+ exact fieldSpinTransition_eq_standard av.1 (av.2 p.1)
107
+ (fieldVaryingValue_regular L hLt p.1).1
108
+ (fieldVaryingSquares_regular L hLt p.1 j).1 p.2
109
+
110
+ theorem continuous_fieldVaryingOverlaps {E : Type*} [TopologicalSpace E]
111
+ [FirstCountableTopology E] (L : List (ℝ × (E → ℝ≥0)))
112
+ (hL : ∀ av ∈ L, 0 < av.1) (hc : ∀ av ∈ L, Continuous av.2)
113
+ {V : ℝ} (hV : 0 ≤ V) (hv : ∀ av ∈ L, ∀ t, (av.2 t : ℝ) ≤ V)
114
+ (root : E → ℝ≥0) (hr : Continuous root) (i : Fin (L.length + 1)) :
115
+ Continuous (fun t => ∫ u, fieldVaryingSquares L t i
116
+ (Real.sqrt (root t : ℝ) * u) ∂gaussianReal 0 1) := by
117
+ have hsq := continuous_fieldVaryingSquares L hL hc hV hv i
118
+ have hshift : Continuous (fun p : E × ℝ => fieldVaryingSquares L p.1 i
119
+ (Real.sqrt (root p.1 : ℝ) * p.2)) :=
120
+ hsq.comp (continuous_fst.prodMk
121
+ (((Real.continuous_sqrt.comp (NNReal.continuous_coe.comp hr)).comp continuous_fst).mul continuous_snd))
122
+ apply continuous_iff_continuousAt.mpr
123
+ intro t
124
+ apply tendsto_integral_filter_of_dominated_convergence (fun _ : ℝ => (1 : ℝ))
125
+ · exact Eventually.of_forall (fun s =>
126
+ (hshift.comp (continuous_const.prodMk continuous_id)).measurable.aestronglyMeasurable)
127
+ · exact Eventually.of_forall (fun s => ae_of_all _ (fun u => by
128
+ have h := (fieldVaryingSquares_regular L hL s i).2 (Real.sqrt (root s : ℝ) * u)
129
+ rw [Real.norm_eq_abs, abs_of_nonneg h.1]
130
+ exact h.2))
131
+ · exact integrable_const _
132
+ · exact ae_of_all _ (fun u =>
133
+ (hshift.comp (continuous_id.prodMk continuous_const)).continuousAt)
134
+
135
+ end InvariantIsing
136
+
137
+ end
138
+
139
+ end OAI
lean/OAI/Probability/InvariantIsing/Fields/FieldVaryingRecursion.lean ADDED
@@ -0,0 +1,158 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Probability.InvariantIsing.Fields.FieldGaussianContinuity
2
+ import OAI.Probability.InvariantIsing.Fields.FieldCapEstimate
3
+ import OAI.Probability.InvariantIsing.Fields.FieldScalarChain
4
+
5
+ namespace OAI
6
+
7
+ /-! Fixed finite cascade exponents with varying nonnegative scalar
8
+ variances. These are the actual log-cosh recursion and spin observables. -/
9
+
10
+ noncomputable section
11
+ open MeasureTheory ProbabilityTheory IsingPerceptron
12
+ open scoped NNReal
13
+
14
+ namespace InvariantIsing
15
+
16
+ def fieldVaryingValue {E : Type*} (L : List (ℝ × (E → ℝ≥0))) (t : E) : ℝ → ℝ :=
17
+ L.foldr (fun av F => gaussianOperator av.1 (av.2 t) F) (fun z => Real.log (Real.cosh z))
18
+
19
+ def fieldVaryingMean {E : Type*} : List (ℝ × (E → ℝ≥0)) → E → ℝ → ℝ
20
+ | [], _ => Real.tanh
21
+ | av :: L, t => fieldSpinTransition av.1 (av.2 t) (fieldVaryingValue L t)
22
+ (fieldVaryingMean L t)
23
+
24
+ def fieldVaryingSquares {E : Type*} : (L : List (ℝ × (E → ℝ≥0))) → E →
25
+ Fin (L.length + 1) → ℝ → ℝ
26
+ | [], _ => fun _ z => (Real.tanh z) ^ 2
27
+ | av :: L, t => Fin.cons (fun z => (fieldVaryingMean (av :: L) t z) ^ 2)
28
+ (fun i => fieldSpinTransition av.1 (av.2 t) (fieldVaryingValue L t)
29
+ (fieldVaryingSquares L t i))
30
+
31
+ lemma fieldVaryingValue_eq_scalar {E : Type*} (L : List (ℝ × (E → ℝ≥0))) (t : E) :
32
+ fieldVaryingValue L t = fieldScalarValue (L.map (fun av => (av.1, av.2 t)))
33
+ (fun z => Real.log (Real.cosh z)) := by
34
+ simp only [fieldVaryingValue, fieldScalarValue, List.foldr_map]
35
+
36
+ lemma fieldVaryingMean_eq_scalar {E : Type*} (L : List (ℝ × (E → ℝ≥0))) (t : E) :
37
+ fieldVaryingMean L t = fieldScalarMean (L.map (fun av => (av.1, av.2 t)))
38
+ (fun z => Real.log (Real.cosh z)) Real.tanh := by
39
+ induction L with
40
+ | nil => rfl
41
+ | cons av L ih =>
42
+ simp only [fieldVaryingMean, List.map_cons, fieldScalarMean,
43
+ fieldVaryingValue_eq_scalar, ih]
44
+
45
+ lemma fieldVaryingSquares_eq_scalar {E : Type*} (L : List (ℝ × (E → ℝ≥0)))
46
+ (t : E) (i : Fin (L.length + 1)) :
47
+ fieldVaryingSquares L t i = fieldScalarSquares (L.map (fun av => (av.1, av.2 t)))
48
+ (fun z => Real.log (Real.cosh z)) Real.tanh (Fin.cast (by simp) i) := by
49
+ induction L with
50
+ | nil => rfl
51
+ | cons av L ih =>
52
+ refine Fin.cases ?_ (fun j => ?_) i
53
+ · simp only [fieldVaryingSquares, Fin.cons_zero, Fin.cast_zero]
54
+ funext z
55
+ rw [fieldScalarSquares_zero, fieldVaryingMean_eq_scalar]
56
+ · change fieldSpinTransition av.1 (av.2 t) (fieldVaryingValue L t)
57
+ (fieldVaryingSquares L t j) =
58
+ fieldSpinTransition av.1 (av.2 t)
59
+ (fieldScalarValue (L.map (fun bv => (bv.1, bv.2 t)))
60
+ (fun z => Real.log (Real.cosh z)))
61
+ (fieldScalarSquares (L.map (fun bv => (bv.1, bv.2 t)))
62
+ (fun z => Real.log (Real.cosh z)) Real.tanh (Fin.cast (by simp) j))
63
+ rw [fieldVaryingValue_eq_scalar, ih]
64
+
65
+ lemma fieldVaryingValue_regular {E : Type*} (L : List (ℝ × (E → ℝ≥0)))
66
+ (hL : ∀ av ∈ L, 0 < av.1) (t : E) :
67
+ Measurable (fieldVaryingValue L t) ∧ HasLinearGrowth (fieldVaryingValue L t) := by
68
+ rw [fieldVaryingValue_eq_scalar]
69
+ apply fieldScalarValue_regular _ _ measurable_logCosh logCosh_linearGrowth
70
+ intro av hav
71
+ obtain ⟨bv, hbv, rfl⟩ := List.mem_map.mp hav
72
+ exact hL bv hbv
73
+
74
+ lemma fieldVaryingMean_regular {E : Type*} (L : List (ℝ × (E → ℝ≥0)))
75
+ (hL : ∀ av ∈ L, 0 < av.1) (t : E) :
76
+ Measurable (fieldVaryingMean L t) ∧ ∀ z, |fieldVaryingMean L t z| ≤ 1 := by
77
+ rw [fieldVaryingMean_eq_scalar]
78
+ apply fieldScalarMean_regular (a := Real.tanh) _ _ measurable_logCosh logCosh_linearGrowth
79
+ (by change Measurable (fun z : ℝ => Real.tanh z); simp only [Real.tanh_eq]; fun_prop)
80
+ field_abs_tanh_le_one
81
+ intro av hav
82
+ obtain ⟨bv, hbv, rfl⟩ := List.mem_map.mp hav
83
+ exact hL bv hbv
84
+
85
+ lemma fieldVaryingSquares_regular {E : Type*} (L : List (ℝ × (E → ℝ≥0)))
86
+ (hL : ∀ av ∈ L, 0 < av.1) (t : E) (i : Fin (L.length + 1)) :
87
+ Measurable (fieldVaryingSquares L t i) ∧
88
+ ∀ z, fieldVaryingSquares L t i z ∈ Set.Icc (0 : ℝ) 1 := by
89
+ rw [fieldVaryingSquares_eq_scalar]
90
+ apply fieldScalarSquares_regular (a := Real.tanh) _ _ measurable_logCosh logCosh_linearGrowth
91
+ (by change Measurable (fun z : ℝ => Real.tanh z); simp only [Real.tanh_eq]; fun_prop)
92
+ field_abs_tanh_le_one
93
+ intro av hav
94
+ obtain ⟨bv, hbv, rfl⟩ := List.mem_map.mp hav
95
+ exact hL bv hbv
96
+
97
+ lemma fieldVaryingValue_nonneg {E : Type*} (L : List (ℝ × (E → ℝ≥0)))
98
+ (hL : ∀ av ∈ L, 0 < av.1) (t : E) (z : ℝ) :
99
+ 0 ≤ fieldVaryingValue L t z := by
100
+ induction L generalizing z with
101
+ | nil => exact Real.log_nonneg (Real.one_le_cosh z)
102
+ | cons av L ih =>
103
+ have ht : ∀ bv ∈ L, 0 < bv.1 := fun bv hb => hL bv (List.mem_cons_of_mem av hb)
104
+ have hr := fieldVaryingValue_regular L ht t
105
+ have hg : HasLinearGrowth (fun _ : ℝ => (0 : ℝ)) := by
106
+ refine ⟨0, 0, le_rfl, le_rfl, ?_⟩
107
+ simp
108
+ have hm := gaussianOperator_mono measurable_const hr.1 hg hr.2
109
+ (fun y => ih ht y) (hL av List.mem_cons_self).le (av.2 t) z
110
+ simpa only [fieldVaryingValue, List.foldr_cons, gaussianOperator, ite_self,
111
+ mul_zero, Real.exp_zero, integral_const, measureReal_def, measure_univ,
112
+ ENNReal.toReal_one, one_smul, Real.log_one, mul_zero] using hm
113
+
114
+ def fieldVaryingCap {E : Type*} (L : List (ℝ × (E → ℝ≥0))) (V : ℝ) : ℝ :=
115
+ (L.map (fun av => av.1 * V / 2 + Real.log 2 / av.1)).sum
116
+
117
+ lemma fieldVaryingValue_bound {E : Type*} (L : List (ℝ × (E → ℝ≥0)))
118
+ (hL : ∀ av ∈ L, 0 < av.1) {V : ℝ} (hV : 0 ≤ V)
119
+ (hv : ∀ av ∈ L, ∀ t, (av.2 t : ℝ) ≤ V) :
120
+ 0 ≤ fieldVaryingCap L V ∧
121
+ ∀ t z, |fieldVaryingValue L t z| ≤ fieldVaryingCap L V + |z| := by
122
+ induction L with
123
+ | nil =>
124
+ refine ⟨le_rfl, fun t z => ?_⟩
125
+ simpa only [fieldVaryingValue, fieldVaryingCap, List.map_nil, List.sum_nil,
126
+ List.foldr_nil, zero_add] using abs_log_cosh_le z
127
+ | cons av L ih =>
128
+ have ht : ∀ bv ∈ L, 0 < bv.1 := fun bv hb => hL bv (List.mem_cons_of_mem av hb)
129
+ have hvt := fun bv hb t => hv bv (List.mem_cons_of_mem av hb) t
130
+ obtain ⟨hc, hb⟩ := ih ht hvt
131
+ have ha := hL av List.mem_cons_self
132
+ have hav := hv av List.mem_cons_self
133
+ have hcap : 0 ≤ fieldVaryingCap (av :: L) V := by
134
+ change 0 ≤ (av.1 * V / 2 + Real.log 2 / av.1) + fieldVaryingCap L V
135
+ positivity
136
+ refine ⟨hcap, fun t z => ?_⟩
137
+ have hr := fieldVaryingValue_regular L ht t
138
+ have hg := linearGrowth_const_add abs_linearGrowth (fieldVaryingCap L V)
139
+ have hm := gaussianOperator_mono (G := fun y : ℝ => fieldVaryingCap L V + |y|)
140
+ hr.1 (by fun_prop)
141
+ hr.2 hg (fun y => (le_abs_self _).trans (hb t y)) ha.le (av.2 t) z
142
+ rw [gaussianOperator_const_add (F := fun y : ℝ => |y|)
143
+ (by fun_prop) abs_linearGrowth] at hm
144
+ have habs : gaussianOperator av.1 (av.2 t) (fun y : ℝ => |y|) z ≤
145
+ |z| + av.1 * (av.2 t : ℝ) / 2 + Real.log 2 / av.1 := by
146
+ rw [gaussianOperator_eq_transform]
147
+ exact gaussianTransform_abs_bound (av.2 t).coe_nonneg ha z
148
+ rw [abs_of_nonneg (fieldVaryingValue_nonneg (av :: L) hL t z)]
149
+ change gaussianOperator av.1 (av.2 t) (fieldVaryingValue L t) z ≤ _
150
+ have hvar := mul_le_mul_of_nonneg_left (hav t) ha.le
151
+ change _ ≤ (av.1 * V / 2 + Real.log 2 / av.1) + fieldVaryingCap L V + |z|
152
+ linarith
153
+
154
+ end InvariantIsing
155
+
156
+ end
157
+
158
+ end OAI
lean/OAI/Probability/InvariantIsing/Fields/FieldVectorPairSampling.lean ADDED
@@ -0,0 +1,139 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Probability.InvariantIsing.Fields.FieldVectorSampling
2
+ import OAI.Probability.InvariantIsing.Fields.FieldScalarSampling
3
+ import OAI.Probability.InvariantIsing.Fields.FieldCommonDepthLaw
4
+
5
+ namespace OAI
6
+
7
+ /-! Evaluation of the common-prefix vector Ising spin pair law, with the
8
+ actual cascade depth distribution and its independent root Gaussian. -/
9
+
10
+ noncomputable section
11
+ open MeasureTheory ProbabilityTheory IsingPerceptron
12
+ open scoped NNReal
13
+
14
+ namespace InvariantIsing
15
+
16
+ def fieldVectorPairSpinKernel (N : ℕ) : (L : List (ℝ × ℝ≥0)) →
17
+ (∀ av ∈ L, 0 < av.1) → Fin (L.length + 1) → Kernel (Fin N → ℝ) (Spin N × Spin N)
18
+ | [], _, _ => fieldVectorSpinKernel N ×ₖ fieldVectorSpinKernel N
19
+ | av :: L, hL, i =>
20
+ let ht := fun bv hb => hL bv (List.mem_cons_of_mem av hb)
21
+ let hreg := fieldScalarValue_regular L ht measurable_logCosh logCosh_linearGrowth
22
+ Fin.cases (fieldVectorTailSpinKernel N (av :: L) hL ×ₖ
23
+ fieldVectorTailSpinKernel N (av :: L) hL)
24
+ (fun j => fieldVectorPairSpinKernel N L ht j ∘ₖ
25
+ fieldVectorTransitionKernel N av.1 av.2
26
+ (fieldScalarValue L (fun z => Real.log (Real.cosh z))) hreg.1) i
27
+
28
+ instance fieldVectorPairSpinKernel_markov (N : ℕ) (L : List (ℝ × ℝ≥0))
29
+ (hL : ∀ av ∈ L, 0 < av.1) (i : Fin (L.length + 1)) :
30
+ IsMarkovKernel (fieldVectorPairSpinKernel N L hL i) := by
31
+ induction L with
32
+ | nil => change IsMarkovKernel (fieldVectorSpinKernel N ×ₖ fieldVectorSpinKernel N); infer_instance
33
+ | cons av L ih =>
34
+ refine Fin.cases ?_ (fun j => ?_) i
35
+ · change IsMarkovKernel (fieldVectorTailSpinKernel N (av :: L) hL ×ₖ
36
+ fieldVectorTailSpinKernel N (av :: L) hL)
37
+ infer_instance
38
+ · have ht := fun bv hb => hL bv (List.mem_cons_of_mem av hb)
39
+ let _ := ih ht j
40
+ change IsMarkovKernel (_ ∘ₖ _)
41
+ infer_instance
42
+
43
+ theorem fieldVectorPairSpinKernel_coordinate_mean (N : ℕ) (L : List (ℝ × ℝ≥0))
44
+ (hL : ∀ av ∈ L, 0 < av.1) (i : Fin (L.length + 1)) (z : Fin N → ℝ) (j : Fin N) :
45
+ (∫ σ, spinValue (σ.1 j) * spinValue (σ.2 j) ∂fieldVectorPairSpinKernel N L hL i z) =
46
+ fieldScalarSquares L (fun u => Real.log (Real.cosh u)) Real.tanh i (z j) := by
47
+ induction L generalizing z with
48
+ | nil =>
49
+ change (∫ σ, spinValue (σ.1 j) * spinValue (σ.2 j)
50
+ ∂(fieldVectorSpinKernel N ×ₖ fieldVectorSpinKernel N) z) = _
51
+ rw [Kernel.prod_apply, integral_prod_mul (fun σ : Spin N => spinValue (σ j))
52
+ (fun σ : Spin N => spinValue (σ j))]
53
+ change (∫ σ, spinValue (σ j) ∂gibbsProbability
54
+ (uniformSpinPrior N : Measure (Spin N)) (fieldEnergy z)) *
55
+ (∫ σ, spinValue (σ j) ∂gibbsProbability
56
+ (uniformSpinPrior N : Measure (Spin N)) (fieldEnergy z)) = _
57
+ rw [fieldSpinGibbs_coordinate_mean]
58
+ simp [fieldScalarSquares, pow_two]
59
+ | cons av L ih =>
60
+ refine Fin.cases ?_ (fun k => ?_) i
61
+ · change (∫ σ, spinValue (σ.1 j) * spinValue (σ.2 j)
62
+ ∂(fieldVectorTailSpinKernel N (av :: L) hL ×ₖ
63
+ fieldVectorTailSpinKernel N (av :: L) hL) z) = _
64
+ rw [Kernel.prod_apply, integral_prod_mul (fun σ : Spin N => spinValue (σ j))
65
+ (fun σ : Spin N => spinValue (σ j)),
66
+ fieldVectorTailSpinKernel_coordinate_mean,
67
+ fieldScalarSquares_zero, pow_two]
68
+ · have ht := fun bv hb => hL bv (List.mem_cons_of_mem av hb)
69
+ have hreg := fieldScalarValue_regular L ht measurable_logCosh logCosh_linearGrowth
70
+ have hsq := fieldScalarSquares_regular L ht measurable_logCosh logCosh_linearGrowth
71
+ (by change Measurable (fun x : ℝ => Real.tanh x); simp only [Real.tanh_eq]; fun_prop)
72
+ field_abs_tanh_le_one k
73
+ change (∫ σ, spinValue (σ.1 j) * spinValue (σ.2 j)
74
+ ∂(fieldVectorPairSpinKernel N L ht k ∘ₖ
75
+ fieldVectorTransitionKernel N av.1 av.2
76
+ (fieldScalarValue L (fun u => Real.log (Real.cosh u))) hreg.1) z) = _
77
+ rw [Kernel.integral_comp (Integrable.of_finite)]
78
+ simp_rw [ih ht]
79
+ exact fieldVectorTransitionKernel_coordinate av.1 av.2 _ hreg.1 hreg.2 _ hsq.1 z j
80
+
81
+ def fieldVectorLevelSpinPair (N : ℕ) (h : FieldStep) (i : Fin (h.depth + 1)) :
82
+ Measure (Spin N × Spin N) :=
83
+ fieldVectorPairSpinKernel N (scalarFieldIncrements h) (scalarFieldIncrements_positive h)
84
+ (Fin.cast (by rw [scalarFieldIncrements_length]) i) ∘ₘ
85
+ (vectorGaussianLaw N (NNReal.mk (h.height 0) (h.nonneg 0)) : Measure (Fin N → ℝ))
86
+
87
+ instance fieldVectorLevelSpinPair_probability (N : ℕ) (h : FieldStep) (i : Fin (h.depth + 1)) :
88
+ IsProbabilityMeasure (fieldVectorLevelSpinPair N h i) := by
89
+ unfold fieldVectorLevelSpinPair
90
+ infer_instance
91
+
92
+ theorem fieldVectorLevelSpinPair_coordinate_mean (N : ℕ) (h : FieldStep)
93
+ (i : Fin (h.depth + 1)) (j : Fin N) :
94
+ (∫ σ, spinValue (σ.1 j) * spinValue (σ.2 j) ∂fieldVectorLevelSpinPair N h i) =
95
+ fieldMagnetizationLevel h i := by
96
+ unfold fieldVectorLevelSpinPair
97
+ rw [Measure.comp_eq_comp_const_apply, Kernel.integral_comp (Integrable.of_finite)]
98
+ simp only [Kernel.const_apply, fieldVectorPairSpinKernel_coordinate_mean]
99
+ let i' : Fin ((scalarFieldIncrements h).length + 1) :=
100
+ Fin.cast (by rw [scalarFieldIncrements_length]) i
101
+ have hs := fieldScalarSquares_regular (scalarFieldIncrements h)
102
+ (scalarFieldIncrements_positive h) measurable_logCosh logCosh_linearGrowth
103
+ (by change Measurable (fun x : ℝ => Real.tanh x); simp only [Real.tanh_eq]; fun_prop)
104
+ field_abs_tanh_le_one i'
105
+ change (∫ z : Fin N → ℝ,
106
+ fieldScalarSquares (scalarFieldIncrements h) (fun u => Real.log (Real.cosh u)) Real.tanh i'
107
+ (z j) ∂Measure.pi (fun _ => gaussianReal 0 (NNReal.mk (h.height 0) (h.nonneg 0)))) = _
108
+ rw [integral_comp_eval hs.1.aestronglyMeasurable]
109
+ rfl
110
+
111
+ theorem fieldVectorLevelSpinPair_cascade_test (N : ℕ) (h : FieldStep)
112
+ (q : Fin (h.depth + 1) → ℝ) (Φ : ℝ → ℝ) (j : Fin N) :
113
+ (∫ α, ∫ σ, Φ (q (fieldCommonLevel h α)) * (spinValue (σ.1 j) * spinValue (σ.2 j))
114
+ ∂fieldVectorLevelSpinPair N h (fieldCommonLevel h α)
115
+ ∂cascadeReplicaLaw h.depth (chainExponent h.cut)) =
116
+ ∫ s, Φ (q (fieldLevelIndex h s)) * fieldMagnetizationPath h s ∂pathMeasure := by
117
+ simp_rw [integral_const_mul, fieldVectorLevelSpinPair_coordinate_mean]
118
+ rw [fieldCommonLevel_integral h (fun i => Φ (q i) * fieldMagnetizationLevel h i)]
119
+ rfl
120
+
121
+ theorem fieldVectorLevelSpinPair_centered_test (N : ℕ) (h : FieldStep)
122
+ (q : Fin (h.depth + 1) → ℝ) (Φ : ℝ → ℝ) (j : Fin N) :
123
+ (∫ α, ∫ σ, Φ (q (fieldCommonLevel h α)) *
124
+ (spinValue (σ.1 j) * spinValue (σ.2 j) - q (fieldCommonLevel h α))
125
+ ∂fieldVectorLevelSpinPair N h (fieldCommonLevel h α)
126
+ ∂cascadeReplicaLaw h.depth (chainExponent h.cut)) =
127
+ ∫ s, Φ (q (fieldLevelIndex h s)) *
128
+ (fieldMagnetizationPath h s - q (fieldLevelIndex h s)) ∂pathMeasure := by
129
+ simp_rw [integral_const_mul,
130
+ integral_sub Integrable.of_finite (integrable_const _),
131
+ fieldVectorLevelSpinPair_coordinate_mean, integral_const, probReal_univ, one_smul]
132
+ rw [fieldCommonLevel_integral h (fun i => Φ (q i) * (fieldMagnetizationLevel h i - q i))]
133
+ rfl
134
+
135
+ end InvariantIsing
136
+
137
+ end
138
+
139
+ end OAI
lean/OAI/Probability/InvariantIsing/Fields/FieldVectorSampling.lean ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Probability.InvariantIsing.Fields.FieldGaussianProduct
2
+ import OAI.Probability.InvariantIsing.Fields.FieldSpinProduct
3
+
4
+ namespace OAI
5
+
6
+ /-! Actual vector spin sampling for independent scalar cavity fields. -/
7
+
8
+ noncomputable section
9
+ open MeasureTheory ProbabilityTheory IsingPerceptron Set
10
+ open scoped BigOperators NNReal
11
+
12
+ namespace InvariantIsing
13
+
14
+ private lemma measurable_field_product {N : ℕ} (κ : Kernel ℝ ℝ) [IsMarkovKernel κ] :
15
+ Measurable (fun z : Fin N → ℝ => Measure.pi (fun i => κ (z i))) := by
16
+ apply Measure.measurable_of_measurable_coe
17
+ intro s hs
18
+ refine MeasurableSpace.induction_on_inter
19
+ (C := fun s _ => Measurable (fun z : Fin N → ℝ => (Measure.pi (fun i => κ (z i))) s))
20
+ _root_.generateFrom_pi.symm isPiSystem_pi ?_ ?_ ?_ ?_ s hs
21
+ · simp only [measure_empty]
22
+ exact measurable_const
23
+ · rintro s ⟨t, ht, rfl⟩
24
+ simp only [Measure.pi_pi]
25
+ exact Finset.measurable_prod _ fun i _ =>
26
+ (κ.measurable_coe (ht i (mem_univ _))).comp (measurable_pi_apply i)
27
+ · intro s hs ih
28
+ have he (z : Fin N → ℝ) : (Measure.pi (fun i => κ (z i))) sᶜ =
29
+ 1 - (Measure.pi (fun i => κ (z i))) s := by
30
+ rw [measure_compl hs (measure_ne_top _ _), measure_univ]
31
+ simp_rw [he]
32
+ exact measurable_const.sub ih
33
+ · intro s hd hs ih
34
+ have he (z : Fin N → ℝ) : (Measure.pi (fun i => κ (z i))) (⋃ n, s n) =
35
+ ∑' n, (Measure.pi (fun i => κ (z i))) (s n) := measure_iUnion hd hs
36
+ simp_rw [he]
37
+ exact Measurable.tsum ih
38
+
39
+ def fieldVectorTransitionKernel (N : ℕ) (ζ : ℝ) (v : ℝ≥0)
40
+ (F : ℝ → ℝ) (hF : Measurable F) : Kernel (Fin N → ℝ) (Fin N → ℝ) :=
41
+ ⟨fun z => Measure.pi (fun i => fieldTransitionKernel ζ v F hF (z i)),
42
+ measurable_field_product _⟩
43
+
44
+ instance fieldVectorTransitionKernel_markov (N : ℕ) (ζ : ℝ) (v : ℝ≥0)
45
+ (F : ℝ → ℝ) (hF : Measurable F) :
46
+ IsMarkovKernel (fieldVectorTransitionKernel N ζ v F hF) :=
47
+ ⟨fun _ => inferInstanceAs (IsProbabilityMeasure (Measure.pi _))⟩
48
+
49
+ lemma fieldVectorTransitionKernel_eq_tilted {N : ℕ} (ζ : ℝ) (v : ℝ≥0)
50
+ (F : ℝ → ℝ) (hF : Measurable F) (hG : HasLinearGrowth F) (z : Fin N → ℝ) :
51
+ fieldVectorTransitionKernel N ζ v F hF z =
52
+ (Measure.pi (fun i => gaussianReal (z i) v)).tilted (fun y => ζ * ∑ i, F (y i)) :=
53
+ (fieldGaussian_product_tilt ζ v F hF hG z).symm
54
+
55
+ lemma fieldVectorTransitionKernel_coordinate {N : ℕ} (ζ : ℝ) (v : ℝ≥0)
56
+ (F : ℝ → ℝ) (hF : Measurable F) (hG : HasLinearGrowth F)
57
+ (a : ℝ → ℝ) (ha : Measurable a) (z : Fin N → ℝ) (j : Fin N) :
58
+ (∫ y, a (y j) ∂fieldVectorTransitionKernel N ζ v F hF z) =
59
+ fieldSpinTransition ζ v F a (z j) := by
60
+ change (∫ y, a (y j) ∂Measure.pi (fun i => fieldTransitionKernel ζ v F hF (z i))) = _
61
+ rw [integral_comp_eval ha.aestronglyMeasurable]
62
+ exact fieldTransitionKernel_integral ζ v F hF hG a (z j)
63
+
64
+ def fieldVectorSpinKernel (N : ℕ) : Kernel (Fin N → ℝ) (Spin N) :=
65
+ ⟨fun z => gibbsProbability (uniformSpinPrior N : Measure (Spin N)) (fieldEnergy z),
66
+ measurable_gibbsProbability (ν := fun _ : Fin N → ℝ =>
67
+ (uniformSpinPrior N : Measure (Spin N)))
68
+ (H := fun p : (Fin N → ℝ) × Spin N => fieldEnergy p.1 p.2)
69
+ measurable_const (by unfold fieldEnergy; fun_prop)⟩
70
+
71
+ instance fieldVectorSpinKernel_markov (N : ℕ) : IsMarkovKernel (fieldVectorSpinKernel N) := by
72
+ constructor
73
+ intro z
74
+ change IsProbabilityMeasure (gibbsProbability (uniformSpinPrior N : Measure (Spin N))
75
+ (fieldEnergy z))
76
+ infer_instance
77
+
78
+ def fieldVectorTailSpinKernel (N : ℕ) : (L : List (ℝ × ℝ≥0)) →
79
+ (∀ av ∈ L, 0 < av.1) → Kernel (Fin N → ℝ) (Spin N)
80
+ | [], _ => fieldVectorSpinKernel N
81
+ | av :: L, hL =>
82
+ let ht := fun bv hb => hL bv (List.mem_cons_of_mem av hb)
83
+ let hreg := fieldScalarValue_regular L ht measurable_logCosh logCosh_linearGrowth
84
+ fieldVectorTailSpinKernel N L ht ∘ₖ
85
+ fieldVectorTransitionKernel N av.1 av.2
86
+ (fieldScalarValue L (fun z => Real.log (Real.cosh z))) hreg.1
87
+
88
+ instance fieldVectorTailSpinKernel_markov (N : ℕ) (L : List (ℝ × ℝ≥0))
89
+ (hL : ∀ av ∈ L, 0 < av.1) : IsMarkovKernel (fieldVectorTailSpinKernel N L hL) := by
90
+ induction L with
91
+ | nil => exact fieldVectorSpinKernel_markov N
92
+ | cons av L ih =>
93
+ have ht := fun bv hb => hL bv (List.mem_cons_of_mem av hb)
94
+ let _ := ih ht
95
+ change IsMarkovKernel (_ ∘ₖ _)
96
+ infer_instance
97
+
98
+ theorem fieldVectorTailSpinKernel_coordinate_mean (N : ℕ) (L : List (ℝ × ℝ≥0))
99
+ (hL : ∀ av ∈ L, 0 < av.1) (z : Fin N → ℝ) (j : Fin N) :
100
+ (∫ σ, spinValue (σ j) ∂fieldVectorTailSpinKernel N L hL z) =
101
+ fieldScalarMean L (fun u => Real.log (Real.cosh u)) Real.tanh (z j) := by
102
+ induction L generalizing z with
103
+ | nil => exact fieldSpinGibbs_coordinate_mean z j
104
+ | cons av L ih =>
105
+ have ht := fun bv hb => hL bv (List.mem_cons_of_mem av hb)
106
+ have hreg := fieldScalarValue_regular L ht measurable_logCosh logCosh_linearGrowth
107
+ have hmean := fieldScalarMean_regular L ht measurable_logCosh logCosh_linearGrowth
108
+ (by change Measurable (fun x : ℝ => Real.tanh x); simp only [Real.tanh_eq]; fun_prop)
109
+ field_abs_tanh_le_one
110
+ change (∫ σ, spinValue (σ j) ∂(fieldVectorTailSpinKernel N L ht ∘ₖ
111
+ fieldVectorTransitionKernel N av.1 av.2
112
+ (fieldScalarValue L (fun u => Real.log (Real.cosh u))) hreg.1) z) = _
113
+ rw [Kernel.integral_comp (Integrable.of_finite)]
114
+ simp_rw [ih ht]
115
+ exact fieldVectorTransitionKernel_coordinate av.1 av.2 _ hreg.1 hreg.2 _ hmean.1 z j
116
+
117
+ end InvariantIsing
118
+
119
+ end
120
+
121
+ end OAI
lean/OAI/Probability/InvariantIsing/Fields/FieldWasserstein.lean ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OAI.Probability.InvariantIsing.Magnetic.MagneticFieldExtension
2
+ import Mathlib.MeasureTheory.Measure.Prod
3
+
4
+ namespace OAI
5
+
6
+ /-! First-moment transport is the infimum of the costs of joint laws. -/
7
+ noncomputable section
8
+ open MeasureTheory ProbabilityTheory Filter Set
9
+ open scoped ENNReal
10
+ namespace InvariantIsing
11
+
12
+ structure FieldLawCoupling (μ ν : ProbabilityMeasure ℝ) where
13
+ law : ProbabilityMeasure (ℝ × ℝ)
14
+ fst : (law : Measure (ℝ × ℝ)).map Prod.fst=(μ : Measure ℝ)
15
+ snd : (law : Measure (ℝ × ℝ)).map Prod.snd=(ν : Measure ℝ)
16
+
17
+ namespace FieldLawCoupling
18
+
19
+ variable {μ ν : ProbabilityMeasure ℝ}
20
+
21
+ def cost (p : FieldLawCoupling μ ν) : ℝ≥0∞ :=
22
+ ∫⁻ xy, ENNReal.ofReal |xy.1-xy.2| ∂(p.law : Measure (ℝ × ℝ))
23
+
24
+ lemma integrable_fst (p : FieldLawCoupling μ ν)
25
+ (hμ : Integrable (fun x : ℝ => x) (μ : Measure ℝ)) :
26
+ Integrable (fun xy : ℝ × ℝ => xy.1) (p.law : Measure (ℝ × ℝ)) := by
27
+ rw [← p.fst] at hμ
28
+ exact (integrable_map_measure (by fun_prop) measurable_fst.aemeasurable).mp hμ
29
+
30
+ lemma integrable_snd (p : FieldLawCoupling μ ν)
31
+ (hν : Integrable (fun x : ℝ => x) (ν : Measure ℝ)) :
32
+ Integrable (fun xy : ℝ × ℝ => xy.2) (p.law : Measure (ℝ × ℝ)) := by
33
+ rw [← p.snd] at hν
34
+ exact (integrable_map_measure (by fun_prop) measurable_snd.aemeasurable).mp hν
35
+
36
+ lemma cost_eq_ofReal (p : FieldLawCoupling μ ν)
37
+ (hμ : Integrable (fun x : ℝ => x) (μ : Measure ℝ))
38
+ (hν : Integrable (fun x : ℝ => x) (ν : Measure ℝ)) :
39
+ p.cost=ENNReal.ofReal (∫ xy, |xy.1-xy.2| ∂(p.law : Measure (ℝ × ℝ))) := by
40
+ symm
41
+ exact ofReal_integral_eq_lintegral_ofReal
42
+ ((p.integrable_fst hμ).sub (p.integrable_snd hν)).abs (ae_of_all _ (fun _ => abs_nonneg _))
43
+
44
+ end FieldLawCoupling
45
+
46
+ def fieldWassersteinOne (μ ν : ProbabilityMeasure ℝ) : ℝ≥0∞ :=
47
+ ⨅ p : FieldLawCoupling μ ν, p.cost
48
+
49
+ lemma exists_fieldLawCoupling_cost_lt {μ ν : ProbabilityMeasure ℝ} {ε : ℝ≥0∞}
50
+ (h : fieldWassersteinOne μ ν < ε) :
51
+ ∃ p : FieldLawCoupling μ ν, p.cost < ε :=
52
+ (iInf_lt_iff).mp h
53
+
54
+ end InvariantIsing
55
+
56
+ end
57
+
58
+ end OAI