From 7662641e7016a3e38826fd5a9e73c30db751452b Mon Sep 17 00:00:00 2001 From: Dugongue <49054532+Dugongue@users.noreply.github.com> Date: Thu, 22 Oct 2026 16:33:02 -0700 Subject: [PATCH] Implement phase-preserving cyclic recovery with bounded-word rounding --- .../native-cyclic-recovery/.gitattributes | 1 + .../APPLICATION-PINS.json | 8 + .../APPLICATIONS-NOTE.md | 67 +++ .../CASCADE-CROSS-REVIEW.json | 83 +++ .../CASCADE-EXPECTED.json | 75 +++ .../native-cyclic-recovery/CASCADE-INVERSE.md | 48 ++ .../CASCADE-ORIGINS.json | 23 + research/native-cyclic-recovery/CHECKS.json | 35 ++ .../DIVISION-CROSS-REVIEW.json | 51 ++ .../native-cyclic-recovery/DIVISION-PROOF.md | 198 +++++++ .../DIVISION-RESULT.json | 489 ++++++++++++++++++ .../INTEGRATED-CASCADE-THEOREM.md | 189 +++++++ .../INTEGRATION-CROSS-REVIEW.json | 57 ++ .../INTEGRATION-RESULT.json | 42 ++ research/native-cyclic-recovery/LICENSE | 201 +++++++ research/native-cyclic-recovery/MANIFEST.json | 40 ++ .../MUTATION-RECEIPTS.json | 20 + research/native-cyclic-recovery/NOTICE | 4 + research/native-cyclic-recovery/README.md | 46 ++ research/native-cyclic-recovery/SOURCES.json | 42 ++ research/native-cyclic-recovery/TASK.json | 80 +++ research/native-cyclic-recovery/VERIFY.json | 82 +++ .../native-cyclic-recovery/cascade_free.py | 149 ++++++ .../cascade_sources/pr4818-LICENSE | 201 +++++++ .../cascade_sources/pr4818-NOTICE.md | 9 + .../cascade_sources/pr4818-verify_schedule.py | 447 ++++++++++++++++ .../cascade_sources/pr4819-LICENSE | 201 +++++++ .../cascade_sources/pr4819-NOTICE.md | 9 + .../cascade_sources/pr4819-verify_schedule.py | 454 ++++++++++++++++ .../cascade_sources/pr4826-LICENSE | 201 +++++++ .../cascade_sources/pr4826-NOTICE.md | 11 + .../cascade_sources/pr4826-verify_schedule.py | 319 ++++++++++++ .../native-cyclic-recovery/fixed_divisor.py | 168 ++++++ research/native-cyclic-recovery/preflight.py | 7 + research/native-cyclic-recovery/verify.py | 60 +++ .../native-cyclic-recovery/verify_division.py | 70 +++ 36 files changed, 4187 insertions(+) create mode 100644 research/native-cyclic-recovery/.gitattributes create mode 100644 research/native-cyclic-recovery/APPLICATION-PINS.json create mode 100644 research/native-cyclic-recovery/APPLICATIONS-NOTE.md create mode 100644 research/native-cyclic-recovery/CASCADE-CROSS-REVIEW.json create mode 100644 research/native-cyclic-recovery/CASCADE-EXPECTED.json create mode 100644 research/native-cyclic-recovery/CASCADE-INVERSE.md create mode 100644 research/native-cyclic-recovery/CASCADE-ORIGINS.json create mode 100644 research/native-cyclic-recovery/CHECKS.json create mode 100644 research/native-cyclic-recovery/DIVISION-CROSS-REVIEW.json create mode 100644 research/native-cyclic-recovery/DIVISION-PROOF.md create mode 100644 research/native-cyclic-recovery/DIVISION-RESULT.json create mode 100644 research/native-cyclic-recovery/INTEGRATED-CASCADE-THEOREM.md create mode 100644 research/native-cyclic-recovery/INTEGRATION-CROSS-REVIEW.json create mode 100644 research/native-cyclic-recovery/INTEGRATION-RESULT.json create mode 100644 research/native-cyclic-recovery/LICENSE create mode 100644 research/native-cyclic-recovery/MANIFEST.json create mode 100644 research/native-cyclic-recovery/MUTATION-RECEIPTS.json create mode 100644 research/native-cyclic-recovery/NOTICE create mode 100644 research/native-cyclic-recovery/README.md create mode 100644 research/native-cyclic-recovery/SOURCES.json create mode 100644 research/native-cyclic-recovery/TASK.json create mode 100644 research/native-cyclic-recovery/VERIFY.json create mode 100644 research/native-cyclic-recovery/cascade_free.py create mode 100644 research/native-cyclic-recovery/cascade_sources/pr4818-LICENSE create mode 100644 research/native-cyclic-recovery/cascade_sources/pr4818-NOTICE.md create mode 100644 research/native-cyclic-recovery/cascade_sources/pr4818-verify_schedule.py create mode 100644 research/native-cyclic-recovery/cascade_sources/pr4819-LICENSE create mode 100644 research/native-cyclic-recovery/cascade_sources/pr4819-NOTICE.md create mode 100644 research/native-cyclic-recovery/cascade_sources/pr4819-verify_schedule.py create mode 100644 research/native-cyclic-recovery/cascade_sources/pr4826-LICENSE create mode 100644 research/native-cyclic-recovery/cascade_sources/pr4826-NOTICE.md create mode 100644 research/native-cyclic-recovery/cascade_sources/pr4826-verify_schedule.py create mode 100644 research/native-cyclic-recovery/fixed_divisor.py create mode 100644 research/native-cyclic-recovery/preflight.py create mode 100644 research/native-cyclic-recovery/verify.py create mode 100644 research/native-cyclic-recovery/verify_division.py diff --git a/research/native-cyclic-recovery/.gitattributes b/research/native-cyclic-recovery/.gitattributes new file mode 100644 index 0000000000..883436c6dc --- /dev/null +++ b/research/native-cyclic-recovery/.gitattributes @@ -0,0 +1 @@ +* -text whitespace=cr-at-eol diff --git a/research/native-cyclic-recovery/APPLICATION-PINS.json b/research/native-cyclic-recovery/APPLICATION-PINS.json new file mode 100644 index 0000000000..887957a141 --- /dev/null +++ b/research/native-cyclic-recovery/APPLICATION-PINS.json @@ -0,0 +1,8 @@ +{ + "pr": 4733, + "head": "dd6948e95eb002d903ce36dd21e0c075e00790ed", + "local_reference_sha256": { + "PR4733-README.md": "01f60b01fc4b8cb70fbac7fff2d4758e4a364cb627463ecd677060a9ce774c34", + "PR4733-PROOF.md": "88118364f7a8e97da76ab7198bf1edde582f1bdd5d62a1d0a881809bcb5f3191" + } +} diff --git a/research/native-cyclic-recovery/APPLICATIONS-NOTE.md b/research/native-cyclic-recovery/APPLICATIONS-NOTE.md new file mode 100644 index 0000000000..0420bdae03 --- /dev/null +++ b/research/native-cyclic-recovery/APPLICATIONS-NOTE.md @@ -0,0 +1,67 @@ +# Concrete native odd-scan services + +This note instantiates the fixed-divisor theorem in existing public component +invoices. It changes the scalar implementation on the declared both-shifts +Word RAM. It does not replace a Turing-tape head-step tariff by the same numeric +RAM count, and does not claim a better kappa or a completed productive caller. + +## Existing centre-code scan obligations + +Ali Romman's PR #4733 at commit +`dd6948e95eb002d903ce36dd21e0c075e00790ed` gives exact component scan counts. +The current +[component README](https://github.com/aliromman/integer-mult-bounds/blob/dd6948e95eb002d903ce36dd21e0c075e00790ed/research/centre-code-services/README.md) +and +[pivot-code proof](https://github.com/aliromman/integer-mult-bounds/blob/dd6948e95eb002d903ce36dd21e0c075e00790ed/research/centre-code-services/annexes/pivot-code-invoice/PROOF.md) +were read directly. Their unchanged matrix identities, code image tests and +precision obligations are retained source premises, not newly replayed here. +No predecessor scientific certificate is copied or rebranded. + +For n scalar records in each real stream, assume each prescribed signed +numerator fits a word after the stated constant guard headroom. Applying the +new exact unsigned quotient/remainder scan and restoring signs supplies the +following sufficient implementations: + +| Source service, inverse direction | Exact fixed-odd divisions | New scalar Word RAM work | +|---|---|---| +| Rank-16 whole-bank code E | 16 at 5 and 16 at 7 | O(32 n log(2+w)) | +| Rank-30 capture | 22 at 3 and 22 at 5 | O(44 n log(2+w)) | +| Rank-30 capture/action/decode | 22 at 3 and 22 at 5, plus the separately charged fixed multiplications | O(44 n log(2+w)) for division, O(44 n) for its fixed-integer multiplications | +| Fixed-reader section swap | 60 at 15, with 60 separately charged multiplication-by-15 scans | O(60 n log(2+w)) for division and O(60 n) for those multiplications | +| Pivot-code inverse annex | 16 at 3 | O(16 n log(2+w)) | + +The fixed constants hidden by O differ with the listed denominator. These are +asymptotic instruction upper bounds, not exact small-word scan tariffs. The +source's 3,420, 2,910, 6,090, 208,028 and 2,078 dyadic scalar accounts, native +translation calls, routing, root conversions and descriptors remain additional. +The two rank-30 rows describe different source service scopes; their bills +must not be added or interchanged without selecting the actual caller. + +On a valid code image, each source inverse requires exact odd divisibility. +The new scan computes q,r with x=dq+r exactly. It therefore checks r=0 and +returns the exact quotient on precisely that domain; it does not replace an +exact inverse by rounded division. A nonzero remainder rejects that exact +service. Arbitrary code coordinates do not acquire missing image membership +from this implementation. Common-grid, matching code types, preservation by +middle operations, full parent height and outer unscaling remain source +premises. The source's generic inverse coefficient 1/12 is not a dyadic unit. + +The pivot annex explicitly charges at most 64 n (w_g+1) arithmetic head steps +for its sixteen fixed-three scans. The theorem here supplies a different, +fully specified Word RAM realization of those exact scalar quotients in +O(16 n log(2+w_g)) instructions, when a bounded word or constant number of +limbs holds the guarded numerator. It is a model-specific alternative, +not a claimed reduction of the original tape head-step count. A practical +constant or crossover improvement has not been measured. + +## Credit and source limits + +Credit Ali Romman and the retained centre-code campaign contributors for +PR #4733's rational-code and pivot constructions, @icekylinx for its common-grid +source, @dcharb78 for the coupled-core folds, Jeremy Diviney for the provider +packing exchange, and the complete original package notices. This note adds +only the explicit restricted-Word-RAM instantiation of the generic scalar +scan. It does not claim invention of the codes, their invoices, exact-image +conditions or the common-grid method. Substantial OpenAI Codex assistance was +used. The independent review of the generic scalar algorithm does not amount +to a fresh review of all PR #4733 constructions. diff --git a/research/native-cyclic-recovery/CASCADE-CROSS-REVIEW.json b/research/native-cyclic-recovery/CASCADE-CROSS-REVIEW.json new file mode 100644 index 0000000000..cc5fb9a9ff --- /dev/null +++ b/research/native-cyclic-recovery/CASCADE-CROSS-REVIEW.json @@ -0,0 +1,83 @@ +{ + "status": "PASS_SCOPED_CASCADE_REVIEW", + "files": { + "cascade_free.py": "64e906a2827f3e17987bddec85ee48a93ee574f494f1566460748bd2edf66162", + "CASCADE-INVERSE.md": "bc66783f0d2e746eecc40246127269612c4443d2813091b38732093637d86cab", + "CASCADE-ORIGINS.json": "b5265c8cd6ac0738a111363f85d4c13a2b910d214ce9c3a5322b16a5d144262b", + "CASCADE-EXPECTED.json": "c772111f1e1a44dda45d85d395eda1a8c9ddf1f23166fe7aee3616e318bb948a" + }, + "normal_or_optimized": "optimized isolated replay matches complete frozen expected receipt", + "independent_random_cases": 144, + "independent_cases": "Roles 1 through 6, addresses 2, 4 and 8; eight deterministic signed rational phase-bearing fixtures per shape; independent literal U action and W-step return.", + "controls": [ + "factored discarded phase rejects", + "false q=2 on order-12 quarter-phase fixture rejects" + ], + "all_width_argument": "The cycle return is Pauli, hence its fourth power is identity; pure XOR return squares to identity. Tensorize unit monomials, keeping the coefficient 1/2 outside.", + "pass_count": "W + q - 2 passes over TOTAL N = W n entries; q = 2 for XOR, q = 4 for general quarter phase.", + "coefficient_norm": "The sum of absolute coefficients is exactly 2; the intermediate first Horner sum is at most 2 and second-stage geometric amplification at most 2.", + "buffers": "Observations retained; q = 2 uses two owned full buffers, q = 4 uses three. Python additionally stores an O(N) compiled return route.", + "runtime_scope": "O((W + q) N d(w)) plus O(W N) literal Python return compilation, for fixed W. O(W N log w) uses TOTAL N entries and denominator constants depending on fixed W.", + "source_binding": [ + { + "pr": 4818, + "head": "fd29d065bbe12f5be5af02fdf5a8b4d86dda3381", + "url": "https://raw.githubusercontent.com/CrocSwap/integer-mult-bounds/fd29d065bbe12f5be5af02fdf5a8b4d86dda3381/research/complex-block4-three-in-ten/verify_schedule.py", + "hash_matches": true, + "changed_notice_paths": [ + "research/complex-block4-three-in-ten/LICENSE", + "research/complex-block4-three-in-ten/NOTICE.md" + ], + "source_header": "#!/usr/bin/env python3\n\"\"\"Exact Synthesis & Verification of the 3-Array 10-Call Cascade Schedule on V = C^16.\n\nProves the viability of breaking the kappa > 0.10 milestone via:\n - W = 3 arrays in s = " + }, + { + "pr": 4819, + "head": "a7b42c2f8ffe5a18d305ca4dda5729d2f1d72ea8", + "url": "https://raw.githubusercontent.com/CrocSwap/integer-mult-bounds/a7b42c2f8ffe5a18d305ca4dda5729d2f1d72ea8/research/complex-block4-thirteen-in-fortyone/verify_schedule.py", + "hash_matches": true, + "changed_notice_paths": [ + "research/complex-block4-thirteen-in-fortyone/LICENSE", + "research/complex-block4-thirteen-in-fortyone/NOTICE.md" + ], + "source_header": "#!/usr/bin/env python3\n\"\"\"Exact Synthesis & Verification of the 13-Array 41-Call Boundary Schedule on V = C^16.\n\nProves the viability of the theoretical maximum boundary schedule for Block m = 4:\n - " + }, + { + "pr": 4826, + "head": "d7b53d3992e658f0dd49d0207ba33bbc39272bac", + "url": "https://raw.githubusercontent.com/CrocSwap/integer-mult-bounds/d7b53d3992e658f0dd49d0207ba33bbc39272bac/research/complex-block5-three-in-nine/verify_schedule.py", + "hash_matches": true, + "changed_notice_paths": [ + "research/complex-block5-three-in-nine/LICENSE", + "research/complex-block5-three-in-nine/NOTICE.md" + ], + "source_header": "#!/usr/bin/env python3\n\"\"\"Exact Synthesis & Algebraic Verification of the 3-Array 9-Call Schedule on Block m=5 (V = C^32).\n\nBreaking into the Block m=5 frontier to achieve saving exponent:\n kappa = 1" + } + ], + "redistributed_notice_obligation": "Original per-package LICENSE and NOTICE.md independently retrieved; retain them with source redistribution. Source headers contain unsupported large kappa claims, which the consumer theorem does not endorse.", + "remaining": "Observation producer and favorable paid profile are not provided. No new kappa, native compiler, Lean kernel audit or human peer review is claimed.", + "literal_tensor_controls": [ + { + "tensor_width": 1, + "dimension": 24, + "q4_recovers": true + }, + { + "tensor_width": 2, + "dimension": 192, + "q4_recovers": true, + "untensorized_central_phase_rejects": true + }, + { + "tensor_width": 3, + "dimension": 1536, + "q4_recovers": true + } + ], + "retained_licenses_sha256": { + "CASCADE-PR4818-LICENSE": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4", + "CASCADE-PR4819-LICENSE": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4", + "CASCADE-PR4826-LICENSE": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4" + }, + "canonical_root_license_sha256": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4", + "integrated_theorem_sha256": "986b7f6a24e387c3cd44317b4d50e790d73c72d13f7befbc0464877eca406394" +} diff --git a/research/native-cyclic-recovery/CASCADE-EXPECTED.json b/research/native-cyclic-recovery/CASCADE-EXPECTED.json new file mode 100644 index 0000000000..92469058b4 --- /dev/null +++ b/research/native-cyclic-recovery/CASCADE-EXPECTED.json @@ -0,0 +1,75 @@ +{ + "status": "PASS_FINITE_MONOMIAL_CASCADE_INVERSE", + "new_kappa": false, + "paid_observation_word_emitted": false, + "cases": [ + { + "roles": 3, + "addresses": 16, + "dimension": 48, + "period": 6, + "exact_basis_columns": 48, + "monomial_passes_upper_bound": 6, + "ADD_passes_upper_bound": 6, + "coefficient_l1": "2", + "factored_monomial_passes": 3, + "factored_ADD_passes": 3 + }, + { + "roles": 3, + "addresses": 32, + "dimension": 96, + "period": 6, + "exact_basis_columns": 96, + "monomial_passes_upper_bound": 6, + "ADD_passes_upper_bound": 6, + "coefficient_l1": "2", + "factored_monomial_passes": 3, + "factored_ADD_passes": 3 + }, + { + "roles": 13, + "addresses": 16, + "dimension": 208, + "period": 26, + "exact_basis_columns": 208, + "monomial_passes_upper_bound": 26, + "ADD_passes_upper_bound": 26, + "coefficient_l1": "2", + "factored_monomial_passes": 13, + "factored_ADD_passes": 13 + }, + { + "roles": 3, + "addresses": 8, + "dimension": 24, + "period": 12, + "exact_basis_columns": 24, + "monomial_passes_upper_bound": 12, + "ADD_passes_upper_bound": 12, + "coefficient_l1": "2", + "factored_monomial_passes": 5, + "factored_ADD_passes": 5 + } + ], + "source_binding": [ + { + "pr": 4818, + "head": "fd29d065bbe12f5be5af02fdf5a8b4d86dda3381", + "exact_coupler_entries": 768 + }, + { + "pr": 4819, + "head": "a7b42c2f8ffe5a18d305ca4dda5729d2f1d72ea8", + "exact_coupler_entries": 3328 + }, + { + "pr": 4826, + "head": "d7b53d3992e658f0dd49d0207ba33bbc39272bac", + "exact_coupler_entries": 3072 + } + ], + "controls": [ + "discarded phase changes decoder and is rejected" + ] +} diff --git a/research/native-cyclic-recovery/CASCADE-INVERSE.md b/research/native-cyclic-recovery/CASCADE-INVERSE.md new file mode 100644 index 0000000000..a836f7b418 --- /dev/null +++ b/research/native-cyclic-recovery/CASCADE-INVERSE.md @@ -0,0 +1,48 @@ +# Finite monomial cascade inverse + +This is a sufficient, constructive consumer theorem. It does not assert that any of the claimed 9-, 10-, 14-, or 41-call producer schedules actually emits its required observations. No new κ is established. + +Let W be a fixed positive integer and let H_0,...,H_(W-1) be phase-retaining Pauli monomials on a qubit address space. Define U on W arrays by (Uz)_k = H_k z_((k+1) mod W). Let M=I+U/2. Then U is unitary, U^(4W)=I, and + + M^-1 = [sum_(j=0)^(4W-1) (-1/2)^j U^j] / (1-2^(-4W)). + +Every factor U is one literal role permutation plus one monomial address pass per role. Horner evaluation uses at most 4W such passes and 4W ADD passes, one fixed rational final scale, the unchanged observation array, and two owned work arrays. Thus this decoder introduces no additional recursive Gaussian child. Its native costs, storage and precision remain charged. It is not an unpriced dense inverse or oracle. + +## Proof and all-width quantifier + +Each diagonal block of U^W is a cyclic product of the H_k. The phase-retaining Pauli group is closed under products and every Pauli has fourth power I, including its quarter phase. Therefore every diagonal block has fourth power I and U^(4W)=I. The finite geometric-series identity gives M times the displayed polynomial equal to I on both sides. This argument applies at every tensor width f: tensorized Paulis remain Paulis; the coefficient 1/2 stays outside tensor products. + +If H_k are pure XOR translations, they commute, square to I and their cycle product squares to I. Then U^(2W)=I and the same formula shortens to 2W terms. In the exact source examples, W=3 with shifts [1,2,4] and W=13 with shifts [1,...,13], the XOR sum is nonzero. The role cycle forces every period to be a multiple of W and the nonzero return translation forces an even multiple. Hence 2W is the exact order, for those literal operators at positive width. + +For target observations v_k=K x_k + K G_k x_(k+1), write y_k=K x_k. The couplers in the y coordinates are H_k=K G_k K^-1. Clifford K conjugates a Pauli G_k to a phase-retaining Pauli. When G_k includes the scalar 1/2, factor that scalar out before defining H_k. Therefore the theorem recovers all y from genuinely emitted v. It does not create v from the original inputs; an actual chronological producer and its paid profile are prerequisites. + +The norm bounds are ||M|| <= 3/2 and ||M^-1|| <= 2. The absolute sum of decoder coefficients is exactly 2, since the geometric sum numerator is 2(1-2^-L) for even period L. A perturbation of the input observations is therefore amplified by at most 2. The exact complete-cascade condition number is 3 in the inspected source examples, as already proved in PR #4842; the small Schur-return bound 9/7 or 8193/8191 is not substituted for this full condition number. + +## Factored operational implementation + +The supplied program also compiles V=U^W as a single monomial, including the exact accumulated phase; it does not perform W live data passes to apply V. Write beta=(-1/2)^W and let q=2 for pure XOR or q=4 for general quarter-phase Pauli routing. Then + + M^-1 = S_W(U) * [sum_(j=0)^(q-1) beta^j V^j] / (1-beta^q), + S_W(U) = sum_(j=0)^(W-1) (-U/2)^j. + +The two Horner evaluations need W-1 and q-1 monomial passes respectively, totaling W+q-2. This is 3 passes for each three-role XOR source and 13 passes for the thirteen-role XOR source; the quarter-phase three-role test uses 5 passes. The same number of ADD passes suffices, followed by the fixed rational scaling. Compared with the direct geometric polynomial, this reduces 6 passes to 3 and 26 passes to 13. The direct count was a constructive upper bound, not an optimality theorem. + +The factored evaluation retains the observation arrays. At most three owned work arrays suffice for general q=4 with separate source and destination buffers; the q=2 case needs two. The Python executable also materializes one monomial routing table, charged as O(W N) index/phase storage. A native Pauli implementation can instead store the W composed Pauli descriptors and enumerate addresses, but this replacement is a mathematical implementation prescription rather than a benchmarked machine program. Compilation and final cleanup are separately charged linear work. + +The coefficient absolute sum of the factored polynomial is again exactly 2: the sums are 2(1-2^-W) and 1/(1-2^-W). This supplies a bound for roundoff and perturbation; it does not make rational scaling free. + +## Native interpretation + +W and L are fixed. An address odometer implements the tensorized Pauli with one XOR/phase update per addressed scalar; all role routing, reads, writes, ADDs and fixed rational scaling are part of the finite bill. With coefficient precision p and word width w, general fixed-denominator rational arithmetic can be charged explicitly by d(w); a restoring-division fallback gives d(w)=O(w). This yields O(W L N d(w)) word operations and O(W N) scalar storage, with a constant depending on the fixed program. No hardware division instruction is assumed. + +Magnitude and roundoff are bounded by a constant independent of width because the Horner multiplier has norm 1/2 and there are only L steps. Choosing p = O(log(2+B)+log N+log(1/δ)) suffices for bounded input magnitude B and requested global error δ, after retaining the input's exact scale. Word-address headroom must include all original, output, scratch and guard fields. The sufficient storage condition is 2^w >= c W N for an explicit implementation constant c; no input is silently overwritten or counted twice as productive data. + +## Exact checks and provenance + +cascade_free.py implements the polynomial directly using exact rational complex pairs. It checks every basis column of the actual permutation operators on dimensions 48, 96 and 208, and a signed quarter-phase Pauli case of dimension 24. CASCADE-ORIGINS.json freezes the exact source bytes of PRs #4818, #4819 and #4826. The checker explicitly compares all 7,168 source coupler entries and verifies K G_k = G_k K. For #4826 it evaluates only the exact constructor prefix through E3, never the dense recovery test. These source checks stay active under optimized Python. The last case has noncommuting phase-bearing couplers; a decoder which discards these phases is rejected. Normal and optimized Python both use explicit checks rather than assertions. + +This leaf builds on hexapode's PRs #4818, #4819 and #4826 for the particular proposed cascade observations; Clear1nsight's PR #4842 for the exact full-cascade conditioning and producer-admission distinction; Dugongue's PR #4743 for the actual dirty native ports and monomial implementation; and the source lineage through Yiyang/Lyy-iiis #4710, lee-phys #4688 and Jacob Alan Sussman #4628. The finite-order geometric-series identity and Clifford/Pauli conjugation are standard facts, not claimed as new general mathematics. The contribution is a literal phase-preserving finite-pass decoder and explicit cost contract at this proposed consumer boundary. Prepared with substantial OpenAI Codex assistance, Apache-2.0. + +## Open next question + +Emit one of these observations from arbitrary independent inputs with an actual favorable paid Gaussian profile, retained source ownership, correct chronology and all-width phases. Then the present decoder can replace the unpriced dense recovery stage. A source which merely inserts K and E into a matrix does not satisfy the prerequisite. Compiler reserve, ordinary/outer admission, native precision and the full multiplication transfer must still be bound to the completed producer before any κ claim. diff --git a/research/native-cyclic-recovery/CASCADE-ORIGINS.json b/research/native-cyclic-recovery/CASCADE-ORIGINS.json new file mode 100644 index 0000000000..6d9508afef --- /dev/null +++ b/research/native-cyclic-recovery/CASCADE-ORIGINS.json @@ -0,0 +1,23 @@ +[ + { + "pr": 4818, + "head": "fd29d065bbe12f5be5af02fdf5a8b4d86dda3381", + "path": "cascade_sources/pr4818-verify_schedule.py", + "sha256": "7fab42730ebb5e1cd88dc369df526a002e91a70dc99cdbf4a7c0133fefa7e33d", + "url": "https://raw.githubusercontent.com/CrocSwap/integer-mult-bounds/fd29d065bbe12f5be5af02fdf5a8b4d86dda3381/research/complex-block4-three-in-ten/verify_schedule.py" + }, + { + "pr": 4819, + "head": "a7b42c2f8ffe5a18d305ca4dda5729d2f1d72ea8", + "path": "cascade_sources/pr4819-verify_schedule.py", + "sha256": "4ddb2d11a4da6a05db3f06a400bd74059ce1448142df028e82a09d50eca06567", + "url": "https://raw.githubusercontent.com/CrocSwap/integer-mult-bounds/a7b42c2f8ffe5a18d305ca4dda5729d2f1d72ea8/research/complex-block4-thirteen-in-fortyone/verify_schedule.py" + }, + { + "pr": 4826, + "head": "d7b53d3992e658f0dd49d0207ba33bbc39272bac", + "path": "cascade_sources/pr4826-verify_schedule.py", + "sha256": "de0256a33d4007615b8dc0ab4c45ce3582bfb2cf963b499f84b0362935c96c4e", + "url": "https://raw.githubusercontent.com/CrocSwap/integer-mult-bounds/d7b53d3992e658f0dd49d0207ba33bbc39272bac/research/complex-block5-three-in-nine/verify_schedule.py" + } +] diff --git a/research/native-cyclic-recovery/CHECKS.json b/research/native-cyclic-recovery/CHECKS.json new file mode 100644 index 0000000000..02fa5034d8 --- /dev/null +++ b/research/native-cyclic-recovery/CHECKS.json @@ -0,0 +1,35 @@ +{ + "status": "PASS_SCOPED_RESEARCH_RELEASE", + "requested_new_kappa_achieved": false, + "new_kappa": null, + "complete_supplier": false, + "registered_replay": "PASS all seven commands, normal and optimized", + "scalar_cases": { + "unsigned": 6912, + "signed_rounding": 24978, + "fixed_rational": 840, + "independent_boundary_review": 5117 + }, + "cascade_cases": { + "exact_basis_columns": 376, + "frozen_coupler_entries": 7168, + "independent_review_fixtures": 144 + }, + "integration": "PASS independent exact references and three beta-sign rejection controls; independent proof/code review", + "mathematical_scope": "Written universal sufficient consumer and fixed-rational arithmetic proofs; finite replay corroboration.", + "runtime": "CPython 3.12 Windows x86-64; Python standard library only.", + "lean_kernel_audit": false, + "hosted_linux_ci": false, + "full_source_history_audit": "not run: shallow checkout", + "predecessor_scripts": "Exact retained source bytes with original per-package licenses and notices; their large-kappa claims are not endorsed.", + "limitations": [ + "No favorable paid observation producer.", + "Both logical shifts are explicit primitives; not literal Problem1.8 DIV-derived right shift.", + "Operation counts are not processor cycles or demonstrated practical speedups." + ], + "executed_source_mutations": [ + "wrong prefix remainder offset", + "discarded return phase", + "wrong inverse normalization" + ] +} diff --git a/research/native-cyclic-recovery/DIVISION-CROSS-REVIEW.json b/research/native-cyclic-recovery/DIVISION-CROSS-REVIEW.json new file mode 100644 index 0000000000..67b21d5ab0 --- /dev/null +++ b/research/native-cyclic-recovery/DIVISION-CROSS-REVIEW.json @@ -0,0 +1,51 @@ +{ + "reviewer": "Independent construction worker, OpenAI Codex", + "status": "PASS_SCOPED_REVIEW", + "files": { + "fixed_divisor.py": "f4eb025ded92028362c68fd070fb181e166f446e7f1307ffa0580c5bc6cd7039", + "DIVISION-PROOF.md": "7aa756b89c59fa107e9c3b8b9d7f3420364aa35c1905f883102d6197d763655d", + "verify_division.py": "f82129d58d35fb8421c53f39f581c0079811477ca53dada6993b13d7714b7ddc", + "DIVISION-RESULT.json": "0c09509a46efe0ecec40a98927d9813043aa34702ee7258cdbd58d9f5073031d" + }, + "checks": [ + { + "command": "python -I -O -B verify_division.py", + "result": "PASS_FIXED_DIVISOR_BITPLANE_SCAN", + "unsigned_cases": 6912, + "signed_rounding_cases": 24978, + "fixed_rational_cases": 840 + }, + { + "command": "python -I -O -B division_independent.py", + "result": "PASS_INDEPENDENT_DIVISION_BOUNDARIES", + "comparisons": 5117, + "scope": "divisors at 2^w-1, 2^w, 2^w+1, 2^(w+1)-1, half-word boundary, and small divisors; widths1..12,15,16,31,32,63,64,127; both signs and all three rounding modes" + } + ], + "reasoning": [ + "Bit-plane lanes encode overlapping low-to-high blocks modulo d; right shift supplies the disjoint upper block, and doubling the represented block length proves all suffix residues.", + "The quotient bit identity [2*r_(i+1)+bit_i(x)>=d] emits the complete word after the logarithmic prefix stage count.", + "Conditional bit-plane subtraction and scalar gap=d-b reduction avoid native carry overflow, including d=maxword.", + "Negative floor, truncation and nearest-even symmetry are correct; thresholds compare r with floor(d/2) without doubling r.", + "Fixed numerator shifts fit the explicit widened physical working width. Constant physical-limb emulation must handle limb-boundary shifts explicitly.", + "O(log(2+w)) holds for fixed p,d, not uniformly over growing denominators: the explicit constant is O(bit_length(d)^2). Bit-plane scratch is O(bit_length(d)) ordinary words.", + "The source framework replacement O(Nw) to O(Nlog(2+w)) is an arithmetic upper-bound improvement under the stated ABI, not a paid Gaussian-profile or kappa improvement." + ], + "controls": [ + "Existing scientific wrong_weight and wrong_suffix mutations have explicit failing witnesses and remain active under -O.", + "Out-of-range input and zero divisor are rejected." + ], + "requirements": [ + "Both logical shifts are primitive in this restricted ABI; the exact Problem1.8 Lean machine derives right shift using division, so no division-free compilation into that machine is claimed.", + "Working word width includes fixed numerator/denominator guard bits; callers must reserve them physically or charge a constant number of limbs.", + "Array address headroom must satisfy 2^W >= c*N+c_d; scalar scratch address space also needs 2^W>=c_d.", + "w is supplied metadata in the executable; automatic width discovery is a separate prescribed option under explicit zero-on-overshift semantics.", + "Instruction count is a conservative emulated data-operation bound plus separately bounded loop/setup cost, not a processor cycle benchmark." + ], + "limitations": [ + "No new kappa, missing channel-complement recovery, complete multiplication theorem, Lean kernel audit, hosted CI or independent human review is established.", + "Primary-literature priority is not certified by this correctness review." + ], + "review_source_sha256": "de0a9f180f840a4819941811b810c33a3dbba2619068729c50f017b02e5bdd61", + "boundary_receipt_sha256": "09608f0f449adbb3549d3366aa13f44147eb631e4c2f5d75207adcd58fadffbd" +} diff --git a/research/native-cyclic-recovery/DIVISION-PROOF.md b/research/native-cyclic-recovery/DIVISION-PROOF.md new file mode 100644 index 0000000000..8db708cd5b --- /dev/null +++ b/research/native-cyclic-recovery/DIVISION-PROOF.md @@ -0,0 +1,198 @@ +# Fixed rational recovery without word multiplication or division + +## Exact useful result and scope + +Fix integers p and d with d > 0. On a Word RAM with bounded-word addition, +subtraction, comparisons, AND, OR, XOR, NOT and both logical shifts, prescribed +rounding of p x / d can be computed in O(log(2 + w)) instructions using O(1) +words, for signed inputs whose magnitude has w bits. The constants depend on +p and d, which are fixed independently of w. The computation uses no word +multiplication, division, remainder, leading-zero-count or table lookup oracle. +The algorithm below handles every positive w; signs use a separate bit and +magnitude word. It supports floor, truncation toward zero and nearest ties to +even. For each fixed denominator, the same compiled program serves all widths. +A valid caller may supply w as metadata; alternatively the standard zero-on- +overshift semantics finds w by doubling and binary search in O(log(2 + w)) +operations. The executable supplies w explicitly and rejects out-of-range shifts +inside the scientific division routine. + +This reduces the basic-arithmetic fallback in Dugongue's PR #4885 from +O(N w) to O(N log(2 + w)) for its fixed-polynomial resonant recovery program, +under the explicitly stated both-shifts instruction set. It supplies no new +multiplication kappa and does not recover the channel's missing complement. +It is an asymptotic upper bound, not a measured speedup for practical widths. + +The existing Problem 1.8 Lean RAM has right shift as a derived operation using +its division primitive. Therefore the division-free instruction set here is +NOT claimed as a literal subset compilation of that exact Lean machine. +Its fixed-width shift and division specifications are semantic precedents; +this contribution has no new Lean kernel audit. + +## Bit-plane invariant + +Let 0 <= x < 2^w and d >= 2. Put b = ceil(log2(d + 1)), implemented as the +ordinary bit length of d. For each address position i, maintain a lane value +r_i in [0,d). Store its b binary digits in b ordinary w-bit words: bit i of +word R_j is bit j of r_i. The w lanes share these b words; this is NOT an +ultraword or an array of w separate word registers. All lane operations use +only ordinary w-bit Boolean operations. A binary ripple circuit across the +b bit planes adds two lane values independently, using a bit-plane carry. +An extra carry plane permits exact values below 2d without machine-word +overflow. Compare with the fixed binary digits of d, then conditionally +subtract d in every selected lane. This computes all lane sums modulo d +in O(b) word operations and O(b) words, including carry and borrow fields. +There is no carry between lanes: every Boolean operation acts on matching +bit positions, and carries move between planes, not adjacent word bits. + +Multiplication of every lane value by a scalar a in [0,d) uses b binary +shift-and-add stages, with each lane doubling/addition reduced modulo d. +It costs O(b^2) word operations. Here this is a construction from Boolean +operations, not a primitive word multiplication. The loop uses only the b +bits of a. To square the scalar weights themselves, ordinary scalar modular +addition avoids overflow as follows: for u,v < d, set gap = d - v; return +u - gap if u >= gap, and u + v otherwise. The latter branch is below d. +A b-step binary product of scalar weights therefore uses O(b) instructions +and never forms the potentially overflowing u + v in the former branch. + +Start with length l = 1 and r_i = bit_i(x). At every stage maintain + + r_i = (sum_{j=0}^{l-1} bit_{i+j}(x) 2^j) mod d, + +where bits at positions >= w are zero. Set a_l = 2^l mod d. The simultaneous +updates are + + r_i <- (r_i + a_l r_{i+l}) mod d, + a_l <- a_l^2 mod d, + l <- 2 l. + +A logical right shift of each bit-plane word by l supplies all r_{i+l}. +Old planes remain available until the entire new collection is finished. +The displayed invariant follows by splitting the 2l-bit block into lower +and upper halves. After ceil(log2 w) stages, every lane contains + + r_i = floor(x / 2^i) mod d. + +The quotient bit at position i is exactly + + [2 r_{i+1} + bit_i(x) >= d]. + +Indeed this is the next quotient bit in ordinary high-to-low long division. +The b+1 planes for the expression are obtained without addition: the lowest +plane is x and the upper planes are the previous remainder planes shifted +right by one. A bit-plane comparison with d emits the ENTIRE quotient word. +The remainder is lane zero, extracted from the b planes in O(b) operations. +Thus the quotient and remainder are exact, not reciprocal approximations. + +If d has more than w bits, x < d gives quotient zero and remainder x directly. +This exceptional branch uses the fixed denominator's bit length and does not +load a truncated denominator into a word. If the denominator fits, the scalar +weight arithmetic above stays below d, even when d is near 2^w. All data word +values and actual shift counts in the executable are checked. Setup, loop +control and fixed-constant bit inspection add O(b log(2+w)) instructions; +the recorded Boolean/arithmetic count is bounded by + + 100 (b + 1)^2 (ceil(log2 w) + 1). + +This is a conservative bound on the emulated data operations, not a cycle- +accurate count for a compiled processor or an exact tariff for a prior ABI. +For fixed d it is O(log(2+w)). Temporary planes occupy O(b) words, a constant +independent of w. Every original input word remains unchanged. + +## Signed rounding and fixed numerators + +Run unsigned division on abs(x), retaining its original sign. Write magnitude +abs(x) = d q + r, 0 <= r < d. Truncation returns sign(x) q. Floor returns q +for nonnegative x, and -q - [r != 0] for negative x. Nearest ties to even +increments q when r > floor(d/2), or when d is even, r = d/2 and q is odd; +then restore the sign. This never forms 2r, so there is no boundary overflow. +When d does not fit a word, the half-denominator threshold either fits and +can be stored as a fixed constant, or exceeds the entire magnitude range +and the comparison is always false. These are fixed-width comparisons, +not an uncharged multiword division. The output has a sign bit and magnitude; +no signed two's-complement overflow convention is silently assumed. + +For fixed p, form abs(p) abs(x) by its fixed binary shift-and-add expansion. +Use W = max(w + bit_length(abs(p)) + 1, bit_length(d) + 1, 3) working bits; +this adds only a constant number of guard bits for fixed p,d. Every shifted +summand and partial sum fits W bits, as checked by the emulator. Apply the +unsigned scan and the selected rounding with sign(x) XOR sign(p). +This proves the stated fixed-rational theorem. If a machine ABI fixes its +physical word width before the payload precision, reserve these constant +guard bits in that ABI; do not store a W-bit temporary in a w-bit word. +Alternatively a constant number of physical limbs implements the same +construction at constant instruction overhead, with logical shifts across +that constant limb count explicitly charged. + +## Application to the resonant pseudoinverse + +PR #4885 proves a fixed rational monomial program for every width, including + + A^dagger = (1/16) R(C) A*, C = A* A / 16, + R(x) = -(q(x) - q(0)) / (x q(0)), q(0) = -40131624960. + +The literal denominator has 2-adic factorization + + 40131624960 = 2^19 * 76545. + +The scalar scan may use the full fixed denominator, or shift the power-of-two +part with explicitly tracked discarded remainder for prescribed rounding. +The executable tests the full denominator; it does not omit those discarded +bits. All numerator heights, polynomial degrees and the number of monomial +passes are fixed constants. Each pass visits N scalar entries and preserves +the arbitrary retained input in an owned buffer. Therefore its prescribed +rounded fixed-rational operations cost O(N log(2+w)), with the same constant +number of full-size buffers plus O(1) scalar scratch words. Clearing those +scratch words costs O(1); buffer initialization and clearing are O(N) passes. +The source requirement 2^W >= c N must include guard words, retained input, +three owned Horner buffers and constant plane scratch. Rounding and original +source precision budgets remain those of #4885; this lemma changes the cost +of implementing their specified scalar rounding, not the algebraic projector +or its inverse-norm bound. It does not claim an unrounded rational computation +in bounded precision. Every rounded scalar step still incurs the explicitly +chosen local error already accounted for by the fixed-degree stability bound. + +## Precedents and review limits + +The general associative scan method is classical: Guy E. Blelloch, Prefix Sums +and Their Applications, CMU-CS-90-190 (1990), and its 1993 chapter. This use of +bit-plane modular prefix blocks is an application of that method, with an +explicit quotient-emission identity and bounded-word invoice. No broad novelty +claim for parallel constant division or Boolean arithmetic is made. Torbjorn +Granlund and Peter L. Montgomery, Division by Invariant Integers Using +Multiplication, PLDI 1994, supplies the important distinct multiplication- +assisted constant-division context; it is not used as an uncharged primitive. +PR #4713's Newton reciprocal implementation also uses word multiplication; +this theorem's restricted instruction-set scope is different. + +The shared MathProof source tree was consulted for fixed word shifts and +long-division semantics, specifically shiftLeftMany_fixed, +shiftRightMany_fixed and divBits_fixed in +Mathproof.Meta.Problem18RAMLax51ProofsRamToTMWordOperations20261001, +and the instruction set in Problem18RAMLax13Ram20261001. These inspected +source files and DAG search matches were not freshly kernel checked. The +current theorem is an informal mathematical proof plus executable exact +word emulation. No independently reviewed full multiplication theorem, +selected-frontier admission, hosted CI or new kappa is claimed. + +## Open next question + +Instantiate this implementation inside a named source-compatible consumer +whose full paid profile already beats the current bound. Begin with the +actual precision/error tariff and both-shifts physical ABI, then price owned +buffers and every pass. The scalar implementation is now supplied; the missing +productive channel complement and favorable complete recurrence remain separate. + +Primary references consulted: + +- [Guy E. Blelloch, Prefix Sums and Their Applications](https://www.cs.cmu.edu/~guyb/papers/Ble93.pdf), especially the definition of associative scan and the logarithmic-depth construction. +- [CMU-CS-90-190 record](https://www.cs.cmu.edu/afs/cs.cmu.edu/project/scandal/public/papers/CMU-CS-90-190.html). +- [Granlund and Montgomery, PLDI 1994](https://doi.org/10.1145/178243.178249), multiplication-assisted invariant division; full publisher text was not accessible in this session, so no internal theorem from it is used as a proof premise. + +A fixed program still needs address space for its constant register allocation. +Require 2^W >= c_d for the b-plane scalar workspace, and 2^W >= c N + c_d +for the array application. The fixed-rational wrapper already reserves +W >= bit_length(d) + 1; if a particular compiled register allocation requires +more constant address headroom, increase W by that fixed additive constant. +The all-width executable scalar identities are not a claim that arbitrarily +many temporaries fit a two-cell w = 1 memory. Constant guard widening and the +stated address condition are part of the native ABI. diff --git a/research/native-cyclic-recovery/DIVISION-RESULT.json b/research/native-cyclic-recovery/DIVISION-RESULT.json new file mode 100644 index 0000000000..9106e3dd12 --- /dev/null +++ b/research/native-cyclic-recovery/DIVISION-RESULT.json @@ -0,0 +1,489 @@ +{ + "status": "PASS_FIXED_DIVISOR_BITPLANE_SCAN", + "unsigned_cases": 6912, + "signed_rounding_cases": 24978, + "fixed_rational_cases": 840, + "maximum_counted_word_operations": 288317, + "large_cases": [ + { + "divisor": 2, + "width": 8, + "cases": 10, + "operations": 411 + }, + { + "divisor": 2, + "width": 16, + "cases": 10, + "operations": 542 + }, + { + "divisor": 2, + "width": 31, + "cases": 10, + "operations": 673 + }, + { + "divisor": 2, + "width": 32, + "cases": 10, + "operations": 673 + }, + { + "divisor": 2, + "width": 63, + "cases": 10, + "operations": 804 + }, + { + "divisor": 2, + "width": 64, + "cases": 10, + "operations": 804 + }, + { + "divisor": 2, + "width": 65, + "cases": 10, + "operations": 935 + }, + { + "divisor": 2, + "width": 127, + "cases": 10, + "operations": 935 + }, + { + "divisor": 2, + "width": 128, + "cases": 10, + "operations": 935 + }, + { + "divisor": 2, + "width": 129, + "cases": 10, + "operations": 1066 + }, + { + "divisor": 2, + "width": 256, + "cases": 10, + "operations": 1066 + }, + { + "divisor": 2, + "width": 512, + "cases": 10, + "operations": 1197 + }, + { + "divisor": 2, + "width": 1024, + "cases": 10, + "operations": 1328 + }, + { + "divisor": 2, + "width": 4096, + "cases": 10, + "operations": 1590 + }, + { + "divisor": 3, + "width": 8, + "cases": 10, + "operations": 504 + }, + { + "divisor": 3, + "width": 16, + "cases": 10, + "operations": 667 + }, + { + "divisor": 3, + "width": 31, + "cases": 10, + "operations": 830 + }, + { + "divisor": 3, + "width": 32, + "cases": 10, + "operations": 830 + }, + { + "divisor": 3, + "width": 63, + "cases": 10, + "operations": 993 + }, + { + "divisor": 3, + "width": 64, + "cases": 10, + "operations": 993 + }, + { + "divisor": 3, + "width": 65, + "cases": 10, + "operations": 1156 + }, + { + "divisor": 3, + "width": 127, + "cases": 10, + "operations": 1156 + }, + { + "divisor": 3, + "width": 128, + "cases": 10, + "operations": 1156 + }, + { + "divisor": 3, + "width": 129, + "cases": 10, + "operations": 1319 + }, + { + "divisor": 3, + "width": 256, + "cases": 10, + "operations": 1319 + }, + { + "divisor": 3, + "width": 512, + "cases": 10, + "operations": 1482 + }, + { + "divisor": 3, + "width": 1024, + "cases": 10, + "operations": 1645 + }, + { + "divisor": 3, + "width": 4096, + "cases": 10, + "operations": 1971 + }, + { + "divisor": 7, + "width": 8, + "cases": 10, + "operations": 830 + }, + { + "divisor": 7, + "width": 16, + "cases": 10, + "operations": 1100 + }, + { + "divisor": 7, + "width": 31, + "cases": 10, + "operations": 1370 + }, + { + "divisor": 7, + "width": 32, + "cases": 10, + "operations": 1370 + }, + { + "divisor": 7, + "width": 63, + "cases": 10, + "operations": 1640 + }, + { + "divisor": 7, + "width": 64, + "cases": 10, + "operations": 1640 + }, + { + "divisor": 7, + "width": 65, + "cases": 10, + "operations": 1910 + }, + { + "divisor": 7, + "width": 127, + "cases": 10, + "operations": 1910 + }, + { + "divisor": 7, + "width": 128, + "cases": 10, + "operations": 1910 + }, + { + "divisor": 7, + "width": 129, + "cases": 10, + "operations": 2180 + }, + { + "divisor": 7, + "width": 256, + "cases": 10, + "operations": 2180 + }, + { + "divisor": 7, + "width": 512, + "cases": 10, + "operations": 2450 + }, + { + "divisor": 7, + "width": 1024, + "cases": 10, + "operations": 2720 + }, + { + "divisor": 7, + "width": 4096, + "cases": 10, + "operations": 3260 + }, + { + "divisor": 31, + "width": 8, + "cases": 10, + "operations": 1716 + }, + { + "divisor": 31, + "width": 16, + "cases": 10, + "operations": 2278 + }, + { + "divisor": 31, + "width": 31, + "cases": 10, + "operations": 2840 + }, + { + "divisor": 31, + "width": 32, + "cases": 10, + "operations": 2840 + }, + { + "divisor": 31, + "width": 63, + "cases": 10, + "operations": 3402 + }, + { + "divisor": 31, + "width": 64, + "cases": 10, + "operations": 3402 + }, + { + "divisor": 31, + "width": 65, + "cases": 10, + "operations": 3964 + }, + { + "divisor": 31, + "width": 127, + "cases": 10, + "operations": 3964 + }, + { + "divisor": 31, + "width": 128, + "cases": 10, + "operations": 3964 + }, + { + "divisor": 31, + "width": 129, + "cases": 10, + "operations": 4526 + }, + { + "divisor": 31, + "width": 256, + "cases": 10, + "operations": 4526 + }, + { + "divisor": 31, + "width": 512, + "cases": 10, + "operations": 5088 + }, + { + "divisor": 31, + "width": 1024, + "cases": 10, + "operations": 5650 + }, + { + "divisor": 31, + "width": 4096, + "cases": 10, + "operations": 6774 + }, + { + "divisor": 76545, + "width": 31, + "cases": 10, + "operations": 25748 + }, + { + "divisor": 76545, + "width": 32, + "cases": 10, + "operations": 25748 + }, + { + "divisor": 76545, + "width": 63, + "cases": 10, + "operations": 32756 + }, + { + "divisor": 76545, + "width": 64, + "cases": 10, + "operations": 32756 + }, + { + "divisor": 76545, + "width": 65, + "cases": 10, + "operations": 39764 + }, + { + "divisor": 76545, + "width": 127, + "cases": 10, + "operations": 39764 + }, + { + "divisor": 76545, + "width": 128, + "cases": 10, + "operations": 39764 + }, + { + "divisor": 76545, + "width": 129, + "cases": 10, + "operations": 46503 + }, + { + "divisor": 76545, + "width": 256, + "cases": 10, + "operations": 46503 + }, + { + "divisor": 76545, + "width": 512, + "cases": 10, + "operations": 52973 + }, + { + "divisor": 76545, + "width": 1024, + "cases": 10, + "operations": 59174 + }, + { + "divisor": 76545, + "width": 4096, + "cases": 10, + "operations": 72921 + }, + { + "divisor": 40131624960, + "width": 63, + "cases": 10, + "operations": 131117 + }, + { + "divisor": 40131624960, + "width": 64, + "cases": 10, + "operations": 131117 + }, + { + "divisor": 40131624960, + "width": 65, + "cases": 10, + "operations": 156935 + }, + { + "divisor": 40131624960, + "width": 127, + "cases": 10, + "operations": 156935 + }, + { + "divisor": 40131624960, + "width": 128, + "cases": 10, + "operations": 156935 + }, + { + "divisor": 40131624960, + "width": 129, + "cases": 10, + "operations": 182180 + }, + { + "divisor": 40131624960, + "width": 256, + "cases": 10, + "operations": 182180 + }, + { + "divisor": 40131624960, + "width": 512, + "cases": 10, + "operations": 208571 + }, + { + "divisor": 40131624960, + "width": 1024, + "cases": 10, + "operations": 236108 + }, + { + "divisor": 40131624960, + "width": 4096, + "cases": 10, + "operations": 288317 + } + ], + "controls": [ + { + "mutation": "wrong_weight", + "witness": 2 + }, + { + "mutation": "wrong_suffix", + "witness": 3 + } + ], + "algorithm_source_sha256": "f4eb025ded92028362c68fd070fb181e166f446e7f1307ffa0580c5bc6cd7039", + "new_kappa": null +} diff --git a/research/native-cyclic-recovery/INTEGRATED-CASCADE-THEOREM.md b/research/native-cyclic-recovery/INTEGRATED-CASCADE-THEOREM.md new file mode 100644 index 0000000000..23f7ed6280 --- /dev/null +++ b/research/native-cyclic-recovery/INTEGRATED-CASCADE-THEOREM.md @@ -0,0 +1,189 @@ +# Integrated phase-retaining cascade consumer on restricted Word RAM + +## Sufficient runtime theorem + +Fix W >= 1, choose q = 2 for pure XOR Pauli couplers or q = 4 for arbitrary +quarter-phase Pauli couplers, and let n be the number of complex entries PER +role. In this note N = W n is the TOTAL number of complex observation entries. +Assume the caller actually supplies + + v = (I + U/2) y, + (U y)_k = H_k y_((k+1) mod W), + +with the phase-retaining unit Pauli monomials H_k and all scalar coefficients +in the stated representation. No observation producer is supplied by this +theorem. If the caller wants y_k = K x_k, those actual independent target +observations, not a matrix merely containing K, are its prerequisite. + +The factored decoder of cascade_free.py and the fixed_divisor.py arithmetic +supply y to prescribed accuracy using no further recursive Gaussian child, +no word multiplication and no word division. With both logical shifts as +primitives, its work is + + O((W + q) N D_W(h) + W N), + D_W(h) = O_W(log(2 + h)), + +including literal return-map compilation, all scalar rounding, routing, +initialization and cleanup. Thus for FIXED W it is O(W N log(2 + h)), with +constants depending on the fixed rational coefficients. If one instead uses +n per role, the same bound is O(W^2 n log(2 + h)). No factor W disappears. +If W varies, keep the coefficient-dependent bound below rather than claiming +a uniform W-linear tariff. No new kappa follows without a favorable paid +producer and the remaining complete caller and transfer contracts. + +## Exact denominator and pass counts + +Put beta = (-1/2)^W and V = U^W. The exact decoder is + + S_W(U) [sum_(j=0)^(q-1) beta^j V^j] / (1 - beta^q), + S_W(U) = sum_(j=0)^(W-1) (-U/2)^j. + +It needs W + q - 2 full monomial passes and as many complex ADD passes, +followed by one real fixed-rational scale on each real and imaginary part. +A full pass visits all N entries. The normalization is + + gamma = 2^(q W) / (2^(q W) - 1). + +The source examples give: + +| Roles and phase contract | Monomial passes | ADD passes | Final gamma | +|---|---:|---:|---| +| W = 3, pure XOR, q = 2 | 3 | 3 | 64/63 | +| W = 13, pure XOR, q = 2 | 13 | 13 | 67108864/67108863 | +| W = 3, quarter phase, q = 4 | 5 | 5 | 4096/4095 | + +The original h-bit value is not multiplied by the large gamma numerator in +an unbounded register: its fixed binary expansion is applied with the constant +q W + 1 guard bits already reserved. Dyadic Horner multipliers are likewise +prescribed fixed-rational operations, with exact remainder-based rounding. + +A deliberately conservative supplied-emulator data-operation bound for one +fixed-rational real scale at working width h is + + D_W(h) <= 100 (q W + 1)^2 (ceil(log2 h) + 1) + 12. + +Here the largest divisor bit length is q W, and the gamma numerator has only +one nonzero binary digit. The first and second Horner coefficients have no +larger divisor. This bound counts emulated Boolean, shift, scalar modular +weight and sign/rounding data operations; loop/control, memory access and +signed ADD instructions have additional constant tariffs. It is not a +cycle-accurate processor count. The fixed program performs at most +2 N (W + q - 1) such real scales, including the final normalization, plus +2 N (W + q - 2) real ADDs and the stated routing passes. Multiplication by +powers of two may be implemented more cheaply, but this bound grants no +unstated fast primitive. + +## Precision and explicit error propagation + +Use the maximum absolute REAL COMPONENT norm on complex vectors. Let the +exact observations have each component at most B, and suppose stored input +components have error at most epsilon_in. Let every Horner scalar update +and final scale introduce at most epsilon additional component error after +its prescribed rounding; signs, quarter phases and permutations are exact. +ADD can be exact on the common grid with the guarded signed-magnitude format. + +The first Horner recurrence has contraction 1/2. Its accumulated arithmetic +error is at most 2 epsilon, independently of W. Let a = |beta| <= 1/2. +The second Horner recurrence retains the first output as its source. Its +error is at most (2 epsilon + epsilon)/(1-a) <= 6 epsilon. The last scale +has gamma <= 4/3 because q is even and at least two; rounding adds epsilon. +Hence internal arithmetic contributes at most + + (4/3) 6 epsilon + epsilon = 9 epsilon. + +The exact complete inverse has coefficient absolute sum exactly 2, so input +perturbation contributes at most 2 epsilon_in. Therefore the component error +of the final answer is at most + + 2 epsilon_in + 9 epsilon, + +and its ordinary complex Euclidean error is at most + + sqrt(2 N) (2 epsilon_in + 9 epsilon). + +These estimates are independent of tensor width and do not substitute the +small return-block condition number for the complete observation operator. +For example, rounding on a grid of step 2^-p with epsilon_in <= 2^-p and +all local errors <= 2^-p gives error <= 11 sqrt(2 N) 2^-p. The conservative +choice + + p >= max(0, ceil(log2(22 N / eta))) + +therefore suffices for a requested Euclidean error eta > 0. Input scale and +magnitude still need to be represented; this is not a precision oracle. +Exact observations on the grid have epsilon_in = 0 and permit the sharper +9 epsilon version. + +For the actual nearest-ties-even implementation one can do better. Let u be +the grid unit, so every individual real scale rounds with error at most u/2. +The first Horner error is at most u. The second Horner error is at most +(u + u/2)/(1-a) <= 3u. The normalization error is at most +(4/3)3u + u/2 = 4.5u. Therefore 5u safely bounds the component error versus +the exact inverse of the SAME stored grid observations. If the original +observations were first rounded to that grid, their component perturbation +is at most u/2, which contributes at most u through the inverse. The total +is at most 5.5u, so 6u is a safe advertised bound. The global Euclidean bound +is 6 sqrt(2N) u. One sufficient choice is + + p >= max(0, ceil(log2(12 N / eta))). + +The constants 5 and 6 are safe upper bounds, not claimed optimal constants. +Exact signed ADDs and phase operations must preserve the common grid; a +separately rounded ADD would require its own error term. + +Exact first-stage intermediates have components at most 2 B and exact +second-stage intermediates at most 4 B. For epsilon <= 1 and epsilon_in <= 1, a safe stored +component majorant throughout is 6 B + 16, including the final output. +Consequently it suffices to reserve p fractional bits, an integer magnitude +field for 8(B+2), and q W + 4 fixed guard bits for numerator products and +sign/rounding temporaries. W is fixed, so these add only a constant to the +payload bit precision. A constant-limb version is possible with its explicit +cross-limb shift tariff; no h-bit word silently holds a larger integer. + +## Ownership and address space + +The observations stay unchanged. For q = 2, two owned full-size work buffers +suffice: alternate them in the first Horner stage, then use its final buffer +as the retained source of the single V stage and the other as destination. +For q = 4, use three owned full-size buffers: retain S_W(U)v in one and +alternate the other two through the V Horner stage. All buffers are newly +owned or supplied zero scratch. The final answer occupies one work buffer; +other dependent buffers can be explicitly cleared in charged linear passes. +Arbitrary dirty caller banks are never overwritten or assumed zero. + +One conservative signed-magnitude layout uses four h-bit words per complex +entry, including separate sign fields. A literal U map and compiled V map +each use one index and one phase word per entry; allowing both costs 4 N +additional words. The fixed-denominator scalar procedure uses at most a fixed +multiple of q W + 1 plane words; reserve 12(q W + 1) + 64 scalar/control words. +Thus, if S other caller words must remain retained, a sufficient uniform +address-headroom condition for either q case is + + 2^h >= S + 20 N + 12(q W + 1) + 64. + +This is a sufficient allocation allowance, not a minimum or an observed peak +of the Python host. Code and read-only fixed constants are separately finite. +Metadata input labels and any descriptor arrays must be included in S if +not already represented by the two full map tables. + +The literal compile_return code walks W routing steps at each of N positions, +so its setup is O(W N), with no hidden W-fold live numeric pass. Alternatively +Pauli descriptors can be composed before enumerating addresses; that optional +implementation is not required by this stated runtime. Index and phase +computation, map storage, cleanup and all fixed-rational scan scratch are +charged. No Gaussian observation schedule or native producer is inferred. + +## Evidence and scope + +The mathematical proof combines the exact all-width Pauli return identity +from CASCADE-INVERSE.md with the bounded-word fixed-rational theorem from +DIVISION-PROOF.md. An independent review checked 144 extra signed rational +Pauli-routing fixtures, the actual compiled W-step map, a factored wrong-phase +rejection, and the failure of falsely using q = 2 on the genuine order-12 +quarter-phase fixture. All three frozen upstream coupler source files were +independently retrieved and matched their pins. Their original LICENSE and +NOTICE files must accompany redistribution. The old source headers' huge +kappa claims are retained provenance, not endorsed by this consumer theorem. +No Lean kernel, hosted CI, original full supplier scientific suite or human +peer review is claimed. Actual observation generation and a favorable complete +paid profile remain unproved. diff --git a/research/native-cyclic-recovery/INTEGRATION-CROSS-REVIEW.json b/research/native-cyclic-recovery/INTEGRATION-CROSS-REVIEW.json new file mode 100644 index 0000000000..e2a2dc28e8 --- /dev/null +++ b/research/native-cyclic-recovery/INTEGRATION-CROSS-REVIEW.json @@ -0,0 +1,57 @@ +{ + "reviewer": "Independent construction worker, OpenAI Codex assistance", + "status": "PASS_SCOPED_INTEGRATION_REVIEW", + "files": { + "verify.py": "ee6426b1a73357cc70c918819dd655050c6c5a7d3ccc76d1ed47d282e86a859f", + "fixed_divisor.py": "f4eb025ded92028362c68fd070fb181e166f446e7f1307ffa0580c5bc6cd7039", + "cascade_free.py": "64e906a2827f3e17987bddec85ee48a93ee574f494f1566460748bd2edf66162", + "INTEGRATED-CASCADE-THEOREM.md": "986b7f6a24e387c3cd44317b4d50e790d73c72d13f7befbc0464877eca406394" + }, + "executed": { + "command": "python -I -O -B research/native-cyclic-recovery/verify.py", + "invocation": "absolute script path from a separate working directory", + "result": "PASS_ROUNDED_NATIVE_CYCLIC_RECOVERY", + "cases": [ + { + "W": 3, + "q": 2, + "entries": 24, + "stored_error": "61/63", + "quantized_error": "86/63" + }, + { + "W": 3, + "q": 4, + "entries": 24, + "stored_error": "13/9", + "quantized_error": "40/21" + }, + { + "W": 13, + "q": 2, + "entries": 208, + "stored_error": "97157066/67108863", + "quantized_error": "131064083/67108863" + } + ], + "beta_sign_mutation_controls": 3 + }, + "mathematical_review": [ + "The max-absolute-real-component norm is preserved by literal unit quarter phases, signs and routing.", + "Nearest-even scale rounding has component error at most u/2. First Horner error is at most u. With a=2^-W<=1/2, the second stage error is at most (u+u/2)/(1-a)<=3u.", + "The normalization gamma<=4/3 amplifies that to at most 4u, and its final rounding contributes at most u/2. Thus 5u is safe against the exact inverse of the stored observations.", + "Input quantization by at most u/2 contributes at most u because the exact inverse has coefficient absolute sum 2. Therefore 6u is safe for the total component error.", + "The Euclidean bound follows by multiplying the component bound by sqrt(2N). The stated sufficient p>=ceil(log2(12N/eta)) is conservative.", + "Every rational scaling in the actual integer-grid datapath calls fixed_divisor.fixed_rational with nearest_even rounding. Fraction arithmetic is confined to the exact reference and error comparison.", + "Signed ADDs use a guarded common-grid representation and are prescribed exact; separately rounded ADDs would require an added error term.", + "The fixed rational numerator products and denominator constants fit the separately reserved physical guard width. Payload bits reported by a fixture are not its whole physical working width.", + "The exact runtime keeps W in both pass and return-compilation costs, and treats denominators as fixed only when W is fixed.", + "The stated allocation includes retained observations, three work buffers, map tables and scalar plane scratch; it is a sufficient implementation allowance, not the observed Python host peak." + ], + "limitations": [ + "These finite checks supplement the informal all-width proof and are not a Lean kernel audit or human peer review.", + "The wrong-beta-sign controls use deliberately large fixture amplitudes to distinguish the mutation from the safe 5u tolerance; they do not establish the proof by testing.", + "Both logical shifts, physical guard bits, complete address headroom, fixed W and fixed rational coefficients are explicit ABI premises.", + "Original multiplication observations and a favorable complete paid profile are not supplied; no new kappa or selected-frontier admission is claimed." + ] +} diff --git a/research/native-cyclic-recovery/INTEGRATION-RESULT.json b/research/native-cyclic-recovery/INTEGRATION-RESULT.json new file mode 100644 index 0000000000..3b3c110d64 --- /dev/null +++ b/research/native-cyclic-recovery/INTEGRATION-RESULT.json @@ -0,0 +1,42 @@ +{ + "status": "PASS_ROUNDED_NATIVE_CYCLIC_RECOVERY", + "cases": [ + { + "roles": 3, + "addresses_per_role": 8, + "total_entries": 24, + "cycle_order_divisor": 2, + "monomial_passes": 3, + "payload_bits": 24, + "stored_observation_error": "61/63", + "quantized_observation_error": "86/63", + "counted_scalar_data_operations": 348240 + }, + { + "roles": 3, + "addresses_per_role": 8, + "total_entries": 24, + "cycle_order_divisor": 4, + "monomial_passes": 5, + "payload_bits": 24, + "stored_observation_error": "13/9", + "quantized_observation_error": "40/21", + "counted_scalar_data_operations": 1064352 + }, + { + "roles": 13, + "addresses_per_role": 16, + "total_entries": 208, + "cycle_order_divisor": 2, + "monomial_passes": 13, + "payload_bits": 33, + "stored_observation_error": "97157066/67108863", + "quantized_observation_error": "131064083/67108863", + "counted_scalar_data_operations": 38170912 + } + ], + "mutation_controls": 3, + "arithmetic": "fixed rational scales use Boolean/both-shift/add bounded-word code, no MUL/DIV primitive", + "complete_supplier": false, + "new_kappa": null +} diff --git a/research/native-cyclic-recovery/LICENSE b/research/native-cyclic-recovery/LICENSE new file mode 100644 index 0000000000..261eeb9e9f --- /dev/null +++ b/research/native-cyclic-recovery/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/research/native-cyclic-recovery/MANIFEST.json b/research/native-cyclic-recovery/MANIFEST.json new file mode 100644 index 0000000000..2759db998d --- /dev/null +++ b/research/native-cyclic-recovery/MANIFEST.json @@ -0,0 +1,40 @@ +{ + "algorithm": "sha256", + "files": { + ".gitattributes": "f06202a408fef9b9ea69bb6b1cb8160dbb0378c5bb67a444d510d231813824c8", + "APPLICATION-PINS.json": "473314b3f2708892e6e4983561b395582592c8d256e4682add58017d372380f6", + "APPLICATIONS-NOTE.md": "f075fe606310500f2cfc9d2e0dbc5a560a2ed743008edcc3e9958652af85091d", + "CASCADE-CROSS-REVIEW.json": "70aba801812c40e390af5d9a8e362c767a0dfcd3338fd3d22ea94704d490ffd3", + "CASCADE-EXPECTED.json": "c772111f1e1a44dda45d85d395eda1a8c9ddf1f23166fe7aee3616e318bb948a", + "CASCADE-INVERSE.md": "bc66783f0d2e746eecc40246127269612c4443d2813091b38732093637d86cab", + "CASCADE-ORIGINS.json": "b5265c8cd6ac0738a111363f85d4c13a2b910d214ce9c3a5322b16a5d144262b", + "cascade_free.py": "64e906a2827f3e17987bddec85ee48a93ee574f494f1566460748bd2edf66162", + "CHECKS.json": "9079f98459e6a127f65770fd327745c03b38f563fc8ca5a9b0e1e4d4515f351c", + "DIVISION-CROSS-REVIEW.json": "b7c5530870445838d1be2864114b3acb6eb520010ab792b08a5136dfe175359e", + "DIVISION-PROOF.md": "7aa756b89c59fa107e9c3b8b9d7f3420364aa35c1905f883102d6197d763655d", + "DIVISION-RESULT.json": "0c09509a46efe0ecec40a98927d9813043aa34702ee7258cdbd58d9f5073031d", + "fixed_divisor.py": "f4eb025ded92028362c68fd070fb181e166f446e7f1307ffa0580c5bc6cd7039", + "INTEGRATED-CASCADE-THEOREM.md": "986b7f6a24e387c3cd44317b4d50e790d73c72d13f7befbc0464877eca406394", + "INTEGRATION-CROSS-REVIEW.json": "9a789aeef3839b397c35535791277302faede3ef85986244ca421c6366be76b5", + "INTEGRATION-RESULT.json": "721d3169fd15879d6db9b3b51d5ba72ad4734e7bb2ffe2b0e9d76d3d68dfa2e4", + "LICENSE": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4", + "MUTATION-RECEIPTS.json": "516990c99c3dfe2830e5b65726bab2e2100f470934fd962899befd4d8c02042c", + "NOTICE": "3804acd4e9c604cbafad5a18049e004eebc7dffa789cf03e693502311ff8b716", + "preflight.py": "761182ae1a70cf5d5b910738e26862d36b0e07c8b7b2990a8d3ef23943bd2c49", + "README.md": "445a4258ca34b0c26dd6d569884c3f489bcaef94e1987c285f55857ac09476db", + "SOURCES.json": "72dc01f42b1f1b2d69f13262c2464711e706376f0ba27c04aaade53899b248fe", + "TASK.json": "94bbab1d5236274b2f3f7e2afa8772bfac463ae2d83a248b9075f9e687ff630b", + "VERIFY.json": "f314429882f0b7e01acd9622be911b7e0cffe536898f2ad339996cf3dcd17677", + "verify.py": "ee6426b1a73357cc70c918819dd655050c6c5a7d3ccc76d1ed47d282e86a859f", + "verify_division.py": "f82129d58d35fb8421c53f39f581c0079811477ca53dada6993b13d7714b7ddc", + "cascade_sources/pr4818-LICENSE": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4", + "cascade_sources/pr4818-NOTICE.md": "800b9d5f73899298881770fc685a781307dbb15f575b699619305d10a9ef6144", + "cascade_sources/pr4818-verify_schedule.py": "7fab42730ebb5e1cd88dc369df526a002e91a70dc99cdbf4a7c0133fefa7e33d", + "cascade_sources/pr4819-LICENSE": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4", + "cascade_sources/pr4819-NOTICE.md": "800b9d5f73899298881770fc685a781307dbb15f575b699619305d10a9ef6144", + "cascade_sources/pr4819-verify_schedule.py": "4ddb2d11a4da6a05db3f06a400bd74059ce1448142df028e82a09d50eca06567", + "cascade_sources/pr4826-LICENSE": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4", + "cascade_sources/pr4826-NOTICE.md": "d1eedd22450ada586f9fdb17f736bb9b20d440d2ea4b8e4bcdbcf39c2d2502dd", + "cascade_sources/pr4826-verify_schedule.py": "de0256a33d4007615b8dc0ab4c45ce3582bfb2cf963b499f84b0362935c96c4e" + } +} diff --git a/research/native-cyclic-recovery/MUTATION-RECEIPTS.json b/research/native-cyclic-recovery/MUTATION-RECEIPTS.json new file mode 100644 index 0000000000..8c7de22a6c --- /dev/null +++ b/research/native-cyclic-recovery/MUTATION-RECEIPTS.json @@ -0,0 +1,20 @@ +[ + { + "mutation": "suffix", + "exit_code": 1, + "diagnostic": "ValueError: exhaustive exact quotient/remainder", + "source_sha256": "f4eb025ded92028362c68fd070fb181e166f446e7f1307ffa0580c5bc6cd7039" + }, + { + "mutation": "return-phase", + "exit_code": 1, + "diagnostic": "ValueError: factored inverse on actual basis column", + "source_sha256": "64e906a2827f3e17987bddec85ee48a93ee574f494f1566460748bd2edf66162" + }, + { + "mutation": "normalization", + "exit_code": 1, + "diagnostic": "ValueError: five-grid-unit bound versus stored observations", + "source_sha256": "ee6426b1a73357cc70c918819dd655050c6c5a7d3ccc76d1ed47d282e86a859f" + } +] diff --git a/research/native-cyclic-recovery/NOTICE b/research/native-cyclic-recovery/NOTICE new file mode 100644 index 0000000000..4b7ed3c6ad --- /dev/null +++ b/research/native-cyclic-recovery/NOTICE @@ -0,0 +1,4 @@ +Prepared for Dugongue with substantial OpenAI Codex assistance, one lead and three workers. +Apache-2.0. New contribution: explicit phase-retaining finite-pass cyclic consumer, bounded-word fixed-rational scan, and their rounded composition. No new kappa or paid observation producer is claimed. +Retained source scripts are byte-identical excerpts from hexapode PRs #4818, #4819 and #4826; their per-package LICENSE and NOTICE.md files accompany them under cascade_sources. Source headers make unsupported large-kappa claims that are not endorsed here. +Credit Clear1nsight #4842, Dugongue #4743/#4885, JoyboyBrian #4797, Nick Petalas #4825, Ali Romman #4733, Yiyang/Lyy-iiis #4710, lee-phys #4688, Jacob Alan Sussman #4628, and every contributor named by the retained notices. Blelloch prefix scan and standard geometric-series/Pauli methods are not claimed as new general techniques. diff --git a/research/native-cyclic-recovery/README.md b/research/native-cyclic-recovery/README.md new file mode 100644 index 0000000000..2c509511f9 --- /dev/null +++ b/research/native-cyclic-recovery/README.md @@ -0,0 +1,46 @@ +# Bounded-word recovery for actual cyclic Pauli ports + +Given cyclic observations `v = (I + U/2)y`, with fixed role count W and phase-retaining Pauli routing U, this package constructs and executes an explicit inverse. It replaces a dense inverse oracle with a finite monomial/ADD program and implements every prescribed fixed-rational rounding using ordinary bounded-word operations, without a multiplication or division primitive. + +The two constructive mechanisms are: + +1. Compile the return monomial V = U^W and factor the finite inverse. At most W + q - 2 monomial/ADD passes suffice, where q = 2 for pure XOR routing and q = 4 for general quarter-phase Pauli routing. The inspected three-role and thirteen-role XOR ports use 3 and 13 passes, respectively. Absolute phases are retained. +2. Pack all binary-prefix remainders of one scalar into a constant number of ordinary bit-plane words. A doubling scan emits all quotient bits in O(log(2 + h)) Boolean/shift/add instructions at h-bit precision, for each fixed divisor. Signed floor, truncation and nearest ties to even are explicit. No MUL, DIV, remainder or table oracle is used. + +For N TOTAL complex entries across the W roles, the combined fixed-W consumer costs O(W N log(2 + h)) instructions, with explicit fixed-denominator constants, O(W N) literal return-table preprocessing, and two owned full buffers for XOR or three for general phases. The observation arrays remain intact. The Python implementation additionally stores an O(N) routing table. [INTEGRATED-CASCADE-THEOREM.md](INTEGRATED-CASCADE-THEOREM.md) gives the quantifiers, address headroom and precision: error is at most 5 grid units against exact recovery of stored observations, or 6 including half-unit observation quantization, per real/imaginary component. + +This also improves PR #4885's conservative fixed-rational recovery fallback from O(N h) to O(N log(2 + h)), under the declared both-logical-shifts Word RAM. [APPLICATIONS-NOTE.md](APPLICATIONS-NOTE.md) instantiates the exact-image odd divisions already priced by Ali Romman's PR #4733; those source constructions are credited premises, not newly replayed here. + +**No new κ was obtained.** The actual paid producer of the favorable cyclic observations remains unproved. This is a sufficient consumer theorem and executable arithmetic implementation, not a complete supplier or multiplication theorem. The literal source couplers from #4818, #4819 and #4826 are authenticated and checked; their retained headers make large κ claims that this package does not endorse. No new κ follows from coupling matrices, their inverse or a favorable hypothetical producer bill. The selected main certificate remains unchanged. + +## Reproduce + +Python 3.10 or later, standard library only; no solver, Git, GPU, network or platform-specific executable is needed for direct replay. From this directory: + +```sh +python3 -I -B verify_division.py +python3 -I -O -B verify_division.py +python3 -I -B cascade_free.py +python3 -I -O -B cascade_free.py +python3 -I -B verify.py +python3 -I -O -B verify.py +python3 -I -B preflight.py +``` + +From a repository checkout, `python3 -B scripts/research_package.py --package research/native-cyclic-recovery` runs the registered checks. Direct checks only read their files. Python Fraction arithmetic is used by the independent references and exact cascade certificate; the bounded-word scalar datapath itself is the explicitly instrumented Boolean/shift/add implementation in fixed_divisor.py. Operation counts are conservative emulation bounds, not cycle-accurate processor timings or a demonstrated practical speedup. Normal and optimized checks use explicit rejection, not assertions. + +The division proof applies to every positive width with fixed guard widening and sufficient address space; finite tests cover widths through 4,096, 6,912 unsigned cases, 24,978 signed-rounding cases and 840 fixed-rational cases. Separate review adds 5,117 boundary cases. The cascade checker covers all 376 literal basis columns and 7,168 pinned coupler entries; independent review includes 144 additional fixtures and tensor-width phase controls. End-to-end checks compare rounded recovery with a distinct exact rational reference and reject a wrong recurrence sign. Separate optimized subprocess mutations also reject an incorrect prefix remainder offset, discarded return phases and a wrong final normalization denominator. These finite checks corroborate the written universal proofs, rather than replacing them. + +## Scope and precedent + +[CASCADE-INVERSE.md](CASCADE-INVERSE.md) proves the phase-preserving decoder. [DIVISION-PROOF.md](DIVISION-PROOF.md) proves the bounded-word scalar implementation. The exact Problem 1.8 Lean RAM derives right shift using DIV; both shifts are primitives in this contribution's explicitly different ABI. There is no claimed division-free compilation into that literal Lean instruction set. Inspected MathProof shift/division sources and DAG entries are source-only precedent, without a fresh kernel audit. + +Credit hexapode's #4818/#4819/#4826 for the particular cyclic couplers, Clear1nsight's #4842 for full-cascade conditioning and the producer/admission distinction, Dugongue's #4743/#4885 for native-port and resonant recovery context, JoyboyBrian #4797 for the resonant channel and Nick Petalas #4825 for its width-four rank question, Ali Romman #4733 for concrete odd-division services, and the retained Yiyang / Lyy-iiis #4710, lee-phys #4688 and Jacob Alan Sussman #4628 lineage. Classical finite geometric series, Clifford/Pauli conjugation, Blelloch associative scan and invariant division are credited standard ingredients; no broad literature-priority claim is made. Prepared by Dugongue with substantial OpenAI Codex assistance from one lead and three workers. Root Apache-2.0 and every redistributed predecessor LICENSE/NOTICE are retained. + +Canonical main was refreshed through a dedicated immutable checkpoint ref at 624de9dc66858af0945e5f8a0942488d62280d43, priority revision 7. Public PR bodies and relevant exact sources were inspected, including #4885 and successors; remote Discussion loading and sparse local notes provide incomplete overlap coverage. No worldwide novelty or exhaustive repository audit is claimed. Full source-history audit, hosted Linux CI, a Lean kernel audit, supplier admission and a practical full multiplier were not run. The authoritative MathProof DAG, frozen predecessor packages and selected frontier are unchanged. + +## Open next questions + +- Emit one named cyclic observation from independent original inputs with a chronological producer, paid Gaussian profile, retained owners and restoration. The inverse here supplies its consumer; it supplies no missing producer. +- Bind the entire producer/consumer word to an admitted native compiler and all nine outer rows. Count every call, monomial pass, buffer, phase, initialization, clearing and source error. +- Integrate the fixed-divisor routine into an executable native backend with the declared both-shifts ABI; compare actual instruction counts and crossover widths without substituting RAM instructions for tape head steps. diff --git a/research/native-cyclic-recovery/SOURCES.json b/research/native-cyclic-recovery/SOURCES.json new file mode 100644 index 0000000000..ac343964bb --- /dev/null +++ b/research/native-cyclic-recovery/SOURCES.json @@ -0,0 +1,42 @@ +{ + "schema_version": 1, + "base_commit": "624de9dc66858af0945e5f8a0942488d62280d43", + "files": [ + { + "path": "certificates/selected-result.json", + "usage": "provenance", + "git_blob": "c35482cd9035843b15a634cc8276a7e1e40e8395", + "sha256": "6fe0a099b89aa2aed796a13c3a21dafc63f3388ebf397464e44e0451893b9375" + }, + { + "path": "docs/research/agent-task-catalog.json", + "usage": "provenance", + "git_blob": "f126dd2e2dad2b669e75d1d0d0bd05c600725602", + "sha256": "f7a48bfa2659b88378282a8eee7d9fe52cdf505594124c4d1686b58510fffd72" + } + ], + "external_origins": [ + { + "pr": 4818, + "head": "fd29d065bbe12f5be5af02fdf5a8b4d86dda3381", + "path": "cascade_sources/pr4818-verify_schedule.py", + "sha256": "7fab42730ebb5e1cd88dc369df526a002e91a70dc99cdbf4a7c0133fefa7e33d", + "url": "https://raw.githubusercontent.com/CrocSwap/integer-mult-bounds/fd29d065bbe12f5be5af02fdf5a8b4d86dda3381/research/complex-block4-three-in-ten/verify_schedule.py" + }, + { + "pr": 4819, + "head": "a7b42c2f8ffe5a18d305ca4dda5729d2f1d72ea8", + "path": "cascade_sources/pr4819-verify_schedule.py", + "sha256": "4ddb2d11a4da6a05db3f06a400bd74059ce1448142df028e82a09d50eca06567", + "url": "https://raw.githubusercontent.com/CrocSwap/integer-mult-bounds/a7b42c2f8ffe5a18d305ca4dda5729d2f1d72ea8/research/complex-block4-thirteen-in-fortyone/verify_schedule.py" + }, + { + "pr": 4826, + "head": "d7b53d3992e658f0dd49d0207ba33bbc39272bac", + "path": "cascade_sources/pr4826-verify_schedule.py", + "sha256": "de0256a33d4007615b8dc0ab4c45ce3582bfb2cf963b499f84b0362935c96c4e", + "url": "https://raw.githubusercontent.com/CrocSwap/integer-mult-bounds/d7b53d3992e658f0dd49d0207ba33bbc39272bac/research/complex-block5-three-in-nine/verify_schedule.py" + } + ], + "claim_scope": "Sufficient consumer and bounded-word scalar arithmetic only; no paid producer, new kappa or kernel audit." +} diff --git a/research/native-cyclic-recovery/TASK.json b/research/native-cyclic-recovery/TASK.json new file mode 100644 index 0000000000..c8e97c37b0 --- /dev/null +++ b/research/native-cyclic-recovery/TASK.json @@ -0,0 +1,80 @@ +{ + "schema_version": 1, + "task_id": "uniform-transfer-audit", + "priority_revision": 7, + "base_commit": "624de9dc66858af0945e5f8a0942488d62280d43", + "original_card": { + "id": "uniform-transfer-audit", + "question": "Does one quantified step of the proposed #4100 all-size construction hold at its actual caller?", + "starting_points": [ + "docs/research/research-family-status.md", + "certificates/selected-result.json", + "research/unconditional-batched-crt/README.md" + ], + "methods": [ + "Prove one missing implication with explicit quantified hypotheses.", + "Find an exact counterexample at the claimed interface boundary." + ], + "acceptance_gate": "Identify the proposition and what would change downstream; do not equate a finite replay with a universal proof.", + "first_step": { + "command": [ + "python3", + "-B", + "scripts/research_baseline.py" + ], + "expected": "PASS_RESEARCH_BASELINE_BINDINGS_ONLY", + "inspect": "Read PROOF.md and AUDIT.md in #4100. Select one distinct obligation: CRT total repair, native/free-algebra lifting, precision/conditioning, or complete fixed-tape cost. This is an author-submitted proof, not an accepted unconditional theorem.", + "scope": "Source-binding orientation only; no scientific replay, theorem acceptance or supplier admission. Budget any heavy replay separately." + }, + "first_experiment": "Check live handoffs; name one proposition, its caller, quantified domain and dependency closure. Independently prove the implication or exhibit a precise gap/counterexample. Prioritize CRT.md total repair or COMPLEX.md free-algebra lift only if unclaimed. Stop at the chosen obligation; do not substitute finite samples or root arithmetic for an all-size proof, or launch the complete package by default.", + "bottleneck_link": "Finite supplier improvements are useful only under the retained transfer obligations.", + "allowed_variations": [ + "One CRT repair, native lift, precision/conditioning or tape-cost proposition, with its exact caller." + ], + "scope_change_triggers": [ + "Replacing a quantified obligation with another finite smoke test.", + "Treating archive intake, an author PASS receipt or a finite composed fixture as discharge of the universal hypotheses." + ], + "overlap_terms": [ + "uniform transfer", + "all-size", + "precision", + "4100", + "unconditional-batched-crt" + ], + "existing_checks": [ + { + "scope": "PR #4100: proposed unconditional construction and finite checks, without independent acceptance.", + "evidence": "research/unconditional-batched-crt/README.md", + "remaining": "Independent proof audit of one caller-bound all-size implication; all other premises remain explicit.", + "status": "author-checked", + "source_commit": "337d04939571a637aeab54a0f58f54fde811663a", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + } + ] + }, + "scope_status": "changed", + "actual_scope": "Construct and execute phase-preserving cyclic Pauli recovery and its bounded-word fixed-rational arithmetic; no observation producer or new kappa.", + "scope_change_reason": "The user assigned a new complete kappa improvement. Bounded complete-cost construction searches found no accepted improvement; this positive consumer/implementation result addresses a concrete gap in the newer cyclic proposals instead of claiming the original root.", + "bottleneck_link": "Replaces dense consumer inversion and a hidden rational-scalar oracle with explicit finite passes and a both-shifts bounded-word algorithm; favorable actual observation emission remains required.", + "budget_minutes": 60, + "stop_rule": "Stop discovery by 23:37 UTC and retain the final quarter of the sixty-minute session for verification and release. No repeated fixed-invoice root refinement counts as an improvement.", + "outcome": "partial", + "evidence": "Written universal proofs, exact normal/optimized standard-library replay, independent cross-review and source-bound phase controls.", + "author": "Dugongue", + "ai_assistance": "OpenAI Codex lead plus three agents; no Jev, Lean proof kernel or human review claimed.", + "open_questions": [ + { + "question": "Can a complete paid producer emit the cyclic observation port?", + "why_it_matters": "Only a source-compatible complete paid profile can yield a kappa improvement.", + "first_step": "Emit and replay one chronological arbitrary-input word including owned restoration, then price the complete consumer supplied here.", + "blocked_by": "No favorable paid observation producer or complete compiler/outer invoice is supplied." + }, + { + "question": "Can the scalar scan be integrated into the declared native ABI?", + "why_it_matters": "The theorem is an operation upper bound, not a measured native backend or tape tariff.", + "first_step": "Implement both logical shifts and constant guard limbs in a bounded-word interpreter, then bind one exact source service.", + "blocked_by": "No compiled native backend or practical crossover measurement is claimed." + } + ] +} diff --git a/research/native-cyclic-recovery/VERIFY.json b/research/native-cyclic-recovery/VERIFY.json new file mode 100644 index 0000000000..c316eefe6b --- /dev/null +++ b/research/native-cyclic-recovery/VERIFY.json @@ -0,0 +1,82 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [], + "commands": [ + { + "argv": [ + "{python}", + "-I", + "-B", + "{package}/preflight.py" + ], + "timeout_seconds": 120, + "checks": "Exact inventory; exact scalar/cascade proof evidence and end-to-end rounded consumer, with explicit rejection active under optimization." + }, + { + "argv": [ + "{python}", + "-I", + "-B", + "{package}/verify_division.py" + ], + "timeout_seconds": 120, + "checks": "Exact inventory; exact scalar/cascade proof evidence and end-to-end rounded consumer, with explicit rejection active under optimization." + }, + { + "argv": [ + "{python}", + "-I", + "-O", + "-B", + "{package}/verify_division.py" + ], + "timeout_seconds": 120, + "checks": "Exact inventory; exact scalar/cascade proof evidence and end-to-end rounded consumer, with explicit rejection active under optimization." + }, + { + "argv": [ + "{python}", + "-I", + "-B", + "{package}/cascade_free.py" + ], + "timeout_seconds": 120, + "checks": "Exact inventory; exact scalar/cascade proof evidence and end-to-end rounded consumer, with explicit rejection active under optimization." + }, + { + "argv": [ + "{python}", + "-I", + "-O", + "-B", + "{package}/cascade_free.py" + ], + "timeout_seconds": 120, + "checks": "Exact inventory; exact scalar/cascade proof evidence and end-to-end rounded consumer, with explicit rejection active under optimization." + }, + { + "argv": [ + "{python}", + "-I", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 120, + "checks": "Exact inventory; exact scalar/cascade proof evidence and end-to-end rounded consumer, with explicit rejection active under optimization." + }, + { + "argv": [ + "{python}", + "-I", + "-O", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 120, + "checks": "Exact inventory; exact scalar/cascade proof evidence and end-to-end rounded consumer, with explicit rejection active under optimization." + } + ] +} diff --git a/research/native-cyclic-recovery/cascade_free.py b/research/native-cyclic-recovery/cascade_free.py new file mode 100644 index 0000000000..b9fc65b88c --- /dev/null +++ b/research/native-cyclic-recovery/cascade_free.py @@ -0,0 +1,149 @@ +"""Exact finite-pass inverse for quarter-phase monomial cyclic couplers. +Apache-2.0. Standalone research leaf; this does not emit paid observations. +""" +from fractions import Fraction as Q +from pathlib import Path +import json + + +def need(ok, message): + if not ok: + raise ValueError(message) + + +def add(a, b): + return (a[0] + b[0], a[1] + b[1]) + + +def scale(a, c): + return (c * a[0], c * a[1]) + + +def phase(a, e): + for unused in range(e % 4): + a = (-a[1], a[0]) + return a + + +def shift(v, w, n, labels, phases): + # Literal U: (Uv)[k,x] = i^phases[k,x] v[k+1, x xor labels[k]]. + return [phase(v[((k+1)%w)*n+(x^labels[k])], phases[k][x]) + for k in range(w) for x in range(n)] + + +def decode(v, w, n, labels, phases, period): + # Horner: I - U/2 + U^2/4 - ... + (-U/2)^(period-1). + need(period % 2 == 0, 'even period required') + z = [(Q(0), Q(0)) for unused in v] + for unused in range(period): + z = [add(a, scale(b, Q(-1, 2))) + for a, b in zip(v, shift(z,w,n,labels,phases))] + denominator = 1 - Q(1, 2)**period + return [scale(a, 1/denominator) for a in z] + + +def compile_return(w,n,labels,phases): + # Compile U^W as a single monomial map; never apply W live data passes. + out=[] + for k in range(w): + for x in range(n): + role=k;address=x;e=0 + for unused in range(w): + e=(e+phases[role][address])%4 + address ^= labels[role];role=(role+1)%w + out.append((role*n+address,e)) + return out + + +def apply_map(v,compiled): + return [phase(v[j],e)for j,e in compiled] + + +def decode_factored(v,w,n,labels,phases,q): + compiled=compile_return(w,n,labels,phases) + z=list(v) + for unused in range(w-1): + z=[add(a,scale(b,Q(-1,2)))for a,b in zip(v,shift(z,w,n,labels,phases))] + # S_W(U) above. V=U^W; beta=(-1/2)^W; invert I-beta V. + beta=Q(-1,2)**w + out=list(z) + for unused in range(q-1): + out=[add(a,scale(b,beta))for a,b in zip(z,apply_map(out,compiled))] + return [scale(a,1/(1-beta**q))for a in out] + + +def verify_case(w,n,labels,phases,period): + dim=w*n + for j in range(dim): + v=[(Q(0),Q(0)) for unused in range(dim)];v[j]=(Q(1),Q(0)) + u=v + for unused in range(period):u=shift(u,w,n,labels,phases) + need(u==v,'literal monomial period') + observed=[add(a,scale(b,Q(1,2)))for a,b in zip(v,shift(v,w,n,labels,phases))] + got=decode(observed,w,n,labels,phases,period) + need(got==v,'inverse on actual basis column') + q=period//w + need(decode_factored(observed,w,n,labels,phases,q)==v,'factored inverse on actual basis column') + return {'roles':w,'addresses':n,'dimension':dim,'period':period, + 'exact_basis_columns':dim,'monomial_passes_upper_bound':period, + 'ADD_passes_upper_bound':period,'coefficient_l1':str(Q(2)), + 'factored_monomial_passes':w+period//w-2, + 'factored_ADD_passes':w+period//w-2} + + +def bind_sources(): + import hashlib, ast + root=Path(__file__).resolve().parent + rows=json.loads((root/'CASCADE-ORIGINS.json').read_text()) + bound=[] + for row in rows: + source=root/row['path'];raw=source.read_bytes() + need(hashlib.sha256(raw).hexdigest()==row['sha256'],'retained cascade source hash') + d={'__name__':'retained_cascade'} + exec(compile(raw,str(source),'exec'),d) + number=row['pr'] + if number in [4818,4819]: + ops=d['build_operators_m4']();k=ops['K'];n=16 + gs=ops['couplers']if number==4819 else[ops['G1'],ops['G2'],ops['G3']] + else: + # Evaluate the frozen constructor only through E3; do not run dense solvers. + tree=ast.parse(raw);function=next(x for x in tree.body if isinstance(x,ast.FunctionDef)and x.name=='run_3in9_schedule_verification') + body=[] + for statement in function.body: + body.append(statement) + if isinstance(statement,ast.Assign)and any(isinstance(t,ast.Name)and t.id=='E3'for t in statement.targets):break + body.append(ast.Return(ast.Call(func=ast.Name(id='locals',ctx=ast.Load()),args=[],keywords=[]))) + f=ast.FunctionDef(name='literal_prefix',args=function.args,body=body,decorator_list=[]) + module=ast.fix_missing_locations(ast.Module(body=[f],type_ignores=[])) + exec(compile(module,'frozen_constructor_prefix','exec'),d);ops=d['literal_prefix']();k=ops['K'];n=32 + gs=[ops['G1'],ops['G2'],ops['G3']] + labels=list(range(1,14))if number==4819 else[1,2,4] + for g,label in zip(gs,labels): + for r in range(n): + for c in range(n): + need(tuple(g[r][c])==((Q(1,2),Q(0))if r==(c^label)else(Q(0),Q(0))),'literal source coupler entry') + need(d['mm'](k,g)==d['mm'](g,k),'source target/coupler conjugation') + bound.append({'pr':number,'head':row['head'],'exact_coupler_entries':len(gs)*n*n}) + return bound + + +def main(): + receipts=[] + for w,n,labels in [(3,16,[1,2,4]),(3,32,[1,2,4]),(13,16,list(range(1,14)))]: + phases=[[0]*n for unused in range(w)] + receipts.append(verify_case(w,n,labels,phases,2*w)) + # Noncommuting quarter-phase Pauli couplers: retain the exact phase. + w=3;n=8;labels=[1,2,4];masks=[2,3,5];es=[1,2,3] + phases=[[(es[k]+2*(x&masks[k]).bit_count())%4 for x in range(n)] for k in range(w)] + receipts.append(verify_case(w,n,labels,phases,4*w)) + # Genuine phase mutation control: same inverse polynomial with one wrong U. + v=[(Q(j%3-1),Q(j%5-2))for j in range(w*n)] + observed=[add(a,scale(b,Q(1,2)))for a,b in zip(v,shift(v,w,n,labels,phases))] + bad=[[0]*n for unused in range(w)] + need(decode(observed,w,n,labels,bad,4*w)!=v,'phase-discard mutation') + result={'status':'PASS_FINITE_MONOMIAL_CASCADE_INVERSE','new_kappa':False, + 'paid_observation_word_emitted':False,'cases':receipts,'source_binding':bind_sources(), + 'controls':['discarded phase changes decoder and is rejected']} + print(json.dumps(result,indent=2)) + +if __name__=='__main__':main() diff --git a/research/native-cyclic-recovery/cascade_sources/pr4818-LICENSE b/research/native-cyclic-recovery/cascade_sources/pr4818-LICENSE new file mode 100644 index 0000000000..261eeb9e9f --- /dev/null +++ b/research/native-cyclic-recovery/cascade_sources/pr4818-LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/research/native-cyclic-recovery/cascade_sources/pr4818-NOTICE.md b/research/native-cyclic-recovery/cascade_sources/pr4818-NOTICE.md new file mode 100644 index 0000000000..c97213cef7 --- /dev/null +++ b/research/native-cyclic-recovery/cascade_sources/pr4818-NOTICE.md @@ -0,0 +1,9 @@ +# Attribution + +Prepared for Dugongue with substantial OpenAI Codex assistance from four workers. Apache-2.0. Independent agent review is AI review, not human peer review or a Lean kernel certificate. + +Yiyang (@Lyy-iiis), PR #4710 at b0d5192390af493d626054b060921895df3c94d2, supplies the phase repair, actual Gaussian-rational residual engine and separately tensorized residual identities. Its engine and README are retained byte for byte. The exact predecessor notice is PREDECESSOR-NOTICE.md. + +lee-phys, PR #4688 at 264c4b3cb13c82d171de352ecf60486dfb8d2bd4, supplies the original two-image prefix and rank engine. Its README is retained unchanged for credit; its rank engine is not needed or rerun here. Jacob Alan Sussman, PR #4628 at ee4fd87f064017c23e5a86fc1dcfe0a5237caed3, supplies the complex small-block engine problem and hook lower-bound framework. All retained predecessor notices and assistance disclosures remain in force. + +The new scope is an arbitrary-second-input port and explicit reverse schedule, a phase-correct swap-sector continuation, the accompanying native address/precision contract, and an exact finite geometry search coordinate system. The underlying prefix and residual identity are predecessor results. No worldwide novelty or new multiplication exponent is claimed. diff --git a/research/native-cyclic-recovery/cascade_sources/pr4818-verify_schedule.py b/research/native-cyclic-recovery/cascade_sources/pr4818-verify_schedule.py new file mode 100644 index 0000000000..8f9a2ef3cd --- /dev/null +++ b/research/native-cyclic-recovery/cascade_sources/pr4818-verify_schedule.py @@ -0,0 +1,447 @@ +#!/usr/bin/env python3 +"""Exact Synthesis & Verification of the 3-Array 10-Call Cascade Schedule on V = C^16. + +Proves the viability of breaking the kappa > 0.10 milestone via: + - W = 3 arrays in s = 10 calls at block size m = 4. + - State space: (C^16)^3 = 48 dimensions over Q(i). + - Target operator: K = C_3 C_2 C_1 C_0 on C^16. + - Saving: kappa = ln(m*W/s) / ln(m) = 1 - ln(10/3) / ln(4) = ln(1.2) / ln(4) = 0.131517... (13.15% > 10%). + - Total demand: 3 * 86,592 = 259,776 ranks. + - Total capacity: 10 * 27,456 = 274,560 ranks. + - Gross surplus: +14,784 ranks (94.62% required efficiency). + +Cascade Schedule: + - Port 1 (3 calls on x1, x2): v1 = K x1 + E1 x2, t1 = C0 x1 + - Port 2 (3 calls on x2, x3): v2 = K x2 + E2 x3, t2 = C0 x2 + - Port 3 (4 calls on x3, x1): closing the 3-cycle loop (v3 = K x3 + E3 x1, t3 = C0 x3) + - Total paid calls = 3 + 3 + 4 = 10 calls. + +Standard library only (fractions.Fraction, math, random). Exact Q(i) arithmetic. +""" + +from __future__ import annotations +import math +import random +from fractions import Fraction +from typing import Dict, List, Tuple + + +# ============================================================================== +# SECTION 1: Exact Gaussian Rational Arithmetic over Q(i) +# ============================================================================== + +def q(real=0, imag=0) -> Tuple[Fraction, Fraction]: + return (Fraction(real), Fraction(imag)) + +ZERO, ONE, I = q(), q(1), q(0, 1) + +def add(x: Tuple[Fraction, Fraction], y: Tuple[Fraction, Fraction]) -> Tuple[Fraction, Fraction]: + return (x[0] + y[0], x[1] + y[1]) + +def sub(x: Tuple[Fraction, Fraction], y: Tuple[Fraction, Fraction]) -> Tuple[Fraction, Fraction]: + return (x[0] - y[0], x[1] - y[1]) + +def mul(x: Tuple[Fraction, Fraction], y: Tuple[Fraction, Fraction]) -> Tuple[Fraction, Fraction]: + return (x[0] * y[0] - x[1] * y[1], x[0] * y[1] + x[1] * y[0]) + +def conj(x: Tuple[Fraction, Fraction]) -> Tuple[Fraction, Fraction]: + return (x[0], -x[1]) + +def div(x: Tuple[Fraction, Fraction], y: Tuple[Fraction, Fraction]) -> Tuple[Fraction, Fraction]: + denom = y[0] ** 2 + y[1] ** 2 + if denom == 0: + raise ZeroDivisionError("division by zero in Q(i)") + return ((x[0] * y[0] + x[1] * y[1]) / denom, (x[1] * y[0] - x[0] * y[1]) / denom) + +def scale_m(c: Tuple[Fraction, Fraction], mat: List[List[Tuple[Fraction, Fraction]]]): + return [[mul(c, val) for val in row] for row in mat] + +def mm(a: List[List[Tuple[Fraction, Fraction]]], b: List[List[Tuple[Fraction, Fraction]]]): + n = len(a) + p = len(b[0]) + k_dim = len(b) + out = [[ZERO for _ in range(p)] for _ in range(n)] + for r in range(n): + for k in range(k_dim): + if a[r][k] == ZERO: + continue + for c in range(p): + if b[k][c] != ZERO: + out[r][c] = add(out[r][c], mul(a[r][k], b[k][c])) + return out + +def mv(mat: List[List[Tuple[Fraction, Fraction]]], vec: List[Tuple[Fraction, Fraction]]): + n = len(mat) + k_dim = len(vec) + out = [ZERO for _ in range(n)] + for r in range(n): + s = ZERO + for c in range(k_dim): + if mat[r][c] != ZERO and vec[c] != ZERO: + s = add(s, mul(mat[r][c], vec[c])) + out[r] = s + return out + +def ident(n=16): + return [[ONE if r == c else ZERO for c in range(n)] for r in range(n)] + +def adjoint(a: List[List[Tuple[Fraction, Fraction]]]): + return [[conj(a[c][r]) for c in range(len(a))] for r in range(len(a[0]))] + + +# ============================================================================== +# SECTION 2: Operators on V = C^16 (Block m = 4) +# ============================================================================== + +def shift_mat(v: int, n=16): + out = [[ZERO for _ in range(n)] for _ in range(n)] + for x in range(n): + out[x ^ v][x] = ONE + return out + +def c_letter(bit: int, n=16): + """C_v = a I + b X_v with a = (1+i)/2, b = (1-i)/2.""" + sh = shift_mat(1 << bit, n) + a_coef = q(Fraction(1, 2), Fraction(1, 2)) + b_coef = q(Fraction(1, 2), Fraction(-1, 2)) + id_n = ident(n) + out = [[ZERO for _ in range(n)] for _ in range(n)] + for r in range(n): + for c in range(n): + out[r][c] = add(mul(a_coef, id_n[r][c]), mul(b_coef, sh[r][c])) + return out + +def build_operators_m4(): + """Constructs the canonical operators on C^16 for block m = 4.""" + I16 = ident(16) + C0 = c_letter(0) + C1 = c_letter(1) + C2 = c_letter(2) + C3 = c_letter(3) + + # Canonical 4-call target operator K = C_3 C_2 C_1 C_0 + K = mm(C3, mm(C2, mm(C1, C0))) + + # Verify exact unitarity: K K^dagger = I_16 + K_adj = adjoint(K) + assert mm(K, K_adj) == I16, "K must be exact unitary on C^16" + + # Contractive couplers G_k with G_k^dagger G_k = (1/4) I_16 (||G_k|| = 1/2) + half = q(Fraction(1, 2)) + G1 = scale_m(half, shift_mat(1, 16)) + G2 = scale_m(half, shift_mat(2, 16)) + G3 = scale_m(half, shift_mat(4, 16)) + + # E_k = K G_k + E1 = mm(K, G1) + E2 = mm(K, G2) + E3 = mm(K, G3) + + return { + "I16": I16, "C0": C0, "C1": C1, "C2": C2, "C3": C3, "K": K, + "G1": G1, "G2": G2, "G3": G3, "E1": E1, "E2": E2, "E3": E3 + } + + +# ============================================================================== +# SECTION 3: Exact Gaussian Elimination Solver over Q(i) +# ============================================================================== + +def solve_linear_system(A: List[List[Tuple[Fraction, Fraction]]], b: List[Tuple[Fraction, Fraction]]): + """Solves A x = b over Q(i) via exact Gaussian elimination with partial pivoting.""" + n = len(A) + aug = [list(A[r]) + [b[r]] for r in range(n)] + + for col in range(n): + piv = -1 + for row in range(col, n): + if aug[row][col] != ZERO: + piv = row + break + if piv == -1: + raise ValueError(f"Matrix is singular at column {col}") + + if piv != col: + aug[col], aug[piv] = aug[piv], aug[col] + + piv_val = aug[col][col] + for c in range(col, n + 1): + aug[col][c] = div(aug[col][c], piv_val) + + for r in range(n): + if r != col and aug[r][col] != ZERO: + factor = aug[r][col] + for c in range(col, n + 1): + aug[r][c] = sub(aug[r][c], mul(factor, aug[col][c])) + + return [aug[r][n] for r in range(n)] + +def matrix_rank_q(mat: List[List[Tuple[Fraction, Fraction]]]) -> int: + """Computes exact column rank of a rectangular matrix over Q(i).""" + aug = [list(row) for row in mat] + n_rows = len(aug) + n_cols = len(aug[0]) + piv_cols = 0 + row = 0 + + for col in range(n_cols): + piv = -1 + for r in range(row, n_rows): + if aug[r][col] != ZERO: + piv = r + break + if piv == -1: + continue + if piv != row: + aug[row], aug[piv] = aug[piv], aug[row] + piv_val = aug[row][col] + for c in range(col, n_cols): + aug[row][c] = div(aug[row][c], piv_val) + for r in range(n_rows): + if r != row and aug[r][col] != ZERO: + factor = aug[r][col] + for c in range(col, n_cols): + aug[r][c] = sub(aug[r][c], mul(factor, aug[row][c])) + row += 1 + piv_cols += 1 + if row == n_rows: + break + + return piv_cols + + +# ============================================================================== +# SECTION 4: Cascade Synthesis & Verification +# ============================================================================== + +def run_3in10_synthesis(): + print("=" * 80) + print("3-ARRAY 10-CALL CASCADE SCHEDULE SYNTHESIS ON V = C^16 (m = 4)") + print("=" * 80) + + # 1. Theoretical Accounting & Capacity Match + m = 4 + W = 3 + s = 10 + n = 16 + demand_per_array = 86592 + cap_per_call = 27456 + + total_demand = W * demand_per_array # 3 * 86,592 = 259,776 + total_capacity = s * cap_per_call # 10 * 27,456 = 274,560 + surplus_ranks = total_capacity - total_demand # +14,784 + efficiency = (total_demand / total_capacity) * 100 + # Saving formula: kappa = ln(m*W / s) / ln(m) = 1 - ln(s/W) / ln(m) + saving_ceiling = math.log(m * W / s) / math.log(m) # = 1 - ln(10/3)/ln(4) = 0.131517 + assert abs(saving_ceiling - 0.131517) < 1e-4 + + print("1. Capacity & Deficit Ledger:") + print(f" - Target demand (3 arrays): 3 * {demand_per_array:,} = {total_demand:,} ranks") + print(f" - Total capacity (10 calls): 10 * {cap_per_call:,} = {total_capacity:,} ranks") + print(f" - Gross surplus capacity: +{surplus_ranks:,} ranks") + print(f" - Required efficiency: {efficiency:.2f}% (surplus provides headroom)") + print(f" - Saving exponent: kappa = {saving_ceiling:.5f} ({saving_ceiling*100:.2f}% > 10%!)") + print("-" * 80) + + # 2. Build Operators + ops = build_operators_m4() + K = ops["K"] + G1, G2, G3 = ops["G1"], ops["G2"], ops["G3"] + E1, E2, E3 = ops["E1"], ops["E2"], ops["E3"] + C0 = ops["C0"] + I16 = ops["I16"] + + # 3. Construct the 48x48 Cascade Matrix M_cascade + # M_cascade maps target vector Y = (K x1, K x2, K x3)^T to primary observations V = (v1, v2, v3)^T: + # [ I_16 G1 0 ] [ y1 ] [ v1 ] + # [ 0 I_16 G2 ] [ y2 ] = [ v2 ] + # [ G3 0 I_16 ] [ y3 ] [ v3 ] + M_cascade = [[ZERO for _ in range(48)] for _ in range(48)] + for r in range(16): + for c in range(16): + # Row block 0: I16, G1, 0 + M_cascade[r][c] = I16[r][c] + M_cascade[r][16 + c] = G1[r][c] + # Row block 1: 0, I16, G2 + M_cascade[16 + r][16 + c] = I16[r][c] + M_cascade[16 + r][32 + c] = G2[r][c] + # Row block 2: G3, 0, I16 + M_cascade[32 + r][c] = G3[r][c] + M_cascade[32 + r][32 + c] = I16[r][c] + + # Also construct triangular unrolling variant (G3 = 0, where Port 3 finishes x3 directly) + M_triangular = [[ZERO for _ in range(48)] for _ in range(48)] + for r in range(16): + for c in range(16): + M_triangular[r][c] = I16[r][c] + M_triangular[r][16 + c] = G1[r][c] + M_triangular[16 + r][16 + c] = I16[r][c] + M_triangular[16 + r][32 + c] = G2[r][c] + M_triangular[32 + r][32 + c] = I16[r][c] + + # 4. Construct Full Observation Matrix O (96x48) over Q(i) + # Primary rows (48x48): V = [K, E1, 0; 0, K, E2; E3, 0, K] * X + # Auxiliary rows (48x48): T = [C0, 0, 0; 0, C0, 0; 0, 0, C0] * X + O_primary = [[ZERO for _ in range(48)] for _ in range(48)] + O_full = [[ZERO for _ in range(48)] for _ in range(96)] + + for r in range(16): + for c in range(16): + # O_primary + O_primary[r][c] = K[r][c] + O_primary[r][16 + c] = E1[r][c] + O_primary[16 + r][16 + c] = K[r][c] + O_primary[16 + r][32 + c] = E2[r][c] + O_primary[32 + r][c] = E3[r][c] + O_primary[32 + r][32 + c] = K[r][c] + + # O_full: Top 48 rows = O_primary + O_full[r][c] = K[r][c] + O_full[r][16 + c] = E1[r][c] + O_full[16 + r][16 + c] = K[r][c] + O_full[16 + r][32 + c] = E2[r][c] + O_full[32 + r][c] = E3[r][c] + O_full[32 + r][32 + c] = K[r][c] + + # O_full: Bottom 48 rows = C0 on each array + O_full[48 + r][c] = C0[r][c] + O_full[64 + r][16 + c] = C0[r][c] + O_full[80 + r][32 + c] = C0[r][c] + + # 5. Rank and Invertibility Verifications over Q(i) + print("2. Observation Matrix Rank Analysis over Q(i):") + rank_M = matrix_rank_q(M_cascade) + rank_M_tri = matrix_rank_q(M_triangular) + rank_O_prim = matrix_rank_q(O_primary) + rank_O_full = matrix_rank_q(O_full) + + print(f" - Rank of M_cascade (48x48 cyclic coupler): {rank_M} / 48 (FULL RANK)") + print(f" - Rank of M_triangular (48x48 unrolled coupler): {rank_M_tri} / 48 (FULL RANK)") + print(f" - Rank of O_primary (48x48 primary observation): {rank_O_prim} / 48 (FULL RANK)") + print(f" - Rank of O_full (96x48 total observation): {rank_O_full} / 48 (FULL RANK)") + + assert rank_M == 48, "M_cascade must have full rank 48" + assert rank_M_tri == 48, "M_triangular must have full rank 48" + assert rank_O_prim == 48, "O_primary must have full rank 48" + assert rank_O_full == 48, "O_full must have full rank 48" + print("-" * 80) + + # 6. Condition Number & Spectral Bounds + # Coupler norms: ||G1|| = ||G2|| = ||G3|| = 1/2. + # 3-cycle loop gain: ||G3 G1 G2|| <= (1/2)^3 = 1/8 = 0.125 << 1. + loop_gain = 0.125 + cond_bound_neumann = (1.0 + loop_gain) / (1.0 - loop_gain) # 9/7 approx 1.2857 + print("3. Contraction & Condition Number Bounds:") + print(f" - Intermediate coupler norms: ||G_1|| = ||G_2|| = ||G_3|| = 1/2") + print(f" - 3-cycle loop gain: ||G_3 G_1 G_2|| <= (1/2)^3 = {loop_gain} << 1") + print(f" - Theoretical condition bound (Neumann): kappa(M_cascade) <= {cond_bound_neumann:.4f} <= 16") + print(" - Invertibility is guaranteed for all inputs without singularity.") + print("-" * 80) + + # 7. Exact Target Recovery Simulation + print("4. Exact Simulation & Target Recovery Tests:") + random.seed(4628) + + test_cases = [] + + # Test Suite A: All 48 Canonical Basis Vectors + print(" - Testing all 48 canonical basis vectors e_1, ..., e_48...") + for idx in range(48): + v = [ZERO] * 48 + v[idx] = ONE + test_cases.append((f"Canonical basis e_{idx}", v[:16], v[16:32], v[32:])) + + # Test Suite B: Random Gaussian Rational Inputs + print(" - Testing random Gaussian rational inputs over Q(i)...") + for test_idx in range(10): + x1 = [q(random.randint(-20, 20), random.randint(-20, 20)) for _ in range(16)] + x2 = [q(random.randint(-20, 20), random.randint(-20, 20)) for _ in range(16)] + x3 = [q(random.randint(-20, 20), random.randint(-20, 20)) for _ in range(16)] + test_cases.append((f"Random Gaussian Q(i) #{test_idx+1}", x1, x2, x3)) + + # Run Simulation on All Test Cases + total_reconstructed = 0 + max_error = 0 + + for name, x1, x2, x3 in test_cases: + X = x1 + x2 + x3 + + # Ground truth canonical targets + y1_true = mv(K, x1) + y2_true = mv(K, x2) + y3_true = mv(K, x3) + Y_true = y1_true + y2_true + y3_true + + # Schedule execution: Compute primary observations V = (v1, v2, v3) + # Port 1: v1 = K x1 + E1 x2 + v1 = [add(k_val, e_val) for k_val, e_val in zip(y1_true, mv(E1, x2))] + # Port 2: v2 = K x2 + E2 x3 + v2 = [add(k_val, e_val) for k_val, e_val in zip(y2_true, mv(E2, x3))] + # Port 3: v3 = K x3 + E3 x1 + v3 = [add(k_val, e_val) for k_val, e_val in zip(y3_true, mv(E3, x1))] + V = v1 + v2 + v3 + + # Target Recovery: Solve M_cascade * Y_rec = V + Y_rec = solve_linear_system(M_cascade, V) + + # Verify exact equality in Q(i) + errors = sum(1 for yr, yt in zip(Y_rec, Y_true) if yr != yt) + assert errors == 0, f"Reconstruction failed on {name} with {errors} errors" + total_reconstructed += 1 + + print(f" --> Successfully verified {total_reconstructed} test cases with ZERO reconstruction error!") + print("=" * 80) + print("ALL 3-ARRAY 10-CALL CASCADE VERIFICATIONS PASSED (kappa = 13.15% certified).") + print("=" * 80) + + return { + "status": "PASS_3IN10_CASCADE_SCHEDULE", + "block_m": m, + "W_arrays": W, + "s_calls": s, + "saving_kappa": saving_ceiling, + "saving_pct": f"{saving_ceiling * 100:.2f}%", + "target_demand": total_demand, + "call_capacity": total_capacity, + "gross_surplus": surplus_ranks, + "required_efficiency": f"{efficiency:.2f}%", + "loop_gain": loop_gain, + "condition_bound": cond_bound_neumann, + "rank_M_cascade": rank_M, + "rank_O_primary": rank_O_prim, + "rank_O_full": rank_O_full, + "total_test_cases_verified": total_reconstructed, + "exact_zero_error": True, + } + + +def main(): + import io, contextlib, json + f = io.StringIO() + with contextlib.redirect_stdout(f): + res = run_3in10_synthesis() + result = { + "W_arrays": res["W_arrays"], + "block_m": res["block_m"], + "call_capacity": res["call_capacity"], + "condition_bound": res["condition_bound"], + "exact_zero_error": res["exact_zero_error"], + "gross_surplus": res["gross_surplus"], + "loop_gain": res["loop_gain"], + "new_kappa": True, + "rank_M_cascade": res["rank_M_cascade"], + "rank_O_full": res["rank_O_full"], + "rank_O_primary": res["rank_O_primary"], + "required_efficiency": res["required_efficiency"], + "s_calls": res["s_calls"], + "saving_kappa": res["saving_kappa"], + "saving_pct": res["saving_pct"], + "status": res["status"], + "target_demand": res["target_demand"], + "total_test_cases_verified": res["total_test_cases_verified"] + } + print(json.dumps(result, sort_keys=True)) + + +if __name__ == "__main__": + main() diff --git a/research/native-cyclic-recovery/cascade_sources/pr4819-LICENSE b/research/native-cyclic-recovery/cascade_sources/pr4819-LICENSE new file mode 100644 index 0000000000..261eeb9e9f --- /dev/null +++ b/research/native-cyclic-recovery/cascade_sources/pr4819-LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/research/native-cyclic-recovery/cascade_sources/pr4819-NOTICE.md b/research/native-cyclic-recovery/cascade_sources/pr4819-NOTICE.md new file mode 100644 index 0000000000..c97213cef7 --- /dev/null +++ b/research/native-cyclic-recovery/cascade_sources/pr4819-NOTICE.md @@ -0,0 +1,9 @@ +# Attribution + +Prepared for Dugongue with substantial OpenAI Codex assistance from four workers. Apache-2.0. Independent agent review is AI review, not human peer review or a Lean kernel certificate. + +Yiyang (@Lyy-iiis), PR #4710 at b0d5192390af493d626054b060921895df3c94d2, supplies the phase repair, actual Gaussian-rational residual engine and separately tensorized residual identities. Its engine and README are retained byte for byte. The exact predecessor notice is PREDECESSOR-NOTICE.md. + +lee-phys, PR #4688 at 264c4b3cb13c82d171de352ecf60486dfb8d2bd4, supplies the original two-image prefix and rank engine. Its README is retained unchanged for credit; its rank engine is not needed or rerun here. Jacob Alan Sussman, PR #4628 at ee4fd87f064017c23e5a86fc1dcfe0a5237caed3, supplies the complex small-block engine problem and hook lower-bound framework. All retained predecessor notices and assistance disclosures remain in force. + +The new scope is an arbitrary-second-input port and explicit reverse schedule, a phase-correct swap-sector continuation, the accompanying native address/precision contract, and an exact finite geometry search coordinate system. The underlying prefix and residual identity are predecessor results. No worldwide novelty or new multiplication exponent is claimed. diff --git a/research/native-cyclic-recovery/cascade_sources/pr4819-verify_schedule.py b/research/native-cyclic-recovery/cascade_sources/pr4819-verify_schedule.py new file mode 100644 index 0000000000..e22dd9afd8 --- /dev/null +++ b/research/native-cyclic-recovery/cascade_sources/pr4819-verify_schedule.py @@ -0,0 +1,454 @@ +#!/usr/bin/env python3 +"""Exact Synthesis & Verification of the 13-Array 41-Call Boundary Schedule on V = C^16. + +Proves the viability of the theoretical maximum boundary schedule for Block m = 4: + - W = 13 arrays in s = 41 calls at block size m = 4 (state space: (C^16)^13 = 208 dimensions). + - Target operator: K = C_3 C_2 C_1 C_0 on C^16. + - Zero-slack capacity match: + Demand: 13 * 86,592 = 1,125,696 ranks + Capacity: 41 * 27,456 = 1,125,696 ranks + Net surplus / slack: 0 ranks (100.000% capacity efficiency) + - Asymptotic integer multiplication exponent ceiling: + kappa = 1 - ln(41/13) / ln(4) = 0.1714417... (17.14% > 10% milestone) + - Unique port call partition: + n_4 = 2 (4-call ports), n_3 = 11 (3-call ports) + 2 * 4 + 11 * 3 = 41 calls across 13 ports + - 13-cycle loop contraction: + ||L_13|| = ||G_12 ... G_0|| <= (1/2)^13 = 1/8,192 approx 0.00012207 + - Cascade condition number: + kappa(M_cascade) <= (1 + 1/8192) / (1 - 1/8192) = 8193 / 8191 approx 1.000244 << 16 + +Standard library only (fractions.Fraction, math, random, time). Exact Q(i) arithmetic. +""" + +from __future__ import annotations +import math +import random +import time +from fractions import Fraction +from typing import Dict, List, Tuple, Any + + +# ============================================================================== +# SECTION 1: Exact Gaussian Rational Arithmetic over Q(i) +# ============================================================================== + +def q(real=0, imag=0) -> Tuple[Fraction, Fraction]: + return (Fraction(real), Fraction(imag)) + +ZERO, ONE, I = q(), q(1), q(0, 1) + +def add(x: Tuple[Fraction, Fraction], y: Tuple[Fraction, Fraction]) -> Tuple[Fraction, Fraction]: + return (x[0] + y[0], x[1] + y[1]) + +def sub(x: Tuple[Fraction, Fraction], y: Tuple[Fraction, Fraction]) -> Tuple[Fraction, Fraction]: + return (x[0] - y[0], x[1] - y[1]) + +def mul(x: Tuple[Fraction, Fraction], y: Tuple[Fraction, Fraction]) -> Tuple[Fraction, Fraction]: + return (x[0] * y[0] - x[1] * y[1], x[0] * y[1] + x[1] * y[0]) + +def conj(x: Tuple[Fraction, Fraction]) -> Tuple[Fraction, Fraction]: + return (x[0], -x[1]) + +def div(x: Tuple[Fraction, Fraction], y: Tuple[Fraction, Fraction]) -> Tuple[Fraction, Fraction]: + denom = y[0] ** 2 + y[1] ** 2 + if denom == 0: + raise ZeroDivisionError("division by zero in Q(i)") + return ((x[0] * y[0] + x[1] * y[1]) / denom, (x[1] * y[0] - x[0] * y[1]) / denom) + +def scale_m(c: Tuple[Fraction, Fraction], mat: List[List[Tuple[Fraction, Fraction]]]): + return [[mul(c, val) for val in row] for row in mat] + +def mm(a: List[List[Tuple[Fraction, Fraction]]], b: List[List[Tuple[Fraction, Fraction]]]): + n = len(a) + p = len(b[0]) + k_dim = len(b) + out = [[ZERO for _ in range(p)] for _ in range(n)] + for r in range(n): + for k in range(k_dim): + if a[r][k] == ZERO: + continue + for c in range(p): + if b[k][c] != ZERO: + out[r][c] = add(out[r][c], mul(a[r][k], b[k][c])) + return out + +def mv(mat: List[List[Tuple[Fraction, Fraction]]], vec: List[Tuple[Fraction, Fraction]]): + n = len(mat) + k_dim = len(vec) + out = [ZERO for _ in range(n)] + for r in range(n): + s = ZERO + for c in range(k_dim): + if mat[r][c] != ZERO and vec[c] != ZERO: + s = add(s, mul(mat[r][c], vec[c])) + out[r] = s + return out + +def ident(n=16): + return [[ONE if r == c else ZERO for c in range(n)] for r in range(n)] + +def adjoint(a: List[List[Tuple[Fraction, Fraction]]]): + return [[conj(a[c][r]) for c in range(len(a))] for r in range(len(a[0]))] + +def invert_mat_16(A: List[List[Tuple[Fraction, Fraction]]]) -> List[List[Tuple[Fraction, Fraction]]]: + """Inverts a 16x16 matrix over Q(i) using exact Gaussian elimination.""" + n = len(A) + aug = [list(A[r]) + [ONE if r == c else ZERO for c in range(n)] for r in range(n)] + for col in range(n): + piv = -1 + for row in range(col, n): + if aug[row][col] != ZERO: + piv = row + break + if piv == -1: + raise ValueError(f"Matrix is singular at column {col}") + if piv != col: + aug[col], aug[piv] = aug[piv], aug[col] + piv_val = aug[col][col] + for c in range(col, 2 * n): + aug[col][c] = div(aug[col][c], piv_val) + for r in range(n): + if r != col and aug[r][col] != ZERO: + factor = aug[r][col] + for c in range(col, 2 * n): + aug[r][c] = sub(aug[r][c], mul(factor, aug[col][c])) + return [[aug[r][n + c] for c in range(n)] for r in range(n)] + + +# ============================================================================== +# SECTION 2: Block m = 4 Operators on V = C^16 +# ============================================================================== + +def shift_mat(v: int, n=16): + out = [[ZERO for _ in range(n)] for _ in range(n)] + for x in range(n): + out[x ^ v][x] = ONE + return out + +def c_letter(bit: int, n=16): + """C_v = a I + b X_v with a = (1+i)/2, b = (1-i)/2.""" + sh = shift_mat(1 << bit, n) + a_coef = q(Fraction(1, 2), Fraction(1, 2)) + b_coef = q(Fraction(1, 2), Fraction(-1, 2)) + id_n = ident(n) + out = [[ZERO for _ in range(n)] for _ in range(n)] + for r in range(n): + for c in range(n): + out[r][c] = add(mul(a_coef, id_n[r][c]), mul(b_coef, sh[r][c])) + return out + +def build_operators_m4(): + """Constructs the canonical operators on C^16 for block m = 4 and 13 couplers.""" + I16 = ident(16) + C0 = c_letter(0) + C1 = c_letter(1) + C2 = c_letter(2) + C3 = c_letter(3) + + # Canonical 4-call target operator K = C_3 C_2 C_1 C_0 + K = mm(C3, mm(C2, mm(C1, C0))) + + # Verify exact unitarity: K K^dagger = I_16 + K_adj = adjoint(K) + assert mm(K, K_adj) == I16, "K must be exact unitary on C^16" + + # 13 Contractive couplers G_k with G_k^dagger G_k = (1/4) I_16 (||G_k|| = 1/2) + half = q(Fraction(1, 2)) + couplers = [scale_m(half, shift_mat((k % 15) + 1, 16)) for k in range(13)] + + # Verify exact contractivity ||G_k|| = 1/2 + quarter_I = scale_m(q(Fraction(1, 4)), I16) + for k, Gk in enumerate(couplers): + Gk_adj = adjoint(Gk) + assert mm(Gk_adj, Gk) == quarter_I, f"Coupler G_{k} must satisfy G^dagger G = (1/4) I_16" + + # E_k = K G_k + E_ops = [mm(K, Gk) for Gk in couplers] + + return { + "I16": I16, "C0": C0, "C1": C1, "C2": C2, "C3": C3, "K": K, + "couplers": couplers, "E_ops": E_ops + } + + +# ============================================================================== +# SECTION 3: Fast Block Back-Substitution Engine for the 208x208 System +# ============================================================================== + +class Cascade13in41Engine: + """Exact solver for the 208-dimensional block cyclic cascade system M_cascade Y = V. + + System structure (13 blocks of 16x16): + y_0 + G_0 y_1 = v_0 + y_1 + G_1 y_2 = v_1 + ... + y_11 + G_11 y_12 = v_11 + y_12 + G_12 y_0 = v_12 + + Complexity: O(16^3) precomputation for inverting P_13 = I_16 + L_13, + then O(13 * 16^2) per vector solve. + """ + + def __init__(self, couplers: List[List[List[Tuple[Fraction, Fraction]]]]): + self.W = 13 + self.n = 16 + self.couplers = couplers + self.I16 = ident(16) + + # Prefix products: Pi[j] = G_0 * G_1 * ... * G_{j-1} + self.Pi = [self.I16] + for k in range(12): + self.Pi.append(mm(self.Pi[-1], self.couplers[k])) + + # 13-cycle loop operator: L_13 = G_12 * Pi[12] = G_12 * G_0 * ... * G_11 + self.L13 = mm(self.couplers[12], self.Pi[12]) + + # Loop matrix P_13 = I_16 + L_13 + self.P13 = [[add(self.I16[r][c], self.L13[r][c]) for c in range(16)] for r in range(16)] + + # Precompute exact inverse P_13^{-1} + self.P13_inv = invert_mat_16(self.P13) + + # Verify exact inversion + prod = mm(self.P13, self.P13_inv) + assert prod == self.I16, "P_13_inv * P_13 must equal I_16" + + def solve(self, V_blocks: List[List[Tuple[Fraction, Fraction]]]) -> List[List[Tuple[Fraction, Fraction]]]: + """Solves M_cascade Y = V for Y given V (each consisting of 13 blocks of length 16).""" + assert len(V_blocks) == 13 + + # Compute alternating cumulative term: sum_{j=0}^{11} (-1)^j Pi[j] v_j + term = [ZERO for _ in range(16)] + for j in range(12): + pv = mv(self.Pi[j], V_blocks[j]) + sign = 1 if j % 2 == 0 else -1 + for i in range(16): + if sign == 1: + term[i] = add(term[i], pv[i]) + else: + term[i] = sub(term[i], pv[i]) + + # RHS for y_12: v_12 - G_12 * term + G12_term = mv(self.couplers[12], term) + rhs12 = [sub(V_blocks[12][i], G12_term[i]) for i in range(16)] + + # Solve y_12 = P_13^{-1} * rhs12 + y12 = mv(self.P13_inv, rhs12) + + # Back-substitution: y_k = v_k - G_k y_{k+1} for k = 11 down to 0 + Y_rec = [None] * 13 + Y_rec[12] = y12 + for k in range(11, -1, -1): + Gky = mv(self.couplers[k], Y_rec[k + 1]) + Y_rec[k] = [sub(V_blocks[k][i], Gky[i]) for i in range(16)] + + return Y_rec + + def forward_multiply(self, Y_blocks: List[List[Tuple[Fraction, Fraction]]]) -> List[List[Tuple[Fraction, Fraction]]]: + """Applies M_cascade to Y to produce V.""" + V = [None] * 13 + for k in range(12): + Gky = mv(self.couplers[k], Y_blocks[k + 1]) + V[k] = [add(Y_blocks[k][i], Gky[i]) for i in range(16)] + G12y0 = mv(self.couplers[12], Y_blocks[0]) + V[12] = [add(Y_blocks[12][i], G12y0[i]) for i in range(16)] + return V + + +# ============================================================================== +# SECTION 4: Comprehensive Verification & Test Suite +# ============================================================================== + +def run_13in41_verification() -> Dict[str, Any]: + print("=" * 80) + print("13-ARRAY 41-CALL CASCADE SCHEDULE SYNTHESIS ON V = C^16 (m = 4)") + print("Theoretical Maximum Boundary Schedule (100.000% Efficiency)") + print("=" * 80) + + # 1. Theoretical Accounting & Capacity Match + m = 4 + W = 13 + s = 41 + n = 16 + demand_per_array = 86592 + cap_per_call = 27456 + + total_demand = W * demand_per_array # 13 * 86,592 = 1,125,696 + total_capacity = s * cap_per_call # 41 * 27,456 = 1,125,696 + surplus_ranks = total_capacity - total_demand # 0 + efficiency = (total_demand / total_capacity) * 100 + + saving_ceiling = 1.0 - math.log(s / W) / math.log(m) # 1 - ln(41/13)/ln(4) = 0.1714417 + assert abs(saving_ceiling - 0.1714417) < 1e-4 + + print("1. Capacity & Deficit Ledger:") + print(f" - Target demand (13 arrays): 13 * {demand_per_array:,} = {total_demand:,} ranks") + print(f" - Total capacity (41 calls): 41 * {cap_per_call:,} = {total_capacity:,} ranks") + print(f" - Net surplus capacity: {surplus_ranks:,} ranks (EXACT ZERO SLACK)") + print(f" - Capacity efficiency: {efficiency:.5f}% (Theoretical Boundary Optimum)") + print(f" - Saving exponent: kappa = {saving_ceiling:.5f} ({saving_ceiling*100:.2f}% > 10%!)") + print("-" * 80) + + # 2. Integer Port Decomposition + # Primitive 3-call and 4-call ports: + # 3 * n_3 + 4 * n_4 = 41 and n_3 + n_4 = 13 + n_4 = s - 3 * W # 41 - 39 = 2 + n_3 = W - n_4 # 13 - 2 = 11 + assert n_4 == 2 and n_3 == 11 + assert 4 * n_4 + 3 * n_3 == 41 + + print("2. Primitive Port Partition Analysis:") + print(f" - 4-call primitive ports: n_4 = {n_4} (calls = {n_4 * 4})") + print(f" - 3-call primitive ports: n_3 = {n_3} (calls = {n_3 * 3})") + print(f" - Total paid calls: {n_4 * 4} + {n_3 * 3} = {s} calls across {W} ports") + print("-" * 80) + + # 3. Spectral Bounds & 13-Cycle Contraction + loop_gain = (1.0 / 2.0) ** 13 # (1/2)^13 = 1/8192 approx 0.00012207 + loop_gain_exact = Fraction(1, 8192) + cond_bound = (1.0 + float(loop_gain_exact)) / (1.0 - float(loop_gain_exact)) # 8193/8191 approx 1.000244 + + print("3. Spectral Bounds & 13-Cycle Contraction:") + print(f" - Intermediate coupler norms: ||G_k|| = 1/2 for all k = 0..12") + print(f" - 13-cycle loop gain: ||L_13|| <= (1/2)^13 = {loop_gain_exact} approx {loop_gain:.8f}") + print(f" - Cascade condition number: kappa(M_cascade) <= {cond_bound:.6f} <= 16 (Essentially Identity!)") + print("-" * 80) + + # 4. Construct Operators and Engine + t_ops0 = time.time() + ops = build_operators_m4() + K = ops["K"] + couplers = ops["couplers"] + E_ops = ops["E_ops"] + engine = Cascade13in41Engine(couplers) + t_ops = time.time() - t_ops0 + print(f"4. Cascade Engine Initialization: {t_ops:.4f}s") + print(f" - Inverted P_13 (16x16) over Q(i) with exact zero residual.") + print("-" * 80) + + # 5. Test Suite A: All 208 Canonical Basis Vectors + print("5. Test Suite A: Reconstructing all 208 Canonical Basis Vectors over Q(i)...") + t_basis0 = time.time() + basis_verified = 0 + + for idx in range(208): + blk = idx // 16 + offset = idx % 16 + V = [[ZERO] * 16 for _ in range(13)] + V[blk][offset] = ONE + + # Solve M_cascade * Y = V + Y = engine.solve(V) + + # Forward verification: M_cascade * Y == V + V_check = engine.forward_multiply(Y) + for b in range(13): + assert V_check[b] == V[b], f"Basis verification failed at basis {idx}, block {b}" + basis_verified += 1 + + t_basis = time.time() - t_basis0 + print(f" --> Successfully verified all {basis_verified}/208 canonical basis vectors in {t_basis:.3f}s!") + print(f" --> Exact Full Rank Certified: rank(M_cascade) = 208 / 208 over Q(i).") + print("-" * 80) + + # 6. Test Suite B: Random Gaussian Rational Array Targets + print("6. Test Suite B: Target Operator Recovery with Random Inputs over Q(i)...") + random.seed(4113) + random_tests_verified = 0 + t_rand0 = time.time() + + for test_idx in range(25): + # Generate random input arrays X_0, ..., X_12 in Q(i)^16 + X_arrays = [ + [q(random.randint(-15, 15), random.randint(-15, 15)) for _ in range(16)] + for _ in range(13) + ] + + # Target outputs: Y_true[k] = K X_k + Y_true = [mv(K, X_arrays[k]) for k in range(13)] + + # Schedule execution: Compute primary observations V_k + # v_k = K X_k + E_k X_{k+1} for k = 0..11 + # v_12 = K X_12 + E_12 X_0 + V_obs = [] + for k in range(12): + Ek_next = mv(E_ops[k], X_arrays[k + 1]) + V_obs.append([add(Y_true[k][i], Ek_next[i]) for i in range(16)]) + E12_X0 = mv(E_ops[12], X_arrays[0]) + V_obs.append([add(Y_true[12][i], E12_X0[i]) for i in range(16)]) + + # Solve for recovered targets Y_rec via engine + Y_rec = engine.solve(V_obs) + + # Assert exact equality: Y_rec == Y_true + for k in range(13): + for i in range(16): + assert Y_rec[k][i] == Y_true[k][i], ( + f"Mismatch on random test {test_idx}, array {k}, dim {i}: " + f"rec={Y_rec[k][i]} != true={Y_true[k][i]}" + ) + random_tests_verified += 1 + + t_rand = time.time() - t_rand0 + print(f" --> Successfully verified {random_tests_verified} random Gaussian rational test cases in {t_rand:.3f}s!") + print(f" --> Exact zero error on all recovered target vectors.") + print("=" * 80) + print("ALL 13-ARRAY 41-CALL SCHEDULE VERIFICATIONS PASSED (kappa = 17.14% certified).") + print("=" * 80) + + return { + "status": "PASS_13IN41_BOUNDARY_SCHEDULE", + "block_m": m, + "W_arrays": W, + "s_calls": s, + "state_dimension": W * n, + "saving_kappa": saving_ceiling, + "saving_pct": f"{saving_ceiling * 100:.2f}%", + "target_demand": total_demand, + "call_capacity": total_capacity, + "net_surplus_slack": surplus_ranks, + "capacity_efficiency": f"{efficiency:.5f}%", + "port_partition_n4": n_4, + "port_partition_n3": n_3, + "contraction_loop_gain": f"1/8192 approx {loop_gain:.8f}", + "cascade_condition_bound": cond_bound, + "rank_M_cascade": 208, + "canonical_basis_vectors_verified": basis_verified, + "random_test_cases_verified": random_tests_verified, + "exact_zero_error": True, + } + + +def main(): + import io, contextlib, json + f = io.StringIO() + with contextlib.redirect_stdout(f): + res = run_13in41_verification() + result = { + "W_arrays": res["W_arrays"], + "block_m": res["block_m"], + "call_capacity": res["call_capacity"], + "canonical_basis_vectors_verified": res["canonical_basis_vectors_verified"], + "capacity_efficiency": res["capacity_efficiency"], + "cascade_condition_bound": res["cascade_condition_bound"], + "contraction_loop_gain": res["contraction_loop_gain"], + "exact_zero_error": res["exact_zero_error"], + "net_surplus_slack": res["net_surplus_slack"], + "new_kappa": True, + "port_partition_n3": res["port_partition_n3"], + "port_partition_n4": res["port_partition_n4"], + "random_test_cases_verified": res["random_test_cases_verified"], + "rank_M_cascade": res["rank_M_cascade"], + "s_calls": res["s_calls"], + "saving_kappa": res["saving_kappa"], + "saving_pct": res["saving_pct"], + "state_dimension": res["state_dimension"], + "status": res["status"], + "target_demand": res["target_demand"] + } + print(json.dumps(result, sort_keys=True)) + + +if __name__ == "__main__": + main() diff --git a/research/native-cyclic-recovery/cascade_sources/pr4826-LICENSE b/research/native-cyclic-recovery/cascade_sources/pr4826-LICENSE new file mode 100644 index 0000000000..261eeb9e9f --- /dev/null +++ b/research/native-cyclic-recovery/cascade_sources/pr4826-LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/research/native-cyclic-recovery/cascade_sources/pr4826-NOTICE.md b/research/native-cyclic-recovery/cascade_sources/pr4826-NOTICE.md new file mode 100644 index 0000000000..560d244e50 --- /dev/null +++ b/research/native-cyclic-recovery/cascade_sources/pr4826-NOTICE.md @@ -0,0 +1,11 @@ +# Attribution + +Prepared by Antigravity Research Team with substantial OpenAI Codex and Claude assistance. Apache-2.0. Independent agent review is AI review, not human peer review or a Lean kernel certificate. + +Jacob Alan Sussman, PR #4628 at ee4fd87f064017c23e5a86fc1dcfe0a5237caed3, supplies the complex small-block engine problem, the kept-subspace lower bound theorem, and explicitly left open the '3 in 9 at m=5' shape. + +Yiyang (@Lyy-iiis), PR #4710 at b0d5192390af493d626054b060921895df3c94d2, supplies the phase repair and Gaussian-rational residual identities. + +lee-phys, PR #4688 at 264c4b3cb13c82d171de352ecf60486dfb8d2bd4, supplies the two-image prefix lineage. All retained predecessor notices and assistance disclosures remain in force. + +The new scope is the algebraic construction and verification of the 3-array 9-call unit schedule on Block m=5 (V = C^32), achieving saving exponent kappa = 1 - ln(3)/ln(5) = 31.74%, reaching the exact integer lower bound of 9 calls for 3 arrays. diff --git a/research/native-cyclic-recovery/cascade_sources/pr4826-verify_schedule.py b/research/native-cyclic-recovery/cascade_sources/pr4826-verify_schedule.py new file mode 100644 index 0000000000..ea1511ae49 --- /dev/null +++ b/research/native-cyclic-recovery/cascade_sources/pr4826-verify_schedule.py @@ -0,0 +1,319 @@ +#!/usr/bin/env python3 +"""Exact Synthesis & Algebraic Verification of the 3-Array 9-Call Schedule on Block m=5 (V = C^32). + +Breaking into the Block m=5 frontier to achieve saving exponent: + kappa = 1 - ln(9/3) / ln(5) = 1 - ln(3) / ln(5) ≈ 0.31739... (31.74%!). + +Theoretical Framework: + 1. Jacob Alan Sussman's lower bound theorem (PR #4628): + - At m=5, s >= 2.99172 W. + - For W=3 arrays, minimum required calls: ceil(3 * 2.99172) = ceil(8.975) = 9 calls! + - '3 in 9 at m=5' is explicitly identified in PR #4628 as open and mathematically allowed. + - Naive classical calls: 3 arrays * 5 calls/array = 15 calls. + - Saving: 15 - 9 = 6 calls (40.0% reduction in paid calls). + 2. Block-5 Primitives on V = C^32: + - Canonical rank-5 target K = C_4 C_3 C_2 C_1 C_0 on C^32 (dim = 32). + - Coordinate swap involution T = SWAP(0, 4) satisfying T C_0 T = C_4. + - Conjugated phase operators P = S U S, Q = S V_01 S = Z_all V_01. + - Ratio R = P^-1 Q has exact order 4: R^4 = I_32, with uniform inverse (I+2R)(I-2R+4R^2-8R^3) = -15 I_32. + - Exact residual identity: J F = M C_4 C_3 C_2 + 2 K, where J = C_4 C_3 C_2 N uses 3 paid calls, + and N and M are exact free monomial matrices. + 3. 3-Array 9-Call Symmetric Partition: + - 3 independent registers (x1, x2, x3) on C^32 (total state dimension 3 * 32 = 96). + - Symmetric budget of 3 calls per port (3 + 3 + 3 = 9 calls): + * Port 1 (3 calls on x1, x2): v1 = K x1 + E1 x2, t1 = C0 x1 + * Port 2 (3 calls on x2, x3): v2 = K x2 + E2 x3, t2 = C0 x2 + * Port 3 (3 calls on x3, x1): v3 = K x3 + E3 x1, t3 = C0 x3 + 4. Contractive Couplers & Strictly Bounded Condition Number: + - Intermediate couplers G_k = K^-1 E_k = (1/2) X_k satisfy G_k^dagger G_k = (1/4) I_32 (||G_k|| = 1/2). + - 3-cycle loop operator L_3 = G1 G2 G3 = (1/8) X_012 satisfies L_3^dagger L_3 = (1/64) I_32. + - Loop gain: ||L_3|| = (1/2)^3 = 1/8 = 0.125 << 1. + - Condition number bound: kappa <= (1 + 1/8) / (1 - 1/8) = 9/7 ≈ 1.2857 <= 16. + 5. Exact Algebraic Invertibility: + - M_cascade (96x96 cyclic matrix) has exact rank 96 / 96 over Q(i). + - O_primary (96x96 primary observation) has exact rank 96 / 96 over Q(i). + - O_full (192x96 total observation) has exact rank 96 / 96 over Q(i). + - Target reconstruction error = 0 across canonical basis, random inputs, and swap sectors. + +Standard library only (fractions.Fraction, math, random, json, time). Exact Q(i) arithmetic. +""" + +from __future__ import annotations +import json +import math +import random +import time +from fractions import Fraction +from typing import Dict, List, Tuple + + +def q(real=0, imag=0) -> Tuple[Fraction, Fraction]: + return (Fraction(real), Fraction(imag)) + +ZERO, ONE, I = q(), q(1), q(0, 1) + +def add(x, y): return (x[0] + y[0], x[1] + y[1]) +def sub(x, y): return (x[0] - y[0], x[1] - y[1]) +def mul(x, y): return (x[0]*y[0] - x[1]*y[1], x[0]*y[1] + x[1]*y[0]) +def conj(x): return (x[0], -x[1]) +def div(x, y): + d = y[0]**2 + y[1]**2 + return ((x[0]*y[0] + x[1]*y[1])/d, (x[1]*y[0] - x[0]*y[1])/d) + +def scale_m(c, mat): return [[mul(c, v) for v in row] for row in mat] +def plus_m(a, b): return [[add(a[r][c], b[r][c]) for c in range(len(a[0]))] for r in range(len(a))] +def minus_m(a, b): return [[sub(a[r][c], b[r][c]) for c in range(len(a[0]))] for r in range(len(a))] + +def mm(a, b): + n, p, k_dim = len(a), len(b[0]), len(b) + out = [[ZERO for _ in range(p)] for _ in range(n)] + for r in range(n): + for k in range(k_dim): + if a[r][k] == ZERO: continue + for c in range(p): + if b[k][c] != ZERO: + out[r][c] = add(out[r][c], mul(a[r][k], b[k][c])) + return out + +def mv(mat, vec): + n, k_dim = len(mat), len(vec) + out = [ZERO for _ in range(n)] + for r in range(n): + s = ZERO + for c in range(k_dim): + if mat[r][c] != ZERO and vec[c] != ZERO: + s = add(s, mul(mat[r][c], vec[c])) + out[r] = s + return out + +def ident(n=32): return [[ONE if r == c else ZERO for c in range(n)] for r in range(n)] + +def shift_mat(v: int, n=32): + out = [[ZERO for _ in range(n)] for _ in range(n)] + for x in range(n): out[x ^ v][x] = ONE + return out + +def c_letter(bit: int, n=32): + sh = shift_mat(1 << bit, n) + id_n = ident(n) + a_coef = q(Fraction(1, 2), Fraction(1, 2)) + b_coef = q(Fraction(1, 2), Fraction(-1, 2)) + out = [[ZERO for _ in range(n)] for _ in range(n)] + for r in range(n): + for c in range(n): + out[r][c] = add(mul(a_coef, id_n[r][c]), mul(b_coef, sh[r][c])) + return out + +def solve_linear_system_q(A: List[List[Tuple[Fraction, Fraction]]], b: List[Tuple[Fraction, Fraction]]): + n = len(A) + aug = [list(A[r]) + [b[r]] for r in range(n)] + for col in range(n): + piv = -1 + for row in range(col, n): + if aug[row][col] != ZERO: + piv = row + break + if piv == -1: raise ValueError(f"Singular system at column {col}") + if piv != col: aug[col], aug[piv] = aug[piv], aug[col] + piv_val = aug[col][col] + for c in range(col, n + 1): aug[col][c] = div(aug[col][c], piv_val) + for r in range(n): + if r != col and aug[r][col] != ZERO: + factor = aug[r][col] + for c in range(col, n + 1): + aug[r][c] = sub(aug[r][c], mul(factor, aug[col][c])) + return [aug[r][n] for r in range(n)] + +def matrix_rank_q(mat: List[List[Tuple[Fraction, Fraction]]]) -> int: + m, n = len(mat), len(mat[0]) + aug = [list(row) for row in mat] + rank = 0 + for col in range(n): + piv = -1 + for row in range(rank, m): + if aug[row][col] != ZERO: + piv = row + break + if piv == -1: continue + if piv != rank: aug[rank], aug[piv] = aug[piv], aug[rank] + piv_val = aug[rank][col] + for c in range(col, n): aug[rank][c] = div(aug[rank][c], piv_val) + for r in range(m): + if r != rank and aug[r][col] != ZERO: + factor = aug[r][col] + for c in range(col, n): + aug[r][c] = sub(aug[r][c], mul(factor, aug[rank][c])) + rank += 1 + if rank == m: break + return rank + + +def run_3in9_schedule_verification() -> Dict: + m = 5 + W = 3 + s = 9 + naive_calls = 15 + saved_calls = 6 + saving_kappa = 1.0 - math.log(3.0) / math.log(5.0) + + I32 = ident(32) + C0 = c_letter(0, 32) + C1 = c_letter(1, 32) + C2 = c_letter(2, 32) + C3 = c_letter(3, 32) + C4 = c_letter(4, 32) + + # Canonical Target: K = C4 C3 C2 C1 C0 + K = mm(C4, mm(C3, mm(C2, mm(C1, C0)))) + + # Intermediate Couplers on axes 0, 1, 2 + half = q(Fraction(1, 2)) + G1 = scale_m(half, shift_mat(1, 32)) + G2 = scale_m(half, shift_mat(2, 32)) + G3 = scale_m(half, shift_mat(4, 32)) + + E1 = mm(K, G1) + E2 = mm(K, G2) + E3 = mm(K, G3) + + # Construct M_cascade (96 x 96) + ZERO_32 = [[ZERO for _ in range(32)] for _ in range(32)] + M_cascade = [[ZERO for _ in range(96)] for _ in range(96)] + for r in range(32): + for c in range(32): + M_cascade[0 + r][0 + c] = I32[r][c] + M_cascade[0 + r][32 + c] = G1[r][c] + M_cascade[32 + r][32 + c] = I32[r][c] + M_cascade[32 + r][64 + c] = G2[r][c] + M_cascade[64 + r][0 + c] = G3[r][c] + M_cascade[64 + r][64 + c] = I32[r][c] + + # Construct O_primary (96 x 96) + O_primary = [[ZERO for _ in range(96)] for _ in range(96)] + for r in range(32): + for c in range(32): + O_primary[0 + r][0 + c] = K[r][c] + O_primary[0 + r][32 + c] = E1[r][c] + O_primary[32 + r][32 + c] = K[r][c] + O_primary[32 + r][64 + c] = E2[r][c] + O_primary[64 + r][0 + c] = E3[r][c] + O_primary[64 + r][64 + c] = K[r][c] + + # Construct O_full (192 x 96) + O_full = [[ZERO for _ in range(96)] for _ in range(192)] + for r in range(96): + for c in range(96): + O_full[r][c] = O_primary[r][c] + for r in range(32): + for c in range(32): + O_full[96 + r][0 + c] = C0[r][c] + O_full[128 + r][32 + c] = C0[r][c] + O_full[160 + r][64 + c] = C0[r][c] + + # 1. Exact Matrix Ranks over Q(i) + rank_M = matrix_rank_q(M_cascade) + rank_O_prim = matrix_rank_q(O_primary) + rank_O_full = matrix_rank_q(O_full) + + assert rank_M == 96, f"M_cascade rank mismatch: {rank_M} != 96" + assert rank_O_prim == 96, f"O_primary rank mismatch: {rank_O_prim} != 96" + assert rank_O_full == 96, f"O_full rank mismatch: {rank_O_full} != 96" + + # 2. Contraction & Condition Bounds + loop_gain = Fraction(1, 8) + cond_bound_neumann = float((1 + loop_gain) / (1 - loop_gain)) # 9/7 ≈ 1.2857 + + # 3. Target Recovery Tests + test_cases = [] + # Test canonical basis vectors + for idx in [0, 1, 2, 3, 4, 31, 32, 33, 64, 95]: + reg = idx // 32 + base = idx % 32 + x = [[ZERO for _ in range(32)] for _ in range(3)] + x[reg][base] = ONE + test_cases.append((f"basis_{idx}", x[0], x[1], x[2])) + + # Test random Gaussian rational inputs + random.seed(4628) + for t in range(6): + x1 = [q(random.randint(-5, 5), random.randint(-5, 5)) for _ in range(32)] + x2 = [q(random.randint(-5, 5), random.randint(-5, 5)) for _ in range(32)] + x3 = [q(random.randint(-5, 5), random.randint(-5, 5)) for _ in range(32)] + test_cases.append((f"random_{t}", x1, x2, x3)) + + # Test swap sectors + T = [[ZERO for _ in range(32)] for _ in range(32)] + for x in range(32): + b0 = x & 1 + b4 = (x >> 4) & 1 + y = (x & ~(1 | 16)) | (b4 | (b0 << 4)) + T[y][x] = ONE + + for sigma in [(1, 1, 1), (-1, 1, -1), (1, -1, -1), (-1, -1, 1)]: + x_base = [q(random.randint(-3, 3), random.randint(-3, 3)) for _ in range(32)] + Tx = mv(T, x_base) + x1 = [add(x_base[i], scale_m(q(sigma[0]), [Tx])[0][i]) for i in range(32)] + x2 = [add(x_base[i], scale_m(q(sigma[1]), [Tx])[0][i]) for i in range(32)] + x3 = [add(x_base[i], scale_m(q(sigma[2]), [Tx])[0][i]) for i in range(32)] + test_cases.append((f"swap_sector_{sigma}", x1, x2, x3)) + + total_verified = 0 + for name, x1, x2, x3 in test_cases: + y1_true = mv(K, x1) + y2_true = mv(K, x2) + y3_true = mv(K, x3) + Y_true = y1_true + y2_true + y3_true + + # Primary observations + v1 = [add(k_v, e_v) for k_v, e_v in zip(y1_true, mv(E1, x2))] + v2 = [add(k_v, e_v) for k_v, e_v in zip(y2_true, mv(E2, x3))] + v3 = [add(k_v, e_v) for k_v, e_v in zip(y3_true, mv(E3, x1))] + V = v1 + v2 + v3 + + # Direct linear solve over Q(i) + Y_rec = solve_linear_system_q(M_cascade, V) + for yr, yt in zip(Y_rec, Y_true): + assert yr == yt, f"M_cascade recovery error on {name}" + + # State recovery from primary observation + X_rec = solve_linear_system_q(O_primary, V) + X_true = x1 + x2 + x3 + for xr, xt in zip(X_rec, X_true): + assert xr == xt, f"O_primary recovery error on {name}" + + # Target verification from recovered state + for k in range(3): + x_rec_k = X_rec[k * 32 : (k + 1) * 32] + y_rec_k = mv(K, x_rec_k) + y_true_k = Y_true[k * 32 : (k + 1) * 32] + assert y_rec_k == y_true_k, f"Target mismatch on array {k+1} in {name}" + + total_verified += 1 + + return { + "status": "PASS_BLOCK5_3IN9_CASCADE_SCHEDULE", + "block_m": m, + "W_arrays": W, + "s_calls": s, + "naive_calls": naive_calls, + "saved_calls": saved_calls, + "saving_kappa": saving_kappa, + "saving_pct": f"{saving_kappa * 100:.2f}%", + "loop_gain": float(loop_gain), + "condition_bound": cond_bound_neumann, + "rank_M_cascade": rank_M, + "rank_O_primary": rank_O_prim, + "rank_O_full": rank_O_full, + "total_test_cases_verified": total_verified, + "exact_zero_error": True, + "new_kappa": True, + } + + +def main(): + res = run_3in9_schedule_verification() + print(json.dumps(res, sort_keys=True)) + + +if __name__ == "__main__": + main() diff --git a/research/native-cyclic-recovery/fixed_divisor.py b/research/native-cyclic-recovery/fixed_divisor.py new file mode 100644 index 0000000000..ea926050c7 --- /dev/null +++ b/research/native-cyclic-recovery/fixed_divisor.py @@ -0,0 +1,168 @@ +"""Fixed-divisor bit-plane scan using bounded-word Boolean/shift/add operations.""" +from dataclasses import dataclass + + +def need(ok, message): + if not ok: + raise ValueError(message) + + +@dataclass +class Machine: + width: int + operations: int = 0 + + def __post_init__(self): + need(type(self.width) is int and self.width >= 1, 'positive word width') + self.mask = (1 << self.width) - 1 + + def op(self, value): + self.operations += 1 + need(type(value) is int and 0 <= value <= self.mask, 'word overflow') + return value + + def band(self, a, b): return self.op(a & b) + def bor(self, a, b): return self.op(a | b) + def bxor(self, a, b): return self.op(a ^ b) + def bnot(self, a): return self.op(a ^ self.mask) + def shr(self, a, count): + need(0 <= count < self.width, 'invalid shift') + return self.op(a >> count) + def shl(self, a, count): + need(0 <= count < self.width, 'invalid shift') + return self.op((a << count) & self.mask) + def add(self, a, b): return self.op(a + b) + def sub(self, a, b): return self.op(a - b) + def ge(self, a, b): + self.operations += 1 + return a >= b + + +def compare_constant(m, planes, constant): + """A mask of lanes whose bit-plane value is at least constant.""" + greater, equal = 0, m.mask + for bit in range(len(planes) - 1, -1, -1): + value = planes[bit] + if (constant >> bit) & 1: + equal = m.band(equal, value) + else: + greater = m.bor(greater, m.band(equal, value)) + equal = m.band(equal, m.bnot(value)) + return m.bor(greater, equal) + + +def subtract_if(m, planes, constant, selected): + borrow, result = 0, [] + for bit, value in enumerate(planes): + part = selected if (constant >> bit) & 1 else 0 + result.append(m.bxor(m.bxor(value, part), borrow)) + borrow = m.bor(m.band(m.bnot(value), m.bor(part, borrow)), + m.band(part, borrow)) + need(borrow == 0, 'selected subtraction underflow') + return result + + +def modular_add(m, a, b, divisor): + carry, result = 0, [] + for left, right in zip(a, b): + temporary = m.bxor(left, right) + result.append(m.bxor(temporary, carry)) + carry = m.bor(m.band(left, right), m.band(temporary, carry)) + result.append(carry) + selected = compare_constant(m, result, divisor) + result = subtract_if(m, result, divisor, selected) + need(result[-1] == 0, 'modular result too large') + return result[:-1] + + +def modular_scale(m, planes, constant, divisor): + result = [0] * len(planes) + current = planes + for bit in range(divisor.bit_length()): + if (constant >> bit) & 1: + result = modular_add(m, result, current, divisor) + current = modular_add(m, current, current, divisor) + return result + + +def scalar_modular_sum(m, a, b, divisor): + gap = m.sub(divisor, b) + if m.ge(a, gap): return m.sub(a, gap) + return m.add(a, b) + + +def scalar_modular_product(m, a, b, divisor): + """At most bit_length(divisor) ordinary shift/add reduction steps.""" + result, current = 0, a + for bit in range(divisor.bit_length()): + if (b >> bit) & 1: + result = scalar_modular_sum(m, result, current, divisor) + current = scalar_modular_sum(m, current, current, divisor) + return result + + +def divide_unsigned(value, divisor, width, mutation=None): + """Exact (quotient, remainder, operation count), no multiplication/division.""" + need(type(divisor) is int and divisor >= 1, 'positive fixed divisor') + need(type(value) is int and 0 <= value < (1 << width), 'unsigned input') + m = Machine(width) + if divisor == 1: return value, 0, m.operations + bits = divisor.bit_length() + if bits > width: return 0, value, m.operations + planes = [value] + [0] * (bits - 1) + length, power = 1, 2 + if power >= divisor: power -= divisor + stages = 0 + while length < width: + upper = [m.shr(x, length) for x in planes] + weighted = modular_scale(m, upper, 1 if mutation == 'wrong_weight' else power, divisor) + planes = modular_add(m, planes, weighted, divisor) + power = scalar_modular_product(m, power, power, divisor) + length <<= 1 + stages += 1 + before = planes if mutation == 'wrong_suffix' else [m.shr(x, 1) for x in planes] + quotient = compare_constant(m, [value] + before, divisor) + remainder = 0 + for bit, plane in enumerate(planes): + remainder = m.bor(remainder, m.shl(m.band(plane, 1), bit)) + need(stages == (width - 1).bit_length(), 'stage count') + need(m.operations <= 100 * (bits + 1) ** 2 * (stages + 1), 'operation upper bound') + return quotient, remainder, m.operations + + +def divide_signed(value, divisor, width, rounding='floor'): + """Signed-magnitude input; magnitude fits width bits. Rounding is explicit.""" + need(type(value) is int and abs(value) < (1 << width), 'signed magnitude') + need(rounding in ('floor', 'toward_zero', 'nearest_even'), 'rounding mode') + q, r, count = divide_unsigned(abs(value), divisor, width) + negative = value < 0 + if rounding == 'floor': + result = -q - (r != 0) if negative else q + elif rounding == 'toward_zero': + result = -q if negative else q + else: + # Fixed thresholds avoid forming 2*r, even at the word boundary. + half = divisor >> 1 + half_fits = half < (1 << width) + above = half_fits and r > half + tie = half_fits and not (divisor & 1) and r == half + result = q + (above or (tie and bool(q & 1))) + if negative: result = -result + return result, count + 10 + + +def fixed_rational(value, numerator, denominator, input_bits, rounding='nearest_even'): + """Fixed numerator/denominator, additive guard bits and explicit rounding.""" + need(type(numerator) is int, 'fixed integer numerator') + need(type(denominator) is int and denominator >= 1, 'positive fixed denominator') + need(type(value) is int and abs(value) < (1 << input_bits), 'input magnitude') + width = max(input_bits + abs(numerator).bit_length() + 1, + denominator.bit_length() + 1, 3) + m = Machine(width) + product = 0 + for bit in range(abs(numerator).bit_length()): + if (abs(numerator) >> bit) & 1: + product = m.add(product, m.shl(abs(value), bit)) + negative = (value < 0) != (numerator < 0) + result, count = divide_signed(-product if negative else product, denominator, width, rounding) + return result, count + m.operations, width diff --git a/research/native-cyclic-recovery/preflight.py b/research/native-cyclic-recovery/preflight.py new file mode 100644 index 0000000000..d03f21edee --- /dev/null +++ b/research/native-cyclic-recovery/preflight.py @@ -0,0 +1,7 @@ +from pathlib import Path +import hashlib,json +p=Path(__file__).resolve().parent +m=json.loads((p/'MANIFEST.json').read_text()) +a={x.relative_to(p).as_posix():hashlib.sha256(x.read_bytes()).hexdigest() for x in p.rglob('*') if x.is_file() and x.name!='MANIFEST.json' and '__pycache__' not in x.parts} +if a!=m['files']:raise ValueError('Package inventory or source hash mismatch') +print('PASS_NATIVE_CYCLIC_RECOVERY_BYTES') diff --git a/research/native-cyclic-recovery/verify.py b/research/native-cyclic-recovery/verify.py new file mode 100644 index 0000000000..c78be2ddbe --- /dev/null +++ b/research/native-cyclic-recovery/verify.py @@ -0,0 +1,60 @@ +"""End-to-end rounded native consumer; references may use exact rationals.""" +from pathlib import Path +from fractions import Fraction as Q +import importlib.util,sys,json,random,hashlib +ROOT=Path(__file__).resolve().parent + +def load(name): + spec=importlib.util.spec_from_file_location(name,ROOT/(name+'.py')) + mod=importlib.util.module_from_spec(spec);sys.modules[name]=mod;spec.loader.exec_module(mod);return mod +D=load('fixed_divisor');C=load('cascade_free') +def need(ok,msg): + if not ok:raise ValueError(msg) + +def rounded_decode(v,w,n,labels,phases,q,bits,mutation=False): + """Integer grid data. Every rational scale uses the bounded-word datapath.""" + ops=0 + def scaled(pair,p,d): + nonlocal ops + out=[] + for x in pair: + y,c,guard=D.fixed_rational(x,p,d,bits,'nearest_even');out.append(y);ops+=c + return tuple(out) + z=list(v) + for unused in range(w-1): + term=C.shift(z,w,n,labels,phases) + z=[C.add(a,scaled(b,-1,2))for a,b in zip(v,term)] + route=C.compile_return(w,n,labels,phases) + out=list(z);sgn=(-1 if w%2 else 1) + if mutation:sgn=-sgn + for unused in range(q-1): + term=C.apply_map(out,route) + out=[C.add(a,scaled(b,sgn,1<5 for a,b in zip(bad,exact)for x,y in zip(a,b)),'changed beta sign must reject') + controls+=1 + cases.append(dict(roles=w,addresses_per_role=n,total_entries=w*n,cycle_order_divisor=q, + monomial_passes=w+q-2,payload_bits=payload_bits,stored_observation_error=str(error),quantized_observation_error=str(total), + counted_scalar_data_operations=ops)) +receipt=dict(status='PASS_ROUNDED_NATIVE_CYCLIC_RECOVERY',cases=cases,mutation_controls=controls, + arithmetic='fixed rational scales use Boolean/both-shift/add bounded-word code, no MUL/DIV primitive', + complete_supplier=False,new_kappa=None) +print(json.dumps(receipt,indent=2)) diff --git a/research/native-cyclic-recovery/verify_division.py b/research/native-cyclic-recovery/verify_division.py new file mode 100644 index 0000000000..43a6c9a7a9 --- /dev/null +++ b/research/native-cyclic-recovery/verify_division.py @@ -0,0 +1,70 @@ +from fractions import Fraction +from pathlib import Path +import json,random,time,hashlib,importlib.util,sys +ROOT=Path(__file__).resolve().parent +spec=importlib.util.spec_from_file_location('fixed_divisor',ROOT/'fixed_divisor.py') +module=importlib.util.module_from_spec(spec);sys.modules[spec.name]=module;spec.loader.exec_module(module) +divide_unsigned=module.divide_unsigned;divide_signed=module.divide_signed;fixed_rational=module.fixed_rational;need=module.need +start=time.monotonic();cases=0;maxops=0;large=[] +for divisor in (2,3,5,7,9,17): + for width in range(1,10): + for value in range(1<