File size: 5,318 Bytes
4a56cd6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
import OAI.Probability.InvariantIsing.Core.Model
import OAI.Probability.InvariantIsing.Core.Ward

namespace OAI

/-! Exact finite-volume algebra for the coupled cavity comparison.  The
spectral coupling and its Gaussian limit are separate source obligations. -/

noncomputable section
open IsingPerceptron
open scoped BigOperators Matrix

namespace InvariantIsing

def cavityQuadratic {d : β„•} (A : Matrix (Fin d) (Fin d) ℝ) (y : Fin d β†’ ℝ) : ℝ :=
  (1 / 2 : ℝ) * βˆ‘ i, βˆ‘ j, y i * A i j * y j

def cavityLogFactor {d n : β„•} (K : Matrix (Fin d) (Fin d) ℝ)
    (L : Matrix (Fin d) (Fin n) ℝ) (C : Matrix (Fin n) (Fin n) ℝ)
    (y : Fin d β†’ ℝ) (Ξ΅ : Spin n) : ℝ :=
  cavityQuadratic K y + (βˆ‘ i, βˆ‘ j, y i * L i j * spinValue (Ξ΅ j)) +
    cavityQuadratic C (fun j => spinValue (Ξ΅ j))

lemma cavityQuadratic_sub {d : β„•} (A B : Matrix (Fin d) (Fin d) ℝ) (y : Fin d β†’ ℝ) :
    cavityQuadratic (A - B) y = cavityQuadratic A y - cavityQuadratic B y := by
  simp only [cavityQuadratic, Matrix.sub_apply, mul_sub, sub_mul, Finset.sum_sub_distrib]

/-- The exact exponent difference in `cav:factor`, with no commutativity
assumption on the two symmetric special-coordinate blocks. -/
theorem cavity_block_factor {d n : β„•} (A A0 : Matrix (Fin d) (Fin d) ℝ)
    (L : Matrix (Fin d) (Fin n) ℝ) (C : Matrix (Fin n) (Fin n) ℝ)
    (y : Fin d β†’ ℝ) (Ξ΅ : Spin n) :
    (1 / 2 : ℝ) * (βˆ‘ i : Fin d βŠ• Fin n, βˆ‘ j : Fin d βŠ• Fin n,
      Sum.elim y (fun a => spinValue (Ξ΅ a)) i *
        (Matrix.fromBlocks A L L.transpose C) i j *
        Sum.elim y (fun a => spinValue (Ξ΅ a)) j) - cavityQuadratic A0 y =
      cavityLogFactor (A - A0) L C y Ξ΅ := by
  have hcross : (βˆ‘ j : Fin n, βˆ‘ i : Fin d, spinValue (Ξ΅ j) * L i j * y i) =
      βˆ‘ i : Fin d, βˆ‘ j : Fin n, y i * L i j * spinValue (Ξ΅ j) := by
    rw [Finset.sum_comm]
    apply Finset.sum_congr rfl
    intro i _
    apply Finset.sum_congr rfl
    intro j _
    ring_nf
  simp only [Fintype.sum_sum_type, Sum.elim_inl, Sum.elim_inr,
    Matrix.fromBlocks_apply₁₁, Matrix.fromBlocks_apply₁₂, Matrix.fromBlocks_apply₂₁,
    Matrix.fromBlocks_applyβ‚‚β‚‚, Matrix.transpose_apply, Finset.sum_add_distrib]
  rw [hcross]
  unfold cavityLogFactor
  rw [cavityQuadratic_sub]
  unfold cavityQuadratic
  ring_nf

/-- The base Gibbs law times the independent uniform probability on the
cavity cube, evaluated on the positive cavity factor. -/
def cavityFactorMean {N n : β„•} (H : Spin N β†’ ℝ) (V : Spin N β†’ Spin n β†’ ℝ) : ℝ :=
  (Fintype.card (Spin n) : ℝ)⁻¹ *
    βˆ‘ Οƒ, (Real.exp (H Οƒ) / βˆ‘ Ο„, Real.exp (H Ο„)) * βˆ‘ Ξ΅, Real.exp (V Οƒ Ξ΅)

