math / data /lean /OAI /Probability /SKBarriers /Model.lean
introvoyz045's picture
Migrated from GitHub
4a56cd6 verified
Raw History Blame Contribute Delete
2.69 kB
import Mathlib
namespace OAI
section
section
noncomputable section
open scoped BigOperators Topology
open MeasureTheory ProbabilityTheory Filter
namespace SK
abbrev Config (n : β„•) := Fin n β†’ Bool
abbrev Edge (n : β„•) := {p : Fin n Γ— Fin n // p.1 < p.2}
abbrev Disorder (n : β„•) := Edge n β†’ ℝ
def spin (b : Bool) : ℝ := if b then 1 else -1
def hamiltonian {n : β„•} (J : Disorder n) (x : Config n) : ℝ :=
(βˆ‘ e : Edge n, J e * spin (x e.val.1) * spin (x e.val.2)) / Real.sqrt n
def partition {n : β„•} (Ξ² : ℝ) (J : Disorder n) : ℝ :=
βˆ‘ x : Config n, Real.exp (Ξ² * hamiltonian J x)
def gibbs {n : β„•} (Ξ² : ℝ) (J : Disorder n) (x : Config n) : ℝ :=
Real.exp (Ξ² * hamiltonian J x) / partition Ξ² J
def coupling {n : β„•} (J : Disorder n) (i j : Fin n) : ℝ :=
if h : i < j then J ⟨(i, j), h⟩ else
if h : j < i then J ⟨(j, i), h⟩ else 0
def localField {n : β„•} (J : Disorder n) (x : Config n) (i : Fin n) : ℝ :=
(βˆ‘ j : Fin n, coupling J i j * spin (x j)) / Real.sqrt n
def heatBath {n : β„•} (Ξ² : ℝ) (J : Disorder n) (x y : Config n) : ℝ :=
(βˆ‘ i : Fin n, if Function.update x i (y i) = y then
Real.exp (Ξ² * spin (y i) * localField J x i) /
(2 * Real.cosh (Ξ² * localField J x i)) else 0) / n
def discreteKernel {n : β„•} (Ξ² : ℝ) (J : Disorder n) : β„• β†’ Config n β†’ Config n β†’ ℝ
| 0, x, y => if x = y then 1 else 0
| k + 1, x, y => βˆ‘ z : Config n, heatBath Ξ² J x z * discreteKernel Ξ² J k z y
def continuousKernel {n : β„•} (Ξ² : ℝ) (J : Disorder n) (t : ℝ)
(x y : Config n) : ℝ :=
βˆ‘' k : β„•, (Real.exp (-(n : ℝ) * t) * ((n : ℝ) * t) ^ k /
(Nat.factorial k : ℝ)) * discreteKernel Ξ² J k x y
def discreteDistance {n : β„•} (Ξ² : ℝ) (J : Disorder n)
(x : Config n) (k : β„•) : ℝ :=
(1 / 2 : ℝ) * βˆ‘ y : Config n, |discreteKernel Ξ² J k x y - gibbs Ξ² J y|
def continuousDistance {n : β„•} (Ξ² : ℝ) (J : Disorder n)
(x : Config n) (t : ℝ) : ℝ :=
(1 / 2 : ℝ) * βˆ‘ y : Config n, |continuousKernel Ξ² J t x y - gibbs Ξ² J y|
def disorderLaw (n : β„•) : Measure (Disorder n) :=
Measure.pi (fun _ : Edge n => gaussianReal 0 1)
def kappa : ℝ := 1 / 10000
def timeScale (n : β„•) : ℝ := Real.exp ((n : ℝ) ^ kappa)
def continuousBadMass (Ξ² : ℝ) (n : β„•) : ℝ :=
∫ J : Disorder n, (βˆ‘ x : Config n, if 1 / 4 < continuousDistance Ξ² J x (timeScale n)
then gibbs Ξ² J x else 0) βˆ‚disorderLaw n
def discreteBadMass (Ξ² : ℝ) (n : β„•) : ℝ :=
∫ J : Disorder n, (βˆ‘ x : Config n, if 1 / 4 < discreteDistance Ξ² J x ⌊timeScale nβŒ‹β‚Š
then gibbs Ξ² J x else 0) βˆ‚disorderLaw n
end SK
end
end
end
end OAI