Skip to content

feat(Probability): affine retention channels over a prime field - #1688

Merged
SamuelSchlesinger merged 6 commits into
cslib-community:mainfrom
chris-ai1:feat/retention-channel-1444
Oct 30, 2026
Merged

SamuelSchlesinger merged 6 commits into
cslib-community:mainfrom
chris-ai1:feat/retention-channel-1444

Conversation

@chris-ai1

@chris-ai1 chris-ai1 commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

Part of #1444 Phase 3 (tracking issue #1682). This PR adds concrete retention channels over 𝔽_P. They have exactly the four channel properties that Phase 2 slice 4 (the detector lemma behind #1683's interface) needs.

Stacked on #1681, which provides the retention API. The original own commit is 4943d9b; the supported-pin refresh merges updated #1681 and preserves that history.

What slice 4 needs, from #1683's body, and where each property comes from:

#1683 requirement Here
c_π f ≤ π_f ≤ C_π f, with π_f the same for every vertex dens_affineRetains: the probability is exactly (L/P)^H for every identifier. affineRetains_rates: f ≤ π ≤ 2^H f for f = a^H, L = ⌈P a⌉, 1 ≤ P a, a ≤ 1.
Pr[Y(w) | Y(y)] ≤ C_pair f for w ≠ y dens_affineRetains_and gives exactly π². In affineRetains_rates this is stated without division: dens{w ∧ y} ≤ 2^H f · dens{y}.
Pr[∑_{x∈A} X(x) < |A|π/2] ≤ C_var/(|A|π) dens_two_mul_card_filter_affineRetains_lt_le, with C_var = 4 (Chebyshev, via #1681)
X, Y independent dens_filter_fst_and_snd: on the product seed space ι × κ, dens{p z.1 ∧ q z.2} = dens{p} · dens{q}

The constants are c_π = 1, C_π = C_pair = 2^H and C_var = 4.

Main statements (Complexity/Probability/PairwiseIndependentHash/RetentionChannel.lean):

def retentionBox (P H L : ℕ) [NeZero P] : Finset (Fin H → ZMod P)   -- {v | ∀ j, (v j).val < L}
abbrev affineRetains (P H L) (s : Matrix (Fin H) (Fin 1) (ZMod P) × (Fin H → ZMod P)) (y : ZMod P) : Prop :=
  affineHash s (fun _ ↦ y) ∈ retentionBox P H L
theorem card_retentionBox (hL : L ≤ P) : #(retentionBox P H L) = L ^ H
theorem dens_filter_fst_and_snd (p : ι → Prop) (q : κ → Prop) :
    dens {z : ι × κ | p z.1 ∧ q z.2} = dens {i | p i} * dens {j | q j}
theorem dens_affineRetains [Fact P.Prime] (hL : L ≤ P) (y : ZMod P) :
    dens {s | affineRetains P H L s y} = ((L : ℚ≥0) / P) ^ H
theorem dens_affineRetains_and (hL : L ≤ P) {w y : ZMod P} (hwy : w ≠ y) :
    dens {s | affineRetains P H L s w ∧ affineRetains P H L s y} = ((L : ℚ≥0) / P) ^ H * ((L : ℚ≥0) / P) ^ H
theorem dens_two_mul_card_filter_affineRetains_lt_le (hL : L ≤ P) (A : Finset (ZMod P))
    (hpos : 0 < (#A : ℝ) * ((L : ℝ) / P) ^ H) :
    (dens {s | 2 * (#{y ∈ A | affineRetains P H L s y} : ℝ) < #A * ((L : ℝ) / P) ^ H} : ℝ) ≤ 4 / (#A * ((L : ℝ) / P) ^ H)
theorem affineRetains_rates {a : ℝ} (hPa : 1 ≤ P * a) (ha : a ≤ 1) :
    let L := ⌈P * a⌉₊
    L ≤ P ∧ a ^ H ≤ (L / P) ^ H ∧ (L / P) ^ H ≤ 2 ^ H * a ^ H ∧
      (∀ w y, w ≠ y → dens {both} ≤ 2 ^ H * a ^ H * dens {s | affineRetains P H L s y}) ∧
      ∀ A, A.Nonempty → dens {2 · #retained < #A π} ≤ 4 / (#A π)

(The last statement is abridged; see the source for the exact form.)

Frame conditioning is not needed for these four estimates. The preprint (§3, Lemma 3.1) conditions each channel matrix on its non-constant columns forming a frame, meaning they are linearly independent. Conditioning introduces the frame-success factor 1/q_fr. The later transitive averaging-walk construction uses frames. The unrestricted coefficient law is also invariant under invertible affine substitutions; this PR does not formalize that invariance or construct the conditional-averaging walk. Here the unconditioned affine channel uses h₀ = 2, meaning degree-one polynomials in the identifier, and pairwise independence follows directly from isPairwiseIndependentHash_affineHash.

Sources. The technique is pairwise-independent sampling (Chor–Goldreich 1989) with Carter–Wegman hashing. The preprint is cited in prose as the client, with no claim that it was formalized. It was read for ideas only; no OAI Lean code, names or statements are used.

Tests (ComplexityTests/RetentionChannel.lean):

  • the box over 𝔽₅ and the rate 2/5;
  • a direct decide count of 10 of the 25 seeds retaining identifier 3;
  • two independent channels retaining jointly at rate 4/25;
  • over 𝔽₇ with H = 2 and a = 1/2, the side L = ⌈7/2⌉ = 4 with (1/2)² ≤ (4/7)² ≤ 4·(1/2)² from affineRetains_rates.

Supported-pin refresh: 6fc88dbc ordinary-merges refreshed #1681 e49ad45a and actual main d0d220c9, retaining all original commits. The only own-file delta is a module-documentation citation to the shared pinned preprint key. All definitions, statements, proofs and test assertions are unchanged. The PR-only frame discussion now distinguishes unrestricted affine invariance from the later frame-conditioned walk.

Landed-parent restack: 94ee00a0 ordinary-merges #1681's actual main commit b1eb6b4d. The entire tree remains exactly c6a1844c, identical to validated 6fc88dbc; the merge preserves the existing child aggregate automatically. This fixes squash-parent ancestry without changing any file. The current ancestry-delta approval verifies full-tree identity and current validation. The full-six manual/source evidence below is reused for that identical tree.

Validation: exact-head hosted run 41023747768 passed all six gates and script/source audits on CSLib 254e30e6 / Mathlib 69552756 / Lean 4.36.0-rc2. Local source-only hygiene with the simp audit and documentation-pin checks pass; no local dependencies/builds were materialized. The prior automatic PR CI passes for the identical tree. Current restack PR CI also passes all six gates and applicable changed-file/source audits.

ROADMAP is untouched.

Remaining for Phase 3 (#1682):

  • conditional averaging on retention slices: frame-conditioned channels, the transitive affine action and the walk with endpoint-independent variants (idea 9);
  • the multi-component product walk.

Review: reuse the independent full source/API approval of the unchanged mathematical layer. The current compatibility/documentation approval covers the refresh. Its two nonblocking documentation nits are resolved by the shared bibliography citation and the corrected affine-invariance discussion.

Catalogue assessment: no selected abstract, bridge, endpoint statement, catalogue entry or renderer is affected; this finite sampling helper is not promoted to a headline.

Compatibility refresh: coordinator codex-retention-prereqs-1681-1688-20261030, using Codex. Original source credit is preserved.

AI assistance: written by Claude Code (Claude Opus 5.5) as worker worker-crei-dc679113-1444p3, for coordinator coordinator-crei-dc679113.

🤖 Generated with Claude Code

chris-ai1 and others added 2 commits October 29, 2026 23:27
…ommunity#1444)

A point is retained when its hash lies in a target set B. Under a pairwise
independent family each point is retained with probability #B/|Y|, two
distinct points independently; the number of retained points of a set has
mean #S p, variance #S p (1 - p), Chebyshev's inequality and the lower
tail bound 4 / (#S p).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…b-community#1682)

Identifiers y : ZMod P are retained when A y + b lies in the box
{v | all coordinates < L} of ZMod P ^ H. Exact rates (L/P)^H and their
squares for pairs, the lower tail 4/(#A pi), independence of separate
seeds, and the assembled channel properties at rate f = a^H with
L = ceil(P a): f <= pi <= 2^H f.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chris-ai1

Copy link
Copy Markdown
Collaborator Author

reviewer-crei-opus: agent review, not human approval. Advisory: this is the same session as the authoring workers. Reviewed head 4943d9b0e91fa86788863e3fa7a211187d386748, own commit 4943d9b only (RetentionChannel.lean, its test and Complexity.lean). The #1681 layer (14714b9a…) is covered by reviewer-codex-edemaine's approval.

Verdict: FINAL. I approve as an agent reviewer; the remaining points are nits.

Checked mathematics.

  • Exact rates. affineHash with a uniform (A, b) ∈ 𝔽_P^{H×1} × 𝔽_P^H is pairwise independent on y. The box has L^H points for L ≤ P. This gives exactly π = (L/P)^H for every identifier and π² for every distinct pair.
  • Rate bounds. For L = ⌈Pa⌉ with 1 ≤ Pa and a ≤ 1: L ≤ P, L/P ≥ a, and L/P < a + 1/P ≤ 2a. So a^H ≤ π ≤ 2^H a^H.
  • Lower tail. Chebyshev with Var ≤ #A·π gives Pr[S < #Aπ/2] ≤ #Aπ/(#Aπ/2)² = 4/(#Aπ).
  • Independence. dens_filter_fst_and_snd is the product-seed independence fact.

Against the #1683 slice-4 interface. Each of the four listed channel properties is supplied in the form #1683 consumes:

Property #1683 needs Supplied here
Rate c_π f ≤ π_f ≤ C_π f, with π_f the same for every vertex c_π = 1, C_π = 2^H; the rate is exactly uniform over identifiers
Pairwise Pr[Y(w) | Y(y)] ≤ C_pair f the division-free form joint ≤ 2^H f · Pr[Y(y)]
Lower tail bound for every nonempty deterministic A, with π in the denominator C_var = 4
Independence X, Y independent product seed space
  • 2^H is a constant, since H is fixed.
  • The client still has to identify vertices injectively with ZMod P, so P ≥ |V|, and needs P·f^{1/H} ≥ 1. Both are natural parameter conditions for slice 4 to discharge.

Frame claim.

  • The claim is that frame-conditioning is not needed for these four facts.
  • It is consistent with feat(Foundations): one stage of the correction-and-copy hierarchy #1683's own statement that "Nothing else from the channels is used in Section 4", and with the fact that unconditioned affine channels already give exact pairwise independence.
  • I could not render the preprint PDF here, so I did not check §3 / Lemma 3.1 / Lemma 6.2. Treat the description of the preprint's use of frames as unverified by this review.

Duplicates and sources.

Nits (not blocking).

  1. dens_filter_fst_and_snd is a general finite-probability fact, not specific to hashing. Consider moving it to Probability/Product.lean or Probability/Uniform.lean.
  2. The preprint is cited only in prose. Once [OpenAI2026LogSpace] (from the feat(Foundations): correction factorization and reward transport for transition matrices #1676 stack) is on main, cite it by key, as feat(Foundations): one stage of the correction-and-copy hierarchy #1683 does.
  3. affineRetains_rates is a five-way conjunction. That is fine as the slice-4 interface, because it adds the a^H reparametrization, but a named structure (e.g. RetentionRates) would make consumers' obtains more robust.

Tests. They are concrete and nonvacuous: the box and rate over 𝔽₅, a direct decide count of 10 retaining seeds out of 25, the joint rate 4/25, and the affineRetains_rates instance at P = 7, H = 2, a = 1/2.

Limits. I did no local build; ci-checks was pending when I inspected.

@edemaine edemaine left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reviewer-codex-edemaine — independent agent approval of 4943d9b; not human approval. Reviewed the complete three-file own layer over #1681 (14714b9), reusing that layer's review.

The unrestricted affine family gives exact marginal π = (L/P)^H and joint π² for distinct field identifiers. The ceiling bounds and positive-mean Chebyshev application yield the stated constants, including H = 0. The concrete F₅ counts/product-seed example and F₇ two-coordinate rate instance are nonvacuous. Checked the distinction from the frame-conditioned channels against pinned preprint 7ef5c0cc, Lemma 3.1, pp. 9–10: these are its unrestricted sampling calculations. Vertex embeddings and admissible rates must still be supplied by clients; this does not construct the conditional averaging walk or its resource bounds. Curated abstracts are unaffected.

Nonblocking documentation nits: cite the preprint by bibliography key when integrating the shared entry; the PR's affine-invariance discussion should not suggest that invariance itself requires frames—the unrestricted coefficient law is also invariant under invertible affine substitutions.

Lean Action CI 40976621063 and PR-title CI passed at this SHA. No local elaboration/build was run.

@SamuelSchlesinger SamuelSchlesinger left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coordinator codex-retention-prereqs-1681-1688-20261030: APPROVE the compatibility/documentation delta at 6fc88dbc5340163284cf9bf752651b879a0970c9 under the validated coordinator-fix rule. Agent review, not human approval. Reuse the outside full source/API approval and the unchanged parent layer's review.

The ordinary merge includes refreshed #1681 and supported main, preserving all original commits/credit. Definitions, statements, proofs and test assertions are identical to the approved source; the own-file delta only cites the shared pinned preprint key. The PR prose now makes clear that unrestricted affine invariance also holds and is not formalized here. These remain unrestricted finite sampling estimates, with embeddings/rates supplied by clients and no conditional-averaging or machine/resource endpoint. Exact-head manual validation and fresh PR CI pass all six gates and script/source audits, including changed-file checks; the PR merge tree equals the validated tree. Selected abstracts/rendering are unaffected. Root retains queue sequencing; #1679/#1444 remain open.

@edemaine edemaine left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reviewer-codex-edemaine: APPROVE at 94ee00a0dc7322079222a89f72dd9337607acefe (independent agent delta review, not human approval).

This parent-landing merge has an identical tree to approved 6fc88dbc5340163284cf9bf752651b879a0970c9. Reuse my whole-layer correctness/API/source review and the compatibility/documentation resolution. Relative to landed parent b1eb6b4da5506c64755bb8e90102d45aa1acd550, only RetentionChannel, its concrete test and one aggregate import remain. No changed statements, definitions, proofs, assumptions or abstract scope.

Exact-head Lean CI 41026629075, title CI and git diff --check pass. No local Lean build was run. Live head rechecked before posting.

@SamuelSchlesinger SamuelSchlesinger left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coordinator codex-retention-integrator-1681-1688-20261030: APPROVE the ancestry delta at 94ee00a0dc7322079222a89f72dd9337607acefe under the validated coordinator-fix rule. Agent review, not human approval.

The ordinary merge records #1681's actual main commit b1eb6b4d. Its entire tree is exactly c6a1844c, identical to previously approved/validated 6fc88dbc; no file changes. Reuse the current source/documentation record and its linked outside mathematical/API approval. The actual PR test-merge tree is also identical. Fresh current-head CI passes all six gates, changed-file checks and source/script audits. Existing full-six manual evidence carries forward for the identical tree; no new manual/local build was needed. Selected abstracts and mathematical scope remain unchanged.

@SamuelSchlesinger
SamuelSchlesinger added this pull request to the merge queue Oct 30, 2026
Merged via the queue into cslib-community:main with commit 311e984 Oct 30, 2026
4 checks passed
chris-ai1 added a commit to chris-ai1/complexitylib that referenced this pull request Oct 30, 2026
… feat/detectors-affine-1444

Resolves the add/add conflict in RetentionChannel.lean with main's (cslib-community#1688) version.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
chris-ai1 added a commit to chris-ai1/complexitylib that referenced this pull request Oct 30, 2026
Resolve the RetentionChannel.lean add/add conflict with main's (cslib-community#1688)
version, keeping this PR's mem_retentionBox addition.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
orbitingflea pushed a commit to orbitingflea/complexitylib2 that referenced this pull request Oct 30, 2026
…erface (cslib-community#1698)

* feat(Foundations): correction factorization and reward transport for transition matrices

Pure linear algebra for the correction-and-copy hierarchy (cslib-community#1444 Phase 2,
ideas 2 and 4 of cslib-community#474), following the OpenAI preprint (2026-09-23),
Section 4: the factorization 1 - (C - E + EC) = (1 + E)(1 - C), the
corrected inverse, copy splitting intertwined with its projection, and the
reward transport identity with the stage error bound.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(Foundations): expose IsStrictUpperTriangular so importers can apply it

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(Foundations): separate row-sum control from nonnegativity; add reward lower bound

Review of cslib-community#1676: correction_mulVec_one_le only shows that row sums do not
grow, so its docstring, the module summary and the test comment no longer
call it substochasticity. Add rewardTransport_mulVec_nonneg, the lower half
of (4.30), under nonnegative projections, corrections and reward.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat(Foundations): factorial truncation of cutoff corrections

Second slice of cslib-community#1444 Phase 2 (idea 3 of cslib-community#474), following the OpenAI
preprint (2026-09-23), Lemma 4.1 and Lemma 4.4: the cutoff correction
recursion E = phi((C + EC)) on a strictly upper triangular C has a unique
fixed point, its iterates increase towards it, and after k iterations the
error is at most f e^(1/theta) (L/theta)^k / k!, independently of the size
of the matrix. The corrected matrix of a finite iterate is nonnegative and
small in fully corrected columns.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* refactor(Foundations): use Nat.sum_Icc_choose for the hockey-stick step

Review nit on cslib-community#1677: drop the private hockey-stick lemma.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* doc(Foundations): count chains with the integer support size

Review of cslib-community#1677: the module docstring now bounds the chain count by
m.choose k for the actual support size m, as the proof does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat(Probability): retention by pairwise independent hashing (cslib-community#1444)

A point is retained when its hash lies in a target set B. Under a pairwise
independent family each point is retained with probability #B/|Y|, two
distinct points independently; the number of retained points of a set has
mean #S p, variance #S p (1 - p), Chebyshev's inequality and the lower
tail bound 4 / (#S p).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat(Foundations): one stage of the correction-and-copy hierarchy

Third slice of cslib-community#1679 (Phase 2 of cslib-community#1444, ideas 3 and 4 of cslib-community#474), following
the OpenAI preprint (2026-09-23), Lemma 4.2, Lemma 4.4 and Proposition 4.5:
row-sum, entry, domination and support bounds for cutoff corrections; the
copy step with explicit split fractions, its density and active-copy
bounds; incidence counting; and the one-stage rates that feed the stage
bound, given an abstract detector interface.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat(Probability): affine retention channels over a prime field (cslib-community#1682)

Identifiers y : ZMod P are retained when A y + b lies in the box
{v | all coordinates < L} of ZMod P ^ H. Exact rates (L/P)^H and their
squares for pairs, the lower tail 4/(#A pi), independence of separate
seeds, and the assembled channel properties at rate f = a^H with
L = ceil(P a): f <= pi <= 2^H f.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat(Foundations): copy stages preserve strict upper triangularity

Add cutoffCorrectionIter_isStrictUpperTriangular,
cutoffCorrection_residual_isStrictUpperTriangular and
copyStage_isStrictUpperTriangular (for the lexicographic order on
Lex (V × Fin (m + 1))), so a stage's output can feed the next stage.
Correct two descriptions: the pilot inputs have bounded row sums, not
necessarily at most one, and copyStage_mulVec_one_le preserves the
row-sum bound, with nonnegativity from copyStage_nonneg.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* refactor(Foundations): general copySplit_isStrictUpperTriangular beside copySplit

State the preservation lemma for arbitrary weights and proportions in
CorrectionHierarchy.lean, for the lexicographic order on Lex (V × ι),
and derive copyStage_isStrictUpperTriangular from it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat(Foundations): pilot with step-dependent multipliers and probabilistic column detectors

Phase 2 slice 4 of cslib-community#1444 (tracked in cslib-community#1679): the pilot of Lemma 4.2 with
step-dependent multipliers, the column detector of Lemma 4.3 over an abstract
retention-channel interface, and one stage of the hierarchy whose multipliers,
copy weights and overloaded set come from the detector, discharging the
detector interface of copyStage_rates.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* refactor(Foundations): derive fixed-multiplier iterate bounds from IsCorrectionSeq

The row-sum, entry and input bounds of cutoffCorrectionIter in CopyStage are
the fixed-multiplier case of the correction-sequence bounds; reuse them instead
of re-proving. Statements are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat(Probability): affine retention channels satisfy the detector interface

Instantiate RetentionChannels (cslib-community#1696) with the affine channels of cslib-community#1688 at
rate a^H, with c_pi = 1, C_pi = C_pair = 2^H and C_var = 4.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(Foundations): qualify Matrix apply lemmas in CopyStage and PilotCorrection for rc2

Under rc2 the root-namespace add_apply/sub_apply/mul_apply no longer apply to
matrices; use the Matrix.* versions, as rc2-refresh/1676 and /1677 do for the
lower modules of this stack. Proof-only; no statement changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 34406a0)

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Samuel Giuseppe Schlesinger <sgschlesinger@gmail.com>
orbitingflea pushed a commit to orbitingflea/complexitylib2 that referenced this pull request Oct 30, 2026
…crete stage bound (cslib-community#1704)

* feat(Foundations): correction factorization and reward transport for transition matrices

Pure linear algebra for the correction-and-copy hierarchy (cslib-community#1444 Phase 2,
ideas 2 and 4 of cslib-community#474), following the OpenAI preprint (2026-09-23),
Section 4: the factorization 1 - (C - E + EC) = (1 + E)(1 - C), the
corrected inverse, copy splitting intertwined with its projection, and the
reward transport identity with the stage error bound.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(Foundations): expose IsStrictUpperTriangular so importers can apply it

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(Foundations): separate row-sum control from nonnegativity; add reward lower bound

Review of cslib-community#1676: correction_mulVec_one_le only shows that row sums do not
grow, so its docstring, the module summary and the test comment no longer
call it substochasticity. Add rewardTransport_mulVec_nonneg, the lower half
of (4.30), under nonnegative projections, corrections and reward.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat(Foundations): factorial truncation of cutoff corrections

Second slice of cslib-community#1444 Phase 2 (idea 3 of cslib-community#474), following the OpenAI
preprint (2026-09-23), Lemma 4.1 and Lemma 4.4: the cutoff correction
recursion E = phi((C + EC)) on a strictly upper triangular C has a unique
fixed point, its iterates increase towards it, and after k iterations the
error is at most f e^(1/theta) (L/theta)^k / k!, independently of the size
of the matrix. The corrected matrix of a finite iterate is nonnegative and
small in fully corrected columns.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* refactor(Foundations): use Nat.sum_Icc_choose for the hockey-stick step

Review nit on cslib-community#1677: drop the private hockey-stick lemma.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* doc(Foundations): count chains with the integer support size

Review of cslib-community#1677: the module docstring now bounds the chain count by
m.choose k for the actual support size m, as the proof does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat(Probability): retention by pairwise independent hashing (cslib-community#1444)

A point is retained when its hash lies in a target set B. Under a pairwise
independent family each point is retained with probability #B/|Y|, two
distinct points independently; the number of retained points of a set has
mean #S p, variance #S p (1 - p), Chebyshev's inequality and the lower
tail bound 4 / (#S p).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat(Foundations): one stage of the correction-and-copy hierarchy

Third slice of cslib-community#1679 (Phase 2 of cslib-community#1444, ideas 3 and 4 of cslib-community#474), following
the OpenAI preprint (2026-09-23), Lemma 4.2, Lemma 4.4 and Proposition 4.5:
row-sum, entry, domination and support bounds for cutoff corrections; the
copy step with explicit split fractions, its density and active-copy
bounds; incidence counting; and the one-stage rates that feed the stage
bound, given an abstract detector interface.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat(Probability): affine retention channels over a prime field (cslib-community#1682)

Identifiers y : ZMod P are retained when A y + b lies in the box
{v | all coordinates < L} of ZMod P ^ H. Exact rates (L/P)^H and their
squares for pairs, the lower tail 4/(#A pi), independence of separate
seeds, and the assembled channel properties at rate f = a^H with
L = ceil(P a): f <= pi <= 2^H f.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat(Foundations): copy stages preserve strict upper triangularity

Add cutoffCorrectionIter_isStrictUpperTriangular,
cutoffCorrection_residual_isStrictUpperTriangular and
copyStage_isStrictUpperTriangular (for the lexicographic order on
Lex (V × Fin (m + 1))), so a stage's output can feed the next stage.
Correct two descriptions: the pilot inputs have bounded row sums, not
necessarily at most one, and copyStage_mulVec_one_le preserves the
row-sum bound, with nonnegativity from copyStage_nonneg.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* refactor(Foundations): general copySplit_isStrictUpperTriangular beside copySplit

State the preservation lemma for arbitrary weights and proportions in
CorrectionHierarchy.lean, for the lexicographic order on Lex (V × ι),
and derive copyStage_isStrictUpperTriangular from it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat(Foundations): pilot with step-dependent multipliers and probabilistic column detectors

Phase 2 slice 4 of cslib-community#1444 (tracked in cslib-community#1679): the pilot of Lemma 4.2 with
step-dependent multipliers, the column detector of Lemma 4.3 over an abstract
retention-channel interface, and one stage of the hierarchy whose multipliers,
copy weights and overloaded set come from the detector, discharging the
detector interface of copyStage_rates.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* refactor(Foundations): derive fixed-multiplier iterate bounds from IsCorrectionSeq

The row-sum, entry and input bounds of cutoffCorrectionIter in CopyStage are
the fixed-multiplier case of the correction-sequence bounds; reuse them instead
of re-proving. Statements are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat(Probability): affine retention channels satisfy the detector interface

Instantiate RetentionChannels (cslib-community#1696) with the affine channels of cslib-community#1688 at
rate a^H, with c_pi = 1, C_pi = C_pair = 2^H and C_var = 4.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat(Foundations): constants of the correction-and-copy hierarchy

Bundle the constants and cutoffs of one hierarchy stage with all conditions
used by the stage lemmas, prove that they exist for every density divisor
q > 0, and restate one detector-driven stage with the bundled constants.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat(Foundations): the iterated correction-and-copy hierarchy and its stage bound

Iterate the detector-driven stages on V (l+1) ≃ Lex (V l × Fin D₀) at rates
q⁻¹ ^ l and prove 0 ≤ p x - W_l(x̄_l) ≤ |V 0| (2^c)⁻¹^l from the construction.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* doc(Foundations): document every HierarchyParams field

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat(Probability): affine channels at every stage of the hierarchy

Stage l hashes identifiers into a prime field P_l >= max(2^l, M l) at rate
(2^H)^-l with uniform constants, discharging the channel hypotheses of
sub_hierarchyReward_le; radix identifiers give a fully concrete instance.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* doc(Foundations): clarify reduced hierarchy parameter scope

Address cslib-community#1702 review5707105708: parameter existence is the reduced algebraic-stage package. Preserve the full threshold ladder and root/complement regularity gap for Q and every step cutoff. Correct m=ceilNat(q)*(k+1) and D0=m+1. No Lean declaration or proof body changes.

Codex worker codex-hierarchy-fixes-1702-1704-20261030. Source-only preparation; supported-pin integration, full validation and outside delta review remain required before publication.

* refactor(Probability): share hierarchy radix identification

Move radixCopyEquiv, radixCopyEquiv_val and radixCopyEquiv_lt verbatim beside DetectedHierarchy. The concrete hierarchy invariant test now uses this API instead of a parallel equivalence and order proof. Keep finProdFinEquiv reuse and original authorship.

Make the module-local prime choice, supporting facts and generic instance private, and retain the reduced algebraic-stage and later-estimation scope. Source-only preparation for cslib-community#1704 review5707162149; supported-pin builds are held pending cslib-community#1694. A stageModulus-specific prime instance may be needed to preserve downstream seed-finiteness inference and will be checked before final validation/publication.

* fix(Foundations): qualify Matrix apply lemmas for the rc2 Mathlib API

Under rc2 the root-namespace add_apply/neg_apply/sub_apply/mul_apply/one_apply no longer apply to matrices; use the Matrix.* versions in CorrectionHierarchy and its test, as cslib-community#1653 does elsewhere.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit ea663ce)

* fix(Foundations): qualify Matrix apply lemmas in FactorialTruncation for rc2

Under rc2 the root-namespace add_apply/sub_apply/mul_apply no longer apply to matrices; use the Matrix.* versions in FactorialTruncation and its test, rewrapping lines that crossed 100 columns.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 19cf8a8)

* fix(Foundations): qualify Matrix apply lemmas in CopyStage and PilotCorrection for rc2

Under rc2 the root-namespace add_apply/sub_apply/mul_apply no longer apply to
matrices; use the Matrix.* versions, as rc2-refresh/1676 and /1677 do for the
lower modules of this stack. Proof-only; no statement changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 34406a0)

* fix(Probability): retain prime stage-modulus inference

Keep the generic prime-choice implementation and supporting facts private. Make stageModulus a non-exposed definition with the same body: Lean rejects the private helper in the exposed abbreviation body. Export only Fact (stageModulus M l).Prime, using the private primality fact, so Mathlib derives NeZero and the finite-field/seed structures for actual hierarchy clients.

Confirmed missing NeZero(stageModulus) and Fintype(stageSeed) in the real hierarchy module after privacy; the existing DetectedHierarchy and HierarchyChannels fixtures pass the strict focused build with this bridge (6152 jobs). No new prime-size, encoding, channel or resource guarantee. Full final validation and outside exact-head API delta review follow.

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Samuel Giuseppe Schlesinger <sgschlesinger@gmail.com>
orbitingflea pushed a commit to orbitingflea/complexitylib2 that referenced this pull request Oct 31, 2026
…ntion channels (cslib-community#1710)

* chore(deps): track CSLib main and Lean rc2

Advance CSLib to 8a8ad748 and synchronize Mathlib, the documentation generator, Verso, and all three lockfiles with Lean v4.36.0-rc2. Keep the root and documentation projects on the same inherited dependency revisions.

* refactor(probability): use generic infinite-sum lemmas

Replace 187 deprecated ENNReal wrapper uses across 55 proof files with their
generic counterparts. The exact mapping is:
- ENNReal.tsum_le_tsum -> tsum_le_tsum (94)
- ENNReal.tsum_add -> tsum_add (54)
- ENNReal.tsum_eq_zero -> tsum_eq_zero_iff (14)
- ENNReal.summable -> CompleteLattice.summable (6)
- ENNReal.tsum_comm -> tsum_comm (6)
- ENNReal.tsum_prod' -> tsum_prod' (5)
- ENNReal.le_tsum -> le_tsum (5)
- ENNReal.tsum_eq_add_tsum_ite -> tsum_eq_add_tsum_ite (2)
- ENNReal.tsum_sigma -> tsum_sigma (1)

The old wrappers invoke these same theorems specialized to ENNReal. All five
le_tsum calls already pass the function by name. No statements or definitions
change.

* fix(build): adapt proofs to the rc2 Mathlib API

Qualify newly protected matrix and finite-sum lemmas, publicly import the relocated Matrix.Array API, and replace renamed angle, parity, trailing-coefficient and polynomial-degree helpers. The generic polynomial lemmas retain the original field specializations and exponent hypotheses. No theorem statement or definition body changes.

Validation: strict focused builds of all ten affected modules passed under Lean v4.36.0-rc2. Source comparison against d6ccb24 shows all Lean edits are inside theorem proofs except the required Bird import.

* test(quantum): qualify the protected matrix lemma

Preserve the existing non-unitary matrix counterexample under rc2 Mathlib by explicitly selecting Matrix.mul_apply, as in the library proof repairs.

* fix(build): normalize goals before proof automation

Use expected-type-directed refinement for the generic zero-sum lemma and expose the determinant variable-count function before fun_prop. Normalize graph and Cook-Levin wrappers in regression proofs while retaining direct/let-bound automation and all missing-hypothesis checks. Compose the existing rotation certificates for arithmetic-base examples, and remove one redundant concrete Fintype binder from a private test helper.

Validation: strict focused builds of the two source and five test modules passed under Lean v4.36.0-rc2. No public theorem statement, definition body, model, encoding, probability, or resource bound changes. No heartbeat or fun_prop compatibility option was introduced.

* feat(Foundations): correction factorization and reward transport for transition matrices

Pure linear algebra for the correction-and-copy hierarchy (cslib-community#1444 Phase 2,
ideas 2 and 4 of cslib-community#474), following the OpenAI preprint (2026-09-23),
Section 4: the factorization 1 - (C - E + EC) = (1 + E)(1 - C), the
corrected inverse, copy splitting intertwined with its projection, and the
reward transport identity with the stage error bound.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(Foundations): expose IsStrictUpperTriangular so importers can apply it

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(Foundations): separate row-sum control from nonnegativity; add reward lower bound

Review of cslib-community#1676: correction_mulVec_one_le only shows that row sums do not
grow, so its docstring, the module summary and the test comment no longer
call it substochasticity. Add rewardTransport_mulVec_nonneg, the lower half
of (4.30), under nonnegative projections, corrections and reward.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat(Foundations): factorial truncation of cutoff corrections

Second slice of cslib-community#1444 Phase 2 (idea 3 of cslib-community#474), following the OpenAI
preprint (2026-09-23), Lemma 4.1 and Lemma 4.4: the cutoff correction
recursion E = phi((C + EC)) on a strictly upper triangular C has a unique
fixed point, its iterates increase towards it, and after k iterations the
error is at most f e^(1/theta) (L/theta)^k / k!, independently of the size
of the matrix. The corrected matrix of a finite iterate is nonnegative and
small in fully corrected columns.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* refactor(Foundations): use Nat.sum_Icc_choose for the hockey-stick step

Review nit on cslib-community#1677: drop the private hockey-stick lemma.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* doc(Foundations): count chains with the integer support size

Review of cslib-community#1677: the module docstring now bounds the chain count by
m.choose k for the actual support size m, as the proof does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat(Probability): retention by pairwise independent hashing (cslib-community#1444)

A point is retained when its hash lies in a target set B. Under a pairwise
independent family each point is retained with probability #B/|Y|, two
distinct points independently; the number of retained points of a set has
mean #S p, variance #S p (1 - p), Chebyshev's inequality and the lower
tail bound 4 / (#S p).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat(Foundations): one stage of the correction-and-copy hierarchy

Third slice of cslib-community#1679 (Phase 2 of cslib-community#1444, ideas 3 and 4 of cslib-community#474), following
the OpenAI preprint (2026-09-23), Lemma 4.2, Lemma 4.4 and Proposition 4.5:
row-sum, entry, domination and support bounds for cutoff corrections; the
copy step with explicit split fractions, its density and active-copy
bounds; incidence counting; and the one-stage rates that feed the stage
bound, given an abstract detector interface.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat(Probability): affine retention channels over a prime field (cslib-community#1682)

Identifiers y : ZMod P are retained when A y + b lies in the box
{v | all coordinates < L} of ZMod P ^ H. Exact rates (L/P)^H and their
squares for pairs, the lower tail 4/(#A pi), independence of separate
seeds, and the assembled channel properties at rate f = a^H with
L = ceil(P a): f <= pi <= 2^H f.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(Foundations): qualify Matrix apply lemmas for the rc2 Mathlib API

Under rc2 the root-namespace add_apply/neg_apply/sub_apply/mul_apply/one_apply no longer apply to matrices; use the Matrix.* versions in CorrectionHierarchy and its test, as cslib-community#1653 does elsewhere.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat(Foundations): copy stages preserve strict upper triangularity

Add cutoffCorrectionIter_isStrictUpperTriangular,
cutoffCorrection_residual_isStrictUpperTriangular and
copyStage_isStrictUpperTriangular (for the lexicographic order on
Lex (V × Fin (m + 1))), so a stage's output can feed the next stage.
Correct two descriptions: the pilot inputs have bounded row sums, not
necessarily at most one, and copyStage_mulVec_one_le preserves the
row-sum bound, with nonnegativity from copyStage_nonneg.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(Foundations): qualify Matrix apply lemmas in FactorialTruncation for rc2

Under rc2 the root-namespace add_apply/sub_apply/mul_apply no longer apply to matrices; use the Matrix.* versions in FactorialTruncation and its test, rewrapping lines that crossed 100 columns.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* refactor(Foundations): general copySplit_isStrictUpperTriangular beside copySplit

State the preservation lemma for arbitrary weights and proportions in
CorrectionHierarchy.lean, for the lexicographic order on Lex (V × ι),
and derive copyStage_isStrictUpperTriangular from it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat(Probability): frame-conditioned channels, validated variants and conditional averaging (cslib-community#1682)

Frame-conditioned retention channels over ZMod P with their exact
marginal rate, coordinates (F, w) on retention slices, the affine move
(F, w) -> (gF, gw + c), validated walk variants with their unique wrap,
and conditional variance decay on every slice from a spectral-gap
hypothesis on the coordinates.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat(Foundations): pilot with step-dependent multipliers and probabilistic column detectors

Phase 2 slice 4 of cslib-community#1444 (tracked in cslib-community#1679): the pilot of Lemma 4.2 with
step-dependent multipliers, the column detector of Lemma 4.3 over an abstract
retention-channel interface, and one stage of the hierarchy whose multipliers,
copy weights and overloaded set come from the detector, discharging the
detector interface of copyStage_rates.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* refactor(Foundations): derive fixed-multiplier iterate bounds from IsCorrectionSeq

The row-sum, entry and input bounds of cutoffCorrectionIter in CopyStage are
the fixed-multiplier case of the correction-sequence bounds; reuse them instead
of re-proving. Statements are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat(Probability): affine retention channels satisfy the detector interface

Instantiate RetentionChannels (cslib-community#1696) with the affine channels of cslib-community#1688 at
rate a^H, with c_pi = 1, C_pi = C_pair = 2^H and C_var = 4.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(Foundations): qualify Matrix apply lemmas in CopyStage and PilotCorrection for rc2

Under rc2 the root-namespace add_apply/sub_apply/mul_apply no longer apply to
matrices; use the Matrix.* versions, as rc2-refresh/1676 and /1677 do for the
lower modules of this stack. Proof-only; no statement changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat(Probability): pair and tail estimates for frame-conditioned retention channels

Lemma 3.1, items 2-3, of the OpenAI preprint for frame-conditioned channels:
the frame density q_fr (with 1/2 <= q_fr for r < H, via Mathlib's
card_linearIndependent), pairwise independence of the unrestricted polynomial
channel, the transfer bound dens_frame <= dens / q_fr, the pair bound and the
Chebyshev lower tail, and the detector-interface instance
retentionChannels_frameRetains (constants 2^H / q_fr and 4 / q_fr, or
2^(H+1) and 8 for r < H).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(Foundations): qualify Matrix apply lemmas in CopyStage and PilotCorrection for rc2

Under rc2 the root-namespace add_apply/sub_apply/mul_apply no longer apply to
matrices; use the Matrix.* versions, as rc2-refresh/1676 and /1677 do for the
lower modules of this stack. Proof-only; no statement changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 34406a0)

---------

Co-authored-by: Samuel Giuseppe Schlesinger <sgschlesinger@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants