Download data/lean/OAI/Probability/FreeIsing/Gibbs/LeafMessage.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 5.18 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/FreeIsing/Gibbs/LeafMessage.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Probability/FreeIsing/Gibbs/LeafMessage.lean
-
curl -L -o LeafMessage.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/FreeIsing/Gibbs/LeafMessage.lean
5.18 kB
| 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 | |