math / data /lean /OAI /Probability /Ising /EdwardsSokal.lean
introvoyz045's picture
Migrated from GitHub
4a56cd6 verified
Raw History Blame Contribute Delete
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