Documentation

CslibFrontier.Computability.LogSpaceDerandomization.RoutedHierarchyBins

Routed bins of the actual correction-and-copy hierarchy #

The cutoff routedBinCutoff is (5.9) of [OpenAI2026LogSpace, Section 5.2], revision 7ef5c0cc: destination routing is evaluated at the raw residual entry, before averaging. DenseSamplingLaws contains only gate and pair-count conditions, and constructs the actual denseAtom. Its direct importance-weighted mean follows from those conditions. Finite bin sums use the existing partition of unity; their coverage condition is explicit, including zeros. The hierarchy client gives the next actual matrix on each fixed source/destination symbol part. This module supplies true-input means. The shared arbitrary-child cutoffs live in DenseRowRecipes; global preparatory and normalized requests live in HierarchyAccess. No parallel routed transition matrix or assumed mean certificate is introduced.

Requests retain whole functions, source/end/usage rates and independent roles. Copy traversal prepends a symbol before the inherited suffix. The product's right request resets the source to the midpoint channel. Its actual inputs are the existing HierarchyTask values and its rank inequalities use that task order. The scheduled coarse/fine payment lemmas consume those ranks. This is a direct/routed-residual client, not full recursive stochastic task assembly: residual raw estimation, estimated routing fractions, preparation access, complete mean prefixes, paired raw differences, full-coordinate conditional walks/noise, compression and statistical-budget recursion remain open. Gate contracts do not establish root regularity. Scheduled bounds retain fourth moments (the source uses eighth moments) and integer scale offsets. No native workspace or complexity claim is made for these finite noncomputable functions.

structure Matrix.DenseSamplingLaws {V : Type u_1} {Ω : Type u_2} [Fintype Ω] (Y Ya Yt : Ω → V → Prop) [(s : Ω) → (v : V) → Decidable (Y s v)] [(s : Ω) → (v : V) → Decidable (Yt s v)] (k : ℝ → ℝ) (b M : ℝ) :

Primitive dense-bin laws. The true input's nonnegativity and row mass are proved by clients; neither a desired mean nor a noise bound is a field.

  • h : ℝ → ℝ

    Preparation support cutoff.

  • ρ : ℝ → ℝ

    Row gate.

  • K : ℕ

    Row rank.

  • η : ℝ

    Safe row threshold.

  • c : ℝ

    Conditional terminal pair constant.

  • usage_subset (s : Ω) (y : V) : Yt s y → Ya s y

    Usage lies inside the parent's conditioning channel.

  • usage_nonempty (y : V) : {s : Ω | Yt s y}.Nonempty

    Every usage conditioning event is nonempty.

  • support (d : ℝ) : k d ≠ 0 → self.h d = 1

    Preparation is one on the cutoff support.

  • gate_nonneg (r : ℝ) : 0 ≤ self.ρ r

    Nonnegative gate.

  • gate_le_one (r : ℝ) : self.ρ r ≤ 1

    Gate bounded by one.

  • η_pos : 0 < self.η

    Positive safe threshold.

  • gate_one (r : ℝ) : r ≤ self.η → self.ρ r = 1

    Gate full through the safe threshold.

  • c_nonneg : 0 ≤ self.c

    Nonnegative pair constant.

  • rank_bound : 2 * (1 + self.c * M / self.η) ≤ ↑self.K

    Rank sufficient for true normalization.

  • pair (y w : V) : w ≠ y → ↑{s : Ω | Yt s y ∧ Y s w}.card ≤ self.c * b * ↑{s : Ω | Yt s y}.card

    Cross-rate count conditional on the actual usage hit.

noncomputable def Matrix.DenseSamplingLaws.atom {V : Type u_1} {Ω : Type u_2} [Fintype V] [Fintype Ω] {Y Ya Yt : Ω → V → Prop} [(s : Ω) → (v : V) → Decidable (Y s v)] [(s : Ω) → (v : V) → Decidable (Yt s v)] {k : ℝ → ℝ} {b M : ℝ} (A : DenseSamplingLaws Y Ya Yt k b M) (G : Matrix V V ℝ) :
Ω → Matrix V V ℝ