lemma cavityFactorMean_eq_gibbsAverage {N n : β„•} (H : Spin N β†’ ℝ)
    (V : Spin N β†’ Spin n β†’ ℝ) :
    cavityFactorMean H V = gibbsAverage (fun _ => 1) H
      (fun Οƒ => (Fintype.card (Spin n) : ℝ)⁻¹ * βˆ‘ Ξ΅, Real.exp (V Οƒ Ξ΅)) := by
  simp only [cavityFactorMean, gibbsAverage, finiteGibbs, finitePartition, one_mul,
    Finset.mul_sum]
  apply Finset.sum_congr rfl
  intro Οƒ _
  ring_nf

lemma cavityFactorMean_eq_ratio {N n : β„•} (H : Spin N β†’ ℝ)
    (V : Spin N β†’ Spin n β†’ ℝ) :
    cavityFactorMean H V = (Fintype.card (Spin n) : ℝ)⁻¹ *
      ((βˆ‘ x : Spin N Γ— Spin n, Real.exp (H x.1 + V x.1 x.2)) /
        βˆ‘ Οƒ, Real.exp (H Οƒ)) := by
  unfold cavityFactorMean
  simp only [div_mul_eq_mul_div, ← Finset.sum_div]
  congr 1
  congr 1
  simp only [Fintype.sum_prod_type, Real.exp_add, Finset.mul_sum]

lemma cavityFactorMean_pos {N n : β„•} (H : Spin N β†’ ℝ) (V : Spin N β†’ Spin n β†’ ℝ) :
    0 < cavityFactorMean H V := by
  rw [cavityFactorMean_eq_ratio]
  have hc : (0 : ℝ) < Fintype.card (Spin n) := by exact_mod_cast Fintype.card_pos
  exact mul_pos (inv_pos.mpr hc) (div_pos (sum_exp_pos _) (sum_exp_pos H))

/-- Exact finite log-partition increment for probability-normalized
partition functions, at the base endpoint of the cavity interpolation. -/
theorem logPartition_cavity_increment {N n : β„•} (H : Spin N β†’ ℝ)
    (V : Spin N β†’ Spin n β†’ ℝ) :
    logPartition (fun x : Spin N Γ— Spin n => H x.1 + V x.1 x.2) - logPartition H =
      Real.log (cavityFactorMean H V) := by
  have hN : (Fintype.card (Spin N) : ℝ) β‰  0 := by exact_mod_cast Fintype.card_ne_zero
  have hn : (Fintype.card (Spin n) : ℝ) β‰  0 := by exact_mod_cast Fintype.card_ne_zero
  have hfull := (sum_exp_pos (fun x : Spin N Γ— Spin n => H x.1 + V x.1 x.2)).ne'
  have hbase := (sum_exp_pos H).ne'
  rw [logPartition_eq, logPartition_eq, cavityFactorMean_eq_ratio,
    Real.log_mul (inv_ne_zero hn) (div_ne_zero hfull hbase), Real.log_inv,
    Real.log_div hfull hbase]
  simp only [Fintype.card_prod, Nat.cast_mul]
  rw [Real.log_mul hN hn]
  ring_nf

theorem logPartition_cavityBlock_increment {N d n : β„•} (H : Spin N β†’ ℝ)
    (K : Matrix (Fin d) (Fin d) ℝ) (L : Matrix (Fin d) (Fin n) ℝ)
    (C : Matrix (Fin n) (Fin n) ℝ) (y : Spin N β†’ Fin d β†’ ℝ) :
    logPartition (fun x : Spin N Γ— Spin n => H x.1 + cavityLogFactor K L C (y x.1) x.2) -
      logPartition H = Real.log (cavityFactorMean H (fun Οƒ Ξ΅ => cavityLogFactor K L C (y Οƒ) Ξ΅)) :=
  logPartition_cavity_increment (N := N) (n := n) H
    (fun Οƒ Ξ΅ => cavityLogFactor K L C (y Οƒ) Ξ΅)

end InvariantIsing

end

end OAI