diff --git a/research/s4-noncommuting-threecycle-r4-seeda27b/CLAIM.md b/research/s4-noncommuting-threecycle-r4-seeda27b/CLAIM.md new file mode 100644 index 0000000000..092ba51ed3 --- /dev/null +++ b/research/s4-noncommuting-threecycle-r4-seeda27b/CLAIM.md @@ -0,0 +1,41 @@ +# Cycle 4 research claim + +- Seed: `a27baaa734817e395db88b840bf4a089` +- Track and task: `bit-mechanisms` / `bit-new-register-model` +- Priority revision: 3 +- Exact base: `0b1cccf86e2f5132ed286a26ef0a681a495740ea` +- Selected-record SHA-256: `10b9e340fd8e354a37a0c4813c90e5de1dd42044b5f6aca4a3fc5a42b685fa32` +- Scope status: refined to a four-register nonabelian address model. + +## Question + +For the ordered noncommuting pairs `([a],[b])` drawn from +`a,b in {s1*s2, s2*s1, s2*s3, s3*s2}`, can one added restored dirty +scalar role let the complete paid alphabet realize +`diag([a], [b], [e], [e])` with at most three calls? Here +`s1=(12)`, `s2=(23)`, and `s3=(34)`. Each paid call is +`I+([s]+[e])N`, for `s` one of the three adjacent transpositions and any +rank-one idempotent `N` in `M4(F2)`; free scalar `GL4(F2)` mixing is included +through this full idempotent alphabet. The finite family has eight ordered +noncommuting pairs. + +## Changed assumption, method, and bounded domain + +The three-register abelian result excludes extra roles and arbitrary free address maps. This scope adds one restored role and uses the explicit nonabelian address group `S4`. Enumerate the exact 360 factors (3 paid labels times 120 rank-one idempotents), all 129,600 ordered two-factor products, and all 2,880 target-side products for the eight targets, giving a complete meet that excludes words of length at most three. Verify the explicit four-call diagonal construction for every target. Stop after this exact radius-three meet. + +## Cost screen + +Optimistically price every paid transposition call at one and scalar mixing, register hosting, and restoration interface overhead at zero. The direct identity costs four; a three-call identity would save one call (25%) in this abstract model. No selected supplier, bit primitive, recursive moment, or `kappa` change is inferred without a physical realization. + +## Nearest work and overlap + +- PR #1720, head `edb4a289a5f32c8209140144e384dcd3fa8cbfd1`: two identical 4-cycle targets at three roles. +- PR #1734, head `48855b620b23af3a7fe87d53bde05cd2211342c8`: two identical double-transposition targets at three roles. +- PR #1705, head `ad6b7d641b3e8576a95add7981fa75b6a8278fbc`: four coordinate-SWAP targets over a different `F2[GL2(F2)]` alphabet at four registers. +- PR #1742, head `679f3624a0a41ed14942825dd7f413132412d1e3`: three-role `UT3(F2)` D8 central-commutator pair with labels `{x,y}` and a seven-call lower-bound search; the group, alphabet, target, role count, and call floor differ from this four-role S4 family. + +The pre-submit REST refresh at 08:37 UTC covered 424 open PRs. The complete Discussions overlap snapshot covered 383 records at 08:33:44 UTC; this claim and its two update comments are the only exact S4 four-role matches. Discussion #1738 / PR #1742 is a structurally related D8 third-role result with a distinct group, target, alphabet, and search depth. The S4 predecessor PRs above are related but use different targets and only three roles. The initial focused target was `diag([s1*s2],[s2*s3],[e],[e])`; the exact radius-three search was then extended over the full eight-pair family without changing the alphabet or method. + +## Expected handoff + +A small registered package with exact group-algebra arithmetic, state counts and hash, the direct word, omission/target mutation controls, source pins, cost accounting, and an explicit scoped conclusion. Claim expiry: `2026-10-14T10:23:00Z`. diff --git a/research/s4-noncommuting-threecycle-r4-seeda27b/README.md b/research/s4-noncommuting-threecycle-r4-seeda27b/README.md new file mode 100644 index 0000000000..5af621bac9 --- /dev/null +++ b/research/s4-noncommuting-threecycle-r4-seeda27b/README.md @@ -0,0 +1,145 @@ +# Four roles do not share two noncommuting S4 three-cycles in three calls + +## Result + +For every ordered noncommuting pair \((a,b)\) from +\(\{s_1s_2,s_2s_1,s_2s_3,s_3s_2\}\), the target +\(T_{a,b}=\operatorname{diag}([a],[b],[e],[e])\) has minimum paid length +**four**. There are eight such ordered pairs. Each has the direct four-call +construction below. The exact radius-three search excludes every word of +length at most three for all eight targets, even with the additional dirty +scalar role and free scalar \(\mathrm{GL}_4(\mathbb F_2)\) mixing included +in the alphabet. This is a scoped negative result: that extra role does not +produce the proposed one-call sharing for these targets and this operation +alphabet. + +With right-to-left permutation composition, \(s_1=(12)\), \(s_2=(23)\), +and \(s_3=(34)\), so \(s_1s_2=(123)\) and \(s_2s_3=(234)\); the set also +contains their inverses. + +## Exact model + +Work over the noncommutative group algebra \(\mathbb F_2[S_4]\). Its 24 +basis elements are the permutations of four points, and matrix entries are +24-bit coefficient masks. A paid call is + +\[ +F_{s,N}=I+([s]+[e])N, +\] + +where the paid address label \(s\) is one of the adjacent transpositions +\((12),(23),(34)\), and \(N=xy^T\in M_4(\mathbb F_2)\) ranges over all +rank-one idempotents, with \(x,y\ne0\) and \(y^Tx=1\). There are 120 such +idempotents and hence 360 paid factors. Each factor is an involution. The +complete idempotent inventory includes the normalized free scalar +\(\mathrm{GL}_4(\mathbb F_2)\) mixing allowed by this formal model. + +The equality to \(T\) restores roles three and four exactly and applies the +two stated transformations to arbitrary values in roles one and two. All +four roles may start dirty. Each adjacent-transposition call costs one; scalar +mixing, hosting the fourth role, and interface transitions are optimistically +priced at zero. + +## Exact lower bound and upper bound + +The verifier enumerates every one of the \(360^2=129{,}600\) ordered products +\(F_iF_j\), including repeated factors. This gives 87,016 distinct pair +product matrices, including the identity. For each of the eight ordered +noncommuting target pairs, it checks all 360 target-side meets, for 2,880 +complete misses. The canonical row-major encoding uses a three-byte +big-endian coefficient mask for each of the 16 entries; the sorted +complete-state stream has SHA-256 + +`cc18ab4f9e58731f43f42ed0fd791531696836385f9435c6328cbbe36651f2f7`. + +No target-side meet hits this set. For each target \(T_{a,b}\) and each of +the 360 possible final factors \(F_k\), the verifier checks +\(T_{a,b}F_k\notin\{F_iF_j\}\). Since every factor is an involution, any +three-call identity \(T_{a,b}=F_iF_jF_k\) would imply +\(T_{a,b}F_k=F_iF_j\). This complete meet excludes length three; direct +membership checks also exclude lengths zero, one, and two for all targets. + +Every target pair has a two-letter factorization for each cycle. If +\(a=u_1u_2\) and \(b=v_1v_2\), its four-call word uses the diagonal +idempotents \(E_{00}\) and \(E_{11}\): + +\[ +F_{u_1,E_{00}}F_{u_2,E_{00}}F_{v_1,E_{11}}F_{v_2,E_{11}}=T_{a,b}. +\] + +The verifier also checks a one-call positive control, all 32 one-call +deletions across the direct words, a changed-target control, all 360 factor +involutions, and noncommutativity of every target pair. Arithmetic is exact +in \(\mathbb F_2[S_4]\); no sampled columns or floating-point checks are used. + +## Cost and limits + +The favorable comparison is four paid calls versus a sought three-call word, +so the proposed saving would have been one call (25%) before any other charge. +This experiment found no such call reduction for any of the eight declared +targets. The fourth role and free scalar mixing were not charged, which makes +the failed three-call search a useful obstruction inside this abstract model. + +The result does not cover other address groups, other paid labels, more than +four roles, different register dimensions, or richer call types. It does not +map these formal calls to the selected bit supplier, prove a native circuit +cost, change the selected recursive moment, or improve \(\kappa\). + +## Provenance, overlap, and reproduction + +The cycle used seed `a27baaa734817e395db88b840bf4a089`, track +`bit-mechanisms`, task `bit-new-register-model`, priority revision 3, base +`0b1cccf86e2f5132ed286a26ef0a681a495740ea`, and selected-record SHA-256 +`10b9e340fd8e354a37a0c4813c90e5de1dd42044b5f6aca4a3fc5a42b685fa32`. +`SOURCES.json` pins the task catalogue, selected record, selected review, +source manifest, assembly certificate, and the abelian three-register +predecessor. Current related work at the final overlap refresh included PR +#1720 (two identical 4-cycle targets at three roles) and PR #1734 (two +identical double-transposition targets at three roles); this package changes +both the target pair and register count. PR #1705 uses a different +`F2[GL2(F2)]` address alphabet. The live pre-submit refresh also found +[PR #1742](https://github.com/CrocSwap/integer-mult-bounds/pull/1742), which +settles a three-role \(UT_3(\mathbb F_2)\) D8 central-commutator target with +labels \(x,y\) and a seven-call lower-bound search. That result has a +different address group, alphabet, target pair, register count, and baseline; +this package searches four roles over \(S_4\), with three adjacent +transpositions and distinct noncommuting 3-cycle targets. The scoped +coordination claim is +[Discussion #1740](https://github.com/CrocSwap/integer-mult-bounds/discussions/1740). + +Run the exact finite search directly: + +```sh +python3.12 -I -B research/s4-noncommuting-threecycle-r4-seeda27b/verify.py +``` + +Expected marker: + +```text +PASS_S4_NONCOMMUTING_R4 rank_one_idempotents=120 factors=360 ordered_pairs=129600 pair_states=87016 target_pairs=8 radius3_misses=2880 pair_sha256=cc18ab4f9e58731f43f42ed0fd791531696836385f9435c6328cbbe36651f2f7 direct_calls=4 +``` + +The registered repository package gate is: + +```sh +python3.12 scripts/research_package.py --package research/s4-noncommuting-threecycle-r4-seeda27b +``` + +Prepared with substantial OpenAI Codex assistance. No subagents or +independent human review are claimed. + +## Open next questions + +- **Question:** Does a fifth restored dirty role or another explicitly priced + paid-label set permit a sub-four-call identity for this family of + noncommuting targets? + **Why it matters:** That would separate a four-role obstruction from a + limitation caused by the three adjacent-transposition labels, and could + expose an actual sharing mechanism in a larger address model. + **First step:** Fix five roles and the same target + `diag([s1*s2],[s2*s3],[e],[e],[e])`, enumerate its complete rank-one + idempotent alphabet through radius three for the eight target pairs, and + test the exact four-call baseline. + **Blocked by:** A new bounded scope and source/base refresh; this package + deliberately stops at four roles. Any abstract saving would still need a + separate implementation and full register/interface cost. diff --git a/research/s4-noncommuting-threecycle-r4-seeda27b/SOURCES.json b/research/s4-noncommuting-threecycle-r4-seeda27b/SOURCES.json new file mode 100644 index 0000000000..23135e92b9 --- /dev/null +++ b/research/s4-noncommuting-threecycle-r4-seeda27b/SOURCES.json @@ -0,0 +1,42 @@ +{ + "schema_version": 1, + "base_commit": "0b1cccf86e2f5132ed286a26ef0a681a495740ea", + "files": [ + { + "path": "docs/research/agent-task-catalog.json", + "usage": "provenance", + "git_blob": "06c96f5579bb67ed1b86d334e78fbed7da6945f1", + "sha256": "6686ad58f1fbdbc87134a78901b60fd53a20d3984355e91defbbebc9e9fa8075" + }, + { + "path": "certificates/selected-result.json", + "usage": "provenance", + "git_blob": "ae6a99f28aa468649eb66a361e764d769363bf11", + "sha256": "10b9e340fd8e354a37a0c4813c90e5de1dd42044b5f6aca4a3fc5a42b685fa32" + }, + { + "path": "docs/research/community-batch1099-review.md", + "usage": "provenance", + "git_blob": "6cb6ec061a071a06a2d18cd4dc3e9a2b05d28099", + "sha256": "7e76d2c38e5fce30587835b7251df1430488ae4dd372611ef69a3f03f476b6cb" + }, + { + "path": "research/community-frontier1094-audit/SELECTED-SOURCE.json", + "usage": "provenance", + "git_blob": "6a75493790b4eff9c4a98051ef8b01d6aad0d5a8", + "sha256": "79b3de5db3dbcb9829789ba58e9e45758926031e2a7d80667a08429d369be53b" + }, + { + "path": "research/community-frontier1094-audit/ASSEMBLY.json", + "usage": "provenance", + "git_blob": "5fd676df060f3b450782fdf5ff5f6beb63a5eeb0", + "sha256": "1122cb3a575f8c788345fc1bf4c108ac7c3250fb81a5988671f5eb04b3ab3045" + }, + { + "path": "research/bit-three-register-lower-bound/README.md", + "usage": "provenance", + "git_blob": "25e41c370c101a33a6deb978de08b03ed7539b79", + "sha256": "c12b33ef388deece0cbf891505a2ce2c0779a0c3a6cf1f0f7f7039bab59cbebd" + } + ] +} diff --git a/research/s4-noncommuting-threecycle-r4-seeda27b/TASK.json b/research/s4-noncommuting-threecycle-r4-seeda27b/TASK.json new file mode 100644 index 0000000000..69a9413fef --- /dev/null +++ b/research/s4-noncommuting-threecycle-r4-seeda27b/TASK.json @@ -0,0 +1,129 @@ +{ + "schema_version": 1, + "task_id": "bit-new-register-model", + "priority_revision": 3, + "base_commit": "0b1cccf86e2f5132ed286a26ef0a681a495740ea", + "original_card": { + "id": "bit-new-register-model", + "question": "Can an explicitly larger or nonabelian register model escape the scoped three-register obstruction?", + "starting_points": [ + "research/bit-three-register-lower-bound/README.md", + "certificates/selected-result.json" + ], + "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.", + "first_step": { + "command": [ + "python3", + "-B", + "scripts/research_baseline.py" + ], + "expected": "PASS_RESEARCH_BASELINE_BINDINGS_ONLY", + "inspect": "Read Model section 1 of the three-register bound and identify the exact excluded free operations.", + "scope": "Positive control / source-bound orientation only; this is not a new construction or full cold replay." + }, + "first_experiment": "Write a complete operation alphabet outside one named premise and price a baseline before searching identities.", + "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." + ], + "overlap_terms": [ + "three-register", + "nonabelian", + "group algebra" + ] + }, + "scope_status": "refined", + "actual_scope": "For exactly four restored dirty scalar roles over F2[S4], determine whether a fourth role enables a three-paid-call implementation of diag([a],[b],[e],[e]) for every ordered noncommuting pair a,b in {s1*s2,s2*s1,s2*s3,s3*s2}, using every rank-one idempotent in M4(F2) and the three adjacent-transposition labels.", + "scope_change_reason": "The selected card allows a fixed larger register count or an explicit nonabelian family. This refinement fixes four roles and exhausts the eight ordered pairs of distinct noncommuting two-letter 3-cycles, separating it from current three-role S4 work on identical 4-cycles and identical double transpositions.", + "bottleneck_link": "A three-call identity would lower this abstract formal bit-mechanism invoice from four paid calls to three, a 25 percent saving before other charges. No physical supplier realization is established, so this gives no selected-moment or kappa change.", + "budget_minutes": 60, + "stop_rule": "Enumerate the complete 360-factor alphabet through length three using all 129600 ordered pairs and all 2880 final-factor meets across the eight ordered noncommuting target pairs, verify all eight explicit four-call words and controls, then stop. Do not generalize to other register counts or address groups.", + "outcome": "negative-result", + "evidence": "The registered exact verifier finds 87016 unique ordered-pair product matrices including identity; all 2880 target-side meets for eight ordered target pairs miss. The canonical sorted-state SHA-256 is cc18ab4f9e58731f43f42ed0fd791531696836385f9435c6328cbbe36651f2f7. All eight direct four-call words pass, the one-call positive control passes, all 32 direct-word deletions fail, and all 360 factors are involutions.", + "author": "Cinna Davis", + "ai_assistance": "Substantial OpenAI Codex assistance for research, implementation, and writing. No subagents or independent human review are claimed.", + "open_questions": [ + { + "question": "Does a fifth restored dirty role or another explicitly priced paid-label set permit a sub-four-call identity for this family of noncommuting targets?", + "why_it_matters": "This would distinguish a four-role obstruction from a limitation caused by the three adjacent-transposition labels and could expose an actual sharing mechanism in a larger address model.", + "first_step": "Fix five roles and the target family diag([a],[b],[e],[e],[e]) for the eight ordered noncommuting pairs a,b in {s1*s2,s2*s1,s2*s3,s3*s2}; enumerate the complete rank-one idempotent alphabet through radius three and verify the direct four-call baseline.", + "blocked_by": "A new bounded scope and source/base refresh; this package intentionally stops at four roles. Any abstract saving would still need a separate implementation and complete register/interface cost." + } + ], + "scope_key": "7f5f4426ef796683c485", + "selection_nonce": "a27baaa734817e395db88b840bf4a089", + "selection_track": "bit-mechanisms", + "selected_record_sha256": "10b9e340fd8e354a37a0c4813c90e5de1dd42044b5f6aca4a3fc5a42b685fa32", + "method": "Exact exhaustive meet in the formal noncommutative group algebra F2[S4], using involutive paid factors and a deterministic hash of the complete radius-two state set.", + "bounded_domain": { + "roles": 4, + "address_group": "S4", + "paid_labels": [ + "(12)", + "(23)", + "(34)" + ], + "scalar_alphabet": "all 120 rank-one idempotents in M4(F2)", + "paid_factors": 360, + "searched_lengths": "all words of length at most 3", + "pair_products": 129600, + "targets": "all eight ordered noncommuting pairs a,b in {s1*s2,s2*s1,s2*s3,s3*s2}, with T=diag([a],[b],[e],[e])", + "target_side_meets": 2880 + }, + "optimistic_full_cost_budget": { + "direct_paid_calls": 4, + "target_paid_calls": 3, + "saving_if_found": 1, + "relative_saving_if_found": "25 percent", + "charged_items": "one per paid adjacent-transposition factor", + "optimistically_unpriced": "free scalar GL4(F2) mixing, fourth-role hosting/restoration, interface transitions, and physical supplier realization" + }, + "predecessor_heads": [ + { + "pr": 1720, + "head": "edb4a289a5f32c8209140144e384dcd3fa8cbfd1", + "relation": "same S4 adjacent-transposition alphabet at three roles; identical 4-cycle targets" + }, + { + "pr": 1734, + "head": "48855b620b23af3a7fe87d53bde05cd2211342c8", + "relation": "same S4 adjacent-transposition alphabet at three roles; identical double-transposition targets" + }, + { + "pr": 1705, + "head": "ad6b7d641b3e8576a95add7981fa75b6a8278fbc", + "relation": "four roles but a distinct F2[GL2(F2)] coordinate-SWAP alphabet" + }, + { + "pr": 1742, + "head": "679f3624a0a41ed14942825dd7f413132412d1e3", + "relation": "distinct adjacent nonabelian scope: three-role UT3(F2) D8 central-commutator pair, labels {x,y}, direct length 8; current four-role S4 pair family has length 4 and a three-call exclusion" + } + ], + "overlap": { + "open_pr_count": 424, + "open_pr_refresh_utc": "2026-10-14T08:37:00Z", + "discussion_record_count": 383, + "discussion_refresh_utc": "2026-10-14T08:33:44Z", + "helper_search_utc": "2026-10-14T08:34:00Z", + "matching_discussions": [ + "#1740, this claim; #1740 scope-update comment 18919560; #1740 D8/UT3 comparison comment 18919679" + ], + "nearest_structural_discussion": "#1738, completed by PR #1742; D8/UT3 third dirty role, distinct group/alphabet/target/rank", + "other_exact_s4_four_role_claims": "none found in the complete current 383-record discussion snapshot", + "notes": "PR #1720 and #1734 use the same S4 alphabet at three roles with different repeated targets. PR #1742 is a recent structural neighbor but uses UT3(F2), two labels, a third role, and an eight-call central-commutator target. PR #1705 uses another address group. The 08:33 snapshot preceded the last comparison comment on this own claim; no external scope or search changed after refresh." + }, + "local_claim": "https://github.com/CrocSwap/integer-mult-bounds/discussions/1740; expires 2026-10-14T10:23:00Z", + "validation": { + "verifier_command": "python3 -I -B research/s4-noncommuting-threecycle-r4-seeda27b/verify.py", + "expected_marker": "PASS_S4_NONCOMMUTING_R4 rank_one_idempotents=120 factors=360 ordered_pairs=129600 pair_states=87016 target_pairs=8 radius3_misses=2880 pair_sha256=cc18ab4f9e58731f43f42ed0fd791531696836385f9435c6328cbbe36651f2f7 direct_calls=4", + "standalone_status": "passed for the full eight-target family" + } +} diff --git a/research/s4-noncommuting-threecycle-r4-seeda27b/VERIFY.json b/research/s4-noncommuting-threecycle-r4-seeda27b/VERIFY.json new file mode 100644 index 0000000000..a48ce6d381 --- /dev/null +++ b/research/s4-noncommuting-threecycle-r4-seeda27b/VERIFY.json @@ -0,0 +1,19 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [], + "commands": [ + { + "argv": [ + "{python}", + "-I", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 120, + "checks": "Exact F2[S4] arithmetic, complete 360-factor radius-three meet, deterministic pair-state digest, direct four-call construction, positive and negative controls." + } + ] +} diff --git a/research/s4-noncommuting-threecycle-r4-seeda27b/verify.py b/research/s4-noncommuting-threecycle-r4-seeda27b/verify.py new file mode 100644 index 0000000000..1c23d0b793 --- /dev/null +++ b/research/s4-noncommuting-threecycle-r4-seeda27b/verify.py @@ -0,0 +1,213 @@ +#!/usr/bin/env python3 +"""Exact radius-three search in the declared F2[S4], four-role alphabet.""" + +from functools import lru_cache +from hashlib import sha256 +from itertools import permutations + + +def require(condition, message): + if not condition: + raise SystemExit("FAIL_S4_NONCOMMUTING_R4: " + message) + + +R = 4 +PERMS = tuple(permutations(range(4))) +PERM_INDEX = {p: i for i, p in enumerate(PERMS)} +GROUP_MUL = tuple( + tuple(PERM_INDEX[tuple(p[q[k]] for k in range(4))] for q in PERMS) + for p in PERMS +) +E_PERM = PERM_INDEX[(0, 1, 2, 3)] +E = 1 << E_PERM + + +def permutation(images): + return PERM_INDEX[tuple(images)] + + +S1 = permutation((1, 0, 2, 3)) # (12) +S2 = permutation((0, 2, 1, 3)) # (23) +S3 = permutation((0, 1, 3, 2)) # (34) +LABELS = (S1, S2, S3) +G1 = GROUP_MUL[S1][S2] +G2 = GROUP_MUL[S2][S3] +G1_WORDS = (G1, (S1, S2)) +G1_INVERSE_WORDS = (GROUP_MUL[S2][S1], (S2, S1)) +G2_WORDS = (G2, (S2, S3)) +G2_INVERSE_WORDS = (GROUP_MUL[S3][S2], (S3, S2)) +TWO_LETTER_CYCLES = ( + G1_WORDS, G1_INVERSE_WORDS, G2_WORDS, G2_INVERSE_WORDS, +) + + +@lru_cache(maxsize=None) +def group_algebra_product(left, right): + """Multiply two F2[S4] elements encoded as 24-bit coefficient masks.""" + answer = 0 + a = left + while a: + bit_a = a & -a + a ^= bit_a + i = bit_a.bit_length() - 1 + b = right + while b: + bit_b = b & -b + b ^= bit_b + j = bit_b.bit_length() - 1 + answer ^= 1 << GROUP_MUL[i][j] + return answer + + +IDENTITY = tuple( + E if i == j else 0 for i in range(R) for j in range(R) +) + + +def matrix_product(left, right): + """Multiply 4 by 4 matrices over the noncommutative group algebra.""" + result = [] + for i in range(R): + for j in range(R): + value = 0 + for k in range(R): + value ^= group_algebra_product(left[R * i + k], right[R * k + j]) + result.append(value) + return tuple(result) + + +def rank_one_idempotents(): + """Return xy^T over F2 for all nonzero x,y with y^T x=1.""" + rows = [] + for x in range(1, 1 << R): + for y in range(1, 1 << R): + if (x & y).bit_count() & 1: + rows.append(tuple( + int(bool((x >> i) & 1) and bool((y >> j) & 1)) + for i in range(R) for j in range(R) + )) + return tuple(rows) + + +IDEMPOTENTS = rank_one_idempotents() + + +def paid_factor(label, idempotent): + """Return I+([s]+[e])N over F2[S4].""" + delta = E ^ (1 << label) + return tuple( + IDENTITY[index] ^ (delta if idempotent[index] else 0) + for index in range(R * R) + ) + + +FACTOR_LABELS = tuple((label, n) for label in LABELS for n in IDEMPOTENTS) +FACTORS = tuple(paid_factor(label, n) for label, n in FACTOR_LABELS) +FACTOR_INDEX = {label: i for i, label in enumerate(FACTOR_LABELS)} + + +def diagonal(entries): + return tuple( + entries[i] if i == j else 0 + for i in range(R) for j in range(R) + ) + + +TARGETS = tuple( + (a, b, diagonal((1 << a, 1 << b, E, E)), word_a, word_b) + for a, word_a in TWO_LETTER_CYCLES + for b, word_b in TWO_LETTER_CYCLES + if a != b and GROUP_MUL[a][b] != GROUP_MUL[b][a] +) + + +def word_product(indices): + result = IDENTITY + for index in indices: + result = matrix_product(result, FACTORS[index]) + return result + + +def encoded_state(matrix): + """Canonical 48-byte encoding: row-major, 3-byte big-endian entries.""" + return b"".join(value.to_bytes(3, "big") for value in matrix) + + +def main(): + require(len(PERMS) == 24 and len(IDEMPOTENTS) == 120, + "S4 basis or rank-one idempotent count changed") + require(len(FACTORS) == 360, "paid generator count changed") + require(len(TARGETS) == 8, + "ordered noncommuting two-letter cycle family changed") + require(GROUP_MUL[E_PERM][S1] == S1 and GROUP_MUL[S1][E_PERM] == S1, + "permutation identity control failed") + require(GROUP_MUL[G1][G2] != GROUP_MUL[G2][G1], + "declared target 3-cycles unexpectedly commute") + require(all(matrix_product(factor, factor) == IDENTITY for factor in FACTORS), + "a paid factor is not involutive") + + # Diagonal idempotents place the two cycle words in roles zero and one. + e00 = tuple(int(i == 0 and j == 0) for i in range(R) for j in range(R)) + e11 = tuple(int(i == 1 and j == 1) for i in range(R) for j in range(R)) + # Positive control: one paid factor realizes diag([s1],[e],[e],[e]). + one_call_target = diagonal((1 << S1, E, E, E)) + require(FACTORS[FACTOR_INDEX[(S1, e00)]] == one_call_target, + "one-call positive control failed") + + # Every ordered noncommuting pair of two-letter 3-cycles has a direct + # four-call word, and every single-call deletion from that word fails. + target_matrices = [] + for a, b, target, word_a, word_b in TARGETS: + direct = tuple(FACTOR_INDEX[(label, e00)] for label in word_a) + direct += tuple(FACTOR_INDEX[(label, e11)] for label in word_b) + require(word_product(direct) == target, + "four-call direct construction failed for a target pair") + for omitted in range(4): + shorter = direct[:omitted] + direct[omitted + 1:] + require(word_product(shorter) != target, + "one-call omission unexpectedly preserved a target") + target_matrices.append(target) + + # An altered second target catches a mistaken cycle or coordinate label. + altered_target = diagonal((1 << G1, 1 << G1, E, E)) + require(word_product(( + FACTOR_INDEX[(S1, e00)], FACTOR_INDEX[(S2, e00)], + FACTOR_INDEX[(S2, e11)], FACTOR_INDEX[(S3, e11)], + )) != altered_target, "target mutation control failed") + + # Complete radius-two ball: every ordered pair, including repeats. + pair_products = set() + for left in FACTORS: + for right in FACTORS: + pair_products.add(matrix_product(left, right)) + require(len(pair_products) == 87016, + "ordered-pair state count changed") + pair_digest = sha256(b"".join(sorted(encoded_state(state) for state in pair_products))).hexdigest() + require(pair_digest == "cc18ab4f9e58731f43f42ed0fd791531696836385f9435c6328cbbe36651f2f7", + "deterministic complete pair-state digest changed: " + pair_digest) + + total_right_meet_misses = 0 + for target in target_matrices: + require(target not in pair_products, + "a target has a zero-, one-, or two-call representation") + require(target not in FACTORS, + "a target has a one-call representation") + + # If T=A*B*C and C^2=I, then T*C=A*B. Check all C and all targets. + for last in FACTORS: + require(matrix_product(target, last) not in pair_products, + "a three-call word exists in the complete meet") + total_right_meet_misses += 1 + require(total_right_meet_misses == 2880, + "the complete target-side meet count changed") + + print( + "PASS_S4_NONCOMMUTING_R4 " + "rank_one_idempotents=120 factors=360 ordered_pairs=129600 " + f"pair_states={len(pair_products)} target_pairs={len(target_matrices)} " + f"radius3_misses={total_right_meet_misses} pair_sha256={pair_digest} direct_calls=4" + ) + + +if __name__ == "__main__": + main()