Documentation

CslibFrontier.Computability.LogSpaceDerandomization.StochasticAtom

Stochastic atoms #

A stochastic atom represents a deterministic number, such as a matrix entry, as the conditional mean of a bounded table over a random retained set. The table has few nonzero entries in each row on every draw. This is idea 6 in issue #474: the dense atoms of the OpenAI preprint [OpenAI2026LogSpace, Section 5.1–5.2].

The dense atom. Fix a row x of a nonnegative matrix G, a scale a > 0, and two retention channels on one seed space κ: a rank channel Y, over whose retained set the row gate ranks the row, and a usage channel Yt, which masks the table. In the preprint, Y and Yt retain at rates a and t ≤ a. For a draw s, the row gate is R = ρ (rank_K {G x w / a : Y s w}) (Matrix.rowGate). The preparatory value is h (G x y / a) · R (Matrix.atomPrep), and its conditional mean given Yt(y) is the normalizer q_y (Matrix.atomNormalizer). The atom is 1{Yt s y} · k (G x y / a) · R / c(q_y), with the clipped denominator c(q) = max (1/2) (min 1 q) (Matrix.denseAtom) [OpenAI2026LogSpace, (5.10), (5.11)].

The identity [OpenAI2026LogSpace, Lemma 5.1]. Suppose h = 1 wherever k ≠ 0, the row has mass at most M, ρ ∈ [0, 1] is one through η > 0, each vertex w ≠ y is retained by Y on at most a c a fraction of the draws with Yt(y), and K ≥ 2 (1 + c M / η). Then the gate is full on at least half of these draws (Matrix.card_filter_rowGate_lt_one_mul_le), so q_y ≥ 1/2. The clipping does nothing, and the conditional mean of the atom is exactly k (G x y / a) (Matrix.expect_denseAtom). The atom is bounded by 2 |k (G x y / a)| (Matrix.abs_denseAtom_le). The preprint takes K larger, so that the gate fails with probability at most 1/8 and q_y ≥ 7/8; the identity only needs q_y ≥ 1/2.

Row support [OpenAI2026LogSpace, Lemma 5.5, first part]. If k vanishes through e ≥ 0, ρ vanishes from g ≤ e on, and Yt ⊆ Y, then on every draw the row has fewer than K nonzero atom entries (Matrix.card_filter_denseAtom_ne_zero_lt). The same holds for the preparatory values and any other m (G x y / a) · R (Matrix.card_filter_mul_rowGate_ne_zero_lt). This holds for every real matrix, with no sign or accuracy hypothesis.

Bins [OpenAI2026LogSpace, (5.6), (5.7)]. For a switch χ, zero through 1/2 and one from 1, and decreasing scales b, the weights ω₀(w) = χ (w / b₀) and ω_{k+1}(w) = χ (w / b_{k+1}) − χ (w / b_k) (Cslib.binWeight) telescope (Cslib.sum_range_binWeight). So w = ∑_{k ≤ n} w ω_k(w) once w ≥ b_n (Cslib.sum_range_mul_binWeight). The weight ω_{k+1} is supported in (b_{k+1}/2, b_k) (Cslib.binWeight_succ_ne_zero). A dense entry is split into these bins before the atoms are formed.

Main definitions #

Main results #

References #

theorem Finset.expect_mul_div_clip_eq {Ω : Type u_1} {S : Finset Ω} (hS : S.Nonempty) {γ : Ω → ℝ} (hγ0 : ∀ s ∈ S, 0 ≤ γ s) (hγ1 : ∀ s ∈ S, γ s ≤ 1) (hfail : 2 * ↑{s ∈ S | γ s < 1}.card ≤ ↑S.card) (m : ℝ) :
(S.expect fun (s : Ω) => m * γ s / max (1 / 2) (min 1 (S.expect fun (s : Ω) => γ s))) = m

The normalization principle [OpenAI2026LogSpace, Section 5.1]. Let a gate γ take values in [0, 1] on a nonempty finite set S of draws, and be below one on at most half of them. Then dividing by its clipped mean c(q) = max (1/2) (min 1 q) removes the gate's bias: 𝔼_S [m · γ / c(𝔼_S γ)] = m.

