diff --git a/research/symplectic-binary-completion/README.md b/research/symplectic-binary-completion/README.md new file mode 100644 index 0000000000..a2b3259cfd --- /dev/null +++ b/research/symplectic-binary-completion/README.md @@ -0,0 +1,246 @@ +# Binary deficiency-two symplectic spread completion + +This contribution was produced by Nick Petalas. Independent human and formal +proof-kernel review are unclaimed. + +## Result and scope + +Claim type: scoped written mathematical proof, with exact finite corroboration. + +Let n >= 1, and let S consist of 2^n - 1 pairwise trivially intersecting +Lagrangian subspaces of a nondegenerate alternating 2n-dimensional F2-space. +A symplectic spread has 2^n + 1 members, so S has deficiency two. + +Let Gamma have the uncovered nonzero vectors as vertices. Over F2 these are +also the uncovered projective points. Two distinct vertices are adjacent +exactly when their symplectic pairing is one. Write A for the ordinary integer +adjacency matrix, and put + +$$ +N=2(2^n-1),\qquad k=2^{n-1},\qquad Q=kI_N+A. +$$ + +Then S extends to a full symplectic spread if and only if Q is singular over +the rationals. When Q is singular, Gamma is connected and bipartite, Q has +nullity one, and every nonzero rational kernel vector has two nonzero opposite +constant values. Its two sign classes are exactly the nonzero vectors of the +two missing Lagrangians. The unordered completion pair is unique. If Q is +nonsingular, it is positive definite over the reals and S has no completion. + +This answers Open next question 1 in Nick Petalas's +[odd-field spectral criterion, PR #5248](https://github.com/CrocSwap/integer-mult-bounds/pull/5248). +That theorem covers q >= 3 and leaves the binary case open because its graph +order argument fails there. Its proof and verifier are cited, not audited or +replayed. The new step here is a geometric component lemma using the span of a +color class. David Ganz's [atlas B098, PR #2849](https://github.com/CrocSwap/integer-mult-bounds/pull/2849) +supplies the original deficiency-two question and its deficiency-one predecessor. +The signless-Laplacian identity and basic symplectic dimension facts are +classical. Global literature priority is unclaimed. + +This is an algebraic side result, recorded as a changed scope of the +`formal-interface-lemma` card. It supplies a precise completion interface for +the atlas. It does not change a supplier, COPY bill, kappa or selected result, +and it does not prove a complete multiplication theorem. + +## Proof + +### Hole count and degree + +A Lagrangian has 2^n - 1 nonzero vectors. The old members have disjoint nonzero +sets, so the number of uncovered vectors is + +$$ +2^{2n}-1-(2^n-1)^2=2(2^n-1)=N. +$$ + +Fix a hole h. For each old Lagrangian L, the functional omega(h,-) on L is +nonzero. Otherwise h would belong to L-perp = L, contrary to being uncovered. +Thus exactly 2^(n-1) vectors of L pair to one with h. There are 2^(2n-1) vectors +in the whole ambient space pairing to one with h. Subtracting the old members +gives + +$$ +\deg_\Gamma(h)=2^{2n-1}-(2^n-1)2^{n-1}=2^{n-1}=k. +$$ + +Alternation excludes loops. Therefore Gamma is a simple k-regular graph with +k > 0. + +### The new geometric component lemma + +Suppose C is a connected bipartite component, with color classes X and Y. +Every vertex in X has k distinct neighbors in Y, and conversely, so both color +classes contain at least k = 2^(n-1) points. + +Points in X pair to zero with each other because there are no edges within a +color class. Their linear span L is isotropic and has dimension at most n. +An F2-subspace of dimension at most n - 1 has at most 2^(n-1) - 1 nonzero +vectors, fewer than |X|. Hence dim L = n and L is Lagrangian. + +Every hole outside C is orthogonal to every member of X, since an edge would +put it in C. It therefore lies in L-perp = L. All holes outside C consequently +pair to zero with one another. They have no edges to C either. Such a vertex +would have degree zero, contradicting k > 0. There are no holes outside C. + +Thus any bipartite component is the whole hole graph. This argument uses the +symplectic geometry rather than a bound on N/k. In the binary case N = 4k - 2, +which exceeds the earlier N <= 3k gate when n >= 3. + +### Spectral decision and recovery + +For every real vector z indexed by the holes, + +$$ +z^TQz=\sum_{\{u,v\}\in E(\Gamma)}(z_u+z_v)^2. +$$ + +Thus Q is positive semidefinite. Its kernel consists exactly of assignments +satisfying z_u = -z_v on each edge. On a connected component these assignments +are determined by one value. An odd cycle forces that value to zero, whereas +a bipartite component admits the opposite constants on its two color classes. +Consequently Q is singular if and only if at least one component is bipartite. + +The geometric lemma makes that component the whole graph. The kernel is +one-dimensional. Because Q has integer entries, its nonzero real kernel has a +nonzero rational vector. Its entries have equal nonzero magnitude and their +signs recover the unique bipartition X,Y, up to swapping the classes. + +Counting edges on either side gives k|X| = k|Y|, and hence + +$$ +|X|=|Y|=N/2=2^n-1. +$$ + +Each class is pairwise orthogonal and therefore spans an isotropic subspace. +Its cardinality forces that span to have dimension n and forces the class to +be its entire nonzero set. These two Lagrangians meet trivially because their +full nonzero sets are disjoint. They meet every old member trivially because +they contain only holes. Adding them completes S. + +Conversely, a completion partitions all holes into the nonzero sets of two +Lagrangians. There are no edges within either set, so Gamma is bipartite and +Q is singular. A connected bipartite graph has only one unordered bipartition, +which proves uniqueness of the completion pair. Nonsingularity of the positive +semidefinite Q gives positive definiteness and excludes a completion. + +## Exact finite evidence + +The standalone verifier constructs four binary models using F_(2^n)^2 and + +$$ +\omega((x,y),(x',y'))=\operatorname{Tr}_{F_{2^n}/F_2}(xy'+x'y). +$$ + +For n = 1,2,3,4, the field polynomials are respectively X+1, X^2+X+1, +X^3+X+1 and X^4+X+1. Multiplication permutations certify the finite field +models. The checker verifies alternation and nondegeneracy directly. It uses +the old Lagrangians y = ax for every nonzero a, omitting y = 0 and x = 0. +Every old member is checked for binary linear closure, isotropy and disjointness. + +Rational RREF and separate integer Bareiss elimination compute the kernel and +determinant. A second search enumerates every isotropic subspace whose full +nonzero set lies among the holes, without using the graph or its spectrum. +It enumerates every possible completion pair and compares it with sign recovery. + +| Ambient F2 dimension | Old members | Holes | Degree | Rank Q | det Q | Hole Lagrangians | Completion pairs | +|---|---:|---:|---:|---:|---:|---:|---:| +| 2 | 1 | 2 | 1 | 1 | 0 | 2 | 1 | +| 4 | 3 | 6 | 2 | 5 | 0 | 2 | 1 | +| 6 | 7 | 14 | 4 | 13 | 0 | 2 | 1 | +| 8 | 15 | 30 | 8 | 29 | 0 | 2 | 1 | + +The controls reject three invalid partial spreads: wrong deficiency, duplicated +members and a nonisotropic member. A separate abstract graph is K4,4 disjoint +from K6 with a perfect matching removed. It has N = 14 and k = 4, exactly the +binary n = 3 parameters, and a singular Q whose unique kernel has six zero +entries. Its bipartite component is not the whole graph. The new geometric +lemma excludes its realization as a valid hole graph. It is an abstract +control, not a symplectic counterexample. + +The connected 14-vertex circulant with steps +/-1 and +/-2 supplies a +nonbipartite spectral control. Its rational kernel is trivial and its integer +determinant is 49,760,288. No claim that this graph is a hole graph is made. +These controls distinguish generic regular-graph facts from the geometric +implication proved here. + +## Reproduction + +From the repository root, use CPython 3.12. No third-party packages, predecessor +verifier, subprocess or network is needed for the mathematical check. + +```sh +~/git/integer-mult-bounds/.venv/bin/python3.12 -W error -B research/symplectic-binary-completion/verify.py +~/git/integer-mult-bounds/.venv/bin/python3.12 -W error -O -B research/symplectic-binary-completion/verify.py +~/git/integer-mult-bounds/.venv/bin/python3.12 -B scripts/research_package.py --package research/symplectic-binary-completion +~/git/integer-mult-bounds/.venv/bin/python3.12 -B scripts/check_research_commit.py --package research/symplectic-binary-completion --check-source-history +``` + +The direct check prints `PASS_SYMPLECTIC_BINARY_COMPLETION` and the exact +fixture/control values above. Optional `--receipt /absolute/path/outside-checkout/receipt.json` +writes a generated receipt containing those results, the interpreter version +and SHA256 hashes of all five package files. Receipt paths inside the checkout +are rejected. No receipt is handwritten or committed. + +`SOURCES.json` pins the original card, selected-record context and both written +predecessors as provenance. The mathematical verifier neither imports nor +replays those predecessors. Hosted CI execution is recorded separately in the +PR body. Local CPython 3.12.15 normal and optimized checks pass, as do the +registered replay, syntax check and receipt-path rejection controls. The written +all-dimension proof is not machine checked. + +## Limits and implementation bounds + +The theorem covers q = 2 and every n >= 1. The executable controls cover only +the four specified punctured field spreads and the listed abstract/invalid +controls. They are not a classification of binary partial spreads. No valid +noncompletable binary deficiency-two fixture is supplied. In particular, this +criterion does not assert that every binary deficiency-two partial spread +completes. Larger deficiencies and nonisotropic partial spreads are outside scope. + +The linear algebra is over the rationals and integers, even though the geometry +is binary. Reducing Q modulo two is not the decision procedure. The algorithm +is polynomial in the explicit hole inventory, not in n. No proof-assistant +build, supplier replay or independent human proof review was run. The selected +construction's five framework assumptions are unaffected. + +The verifier has no recursion or dynamic code evaluation. Finite models have +at most 256 ambient vectors, 30 holes and 30-by-30 matrices. Span enumeration +is bounded by four rounds and a checked capacity of 4,096 stored subspaces; +each subspace has at most 16 vectors. All functions are under 60 physical lines. +Python and Fraction allocate dynamically, a managed-runtime deviation from +fixed allocation. Explicit finite input sizes bound this work. Runtime checks +remain enabled under optimized Python. The only indirect call is the bounded +invalid-input control callback. No shared source or validation policy is changed. + +## Open next questions + +1. Can the binary criterion be simplified to unconditional completion, or is + there a binary deficiency-two noncompletable example? This distinguishes a + recognition theorem from an existence theorem. Start with a literature-bound + construction or a bounded search at one specified n. A failed finite search + would not prove all-dimension completion; no such conclusion is claimed here. +2. At deficiency at least three, what geometric replacement for two-color + recovery can identify the missing Lagrangians? Begin with the hole degree + and one literal deficiency-three fixture. The signless kernel argument here + only recognizes two color classes and does not settle that question. + +## Provenance and overlap + +Base: `de5ec2e7a6074068452f45b1a191b5c72832df4a`, priority revision 8. +The [advance CLAIM](https://github.com/CrocSwap/integer-mult-bounds/discussions/1166#discussioncomment-19213513) +records the binary question and source pins. The selected-baseline command was +run after materializing its omitted sparse inputs. It authenticates metadata, +not the selected mathematics. + +Live open PRs, recent account PRs, handoffs, active Discussions, local question +reservations, targeted merged searches and main-tree README searches were +checked before claiming. The `formal-interface-lemma` overlap report includes +remote pagination and explicitly incomplete sparse local-note coverage. +The same-account predecessor #5248 was published October 23, outside the last +24 hours. None of its mathematical checks was rerun. No global novelty or +exhaustive unpublished-work coverage is claimed. + +Credit David Ganz for atlas B098 and the deficiency-two proposal, and Nick +Petalas for #5248's odd-field criterion and explicit binary question. The new +geometric component argument and binary extension are the contribution here. +All predecessor files and credit lines remain unchanged. Apache-2.0. diff --git a/research/symplectic-binary-completion/SOURCES.json b/research/symplectic-binary-completion/SOURCES.json new file mode 100644 index 0000000000..1a31ca8873 --- /dev/null +++ b/research/symplectic-binary-completion/SOURCES.json @@ -0,0 +1,30 @@ +{ + "schema_version": 1, + "base_commit": "de5ec2e7a6074068452f45b1a191b5c72832df4a", + "files": [ + { + "path": "certificates/selected-result.json", + "usage": "provenance", + "git_blob": "581f8d87008354eb5b869f7ed9de1317ad837ce8", + "sha256": "2a0220e866417774606e0f991e41b9c1d26b1f43b97857238cf478dbc7d330b5" + }, + { + "path": "docs/research/agent-task-catalog.json", + "usage": "provenance", + "git_blob": "3404fbdd5e7529a0674eef26114b5071e4586cec", + "sha256": "ead6cdc9d0af6d58e8a49744d8ec8c7c15e13d2ba93c276c434bcf9b51b93a81" + }, + { + "path": "research/pure-math-atlas-400/volumes/02-geometry.md", + "usage": "provenance", + "git_blob": "baef1e69c08c7cbd4dfd020862870fa5161afc86", + "sha256": "39fc97bdfa29337b79d1308e35df41e867ce2102d44755fd407aa09ff8352b39" + }, + { + "path": "research/symplectic-deficiency-two-spectral/README.md", + "usage": "provenance", + "git_blob": "0de39befd926911522462f8209221fe95c432757", + "sha256": "6c03ec34d9d58d97e12ba56b9c19063888e75ec09fccf1fa7b031f18c905c9d8" + } + ] +} diff --git a/research/symplectic-binary-completion/TASK.json b/research/symplectic-binary-completion/TASK.json new file mode 100644 index 0000000000..44135945d6 --- /dev/null +++ b/research/symplectic-binary-completion/TASK.json @@ -0,0 +1,102 @@ +{ + "schema_version": 1, + "task_id": "formal-interface-lemma", + "priority_revision": 8, + "base_commit": "de5ec2e7a6074068452f45b1a191b5c72832df4a", + "original_card": { + "id": "formal-interface-lemma", + "question": "Can one uncovered interface implication be formalized with exact caller and certificate bindings?", + "starting_points": [ + "docs/research/research-family-status.md", + "certificates/selected-result.json", + "research/gate-operand-parity-lean/README.md", + "research/staged544-certified-endpoint/README.md", + "research/unconditional-batched-crt/README.md" + ], + "methods": [ + "Formalize a missing boundary lemma identified by the selected review.", + "Audit a formal theorem-to-certificate binding independently." + ], + "acceptance_gate": "State the exact formalized proposition and remaining assumptions; avoid duplicate arithmetic formalizations already present.", + "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": "Write one missing statement with quantified hypotheses, actual caller and existing coverage. A compact-switch lemma is a candidate only after its mathematical contract is reviewed. Establish a bounded proof plan before a separately budgeted proof-assistant build; do not rerun large Lean jobs as orientation.", + "bottleneck_link": "A missing interface proof can reduce the conditional gap even if it does not change kappa.", + "allowed_variations": [ + "Narrow to one formal lemma or one theorem-to-certificate binding." + ], + "scope_change_triggers": [ + "Formalizing already-covered arithmetic and claiming the full multiplication theorem." + ], + "overlap_terms": [ + "hyperplane end", + "formal interface", + "Lean binding", + "3807", + "3857", + "4100", + "gate-operand-parity-lean", + "staged544-certified-endpoint", + "unconditional-batched-crt" + ], + "existing_checks": [ + { + "scope": "PR #3807: scoped gate-operand parity formalization.", + "evidence": "research/gate-operand-parity-lean/README.md", + "remaining": "Exact theorem-to-caller binding and genuinely uncovered interface lemmas.", + "status": "author-checked", + "source_commit": "4c3530f42a6abcc48e7a6bcffd6c901911dc8269", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + }, + { + "scope": "PR #3857: certified real-power moment/endpoint arithmetic.", + "evidence": "research/staged544-certified-endpoint/README.md", + "remaining": "Uniform algorithmic implications, not another endpoint digit.", + "status": "author-checked", + "source_commit": "ef4315b8caa605e47a2515004845eb2d2ed71a86", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + }, + { + "scope": "PR #4100: compact-switch formalization proposed as future validation.", + "evidence": "research/unconditional-batched-crt/README.md", + "remaining": "Audit the statement and assumptions before a formal proof campaign.", + "status": "author-checked", + "source_commit": "337d04939571a637aeab54a0f58f54fde811663a", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + } + ] + }, + "scope_status": "changed", + "actual_scope": "Prove the exact rational signless-Laplacian completion criterion for binary deficiency-two symplectic partial spreads in every dimension.", + "scope_change_reason": "The assignment requires an original result rather than an audit. This takes the explicit binary open question in PR5248, building on David Ganz atlas B098, as an algebraic side result rather than a selected-supplier formalization.", + "bottleneck_link": "Algebraic side result for the atlas completion interface. No supplier, kappa or selected-frontier improvement is claimed.", + "budget_minutes": 60, + "stop_rule": "Package the first proved binary extension; do not extend it to higher deficiency or a classification.", + "outcome": "completed", + "evidence": "Written all-dimension proof and standalone exact controls for n=1,2,3,4; unique sign recovery independently compared with exhaustive hole-subspace completion search; invalid-input and abstract spectral controls.", + "author": "Nick Petalas", + "ai_assistance": "Independent human and formal proof-kernel review are unclaimed.", + "open_questions": [ + { + "question": "Does every binary deficiency-two symplectic partial spread complete, or is there a nonsingular-Q example?", + "why_it_matters": "Distinguishes recognition from unconditional existence.", + "first_step": "Locate a source-bound example or search a single specified binary dimension.", + "blocked_by": "No all-dimension existence argument or valid negative fixture is supplied." + }, + { + "question": "Can a geometric invariant recover missing Lagrangians at deficiency at least three?", + "why_it_matters": "The two-color kernel criterion addresses only deficiency two.", + "first_step": "Derive the hole degree and test one literal deficiency-three fixture.", + "blocked_by": "No higher-color recovery implication is proved here." + } + ], + "claim_url": "https://github.com/CrocSwap/integer-mult-bounds/discussions/1166#discussioncomment-19213513" +} diff --git a/research/symplectic-binary-completion/VERIFY.json b/research/symplectic-binary-completion/VERIFY.json new file mode 100644 index 0000000000..2f16077bd0 --- /dev/null +++ b/research/symplectic-binary-completion/VERIFY.json @@ -0,0 +1,32 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [], + "commands": [ + { + "argv": [ + "{python}", + "-W", + "error", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 60, + "checks": "Exact binary field/spread/degree/kernel/recovery controls in dimensions 2,4,6,8; exhaustive hole-subspace completions; three invalid spreads and two abstract graph controls." + }, + { + "argv": [ + "{python}", + "-W", + "error", + "-O", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 60, + "checks": "The same mathematical predicates with optimized Python; all explicit runtime checks remain active." + } + ] +} diff --git a/research/symplectic-binary-completion/verify.py b/research/symplectic-binary-completion/verify.py new file mode 100644 index 0000000000..7969895e8c --- /dev/null +++ b/research/symplectic-binary-completion/verify.py @@ -0,0 +1,276 @@ +#!/usr/bin/env python3 +"""Exact finite corroboration for the binary completion theorem. + +Produced by Nick Petalas. Apache-2.0. +No predecessor verifier, external package, network or subprocess is used. +""" +import argparse +from fractions import Fraction +from hashlib import sha256 +from itertools import combinations +import json +from pathlib import Path +import platform + + +MODELS = ((1, 0b11), (2, 0b111), (3, 0b1011), (4, 0b10011)) +PACKAGE_FILES = ("README.md", "TASK.json", "SOURCES.json", "VERIFY.json", "verify.py") + + +def require(condition, message): + if not condition: + raise ValueError(message) + + +def multiply(a, b, n, polynomial): + result = 0 + for _ in range(n): + if b & 1: + result ^= a + b >>= 1 + a <<= 1 + if a & (1 << n): + a ^= polynomial + return result + + +def trace(a, n, polynomial): + result = 0 + for _ in range(n): + result ^= a + a = multiply(a, a, n, polynomial) + require(result in (0, 1), "trace is not binary") + return result + + +def pairing(a, b, n, polynomial): + mask = (1 << n) - 1 + cross = multiply(a & mask, b >> n, n, polynomial) + cross ^= multiply(b & mask, a >> n, n, polynomial) + return trace(cross, n, polynomial) + + +def validate_model(n, polynomial): + size = 1 << n + # A multiplication permutation for each nonzero element certifies the field. + for a in range(1, size): + require({multiply(a, b, n, polynomial) for b in range(size)} + == set(range(size)), "nonfield model") + for a in range(1, size * size): + require(pairing(a, a, n, polynomial) == 0, "nonalternating model") + require(any(pairing(a, b, n, polynomial) for b in range(size * size)), + "degenerate model") + + +def is_lagrangian(points, n, polynomial): + if len(points) != (1 << n) - 1 or 0 in points: + return False + space = points | {0} + return (all((a ^ b) in space for a in space for b in space) + and all(pairing(a, b, n, polynomial) == 0 + for a in points for b in points)) + + +def validate_spread(old, n, polynomial): + require(1 <= n <= 4, "dimension outside finite verifier bounds") + require(len(old) == (1 << n) - 1, "wrong deficiency") + used = set() + for line in old: + require(all(isinstance(x, int) and 0 < x < (1 << (2 * n)) for x in line), + "point outside ambient space") + require(is_lagrangian(line, n, polynomial), "non-Lagrangian member") + require(not used.intersection(line), "overlapping members") + used.update(line) + holes = tuple(sorted(set(range(1, 1 << (2 * n))) - used)) + require(len(holes) == 2 * ((1 << n) - 1), "wrong hole count") + return holes + + +def field_puncture(n, polynomial): + return tuple(frozenset(x | (multiply(slope, x, n, polynomial) << n) + for x in range(1, 1 << n)) + for slope in range(1, 1 << n)) + + +def hole_adjacency(holes, n, polynomial): + return [[pairing(a, b, n, polynomial) for b in holes] for a in holes] + + +def signless(adjacency): + size = len(adjacency) + require(1 <= size <= 30, "matrix outside finite verifier bounds") + require(all(len(row) == size for row in adjacency), "nonsquare adjacency") + degrees = [sum(row) for row in adjacency] + require(min(degrees) > 0 and len(set(degrees)) == 1, "not positive regular") + require(all(adjacency[i][i] == 0 for i in range(size)), "loop") + require(all(adjacency[i][j] in (0, 1) + and adjacency[i][j] == adjacency[j][i] + for i in range(size) for j in range(size)), "not simple symmetric") + return [[adjacency[i][j] + (degrees[i] if i == j else 0) + for j in range(size)] for i in range(size)] + + +def kernel(matrix): + """Rational RREF, with a directly substituted basis for every free column.""" + size = len(matrix) + require(1 <= size <= 30 and all(len(row) == size for row in matrix), + "kernel matrix outside bounds") + work = [list(map(Fraction, row)) for row in matrix] + pivots = [] + for column in range(size): + row = next((r for r in range(len(pivots), size) if work[r][column]), None) + if row is None: + continue + target = len(pivots) + work[target], work[row] = work[row], work[target] + scale = work[target][column] + work[target] = [v / scale for v in work[target]] + for r in range(size): + if r != target: + scale = work[r][column] + work[r] = [a - scale * b for a, b in zip(work[r], work[target])] + pivots.append(column) + basis = [] + for column in range(size): + if column not in pivots: + vector = [Fraction(i == column) for i in range(size)] + for row, pivot in enumerate(pivots): + vector[pivot] = -work[row][column] + require(all(sum(a * b for a, b in zip(row, vector)) == 0 + for row in matrix), "bad kernel substitution") + basis.append(vector) + return basis + + +def determinant(matrix): + """Integer Bareiss elimination, separate from the rational kernel engine.""" + size = len(matrix) + require(1 <= size <= 30 and all(len(row) == size for row in matrix), + "determinant matrix outside bounds") + work = [row[:] for row in matrix] + previous, sign = 1, 1 + for column in range(size - 1): + row = next((r for r in range(column, size) if work[r][column]), None) + if row is None: + return 0 + if row != column: + work[column], work[row] = work[row], work[column] + sign = -sign + pivot = work[column][column] + for r in range(column + 1, size): + for c in range(column + 1, size): + numerator = work[r][c] * pivot - work[r][column] * work[column][c] + require(numerator % previous == 0, "inexact Bareiss division") + work[r][c] = numerator // previous + work[r][column] = 0 + previous = pivot + return sign * work[-1][-1] + + +def candidates_in_holes(holes, n, polynomial): + """Enumerate closed isotropic spans, independently of the graph spectrum.""" + require(len(holes) <= 30, "hole inventory outside enumeration bound") + allowed = frozenset(holes) | {0} + spaces = {frozenset({0})} + for _ in range(n): + extended = set() + for space in spaces: + for point in holes: + if point in space: + continue + if any(pairing(point, x, n, polynomial) for x in space): + continue + bigger = space | frozenset(x ^ point for x in space) + if bigger <= allowed and bigger not in extended: + require(len(extended) < 4096, "isotropic-span capacity exceeded") + extended.add(bigger) + spaces = extended + return tuple(sorted((space - {0} for space in spaces), key=lambda s: sorted(s))) + + +def check_fixture(n, polynomial): + validate_model(n, polynomial) + old = field_puncture(n, polynomial) + holes = validate_spread(old, n, polynomial) + adjacency = hole_adjacency(holes, n, polynomial) + degree = 1 << (n - 1) + require(all(sum(row) == degree for row in adjacency), "wrong hole degree") + matrix = signless(adjacency) + basis = kernel(matrix) + require(determinant(matrix) == 0 and len(basis) == 1, "wrong spectral decision") + vector = basis[0] + require(all(abs(v) == 1 for v in vector), "nonconstant kernel magnitude") + recovered = frozenset(frozenset(h for h, v in zip(holes, vector) if v * sign > 0) + for sign in (-1, 1)) + require(len(recovered) == 2, "missing color class") + require(all(is_lagrangian(s, n, polynomial) for s in recovered), "bad recovery") + candidates = candidates_in_holes(holes, n, polynomial) + completions = [frozenset((a, b)) for a, b in combinations(candidates, 2) + if not a.intersection(b)] + require(completions == [recovered], "independent completion search disagrees") + expected = frozenset((frozenset(range(1, 1 << n)), + frozenset(y << n for y in range(1, 1 << n)))) + require(recovered == expected, "wrong missing subspaces") + return {"n": n, "old_members": len(old), "holes": len(holes), "degree": degree, + "rank_Q": len(holes) - len(basis), "det_Q": 0, + "candidate_lagrangians": len(candidates), "completion_pairs": len(completions)} + + +def expect_rejection(operation, message): + try: + operation() + except ValueError as exc: + require(str(exc) == message, "unexpected rejection: " + str(exc)) + else: + raise ValueError("invalid input accepted: " + message) + + +def check_controls(): + n, polynomial = MODELS[1] + old = field_puncture(n, polynomial) + expect_rejection(lambda: validate_spread(old[:-1], n, polynomial), "wrong deficiency") + expect_rejection(lambda: validate_spread((old[0], old[0], old[2]), n, polynomial), + "overlapping members") + invalid = frozenset((1, 8, 9)) + expect_rejection(lambda: validate_spread((invalid, old[1], old[2]), n, polynomial), + "non-Lagrangian member") + # K4,4 disjoint (K6 minus a perfect matching). Same N=14,k=4 as n=3. + mixed = [[int((i < 4 <= j < 8 or j < 4 <= i < 8) + or (i >= 8 and j >= 8 and (i - 8) // 2 != (j - 8) // 2)) + for j in range(14)] for i in range(14)] + mixed_kernel = kernel(signless(mixed)) + require(len(mixed_kernel) == 1 and determinant(signless(mixed)) == 0, + "mixed abstract graph must be singular") + require(sum(v == 0 for v in mixed_kernel[0]) == 6, "mixed kernel zero support") + # The connected circulant with steps +/-1,+/-2 has a triangle. + nonbipartite = [[int((i - j) % 14 in (1, 2, 12, 13)) + for j in range(14)] for i in range(14)] + nonsingular = signless(nonbipartite) + det = determinant(nonsingular) + require(not kernel(nonsingular) and det > 0, "odd-cycle graph must be nonsingular") + return {"invalid_spreads_rejected": 3, "mixed_graph_vertices": 14, + "mixed_graph_degree": 4, "mixed_graph_kernel_zeros": 6, + "nonbipartite_graph_det_Q": det} + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("--receipt", type=Path) + args = parser.parse_args() + package = Path(__file__).resolve().parent + if args.receipt and args.receipt.resolve().is_relative_to(package.parents[1]): + parser.error("receipt must be outside the checkout") + result = {"status": "PASS_SYMPLECTIC_BINARY_COMPLETION", + "fixtures": [check_fixture(n, p) for n, p in MODELS], + "controls": check_controls()} + print(json.dumps(result, sort_keys=True)) + if args.receipt: + receipt = {"result": result, "python": platform.python_version(), + "files_sha256": {name: sha256((package / name).read_bytes()).hexdigest() + for name in PACKAGE_FILES}} + payload = json.dumps(receipt, indent=2, sort_keys=True) + "\n" + require(args.receipt.write_text(payload) == len(payload), "short receipt write") + + +if __name__ == "__main__": + main()