Samplinglib
Lean gate not recorded for this source state main · 0e31a3cda412

Shared proof readers

Samplinglib · shared mathematical prerequisite

The exact law of one random-coordinate update

Turn the instruction “resample a uniformly selected coordinate conditionally” into an explicit transition probability.

Theorem. One-update transition probability

Statement

Let \(\mu\) be a probability measure on \(\{0,1\}^{n+1}\), and assume \(\mu(\{x\})>0\). One step selects a site uniformly and applies the existing coordinate heat-bath kernel. With \(F_i(x)=\{z:z_j=x_j\text{ for }j\ne i\}\), its singleton transition law is:

\[P(x,\{y\})=\frac1{n+1}\sum_{i=0}^{n}\mathbf1_{\{y_{-i}=x_{-i}\}}\frac{\mu(\{y\})}{\mu(F_i(x))}.\]
  • The finite site set is nonempty: there are \(n+1\) Boolean coordinates. \(\mu\) is a probability measure. Only the initial atom \(x\) must have positive mass; the destination \(y\) is arbitrary.
  • One step is a uniform random mixture, not a deterministic sweep. The underlying Markov kernel uses selected conditional versions, including at null fibers.
Lean statement · randomScan_apply_singleton

Fin (n + 1) → Bool is the finite configuration space. [IsProbabilityMeasure μ] is an inferred premise asserting total mass one. hx states nonzero starting mass; since measures are nonnegative, this is positivity. The sum and if-expression are exactly the displayed transition formula.

Braces mark parameters Lean can infer; square brackets request structures such as a measurable space or probability measure. Named hypotheses are mathematical premises, not facts established by this declaration. Section parameters are described in the mathematical hypotheses above; the module link retains their exact source context.

theorem randomScan_apply_singleton {n : ℕ} (μ : Measure (Fin (n + 1) → Bool))
    [IsProbabilityMeasure μ] (x y : Fin (n + 1) → Bool) (hx : μ {x} ≠ 0) :
    randomScan μ x {y} = (n + 1 : ℝ≥0∞)⁻¹ *
      ∑ i : Fin (n + 1),
        if ∀ j, j ≠ i → y j = x j then
          (μ {z | (fun j => z (i.succAbove j)) =
            (fun j => x (i.succAbove j))})⁻¹ * μ {y}
        else 0

Exact module and namespace context

Mathematical proof

Evaluate the existing mixture, prove every conditioning fiber encountered from the supported start has positive mass, and evaluate its normalized restriction.

1. Evaluate the finite mixture

The actual kernel is already defined as a state-independent finite mixture of coordinate heat-bath kernels. Evaluate this mixture on a singleton; the uniform weight can be factored out of the finite sum.

\[P(x,\{y\})=\sum_i w_iK_i(x,\{y\}),\qquad w_i=(n+1)^{-1}.\]
How this step appears in Lean

Unfold randomScan, then use KernelMixture.finiteMixture_apply, Measure.finsetSum_apply and Finset.mul_sum.

2. Derive, rather than assume, positive conditioning mass

The initial configuration belongs to every retained-coordinate fiber. Monotonicity of the target measure therefore makes every relevant denominator positive. It is finite because the target is a probability measure.

\[0<\mu(\{x\})\leq\mu(F_i(x))\leq1.\]
How this step appears in Lean

The local hpos proof uses measure_mono and Set.singleton_subset_iff. The proof never inserts a separate unexplained fiber-positivity assumption.

3. Evaluate conditional restriction on the destination atom

On a positive fiber, the existing conditional-law theorem identifies the heat-bath kernel with normalized restriction. Its intersection with a singleton is either the singleton or the empty set.

\[K_i(x,\{y\})=\frac{\mu(F_i(x)\cap\{y\})}{\mu(F_i(x))}=\begin{cases}\mu(\{y\})/\mu(F_i(x)),&y_{-i}=x_{-i},\\0,&\text{otherwise}.\end{cases}\]
How this step appears in Lean

