Download data/lean/OAI/Probability/FreeIsing/Gibbs/Leaf.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 5.05 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/FreeIsing/Gibbs/Leaf.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Probability/FreeIsing/Gibbs/Leaf.lean
-
curl -L -o Leaf.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/FreeIsing/Gibbs/Leaf.lean
5.05 kB
| import OAI.Probability.FreeIsing.Gibbs.Weights | |
| namespace OAI | |
| noncomputable section | |
| namespace Problem367.GibbsLeaf | |
| def energy {d : β} (beta : β) (h : TreeVertex d β β) | |
| (D : Finset (TreeVertex d)) (eta : TreeVertex d β IsingSpin) : β := | |
| (β x β D, h x * spinSign (eta x)) + | |
| beta * β e β inducedEdges D, spinSign (eta e.1) * spinSign (eta e.2) | |
| def weight {d : β} (beta : β) (h : TreeVertex d β β) | |
| (D : Finset (TreeVertex d)) (eta : TreeVertex d β IsingSpin) : β := | |
| Real.exp (energy beta h D eta) | |
| theorem energy_congr_on {d : β} (beta : β) (h : TreeVertex d β β) | |
| (D : Finset (TreeVertex d)) {eta xi : TreeVertex d β IsingSpin} | |
| (heq : β x β D, eta x = xi x) : energy beta h D eta = energy beta h D xi := by | |
| classical | |
| unfold energy | |
| congr 1 | |
| Β· exact Finset.sum_congr rfl (fun x hx => by rw [heq x hx]) | |
| Β· congr 1 | |
| apply Finset.sum_congr rfl | |
| intro e he | |
| have hm := (Finset.mem_filter.mp he).1 | |
| rw [Finset.product_eq_sprod] at hm | |
| obtain β¨hu, hvβ© := Finset.mem_product.mp hm | |
| rw [heq e.1 hu, heq e.2 hv] | |
| theorem energy_update_eq_erase_add | |
| {d : β} {D : Finset (TreeVertex d)} {v p : TreeVertex d} | |
| (beta : β) (h : TreeVertex d β β) (hv : v β D) (hpne : p β v) | |
| (hedges : inducedEdges D = insert (p, v) (inducedEdges (D.erase v))) | |
| (eta : TreeVertex d β IsingSpin) (s : IsingSpin) : | |
| energy beta h D (Function.update eta v s) = energy beta h (D.erase v) eta + | |
| (h v + beta * spinSign (eta p)) * spinSign s := by | |
| classical | |
| have hnot : (p, v) β inducedEdges (D.erase v) := by | |
| simp [inducedEdges, Finset.product_eq_sprod] | |
| have hfield : (β x β D, h x * spinSign (Function.update eta v s x)) = | |
| (β x β D.erase v, h x * spinSign (eta x)) + h v * spinSign s := by | |
| rw [β Finset.sum_erase_add D _ hv] | |
| simp only [Function.update_self] | |
| congr 1 | |
| apply Finset.sum_congr rfl | |
| intro x hx | |
| rw [Function.update_of_ne (Finset.mem_erase.mp hx).1] | |
| have hedge : (β e β inducedEdges (D.erase v), | |
| spinSign (Function.update eta v s e.1) * spinSign (Function.update eta v s e.2)) = | |
| β e β inducedEdges (D.erase v), spinSign (eta e.1) * spinSign (eta e.2) := by | |
| apply Finset.sum_congr rfl | |
| intro e he | |
| have hm := (Finset.mem_filter.mp he).1 | |
| rw [Finset.product_eq_sprod] at hm | |
| obtain β¨hu, hwβ© := Finset.mem_product.mp hm | |
| rw [Function.update_of_ne (Finset.mem_erase.mp hu).1, | |
| Function.update_of_ne (Finset.mem_erase.mp hw).1] | |
| unfold energy | |
| rw [hfield, hedges, Finset.sum_insert hnot, hedge] | |
| simp only [Function.update_of_ne hpne, Function.update_self] | |
| ring | |
| theorem sum_weight_update_of_edges | |
| {d : β} {D : Finset (TreeVertex d)} {v p : TreeVertex d} | |
| (beta : β) (h : TreeVertex d β β) (hv : v β D) (hpne : p β 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)) = | |
| 2 * Real.cosh (h v + beta * spinSign (eta p)) * weight beta h (D.erase v) eta := by | |
| simp only [weight, energy_update_eq_erase_add beta h hv hpne hedges, Real.exp_add] | |
| rw [β Finset.mul_sum, sum_isingSpin] | |
| simp only [spinSign_neg, spinSign_pos, mul_neg_one, mul_one] | |
| rw [Real.cosh_eq] | |
| ring | |
| theorem sum_weight_update_leaf | |
| {d : β} {D : Finset (TreeVertex d)} {v p : TreeVertex d} | |
| (beta : β) (h : TreeVertex d β β) | |
| (hv : v β D) (hp : p β D) (hpv : treeAdj p v) | |
| (hplen : p.1.length < v.1.length) | |
| (hmax : β x β D, x.1.length β€ v.1.length) | |
| (eta : TreeVertex d β IsingSpin) : | |
| (β s : IsingSpin, weight beta h D (Function.update eta v s)) = | |
| 2 * Real.cosh (h v + beta * spinSign (eta p)) * weight beta h (D.erase v) eta := by | |
| apply sum_weight_update_of_edges beta h hv | |
| Β· intro heq | |
| subst p | |
| exact lt_irrefl _ hplen | |
| Β· exact inducedEdges_eq_insert_erase_of_max_length hv hp hpv hplen hmax | |
| theorem sum_weight_eq_erase_sum | |
| {d : β} {D : Finset (TreeVertex d)} {v p : TreeVertex d} | |
| (beta : β) (h : TreeVertex d β β) (hv : v β D) (hpne : p β v) | |
| (hedges : inducedEdges D = insert (p, v) (inducedEdges (D.erase v))) : | |
| (β eta : D β IsingSpin, weight beta h D (extendFiniteSpin D eta)) = | |
| β eta : D.erase v β IsingSpin, | |
| 2 * Real.cosh (h v + beta * spinSign (extendFiniteSpin (D.erase v) eta p)) * | |
| weight beta h (D.erase v) (extendFiniteSpin (D.erase v) eta) := by | |
| classical | |
| calc | |
| _ = β z : (D.erase v β IsingSpin) Γ IsingSpin, | |
| weight beta h D (extendFiniteSpin D ((finiteSpinEraseEquiv hv).symm z)) := | |
| ((finiteSpinEraseEquiv hv).symm.sum_comp | |
| (fun eta => weight beta h D (extendFiniteSpin D eta))).symm | |
| _ = _ := by | |
| rw [Fintype.sum_prod_type] | |
| apply Finset.sum_congr rfl | |
| intro eta _ | |
| simp only [extendFiniteSpin_eraseEquiv_symm] | |
| exact sum_weight_update_of_edges beta h hv hpne hedges _ | |
| end Problem367.GibbsLeaf | |
| end | |
| end OAI | |