Actual atom; row and endpoint stay function arguments.

noncomputable def Matrix.DenseSamplingLaws.direct {V : Type u_1} {Ω : Type u_2} [Fintype V] [Fintype Ω] {Y Ya Yt : Ω → V → Prop} [(s : Ω) → (v : V) → Decidable (Y s v)] [(s : Ω) → (v : V) → Decidable (Ya s v)] [(s : Ω) → (v : V) → Decidable (Yt s v)] {k : ℝ → ℝ} {b M : ℝ} (A : DenseSamplingLaws Y Ya Yt k b M) (G : Matrix V V ℝ) (s : Ω) (x y : V) :

The raw direct term in original matrix units, on the broad terminal slice.

theorem Matrix.DenseSamplingLaws.expect_direct {V : Type u_1} {Ω : Type u_2} [Fintype V] [Fintype Ω] {Y Ya Yt : Ω → V → Prop} [(s : Ω) → (v : V) → Decidable (Y s v)] [(s : Ω) → (v : V) → Decidable (Ya s v)] [(s : Ω) → (v : V) → Decidable (Yt s v)] {k : ℝ → ℝ} {b M : ℝ} (A : DenseSamplingLaws Y Ya Yt k b M) (hb : 0 < b) {G : Matrix V V ℝ} (hG : ∀ (x y : V), 0 ≤ G x y) (hGM : ∀ (x : V), ∑ y : V, G x y ≤ M) (x y : V) :
({s : Ω | Ya s y}.expect fun (s : Ω) => A.direct G s x y) = b * k (G x y / b)

True direct mean, derived from row gates and cross-rate channel laws.

theorem Matrix.DenseSamplingLaws.expect_direct_source {V : Type u_1} {Ω : Type u_2} [Fintype V] [Fintype Ω] {Y Ya Yt : Ω → V → Prop} [(s : Ω) → (v : V) → Decidable (Y s v)] [(s : Ω) → (v : V) → Decidable (Ya s v)] [(s : Ω) → (v : V) → Decidable (Yt s v)] {k : ℝ → ℝ} {b M : ℝ} (A : DenseSamplingLaws Y Ya Yt k b M) {Γ : Type u_3} [Fintype Γ] (X : Γ → V → Prop) [(s : Γ) → (x : V) → Decidable (X s x)] (hb : 0 < b) {G : Matrix V V ℝ} (hG : ∀ (x y : V), 0 ≤ G x y) (hGM : ∀ (x : V), ∑ y : V, G x y ≤ M) (x y : V) (hx : {s : Γ | X s x}.Nonempty) :
(({s : Γ | X s x} ×ˢ {t : Ω | Ya t y}).expect fun (s : Γ × Ω) => A.direct G s.2 x y) = b * k (G x y / b)

Independent source conditioning leaves a true direct bin unchanged. The source argument is still available to estimated child functions, rather than being stored in their task tuple.

noncomputable def Matrix.DenseSamplingLaws.ofAffine {V : Type u_1} {p H : ℕ} [Fact (Nat.Prime p)] {ident : V → ZMod p} (hident : Function.Injective ident) {a : ℝ} (hpa : 1 ≤ ↑p * a) (ha : a ≤ 1) {Lt La : ℕ} (hLt0 : 0 < Lt) (hLt : Lt ≤ ⌈↑p * a⌉₊) (hLa : Lt ≤ La) (k h ρ : ℝ → ℝ) (K : ℕ) (M η : ℝ) (hsupport : ∀ (d : ℝ), k d ≠ 0 → h d = 1) (hρ0 : ∀ (r : ℝ), 0 ≤ ρ r) (hρ1 : ∀ (r : ℝ), ρ r ≤ 1) (hη : 0 < η) (hone : ∀ r ≤ η, ρ r = 1) (hK : 2 * (1 + 2 ^ H * M / η) ≤ ↑K) :
DenseSamplingLaws (fun (s : Matrix (Fin H) (Fin 1) (ZMod p) × (Fin H → ZMod p)) (v : V) => Cslib.Probability.affineRetains p H ⌈↑p * a⌉₊ s (ident v)) (fun (s : Matrix (Fin H) (Fin 1) (ZMod p) × (Fin H → ZMod p)) (v : V) => Cslib.Probability.affineRetains p H La s (ident v)) (fun (s : Matrix (Fin H) (Fin 1) (ZMod p) × (Fin H → ZMod p)) (v : V) => Cslib.Probability.affineRetains p H Lt s (ident v)) k (a ^ H) M

Affine channels supply the actual dense sampling conditions at distinct rank, usage and parent conditioning sides. Only injectivity of the padded identifier is required, not an arbitrary equivalence of all-coordinate environments.

noncomputable def Matrix.HierarchyParams.CorrectionSampling.binProductRecipe {q cπ Cπ Cpair Cvar : ℝ} {P : HierarchyParams q cπ Cπ Cpair Cvar} {V : Type u_3} {Γ : Type u_4} {Ζ : Type u_5} {Ω : Type u_6} {ι : Type u_7} {κ : Type u_8} [Fintype V] [Fintype Γ] [Fintype Ζ] [Fintype Ω] [Fintype ι] [Fintype κ] {X : ι → V → Prop} {Y : κ → V → Prop} {Xs : Γ → V → Prop} {Z Zt : Ζ → V → Prop} {Ya Yt : Ω → V → Prop} [(s : ι) → (v : V) → Decidable (X s v)] [(s : κ) → (v : V) → Decidable (Y s v)] [(s : Γ) → (v : V) → Decidable (Xs s v)] [(s : Ζ) → (v : V) → Decidable (Z s v)] [(s : Ζ) → (v : V) → Decidable (Zt s v)] [(s : Ω) → (v : V) → Decidable (Ya s v)] [(s : Ω) → (v : V) → Decidable (Yt s v)] {f b : ℝ} {C : Matrix V V ℝ} {i : ℕ} (A : P.CorrectionSampling X Y Xs Z Zt f C i) (F : Γ × Ζ → Matrix V V ℝ) (H : Ω → Matrix V V ℝ) (draw : (Γ × Ζ) × Ω) (x y : V) :

The real raw product recipe accepts whole earlier functions; its right row is called at z. There is no old-source or fixed-endpoint parameter in that child.

theorem Matrix.HierarchyParams.CorrectionSampling.expect_binProductRecipe {q cπ Cπ Cpair Cvar : ℝ} {P : HierarchyParams q cπ Cπ Cpair Cvar} {V : Type u_3} {Γ : Type u_4} {Ζ : Type u_5} {Ω : Type u_6} {ι : Type u_7} {κ : Type u_8} [Fintype V] [Fintype Γ] [Fintype Ζ] [Fintype Ω] [Fintype ι] [Fintype κ] {X : ι → V → Prop} {Y : κ → V → Prop} {Xs : Γ → V → Prop} {Z Zt : Ζ → V → Prop} {Yr Ya Yt : Ω → V → Prop} [(s : ι) → (v : V) → Decidable (X s v)] [(s : κ) → (v : V) → Decidable (Y s v)] [(s : Γ) → (v : V) → Decidable (Xs s v)] [(s : Ζ) → (v : V) → Decidable (Z s v)] [(s : Ζ) → (v : V) → Decidable (Zt s v)] [(s : Ω) → (v : V) → Decidable (Yr s v)] [(s : Ω) → (v : V) → Decidable (Ya s v)] [(s : Ω) → (v : V) → Decidable (Yt s v)] {f b : ℝ} {C : Matrix V V ℝ} {i : ℕ} (A : P.CorrectionSampling X Y Xs Z Zt f C i) {k : ℝ → ℝ} (B : DenseSamplingLaws Yr Ya Yt k b 1) (hf : 0 < f) (hb : 0 < b) (hC : ∀ (x y : V), 0 ≤ C x y) (hC1 : C.mulVec 1 ≤ 1) (x y : V) (hx : {s : Γ | Xs s x}.Nonempty) :
((({s : Γ | Xs s x} ×ˢ Finset.univ) ×ˢ {s : Ω | Ya s y}).expect fun (draw : (Γ × Ζ) × Ω) => A.binProductRecipe A.atom (B.atom C) draw x y) = ∑ z : V, P.correctionIter X Y f C (i + 1) x z * (b * k (C z y / b))