CoordinateHeatBath.heatBath_eq_cond and Mathlib cond_apply' supply the normalized measure. hret proves that succAbove enumeration is exactly equality at every unselected coordinate; split_ifs handles the two intersections.

4. Sum all site contributions

Substitute the conditional value into the mixture. The sum includes every selected site: a self-transition can arise from several coordinates. For the uniform two-bit target, remaining at the start has probability one half and either one-bit flip has probability one quarter.

\[\mu\text{ uniform on }\{0,1\}^2:\quad P(x,\{x\})=\tfrac12,\quad P(x,\{x^{(i)}\})=\tfrac14,\quad P(x,\{x^{(1,2)}\})=0.\]
How this step appears in Lean

The public theorem finishes by Finset.sum_congr and the ENNReal coercion of the reciprocal weight. Tests/RandomScanHeatBath.lean checks the uniform row and forbidden-state and one-site boundaries.

Lean proof · randomScan_apply_singleton

The first rw expands the mixture, not the conditional law. hpos derives fiber positivity; hret proves that the indexing implementation matches ordinary coordinate retention. Only then does heatBath_eq_cond rewrite each component. split_ifs performs the two intersection cases.

Braces mark parameters Lean can infer; square brackets request structures such as a measurable space or probability measure. Named hypotheses are mathematical premises, not facts established by this declaration. Section parameters are described in the mathematical hypotheses above; the module link retains their exact source context.

