roseking's picture
Add lean source and binary files (part 125)
dd14c26 verified
Raw History Blame Contribute Delete
3.38 kB
import Mathlib
namespace OAI
section
section
noncomputable section
open MeasureTheory Filter
open scoped ENNReal NNReal Topology
namespace LogConcaveSampling
abbrev Point (d : ℕ) := EuclideanSpace ℝ (Fin d)
abbrev Reply (d : ℕ) := ℝ × Point d
abbrev Transcript (d q : ℕ) := Fin q → Reply d
/-- Normalized twice continuously differentiable potentials with Hessian between the identity and twice the identity. -/
structure Admissible {d : ℕ} (V : Point d → ℝ) : Prop where
smooth : ContDiff ℝ 2 V
value_zero : V 0 = 0
gradient_zero : gradient V 0 = 0
hessian_bounds : ∀ x v : Point d,
‖v‖ ^ 2 ≤ inner ℝ v (fderiv ℝ (gradient V) x v) ∧
inner ℝ v (fderiv ℝ (gradient V) x v) ≤ 2 * ‖v‖ ^ 2
/-- The unnormalized Gibbs density relative to Euclidean volume. -/
def gibbsDensity {d : ℕ} (V : Point d → ℝ) (x : Point d) : ℝ≥0∞ :=
ENNReal.ofReal (Real.exp (-V x))
def partition {d : ℕ} (V : Point d → ℝ) : ℝ≥0∞ :=
∫⁻ x, gibbsDensity V x ∂volume
/-- The Gibbs probability law, normalized by its partition function. -/
def gibbs {d : ℕ} (V : Point d → ℝ) : Measure (Point d) :=
(partition V)⁻¹ • volume.withDensity (gibbsDensity V)
def TVAtMost {E : Type*} [MeasurableSpace E]
(μ ν : Measure E) (ε : ℝ) : Prop :=
∀ s : Set E, MeasurableSet s → |μ.real s - ν.real s| ≤ ε
def firstOrderReply {d : ℕ} (V : Point d → ℝ) (x : Point d) : Reply d :=
(V x, gradient V x)
/-- Measurable adaptive queries and output, parametrized by private randomness. -/
structure OracleAlgorithm (Ω : Type*) [MeasurableSpace Ω] (d q : ℕ) where
query : Fin q → Ω × Transcript d q → Point d
query_measurable : ∀ i, Measurable (query i)
output : Ω × Transcript d q → Point d
output_measurable : Measurable output
def OracleAlgorithm.history {Ω : Type*} [MeasurableSpace Ω] {d q : ℕ}
(A : OracleAlgorithm Ω d q) (V : Point d → ℝ) (ω : Ω) : ℕ → Transcript d q
| 0 => 0
| n + 1 =>
let h := A.history V ω n
if hn : n < q then
Function.update h ⟨n, hn⟩ (firstOrderReply V (A.query ⟨n, hn⟩ (ω, h)))
else h
def OracleAlgorithm.run {Ω : Type*} [MeasurableSpace Ω] {d q : ℕ}
(A : OracleAlgorithm Ω d q) (V : Point d → ℝ) (ω : Ω) : Point d :=
A.output (ω, A.history V ω q)
/-- A uniform sampler with a deterministic query budget on every execution and total-variation error at most one tenth. -/
def CanSample (d q : ℕ) : Prop :=
∃ (Ω : Type) (_ : MeasurableSpace Ω) (μ : Measure Ω)
(_ : IsProbabilityMeasure μ) (A : OracleAlgorithm Ω d q),
∀ V : Point d → ℝ, Admissible V →
Measurable (A.run V) ∧ TVAtMost (μ.map (A.run V)) (gibbs V) (1 / 10)
/-- The smallest feasible integer query budget, or infinity when no budget is feasible. -/
def queryComplexity (d : ℕ) : ℕ∞ :=
sInf ((fun q : ℕ => (q : ℕ∞)) '' {q | CanSample d q})
/-- The quantified dimension-exponent upper bound with every positive exponent slack. -/
def ExponentBound (γ : ℝ) : Prop :=
0 ≤ γ ∧ ∀ ε : ℝ, 0 < ε → ∃ d₀ : ℕ, ∀ d : ℕ, d₀ ≤ d →
(queryComplexity d).toENNReal ≤ ENNReal.ofReal ((d : ℝ) ^ (γ + ε))
def gammaStar : ℝ := sInf {γ : ℝ | ExponentBound γ}
end LogConcaveSampling
end
end
end
end OAI