Documentation

CslibFrontier.Computability.StreamArithmetic.Primitives

Uncompiled stream query schedules for arithmetic primitives #

This module constructs uncompiled StreamSchedule exact-evaluation and digit-lookahead helpers as intermediate steps after, and not formalizations of, [OpenAI2026LogSpace, Sections 10.2--10.6, Lemmas 10.3--10.7]. Native Turing-machine or counter-program space realization remains open and is tracked in #9181.

Because QueryProg continuations are arbitrary host Lean functions, every StreamSchedule below certifies only exact signed-digit stream evaluation (emits_signed, emits_exact) and digit-query index lookahead (j ≤ t + lookaheadCoeff * slack); no uniformity, computability, or machine workspace bound is claimed.

Main definitions #

Main results #

References #

Variables, rational constants, negation, and structural guards #

Exact negation of a signed-digit stream negates its real value.

noncomputable def Cslib.StreamArithmetic.varSchedule {Op : Type u} {Struct : Type v} (d : ℕ) (hd : 1 ≤ d) (op : Op) :
StreamSchedule Op Struct

Identity StreamSchedule reading operand op directly at place t (lookaheadCoeff = 0).

noncomputable def Cslib.StreamArithmetic.ratSchedule {Op : Type u} {Struct : Type v} (d : ℕ) (hd : 1 ≤ d) (q : ℚ) (hq : |q| ≤ 1) :
StreamSchedule Op Struct

Constant rational StreamSchedule emitting ratStream q for any |q| ≤ 1 with zero oracle queries (lookaheadCoeff = 0).

noncomputable def Cslib.StreamArithmetic.StreamSchedule.neg {Op : Type u} {Struct : Type v} (S : StreamSchedule Op Struct) :
StreamSchedule Op Struct

Exact stream negation preserving lookaheadCoeff.

noncomputable def Cslib.StreamArithmetic.StreamSchedule.guardStruct {Op : Type u} {Struct : Type v} (S : StreamSchedule Op Struct) (sOp : Struct) :
StreamSchedule Op Struct

