Documentation

CslibFrontier.Computability.LogSpaceDerandomization.SignedResidualBins

Signed residuals and bounded routed-bin evaluation #

The raw residual is C - E + EC, including the negative direct correction at scale f [OpenAI2026LogSpace, Section 7.2, after (7.2)], revision 7ef5c0cc. Its four children are whole functions; the right product child is evaluated at the midpoint. No positivity is asserted for estimated residuals. The top-bin extension clips the entire defining expression, including its routing argument, as prescribed in Section 5.2, (5.8)–(5.9). Other bins are extended by zero below zero and retain their original upper support.

The dense preparation and normalization evaluator accepts arbitrary completed raw and preparatory children. Ranks inspect the raw matrix before scalar clipping. True-input agreement and means are derived from the actual hierarchy residual bounds and primitive sampling laws, rather than stored mean certificates. This is finite mathematical evaluation; statistical error induction and finite-accuracy access enumeration are not proved here. The negative correction has its own scale-f rank channel, separate from the bin rank channel. The true residual fits the cap k + 2 at top scale one, since it is nonnegative with row mass at most one. Fine bins retain their true upper support; their uniform bound uses the adjacent-scale ratio.

Main definitions #

Main results #

Estimated copy-weight/routing-fraction root-error comparisons and the full threshold ladder with root/complement regularity are still needed for mean prefixes. The structural rank and range identities do not provide statistical-budget induction. Paired raw differences, full-coordinate walks/noise, compression, strong recursion and native workspace/class equality remain outside this bounded client.

theorem Matrix.HierarchyParams.boundedRoutedBinCutoff_residual {q cπ Cπ Cpair Cvar : ℝ} (P : HierarchyParams q cπ Cπ Cpair Cvar) {V : Type u_1} {ι : Type u_2} {κ : Type u_3} [Fintype V] [Fintype ι] [Fintype κ] (X : ι → V → Prop) (Y : κ → V → Prop) [(s : ι) → (v : V) → Decidable (X s v)] [(s : κ) → (v : V) → Decidable (Y s v)] {f : ℝ} {C : Matrix V V ℝ} (hf : 0 < f) (hC : ∀ (x y : V), 0 ≤ C x y) (hC1 : C.mulVec 1 ≤ 1) (χ : ℝ → ℝ) (b : ℕ → ℝ) (hb : ∀ (i : ℕ), 0 < b i) (hb0 : b 0 = 1) (i : ℕ) (route : ℝ → ℝ) (x y : V) :
boundedRoutedBinCutoff χ b (↑P.k + 2) i route (CorrectionRowRecipe.residual C (P.correction X Y f C) (P.correction X Y f C) C x y / b i) = routedBinCutoff χ b i route (P.residual X Y f C x y / b i)

The true residual fits a fixed top cap when the top scale is one. The bound follows from the hierarchy input bounds (each residual entry is nonnegative with row mass at most one), not from a desired mean or error estimate.

noncomputable def Matrix.HierarchyParams.CorrectionSampling.negativeRecipe {V : Type u_1} {Γ : Type u_4} {Ω : Type u_5} [Fintype Ω] {f : ℝ} (Ya Yt : Ω → V → Prop) [(s : Ω) → (v : V) → Decidable (Ya s v)] [(s : Ω) → (v : V) → Decidable (Yt s v)] (F : Γ × Ω → Matrix V V ℝ) (σ : Γ × Ω) (x y : V) :

The special negative term of Section 7.2: direct correction at scale f, with the endpoint usage density ratio. There is no midpoint density factor in this term.

theorem Matrix.HierarchyParams.CorrectionSampling.expect_negativeRecipe {q cπ Cπ Cpair Cvar : ℝ} {P : HierarchyParams q cπ Cπ Cpair Cvar} {V : Type u_1} {ι : Type u_2} {κ : Type u_3} {Γ : Type u_4} {Ω : Type u_5} [Fintype V] [Fintype ι] [Fintype κ] [Fintype Γ] [Fintype Ω] {X : ι → V → Prop} {Y : κ → V → Prop} {Xs : Γ → V → Prop} {Z Zt Ya : Ω → 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)] {f : ℝ} {C : Matrix V V ℝ} {i : ℕ} (A : P.CorrectionSampling X Y Xs Z Zt f C i) (hf : 0 < f) (hC : ∀ (x y : V), 0 ≤ C x y) (hC1 : C.mulVec 1 ≤ 1) (hsub : ∀ (s : Ω) (y : V), Zt s y → Ya s y) (x y : V) (hx : {s : Γ | Xs s x}.Nonempty) :
(({s : Γ | Xs s x} ×ˢ {s : Ω | Ya s y}).expect fun (σ : Γ × Ω) => negativeRecipe Ya Zt A.atom σ x y) = -P.correctionIter X Y f C (i + 1) x y

