From c92a21f9e0f1a41550ad113bd3654c92560525c8 Mon Sep 17 00:00:00 2001 From: Nick Petalas Date: Tue, 3 Nov 2026 12:12:10 +0000 Subject: [PATCH 1/2] feat(research): construct uniform two-capacity completions --- research/two-capacity-uniform-codec/PROOF.md | 168 +++++++++++++ research/two-capacity-uniform-codec/README.md | 140 +++++++++++ .../two-capacity-uniform-codec/SOURCES.json | 36 +++ research/two-capacity-uniform-codec/TASK.json | 114 +++++++++ .../two-capacity-uniform-codec/VERIFY.json | 32 +++ research/two-capacity-uniform-codec/codec.py | 161 ++++++++++++ research/two-capacity-uniform-codec/count.py | 73 ++++++ research/two-capacity-uniform-codec/linear.py | 81 ++++++ .../source/PR6539-NOTICE | 4 + .../source/PR6539-PROOF.md | 210 ++++++++++++++++ research/two-capacity-uniform-codec/verify.py | 237 ++++++++++++++++++ 11 files changed, 1256 insertions(+) create mode 100644 research/two-capacity-uniform-codec/PROOF.md create mode 100644 research/two-capacity-uniform-codec/README.md create mode 100644 research/two-capacity-uniform-codec/SOURCES.json create mode 100644 research/two-capacity-uniform-codec/TASK.json create mode 100644 research/two-capacity-uniform-codec/VERIFY.json create mode 100644 research/two-capacity-uniform-codec/codec.py create mode 100644 research/two-capacity-uniform-codec/count.py create mode 100644 research/two-capacity-uniform-codec/linear.py create mode 100644 research/two-capacity-uniform-codec/source/PR6539-NOTICE create mode 100644 research/two-capacity-uniform-codec/source/PR6539-PROOF.md create mode 100644 research/two-capacity-uniform-codec/verify.py diff --git a/research/two-capacity-uniform-codec/PROOF.md b/research/two-capacity-uniform-codec/PROOF.md new file mode 100644 index 0000000000..3bbe424ffe --- /dev/null +++ b/research/two-capacity-uniform-codec/PROOF.md @@ -0,0 +1,168 @@ +# Enumerating and sampling two-capacity completions + +## Contract and cited premise + +Let V and W have dimension n over a finite field F_q. Fix an injection +h:U→W, and arbitrary subspaces A,B of V and C,D of W. Write + +`G(h) = {g:V→W invertible | g|U=h, g(A)⊂C, g(B)⊂D}`. + +The inclusions may be equalities and neither pair needs to be nested. +Ali Romman's [PR6539](https://github.com/CrocSwap/integer-mult-bounds/pull/6539), +head `96c63f994af628f574c71dca0d7ed219cbfc70c2`, gives an exact formula +N(h)=|G(h)| from a constant number of subspace calculations and at most n+1 +summands. Its proof is retained verbatim in `source/PR6539-PROOF.md`. +The coupled feasibility and common-quotient construction are ToikY's PR6535. +The nested count is Nick Petalas's PR6489. These are cited premises here. +This package does not reprove their count or feasibility theorems. + +The new result is an explicit enumerative construction and finite-fair-bit +sampling interface for this coupled contract. Counting-to-sampling reduction, +lexicographic interval coding and binary entropy recycling are classical. +No general literature-priority claim is made for those methods. + +## 1. A conditional partition + +Choose an ordered basis u_1,...,u_r of U. Extend it deterministically to a +basis of V by greedily adding standard vectors e_1,...,e_n that increase the +span. Denote the added vectors by x_1,...,x_m, where m=n-r. They are fixed +before choosing any images. + +Suppose the images of x_1,...,x_i have been specified, giving an injection +h_i on U_i=U+span(x_1,...,x_i). For every y in W define + +`w_i(y) = 0` if y belongs to h_i(U_i), and otherwise + +`w_i(y) = N(h_i extended by x_(i+1)↦y)`. + +The new source vector is independent of U_i. For y outside h_i(U_i), the +extended prescription is again an injection, so PR6539 applies with the +same two capacities. No capacity is discarded, split or replaced by a +separate independent count. In particular, the prescribed-image coupling +in the predecessor's kernel condition persists at every step. + +Every g in G(h_i) has exactly one value y=g(x_(i+1)), and that value lies +outside h_i(U_i). Conversely every completion counted by that branch is a +completion of h_i. The branches are disjoint and exhaust G(h_i). Thus + +`N(h_i) = sum_(y∈W) w_i(y)`. + +At depth m the domain is V. A prescribed invertible map has exactly one +completion if it satisfies the capacities and zero otherwise. Every +positive leaf therefore has weight one. + +## 2. Rank and unrank + +Order the field elements once, then order vectors y lexicographically. +Assign each child of h_i a consecutive interval of w_i(y) integers, in +this order, starting at zero. Zero-weight children receive empty intervals. +The partition identity makes these intervals a partition of [0,N(h_i)). + +Given k in [0,N(h)), choose its containing interval, subtract that +interval's left endpoint and continue. The residual integer is always in +the selected child's interval. After m choices it is zero because the +selected leaf has weight one. The fixed images on the resulting domain +basis determine all standard columns of an invertible map satisfying the +original prescription and both capacities. This is `unrank(k)`. + +Conversely, for a supplied admissible map g, follow its successive images +g(x_1),...,g(x_m) and add every left endpoint encountered. This is `rank(g)`. +The same interval partition is used at every level. Induction on the +remaining depth proves + +`rank(unrank(k)) = k`, and `unrank(rank(g)) = g`. + +Consequently `unrank` is a bijection from [0,N(h)) onto G(h). A uniform rank +gives a uniform admissible completion, including arbitrary nonnormalized +prescribed injections. If N(h)=0, no rank or sample exists. If n=r, there +is either no completion or exactly one; no branch is needed. + +The abstract statement works over every finite field with an ordered +element representation and the cited oracle. The executable uses prime +fields only. It does not implement extension-field arithmetic. + +## 3. Exact sampling with a finite fair-bit budget + +Put M=N(h)>0. If M=1, return rank zero without reading a bit. Otherwise +start with an interval width v=1 and value c=0. For each supplied fair bit b, +replace `(v,c)` by `(2v,2c+b)`. If v≥M and c1, after any surviving prefix one has `0≤c