Download data/lean/OAI/Probability/Ising/EdwardsSokal.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 11.1 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/Ising/EdwardsSokal.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Probability/Ising/EdwardsSokal.lean
-
curl -L -o EdwardsSokal.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/Ising/EdwardsSokal.lean
11.1 kB
| import OAI.Probability.Ising.RandomCluster | |
| import OAI.Probability.Ising.Colorings | |
| namespace OAI | |
| open scoped BigOperators Classical | |
| namespace BufferedIsing | |
| /-- Independent bond part of the comparison FK weight; the cluster factor | |
| is supplied by summing compatible fair cluster colors. -/ | |
| noncomputable def fkEdgeWeight {n m : β} (G : FiniteGraph n m) | |
| (F : Finset (Fin n)) (Ο : Finset (Fin m)) : β := | |
| β e β keptEdges G F, | |
| if e β Ο then 1 - Real.exp (-2 * G.coupling e) else Real.exp (-2 * G.coupling e) | |
| noncomputable def jointColorWeight {n m : β} (G : FiniteGraph n m) | |
| (I J F : Finset (Fin n)) (Ο : Finset (Fin m)) (Ο : KeptVertex F β Bool) : β := | |
| if Respects (comparisonSetoid G I J F Ο) Ο then fkEdgeWeight G F Ο else 0 | |
| noncomputable def comparisonSpinWeight {n m : β} (G : FiniteGraph n m) | |
| (I J F : Finset (Fin n)) (Ο : KeptVertex F β Bool) : β := | |
| β Ο β (keptEdges G F).powerset, jointColorWeight G I J F Ο Ο | |
| lemma sum_jointColorWeight {n m : β} (G : FiniteGraph n m) | |
| (I J F : Finset (Fin n)) (Ο : Finset (Fin m)) : | |
| (β Ο, jointColorWeight G I J F Ο Ο) = fkWeight G I J F Ο := by | |
| calc | |
| _ = fkEdgeWeight G F Ο * β Ο : KeptVertex F β Bool, | |
| if Respects (comparisonSetoid G I J F Ο) Ο then 1 else 0 := by | |
| rw [Finset.mul_sum] | |
| apply Finset.sum_congr rfl | |
| intro Ο _ | |
| simp only [jointColorWeight] | |
| split_ifs <;> simp | |
| _ = _ := by | |
| rw [sum_respects_one] | |
| exact mul_comm _ _ | |
| lemma sum_jointColorWeight_spin_product {n m : β} (G : FiniteGraph n m) | |
| (I J F : Finset (Fin n)) (Ο : Finset (Fin m)) (i j : KeptVertex F) : | |
| (β Ο, jointColorWeight G I J F Ο Ο * spin (Ο i) * spin (Ο j)) = | |
| if (comparisonSetoid G I J F Ο).r i j then fkWeight G I J F Ο else 0 := by | |
| calc | |
| _ = fkEdgeWeight G F Ο * β Ο : KeptVertex F β Bool, | |
| if Respects (comparisonSetoid G I J F Ο) Ο then spin (Ο i) * spin (Ο j) | |
| else 0 := by | |
| rw [Finset.mul_sum] | |
| apply Finset.sum_congr rfl | |
| intro Ο _ | |
| simp only [jointColorWeight] | |
| split_ifs <;> ring | |
| _ = _ := by | |
| rw [sum_respects_spin_product] | |
| split_ifs | |
| Β· exact mul_comm _ _ | |
| Β· exact mul_zero _ | |
| lemma sum_comparisonSpinWeight {n m : β} (G : FiniteGraph n m) | |
| (I J F : Finset (Fin n)) : | |
| (β Ο, comparisonSpinWeight G I J F Ο) = | |
| β Ο β (keptEdges G F).powerset, fkWeight G I J F Ο := by | |
| unfold comparisonSpinWeight | |
| rw [Finset.sum_comm] | |
| simp only [sum_jointColorWeight] | |
| lemma sum_comparisonSpinWeight_spin_product {n m : β} (G : FiniteGraph n m) | |
| (I J F : Finset (Fin n)) (i j : KeptVertex F) : | |
| (β Ο, comparisonSpinWeight G I J F Ο * spin (Ο i) * spin (Ο j)) = | |
| β Ο β (keptEdges G F).powerset, | |
| if (comparisonSetoid G I J F Ο).r i j then fkWeight G I J F Ο else 0 := by | |
| unfold comparisonSpinWeight | |
| simp only [Finset.sum_mul] | |
| rw [Finset.sum_comm] | |
| simp only [sum_jointColorWeight_spin_product] | |
| /-- Finite EdwardsβSokal color averaging after vertex deletion and separate terminal contraction. -/ | |
| lemma qZero_eq_color_correlation {n m : β} (G : FiniteGraph n m) | |
| (I J F : Finset (Fin n)) (i j : KeptVertex F) : | |
| qZero G I J F i j = | |
| (β Ο, comparisonSpinWeight G I J F Ο * spin (Ο i) * spin (Ο j)) / | |
| β Ο, comparisonSpinWeight G I J F Ο := by | |
| rw [sum_comparisonSpinWeight_spin_product, sum_comparisonSpinWeight] | |
| rfl | |
| lemma sum_subsets_product {E : Type*} [DecidableEq E] (s : Finset E) | |
| (f g : E β β) : | |
| (β Ο β s.powerset, β e β s, if e β Ο then f e else g e) = | |
| β e β s, (f e + g e) := by | |
| rw [Finset.prod_add] | |
| apply Finset.sum_congr rfl | |
| intro Ο hΟ | |
| have hsub := Finset.mem_powerset.mp hΟ | |
| rw [Finset.prod_ite] | |
| have hf : s.filter (fun e => e β Ο) = Ο := by | |
| ext e | |
| simp only [Finset.mem_filter] | |
| exact β¨And.right, fun he => β¨hsub he, heβ©β© | |
| have hg : s.filter (fun e => e β Ο) = s \ Ο := by | |
| ext e | |
| simp | |
| rw [hf, hg] | |
| /-- Extend a coloring from the vertex-DELETED graph. The values at deleted | |
| vertices are immaterial: every incident edge is absent from keptEdges. -/ | |
| def extendKept {n : β} (F : Finset (Fin n)) (Ο : KeptVertex F β Bool) : Spins n := | |
| fun v => if hv : v β F then Ο β¨v, hvβ© else false | |
| @[simp] lemma extendKept_apply {n : β} (F : Finset (Fin n)) | |
| (Ο : KeptVertex F β Bool) (v : KeptVertex F) : | |
| extendKept F Ο v.val = Ο v := by | |
| simp [extendKept, v.property] | |
| def BondCompatible {n m : β} (G : FiniteGraph n m) | |
| (F : Finset (Fin n)) (Ο : KeptVertex F β Bool) (Ο : Finset (Fin m)) : Prop := | |
| β e β Ο, extendKept F Ο (G.left e) = extendKept F Ο (G.right e) | |
| lemma respects_comparison_iff {n m : β} (G : FiniteGraph n m) | |
| (I J F : Finset (Fin n)) (Ο : Finset (Fin m)) (hΟ : Ο β keptEdges G F) | |
| (Ο : KeptVertex F β Bool) : | |
| Respects (comparisonSetoid G I J F Ο) Ο β | |
| Respects (comparisonSetoid G I J F β ) Ο β§ BondCompatible G F Ο Ο := by | |
| simp only [comparisonSetoid, respects_eqvGen] | |
| constructor | |
| Β· intro H | |
| constructor | |
| Β· intro u v huv | |
| rcases huv with hi | hj | β¨e, he, _β© | |
| Β· exact H u v (Or.inl hi) | |
| Β· exact H u v (Or.inr (Or.inl hj)) | |
| Β· exact (Finset.notMem_empty e he).elim | |
| Β· intro e he | |
| have hk := (Finset.mem_filter.mp (hΟ he)).2 | |
| let u : KeptVertex F := β¨G.left e, hk.1β© | |
| let v : KeptVertex F := β¨G.right e, hk.2β© | |
| have He := H u v (Or.inr (Or.inr β¨e, he, Or.inl β¨rfl, rflβ©β©)) | |
| simpa only [β extendKept_apply F Ο u, β extendKept_apply F Ο v] using He | |
| Β· rintro β¨H, HΟβ© u v huv | |
| rcases huv with hi | hj | β¨e, he, huv | hvuβ© | |
| Β· exact H u v (Or.inl hi) | |
| Β· exact H u v (Or.inr (Or.inl hj)) | |
| Β· have He := HΟ e he | |
| rw [huv.1, huv.2] at He | |
| simpa only [extendKept_apply] using He | |
| Β· have He := HΟ e he | |
| rw [hvu.1, hvu.2] at He | |
| simpa only [extendKept_apply] using He.symm | |
| lemma prod_conditioned_subset {E : Type*} [DecidableEq E] (s Ο : Finset E) | |
| (hΟ : Ο β s) (P : E β Prop) [DecidablePred P] (f g : E β β) : | |
| (if β e β Ο, P e then β e β s, if e β Ο then f e else g e else 0) = | |
| β e β s, if e β Ο then (if P e then f e else 0) else g e := by | |
| by_cases H : β e β Ο, P e | |
| Β· rw [ite_eq_left H] | |
| apply Finset.prod_congr rfl | |
| intro e _ | |
| by_cases he : e β Ο | |
| Β· simp only [he, H e he, ite_true] | |
| Β· simp only [he, ite_false] | |
| Β· rw [ite_eq_right H] | |
| push Not at H | |
| obtain β¨e, he, hPβ© := H | |
| symm | |
| apply Finset.prod_eq_zero (hΟ he) | |
| simp only [he, hP, ite_true, ite_false] | |
| lemma jointColorWeight_expansion {n m : β} (G : FiniteGraph n m) | |
| (I J F : Finset (Fin n)) (Ο : Finset (Fin m)) (hΟ : Ο β keptEdges G F) | |
| (Ο : KeptVertex F β Bool) : | |
| jointColorWeight G I J F Ο Ο = | |
| if Respects (comparisonSetoid G I J F β ) Ο then | |
| β e β keptEdges G F, if e β Ο then | |
| (if extendKept F Ο (G.left e) = extendKept F Ο (G.right e) | |
| then 1 - Real.exp (-2 * G.coupling e) else 0) | |
| else Real.exp (-2 * G.coupling e) | |
| else 0 := by | |
| unfold jointColorWeight | |
| rw [respects_comparison_iff G I J F Ο hΟ Ο] | |
| by_cases H : Respects (comparisonSetoid G I J F β ) Ο | |
| Β· simp only [H, true_and, ite_true] | |
| have hP := prod_conditioned_subset (keptEdges G F) Ο hΟ | |
| (fun e => extendKept F Ο (G.left e) = extendKept F Ο (G.right e)) | |
| (fun e => 1 - Real.exp (-2 * G.coupling e)) | |
| (fun e => Real.exp (-2 * G.coupling e)) | |
| unfold BondCompatible fkEdgeWeight | |
| by_cases HΟ : β e β Ο, extendKept F Ο (G.left e) = extendKept F Ο (G.right e) | |
| Β· rw [ite_eq_left HΟ] at hP β’ | |
| exact hP | |
| Β· rw [ite_eq_right HΟ] at hP β’ | |
| exact hP | |
| Β· simp only [H, false_and, ite_false] | |
| lemma comparisonSpinWeight_product {n m : β} (G : FiniteGraph n m) | |
| (I J F : Finset (Fin n)) (Ο : KeptVertex F β Bool) : | |
| comparisonSpinWeight G I J F Ο = | |
| if Respects (comparisonSetoid G I J F β ) Ο then | |
| β e β keptEdges G F, | |
| ((if extendKept F Ο (G.left e) = extendKept F Ο (G.right e) | |
| then 1 - Real.exp (-2 * G.coupling e) else 0) + | |
| Real.exp (-2 * G.coupling e)) | |
| else 0 := by | |
| unfold comparisonSpinWeight | |
| by_cases H : Respects (comparisonSetoid G I J F β ) Ο | |
| Β· simp only [H, ite_true] | |
| calc | |
| _ = β Ο β (keptEdges G F).powerset, β e β keptEdges G F, | |
| if e β Ο then | |
| (if extendKept F Ο (G.left e) = extendKept F Ο (G.right e) | |
| then 1 - Real.exp (-2 * G.coupling e) else 0) | |
| else Real.exp (-2 * G.coupling e) := by | |
| apply Finset.sum_congr rfl | |
| intro Ο hΟ | |
| rw [jointColorWeight_expansion G I J F Ο (Finset.mem_powerset.mp hΟ) Ο] | |
| simp only [H, ite_true] | |
| _ = _ := sum_subsets_product _ _ _ | |
| Β· simp only [H, ite_false] | |
| apply Finset.sum_eq_zero | |
| intro Ο hΟ | |
| rw [jointColorWeight_expansion G I J F Ο (Finset.mem_powerset.mp hΟ) Ο] | |
| simp only [H, ite_false] | |
| lemma es_one_edge_identity (K : β) (s t : Bool) : | |
| ((if s = t then 1 - Real.exp (-2 * K) else 0) + Real.exp (-2 * K)) = | |
| Real.exp (-K) * Real.exp (K * spin s * spin t) := by | |
| rw [β Real.exp_add] | |
| cases s <;> cases t <;> simp [spin] <;> ring | |
| noncomputable def deletedEnergy {n m : β} (G : FiniteGraph n m) | |
| (F : Finset (Fin n)) (Ο : KeptVertex F β Bool) : β := | |
| β e β keptEdges G F, | |
| G.coupling e * spin (extendKept F Ο (G.left e)) * spin (extendKept F Ο (G.right e)) | |
| /-- Zero-field Ising weight on the vertex-deleted graph, with I,J separately | |
| contracted by restricting each to constant spin assignments. -/ | |
| noncomputable def contractedZeroWeight {n m : β} (G : FiniteGraph n m) | |
| (I J F : Finset (Fin n)) (Ο : KeptVertex F β Bool) : β := | |
| if Respects (comparisonSetoid G I J F β ) Ο then Real.exp (deletedEnergy G F Ο) else 0 | |
| lemma comparisonSpinWeight_eq_Ising {n m : β} (G : FiniteGraph n m) | |
| (I J F : Finset (Fin n)) (Ο : KeptVertex F β Bool) : | |
| comparisonSpinWeight G I J F Ο = | |
| Real.exp (-(β e β keptEdges G F, G.coupling e)) * contractedZeroWeight G I J F Ο := by | |
| rw [comparisonSpinWeight_product] | |
| unfold contractedZeroWeight | |
| split_ifs | |
| Β· simp only [es_one_edge_identity, Finset.prod_mul_distrib, β Real.exp_sum, | |
| Finset.sum_neg_distrib] | |
| rfl | |
| Β· exact (mul_zero _).symm | |
| /-- The zero-field FK/Ising identity with vertex deletion, separate terminal contractions, and parallel edges. -/ | |
| lemma qZero_eq_zero_field_correlation {n m : β} (G : FiniteGraph n m) | |
| (I J F : Finset (Fin n)) (i j : KeptVertex F) : | |
| qZero G I J F i j = | |
| (β Ο, contractedZeroWeight G I J F Ο * spin (Ο i) * spin (Ο j)) / | |
| β Ο, contractedZeroWeight G I J F Ο := by | |
| rw [qZero_eq_color_correlation] | |
| simp only [comparisonSpinWeight_eq_Ising, mul_assoc, β Finset.mul_sum] | |
| exact mul_div_mul_left _ _ (Real.exp_ne_zero _) | |
| end BufferedIsing | |
| end OAI | |