diff --git a/research/eisenstein-port-quadratic-floor/PROOF.md b/research/eisenstein-port-quadratic-floor/PROOF.md new file mode 100644 index 0000000000..3a2444809e --- /dev/null +++ b/research/eisenstein-port-quadratic-floor/PROOF.md @@ -0,0 +1,158 @@ +# A polar-rank obstruction for quadratic messages + +This contribution was produced by Nick Petalas. Apache-2.0. + +## Contract and credited premise + +Use Michael Fischler / shiftybitshiftr's PR814 fixed-support nonlinear +Eisenstein model. Port t has an independent vector X_t in F2^(b_t), with +b_t >= 0 and N = sum_t b_t. Every fixed message bit has fixed source and +reader port sets. Its additive charge is the rational pairing-rank price +in that model. Receiver t recovers X_t on every input from its received +messages and the inputs at ports orthogonal to t. Decoders can be nonlinear. +There are no free input-dependent headers or correlated entrance promises. + +We use Jose Manuel / jmbarrancoml's PR2017 fixed-support block-linear +corollary as a cited theorem: affine messages with these supports and +independent demands cost at least the total demand. Known constants can be +subtracted. That source result, its geometry and its numerical evidence +are not independently proved or replayed here. + +## Product-affine restriction lemma + +For each port choose an injective affine map + + X_t = a_t + M_t U_t, U_t in F2^(d_t). + +Suppose all message bits become affine functions of the full independent +product U. Then the unchanged original message charge C satisfies + + C >= sum_t d_t. (1) + +Indeed, compose the original exact encoder and decoder with these maps. +Each receiver recovers X_t and hence U_t using a fixed left inverse of M_t. +Orthogonal-port side information is still available: U_s determines X_s. +All U_t vary independently. A message can retain its original source and +reader supports and width, so its charge is unchanged. Subtract the known +affine constants and apply the credited block-linear theorem. The maps +are a restriction used in a lower-bound proof, not free physical gates +or an input-dependent observation channel. A subspace coupling distinct +ports would invalidate this argument and is excluded. + +## Quadratic class and theorem + +For every active port t, fix a scalar Boolean polynomial q_t of degree at +most two. Write every transmitted bit in the form + + Y_j(X) = ell_j(X) + sum_t lambda_jt q_t(X_t), + +where ell_j is affine and lambda_jt is in F2. The index j runs over all +message bits, not just messages. The displayed function must obey its +declared source support. Call t active when some lambda_jt is one; forms +at inactive ports are ignored. Multiple independent quadratic forms at +one port and cross-port quadratic monomials are outside this theorem. +Linear and constant parts of q_t are allowed and immaterial. + +Define its alternating polar form + + B_t(v,w) = q_t(v+w) + q_t(v) + q_t(w) + q_t(0). + +Let rank(B_t) = 2 r_t at active ports and r_t = 0 otherwise. Then + + C >= N - sum_t r_t. (2) + +Moreover, sum_t r_t is exactly the least total codimension of a product +of affine subspaces on which every transmitted bit is affine. Thus (2) +is the best bound from lemma (1) for this declared quadratic class. +It is not asserted to be the optimal message charge. + +## Isotropic dimensions, including degenerate forms + +For a quadratic q with polar form B on V = F2^b, its restriction to +an affine subspace a+L is affine exactly when B vanishes on L times L. +To see this, the translated function q(a+v)+q(a) has polarization B +on L. It is linear precisely when it is additive. Thus the translation +a and every original affine term have no effect on the criterion. + +An alternating form has a radical R = ker B and a basis of r symplectic +pairs plus b-2r radical vectors. This follows constructively: if B is +nonzero, choose e,f with B(e,f)=1. For each remaining vector v replace it +by v+B(v,f)e+B(v,e)f, which removes both pairings. Repeat on the remaining +space. Each iteration removes two dimensions, so the process terminates. +Taking one member of every pair and all radical vectors gives an +isotropic subspace of dimension b-r. + +For the upper bound, the image of any isotropic L in the nondegenerate +quotient V/R is isotropic. In a nondegenerate 2r-dimensional alternating +space, W is contained in its perpendicular and + + dim(W) + dim(W-perpendicular) = 2r, + +so dim(W) <= r. Consequently + + dim(L) <= dim(R) + r = b-r. (3) + +This proves both the even-rank assertion and the exact maximum dimension. +These are classical alternating-form facts; no historical priority is +claimed for symplectic elimination or the isotropic dimension formula. + +## Apply the dimension calculation without coupling ports + +Choose a maximum isotropic L_t at every active port and the entire input +space at every inactive port. All q_t become affine on the product, hence +all messages do. Its dimension is N-sum_t r_t, proving (2) by (1). + +Conversely, suppose every message is affine on a product of affine spaces +with direction spaces L_t. Fix a port t and vary only its coordinates. +The polarization of bit j is lambda_jt B_t restricted to L_t. Since t +is active, one bit has lambda_jt=1. Thus B_t vanishes on L_t. No quadratic +term at another port can cancel this polarization because those inputs +are held fixed. Formula (3) bounds every active d_t by b_t-r_t; inactive +ones are at most b_t. Summing proves the exact restriction codimension. + +## Strict improvement over coordinate faces + +For any integer s >= 1, take one port of width 2s+1, with coordinates +u_1,...,u_s,v_1,...,v_s,z, and put + + q(X) = (u_1+...+u_s)(v_1+...+v_s). + +Its polar form has rank two, so its exact affine restriction loss is one. +The hyperplane sum_i u_i=0 kills q while preserving independent parameters +within that port. In contrast, fixing individual coordinates to arbitrary +constants makes q affine only after all u coordinates or all v coordinates +have been fixed. If one unfixed u and one unfixed v remain, their mixed +quadratic coefficient is still one, regardless of the constants. Therefore +the exact coordinate-face loss is s. The difference s-1 is unbounded. +This comparison sharpens Nick Petalas / PR4895's coordinate-face obstruction +within its own fixed-support model; it does not contradict that theorem. + +The first strict case is s=2, b=5. Give every one of the forty ports five +input bits. At port zero send its four u/v bits directly to itself and +send z+q instead of z. Every other port sends its five bits directly to +itself. This is an exact fixed-support code: the first four messages +recover q and hence z. The credited singleton pairing price is one, so +its charge is 200. The new lower bound is 199, while the exact coordinate +face bound is 198. The example distinguishes the two obstructions; it +is not an attaining charge-199 code or a nonlinear saving construction. + +## Scope and next decision + +The result is a scoped written proof with finite exact corroboration, +conditional on the cited fixed-support linear pricing theorem. It narrows +the genuinely nonlinear payload direction left open by ywz65 / PR2607. +A proposed saving d in this class needs sum_t r_t >= d. Dense monomials +alone do not imply enough nonlinear freedom to support that saving. + +No physical encoder, native delivery, restoration schedule, complete signed +supplier invoice, selected framework assumption, new kappa or multiplication +theorem is supplied. Arbitrary quadratic vector maps, cross-port products, +adaptive queries, errors, private headers and correlated demands are excluded. +The general nonlinear optimum remains open. Independent human and formal +proof-kernel review are unclaimed. + +Credit Michael Fischler / PR814 for the nonlinear model; Jose Manuel / +PR2017 for the linear floor; Jonathan Lam / PR798 and Joel Pulikkan / +GamingPuzzled for geometry and pricing; ywz65 / PR2607 for the open nonlinear +payload direction; Nick Petalas / PR4895 for the coordinate restriction +comparison; and the retained Eisenstein, decoder and construction lineage. diff --git a/research/eisenstein-port-quadratic-floor/README.md b/research/eisenstein-port-quadratic-floor/README.md new file mode 100644 index 0000000000..a3bf2bc40c --- /dev/null +++ b/research/eisenstein-port-quadratic-floor/README.md @@ -0,0 +1,134 @@ +# A polar-rank obstruction for nonlinear Eisenstein messages + +This contribution was produced by Nick Petalas. Apache-2.0. + +For a fixed-support exact Eisenstein message code with one shared scalar +quadratic form q_t at each input port, let B_t be its binary polar form. +Every transmitted bit may combine these forms with arbitrary binary +coefficients and an arbitrary affine function. With N independent input +bits and the retained additive pairing price, the new obstruction is + + C >= N - sum_t rank(B_t)/2. + +Only forms actually used by the encoder enter the sum. The proof also +shows that this is the strongest lower bound obtainable by restricting +each port to an affine subspace and applying the cited linear-copy floor. +The input restriction preserves independent demands at distinct ports. + +This is a scoped written proof with finite exact corroboration. It builds +on Jose Manuel / jmbarrancoml's PR2017 linear theorem and responds to ywz65 / +PR2607's open genuinely nonlinear payload direction. Those results are +cited premises, not independently audited or replayed here. The alternating +form decomposition is classical; the contribution is its exact use in this +fixed-support restriction contract and its stricter nonlinear obstruction. + +## First strict improvement + +At one port put q=(u0+u1)(v0+v1), with an additional independent coordinate z. +Fixing individual coordinates requires two fixings to make q affine. +The single linear equation u0=u1 suffices, and its polar rank is two. +For forty five-bit ports, the new lower bound is **199**, compared with +**198** from the exact coordinate-face criterion of Nick Petalas / PR4895. +The demonstrated exact code costs **200**. No cheaper code is claimed. + +More generally q=(sum u_i)(sum v_i), with s coordinates in each sum, +has exact coordinate restriction loss s and exact product-affine loss one. +The improvement in this restriction parameter is therefore unbounded. +The universal statement is the written argument in [PROOF.md](PROOF.md). +The first strict s=2 case is the literal finite decoder fixture. + +## Reproduce + +From the repository root, CPython 3.12 and the standard library suffice: + +```sh +/Users/nick/git/integer-mult-bounds/.venv/bin/python3.12 -I -W error -B research/eisenstein-port-quadratic-floor/verify.py +/Users/nick/git/integer-mult-bounds/.venv/bin/python3.12 -I -O -W error -B research/eisenstein-port-quadratic-floor/verify.py +/Users/nick/git/integer-mult-bounds/.venv/bin/python3.12 -B scripts/research_package.py --package research/eisenstein-port-quadratic-floor +/Users/nick/git/integer-mult-bounds/.venv/bin/python3.12 -B scripts/check_research_commit.py --package research/eisenstein-port-quadratic-floor --check-source-history +``` + +Other hosts may substitute a CPython 3.12 executable. Each registered command +has a 120-second limit and generates its receipt on stdout. No generated +receipt or replay output is retained in the checkout. The marker is +`PASS_EISENSTEIN_PORT_QUADRATIC_FLOOR` followed by exact enumerated evidence +and SHA256 hashes of package files and all four live source inputs. + +The verifier checks all **1,100** homogeneous quadratic forms through five +variables against an independent complete subspace/truth-table oracle. +It tests **387,405** subspace restrictions, including degenerate forms, +and **69,677** translated restrictions through four variables. Constructed +maximum isotropic spaces are checked directly. Another **64** three-bit +vector maps on two independent two-bit ports receive **1,600** complete +product-subspace checks, including equal nonzero quadratic coefficient +columns and inactive ports. The decoder fixture checks **1,280** local +input/receiver cases. Six malformed-form rejections and four mathematical +boundary controls delimit the implementation and model. + +Local CPython 3.12.15 on macOS 27.0.1 arm64 passed both registered modes +and both direct commands. Direct normal/optimized elapsed times were +0.217/0.217 seconds, each below the 120-second registered limit. This is +a replay-budget observation, not a speedup claim. Warning-strict source +compilation and AST inspection pass; the longest function is 35 lines. +Ruff is unavailable in the local environment. Hosted CI is pending. + +Finite checks corroborate the written theorem. They do not prove its +all-width quantifiers, re-establish the cited linear theorem, or constitute +independent human or formal proof-kernel review. + +## Scope and provenance + +[Task metadata](TASK.json) records the changed scope under +`complex-rank-shape-decoder`. This is a nonlinear decoder side result, +not a completed supplier or changed paid/productive histogram. The source +question is ywz65 / PR2607; the earlier coordinate-face result supplies a +comparison, not the assignment. The [advance claim](https://github.com/CrocSwap/integer-mult-bounds/discussions/1166#discussioncomment-19291977) +records the question, boundaries and overlap checks. + +The package starts at canonical main +`2485805a6d47f36ea83ddde6327d453ac82d44dc`, priority revision 8. The selected +binding-only orientation passed and resolved selected PR6030. Historical +priority prose still mentions PR5599; the selected record governs. The +selected frontier is unchanged. [SOURCES.json](SOURCES.json) pins four +unchanged predecessor documents and historical catalogue/selected metadata. +No predecessor verifier is imported or executed. + +The proof assumes fixed supports/widths, independent full binary demands, +zero-error decoding, orthogonal side information and additive pairing prices. +It permits one shared polar form per port. Cross-port quadratic products, +multiple independent polar forms at one port, adaptive queries, private +headers, errors and correlated inputs require a different argument. +The new bound need not be sharp for message cost. Native operations, +physical delivery/restoration, precision/tape, stock, compiler, analytic +recovery and a complete signed supplier invoice remain open. There is no +new kappa or complete multiplication theorem. Selected cold replay, Lean, +Docker, independent human review and formal-kernel review were not run. + +Credit Michael Fischler / shiftybitshiftr / PR814 for the nonlinear model, +Jose Manuel / jmbarrancoml / PR2017 for the fixed-support block-linear floor, +Jonathan Lam / PR798 and Joel Pulikkan / GamingPuzzled for geometry and +pricing, ywz65 / PR2607 for the nonlinear payload question, Nick Petalas / +PR4895 for coordinate restrictions, and the retained Eisenstein, decoder +and construction lineage. Symplectic elimination, Boolean polarization, +and the isotropic dimension bound retain their classical status. + +Power of Ten inspection is scoped to the new verifier. It has no recursion, +subprocesses, dynamic imports or writes. Its largest exhaustive dimension +is five and its subspace list has at most 374 entries. Functions remain +below sixty lines. Source inputs have explicit byte and inventory limits. +CPython integer/container allocation is a managed-runtime deviation from +static allocation; fixed mathematical domains bound live data. Warning-strict +normal and optimized replays provide the available runtime diagnostics. + +## Open next questions + +- Determine the exact product-affine restriction dimension for two independent + quadratic forms at one port. Start with literal small alternating matrices + and a complete common-isotropic-space oracle. The single-form rank formula + does not determine their simultaneous restriction. +- Construct a genuinely nonlinear exact Eisenstein code with charge below + total demand, if one exists. Specify source/reader sets and every additive + charge, then calculate the restriction certificate. No lower-charge code + or favorable complete physical invoice is supplied here. + +Structured first steps and blockers are in TASK.json. diff --git a/research/eisenstein-port-quadratic-floor/SOURCES.json b/research/eisenstein-port-quadratic-floor/SOURCES.json new file mode 100644 index 0000000000..619ddc9ad1 --- /dev/null +++ b/research/eisenstein-port-quadratic-floor/SOURCES.json @@ -0,0 +1,42 @@ +{ + "schema_version": 1, + "base_commit": "2485805a6d47f36ea83ddde6327d453ac82d44dc", + "files": [ + { + "path": "certificates/selected-result.json", + "usage": "provenance", + "git_blob": "d59b5035e7b4cbaa9d688a1d32dd0d6eb79c466a", + "sha256": "9b8d0eea95b3bf0dfcb7938a732a6439b87a2685dec2a5ab9e525b3b34debbfa" + }, + { + "path": "docs/research/agent-task-catalog.json", + "usage": "provenance", + "git_blob": "3404fbdd5e7529a0674eef26114b5071e4586cec", + "sha256": "ead6cdc9d0af6d58e8a49744d8ec8c7c15e13d2ba93c276c434bcf9b51b93a81" + }, + { + "path": "research/eisenstein-adaptive-affine-floor/README.md", + "usage": "input", + "git_blob": "0330271cb21c80956dcf210261cf580c74ec6f30", + "sha256": "6bc9f92041abaa0f4a311cd6156301f47c408acb317df0d0d11f9d2d00b28b6c" + }, + { + "path": "research/eisenstein-message-copy-bound/PROOF.md", + "usage": "input", + "git_blob": "86d6e25ed60488646c0316a2c930e1f9e3ade99a", + "sha256": "dd8c7890d661ae87167d038d12356845470a2822733c45bd9ab4c9208e381311" + }, + { + "path": "research/eisenstein-nonlinear-restriction/PROOF.md", + "usage": "input", + "git_blob": "af2a642cea88c1ba93cfabb41b9b5c6b41e553e5", + "sha256": "05d3cd1a76ac9dfb4479c7f0fb0703ec8ce847ed24f226fdb6ca1ca9483683cc" + }, + { + "path": "research/eisenstein-reduction-copy-floor/README.md", + "usage": "input", + "git_blob": "ebf030c2592de812a6189722b5bf7bdf854bc4ae", + "sha256": "f3f243524fd1ddc0fc893b144994ce184fee8fd8e7e49d544281863559f8c1de" + } + ] +} diff --git a/research/eisenstein-port-quadratic-floor/TASK.json b/research/eisenstein-port-quadratic-floor/TASK.json new file mode 100644 index 0000000000..e3519ebe4f --- /dev/null +++ b/research/eisenstein-port-quadratic-floor/TASK.json @@ -0,0 +1,114 @@ +{ + "schema_version": 1, + "task_id": "complex-rank-shape-decoder", + "priority_revision": 8, + "base_commit": "2485805a6d47f36ea83ddde6327d453ac82d44dc", + "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": "changed", + "actual_scope": "A polar-rank lower bound and exact product-affine restriction dimension for fixed-support Eisenstein messages with one shared scalar quadratic form per input port.", + "scope_change_reason": "The chosen source is ywz65 / PR2607's nonlinear-payload open question. This is a scoped nonlinear obstruction rather than a paid itinerary, supplier, coframe search or audit. It sharpens the earlier coordinate-face criterion for a declared subclass.", + "bottleneck_link": "A nonlinear decoder proposal below the linear copy floor must have enough port-local polar rank. This side result eliminates some proposed savings before physical delivery and complete signed-moment work; it does not discharge a selected assumption.", + "budget_minutes": 60, + "stop_rule": "Package the first verified strict improvement over the coordinate-face bound; do not search for a cheaper nonlinear code or extend the quadratic class.", + "outcome": "completed", + "evidence": "PROOF.md proves the all-width statement relative to PR2017; verify.py generates file-hash-bound exact evidence for 1100 forms, 387405 subspace restrictions, 69677 translations, 64 vector maps, 1600 product restrictions, 1280 receiver cases and ten controls. First strict lower-bound improvement: 198 to 199, with actual fixture charge 200.", + "author": "Nick Petalas", + "ai_assistance": "Independent human and formal proof-kernel review are unclaimed.", + "open_questions": [ + { + "question": "What is the exact product-affine restriction dimension when one port has multiple independent quadratic polar forms?", + "why_it_matters": "Such encoders can evade the single-form hypothesis and require a simultaneous isotropic-space certificate.", + "first_step": "Specify two literal alternating forms on one small port and determine their largest common isotropic subspace with a complete truth-table oracle.", + "blocked_by": "The single-form rank formula does not determine common isotropic dimension." + }, + { + "question": "Can a genuinely nonlinear exact fixed-support Eisenstein code have charge below its total demand?", + "why_it_matters": "The new obstruction is necessary and supplies no nonlinear saving or complete supplier.", + "first_step": "Give one exact code with declared source/reader sets, widths and additive pairing charges; compute its restriction certificate before physical expansion.", + "blocked_by": "No such lower-charge code or favorable complete physical supplier invoice is supplied." + } + ], + "source_question": { + "pr": 2607, + "author": "ywz65", + "head": "42e80fe2c5baac8d0e259cfbe7b5479e5ab8d9ae", + "question": "Can genuinely nonlinear payload queries improve the nonlinear 22b-to-40b interval?" + }, + "claim_url": "https://github.com/CrocSwap/integer-mult-bounds/discussions/1166#discussioncomment-19291977", + "environment": { + "python": "CPython 3.12.15", + "platform": "macOS 27.0.1 arm64", + "dependencies": "standard library only" + }, + "evidence_details": { + "claim_type": "scoped written proof with finite exact corroboration", + "proof": "PROOF.md", + "verifier": "verify.py", + "first_strict_example": { + "coordinate_face_floor": 198, + "polar_floor": 199, + "actual_code_charge": 200 + }, + "counts": { + "quadratic_forms": 1100, + "subspace_restrictions": 387405, + "translated_restrictions": 69677, + "vector_maps": 64, + "product_subspace_restrictions": 1600, + "local_receiver_cases": 1280, + "invalid_forms_rejected": 6, + "boundary_controls": 4 + }, + "baseline": "PASS_RESEARCH_BASELINE_BINDINGS_ONLY; not a supplier replay" + } +} diff --git a/research/eisenstein-port-quadratic-floor/VERIFY.json b/research/eisenstein-port-quadratic-floor/VERIFY.json new file mode 100644 index 0000000000..3c96326977 --- /dev/null +++ b/research/eisenstein-port-quadratic-floor/VERIFY.json @@ -0,0 +1,39 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [ + "research/eisenstein-adaptive-affine-floor/README.md", + "research/eisenstein-message-copy-bound/PROOF.md", + "research/eisenstein-nonlinear-restriction/PROOF.md", + "research/eisenstein-reduction-copy-floor/README.md" + ], + "commands": [ + { + "argv": [ + "{python}", + "-I", + "-W", + "error", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 120, + "checks": "All quadratic forms through five variables; independent affine truth-table maxima; translated restrictions through four variables; two-port vector maps; exact decoder fixture and boundary/rejection controls." + }, + { + "argv": [ + "{python}", + "-I", + "-O", + "-W", + "error", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 120, + "checks": "The same complete finite evidence and source authentication with optimization enabled." + } + ] +} diff --git a/research/eisenstein-port-quadratic-floor/verify.py b/research/eisenstein-port-quadratic-floor/verify.py new file mode 100644 index 0000000000..83dd9b1422 --- /dev/null +++ b/research/eisenstein-port-quadratic-floor/verify.py @@ -0,0 +1,294 @@ +#!/usr/bin/env python3 +"""Exact finite corroboration for the written port-quadratic theorem.""" + +import hashlib +import itertools +import json +from pathlib import Path +import sys + +MAX_DIMENSION = 5 + + +def require(condition, message): + if not condition: + raise ValueError(message) + + +def validate_form(rows): + n = len(rows) + require(0 <= n <= MAX_DIMENSION, "dimension outside 0..5") + require(all(type(row) is int and 0 <= row < (1 << n) + for row in rows), "invalid binary row") + for i in range(n): + require(not (rows[i] >> i) & 1, "nonzero alternating diagonal") + for j in range(n): + require((rows[i] >> j) & 1 == (rows[j] >> i) & 1, + "nonsymmetric form") + + +def binary_rank(rows): + pivots = {} + for original in rows: + value = original + for bit in range(MAX_DIMENSION - 1, -1, -1): + if not (value >> bit) & 1: + continue + if bit in pivots: + value ^= pivots[bit] + else: + pivots[bit] = value + break + return len(pivots) + + +def pairing(rows, x, y): + return sum(((x >> i) & 1) * ((rows[i] & y).bit_count() & 1) + for i in range(len(rows))) & 1 + + +def isotropic_basis(rows): + validate_form(rows) + n = len(rows) + remaining = [1 << i for i in range(n)] + answer = [] + for _ in range(n // 2 + 1): + pair = next(((i, j) for i in range(len(remaining)) + for j in range(i + 1, len(remaining)) + if pairing(rows, remaining[i], remaining[j])), None) + if pair is None: + answer.extend(remaining) + break + i, j = pair + e, f = remaining[i], remaining[j] + answer.append(e) + remaining = [v ^ (e if pairing(rows, v, f) else 0) + ^ (f if pairing(rows, v, e) else 0) + for k, v in enumerate(remaining) if k not in (i, j)] + else: + raise ValueError("symplectic elimination exhausted") + require(binary_rank(answer) == len(answer), "dependent construction") + require(all(pairing(rows, x, y) == 0 + for x in answer for y in answer), "nonisotropic construction") + require(2 * (n - len(answer)) == binary_rank(rows), "wrong dimension") + return tuple(answer) + + +def subspaces(n): + """Enumerate subspaces by intersection with each coordinate hyperplane.""" + require(type(n) is int and 0 <= n <= MAX_DIMENSION, "bad space dimension") + spaces = [((0,), ())] + for k in range(n): + updated = list(spaces) + for elements, basis in spaces: + remaining = set(range(1 << k)) + for representative in range(1 << k): + if representative not in remaining: + continue + coset = {representative ^ x for x in elements} + remaining.difference_update(coset) + v = representative | (1 << k) + extension = tuple(sorted(elements + tuple(x ^ v for x in elements))) + updated.append((extension, basis + (v,))) + spaces = updated + require(len({elements for elements, _ in spaces}) == len(spaces), + "duplicate subspace") + return tuple(spaces) + + +def quadratic_value(edges, x): + return sum(((x >> i) & 1) * ((x >> j) & 1) for i, j in edges) & 1 + + +def truth_affine(values, elements, basis, offset): + """Test affine truth values using all generator translations, without B.""" + origin = values[offset] + for v in elements: + for e in basis: + if values[offset ^ v ^ e] ^ values[offset ^ v] != values[offset ^ e] ^ origin: + return False + return True + + +def form_rows(n, edges): + rows = [0] * n + for i, j in edges: + rows[i] |= 1 << j + rows[j] |= 1 << i + return tuple(rows) + + +def check_quadratic_forms(): + counts = {"quadratic_forms": 0, "subspace_restrictions": 0, + "translated_restrictions": 0, "attaining_subspaces": 0} + rank_profile = {} + for n in range(MAX_DIMENSION + 1): + spaces = subspaces(n) + possible = tuple(itertools.combinations(range(n), 2)) + for mask in range(1 << len(possible)): + edges = tuple(e for i, e in enumerate(possible) if (mask >> i) & 1) + rows = form_rows(n, edges) + basis = isotropic_basis(rows) + target = len(basis) + values = tuple(quadratic_value(edges, x) for x in range(1 << n)) + observed = -1 + for elements, candidate in spaces: + affine = truth_affine(values, elements, candidate, 0) + if affine: + observed = max(observed, len(candidate)) + if len(candidate) == target: + counts["attaining_subspaces"] += 1 + counts["subspace_restrictions"] += 1 + # Every translation on all forms through dimension four. + if n <= 4: + for offset in range(1 << n): + require(truth_affine(values, elements, candidate, offset) + == affine, "translation changed criterion") + counts["translated_restrictions"] += 1 + require(observed == target, "truth-table maximum disagrees") + restricted = tuple(x for x in range(1 << n) + if binary_rank(basis + (x,)) == target) + require(truth_affine(values, restricted, basis, 0), "attainer not affine") + rank_profile[str(binary_rank(rows))] = rank_profile.get(str(binary_rank(rows)), 0) + 1 + counts["quadratic_forms"] += 1 + counts["rank_profile"] = rank_profile + return counts + + +def coordinate_loss(values, n): + """Independent complete coordinate-face search, including nonzero fixings.""" + for loss in range(n + 1): + for fixed in itertools.combinations(range(n), loss): + free = tuple(i for i in range(n) if i not in fixed) + basis = tuple(1 << i for i in free) + elements = tuple(sum(((mask >> j) & 1) << i + for j, i in enumerate(free)) + for mask in range(1 << len(free))) + for pattern in range(1 << loss): + offset = sum(((pattern >> j) & 1) << i + for j, i in enumerate(fixed)) + if truth_affine(values, elements, basis, offset): + return loss + raise ValueError("coordinate search exhausted") + + +def check_strict_fixture(): + # u0,u1,v0,v1,z. All four K2,2 monomials are retained. + edges = ((0, 2), (0, 3), (1, 2), (1, 3)) + values = tuple(quadratic_value(edges, x) for x in range(32)) + rows = form_rows(5, edges) + require(binary_rank(rows) == 2, "fixture polar rank") + require(coordinate_loss(values, 5) == 2, "fixture coordinate loss") + require(len(isotropic_basis(rows)) == 4, "fixture affine loss") + # The literal hyperplane u0=u1 has four independent coordinates. + hyperplane = tuple(x for x in range(32) if (x & 1) == ((x >> 1) & 1)) + require(all(values[x] == 0 for x in hyperplane), "hyperplane does not kill q") + recovered = 0 + for port in range(40): + for x in range(32): + sent = x ^ (values[x] << 4) if port == 0 else x + decoded = sent ^ (values[sent] << 4) if port == 0 else sent + require(decoded == x, "local decoder failure") + recovered += 1 + return {"ports": 40, "bits_per_port": 5, "coordinate_floor": 198, + "polar_floor": 199, "actual_fixture_charge": 200, + "local_receiver_cases": recovered, "hyperplane_inputs": len(hyperplane)} + + +def check_vector_quadratic_maps(): + """Check simultaneous restriction across two ports and three output bits.""" + configurations = 0 + products = 0 + spaces = subspaces(2) + for column_a in range(8): + for column_b in range(8): + expected = 4 - bool(column_a) - bool(column_b) + maximum = -1 + for left, lb in spaces: + for right, rb in spaces: + domain = tuple(x | (y << 2) for x in left for y in right) + basis = lb + tuple(v << 2 for v in rb) + values = tuple((column_a if (x & 3) == 3 else 0) + ^ (column_b if (x >> 2) == 3 else 0) + ^ ((x & 1) | (((x >> 3) & 1) << 1)) + for x in range(16)) + affine = truth_affine(values, domain, basis, 0) + if affine: + maximum = max(maximum, len(basis)) + products += 1 + require(maximum == expected, "product maximum disagrees") + # Distinct nonzero columns may also be equal; independence of ports + # prevents cancellation from increasing the product restriction. + configurations += 1 + return {"vector_maps": configurations, "product_subspace_restrictions": products} + + +def check_controls(): + cases = [(((1,),), "invalid binary row"), + ((1,), "nonzero alternating diagonal"), + ((2, 0), "nonsymmetric form"), + ((8, 0), "invalid binary row"), + ((0,) * 6, "dimension outside 0..5"), + ((-1,), "invalid binary row")] + for rows, reason in cases: + try: + isotropic_basis(rows) + except ValueError as error: + require(str(error) == reason, "wrong rejection reason") + else: + raise ValueError("invalid form accepted") + # Model counterexamples: cross-port coupling and two independent forms. + rows = form_rows(2, ((0, 1),)) + require(pairing(rows, 1, 2) == 1, "rank mutant survived") + require(pairing(rows, 1, 1) == 0, "alternation mutant survived") + # A diagonal x=y kills cross-port xy but destroys independent demands. + cross = (0, 0, 0, 1) + require(truth_affine(cross, (0, 3), (3,), 0), "diagonal control") + require(not truth_affine(cross, (0, 1, 2, 3), (1, 2), 0), + "independent-product control") + # q1=x0*x1 and q2=x0*x2 have separate maximal planes whose intersection + # need not be maximal. Taking only the rank of q1+q2 misses this contract. + q1 = tuple(quadratic_value(((0, 1),), x) for x in range(8)) + q2 = tuple(quadratic_value(((0, 2),), x) for x in range(8)) + plane = (0, 3, 4, 7) + require(not truth_affine(q2, plane, (3, 4), 0), "second-form control") + require(truth_affine(q1, (0, 1), (1,), 0), "positive truth control") + return {"invalid_forms_rejected": len(cases), "boundary_controls": 4} + + +def authenticate_sources(package): + manifest_path = package / "SOURCES.json" + require(manifest_path.stat().st_size <= 1_048_576, "manifest exceeds byte bound") + manifest = json.loads(manifest_path.read_text()) + require(len(manifest["files"]) <= 8, "source inventory exceeds bound") + inputs = {} + for source in manifest["files"]: + if source["usage"] != "input": + continue + path = package.parent.parent / source["path"] + require(path.stat().st_size <= 1_048_576, "source exceeds byte bound") + payload = path.read_bytes() + require(len(payload) <= 1_048_576, "source exceeds byte bound") + digest = hashlib.sha256(payload).hexdigest() + require(digest == source["sha256"], "changed source: " + source["path"]) + inputs[source["path"]] = digest + require(len(inputs) == 4, "source inventory changed") + return inputs + + +def main(): + require(len(sys.argv) == 1, "no arguments accepted") + package = Path(__file__).resolve().parent + inputs = authenticate_sources(package) + evidence = {**check_quadratic_forms(), **check_strict_fixture(), + **check_vector_quadratic_maps(), **check_controls()} + names = ("README.md", "PROOF.md", "verify.py", "TASK.json", "SOURCES.json", "VERIFY.json") + sources = {name: hashlib.sha256((package / name).read_bytes()).hexdigest() + for name in names} + print("PASS_EISENSTEIN_PORT_QUADRATIC_FLOOR " + json.dumps( + {"claim_type": "scoped proof with finite corroboration", "evidence": evidence, + "package_sha256": sources, "input_sha256": inputs}, sort_keys=True)) + + +if __name__ == "__main__": + main()