theorem randomScan_apply_singleton {n : ℕ} (μ : Measure (Fin (n + 1) → Bool))
    [IsProbabilityMeasure μ] (x y : Fin (n + 1) → Bool) (hx : μ {x} ≠ 0) :
    randomScan μ x {y} = (n + 1 : ℝ≥0∞)⁻¹ *
      ∑ i : Fin (n + 1),
        if ∀ j, j ≠ i → y j = x j then
          (μ {z | (fun j => z (i.succAbove j)) =
            (fun j => x (i.succAbove j))})⁻¹ * μ {y}
        else 0 := by
  classical
  rw [randomScan, KernelMixture.finiteMixture_apply, Measure.finsetSum_apply,
    Finset.mul_sum]
  apply Finset.sum_congr rfl
  intro i _
  have hpos : μ {z | (fun j => z (i.succAbove j)) =
      (fun j => x (i.succAbove j))} ≠ 0 := by
    have hle : μ {x} ≤ μ {z | (fun j => z (i.succAbove j)) =
        (fun j => x (i.succAbove j))} :=
      measure_mono (Set.singleton_subset_iff.mpr rfl)
    intro hzero
    exact hx (le_antisymm (hzero ▸ hle) bot_le)
  have hret : (∀ j, j ≠ i → y j = x j) ↔
      (fun j => y (i.succAbove j)) = (fun j => x (i.succAbove j)) := by
    constructor
    · intro h
      exact funext (fun j => h _ (Fin.succAbove_ne _ _))
    · intro h j hji
      obtain ⟨k, rfl⟩ := Fin.exists_succAbove_eq hji
      exact congrFun h k
  simp only [Measure.smul_apply, smul_eq_mul]
  apply congrArg₂ (· * ·)
  · simpa only [ENNReal.coe_add, ENNReal.coe_natCast, ENNReal.coe_one] using
      (ENNReal.coe_inv (r := (n + 1 : ℝ≥0)) (by positivity))
  · rw [CoordinateHeatBath.heatBath_eq_cond _ μ i x hpos,
      cond_apply' (measurableSet_singleton _)]
    split_ifs with hy
    · rw [Set.inter_singleton_of_mem (show y ∈ {z |
        (fun j => z (i.succAbove j)) = (fun j => x (i.succAbove j))} from hret.mp hy)]
    · rw [Set.inter_singleton_of_notMem (show y ∉ {z |
        (fun j => z (i.succAbove j)) = (fun j => x (i.succAbove j))} from mt hret.mpr hy),
        measure_empty, mul_zero]

end AutoSamplingTheory.TechnicalLemmas.Probability.RandomScanHeatBath

Exact module and namespace context

What is still not proved by this result

  • This formula is not claimed pointwise at a zero-mass starting atom. The existing Markov kernel remains total there through its chosen conditional versions.
  • The formula is a noncomputable law interface, not an executable sampler. Invariance and reversibility have separate declarations; mixing, irreducibility and sampling complexity do not follow from the formula alone.
  • The source’s copy-index discrepancy is recorded separately. The accepted comparison covers the conditional-update interpretation and retention prose, not unqualified equivalence to every printed numbered instruction.

Proof dependencies

Declarations and reuse: ASTIS versus Mathlib

Results proved here by ASTIS

Existing ASTIS declarations reused

Mathlib results called, not re-proved here

Focused tests · exact source
import AutoSamplingTheory.TechnicalLemmas.Probability.RandomScanHeatBath
import AutoSamplingTheory.TechnicalLemmas.Probability.KernelInvariance

namespace AutoSamplingTheory.Tests.RandomScanHeatBath

open MeasureTheory ProbabilityTheory
open scoped ENNReal NNReal
open AutoSamplingTheory.TechnicalLemmas.Probability
open AutoSamplingTheory.TechnicalLemmas.Probability.RandomScanHeatBath

private abbrev State := Fin 2 → Bool
private def a : State := ![false, false]
private def b : State := ![true, false]
private def c : State := ![false, true]
private def d : State := ![true, true]

private noncomputable def uniform : Measure State :=
  (1 / 4 : ℝ≥0) • (Measure.dirac a + Measure.dirac b + Measure.dirac c + Measure.dirac d)

local instance : IsProbabilityMeasure (α := Fin (1 + 1) → Bool) uniform := by
  constructor
  norm_num [uniform, Measure.add_apply, Measure.smul_apply, measure_univ]
  simpa using congrArg (fun r : ℝ≥0 => (r : ℝ≥0∞))
    (show (4 : ℝ≥0)⁻¹ + 4⁻¹ + 4⁻¹ + 4⁻¹ = 1 by norm_num)

private theorem uniform_a_pos : uniform {a} ≠ 0 := by
  norm_num [uniform, Measure.smul_apply, Measure.add_apply, Measure.dirac_apply,
    Set.indicator_apply, a, b, c, d, funext_iff, Fin.forall_fin_two]

-- The actual random-scan kernel stays with probability 1/2 after ONE move.
example : randomScan uniform a {a} = 1 / 2 := by
  rw [randomScan_apply_singleton uniform a a uniform_a_pos]
  rw [Fin.sum_univ_two]
  norm_num [Fin.forall_fin_succ,
    uniform, Measure.smul_apply, Measure.add_apply, Measure.dirac_apply,
    Set.indicator_apply, a, b, c, d, funext_iff]
  have hhalf : (4 : ℝ≥0∞)⁻¹ + 4⁻¹ = 2⁻¹ := by
    simpa using congrArg (fun r : ℝ≥0 => (r : ℝ≥0∞))
      (show (4 : ℝ≥0)⁻¹ + 4⁻¹ = 2⁻¹ by norm_num)
  rw [hhalf, inv_inv, ← mul_add, ← mul_assoc,
    ENNReal.inv_mul_cancel (by norm_num) (by simp), one_mul, hhalf]

-- Either one-bit change has probability 1/4, including the site-selection factor.
example : randomScan uniform a {b} = 1 / 4 := by
  rw [randomScan_apply_singleton uniform a b uniform_a_pos, Fin.sum_univ_two]
  norm_num [Fin.forall_fin_succ,
    uniform, Measure.smul_apply, Measure.add_apply, Measure.dirac_apply,
    Set.indicator_apply, a, b, c, d, funext_iff]
  have hhalf : (4 : ℝ≥0∞)⁻¹ + 4⁻¹ = 2⁻¹ := by
    simpa using congrArg (fun r : ℝ≥0 => (r : ℝ≥0∞))
      (show (4 : ℝ≥0)⁻¹ + 4⁻¹ = 2⁻¹ by norm_num)
  rw [hhalf, inv_inv, ← mul_assoc,
    ENNReal.inv_mul_cancel (by norm_num) (by simp), one_mul]

example : randomScan uniform a {c} = 1 / 4 := by
  rw [randomScan_apply_singleton uniform a c uniform_a_pos, Fin.sum_univ_two]
  norm_num [Fin.forall_fin_succ,
    uniform, Measure.smul_apply, Measure.add_apply, Measure.dirac_apply,
    Set.indicator_apply, a, b, c, d, funext_iff]
  have hhalf : (4 : ℝ≥0∞)⁻¹ + 4⁻¹ = 2⁻¹ := by
    simpa using congrArg (fun r : ℝ≥0 => (r : ℝ≥0∞))
      (show (4 : ℝ≥0)⁻¹ + 4⁻¹ = 2⁻¹ by norm_num)
  rw [hhalf, inv_inv, ← mul_assoc,
    ENNReal.inv_mul_cancel (by norm_num) (by simp), one_mul]

-- A sweep could change both bits; this one-move kernel cannot.
example : randomScan uniform a {d} = 0 := by
  rw [randomScan_apply_singleton uniform a d uniform_a_pos, Fin.sum_univ_two]
  norm_num [a, d, Fin.forall_fin_succ]

-- Two supported configurations, with forbidden ambient configurations between them.
private noncomputable def diagonal : Measure State :=
  (1 / 2 : ℝ≥0) • (Measure.dirac a + Measure.dirac d)

local instance : IsProbabilityMeasure (α := Fin (1 + 1) → Bool) diagonal := by
  constructor
  norm_num [diagonal, Measure.add_apply, Measure.smul_apply, measure_univ]
  simpa using congrArg (fun r : ℝ≥0 => (r : ℝ≥0∞))
    (show (2 : ℝ≥0)⁻¹ + 2⁻¹ = 1 by norm_num)

private theorem diagonal_a_pos : diagonal {a} ≠ 0 := by
  norm_num [diagonal, Measure.smul_apply, Measure.add_apply, Measure.dirac_apply,
    Set.indicator_apply, a, d, funext_iff, Fin.forall_fin_two]

example : diagonal {b} = 0 := by
  norm_num [diagonal, Measure.smul_apply, Measure.add_apply, Measure.dirac_apply,
    Set.indicator_apply, a, b, d, funext_iff, Fin.forall_fin_two]

-- Valid denominators do not require full ambient support, nor imply irreducibility.
example : randomScan diagonal a {a} = 1 := by
  rw [randomScan_apply_singleton diagonal a a diagonal_a_pos, Fin.sum_univ_two]
  norm_num [Fin.forall_fin_two, Fin.forall_fin_one, diagonal,
    Measure.smul_apply, Measure.add_apply, Measure.dirac_apply,
    Set.indicator_apply, a, d, funext_iff]
  rw [ENNReal.mul_inv_cancel (by norm_num) (by simp)]
  norm_num
  exact ENNReal.inv_mul_cancel (by norm_num) (by simp)

example : randomScan diagonal a {b} = 0 := by
  rw [randomScan_apply_singleton diagonal a b diagonal_a_pos, Fin.sum_univ_two]
  norm_num [Fin.forall_fin_two, Fin.forall_fin_one, diagonal,
    Measure.smul_apply, Measure.add_apply, Measure.dirac_apply,
    Set.indicator_apply, a, b, d, funext_iff]

example : randomScan diagonal a {d} = 0 := by
  rw [randomScan_apply_singleton diagonal a d diagonal_a_pos, Fin.sum_univ_two]
  norm_num [a, d, Fin.forall_fin_succ]

-- Source support supplies BOTH normalization endpoints through native inequalities.
example {n : ℕ} (μ : Measure (Fin (n + 1) → Bool)) [IsProbabilityMeasure μ]
    (x : Fin (n + 1) → Bool) (hx : μ {x} ≠ 0) (i : Fin (n + 1)) :
    μ {z | (fun j => z (i.succAbove j)) = (fun j => x (i.succAbove j))} ≠ 0 ∧
      μ {z | (fun j => z (i.succAbove j)) = (fun j => x (i.succAbove j))} ≠ ∞ := by
  refine ⟨?_, measure_ne_top _ _⟩
  have hle : μ {x} ≤ μ {z | (fun j => z (i.succAbove j)) =
      (fun j => x (i.succAbove j))} :=
    measure_mono (Set.singleton_subset_iff.mpr rfl)
  intro hz
  exact hx (le_antisymm (hz ▸ hle) bot_le)

-- A nonzero probability target can have null fibers at an ambient but invalid start.
private theorem null_fibers (i : Fin 2) :
    Measure.dirac a {z : State | (fun j => z (i.succAbove j)) =
      (fun j => d (i.succAbove j))} = 0 := by
  fin_cases i <;> norm_num [Measure.dirac_apply, Set.indicator_apply,
    a, d, funext_iff, Fin.forall_fin_one]

example : Measure.dirac a {d} = 0 := by
  norm_num [Measure.dirac_apply, Set.indicator_apply, a, d, funext_iff, Fin.forall_fin_two]

-- Extending the normalized-fiber measure formula to this ambient input is false:
-- its normalized restrictions vanish, while the actual randomScan remains Markov.
example : randomScan (Measure.dirac a) d ≠
    (2 : ℝ≥0∞)⁻¹ • ∑ i : Fin 2,
      cond (Measure.dirac a) {z : State | (fun j => z (i.succAbove j)) =
        (fun j => d (i.succAbove j))} := by
  simp only [cond_eq_zero_of_meas_eq_zero (null_fibers _), Finset.sum_const_zero, smul_zero]
  intro h
  have hmass := congrArg (fun ν : Measure State => ν Set.univ) h
  simp only [measure_univ, Measure.coe_zero, Pi.zero_apply] at hmass
  exact one_ne_zero hmass

-- With a single site the retained tuple is empty and one move draws the whole target.
example (μ : Measure (Fin 1 → Bool)) [IsProbabilityMeasure μ]
    (x y : Fin 1 → Bool) (hx : μ {x} ≠ 0) : randomScan μ x {y} = μ {y} := by
  rw [randomScan_apply_singleton μ x y hx, Fin.sum_univ_one]
  simp [Fin.forall_fin_one, funext_iff]

-- Existing invariance and finite powers consume this actual random-scan kernel.
-- These are test-consumer inputs, not extra proof parents of the singleton law.
example {n : ℕ} (μ : Measure (Fin (n + 1) → Bool)) [IsProbabilityMeasure μ]
    (k : ℕ) : ((randomScan μ) ^ k).Invariant μ := by
  apply KernelInvariance.invariant_pow
  apply KernelMixture.finiteMixture_invariant
  · simp [Finset.sum_const, nsmul_eq_mul, Nat.cast_add, Nat.cast_one]
  · exact fun i => CoordinateHeatBath.heatBath_invariant _ μ i

#check @randomScan
#check @randomScan_isMarkovKernel
#check @randomScan_apply_singleton
#print axioms randomScan
#print axioms randomScan_isMarkovKernel
#print axioms randomScan_apply_singleton

end AutoSamplingTheory.Tests.RandomScanHeatBath

Source and evidence

This is original ASTIS exposition of a shared prerequisite, not a quotation or a replacement statement for a numbered source theorem. Expository coverage does not change formal completion.

Current checkout compilation not certified
Frontier Cell
independently_verified
Source comparison
source-reviewed / equivalent-after-elaboration / accepted
Registry membership
0 of 1 displayed results; repository Registry total: 438. Compilation and Registry admission are separate.
Source correspondence and exact audit records

Independent comparison accepted the narrow target as equivalent-after-elaboration. Positive support and the source copy-index issue remain explicit in the audit.

Frontier Cell record · Independent source audit