theorem Cslib.abs_mul_div_clip_le {m γ : ℝ} (hγ0 : 0 ≤ γ) (hγ1 : γ ≤ 1) (q : ℝ) :
|m * γ / max (1 / 2) (min 1 q)| ≤ 2 * |m|

Dividing a [0, 1]-gated value by a denominator clipped to at least 1/2 at most doubles its magnitude [OpenAI2026LogSpace, Section 5.1].

theorem Matrix.card_filter_mul_rowGate_ne_zero_lt {V : Type u_1} {ρ m : ℝ → ℝ} {K : ℕ} {a : ℝ} {G : Matrix V V ℝ} (T : Finset V) (x : V) (hK : 0 < K) {e g : ℝ} (he : 0 ≤ e) (hm : ∀ d ≤ e, m d = 0) (hg : g ≤ e) (hρ : ∀ (r : ℝ), g ≤ r → ρ r = 0) :
{y ∈ T | m (G x y / a) * rowGate ρ K a G T x ≠ 0}.card < K

Row support [OpenAI2026LogSpace, Lemma 5.5]: if m vanishes through e ≥ 0 and the gate function ρ vanishes from g ≤ e on, then fewer than K > 0 retained entries y ∈ T have m (G x y / a) · rowGate x ≠ 0. Indeed K such entries would all exceed e, so the K-th largest value would exceed g and close the gate.

noncomputable def Matrix.atomPrep {V : Type u_1} (h ρ : ℝ → ℝ) (K : ℕ) (a : ℝ) (G : Matrix V V ℝ) (T : Finset V) (x y : V) :

The preparatory value h (G x y / a) · rowGate x of a dense atom, for the retained set T of the rank channel [OpenAI2026LogSpace, (5.10)].

noncomputable def Matrix.atomNormalizer {V : Type u_1} {κ : Type u_2} [Fintype V] [Fintype κ] (Y Yt : κ → V → Prop) [(s : κ) → (v : V) → Decidable (Y s v)] [(s : κ) → (v : V) → Decidable (Yt s v)] (h ρ : ℝ → ℝ) (K : ℕ) (a : ℝ) (G : Matrix V V ℝ) (x y : V) :

The normalizer q_y of a dense atom: the conditional mean of the preparatory value given that the usage channel retains y [OpenAI2026LogSpace, (5.10)].

noncomputable def Matrix.denseAtom {V : Type u_1} {κ : Type u_2} [Fintype V] [Fintype κ] (Y Yt : κ → V → Prop) [(s : κ) → (v : V) → Decidable (Y s v)] [(s : κ) → (v : V) → Decidable (Yt s v)] (k h ρ : ℝ → ℝ) (K : ℕ) (a : ℝ) (G : Matrix V V ℝ) (s : κ) (x y : V) :

The dense atom at (x, y) on the draw s: 1{Yt s y} · k (G x y / a) · rowGate x / c(q_y), with c(q) = max (1/2) (min 1 q) [OpenAI2026LogSpace, (5.11)].

theorem Matrix.abs_denseAtom_le {V : Type u_1} {κ : Type u_2} [Fintype V] [Fintype κ] {Y Yt : κ → V → Prop} [(s : κ) → (v : V) → Decidable (Y s v)] [(s : κ) → (v : V) → Decidable (Yt s v)] {k h ρ : ℝ → ℝ} {K : ℕ} {a : ℝ} {G : Matrix V V ℝ} (hρ0 : ∀ (r : ℝ), 0 ≤ ρ r) (hρ1 : ∀ (r : ℝ), ρ r ≤ 1) (s : κ) (x y : V) :
|denseAtom Y Yt k h ρ K a G s x y| ≤ 2 * |k (G x y / a)|

The dense atom is bounded: |B(x, y)| ≤ 2 |k (G x y / a)| on every draw, when ρ ∈ [0, 1] [OpenAI2026LogSpace, Lemma 5.1].

theorem Matrix.card_filter_denseAtom_ne_zero_lt {V : Type u_1} {κ : Type u_2} [Fintype V] [Fintype κ] {Y Yt : κ → V → Prop} [(s : κ) → (v : V) → Decidable (Y s v)] [(s : κ) → (v : V) → Decidable (Yt s v)] {k h ρ : ℝ → ℝ} {K : ℕ} {a : ℝ} {G : Matrix V V ℝ} (hYt : ∀ (s : κ) (v : V), Yt s v → Y s v) (hK : 0 < K) {e g : ℝ} (he : 0 ≤ e) (hk : ∀ d ≤ e, k d = 0) (hg : g ≤ e) (hρ : ∀ (r : ℝ), g ≤ r → ρ r = 0) (s : κ) (x : V) :
{y : V | denseAtom Y Yt k h ρ K a G s x y ≠ 0}.card < K

Row support of the dense atom [OpenAI2026LogSpace, Lemmas 5.1 and 5.5]: if k vanishes through e ≥ 0, ρ vanishes from g ≤ e on, and the usage channel retains only vertices that the rank channel retains, then on every draw fewer than K > 0 atoms of a row are nonzero.

theorem Matrix.expect_denseAtom {V : Type u_1} {κ : Type u_2} [Fintype V] [Fintype κ] {Y Yt : κ → V → Prop} [(s : κ) → (v : V) → Decidable (Y s v)] [(s : κ) → (v : V) → Decidable (Yt s v)] {k h ρ : ℝ → ℝ} {K : ℕ} {a : ℝ} {G : Matrix V V ℝ} {x y : V} (hS : {s : κ | Yt s y}.Nonempty) (hkh : ∀ (d : ℝ), k d ≠ 0 → h d = 1) (hρ0 : ∀ (r : ℝ), 0 ≤ ρ r) (hρ1 : ∀ (r : ℝ), ρ r ≤ 1) {η : ℝ} (hη : 0 < η) (hρη : ∀ r ≤ η, ρ r = 1) (ha : 0 < a) (hG0 : ∀ (w : V), 0 ≤ G x w) {M : ℝ} (hGM : ∑ w : V, G x w ≤ M) {c : ℝ} (hc : 0 ≤ c) (hK : 2 * (1 + c * M / η) ≤ ↑K) (hpair : ∀ (w : V), w ≠ y → ↑{s : κ | Yt s y ∧ Y s w}.card ≤ c * a * ↑{s : κ | Yt s y}.card) :
({s : κ | Yt s y}.expect fun (s : κ) => denseAtom Y Yt k h ρ K a G s x y) = k (G x y / a)

The dense atom identity [OpenAI2026LogSpace, Lemma 5.1]. Let h = 1 wherever k ≠ 0, let row x of G ≥ 0 have mass at most M, let ρ ∈ [0, 1] be one through η > 0, and let K ≥ 2 (1 + c M / η). Suppose the usage channel retains y on some draw, and every vertex w ≠ y is retained by the rank channel on at most a c a fraction of those draws. Then the conditional mean of the dense atom given Yt(y) is exactly k (G x y / a).

theorem Matrix.expect_denseAtom_of_retentionChannels {V : Type u_1} {κ : Type u_2} [Fintype V] [Fintype κ] {Y : κ → V → Prop} [(s : κ) → (v : V) → Decidable (Y s v)] {k h ρ : ℝ → ℝ} {K : ℕ} {a : ℝ} {G : Matrix V V ℝ} {ι : Type u_3} [Fintype ι] {X : ι → V → Prop} [(s : ι) → (v : V) → Decidable (X s v)] {π cπ Cπ Cpair Cvar : ℝ} (hch : Cslib.Probability.RetentionChannels X Y a π cπ Cπ Cpair Cvar) (ha : 0 < a) (hcπ : 0 < cπ) (hCpair : 0 ≤ Cpair) {x y : V} (hkh : ∀ (d : ℝ), k d ≠ 0 → h d = 1) (hρ0 : ∀ (r : ℝ), 0 ≤ ρ r) (hρ1 : ∀ (r : ℝ), ρ r ≤ 1) {η : ℝ} (hη : 0 < η) (hρη : ∀ r ≤ η, ρ r = 1) (hG0 : ∀ (w : V), 0 ≤ G x w) {M : ℝ} (hGM : ∑ w : V, G x w ≤ M) (hK : 2 * (1 + Cpair * M / η) ≤ ↑K) :
({s : κ | Y s y}.expect fun (s : κ) => denseAtom Y Y k h ρ K a G s x y) = k (G x y / a)

