From e2021d1c9e06948528cbc0a8fd7079b671da981d Mon Sep 17 00:00:00 2001 From: Jerry Chen Date: Tue, 13 Oct 2026 08:16:47 +0000 Subject: [PATCH] Research: batch common-factor product shears with dirty restoration Add a scoped multi-output interface, exact 246-vs-680 factor-call fixture, complete local cost recurrence, independent replay and corruption controls. No new kappa. Prepared with substantial OpenAI Codex assistance. --- research/dirty-fanout-batch/CERTIFICATE.json | 175 ++++++++++++ research/dirty-fanout-batch/CLAIM.md | 29 ++ research/dirty-fanout-batch/NOTICE.md | 31 +++ research/dirty-fanout-batch/README.md | 227 +++++++++++++++ research/dirty-fanout-batch/SOURCES.json | 27 ++ research/dirty-fanout-batch/VALIDATION.md | 43 +++ research/dirty-fanout-batch/batch.py | 105 +++++++ .../dirty-fanout-batch/sources/DIRTY-PROOF.md | 128 +++++++++ research/dirty-fanout-batch/sources/NOTICE.md | 24 ++ research/dirty-fanout-batch/sources/dirty.py | 133 +++++++++ research/dirty-fanout-batch/test_package.py | 42 +++ research/dirty-fanout-batch/verify.py | 261 ++++++++++++++++++ 12 files changed, 1225 insertions(+) create mode 100644 research/dirty-fanout-batch/CERTIFICATE.json create mode 100644 research/dirty-fanout-batch/CLAIM.md create mode 100644 research/dirty-fanout-batch/NOTICE.md create mode 100644 research/dirty-fanout-batch/README.md create mode 100644 research/dirty-fanout-batch/SOURCES.json create mode 100644 research/dirty-fanout-batch/VALIDATION.md create mode 100644 research/dirty-fanout-batch/batch.py create mode 100644 research/dirty-fanout-batch/sources/DIRTY-PROOF.md create mode 100644 research/dirty-fanout-batch/sources/NOTICE.md create mode 100644 research/dirty-fanout-batch/sources/dirty.py create mode 100644 research/dirty-fanout-batch/test_package.py create mode 100644 research/dirty-fanout-batch/verify.py diff --git a/research/dirty-fanout-batch/CERTIFICATE.json b/research/dirty-fanout-batch/CERTIFICATE.json new file mode 100644 index 0000000000..103a6526a7 --- /dev/null +++ b/research/dirty-fanout-batch/CERTIFICATE.json @@ -0,0 +1,175 @@ +{ + "base": "f567884aeb8851b6e794af1184119a3bfbe1e631", + "binary_optimum_domain": "all ordered binary splits, unweighted n=1..64", + "controls": [ + "omit_final_leaf", + "reverse_factor_order", + "change_common_source_during_batch", + "omit_common_restoration", + "negate_without_reverse", + "omit_one_output", + "empty_common", + "empty_output_list", + "insufficient_scratch", + "ancestor_alias", + "target_source_alias", + "coefficient_alias", + "boolean_sign", + "nonlinear_left_map_has_dirty_cross_term", + "rounded_left_map_is_not_exact_linear_map" + ], + "dense_cases": 795, + "rational_cases": 1, + "rounded_cases": 27, + "scope": "Exact linear multi-output interface; no instantiated supplier, rounded inverse theorem, or new kappa", + "seed": 58, + "seed_case": { + "common_factors": 8, + "dirty_arrays": 4, + "invoices": { + "batch": { + "additions": 2952, + "calls_by_factor": { + "0": 16, + "1": 16, + "10": 4, + "11": 4, + "12": 8, + "13": 8, + "14": 8, + "15": 8, + "16": 8, + "17": 8, + "18": 8, + "19": 8, + "2": 16, + "20": 8, + "21": 16, + "22": 16, + "3": 16, + "4": 16, + "5": 16, + "6": 16, + "7": 16, + "8": 2, + "9": 4 + }, + "coefficient_reads": 2214, + "coefficient_storage_words": 207, + "data_storage_words": 30, + "head_travel_word_slots": 458208, + "instruction_records": 246, + "leaf_calls": 246, + "multiplications": 2214, + "negations": 369, + "preflight_array_length_checks": 10, + "preflight_coefficient_alias_pairs": 7380, + "preflight_matrix_row_length_checks": 738, + "preflight_role_alias_entries": 10, + "source_reads": 2214, + "target_read_writes": 738 + }, + "grouped": { + "additions": 9096, + "calls_by_factor": { + "0": 80, + "1": 80, + "10": 4, + "11": 4, + "12": 8, + "13": 8, + "14": 8, + "15": 8, + "16": 8, + "17": 8, + "18": 8, + "19": 8, + "2": 80, + "20": 8, + "21": 16, + "22": 16, + "3": 80, + "4": 80, + "5": 80, + "6": 80, + "7": 80, + "8": 2, + "9": 4 + }, + "coefficient_reads": 6822, + "coefficient_storage_words": 207, + "data_storage_words": 30, + "head_travel_word_slots": 885344, + "instruction_records": 758, + "leaf_calls": 758, + "multiplications": 6822, + "negations": 1137, + "preflight_array_length_checks": 10, + "preflight_coefficient_alias_pairs": 22740, + "preflight_matrix_row_length_checks": 2274, + "preflight_role_alias_entries": 10, + "source_reads": 6822, + "target_read_writes": 2274 + }, + "separate": { + "additions": 8160, + "calls_by_factor": { + "0": 40, + "1": 56, + "10": 16, + "11": 8, + "12": 16, + "13": 16, + "14": 16, + "15": 8, + "16": 16, + "17": 16, + "18": 16, + "19": 16, + "2": 56, + "20": 16, + "21": 16, + "22": 16, + "3": 56, + "4": 72, + "5": 56, + "6": 48, + "7": 72, + "8": 16, + "9": 16 + }, + "coefficient_reads": 6120, + "coefficient_storage_words": 207, + "data_storage_words": 30, + "head_travel_word_slots": 998624, + "instruction_records": 680, + "leaf_calls": 680, + "multiplications": 6120, + "negations": 1020, + "preflight_array_length_checks": 10, + "preflight_coefficient_alias_pairs": 20400, + "preflight_matrix_row_length_checks": 2040, + "preflight_role_alias_entries": 10, + "source_reads": 6120, + "target_read_writes": 2040 + } + }, + "left_factors": [ + 1, + 2, + 3, + 4, + 5 + ], + "word_sha256": { + "batch": "a8a8a350ea43fec5769f393de1eb077c51216a5aa2cbec7046511f58fd8fa970", + "grouped": "de2b43e1f8d00c93a1a6a8c90378713fdc8d59d42339f40a7a59a23b4cba7818", + "separate": "50f414e6ea161dc6ab1f54c90bf100ebe3ec1433d9b8fb84c8e9b2832f636828" + } + }, + "short_star_words_rejected": 9331, + "status": "PASS_DIRTY_FANOUT_BATCH", + "symbolic_cases": 128, + "tape_cases": 15, + "weighted_cases": 384 +} diff --git a/research/dirty-fanout-batch/CLAIM.md b/research/dirty-fanout-batch/CLAIM.md new file mode 100644 index 0000000000..2117764e24 --- /dev/null +++ b/research/dirty-fanout-batch/CLAIM.md @@ -0,0 +1,29 @@ +# Sprint claim: dirty common-factor fanout + +- Track: recursive interfaces; OS-random seed **58** (Python secrets.randbelow(100)). +- Exact base: `f567884aeb8851b6e794af1184119a3bfbe1e631`. +- Object: simultaneous independent output shears `y_i += A_i B x` with a shared, unchanged input and entirely dirty workspace. +- Method: one batched dirty commutator, exact noncommutative replay, a restricted-query lower bound, and complete weighted recursive cost/storage accounting. +- Seed choices: fanout `2 + 58 % 5 = 5`, common factor length `1 + 58 % 17 = 8`; left lengths 1 through 5. +- Deliverable: scoped interface construction and standalone exact verifier/certificate; no new kappa. +- Finish target: 2026-10-13 08:29 UTC (19:29 Australia/Melbourne). Final 10 minutes reserved for verification and handoff. + +Three candidates were considered: cancellation of repeated transparent calls; deferred sibling cleanup; shared common-right-factor output batching. The first overlaps PR840's native dyadic pair; the second overlaps PR822's dirty connector reuse and PR714/788 clean checkpoints. The third changes the multi-output contract and retains conservative private scratch. + +At claim time the public issues page listed only #650, with no pinned sprint coordination issue. GitHub API read access returned `Forbidden`; no claim was posted. Public open-PR metadata was checked through #856, plus searches for boundary, echo/checkpoint/batch/prefix, common right factor, fanout and multiple outputs. Relevant context: #628, #663, #673, #689, #714, #730, #788, #822, #840. Existing echo work changes decomposition/scratch for one product output; this work batches distinct outputs sharing B. No claim of general algebraic novelty or first discovery is made. + +Selected state read: #799/#589, kappa `1661634653669567/10^18`, its actual X4 proof note and maintainer review. This package does not change that construction. + +## Result update + +Completed one scoped construction: common-factor multi-output batching with +246 versus 680 complete binary factor-shear calls and four dirty arrays. +The proof, full weighted/storage/routing/precision bill, exact certificate, +independent checks and controls are in [README.md](README.md) and +[VALIDATION.md](VALIDATION.md). There is no new κ or admitted supplier. + +The overlap refresh reached #859 and explicitly distinguished #793's scalar +coefficient batching. No coordination issue was found. API access is denied, +so the completed contribution is handed off as one local commit and clean patch; +no external claim or PR was posted. Existing source and the selected frontier +remain unchanged. diff --git a/research/dirty-fanout-batch/NOTICE.md b/research/dirty-fanout-batch/NOTICE.md new file mode 100644 index 0000000000..7c5788e076 --- /dev/null +++ b/research/dirty-fanout-batch/NOTICE.md @@ -0,0 +1,31 @@ +# Attribution and scope + +Prepared for the requesting contributor with substantial OpenAI Codex assistance +in the mathematical argument, implementation, tests and prose. The user's human +identity is not asserted. This package uses the repository's Apache-2.0 license. + +Chafik Boukhalfa / chafreaky's PR628 supplies the dirty product commutator, +literal-inverse convention, exact restoration contract and rounded-error +analysis. Its reference source, proof and notice are retained byte for byte. +Ali Romman's PR621 and OpenAI's exact-DFT/Newton framework are inherited context; +we do not use their analytic kernel claims to certify the abstract matrices here. +The commutator and batching algebra are classical; no literature-priority claim +is made. + +Relevant concurrent work inspected: androolloyd's PR673 (multiway dirty echo), +commdata2338's PR677 (native DATA-query contract), Dillon Amburgey's PR689 +(ternary placement), FanPUYen's PR714 (clean root checkpoint), Sagar Thakrar's +PR730 (fixed scratch optimization), nightangelflowerwin-ops's PR788 (reusable +clean checkpoint), PR822 (dirty sibling connector reuse), and Wentao Li's PR840 +(dyadic ADDRESS-query pair). These concern different contracts or one-output +schedules. Their code is not consumed; no relative optimality against their +broader classes is claimed. Varun Mittal's PR793 batches scalar coefficient +preparation in historical JP8 compensation and preserves its recursive profile; +this package instead batches full product-query calls under a different abstract +multi-output contract. No PR793 code or claimed savings are consumed. PR663's nonlinear-restoration distinction is +acknowledged and explicitly respected by the rounded controls. + +The accepted frontier's authors and source lineage retain all attribution. +This local multi-output result supplies neither a new κ nor an instantiated +current supplier, physical tape compiler, full theorem formalization, human +peer review or measured performance result. diff --git a/research/dirty-fanout-batch/README.md b/research/dirty-fanout-batch/README.md new file mode 100644 index 0000000000..400761138d --- /dev/null +++ b/research/dirty-fanout-batch/README.md @@ -0,0 +1,227 @@ +# Batch product shears with a common right factor + +**Recursive-interface construction; no new κ.** This package supplies an exact +multi-output version of the dirty product commutator from Chafik Boukhalfa's +[PR628](https://github.com/CrocSwap/integer-mult-bounds/pull/628), with a literal +instruction generator, complete local cost recurrence, a restricted-query +optimality argument, and independent exact checks. + +For the seed-58 fixture, five outputs share eight rightmost factors. Batching +uses **246 primitive factor-shear calls**, versus **680** for five separate +balanced binary products, with **four borrowed dirty arrays in either case**. +The comparison is between these explicit binary schedules. Multiway echoes and +arbitrary circuits are outside the comparison. The 434-call reduction (about +63.82%) is not a measured runtime or an integer-multiplication exponent gain. + +From the repository root, Python 3.9+ and the standard library suffice: + +```sh +python3 -I -O -B research/dirty-fanout-batch/verify.py +``` + +Expected: `PASS_DIRTY_FANOUT_BATCH`, 128 free-word cases, 795 dense cases, +`680 -> 246 leaves`, four dirty arrays. The default command checks the complete +committed [certificate](CERTIFICATE.json); `--write` regenerates it instead. +`python3 -I -O -B research/dirty-fanout-batch/test_package.py` checks relocation +and rejects deliberately broken packages. + +## Contract and exact identity + +Let x, y_1,...,y_k and every borrowed array be independent arbitrary elements +of R^L, with distinct storage and unchanged read-only coefficients. R may be a +noncommutative ring; A_i and B are additive linear operators, in the indicated +order. The goal is simultaneously + +``` +x -> x, y_i -> y_i + A_i B x, all borrowed arrays restored. +``` + +A child `target += F(source)` preserves its source and all its own scratch. +It is independent of the target's previous value. Its negative call is the +literal reverse instruction word with signs reversed. Every source/target and +coefficient array is excluded from borrowed storage. All outputs are reserved +throughout the batch. No concurrent observer may use the temporary output +values. Common B and its input x must stay identical across the two calls. + +With one arbitrary dirty connector z, execute: + +1. `z += B x`. +2. For every i, `y_i += A_i z`. +3. `z -= B x`. +4. For every i in reverse order, `y_i -= A_i z`. + +The two observed values of z are z_0+B x and z_0. Thus the increment is +A_i(z_0+B x)-A_i z_0=A_i B x. All dirt cancels, and z returns to z_0. No +commutation of A_i with B, or of individual factors, is used. Neither A_i +nor B needs to be invertible; their additive shears are invertible. Distinct output +ports make the A_i calls commute with one another after their private scratch +has been restored. The emitted negative block nevertheless uses the literal +inverse, so no extra commutation assumption is needed for its implementation. + +This is the familiar commutator identity applied to a direct-sum output map; +we make no algebraic or literature-priority claim. The contribution is the +explicit batched interface, executable factor lowering, pricing, and controls. +It changes the demanded output family; it is not a new single-output echo tree. + +### A sharp bound in the specified star-query model + +Allow only signed queries `z += ±B x` and `y_i += ±A_i z`, with one connector, +read-only x, private query scratch restored before return, and no other data +operations. Treat the maps as free formal operators. At an A_i query, write +z=z_0+t Bx. Final dirt independence forces the signed coefficient sum on A_i z_0 +to vanish, while correctness requires the signed sum of the corresponding t's +to be one. Therefore there must be at least two A_i queries for every output. +At least one B query is needed for a nonzero signal; restoration of z requires +at least one opposite B query. Hence every admissible word uses at least +`2k+2` queries. The construction attains it, including under arbitrary positive +per-operator query prices. This does not bound models admitting combined-output +queries, extra connectors, direct A_i B queries, or other linear operations. + +The finite regression exhausts all 9,331 signed star words of lengths zero +through five for k=2. Their failure supports the implementation of the universal +argument above; enumeration is not the proof of that argument. + +## Recursive lowering and exact cost + +Factor lists are in **application order**: `[B0,B1,A0]` means A0 B1 B0. +Each product is lowered with PR628's balanced binary dirty commutator, using +one distinct array per active recursion level. All child calls operate on +**full length-L rows**. Batching never divides their charged volume by k. +Let C(F;L,w) be the complete cost of an additive product child, with both signs +bounded by the same price and with its heads returned to the documented entry +positions. For a leaf j let c_j include arithmetic, source and coefficient +access, target update, phase/descriptor work, routing and head returns. Then + +``` +C([j]) = c_j + dispatch_leaf +C(F_right followed by F_left) + = 2 C(F_right) + 2 C(F_left) + dispatch_node +C_batch = 2 C(B) + 2 sum_i C(A_i) + dispatch_batch. +``` + +No child or inverse is free. The unbatched *same-root-split* comparator costs +`2k C(B) + 2 sum C(A_i) + dispatch_separate`, so the recursive saving is +`2(k-1) C(B)` before comparing dispatch and layout overhead. If source access, +layout or external frames differ, use their actual c_j; the operation count +alone does not imply a bit-cost improvement. + +For an unweighted balanced product of n factors, L(1)=1 and +L(n)=2L(floor(n/2))+2L(ceil(n/2)). Writing p=2^floor(log2 n), induction gives +L(n)=p(3n-2p). Scratch is ceil(log2 n). The batch's dirty requirement is +`1 + max(ceil(log2 |B|), max_i ceil(log2 |A_i|))`, in addition to its source +and k output arrays. Child scratch is reused only after return; all sibling +outputs remain excluded. There is no clean length-L array. + +For seed 58, k=2+(58 mod 5)=5, |B|=1+(58 mod 17)=8, and |A_i|=i: + +| Schedule | Complete leaf calls | Dirty arrays | +|---|---:|---:| +| Separate products, each split into the common B and its A_i | 758 | 4 | +| Separate balanced products of lengths 9,10,11,12,13 | 680 | 4 | +| Shared B batch | 246 | 4 | + +A separate integer DP checks the minimum over all ordered **binary** splits +for n=1,...,64 and agrees with the balanced counts. No all-arity optimum is +asserted; PR673, PR730 and PR822 investigate different tree/allocation classes. +The certificate lists exact per-factor multiplicities and three positive +nonuniform price assignments for every sampled batch, rather than crediting +only the convenient common-factor calls. + +### Fully charged dense reference realization + +There is also a simple, deliberately slow implementation of each matrix leaf. +For every target entry, form the dot product in one scalar accumulator, then +add/subtract it to the target. All matrix coefficients are read-only. The +source and target rows are distinct. The certificate records, for each schedule +on identical 3-by-3 inputs and the same role layout: + +- N L² coefficient reads and N L² source reads; +- N L target read/write updates; +- N L² multiplications, N L(L+1) additions (including zero-initialized sums), + and one sign negation per negative target update; +- literal one-tape head travel, measured in word slots, including returning + to slot zero after **every** primitive call; +- coefficient storage, data storage and every emitted instruction record; +- array-length/role-alias checks and the explicit preflight matrix-row and + coefficient-alias checks (N L and N R L respectively, for R live roles). + +The tape layout puts all mutable rows first and the coefficient matrices +second. Within a dot product it visits coefficient then source for each term, +then the destination, and returns home at leaf end. The head-travel sum is +`sum |next_position-current_position|` for that literal trace. Coefficients and +source entries must be loaded into a constant number of scalar arithmetic +ports. This reference makes no locality or free-gather assumption. + +For word size w, multiply this travel by w, add O(w) per load/store, the listed +counts times integer multiplication/addition costs M(w), A(w), and charge +O(N(log(number of roles)+log(number of factors))) instruction/control bits +and O(N) generator records. Also charge the listed descriptor/alias preflight +comparisons at the required index/pointer bit width; they are not arithmetic +leaf calls. This invoice describes the reference algorithm, not CPython +interpreter wall time. Input coefficient preparation is additional and +paid once for each distinct factor, equally available to both comparators. +The seed matrices are already supplied exact integers; a cyclic-inverse or +phase oracle would need its own preparation and validation bill. + +For integer matrices of row norm at most K=L H, input magnitude at most D, +and N leaf calls, exact states are bounded by D(1+K)^N. Thus signed word length +`2 + ceil(log2(max(1,D))) + N ceil(log2(1+K))` suffices. The same conservative +word length from the larger comparator can be used for all schedules. This +is a finite dense-matrix realization, not an efficient common-label/tape +compiler for the selected supplier. + +## Rounded leaves: restoration and accuracy are different + +A deterministic grid leaf `target += F(source)` can be inverted exactly by +subtracting the same computed increment. Literal inverse words then restore +all source/borrowed arrays even when F is nonlinear from rounding, provided +read-only data and all excluded arrays are respected. B's paired calls see +the same source and deeper dirt: intervening A_i calls restore their source +z and private scratch. The final A_i calls use the restored connector. + +The target increment need not be the exact, dirt-independent A_i Bx in this +case. For example floor((z+1)/2)-floor(z/2) depends on dirty z. We include this +negative control and make no substitution of approximate linearity for exact +linearity in the identity or query minimum above. + +For a separate accuracy bound, suppose the ideal primitive operators have +infinity norm at most K and each rounded primitive's increment error is at +most u, uniformly on the actual trajectory. A full ideal shear has norm at +most 1+K. Telescoping the N perturbed shears gives + +``` +error <= u sum_(j=0)^(N-1) (1+K)^j <= N u (1+K)^(N-1). +``` + +For u=2^-w, `w >= p + ceil(log2 N) + (N-1)ceil(log2(1+K))` suffices for error +at most 2^-p. Actual state magnitudes are bounded by (D+1)(2+K)^N for u<=1, +which must also be included in integer-word storage. Coefficient perturbation +and preparation errors must be added separately; source-dependent error +bounds require checking the resulting magnitude bound, not silently using +this uniform-u premise. Twenty-seven exact grid experiments compare a floor +rounding interpreter with independent dense ideal products and check the full +error bound and exact all-role reversal. + +## Verification scope, provenance and stopping rule + +[CLAIM.md](CLAIM.md) records the OS seed, three candidates, overlap review and +local claim. Exact base: `f567884aeb8851b6e794af1184119a3bfbe1e631`. +[Source pins](SOURCES.json) retain the original proof, implementation reference +and notice from PR628 at `0768f97d06c623b8211e651543c66135796b62bf`, with Git +blob and SHA256 hashes. Those source files are references; their cyclic-scan +implementation is not imported or asserted to have been revalidated here. + +The test domain is fixed: common lengths 1..16, fanout 1..8 with left lengths +1..k; dense domains/fixtures listed in verify.py; and the seed-selected example. +Random dense inputs use Python Random(58); the track draw used OS randomness. +This is a bounded constructive check, not a search for a new multiplication +bound or an impossibility claim outside the stated star-query model. + +The selected #799/#589 result at this base is κ=1661634653669567/10^18. Its +native calls are not assumed to have the shared source, coefficient, frame, +volume and exclusivity contract used here. No current invoice term is removed. +Existing owner obligations, ordinary child widths, read-only source access, +common-label realization, precision, layout and all-size analytic transfer +remain unresolved for any supplier application. This package changes no +selected certificate or upstream manuscript. See [NOTICE.md](NOTICE.md) for +attribution and substantial AI assistance. diff --git a/research/dirty-fanout-batch/SOURCES.json b/research/dirty-fanout-batch/SOURCES.json new file mode 100644 index 0000000000..c9b4e7166d --- /dev/null +++ b/research/dirty-fanout-batch/SOURCES.json @@ -0,0 +1,27 @@ +{ + "base": "f567884aeb8851b6e794af1184119a3bfbe1e631", + "dependency_pr": 628, + "files": [ + { + "path": "sources/DIRTY-PROOF.md", + "upstream_path": "research/prime-power-cyclic-scan/DIRTY-PROOF.md", + "commit": "0768f97d06c623b8211e651543c66135796b62bf", + "sha256": "bb7c2fdc1c4673d56531fd56fb8790c81a16813ac152c10f1afabc9efdd70d61", + "git_blob": "caf4aafc784a630d61ca7874a0bd19cbcb34e585" + }, + { + "path": "sources/dirty.py", + "upstream_path": "research/prime-power-cyclic-scan/dirty.py", + "commit": "0768f97d06c623b8211e651543c66135796b62bf", + "sha256": "09e7f41141594e6540828330d27be27c083ee6569660ae42c0cd519b09fc8d21", + "git_blob": "2b9471083706a37519a1af7598e012f5fecf2636" + }, + { + "path": "sources/NOTICE.md", + "upstream_path": "research/prime-power-cyclic-scan/NOTICE.md", + "commit": "0768f97d06c623b8211e651543c66135796b62bf", + "sha256": "abeacf1ad1491d5797cfcf1f3832799bbf3b24b99597229d7bc884059a51ec68", + "git_blob": "22fbeb8ef0a28dd6b3feea718492091319ceb96e" + } + ] +} diff --git a/research/dirty-fanout-batch/VALIDATION.md b/research/dirty-fanout-batch/VALIDATION.md new file mode 100644 index 0000000000..8099d1e57d --- /dev/null +++ b/research/dirty-fanout-batch/VALIDATION.md @@ -0,0 +1,43 @@ +# Validation receipt + +Executed on Linux x86_64, CPython 3.12.14. No third-party package is needed. +The exact base is `f567884aeb8851b6e794af1184119a3bfbe1e631`. + +| Check | Outcome | +|---|---| +| `python3 -I -B research/dirty-fanout-batch/verify.py` | PASS; complete committed certificate matches | +| Same with `-O` | PASS; checks use explicit exceptions, not assertions | +| `python3 -I -O -B research/dirty-fanout-batch/test_package.py` | PASS outside the checkout in a path with spaces; all six corruption controls rejected | +| Three retained PR628 files vs fetched exact Git objects | Byte-identical; SHA256 and Git blob pins also verified offline | +| `python3 -B scripts/verify_selected_result.py` | PASS, selected κ = 1661634653669567/10^18 | +| `python3 -B -m unittest discover -s tests -p test_selected_result.py -v` | All five existing tests passed | + +Completed mathematical coverage: 128 free noncommutative word cases and literal +inverses; 384 nonuniform weighted price cases; integer DP over all binary splits +for n=1..64; 795 dense cases (each compared across three schedules and their +inverses), including integers and moduli 2,3,5,9; one rational noncommuting case; +15 independent closed-form tape-travel cases; 27 rounded-grid cases with exact dirty restoration, inverse and error bound; +all 9,331 signed two-output star words shorter than six queries; and 15 named +algebraic/admission controls. The package test additionally rejects a damaged +source pin, changed certificate, omitted restoration, wrong inverse order and +unpaid child, and unpaid head return. Expected-failure controls are separate from passing examples. + +This adds a standalone research package and no production/selected-supplier +changes. The repository-wide regeneration suite and expensive selected-supplier +cold replay were not rerun for this package. No hosted CI, proof-assistant or +human peer-review pass is claimed. Timing is not a contribution claim. + +The final public overlap refresh reached #859 (656 open PRs). Targeted searches +covered common factors, fanout, multiple outputs, multi-output, and batch/dirty; +the latter returned 24 PRs, all on one page. Relevant additional comparison: +PR793 at `f9383f324ee86793c5ae7b73f8e39d5827a8aa52` shares JP8 coefficient +preparation while leaving recursive calls unchanged. This package changes the +number of full-row product queries under an explicit multi-output contract. +PR859's public description was a template; no mathematical overlap could be +inferred from that description. We do not claim an exhaustive review of every +open PR or priority over unpublished work. + +GitHub API requests returned `Forbidden`, including the repository permissions +read, while HTTPS Git and public web metadata reads worked. No PR or issue +comment was submitted. The local claim, commit and clean patch provide the +handoff requested for unavailable submission access. diff --git a/research/dirty-fanout-batch/batch.py b/research/dirty-fanout-batch/batch.py new file mode 100644 index 0000000000..499db25870 --- /dev/null +++ b/research/dirty-fanout-batch/batch.py @@ -0,0 +1,105 @@ +"""Exact common-right-factor batching. Apache-2.0; see NOTICE.md.""" +from collections import Counter + + +def need(condition, message): + if not condition: + raise ValueError(message) + + +def inverse(word): + return [(f, x, y, -s) for f, x, y, s in reversed(word)] + + +def product(factors, source, target, scratch): + """Factors are in application order, so [B, A] means A B.""" + need(bool(factors), 'empty factor list') + need(len(scratch) >= (len(factors)-1).bit_length(), 'insufficient scratch') + need(len(set([source, target] + list(scratch))) == 2+len(scratch), 'aliased roles') + if len(factors) == 1: + return [(factors[0], source, target, 1)] + mid = len(factors)//2 + z, *rest = scratch + right = product(factors[:mid], source, z, rest) + left = product(factors[mid:], z, target, rest) + return right + left + inverse(right) + inverse(left) + + +def compile_batch(common, branches, mode='batch'): + """Return (literal leaf word, dirty role count), reserving all output roles.""" + need(bool(common) and bool(branches) and all(branches), 'nonempty factors and outputs required') + need(mode in ('batch', 'separate', 'grouped'), 'unknown comparator') + k = len(branches) + depth = max((len(common)-1).bit_length(), *((len(a)-1).bit_length() for a in branches)) + dirt = max(1+depth, max((len(common)+len(a)-1).bit_length() for a in branches)) + scratch = list(range(k+1, k+1+dirt)) + if mode == 'separate': + return [op for i, a in enumerate(branches, 1) + for op in product(common+a, 0, i, scratch)], dirt + right = product(common, 0, scratch[0], scratch[1:]) + lefts = [product(a, scratch[0], i, scratch[1:]) for i, a in enumerate(branches, 1)] + if mode == 'grouped': + return [op for left in lefts for op in right+left+inverse(right)+inverse(left)], dirt + # Distinct targets and read-only shared source make these left words commute. + left = [op for word in lefts for op in word] + return right + left + inverse(right) + inverse(left), dirt + + +def run(word, matrices, arrays, modulus=None): + """Literal exact leaf interpreter; validate every alias before any mutation.""" + need(len({id(v) for v in arrays}) == len(arrays), 'aliased arrays') + n = len(arrays[0]) + need(n > 0 and all(len(v) == n for v in arrays), 'array lengths') + need(modulus is None or type(modulus) is int and modulus > 1, 'modulus') + for f, x, y, sign in word: + need(type(f) is int and f in matrices, 'unknown factor') + need(type(x) is int and type(y) is int and 0 <= x < len(arrays) and 0 <= y < len(arrays) and x != y, 'leaf ports') + need(type(sign) is int and sign in (-1, 1), 'leaf sign') + a = matrices[f] + need(len(a) == n and all(len(row) == n for row in a), 'matrix dimensions') + need(all(a is not v and row is not v for v in arrays for row in a), 'mutable coefficient alias') + for f, x, y, sign in word: + for i, row in enumerate(matrices[f]): + increment = sum(a*b for a, b in zip(row, arrays[x])) + arrays[y][i] += sign*increment + if modulus is not None: + arrays[y][i] %= modulus + + +def leaf_count(n): + need(type(n) is int and n > 0, 'positive factor count') + p = 1 << (n.bit_length()-1) + return p*(3*n-2*p) + + +def invoice(word, dimension, roles, factors): + """Dense reference leaf invoice, including literal head travel in word slots. + + Data rows precede the read-only coefficient matrices on one tape. Each leaf + starts and ends at word slot 0; the scalar accumulator is an arithmetic port. + This deliberately slow layout makes source access and head returns explicit. + """ + n = dimension + counts = Counter(f for f, _, _, _ in word) + moves = 0 + for f, x, y, _ in word: + head = 0 + for i in range(n): + for j in range(n): + for pos in (roles*n + f*n*n + i*n+j, x*n+j): + moves += abs(pos-head) + head = pos + pos = y*n+i + moves += abs(pos-head) + head = pos + moves += head + return dict(leaf_calls=len(word), calls_by_factor={str(f): counts[f] for f in range(factors)}, + coefficient_reads=len(word)*n*n, source_reads=len(word)*n*n, + target_read_writes=len(word)*n, multiplications=len(word)*n*n, + additions=len(word)*n*(n+1), negations=sum(s < 0 for _,_,_,s in word)*n, + head_travel_word_slots=moves, + preflight_array_length_checks=roles, preflight_role_alias_entries=roles, + preflight_matrix_row_length_checks=len(word)*n, + preflight_coefficient_alias_pairs=len(word)*roles*n, + coefficient_storage_words=factors*n*n, data_storage_words=roles*n, + instruction_records=len(word)) diff --git a/research/dirty-fanout-batch/sources/DIRTY-PROOF.md b/research/dirty-fanout-batch/sources/DIRTY-PROOF.md new file mode 100644 index 0000000000..caf4aafc78 --- /dev/null +++ b/research/dirty-fanout-batch/sources/DIRTY-PROOF.md @@ -0,0 +1,128 @@ +# Cyclic inverse shears with dirty array restoration + +This extends the classical rounded cyclic-inverse primitive of PR628. It removes +its need for a clean length-L intermediate array. It does not supply a common-label +Clifford realization, reversible bit arithmetic, transform layout, or the complete +integer-multiplication reduction. No new kappa follows from this lemma. + +## Contract + +Input x, target y and h borrowed arrays are complex dyadic grids of spacing u=2^-w. +Every array has length L>=1 and may initially contain arbitrary data. The arrays +are distinct. Their initial infinity norms are at most D. Read-only phases tau_i +have modulus one. Phase generation/storage and coefficient preparation are paid; +there is no free phase table. The primitive adds an approximation to Q(W)^-1 x +to y, restores x and every borrowed array exactly, and needs only a constant number +of clean scalar arithmetic registers besides loop counters and factor descriptors. +Here (Wx)_i=tau_i*x_(i-d), initially for d=+/-1 in a cyclic layout, and +Q(z)=r^-1 product_(j=1)^n(z-rho_j), n=r-1, with stable reciprocal/inner factors +of norm at most 1-beta. The final increment can depend on the initial dirt within +the stated approximation error. Exact independence of the increment from dirt is +not claimed for rounded arithmetic. + +## One factor + +First consider T x = y defined by y_i=x_i+b_i*y_(i-d), |b_i|<=1-beta. +Choose the cyclic order in direction d. Let z be the zero-boundary causal solution +and p_i the product of b from the first position through i. Let c be the complete +product. Then y_i=z_i+p_i*s, s=z_last/(1-c). The stable cyclic equation itself +implies ||y||<=B/beta when ||x||<=B, so |s|<=B/beta. + +On the dyadic grid, perform the causal pass directly in x, skipping the first +position: x_i += round(b_i*x_previous). These are integer lifts. Reversing their +order and subtracting the same rounded source products restores x exactly, +including arbitrary nonzero initial values. During the first pass also accumulate +the rounded scalar product c_hat. Compute s_hat=round(z_hat_last/(1-c_hat)). +In a second pass accumulate rounded prefix products p_hat_i and add +round(m_i*(z_hat_i+round(p_hat_i*s_hat))) to the appropriate target position. +Finally undo the causal lifts. Each target position is written exactly once; +its existing value never enters the computed increment. Scalar arithmetic and +coefficient scratch can be cleared classically; no reversible arithmetic gate +claim is made. Three passes suffice, excluding validation scans and paid +coefficient access. O(1) clean scalar words and O(log L) indexing bits suffice. + +Nearest complex rounding has norm error at most u. Assuming u<=beta^2/2, +|z_hat-z|<=u/beta, |p_hat-p|<=u/beta, |c_hat-c|<=u/beta, and +|1-c_hat|>=beta/2. Using s=z_last/(1-c), rather than separately bounding the +numerator and denominator, gives + + |s_hat-s| <= u + (2/beta)*(u/beta + (B/beta)*(u/beta)) + <= 5*(B+1)*u/beta^3. + +Also |p_hat|<=1+u/beta<=3/2. Hence the corrected output before m multiplication +has error at most 12*(B+1)*u/beta^3. If |m_i|<=r, the final rounded multiplication +has error at most a*(B+1)*u, a=13*(r+1)/beta^3. None of these constants depends +on L. + +For an outer root, b_i=rho^-1*tau_i, m_i=-rho^-1. For an inner root, scan in +direction -d with b_i=rho*conjugate(tau_(i+d)); the value at position i is +multiplied by conjugate(tau_i) and added at i-d. This is +(W-rho I)^-1=(I-rho W^-1)^-1 W^-1. The scalar r is included in one leaf's +multiplier. Each exact factor has operator norm at most K=r/beta. No permutation +of the mutable source array is required for the inner factor. + +## Product of factors + +For exact linear maps A,B and a dirty scratch array z, the sequence + + z += B*x; y += A*z; z -= B*x; y -= A*z + +adds AB*x to y and restores z. Split the factor list in halves recursively; +use one distinct borrowed array per recursion depth. A negative call executes +the exact inverse instruction word (reverse operation order and invert signs). +It is not obtained by negating signs in the original order. + +The rounded construction still restores every borrowed array and x exactly. +Inductively each call preserves its input and all deeper scratch, and its increment +is independent of its target. The paired calls computing B therefore see the same +input and deeper initial dirt. Never use an ancestor input or target as deeper +scratch: the ancestor target may have changed between the paired calls. This is +an explicit alias exclusion in the executable contract. + +There are h=ceil(log2 n) borrowed arrays and at most N=4*n^2 leaf calls. Pad to the +next power of two for this count if desired (identity leaves require no rounded +inverse). The implementation splits without padding and checks the actual count. + +For the ideal elementary shears, the joint max norm grows by at most C=1+K per +leaf. With a*u<=1 the computed trajectory satisfies + + M_j+1 <= G^j*(D+1), G=C+1. + +Comparing the complete rounded word with the ideal word on the same initial +arrays, and summing the propagated leaf errors, gives + + E_N <= N*a*(D+1)*u*G^(N-1). + +The ideal word cancels all borrowed initial data exactly. This proves the target +error bound for every length and every initial dirt bounded by D, while actual +restoration is exact without an error allowance. Choosing + + w >= p+1+ceil(log2(N*a*(D+1)))+(N-1)*ceil(log2 G) + +and enforcing a*u<=1 and u<=beta^2/2 gives execution error <=2^(-p-1). +PR628's coefficient/phase perturbation bound, budgeted to <=2^(-p-1) for the +original x, then gives total <=2^-p. That perturbation bound scales with ||x||; +for general input bound X use p+ceil(log2(max(1,X))) in its preparation budget. +The initial borrowed dirt does not enter the ideal operator perturbation bound. + +PR628 has log2(beta^-1)=O(r^3). Therefore these deliberately loose budgets need +w=O(p+log(D+1)+r^5) bits, and O(r^2) passes. Inside a leaf, the causal state and closure scalars add at most another +O(log(beta^-1)+log r) magnitude bits. Maximum transient magnitudes thus add +O(log(D+1)+r^5) integer bits, already covered by this word-size bound. Standard +fast fixed-precision arithmetic yields soft-O((L*r^2+r^3)*(p+log(D+1)+r^5)) +bit work plus charged phase-oracle and routing costs. Factor preparation and +coefficient enclosures are inherited from PR628. Borrowed storage is +O(L log r) words; clean arithmetic storage is O(w+log L) bits up to the chosen +multiplication implementation's workspace, plus O(r) read-only factor descriptors. +A machine with only a fixed number of dirty data arrays is not covered by this +contract. Arbitrary stride still incurs PR628's explicitly charged routing. + +## Executable evidence + +`dirty.py` uses exact rational arithmetic and explicit nearest dyadic rounding. +It checks generic variable-coefficient leaves, dense independently assembled +factor inverses, both orientations, nonzero targets, several initial dirty arrays, +exact source/scratch restoration, exact whole-word inversion, and the leaf count. +Finite checks support the implementation; the inequalities above are the all-L +argument. The exact-rational prototype does not itself implement the claimed +fast fixed-precision arithmetic cost. diff --git a/research/dirty-fanout-batch/sources/NOTICE.md b/research/dirty-fanout-batch/sources/NOTICE.md new file mode 100644 index 0000000000..22fbeb8ef0 --- /dev/null +++ b/research/dirty-fanout-batch/sources/NOTICE.md @@ -0,0 +1,24 @@ +# Attribution and scope + +Ali Romman's PR621, exact head 520774462b19b29af41554b74def31f9d01e997e, +supplies the prime-power kernel circle bound. Its kernel attribution is +OpenAI's exact-DFT preprint at adc7f1241b42e322a6451854ab7e4b4c146bf78a +(`loc:newton`, `loc:fourier-factorization`) and classical q-Pochhammer/Newton +factorization, including Alexey Kuznetsov's cited q-calculus work. This +package does not claim to originate those constructions. + +Pan's approximate-factorization theorem is used in the form stated by +Mehlhorn, Sagraloff and Wang; Brent's work supplies fast elementary-function +evaluation. Causal/anticausal recursive filtering is standard, as illustrated +by the Briand-Davy source listed in SOURCE.json. Sources are cited for these +specific tools, not as proofs of this package's complete claim. + +The scan rounding analysis, explicit budget composition, interval and +factor certificates, routed reference execution, and packaging were +prepared with substantial OpenAI Codex assistance for chafreaky. The dense +matrix solver and algebraic coefficient crosschecks provide independent +computational paths, not human peer review or formal Lean verification. + +No new multiplication exponent, literature priority, maintainer acceptance, +physical tape execution, or production performance result is claimed. +The code and documents use the repository's Apache-2.0 license. diff --git a/research/dirty-fanout-batch/sources/dirty.py b/research/dirty-fanout-batch/sources/dirty.py new file mode 100644 index 0000000000..2b94710837 --- /dev/null +++ b/research/dirty-fanout-batch/sources/dirty.py @@ -0,0 +1,133 @@ +"""Integer lifting for cyclic inverse shears using borrowed dirty arrays. +Exact rational prototype. Arithmetic workspace and phase access are charged in the proof; +this is not a common-label Clifford word or a bit-reversible arithmetic compiler. +""" +from pathlib import Path +from fractions import Fraction as F +import importlib.util,json,argparse,itertools +P=Path(__file__).resolve().parent +s=importlib.util.spec_from_file_location('weighted',P/'weighted.py');w=importlib.util.module_from_spec(s);s.loader.exec_module(w);c=w.c + +def scaled(z,q):return(z[0]*q,z[1]*q) +def conj(z):return(z[0],-z[1]) +def ordered(n,d):return range(n)if d==1 else range(n-1,-1,-1) + +def lift(x,y,coefficient,beta,bits,d,sign=1,destination=None,multiplier=None,stats=None): + """y += sign*F(x), restoring x exactly; no length-dependent clean data array.""" + n=len(x);c.need(x is not y and n==len(y)>0,'distinct equally sized arrays') + c.need(d in(-1,1)and sign in(-1,1),'orientation and sign') + c.need(0=(beta/2)**2,'closure denominator') + seed=c.rounded(c.div(x[previous],denominator),bits) + power=c.ONE + for i in ordered(n,d): + power=c.rounded(c.mul(coefficient(i),power),bits) + value=c.add(x[i],c.rounded(c.mul(power,seed),bits)) + value=c.rounded(c.mul(multiplier(i),value),bits) + j=destination(i);y[j]=c.add(y[j],scaled(value,sign)) + # The scalar seed and coefficient scratch may be cleared by ordinary classical + # arithmetic. The dirty data itself is restored by exact inverse integer lifts. + first=0 if d==1 else n-1 + for i in ordered(n,-d): + if i!=first:x[i]=c.sub(x[i],c.rounded(c.mul(coefficient(i),x[i-d]),bits)) + if stats is not None:stats['leaves']+=1;stats['scalar_steps']+=3*n + +def leaf(x,y,factor,phases,beta,bits,d,sign,stats): + inside,b,scale=factor;n=len(x) + if inside: + lift(x,y,lambda i:c.mul(b,conj(phases[(i+d)%n])),beta,bits,-d,sign, + lambda i:(i-d)%n,lambda i:scaled(conj(phases[i]),scale),stats) + else: + lift(x,y,lambda i:c.mul(b,phases[i]),beta,bits,d,sign, + multiplier=lambda i:scaled(c.neg(b),scale),stats=stats) + +def compose(x,y,factors,scratch,phases,beta,bits,d,sign=1,stats=None): + """Balanced commutator; negative call is the exact inverse instruction word.""" + c.need(sign in(-1,1)and d in(-1,1),'orientation and sign') + c.need(factors and len(scratch)>=(len(factors)-1).bit_length(),'dirty depth') + arrays=[x,y]+scratch;c.need(len({id(v)for v in arrays})==len(arrays),'all ancestor arrays distinct') + c.need(len(x)>0 and all(len(v)==len(x)for v in arrays)and len(phases)==len(x),'array lengths') + c.need(all(c.norm2(t)==1 for t in phases),'unit phases') + if len(factors)==1:return leaf(x,y,factors[0],phases,beta,bits,d,sign,stats) + mid=len(factors)//2;B,A=factors[:mid],factors[mid:];z=scratch[0];rest=scratch[1:] + operations=[(x,z,B,1),(z,y,A,1),(x,z,B,-1),(z,y,A,-1)] + if sign==-1:operations=[(src,dst,fs,-sgn)for src,dst,fs,sgn in reversed(operations)] + for src,dst,fs,sgn in operations:compose(src,dst,fs,rest,phases,beta,bits,d,sgn,stats) + +def exact_operator(x,factors,phases,d): + # Dense rational oracle constructed independently from the lifting recurrence. + n=len(x);out=x[:] + for inside,b,scale in factors: + a=[[c.ZERO for _ in range(n)]for _ in range(n)] + if inside: + for i in range(n):a[i][i]=c.neg(b);a[i][(i-d)%n]=c.add(a[i][(i-d)%n],phases[i]) + else: + rho=c.div(c.ONE,b) + for i in range(n):a[i][i]=c.neg(rho);a[i][(i-d)%n]=c.add(a[i][(i-d)%n],phases[i]) + out=[scaled(z,scale)for z in w.solve(a,out)] + return out + +def certificate(n,beta,r,D,bits): + N=4*n*n;a=13*(r+1)/beta**3;G=2+F(r)/beta;u=F(1,1< 246 leaves; {dirt} dirty arrays; no new kappa') + + +if __name__ == '__main__': + parser=argparse.ArgumentParser() + parser.add_argument('--write',action='store_true',help='regenerate, not verify, the certificate') + main(parser.parse_args().write)