yang
This project has not described itself yet.
Brought by drakestapleton
yang / proofs / WilsonReplicaExchange.lean
| 1 | -- SPDX-License-Identifier: Apache-2.0 |
| 2 | import WilsonWordClustering |
| 3 | |
| 4 | namespace YangMills.PeriodicWilson |
| 5 | open FundamentalSU2 MeasureTheory Real |
| 6 | noncomputable section |
| 7 | |
| 8 | abbrev WilsonConfig (l : ℕ+) := Configuration gaugeGroup l |
| 9 | abbrev WilsonReplicas (l : ℕ+) := WilsonConfig l × WilsonConfig l |
| 10 | private abbrev G := gaugeGroup.image |
| 11 | abbrev prior (l : ℕ+) := Measure.pi (fun _ : Edge l => su2Haar) |
| 12 | private abbrev law (l : ℕ+) (β : ℝ) := wilsonLaw gaugeGroup l β su2Haar |
| 13 | |
| 14 | /-- Two independent copies of the normalized Wilson field. -/ |
| 15 | def replicaLaw (l : ℕ+) (β : ℝ) := (law l β).prod (law l β) |
| 16 | |
| 17 | instance replicaLaw_probability (l : ℕ+) (β : ℝ) : IsProbabilityMeasure (replicaLaw l β) := by |
| 18 | haveI := wilson_probability l β |
| 19 | unfold replicaLaw; infer_instance |
| 20 | |
| 21 | /-- Exchange both replicas on a selected set of links. -/ |
| 22 | def exchangeLinks {l : ℕ+} (m : Edge l → Bool) (z : WilsonReplicas l) : WilsonReplicas l := |
| 23 | (fun e => if m e then z.2 e else z.1 e, fun e => if m e then z.1 e else z.2 e) |
| 24 | |
| 25 | theorem exchangeLinks_involutive {l : ℕ+} (m : Edge l → Bool) : Function.Involutive (exchangeLinks m) := by |
| 26 | intro z; apply Prod.ext <;> funext e <;> cases h : m e <;> simp [exchangeLinks,h] |
| 27 | |
| 28 | theorem exchangeLinks_commute {l : ℕ+} (m n : Edge l → Bool) (z : WilsonReplicas l) : |
| 29 | exchangeLinks m (exchangeLinks n z) = exchangeLinks n (exchangeLinks m z) := by |
| 30 | apply Prod.ext <;> funext e <;> cases a : m e <;> cases b : n e <;> simp [exchangeLinks,a,b] |
| 31 | |
| 32 | theorem exchange_cont {l : ℕ+} (m : Edge l → Bool) : Continuous (exchangeLinks m) := by |
| 33 | apply Continuous.prodMk <;> apply continuous_pi <;> intro e <;> |
| 34 | split <;> fun_prop |
| 35 | |
| 36 | theorem exchange_preserving {l : ℕ+} (m : Edge l → Bool) : |
| 37 | MeasurePreserving (exchangeLinks m) ((prior l).prod (prior l)) ((prior l).prod (prior l)) := by |
| 38 | let E := MeasurableEquiv.arrowProdEquivProdArrow G G (Edge l) |
| 39 | have he := measurePreserving_arrowProdEquivProdArrow G G (Edge l) (fun _ => su2Haar) (fun _ => su2Haar) |
| 40 | let f (e : Edge l) (x : G × G) := if m e then x.swap else x |
| 41 | have hf (e : Edge l) : MeasurePreserving (f e) (su2Haar.prod su2Haar) (su2Haar.prod su2Haar) := by |
| 42 | cases h : m e <;> simp only [f,h, Bool.false_eq_true, if_false, if_true] |
| 43 | · exact MeasurePreserving.id _ |
| 44 | · exact Measure.measurePreserving_swap |
| 45 | have H := he.comp ((measurePreserving_pi _ _ hf).comp (he.symm E)) |
| 46 | convert H using 1 |
| 47 | funext z; apply Prod.ext <;> funext e <;> cases a : m e <;> simp [exchangeLinks, E, f, Function.comp_def, a, |
| 48 | MeasurableEquiv.arrowProdEquivProdArrow, Equiv.arrowProdEquivProdArrow] |
| 49 | |
| 50 | private theorem continuous_wilsonEnergy {l : ℕ+} : Continuous (wilsonEnergy (g := gaugeGroup) (l := l)) := by |
| 51 | unfold wilsonEnergy |
| 52 | apply continuous_finsetSum |
| 53 | intro p _ |
| 54 | have h : Continuous (fun U : WilsonConfig l => plaquette U p.1 p.2.val.1 p.2.val.2) := by unfold plaquette; fun_prop |
| 55 | exact continuous_const.sub ((Complex.continuous_re.comp |
| 56 | ((continuous_subtype_val.comp (continuous_subtype_val.comp h)).matrix_trace)).div_const _) |
| 57 | |
| 58 | def logWeight {l : ℕ+} (β : ℝ) (z : WilsonReplicas l) := -β*(wilsonEnergy z.1 + wilsonEnergy z.2) |
| 59 | |
| 60 | theorem logWeight_cont {l : ℕ+} (β : ℝ) : Continuous (logWeight (l := l) β) := |
| 61 | continuous_const.mul ((continuous_wilsonEnergy.comp continuous_fst).add (continuous_wilsonEnergy.comp continuous_snd)) |
| 62 | |
| 63 | /-- Half the change of Wilson log weight from keeping to exchanging the selected links. -/ |
| 64 | def exchangeField {l : ℕ+} (β : ℝ) (m : Edge l → Bool) (z : WilsonReplicas l) := |
| 65 | (logWeight β z - logWeight β (exchangeLinks m z))/2 |
| 66 | |
| 67 | theorem exchangeField_cont {l : ℕ+} (β : ℝ) (m : Edge l → Bool) : Continuous (exchangeField β m) := |
| 68 | ((logWeight_cont β).sub ((logWeight_cont β).comp (exchange_cont m))).div_const _ |
| 69 | |
| 70 | theorem replica_integral {l : ℕ+} (β : ℝ) (D : WilsonReplicas l → ℝ) : |
| 71 | ∫ z, D z ∂replicaLaw l β = |
| 72 | (∫ z, exp (logWeight β z)*D z ∂(prior l).prod (prior l)) / |
| 73 | (∫ U, exp (-β*wilsonEnergy U) ∂prior l)^2 := by |
| 74 | let w := fun U : WilsonConfig l => exp (-β*wilsonEnergy U) |
| 75 | let Z := ∫ U, w U ∂prior l |
| 76 | let f := fun U => ENNReal.ofReal (w U/Z) |
| 77 | have hw : Continuous w := continuous_exp.comp (continuous_const.mul continuous_wilsonEnergy) |
| 78 | have hZ : 0 < Z := integral_exp_pos (hw.integrable_of_hasCompactSupport (HasCompactSupport.of_compactSpace _)) |
| 79 | have hf : Measurable f := (hw.measurable.div_const _).ennreal_ofReal |
| 80 | change (∫ z, D z ∂((prior l).withDensity f).prod ((prior l).withDensity f)) = |
| 81 | (∫ z, exp (logWeight β z)*D z ∂(prior l).prod (prior l))/Z^2 |
| 82 | rw [prod_withDensity hf hf, integral_withDensity_eq_integral_toReal_smul] |
| 83 | · have he (z : WilsonReplicas l) : (f z.1 * f z.2).toReal • D z = exp (logWeight β z)*D z / Z^2 := by |
| 84 | simp only [f, ENNReal.toReal_mul, ENNReal.toReal_ofReal (div_nonneg (exp_pos _).le hZ.le), smul_eq_mul, |
| 85 | w, logWeight, mul_add, exp_add] |
| 86 | ring |
| 87 | simp_rw [he]; rw [integral_div] |
| 88 | · exact (hf.comp measurable_fst).mul (hf.comp measurable_snd) |
| 89 | · exact .of_forall fun z => ENNReal.mul_lt_top (ENNReal.ofReal_lt_top) (ENNReal.ofReal_lt_top) |
| 90 | |
| 91 | theorem replica_tanh_continuous : Continuous Real.tanh := by |
| 92 | have h : Real.tanh = fun x => sinh x / cosh x := funext tanh_eq_sinh_div_cosh |
| 93 | rw [h]; exact continuous_sinh.div continuous_cosh fun x => (cosh_pos x).ne' |
| 94 | |
| 95 | private theorem tanh_exchange (a b : ℝ) : (exp a + exp b)*tanh ((a-b)/2) = exp a - exp b := by |
| 96 | have h := PhaseTwo.tanh_quarter_eq (2*(a-b)) |
| 97 | rw [show 2*(a-b)/4 = (a-b)/2 by ring, show 2*(a-b)/2 = a-b by ring, exp_sub] at h |
| 98 | rw [h] |
| 99 | field_simp |
| 100 | |
| 101 | /-- The orbit calculation works for every finite exchange-invariant prior. -/ |
| 102 | theorem weighted_exchange_identity {l : ℕ+} (β : ℝ) (m : Edge l → Bool) |
| 103 | (μ : Measure (WilsonReplicas l)) [IsFiniteMeasure μ] (hμ : MeasurePreserving (exchangeLinks m) μ μ) |
| 104 | {D : WilsonReplicas l → ℝ} (hc : Continuous D) (ha : ∀ z, D (exchangeLinks m z) = -D z) : |
| 105 | (∫ z, exp (logWeight β z)*D z ∂μ) = ∫ z, exp (logWeight β z)*(D z*tanh (exchangeField β m z)) ∂μ := by |
| 106 | let S := exchangeLinks m |
| 107 | let f := fun z => exp (logWeight β z)*D z |
| 108 | let g := fun z => exp (logWeight β z)*(D z*tanh (exchangeField β m z)) |
| 109 | have cf : Continuous f := (continuous_exp.comp (logWeight_cont β)).mul hc |
| 110 | have cg : Continuous g := (continuous_exp.comp (logWeight_cont β)).mul (hc.mul (replica_tanh_continuous.comp (exchangeField_cont β m))) |
| 111 | have emb : MeasurableEmbedding S := (show WilsonReplicas l ≃ᵐ WilsonReplicas l from |
| 112 | ⟨⟨S,S,exchangeLinks_involutive m,exchangeLinks_involutive m⟩,(exchange_cont m).measurable,(exchange_cont m).measurable⟩).measurableEmbedding |
| 113 | have sym (v : WilsonReplicas l → ℝ) (cv : Continuous v) : |
| 114 | ∫ z, v z + v (S z) ∂μ = (∫ z, v z ∂μ) + ∫ z, v z ∂μ := by |
| 115 | have cS : Continuous (fun z => v (S z)) := cv.comp (exchange_cont m) |
| 116 | rw [integral_add (μ := μ) (cv.integrable_of_hasCompactSupport (HasCompactSupport.of_compactSpace _)) |
| 117 | (cS.integrable_of_hasCompactSupport (HasCompactSupport.of_compactSpace _)), |
| 118 | hμ.integral_comp emb v] |
| 119 | have hp (z : WilsonReplicas l) : f z + f (S z) = g z + g (S z) := by |
| 120 | have hflip : exchangeField β m (S z) = -exchangeField β m z := by |
| 121 | simp only [S,exchangeField,exchangeLinks_involutive m z]; ring |
| 122 | simp only [f,g,hflip,tanh_neg, S,ha] |
| 123 | have H := tanh_exchange (logWeight β z) (logWeight β (exchangeLinks m z)) |
| 124 | change (_ + _) * tanh (exchangeField β m z) = _ at H |
| 125 | linear_combination -D z * H |
| 126 | have h := integral_congr_ae (μ := μ) (.of_forall hp) |
| 127 | rw [sym f cf, sym g cg] at h |
| 128 | linarith only [h] |
| 129 | |
| 130 | /-- An antisymmetric observable acquires one signed boundary factor in its |
| 131 | expectation. This is a change of variables under the product Haar prior. -/ |
| 132 | theorem replica_exchange_identity {l : ℕ+} (β : ℝ) (m : Edge l → Bool) {D : WilsonReplicas l → ℝ} |
| 133 | (hc : Continuous D) (ha : ∀ z, D (exchangeLinks m z) = -D z) : |
| 134 | (∫ z, D z ∂replicaLaw l β) = ∫ z, D z * tanh (exchangeField β m z) ∂replicaLaw l β := by |
| 135 | rw [replica_integral,replica_integral,weighted_exchange_identity β m _ (exchange_preserving m) hc ha] |
| 136 | |
| 137 | def replicaDifference {l : ℕ+} (F G : WilsonConfig l → ℝ) (z : WilsonReplicas l) := |
| 138 | (F z.1-F z.2)*(G z.1-G z.2) |
| 139 | |
| 140 | theorem twice_wilsonCovariance {l : ℕ+} (β : ℝ) {F G : WilsonConfig l → ℝ} |
| 141 | (hF : Continuous F) (hG : Continuous G) : |
| 142 | 2*wilsonCovariance β F G = ∫ z, replicaDifference F G z ∂replicaLaw l β := by |
| 143 | haveI := wilson_probability l β |
| 144 | let μ : Measure (WilsonConfig l) := law l β |
| 145 | haveI : IsProbabilityMeasure μ := wilson_probability l β |
| 146 | haveI : IsFiniteMeasure μ := ⟨by rw [measure_univ]; exact ENNReal.one_lt_top⟩ |
| 147 | haveI : SigmaFinite μ := IsFiniteMeasure.toSigmaFinite μ |
| 148 | haveI : SFinite μ := inferInstance |
| 149 | have hi {f : WilsonReplicas l → ℝ} (hf : Continuous f) : Integrable f (μ.prod μ) := |
| 150 | hf.integrable_of_hasCompactSupport (HasCompactSupport.of_compactSpace _) |
| 151 | let H := fun z : WilsonReplicas l => F z.1*G z.1 + F z.2*G z.2 - (F z.1*G z.2 + F z.2*G z.1) |
| 152 | have e (z : WilsonReplicas l) : replicaDifference F G z = H z := by dsimp [replicaDifference,H]; ring |
| 153 | simp_rw [e]; unfold H |
| 154 | change _ = ∫ z, _ ∂μ.prod μ |
| 155 | rw [integral_sub (hi (by fun_prop)) (hi (by fun_prop)), integral_add (hi (by fun_prop)) (hi (by fun_prop)), |
| 156 | integral_add (hi (by fun_prop)) (hi (by fun_prop))] |
| 157 | have hswap : (∫ z : WilsonReplicas l, F z.2*G z.1 ∂μ.prod μ) = ∫ z : WilsonReplicas l, G z.1*F z.2 ∂μ.prod μ := |
| 158 | integral_congr_ae (.of_forall fun _ => mul_comm ..) |
| 159 | rw [hswap, integral_prod_mul (μ := μ) (ν := μ) F G, integral_prod_mul (μ := μ) (ν := μ) G F] |
| 160 | rw [integral_fun_fst (μ := μ) (ν := μ) (fun u => F u * G u), integral_fun_snd (μ := μ) (ν := μ) (fun u => F u * G u)] |
| 161 | simp only [probReal_univ, one_smul, wilsonCovariance, μ] |
| 162 | ring |
| 163 | |
| 164 | #print axioms replica_exchange_identity |
| 165 | #print axioms twice_wilsonCovariance |
| 166 | end |
| 167 | end YangMills.PeriodicWilson |