File size: 5,180 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.FreeIsing.Cavity.LogOdds
import OAI.Probability.FreeIsing.Gibbs.Leaf
namespace OAI
noncomputable section
namespace Problem367.GibbsLeaf
def eliminationConstant (beta z : β) : β :=
2 * Real.exp ((Real.log (Real.cosh (z + beta)) + Real.log (Real.cosh (z - beta))) / 2)
theorem eliminationConstant_pos (beta z : β) : 0 < eliminationConstant beta z := by
unfold eliminationConstant
positivity
theorem cosh_eq_eliminationConstant_mul_message (beta z : β) (s : IsingSpin) :
2 * Real.cosh (z + beta * spinSign s) =
eliminationConstant beta z * Real.exp
(cavityMessage (Real.tanh beta) z * spinSign s) := by
unfold eliminationConstant
rw [mul_assoc, β Real.exp_add, cavityMessage_eq_log_cosh_sub]
cases s
Β· simp only [spinSign_neg, mul_neg_one]
rw [show (Real.log (Real.cosh (z + beta)) + Real.log (Real.cosh (z - beta))) / 2 +
-((Real.log (Real.cosh (z + beta)) - Real.log (Real.cosh (z - beta))) / 2) =
Real.log (Real.cosh (z - beta)) by ring]
rw [Real.exp_log (Real.cosh_pos _)]
congr 2
Β· simp only [spinSign_pos, mul_one]
rw [show (Real.log (Real.cosh (z + beta)) + Real.log (Real.cosh (z - beta))) / 2 +
(Real.log (Real.cosh (z + beta)) - Real.log (Real.cosh (z - beta))) / 2 =
Real.log (Real.cosh (z + beta)) by ring]
rw [Real.exp_log (Real.cosh_pos _)]
theorem energy_update_field {d : β} (beta : β) (h : TreeVertex d β β)
(D : Finset (TreeVertex d)) {p : TreeVertex d} (hp : p β D)
(z : β) (eta : TreeVertex d β IsingSpin) :
energy beta (Function.update h p (h p + z)) D eta =
energy beta h D eta + z * spinSign (eta p) := by
classical
have hsum : (β x β D.erase p, Function.update h p (h p + z) x * spinSign (eta x)) =
β x β D.erase p, h x * spinSign (eta x) := by
apply Finset.sum_congr rfl
intro x hx
rw [Function.update_of_ne (Finset.mem_erase.mp hx).1]
unfold energy
rw [β Finset.sum_erase_add D
(fun x => Function.update h p (h p + z) x * spinSign (eta x)) hp,
β Finset.sum_erase_add D (fun x => h x * spinSign (eta x)) hp, hsum]
simp only [Function.update_self]
ring
theorem sum_weight_update_eq_cavity
{d : β} {D : Finset (TreeVertex d)} {v p : TreeVertex d}
(beta : β) (h : TreeVertex d β β) (hv : v β D) (hp : p β D.erase v)
(hedges : inducedEdges D = insert (p, v) (inducedEdges (D.erase v)))
(eta : TreeVertex d β IsingSpin) :
(β s : IsingSpin, weight beta h D (Function.update eta v s)) =
eliminationConstant beta (h v) *
weight beta (Function.update h p (h p + cavityMessage (Real.tanh beta) (h v)))
(D.erase v) eta := by
rw [sum_weight_update_of_edges beta h hv (Finset.mem_erase.mp hp).1 hedges,
cosh_eq_eliminationConstant_mul_message]
simp only [weight, energy_update_field beta h (D.erase v) hp, Real.exp_add]
ring
theorem partition_eq_cavity_partition
{d : β} {D : Finset (TreeVertex d)} {v p : TreeVertex d}
(beta : β) (h : TreeVertex d β β) (hv : v β D) (hp : p β D.erase v)
(hedges : inducedEdges D = insert (p, v) (inducedEdges (D.erase v))) :
(β eta : D β IsingSpin, weight beta h D (extendFiniteSpin D eta)) =
eliminationConstant beta (h v) *
β eta : D.erase v β IsingSpin,
weight beta (Function.update h p (h p + cavityMessage (Real.tanh beta) (h v)))
(D.erase v) (extendFiniteSpin (D.erase v) eta) := by
classical
rw [sum_weight_eq_erase_sum beta h hv (Finset.mem_erase.mp hp).1 hedges, Finset.mul_sum]
apply Finset.sum_congr rfl
intro eta _
rw [β sum_weight_update_of_edges beta h hv (Finset.mem_erase.mp hp).1 hedges]
exact sum_weight_update_eq_cavity beta h hv hp hedges _
def partition {d : β} (beta : β) (h : TreeVertex d β β)
(D : Finset (TreeVertex d)) : β :=
β eta : D β IsingSpin, weight beta h D (extendFiniteSpin D eta)
def mass {d : β} (beta : β) (h : TreeVertex d β β)
(D : Finset (TreeVertex d)) (eta : TreeVertex d β IsingSpin) : β :=
weight beta h D eta / partition beta h D
theorem partition_pos {d : β} (beta : β) (h : TreeVertex d β β)
(D : Finset (TreeVertex d)) : 0 < partition beta h D := by
classical
let : Nonempty (D β IsingSpin) := β¨fun _ => .negβ©
exact Finset.sum_pos (fun eta _ => Real.exp_pos _) Finset.univ_nonempty
theorem sum_mass_update_eq_cavity
{d : β} {D : Finset (TreeVertex d)} {v p : TreeVertex d}
(beta : β) (h : TreeVertex d β β) (hv : v β D) (hp : p β D.erase v)
(hedges : inducedEdges D = insert (p, v) (inducedEdges (D.erase v)))
(eta : TreeVertex d β IsingSpin) :
(β s : IsingSpin, mass beta h D (Function.update eta v s)) =
mass beta (Function.update h p (h p + cavityMessage (Real.tanh beta) (h v)))
(D.erase v) eta := by
classical
simp only [mass, β Finset.sum_div]
rw [sum_weight_update_eq_cavity beta h hv hp hedges]
unfold partition
rw [partition_eq_cavity_partition beta h hv hp hedges]
exact mul_div_mul_left _ _ (ne_of_gt (eliminationConstant_pos beta (h v)))
end Problem367.GibbsLeaf
end
end OAI
|