diff --git a/research/kind-b-last-call-obstruction/PROOF.md b/research/kind-b-last-call-obstruction/PROOF.md new file mode 100644 index 0000000000..fd87cb6164 --- /dev/null +++ b/research/kind-b-last-call-obstruction/PROOF.md @@ -0,0 +1,101 @@ +# A kind B part cannot finish by one last call alone + +## Statement and model + +Work in the formal group algebra `Q[G]`, where `G=Sp(2m,2)` and `m>=3`. Write labels as `(x,z)` and let the raw Lagrangian be `L={x=0}`. Let `P=Stab_G(L)`. Free combinations act on the left and lie in `Q[P]`. A paid call is a symplectic transvection with normal outside L. Calls are involutions. Products act right to left. + +The frame of a term g is `g^-1 L`. Its level is `ell(g)=m-dim(L intersection g^-1 L)`. Two terms have the same frame exactly when `g h^-1` is in P. Level is invariant under left and right multiplication by P. It is also unchanged under inversion. We can therefore compute level as the dimension of the horizontal image `X(gL)`, where X projects `(x,z)` to x. + +Let D,W,T be first, shared and final calls, and suppose `ell(TWD)=3`. Set + +```text +M = WD, E = W gamma, y = M+cE, +gamma in P, c in Q with c != 0, E not in PD, +U = span_Q {p, pD, py : p in P}. +``` + +The nonplain condition `E not in PD` excludes a free image of the first-call output. E has level one, so it is already outside P. The finishing condition in [Jacob Sussman's PR #7629](https://github.com/CrocSwap/integer-mult-bounds/pull/7629) is `TM in U+TU`. This allows free preparation of the last call and free additions of earlier arrays to its output. It permits no free map on the output itself and no access to another last-call output. + +**Theorem.** Under these hypotheses, `TM` is not in `U+TU`, at every address width and every nonzero rational c. + +The source checked this nonfinishability at three address bits and three coefficients. This proof includes arbitrary spare address bits and all nonzero rational coefficients. It does not exclude a general two-in-five program, post-call free processing, joint decoding, extra terms, or phase-sensitive engine programs. There is no new kappa. + +## A horizontal-plane fact + +For a call with normal u, write d=X(u). Acting on L, the call produces horizontal component `d*(d dot z)`. If two calls have linearly independent horizontal normals d,w, their product maps L to a subspace whose horizontal image is exactly `span(d,w)`. The two coefficients are independent linear forms: applying the second call and then the first makes a triangular change to `d dot z` and `w dot z`. No condition on the vertical parts or commutation of the calls is needed. + +Let d,w,t be the horizontal normals of D,W,T. The horizontal image of `TWD L` is contained in `span(d,w,t)`. The level-three hypothesis thus makes d,w,t linearly independent. In particular `ell(M)=ell(TW)=2`. If gamma is free, it has block form `[[A,0],[C,A^(-T)]]`, with A invertible, and sends every horizontal image V to AV. + +We will use one consequence. If `ell(D gamma D)=1`, then `A d=d`. Indeed `D gamma D` has the same image of L as the two calls `D` and `gamma D gamma^-1`. Their horizontal normals are d and Ad. If they were distinct, they would be independent over F2 and the preceding fact would give level two. + +## The first two forced coordinates + +Write `g0=TM` and `g1=TE`. Their levels are three and two. The available singleton columns have support in `P,PD,TP,TPD`; their levels are at most two. The available binomial columns are `py` and `Tpy` for p in P. + +The only column touching g0 is `Ty=g0+c g1`. Old first endpoints pM have level two and old second endpoints pE have level one. A paid first endpoint equals g0 only for p=1. A paid second endpoint equals g0 only if `M E^-1` is free, which would give M and E the same level. + +At g1, earlier singletons in P or PD are excluded by level. Membership in TP would make E free. Membership in TPD would put E in PD, contrary to the nonplain condition. An old second endpoint has level one. A paid first endpoint at g1 would require `E M^-1` free. The paid second endpoint at g1 again comes only from Ty. + +There is one possible additional column: an old first endpoint at g1 exists exactly when + +```text +q = TE M^-1 is in P. +``` + +If q is not free, define a linear functional on the formal basis by `lambda(g0)=c`, `lambda(g1)=-1`, and zero elsewhere. It kills every available column but takes the nonzero value c on the target. This proves the theorem in that case. + +## The third coordinate cannot be cancelled + +Suppose q is free. Put `g2=qE` and `a=E M^-1`. Then `q=Ta`, g2 has level one, and `qy=g1+c g2` is the sole new column at g1. We show that no further column touches g2. + +An old first endpoint has level two, and the only old second endpoint at g2 is qE itself. A paid second endpoint at g2 would require `Tq=a` free, which is impossible since M and E have different levels. A paid first endpoint at g2 would require `a^2` free. In that case `T a^-1=q a^-2` would be free. This is `TM E^-1`, which would make the level-three target TM have the same frame as level-one E. Thus that paid endpoint is absent. + +No singleton in P or PD can equal g2: its level is one, q is free, and E is not in PD. For a singleton in TP, we would need + +```text +Tg2 = aE = W gamma D gamma in P. +``` + +Right multiplication by the free gamma inverse would put `W gamma D=ED` in P, again contrary to the nonplain condition. + +It remains to exclude TPD. Suppose `Tg2 D=W gamma D gamma D` were free. Its action on L would give + +```text +D gamma D L = gamma^-1 W L. +``` + +The right side has level one. The horizontal-plane fact therefore gives `Ad=d`. On the other hand q is free, and `q=T W gamma D W`. Its action on L gives + +```text +gamma D W L = W T L, +A span(d,w) = span(w,t). +``` + +The left plane contains Ad=d. The right plane cannot contain d because d,w,t are independent. This is a contradiction. It excludes the last possible singleton at g2. + +Consequently the only columns incident to `{g0,g1,g2}` are `g0+c g1` and `g1+c g2`. Define + +```text +lambda(g0)=c^2, lambda(g1)=-c, lambda(g2)=1, +lambda(g)=0 for every other formal term g. +``` + +Both columns have value zero. Every other available column has disjoint support, so it also has value zero. But the target has value `c^2`, which is nonzero. This proves the theorem. The two- and three-coordinate functionals are explicit separating certificates; the proof does not depend on an orbit size or enumeration of P. + +## Exact checks + +The checker uses binary row matrices. It constructs all 10752 elements of the three-bit parabolic group from all invertible A and symmetric S, with lower block `A^(-T) S`. Every matrix is unique and satisfies the symplectic identity. The nonplain condition excludes 768 elements. It tests every one of the 32 final calls that raises `WD` to level three for each of the remaining 9984 elements. This covers 319488 part/call pairs for the fixed first and shared calls D and W with horizontal normals 1 and 2. + +For each pair the checker enumerates every possible old or paid column incident to each selected coordinate, and all four singleton families. It verifies the separating functional as a polynomial in c. Thus these finite certificates cover every nonzero rational coefficient, not just a sampled list. There are 315392 two-coordinate certificates and 4096 three-coordinate certificates. The universal width and arbitrary-call statement follows from the written proof, not from this normal-form census. + +A separate check constructs the whole right-multiplication orbit through TM with step `M^-1 E`. Every binomial stays within such an orbit. It retains every available singleton and binomial in that orbit and solves the rational span problem for the singleton target. Eighty contracts cover both certificate types, five coefficients, widths three through six, and free conjugations that mix the core with spare coordinates. The longest tested orbit has length four. These are selected checks, not a complete wider-width census. + +Another 240 checks vary all three call directions and the free map at widths four through six. All have the required independent horizontal directions; 115 have noncommuting first and shared calls. These sampled cases all use the two-coordinate separator. They complement the wider three-coordinate examples above. + +Five nonzero coefficients on a plain extra term give positive finishing controls. A zero coefficient and a final call that fails the level-three premise also give positive controls. Deleting the third weight from a three-coordinate separator is rejected. Two rational-elimination controls check a small full-rank and a deficient system. [Receipt and examples](RESULT.json) · [Verifier](verify.py) + +## Credit and limits + +Prepared by Ali Romman with substantial OpenAI Codex assistance. Jacob Sussman supplied the model, the finite kind B nonfinishability observation and the source boundaries in [PR #7629](https://github.com/CrocSwap/integer-mult-bounds/pull/7629), [exact source](https://github.com/jacobalansussman/integer-mult-bounds/blob/c2a2131e7dba35f9396b16588e125a7e8b5fab8e/research/complex-m3-shared-call-finish-or-remove/README.md). Nick Petalas's [kind A finishing proof](https://github.com/petalas/integer-mult-bounds/blob/f642d2740265a61f8ac64b3a087f0118382c56e3/research/kind-a-last-call-coset/README.md) in [PR #7649](https://github.com/CrocSwap/integer-mult-bounds/pull/7649) supplies a related coset method. The [kind B removal proof](https://github.com/aliromman/integer-mult-bounds/blob/7c3b229d0788d6e980f75cbaabe07287899263a2/research/kind-b-frame-swap-removal/PROOF.md) in [PR #7679](https://github.com/CrocSwap/integer-mult-bounds/pull/7679) supplies the related endpoint method. Its binary matrix and rational-span routines are reused here; the finishing separator, horizontal-plane proof and census are new. No source file is read at run time. New work is Apache-2.0. + +The finite source already observed zero finishable parts for its tested coefficients. The new result is the proof at all widths and all nonzero rational coefficients. It remains a theorem about formal terms with Pauli phases removed. No paid native word, physical decoder, precision bound, restoration protocol, complete invoice or selected-assumption discharge follows. The selected frontier and its five assumptions remain unchanged. Independent human and formal-kernel review are unclaimed. diff --git a/research/kind-b-last-call-obstruction/README.md b/research/kind-b-last-call-obstruction/README.md new file mode 100644 index 0000000000..05229af17a --- /dev/null +++ b/research/kind-b-last-call-obstruction/README.md @@ -0,0 +1,35 @@ +# Prove the all-width kind B finishing obstruction + +A nonplain kind B shared-call part `y=WD+cW gamma` cannot be finished by one last call alone at any address width or any nonzero rational coefficient. The final call must raise `WD` to level three. The proof supplies an explicit linear functional on two or three formal group terms that kills every available column and is nonzero on the target. + +This upgrades the finite kind B observation in [PR #7629](https://github.com/CrocSwap/integer-mult-bounds/pull/7629). It covers spare address bits. It does not exclude post-call free processing, joint use of both last outputs, three-term parts or a general two-in-five program. It is separate from the removal theorem in [PR #7679](https://github.com/CrocSwap/integer-mult-bounds/pull/7679). No new kappa is claimed. + +[Proof and exact hypotheses](PROOF.md) · [Receipt and representative matrices](RESULT.json) · [Verifier](verify.py) · [Task and open questions](TASK.json) + +## Reproduce + +Use CPython 3.12 and the standard library. No external runtime input is needed. + +```sh +python3.12 -I -W error -B research/kind-b-last-call-obstruction/verify.py +python3.12 -I -W error -B -O research/kind-b-last-call-obstruction/verify.py +python3.12 -B scripts/research_package.py --package research/kind-b-last-call-obstruction +``` + +Expected status: `PASS_KIND_B_LAST_CALL_OBSTRUCTION`. The verifier checks all 319488 nonplain three-bit part/call pairs for fixed first/shared calls. Polynomial separating certificates cover all nonzero rational coefficients on those pairs. Eighty full rational orbit-span checks and 240 varied-direction checks cover selected wider instances. Plain, zero-coefficient and lower-target-level cases give positive controls. A corrupt separator and two small linear-system checks test the proof and elimination boundaries. Each registered command has a 120-second limit. + +The all-width conclusion follows from the written horizontal-plane and forced-coordinate proof. The finite census is not an exhaustive check of larger widths or arbitrary programs. The original scientific suite, selected cold replay, Lean and Docker were not run. No independent human or formal-kernel review is claimed. + +## Task and next questions + +Base: canonical main `e54523517d0f03e58352e647c403a5af3e525a57`, priority revision 8, card `complex-rank-shape-decoder` narrowed to one formal finishing obstruction. The [advance claim](https://github.com/CrocSwap/integer-mult-bounds/discussions/1166#discussioncomment-19704095) names that scope. The current priorities permit a scoped local result; no physical construction is proposed because a source-compatible native decoder and complete invoice remain absent. Open/closed PR and Discussion overlap contains the finite source and the distinct kind A and removal results. Sparse local and unpublished work remain coverage limits. + +## Open next questions + +Can a free map on the last-call output finish a nonplain kind B part? First add those output terms to the column family and check exactly where the two- or three-coordinate separator fails. The present theorem does not include those columns. + +Can both last-call outputs be used together without losing either target? First put both input parts and both last-output families in one formal system with shared preparations explicit. One-part finishability does not decide that joint problem. A Pauli-phase lift and a complete physical invoice would then be separate requirements. [Structured questions](TASK.json) + +## Credit + +Prepared by Ali Romman with substantial OpenAI Codex assistance. Credit Jacob Sussman for the definitions and finite kind B observation in [PR #7629](https://github.com/CrocSwap/integer-mult-bounds/pull/7629), [pinned source](https://github.com/jacobalansussman/integer-mult-bounds/blob/c2a2131e7dba35f9396b16588e125a7e8b5fab8e/research/complex-m3-shared-call-finish-or-remove/README.md); Nick Petalas for the related coset proof in [PR #7649](https://github.com/CrocSwap/integer-mult-bounds/pull/7649), [pinned proof](https://github.com/petalas/integer-mult-bounds/blob/f642d2740265a61f8ac64b3a087f0118382c56e3/research/kind-a-last-call-coset/README.md); and the endpoint method and reused arithmetic routines in Ali Romman's [PR #7679](https://github.com/CrocSwap/integer-mult-bounds/pull/7679), [pinned verifier](https://github.com/aliromman/integer-mult-bounds/blob/7c3b229d0788d6e980f75cbaabe07287899263a2/research/kind-b-frame-swap-removal/verify.py). The source retains the original frame-geometry lineage. New work is Apache-2.0. diff --git a/research/kind-b-last-call-obstruction/RESULT.json b/research/kind-b-last-call-obstruction/RESULT.json new file mode 100644 index 0000000000..f99a429212 --- /dev/null +++ b/research/kind-b-last-call-obstruction/RESULT.json @@ -0,0 +1,51 @@ +{ + "status": "PASS_KIND_B_LAST_CALL_OBSTRUCTION", + "census": { + "nonplain_elements": 9984, + "support_2_pairs": 315392, + "support_3_pairs": 4096, + "plain_elements_excluded": 768, + "free_elements": 10752, + "finishing_calls": 32, + "part_call_pairs": 319488 + }, + "separators": { + "2": { + "gamma_rows": [ + 1, + 2, + 4, + 8, + 16, + 32 + ], + "last_normal": 4 + }, + "3": { + "gamma_rows": [ + 1, + 2, + 5, + 40, + 16, + 32 + ], + "last_normal": 5 + } + }, + "wider": { + "full_orbit_contracts": 80, + "maximum_orbit_length": 4, + "varied_support_2": 240, + "varied_direction_contracts": 240, + "noncommuting_first_shared": 115 + }, + "controls": { + "plain_positive_coefficients": 5, + "zero_coefficient_positive": 1, + "lower_target_level_positive": 1, + "corrupt_separator_rejected": 1, + "span_controls": 2 + }, + "scope": "Nonplain kind B, every nonzero rational coefficient, level-three final target; no post-call free step or joint output decoder." +} diff --git a/research/kind-b-last-call-obstruction/SOURCES.json b/research/kind-b-last-call-obstruction/SOURCES.json new file mode 100644 index 0000000000..5335fa97d9 --- /dev/null +++ b/research/kind-b-last-call-obstruction/SOURCES.json @@ -0,0 +1,18 @@ +{ + "schema_version": 1, + "base_commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "files": [ + { + "path": "certificates/selected-result.json", + "usage": "provenance", + "git_blob": "75d77b328ea02ded535e7f23aee5b1e55d0bb1a8", + "sha256": "154c3d30455d778fd3343b6b4851f0fa4665f0f7625b0adb3675e2bafbbf6bf1" + }, + { + "path": "docs/research/agent-task-catalog.json", + "usage": "provenance", + "git_blob": "3404fbdd5e7529a0674eef26114b5071e4586cec", + "sha256": "ead6cdc9d0af6d58e8a49744d8ec8c7c15e13d2ba93c276c434bcf9b51b93a81" + } + ] +} diff --git a/research/kind-b-last-call-obstruction/TASK.json b/research/kind-b-last-call-obstruction/TASK.json new file mode 100644 index 0000000000..759bef6a50 --- /dev/null +++ b/research/kind-b-last-call-obstruction/TASK.json @@ -0,0 +1,81 @@ +{ + "schema_version": 1, + "task_id": "complex-rank-shape-decoder", + "priority_revision": 8, + "base_commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "original_card": { + "id": "complex-rank-shape-decoder", + "question": "Can a legal decoder or coframe change improve the full signed moment, including changed helper targets?", + "starting_points": [ + "docs/research/current-priorities.md", + "docs/research/research-family-status.md", + "certificates/selected-result.json", + "docs/research/pr-intake-evidence/pr5599-completion/PROOF-REVIEW.md", + "docs/research/recursive-invoice-preflight.md" + ], + "methods": [ + "Construct and independently check one source-bound instance of the stated first experiment.", + "Seek an exact counterexample or target-specific complete-budget obstruction to that same proposed change." + ], + "acceptance_gate": "A source-bound arbitrary-input identity and legal producer/consumer boundary with the complete paid and productive target invoice, including restoration, ownership, native alignment and extra charges. Price under the actual current model; historical ceiling.py assumptions must be established before use. A favorable optimistic relaxation keeps a route open but is not a completed supplier. A scoped local result remains useful; expansion requires the family-level budget gate.", + "first_step": { + "command": [ + "python3", + "-B", + "scripts/research_selected_baseline.py" + ], + "expected": "PASS_RESEARCH_BASELINE_BINDINGS_ONLY", + "inspect": "Read revision 8, the selected review and live exact-source handoffs. Then follow this card's bounded first_experiment.", + "scope": "Source-bound orientation only, not a supplier replay or theorem proof." + }, + "first_experiment": "Price one complete changed itinerary with both paid and productive histograms. Check #5693/#5698 for overlap and their exact hypotheses before another coframe search. Use the signed invoice preflight where its boundary contract agrees; an inconclusive concave comparison is not a power crossing. Stop if an optimistic complete budget fails at the chosen target or native delivery remains unspecified.", + "bottleneck_link": "Judge the actual current supplier contract and complete signed target/paid bill; frozen-profile ceilings require an applicability proof.", + "allowed_variations": [ + "One exact source head, helper/cut region or quantified proposition and changed hypothesis; check live handoffs first. Different seeds are not different scopes." + ], + "scope_change_triggers": [ + "Changing source head, helper/cut domain, operation alphabet or caller boundary without recording the new scope.", + "Treating an archived proposal or local numerical pass as complete supplier admission." + ], + "overlap_terms": [ + "coframe", + "signed moment", + "5693", + "5698" + ], + "existing_checks": [ + { + "scope": "Selected PR5599: complete helper-subspace construction and independent caller replay; five framework assumptions remain.", + "evidence": "docs/research/pr-intake-evidence/pr5599-completion/PROOF-REVIEW.md", + "remaining": "The next experiment must identify uncovered source-specific work. Successor archive intake does not transfer this admission.", + "status": "reviewed", + "source_commit": "09dd0965711ca7eeb169057a420abab1c9052137", + "selected_record_sha256": "2a0220e866417774606e0f991e41b9c1d26b1f43b97857238cf478dbc7d330b5" + } + ] + }, + "scope_status": "refined", + "actual_scope": "Prove that a nonplain kind B part cannot finish by a single level-three last call, at every address width and every nonzero rational coefficient.", + "scope_change_reason": "The source proves only finite kind B nonfinishability. This package resolves that one formal obstruction with a proof and exact separating certificates, not a physical decoder.", + "bottleneck_link": "It closes a remaining single-call finishing route with arbitrary spare bits while leaving post-call processing and joint decoding explicit.", + "budget_minutes": 60, + "stop_rule": "Stop at the all-width proof and bounded exact checks. Do not infer a general two-in-five impossibility or a physical cost bound.", + "outcome": "completed", + "evidence": "PROOF.md; RESULT.json; 319488 complete incident-column certificates as polynomials in c, 80 exact orbit-span contracts, 240 varied wider cases and hypothesis/solver controls.", + "author": "Ali Romman", + "ai_assistance": "Substantial OpenAI Codex assistance; independent human and formal-kernel review unclaimed.", + "open_questions": [ + { + "question": "Can post-call free processing finish a nonplain kind B part?", + "why_it_matters": "Those extra columns are outside this separating certificate.", + "first_step": "Add the exact post-call family and identify which support coordinates it can reach.", + "blocked_by": "No characterization of that larger final-output family is supplied." + }, + { + "question": "Can both last outputs jointly decode both input parts?", + "why_it_matters": "Independent single-part failures do not exclude joint cancellation.", + "first_step": "Model both last-output families and their shared preparation coefficients in one formal system.", + "blocked_by": "The joint decoder, phase lift, native realization and complete invoice remain open." + } + ] +} diff --git a/research/kind-b-last-call-obstruction/VERIFY.json b/research/kind-b-last-call-obstruction/VERIFY.json new file mode 100644 index 0000000000..f1e3edea19 --- /dev/null +++ b/research/kind-b-last-call-obstruction/VERIFY.json @@ -0,0 +1,34 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [], + "commands": [ + { + "argv": [ + "{python}", + "-I", + "-W", + "error", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 120, + "checks": "Complete three-bit polynomial separators, wider full rational orbit spans, varied directions and positive/fault controls." + }, + { + "argv": [ + "{python}", + "-I", + "-W", + "error", + "-B", + "-O", + "{package}/verify.py" + ], + "timeout_seconds": 120, + "checks": "Complete three-bit polynomial separators, wider full rational orbit spans, varied directions and positive/fault controls." + } + ] +} diff --git a/research/kind-b-last-call-obstruction/verify.py b/research/kind-b-last-call-obstruction/verify.py new file mode 100644 index 0000000000..7185b933c9 --- /dev/null +++ b/research/kind-b-last-call-obstruction/verify.py @@ -0,0 +1,308 @@ +#!/usr/bin/env python3 +"""Check the all-width kind B finishing obstruction. + +Ali Romman, with substantial OpenAI Codex assistance. Apache-2.0. +""" +from collections import Counter +from fractions import Fraction +from random import Random +import json +from pathlib import Path + +ROOT = Path(__file__).resolve().parent +COEFFICIENTS = (Fraction(1), Fraction(-1), Fraction(2), Fraction(1, 2), Fraction(-2, 3)) + + +def need(ok, message): + if not ok: + raise ValueError(message) + + +def unit(n): + return tuple(1 << i for i in range(n)) + + +def mul(a, b): + rows = [] + for row in a: + value = 0 + while row: + bit = row & -row + value ^= b[bit.bit_length()-1] + row ^= bit + rows.append(value) + return tuple(rows) + + +def transpose(a): + return tuple(sum(((row >> j) & 1) << i for i, row in enumerate(a)) for j in range(len(a))) + + +def inv(a): + n = len(a) + rows = [row | (1 << (n+i)) for i, row in enumerate(a)] + for i in range(n): + j = next(j for j in range(i, n) if rows[j] & (1 << i)) + rows[i], rows[j] = rows[j], rows[i] + for j in range(n): + if j != i and rows[j] & (1 << i): + rows[j] ^= rows[i] + return tuple(row >> n for row in rows) + + +def rank2(rows): + pivots = {} + for row in rows: + while row: + i = row.bit_length()-1 + if i not in pivots: + pivots[i] = row + break + row ^= pivots[i] + return len(pivots) + + +def is_free(g): + m = len(g)//2 + return all(row >> m == 0 for row in g[:m]) + + +def level(g): + m = len(g)//2 + return rank2(row >> m for row in g[:m]) + + +def call(m, normal): + paired = ((normal & ((1 << m)-1)) << m) | (normal >> m) + return tuple((1 << i) ^ (paired if normal & (1 << i) else 0) for i in range(2*m)) + + +def all_free(m): + def bases(rows): + if len(rows) == m: + yield tuple(rows) + else: + for x in range(1, 1 << m): + if rank2([*rows, x]) > len(rows): + yield from bases([*rows, x]) + places = [(i, j) for i in range(m) for j in range(i, m)] + form = tuple(1 << ((i+m) % (2*m)) for i in range(2*m)) + result = [] + for a in bases([]): + b = transpose(inv(a)) + for mask in range(1 << len(places)): + s = [0]*m + for bit, (i, j) in enumerate(places): + if mask & (1 << bit): + s[i] |= 1 << j + s[j] |= 1 << i + lower = mul(b, s) + g = a + tuple(lower[i] | (b[i] << m) for i in range(m)) + need(is_free(g) and mul(mul(g, form), transpose(g)) == form, 'free symplectic matrix') + result.append(g) + need(len(result) == len(set(result)) == 10752, 'three-bit free group') + return result + + +def orbit(start, step): + points = [start] + point = mul(start, step) + while point != start: + need(point not in points, 'orbit closure') + points.append(point) + point = mul(point, step) + return points + + +def in_span(columns, target): + pivots = {} + for v in columns: + row = list(map(Fraction, v)) + for i in range(len(row)): + coefficient = row[i] + if coefficient == 0: + continue + if i in pivots: + row = [x-coefficient*y for x, y in zip(row, pivots[i], strict=True)] + else: + pivots[i] = [x/coefficient for x in row] + break + row = list(map(Fraction, target)) + for i, pivot in sorted(pivots.items()): + coefficient = row[i] + row = [x-coefficient*y for x, y in zip(row, pivot, strict=True)] + return all(x == 0 for x in row) + + +def singleton(g, first, last): + tg = mul(last, g) + return any(is_free(h) for h in (g, mul(g, first), tg, mul(tg, first))) + + +def separator(first, shared, last, gamma): + middle, extra = mul(shared, first), mul(shared, gamma) + need(is_free(gamma) and level(middle) == 2 and level(mul(last, middle)) == 3, 'finishing premises') + need(not is_free(mul(extra, first)), 'nonplain extra term') + mi, ei = inv(middle), inv(extra) + target, second = mul(last, middle), mul(last, extra) + q = mul(second, mi) + if is_free(q): + third = mul(q, extra) + weights = {target: (2, 1), second: (1, -1), third: (0, 1)} + expected = {(target, second), (second, third)} + else: + weights = {target: (1, 1), second: (0, -1)} + expected = {(target, second)} + need(len(weights) == len(expected)+1, 'distinct support') + columns = set() + for point in weights: + need(not singleton(point, first, last), 'singleton hits separator') + for paid in (False, True): + x = mul(last, point) if paid else point + for inverse in (mi, ei): + p = mul(x, inverse) + if is_free(p): + left = mul(last, p) if paid else p + columns.add((mul(left, middle), mul(left, extra))) + need(columns == expected, 'complete incident columns') + for a, b in columns: + polynomial = Counter() + for point, shift in ((a, 0), (b, 1)): + if point in weights: + exponent, coefficient = weights[point] + polynomial[exponent+shift] += coefficient + need(all(x == 0 for x in polynomial.values()), 'separator annihilates every column') + need(weights[target][1] == 1, 'nonzero target monomial') + return len(weights), weights, columns + + +def full_span(first, shared, last, gamma, coefficient): + middle, extra = mul(shared, first), mul(shared, gamma) + mi = inv(middle) + points = orbit(mul(last, middle), mul(mi, extra)) + n = len(points) + columns = [] + for j, point in enumerate(points): + if singleton(point, first, last): + row = [Fraction(0)]*n; row[j] = 1; columns.append(row) + old = is_free(mul(point, mi)) + paid = is_free(mul(mul(last, point), mi)) + if old or paid: + row = [Fraction(0)]*n; row[j] = 1; row[(j+1) % n] += coefficient; columns.append(row) + target = [Fraction(0)]*n; target[0] = 1 + return in_span(columns, target), n + + +def census(): + first, shared = call(3, 1), call(3, 2) + middle = mul(shared, first) + finishing = [(u, call(3, u)) for u in range(1, 64) if u & 7 and level(mul(call(3, u), middle)) == 3] + need(len(finishing) == 32, 'all finishing calls') + counts = Counter(); examples = {}; plain_example = None + for gamma in all_free(3): + extra = mul(shared, gamma) + if is_free(mul(extra, first)): + counts['plain_elements_excluded'] += 1 + plain_example = gamma + continue + counts['nonplain_elements'] += 1 + for normal, last in finishing: + size, _, _ = separator(first, shared, last, gamma) + counts[f'support_{size}_pairs'] += 1 + examples.setdefault(size, (gamma, normal)) + need(counts['plain_elements_excluded'] == 768 and counts['nonplain_elements'] == 9984, 'part inventory') + need(counts['support_2_pairs']+counts['support_3_pairs'] == 9984*32, 'complete pair inventory') + counts['free_elements'] = 10752 + counts['finishing_calls'] = 32 + counts['part_call_pairs'] = 9984*32 + return dict(counts), examples, plain_example + + +def embed(g, m): + positions = [0, 1, 2, m, m+1, m+2] + out = list(unit(2*m)) + for old, new in enumerate(positions): + out[new] = sum(((g[old] >> j) & 1) << positions[j] for j in range(6)) + return tuple(out) + + +def random_free(m, rng): + a = list(unit(m)) + for _ in range(8*m): + i, j = rng.sample(range(m), 2) + a[i] ^= a[j] + a = tuple(a); b = transpose(inv(a)); s = [0]*m + for i in range(m): + for j in range(i, m): + if rng.randrange(2): + s[i] ^= 1 << j + if i != j: + s[j] ^= 1 << i + lower = mul(b, s) + return a+tuple(lower[i] | (b[i] << m) for i in range(m)) + + +def wider(examples): + exact = Counter(); rng = Random(260018) + for m in (3, 4, 5, 6): + for gamma3, normal3 in examples.values(): + base = [embed(g, m) for g in (call(3, 1), call(3, 2), call(3, normal3), gamma3)] + for h in (unit(2*m), random_free(m, rng)): + hi = inv(h) + first, shared, last, gamma = [mul(mul(h, g), hi) for g in base] + separator(first, shared, last, gamma) + for c in COEFFICIENTS: + got, length = full_span(first, shared, last, gamma, c) + need(not got, 'full orbit obstruction') + exact['full_orbit_contracts'] += 1 + exact['maximum_orbit_length'] = max(exact['maximum_orbit_length'], length) + # These cases change all call directions and the free map, not only the width. + for m in (4, 5, 6): + for _ in range(80): + while True: + normals = [rng.randrange(1, 1 << (2*m)) for _ in range(3)] + if rank2(u & ((1 << m)-1) for u in normals) == 3: + break + first, shared, last = [call(m, u) for u in normals] + while True: + gamma = random_free(m, rng) + if not is_free(mul(mul(shared, gamma), first)): + break + size, _, _ = separator(first, shared, last, gamma) + exact[f'varied_support_{size}'] += 1 + exact['varied_direction_contracts'] += 1 + exact['noncommuting_first_shared'] += mul(first, shared) != mul(shared, first) + return dict(exact) + + +def controls(examples, plain): + first, shared, last = call(3, 1), call(3, 2), call(3, 4) + for c in COEFFICIENTS: + need(full_span(first, shared, last, plain, c)[0], 'plain extra must finish') + gamma, normal = examples[3] + final = call(3, normal) + need(full_span(first, shared, final, gamma, Fraction(0))[0], 'zero coefficient must finish') + need(full_span(first, shared, first, unit(6), Fraction(2))[0], 'lower-level call must finish control') + _, weights, columns = separator(first, shared, final, gamma) + third = next(g for g, value in weights.items() if value == (0, 1)) + corrupted = {g: Fraction(2)**power*sign for g, (power, sign) in weights.items() if g != third} + need(any(corrupted.get(a, 0)+2*corrupted.get(b, 0) for a, b in columns), 'missing tail weight must fail') + need(in_span([[1, 1], [1, 2]], [0, 1]), 'positive span control') + need(not in_span([[1, 1]], [1, 2]), 'negative span control') + return {'plain_positive_coefficients': len(COEFFICIENTS), 'zero_coefficient_positive': 1, + 'lower_target_level_positive': 1, 'corrupt_separator_rejected': 1, 'span_controls': 2} + + +def compute(): + counts, examples, plain = census() + return {'status': 'PASS_KIND_B_LAST_CALL_OBSTRUCTION', 'census': counts, + 'separators': {str(size): {'gamma_rows': list(gamma), 'last_normal': normal} + for size, (gamma, normal) in examples.items()}, + 'wider': wider(examples), 'controls': controls(examples, plain), + 'scope': 'Nonplain kind B, every nonzero rational coefficient, level-three final target; no post-call free step or joint output decoder.'} + + +if __name__ == '__main__': + result = compute() + need(json.loads((ROOT/'RESULT.json').read_text()) == result, 'retained result') + print(json.dumps(result, indent=2, sort_keys=True))