True product mean from the actual correction and bin gate laws. In particular the shared midpoint source role does not survive in the true right atom after its membership condition has been fixed. Estimated factors need joint comparisons, not this factorization.

def Matrix.CopyPadding.identifier {p : ℕ} (D : ZMod p) (suffix : List (ZMod p)) (x : ZMod p) :

Native hash padding: append each digit from left to right.

theorem Matrix.CopyPadding.identifier_cons {p : ℕ} (D j : ZMod p) (suffix : List (ZMod p)) (x : ZMod p) :
identifier D (j :: suffix) x = identifier D suffix (D * x + j)

Prepending the copy symbol means appending it to the native identifier first.

theorem Matrix.CopyPadding.identifier_radixCopy {p : ℕ} (n m l : ℕ) (x : Fin (n * (m + 1) ^ l)) (j : Fin (m + 1)) (suffix : List (ZMod p)) :
identifier (↑m + 1) (↑↑j :: suffix) ↑↑x = identifier (↑m + 1) suffix ↑↑((radixCopyEquiv n m l).symm (toLex (x, j)))

Native radix-copy identifiers obey exactly the same prepend-before-suffix recipe.

theorem Matrix.CopyPadding.identifier_affine {p : ℕ} (D : ZMod p) (suffix : List (ZMod p)) (x : ZMod p) :
identifier D suffix x = D ^ suffix.length * x + identifier D suffix 0

A common fixed suffix is the affine substitution used by the channel invariance law.

theorem Matrix.CopyPadding.identifier_injective {p : ℕ} [Fact (Nat.Prime p)] {D : ZMod p} (hD : D ≠ 0) (suffix : List (ZMod p)) :

Padding preserves distinct identifiers when the radix is nonzero modulo the prime.

theorem Matrix.CopyPadding.dens_frame_padding {p H r : ℕ} [Fact (Nat.Prime p)] {D : ZMod p} (hD : D ≠ 0) (suffix : List (ZMod p)) (E : (ZMod p → Fin H → ZMod p) → Prop) [DecidablePred E] :
{A : Cslib.Probability.FrameChannel p H r | E fun (x : ZMod p) => A.eval (identifier D suffix x)}.dens = {A : Cslib.Probability.FrameChannel p H r | E A.eval}.dens

The exact joint frame law for native padding follows from affine substitution. This is distributional invariance, not pointwise equality of arbitrary environments.

def Matrix.HierarchyParams.CorrectionRowTask.Channel.throughCopy {Role : Type u_3} {Symbol : Type u_4} (ch : Channel Role (List Symbol)) (j : Symbol) :
Channel Role (List Symbol)

Append the native copy digit before every already inherited suffix digit.

theorem Matrix.HierarchyParams.CorrectionRowTask.Channel.throughCopy_twice {Role : Type u_3} {Symbol : Type u_4} (ch : Channel Role (List Symbol)) (i j : Symbol) :

A second descent prepends its symbol before the first one; neither inherited digit is lost.

structure Matrix.HierarchyParams.HierarchyTask.Request (k : ℕ) (Role : Type u_3) (Symbol : Type u_4) :
Type (max u_3 u_4)

Whole-function request in the existing global task order, with concrete channel tuples.

def Matrix.HierarchyParams.HierarchyTask.inputRequests {k : ℕ} {Role : Type u_3} {Symbol : Type u_4} (l : ℕ) (i : Fin k) (source midpoint terminal usage : CorrectionRowTask.Channel Role (List Symbol)) :
List (Request k Role Symbol)

Raw input calls in direct/left/right order. Endpoint and midpoint remain arguments of these whole child functions; the right child resets the source tuple completely.

