Download data/lean/OAI/Probability/InvariantIsing/Cavity/CavityBlockFactor.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 5.32 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/InvariantIsing/Cavity/CavityBlockFactor.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Probability/InvariantIsing/Cavity/CavityBlockFactor.lean
-
curl -L -o CavityBlockFactor.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/InvariantIsing/Cavity/CavityBlockFactor.lean
5.32 kB
| import OAI.Probability.InvariantIsing.Core.Model | |
| import OAI.Probability.InvariantIsing.Core.Ward | |
| namespace OAI | |
| /-! Exact finite-volume algebra for the coupled cavity comparison. The | |
| spectral coupling and its Gaussian limit are separate source obligations. -/ | |
| noncomputable section | |
| open IsingPerceptron | |
| open scoped BigOperators Matrix | |
| namespace InvariantIsing | |
| def cavityQuadratic {d : β} (A : Matrix (Fin d) (Fin d) β) (y : Fin d β β) : β := | |
| (1 / 2 : β) * β i, β j, y i * A i j * y j | |
| def cavityLogFactor {d n : β} (K : Matrix (Fin d) (Fin d) β) | |
| (L : Matrix (Fin d) (Fin n) β) (C : Matrix (Fin n) (Fin n) β) | |
| (y : Fin d β β) (Ξ΅ : Spin n) : β := | |
| cavityQuadratic K y + (β i, β j, y i * L i j * spinValue (Ξ΅ j)) + | |
| cavityQuadratic C (fun j => spinValue (Ξ΅ j)) | |
| lemma cavityQuadratic_sub {d : β} (A B : Matrix (Fin d) (Fin d) β) (y : Fin d β β) : | |
| cavityQuadratic (A - B) y = cavityQuadratic A y - cavityQuadratic B y := by | |
| simp only [cavityQuadratic, Matrix.sub_apply, mul_sub, sub_mul, Finset.sum_sub_distrib] | |
| /-- The exact exponent difference in `cav:factor`, with no commutativity | |
| assumption on the two symmetric special-coordinate blocks. -/ | |
| theorem cavity_block_factor {d n : β} (A A0 : Matrix (Fin d) (Fin d) β) | |
| (L : Matrix (Fin d) (Fin n) β) (C : Matrix (Fin n) (Fin n) β) | |
| (y : Fin d β β) (Ξ΅ : Spin n) : | |
| (1 / 2 : β) * (β i : Fin d β Fin n, β j : Fin d β Fin n, | |
| Sum.elim y (fun a => spinValue (Ξ΅ a)) i * | |
| (Matrix.fromBlocks A L L.transpose C) i j * | |
| Sum.elim y (fun a => spinValue (Ξ΅ a)) j) - cavityQuadratic A0 y = | |
| cavityLogFactor (A - A0) L C y Ξ΅ := by | |
| have hcross : (β j : Fin n, β i : Fin d, spinValue (Ξ΅ j) * L i j * y i) = | |
| β i : Fin d, β j : Fin n, y i * L i j * spinValue (Ξ΅ j) := by | |
| rw [Finset.sum_comm] | |
| apply Finset.sum_congr rfl | |
| intro i _ | |
| apply Finset.sum_congr rfl | |
| intro j _ | |
| ring_nf | |
| simp only [Fintype.sum_sum_type, Sum.elim_inl, Sum.elim_inr, | |
| Matrix.fromBlocks_applyββ, Matrix.fromBlocks_applyββ, Matrix.fromBlocks_applyββ, | |
| Matrix.fromBlocks_applyββ, Matrix.transpose_apply, Finset.sum_add_distrib] | |
| rw [hcross] | |
| unfold cavityLogFactor | |
| rw [cavityQuadratic_sub] | |
| unfold cavityQuadratic | |
| ring_nf | |
| /-- The base Gibbs law times the independent uniform probability on the | |
| cavity cube, evaluated on the positive cavity factor. -/ | |
| def cavityFactorMean {N n : β} (H : Spin N β β) (V : Spin N β Spin n β β) : β := | |
| (Fintype.card (Spin n) : β)β»ΒΉ * | |
| β Ο, (Real.exp (H Ο) / β Ο, Real.exp (H Ο)) * β Ξ΅, Real.exp (V Ο Ξ΅) | |
| lemma cavityFactorMean_eq_gibbsAverage {N n : β} (H : Spin N β β) | |
| (V : Spin N β Spin n β β) : | |
| cavityFactorMean H V = gibbsAverage (fun _ => 1) H | |
| (fun Ο => (Fintype.card (Spin n) : β)β»ΒΉ * β Ξ΅, Real.exp (V Ο Ξ΅)) := by | |
| simp only [cavityFactorMean, gibbsAverage, finiteGibbs, finitePartition, one_mul, | |
| Finset.mul_sum] | |
| apply Finset.sum_congr rfl | |
| intro Ο _ | |
| ring_nf | |
| lemma cavityFactorMean_eq_ratio {N n : β} (H : Spin N β β) | |
| (V : Spin N β Spin n β β) : | |
| cavityFactorMean H V = (Fintype.card (Spin n) : β)β»ΒΉ * | |
| ((β x : Spin N Γ Spin n, Real.exp (H x.1 + V x.1 x.2)) / | |
| β Ο, Real.exp (H Ο)) := by | |
| unfold cavityFactorMean | |
| simp only [div_mul_eq_mul_div, β Finset.sum_div] | |
| congr 1 | |
| congr 1 | |
| simp only [Fintype.sum_prod_type, Real.exp_add, Finset.mul_sum] | |
| lemma cavityFactorMean_pos {N n : β} (H : Spin N β β) (V : Spin N β Spin n β β) : | |
| 0 < cavityFactorMean H V := by | |
| rw [cavityFactorMean_eq_ratio] | |
| have hc : (0 : β) < Fintype.card (Spin n) := by exact_mod_cast Fintype.card_pos | |
| exact mul_pos (inv_pos.mpr hc) (div_pos (sum_exp_pos _) (sum_exp_pos H)) | |
| /-- Exact finite log-partition increment for probability-normalized | |
| partition functions, at the base endpoint of the cavity interpolation. -/ | |
| theorem logPartition_cavity_increment {N n : β} (H : Spin N β β) | |
| (V : Spin N β Spin n β β) : | |
| logPartition (fun x : Spin N Γ Spin n => H x.1 + V x.1 x.2) - logPartition H = | |
| Real.log (cavityFactorMean H V) := by | |
| have hN : (Fintype.card (Spin N) : β) β 0 := by exact_mod_cast Fintype.card_ne_zero | |
| have hn : (Fintype.card (Spin n) : β) β 0 := by exact_mod_cast Fintype.card_ne_zero | |
| have hfull := (sum_exp_pos (fun x : Spin N Γ Spin n => H x.1 + V x.1 x.2)).ne' | |
| have hbase := (sum_exp_pos H).ne' | |
| rw [logPartition_eq, logPartition_eq, cavityFactorMean_eq_ratio, | |
| Real.log_mul (inv_ne_zero hn) (div_ne_zero hfull hbase), Real.log_inv, | |
| Real.log_div hfull hbase] | |
| simp only [Fintype.card_prod, Nat.cast_mul] | |
| rw [Real.log_mul hN hn] | |
| ring_nf | |
| theorem logPartition_cavityBlock_increment {N d n : β} (H : Spin N β β) | |
| (K : Matrix (Fin d) (Fin d) β) (L : Matrix (Fin d) (Fin n) β) | |
| (C : Matrix (Fin n) (Fin n) β) (y : Spin N β Fin d β β) : | |
| logPartition (fun x : Spin N Γ Spin n => H x.1 + cavityLogFactor K L C (y x.1) x.2) - | |
| logPartition H = Real.log (cavityFactorMean H (fun Ο Ξ΅ => cavityLogFactor K L C (y Ο) Ξ΅)) := | |
| logPartition_cavity_increment (N := N) (n := n) H | |
| (fun Ο Ξ΅ => cavityLogFactor K L C (y Ο) Ξ΅) | |
| end InvariantIsing | |
| end | |
| end OAI | |