diff --git a/research/complex-m3-shared-call-finish-or-remove/README.md b/research/complex-m3-shared-call-finish-or-remove/README.md new file mode 100644 index 0000000000..e1a3b7d47f --- /dev/null +++ b/research/complex-m3-shared-call-finish-or-remove/README.md @@ -0,0 +1,233 @@ +# One shared call at three directions: which two-term parts can be finished, which removed + +**No new κ.** A small negative result, checked by computer in exact arithmetic, in the frame game at 3 address +bits. Two arrays share one call. For one array's part of that call's output I ask two things: can one more call +finish it, and can the other array's last call have it removed? Among the two-term parts tested (two kinds, the +coefficients in the table) none is both. Nothing new is excluded: my earlier note (#4628) already proves +s ≥ 14W/5 there in Lean for the engine game, which excludes a 2 in 5. With one spare address bit no bound I know +excludes it, and there I only sampled 100 cases. + +Jacob Sussman, 16 November 2026. Labels: **checked by computer** (an exact, finite check that `verify.py` +reruns), **argued by hand** (a written argument that no person has checked), **local only** (work of mine that is +not public and not in this package), **open** (not known). + +## 1. What this is + +At three directions the plain way costs 3 calls per array, so 6 calls for two arrays. Two arrays in 5 calls +("2 in 5") would save 1.66e-1 (a saving in the paid calls of one unit, not a κ). The arrangement studied here +gives each array one call of its own, then one call on a mix of the two arrays, then one more call each. The +simplest way for the shared call to pay off asks two things of each array's part of its output. That array's last +call must be able to **finish** the part into a single third-level term. The other array's last call, which reads +the same output, must be able to have the part **removed** from its own result. The table tests both for two-term +parts (sections 3 and 4 define the words). Each row has 10,752 cases. + +| part | coefficient c | plain in disguise | tested | finishable | removable | both | +|---|---|---|---|---|---|---| +| kind A | 1 | 769 | 9,983 | 128 | 639 | **0** | +| kind A | −1 | 769 | 9,983 | 0 | 767 | **0** | +| kind A | 2 | 769 | 9,983 | 767 | 0 | **0** | +| kind A | 1/2 | 769 | 9,983 | 767 | 0 | **0** | +| kind B | 1 | 768 | 9,984 | 0 | 128 | **0** | +| kind B | −1 | 768 | 9,984 | 0 | 128 | **0** | +| kind B | 2 | 768 | 9,984 | 0 | 0 | **0** | + +Status: checked by computer, in exact rational arithmetic. "Finishable" means by the last call alone. A free step +after that call finishes more parts, none of them removable (section 5). For kind A one rule fits every tested +case (section 5); I have no proof of it. The conflict between the two jobs was met before (section 2), and the +table is a result about the cases it lists, not about all programs (section 7). + +## 2. What was known, and what this adds + +- **The shape.** eumemic's negative results (#288) closed two arrays in five calls at block 3 in one normal form + and left the general case open. Jose Manuel (#2108) proved that such a circuit needs at least four "mixing + blocks" (their term). My note (#4628) excluded 2 in 5 at block 3 in the engine game. +- **The conflict was met before, on examples.** In October 2026 a thread on the hub ran into both halves of it, + on a five-call preparation built on lee-phys's two-image prefix (#4688) after Yiyang's phase repair (#4710). + The prefix is invertible with the combination U + 2V and has a kernel with U + V. JoyboyBrian showed that with + the invertible coefficient no change of the fresh input's free feed repairs the preparation (#4751), and that + with coefficient 1 an exact free decoder leaves no contamination from the fresh owner but only a partial + channel (#4797), whose rank Nick Petalas (#4825) and Dugongue (#4885) then found. Reading these as one conflict + is my reading, not a statement of those notes, and they keep every phase (the engine game). My repository + argues the same conflict by hand for a symmetric 2 in 7 at block 4 (a filter 1 + a·u that must be invertible + while a = ±1 is forced), and ran the arrangement of section 1 at the excluded shapes 2 in 5 and 2 in 6 as a + negative control. +- **The same finite geometry is on the hub.** Dugongue's native ports (#4743) include a census of it: the group + of order 10,752 that keeps the raw frame, the 14 frames next to it, and their split 1 + 1 + 12 under a + stabiliser of order 768. That note uses this "symplectic quotient" as a search coordinate system and says that + alone it omits phases. zxv's note on cache reuse (#5283) defines frames the same way. The frame game is that + quotient. +- **Added here** (checked by computer): the table for the two kinds of two-term part of section 4 at 3 address + bits, over all 10,752 free elements, and a rule with a coefficient that describes kind A. +- **Nearby.** Nick Petalas's open note (#7551) proves a cut ceiling on the same graph. Dugongue's atlas (#5803) + and the five-array shared port of Chris R (#4856) and JoyboyBrian (#5491) study other shared calls. The one + unit claimed at three directions (#4813, 5 in 14) was withdrawn by its author on 23 October 2026; its folder on + main still shows the original text, and this note says nothing on 5 in 14. + +## 3. The game, in plain words + +- **The engine game** is that of my note #4628, which defines array, call, free steps, width, unit, "W in s" and + the plain way. An array holds 2^m complex numbers, addressed by m address bits; a paid call applies OpenAI's + 2-point kernel along one direction; shifts, phases, address maps and rational mixing of arrays are free. For a + target of k directions the plain way costs k calls per array, and a unit with W arrays and s calls saves + ln(kW/s)/ln k. Block m means m address bits and a target of all m directions. +- **A spare address bit.** An address has four bits and the target applies only three of the four directions. The + program may use the fourth bit. My repository calls this a rank-3 target with a spare row. +- **Term, frame, level.** An array's content is a sum of terms. Each term is one input passed through one fixed + product of steps, times a number. A term's frame is where it stands up to free steps. The frames are the + Lagrangian subspaces of F_2^(2m), 135 of them at m = 3. Two frames are adjacent when they meet in dimension + m − 1. This is the dual polar graph (DSp(2m, 2) in eumemic's #288, the binary symplectic dual-polar graph in + Nick Petalas's #7551, the frame graph in my repository). A term's level is the distance of its frame from the + raw frame, where every input starts. A finished target of k directions is at level k. +- **Frame game.** The same game with the Pauli part (bit flips, sign flips, the scalar i) dropped. A term is then + an element of the symplectic group Sp(2m, 2), acting on labels (x, z) in F_2^m × F_2^m. The free elements are + those that keep the raw frame L = {x = 0}; there are 10,752 at m = 3. A paid call is a transvection + t_u(v) = v + ⟨v, u⟩u with u outside L; there are 56 at m = 3. The frame of a term g is g⁻¹(L). Products act + from right to left: in t_w·γ·D0 the call D0 is applied first. + +## 4. The question + +Take one input. Its raw term is 1, and its first call D0 gives the term D0, at level 1. The shared call t_w then +acts on an array in which this input has D0 and one more term. Its part of the shared output is + +- **kind A:** y = t_w·(1 + c·γ)·D0, when the extra term going in is a free image of the first-call term; +- **kind B:** y = t_w·(D0 + c·γ), when the extra term going in is a free image of the raw input. + +Here γ is a free element, c is a rational number, and a free image of a term is a free element applied to it on +the left. M = t_w·D0 is the plain middle term, at level 2, and E is the other term of y. A "free combination" is +a sum of rational multiples of free elements, applied on the left. If the first call reads the raw input alone, +these are all the two-term parts with a level-2 term, up to a scalar, a free step on the left and symmetry, and +one first call and one shared call are enough (argued by hand). The docstring of `symmetries` in `verify.py` has +the map; `--part symmetry` checks its counts, a second shared call with the same table, and 368 cases of the map. + +- **Finishable (by the call alone):** for some call t that raises M to level 3, the term t·M is a free + combination of 1, D0 and y, plus t applied to a free combination of 1, D0 and y. Free steps may prepare the + call's input and may add earlier arrays to its output. None is applied to the output itself (see section 5). +- **Removable:** for some call t that could be the other array's last call, t·y is a free combination of 1, D0 + and y, plus t applied to free combinations of 1 and D0 and to free images p·y of the part, with p a free + element other than 1. A call that reads the shared output can then have this input's part cancelled from its + result. A call could be the other array's last call when t·t_w is at level 2, which holds for 48 of the 56 + calls: only then can it raise that array's middle term to level 3 (argued by hand). +- **Plain in disguise:** y has one term or none, or E is a free image of 1 or of D0. These cases are set aside. + +## 5. The table and the rule + +**Kind A.** Compare the frames of the two terms M and E. The rule fits every tested case; it is not proved. + +| frames of M and E | cases | finishable by the call alone | removable | +|---|---|---|---| +| the same: E = g·M with g free, so y = (1 + c·g)·M | 767 | exactly when 1 + c·g is invertible | exactly when it is not | +| adjacent | 768 | never | never | +| further apart | 8,448 | never | never | + +"Invertible" means that another free combination undoes it. For g of order n the test is (−c)^n ≠ 1. With c = 1 +the 128 cases with g of order 3 are finishable, and the 639 with g of order 2, 4 or 6 are removable. So on one +frame the part is either undone and finished like the plain term, or killed by a free step before any call reads +it (argued by hand); in the second case every one of the 52 calls tried removes it. The rule matches all 9,983 +tested cases for each of c = 1, −1, 2 and 1/2 (checked by computer). I did not run other c. Two pieces are +standard: an invertible multiple of M is finished like M, and 1 + c·g is invertible exactly when (−c)^n ≠ 1. + +Two things that the columns leave out (checked by computer): + +- **Adjacent frames, and calls that cannot be a last call.** Let the removing call be any call that does not + simply undo the shared call. Then the 768 adjacent-frame parts are removable too when c = ±1, which gives 1,407 + parts for c = 1 and 1,535 for c = −1. Each of them is removed by the same four calls, those with t·t_w at + level 1, and none of the four can be anybody's last call. +- **A free step after the last call.** For a part with frames further apart, a call t that raises M to level 3 + may put both terms on one frame: t·E = h·t·M with h free. Then t·y = (1 + c·h)·t·M, and when 1 + c·h is + invertible a free step applied to the call's output gives t·M alone. This finishes 128 more parts for c = 1 (h + of order 3), 512 for c = 2 and for c = 1/2, and none for c = −1 (`--part poststep`). None of them is removable. + An AI reviewer's own program found no other part that such a step finishes, and none that is then both. That + program, and its argument that the list is complete, are local only. + +**Kind B.** No part is finishable by the call alone, for c = 1, −1 and 2. For c = 1 and for c = −1 the same 128 +parts are removable, and for c = 2 none is. The 128 are exactly the parts for which some call carries M onto the +frame of E and E onto the frame of M (checked by computer on all 9,984 cases; no proof). All of them sit among +the 1,536 parts whose two terms are on adjacent frames. In kind A the same test picks out exactly the 768 +adjacent-frame parts. + +**One spare address bit: a sample only.** With 4 address bits and the same target there are 20,643,840 free +elements, and I did not run them all. On a seeded sample of 100 kind A parts with c = 1 (20 on the same frame +with g of even order, 20 with g of odd order, 20 on adjacent frames, 40 further apart) the rule is right on every +case and none is both (checked by computer). The sample is drawn by random walks, not uniformly. It is no proof. + +## 6. How to re-check + +Run `python3 -B research/complex-m3-shared-call-finish-or-remove/verify.py --part controls`, then the same with +`main`, `poststep`, `symmetry`, `coefficients` and `spare`. Standard library only; no file is read or written. +With Python 3.12 on an Apple M4 the six parts take about 3, 38, 4, 42, 85 and 22 seconds and under 30 MB each, +and each ends with a line that starts `PASS_COMPLEX_M3_SHARED_CALL_`. The program checks with assert statements +and refuses to run under `-O`. `VERIFY.json` says what each part checks, the controls included. `--part full`, +which is not listed there, runs every case one at a time with no symmetry reduction, in about 4 minutes (or in +four quarters, `--quarter 0` to `--quarter 3`), and gives the same table. + +## 7. Limits of this work + +- **The frame game only.** My repository argues by hand that every engine unit gives a frame-game program with + the same calls, and that every frame-game program completes to an engine unit (stated there for targets of all + m directions). I have not turned this table into a statement about engine-game parts, where two terms that + differ by a Pauli are different terms. +- **Two terms, one input at a time, one arrangement.** A part with three or more terms is not covered. The first + call reads the raw input alone: a first call on a free combination (1 + c·a)·x of the raw input x gives a third + kind of part, M + c·M·a, which is not in the table. The other array's part of the shared output is ignored, + and each last call is treated on its own. A program that cancels what one last call leaves over against the + output of the other is not covered. Nor is a shared first or last call, or two shared calls. +- **A finite check, not a theorem about all programs.** Complete at 3 address bits and sampled at 4, for the + coefficients in the table only. With a free step after the last call, the list of finished parts is complete + only by a reviewer's local program, and kind B was not run that way here. The table is a result about the + cases it lists. +- **Fixed widths are not studied.** Terms are treated as formal. alephnan's threshold T(3) = 10 (#6714) says from + which width distinct three-qubit Clifford terms are independent. +- **No person has checked this.** + +## Open next questions + +1. **Is there a 2 in 5 at three directions with one spare address bit (a saving of 1.66e-1)?** In the engine game + it is the smallest shape at three directions (fewest arrays, fewest calls) that no bound I know excludes. My + repository has listed it as open since 20 October 2026: the best lower bound there is 2.4883 calls per array + (checked by computer, by one family of programs), and a 2 in 5 uses 2.5. I know of no search of this exact + case, and I have no evidence either way. First step: the same arrangement at 4 address bits with every + coefficient left free and the two last outputs read together, starting with the parts for which something + happened here. Blocked by nothing but size: 20,643,840 free elements before symmetry. +2. **Is the kind A rule a theorem at every number of address bits?** A proof by hand would replace the sample at + 4 bits. First step: show that a part whose two terms sit on different frames is never finishable by the call + alone. Blocked by nothing. +3. **Why are exactly those 128 kind B parts removable?** First step: prove that a call which carries M onto the + frame of E and E onto the frame of M removes the part when c = ±1. Blocked by nothing. + +## How this was found (a remark on method, not evidence; local only) + +The table came out of nine runs in which AI agents carried ideas for sharing work into this game, eight of them +from other fields (the pull request names the fields and their originators). None gave a program that beats the +plain way at three directions, and six arrived separately at the arrangement of section 1. An earlier run had +given three totals (10,752 cases, 128 finishable, 1,407 removable under the wider test of section 5) and no rule. +Before looking at which cases were removable, the AI agent I work with wrote its guess for the rule in a dated +file, with a confidence of 75 %, and the comparison matched case by case. That afternoon it wrote eight such +guesses, all about this one table; seven were right, one of them on a sample only. Review by other AI agents then +asked two things that no guess had asked: could the removing call be a last call at all, and may a free step +follow the last call? Both changed the table. A guess written down first tested the agent's sense of the answer, +not whether the question was the right one. Only a file time dates the guess files. The nearest thing I found on +the hub is zxv's frozen forecast (#5283). + +## AI assistance and credit + +Substantial AI assistance: I did this work with the help of AI agents (Anthropic's Claude). The programs, the +searches, the arguments and the text were written by the agents under my direction. Two AI reviewers rebuilt the +counts of an earlier form of this table from the definitions with their own programs, and between them found the +two corrections of section 5; `verify.py` then reproduced the corrected counts (local only: the reviewers' +programs are not in this package). No independent human review of this package is claimed. + +Credit on the hub: eumemic (#288); Jose Manuel (#2108); lee-phys (#4688); Yiyang (#4710); Dugongue (#4743, #4885 +and #5803); JoyboyBrian (#4751, #4797, #5491); Nick Petalas (#4825, #7551); Chris R (#4856); alephnan (#6714); +zxv (#5283). OpenAI for the cost model, the call and its 2-point kernel. Apache-2.0. + +## Sources + +`SOURCES.json` has the hub base commit (`e54523517d`, main, 10 November 2026) and its pins. #288 was closed +without merge; its text is on main at `research/abelian-cayley-metric-scope/sources/pr288-README.md`. #7551 is +open and is cited at its head `9aec48e750`, not pinned. My repository is +https://github.com/jacobalansussman/wht-power-saving-lean at commit `0788bc6568` (3 November 2026): +`research/frame-packing-two-arrays/` (the frame game in "Words used here" and, for its symplectic form, in +`proofs/frame-game-sandwich.md`; engine units and frame-game programs; the negative control), +`research/moonshot-block4-block5/` (the 2 in 7 dilemma) and `research/block-bounds-and-new-rules/`, section 4.2 +(spare rows, the 2.4883 lower bound, the open case; its table of open cases says "4 spare rows", meaning 4 rows +in all, one of them spare). Nothing is copied from another repository: `verify.py` rebuilds the table each run. diff --git a/research/complex-m3-shared-call-finish-or-remove/SOURCES.json b/research/complex-m3-shared-call-finish-or-remove/SOURCES.json new file mode 100644 index 0000000000..83613b583b --- /dev/null +++ b/research/complex-m3-shared-call-finish-or-remove/SOURCES.json @@ -0,0 +1,56 @@ +{ + "schema_version": 1, + "base_commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "upstream_repository": "https://github.com/CrocSwap/integer-mult-bounds", + "files": [ + { + "path": "docs/research/agent-task-catalog.json", + "usage": "provenance", + "git_blob": "3404fbdd5e7529a0674eef26114b5071e4586cec", + "sha256": "ead6cdc9d0af6d58e8a49744d8ec8c7c15e13d2ba93c276c434bcf9b51b93a81" + }, + { + "path": "research/complex-small-m-lower-bounds/README.md", + "usage": "provenance", + "git_blob": "8e140d056a3334a4bdb1d2afe10dd7155db8e347", + "sha256": "c9656be3d910e4ab64b9e8b7beb66198ff9744cde5405ee07156578f89f2f196" + }, + { + "path": "research/complex-prefix-native-ports/README.md", + "usage": "provenance", + "git_blob": "b24dd748956185247c5794e1a20102966aa32e56", + "sha256": "bc9dd236445665cb7ea8fdd6b1c3783e70018ec0fbe19ad1a756fb4e80f40f6f" + }, + { + "path": "research/complex-two-image-hook-prefix/README.md", + "usage": "provenance", + "git_blob": "ac33ab36287fe1f1d9ba51b5360f44536c2ff3fc", + "sha256": "91d45b5af6063e30c6860a4cb46cfc44960ecd67f37c3bce9675924e30b89b4e" + }, + { + "path": "research/staggered-single-owner-obstruction/README.md", + "usage": "provenance", + "git_blob": "42cf519d1737dbabc31d0c0f9c77dedda5f9e6f0", + "sha256": "ff1acb5907e2f5fb1ca41bacbe331384dd6e5b9cfec821cd4d7209b8dddb1030" + }, + { + "path": "research/resonant-owner-extraction/README.md", + "usage": "provenance", + "git_blob": "83d455ec6097294bfb7d26bb78a742f326b5a12d", + "sha256": "c24478b434a7dd4bad24bd5e220fb5cc296ce5be7ddb7f1fbba62afeb9b9364f" + } + ], + "inputs_note": "No live inputs from this repository. The provenance rows are the task catalogue and the five predecessor texts that README.md section 2 leans on: my #4628, Dugongue's native ports with their census of the same finite geometry (#4743), lee-phys's two-image prefix (#4688), and JoyboyBrian's single-owner obstruction (#4751) and resonant partial channel (#4797). verify.py reads no file at all: it rebuilds the table from the definitions on every run.", + "external_sources": [ + { + "what": "Statements cited from my public repository (the frame game, the completion of frame-game programs, the 2 in 7 dilemma, the negative control, the 2.4883 lower bound and the open case). They are linked, not copied; nothing in this package depends on their bytes.", + "repository": "https://github.com/jacobalansussman/wht-power-saving-lean", + "commit": "0788bc656827ff2e7e44f5a77299eea19f0002fe" + }, + { + "what": "Nick Petalas's open pull request #7551 (research/binary-dual-polar-cut-ceiling), cited as nearby work. It is not on main, so it is cited by its head and not pinned.", + "repository": "https://github.com/CrocSwap/integer-mult-bounds", + "commit": "9aec48e7507d4fb6e52170f40505b72e6e9e41f8" + } + ] +} diff --git a/research/complex-m3-shared-call-finish-or-remove/TASK.json b/research/complex-m3-shared-call-finish-or-remove/TASK.json new file mode 100644 index 0000000000..65a764b637 --- /dev/null +++ b/research/complex-m3-shared-call-finish-or-remove/TASK.json @@ -0,0 +1,73 @@ +{ + "schema_version": 1, + "task_id": "scope-navigation", + "priority_revision": 8, + "base_commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "original_card": { + "id": "scope-navigation", + "question": "Can one misleading historical-current claim or missing research cross-reference be corrected?", + "starting_points": [ + "docs/research/current-status.md", + "docs/research/pr-ledger.md", + "certificates/selected-result.json" + ], + "methods": [ + "Trace one confusing path from onboarding to its authoritative source.", + "Index one tightly related family of obstructions with explicit excluded and open hypotheses." + ], + "acceptance_gate": "Produce evidence-backed navigation, preserve historical records and avoid a duplicate global survey.", + "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": "Repair one confusing path or produce a scoped map of one related obstruction family.", + "bottleneck_link": "Clear navigation lowers entry cost for central research; a global survey without a concrete fix is not required.", + "allowed_variations": [ + "One historical-current ambiguity or one bounded family index." + ], + "scope_change_triggers": [ + "Rewriting frozen scientific packages just to change their historical wording." + ], + "overlap_terms": [ + "current status", + "historical checkpoint", + "scope navigation" + ] + }, + "scope_status": "changed", + "actual_scope": "One bounded family index at three directions: what one array can hold in the output of a call shared with a second array, in the frame game (the engine game with its Pauli part dropped; terms in Sp(2m, 2), free elements the stabiliser of the raw frame, paid calls the transvections outside it). For two kinds of two-term part of one shared middle call at 3 address bits (10,752 free elements each), with coefficient 1, -1, 2 or 1/2 for the first kind and 1, -1 or 2 for the second, the package decides exactly whether one more call alone (no free step applied to its output) can finish the part, and whether a call that could be the other array's last call can have it removed. No tested part is both. For the first kind one rule fits every tested case (same frame: finishable exactly when 1 + c.g is invertible, removable exactly when it is not; other frames: neither); it is not proved. Two additions are checked: with a free step after the last call 128 more parts of the first kind are finished at coefficient 1 (512 at 2 and at 1/2), none of them removable; and the parts on adjacent frames are removable at coefficient +1 or -1 only by four calls that cannot be a last call. With one spare address bit (4 bits) the rule is checked on a seeded sample of 100 cases only. The open case (2 in 5 at three directions with one spare address bit, a saving of 1.66e-1 in the paid calls of one unit, not a kappa) is stated with its status and is not settled.", + "scope_change_reason": "The card's method 'Index one tightly related family of obstructions with explicit excluded and open hypotheses' fits: the package ties one conflict that the hub met on examples in October (lee-phys's two-image prefix, #4688; JoyboyBrian's #4751 and #4797) to the statements in my repository, to the earlier bounds (eumemic's #288, Jose Manuel's #2108, my #4628) and to Dugongue's census of the same finite geometry (#4743), and names the open case. It is more than navigation because it also adds a result that is not on main: the table and the rule that describes its first kind of part. The game is stated in every claim.", + "bottleneck_link": "A 2 in 5 at three directions with one spare address bit would save 1.66e-1 in the paid calls of one unit, and no bound I know excludes it. This package shows, for two kinds of two-term part of one shared call and the coefficients tested, which parts the last call alone can finish and which can be removed, and that none is both, which narrows where a search for that unit should look. It does not change kappa.", + "budget_minutes": 180, + "stop_rule": "One table, its rule and its controls, rebuilt by verify.py in exact rational arithmetic; no search for the open case and no Lean build for this package.", + "outcome": "negative-result", + "evidence": "verify.py, standard library, exact rational arithmetic, no file read or written; times with Python 3.12 on an Apple M4. --part main (about 38 s): at 3 address bits, for both kinds of part with coefficient 1 and all 10,752 free elements, the counts 9,983 tested / 769 plain in disguise / 128 finishable by the call alone / 639 removable by a call that could be a last call / 1,407 removable by any call that does not undo the shared call (kind A) and 9,984 / 768 / 0 / 128 / 128 (kind B), no case both, the kind A rule on every tested case, and the reduction to 1,632 classes tested directly on 80 cases. --part poststep (about 4 s): the kind A parts with frames further apart that one call and one free step on its output finish (128, 0, 512 and 512 for coefficients 1, -1, 2 and 1/2), each identity checked term by term. --part symmetry (about 42 s): the free elements carry the first call to each of the 56 calls; 768 symmetries carry one shared call to each of the 48 that give a level-2 term; the whole table again for a second shared call; the symmetry map tested on 368 distinct cases. --part coefficients (about 85 s): kind A with coefficients -1, 2 and 1/2 and kind B with -1 and 2, the kind A rule on every case, none both. --part spare (about 22 s): the rule on a seeded sample of 100 kind A parts at 4 address bits. --part controls (about 3 s): the solver finds the plain third call and refuses a target two calls away; arithmetic modulo 2^61 - 1 agrees on 92 seeded cases; three wrong variants of the rule are rejected. Not registered: --part full, every case one at a time with no symmetry reduction (run once in four quarters; same totals). Local only, not in this package: two AI reviewers' own programs, which rebuilt the counts of an earlier form of the table and between them found the two additions.", + "author": "Jacob Sussman", + "ai_assistance": "Substantial AI assistance: I did this work with the help of AI agents (Anthropic's Claude). The programs, the searches, the arguments and the text were written by the agents under my direction. Two AI reviewers rebuilt the counts of an earlier form of this table from the definitions with their own programs, and between them found the two corrections of README section 5 (local only: those programs are not in this package). No independent human review of this package is claimed.", + "open_questions": [ + { + "question": "Is there a 2 in 5 at three directions with one spare address bit (a saving of 1.66e-1 in the paid calls of one unit, not a kappa)?", + "why_it_matters": "In the engine game it is the smallest shape at three directions (fewest arrays, fewest calls) that no bound I know excludes; my best lower bound there is 2.4883 calls per array (checked by computer, by one family of programs) and the shape uses 2.5.", + "first_step": "The same arrangement (one call each, one shared call, one call each) at 4 address bits with every coefficient left free and the two last outputs read together; start with extra terms on the frame of the plain term, with kind B parts on adjacent frames, and with parts that a last call brings onto one frame.", + "blocked_by": "Nothing but size: 20,643,840 free elements at 4 address bits before any symmetry is used." + }, + { + "question": "Is the kind A rule a theorem at every number of address bits?", + "why_it_matters": "A proof by hand would replace the sample at 4 address bits and would say what a shared call can do at every block size.", + "first_step": "Show that a part whose two terms sit on different frames is never finishable by the call alone; the same-frame half is a statement about invertible elements of a group algebra.", + "blocked_by": "None." + }, + { + "question": "Why are exactly those 128 kind B parts removable?", + "why_it_matters": "The 128 are exactly the parts for which some call carries the plain term onto the frame of the extra term and the extra term onto the frame of the plain term, on all 9,984 cases, but I have no proof; a proof would complete the picture for two-term parts.", + "first_step": "Prove that such a call removes the part when the coefficient is +1 or -1.", + "blocked_by": "None." + } + ] +} diff --git a/research/complex-m3-shared-call-finish-or-remove/VERIFY.json b/research/complex-m3-shared-call-finish-or-remove/VERIFY.json new file mode 100644 index 0000000000..1087c3495c --- /dev/null +++ b/research/complex-m3-shared-call-finish-or-remove/VERIFY.json @@ -0,0 +1,75 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [], + "commands": [ + { + "argv": [ + "{python}", + "-B", + "{package}/verify.py", + "--part", + "controls" + ], + "timeout_seconds": 60, + "checks": "Standard library, about 3 s and under 30 MB, no file read or written. The exact solver finds the plain third call for each of the 32 calls that raise the plain middle term to level 3 and refuses a target two calls away; exact rational arithmetic and arithmetic modulo 2^61 - 1 give the same answers on 92 seeded cases; three wrong variants of the kind A rule are each rejected on 22 seeded cases; with coefficient -1 no same-frame part is finishable on 24 seeded cases. Prints PASS_COMPLEX_M3_SHARED_CALL_CONTROLS." + }, + { + "argv": [ + "{python}", + "-B", + "{package}/verify.py", + "--part", + "main" + ], + "timeout_seconds": 240, + "checks": "About 38 s and under 30 MB. Frame game at 3 address bits: 10,752 free elements, 56 paid calls; 32 of them raise the plain middle term to level 3; 4 undo the shared call and 48 could be the other array's last call. For both kinds of two-term part with coefficient 1 and every free element (reduced to 1,632 classes by the 8 free elements that commute with both calls): kind A 9,983 tested, 769 plain in disguise, 128 finishable by the call alone, 639 removable by a call that could be a last call, 1,407 removable by any call that does not undo the shared call; kind B 9,984, 768, 0, 128, 128; no case is both. The kind A rule matches every tested case: same frame with g of odd order finishable, same frame with g of even order removable (by all 52 calls tried), adjacent frames removable only by the 4 calls that cannot be a last call, further apart neither. The 128 removable kind B parts, and the 768 adjacent-frame kind A parts, are exactly the parts for which some call exchanges the frames of the two terms. The reduction to classes is tested directly on 80 cases that were not representatives. Prints PASS_COMPLEX_M3_SHARED_CALL_MAIN." + }, + { + "argv": [ + "{python}", + "-B", + "{package}/verify.py", + "--part", + "poststep" + ], + "timeout_seconds": 60, + "checks": "About 4 s. Kind A parts with frames further apart that are finished by one call followed by a free step on its output: a call t that raises the plain term M to level 3 with t.E = h.t.M, h free and 1 + c.h invertible; the identity (1 + c.h)^-1.(t.y) = t.M is checked term by term in exact arithmetic. 128 parts for c = 1 (h of order 3), 0 for c = -1, 512 for c = 2 and 512 for c = 1/2; by the rule checked in the other parts none of them is finishable by the call alone or removable. Whether this list is complete is not checked here. Prints PASS_COMPLEX_M3_SHARED_CALL_POSTSTEP." + }, + { + "argv": [ + "{python}", + "-B", + "{package}/verify.py", + "--part", + "symmetry" + ], + "timeout_seconds": 240, + "checks": "About 42 s. The free elements carry the first call to each of the 56 paid calls; 48 shared calls give a level-2 term and the 768 symmetries of the question carry one of them to each of the others; the whole table is recomputed for a second shared call (w = 10) with the same counts and the same rule; the symmetry map is tested case by case on 368 distinct cases, with a symmetry that does not commute with the first call, among them all 128 removable kind B parts. Prints PASS_COMPLEX_M3_SHARED_CALL_SYMMETRY." + }, + { + "argv": [ + "{python}", + "-B", + "{package}/verify.py", + "--part", + "coefficients" + ], + "timeout_seconds": 360, + "checks": "About 85 s. All tested cases for five more rows. Kind A with coefficient -1: none finishable by the call alone, 767 removable by a call that could be a last call, 1,535 by any call that does not undo the shared call. Kind A with 2 and with 1/2: the 767 same-frame cases finishable, none removable. The kind A rule with a coefficient matches every case. Kind B with -1: none finishable, the same 128 parts removable as with coefficient 1. Kind B with 2: none either way. None is both in any row. Prints PASS_COMPLEX_M3_SHARED_CALL_COEFFICIENTS." + }, + { + "argv": [ + "{python}", + "-B", + "{package}/verify.py", + "--part", + "spare" + ], + "timeout_seconds": 240, + "checks": "About 22 s. One spare address bit (4 address bits, 240 paid calls): a seeded sample of 100 kind A parts with coefficient 1 (20 same frame with g of even order, 20 adjacent frames, 20 same frame with g of odd order, 40 further apart); the rule found at 3 address bits is right on every sampled case and none is both. A sample, not a complete table. Prints PASS_COMPLEX_M3_SHARED_CALL_SPARE." + } + ] +} diff --git a/research/complex-m3-shared-call-finish-or-remove/verify.py b/research/complex-m3-shared-call-finish-or-remove/verify.py new file mode 100644 index 0000000000..09932bb001 --- /dev/null +++ b/research/complex-m3-shared-call-finish-or-remove/verify.py @@ -0,0 +1,823 @@ +#!/usr/bin/env python3 +"""verify.py -- one shared call at three directions: two-term parts finish or remove, not both. + +Standard library only, exact rational arithmetic. Reads no file and writes no file. + + python3 -B verify.py --part controls the solver and the rule are not vacuous; modular arithmetic agrees + python3 -B verify.py --part main the complete table at 3 address bits and the rule that describes it + python3 -B verify.py --part poststep the parts that one more call and a free step after it can finish + python3 -B verify.py --part symmetry one first call and one shared call up to symmetry; a second shared + call gives the same table + python3 -B verify.py --part coefficients other coefficients: kind A with -1, 2 and 1/2, kind B with -1 and 2 + python3 -B verify.py --part spare the rule on a seeded sample with one spare address bit (4 bits) + python3 -B verify.py --part full (slow, not registered) every case one at a time, with no symmetry + reduction; --quarter 0..3 runs one quarter of it + +THE GAME (the frame game: the engine game with its Pauli part dropped; README section 3). +Labels are the vectors of F_2^(2m), written x | z << m, with the symplectic form = x_u.z_v + z_u.x_v. +A term is an element g of Sp(2m, 2), stored as the images of the 2m basis labels; products act from right to left. +An array is a rational combination of terms. L is the set of labels with x = 0 (the raw frame). The FREE elements +are the g that map L to L (address maps and phases). A PAID call is a transvection t_u : v -> v + u with u +outside L. Free steps multiply an array on the left by any rational combination of free elements, and add arrays. +A paid call multiplies one array on the left by one t_u. A free image of a term h is p.h with p free. The frame of +a term g is g^-1(L); two frames are adjacent when they meet in dimension m - 1. The level of g is +m - dim(g^-1(L) meet L), its distance from the raw frame. + +THE QUESTION (README section 4). One input's part y of a shared array, after its first call D0 and the shared +call t_w. M = t_w.D0 is the plain middle term; the part has one extra term E, with coefficient c: + kind A y = t_w.(1 + c.gamma).D0 E = t_w.gamma.D0 (a free image of the first-call term went in too) + kind B y = t_w.(D0 + c.gamma) E = t_w.gamma (a free image of the raw input went in too) +with gamma free. The same input also has v = 1 (the raw input) and a = D0 (its first-call term). + FINISHABLE BY THE CALL ALONE: for some paid t that raises M to level 3, the term t.M is a free combination of + v, a, y plus t applied to a free combination of v, a, y. (No free combination is applied to the + output of t itself; --part poststep treats that.) + REMOVABLE: for some paid t, t.y is a free combination of v, a, y, plus t applied to free combinations of + v and a, plus other free images t.p.y (p free, p != 1) of the same call. A call t with t.t_w free + only undoes the shared call and is not tried. The program reports two counts: removable by a call + that could be a last call (t.t_w at level 2, so t can raise a middle term to level 3), and + removable by any call that is tried. +A case is "plain in disguise" and is set aside when y has one term or none, or E is a free image of v or of a. +""" +import argparse +import random +import sys +import time +from fractions import Fraction + +PRIME = (1 << 61) - 1 # used only by a control; every result is computed in exact rational arithmetic + + +def parity(x): + return bin(x).count("1") & 1 + + +class Game: + def __init__(self, m): + self.m = m + self.n = 1 << m + self.mask = self.n - 1 + self.I = tuple(1 << j for j in range(2 * m)) + self.L = frozenset(z << m for z in range(self.n)) + self._free = None + + def form(self, u, v): + m, k = self.m, self.mask + return parity((u & k) & (v >> m)) ^ parity((u >> m) & (v & k)) + + def apply(self, g, v): + out, j = 0, 0 + while v: + if v & 1: + out ^= g[j] + v >>= 1 + j += 1 + return out + + def mul(self, h, g): + """h after g: the term g multiplied on the left by h""" + ap = self.apply + return tuple(ap(h, x) for x in g) + + def inv(self, g): + tab = [0] * (1 << (2 * self.m)) + for v in range(1 << (2 * self.m)): + tab[self.apply(g, v)] = v + return tuple(tab[1 << j] for j in range(2 * self.m)) + + def transv(self, u): + return tuple((v ^ u) if self.form(v, u) else v for v in self.I) + + def is_symplectic(self, g): + I = self.I + return all(self.form(g[i], g[j]) == self.form(I[i], I[j]) for i in range(2 * self.m) for j in range(2 * self.m)) + + def is_free(self, g): + k = self.mask + return all((g[j] & k) == 0 for j in range(self.m, 2 * self.m)) + + def image_of_L(self, g): + return frozenset(self.apply(g, x) for x in self.L) + + def frame(self, g): + """g^-1(L)""" + return self.image_of_L(self.inv(g)) + + def level(self, g): + """m - dim(g^-1(L) meet L)""" + c = len(self.frame(g) & self.L) + return self.m - (c.bit_length() - 1) + + def order(self, g): + x, k = g, 1 + while x != self.I: + x = self.mul(g, x) + k += 1 + return k + + def free_generators(self): + m = self.m + gens = [self.transv(z << m) for z in range(1, self.n)] # phases + for i in range(m): + for j in range(m): + if i != j: # address map: bit i added into bit j + g = list(self.I) + g[i] ^= 1 << j + g[m + j] ^= 1 << (m + i) + gens.append(tuple(g)) + for g in gens: + assert self.is_symplectic(g) and self.is_free(g) + return gens + + def free_group(self): + if self._free is None: + gens = self.free_generators() + seen = {self.I} + todo = [self.I] + while todo: + g = todo.pop() + for h in gens: + x = self.mul(h, g) + if x not in seen: + seen.add(x) + todo.append(x) + self._free = sorted(seen) + return self._free + + def paid_calls(self): + return [self.transv(u) for u in range(1, 1 << (2 * self.m)) if u & self.mask] + + +def left(G, h, arr): + out = {} + for g, c in arr.items(): + k = G.mul(h, g) + c2 = out.get(k, 0) + c + if c2: + out[k] = c2 + else: + out.pop(k, None) + return out + + +def in_span(G, target, free_gens, paid_gens, prime=None, exclude=frozenset(), max_cols=3000): + """Is the array `target` in sum_R Q[P].R + sum_(t,R) t.Q[P].R (P = the free elements)? + + free_gens: list of arrays R. paid_gens: list of (t, R). Arrays are dicts {term: integer coefficient}. + exclude: set of (index into paid_gens, p) naming columns t.p.R that may not be used (R with two or more terms). + Returns (answer, number of columns): answer True or False, or None if more than max_cols columns were needed. + + A generator with ONE term h gives every free image of h: every term g with g.h^-1 free (or t.g.h^-1 free for + a paid generator) is such a column by itself, so those terms are dropped everywhere. For a generator with + several terms, a column p.R or t.p.R can only help if one of its terms is a term that still has to be + cancelled, and that fixes p; so the columns are found by following terms from the target, and the columns + never reached share no term with it. The elimination is in exact rational arithmetic (prime=None), or + modulo `prime` when one is given (a control only).""" + mul, inv, is_free = G.mul, G.inv, G.is_free + single = [] # (t or None, h^-1) + multi = [] # (index in paid_gens or -1, t or None, R, [(h^-1, c)]) + for R in free_gens: + if len(R) == 1: + single.append((None, inv(next(iter(R))))) + elif R: + multi.append((-1, None, R, [inv(h) for h in R])) + for i, (t, R) in enumerate(paid_gens): + if len(R) == 1: + single.append((t, inv(next(iter(R))))) + elif R: + multi.append((i, t, R, [inv(h) for h in R])) + cache = {} + + def is_free_image(g): + r = cache.get(g) + if r is None: + r = False + for t, hi in single: + x = mul(g, hi) + if is_free(x if t is None else mul(t, x)): + r = True + break + cache[g] = r + return r + + if prime is None: + def num(c): + return Fraction(c) + + def recip(c): + return 1 / c + else: + def num(c): + return c % prime + + def recip(c): + return pow(c, prime - 2, prime) + + def project(arr): + return {g: num(c) for g, c in arr.items() if not is_free_image(g)} + + tvec = project(target) + if not tvec: + return True, 0 + cols = {} + done = set() + frontier = list(tvec) + while frontier: + nxt = [] + for g in frontier: + if g in done: + continue + done.add(g) + for gi, (pi, t, R, invs) in enumerate(multi): + for hi in invs: + p = mul(g, hi) if t is None else mul(t, mul(g, hi)) + if not is_free(p): + continue + key = (gi, p) + if key in cols or (pi, p) in exclude: + continue + col = left(G, p, R) + if t is not None: + col = left(G, t, col) + vec = project(col) + cols[key] = vec + nxt.extend(k for k in vec if k not in done) + if len(cols) > max_cols: + return None, len(cols) + frontier = nxt + pivots = {} + basis = [] + + def reduce(vec): + while True: + best = None + for k in vec: + i = pivots.get(k) + if i is not None and (best is None or i < best): + best = i + if best is None: + return vec + pk, bv = basis[best] + f = vec[pk] + for k, x in bv.items(): + nv = num(vec.get(k, 0) - f * x) + if nv: + vec[k] = nv + else: + vec.pop(k, None) + + for vec in cols.values(): + r = reduce(dict(vec)) + if r: + pk = next(iter(r)) + f = recip(r[pk]) + pivots[pk] = len(basis) + basis.append((pk, {k: num(x * f) for k, x in r.items()})) + return (not reduce(dict(tvec))), len(cols) + + +class Setting: + """a first call D0 = t_(X0), a shared call t_w, and everything fixed by them""" + + def __init__(self, m, w, prime=None): + G = self.G = Game(m) + self.w = w + self.prime = prime + self.D0 = G.transv(1) + self.tw = G.transv(w) + self.main = G.mul(self.tw, self.D0) + assert G.level(self.D0) == 1 and G.level(self.main) == 2 + self.v = {G.I: 1} + self.a = {self.D0: 1} + self.paid = G.paid_calls() + self.lifting = [t for t in self.paid if G.level(G.mul(t, self.main)) == 3] + lev = [G.level(G.mul(t, self.tw)) for t in self.paid] + self.undo = frozenset(i for i, x in enumerate(lev) if x == 0) # t.t_w free: t undoes the shared call + self.last = frozenset(i for i, x in enumerate(lev) if x == 2) # t can raise a middle term to level 3 + assert len(self.undo) + len(self.last) + sum(1 for x in lev if x == 1) == len(self.paid) + self.main_inv = G.inv(self.main) + self.main_frame = G.frame(self.main) + self.tests = 0 + + def part(self, kind, gamma, coef=1): + G = self.G + second = G.mul(self.tw, G.mul(gamma, self.D0)) if kind == "A" else G.mul(self.tw, gamma) + y = {self.main: 1} + c = y.get(second, 0) + coef + if c: + y[second] = c + else: + y.pop(second, None) + return y, second + + def skipped(self, y, second): + """plain in disguise""" + G = self.G + return len(y) < 2 or G.is_free(second) or G.is_free(G.mul(second, self.D0)) + + def finishable(self, y): + """by the call alone""" + G = self.G + for t in self.lifting: + self.tests += 1 + ans, _ = in_span(G, {G.mul(t, self.main): 1}, [self.v, self.a, y], + [(t, self.v), (t, self.a), (t, y)], self.prime) + assert ans is not None + if ans: + return True + return False + + def removing_calls(self, y): + """the calls that pass the removal test, as indices into self.paid""" + G = self.G + assert len(y) >= 2 # in_span ignores `exclude` for a generator with one term + out = [] + for i, t in enumerate(self.paid): + if i in self.undo: # a call that only undoes the shared call is not tried + continue + self.tests += 1 + ans, _ = in_span(G, left(G, t, y), [self.v, self.a, y], [(t, self.v), (t, self.a), (t, y)], + self.prime, exclude=frozenset({(2, G.I)})) + assert ans is not None + if ans: + out.append(i) + return out + + def answers(self, y): + """(finishable by the call alone, removable by a possible last call, removable by any call tried, + number of calls that remove)""" + calls = self.removing_calls(y) + return self.finishable(y), any(i in self.last for i in calls), bool(calls), len(calls) + + # ---- the rule + def frames(self, kind, gamma): + """how the frame of the extra term E sits to the frame of the plain middle term M: + ('same', order of the free element g with E = g.M), ('adjacent', 0) or ('apart', 0)""" + G = self.G + second = G.mul(self.tw, G.mul(gamma, self.D0)) if kind == "A" else G.mul(self.tw, gamma) + k = len(G.frame(second) & self.main_frame) + if k == len(self.main_frame): + g = G.mul(second, self.main_inv) + assert G.is_free(g) + return "same", G.order(g) + return ("adjacent" if 2 * k == len(self.main_frame) else "apart"), 0 + + def rule_A(self, gamma, coef=1): + """(finishable by the call alone, removable by a possible last call, removable by any call tried) + predicted for the kind A part t_w.(1 + coef.gamma).D0. + On the same frame the part is (1 + coef.g).M with g free, and 1 + coef.g is invertible in the group + algebra exactly when (-coef)^(order of g) is not 1.""" + k, o = self.frames("A", gamma) + if k == "same": + unit = (-Fraction(coef)) ** o != 1 + return (unit and o > 1), (not unit), (not unit) + return False, False, (k == "adjacent" and abs(coef) == 1) + + def swapped(self, kind, gamma): + """some paid call carries M onto the frame of E and E onto the frame of M""" + G = self.G + y, second = self.part(kind, gamma) + inv2 = G.inv(second) + return any(G.is_free(G.mul(G.mul(t, self.main), inv2)) and G.is_free(G.mul(G.mul(t, second), self.main_inv)) + for t in self.paid) + + def symmetries(self): + """the free s with s* = D0.s.D0 free. Right multiplication of every term by s* keeps the free images of + v and of a, and maps the question for (t_w, gamma) onto the question for (t_(s^-1 w), gamma'), where + gamma' = s^-1.gamma.s for kind A and gamma' = s^-1.gamma.s* for kind B (README section 5)""" + G = self.G + return [s for s in G.free_group() if G.is_free(G.mul(self.D0, G.mul(s, self.D0)))] + + def centraliser(self): + G = self.G + return [s for s in G.free_group() if G.mul(s, self.D0) == G.mul(self.D0, s) + and G.mul(s, self.tw) == G.mul(self.tw, s)] + + +def conjugacy_orbits(S): + """orbits of gamma -> s^-1.gamma.s over the free s that commute with D0 and t_w. Such an s has s* = s, so + right multiplication of every term by it maps the question for gamma onto the question for s^-1.gamma.s, + for both kinds (README section 5).""" + G = S.G + C = S.centraliser() + Cinv = [G.inv(s) for s in C] + rep = {} + orbits = {} + for g in G.free_group(): + if g in rep: + continue + orb = {G.mul(si, G.mul(g, s)) for s, si in zip(C, Cinv)} + r = min(orb) + for x in orb: + rep[x] = r + orbits[r] = sorted(orb) + return C, orbits + + +def counts(tab): + """(tested, finishable by the call alone, removable by a possible last call, removable by any call, both)""" + return (len(tab), sum(f for f, rl, ra, n in tab.values()), sum(rl for f, rl, ra, n in tab.values()), + sum(ra for f, rl, ra, n in tab.values()), sum(f and ra for f, rl, ra, n in tab.values())) + + +def table(S, kind, orbits=None, show=True, coef=1): + """the table for one kind of part: {gamma: answers} for every gamma that is not plain in disguise""" + G = S.G + out = {} + skipped = 0 + items = orbits.items() if orbits is not None else ((g, [g]) for g in G.free_group()) + for r, orb in items: + y, second = S.part(kind, r, coef) + if S.skipped(y, second): + for x in orb: + y2, s2 = S.part(kind, x, coef) + assert S.skipped(y2, s2) + skipped += len(orb) + continue + res = S.answers(y) + for x in orb: + out[x] = res + if show: + n, f, rl, ra, both = counts(out) + print(f" kind {kind} tested {n:5d} plain in disguise {skipped:4d} finishable by the call alone {f:4d} " + f"removable by a possible last call {rl:4d}, by any call {ra:5d} both {both}") + return out, skipped + + +# tested, plain in disguise, finishable by the call alone, removable by a possible last call, removable by any call +EXPECT = {"A": (9983, 769, 128, 639, 1407), "B": (9984, 768, 0, 128, 128)} + + +def check_tables(S, use_orbits): + G = S.G + P = G.free_group() + assert len(P) == 10752 and len(S.paid) == 56 and len(S.lifting) == 32 + assert len(S.undo) == 4 and len(S.last) == 48 + orbits = None + if use_orbits: + C, orbits = conjugacy_orbits(S) + print(f" shared call t_w, w = {S.w}: {len(C)} free elements commute with both calls; " + f"{len(orbits)} classes of gamma") + by, orders = {}, {} + for g in P: + k, o = S.frames("A", g) + key = k if k != "same" else ("same frame, E = M" if o == 1 else + "same frame, odd order" if o % 2 else "same frame, even order") + by[key] = by.get(key, 0) + 1 + if k == "same": + orders[o] = orders.get(o, 0) + 1 + assert by == {"same frame, E = M": 1, "same frame, odd order": 128, "same frame, even order": 639, + "adjacent": 768, "apart": 9216}, by + assert orders == {1: 1, 2: 127, 3: 128, 4: 384, 6: 128}, orders + print(f" kind A, frames of the two terms: {by}") + print(f" kind A, same frame: orders of g {dict(sorted(orders.items()))}") + tabs = {} + for kind in ("A", "B"): + tab, skipped = table(S, kind, orbits) + tabs[kind] = tab + n, f, rl, ra, both = counts(tab) + assert (n, skipped, f, rl, ra) == EXPECT[kind], (kind, n, skipped, f, rl, ra) + assert both == 0, "a case is both finishable and removable" + # the rule for kind A, exactly; and which calls remove + for g, (f, rl, ra, n) in tabs["A"].items(): + assert (f, rl, ra) == S.rule_A(g) + k = S.frames("A", g)[0] + if ra: + assert n == (52 if k == "same" else 4) and rl == (k == "same") + assert S.swapped("A", g) == (k == "adjacent") + for g in P: + if g not in tabs["A"]: + assert g == G.I or S.frames("A", g)[0] == "apart" + print(" kind A: finishable by the call alone = same frame with g of odd order (128); removable by a possible" + " last call = same frame with g of even order (639, by every one of the 52 calls tried); the 768" + " adjacent-frame parts are removable only by the 4 calls with t.t_w at level 1, which cannot be a last" + " call, and they are exactly the parts for which some call carries M onto the frame of E and E onto the" + " frame of M; the rule matches all 9,983 cases; none is both") + # kind B: what is known + rel, rem = {}, {} + for g, (f, rl, ra, n) in tabs["B"].items(): + k = S.frames("B", g)[0] + rel[k] = rel.get(k, 0) + 1 + if ra: + rem[k] = rem.get(k, 0) + 1 + assert rl == ra == S.swapped("B", g) + assert rel == {"adjacent": 1536, "apart": 8448} and rem == {"adjacent": 128}, (rel, rem) + print(" kind B: none finishable; 128 removable, each by a possible last call, all among the 1,536 cases with" + " adjacent frames, and exactly the cases where some call carries M onto the frame of E and E onto the" + " frame of M; none is both") + print(f" [{S.tests} span tests, exact rational arithmetic]") + return tabs, orbits + + +def part_main(): + t0 = time.time() + print("3 address bits: two-term parts of kinds A and B of one shared array (10,752 free gamma for each kind)") + S = Setting(3, 2) + tabs, orbits = check_tables(S, True) + # the symmetry reduction, tested directly on cases that were not representatives + rng = random.Random(1002) + others = [g for r, orb in orbits.items() for g in orb if g != r] + n = 0 + for kind in ("A", "B"): + sample = [g for g in rng.sample(others, 60) if g in tabs[kind]][:40] + for g in sample: + y, _ = S.part(kind, g) + assert S.answers(y) == tabs[kind][g] + n += 1 + print(f" the reduction to classes was tested directly on {n} cases that were not representatives " + f"[{time.time() - t0:.0f} s]") + print("PASS_COMPLEX_M3_SHARED_CALL_MAIN") + + +def part_poststep(): + """kind A parts finished by one more call followed by a free step on its output. + If a call t raises M to level 3 and puts t.E among the free images of t.M (t.E = h.t.M with h free), then + t.y = (1 + c.h).t.M, and when 1 + c.h is invertible, (1 + c.h)^-1 applied to the call's output is the single + third-level term t.M. The inverse is sum_j (-c)^j h^j / (1 - (-c)^n) for h of order n.""" + t0 = time.time() + S = Setting(3, 2) + G = S.G + print("3 address bits, kind A: parts finished by one more call and a free step applied to its output") + expect = {1: 128, -1: 0, 2: 512, Fraction(1, 2): 512} + for c in (1, -1, 2, Fraction(1, 2)): + c = Fraction(c) + found, orders = 0, {} + for g in G.free_group(): + y, second = S.part("A", g, c) + if S.skipped(y, second) or S.frames("A", g)[0] == "same": + continue + rel = G.mul(second, S.main_inv) # E.M^-1 + for t in S.lifting: + h = G.mul(t, G.mul(rel, t)) # t.E.(t.M)^-1 + if not G.is_free(h): + continue + n = G.order(h) + if (-c) ** n == 1: + continue + out, hp, ty = {}, G.I, left(G, t, y) + for j in range(n): + for term, x in left(G, hp, ty).items(): + out[term] = out.get(term, 0) + (-c) ** j / (1 - (-c) ** n) * x + hp = G.mul(h, hp) + assert {k: x for k, x in out.items() if x} == {G.mul(t, S.main): 1} + # frames apart, and by the rule neither finishable by the call alone nor removable + assert S.frames("A", g)[0] == "apart" and S.rule_A(g, c) == (False, False, False) + found += 1 + orders[n] = orders.get(n, 0) + 1 + break + assert found == expect[c], (c, found) + assert c != 1 or set(orders) <= {3} + print(f" c = {c}: {found} parts with frames apart are finished by one call and one free step after it" + f" (orders of h: {dict(sorted(orders.items()))})") + print(f" each identity (1 + c.h)^-1.(t.y) = t.M is checked term by term; by the rule checked in the other" + f" parts, none of these parts is finishable by the call alone or removable [{time.time() - t0:.0f} s]") + print("PASS_COMPLEX_M3_SHARED_CALL_POSTSTEP") + + +def part_full(quarters=(0, 1, 2, 3)): + """every gamma one at a time: kind A against the rule (which fixes the whole kind A table), kind B counted""" + t0 = time.time() + S = Setting(3, 2) + G = S.G + P = G.free_group() + print(f"3 address bits, no symmetry reduction: quarters {list(quarters)} (gamma number i is in quarter i mod 4)") + tot = {"A": [0] * 5, "B": [0] * 5} # tested, plain in disguise, finishable, removable (last), removable (any) + for k in quarters: + row = {"A": [0] * 5, "B": [0] * 5} + for g in P[k::4]: + for kind in ("A", "B"): + y, second = S.part(kind, g) + if S.skipped(y, second): + row[kind][1] += 1 + continue + f, rl, ra, n = S.answers(y) + assert not (f and ra), "a case is both finishable and removable" + if kind == "A": + assert (f, rl, ra) == S.rule_A(g) + else: + assert not f and rl == ra and (not ra or S.frames("B", g)[0] == "adjacent") + row[kind][0] += 1 + row[kind][2] += f + row[kind][3] += rl + row[kind][4] += ra + for kind in ("A", "B"): + r = row[kind] + print(f" quarter {k}: kind {kind} tested {r[0]:5d} plain in disguise {r[1]:4d} finishable {r[2]:4d} " + f"removable by a possible last call {r[3]:4d}, by any call {r[4]:5d} both 0 " + f"[{time.time() - t0:.0f} s]") + tot[kind] = [x + y for x, y in zip(tot[kind], r)] + if tuple(quarters) == (0, 1, 2, 3): + assert tuple(tot["A"]) == EXPECT["A"] and tuple(tot["B"]) == EXPECT["B"], tot + print(" totals as in the main table; every kind A case matches the rule; none is both") + print("PASS_COMPLEX_M3_SHARED_CALL_FULL") + else: + print(" every kind A case of these quarters matches the rule; none is both") + print(f"PASS_COMPLEX_M3_SHARED_CALL_FULL_QUARTER_{'_'.join(str(k) for k in quarters)}") + + +def part_symmetry(): + t0 = time.time() + G = Game(3) + labels = [u for u in range(1, 1 << 6) if u & G.mask] + # 1. the free elements move the first call to every other paid call + orb, todo, gens = {1}, [1], G.free_generators() + while todo: + u = todo.pop() + for h in gens: + x = G.apply(h, u) + if x not in orb: + orb.add(x) + todo.append(x) + assert sorted(orb) == labels and len(labels) == 56 + print(" the free elements carry the first call to each of the 56 paid calls") + # 2. the shared calls that give a level-2 term form one class under the symmetries of the question + S = Setting(3, 2) + mids = [w for w in labels if G.level(G.mul(G.transv(w), S.D0)) == 2] + sym = S.symmetries() + reach = {2} + for s in sym: + reach.add(G.apply(G.inv(s), 2)) + assert len(mids) == 48 and len(sym) == 768 and sorted(reach) == mids + print(" 48 shared calls give a level-2 term; the 768 symmetries carry w = 2 to each of them") + # 3. a second shared call: the same counts and the same rule + print(" the table again for the shared call w = 10:") + S10 = Setting(3, 10) + tabs10, _ = check_tables(S10, True) + # 4. the symmetry itself, case by case: gamma at w = 2 against gamma' at w = 10 + cands = [s for s in sym if G.apply(G.inv(s), 2) == 10] + s = next(s for s in cands if G.mul(s, S.D0) != G.mul(S.D0, s)) # one that does not commute with D0 + si = G.inv(s) + sstar_inv = G.mul(S.D0, G.mul(si, S.D0)) + assert len(cands) == 16 and G.is_free(sstar_inv) and sstar_inv != si + rng = random.Random(1010) + n = 0 + for kind in ("A", "B"): + keys = sorted(tabs10[kind]) + chosen = [g for g in keys if tabs10[kind][g][2]] if kind == "B" else [] + have = set(chosen) + chosen += rng.sample([g for g in keys if g not in have], 120) + for g10 in chosen: + g2 = G.mul(s, G.mul(g10, si if kind == "A" else sstar_inv)) + y, second = S.part(kind, g2) + assert not S.skipped(y, second) + assert S.answers(y) == tabs10[kind][g10] + n += 1 + print(f" the symmetry was tested case by case on {n} distinct cases, among them all 128 removable kind B parts " + f"[{time.time() - t0:.0f} s]") + print("PASS_COMPLEX_M3_SHARED_CALL_SYMMETRY") + + +def part_coefficients(): + t0 = time.time() + print("3 address bits, other coefficients c of the extra term") + half = Fraction(1, 2) + # finishable by the call alone, removable by a possible last call, removable by any call + expect = {("A", -1): (0, 767, 1535), ("A", 2): (767, 0, 0), ("A", half): (767, 0, 0), + ("B", -1): (0, 128, 128), ("B", 2): (0, 0, 0)} + S = Setting(3, 2) + C, orbits = conjugacy_orbits(S) + for (kind, c), want in expect.items(): + print(f" c = {c}:") + tab, skipped = table(S, kind, orbits, coef=c) + n, f, rl, ra, both = counts(tab) + assert (n, skipped) == EXPECT[kind][:2] and (f, rl, ra) == want and both == 0, (kind, c, n, skipped, f, rl, ra) + if kind == "A": + assert all(res[:3] == S.rule_A(g, c) for g, res in tab.items()) + elif c == -1: + # the same parts as for c = 1 (--part main checks that test for c = 1) + assert all(res[2] == S.swapped("B", g) for g, res in tab.items()) + print(" kind A: the rule with a coefficient matches every case. c = -1: nothing is finishable, the 767" + " same-frame cases are removable by a possible last call. c = 2 and c = 1/2: the 767 same-frame cases are" + " finishable by the call alone and nothing is removable") + print(f" kind B: c = -1 as c = 1 (none finishable, the same 128 parts removable); c = 2: nothing either way;" + f" none is both in any row [{time.time() - t0:.0f} s]") + print("PASS_COMPLEX_M3_SHARED_CALL_COEFFICIENTS") + + +def part_spare(sizes=(20, 20, 20, 40), seed=2026): + t0 = time.time() + S = Setting(4, 2) + G = S.G + rng = random.Random(seed) + gens = G.free_generators() + names = ["same frame, even order", "adjacent frames", "same frame, odd order", "frames apart"] + want = dict(zip(names, sizes)) + pool = {k: [] for k in names} + seen = set() + drawn = 0 + while any(len(pool[k]) < want[k] for k in names): + g = G.I + for _ in range(40): + g = G.mul(rng.choice(gens), g) + drawn += 1 + if g in seen or g == G.I: + continue + seen.add(g) + y, second = S.part("A", g) + if S.skipped(y, second): + continue + k, o = S.frames("A", g) + name = ("same frame, even order" if o % 2 == 0 else "same frame, odd order") if k == "same" else \ + ("adjacent frames" if k == "adjacent" else "frames apart") + if len(pool[name]) < want[name]: + pool[name].append(g) + print(f"4 address bits (one spare), kind A, shared call w = 2: {drawn} random free elements drawn, seed {seed}; " + f"{len(S.paid)} paid calls, {len(S.lifting)} of them raise the plain middle term to level 3, " + f"{len(S.last)} could be a last call") + bad = 0 + for name in names: + fin = reml = rema = 0 + for g in pool[name]: + y, _ = S.part("A", g) + f, rl, ra, n = S.answers(y) + fin += f + reml += rl + rema += ra + bad += (f, rl, ra) != S.rule_A(g) or (f and ra) + print(f" {name:24s} sampled {len(pool[name]):3d} finishable by the call alone {fin:3d} " + f"removable by a possible last call {reml:3d}, by any call {rema:3d}") + assert bad == 0, bad + print(f" the rule found at 3 address bits is right on all {sum(sizes)} sampled cases; none is both " + f"[{S.tests} span tests, {time.time() - t0:.0f} s]") + print("PASS_COMPLEX_M3_SHARED_CALL_SPARE") + + +def part_controls(): + t0 = time.time() + S = Setting(3, 2) + G = S.G + P = G.free_group() + # 1. the solver finds the plain last call and refuses a missing one + plain = {S.main: 1} + T = [G.mul(t, S.main) for t in S.lifting] + assert all(in_span(G, {G.mul(t, S.main): 1}, [S.v, S.a, plain], [(t, S.v), (t, S.a), (t, plain)])[0] + for t in S.lifting) + assert not any(in_span(G, {x: 1}, [S.v, S.a], [(t, S.v), (t, S.a)])[0] for x in T[:8] for t in S.paid) + print(" the solver finds the plain third call and refuses a target two calls away") + # 2. arithmetic modulo a large prime gives the same answers on a seeded sample from every class + rng = random.Random(7) + S2 = Setting(3, 2, PRIME) + groups = {} + for g in P: + k, o = S.frames("A", g) + groups.setdefault((k, o % 2 if k == "same" else 0), []).append(g) + n = 0 + for key in sorted(groups): + for g in rng.sample(groups[key], min(12, len(groups[key]))): + for kind in ("A", "B"): + y, second = S.part(kind, g) + if S.skipped(y, second): + continue + r1 = S.answers(y) + assert r1 == S2.answers(y) + if kind == "A": + assert r1[:3] == S.rule_A(g) + n += 1 + print(f" exact arithmetic and arithmetic modulo 2^61 - 1 give the same answers on {n} seeded cases") + # 3. the rule is not vacuous: each wrong variant fails on some sampled case + cases = [] + for key in sorted(groups): + for g in rng.sample(groups[key], min(6, len(groups[key]))): + y, second = S.part("A", g) + if not S.skipped(y, second): + cases.append((g, S.answers(y)[:3])) + + def variant(name, g): + k, o = S.frames("A", g) + same = k == "same" + odd, even = same and o % 2 == 1 and o > 1, same and o % 2 == 0 + if name == "parities swapped": + return even, odd, odd or k == "adjacent" + if name == "adjacent frames removable by a last call": + return odd, even or k == "adjacent", even or k == "adjacent" + if name == "frames apart removable": + return odd, even, not odd + for name in ("parities swapped", "adjacent frames removable by a last call", "frames apart removable"): + assert any(variant(name, g) != res for g, res in cases), name + assert all(S.rule_A(g) == res for g, res in cases) + print(f" three wrong variants of the rule are each rejected on {len(cases)} seeded cases") + # 4. coefficient -1 never finishes (1 - g is never invertible), on a seeded sample of same-frame cases + same = [g for g in P if S.frames("A", g)[0] == "same" and g != G.I] + m = 0 + for g in rng.sample(same, 24): + y, second = S.part("A", g, coef=-1) + if not S.skipped(y, second): + assert not S.finishable(y) + m += 1 + print(f" with coefficient -1 no same-frame part is finishable ({m} seeded cases) [{time.time() - t0:.0f} s]") + print("PASS_COMPLEX_M3_SHARED_CALL_CONTROLS") + + +if __name__ == "__main__": + if not __debug__: + sys.exit("verify.py checks with assert statements: run it without -O") + ap = argparse.ArgumentParser() + ap.add_argument("--part", choices=["controls", "main", "poststep", "symmetry", "coefficients", "spare", "full"], + required=True) + ap.add_argument("--quarter", type=int, choices=[0, 1, 2, 3], help="full only: one quarter of the cases") + args = ap.parse_args() + if args.part == "full": + part_full((0, 1, 2, 3) if args.quarter is None else (args.quarter,)) + else: + {"controls": part_controls, "main": part_main, "poststep": part_poststep, "symmetry": part_symmetry, + "coefficients": part_coefficients, "spare": part_spare}[args.part]() + sys.exit(0)