Its true conditional mean is explicitly negative. The correction's primitive sampling laws use its own raw input and multiplier, and usage is nested in the broad endpoint slice.

noncomputable def Matrix.HierarchyParams.CorrectionSampling.residualSample {q cπ Cπ Cpair Cvar : ℝ} {P : HierarchyParams q cπ Cπ Cpair Cvar} {V : Type u_1} {ι : Type u_2} {κ : Type u_3} {Γ : Type u_4} {Ω : Type u_5} [Fintype V] [Fintype ι] [Fintype κ] [Fintype Γ] [Fintype Ω] {X : ι → V → Prop} {Y : κ → V → Prop} {Xs : Γ → V → Prop} [(s : ι) → (v : V) → Decidable (X s v)] [(s : κ) → (v : V) → Decidable (Y s v)] [(s : Γ) → (v : V) → Decidable (Xs s v)] {f : ℝ} {C : Matrix V V ℝ} {i : ℕ} {Ζ : Type u_6} [Fintype Ζ] {Mid Midt : Ζ → V → Prop} [(s : Ζ) → (v : V) → Decidable (Mid s v)] [(s : Ζ) → (v : V) → Decidable (Midt s v)] (L : P.CorrectionSampling X Y Xs Mid Midt f C i) (Ya Yt Nt : Ω → V → Prop) [(s : Ω) → (v : V) → Decidable (Ya s v)] [(s : Ω) → (v : V) → Decidable (Yt s v)] [(s : Ω) → (v : V) → Decidable (Nt s v)] (b : ℝ) (F : Γ × Ζ → Matrix V V ℝ) (B : Ω → Matrix V V ℝ) (N : Γ × Ω → Matrix V V ℝ) (draw : (Γ × Ζ) × Ω) (x y : V) :

One direct/product bin contribution plus the whole special negative correction, which does not depend on the bin scale b; summing this sample over several bins counts that correction once per bin. Bin assembly with a single negative correction uses the separate HierarchyTask.rawPositiveSample and HierarchyTask.rawNegativeSample. Earlier tables are whole functions; negative and product-left factors have distinct endpoint/midpoint roles and usage slices.

theorem Matrix.HierarchyParams.CorrectionSampling.residualSample_eq_raw {q cπ Cπ Cpair Cvar : ℝ} {P : HierarchyParams q cπ Cπ Cpair Cvar} {V : Type u_1} {ι : Type u_2} {κ : Type u_3} {Γ : Type u_4} {Ω : Type u_5} [Fintype V] [Fintype ι] [Fintype κ] [Fintype Γ] [Fintype Ω] {X : ι → V → Prop} {Y : κ → V → Prop} {Xs : Γ → V → Prop} [(s : ι) → (v : V) → Decidable (X s v)] [(s : κ) → (v : V) → Decidable (Y s v)] [(s : Γ) → (v : V) → Decidable (Xs s v)] {f : ℝ} {C : Matrix V V ℝ} {i : ℕ} {Ζ : Type u_6} [Fintype Ζ] {Mid Midt : Ζ → V → Prop} [(s : Ζ) → (v : V) → Decidable (Mid s v)] [(s : Ζ) → (v : V) → Decidable (Midt s v)] (L : P.CorrectionSampling X Y Xs Mid Midt f C i) (Ya Yt Nt : Ω → V → Prop) [(s : Ω) → (v : V) → Decidable (Ya s v)] [(s : Ω) → (v : V) → Decidable (Yt s v)] [(s : Ω) → (v : V) → Decidable (Nt s v)] (b : ℝ) (F : Γ × Ζ → Matrix V V ℝ) (B : Ω → Matrix V V ℝ) (N : Γ × Ω → Matrix V V ℝ) (s : Γ) (t : Ζ) (u : Ω) (x y : V) :
L.residualSample Ya Yt Nt b F B N ((s, t), u) x y = CorrectionRowRecipe.residual (fun (x y : V) => b * (↑{s : Ω | Ya s y}.dens / ↑{s : Ω | Yt s y}.dens) * B u x y) (fun (x y : V) => f * (↑{s : Ω | Ya s y}.dens / ↑{s : Ω | Nt s y}.dens) * N (s, u) x y) (fun (x z : V) => f / L.π * F (s, t) x z) (fun (z y : V) => b * (↑{s : Ω | Ya s y}.dens / ↑{s : Ω | Yt s y}.dens) * B u z y) x y

