From cde5fd401fa464f82b6950715e7e306433a4dc2e Mon Sep 17 00:00:00 2001 From: Nick Petalas Date: Fri, 23 Oct 2026 00:39:12 +0100 Subject: [PATCH 1/2] feat(research): prove exact bipartite query capacity --- research/bipartite-query-capacity/PROOF.md | 144 +++++++++ research/bipartite-query-capacity/README.md | 107 +++++++ .../bipartite-query-capacity/SOURCES.json | 36 +++ research/bipartite-query-capacity/TASK.json | 78 +++++ research/bipartite-query-capacity/VERIFY.json | 32 ++ research/bipartite-query-capacity/verify.py | 301 ++++++++++++++++++ 6 files changed, 698 insertions(+) create mode 100644 research/bipartite-query-capacity/PROOF.md create mode 100644 research/bipartite-query-capacity/README.md create mode 100644 research/bipartite-query-capacity/SOURCES.json create mode 100644 research/bipartite-query-capacity/TASK.json create mode 100644 research/bipartite-query-capacity/VERIFY.json create mode 100644 research/bipartite-query-capacity/verify.py diff --git a/research/bipartite-query-capacity/PROOF.md b/research/bipartite-query-capacity/PROOF.md new file mode 100644 index 0000000000..39c6b60b0b --- /dev/null +++ b/research/bipartite-query-capacity/PROOF.md @@ -0,0 +1,144 @@ +# Exact query dimension on bipartite masks + +This is a scoped algebraic theorem, not a physical supplier or a complete +multiplication theorem. All dimensions below are integers. The field is arbitrary. + +## Contract and result + +Let G=(L disjoint-union R,E) be any finite simple bipartite graph. At vertex v +there are d_v>=0 source coordinates and d_v target coordinates. Put D=sum_v d_v. +A fitting matrix M has D rows and D columns, partitioned by these vertices, with + + M_vv = I_(d_v), + M_uv = 0 if u != v and {u,v} is not an edge. + +Each permitted ordered block is arbitrary. Rectangular blocks, asymmetric +opposite blocks, noncommuting coefficients and empty blocks are allowed. + +Define the maximum integral edge sharing + + nu = max sum_(e in E) x_e, + x_e integer >= 0, + sum_(e incident to v) x_e <= d_v for every v. + +Define alpha_d(G) as the maximum of sum_(v in I) d_v over independent vertex +sets I. Then, over every field F, + + min_(M fits G) rank_F(M) = D - nu = alpha_d(G). (1) + +Equivalently, a linear query factorization M=A B needs at least alpha_d(G) +intermediate field coordinates, and a factorization of exactly that size exists. +Any factorization gives rank(M)<=its intermediate dimension. Conversely a rank +factorization exists by selecting a basis of the column space of M. + +The new repository statement is this complete bipartite-mask contract with +unequal payloads. Weighted matching and cover duality are classical. We give +the elementary proof rather than claiming a new graph-theoretic theorem. + +## Integral sharing equals minimum weighted vertex cover + +Construct a directed network with source s and sink t. Give s->u capacity d_u +for u in L, u->v capacity D+1 for every {u,v} in E, and v->t capacity d_v for +v in R. Start with zero flow. As long as a residual s-to-t path exists, augment +by the smallest residual capacity along that path. Every capacity and flow stays +integral. Each augmentation increases the flow value by at least one, and the +value is at most D. Thus the process terminates, including when D=0. + +At termination let S contain the residual vertices reachable from s. There is +no positive residual arc leaving S, and t is outside S. Therefore every original +arc leaving S is saturated and every original arc entering S carries zero flow. +Conservation shows that the flow value equals the capacity of this cut. Every +flow value is at most every cut capacity, by the same conservation identity, so +both are optimal. This proves the needed integral flow and cut statement. + +The cut capacity is at most D because the cut containing only s costs at most D. +It therefore cannot cut a D+1 arc. Write P=S intersect L and Q=S intersect R. +Every neighbor in R of P lies in Q. Consequently + + C = (L minus P) union Q + +is a vertex cover, and the cut capacity is exactly sum_(v in C) d_v. Conversely +a vertex cover C defines such a cut by taking P=L minus C and Q=R intersect C; +its capacity is the cover weight. Edge flows x_e satisfy the vertex capacities, +and every feasible integer x extends to a network flow. Hence nu is exactly the +minimum weighted vertex-cover value. + +A set is independent exactly when its complement is a vertex cover. Taking +complements gives alpha_d(G)=D-nu. Zero weights and isolated vertices need no +special convention beyond empty sums. + +## Lower bound for every fitting matrix + +Choose an independent set I of weight alpha_d(G). The principal submatrix on +all coordinates at vertices in I is the identity of size alpha_d(G). The +nonedge condition forces every off-diagonal vertex block in this submatrix to +vanish. Taking a submatrix cannot increase rank. Thus every fitting M has +rank at least alpha_d(G), regardless of its permitted coefficients or the field. + +## Attainment by coordinate pairs + +Take optimal integral edge counts x. Allocate x_(uv) distinct, previously unused +coordinates at u and the same number at v. Pair them across edge {u,v}. The +vertex constraints make these allocations possible. Each unallocated coordinate +is private. A pair contributes the matrix + + [1 1] + [1 1] + +on its two coordinates, and a private coordinate contributes [1]. Put zero in +all other positions. After a simultaneous permutation this is a direct sum of +rank-one two-coordinate matrices and rank-one private matrices. It fits G, +because the only off-diagonal entries join an edge and each diagonal block is +its identity. Its rank over every field is + + number of pairs + number of private coordinates + = nu + (D - 2 nu) = D - nu = alpha_d(G). + +A query for a pair is the sum of its two source coordinates, read by each of its +two targets. A private query is its source coordinate. These give literal A,B +with M=A B. Each receiver may subtract its neighbor contribution in the usual +fitting-matrix interpretation; physical side-information access is a separate +contract. The theorem only states the algebraic factorization. + +This proves (1). It also proves integrality: multiplying every d_v by a positive +integer k multiplies the optimum by k. Vector payload mixing gives no rate gain +beyond scalar coordinate pairing on this graph class. This is a dimension +statement, not a claim that a physical pair query costs one native operation. + +## First example and decision + +For a star with center width 4 and three leaves of width 1, D=7, nu=3 and the +exact rank is 4. The larger bipartition-side total is sharp here. On a +path with widths (4,1,1,4), the two side totals are both 5, but the independent +endpoint set has weight 8, nu=2, and the exact rank is 8. Merely taking the +larger side total can therefore underprice even a connected bipartite mask. + +In this contract, searches for arbitrary block coefficients on a bipartite mask +cannot beat an integral edge-sharing construction. To seek a lower algebraic +query rate, change the graph class, the diagonal/zero contract or the type of +encoding. Tekalign's #3362 treats the nonbipartite five-cycle and its P112 +principal core. That result is a credited model antecedent, not an input or a +result replayed here. We do not claim a stronger full-P112 lower bound. + +## Finite evidence and scope + +The verifier has an integral residual-flow constructor and a separate exhaustive +independent-set oracle. It expands the pair construction, checks every required +matrix entry and computes actual ranks over GF(2), GF(3) and GF(101). A second +finite experiment enumerates every ordered binary fitting block in its declared +small domain, including nonsymmetric completions. These checks corroborate the +proof; they do not replace its all-field and all-dimension arguments. + +The mathematical theorem has no bound on graph size or dimensions. The checker +has explicit finite capacities. It imports no predecessor code and has no +runtime input from another package. No claim is made about coefficient bit cost, +nonlinear queries, native COPY tariffs, source acquisition, frames, arbitrary +dirty-state restoration, ownership, hosting, stock, precision/tape, all-size +compiler admission, a complete supplier or outer multiplication transfer. + +This contribution is produced by Nick Petalas. Credit Tekalign/#3362 for the +unequal-payload block-fitting interface; Sagar Thakrar/#2484 and ywz65/#2471 for +the P112 cycle setting, and the classical matching/vertex-cover and block-fitting +methods. Cinna Davis, Adam Gall, ctoth, Philippe Van Velzen and the retained +P112/E8/native/compiler lineage retain their predecessor credit. Apache-2.0. +Independent human and formal proof-kernel review are unclaimed. diff --git a/research/bipartite-query-capacity/README.md b/research/bipartite-query-capacity/README.md new file mode 100644 index 0000000000..633e40e8ee --- /dev/null +++ b/research/bipartite-query-capacity/README.md @@ -0,0 +1,107 @@ +# Exact unequal-payload query capacity for bipartite masks + +For every finite bipartite permitted-read graph G, every nonnegative integer +payload vector d and every coefficient field, the exact minimum fitting-matrix +rank is + + total payload - maximum integral edge sharing + = maximum independent-set payload weight. + +This is a scoped proof about linear query dimension. Arbitrary rectangular, +nonsymmetric and noncommuting permitted blocks cannot beat coordinate pairing. +It gives no physical supplier, new kappa or selected-frontier change. +[PROOF.md](PROOF.md) gives the full contract, all-field proof and construction. + +The three-leaf star with widths (4,1,1,1) has exact query dimension 4. The path +with widths (4,1,1,4) has dimension 8, although each bipartition side has total +width 5. Thus even the larger side total can understate the required capacity. +Integral coordinate sharing attains both answers. + +## Contribution and credit + +This contribution is produced by Nick Petalas. It extends the unequal-payload +block-fitting interface of [Tekalign's #3362](https://github.com/CrocSwap/integer-mult-bounds/pull/3362) +to the bipartite graph class. The predecessor's nonbipartite C5 result and P112 +numbers are cited without replay or audit. Classical weighted matching, +vertex-cover duality and block-fitting methods are credited; no new general +graph-theoretic method or literature priority is claimed. + +Credit Sagar Thakrar/#2484, ywz65/#2471, Cinna Davis, Adam Gall, ctoth, +Philippe Van Velzen and the retained P112/E8/native/compiler lineage. +[SOURCES.json](SOURCES.json) binds the historical model and base by exact bytes. +There are no external scientific runtime inputs. Apache-2.0. +Independent human and formal proof-kernel review are unclaimed. + +## Reproduction and evidence + +From the repository root, using standard-library CPython 3.12: + +```sh +/Users/nick/git/integer-mult-bounds/.venv/bin/python3.12 -W error -B research/bipartite-query-capacity/verify.py +/Users/nick/git/integer-mult-bounds/.venv/bin/python3.12 -O -W error -B research/bipartite-query-capacity/verify.py +/Users/nick/git/integer-mult-bounds/.venv/bin/python3.12 -B scripts/research_package.py --package research/bipartite-query-capacity +/Users/nick/git/integer-mult-bounds/.venv/bin/python3.12 -B scripts/check_research_commit.py --package research/bipartite-query-capacity --check-source-history +``` + +Substitute an installed Python 3.12 path on another host. The verifier prints +`PASS_BIPARTITE_QUERY_CAPACITY` after its JSON receipt. An optional +`--receipt /absolute/external/new-file.json` saves the generated receipt with +SHA256 of all six package files. It refuses an existing destination or a path +inside the checkout. Default verification writes nothing. + +The replay checks 15,552 weighted cases and 46,656 constructed field ranks. +The separate binary enumeration has 1,297 mask/width/matrix cases, including +repetitions across zero-width masks. Thirteen controls and fixtures pass. + +The weighted domain is every one of the 64 bipartite masks on fixed parts of +sizes 2 and 3, with every width vector in {0,1,2}^5. For each recipe an independent +subset enumerator finds the maximum independent weight. The verifier checks +all entries of its expanded matrix and its rank over GF(2), GF(3) and GF(101). +A separate loop enumerates every directed binary fitting matrix on fixed parts +of sizes 2 and 2 for every binary width vector, allowing asymmetric blocks. +Input rejection, false fitting matrices, the unequal star, the path example and +a 4096-bit compressed capacity fixture are also checked. + +These are finite corroborations of the written proof. The generic metadata +runner also checks provenance. It is not mathematical acceptance by a reviewer. + +## Scope and family decision + +The `complex-rank-shape-decoder` card changes to a side result about exact +query capacity. A coefficient search on this graph class cannot improve on the +proved pairing recipe. Stop at that obstruction. No dependent physical +construction round is proposed. + +Source access, actual COPY tariffs, frames, dirty restoration, ownership, hosting, +stock, precision/tape, all-size compilation, native realization and complete +supplier/outer transfer remain unproved. A dimension-optimal factorization does +not supply their costs. Nonlinear encoders and nonbipartite masks are outside +the theorem. No selected cold replay, Lean or Docker run is needed or claimed. + +## Engineering constraints + +Build the Lever supplies a deterministic constructor and verifier. Prove It +Works requires literal fitting entries and actual field ranks, including every +small directed binary completion. Power of Ten bounds the implementation to +at most 14 vertices, 49 edges, 4096-bit widths and 16 dense coordinates. The +scientific driver fixes smaller domains. Residual BFS scans at most V vertices; +Edmonds-Karp uses at most V^3+1 attempts and each path has at most V arcs. +Functions stay below 60 physical lines. All contracts use explicit exceptions +and remain active under optimization. Python's managed allocation is a bounded +rule-3 deviation; allocator internals are not inspected. The proof itself is +unbounded in graph size and dimensions. No metaprogramming, recursion or dynamic +imports are used. Warning-strict normal and optimized runs are registered. +Local Ruff 0.17.1 +checks E,F,I,B,UP,SIM,RUF,C4,PIE,PERF,PTH,RET and formatting without suppressions. +The registered scientific replay needs only the Python standard library. + +## Open next questions + +Can one named nonbipartite mask support a block query rate below its integral +coordinate-sharing optimum? Start with an exact fitting identity and price every +required read. The present theorem offers no candidate or native contract. + +Can an attaining pair-query factorization fit a fully charged native consumer? +Start with one literal caller and include neighbor reads, frame conversions, +helper restoration and target writes. Physical acquisition and all-size +admission are the blockers. Neither question is reserved by this package. diff --git a/research/bipartite-query-capacity/SOURCES.json b/research/bipartite-query-capacity/SOURCES.json new file mode 100644 index 0000000000..8ee9a9b887 --- /dev/null +++ b/research/bipartite-query-capacity/SOURCES.json @@ -0,0 +1,36 @@ +{ + "schema_version": 1, + "base_commit": "624de9dc66858af0945e5f8a0942488d62280d43", + "files": [ + { + "path": "certificates/selected-result.json", + "usage": "provenance", + "git_blob": "c35482cd9035843b15a634cc8276a7e1e40e8395", + "sha256": "6fe0a099b89aa2aed796a13c3a21dafc63f3388ebf397464e44e0451893b9375" + }, + { + "path": "docs/research/agent-task-catalog.json", + "usage": "provenance", + "git_blob": "f126dd2e2dad2b669e75d1d0d0bd05c600725602", + "sha256": "f7a48bfa2659b88378282a8eee7d9fe52cdf505594124c4d1686b58510fffd72" + }, + { + "path": "research/unequal-cycle-payloads/README.md", + "usage": "provenance", + "git_blob": "8e1e01bb308b7a9147847446a7070b0c7bb9f354", + "sha256": "834cd8c46c3893962afe96bdf13eccf21f698fcf26e8fe0ac3c9efd1cea1e4c4" + }, + { + "path": "research/unequal-cycle-payloads/PROOF.md", + "usage": "provenance", + "git_blob": "e407a81af930a1b218f899f244edb303547f3d5c", + "sha256": "684d0281bd0308a6c3eeea602b0d6ac4e35a66a0ff740e3aeb6d5d2309805753" + } + ], + "predecessor": { + "pr": 3362, + "author": "Tekalign", + "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/3362", + "role": "bibliographic model antecedent; no executable or mathematical result is a runtime dependency" + } +} diff --git a/research/bipartite-query-capacity/TASK.json b/research/bipartite-query-capacity/TASK.json new file mode 100644 index 0000000000..13d469c9d0 --- /dev/null +++ b/research/bipartite-query-capacity/TASK.json @@ -0,0 +1,78 @@ +{ + "schema_version": 1, + "task_id": "complex-rank-shape-decoder", + "priority_revision": 7, + "base_commit": "624de9dc66858af0945e5f8a0942488d62280d43", + "original_card": { + "id": "complex-rank-shape-decoder", + "question": "Can a decoder deliver the local paid mass in fewer, larger-rank children (block frame climbs instead of rank-1 to rank-3 steps)?", + "starting_points": [ + "docs/research/research-family-status.md", + "research/complex-local-word-ceiling/README.md", + "research/complex-decoder-field-extension-seed44/README.md", + "research/complex-frame-pair-decoders/README.md", + "research/selected-k8-unrestricted-ends/README.md", + "research/eisenstein-reduction-copy-floor/README.md" + ], + "methods": [ + "Find one exact small decoding identity whose frame path climbs in blocks, and price its complete per-call profile.", + "Bound the best effective child rank achievable for one fixed support alphabet, including copies, frames and restoration." + ], + "acceptance_gate": "A per-call local profile, with all copied information, frames and restoration counted, whose ceiling exceeds the selected word's by at least 5%; masked or overcomplete supports must change an assumption of the eight-term all-pairs bound. A scoped local result may be retained without a complete supplier. Expanding it into further construction rounds requires the family-level budget and obligation gate in research-family-status.md; an optimistic passing relaxation alone is not acceptance.", + "first_step": { + "command": [ + "python3", + "-B", + "research/complex-local-word-ceiling/verify.py" + ], + "expected": "PASS_COMPLEX_LOCAL_WORD_CEILING", + "inspect": "Read the selected word's per-call local profile, its packing ceiling and the lever table; run levers.py for the ideal budget of the lever you target.", + "scope": "Positive control and planning budget only; this is not a new construction or full cold replay." + }, + "first_experiment": "Before any synthesis, write the candidate per-call local profile (and centre charge / unpaid coordinates if changed) and screen it with ceiling.ceiling(); reject it if even the ideal ceiling does not beat the selected word's by your stated margin. Ideal budget: rank-16 delivery is 2.31x (levers.py).", + "bottleneck_link": "Rank-1 children are about half of recursive cost; the selected word's effective child rank is about 3.9. Larger-rank delivery lowers recursive cost per unit of paid mass.", + "allowed_variations": [ + "One masked, overcomplete or block decoder family with exact labels and supports.", + "A scoped lower bound on effective rank for one alphabet.", + "If the coverage law, template or guard changes, derive an applicable fully charged replacement bound instead of applying the incumbent ceiling outside its scope." + ], + "scope_change_triggers": [ + "Repacking idle remainders of an unchanged word (covered by the packing ceiling).", + "Repeating the eight-term all-pairs search inside its proved scope.", + "Only changing helper terminal subspaces and monotone frames within the fixed scalar word, entrances and cleanup contract already covered by #1995/#2013.", + "Searching below C=40 in the #2017 Eisenstein binary scalar-rectangle or fixed-support block-linear additive pairing model; specify a changed premise instead. This bound does not cover every complex decoder.", + "Continuing a partial cost improvement while leaving the same unpriced consumer, restoration or central-readout obligation unresolved; refresh the family expansion decision first. Local product-retiming evidence has a narrow scope and is not a ban on changed graphs or contracts." + ], + "overlap_terms": [ + "rank shape", + "block climb", + "masked decoder", + "overcomplete", + "effective rank" + ] + }, + "scope_status": "changed", + "actual_scope": "Exact all-field minimum query dimension for arbitrary finite bipartite fitting masks with unequal nonnegative integer payload widths.", + "scope_change_reason": "Replace the decoder coefficient search by a sharp obstruction for a changed bipartite permitted-read contract; the unequal C5 predecessor is a model antecedent, not replayed evidence.", + "bottleneck_link": "A scoped query-capacity result: arbitrary block mixing on bipartite masks cannot improve on coordinate edge sharing. Native tariffs and a complete supplier remain outside scope.", + "budget_minutes": 60, + "stop_rule": "Ship the first exact theorem and bounded corroboration; do not extend to odd cycles or physical suppliers.", + "outcome": "completed", + "evidence": "PROOF.md and standalone verify.py; generated source-bound receipts go to an external directory.", + "author": "Nick Petalas", + "ai_assistance": "Independent human and formal proof-kernel review are unclaimed.", + "open_questions": [ + { + "question": "Which changed nonbipartite permitted-read masks admit a block query rate below integral coordinate sharing?", + "why_it_matters": "Bipartite masks cannot provide such a gain under this contract.", + "first_step": "Supply one exact matrix factorization on a named nonbipartite mask and compare with its integral sharing optimum.", + "blocked_by": "No such candidate or physical read contract is supplied here." + }, + { + "question": "Can an attaining pair-query factorization fit a fully charged native consumer?", + "why_it_matters": "Query dimension alone does not price a supplier.", + "first_step": "Choose one literal caller and price every neighbor read, frame conversion, helper restoration and target write.", + "blocked_by": "Physical acquisition and all-size admission remain unspecified." + } + ] +} diff --git a/research/bipartite-query-capacity/VERIFY.json b/research/bipartite-query-capacity/VERIFY.json new file mode 100644 index 0000000000..1370e9de27 --- /dev/null +++ b/research/bipartite-query-capacity/VERIFY.json @@ -0,0 +1,32 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [], + "commands": [ + { + "argv": [ + "{python}", + "-W", + "error", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 240, + "checks": "Complete weighted masks, independent-set dual oracle, literal constructed ranks in three fields, every small directed binary fit, and rejection controls." + }, + { + "argv": [ + "{python}", + "-O", + "-W", + "error", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 240, + "checks": "Repeat the same complete coverage with optimization enabled; all scientific checks remain active." + } + ] +} diff --git a/research/bipartite-query-capacity/verify.py b/research/bipartite-query-capacity/verify.py new file mode 100644 index 0000000000..ccabb1cac1 --- /dev/null +++ b/research/bipartite-query-capacity/verify.py @@ -0,0 +1,301 @@ +#!/usr/bin/env python3 +"""Exact finite corroboration for the bipartite block-fitting theorem. + +Nick Petalas. Apache-2.0. +""" + +import argparse +import hashlib +import itertools +import json +from pathlib import Path + + +def require(condition, message): + if not condition: + raise ValueError(message) + + +def validate(left, right, edges, widths): + require(type(left) is int and type(right) is int, "integer partition sizes") + require(0 <= left <= 7 and 0 <= right <= 7, "partition capacity") + require(len(widths) == left + right, "width count") + require( + all(type(d) is int and d >= 0 and d.bit_length() <= 4096 for d in widths), + "nonnegative bounded integer widths", + ) + require(len(edges) <= left * right, "edge capacity") + require(len(set(edges)) == len(edges), "duplicate edge") + require( + all( + type(i) is int + and type(j) is int + and 0 <= i < left + and left <= j < left + right + for i, j in edges + ), + "bipartite edge", + ) + + +def reachable(capacity, source): + size = len(capacity) + parent = [-1] * size + parent[source] = source + queue = [source] + for head in range(size): + if head == len(queue): + break + i = queue[head] + for j in range(size): + if capacity[i][j] > 0 and parent[j] == -1: + parent[j] = i + queue.append(j) + return parent + + +def construct(left, right, edges, widths): + validate(left, right, edges, widths) + size = left + right + 2 + source, sink = size - 2, size - 1 + total = sum(widths) + capacity = [[0] * size for _ in range(size)] + for i in range(left): + capacity[source][i] = widths[i] + for j in range(left, left + right): + capacity[j][sink] = widths[j] + for i, j in edges: + capacity[i][j] = total + 1 + flow = 0 + # Edmonds-Karp has at most V*E augmentations; E <= V**2. + for _ in range(size**3 + 1): + parent = reachable(capacity, source) + if parent[sink] == -1: + break + path = [] + vertex = sink + for _ in range(size): + if vertex == source: + break + previous = parent[vertex] + path.append((previous, vertex)) + vertex = previous + require(vertex == source, "bounded augmenting path") + amount = min(capacity[i][j] for i, j in path) + require(amount > 0, "positive augmentation") + for i, j in path: + capacity[i][j] -= amount + capacity[j][i] += amount + flow += amount + else: + raise ValueError("augmentation bound exhausted") + counts = tuple(capacity[j][i] for i, j in edges) + private = list(widths) + for (i, j), count in zip(edges, counts, strict=True): + private[i] -= count + private[j] -= count + cover = tuple(i for i in range(left) if parent[i] == -1) + tuple( + j for j in range(left, left + right) if parent[j] != -1 + ) + require(all(d >= 0 for d in private), "endpoint capacities") + require(sum(counts) == flow == sum(widths[i] for i in cover), "flow cut equality") + require(all(i in cover or j in cover for i, j in edges), "vertex cover") + return counts, tuple(private), cover, total - flow + + +def independent_optimum(edges, widths): + best = 0 + for mask in range(1 << len(widths)): + if all(not (mask >> i & 1 and mask >> j & 1) for i, j in edges): + best = max(best, sum(d for i, d in enumerate(widths) if mask >> i & 1)) + return best + + +def matrix_from_recipe(edges, widths, counts, private): + total = sum(widths) + require(total <= 16, "dense matrix capacity") + offsets = [sum(widths[:i]) for i in range(len(widths))] + used = [0] * len(widths) + matrix = [[0] * total for _ in range(total)] + for (i, j), count in zip(edges, counts, strict=True): + for _ in range(count): + a, b = offsets[i] + used[i], offsets[j] + used[j] + for row in (a, b): + for column in (a, b): + matrix[row][column] = 1 + used[i] += 1 + used[j] += 1 + for i, count in enumerate(private): + for _ in range(count): + a = offsets[i] + used[i] + matrix[a][a] = 1 + used[i] += 1 + require(tuple(used) == tuple(widths), "all coordinates allocated once") + return matrix + + +def rank_mod(matrix, prime): + rows = [[value % prime for value in row] for row in matrix] + rank = 0 + for column in range(len(rows)): + pivot = next((i for i in range(rank, len(rows)) if rows[i][column]), None) + if pivot is None: + continue + rows[rank], rows[pivot] = rows[pivot], rows[rank] + inverse = pow(rows[rank][column], -1, prime) + rows[rank] = [x * inverse % prime for x in rows[rank]] + for i in range(rank + 1, len(rows)): + factor = rows[i][column] + rows[i] = [ + (a - factor * b) % prime + for a, b in zip(rows[i], rows[rank], strict=True) + ] + rank += 1 + return rank + + +def check_fit(matrix, edges, widths): + owners = [i for i, count in enumerate(widths) for _ in range(count)] + allowed = set(edges) | {(j, i) for i, j in edges} + for a, i in enumerate(owners): + for b, j in enumerate(owners): + if i == j: + require(matrix[a][b] == int(a == b), "identity diagonal block") + elif (i, j) not in allowed: + require(matrix[a][b] == 0, "forbidden ordered block") + + +def weighted_cases(): + count = 0 + digest = hashlib.sha256() + possibilities = tuple(itertools.product(range(2), range(2, 5))) + for mask in range(64): + edges = tuple(edge for bit, edge in enumerate(possibilities) if mask >> bit & 1) + for widths in itertools.product(range(3), repeat=5): + counts, private, cover, optimum = construct(2, 3, edges, widths) + require( + optimum == independent_optimum(edges, widths), "independent-set oracle" + ) + matrix = matrix_from_recipe(edges, widths, counts, private) + check_fit(matrix, edges, widths) + for prime in (2, 3, 101): + require(rank_mod(matrix, prime) == optimum, "actual constructed rank") + digest.update( + json.dumps( + [mask, widths, counts, private, cover, optimum], + separators=(",", ":"), + ).encode() + ) + count += 1 + return count, digest.hexdigest() + + +def exhaustive_binary(): + count = 0 + possibilities = tuple(itertools.product(range(2), range(2, 4))) + for mask in range(16): + edges = tuple(edge for bit, edge in enumerate(possibilities) if mask >> bit & 1) + for widths in itertools.product(range(2), repeat=4): + total = sum(widths) + owners = [i for i, width in enumerate(widths) if width] + allowed = set(edges) | {(j, i) for i, j in edges} + slots = [ + (a, b) + for a, i in enumerate(owners) + for b, j in enumerate(owners) + if (i, j) in allowed + ] + best = total + for values in itertools.product(range(2), repeat=len(slots)): + matrix = [[int(a == b) for b in range(total)] for a in range(total)] + for (a, b), value in zip(slots, values, strict=True): + matrix[a][b] = value + best = min(best, rank_mod(matrix, 2)) + count += 1 + require( + best == independent_optimum(edges, widths), "all directed binary fits" + ) + return count + + +def controls(): + invalid = [ + (-1, 1, (), ()), + (1, 1, (), (1,)), + (1, 1, (), (True, 1)), + (1, 1, (), (-1, 1)), + (1, 1, ((0, 0),), (1, 1)), + (1, 1, ((0, 1), (0, 1)), (1, 1)), + (8, 0, (), (0,) * 8), + (1, 0, (), (1 << 4096,)), + ] + for args in invalid: + try: + construct(*args) + except ValueError: + continue + raise ValueError("invalid input admitted") + edges, widths = ((0, 1), (0, 2), (0, 3)), (4, 1, 1, 1) + recipe = construct(1, 3, edges, widths) + require(recipe[-1] == 4 and sum(recipe[0]) == 3, "unequal star fixture") + huge = (1 << 4095) + 17 + require( + construct(1, 1, ((0, 1),), (huge, huge))[-1] == huge, "compressed large widths" + ) + path_edges = ((0, 2), (1, 2), (1, 3)) + require( + construct(2, 2, path_edges, (4, 1, 1, 4))[-1] == 8, + "larger side total can be too small", + ) + for mutant in ([[0, 1], [1, 1]], [[1, 1], [0, 1]]): + try: + check_fit(mutant, (), (1, 1)) + except ValueError: + continue + raise ValueError("invalid fitting matrix admitted") + return len(invalid) + 5 + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("--receipt", type=Path, help="create an external new receipt") + args = parser.parse_args() + weighted, stream = weighted_cases() + binary = exhaustive_binary() + control_count = controls() + here = Path(__file__).resolve().parent + names = ( + "README.md", + "PROOF.md", + "TASK.json", + "SOURCES.json", + "VERIFY.json", + "verify.py", + ) + receipt = { + "weighted_cases": weighted, + "constructed_field_ranks": weighted * 3, + "directed_binary_matrices": binary, + "controls": control_count, + "recipe_sha256": stream, + "source_sha256": { + name: hashlib.sha256((here / name).read_bytes()).hexdigest() + for name in names + }, + } + encoded = json.dumps(receipt, indent=2, sort_keys=True) + "\n" + if args.receipt: + require( + not args.receipt.resolve().is_relative_to(here.parents[1]), + "receipt destination outside the checkout", + ) + with args.receipt.open("x", encoding="utf-8") as destination: + require( + destination.write(encoded) == len(encoded), "complete receipt write" + ) + print(encoded, end="") + print("PASS_BIPARTITE_QUERY_CAPACITY") + + +if __name__ == "__main__": + main() From 1244701f6f868f690104fd64d65013d822e59bdc Mon Sep 17 00:00:00 2001 From: Nick Petalas Date: Fri, 23 Oct 2026 00:39:55 +0100 Subject: [PATCH 2/2] docs(research): specify triangle-free follow-on masks --- research/bipartite-query-capacity/README.md | 4 ++-- research/bipartite-query-capacity/TASK.json | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/research/bipartite-query-capacity/README.md b/research/bipartite-query-capacity/README.md index 633e40e8ee..6f233535ea 100644 --- a/research/bipartite-query-capacity/README.md +++ b/research/bipartite-query-capacity/README.md @@ -97,8 +97,8 @@ The registered scientific replay needs only the Python standard library. ## Open next questions -Can one named nonbipartite mask support a block query rate below its integral -coordinate-sharing optimum? Start with an exact fitting identity and price every +Can one named triangle-free nonbipartite mask support a block query rate below +its integral coordinate-sharing optimum? Start with an exact fitting identity and price every required read. The present theorem offers no candidate or native contract. Can an attaining pair-query factorization fit a fully charged native consumer? diff --git a/research/bipartite-query-capacity/TASK.json b/research/bipartite-query-capacity/TASK.json index 13d469c9d0..0958b10d72 100644 --- a/research/bipartite-query-capacity/TASK.json +++ b/research/bipartite-query-capacity/TASK.json @@ -63,9 +63,9 @@ "ai_assistance": "Independent human and formal proof-kernel review are unclaimed.", "open_questions": [ { - "question": "Which changed nonbipartite permitted-read masks admit a block query rate below integral coordinate sharing?", + "question": "Which triangle-free nonbipartite permitted-read masks, if any, admit a block query rate below integral edge sharing?", "why_it_matters": "Bipartite masks cannot provide such a gain under this contract.", - "first_step": "Supply one exact matrix factorization on a named nonbipartite mask and compare with its integral sharing optimum.", + "first_step": "Supply one exact fitting factorization on a named triangle-free nonbipartite mask and compare with its integral edge-sharing optimum.", "blocked_by": "No such candidate or physical read contract is supplied here." }, {