The dense atom identity for retention channels [OpenAI2026LogSpace, Lemma 5.1], when the usage channel is the rank channel Y at the atom's scale f, as for corrections and detector scores. With RetentionChannels at rate f > 0 and c_π > 0, the pair bound supplies the retention hypothesis with c = C_pair.

theorem Matrix.denseAtom_nonneg {V : Type u_1} {κ : Type u_2} [Fintype V] [Fintype κ] {Y Yt : κ → V → Prop} [(t : κ) → (y : V) → Decidable (Y t y)] [(t : κ) → (y : V) → Decidable (Yt t y)] {k h ρ : ℝ → ℝ} {K : ℕ} {a : ℝ} {H : Matrix V V ℝ} (hk0 : ∀ (v : ℝ), 0 ≤ k v) (hρ0 : ∀ (r : ℝ), 0 ≤ ρ r) (t : κ) (z y : V) :
0 ≤ denseAtom Y Yt k h ρ K a H t z y

Nonnegative cutoff and gate values give a nonnegative atom.

noncomputable def Cslib.binWeight (χ : ℝ → ℝ) (b : ℕ → ℝ) :
ℕ → ℝ → ℝ

The bin weights for the scales b: ω₀(w) = χ (w / b₀) and ω_{k+1}(w) = χ (w / b_{k+1}) − χ (w / b_k) [OpenAI2026LogSpace, (5.6)].

theorem Cslib.sum_range_binWeight {χ : ℝ → ℝ} {b : ℕ → ℝ} (n : ℕ) (w : ℝ) :
∑ k ∈ Finset.range (n + 1), binWeight χ b k w = χ (w / b n)

The bin weights telescope: ∑_{k ≤ n} ω_k(w) = χ (w / b_n).

theorem Cslib.sum_range_mul_binWeight {χ : ℝ → ℝ} {b : ℕ → ℝ} (hχ1 : ∀ (t : ℝ), 1 ≤ t → χ t = 1) {n : ℕ} (hb : 0 < b n) {w : ℝ} (hw : b n ≤ w) :
∑ k ∈ Finset.range (n + 1), w * binWeight χ b k w = w

Bin decomposition [OpenAI2026LogSpace, (5.7)]: if χ is one from 1 on and 0 < b_n ≤ w, then w = ∑_{k ≤ n} w ω_k(w).

theorem Cslib.binWeight_nonneg {χ : ℝ → ℝ} {b : ℕ → ℝ} (hχ : Monotone χ) (hχ0 : χ 0 = 0) (hb : ∀ (k : ℕ), 0 < b k) (hanti : Antitone b) {w : ℝ} (hw : 0 ≤ w) (k : ℕ) :
0 ≤ binWeight χ b k w

The bin weights are nonnegative for a monotone switch that vanishes at 0, decreasing positive scales and 0 ≤ w.

theorem Cslib.binWeight_succ_ne_zero {χ : ℝ → ℝ} {b : ℕ → ℝ} (hχ0 : ∀ t ≤ 1 / 2, χ t = 0) (hχ1 : ∀ (t : ℝ), 1 ≤ t → χ t = 1) (hb : ∀ (k : ℕ), 0 < b k) (hanti : Antitone b) {k : ℕ} {w : ℝ} (hω : binWeight χ b (k + 1) w ≠ 0) :
b (k + 1) / 2 < w ∧ w < b k

Bin support [OpenAI2026LogSpace, (5.8)]: if χ is zero through 1/2 and one from 1 on, then ω_{k+1}(w) ≠ 0 forces b_{k+1} / 2 < w < b_k, for decreasing positive scales.