From 06c46bed7ec9168c9d0b2a5561eeb6079b0f1ef1 Mon Sep 17 00:00:00 2001 From: Nick Petalas Date: Fri, 13 Nov 2026 16:57:58 +0000 Subject: [PATCH] feat(research): characterize tensor splitting feasibility --- .../split-only-tensor-feasibility/PROOF.md | 151 +++++++++ .../split-only-tensor-feasibility/README.md | 144 +++++++++ .../SOURCES.json | 24 ++ .../split-only-tensor-feasibility/TASK.json | 116 +++++++ .../split-only-tensor-feasibility/VERIFY.json | 34 ++ .../split-only-tensor-feasibility/verify.py | 302 ++++++++++++++++++ 6 files changed, 771 insertions(+) create mode 100644 research/split-only-tensor-feasibility/PROOF.md create mode 100644 research/split-only-tensor-feasibility/README.md create mode 100644 research/split-only-tensor-feasibility/SOURCES.json create mode 100644 research/split-only-tensor-feasibility/TASK.json create mode 100644 research/split-only-tensor-feasibility/VERIFY.json create mode 100644 research/split-only-tensor-feasibility/verify.py diff --git a/research/split-only-tensor-feasibility/PROOF.md b/research/split-only-tensor-feasibility/PROOF.md new file mode 100644 index 0000000000..2db685d158 --- /dev/null +++ b/research/split-only-tensor-feasibility/PROOF.md @@ -0,0 +1,151 @@ +# Exact feasibility of tensoring with capped splitting + +This scoped proof was produced by Nick Petalas. Apache-2.0. + +Fix a real exponent 0=1, +each ordered v-tuple of original paid jobs supplies one job of rank equal to +the product of its ranks. These jobs remain distinct even when their ranks +coincide. Partition each such job separately into positive integer pieces +of rank at most J=c^v. Charge the sum of the pieces' t-powers. Targets stay +unchanged, so their tensor t-moment is T_t^v. There is no target completion. + +## Theorem + +Let S_v be the least possible total paid charge over these capped partitions. +Put A=P_t and D=P_1 c^(t-1). Then + +```text +max(A^v,D^v) <= S_v <= A^v+D^v. +lim_(v->infinity) S_v^(1/v) = max(A,D). + +There is a v>=1 with S_v= R^t, +sum_i r_i^t >= sum_i r_i J^(t-1)=R J^(t-1). +``` + +Subadditivity follows from (a+b)^t<=a^t+b^t for nonnegative a,b. +For b>0 the derivative of (a+b)^t-a^t is nonpositive as a increases, +so the difference is at most b^t. Induction covers every finite partition. +The second inequality uses t-1<0 and 0=T_t or D>=T_t, the corresponding lower bound excludes every power. +In particular, a limiting equality cannot be treated as a passing endpoint. + +## Padding-free separation + +Let k be the least original target rank. If 1<=c=2, a legal integer cap exists with a strict moment advantage at some +power exactly when + +```text +P_t6, so no tensor power + works, even with arbitrary capped partitions. At c=3, D=3sqrt(3)<6 + and P_t=3<6. All targets exceed the cap base in both cases. +* T={81}, P={17}, c=4. The first power costs 4sqrt(4)+sqrt(1)=9, + exactly the target charge. At power two the cost is + 18sqrt(16)+sqrt(1)=73<81. The criterion predicts existence, rather + than a win at every positive power. Dropping the first remainder would + falsely claim a first-power win of 8<9. +* T={16}, P={4,4}, c=9. A=T_t=4 and all jobs are unsplit, so S_v=4^v. + T={64}, P={16}, c=4 instead has A=4=2 is the least target rank, some legal integer cap c6. Cap base three passes the criterion. + +For T={81}, P={17}, c=4, the first-power split charge is exactly nine, +equal to the target. At the second power it is 73<81. This distinguishes +eventual feasibility from an immediate win. The verifier also treats both +types of equality obstruction. None of these inventories is asserted to +have a native realization. + +## Reproduce + +From the repository root with CPython 3.12 and the standard library: + +```sh +/Users/nick/git/integer-mult-bounds/.venv/bin/python3.12 -I -W error -B research/split-only-tensor-feasibility/verify.py +/Users/nick/git/integer-mult-bounds/.venv/bin/python3.12 -I -O -W error -B research/split-only-tensor-feasibility/verify.py +/Users/nick/git/integer-mult-bounds/.venv/bin/python3.12 -B scripts/research_package.py --package research/split-only-tensor-feasibility +/Users/nick/git/integer-mult-bounds/.venv/bin/python3.12 -B scripts/check_research_commit.py --package research/split-only-tensor-feasibility --check-source-history +``` + +Other machines may substitute any CPython 3.12 path. The direct verifier +writes nothing, imports no predecessor executable and works without Git or +network access. It prints generated JSON bound to all six package-file +hashes, followed by `PASS_SPLIT_ONLY_TENSOR_FEASIBILITY`. No receipt is +handwritten or used as an answer oracle. The metadata and committed-byte +checks separately authenticate provenance and publication bytes. + +The finite replay checks 18,432 one-job splits at six rational exponents; +256 exact dynamic-programming partition optima; 468 tensor histograms; +and 2,496 profile/cap/target-moment decisions. The 1,767 passing decisions +each have an actually evaluated sufficient-power witness, at powers up +to twenty. Independent literal enumeration checks 3,072 ordered job tuples +and 176 explicit partition contexts. Thirty-nine boundary checks and +fifteen invalid-input rejections protect remainder costs and strictness. +Rational root brackets use integer arithmetic; comparisons fail if their +intervals do not separate. The universal theorem rests on the written proof. + +## Sources and scope + +Base canonical main is `e54523517d0f03e58352e647c403a5af3e525a57`, priority +revision eight. The selected record is #7000 and kappa=0.00363005817. +The selected binding-only orientation passed; it is not a supplier replay. +[SOURCES.json](SOURCES.json) pins historical provenance, including zxv's +PR4433 framework document. There are no external scientific runtime inputs. + +Credit zxv's [PR4433](https://github.com/CrocSwap/integer-mult-bounds/pull/4433) +for the tensor paid-splitting framework; Cinna Davis's PR4412/4414/4416 +for chronological product and completion; and Jacob Alan Sussman for the +integer compiler. Their native, helper, controller and outer lineage retains +its credit. The new step is the exact exponential rate and any-power +feasibility criterion. Concavity and the product/squeeze arguments are +classical; no global literature-priority claim is made for those ingredients. + +Nick Petalas's PR4832/6390 one-job coefficient results and PR7135 net-tax +optimizer are background, not premises or main steps of this proof. This +result does not change their optimizers or reuse their constructions. It +changes the independent-moment card from audit to an original quantified +accounting theorem, as recorded in [TASK.json](TASK.json). + +The [advance claim](https://github.com/CrocSwap/integer-mult-bounds/discussions/1166#discussioncomment-19595330) +states the same scope. Entry checks covered live open/own PRs, the handoff +and active Discussions, all tracked main README/proof literal searches, +and merged-PR searches. The cached helper reported 826 open PRs and 7,445 +Discussion records with complete pagination. Its sparse local coverage +was only 228 of 10,178 notes, supplemented by direct Git searches. +Arbitrary historical diffs and unpublished work remain outside coverage. + +This is not a complete signed invoice when completion, target debits or +other costs apply. Physical arbitrary-input realization, ownership, +restoration, chronological native closure, stock, precision, tape and outer +recovery remain unproved and unpriced here. All five selected assumptions +remain. No predecessor scientific verifier, selected cold replay, Lean or +Docker run was performed. Independent human and formal proof-kernel review +are unclaimed. + +## Open next questions + +1. Can one changed native inventory use this screen to avoid target + completion? Start with its complete tensor/splitting contract and the + two moments at c=min(target)-1. Native realization and full physical + costs remain blockers. +2. What is the exact feasibility criterion when same-owner target completion + is also allowed? Start with both completed inventories at one fixed + floor base. A joint two-sided estimate is missing; this result cannot + discard the completion charge. + +## Verifier constraints + +The verifier has no recursion, subprocesses, network access, writes or +generated code. Every function is under sixty lines. Integer-root bisection +has a bit-length iteration cap. Scientific fixture loops have explicit +finite domains; tensor powers are capped at 64, profile supports at three, +histograms at 5,000 entries and power inputs at 1,024 bits. Source reads cover +six files capped at 256 KiB each. All guards remain active under optimization. + +Power of Ten rule 3 has a managed-runtime deviation. CPython allocates +integers, fractions and bounded containers dynamically. The fixture caps +bound live algorithmic state; allocator internals are not instrumented. +Warning-strict normal and optimized runs and AST/function-size inspection +are the available diagnostics. No repository-wide static analyzer or +fixed-allocation implementation is claimed. diff --git a/research/split-only-tensor-feasibility/SOURCES.json b/research/split-only-tensor-feasibility/SOURCES.json new file mode 100644 index 0000000000..b6eae76629 --- /dev/null +++ b/research/split-only-tensor-feasibility/SOURCES.json @@ -0,0 +1,24 @@ +{ + "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" + }, + { + "path": "research/higher-moment-strictification/README.md", + "usage": "provenance", + "git_blob": "0a736ca89e1eafb73a30e1f2589cc45e6b5f76c3", + "sha256": "ebe80b68ff026ce90f71f274c31744f4c0b36132d15ebb7e39cf2d5df4df270d" + } + ] +} diff --git a/research/split-only-tensor-feasibility/TASK.json b/research/split-only-tensor-feasibility/TASK.json new file mode 100644 index 0000000000..ed2e70cfd2 --- /dev/null +++ b/research/split-only-tensor-feasibility/TASK.json @@ -0,0 +1,116 @@ +{ + "schema_version": 1, + "task_id": "independent-moment", + "priority_revision": 8, + "base_commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "original_card": { + "id": "independent-moment", + "question": "Does a changed construction's serialized target/paid invoice independently support its claimed improvement?", + "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": "Demonstrate independence, source binding, positive cases and semantic failure controls. Name the existing checks and the missing coverage. More digits or another equivalent evaluation of an unchanged root is not by itself new verification coverage.", + "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": "Independently recount one changed emitted word and its complete caller, importing no constructor or pricing engine. Include target losses, owned lifetimes, native orientation and extra charges. Check existing #5633/#5708/#5717/#5719 coverage to avoid duplicate audits and preserve its exact head. Stop after the chosen missing implication; a correct root alone is not supplier admission.", + "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": [ + "invoice", + "signed moment", + "productive target", + "independent recount" + ], + "existing_checks": [ + { + "scope": "PR #4088: mixed local/owner/phase ledger and moment reported.", + "evidence": "research/staged544-mixed-fourth-entry/README.md", + "remaining": "Independent binding of changed construction to paid histogram, distinct from full admission.", + "status": "author-checked", + "source_commit": "72d7efc181edb21806a878f174847c96dd410ab0", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + }, + { + "scope": "PR #4091: sharp pooled ceiling proposed for fixed THREE/FOUR words and inventory.", + "evidence": "research/staged-fourth-mixture-ceiling/README.md", + "remaining": "Validate dual, exhaustive pattern scope and exact source equivalence before applying to newer fills.", + "status": "author-checked", + "source_commit": "a29bdd8f56cd18b805917775cdec09ff935eddc4", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + }, + { + "scope": "PR #4067: paid (2,2) to (1,3) exchange and fixed OQ4 host reported.", + "evidence": "research/r437-two-window-carrier/README.md", + "remaining": "Independent full cost delta; remaining caller/precision/stock obligations are separate.", + "status": "author-checked", + "source_commit": "a95f11c52e3ca1e4c5171b3c20d8f4b0815aee2e", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + }, + { + "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": "Exact exponential rate and any-power feasibility for tensoring and arbitrary disjoint capped integer partitions, with unchanged targets and no completion.", + "scope_change_reason": "The user requires original research, not an audit. This original question changes the independent-moment card to a sharp accounting theorem which can reject futile fixed-cap tensor searches.", + "bottleneck_link": "A complete strictification must pay for every split. The theorem gives an exact screen for the padding-free splitting step, and a negative decision that increasing tensor power cannot undo. Native interfaces and full compiler admission remain separate.", + "budget_minutes": 60, + "stop_rule": "Stop at the first verified criterion, exact finite corroboration and a focused package. Do not optimize a supplier, add target completion or search larger mechanisms.", + "outcome": "completed", + "evidence": "PROOF.md proves the real-exponent/all-power theorem; verify.py checks rational bounds, arbitrary partitions, tensor histograms, literal jobs, attaining powers and strict-boundary controls.", + "author": "Nick Petalas", + "ai_assistance": "Independent human and formal proof-kernel review are unclaimed.", + "open_questions": [ + { + "question": "Can one changed native inventory use the exact padding-free cap screen to avoid target completion?", + "why_it_matters": "It would remove one paid step rather than tighten its overcount.", + "first_step": "State that inventory and its arbitrary-input tensor/splitting contract, then compare its two moments at c=min(target)-1.", + "blocked_by": "A named native realization, full physical costs and compiler admission are not supplied." + }, + { + "question": "What is the exact any-power feasibility criterion when same-owner target completion is also allowed?", + "why_it_matters": "Completion changes both target credit and paid charges, so this criterion cannot decide that larger model.", + "first_step": "Write both completed inventories at one fixed floor base and preserve every completion charge.", + "blocked_by": "A new joint two-sided estimate for completion and splitting is required." + } + ], + "claim_type": "scoped proof with exact finite corroboration", + "claim_url": "https://github.com/CrocSwap/integer-mult-bounds/discussions/1166#discussioncomment-19595330", + "engineering_playbook": "investigation", + "selected_kappa": "363005817/100000000000", + "overlap": { + "main_commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "priority_revision": 8, + "question_source": "original", + "main_predecessor_author": "zxv", + "scope": "Live open/own PR lists, last 30 handoff posts and active Discussions; complete tracked main README/proof term searches and merged literal searches. Arbitrary historical diffs and unpublished work are excluded." + } +} diff --git a/research/split-only-tensor-feasibility/VERIFY.json b/research/split-only-tensor-feasibility/VERIFY.json new file mode 100644 index 0000000000..c72751a818 --- /dev/null +++ b/research/split-only-tensor-feasibility/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": "Exact rational finite corroboration of the two-sided split bounds, arbitrary partitions, tensor feasibility, strict boundaries and domain rejections." + }, + { + "argv": [ + "{python}", + "-I", + "-O", + "-W", + "error", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 120, + "checks": "The complete scientific check with optimization enabled; explicit guards retain every check." + } + ] +} diff --git a/research/split-only-tensor-feasibility/verify.py b/research/split-only-tensor-feasibility/verify.py new file mode 100644 index 0000000000..da04f9df55 --- /dev/null +++ b/research/split-only-tensor-feasibility/verify.py @@ -0,0 +1,302 @@ +#!/usr/bin/env python3 +"""Exact finite corroboration of the split-only tensor feasibility theorem.""" + +from collections import Counter +from fractions import Fraction +from hashlib import sha256 +from itertools import product +import json +from math import isqrt, prod +from pathlib import Path +import sys + + +BITS = 96 +SCALE = 1 << BITS +FILES = ("PROOF.md", "README.md", "SOURCES.json", "TASK.json", "VERIFY.json", "verify.py") + + +def require(condition, message): + if not condition: + raise ValueError(message) + + +def integer_root(n, degree): + require(type(n) is int and n >= 0, "invalid radicand") + require(type(degree) is int and 1 <= degree <= 8, "invalid root degree") + if degree == 2: + return isqrt(n) + low, high = 0, 1 << ((n.bit_length() + degree - 1) // degree) + for _ in range(high.bit_length() + 1): + if high - low <= 1: + break + middle = (low + high) // 2 + if middle**degree <= n: + low = middle + else: + high = middle + require(low**degree <= n < (low + 1)**degree, "root bracket failed") + return low + + +def power_bounds(n, exponent): + require(type(n) is int and 0 <= n < 1 << 1024, "power input outside replay domain") + require(isinstance(exponent, Fraction) and 0 < exponent < 1, "invalid exponent") + require(exponent.denominator <= 8, "exponent outside replay domain") + a, b = exponent.numerator, exponent.denominator + scaled = n**a << (BITS * b) + root = integer_root(scaled, b) + low = Fraction(root, SCALE) + high = low if root**b == scaled else Fraction(root + 1, SCALE) + return low, high + + +def profile_ok(profile): + require(type(profile) is dict and 1 <= len(profile) <= 3, "invalid profile") + for rank, count in profile.items(): + require(type(rank) is int and 1 <= rank <= 81, "invalid rank") + require(type(count) is int and 1 <= count <= 8, "invalid multiplicity") + + +def tensor_histogram(profile, width): + profile_ok(profile) + require(type(width) is int and 1 <= width <= 64, "invalid tensor power") + current = {1: 1} + for _ in range(width): + following = Counter() + for left, multiplicity in current.items(): + for right, count in profile.items(): + following[left * right] += multiplicity * count + current = dict(following) + require(len(current) <= 5000, "histogram capacity exceeded") + require(sum(current.values()) == sum(profile.values())**width, "job count drift") + return current + + +def split_bounds(histogram, cap, exponent): + require(type(cap) is int and 1 <= cap < 1 << 1024, "invalid cap") + cap_low, cap_high = power_bounds(cap, exponent) + low, high = Fraction(0), Fraction(0) + for rank, count in histogram.items(): + quotient, remainder = divmod(rank, cap) + rem_low, rem_high = power_bounds(remainder, exponent) + low += count * (quotient * cap_low + rem_low) + high += count * (quotient * cap_high + rem_high) + return low, high + + +def check_one_job(): + checked = 0 + exponents = (Fraction(1, 4), Fraction(1, 3), Fraction(1, 2), + Fraction(2, 3), Fraction(3, 4), Fraction(7, 8)) + for exponent in exponents: + powers = [power_bounds(n, exponent) for n in range(97)] + for rank in range(1, 97): + for cap in range(1, 33): + low, high = split_bounds({rank: 1}, cap, exponent) + q, r = divmod(rank, cap) + if rank > cap: + require(low > powers[rank][1], "concave lower bound failed") + else: + require((low, high) == powers[rank], "unsplit job changed") + if r: + require(low > rank * powers[cap][1] / cap, "linear lower bound failed") + else: + require((low, high) == (q * powers[cap][0], q * powers[cap][1]), + "exact full-block equality failed") + require(high < rank * powers[cap][0] / cap + powers[rank][0], + "two-term upper bound failed") + checked += 1 + return checked + + +def check_partition_optima(): + checked = 0 + for cap in range(1, 9): + optimum = [(0,) * 9] + for rank in range(1, 33): + # Independent DP over every ordered capped integer partition. + best = None + for piece in range(1, min(cap, rank) + 1): + candidate = tuple(a + b for a, b in + zip(optimum[rank - piece], radical_vector(piece))) + if best is None or radical_less(candidate, best): + best = candidate + require(best is not None, "partition oracle has no candidate") + optimum.append(best) + q, r = divmod(rank, cap) + greedy = tuple(q * a + b for a, b in + zip(radical_vector(cap), radical_vector(r))) + require(best == greedy, "arbitrary-partition oracle disagrees") + checked += 1 + return checked + + +def radical_vector(n): + require(type(n) is int and 0 <= n <= 8, "radical outside oracle domain") + vector = [0] * 9 + if n: + for factor in range(isqrt(n), 0, -1): + if n % (factor * factor) == 0: + vector[n // (factor * factor)] = factor + break + return tuple(vector) + + +def radical_less(left, right): + if left == right: + return False + low, high = Fraction(0), Fraction(0) + for n, coefficient in enumerate(a - b for a, b in zip(left, right)): + lo, hi = power_bounds(n, Fraction(1, 2)) + low += coefficient * (lo if coefficient >= 0 else hi) + high += coefficient * (hi if coefficient >= 0 else lo) + require(high < 0 or low > 0, "radical comparison did not separate") + return high < 0 + + +def profiles(): + result = [] + for counts in product(range(3), repeat=3): + if any(counts): + result.append({r: n for r, n in zip((1, 4, 9), counts) if n}) + require(len(result) == 26, "profile domain changed") + return result + + +def check_histograms(): + checked, decisions, witnesses, max_width = 0, 0, 0, 0 + for profile in profiles(): + pt = sum(isqrt(r) * n for r, n in profile.items()) + p1 = sum(r * n for r, n in profile.items()) + for base in (1, 4, 9): + rate = max(Fraction(pt), Fraction(p1, isqrt(base))) + for width in range(1, 7): + histogram = tensor_histogram(profile, width) + low, high = split_bounds(histogram, base**width, Fraction(1, 2)) + require(low >= rate**width, "tensor lower rate failed") + require(high <= pt**width + Fraction(p1, isqrt(base))**width, + "tensor upper rate failed") + checked += 1 + for target in range(1, 33): + decisions += 1 + if rate >= target: + # The universal lower bound excludes EVERY power. + continue + for width in range(1, 65): + if 2 * rate**width < target**width: + break + else: + raise ValueError("sufficient witness exceeded finite replay budget") + histogram = tensor_histogram(profile, width) + _, high = split_bounds(histogram, base**width, Fraction(1, 2)) + require(high < target**width, "constructed tensor witness failed") + witnesses += 1 + max_width = max(max_width, width) + return checked, decisions, witnesses, max_width + + +def check_literal_jobs(): + sequences, contexts = 0, 0 + for profile in profiles(): + atoms = tuple(r for r, n in profile.items() for _ in range(n)) + if len(atoms) > 4: + continue + for width in range(1, 5): + literal = Counter() + for sequence in product(atoms, repeat=width): + literal[prod(sequence)] += 1 + sequences += 1 + require(dict(literal) == tensor_histogram(profile, width), "literal jobs disagree") + for base in (2, 3): + cap = base**width + pieces = Counter() + for rank, count in literal.items(): + # Explicit pieces, rather than the quotient-weighted price. + remaining = rank + for _ in range(rank // cap + 1): + if not remaining: + break + piece = min(cap, remaining) + pieces[piece] += count + remaining -= piece + require(remaining == 0, "literal partition incomplete") + price = [Fraction(0), Fraction(0)] + for piece, count in pieces.items(): + lo, hi = power_bounds(piece, Fraction(1, 2)) + price[0] += count * lo + price[1] += count * hi + require(tuple(price) == split_bounds(literal, cap, Fraction(1, 2)), + "literal partition price disagrees") + contexts += 1 + return sequences, contexts + + +def check_boundaries(): + half = Fraction(1, 2) + for width in range(1, 13): + # Raw moment and rank-one surplus do not suffice at c=2. + low, _ = split_bounds(tensor_histogram({9: 1}, width), 2**width, half) + require(low > 6**width, "unsafe raw-moment-only rule survived") + # Equality in the raw and linear bounds each blocks strict advantage. + require(split_bounds(tensor_histogram({4: 2}, width), 9**width, half) == + (Fraction(4**width), Fraction(4**width)), "raw equality changed") + require(split_bounds(tensor_histogram({16: 1}, width), 4**width, half) == + (Fraction(8**width), Fraction(8**width)), "linear equality changed") + require(split_bounds({17: 1}, 4, half) == (9, 9), "first-power equality lost") + require(split_bounds({289: 1}, 16, half) == (73, 73), "second-power win lost") + require((17 // 4) * 2 == 8 < 9, "remainder control lost") + return 39 + + +def check_rejections(): + rejected = 0 + invalid = ({}, {0: 1}, {-1: 1}, {1: 0}, {1: -1}, {True: 1}, {1: True}, {82: 1}) + for profile in invalid: + try: + tensor_histogram(profile, 1) + except ValueError: + rejected += 1 + else: + raise ValueError("invalid profile accepted") + for exponent in (Fraction(0), Fraction(1), Fraction(-1, 2), Fraction(1, 9)): + try: + power_bounds(2, exponent) + except ValueError: + rejected += 1 + else: + raise ValueError("invalid exponent accepted") + for cap in (0, -1, True): + try: + split_bounds({1: 1}, cap, Fraction(1, 2)) + except ValueError: + rejected += 1 + else: + raise ValueError("invalid cap accepted") + return rejected + + +def main(): + require(len(sys.argv) == 1, "this verifier takes no arguments") + report = {"one_job_splits": check_one_job(), + "partition_optima": check_partition_optima()} + hist, decisions, witnesses, width = check_histograms() + report.update(histogram_checks=hist, feasibility_cases=decisions, + attaining_power_witnesses=witnesses, largest_witness_power=width) + report["literal_sequences"], report["literal_partition_contexts"] = check_literal_jobs() + report["boundary_checks"] = check_boundaries() + report["rejected_inputs"] = check_rejections() + root = Path(__file__).resolve().parent + hashes = {} + for name in FILES: + with (root / name).open("rb") as stream: + data = stream.read(256 * 1024 + 1) + require(len(data) <= 256 * 1024, "package file exceeds receipt bound") + hashes[name] = sha256(data).hexdigest() + report["package_sha256"] = hashes + print(json.dumps(report, sort_keys=True, indent=2)) + print("PASS_SPLIT_ONLY_TENSOR_FEASIBILITY") + + +if __name__ == "__main__": + main()