The stochastic signed sample is exactly the completed four-child raw recipe used by preparation and normalization. Density factors belong to the appropriate whole child; the negative endpoint child and product-left midpoint child are kept separate.

theorem Matrix.HierarchyParams.CorrectionSampling.expect_residualSample {q cπ Cπ Cpair Cvar : ℝ} {P : HierarchyParams q cπ Cπ Cpair Cvar} {V : Type u_1} {ι : Type u_2} {κ : Type u_3} {Γ : Type u_4} {Ω : Type u_5} [Fintype V] [Fintype ι] [Fintype κ] [Fintype Γ] [Fintype Ω] {X : ι → V → Prop} {Y : κ → V → Prop} {Xs : Γ → V → Prop} {Ya : Ω → 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 (Ya s v)] {f : ℝ} {C : Matrix V V ℝ} {i : ℕ} {Ζ : Type u_6} [Fintype Ζ] {Mid Midt : Ζ → V → Prop} {Yr Yt Nr Nt : Ω → V → Prop} [(s : Ζ) → (v : V) → Decidable (Mid s v)] [(s : Ζ) → (v : V) → Decidable (Midt s v)] [(s : Ω) → (v : V) → Decidable (Yr s v)] [(s : Ω) → (v : V) → Decidable (Yt s v)] [(s : Ω) → (v : V) → Decidable (Nr s v)] [(s : Ω) → (v : V) → Decidable (Nt s v)] {b : ℝ} {k : ℝ → ℝ} (L : P.CorrectionSampling X Y Xs Mid Midt f C i) (B : DenseSamplingLaws Yr Ya Yt k b 1) (N : P.CorrectionSampling X Y Xs Nr Nt f C i) (hf : 0 < f) (hb : 0 < b) (hC : ∀ (x y : V), 0 ≤ C x y) (hC1 : C.mulVec 1 ≤ 1) (hsub : ∀ (s : Ω) (y : V), Nt s y → Ya s y) (x y : V) (hx : {s : Γ | Xs s x}.Nonempty) :
((({s : Γ | Xs s x} ×ˢ Finset.univ) ×ˢ {s : Ω | Ya s y}).expect fun (draw : (Γ × Ζ) × Ω) => L.residualSample Ya Yt Nt b L.atom (B.atom C) N.atom draw x y) = b * k (C x y / b) + ∑ z : V, P.correctionIter X Y f C (i + 1) x z * (b * k (C z y / b)) - P.correctionIter X Y f C (i + 1) x y

All three signed means follow from primitive laws on the actual tuples. This is the mean of one bin sample: the direct and product terms carry the cutoff k at scale b, and the whole -E is included, where E is correction iterate i + 1. Summing these means over several bins therefore repeats -E once per bin. No independence of estimated factors is asserted.

Completed residual, its broad preparation, then its usage-normalized bin.

noncomputable def Matrix.ResidualBinTask.value {V : Type u_1} {Γ : Type u_2} {Ω : Type u_3} [Fintype V] [Fintype Γ] [Fintype Ω] (χ : ℝ → ℝ) (b : ℕ → ℝ) (cap : ℝ) (i : ℕ) (route h ρ : ℝ → ℝ) (K : ℕ) (X : Γ → V → Prop) (Y Yt : Ω → V → Prop) [(s : Γ) → (v : V) → Decidable (X s v)] [(s : Ω) → (v : V) → Decidable (Y s v)] [(s : Ω) → (v : V) → Decidable (Yt s v)] (base negative left right prep : Γ × Ω → Matrix V V ℝ) (p : Phase) (σ : Γ × Ω) :

A real evaluator for substituted child functions, including signed residual preparation and normalization. The preparatory child is separately supplied to the normalized phase so an estimate of that earlier output can be substituted. Ranks use this draw's completed raw residual; only the scalar row function clips.

