From 5690b63f877654bca13e3d4777c081e7d538d7bc Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Tue, 10 Nov 2026 13:52:47 +0000 Subject: [PATCH] Prove the weight-1 no-edge image bound is 6 at pattern dimension 4. A complete no-edge pool whose covectors all have weight 1, and whose pattern space has dimension at most 4, has joint image dimension at most 6. The action is reducible once that dimension exceeds the pattern dimension. The bound is attained by an explicit reducible witness. No kappa change. Co-authored-by: unpaidmoon --- .../weight1-pattern-dim4-reducible/PROOF.md | 216 +++++++++++++ .../weight1-pattern-dim4-reducible/README.md | 121 ++++++++ .../SOURCES.json | 18 ++ .../weight1-pattern-dim4-reducible/TASK.json | 79 +++++ .../VERIFY.json | 34 ++ .../weight1-pattern-dim4-reducible/verify.py | 291 ++++++++++++++++++ 6 files changed, 759 insertions(+) create mode 100644 research/weight1-pattern-dim4-reducible/PROOF.md create mode 100644 research/weight1-pattern-dim4-reducible/README.md create mode 100644 research/weight1-pattern-dim4-reducible/SOURCES.json create mode 100644 research/weight1-pattern-dim4-reducible/TASK.json create mode 100644 research/weight1-pattern-dim4-reducible/VERIFY.json create mode 100644 research/weight1-pattern-dim4-reducible/verify.py diff --git a/research/weight1-pattern-dim4-reducible/PROOF.md b/research/weight1-pattern-dim4-reducible/PROOF.md new file mode 100644 index 0000000000..b0b97baf22 --- /dev/null +++ b/research/weight1-pattern-dim4-reducible/PROOF.md @@ -0,0 +1,216 @@ +# Weight-one covectors cap a pattern-dimension-4 no-edge image at 6 + +Prepared by unpaidmoon with substantial Cursor Grok assistance. Apache-2.0. +Independent human and formal proof-kernel review are unclaimed. + +No new κ is claimed. The selected frontier stays +`781451/250000000`. + +Evidence class: **proof** of a dimension bound and a reducibility statement, +under an exact covector-weight hypothesis, together with one **exhaustive +finite census** of an 8-coordinate witness. It is not a census of all pattern +spaces, and it is not a claim about pools that use a covector of weight 2 or +more. + +## Theorem + +Work over `F2`. Let `P` be a linear space of zero-diagonal `W` by `W` +matrices, with `dim P ≤ 4`, containing no matrix unit. Write `C(P)` for the +complete pool of rank-one idempotents `N = x y^T` with `y^T x = 1` and +`off(N)` a nonzero element of `P`. Suppose every covector `y` that appears +has weight 1. Let `V(P)` be the sum of the images of the pool. + +Then `dim V(P) ≤ 6`. If the pool is nonempty and +`dim V(P) ≥ dim P + 1`, the action on `V(P)` is reducible. In particular +every such pool with `dim P = 4` and `dim V(P) ≥ 5` is reducible. + +Dimension 6 is attained by the witness in Section 6, so the upper bound is +sharp. That witness is reducible: the common kernel of its covectors inside +`V` has dimension 4. + +## Notation + +`off(N)` is `N` with its diagonal deleted. A matrix unit `E_ab` (`a ≠ b`) +is the pattern with a single 1 in row `a`, column `b`. The fiber lemma +quoted below is Lemma 1 of `research/pattern-pool-cardinality/PROOF.md` +(Nick Petalas, #5921): a realizable nonzero off-diagonal pattern has exactly +one rank-one idempotent lift, except a matrix unit, which has two. + +For each column index `j`, write `U_j` for the patterns in `P` supported +only in column `j`. Those patterns occupy disjoint matrix positions, so + +```text +sum_j dim U_j ≤ dim P. +``` + +## 1. The pool is the nonzero pure columns + +**Lemma.** Under the hypotheses, `off(C(P))` is exactly the set of nonzero +elements of the spaces `U_j`. The unique lift of a nonzero `v ∈ U_j` is + +```text +x = e_j + v, y = e_j. +``` + +The column vector `v` is zero in row `j`, because the pattern is +off-diagonal. + +A pool element with `y = e_j` has only column `j` possibly nonzero, and +that column of `x y^T` is `x`. Deleting the diagonal leaves `x + e_j`, +which lies in `U_j`, and `y^T x = 1` forces the `j`-th bit of `x` to be 1. +So every pool pattern is a nonzero element of some `U_j`. + +Conversely, take nonzero `v ∈ U_j`. It is not a matrix unit, so its weight +is at least 2. The displayed lift is a rank-one idempotent: + +```text +(x y^T)^2 = x (y^T x) y^T = x y^T, +``` + +and its off-diagonal pattern is `v` in column `j`. The fiber lemma supplies +no second lift. + +Thus no pool covector has weight greater than 1, which is the hypothesis, +and there is nothing else in the pool. + +## 2. Dimension contributed by one column + +Let `S_j` be the span of `{e_j + v : v ∈ U_j, v ≠ 0}`, and write +`d_j = dim U_j`. + +- If `d_j = 0`, then `S_j = 0`. +- If `d_j = 1`, there is one nonzero vector `v`, so `dim S_j = 1`. +- If `d_j ≥ 2`, then `U_j` has at least three nonzero vectors. For any + nonzero `u ∈ U_j`, choose nonzero `v ≠ u`. Then + + ```text + (e_j + v) + (e_j + (v + u)) = u, + ``` + + so `U_j ⊆ S_j`. Hence `e_j = (e_j + v) + v` lies in `S_j`. Every column + vector is zero at coordinate `j`, so `e_j` is outside the column space + and `dim S_j = 1 + d_j`. + +Write `f(0) = 0`, `f(1) = 1`, and `f(d) = 1 + d` for `d ≥ 2`. Then +`dim S_j = f(d_j)`. The joint image is the sum of the `S_j`, so + +```text +dim V(P) ≤ sum_j f(d_j). +``` + +## 3. The sum is at most 6 + +The positive `d_j` are positive integers whose sum is at most +`dim P ≤ 4`. The complete list of such tuples, up to order, and the +value of `sum f`, is: + +| parts | sum f | +|---|---:| +| (4) | 5 | +| (3,1) | 5 | +| (3) | 4 | +| (2,2) | 6 | +| (2,1,1) | 5 | +| (2,1) | 4 | +| (2) | 3 | +| (1,1,1,1) | 4 | +| (1,1,1) | 3 | +| (1,1) | 2 | +| (1) | 1 | + +No other partition of an integer at most 4 exists. Therefore +`dim V(P) ≤ 6`. + +Equality forces `dim P = 4`, exactly two columns, each of pattern +dimension 2, each image space of dimension 3, those two spaces meeting +only at 0, and `sum d_j = dim P`. + +## 4. Reducibility above `dim P` + +Let `L` be the span of the basis vectors `e_j` for the columns with +`d_j ≥ 1`. Then `dim L` equals the number `c` of those columns. Each such +column has `d_j ≥ 1`, so `c ≤ sum d_j ≤ dim P`. + +Every pool covector is one of those `e_j`. The common kernel inside `V` +is + +```text +K = {z ∈ V : y·z = 0 for every pool covector y} = V ∩ L^⊥. +``` + +Hence `dim K = dim V - dim π_L(V) ≥ dim V - dim L ≥ dim V - dim P`. + +If the pool is nonempty and `dim V ≥ dim P + 1`, then `dim K ≥ 1`. +Some pool vector `x` satisfies `y·x = 1` and lies in `V`, so `x ∉ K` and +`K ≠ V`. Each pool map is `z ↦ (y·z) x`, which is zero on `K`. Thus `K` +is a nonzero proper invariant subspace, and the action is reducible. + +For `dim P = 4` this covers every weight-1 pool with `dim V ≥ 5`. + +In the equality case `dim V = 6`, Section 3 forces `c = 2`. Each +3-dimensional image space contains its `e_j`, so `π_L(V) = L` and +`dim K = 4`. + +## 5. The kernel test needs `dim V ≥ dim P + 1` + +The inequality `dim K ≥ dim V - dim P` is zero when `dim V ≤ dim P`. +That bound is attained. On twelve coordinates, for `b = 0,1,2,3`, put + +```text +x_b = e_{3b} + e_{3b+1} + e_{3b+2}, y_b = e_{3b}, +``` + +and let `P` be the span of the four off-diagonal patterns. Each pattern +has weight 2. A nonempty sum of two or more of them has two or more +unequal nonzero columns, so it is not `off(x y^T)`. The fiber lemma gives +one lift of each single pattern. The pool is exactly these four +projectors, `dim P = 4`, `e(P) = 0`, and every covector has weight 1. +The four images are independent, so `dim V = 4`. Each image meets its +own column coordinate and no other column coordinate, so the common +kernel inside `V` is zero. Each line `span(x_b)` is invariant, so this +particular action is reducible for a different reason. The theorem does +not claim that every weight-1 pool with `dim V = dim P` is reducible. + +## 6. Witness of dimension 6 + +Use width 8. Let + +```text +U_0 = span{e_1+e_2, e_1+e_3}, U_4 = span{e_5+e_6, e_5+e_7}, +``` + +and let `P` be the direct sum of those two column spaces. Each space has +three nonzero vectors, all of weight 2. Thus `dim P = 4` and `P` contains +no matrix unit. A pattern with both columns nonzero has those columns +supported on `{1,2,3}` and `{5,6,7}` respectively. Both are nonzero and +they are unequal, so the pattern is not an off-diagonal of a rank-one +matrix. The pool is therefore the six lifts + +```text +e_0+e_1+e_2, e_0+e_1+e_3, e_0+e_2+e_3 against y = e_0, +e_4+e_5+e_6, e_4+e_5+e_7, e_4+e_6+e_7 against y = e_4. +``` + +Differences of the first triple span `U_0` and recover `e_0`, a +3-dimensional space. The second triple does the same on the complementary +coordinates. The sum is direct, so `dim V = 6`. Section 4 gives an +invariant kernel of dimension 4. + +`verify.py` enumerates every nonzero `x` and `y` on these eight +coordinates. That domain is finite, the enumeration is complete, and the +structural reason above is why only the six lifts appear. The same +program checks the one-column dimension-5 example (even-weight columns +on coordinates `1..5`, pattern dimension 4, image dimension 5, kernel +dimension 4) and the four-line example of Section 5. + +## 7. What this does not say + +A covector of weight 2 or more is outside the hypothesis. The four-cycle +of #6962 has covector weight 3 and acts irreducibly in dimension 4. +Open PR #7094 exhibits an irreducible joint image of dimension 5 at +pattern dimension 4; its covectors have weight at least 2. Neither +example contradicts the theorem. + +The argument does not bound irreducible dimension 6 in that heavier +class, and it does not change the selected conditional κ. No search is +used as a nonexistence proof. diff --git a/research/weight1-pattern-dim4-reducible/README.md b/research/weight1-pattern-dim4-reducible/README.md new file mode 100644 index 0000000000..19999c6ba8 --- /dev/null +++ b/research/weight1-pattern-dim4-reducible/README.md @@ -0,0 +1,121 @@ +# Weight-one covectors cap a pattern-dimension-4 no-edge image at 6 + +**Proof, plus one finite witness. No new κ.** The selected conditional +value stays `781451/250000000`. + +## Result + +Over `F2`, let `P` be a linear space of zero-diagonal matrices with +`dim P ≤ 4` and with no matrix unit. Suppose every rank-one idempotent in +the complete off-diagonal pool has covector weight 1. Then the joint image +`V` has dimension at most 6. If the pool is nonempty and +`dim V ≥ dim P + 1`, the action on `V` is reducible. In particular every +such pool with pattern dimension 4 and joint-image dimension at least 5 is +reducible. + +Dimension 6 is attained. On eight coordinates the two column spaces + +```text +span{e1+e2, e1+e3} and span{e5+e6, e5+e7} +``` + +give a complete pool of six projectors, pattern dimension 4, no matrix +unit, image dimension 6, and an invariant kernel of dimension 4. The +argument is in [PROOF.md](PROOF.md). + +This is a proof under the weight-1 hypothesis. The width-8 pool equality +is an exhaustive census of the finitely many rank-one idempotents on those +eight coordinates. Neither statement is a census of all pattern spaces, and +neither bounds a pool that uses a covector of weight 2 or more. + +## Scope and evidence + +Catalogue card: `bit-new-register-model`, priority revision 8, base commit +`f16923d466a6aba912299882e0545564d2ba7bb2`. The session opened on +`17469fff78c22941280f04d39dc5a1faee09c840`; upstream main then advanced by +the PR #7000 admission commit, which does not touch this proof. Scope +status is **changed**. +The card asks for a larger or nonabelian register alphabet. This package +answers the weight-1 case of the pattern-dimension-4 image question left +by #6962 and narrowed by open #7094. The original card is copied verbatim +in [TASK.json](TASK.json). Pins are in [SOURCES.json](SOURCES.json). + +Ordered eligible list for session r230. Dropped first: every unpaidmoon +pull request and fork `cursor/*` branch named in the session brief, +including the newer fork tips `cursor/frame506-carry-ledger-30b5`, +`cursor/two-gap-constant-insertion-1bb5`, +`cursor/y-exit-partial-round-trip-70ac`, and +`cursor/y-exit-rank-lift-obstruction-b140`. The 19 October handoffs are +already delivered. The revision-8 next-decision table comes next, then +catalogue cards that table does not name, in catalogue order. + +1. Complex helpers (`p104-side-correction`, `coverage-law-change`). +2. BIT helper contract (`bit-helper-contract`). +3. New decoders and interfaces. +4. Supplier audit. +5. All-size audit and formalization. +6. Verification tooling. +7. `bit-new-register-model`. +8. `r437-carrier-integration`. +9. `complex-rank-shape-decoder`. +10. `complex-new-helper-inventory`. + +Item 3 of that list is a changed producer/consumer contract. This package +is item 7. It is the distinct remaining piece of that card after #6921, +#6962, and open #7094: those results use covectors of weight greater than +1, or stop at pattern dimension 3. The weight-1 hypothesis is not the +hypothesis of #7094, whose irreducible dimension-5 pool has covector weight +at least 2. The 112-owner linear relation left by open #7056 was not +taken. + +#7094 is not on this main. Its factors were read from the pull-request +head and are not replayed here. The four-cycle of #6962 is used only as a +negative control: its covector weight is 3, so the theorem does not apply +to it. + +## Reproduce + +Python 3.12, standard library only, from the repository root: + +```sh +python3 -B scripts/research_package.py --package research/weight1-pattern-dim4-reducible --check-only +python3 -B scripts/research_package.py --package research/weight1-pattern-dim4-reducible +``` + +`verify.py` prints `PASS_WEIGHT1_PATTERN_DIM4_REDUCIBLE` with +`pool=6`, `image_dim=6`, `kernel_dim=4`, `partition_max=6`, and +`new_kappa=null`. + +Not run: Lean, Docker, the selected cold replay, and any search over +heavy covectors. An incomplete search is not evidence in this package. + +## Open next questions + +Can a complete no-edge pool of pattern dimension 4 that uses at least one +covector of weight 2 or more act irreducibly on a joint image of dimension +6 or more? Open #7094 already gives irreducible dimension 5 in that heavier +class, so the weight-1 cap does not bound it. The smallest next step is one +explicit heavy-covector pool with a written invariant-subspace check, or a +proof that every such pool has image dimension at most 5 or is reducible. +No column decomposition in this note makes that domain finite, so a search +that finds nothing would not be a proof. + +A second boundary is left open on purpose. The kernel test needs +`dim V ≥ dim P + 1`. The four disjoint weight-1 lines have pattern +dimension 4, image dimension 4, and trivial common kernel, while each line +is invariant. That example does not decide whether every weight-1 pool with +`dim V = 4` is reducible. + +## Credit + +The fiber lemma is Nick Petalas, #5921, +`research/pattern-pool-cardinality`. CubeJerry, #6838, proved the +pattern-dimension-at-most-3 total-image bound and gave the reducible parity +pool of image dimension 5; this note does not reprove that theorem. #6921 +proved the irreducible bound 3 for pattern dimension at most 3. #6962 showed +that bound fails in pattern dimension 4, by the four-cycle. Open #7094 +shows irreducible image dimension 5 with heavier covectors. This package +does not replace those arguments. + +Prepared by unpaidmoon with substantial Cursor Grok assistance. New work is +Apache-2.0. No independent human or formal-kernel review is claimed. diff --git a/research/weight1-pattern-dim4-reducible/SOURCES.json b/research/weight1-pattern-dim4-reducible/SOURCES.json new file mode 100644 index 0000000000..ab68b0fad1 --- /dev/null +++ b/research/weight1-pattern-dim4-reducible/SOURCES.json @@ -0,0 +1,18 @@ +{ + "schema_version": 1, + "base_commit": "f16923d466a6aba912299882e0545564d2ba7bb2", + "files": [ + { + "path": "certificates/selected-result.json", + "usage": "provenance", + "git_blob": "d59b5035e7b4cbaa9d688a1d32dd0d6eb79c466a", + "sha256": "9b8d0eea95b3bf0dfcb7938a732a6439b87a2685dec2a5ab9e525b3b34debbfa" + }, + { + "path": "docs/research/agent-task-catalog.json", + "usage": "provenance", + "git_blob": "3404fbdd5e7529a0674eef26114b5071e4586cec", + "sha256": "ead6cdc9d0af6d58e8a49744d8ec8c7c15e13d2ba93c276c434bcf9b51b93a81" + } + ] +} diff --git a/research/weight1-pattern-dim4-reducible/TASK.json b/research/weight1-pattern-dim4-reducible/TASK.json new file mode 100644 index 0000000000..2bda548e28 --- /dev/null +++ b/research/weight1-pattern-dim4-reducible/TASK.json @@ -0,0 +1,79 @@ +{ + "schema_version": 1, + "task_id": "bit-new-register-model", + "priority_revision": 8, + "base_commit": "f16923d466a6aba912299882e0545564d2ba7bb2", + "original_card": { + "id": "bit-new-register-model", + "question": "Can an explicitly larger or nonabelian register model escape the scoped three-register obstruction?", + "starting_points": [ + "docs/research/research-family-status.md", + "research/bit-three-register-lower-bound/README.md", + "certificates/selected-result.json", + "research/bit-gl3-mixed-targets-length10/README.md", + "docs/research/community-efficient1000-review.md" + ], + "methods": [ + "Construct the smallest exact identity in a newly specified legal operation alphabet.", + "Derive a target-specific relaxation bound for that same explicit alphabet." + ], + "acceptance_gate": "Name the changed hypothesis, all counted roles and a uniform identity; finite column tests alone do not certify it. 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", + "scripts/research_selected_baseline.py" + ], + "expected": "PASS_RESEARCH_BASELINE_BINDINGS_ONLY", + "inspect": "Resolve the current selected review, separate complex/ordinary BIT/admitted BIT/outer budgets, and compare the card against live handoffs before starting. Historical ceilings require exact source/model equivalence.", + "scope": "Source-binding orientation only; not a scientific replay or all-size proof. Materialize selected inputs if this checkout is sparse." + }, + "first_experiment": "First compare the alphabet, role count and length with the fully replayed #1974 census and #2027 mixed-root tariff. Identify a changed premise and a legal native implementation; then price one smallest completed instance before searching larger words.", + "bottleneck_link": "A small-width completed saving changes the bit primitive; a finite-address identity alone is insufficient.", + "allowed_variations": [ + "Choose a fixed larger register count or a specified nonabelian operation family." + ], + "scope_change_triggers": [ + "Remaining inside the already-excluded three-register abelian model.", + "Repeating the two-register GL3 census or a covered three-register length without changing a hypothesis; a formal group-algebra word without native conversion is a partial result." + ], + "overlap_terms": [ + "three-register", + "nonabelian", + "group algebra" + ] + }, + "scope_status": "changed", + "actual_scope": "Whether every complete no-edge pool of pattern dimension at most 4 whose covectors all have weight 1 has joint-image dimension at most 6, and is reducible once that dimension exceeds the pattern dimension.", + "scope_change_reason": "The card asks for a larger or nonabelian register alphabet. This package answers the weight-1 case of the pattern-dimension-4 irreducible-image question left by #6962 and narrowed by open #7094. No new alphabet, word, or kappa is claimed. The same card was already moved to scalar pattern-pool questions by #5921, #6838, #6921 and #6962.", + "bottleneck_link": "Side result. A later word argument cannot quote an irreducible image of dimension 5 or 6 for a weight-1 no-edge pool of pattern dimension 4. The original native acceptance gate remains unmet, and the selected frontier is unchanged.", + "budget_minutes": 60, + "stop_rule": "Stop once the weight-1 bound and the dimension-6 witness are proved, including the kernel test and the partition table. Do not search heavy covectors or claim they are impossible.", + "outcome": "completed", + "evidence": "PROOF.md proves dim V <= 6 and reducibility when dim V >= dim P + 1, for no-edge pools of pattern dimension at most 4 whose covectors all have weight 1. verify.py exhaustively enumerates the width-8 witness (pool 6, image 6, kernel 4), the one-column image of dimension 5, the four-line example with trivial kernel, and the negative controls.", + "author": "unpaidmoon", + "ai_assistance": "Substantial Cursor Grok assistance with the column decomposition, the witness, and the package verifier. Independent human and formal proof-kernel review are unclaimed.", + "open_questions": [ + { + "question": "Can a complete no-edge pool of pattern dimension 4 that uses at least one covector of weight 2 or more act irreducibly on a joint image of dimension 6 or more?", + "why_it_matters": "Open #7094 gives irreducible dimension 5 with heavy covectors, so the weight-1 cap of 6 does not bound that class. An irreducible dimension-6 example, or a proof that none exists, is the question #6962 left after the dimension-5 witness.", + "first_step": "Give one explicit heavy-covector pool with a written invariant-subspace check, or prove that every such pool has image dimension at most 5 or is reducible.", + "blocked_by": "The weight-1 column decomposition does not apply, and no support reduction in this package makes the heavy-covector domain finite. A search that finds nothing would not be a proof." + }, + { + "question": "Is every weight-1 no-edge pool of pattern dimension 4 with joint-image dimension 4 reducible?", + "why_it_matters": "The kernel test needs dim V >= dim P + 1. The four disjoint lines have dim V = 4, trivial common kernel, and are reducible by another invariant subspace, so they do not settle the general dim-4 case.", + "first_step": "Either exhibit a weight-1 pattern-dimension-4 pool whose four-dimensional image has no proper nonzero invariant subspace, or prove that every such action has one.", + "blocked_by": "The common-kernel count can be zero, so that test does not finish the argument." + } + ], + "coordination": { + "thread": "https://github.com/CrocSwap/integer-mult-bounds/discussions/1166", + "question_source": "https://github.com/CrocSwap/integer-mult-bounds/pull/6962", + "depends_on": [ + "https://github.com/CrocSwap/integer-mult-bounds/pull/5921", + "https://github.com/CrocSwap/integer-mult-bounds/pull/6962", + "https://github.com/CrocSwap/integer-mult-bounds/pull/7094" + ] + } +} diff --git a/research/weight1-pattern-dim4-reducible/VERIFY.json b/research/weight1-pattern-dim4-reducible/VERIFY.json new file mode 100644 index 0000000000..74412f3597 --- /dev/null +++ b/research/weight1-pattern-dim4-reducible/VERIFY.json @@ -0,0 +1,34 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [], + "commands": [ + { + "argv": [ + "{python}", + "-I", + "-W", + "error", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 120, + "checks": "Width-8 six-projector witness, one-column dimension 5, four-line kernel vanishing, partition table, and failure controls." + }, + { + "argv": [ + "{python}", + "-I", + "-O", + "-W", + "error", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 120, + "checks": "The same checks with assert statements disabled; the verifier raises SystemExit instead of using assert." + } + ] +} diff --git a/research/weight1-pattern-dim4-reducible/verify.py b/research/weight1-pattern-dim4-reducible/verify.py new file mode 100644 index 0000000000..fde0d8bf0b --- /dev/null +++ b/research/weight1-pattern-dim4-reducible/verify.py @@ -0,0 +1,291 @@ +#!/usr/bin/env python3 +"""Finite checks for the weight-1 pattern-dimension-4 image bound. + +PROOF.md is the all-width argument. This program enumerates the width-8 +witness, the one-column dimension-5 example, the four-line kernel example, +and the partition table. It also runs negative controls. It does not use +assert, so python -O does not skip checks. Standard library only. +""" + +import sys + +MARKER = "PASS_WEIGHT1_PATTERN_DIM4_REDUCIBLE" + + +def fail(message): + raise SystemExit("FAIL: " + message) + + +def require(condition, message): + if not condition: + fail(message) + + +def weight(mask): + return mask.bit_count() + + +def dot(left, right): + return weight(left & right) & 1 + + +def rank(vectors): + pivots = {} + for value in vectors: + while value: + lead = value.bit_length() - 1 + if lead in pivots: + value ^= pivots[lead] + else: + pivots[lead] = value + break + return len(pivots) + + +def span(vectors): + found = [0] + for value in vectors: + found += [item ^ value for item in found] + return found + + +def pattern_rows(image, covector, width): + rows = [] + for row in range(width): + if (image >> row) & 1: + rows.append(covector & ~(1 << row)) + else: + rows.append(0) + return tuple(rows) + + +def pack(rows): + packed = 0 + for index, row in enumerate(rows): + packed |= row << (16 * index) + return packed + + +def pattern_weight(rows): + return sum(weight(row) for row in rows) + + +def subspace(basis): + found = [0] + for value in basis: + found += [item ^ value for item in found] + return found + + +def f_dim(column_dimension): + if column_dimension <= 0: + return 0 + if column_dimension == 1: + return 1 + return 1 + column_dimension + + +def compositions(total): + if total == 0: + yield () + return + for first in range(1, total + 1): + for rest in compositions(total - first): + yield (first,) + rest + + +def partition_maximum(limit): + best = 0 + winners = [] + for total in range(0, limit + 1): + for parts in compositions(total): + score = sum(f_dim(part) for part in parts) + if score > best: + best = score + winners = [parts] + elif score == best: + winners.append(parts) + return best, winners + + +def lifts(column_space, column, width): + found = [] + for vector in column_space: + if vector == 0: + continue + require((vector >> column) & 1 == 0, "column vector meets the diagonal") + image = (1 << column) ^ vector + covector = 1 << column + require(dot(image, covector) == 1, "lift is not idempotent") + found.append((image, covector)) + return found + + +def kernel_inside(space, covectors): + return [vector for vector in space if all(dot(covector, vector) == 0 for covector in covectors)] + + +def check_reducible_kernel(space, pool): + covectors = [covector for _, covector in pool] + images = [image for image, _ in pool] + live = kernel_inside(space, covectors) + require(len(live) > 1, "kernel is zero") + require(len(live) < len(space), "kernel is the whole image") + for image, covector in pool: + for vector in live: + require(dot(covector, vector) == 0, "kernel vector is not killed") + require(dot(covector, vector) * image == 0, "projector moves the kernel") + require(any(dot(covector, image) == 1 for image, covector in pool), "no pool vector exits the kernel") + return rank(live) + + +def census(pattern_set, width): + found = [] + for image in range(1, 1 << width): + for covector in range(1, 1 << width): + if dot(image, covector) != 1: + continue + rows = pattern_rows(image, covector, width) + if pack(rows) in pattern_set and pattern_weight(rows) != 0: + found.append((image, covector)) + return found + + +def column_pattern_space(column_spaces, width): + basis = [] + for column, vectors in column_spaces: + for vector in vectors: + if vector == 0: + continue + image = (1 << column) ^ vector + basis.append(pack(pattern_rows(image, 1 << column, width))) + patterns = set(span(basis)) + return basis, patterns + + +def two_column_witness(): + width = 8 + left = subspace([(1 << 1) ^ (1 << 2), (1 << 1) ^ (1 << 3)]) + right = subspace([(1 << 5) ^ (1 << 6), (1 << 5) ^ (1 << 7)]) + require(all(weight(vector) != 1 for vector in left + right if vector), "witness has a matrix unit") + basis, patterns = column_pattern_space([(0, left), (4, right)], width) + require(rank(basis) == 4, "witness pattern rank") + require(len(patterns) == 16, "witness pattern count") + require(all(weight(pack_value) != 1 for pack_value in patterns if pack_value), "packed matrix unit") + pool = census(patterns, width) + expected = lifts(left, 0, width) + lifts(right, 4, width) + require(sorted(pool) == sorted(expected), "witness pool is not the six lifts") + require(all(weight(covector) == 1 for _, covector in pool), "witness covector weight") + require(rank([image for image, _ in pool]) == 6, "witness image rank") + space = span([image for image, _ in pool]) + require(len(space) == 64, "witness image order") + kernel_rank = check_reducible_kernel(space, pool) + require(kernel_rank == 4, "witness kernel rank") + return len(pool), kernel_rank + + +def one_column_dimension_five(): + width = 6 + basis = [(1 << 1) ^ (1 << (2 + index)) for index in range(4)] + column = subspace(basis) + require(rank(column) == 4, "even-weight column rank") + require(all(weight(vector) % 2 == 0 and weight(vector) != 1 for vector in column if vector), "even-weight column") + _, patterns = column_pattern_space([(0, column)], width) + require(rank([pack(pattern_rows((1 << 0) ^ vector, 1, width)) for vector in basis]) == 4, "one-column pattern rank") + pool = census(patterns, width) + require(len(pool) == 15, "one-column pool size") + require(all(weight(covector) == 1 for _, covector in pool), "one-column covector weight") + space = span([image for image, _ in pool]) + require(rank([image for image, _ in pool]) == 5, "one-column image rank") + require(check_reducible_kernel(space, pool) == 4, "one-column kernel rank") + + +def four_line_kernel_vanishes(): + width = 12 + pool = [] + patterns = [] + for block in range(4): + column = 3 * block + vector = (1 << (column + 1)) ^ (1 << (column + 2)) + image = (1 << column) ^ vector + covector = 1 << column + pool.append((image, covector)) + patterns.append(pack(pattern_rows(image, covector, width))) + require(rank(patterns) == 4, "four-line pattern rank") + require(all(weight(covector) == 1 for _, covector in pool), "four-line covector weight") + require(rank([image for image, _ in pool]) == 4, "four-line image rank") + space = span([image for image, _ in pool]) + live = kernel_inside(space, [covector for _, covector in pool]) + require(live == [0], "four-line kernel should vanish") + for image, covector in pool: + require(dot(covector, image) == 1, "four-line line is not fixed") + for other, other_covector in pool: + if other != image: + require(dot(other_covector, image) == 0, "four-line cross term") + + +def four_cycle_is_outside(): + width = 4 + pool = [] + for index in range(4): + covector = (1 << index) ^ (1 << ((index + 1) % 4)) ^ (1 << ((index + 2) % 4)) + image = 1 << index + require(dot(image, covector) == 1, "four-cycle idempotent") + pool.append((image, covector)) + require(any(weight(covector) != 1 for _, covector in pool), "four-cycle should leave the hypothesis") + require(all(weight(covector) == 3 for _, covector in pool), "four-cycle covector weight") + + +def matrix_unit_is_outside(): + rows = tuple(1 << 1 if row == 0 else 0 for row in range(4)) + require(pattern_weight(rows) == 1, "control pattern should be a matrix unit") + + +def expect_failure(function, label): + try: + function() + except SystemExit as stopped: + text = str(stopped) + require(text.startswith("FAIL:"), label + " did not fail closed") + return + fail(label + " did not fail") + + +def bad_rank_claim(): + require(rank([0b111, 0b1011]) == 6, "truncated witness is not rank 6") + + +def bad_kernel_claim(): + space = span([0b111]) + pool = [(0b111, 0b1)] + # The single image is the whole space and is not in the kernel, so this + # call must succeed. Feeding the image as a fake extra covector of zero + # weight is not the control. Drop the exiting vector by using an empty + # pool, which makes the kernel the whole space. + check_reducible_kernel(space, []) + + +def main(): + best, winners = partition_maximum(4) + require(best == 6, "partition maximum") + require(set(winners) == {(2, 2)}, "only the pair of twos attains 6") + pool_size, kernel_rank = two_column_witness() + one_column_dimension_five() + four_line_kernel_vanishes() + four_cycle_is_outside() + matrix_unit_is_outside() + expect_failure(bad_rank_claim, "truncated rank") + expect_failure(bad_kernel_claim, "empty pool kernel") + print( + MARKER + + " pool=" + + str(pool_size) + + " image_dim=6 kernel_dim=" + + str(kernel_rank) + + " partition_max=6 new_kappa=null" + ) + return 0 + + +if __name__ == "__main__": + sys.exit(main())