def Matrix.HierarchyParams.HierarchyTask.copyRequests {k : ℕ} {Role : Type u_3} {Symbol : Type u_4} (l : ℕ) (source midpoint terminal usage : CorrectionRowTask.Channel Role (List Symbol)) (i j : Symbol) :
List (Request k Role Symbol)

Fixed-symbol projection calls the actual parent base/correction/weights. Its source and terminal channels prepend their respective symbols; the midpoint has no copy symbol appended. The weight is evaluated on the broad parent source domain by the copy recipe.

def Matrix.HierarchyParams.HierarchyTask.binInputRequests {k : ℕ} {Role : Type u_3} {Symbol : Type u_4} (l : ℕ) (i : Fin k) (source midpoint endpoint : CorrectionRowTask.Channel Role (List Symbol)) (b : ℝ) :
List (Request k Role Symbol)

The bin rank uses rate b; usage uses min a b on the same endpoint role and suffix. The midpoint remains at the stage rate. These are the actual tuples of (7.1)–(7.2).

def Matrix.HierarchyParams.HierarchyTask.binCopyRequests {k : ℕ} {Role : Type u_3} {Symbol : Type u_4} (l : ℕ) (source midpoint endpoint : CorrectionRowTask.Channel Role (List Symbol)) (b : ℝ) (i j : Symbol) :
List (Request k Role Symbol)

Projection uses the same bin/usage convention, with different source/destination symbols.

theorem Matrix.HierarchyParams.HierarchyTask.inputRequests_rank_lt {k : ℕ} {Role : Type u_3} {Symbol : Type u_4} (l : ℕ) (i : Fin k) (source midpoint terminal usage : CorrectionRowTask.Channel Role (List Symbol)) (r : Request k Role Symbol) (hr : r ∈ inputRequests l i source midpoint terminal usage) :

The raw-input requests decrease the existing global rank, including the repeated base call.

theorem Matrix.HierarchyParams.HierarchyTask.copyRequests_rank_lt {k : ℕ} {Role : Type u_3} {Symbol : Type u_4} (l : ℕ) (source midpoint terminal usage : CorrectionRowTask.Channel Role (List Symbol)) (i j : Symbol) (r : Request k Role Symbol) (hr : r ∈ copyRequests l source midpoint terminal usage i j) :

All fixed-symbol copy calls precede the existing actual next-matrix constructor.

theorem Matrix.HierarchyParams.HierarchyTask.scheduled_request_error_le {k : ℕ} {Role : Type u_3} {Symbol : Type u_4} (parent : HierarchyTask k) (r : Request k Role Symbol) (hr : r.task.rank < parent.rank) {A C a b c₁ u E : ℝ} (hA : 0 ≤ A) (hC : 0 ≤ C) (ha : 0 < a) (hb : 0 < b) (hc₁ : 0 < c₁) (hba : c₁ * b ≤ r.terminal.rate) (hu : 0 < u) (huur : u ≤ r.source.rate) (M d c : ℕ) (hc : 0 < c) (offset : ℤ) (hscale : Real.logb 2 (b / a) = ↑offset) (hE : E ≤ (C * 2 ^ (-Cslib.LogSpaceEstimation.precision (16 * ↑c) A (Cslib.LogSpaceEstimation.lastBudget M d c offset) r.task.rank r.terminal.rate r.source.rate)) ^ 4) :
(if 0 ≤ offset then b / a else (b / a) ^ 3) * (r.source.rate / u) * E ≤ (C * 2 ^ (-Real.logb 2 c₁ / 2) * (2 ^ (-Cslib.LogSpaceEstimation.precision (16 * ↑c) A M parent.rank a u - A + ↑d / (16 * ↑c) + 1 / 16) * Cslib.LogSpaceEstimation.scaleMajorant offset)) ^ 4

Computed cross-stage ranks pay the scheduled coarse or fine child root bound. The actual source reset is supplied by the request's source tuple; no independence of errors is required. The two branches are the existing scheduled mean-comparison payments.