theorem Matrix.ResidualBinTask.value_true {V : Type u_1} {Γ : Type u_2} {Ω : Type u_3} [Fintype V] [Fintype Γ] [Fintype Ω] {q cπ Cπ Cpair Cvar : ℝ} (P : HierarchyParams q cπ Cπ Cpair Cvar) {ι : Type u_4} {κ : Type u_5} [Fintype ι] [Fintype κ] (X₀ : ι → V → Prop) (Y₀ : κ → V → Prop) [(s : ι) → (v : V) → Decidable (X₀ s v)] [(s : κ) → (v : V) → Decidable (Y₀ s v)] (f : ℝ) (C : Matrix V V ℝ) (χ : ℝ → ℝ) (b : ℕ → ℝ) (cap : ℝ) (i : ℕ) (route h ρ : ℝ → ℝ) (K : ℕ) (X : Γ → V → Prop) (Y Yt : Ω → V → Prop) [(s : Γ) → (v : V) → Decidable (X s v)] [(s : Ω) → (v : V) → Decidable (Y s v)] [(s : Ω) → (v : V) → Decidable (Yt s v)] (σ : Γ × Ω) (x y : V) (hx : {s : Γ | X s x}.Nonempty) :
have base := fun (x : Γ × Ω) => C; have correction := fun (x : Γ × Ω) => P.correction X₀ Y₀ f C; have prep := value χ b cap i route h ρ K X Y Yt base correction correction base base Phase.preparation; value χ b cap i route h ρ K X Y Yt base correction correction base prep Phase.normalized σ x y = denseAtom Y Yt (boundedRoutedBinCutoff χ b cap i route) h ρ K (b i) (P.residual X₀ Y₀ f C) σ.2 x y

True preparation and normalization on a real residual agree with the actual dense atom. The exact residual is the existing hierarchy operation, rather than a second hierarchy.

theorem Matrix.ResidualBinTask.expect_value_true {V : Type u_1} {Γ : Type u_2} {Ω : Type u_3} [Fintype V] [Fintype Γ] [Fintype Ω] {q cπ Cπ Cpair Cvar : ℝ} (P : HierarchyParams q cπ Cπ Cpair Cvar) {ι : Type u_4} {κ : Type u_5} [Fintype ι] [Fintype κ] (X₀ : ι → V → Prop) (Y₀ : κ → V → Prop) [(s : ι) → (v : V) → Decidable (X₀ s v)] [(s : κ) → (v : V) → Decidable (Y₀ s v)] {f : ℝ} (C : Matrix V V ℝ) (hf : 0 < f) (hC : ∀ (x y : V), 0 ≤ C x y) (hC1 : C.mulVec 1 ≤ 1) (χ : ℝ → ℝ) (b : ℕ → ℝ) (hb : ∀ (i : ℕ), 0 < b i) (hb0 : b 0 = 1) (i : ℕ) (route : ℝ → ℝ) (X : Γ → V → Prop) (Y Ya Yt : Ω → V → Prop) [(s : Γ) → (v : V) → Decidable (X s v)] [(s : Ω) → (v : V) → Decidable (Y s v)] [(s : Ω) → (v : V) → Decidable (Ya s v)] [(s : Ω) → (v : V) → Decidable (Yt s v)] (A : DenseSamplingLaws Y Ya Yt (boundedRoutedBinCutoff χ b (↑P.k + 2) i route) (b i) 1) (x y : V) (hx : {s : Γ | X s x}.Nonempty) :
have base := fun (x : Γ × Ω) => C; have correction := fun (x : Γ × Ω) => P.correction X₀ Y₀ f C; have prep := value χ b (↑P.k + 2) i route A.h A.ρ A.K X Y Yt base correction correction base base Phase.preparation; (({s : Γ | X s x} ×ˢ {s : Ω | Ya s y}).expect fun (σ : Γ × Ω) => b i * (↑{s : Ω | Ya s y}.dens / ↑{s : Ω | Yt s y}.dens) * value χ b (↑P.k + 2) i route A.h A.ρ A.K X Y Yt base correction correction base prep Phase.normalized σ x y) = b i * routedBinCutoff χ b i route (P.residual X₀ Y₀ f C x y / b i)

True conditional mean for the actual residual client. Input bounds and the cap are checked against the actual finite correction hierarchy; gate/pair laws supply normalization. Preparation uses the broad rank channel and averages on the narrower usage slice.

def Matrix.HierarchyParams.HierarchyTask.residualRequests {k : ℕ} {Role : Type u_1} {Symbol : Type u_2} (l : ℕ) (source midpoint endpoint : CorrectionRowTask.Channel Role (List Symbol)) (b : ℝ) :
List (Request k Role Symbol)

Actual direct, left, right and special negative requests for a residual sample. The negative child uses the endpoint role at scale f, with usage min(a,f); it is not the left child on the midpoint role. The right child resets its source to the full midpoint tuple.

theorem Matrix.HierarchyParams.HierarchyTask.residualRequests_rank_lt {k : ℕ} {Role : Type u_1} {Symbol : Type u_2} (l : ℕ) (source midpoint endpoint : CorrectionRowTask.Channel Role (List Symbol)) (b : ℝ) (r : Request k Role Symbol) (hr : r ∈ residualRequests l source midpoint endpoint b) :

Each actual residual child decreases the existing matrix-output structural rank.