Structural indicator guard emitting S when sEnv sOp = true and 0 when sEnv sOp = false, requiring S.ValidEnv only on the active branch sEnv sOp = true (uncompiled helper after [OpenAI2026LogSpace, Section 10.5]; see #9181).

def Cslib.StreamArithmetic.QueryProg.reindexOp {Op₁ : Type u} {Op₂ : Type u'} {Struct : Type v} {α : Type w} (f : Op₁ → Op₂) :
QueryProg Op₁ Struct α → QueryProg Op₂ Struct α

Remap operand indices inside a QueryProg.

@[simp]
theorem Cslib.StreamArithmetic.QueryProg.eval_reindexOp {Op₁ : Type u} {Op₂ : Type u'} {Struct : Type v} {α : Type w} (f : Op₁ → Op₂) (p : QueryProg Op₁ Struct α) (env : Op₂ → ℕ → ℤ) (sEnv : Struct → Bool) :
(reindexOp f p).eval env sEnv = p.eval (fun (op : Op₁) => env (f op)) sEnv
theorem Cslib.StreamArithmetic.QueryProg.mem_activeQueries_reindexOp {Op₁ : Type u} {Op₂ : Type u'} {Struct : Type v} {α : Type w} (f : Op₁ → Op₂) (p : QueryProg Op₁ Struct α) (env : Op₂ → ℕ → ℤ) (sEnv : Struct → Bool) {ev : QueryEvent Op₂ Struct} (hev : ev ∈ (reindexOp f p).activeQueries env sEnv) :
(∃ (sOp : Struct), QueryEvent.struct sOp ∈ p.activeQueries (fun (op : Op₁) => env (f op)) sEnv ∧ ev = QueryEvent.struct sOp) ∨ ∃ (op : Op₁) (j : ℕ), QueryEvent.digit op j ∈ p.activeQueries (fun (op : Op₁) => env (f op)) sEnv ∧ ev = QueryEvent.digit (f op) j

Elementary binary schedules (pairAvg, max, min) #

Pairwise average #

def Cslib.StreamArithmetic.pairAvgResProg {Struct : Type v} (s : ℕ) :
QueryProg (Fin 2) Struct ℤ

Uncompiled mod-16 residue query tree for (streamVal x + streamVal y) / 2 using 9-place low windows (helper after [OpenAI2026LogSpace, Lemma 10.3]; see #9181).

theorem Cslib.StreamArithmetic.eval_pairAvgResProg {Struct : Type v} (s : ℕ) (env : Fin 2 → ℕ → ℤ) (sEnv : Struct → Bool) :
(pairAvgResProg s).eval env sEnv = SignedDigitStream.pairAvgApprox (env 0) (env 1) s % 16
theorem Cslib.StreamArithmetic.mem_activeQueries_pairAvgResProg {Struct : Type v} (s : ℕ) (env : Fin 2 → ℕ → ℤ) (sEnv : Struct → Bool) {ev : QueryEvent (Fin 2) Struct} (hev : ev ∈ (pairAvgResProg s).activeQueries env sEnv) :
∃ (op : Fin 2), ∃ j ≤ s + 4, ev = QueryEvent.digit op j
noncomputable def Cslib.StreamArithmetic.pairAvgSchedule {Struct : Type v} (d : ℕ) (hd : 1 ≤ d) :
StreamSchedule (Fin 2) Struct

Uncompiled pairwise-average query schedule after, and not a machine-space formalization of, [OpenAI2026LogSpace, Lemma 10.3] (native space realization is tracked in #9181): computes (val 0 + val 1) / 2 with digit lookahead j ≤ t + 4 * d.

Windowed comparison, max, and min #

def Cslib.StreamArithmetic.maxResProg {Struct : Type v} (s : ℕ) :
QueryProg (Fin 2) Struct ℤ

Uncompiled mod-16 residue query tree for max (streamVal x) (streamVal y) (helper after [OpenAI2026LogSpace, Lemma 10.3]; see #9181).

theorem Cslib.StreamArithmetic.eval_maxResProg {Struct : Type v} (s : ℕ) (env : Fin 2 → ℕ → ℤ) (sEnv : Struct → Bool) :
(maxResProg s).eval env sEnv = SignedDigitStream.maxApprox (env 0) (env 1) s % 16
noncomputable def Cslib.StreamArithmetic.maxSchedule {Struct : Type v} (d : ℕ) (hd : 1 ≤ d) :
StreamSchedule (Fin 2) Struct

Uncompiled binary-maximum query schedule after, and not a machine-space formalization of, [OpenAI2026LogSpace, Lemma 10.3] (native space realization is tracked in #9181): computes max (val 0) (val 1) with digit lookahead j ≤ t + 4 * d.

def Cslib.StreamArithmetic.minResProg {Struct : Type v} (s : ℕ) :
QueryProg (Fin 2) Struct ℤ

Uncompiled mod-16 residue query tree for min (streamVal x) (streamVal y) (helper after [OpenAI2026LogSpace, Lemma 10.3]; see #9181).

theorem Cslib.StreamArithmetic.eval_minResProg {Struct : Type v} (s : ℕ) (env : Fin 2 → ℕ → ℤ) (sEnv : Struct → Bool) :
(minResProg s).eval env sEnv = SignedDigitStream.minApprox (env 0) (env 1) s % 16
noncomputable def Cslib.StreamArithmetic.minSchedule {Struct : Type v} (d : ℕ) (hd : 1 ≤ d) :
StreamSchedule (Fin 2) Struct

Uncompiled binary-minimum query schedule after, and not a machine-space formalization of, [OpenAI2026LogSpace, Lemma 10.3] (native space realization is tracked in #9181): computes min (val 0) (val 1) with digit lookahead j ≤ t + 4 * d.

Binary schedule composition combinators #

noncomputable def Cslib.StreamArithmetic.composeBinSchedule {Op : Type u} {Struct : Type v} (prim : StreamSchedule (Fin 2) Struct) (hPrimValid : ∀ (env₁ : Fin 2 → ℕ → ℤ) (sEnv : Struct → Bool), (∀ (i : Fin 2), IsNormSignedStream (env₁ i)) → prim.ValidEnv env₁ sEnv) (S₁ S₂ : StreamSchedule Op Struct) (hSlackP : prim.slack = S₁.slack) (hSlack₂ : S₂.slack = S₁.slack) :
StreamSchedule Op Struct

Helper composing any normalized binary StreamSchedule on Fin 2 with two child schedules S₁, S₂.

noncomputable def Cslib.StreamArithmetic.StreamSchedule.pairAvg {Op : Type u} {Struct : Type v} (S₁ S₂ : StreamSchedule Op Struct) (hSlack : S₂.slack = S₁.slack) :
StreamSchedule Op Struct

Compose two StreamSchedules with exact pairwise average (S₁ + S₂) / 2.

noncomputable def Cslib.StreamArithmetic.StreamSchedule.max {Op : Type u} {Struct : Type v} (S₁ S₂ : StreamSchedule Op Struct) (hSlack : S₂.slack = S₁.slack) :
StreamSchedule Op Struct

Compose two StreamSchedules with exact binary maximum max S₁ S₂.

noncomputable def Cslib.StreamArithmetic.StreamSchedule.min {Op : Type u} {Struct : Type v} (S₁ S₂ : StreamSchedule Op Struct) (hSlack : S₂.slack = S₁.slack) :
StreamSchedule Op Struct

Compose two StreamSchedules with exact binary minimum min S₁ S₂.

Shift-clip and balanced binary-tree averages #

Shift-clip schedule #

Public signed-digit stream whose K-place intPrefix equals 2 ^ m whenever m ≤ K + 3 and 4 ≤ m.

Mod-16 saturated positive boundary residue ⌊2 ^ (s + 4) / 16⌋ % 16 for shiftClipApprox.

Mod-16 saturated negative boundary residue (-2 ^ s) % 16 for shiftClipApprox.

Uncompiled mod-16 residue query tree for shiftClipApprox v (env ()) s using at most two constant-bound prefix comparisons and an 8-bit low-residue window (helper after [OpenAI2026LogSpace, Lemma 10.7]; see #9181).

theorem Cslib.StreamArithmetic.eval_shiftClipResProg {Struct : Type v} (v : ℤ) (s : ℕ) {env : Unit → ℕ → ℤ} (hx : SignedDigitStream.IsSignedStream (env ())) (sEnv : Struct → Bool) :
noncomputable def Cslib.StreamArithmetic.shiftClipSchedule {Struct : Type v} (d : ℕ) (hd : 1 ≤ d) (v : ℤ) (κ : ℕ) (hv : v ≤ ↑(κ * d)) :

Uncompiled shift-and-clip query schedule after, and not a machine-space formalization of, [OpenAI2026LogSpace, Lemma 10.7] (native space realization is tracked in #9181): computes max (-1) (min 1 (2 ^ v * streamVal x)) for any integer shift v ≤ κ * d with digit lookahead j ≤ t + (κ + 4) * d.

noncomputable def Cslib.StreamArithmetic.StreamSchedule.shiftClip {Op : Type u} {Struct : Type v} (S : StreamSchedule Op Struct) (v : ℤ) (κ : ℕ) (hv : v ≤ ↑(κ * S.slack)) :
StreamSchedule Op Struct

Apply exact shift-and-clip max (-1) (min 1 (2 ^ v * S)) (v ≤ κ * d) to a StreamSchedule.

Balanced binary-tree averages #

def Cslib.StreamArithmetic.splitFinPow {r : ℕ} (b : Fin 2) (idx : Fin (2 ^ r)) :
Fin (2 ^ (r + 1))

Binary-tree child index embedding Fin 2 × Fin (2 ^ r) → Fin (2 ^ (r + 1)).

def Cslib.StreamArithmetic.balancedAvgDigitProg {Struct : Type v} (r a✝ : ℕ) :
QueryProg (Fin (2 ^ r)) Struct ℤ

Uncompiled balanced binary-tree average digit query tree over 2 ^ r operand streams (helper after [OpenAI2026LogSpace, Lemma 10.7]; see #9181).

theorem Cslib.StreamArithmetic.balancedAvgDigitProg_emits {Struct : Type v} (r : ℕ) {env : Fin (2 ^ r) → ℕ → ℤ} (hEnv : ∀ (i : Fin (2 ^ r)), IsNormSignedStream (env i)) (sEnv : Struct → Bool) :
(SignedDigitStream.IsSignedStream fun (t : ℕ) => (balancedAvgDigitProg r t).eval env sEnv) ∧ (SignedDigitStream.streamVal fun (t : ℕ) => (balancedAvgDigitProg r t).eval env sEnv) = (∑ i : Fin (2 ^ r), SignedDigitStream.streamVal (env i)) / 2 ^ r ∧ |(∑ i : Fin (2 ^ r), SignedDigitStream.streamVal (env i)) / 2 ^ r| ≤ 1
theorem Cslib.StreamArithmetic.mem_activeQueries_balancedAvgDigitProg {Struct : Type v} (r t : ℕ) (env : Fin (2 ^ r) → ℕ → ℤ) (sEnv : Struct → Bool) {ev : QueryEvent (Fin (2 ^ r)) Struct} (hev : ev ∈ (balancedAvgDigitProg r t).activeQueries env sEnv) :
∃ (op : Fin (2 ^ r)), ∃ j ≤ t + 4 * r, ev = QueryEvent.digit op j
noncomputable def Cslib.StreamArithmetic.balancedAvgPrimSchedule {Struct : Type v} (d : ℕ) (hd : 1 ≤ d) (r κ : ℕ) (hr : r ≤ κ * d) :
StreamSchedule (Fin (2 ^ r)) Struct

Uncompiled balanced binary-tree average query schedule after, and not a machine-space formalization of, [OpenAI2026LogSpace, Lemma 10.7] (native space realization is tracked in #9181): averages 2 ^ r normalized streams (r ≤ κ * d) with digit lookahead j ≤ t + 4 * r ≤ t + (4 * κ) * d.

noncomputable def Cslib.StreamArithmetic.balancedAvgSchedule {Op : Type u} {Struct : Type v} (d : ℕ) (hd : 1 ≤ d) (r κ : ℕ) (hr : r ≤ κ * d) (children : Fin (2 ^ r) → StreamSchedule Op Struct) (cC : ℕ) (hSlack : ∀ (i : Fin (2 ^ r)), (children i).slack = d) (hLookahead : ∀ (i : Fin (2 ^ r)), (children i).lookaheadCoeff ≤ cC) :
StreamSchedule Op Struct

Compose 2 ^ r (r ≤ κ * d) child StreamSchedules with balancedAvgPrimSchedule (uncompiled helper after [OpenAI2026LogSpace, Lemma 10.7]; see #9181).

Minimum-index dyadic band multiplication #

Band window geometry and scanning programs #

Decidable membership predicate for (i, j) ∈ bandWindowPairs s 4 k.

Instances For
    @[instance_reducible]
    def Cslib.StreamArithmetic.bandScanJ {Struct : Type v} (s k i idxJ : ℕ) :
    ℕ → ℤ → QueryProg (Fin 2) Struct ℤ

    Inner column loop accumulating band k terms modulo 2 ^ (4 + bandMargin k).

    def Cslib.StreamArithmetic.bandScanI {Struct : Type v} (s k idxI : ℕ) :
    ℕ → ℤ → QueryProg (Fin 2) Struct ℤ

    Row loop over i ∈ range (s + bandMargin k + 1) for band k.

    def Cslib.StreamArithmetic.bandOuterAux {Struct : Type v} (s step : ℕ) :
    ℕ → ℤ → QueryProg (Fin 2) Struct ℤ

    Outer downward band fold from maxBand s - 1 down to 0 (step = 0 .. maxBand s).

    def Cslib.StreamArithmetic.mulResProg {Struct : Type v} (s : ℕ) :
    QueryProg (Fin 2) Struct ℤ

    Uncompiled windowed mod-16 product residue query tree (helper after [OpenAI2026LogSpace, Lemma 10.4]; see #9181).

    Evaluation correctness #

    theorem Cslib.StreamArithmetic.eval_mulResProg {Struct : Type v} (s : ℕ) (env : Fin 2 → ℕ → ℤ) (sEnv : Struct → Bool) :
    (mulResProg s).eval env sEnv = SignedDigitStream.mulApprox (env 0) (env 1) s % 16

    Active queries and lookahead bound #

    theorem Cslib.StreamArithmetic.lookahead_mulResProg {Struct : Type v} {d : ℕ} (hd : 1 ≤ d) (s : ℕ) (env : Fin 2 → ℕ → ℤ) (sEnv : Struct → Bool) {op : Fin 2} {j : ℕ} (hev : QueryEvent.digit op j ∈ (mulResProg s).activeQueries env sEnv) :
    j ≤ s + 16 * d

    Uncompiled multiplication schedule #

    noncomputable def Cslib.StreamArithmetic.mulSchedule {Struct : Type v} (d : ℕ) (hd : 1 ≤ d) :
    StreamSchedule (Fin 2) Struct

    Uncompiled minimum-index dyadic band multiplication query schedule after, and not a machine-space formalization of, [OpenAI2026LogSpace, Lemma 10.4] (native space realization is tracked in #9181): computes val 0 * val 1 with digit lookahead j ≤ t + 16 * d.

    noncomputable def Cslib.StreamArithmetic.StreamSchedule.mul {Op : Type u} {Struct : Type v} (S₁ S₂ : StreamSchedule Op Struct) (hSlack : S₂.slack = S₁.slack) :
    StreamSchedule Op Struct

    Compose two StreamSchedules with exact multiplication S₁ * S₂.

    Early-word reciprocal and unit prefix clamping #

    Integer prefix queries and unit-interval clamping #

    def Cslib.StreamArithmetic.intPrefixAux {Op : Type u} {Struct : Type v} (op : Op) (idx : ℕ) :
    ℕ → ℤ → QueryProg Op Struct ℤ

    Tail-recursive early-word integer prefix query tree over rem consecutive digits starting at idx.

    def Cslib.StreamArithmetic.intPrefixProg {Op : Type u} {Struct : Type v} (op : Op) (K : ℕ) :
    QueryProg Op Struct ℤ

    Uncompiled query tree computing intPrefix (env op) K by querying places 0, ..., K.

    theorem Cslib.StreamArithmetic.eval_intPrefixProg {Op : Type u} {Struct : Type v} (op : Op) (K : ℕ) (env : Op → ℕ → ℤ) (sEnv : Struct → Bool) :
    (intPrefixProg op K).eval env sEnv = SignedDigitStream.intPrefix (env op) K
    theorem Cslib.StreamArithmetic.mem_activeQueries_intPrefixProg {Op : Type u} {Struct : Type v} (op : Op) (K : ℕ) (env : Op → ℕ → ℤ) (sEnv : Struct → Bool) {ev : QueryEvent Op Struct} (hev : ev ∈ (intPrefixProg op K).activeQueries env sEnv) :
    ∃ j ≤ K, ev = QueryEvent.digit op j

    Clamp a K-place signed-digit integer prefix into the canonical nonnegative range {0, ..., 2 ^ K} (after [OpenAI2026LogSpace, Section 10.4, Lemma 10.5]).

    def Cslib.StreamArithmetic.clippedUnitPrefixProg {Op : Type u} {Struct : Type v} (op : Op) (K : ℕ) :
    QueryProg Op Struct ℕ

    Uncompiled query tree computing the {0, ..., 2 ^ K}-clamped integer prefix of env op at place K (helper after [OpenAI2026LogSpace, Section 10.4, Lemma 10.5]; see #9181).

    theorem Cslib.StreamArithmetic.eval_clippedUnitPrefixProg {Op : Type u} {Struct : Type v} (op : Op) (K : ℕ) (env : Op → ℕ → ℤ) (sEnv : Struct → Bool) :

    Virtual reciprocal composition and evaluation #

    noncomputable def Cslib.StreamArithmetic.recipHalfVirtualSchedule {Struct : Type v} :
    StreamSchedule (Fin 3) Struct

    Fixed slack-1 inner StreamSchedule computing (v₀ + v₁ * v₂) / 2 over virtual streams Fin 3.

    def Cslib.StreamArithmetic.recipVirtualEnv (x : ℕ → ℤ) (s : ℕ) (i : Fin 3) :
    ℕ → ℤ

    Virtual 3-operand environment [ratStream α, ratStream β, suffixStream x (recipCutoff s)].

    noncomputable def Cslib.StreamArithmetic.recipOuterProg {Struct : Type v} (s : ℕ) :
    QueryProg (Fin 3) Struct ℤ

    Outer fixed-depth query tree over the 3 virtual reciprocal streams.

    def Cslib.StreamArithmetic.recipChild {Struct : Type v} (s : ℕ) (op : Fin 3) (r : ℕ) :

    Uncompiled early-word / suffix child query trees realizing recipVirtualEnv: streams 0, 1 query places j ≤ recipCutoff s and stream 2 (suffixStream) queries env () directly only at places r > recipCutoff s (helper after [OpenAI2026LogSpace, Lemma 10.5]; see #9181).

    noncomputable def Cslib.StreamArithmetic.recip64ResProg {Struct : Type v} (s : ℕ) :

    Uncompiled mod-16 residue query tree for recip64Approx (env ()) s (helper after [OpenAI2026LogSpace, Lemma 10.5]; see #9181).

    theorem Cslib.StreamArithmetic.eval_recip64ResProg {Struct : Type v} (s : ℕ) {env : Unit → ℕ → ℤ} (hx : SignedDigitStream.IsSignedStream (env ())) (hx_mem : SignedDigitStream.streamVal (env ()) ∈ Set.Icc (1 / 4) 1) (sEnv : Struct → Bool) :

    Active queries and lookahead bound #

    theorem Cslib.StreamArithmetic.mem_activeQueries_recipOuterProg_digit {Struct : Type v} (s : ℕ) (vEnv : Fin 3 → ℕ → ℤ) (sEnv : Struct → Bool) {op : Fin 3} {r : ℕ} (hev : QueryEvent.digit op r ∈ (recipOuterProg s).activeQueries vEnv sEnv) :

    Uncompiled reciprocal schedule #

    noncomputable def Cslib.StreamArithmetic.recip64Schedule {Struct : Type v} (d : ℕ) (hd : 1 ≤ d) :

    Uncompiled early-word reciprocal query schedule on [1 / 4, 1] after, and not a machine-space formalization of, [OpenAI2026LogSpace, Lemma 10.5] (native space realization is tracked in #9181): computes 1 / (64 * val ()) for streamVal (env ()) ∈ [1 / 4, 1] with digit lookahead j ≤ t + (8 + recipHalfVirtualSchedule.lookaheadCoeff) * d.

    noncomputable def Cslib.StreamArithmetic.StreamSchedule.recip64 {Op : Type u} {Struct : Type v} (S : StreamSchedule Op Struct) :
    StreamSchedule Op Struct

    Compose a StreamSchedule whose target value lies in [1 / 4, 1] with recip64Schedule to obtain 1 / (64 * S).

    Zero-padded detector rank #

    Counting and fold query trees #

    def Cslib.StreamArithmetic.countAtLeastProg {Op : Type u} {Struct : Type v} (i : Op) (K : ℕ) :
    List Op → ℕ → QueryProg Op Struct ℕ

    Count how many elements w in ws satisfy 0 ≤ cmpPrefixProg w i K.

    def Cslib.StreamArithmetic.zeroPaddedRankFoldProg {Op : Type u} {Struct : Type v} (k : ℕ) (items : List Op) (K : ℕ) :
    List Op → Option Op → QueryProg Op Struct (Option Op)

    Uncompiled outer scan over candidate elements rem for the zero-padded detector rank, tracking the index best : Option Op with largest positive intPrefix among elements exceeded or matched by at least k members of items.

    def Cslib.StreamArithmetic.zeroPaddedRankListResProg {Op : Type u} {Struct : Type v} (k : ℕ) (items : List Op) (s : ℕ) :
    QueryProg Op Struct ℤ

    Uncompiled mod-16 residue query tree for zeroPaddedRankApprox k items.toFinset env s (clamping negative order statistics up to 0 as in Finset.kthLargest; helper after [OpenAI2026LogSpace, Lemma 10.6] and Sections 4.2, 8.2; see #9181).

    Evaluation correctness #

    theorem Cslib.StreamArithmetic.eval_zeroPaddedRankListResProg {Op : Type u} [DecidableEq Op] {Struct : Type v} (k : ℕ) (items : List Op) (hNodup : items.Nodup) (s : ℕ) {env : Op → ℕ → ℤ} (hEnv : ∀ x ∈ items, SignedDigitStream.IsSignedStream (env x)) (sEnv : Struct → Bool) :

    Active queries and lookahead bound #

    theorem Cslib.StreamArithmetic.mem_activeQueries_zeroPaddedRankFoldProg {Op : Type u} {Struct : Type v} (k : ℕ) (items : List Op) (K : ℕ) (rem : List Op) (best : Option Op) (env : Op → ℕ → ℤ) (sEnv : Struct → Bool) {ev : QueryEvent Op Struct} (hev : ev ∈ (zeroPaddedRankFoldProg k items K rem best).activeQueries env sEnv) :
    ∃ (op : Op), ∃ j ≤ K, ev = QueryEvent.digit op j

    Uncompiled rank schedules #

    noncomputable def Cslib.StreamArithmetic.zeroPaddedRankListSchedule {Op : Type u} [DecidableEq Op] {Struct : Type v} (d : ℕ) (hd : 1 ≤ d) (k : ℕ) (items : List Op) (hNodup : items.Nodup) :
    StreamSchedule Op Struct

    Uncompiled zero-padded detector-rank query schedule over a duplicate-free list (intermediate helper after, and not a machine-space formalization of, [OpenAI2026LogSpace, Lemma 10.6] and Sections 4.2, 8.2; native space realization is tracked in #9181): computes Finset.kthLargest k items.toFinset (clamping negative order statistics up to 0) with digit lookahead j ≤ t + 4 * d.

    noncomputable def Cslib.StreamArithmetic.zeroPaddedRankFinsetSchedule {Op : Type u} [DecidableEq Op] {Struct : Type v} (d : ℕ) (hd : 1 ≤ d) (k : ℕ) (s : Finset Op) :
    StreamSchedule Op Struct

    Noncomputable Finset wrapper for zeroPaddedRankListSchedule (uncompiled helper after [OpenAI2026LogSpace, Lemma 10.6]; see #9181). Because Finset.toList uses Classical.choose to pick an arbitrary list ordering, any future machine-realizable stage must pass an explicit duplicate-free list directly to zeroPaddedRankListSchedule.