@[reducible, inline]
noncomputable abbrev Matrix.hierarchyResidual {q cπ Cπ Cpair Cvar : ℝ} (P : HierarchyParams q cπ Cπ Cpair Cvar) {V : ℕ → Type u_3} [(l : ℕ) → Fintype (V l)] (e : (l : ℕ) → V (l + 1) ≃ Lex (V l × Fin (P.m + 1))) {ι : ℕ → Type u_4} {κ : ℕ → Type u_5} [(l : ℕ) → Fintype (ι l)] [(l : ℕ) → Fintype (κ l)] (X : (l : ℕ) → ι l → V l → Prop) (Y : (l : ℕ) → κ l → V l → Prop) [(l : ℕ) → (s : ι l) → (v : V l) → Decidable (X l s v)] [(l : ℕ) → (s : κ l) → (v : V l) → Decidable (Y l s v)] (S : Matrix (V 0) (V 0) ℝ) (l : ℕ) :
Matrix (V l) (V l) ℝ

The raw argument of a routed bin is the residual of the actual detected hierarchy.

theorem Matrix.sum_expect_hierarchy_routed_bins {q cπ Cπ Cpair Cvar : ℝ} (P : HierarchyParams q cπ Cπ Cpair Cvar) {V : ℕ → Type u_3} [(l : ℕ) → Fintype (V l)] (e : (l : ℕ) → V (l + 1) ≃ Lex (V l × Fin (P.m + 1))) {ι : ℕ → Type u_4} {κ : ℕ → Type u_5} [(l : ℕ) → Fintype (ι l)] [(l : ℕ) → Fintype (κ l)] (X : (l : ℕ) → ι l → V l → Prop) (Y : (l : ℕ) → κ l → V l → Prop) [(l : ℕ) → (s : ι l) → (v : V l) → Decidable (X l s v)] [(l : ℕ) → (s : κ l) → (v : V l) → Decidable (Y l s v)] (S : Matrix (V 0) (V 0) ℝ) {Ω : Type u_6} [Fintype Ω] (l n : ℕ) (χ : ℝ → ℝ) (b : ℕ → ℝ) (hb : ∀ (i : ℕ), 0 < b i) (hχ : ∀ (t : ℝ), 1 ≤ t → χ t = 1) (Yr Ya Yt : Fin (P.m + 1) → Ω → V l → Prop) [(j : Fin (P.m + 1)) → (s : Ω) → (v : V l) → Decidable (Yr j s v)] [(j : Fin (P.m + 1)) → (s : Ω) → (v : V l) → Decidable (Ya j s v)] [(j : Fin (P.m + 1)) → (s : Ω) → (v : V l) → Decidable (Yt j s v)] (a d : V (l + 1)) (M : ℝ) (A : (j : Fin (P.m + 1)) → (i : ℕ) → DenseSamplingLaws (Yr j) (Ya j) (Yt j) (routedBinCutoff χ b i fun (w : ℝ) => copyFraction (P.copyCutoff (q⁻¹ ^ l)) P.m w j) (b i) M) (hD : ∀ (x y : V l), 0 ≤ hierarchyResidual P e X Y S l x y) (hDM : ∀ (x : V l), ∑ y : V l, hierarchyResidual P e X Y S l x y ≤ M) (hcover : hierarchyResidual P e X Y S l (ofLex ((e l) a)).1 (ofLex ((e l) d)).1 = 0 ∨ b n ≤ hierarchyResidual P e X Y S l (ofLex ((e l) a)).1 (ofLex ((e l) d)).1) :
(∑ i ∈ Finset.range (n + 1), P.weight (X l) (Y l) (q⁻¹ ^ l) (hierarchy P e X Y S l) (ofLex ((e l) a)).2 (ofLex ((e l) a)).1 * {s : Ω | Ya (ofLex ((e l) d)).2 s (ofLex ((e l) d)).1}.expect fun (s : Ω) => (A (ofLex ((e l) d)).2 i).direct (hierarchyResidual P e X Y S l) s (ofLex ((e l) a)).1 (ofLex ((e l) d)).1) = hierarchy P e X Y S (l + 1) a d

Summing true routed direct bins gives the next actual hierarchy matrix, on every fixed copy-symbol part. Row/gate laws are explicit; no desired conditional mean is assumed.