diff --git a/research/source-remaining-diagonal/CHECKPOINT.md b/research/source-remaining-diagonal/CHECKPOINT.md new file mode 100644 index 0000000000..db087f64db --- /dev/null +++ b/research/source-remaining-diagonal/CHECKPOINT.md @@ -0,0 +1,34 @@ +# Wave 4: source remaining diagonal — reviewed and verified locally + +Base: 7c49fe32c55de02c2c873655c804b16e4c3fef0a. +Branch: research/source-remaining-diagonal-20261109. +Worker: analytic_join; worktree: /workspace/scratch/a365d332d434/worker-analytic-wave4. + +Completed: actual canonical Reference coefficients, finite sufficient normalizer +admission and source p^100 implication; certified upper-floor one-ulp quantizer; +unchanged original Full Diagonal event/FFT scalar service; two actual global +routes; exact same-grid codec with no added normalization; full cost/backing +invoice; substitution into public ledger equation (4). + +Verified: 272 exact coefficients, 1904 independent signed-grid trajectories, +1998 boundary quantizers, 9 source/coefficient controls. Native 32-record run +executes 2 routes, 64 squares, 32 complex products and 192 scalar calls; all +16 native parameter positions and accumulator margin checked. Six physical +alias/return controls; borrowed input/heads restored; protected output consumed. +Registered normal and optimized replays PASS. Lead independently checked the +universal quantizer proof, 7992 rational enclosures, source/codec contract, +exact route exponent inequality and accumulator margin; receipt retained. + +Dependencies: public ledger76a84e1c4bfa4035e5ee85410dbfc4541f0da168, +source codec73d5adaba2b7dc662e86eb901e81369a3f73be9f, +complete Core6fb9ab776b7d0956b8bcc2d3cfde0f3034421630, +Full FFT service2882d4414e95a6884f7b588d9da7ca893f800cbf. +SOURCES/VERIFY declare all 51 canonical live inputs; DEPENDENCIES authenticates +20 retained public files. The registered card/provenance input is also pinned. + +Remaining: committed-byte/mode gate and lead remote publication. No remote +branch or completed multiplier is claimed by this local checkpoint. Production +context delivery, H/ideal-Gaussian comparison, native/route/lifecycle premises, +complete source prefix/suffix, extraction and final recovery stay open. +No new kappa. Follow README reproduction and exact pins; old public branches +are frozen. This scratch worktree alone is transient until lead publication. diff --git a/research/source-remaining-diagonal/DEPENDENCIES.json b/research/source-remaining-diagonal/DEPENDENCIES.json new file mode 100644 index 0000000000..8b4c9bd29c --- /dev/null +++ b/research/source-remaining-diagonal/DEPENDENCIES.json @@ -0,0 +1,165 @@ +{ + "schema_version": 1, + "files": [ + { + "retained_path": "retained/fft/SOURCES.json", + "repository": "CubeJerry/integer-mult-bounds", + "commit": "2882d4414e95a6884f7b588d9da7ca893f800cbf", + "original_path": "research/full-fft-scalar-join/SOURCES.json", + "git_blob": "60c1abe481dff32e58c04fd844e642d4f218e30f", + "sha256": "dd7aa44b0846ef8a944c40d25b96d296d57f2c7c996a53320e0c7eca898a007d" + }, + { + "retained_path": "retained/fft/VENDOR.json", + "repository": "CubeJerry/integer-mult-bounds", + "commit": "2882d4414e95a6884f7b588d9da7ca893f800cbf", + "original_path": "research/full-fft-scalar-join/VENDOR.json", + "git_blob": "ae23608262fc490a8850d7c9042efad9742d8450", + "sha256": "8d1df6afc64ea678e1fa6d4ed791ff71f511118c835ca40667ecf91e049399ef" + }, + { + "retained_path": "retained/fft/COLD-NAMES.json", + "repository": "CubeJerry/integer-mult-bounds", + "commit": "2882d4414e95a6884f7b588d9da7ca893f800cbf", + "original_path": "research/full-fft-scalar-join/COLD-NAMES.json", + "git_blob": "ad8be217000d517422363f319a5bc95f554b2536", + "sha256": "27d6c3c96d8fa073fd0b1446365912e8e9aa7e86ff6c42136a89d56927cee5e3" + }, + { + "retained_path": "retained/fft/join_sources.py", + "repository": "CubeJerry/integer-mult-bounds", + "commit": "2882d4414e95a6884f7b588d9da7ca893f800cbf", + "original_path": "research/full-fft-scalar-join/join_sources.py", + "git_blob": "9106ff1a3ab38c78cc7f76580d5acf8401ad7530", + "sha256": "e28d1699326e713c71300faee84647e6c0d95ba22e8107bc3dd9502a7611a9fb" + }, + { + "retained_path": "retained/fft/join_engine.py", + "repository": "CubeJerry/integer-mult-bounds", + "commit": "2882d4414e95a6884f7b588d9da7ca893f800cbf", + "original_path": "research/full-fft-scalar-join/join_engine.py", + "git_blob": "4b410a9e3b7f4e7a8586ffbf6af6950ccb0f914b", + "sha256": "c9c71639f4aadf8315c1a8aa49abee1592ab7e905122359d2a5ff7bc0f539725" + }, + { + "retained_path": "retained/fft/PROOF.md", + "repository": "CubeJerry/integer-mult-bounds", + "commit": "2882d4414e95a6884f7b588d9da7ca893f800cbf", + "original_path": "research/full-fft-scalar-join/PROOF.md", + "git_blob": "60d86c8b1186761acf6e7a05e6a9e69f54e8ee87", + "sha256": "e62671838b1dd21490b2a9dfa821ca5a5450aeeeaf647e43c8a1db421f6100d1" + }, + { + "retained_path": "retained/bridge/boundary_codec.py", + "repository": "CubeJerry/integer-mult-bounds", + "commit": "73d5adaba2b7dc662e86eb901e81369a3f73be9f", + "original_path": "research/core-halo-source-bridge/boundary_codec.py", + "git_blob": "5fdbd993cc4d9087e509fec2d9fb6e34912fa232", + "sha256": "e28149c32d9a53fbbe9b93c67bc0b85f1587747f74fa0452b6ff26618972eace" + }, + { + "retained_path": "retained/bridge/tapes.py", + "repository": "CubeJerry/integer-mult-bounds", + "commit": "73d5adaba2b7dc662e86eb901e81369a3f73be9f", + "original_path": "research/core-halo-source-bridge/retained/halo/sparse-halo-tape-transaction/tapes.py", + "git_blob": "b3dfa43ba0d08c6393731ac3cd2857a92e4c8aa2", + "sha256": "80b246fafae0adf53af7561e1be59f4374e6294d66bb7a12ef9524b9ef4f2a78" + }, + { + "retained_path": "retained/fft/vendor/full/sources.py", + "repository": "CubeJerry/integer-mult-bounds", + "commit": "2882d4414e95a6884f7b588d9da7ca893f800cbf", + "original_path": "research/full-fft-scalar-join/vendor/full/sources.py", + "git_blob": "f8cebf330fd5d1b81be5bd1855d4e4e0e0070a6a", + "sha256": "fa1151e5d482a8b4c604754b6a5a14c7c22c1a017fb713ce29a3e37bd557f718" + }, + { + "retained_path": "retained/fft/vendor/full/SOURCES.json", + "repository": "CubeJerry/integer-mult-bounds", + "commit": "2882d4414e95a6884f7b588d9da7ca893f800cbf", + "original_path": "research/full-fft-scalar-join/vendor/full/SOURCES.json", + "git_blob": "83d5d82738c3965fa2b412c450db999115b1ac37", + "sha256": "9af528ad94beacce0a859bb1ae6af95c2419e2a0dfaf7cafbd9563ccc3b4e945" + }, + { + "retained_path": "retained/fft/vendor/full/compiler.py", + "repository": "CubeJerry/integer-mult-bounds", + "commit": "2882d4414e95a6884f7b588d9da7ca893f800cbf", + "original_path": "research/full-fft-scalar-join/vendor/full/compiler.py", + "git_blob": "802b917e8bc2ca6629c3fb7df9a14c55d8c9ebcd", + "sha256": "d16ffd1f09efda2c1ce27fd68c64b7039a07903042440c97195eb392ef8d5c68" + }, + { + "retained_path": "retained/fft/vendor/full/reference.py", + "repository": "CubeJerry/integer-mult-bounds", + "commit": "2882d4414e95a6884f7b588d9da7ca893f800cbf", + "original_path": "research/full-fft-scalar-join/vendor/full/reference.py", + "git_blob": "255bdf15079d41acca4ee27092bdabbb29a7ca70", + "sha256": "8d762677657a7ad0863096dba3214ed50d1260ca0ab1487ab44d3bef8724de0c" + }, + { + "retained_path": "retained/fft/vendor/full/physical_engine.py", + "repository": "CubeJerry/integer-mult-bounds", + "commit": "2882d4414e95a6884f7b588d9da7ca893f800cbf", + "original_path": "research/full-fft-scalar-join/vendor/full/physical_engine.py", + "git_blob": "7164f0921eb3c824e5e7bda4c72359f2928491e1", + "sha256": "072306676a44c1fc130aedf9ca7ae2d1bdcca2309b77661b3bb4523bcb4fe7f3" + }, + { + "retained_path": "retained/fft/vendor/full/physical_controls.py", + "repository": "CubeJerry/integer-mult-bounds", + "commit": "2882d4414e95a6884f7b588d9da7ca893f800cbf", + "original_path": "research/full-fft-scalar-join/vendor/full/physical_controls.py", + "git_blob": "83a85800306fb0d892f313230c61847a02ea906f", + "sha256": "d5fbe750e26fe71eb08ded86ebec06ca92c3390ba0d516676489f3231f93540c" + }, + { + "retained_path": "retained/fft/vendor/full/physical_sources.py", + "repository": "CubeJerry/integer-mult-bounds", + "commit": "2882d4414e95a6884f7b588d9da7ca893f800cbf", + "original_path": "research/full-fft-scalar-join/vendor/full/physical_sources.py", + "git_blob": "5451de1ba3426c6122d88b20a8d157d36cf4046c", + "sha256": "b23d201c1b449301400db446f68f1b30a43049141654754d03c3e1c4c20697bc" + }, + { + "retained_path": "retained/fft/vendor/full/vendor/global-boundary/frontend.py", + "repository": "CubeJerry/integer-mult-bounds", + "commit": "2882d4414e95a6884f7b588d9da7ca893f800cbf", + "original_path": "research/full-fft-scalar-join/vendor/full/vendor/global-boundary/frontend.py", + "git_blob": "890a67ea1ed36541d98027271f141aa8b3400c10", + "sha256": "0847d68370f72c2eb0ac07be0746b59a2f88d7a555aff21c157f0fd7a61620a5" + }, + { + "retained_path": "retained/fft/vendor/full/vendor/global-boundary/bridge.py", + "repository": "CubeJerry/integer-mult-bounds", + "commit": "2882d4414e95a6884f7b588d9da7ca893f800cbf", + "original_path": "research/full-fft-scalar-join/vendor/full/vendor/global-boundary/bridge.py", + "git_blob": "4b9f0042ebe2c62a5be515ffbcae1d62693d5ae6", + "sha256": "445d7150a61032f83bd5406ae8083bdf0ce5b937eebdf76a3ff7291b8e31a5da" + }, + { + "retained_path": "retained/fft/vendor/full/verify_physical.py", + "repository": "CubeJerry/integer-mult-bounds", + "commit": "2882d4414e95a6884f7b588d9da7ca893f800cbf", + "original_path": "research/full-fft-scalar-join/vendor/full/verify_physical.py", + "git_blob": "3998e503bd7bc45f091360689d2b015b13e6f1fe", + "sha256": "a19db64aaf7f2135818c95be0b7a7ad6db97625b094753c7ed3aa9ae978358d1" + }, + { + "retained_path": "retained/ledger/PROOF.md", + "repository": "CubeJerry/integer-mult-bounds", + "commit": "76a84e1c4bfa4035e5ee85410dbfc4541f0da168", + "original_path": "research/core-group-scale-ledger/PROOF.md", + "git_blob": "3e580dee35c9b597d9b66932282fefa4ef92306a", + "sha256": "59ee004f3d69e70abf8a7fd82f99312b31d4ad32fed3d6866d61e197177599a4" + }, + { + "retained_path": "retained/core/NUMERICS.md", + "repository": "CubeJerry/integer-mult-bounds", + "commit": "6fb9ab776b7d0956b8bcc2d3cfde0f3034421630", + "original_path": "research/complete-core-physical-join/NUMERICS.md", + "git_blob": "44e5164ebceaf6b2c5d644f10081e17faebec4be", + "sha256": "be695b11fdb657e837a7f1dd84da7314c605d0534063536cc4d1696141a7c481" + } + ] +} diff --git a/research/source-remaining-diagonal/NOTICE.md b/research/source-remaining-diagonal/NOTICE.md new file mode 100644 index 0000000000..67acb10ff2 --- /dev/null +++ b/research/source-remaining-diagonal/NOTICE.md @@ -0,0 +1,27 @@ +# Attribution and scope + +Prepared for @CubeJerry with substantial OpenAI assistance in source audits, +proofs, implementation, exact independent oracles and packaging. Apache-2.0. + +Jose Manuel (jmbarrancoml) authored the canonical rational Gaussian Reference, +with substantial OpenAI Codex assistance. Its source credits Vlado Vojdanovski, +Jeremy Kothe and Cinna Davis for geometry/reference work, and Mason Hale for +the interval arithmetic. Their exact source files are external authenticated +inputs, and their notices are unchanged. + +The exact Full/FFT service credits the original Full/fixed-word compiler, +global caller, Count/ownership interfaces and prior scalar/native work, notably +CrocSwap/integer-mult-bounds#3787, #3709, #3627, #4205, #4253, #4178 and #6898. +The retained public files preserve all original author and assistance notices. +The successful physical route/owner pattern follows the public complete Core +join at `6fb9ab776b7d0956b8bcc2d3cfde0f3034421630`; this explicit new producer/ +owner does not claim to be that prior program or its original FullRoot theorem. + +The same-session published source codec `73d5adab` and group ledger `76a84e1c` +are immediate predecessors. Their public commits, paths and hashes are in +DEPENDENCIES.json. The source Gaussian diagonal cache and older C/D +normalization in CrocSwap/integer-mult-bounds#3851 are prior work, as are the +Karatsuba Full physical service #6894 and separate FFT recovery #6895. + +No upstream selection, unconditional multiplier or new complete kappa is +claimed. Source and native premises are stated explicitly in PROOF.md. diff --git a/research/source-remaining-diagonal/PR-DESCRIPTION.md b/research/source-remaining-diagonal/PR-DESCRIPTION.md new file mode 100644 index 0000000000..6ca9fb821a --- /dev/null +++ b/research/source-remaining-diagonal/PR-DESCRIPTION.md @@ -0,0 +1,79 @@ +## Why this matters + +The public group scale ledger leaves an explicit missing service: after the +actual Core/halo routine returns the inverse divided by 2^U, apply the source's +remaining `2^(U-K)Dtilde` on the same original padded field, actual-state radius +and common q grid. A norm bound or generic cached diagonal pass does not +establish those source, scale and physical interfaces. + +## Exact result + +This package binds the actual canonical Gaussian Reference coordinates, +including identity holes, to one original Full Diagonal event and the unchanged +exact FFT scalar owner. Two real whole-field routes restore original order; +the existing external codec has zero grid drop and zero added normalization. +For all admitted q-grid inputs of component-l1 radius 3R0, the error is at most +`(3R0+2)2^-q`. This fits the ledger's existing q budget, so that particular +remaining-diagonal error obligation is supplied without changing gamma. + +The finite guard `K-U>=2 sum alpha_i^2` is explicit and follows from the +conservative source p^100 budget and its existing alpha/gap admissions. +Certified reciprocal exponential intervals and an upper-endpoint floor with +clipping give one-ulp coefficient error without a transcendental separation +assumption. The complete full-period stock, spectator code, both routes, +all radius squares/products, format conversions and retained backing are paid. + +## Novelty and predecessors + +This is the specific source/remaining-scale/common-grid/physical join, not a +new scalar multiplier, Gaussian cache or generic perturbation inequality. +CrocSwap/integer-mult-bounds#3851 already has C/D normalization, #6894 the +original Full physical service, #6898 its exact FFT scalar owner and #3787 the +scalar theorem. The source GAUSSIAN.md already gives cached prefix products. +#6895 addresses a different whole FFT recovery boundary. + +Immediate public dependencies: + +* [Group ledger 76a84e1c](https://github.com/CubeJerry/integer-mult-bounds/tree/76a84e1c4bfa4035e5ee85410dbfc4541f0da168/research/core-group-scale-ledger). +* [Source codec 73d5adab](https://github.com/CubeJerry/integer-mult-bounds/tree/73d5adaba2b7dc662e86eb901e81369a3f73be9f/research/core-halo-source-bridge). +* [Full FFT owner 2882d441](https://github.com/CubeJerry/integer-mult-bounds/tree/2882d4414e95a6884f7b588d9da7ca893f800cbf/research/full-fft-scalar-join). +* [Complete Core family 6fb9ab77](https://github.com/CubeJerry/integer-mult-bounds/tree/6fb9ab776b7d0956b8bcc2d3cfde0f3034421630/research/complete-core-physical-join). + +Canonical base is `7c49fe32c55de02c2c873655c804b16e4c3fef0a`; all source paths, +individual hashes and dependencies are recorded. Retained source bytes are +unchanged, and large canonical archives remain external inputs. + +## Reproduction and checks + +```sh +python3 -B research/source-remaining-diagonal/verify.py --physical +python3 -O -B research/source-remaining-diagonal/verify.py --physical +python3 scripts/research_package.py --package research/source-remaining-diagonal --check-only +python3 scripts/research_package.py --package research/source-remaining-diagonal +python3 scripts/check_research_commit.py --package research/source-remaining-diagonal --check-modes +``` + +Expected status is `PASS_SOURCE_REMAINING_DIAGONAL`. Exact independent +positive-exponential and forward-coordinate oracles check 272 coefficients, +1,904 signed-grid trajectories and 1,998 adversarial quantizer cases. There +are 9 coefficient/source controls and 6 physical controls. The actual 32-record +native witness runs 2 global routes, 64 exact radius squares and 32 complex +products (192 scalar calls), checks all 16 parameter positions, matches every +original-coordinate result, restores input and borrowed heads, and consumes +its protected return. Its scalar widths use the fixed cutoff's base branch; +the universal FFT bound is credited separately. + +## Limitations and kappa status + +**No new kappa.** This is one source-specific conditional service theorem. +Whole production-context delivery, rational H/ideal-Gaussian comparison, +native/Count/route/lifecycle premises, the rest of the source transform, +final extraction and complete integer recovery remain necessary. A finite +fixture does not prove those claims. The integration is supplied at the +service boundary; a complete Core/halo-plus-diagonal physical fixture is not +asserted here. + +Prepared for **@CubeJerry**. Predecessor authors and exact retained notices are +credited in NOTICE.md. Substantial OpenAI assistance was used in proofs, +source analysis, implementation, checks and packaging. Independent lead +review is a separate recorded review, not proof-kernel or human acceptance. diff --git a/research/source-remaining-diagonal/PR-TITLE.txt b/research/source-remaining-diagonal/PR-TITLE.txt new file mode 100644 index 0000000000..932e7b7b3d --- /dev/null +++ b/research/source-remaining-diagonal/PR-TITLE.txt @@ -0,0 +1 @@ +Supply the actual remaining Gaussian diagonal on the common grid (no new kappa) diff --git a/research/source-remaining-diagonal/PROOF.md b/research/source-remaining-diagonal/PROOF.md new file mode 100644 index 0000000000..0ad3a34cc3 --- /dev/null +++ b/research/source-remaining-diagonal/PROOF.md @@ -0,0 +1,372 @@ +# The actual remaining Gaussian diagonal on the common grid + +Prepared for **@CubeJerry**, with substantial OpenAI assistance. Apache-2.0. +Canonical base: `7c49fe32c55de02c2c873655c804b16e4c3fef0a`. +**A source-specific conditional service theorem; no new kappa.** + +## 1. The implication supplied here + +The public [group scale ledger](https://github.com/CubeJerry/integer-mult-bounds/tree/76a84e1c4bfa4035e5ee85410dbfc4541f0da168/research/core-group-scale-ledger) +leaves its equation (4) as a concrete missing implication. After the actual +Core/halo bridge returns an approximation to + +`B=2^-U tensor H_i^-1`, `U=sum u_i`, + +the source's existing completed-map normalizer K must be spent by applying + +`A=2^(U-K) Dtilde_G`. (1) + +On original selected coordinate `q_i(j)=j+floor(e_i j/S_i+1/2)`, the actual +diagonal is `D_i=exp(pi alpha_i^2 beta_i(j)^2)`, with +`beta_i(j)=e_i j/S_i-floor(e_i j/S_i+1/2)`. At a hole, Dtilde_i is 1. +These are exactly the source definitions in `unconditional-batched-crt/PROOF.md` +and the original `rational-unitary-fft/gaussian_reference.py` coordinates. +The field remains the complete padded target field, before final extraction. + +This package produces those coefficients, invokes the unchanged physical +Full diagonal implementation with the public exact FFT scalar owner, and +returns through the public format codec with **zero additional normalization**. +For every actual input z on the component q-grid with +`||z||_* = max_k (|Re z_k|+|Im z_k|) <= R_w`, it proves + +`||Ahat(z)-Az||_* <= (R_w+2) 2^-q`. (2) + +All original coordinates and spectator records participate. The service +returns to that same q-grid. Its actual output even satisfies +`||Ahat(z)||_*<=||z||_*`. This last pointwise radius bound does not assert +linearity or a Lipschitz property of the rounded routine. + +The exact source/physical premises below remain necessary. In particular, +this does not independently discharge a native supplier theorem, prove the +rational H versus ideal Gaussian N comparison, implement final extraction, +or establish whole integer recovery. It consumes one identified open service +in a conditional ledger. + +### Prior work and exact pins + +The global scalar service is the unchanged public package +[2882d441](https://github.com/CubeJerry/integer-mult-bounds/tree/2882d4414e95a6884f7b588d9da7ca893f800cbf/research/full-fft-scalar-join), +whose full physical source is pinned to +`d51859e7816771f627033b23db0f9786ada863f8`. +CrocSwap/integer-mult-bounds#6898 supplies that owner; #3787 supplies its exact +`FftWord` scalar; #3709 supplies the retained signed arithmetic/inner product +lineage. The independent scalar numerical review and source lifecycle +premises are inherited as stated in the retained FFT proof. The external +codec is unchanged public +[73d5adab](https://github.com/CubeJerry/integer-mult-bounds/tree/73d5adaba2b7dc662e86eb901e81369a3f73be9f/research/core-halo-source-bridge). +The complete Core numerical family is cited at +[6fb9ab77](https://github.com/CubeJerry/integer-mult-bounds/blob/6fb9ab776b7d0956b8bcc2d3cfde0f3034421630/research/complete-core-physical-join/NUMERICS.md). + +#3851 already has physical C selection and Gaussian normalization, #6894 has +the original global Full physical service, and #6895 has a different complete +FFT product recovery boundary. The source GAUSSIAN.md already describes +cached axis-prefix products with O(1) average word products per record. +`gaussian-origin-diagonals` concerns source Schur diagonals; +`encoded-twiddle-diagonal-pass` concerns signed packet rotations. We do not +claim a new cache, generic diagonal multiplier, or exponential algorithm. +The new implication binds (1), including its changed scale, actual original +Reference coordinates, all-input radius, exact q-grid codec and complete paid +physical calls to the ledger's remaining service. + +## 2. Finite admissions and their source-family consequence + +Let the original target sides be `N_i=S_i+e_i=2^ell_i`, with `0=1`. K is the actual already-declared completed normalization. + +The new sufficient finite admission is + +`K-U >= L_exp := 2 sum_i alpha_i^2`. (3) + +Nearest half-up rounding gives `-1/2<=beta_i(j)<1/2`. Put +`F_max=sum alpha_i^2/4`, so L_exp=8F_max is an integer. At every complete +coordinate, with hole contributions zero, define +`F=sum_selected alpha_i^2 beta_i(j)^2`; then `0<=F<=F_max` and +`A_k=2^(U-K) exp(pi F)`. The elementary strict inequalities +`pi<4` and `log 2>1/2` give `pi<8 log 2`. Therefore + +`0=2, and let +`l=ceil(log2 p)`. Then, using `pi>3` and `log2<1`, + +`2 alpha_i^2 <= (10/pi) log(16p) < 4(l+4)`, + +so `2 alpha_i^2<=4l+16`. The least dyadic source normalizer and +`delta_i>=1/(16p^2)` give `u_i<=2l+4`. Thus the public ledger's concrete +`k_i=100l` has + +`k_i-u_i-2 alpha_i^2 >=94l-20>0`. (5) + +Even a dyadic completed bound merely at least p^100 suffices: for l>=2, +`k_i>=100 log2 p>100(l-1)>=6l+20`; at l=1 and p>=2 one has p=2 and k_i>=100. +Summing proves (3). This implication inherits the source's eventual alpha +and gap admissions; it does not prove those admissions. Oversized caller +normalizers u_i must pass the actual finite inequality. + +## 3. Certified coefficients without a separation assumption + +The producer calls the original `Reference.exp.relative(F,F_max,q+4)`. +Let `w=exp(-pi F)`, `s=2^(U-K)`, and let its certified receipt supply +`0=2^-L_exp`, `s/w<=1`. With `epsilon_q=2^(-q-6)`, +`l_w>=w(1-epsilon_q)`. Hence the exact rational reciprocal enclosure + +`a_lo=s/u_w`, `a_hi=s/l_w` + +contains A_k and has width at most + +`s (u_w-l_w)/(l_w u_w) <= epsilon_q/(1-epsilon_q) < 2^-q`. (6) + +The implementation checks positivity and this width directly as well. +The unchanged relative-exponential routine computes a fixed prescribed +precision; it never loops until the transcendental value has a unique grid +floor. + +Let h_q=2^-q and encode + +`c_k = min(1, h_q floor(a_hi/h_q))`. (7) + +Without clipping, `c_k-A_k<=a_hi-a_lo<=h_q` and +`A_k-c_k=1 and + +`r=ceil(log2 R_w)+ceil(n_addr/2)`, `W=q+r+2`. + +Every admitted field has Euclidean norm at most R_w sqrt(T)<=2^r. The actual +native Full routine checks this with all 2T exact component squares and the +complete accumulator; no local-field radius replaces the full one. Set +`incoming_bits=fractional_bits=q`, `incoming_width=data_width=W`, coefficient +and cache widths q+2, and temporary width 2W+3. Factors in [0,1] fit; signed +products and full sums fit the temporary width. Component magnitudes after +truncation cannot exceed their incoming magnitudes, so the W output carrier +and the original external carrier fit. +For the maximum squared-radius exponent +`2q+2ceil(log2 R_w)+n_addr`, the difference from temporary width 2W+3 is +`2ceil(n_addr/2)-n_addr+7>=7`. The radius accumulator itself is an actual +Count whose complete width/cost is charged; this margin is not a claim that +the accumulator is stored in the complex-product temporary. The checker +compares all 16 encoded native metadata positions with their stated values. + +`RemainingOwner` surrounds unchanged `FastFullPhysical.run` by the two actual +global routes, using one already constructed composed root. The code has +exactly one D event and no H events. Its data operation is the original four +exact real products and exact complex sums, followed once by componentwise +toward-zero division by 2^q. Because the coefficient imaginary part is zero, +the result is precisely + +`(Q_q(c_k Re z_k), Q_q(c_k Im z_k))`. + +The coefficient error contributes at most R_w h_q in component-l1 norm and +the two component roundings contribute strictly less than 2h_q. This proves +(2) and the pointwise radius bound. The native implementation really pays +four real products even when two involve the zero coefficient component. + +The retained external/native codec has +`native_grid=external_grid=q`, `normalizer_bits=0`, hence `lift=drop=0`. +Its incoming sign-magnitude/two's-complement conversion is exact. Its return +absolute-value conversion discards zero digits and is exact too; this is a +source-level fact of its literal drop loop, corroborated by the actual +negative and mixed-sign witness. There is no second final q truncation and +no second factor 2^-U. A caller choosing another native grid or an additional +normalizer falls outside this specific wrapper and needs its own error bill. + +## 6. Ownership and full physical invoice + +All owners, scalar children, formats and role inventories are constructed +before sealed execution. Private pools and every nested protected output are +forbidden borrowed ports. The parent copies its complete input into owned +state, suspends its scope at the route and D-child boundaries, copies and +consumes each protected child return, and restores every borrowed head. +It returns one protected original-order result. The codec protects a complete +external result and uses the unchanged original input as its record clock. +Consumption clears the codec input/work and native outputs; it does not claim +to shrink retained tape backing. This is a successful legal-call theorem +under the predecessor native/Count/ownership contracts, not a theorem of +arbitrary interruption recovery. + +Let `F_scalar(w)=O(w log^2(w+2))` be the inherited exact FFT scalar tariff, +with the fixed production cutoff 4096 and all setup, carries, copies and +cleanup included. Let C_route be the actually admitted complete route bill +at `precision=W+h_G`, support at most 2h_G, position width +`max(1,ceil(log2 n_addr))`, complete record width 2W, and T records. Let S_ref +denote source Reference construction/retained state already required by the +caller; it is not made free if absent. A safe added service invoice is + +`S_ref + 2^h_G poly(p) + O(Tq) + S_constructor + 2 C_route` +` + O(T F_scalar(W+n_addr+1) + T W + poly(n_addr+log(q+R_w+2)))`. (9) + +Before substituting a p-family, replace `2^h_G poly(p)` by the actual finite +coordinate/exponential/source-validation cost. The complete formula includes: + +* all P coefficient evaluations and original source admissions, full spectator + page validation/encoding, the O(2^(n_addr-h_G)) repeated-page container, + route descriptor emission and metadata preparation; +* all 2T radius squares and the complete accumulator, T complex data products + (four scalar calls each), exact sums, rounding, full lifts/copies/rewinds; +* both global routes, input/output sign codecs and every complete return copy, + saved original input, protected output, disposal and fixed owner setup. + +Neither a payload value nor a record index is decoded by the online code. +The source producer's host rational work is input-independent setup. Its +straight sequential fixed-tape simulation visits the P stock entries, with +g and all numerical heights polynomially bounded; a fixed polynomial overhead +is covered in (9). The prepared stock is then rewound/emitted once per +spectator page. It does not simulate a random-access T-entry numeric store. +Each source seal enumerates all original axis coordinates, costing +O(sum_i N_i poly(p))<=P poly(p); it is not a constant-time hash assumption. + +The native fixed owner graph is the credited Full/FFT graph plus one fixed +global parent; the public codec uses 10 fixed roles. Its finite witness has +6080 distinct native roles, not 6080 fresh tapes per record. Added retained +backing comprises the maximum complete code(8), T W input/current/protected +buffers, codec buffers/formats, `2^h_G poly(p)` source stock, descriptor and +preparation peak, the scalar O(max_previous W) history and **all inherited +route/native backing**. Erased buffers still contribute their high-water +extent. Parent/child input references alias only through the stated borrowed +protocol; the saved original external input remains charged throughout. + +## 7. Favorable complete family and ledger substitution + +Use the published conservative family, with beta=39/40, +`epsilon=1-10^-30`, `g=Theta(p^beta)`, `d=Theta(p^epsilon)`, balanced groups +between g and 2g, `ell_original=O(p^(1-epsilon))`, and `n_addr=Theta(p)`. +The common q and `log R_w` are O(p) by the public group ledger. Then + +`h_G=O(p^(beta+1-epsilon))=o(p)`, `W=Theta(p)` + +when the incoming grid is Omega(p). The actual exponential factor height is +O(g log p); the rational coordinate description height is O(h_G+log p), and +the retained exponential working precision is O(q+g log p)=O(p). Its fixed +Taylor/range-reduction algorithms therefore take polynomial time per stock +entry. For every fixed polynomial degree, `2^h_G poly(p)=o(Tp)`; multiplying +by O(d/g) groups preserves this absorption. It is the full-period bound, +not the Core-side microbox count, that proves it. + +The added scalar/codec/encoding bill over all groups is +`O(V (d/g) polylog p)`, V=Theta(Tp). The two complete routes must still be +admitted: n_addr=Theta(W+h_G), support<=2h_G<=(W+h_G)^.997 eventually, and +the actual native stock/free-space/reserve guards are inherited. Under the +same historical route tariff used by the public Core numerical family, its +all-group contribution is + +`O(V p^(epsilon-beta+eta(beta+1-epsilon)) polylog p)`, +`eta=332353/332929`. (10) + +Keep 2 C_route if these admissions are absent. The public dense exponent is +`epsilon-(1-alpha)beta`, alpha=99827101/100000000. The exact rational inequality + +`eta*10^-30 < (39/40)*(alpha-eta)` (11) + +shows that (10) is strictly subordinate to that existing dense term. The +checker verifies (11) with exact fractions. The extra full-period route +factor is therefore not silently hidden in a logarithm. This is a compatible +conditional invoice, not a new accepted assembled kappa. + +For the ledger set R_w=3R_0. Its existing precision guard is +`q>=z+ceil(log2 max(8,2 max_j L_j(2R_0)))`. Since each nonempty group has +`0=0, `L_j(2R_0)>=2R_0+2`. Thus +`2L_j>=4R_0+4>=3R_0+2`, and (2) gives `e_A,j<=2^-z=eta_ledger`. +No extra precision bit is needed for this specific upper-endpoint quantizer +and zero-drop native codec. The public actual-state recurrence and final +restoration can consequently consume this service directly, subject to all +their remaining hypotheses. The already-existing K normalizer is spent once; +the final restoration exponent gamma is unchanged. + +## 8. Checks, limits and remaining obligations + +The bounded replay authenticates all canonical and retained inputs, including +the unchanged source archive closure. Its independently coded positive +exponential oracle uses exact rational Machin bounds and a direct positive +Taylor tail. It does not import the retained negative-exponential interval +backend. It independently enumerates original source j coordinates, beta +and holes before checking 272 one/two-axis coefficients and 1904 signed-grid +trajectories. It also checks 1998 adversarial rational quantizer cases and +source/allocation corruption controls. These finite checks corroborate the +universal proof; they are not a substitute for it. + +The actual 32-record physical witness uses one original 16-coordinate Gaussian +axis and a spectator bit. Both physical global routes are nontrivial. It +executes 64 actual input squares and 32 complete complex products, exactly 192 +scalar calls, restores borrowed controls, preserves the external input and +consumes the protected result. All native values are below the fixed 4096 +scalar cutoff, so this witness uses the existing base branch. The all-width +FFT bound is inherited from #6898/#3787, not inferred from this fixture. +The separate two-axis stock test covers the full 256-entry period and 512 +original coordinates without claiming another 512-record native replay. + +The checker disables the inherited host-decoding helpers during physical +execution and tests private-port aliases and protected-return reentry. These +are negative controls for the stated interface; no assertion claims complete +formal verification of Python or the simulator. Exact source objects and +files are frozen during execution, as in the predecessor contracts. + +Remaining obligations are the complete production-context delivery and +reference/ideal-Gaussian comparison, native supplier and route/ownership +premises, the other side of the source transform, actual final selected +extraction/CRT/Fourier restoration and final rounding. This result supplies +only the particular missing remaining-diagonal service on the padded field. diff --git a/research/source-remaining-diagonal/README.md b/research/source-remaining-diagonal/README.md new file mode 100644 index 0000000000..9649dd8be6 --- /dev/null +++ b/research/source-remaining-diagonal/README.md @@ -0,0 +1,111 @@ +# Actual remaining Gaussian diagonal: source, scale, grid and physical service + +Prepared for **@CubeJerry**, with substantial OpenAI assistance. **No new kappa.** +Base: `7c49fe32c55de02c2c873655c804b16e4c3fef0a`. + +This supplies the explicit remaining-diagonal service left open in equation (4) +of the public [group scale ledger](https://github.com/CubeJerry/integer-mult-bounds/tree/76a84e1c4bfa4035e5ee85410dbfc4541f0da168/research/core-group-scale-ledger). +After the actual normalized Core/halo inverse, the source needs +`A=2^(U-K)Dtilde`, where K is its already-declared completed-map normalizer. +The returned field stays on the original padded target coordinates and the +same component q-grid. The source-derived finite contraction guard is explicit. + +The delivered all-input bound is + +`||Ahat(z)-Az||_* <= (3R0+2)2^-q`, for `||z||_*<=3R0`. + +It fits the public ledger's existing q budget. The native service performs +one actual product truncation; the retained external codec has drop 0 and +introduces no additional error or normalization. The final restoration gamma +is unchanged. Every coefficient, spectator page, route, radius square, scalar +product, copy and retained backing remains paid. + +## Files and exact dependencies + +* [PROOF.md](PROOF.md): finite source admissions; coefficient enclosure and + one-ulp quantizer; unchanged native execution; actual common-grid error; + full setup/routes/scalar/backing invoice and ledger substitution. +* [coefficients.py](coefficients.py): actual Reference binding, full original + group-period coefficient stock, and one original Diagonal event. +* [diagonal_owner.py](diagonal_owner.py): two actual original-coordinate + physical routes, unchanged Full D consumer, and exact zero-drop codec. +* [diagonal_sources.py](diagonal_sources.py), [SOURCES.json](SOURCES.json), + [DEPENDENCIES.json](DEPENDENCIES.json): exact canonical and public source + cohorts. Original source files and their relative loader layouts are intact. +* [verify.py](verify.py), [evidence/REPLAY.json](evidence/REPLAY.json): independent + rational oracle, immutable-source failures and real physical witness. + +Retained public dependencies are the group ledger at `76a84e1c`, source codec +at `73d5adab`, complete Core numerical family at `6fb9ab77`, and exact FFT/Full +owner at `2882d441` with its unchanged `d51859e7` Full source. All complete SHAs +and individual hashes are recorded. Canonical live dependencies remain +external; the two existing large archives are reused, not copied here. + +## Reproduction and executed evidence + +From the repository root: + +```sh +python3 -B research/source-remaining-diagonal/verify.py --physical +python3 -O -B research/source-remaining-diagonal/verify.py --physical +python3 scripts/research_package.py --package research/source-remaining-diagonal --check-only +python3 scripts/research_package.py --package research/source-remaining-diagonal +python3 scripts/check_research_commit.py --package research/source-remaining-diagonal --check-modes +``` + +Expected replay status: `PASS_SOURCE_REMAINING_DIAGONAL`. The receipt records +272 coefficient entries, 1,904 independent signed-grid trajectories, 1,998 +rational boundary quantizers, 9 coefficient/source controls, and 6 physical +alias/return controls. Independent forward source enumeration covers the +one-axis 16-entry and two-axis 256-entry full original periods, including holes. +The separate positive-exponential oracle uses exact rational arithmetic and +never calls the retained interval backend. + +The physical 32-record witness executes two real whole-field routes, 64 exact +input squares, 32 complex data products and 192 scalar calls. All 16 encoded +metadata positions and the full-field accumulator margin are checked. Original +controls/heads and saved input are preserved; every returned record matches +the independent original-coordinate oracle and the protected result is +consumed. Its roughly 3-second native execution uses the fixed 4096 cutoff's +existing base branch. The universal fast scalar theorem is inherited, not +inferred from that run. Full two-axis native execution and an integrated +Core/halo-plus-diagonal run are not claimed. + +## Scope and limitations + +The sufficient guard `K-U>=2 sum alpha_i^2` is tested directly. It follows +from the conservative source p^100 completed normalizers, least dyadic inverse +normalizers and the existing alpha/gap admissions. Smaller arbitrary caller +normalizers need to satisfy it; their asymptotic names are insufficient. + +Coefficient stock has `2^h` entries for h equal to the **full original** +group address width. Its subexponential setup bound and the two extra route +costs are proved at the actual production parameters. A finite experiment +does not prove those asymptotic premises. Native, Count, routing, ownership +and scalar contracts, source H/ideal-Gaussian comparison and final outer +recovery remain inherited or unresolved. This advances the analytic/compiler/ +precision interface; the complete multiplication bound remains conditional. + +## Open next questions + +1. Can the actual normalized Core/halo and remaining diagonal be delivered + together on every production context, using the same Reference identities, + original axis descriptors and prepared owned streams? The theorem supplies + the exact composable service; its physical witness begins at the admitted + remaining-diagonal input. +2. Can the complete padded protocol connect to actual final extraction and + the source transform's prefix/suffix on the same global field? Existing + extraction and normalization mechanisms are credited; their specific + whole-source integration and accumulated error remain required. +3. Can the rational H versus ideal N comparison and all retained native + supplier/lifecycle admissions be independently discharged at this caller? + This service makes neither implication automatic. + +## Credit + +See [NOTICE.md](NOTICE.md). Existing cache, scalar arithmetic, Full event +consumer, Gaussian interval construction, route and codec work are retained +and credited. The contribution is this exact remaining source/scale/grid +join and its complete invoice. AI assistance is substantial; independent +review is recorded separately and no proof-kernel or human acceptance is +implied by the finite receipt. diff --git a/research/source-remaining-diagonal/SOURCES.json b/research/source-remaining-diagonal/SOURCES.json new file mode 100644 index 0000000000..a6a4964ccc --- /dev/null +++ b/research/source-remaining-diagonal/SOURCES.json @@ -0,0 +1,318 @@ +{ + "schema_version": 1, + "base_commit": "7c49fe32c55de02c2c873655c804b16e4c3fef0a", + "files": [ + { + "path": "research/capped-phase-fusion/TENSOR-COMPILER.md", + "usage": "input", + "git_blob": "19efb9cb1c5a738e57caadf2dd6f5611af1bc78a", + "sha256": "4d3b8466598a864a234b978e25976648d4e761840aad9153dd18d73d3dfe4d15" + }, + { + "path": "research/capped-phase-fusion/evidence/inplace_algebra_ultra/check_circuits.py", + "usage": "input", + "git_blob": "f80c141c8116b163c2bb5a028c28212077c8d5a9", + "sha256": "06d1861bfe8af543908e26557ffda7e451ff176bceb9bacfaf0f04f234b336d5" + }, + { + "path": "research/capped-phase-fusion/evidence/inplace_algebra_ultra/check_tensor_compiler.py", + "usage": "input", + "git_blob": "5eb5c1ffd23932ba7ccaa0d7686a5b875a3b1809", + "sha256": "dc4b1f1884489215a2c2d0e8978a241e99e6c8c9f1d2fa2460c73d2c7d4ba30a" + }, + { + "path": "research/cubic-cyclic-inverse/vendor/PR628-NOTICE.md", + "usage": "input", + "git_blob": "22fbeb8ef0a28dd6b3feea718492091319ceb96e", + "sha256": "abeacf1ad1491d5797cfcf1f3832799bbf3b24b99597229d7bc884059a51ec68" + }, + { + "path": "research/cubic-cyclic-inverse/vendor/PR628-PROOF.md", + "usage": "input", + "git_blob": "fb8fe7cb3bd036c69047ae7b4f4009a51b11825b", + "sha256": "595893609764c64a90d9b21b9cbd6d9e61980703f3deb43361105cf8c3d1d093" + }, + { + "path": "research/cubic-cyclic-inverse/vendor/interval_kernel.py", + "usage": "input", + "git_blob": "1182175a55cb871481de0f56ea9ae56e474705fe", + "sha256": "9b7bb24640a9a7d3f83c7951dfef483ec933db4c50de6c0130b85f450eeddfbe" + }, + { + "path": "research/gaussian-height-contract/CALLER.md", + "usage": "input", + "git_blob": "9754af67d2109153ec019877f824708bf9ff988e", + "sha256": "0f6687778b0dd2b5046ced1bcda13970b2f45c35186bb00ae205c682590b8668" + }, + { + "path": "research/gaussian-height-contract/check_caller.py", + "usage": "input", + "git_blob": "db4382fbd836923aeda5b670ba71a27f6ebd9521", + "sha256": "5e16aefe99bc3f4086e41b3fa6349b2796201d1ed1bbdbc304f48e23af7fcf73" + }, + { + "path": "research/physical-fft-word/EVIDENCE.md", + "usage": "input", + "git_blob": "cefb9b6159689bba582fdc2e5cc76425d4770f2b", + "sha256": "c2314c62bbb1cfc0400dd09875926e1efb0000d1db450a984b2f86253d064997" + }, + { + "path": "research/physical-fft-word/PROOF.md", + "usage": "input", + "git_blob": "b066548b77ae99d36d11df379c6c2332caccd0f1", + "sha256": "5d7e5c3e47c4936023f191ef91ff4015d4786cb4de303d8fd3bef0fcec7a77b0" + }, + { + "path": "research/physical-fft-word/README.md", + "usage": "input", + "git_blob": "d149d6c20f47208f81f78c0f038e0201585c2ba3", + "sha256": "0a47858de0cbe7700792b52ee3dcd9ae66f3ad9eb1f99f450515e820ed099dc8" + }, + { + "path": "research/physical-fft-word/fft_word_codec.py", + "usage": "input", + "git_blob": "9444abc96a1cd44309d291589d895120e0eae6b9", + "sha256": "d13f25fc215aa28570ca750afb7153f38d7fb62f92d28e404bb84396e2a90768" + }, + { + "path": "research/physical-fft-word/fft_word_engine.py", + "usage": "input", + "git_blob": "a9e00dd0b5d26719e8d74ba53ce625e4de58b447", + "sha256": "4b2ed4bb244a4b7537432e33706caf2abe19e44ab50cbc0a78db135e9581dee1" + }, + { + "path": "research/physical-fft-word/fft_word_plan.py", + "usage": "input", + "git_blob": "a3914e8e0683f7516332d213254dbd3a8c2122fd", + "sha256": "f8fff468b77753aa5f0d446c5d4381653659253051c1fcd066cd3b345cffd7c1" + }, + { + "path": "research/physical-fft-word/fft_word_sources.py", + "usage": "input", + "git_blob": "77662c14546cc77a1ecfc05b2d404f744fa9dc45", + "sha256": "46f40da411e3779b407bb11a0f7f1526b2d8611c1c6c1ab54f12f0cc00f8ebc2" + }, + { + "path": "research/physical-fft-word/inputs/ring-export.tar", + "usage": "input", + "git_blob": "004c660f786cee08b07fd74af80c9c91146b89f4", + "sha256": "c03d4b056ccd3db860c93579f6525e0bb1baea31cff879eb07135c99432ef159" + }, + { + "path": "research/physical-ring-product/PROOF.md", + "usage": "input", + "git_blob": "2bc9926799296bb348193e68e55aed60ec6ce96d", + "sha256": "a2e43fe5f77350958c2d7d66a50389e5ec6b439a7f9620e94862b969e88fb500" + }, + { + "path": "research/physical-ring-product/fft_arithmetic.py", + "usage": "input", + "git_blob": "606bb6c5e32ca813c927fba1a45315aae3e7de52", + "sha256": "bf7deff44f15f3349fcec98d0e86a6d20820f49ca008892fef9456b3629509e0" + }, + { + "path": "research/physical-ring-product/inputs/fourier-export.tar", + "usage": "input", + "git_blob": "6f7f9d59abdf5d98cbecde1583db61103c1cd973", + "sha256": "30e460df0428ea1ff72dba6528537e53aec62fcec5dc6077bf736afd5cbbc7e8" + }, + { + "path": "research/physical-ring-product/ring_sources.py", + "usage": "input", + "git_blob": "40a4b21a6ffd89d20051fac8055998fac252f130", + "sha256": "82f469acd7f8960ab6b32698e5300a377eb3f18f015f1f129f84604181cac746" + }, + { + "path": "research/physical-ring-product/ring_words.py", + "usage": "input", + "git_blob": "1cb44ce6d95a1e0f9d2c6f78ecd5c7a8e8b39ba9", + "sha256": "6bd18c8f78c94b8a0b97512b4f45c03f88b608e895d0f120296585976e1e8104" + }, + { + "path": "research/physical-ring-product/word_product.py", + "usage": "input", + "git_blob": "67e09e91103535fd1eb0b2d7d6db1fdc13de07d2", + "sha256": "12020ed0571fa756c2d19942b6ccdd6dc5627fdaadb388051417a618c14417d6" + }, + { + "path": "research/rational-fft-fixed-h/DENSE-PROOF.md", + "usage": "input", + "git_blob": "3ee98912ec954824f2a9a0ccdecffce8583832f8", + "sha256": "aa16b3c3124f8b33846319629532cd81106ff8f2a86750c2c327b6cdf6201b85" + }, + { + "path": "research/rational-fft-fixed-h/SOURCES.json", + "usage": "input", + "git_blob": "220b267ed60866653330b7e3d2136d741e40a095", + "sha256": "8d1e091cd6a7b92519bb402d546da73e9f1aca428425ed9caf7f9db922365102" + }, + { + "path": "research/rational-fft-fixed-h/dense.py", + "usage": "input", + "git_blob": "7a48c8d2d566ff64d370c4cb8f793f5cf989c072", + "sha256": "b94d74ede0cced358f0c56646b1dc1e8cb182bbb215ebb40cf56e1d3d262a3f5" + }, + { + "path": "research/rational-fft-fixed-h/lowering.py", + "usage": "input", + "git_blob": "5c2adcfd96f1b2d5987f04242434cd30fdfc33d0", + "sha256": "93b6e86c81a8f12e80688a8f7ec8ddaffedd729fe46b02554b6ed1c135fdd397" + }, + { + "path": "research/rational-fft-fixed-h/vendor/PROVENANCE.json", + "usage": "input", + "git_blob": "22cf8bdcb94f8fff0d1f3f9a38ce9402cc0013df", + "sha256": "302a23bacdb464ef8f1c5d6c87cf72ce846c52c34bd69d245a51c1972e9852f2" + }, + { + "path": "research/rational-fft-fixed-h/vendor/full_source/FULL-PROOF.md", + "usage": "input", + "git_blob": "e650f46863115f810e27b403f916dd7f79b37786", + "sha256": "acf8c596d91b5efd35a286735d6867ff8afce64354a13f680c2fae3dab824410" + }, + { + "path": "research/rational-fft-fixed-h/vendor/full_source/GENERATOR-PROOF.md", + "usage": "input", + "git_blob": "8bef383eec887450e86f14365a6f7b07c1310e9d", + "sha256": "cddda1f944299a349c837808b349fa6e4499cbb1889f7dacc00ca8afac9b580c" + }, + { + "path": "research/rational-fft-fixed-h/vendor/full_source/PROOF.md", + "usage": "input", + "git_blob": "99a55596f67ae3b94ef02ebb159b313f33bf22af", + "sha256": "50e31e33e1275a133d10e87208ceb50dddce67d0678d2a89de9f7ba28d8380d9" + }, + { + "path": "research/rational-fft-fixed-h/vendor/full_source/PROVENANCE.json", + "usage": "input", + "git_blob": "9d848703ed1e2cae899951bb5660de7ab8335d5b", + "sha256": "209f50a6f131db73364989048188c0fec007b20f031b5719e6c8bddac1d37888" + }, + { + "path": "research/rational-fft-fixed-h/vendor/full_source/TRIANGLE-PROOF.md", + "usage": "input", + "git_blob": "f923f4ff2dfe40401fa90d83727ade62b2ef5b5f", + "sha256": "abea26e3c86a9970225b070be034c47e7970e10fe1b5686f405e0b301acf3159" + }, + { + "path": "research/rational-fft-fixed-h/vendor/full_source/full.py", + "usage": "input", + "git_blob": "7f85ad1a89e81b7dfc6b54e7bd9547120e86d5d3", + "sha256": "1f42d5f2858564ffb320e54ba6aa29651025491569823e25006bf5862457b803" + }, + { + "path": "research/rational-fft-fixed-h/vendor/full_source/generator.py", + "usage": "input", + "git_blob": "d761d3c88b1685fb64d92d69f699b8218c9ec30f", + "sha256": "827ef9fe1bd664859995892b59843c390f7969c938fb7e1e6dc585c31a54b555" + }, + { + "path": "research/rational-fft-fixed-h/vendor/full_source/triangular.py", + "usage": "input", + "git_blob": "2bd8de01a7ac80de7e6b9f8252bc69d0e0a291e8", + "sha256": "46780d95ddebfed22e8f0c18565fe2e768250afa5beeb31f450292cc06f7ec11" + }, + { + "path": "research/rational-fft-fixed-h/vendor/full_source/vendor/STEIN-PROVENANCE.json", + "usage": "input", + "git_blob": "c602fb5bb332dbe098950b14d55da05ce2cf4312", + "sha256": "e7f0e8dc517387e302b1e8bf5dff7e12b29da8aa91abc6ea597f33c1ac08ba62" + }, + { + "path": "research/rational-fft-fixed-h/vendor/full_source/vendor/stein_rational.py", + "usage": "input", + "git_blob": "71b240a460a185ee2fe926cd189b56aeac6f997f", + "sha256": "3065fc5d6d22ec44de533b08fb0c639603449456383668e561dc46629e641502" + }, + { + "path": "research/rational-fft-fixed-h/vendor/rational_fft/engine.py", + "usage": "input", + "git_blob": "e9f2f2b08dc2bc4c646e47dca92059351ca89384", + "sha256": "9e36aee0835e6b1b62997433581f88b5a434ccab8ae43e5c25d1deaaf1ebf653" + }, + { + "path": "research/rational-fft-fixed-h/vendor/rational_fft/exact.py", + "usage": "input", + "git_blob": "aae41e6acfb2e5a4fafdd85727891eb746b57b42", + "sha256": "c9b89d7357210af69865690ba12e695366961f8b501a8fab9d0fefe3fb30c479" + }, + { + "path": "research/unconditional-batched-crt/GAUSSIAN.md", + "usage": "input", + "git_blob": "adfb28c93e6b06178c901caaac39ede41a9e541b", + "sha256": "2f63c91c58f2d1cf31294812c75970ea390c61866a8da7ed700d4316a033a242" + }, + { + "path": "research/unconditional-batched-crt/vendor/GAUGEFREE-INTERIORS.md", + "usage": "input", + "git_blob": "20585e44fa4e49b13b5d8495bbf6ed254459a362", + "sha256": "d1423ac0ea0003521797209f4396e6981a66994bbee4f8b48026e5b95f8c5116" + }, + { + "path": "research/unconditional-batched-crt/vendor/SHALLOW-TOEPLITZ.md", + "usage": "input", + "git_blob": "bc4349b2daea548ffa09e1f38a31f1df86b0b7be", + "sha256": "b384b93f3fb4a8c97da2e617ebc14d55cebb0a739070e7f8dbb66f63e24e9310" + }, + { + "path": "research/rational-unitary-fft/exact.py", + "git_blob": "aae41e6acfb2e5a4fafdd85727891eb746b57b42", + "sha256": "c9b89d7357210af69865690ba12e695366961f8b501a8fab9d0fefe3fb30c479", + "usage": "input" + }, + { + "path": "research/rational-unitary-fft/engine.py", + "git_blob": "e9f2f2b08dc2bc4c646e47dca92059351ca89384", + "sha256": "9e36aee0835e6b1b62997433581f88b5a434ccab8ae43e5c25d1deaaf1ebf653", + "usage": "input" + }, + { + "path": "research/rational-unitary-fft/triangular.py", + "git_blob": "2bd8de01a7ac80de7e6b9f8252bc69d0e0a291e8", + "sha256": "46780d95ddebfed22e8f0c18565fe2e768250afa5beeb31f450292cc06f7ec11", + "usage": "input" + }, + { + "path": "research/rational-unitary-fft/generator.py", + "git_blob": "d761d3c88b1685fb64d92d69f699b8218c9ec30f", + "sha256": "827ef9fe1bd664859995892b59843c390f7969c938fb7e1e6dc585c31a54b555", + "usage": "input" + }, + { + "path": "research/rational-unitary-fft/full.py", + "git_blob": "7f85ad1a89e81b7dfc6b54e7bd9547120e86d5d3", + "sha256": "1f42d5f2858564ffb320e54ba6aa29651025491569823e25006bf5862457b803", + "usage": "input" + }, + { + "path": "research/rational-unitary-fft/gaussian.py", + "git_blob": "52ad2e1d605f5f7d669234567c25bc087306dd44", + "sha256": "08155357fd39b5fd7959f51f1d205b6511b8577b51520d793c89f92368b399ab", + "usage": "input" + }, + { + "path": "research/rational-unitary-fft/gaussian_reference.py", + "git_blob": "92addfabde50655cea7ad5a84cca9cff5457adee", + "sha256": "ed4d0908646e391d4a0ea32c988a0301a1793a72294ac7058a664ed3283ca3c3", + "usage": "input" + }, + { + "path": "research/certified-gaussian-recovery/intervals.py", + "git_blob": "91d458865aa026bdf0d59653a4ecbfe3a178ecbc", + "sha256": "159d2a7d32a8cc7c8f56632a8ef127308b984a0a6753c9d6bdccacc6e7d6d4df", + "usage": "input" + }, + { + "path": "docs/research/agent-task-catalog.json", + "git_blob": "3404fbdd5e7529a0674eef26114b5071e4586cec", + "sha256": "ead6cdc9d0af6d58e8a49744d8ec8c7c15e13d2ba93c276c434bcf9b51b93a81", + "usage": "provenance" + }, + { + "path": "research/unconditional-batched-crt/PROOF.md", + "usage": "input", + "git_blob": "406eb561cc8d6041ea3fba1a849653b654f2198c", + "sha256": "689fc7b01c5f04f77019ff02d1b79cb4f7020bd98e05b1052020bad295dec060" + } + ] +} diff --git a/research/source-remaining-diagonal/TASK.json b/research/source-remaining-diagonal/TASK.json new file mode 100644 index 0000000000..506fe48bec --- /dev/null +++ b/research/source-remaining-diagonal/TASK.json @@ -0,0 +1,107 @@ +{ + "actual_scope": "Supply the exact remaining 2^(U-K) Dtilde service on the original padded field and q grid, using actual References, unchanged physical Full/FFT D execution, two paid routes and the exact zero-drop codec.", + "ai_assistance": "Substantial OpenAI assistance in proofs, source audit, code, exact independent oracles and packaging. Independent lead review is recorded separately; no human or proof-kernel acceptance.", + "author": "Prepared for @CubeJerry", + "base_commit": "7c49fe32c55de02c2c873655c804b16e4c3fef0a", + "bottleneck_link": "The public group ledger equation (4) leaves this actual source/scale/grid/physical remaining-diagonal error contract open.", + "budget_minutes": 120, + "evidence": "PROOF.md proves the coefficient enclosure, no-separation quantizer, actual native/codec bound, complete source/full-period/router/scalar invoice and direct ledger substitution. An independent positive-exponential/forward-coordinate oracle and actual 32-record native witness are executed.", + "finite_domain": "272 coefficients on full 16/256-entry original periods; 512+32 original coordinate checks; 1904 signed-grid trajectories; 1998 rational quantizers; 9 source/coefficient and 6 physical controls. Actual 32-record native run: 2 routes, 64 squares, 32 complex products, 192 scalar calls. No random search.", + "independent_previous_package": false, + "no_new_kappa": true, + "open_questions": [ + { + "blocked_by": "Uniform production context delivery and all inherited source/native guards remain required.", + "first_step": "Bind the two existing prepared streams and protected-return owners to the same full-field source family.", + "question": "Can the normalized Core/halo and remaining diagonal be delivered together on every production context?", + "why_it_matters": "Both services must use identical References, original axes and normalizers on actual intermediate states." + }, + { + "blocked_by": "Whole-source integration and accumulated outer recovery are not supplied here.", + "first_step": "Compare exact original-coordinate C extraction and existing source transform streams at the padded field boundary.", + "question": "Can the complete padded protocol join actual final extraction and the source transform prefix/suffix?", + "why_it_matters": "The completed integer target depends on all global volume, scale and final-error interfaces." + }, + { + "blocked_by": "This package supplies only the specific remaining diagonal service.", + "first_step": "Audit one remaining quantified source comparison or native contract at its actual caller.", + "question": "Can the rational H versus ideal N comparison and native supplier/lifecycle admissions be independently discharged?", + "why_it_matters": "The multiplication bound remains conditional until those source-level implications are established." + } + ], + "original_card": { + "acceptance_gate": "Identify the proposition and what would change downstream; do not equate a finite replay with a universal proof.", + "allowed_variations": [ + "One exact source head, helper/cut region or quantified proposition and changed hypothesis; check live handoffs first. Different seeds are not different scopes." + ], + "bottleneck_link": "Judge the actual current supplier contract and complete signed target/paid bill; frozen-profile ceilings require an applicability proof.", + "existing_checks": [ + { + "evidence": "research/unconditional-batched-crt/README.md", + "remaining": "Independent proof audit of one caller-bound all-size implication; all other premises remain explicit.", + "scope": "PR #4100: proposed unconditional construction and finite checks, without independent acceptance.", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129", + "source_commit": "337d04939571a637aeab54a0f58f54fde811663a", + "status": "author-checked" + }, + { + "evidence": "docs/research/pr-intake-evidence/pr5599-completion/PROOF-REVIEW.md", + "remaining": "The next experiment must identify uncovered source-specific work. Successor archive intake does not transfer this admission.", + "scope": "Selected PR5599: complete helper-subspace construction and independent caller replay; five framework assumptions remain.", + "selected_record_sha256": "2a0220e866417774606e0f991e41b9c1d26b1f43b97857238cf478dbc7d330b5", + "source_commit": "09dd0965711ca7eeb169057a420abab1c9052137", + "status": "reviewed" + } + ], + "first_experiment": "Choose one assumption ID (native_all_columns, owned_erasure, compiler, precision_tape, analytic_recovery), one quantified implication and exact dependency closure. Check current handoffs, including #5625 row reentry and #5707 root-prefix lowering, without treating their partial scope as the whole theorem. Prove or falsify that implication with a caller-bound argument; stop at the chosen obligation. Finite tests or root digits do not discharge an all-size statement.", + "first_step": { + "command": [ + "python3", + "-B", + "scripts/research_selected_baseline.py" + ], + "expected": "PASS_RESEARCH_BASELINE_BINDINGS_ONLY", + "inspect": "Read revision 8, the selected review and live exact-source handoffs. Then follow this card's bounded first_experiment.", + "scope": "Source-bound orientation only, not a supplier replay or theorem proof." + }, + "id": "uniform-transfer-audit", + "methods": [ + "Construct and independently check one source-bound instance of the stated first experiment.", + "Seek an exact counterexample or target-specific complete-budget obstruction to that same proposed change." + ], + "overlap_terms": [ + "native_all_columns", + "owned_erasure", + "compiler", + "precision_tape", + "analytic_recovery" + ], + "question": "Can one of the selected record's five inherited assumptions be proved at its actual caller?", + "scope_change_triggers": [ + "Changing source head, helper/cut domain, operation alphabet or caller boundary without recording the new scope.", + "Treating an archived proposal or local numerical pass as complete supplier admission." + ], + "starting_points": [ + "docs/research/current-priorities.md", + "docs/research/research-family-status.md", + "certificates/selected-result.json", + "docs/research/pr-intake-evidence/pr5599-completion/PROOF-REVIEW.md" + ] + }, + "outcome": "completed", + "previous_public_commit": "76a84e1c4bfa4035e5ee85410dbfc4541f0da168", + "priority_revision": 8, + "schema_version": 1, + "scope_change_reason": "Previous public ledger left actual remaining-diagonal obligation (4) unresolved; unchanged public FFT scalar service now supplies its paid backend. Existing generic cache/normalization/scalar work is credited; new scope is the source-specific remaining-scale and format join.", + "scope_status": "refined", + "seed": 77, + "source_projection_scope": "No source projection: actual canonical Gaussian Reference constructor/exponentials/coordinates and actual unchanged physical Full/FFT source cohort execute. The independent oracle imports no retained interval arithmetic.", + "stop_rule": "Freeze once actual source service, all-input bound, complete invoice, bounded independent controls and native witness are reviewed. Do not claim full Gaussian transform or integer recovery.", + "task_id": "uniform-transfer-audit", + "tracks": [ + "75-84 independent verification/formalization", + "60-74 adversarial audit" + ], + "wave": 4, + "worker": "analytic_join" +} diff --git a/research/source-remaining-diagonal/VERIFY.json b/research/source-remaining-diagonal/VERIFY.json new file mode 100644 index 0000000000..521d2e3da7 --- /dev/null +++ b/research/source-remaining-diagonal/VERIFY.json @@ -0,0 +1,82 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [ + "research/capped-phase-fusion/TENSOR-COMPILER.md", + "research/capped-phase-fusion/evidence/inplace_algebra_ultra/check_circuits.py", + "research/capped-phase-fusion/evidence/inplace_algebra_ultra/check_tensor_compiler.py", + "research/cubic-cyclic-inverse/vendor/PR628-NOTICE.md", + "research/cubic-cyclic-inverse/vendor/PR628-PROOF.md", + "research/cubic-cyclic-inverse/vendor/interval_kernel.py", + "research/gaussian-height-contract/CALLER.md", + "research/gaussian-height-contract/check_caller.py", + "research/physical-fft-word/EVIDENCE.md", + "research/physical-fft-word/PROOF.md", + "research/physical-fft-word/README.md", + "research/physical-fft-word/fft_word_codec.py", + "research/physical-fft-word/fft_word_engine.py", + "research/physical-fft-word/fft_word_plan.py", + "research/physical-fft-word/fft_word_sources.py", + "research/physical-fft-word/inputs/ring-export.tar", + "research/physical-ring-product/PROOF.md", + "research/physical-ring-product/fft_arithmetic.py", + "research/physical-ring-product/inputs/fourier-export.tar", + "research/physical-ring-product/ring_sources.py", + "research/physical-ring-product/ring_words.py", + "research/physical-ring-product/word_product.py", + "research/rational-fft-fixed-h/DENSE-PROOF.md", + "research/rational-fft-fixed-h/SOURCES.json", + "research/rational-fft-fixed-h/dense.py", + "research/rational-fft-fixed-h/lowering.py", + "research/rational-fft-fixed-h/vendor/PROVENANCE.json", + "research/rational-fft-fixed-h/vendor/full_source/FULL-PROOF.md", + "research/rational-fft-fixed-h/vendor/full_source/GENERATOR-PROOF.md", + "research/rational-fft-fixed-h/vendor/full_source/PROOF.md", + "research/rational-fft-fixed-h/vendor/full_source/PROVENANCE.json", + "research/rational-fft-fixed-h/vendor/full_source/TRIANGLE-PROOF.md", + "research/rational-fft-fixed-h/vendor/full_source/full.py", + "research/rational-fft-fixed-h/vendor/full_source/generator.py", + "research/rational-fft-fixed-h/vendor/full_source/triangular.py", + "research/rational-fft-fixed-h/vendor/full_source/vendor/STEIN-PROVENANCE.json", + "research/rational-fft-fixed-h/vendor/full_source/vendor/stein_rational.py", + "research/rational-fft-fixed-h/vendor/rational_fft/engine.py", + "research/rational-fft-fixed-h/vendor/rational_fft/exact.py", + "research/unconditional-batched-crt/GAUSSIAN.md", + "research/unconditional-batched-crt/vendor/GAUGEFREE-INTERIORS.md", + "research/unconditional-batched-crt/vendor/SHALLOW-TOEPLITZ.md", + "research/rational-unitary-fft/exact.py", + "research/rational-unitary-fft/engine.py", + "research/rational-unitary-fft/triangular.py", + "research/rational-unitary-fft/generator.py", + "research/rational-unitary-fft/full.py", + "research/rational-unitary-fft/gaussian.py", + "research/rational-unitary-fft/gaussian_reference.py", + "research/certified-gaussian-recovery/intervals.py", + "research/unconditional-batched-crt/PROOF.md" + ], + "commands": [ + { + "argv": [ + "{python}", + "-B", + "{package}/verify.py", + "--physical" + ], + "checks": "Authenticate exact canonical/public sources; independently verify source coefficients and grid errors; execute actual routes/Full/FFT/zero-drop codec and reject source/port/return failures.", + "timeout_seconds": 180 + }, + { + "argv": [ + "{python}", + "-O", + "-B", + "{package}/verify.py", + "--physical" + ], + "checks": "Authenticate exact canonical/public sources; independently verify source coefficients and grid errors; execute actual routes/Full/FFT/zero-drop codec and reject source/port/return failures.", + "timeout_seconds": 180 + } + ] +} diff --git a/research/source-remaining-diagonal/coefficients.py b/research/source-remaining-diagonal/coefficients.py new file mode 100644 index 0000000000..6b9f652358 --- /dev/null +++ b/research/source-remaining-diagonal/coefficients.py @@ -0,0 +1,195 @@ +"""The actual remaining Gaussian diagonal, on full original target axes. + +This is a new explicit Diagonal-event producer, not a FullRoot execution. +All preparation is input-independent and paid; online payloads stay on tapes. +Prepared for @CubeJerry with substantial OpenAI assistance. Apache-2.0. +""" +from dataclasses import dataclass +from fractions import Fraction as Q +from hashlib import sha256 +import json +from math import prod + + +def need(condition, message): + if not condition: + raise ValueError(message) + + +def ceiling(value): + value = Q(value) + return -(-value.numerator // value.denominator) + + +def ceil_log2(value): + value = Q(value) + need(value > 0, "positive radius") + k = value.numerator.bit_length() - value.denominator.bit_length() + power = Q(1 << k) if k >= 0 else Q(1, 1 << -k) + return k + int(power < value) + + +def upper_grid(lower, upper, bits): + """One-ulp approximation to A in [lower,upper] intersect [0,1].""" + need(type(bits) is int and bits >= 1 and Q(0) <= lower <= upper + and lower <= 1 and upper - lower <= Q(1, 1 << bits), + "positive coefficient enclosure with one-ulp width") + return min(1 << bits, (upper.numerator << bits) // upper.denominator) + + +@dataclass(frozen=True) +class Layout: + lengths: tuple + selected: tuple + + def __post_init__(self): + need(type(self.lengths) is tuple and self.lengths + and all(type(x) is int and x >= 1 for x in self.lengths), + "positive original dyadic axis widths") + need(type(self.selected) is tuple and self.selected and len(set(self.selected)) == len(self.selected) + and all(type(x) is int and 0 <= x < len(self.lengths) for x in self.selected), + "distinct original source axes in low-first packed order") + + @property + def n(self): + return sum(self.lengths) + + @property + def h(self): + return sum(self.lengths[a] for a in self.selected) + + @property + def positions(self): + starts = tuple(sum(self.lengths[:a]) for a in range(len(self.lengths))) + return tuple(starts[a] + j for a in self.selected for j in range(self.lengths[a])) + + @property + def gather(self): + # Complete the selected source-to-low-target bijection on its union. + source, target = self.positions, tuple(range(self.h)) + mapping = dict(zip(source, target)) + mapping.update(zip(sorted(set(target) - set(source)), sorted(set(source) - set(target)))) + return {a: b for a, b in mapping.items() if a != b} + + @property + def inverse(self): + return {b: a for a, b in self.gather.items()} + + def coordinates(self, packed_index): + need(type(packed_index) is int and 0 <= packed_index < 1 << self.h, + "full original group period index") + values = [] + for a in self.selected: + values.append(packed_index & ((1 << self.lengths[a]) - 1)) + packed_index >>= self.lengths[a] + return tuple(values) + + +class RemainingProgram: + """Bind the same References/u_i and emit one original Diagonal event. + + Caller supplies the original Core normalizer exponents, and the completed + source normalization K. No further 2^-U is applied by the codec. + """ + def __init__(self, Reference, references, normalizer_bits, layout, completed_bits, + bits, radius, Diagonal): + self.Reference, self.references, self.normalizer_bits = Reference, tuple(references), tuple(normalizer_bits) + self.layout, self.completed_bits, self.Diagonal = layout, completed_bits, Diagonal + need(len(self.references) == len(layout.selected) == len(self.normalizer_bits), + "same source-axis and original normalizer family") + need(type(completed_bits) is int and completed_bits >= 0 + and type(bits) is int and bits >= 1 and type(radius) is int and radius >= 1, + "integer completed normalization, grid, and actual-state radius") + need(all(type(u) is int and u >= 0 for u in self.normalizer_bits), "original dyadic normalizer exponents") + self.U, self.radius = sum(self.normalizer_bits), radius + self.bound = sum(Q(ref.spec.alpha ** 2, 4) for ref in self.references) + self.length = ceiling(8 * self.bound) + need(completed_bits - self.U >= self.length, "funded actual remaining-diagonal contraction") + self.bits = self.incoming = bits + self.array_bits, self.axis_bits, self.axes = layout.n, layout.h, 1 + self.coarse_bits = layout.n - layout.h + self.radius_bits = ceil_log2(radius) + (layout.n + 1) // 2 + self.data_width = bits + self.radius_bits + 2 + self.factor_width = self.cache_width = bits + 2 + self.temporary_width = 2 * self.data_width + 3 + self.stages, self.h_count, self.diagonal_count = 1, 0, 1 + self.reference_seal = self.source_seal() + scale = Q(1, 1 << (completed_bits - self.U)) + self.receipts, page = [], [] + for index in range(1 << layout.h): + coordinates = layout.coordinates(index) + exponent = Q(0) + for ref, k in zip(self.references, coordinates): + source = ref.source_at.get(k) + if source is not None: + exponent += ref.spec.alpha ** 2 * ref.betas[source] ** 2 + box = self.references[0].exp.relative(exponent, self.bound, bits + 4) + need(box["lower"] > 0, "positive retained Gaussian enclosure") + lower, upper = scale / box["upper"], scale / box["lower"] + value = upper_grid(lower, upper, bits) + page.append((value, 0)) + self.receipts.append(dict(coordinates=coordinates, exponent=exponent, lower=lower, + upper=upper, value=value, precision=box["precision"], + working_bits=box["working_bits"])) + self.page = tuple(page) + self.receipts = tuple(self.receipts) + self.page_seal = sha256(repr(self.page).encode()).hexdigest() + self.allocation_seal = self.allocation() + self.validate() + + def source_seal(self): + rows = [] + for a, ref, u in zip(self.layout.selected, self.references, self.normalizer_bits): + need(type(ref) is self.Reference and ref.target_size == 1 << self.layout.lengths[a], + "same actual Reference and full original target axis") + need(ref.narrow_gap > 0 and (1 << u) * ref.narrow_gap >= 1, + "same admitted narrow inverse normalizer") + spec = {key: getattr(ref.spec, key) for key in ref.spec.__dataclass_fields__} + need(sha256(json.dumps(spec, sort_keys=True).encode()).hexdigest() == ref.description_hash, + "unchanged immutable reference specification") + S, e, N = ref.spec.source_size, ref.spec.excess, ref.target_size + need(N == S + e, "unchanged original target period") + source_map = [] + for k in range(N): + j = ref.source_at.get(k) + candidate = (2 * S * k + N) // (2 * N) + phi = (2 * e * candidate + S) // (2 * S) + expected = candidate if 0 <= candidate < S and candidate + phi == k else None + need(j == expected, "literal original selected-coordinate map") + if j is not None: + beta = Q(e * j, S) - (2 * e * j + S) // (2 * S) + need(ref.betas[j] == beta and abs(beta) <= Q(1, 2), "literal original beta") + source_map.append(j) + rows.append((id(ref), ref.description_hash, u, tuple(source_map))) + return tuple(rows) + + def allocation(self): + names = ("normalizer_bits", "layout", "completed_bits", "U", "radius", "bound", "length", + "bits", "incoming", "array_bits", "axis_bits", "axes", "coarse_bits", "radius_bits", + "data_width", "factor_width", "cache_width", "temporary_width", "stages", "h_count", + "diagonal_count") + return tuple(getattr(self, name) for name in names) + + def validate(self): + need(self.allocation() == self.allocation_seal, "unchanged complete remaining-diagonal allocation") + need(self.source_seal() == self.reference_seal, "unchanged same-reference source binding") + need(sha256(repr(self.page).encode()).hexdigest() == self.page_seal, + "unchanged certified remaining coefficient period") + need(len(self.page) == 1 << self.layout.h and + all(type(a) is int and 0 <= a <= 1 << self.bits and b == 0 for a, b in self.page), + "contractive real common-grid coefficient page") + + def events(self): + self.validate() + # Full original spectator pages are explicitly emitted and paid. + pages = ((self.page,),) * (1 << self.coarse_bits) + yield self.Diagonal(0, self.coarse_bits, self.axis_bits, 1, self.bits, self.data_width, + self.factor_width, self.cache_width, self.temporary_width, pages) + + def record(self): + return dict(original_axis_bits=self.layout.lengths, selected_axes=self.layout.selected, + full_group_bits=self.layout.h, records=1 << self.layout.n, U=self.U, + completed_bits=self.completed_bits, grid=self.bits, radius=self.radius, + radius_bits=self.radius_bits, data_width=self.data_width, + coefficient_stock=len(self.page), original_description_hashes= + [r.description_hash for r in self.references], page_sha256=self.page_seal) diff --git a/research/source-remaining-diagonal/diagonal_owner.py b/research/source-remaining-diagonal/diagonal_owner.py new file mode 100644 index 0000000000..c8eb1a3c9c --- /dev/null +++ b/research/source-remaining-diagonal/diagonal_owner.py @@ -0,0 +1,170 @@ +"""Original-coordinate routes around one unchanged physical Full D event. + +Explicit new owner ABI; no synthetic FullRoot or payload callback is used. +Prepared for @CubeJerry with substantial OpenAI assistance. Apache-2.0. +The ownership/route pattern is credited to the published complete Core join. +""" +from cardinal_counts import Count +from compact_counts import append_bits +from encoded import compare +from records import Tape +from router_metadata import owned +from session import (borrowed_count, borrowed_tape, erase_marker, sealed_constructors) +from words import BLANK, LEFT, need +from global_h_boundary import GlobalBoundary +from physical_engine import NullCounters, private_tapes +from physical_controls import emit_unsigned +from join_engine import FastFullPhysical + + +def origin(tape): + """Check a borrowed head is immediately right of its actual left marker.""" + need(tape.read() != LEFT, "remaining-diagonal borrowed head at origin") + tape.step(-1) + try: + need(tape.read() == LEFT, "remaining-diagonal borrowed head at origin") + finally: + tape.step(1) + + +class RemainingOwner(GlobalBoundary): + def __init__(self, root, observe=None): + super().__init__(root) + self.diagonal = FastFullPhysical(root, observe=observe) + if observe is None: + self.calls = NullCounters(self.calls) + self.pending = False + self.private = private_tapes(self) + + def idle(self): + super().idle() + if hasattr(self, "diagonal"): + self.diagonal.idle() + need(self.diagonal.closed and self.diagonal.output.read() == BLANK, + "consumed remaining-diagonal child") + + def consume(self): + need(self.closed and self.pending, "protected remaining-diagonal return") + self.output.clear() + erase_marker(self.output) + self.pending = False + self.idle() + + def run(self, payload, forward, inverse, route_parameters, code, parameters): + data = tuple(borrowed_tape(t) for t in (payload, forward, inverse, code)) + payload, forward, inverse, code = data + rp = tuple(borrowed_count(x) for x in route_parameters) + fp = tuple(borrowed_count(x) for x in parameters) + need(len(rp) == 4 and len(fp) == 16, "complete remaining-diagonal route/control ports") + ports = (*data, *(x.tape for x in (*rp, *fp))) + need(len(set(data)) == len(data) and all(t not in self.private for t in ports) + and all(x.tape not in data for x in (*rp, *fp)), + "external remaining-diagonal source/control ports") + need(not self.pending, "consume previous remaining-diagonal return") + for tape in ports: + origin(tape) + self.rearm() + succeeded = False + try: + with sealed_constructors(), self.scope.installed(): + n, precision, support, pw = rp + need(compare(n, fp[0]) == 0 and compare(fp[5], fp[10]) == 0, + "same original/packed full field and unchanged grid carrier") + with owned(Count.literal(1)) as (one,): + self.current = self.pool.acquire() + append_bits(payload, self.current) + payload.rewind() + self.current.rewind() + self.gather(forward, n, precision, support, pw, fp[5], one, one) + with self.scope.suspended(): + returned = self.diagonal.run(self.current, code, *fp) + following = self.pool.acquire() + try: + append_bits(returned, following) + finally: + returned.clear() + erase_marker(returned) + self.current.clear() + self.current = following + self.current.rewind() + self.gather(inverse, n, precision, support, pw, fp[5], one, one) + append_bits(self.current, self.output) + self.current.clear() + self.current = None + self.pool.empty() + succeeded = self.pending = True + finally: + if self.diagonal.closed and self.diagonal.output.read() != BLANK: + self.diagonal.output.clear() + erase_marker(self.diagonal.output) + if self.current is not None: + self.current.clear() + self.current = None + self.pool.empty() + for tape in ports: + tape.rewind() + for tape in self.pool.tapes: + erase_marker(tape) + self.output.rewind() + if not succeeded: + self.output.clear() + erase_marker(self.output) + self.pending = False + self.closed = True + return self.output + + +class PreparedRoutes: + def __init__(self, layout, width): + self.forward, self.inverse = Tape(), Tape() + pw = max(1, (layout.n - 1).bit_length()) + for tape, mapping in ((self.forward, layout.gather), (self.inverse, layout.inverse)): + for old, new in sorted(mapping.items()): + emit_unsigned(tape, old, pw) + emit_unsigned(tape, new, pw) + tape.rewind() + self.parameters = tuple(Count.literal(x) for x in + (layout.n, width + layout.h, len(layout.gather), pw)) + + def close(self): + for value in self.parameters: + value.close() + erase_marker(value.tape) + for tape in (self.forward, self.inverse): + tape.clear() + erase_marker(tape) + + +class BoundRemaining: + """Protected external q-grid return, with exactly zero extra normalization.""" + def __init__(self, codec, owner, routes, prepared): + need(codec.fmt.drop == codec.fmt.lift == codec.fmt.normalizer_bits == 0, + "remaining diagonal keeps external q grid without another scale") + need(codec.fmt.native_grid == prepared.metadata["fractional_bits"] + == prepared.metadata["incoming_bits"] and codec.fmt.native_bits + == prepared.metadata["data_width"] == prepared.metadata["incoming_width"], + "actual remaining-diagonal source and codec formats agree") + self.codec, self.owner, self.routes, self.prepared = codec, owner, routes, prepared + self.pending = False + + def run(self, source): + need(not self.pending, "consume previous external remaining-diagonal output") + succeeded = False + try: + payload = self.codec.prepare_input(source) + returned = self.owner.run(payload, self.routes.forward, self.routes.inverse, + self.routes.parameters, self.prepared.code, self.prepared.parameters) + self.codec.prepare_return(returned, source) + self.owner.consume() + succeeded = self.pending = True + return self.codec.output + finally: + if self.owner.pending: + self.owner.consume() + if not succeeded: + self.codec.abort() + + def consume(self): + need(self.pending, "protected external remaining-diagonal return") + self.codec.abort() + self.pending = False diff --git a/research/source-remaining-diagonal/diagonal_sources.py b/research/source-remaining-diagonal/diagonal_sources.py new file mode 100644 index 0000000000..2f43b557b6 --- /dev/null +++ b/research/source-remaining-diagonal/diagonal_sources.py @@ -0,0 +1,98 @@ +"""Authenticate and open exact, unmodified source cohorts at their own paths. + +Prepared for @CubeJerry with substantial OpenAI assistance. Apache-2.0. +Mirrors contain hard links to authenticated read-only inputs, never patched code. +""" +from contextlib import contextmanager +from hashlib import sha1, sha256 +import importlib.util +import json +import os +from pathlib import Path +import sys +import tempfile + +HERE = Path(__file__).resolve().parent +ROOT = HERE.parents[1] + + +def need(condition, message): + if not condition: + raise ValueError(message) + + +def load(name, path): + need(name not in sys.modules, "cold remaining-diagonal source alias: " + name) + spec = importlib.util.spec_from_file_location(name, path) + module = importlib.util.module_from_spec(spec) + sys.modules[name] = module + try: + spec.loader.exec_module(module) + except BaseException: + sys.modules.pop(name, None) + raise + return module + + +def authenticate(): + files = json.loads((HERE / "SOURCES.json").read_text())["files"] + retained = json.loads((HERE / "DEPENDENCIES.json").read_text())["files"] + checked = {} + for row in files + retained: + key = row.get("retained_path", row.get("path")) + path = HERE / key if "retained_path" in row else ROOT / key + need(path.is_file() and not path.is_symlink(), "regular authenticated input: " + key) + raw = path.read_bytes() + need(sha256(raw).hexdigest() == row["sha256"] and + sha1(b"blob " + str(len(raw)).encode() + b"\0" + raw).hexdigest() == row["git_blob"], + "exact remaining-diagonal input: " + key) + checked[key] = row["sha256"] + return checked + + +@contextmanager +def references(): + authenticate() + names = ("exact", "engine", "triangular", "generator", "full", "gaussian", "gaussian_reference") + modules = {} + try: + for name in names: + modules[name] = load(name, ROOT / "research/rational-unitary-fft" / (name + ".py")) + yield modules["gaussian_reference"], { + "research/certified-gaussian-recovery/intervals.py": + (ROOT / "research/certified-gaussian-recovery/intervals.py").read_bytes() + } + finally: + for name, module in modules.items(): + if sys.modules.get(name) is module: + del sys.modules[name] + + +@contextmanager +def native(): + """Preserve original relative paths and original authentication/ROOT logic.""" + authenticate() + with tempfile.TemporaryDirectory(prefix="remaining-diagonal-sources-") as directory: + mirror = Path(directory) + for row in json.loads((HERE / "retained/fft/SOURCES.json").read_text())["files"]: + if row["usage"] == "input": + destination = mirror / row["path"] + destination.parent.mkdir(parents=True, exist_ok=True) + os.link(ROOT / row["path"], destination) + package = mirror / "research/full-fft-scalar-join" + for path in sorted((HERE / "retained/fft").rglob("*")): + if path.is_file(): + destination = package / path.relative_to(HERE / "retained/fft") + destination.parent.mkdir(parents=True, exist_ok=True) + os.link(path, destination) + name = "remaining_exact_fft_sources" + module = load(name, package / "join_sources.py") + try: + yield module + finally: + sys.modules.pop(name, None) + + +def bridge(): + return (load("remaining_external_tapes", HERE / "retained/bridge/tapes.py"), + load("remaining_exact_codec", HERE / "retained/bridge/boundary_codec.py")) diff --git a/research/source-remaining-diagonal/evidence/LEAD-REVIEW.json b/research/source-remaining-diagonal/evidence/LEAD-REVIEW.json new file mode 100644 index 0000000000..0703b7b3d5 --- /dev/null +++ b/research/source-remaining-diagonal/evidence/LEAD-REVIEW.json @@ -0,0 +1,13 @@ +{ + "status": "reviewed-with-stated-contracts", + "reviewer": "lead orchestrator /root", + "method": "Code-assisted exact Fraction checks plus direct universal proof/source review; no worker verifier import for the reported independent calculations.", + "not_human_or_kernel_acceptance": true, + "quantizer_cases": 7992, + "quantizer_failures": 0, + "lower_floor_failures": 3490, + "quantizer_domain": "q=1..9; A=i/73; 11-offset enclosure positions", + "exact_route_margin": "359861082749999999999999667647/332929000000000000000000000000000000", + "accumulator_margin": "2*ceil(n_addr/2)-n_addr+7 >= 7", + "source": "Lead review messages in this run, 2026-11-09; proof/source code reviewed before final package gates." +} diff --git a/research/source-remaining-diagonal/evidence/REPLAY.json b/research/source-remaining-diagonal/evidence/REPLAY.json new file mode 100644 index 0000000000..6184ab51f0 --- /dev/null +++ b/research/source-remaining-diagonal/evidence/REPLAY.json @@ -0,0 +1,139 @@ +{ + "coefficient": { + "coefficient_entries": 272, + "independent_grid_trajectories": 1904, + "negative_controls": 9, + "programs": [ + { + "U": 1, + "coefficient_stock": 16, + "completed_bits": 9, + "data_width": 19, + "full_group_bits": 4, + "grid": 12, + "original_axis_bits": [ + 1, + 4 + ], + "original_description_hashes": [ + "bebbf77ee04f9030f72db994385c36a27992a20dac55b8707d4d64ec82ad792c" + ], + "page_sha256": "cab9598fc9fda75b1a633741c2f703f919c1a4aa195eba4752741285931673e1", + "radius": 3, + "radius_bits": 5, + "records": 32, + "selected_axes": [ + 1 + ] + }, + { + "U": 2, + "coefficient_stock": 256, + "completed_bits": 18, + "data_width": 21, + "full_group_bits": 8, + "grid": 12, + "original_axis_bits": [ + 4, + 1, + 4 + ], + "original_description_hashes": [ + "bebbf77ee04f9030f72db994385c36a27992a20dac55b8707d4d64ec82ad792c", + "bebbf77ee04f9030f72db994385c36a27992a20dac55b8707d4d64ec82ad792c" + ], + "page_sha256": "94237ffd729eacd6adfb445ee516631f5444210999573171ac63ad609b893a9f", + "radius": 3, + "radius_bits": 7, + "records": 512, + "selected_axes": [ + 2, + 0 + ] + } + ], + "rational_quantizer_cases": 1998 + }, + "physical": { + "accumulator_margin_bits": 8, + "authenticated_native_imports": 129, + "codec_drop": 0, + "elapsed_seconds": 3.622, + "external_grid": 12, + "external_tapes": [ + { + "move": 5779, + "read": 5958, + "retained_cells": 16, + "write": 30 + }, + { + "move": 133, + "read": 198, + "retained_cells": 2, + "write": 2 + }, + { + "move": 778, + "read": 838, + "retained_cells": 7, + "write": 12 + }, + { + "move": 2584, + "read": 2630, + "retained_cells": 21, + "write": 40 + }, + { + "move": 133, + "read": 198, + "retained_cells": 2, + "write": 2 + }, + { + "move": 12031, + "read": 12351, + "retained_cells": 21, + "write": 6848 + }, + { + "move": 7935, + "read": 8127, + "retained_cells": 21, + "write": 3904 + }, + { + "move": 4095, + "read": 4223, + "retained_cells": 16, + "write": 2944 + }, + { + "move": 1989, + "read": 998, + "retained_cells": 994, + "write": 1986 + } + ], + "gathers": 2, + "input_sha256": "f00c63e20338668985d0edd0d8b2839790e160cbca2fd98bc9baa1e5074772d3", + "native_grid": 12, + "native_observations": { + "coarse_resets": 2, + "data_products": 32, + "initial_coefficients": 32, + "input_squares": 64 + }, + "negative_controls": 6, + "output_sha256": "8d1999f5d1619e2b8ba9877a2cb97dc1039d4e22b948b8cb51bc334b89140829", + "page_components": 64, + "parameter_positions_checked": 16, + "private_tape_roles": 6080, + "retained_native_cells": 30183, + "scalar_cutoff": 4096, + "scalar_products": 192 + }, + "source_inputs": 72, + "status": "PASS" +} diff --git a/research/source-remaining-diagonal/retained/bridge/boundary_codec.py b/research/source-remaining-diagonal/retained/bridge/boundary_codec.py new file mode 100644 index 0000000000..5fdbd993cc --- /dev/null +++ b/research/source-remaining-diagonal/retained/bridge/boundary_codec.py @@ -0,0 +1,298 @@ +"""Finite-control common-grid/normalization bridge for two actual tape codecs. + +Prepared for @CubeJerry with substantial OpenAI assistance. Apache-2.0. +Payload routines use only one-symbol reads/writes and unit head motion. Unary +format templates are prepared once; no payload integer or record counter is +decoded by these routines. Native numerical work belongs to the named service. +""" +from dataclasses import dataclass + + +def require(ok, message): + if not ok: + raise ValueError(message) + + +@dataclass(frozen=True) +class Format: + external_bits: int # one sign-magnitude real/imaginary component + external_grid: int + native_bits: int # one little-endian two's-complement component + native_grid: int + normalizer_bits: int # a_total = 2**normalizer_bits + + def __post_init__(self): + values = tuple(self.__dict__.values()) + require(all(type(x) is int for x in values), "integer format, not Boolean") + require(self.external_bits >= 2 and self.external_grid >= 0, + "positive external magnitude carrier") + require(self.native_grid >= self.external_grid and self.normalizer_bits >= 0, + "exact incoming grid lift and nonnegative dyadic normalizer") + require(self.native_bits >= self.external_bits + self.lift, + "complete native sign and lifted external magnitude") + + @property + def lift(self): + return self.native_grid - self.external_grid + + @property + def drop(self): + return self.native_grid + self.normalizer_bits - self.external_grid + + +class Codec: + """Constant owned roles, shared immutable unary formats, protected output. + + B is exactly the retained first-face transport module. Native tape methods + are those of the retained Core Tape class. Lifecycle marker operations are + the actual native session operations. These are source-model parameters, + never numerical callbacks. The online code has finite-valued local state. + """ + + def __init__(self, B, NativeTape, blank, initialize_marker, erase_marker, fmt): + self.B = B + self.blank = blank + self.initialize_marker = initialize_marker + self.erase_marker = erase_marker + # This input-independent setup is charged; no role is made per record. + self.magnitude_clock = B.Tape("bridge magnitude clock") + self.lift_clock = B.Tape("bridge lift clock") + self.pad_clock = B.Tape("bridge pad clock") + self.native_clock = B.Tape("bridge native clock") + self.drop_clock = B.Tape("bridge drop clock") + self.raw = B.Tape("bridge raw component") + self.absolute = B.Tape("bridge absolute component") + self.magnitude = B.Tape("bridge final magnitude") + self.output = B.Tape("bridge protected normalized field") + self.input = NativeTape() + erase_marker(self.input) + self.pending = False + self.active = False + self.input_armed = False + self.reconfigure(fmt) + + @property + def templates(self): + return (self.magnitude_clock, self.lift_clock, self.pad_clock, + self.native_clock, self.drop_clock) + + @property + def work(self): + return (self.raw, self.absolute, self.magnitude, self.output) + + def reconfigure(self, fmt): + """Rebuild formats in the same roles; old visited blanks stay charged.""" + require(not self.active and not self.pending and not self.input_armed, + "quiescent bridge format change") + lengths = (fmt.external_bits - 1, fmt.lift, + fmt.native_bits - fmt.lift - fmt.external_bits + 1, + fmt.native_bits, fmt.drop) + for tape, length in zip(self.templates, lengths): + self.B.clear(tape) + for _ in range(length): + self.B.append(tape, "1") + self.B.home(tape) + self.fmt = fmt + + def bbit(self, tape): + bit = tape.read() + require(bit in ("0", "1"), "complete binary external component") + tape.move(1) + return bit == "1" + + def cbit(self, tape): + bit = tape.read() + require(bit in (0, 1), "complete binary native component") + tape.step(1) + return bit == 1 + + def lift_component(self, source): + B = self.B + sign = self.bbit(source) + any_one = False + B.clear(self.raw) + B.home(self.magnitude_clock) + while self.magnitude_clock.read() == "1": + bit = self.bbit(source) + any_one = any_one or bit + B.append(self.raw, "1" if bit else "0") + self.magnitude_clock.move(1) + require(not sign or any_one, "canonical external zero sign") + B.home(self.lift_clock) + while self.lift_clock.read() == "1": + self.input.append(0) + self.lift_clock.move(1) + # raw is at its right terminator: read magnitude from least significant. + self.raw.move(-1) + carry = sign + while self.raw.read() != "^": + bit = self.raw.read() == "1" + bit = not bit if sign else bit + self.input.append(int(bit != carry)) + carry = bit and carry + self.raw.move(-1) + B.home(self.pad_clock) + while self.pad_clock.read() == "1": + bit = sign + self.input.append(int(bit != carry)) + carry = bit and carry + self.pad_clock.move(1) + B.clear(self.raw) + + def prepare_input(self, source): + """Lift the complete immutable external stream, exactly and in order.""" + B = self.B + require(not self.active and not self.pending, "idle source bridge") + require(source not in (*self.templates, *self.work), "external source owner") + self.active = True + self.initialize_marker(self.input) + self.input_armed = True + B.home(source) + try: + while source.read() != "!": + self.lift_component(source) + self.lift_component(source) + require(source.read() == "#", "one complete complex source record") + source.move(1) + self.input.rewind() + except BaseException: + self.abort() + raise + finally: + B.home(source) + return self.input + + def return_component(self, returned): + B = self.B + B.clear(self.raw) + B.home(self.native_clock) + sign = False + while self.native_clock.read() == "1": + sign = self.cbit(returned) + B.append(self.raw, "1" if sign else "0") + self.native_clock.move(1) + # Last native bit is the sign. Absolute value is formed without decoding. + B.home(self.raw) + B.clear(self.absolute) + carry = sign + while self.raw.read() != "!": + bit = self.raw.read() == "1" + bit = not bit if sign else bit + B.append(self.absolute, "1" if bit != carry else "0") + carry = bit and carry + self.raw.move(1) + B.home(self.absolute) + B.home(self.drop_clock) + while self.drop_clock.read() == "1" and self.absolute.read() != "!": + self.drop_clock.move(1) + self.absolute.move(1) + B.clear(self.magnitude) + B.home(self.magnitude_clock) + any_one = False + while self.magnitude_clock.read() == "1": + bit = self.absolute.read() == "1" + any_one = any_one or bit + B.append(self.magnitude, "1" if bit else "0") + if self.absolute.read() != "!": + self.absolute.move(1) + self.magnitude_clock.move(1) + while self.absolute.read() != "!": + require(self.absolute.read() == "0", "normalized return fits external magnitude") + self.absolute.move(1) + B.append(self.output, "1" if sign and any_one else "0") + self.magnitude.move(-1) + while self.magnitude.read() != "^": + B.append(self.output, self.magnitude.read()) + self.magnitude.move(-1) + for tape in (self.raw, self.absolute, self.magnitude): + B.clear(tape) + + def prepare_return(self, returned, source): + """Normalize once, round toward zero, preserve input, check full count. + + The unchanged original stream supplies the record clock. This avoids a + host record counter and checks that the native field has the same size. + """ + B = self.B + require(self.active and not self.pending, "one active bridge input") + B.clear(self.output) + B.home(source) + returned.rewind() + try: + while source.read() != "!": + for _ in (0, 1): + self.bbit(source) + B.home(self.magnitude_clock) + while self.magnitude_clock.read() == "1": + self.bbit(source) + self.magnitude_clock.move(1) + self.return_component(returned) + require(source.read() == "#", "unchanged complete input record clock") + source.move(1) + B.append(self.output, "#") + require(returned.read() == self.blank, "no extra native output records") + B.home(self.output) + self.pending = True + except BaseException: + B.clear(self.output) + raise + finally: + B.home(source) + returned.rewind() + return self.output + + def commit(self, transport): + """Commit only a complete normalized return after the saved-copy phase.""" + B = self.B + require(self.active and self.pending and transport.phase == "saved", + "saved originals and complete protected Core return") + require(transport.source not in (*self.templates, *self.work), + "distinct destination source owner") + # No validation remains after this point: a whole sequential clone. + B.clone(self.output, transport.source) + B.home(transport.source) + transport.phase = "core" + self.abort() + + def abort(self): + """Erase owned payloads; retained extent and immutable templates remain.""" + B = self.B + if self.input_armed: + self.input.clear() + self.erase_marker(self.input) + self.input_armed = False + for tape in self.work: + B.clear(tape) + for tape in self.templates: + B.home(tape) + self.active = self.pending = False + + +class BoundCore: + """The concrete Core run/consume protocol, without a payload callback. + + `core` is the pinned OriginalCore (or the independently scoped CompleteCore + packed boundary); its prepared immutable source ports are `arguments`. + The all-size source theorem determines which boundary is being invoked. + """ + + def __init__(self, codec, core, arguments): + self.codec = codec + self.core = core + self.arguments = tuple(arguments) + + def run(self, transport): + require(transport.phase == "saved", "halo copies precede actual Core") + succeeded = False + try: + payload = self.codec.prepare_input(transport.source) + returned = self.core.run(payload, *self.arguments) + self.codec.prepare_return(returned, transport.source) + self.core.consume() + self.codec.commit(transport) + succeeded = True + finally: + if getattr(self.core, "pending", False): + self.core.consume() + if not succeeded: + self.codec.abort() diff --git a/research/source-remaining-diagonal/retained/bridge/tapes.py b/research/source-remaining-diagonal/retained/bridge/tapes.py new file mode 100644 index 0000000000..b3dfa43ba0 --- /dev/null +++ b/research/source-remaining-diagonal/retained/bridge/tapes.py @@ -0,0 +1,644 @@ +"""Sequential bit-tape halo transport; no numerical halo solver is hidden here. + +Only Tape's simulator backend uses positions or random-access storage. Program +methods observe one symbol, write one symbol, or move one cell. Python locals +in those methods range over finite alphabets/booleans, except fixed tape handles. +Fixture construction, inspection, and instrumentation are outside the machine. +""" + +from collections import Counter + + +class Reject(ValueError): + pass + + +class Tape: + """Simulator backend. Erased cells still count toward retained backing.""" + + def __init__(self, name, contents=""): + self.name = name + self._cells = dict(enumerate("^" + contents + "!")) + self._head = 0 + self._high = len(contents) + 1 + self.actions = Counter() + + def read(self): + self.actions["read"] += 1 + return self._cells.get(self._head, "_") + + def write(self, symbol): + if len(symbol) != 1: + raise Reject("non-symbol write") + self.actions["write"] += 1 + self._cells[self._head] = symbol + self._high = max(self._high, self._head) + + def move(self, direction): + if direction not in (-1, 1): + raise Reject("nonunit head move") + self.actions["move"] += 1 + self._head += direction + if self._head < 0: + raise Reject("crossed left sentinel") + self._high = max(self._high, self._head) + + def inspect(self): + """Unmetered *test observer*: never called by Program or its helpers.""" + chars = [] + pos = 1 + while self._cells.get(pos) != "!": + chars.append(self._cells.get(pos, "_")) + pos += 1 + if pos > self._high: + raise Reject("observer found no terminator") + return "".join(chars) + + def bill(self): + return {**self.actions, "retained_cells": self._high + 1} + + +def home(t): + while t.read() != "^": + t.move(-1) + t.move(1) + + +def end(t): + while t.read() != "!": + t.move(1) + + +def append(t, ch): + # Caller owns the right-end head. No length or append index is available. + t.write(ch) + t.move(1) + t.write("!") + + +def clear(t): + home(t) + while t.read() != "!": + t.write("_") + t.move(1) + t.write("_") + home(t) + t.write("!") + + +def copy_bits(src, dst): + while src.read() in "01": + append(dst, src.read()) + src.move(1) + + +def copy_whole(src, dst): + home(src) + while src.read() != "!": + append(dst, src.read()) + src.move(1) + + +def clone(src, dst): + clear(dst) + copy_whole(src, dst) + + +def skip_to(t, ch): + while t.read() != ch: + if t.read() == "!": + raise Reject("missing field delimiter") + t.move(1) + + +def compare(a, b): + """Equal-width unsigned binary comparison; result is a three-state value.""" + home(a) + home(b) + relation = "equal" + while a.read() != "!": + if b.read() not in "01" or a.read() not in "01": + raise Reject("unequal or malformed comparison fields") + if relation == "equal": + if a.read() == "0" and b.read() == "1": + relation = "less" + elif a.read() == "1" and b.read() == "0": + relation = "greater" + a.move(1) + b.move(1) + if b.read() != "!": + raise Reject("unequal comparison widths") + return relation + + +def add_mod(a, b, subtract=False): + """Binary ripple addition/subtraction, truncated to the common field width.""" + home(a) + end(a) + home(b) + end(b) + a.move(-1) + b.move(-1) + carry = subtract + while a.read() != "^": + x = a.read() == "1" + y = b.read() == "1" + if b.read() not in "01": + raise Reject("unequal arithmetic widths") + if subtract: + y = not y + a.write("1" if x ^ y ^ carry else "0") + carry = (x and y) or (carry and (x or y)) + a.move(-1) + b.move(-1) + if b.read() != "^": + raise Reject("unequal arithmetic widths") + + +def step_binary(t, down=False): + """Modulo 2**width increment/decrement of a plain binary field.""" + home(t) + end(t) + t.move(-1) + while t.read() != "^": + old = t.read() + t.write("0" if old == "1" else "1") + if (old == "1") == down: + return + t.move(-1) + + +def coordinate_next(t): + """Increment concatenated coordinate bits, skipping only schema delimiters.""" + home(t) + end(t) + t.move(-1) + carrying = True + while t.read() != "^": + if t.read() in "01" and carrying: + if t.read() == "0": + t.write("1") + carrying = False + else: + t.write("0") + t.move(-1) + return not carrying + + +def flatten(t, dst): + clear(dst) + home(t) + while t.read() != "!": + if t.read() in "01": + append(dst, t.read()) + t.move(1) + + +class Program: + """A fixed collection of tape roles, independent of dimension or volume.""" + + def __init__(self, source, coordinates, length, width_a, width_b, returns=""): + # Loading caller-supplied binary inputs is outside the program's bill; + # their cells are included in retained backing from the beginning. + self.source = Tape("source", source) + self.x = Tape("coordinates", coordinates) + self.L = Tape("L", length) + self.A = Tape("A", width_a) + self.b = Tape("b", width_b) + self.returns = Tape("returns", returns) + self.saved = Tape("saved") + self.final = Tape("final") + self.d = Tape("descriptor") + self.faces = Tape("faces") + self.unary = Tape("axis_index") + self.q = Tape("core_field") + self.r = Tape("local_field") + self.payload = Tape("payload") + self.kcore = Tape("key_core") + self.kface = Tape("key_face") + self.klocal = Tape("key_local") + self.ksource = Tape("key_source") + self.retkey = Tape("return_key") + self.retval = Tape("return_value") + self.bucket0 = Tape("radix_zero") + self.bucket1 = Tape("radix_one") + self.record = Tape("radix_record") + self.passes = Tape("radix_passes") + self.Am = Tape("A_minus_b") + self.Ap = Tape("A_plus_b") + self.LAm = Tape("L_minus_A_minus_b") + self.LAp = Tape("L_minus_A_plus_b") + self.Lb = Tape("L_minus_b") + self.LA = Tape("L_minus_A") + # This tuple is a fixed schema, never sized using input data. + self.roles = ( + self.source, self.x, self.L, self.A, self.b, self.returns, + self.saved, self.final, self.d, self.faces, self.unary, self.q, + self.r, self.payload, self.kcore, self.kface, self.klocal, + self.ksource, self.retkey, self.retval, self.bucket0, self.bucket1, + self.record, self.passes, self.Am, self.Ap, self.LAm, self.LAp, + self.Lb, self.LA, + ) + self.phase = "input" + + def setup(self): + clone(self.A, self.Am) + add_mod(self.Am, self.b, subtract=True) + clone(self.A, self.Ap) + add_mod(self.Ap, self.b) + clone(self.L, self.LA) + add_mod(self.LA, self.A, subtract=True) + clone(self.LA, self.LAm) + add_mod(self.LAm, self.b, subtract=True) + clone(self.LA, self.LAp) + add_mod(self.LAp, self.b) + clone(self.L, self.Lb) + add_mod(self.Lb, self.b, subtract=True) + + def load_payload(self, source, dest): + clear(dest) + copy_bits(source, dest) + if source.read() != "#": + raise Reject("bad payload delimiter") + source.move(1) + + def face_record(self, side): + home(self.unary) + copy_bits(self.unary, self.faces) + append(self.faces, "0") + append(self.faces, side) + append(self.faces, "#") + + def build_descriptor(self): + clear(self.d) + clear(self.faces) + clear(self.unary) + clear(self.ksource) + home(self.x) + while self.x.read() != "&": + append(self.d, self.x.read()) + append(self.ksource, self.x.read()) + self.x.move(1) + append(self.d, "&") + self.x.move(1) + prefix = True + while self.x.read() != "!": + if self.x.read() != "@": + raise Reject("bad coordinate schema") + append(self.d, "@") + self.x.move(1) + while self.x.read() != "#": + append(self.d, self.x.read()) + append(self.ksource, self.x.read()) + self.x.move(1) + append(self.d, "#") + self.x.move(1) + clear(self.r) + append(self.r, "0") + append(self.r, "0") + while self.x.read() != ";": + append(self.r, self.x.read()) + append(self.ksource, self.x.read()) + self.x.move(1) + self.x.move(1) + copy_whole(self.r, self.d) + append(self.d, "#") + interior = compare(self.r, self.Am) != "less" + interior = interior and compare(self.r, self.LAp) == "less" + low = compare(self.r, self.b) == "less" + high = compare(self.r, self.Lb) != "less" + lower = compare(self.r, self.Ap) == "less" + upper = compare(self.r, self.LAm) != "less" + append(self.d, "1" if interior else "0") + append(self.d, "1" if low else "0") + append(self.d, "1" if high else "0") + append(self.d, "1" if lower else "0") + append(self.d, "1" if upper else "0") + append(self.d, "e" if low or high else "n") + append(self.d, "0") + append(self.d, ";") + if prefix and (lower or high): + self.face_record("0") + if prefix and (upper or low): + self.face_record("1") + prefix = prefix and interior + end(self.unary) + append(self.unary, "1") + + def prepare_face(self): + # Reset old face and suffix choices; all scans are through tape cells. + home(self.d) + skip_to(self.d, "&") + self.d.move(1) + while self.d.read() != "!": + self.d.write("@") + skip_to(self.d, "#") + self.d.move(1) + skip_to(self.d, "#") + self.d.move(1) + self.d.move(1) + self.d.move(1) + self.d.move(1) + self.d.move(1) + self.d.move(1) + if self.d.read() == "*": + self.d.write("e") + self.d.move(1) + self.d.write("0") + self.d.move(1) + self.d.move(1) + home(self.d) + skip_to(self.d, "&") + self.d.move(1) + while self.faces.read() == "1": + skip_to(self.d, ";") + self.d.move(1) + self.faces.move(1) + if self.faces.read() != "0": + raise Reject("bad face index") + self.faces.move(1) + self.d.write("<" if self.faces.read() == "0" else ">") + self.faces.move(1) + if self.faces.read() != "#": + raise Reject("bad face delimiter") + self.faces.move(1) + skip_to(self.d, ";") + self.d.move(1) + while self.d.read() != "!": + skip_to(self.d, ";") + self.d.move(-1) + self.d.move(-1) + if self.d.read() == "e": + self.d.write("*") + self.d.move(1) + self.d.move(1) + self.d.move(1) + + def next_choice(self): + home(self.d) + end(self.d) + self.d.move(-1) + while self.d.read() != "^": + if self.d.read() == "*": + self.d.move(1) + if self.d.read() == "0": + self.d.write("1") + return True + self.d.write("0") + self.d.move(-1) + self.d.move(-1) + return False + + def emit(self): + clear(self.kcore) + clear(self.kface) + clear(self.klocal) + home(self.d) + while self.d.read() != "&": + append(self.kcore, self.d.read()) + self.d.move(1) + self.d.move(1) + after = False + side = "0" + while self.d.read() != "!": + marker = self.d.read() + self.d.move(1) + clear(self.q) + copy_bits(self.d, self.q) + self.d.move(1) + clear(self.r) + copy_bits(self.d, self.r) + self.d.move(1) + self.d.move(1) # interior flag + low = self.d.read() == "1" + self.d.move(1) + high = self.d.read() == "1" + self.d.move(1) + lower = self.d.read() == "1" + self.d.move(1) + upper = self.d.read() == "1" + self.d.move(1) # eligibility + self.d.move(1) + alternative = self.d.read() == "1" + self.d.move(1) + self.d.move(1) + if marker == "<": + side = "0" + append(self.kface, "1") + add_mod(self.r, self.b) + if not lower: + if not high: + raise Reject("inadmissible lower face") + step_binary(self.q) + add_mod(self.r, self.L, subtract=True) + after = True + elif marker == ">": + side = "1" + append(self.kface, "1") + add_mod(self.r, self.Ap) + if upper: + add_mod(self.r, self.L, subtract=True) + else: + if not low: + raise Reject("inadmissible upper face") + step_binary(self.q, down=True) + after = True + elif not after: + append(self.kface, "0") + add_mod(self.r, self.Am, subtract=True) + else: + append(self.kface, "0") + add_mod(self.r, self.b) + if alternative: + if low: + step_binary(self.q, down=True) + add_mod(self.r, self.L) + elif high: + step_binary(self.q) + add_mod(self.r, self.L, subtract=True) + else: + raise Reject("inadmissible suffix alternative") + copy_whole(self.q, self.kcore) + copy_whole(self.r, self.klocal) + append(self.kface, side) + copy_whole(self.kcore, self.saved) + copy_whole(self.kface, self.saved) + copy_whole(self.klocal, self.saved) + copy_whole(self.ksource, self.saved) + append(self.saved, "#") + copy_whole(self.payload, self.saved) + append(self.saved, "#") + + def gather(self): + if self.phase != "input": + raise Reject("gather must precede every core mutation") + self.setup() + home(self.source) + end(self.saved) + more = True + while self.source.read() != "!": + if not more: + raise Reject("more payloads than coordinates") + self.load_payload(self.source, self.payload) + self.build_descriptor() + home(self.faces) + while self.faces.read() != "!": + self.prepare_face() + self.emit() + while self.next_choice(): + self.emit() + more = coordinate_next(self.x) + if more: + raise Reject("fewer payloads than coordinates") + self.phase = "saved" + + def sort(self, tape, reverse_buckets=False): + """Stable binary LSD radix; rotate keys to expose each next digit. + + A unary pass clock is copied from the first key on tape. After exactly + that many right rotations, the complete key is restored. No host key + length, pass index, record array, integer key, or comparison sort occurs. + """ + clear(self.passes) + home(tape) + if tape.read() == "!": + return + while tape.read() in "01": + append(self.passes, "1") + tape.move(1) + if tape.read() != "#": + raise Reject("bad radix key") + home(self.passes) + while self.passes.read() == "1": + clear(self.bucket0) + clear(self.bucket1) + home(tape) + while tape.read() != "!": + clear(self.record) + last = "0" + while tape.read() in "01": + last = tape.read() + append(self.record, last) + tape.move(1) + if tape.read() != "#": + raise Reject("bad radix key delimiter") + append(self.record, "#") + tape.move(1) + copy_bits(tape, self.record) + if tape.read() != "#": + raise Reject("bad radix payload delimiter") + append(self.record, "#") + tape.move(1) + target = self.bucket0 if last == "0" else self.bucket1 + append(target, last) + home(self.record) + previous = self.record.read() + self.record.move(1) + while self.record.read() != "#": + append(target, previous) + previous = self.record.read() + self.record.move(1) + append(target, "#") + self.record.move(1) + copy_bits(self.record, target) + append(target, "#") + clear(tape) + if reverse_buckets: + copy_whole(self.bucket1, tape) + copy_whole(self.bucket0, tape) + else: + copy_whole(self.bucket0, tape) + copy_whole(self.bucket1, tape) + self.passes.write("0") + self.passes.move(1) + clear(self.bucket0) + clear(self.bucket1) + clear(self.record) + clear(self.passes) + + def core_complement_test_double(self): + """Physical mutation for chronology controls; not a Gaussian core.""" + if self.phase != "saved": + raise Reject("core mutation before copies are complete") + home(self.source) + while self.source.read() != "!": + if self.source.read() == "0": + self.source.write("1") + elif self.source.read() == "1": + self.source.write("0") + self.source.move(1) + self.phase = "core" + + def pending_return(self): + if self.returns.read() == "!": + clear(self.retkey) + clear(self.retval) + return False + self.load_payload(self.returns, self.retkey) + self.load_payload(self.returns, self.retval) + return True + + def discarded(self): + home(self.x) + skip_to(self.x, "&") + self.x.move(1) + boundary = False + while self.x.read() != "!": + skip_to(self.x, "#") + self.x.move(1) + clear(self.r) + append(self.r, "0") + append(self.r, "0") + copy_bits(self.x, self.r) + if compare(self.r, self.A) == "less": + boundary = True + if compare(self.r, self.LA) != "less": + boundary = True + if self.x.read() != ";": + raise Reject("bad coordinate local field") + self.x.move(1) + return boundary + + def merge_returns(self): + if self.phase != "core": + raise Reject("return requires completed core phase") + self.sort(self.returns) + home(self.returns) + pending = self.pending_return() + home(self.source) + clear(self.final) + more = True + while self.source.read() != "!": + if not more: + raise Reject("more core values than coordinates") + self.load_payload(self.source, self.payload) + flatten(self.x, self.ksource) + boundary = self.discarded() + relation = compare(self.retkey, self.ksource) if pending else "none" + if boundary: + if relation != "equal": + raise Reject("missing, duplicate, or misplaced boundary return") + copy_whole(self.retval, self.final) + pending = self.pending_return() + else: + if pending and relation != "greater": + raise Reject("duplicate or kept-row return") + copy_whole(self.payload, self.final) + append(self.final, "#") + more = coordinate_next(self.x) + if more or pending: + raise Reject("incomplete source cube or extra return") + self.phase = "returned" + + def erase_work(self): + if self.phase != "returned": + raise Reject("erase before return completion") + # Roles remain allocated. The ledger deliberately does not reset peaks. + for tape in self.roles: + if tape is not self.final: + clear(tape) + self.phase = "erased" + + def ledger(self): + """Observer, not part of the machine.""" + return {tape.name: tape.bill() for tape in self.roles} diff --git a/research/source-remaining-diagonal/retained/core/NUMERICS.md b/research/source-remaining-diagonal/retained/core/NUMERICS.md new file mode 100644 index 0000000000..44e5164ebc --- /dev/null +++ b/research/source-remaining-diagonal/retained/core/NUMERICS.md @@ -0,0 +1,568 @@ +# Numerical and complete-cost interface for the current finite Core + +Prepared for @CubeJerry with substantial OpenAI assistance. Apache-2.0. +This is the numerical part of the proposed physical join of the current-source +dense interior cohort #6899, the first inverse window #6908 and its complete +union router, and the supplied band action #6909. The Schur identity, generic +residual telescopes and individual provider estimates are inherited. The +contribution is their concrete common-source, actual-radius, precision, +signed-word and complete-cost compatibility. Source binding, literal execution +and controller review are separately required and reported by the integrated +physical package; the numerical interface by itself is not a physical closure. + +The primary implementation target is the narrow inverse. Section 8 scopes the +broad compatibility separately. All five selected assumptions and selected +frontier remain unchanged. No new kappa is claimed. Numerical source bodies +are inherited from the canonical commit +`7c49fe32c55de02c2c873655c804b16e4c3fef0a`; #6899 is pinned at +`61d86cbe25657af55b9463bd3f072b6cbf952638`, #6908 at +`9c6078ff36ae2110e6cc30ff69a9addbf5a47bf2`, #6909 at +`ad6a7bf2213130719e9bf2022d01a30c79638f17`, and the complete union router at +`CubeJerry/integer-mult-bounds@73f3ea9f5773d46113b7d7b1ec21724572de59e1`. +The integrated manifest supplies exact source bytes and their original notices. + +## 1. One immutable source and the actual five factors + +For each actual coarse context and selected axis take one canonical rational +Reference, an ordinary original-coordinate window, and one admitted interior +partition. The production-source case uses #6899's Partition, invoking the +unchanged Core.load_carve and Core.partition. An explicitly admitted small +partition is distinct from that production carve. It must preserve the source's +original phase, holes, cuts, absolute origin and each interior source_start. + +In interior/boundary order the exact original matrix is + +\[ + Q=\begin{pmatrix}A&B_0\\C_0&D\end{pmatrix},\qquad + F=D-C_0A^{-1}B_0. \tag{1} +\] + +A is the direct sum of all actual interior blocks, possibly empty. E consists +of J and every I coordinate incident to a nonzero original B0 or C0 entry. +E and J retain increasing original-coordinate order. Source setup checks the +complete partition, exact zero interactions between different interiors, original +band, source gap/norm and the actual compressed bands used by the providers. +The exact Schur coefficients are formed from this Reference, not from an online +approximate interior inverse. The sparse contract requires nonempty J; an empty +sparse substream makes no numerical call. + +The five narrow operations in **execution order** are: + +| Stage | Exact complete-axis operation | Provider | +| --- | --- | --- | +| 1 | `Dminus=diag(A^-1,I_J)` | #6899 stored interior inverse | +| 2 | `Tlower(u)_J=F^-1(u_J-C0 u_I)`, identity elsewhere | #6908 complete first inverse window and physical union router | +| 3 | `Dplus=diag(A,I_J)` | #6899 interior forward | +| 4 | `Tupper(u)_I=u_I-B0 u_J`, identity on J | #6909 supplied E-matrix `I-N_B` and complete union transport | +| 5 | `Dminus` | #6899 stored interior inverse | + +Here N_B has B0 only in I rows and J columns. In matrix multiplication order, +`Dminus Tupper Dplus Tlower Dminus=Q^-1`. Stage 2 must include the original +lower coupling shear at its actual input. F^-1 on the original boundary alone +does not implement it. + +This rounded schedule is not claimed to equal Core.execute bit for bit. +The actual global H/D implementation of a dense direct sum can round boundary +coordinates. Sparse stages must receive those actual values. Each error is +compared with the exact local map at the current input, then propagated through +exact later factors. No boundary reset, exact-state radius, commuting rounded +maps or Lipschitz bound for a rounded map is used. + +Let the complete field contain T=2^n complex records, with g selected axes and +common side L=2^m. It has K=T/L^g complete contexts. Each exact stage is the +direct sum over K contexts of the tensor product of its g axis factors. Dense +stages operate on the **whole T-record field**. Sparse stages traverse complete +contexts, updating their union records in increasing active-axis order before +restoring the complete field. Different-axis exact maps commute within a fixed +context; this identifies the exact tensor endpoint without commuting rounded +operations. Axis order and the dense/router reversal must be bound explicitly. + +## 2. Rational norm certificate and actual input radius + +Let h be a common dyadic integer at least one and at least every row sum and +column sum of `|Re entry|+|Im entry|` of all five exact local factor matrices, +over all actual contexts/axes. These are literal rational sums. They dominate +the usual complex row and column norms; current Reference entries are real. +Setup computes them exactly and rounds the maximum upward to a power of two. +Include the elementary broad factors of section 8 when enabled. Therefore + +\[ + \|M_{local}\|_2\le h, + \qquad \|M_{whole\ stage}\|_2\le H:=h^g. \tag{2} +\] + +This follows from the row/column bound on the Euclidean operator norm and the +tensor/direct-sum norm identities. It is a bound for each complete factor, +including the combined first sparse window, not a bound inferred from A alone. + +The actual incoming field x is on grid 2^-P0 and has `||x||_2<=R0=2^r0`. +If it differs from an ideal x0 by e0, the final comparison with the exact Core +at x0 retains the additional term H^5 e0. The present contract first bounds +the local error relative to the exact Core at the actual x. + +For tau=2^-t choose + +\[ + t_d=t+\lceil\log_2(10H^4)\rceil,\qquad \delta=2^{-t_d}, \tag{3} +\] + +and dyadic radii + +\[ + R_2\ge(H+1)^5(R_0+1),\qquad + R_*\ge2(h+1)^{g+1}(R_2+1). \tag{4} +\] + +Every dense call uses whole-field Euclidean radius R2; each sparse axis call +uses maximum complex-l1 radius R*. If a complete stage has defect at most +delta, its actual radius satisfies `r_next<=H r_current+delta`. Since +delta<=1, (4) covers all five inputs and outputs. During a sparse stage the +same recurrence with local h covers the partial axis applications. The extra +power in R* also covers the broad F micro-step. Finally +`max_i(|Re x_i|+|Im x_i|)<=sqrt(2)||x||_2<=2||x||_2`. +Internal inverse-pass states use their separate completed-residual bounds. +They are not bounded merely by the incoming R*. + +Dyadic radii are useful for setup accounting: their full numerator/denominator +description heights are their displayed exponents. Charging only log of the +value of an arbitrary rational radius would not charge its full description. + +## 3. Sparse error aggregated over the complete field + +Put `V2=2^ceil(n/2)` and choose + +\[ + q=t_d+\lceil\log_2(V_2 g h^{g-1})\rceil. \tag{5} +\] + +Require each sparse local axis call to have complex-l1 defect at most 2^-q +on every coordinate, evaluated at its actual input. Its complete-field residual +then has Euclidean norm at most V2 2^-q. Propagating realized residuals through +exact later axis factors gives + +\[ + \|\widehat S(u)-Su\|_2 + \le V_2\sum_{a=1}^g h^{g-a}2^{-q} + \le V_2g h^{g-1}2^{-q}\le\delta. \tag{6} +\] + +T and V2 include **all K contexts**. There is no error-budget reset at a new +context key. The union chronology supplies a complete E-line at its current +values. Outside E the map is identity; omitted rows cannot be sources of a +nonzero original coupling because E includes every such source coordinate. +Later sparse windows gather fresh values after the intervening dense stage. + +A second exact-suffix expansion for the five stages yields + +\[ + \|\widehat C(x)-Cx\|_2 + \le\sum_{j=1}^5 H^{5-j}\delta\le5H^4\delta\le\tau/2. \tag{7} +\] + +For an incoming approximation the bound is H^5 e0+tau/2. Across several axis +groups retain the corresponding actual group norms and error recurrence, or +fund each local target by its downstream exact norm product. The conversions +below are exact, so their defect is zero; an unimplemented conversion does not +receive a free allowance from the factor-two margin. + +## 4. Actual sparse admissions and scalar widths + +### 4.1 First narrow inverse window + +#6908 prepares the C0 shear and the exact Schur F from (1). It executes two +physical bidiagonal passes for the shear and two for F. Its staged rounding is +retained. For eta=2^(1-P), a pass uses exact diagonal-block norm a, preceding-block +norm c, full inverse norm M and + +\[ + c_0=ab+2a+1,\quad c_1=b[a(c+1)+1],\quad + K_{pass}=M(c_0+4Mc_1). \tag{8} +\] + +The producer checks `b eta<=1`, `c0 eta<=1`, `M c1 eta<=1/2`. The actual +completed states are bounded by 4MY and the local defect by Kpass eta Y. +For two passes the error is `eta(M2 K1+4M1 K2)Y`. +Let es be this shear error at R*. Its actual F input radius is +`Rs=(1+||C0||_infinity)R*+es`. If ef is the F-solve error at Rs, the complete +local defect is `||F^-1||_infinity es+ef`, checked against 2^-q. The earlier +dense error in both I and J is already part of the input; it is neither erased +nor charged twice inside es. + +One all-size sufficient allocation uses +`pbar=max(W+1,ceil(sqrt(1/(16 gap))),1)` and a dyadic block covering the actual +compressed shear/Schur bands, with `2<=b<=4 pbar`: + +\[ + P\ge\max(P_0,q+45+16\lceil\log_2\bar p\rceil+ + \lceil\log_2R_*\rceil),\qquad + w_I\ge P+52+16\lceil\log_2\bar p\rceil+ + \lceil\log_2R_*\rceil. \tag{9} +\] + +Increase the width to cover the largest encoded descriptor. The exact finite +producer also checks all input/state/coefficient and residual ranges, including +`Y+(c+b eta)4MY+eta`, against `2^(w_I-P-1)`. A sharper finite allocation is +valid only when these actual source inequalities pass, not because one payload +has a small final output. + +### 4.2 Upper negative shear + +Supply #6909 with G=I-N_B on E. Check its exact compressed half-band v and +the literal lifted support before coefficient rounding. The lift half-band is +`v_lift=max_{G_ij!=0}|2i-(2j+1)|<=2v+1`; the source preparer checks this actual +support. Choose a dyadic b>=max(2,v_lift). The simpler b>=max(2,2v+1) also +suffices. The proof needs the actual nilpotent lift to be block bidiagonal, +which follows from v_lift<=b; no artificial enlargement is necessary. If s is the +maximum number of nonzero G entries per row and Gamma>=||G||_infinity, its +actual staged return satisfies + +\[ + \|\widehat G(u)-Gu\|_*\le(sR_*+6)2^{-P}. \tag{10} +\] + +Sufficient precision and width are + +\[ + P\ge\max(P_0,q+\lceil\log_2(sR_*+6)\rceil+1),\qquad + w_A\ge P+2+\lceil\log_2(\max(1,\Gamma)(R_*+1))\rceil. \tag{11} +\] + +There are at most three effective truncations per real component in the +nilpotent lift. No one-shot rounding equivalence is assumed. Its stored-state +bound does not replace the larger seven-product operand width w+log2(b)+2, +internal width 2w+4log2(b)+4 or exact returned width 2w+log2(b)+2. + +## 5. Dense source accuracy, common grid and paid conversions + +Prepare each of the three actual dense programs for target td, radius R2 and +its stated stored direction. If Lambda bounds its exact local interior endpoints, +the actual #6899 source target is at least + +\[ + t_s=t_d+\lceil\log_2(8gR_2(\Lambda+1)^{g-1})\rceil. \tag{12} +\] + +The immutable Reference must already meet all resulting RawGaussian/Full +admissions. Increasing arithmetic precision cannot repair insufficient source +accuracy. Replacing the Reference between dense and sparse stages changes (1). +All strengthened source interval precision, original weights, exact inverses, +Full words, genuine idle words, pages and validation are charged as setup. + +The unchanged global allocation suffix checks its source telescope against +2^-td/8. Let A be its actual complete prefix product, E its endpoint product, +Dc its diagonal count and bcoef one plus the actual factor-entry bound. Its +arithmetic requirement is + +\[ + [8E D_c A^2g b_{coef}^{g-1}R_2+4EA D_cV_2]2^{-P} + \le2^{-t_d}/4. \tag{13} +\] + +Its actual minimum also checks the perturbed-prefix allowance. Choose P at +least P0, all three dense minima, and (9),(11). Invoke the real +`fractional_bits=P` interface, with incoming=P after the initial exact lift. +The source suffix validates its minimum and freezes all internal widths. The +complete dense defect is then strictly below 2^-td as needed in (7). + +The dense input width is W0=P+r2+2 where R2=2^r2. Its output is +`Wd=P+ceil(log2(4A(R2+1)))+2`. Factor, cache and product widths remain the +source's own frozen allocations. Choose common sparse w at least W0, all +actually certified sparse widths and descriptor guards; do not mutate a dense +allocation seal. It is sufficient, but unnecessary, to also require w>=all Wd. + +The implemented public input already has grid 2^-P: its encoded incoming +precision equals P, so P0=P at this boundary. A caller starting with a coarser +external P0 must first supply an exact numerator shift by P-P0 and signed-width +extension, with its complete O(Tw) scan charged. That initial lift is an explicit +entry requirement; the present controller's converters change signed width at +unchanged P. Before each dense call, check/discard only redundant sign-extension bits into W0; the +actual radius ensures this is exact and the dense consumer still performs its +real squared-radius test. After its return, sign-extend or check/narrow Wd to w. +The five-stage induction in (4), including its actual local defects, bounds +every **completed dense output** by R2. Hence each returned component numerator +has absolute value at most 2^(P+r2), and fits W0 with headroom. This completed +stage bound, not the larger raw-prefix allowance defining Wd, justifies the +shrink when w>=W0. The physical converter still checks every discarded high +bit is redundant sign extension. It discards no low fractional bit. Wd remains +the true provider width throughout its interior work and in the invoice. +Sparse data and pages remain at P,w. All conversions read/write their complete extents and cost +`O(T(w+W0+max Wd))`; old bodies are erased and historical backing retained in +space. Any marker/codec adapter between owners is also a complete paid scan, +not a host decode of a whole field. No conversion rounds downward. + +## 6. Complete time, layout and ceiling invoice + +Let C_dense(j) be the full #6899 tariff, including its two complete-field +permutations, actual radius squares, every H/diagonal event, Karatsuba products, +controls, native constructor, setup and cleanup. Let C_route denote the actual +support route with precision w+g and support k, and C_union(c,s) the complete +transport, catalogue and numerical tariff for context c and sparse stage s. +A safe complete invoice is + +\[ + \sum_{j\in\{1,3,5\}}C_{dense}(j) + +\sum_{s\in\{2,4\}} + [2C_{route}(n,w+g,k,w)+\sum_{c=1}^K C_{union}(c,s)] + +C_{convert}+C_{assembly}. \tag{14} +\] + +The extra sparse routes put the original field into complete-context order +and restore it. An enclosing controller may prove a smaller bill by actually +keeping compatible packed order throughout. Identity permutation in one finite +fixture does not remove the all-size charge. Assembly includes complete copies, +encoded context traversal, bank selection and every ABI adapter. + +**Three global dense cohorts are essential to this favorable rate.** The +retained physical dense theorem expressly needs n=Theta(P) for its accelerated +H tariff. Separate local-context dense calls have n_local=g log2 L=o(p), while +the requested accuracy may require P=Theta(p). They cannot inherit that rate +without another theorem. They retain the unsimplified provider cost instead. +A K=1 small fixture establishes execution at its actual dimensions only. + +For m nonempty complete complex E-lines, a=|E|, j=|J|, the exact inverse +matrix-call count is + +\[ + Q_I=[2(2\lceil a/b\rceil-1)+2(2\lceil j/b\rceil-1)] + \lceil2m/b\rceil. \tag{15} +\] + +One supplied forward action on k rows has + +\[ + Q_A=2(2\lceil2k/b\rceil-1)\lceil2m/b\rceil. \tag{16} +\] + +Each matrix call uses exactly 7^log2(b) scalar children. The 2k in (16) is +the actual zero/source lift; 2m is the real/imaginary pairing. All transposes, +extraction/return, zero writes, page scans, source comparisons, padding, +additions, protected returns and erasures remain priced. Scalar arguments have +width w+log2(b)+2, never the width of a packed tensor. + +The sparse source instantiates FftWord(base_bits=4096), with retained theorem +`M(u)=O(u log^2(u+2))`, including unamortized twiddle setup. It uses the +corrected #3709 normalized product. Pending #6895 at +`85e0534b3a86dc0237f368ff0e5fb646fe4744ec` already gives the arbitrary-input +numerical source implication. The source-compatibility receipt compares all +seven of its numerical files with the actual sparse FftWord nested ring archive +by Git blob and SHA256. Inherit that audited numerical implication only for +the byte-identical source closure; no new numerical audit is claimed here. +Count, WordProduct, codecs, live-operand, owner and complete-cost premises remain. +The exact comparison is recorded in +[NORMALIZED-SOURCE-COMPATIBILITY.json](NORMALIZED-SOURCE-COMPATIBILITY.json). +This scalar differs from dense #6899's Karatsuba. + +With omega=log2(7) and Lambda7=1+log2(b)+ceil(log2(w+2)), retain + +\[ + Q\,O\{b^\omega[M(w+\log_2b+2) + +(2w+4\log_2b+4)\Lambda_7^3]\} \tag{17} +\] + +plus the full movement terms of the union and action providers. If an action +uses global RHS count, retain its log(2k+2m+2) descriptor term. In the intended +regime it is O(n)=O(p) and is absorbed by w=Theta(p), not called O(log p). +A local b-column adapter uses the smaller descriptor only if actually executed. + +### 6.1 Least checked blocks fund the row ceilings + +Choose the least dyadic inverse block covering max(2,v_N,v_F), using the actual +checked bands. Matrices have dimensions at most a, so b<=4a; the ordinary band +also gives b<=4pbar as required in (9). For a forward action choose the least +dyadic block covering max(2,v_lift). Since v_lift<=2k-1 and k<=a, again b<=4a, including +the a=1,b=2 case. No arbitrary-partition boundary density is inferred here. + +Expanding (15)--(17) bounds arithmetic by a constant times + +\[ + [am b^{\omega-2}+(a+m)b^{\omega-1}+b^\omega] + [M(w+\log b)+O((w+\log b)\Lambda_7^3)]. \tag{18} +\] + +The m b^(omega-1) term is at most 4am b^(omega-2). Remaining +`a b^(omega-1)+b^omega` terms are genuine per-substream remainders. At most +g squared nonempty round/axis substreams occur per context. Their full cost +is charged before context absorption. Oversized user blocks retain the full +ceiling bill without this simplification; empty substreams make no call. + +## 7. Compatible conservative family; no new bound claim + +Use the admitted #6899 family beta=39/40, xi=15/16, epsilon=1-10^-30, +g=Theta(p^beta), d=Theta(p^epsilon), +`L=2^ceil(400 log2 p)`, `Bint=2^floor(xi log2 p)`. +The complete field has n=Theta(p), original-axis address width +ell_original=O(p^(1-epsilon)), and balanced groups between g and 2g axes. +No independently padded small final group is used. + +Retain the actual source accuracy/carve regime: physical +W=O(sqrt(p) polylog p), gap>=1/(16p^2), and enlarged boundary density +`a/L=O(W/Bint polylog p)`. Finite admitted small partitions do not prove +this density or the production source regime. The source conditioning gives +polynomial local factor row norms; column norms are at most L times them, +also polynomial. Thus log h=O(log p), log H=O(g log p)=o(p). +With target, incoming precision and log R0 all O(p), (3)--(5) give +td,q,log R2,log R*=O(p). Equations (9),(11)--(13) and the retained raw-prefix +analysis give P,w,U=O(p). The raw-prefix condition is exactly +beta+2xi-2=17/20<1. The larger offline original-weight precision remains setup +height, not an online scalar width. An initial grid Omega(p) gives w=Theta(p). + +The complete uniform preparation/remainder envelope per delivered context is + +\[ + 2^{O(\ell_{original})}\operatorname{poly}(p). \tag{19} +\] + +It includes all g source keys, exact matrix/Schur formation, interval and +original-coordinate generation, radius-description heights, all three dense +source words, real page preparation, coefficient code, every catalogue traversal, +g-squared ceiling remainders and disposal or retained source/cache backing. +Constants must be uniform over contexts. Multiply by **K** for the complete +field. Since + +\[ + \log_2(L^g)=\Theta(p^\beta\log p),\quad + \log_2(2^{O(\ell_{original})}\operatorname{poly}(p)) + =O(p^{1-\epsilon}+\log p),\quad 1-\epsilon<\beta, +\] + +the complete term is o(Tw). No cross-context cache or omitted K is needed. +Time absorption does not erase retained source objects or old physical backing +from the space invoice. Native constructor charges remain positive inherited +admissions, even when their fixed source constant is astronomical. + +With V=Theta(Tp), use the incidence identity +`sum_(r,f) a_f m_(r,f)=sum_f a_f L^(g-1)` in each context. The two sparse +windows, the exact scalar FFT tariff, b=O(W) and density give over O(d/g) groups + +\[ + O(Vd W^{\omega-1}/B_{int}\operatorname{polylog}p) + +O(V[d/g+dW/B_{int}]\operatorname{polylog}p), \tag{20} +\] + +besides the absorbed complete setup and remainder. Lift constants and every +inner scalar product are already included. Since 7^16<2^45, the sparse +arithmetic power above V is strictly below + +\[ + \epsilon+(45/16-1)/2-15/16=\epsilon-1/32. \tag{21} +\] + +Use only the historical physical rates actually retained by #6899: +alpha=99827101/100000000 and eta=332353/332929. Dense and support-route powers +are respectively epsilon-(1-alpha)beta<.99831423475 and +epsilon-(1-eta)beta<.998313153856. Three dense calls, the four additionally +charged sparse layout routes and exact conversions preserve these powers up +to fixed logs/constants. Actual route reserve/free-block and stock guards +remain admissions; outside them retain its unsimplified tariff. +The exact comparison 3^5<2^8 bounds dense scalar power by +epsilon-beta+3/5<.625; scans/conversions have epsilon-beta<.025. +Thus the complete sparse arithmetic is subordinate to the inherited dense +maximum. Substituting Karatsuba into the sparse service instead destroys +this favorable comparison, as the checker demonstrates. + +This is no identification of alpha or eta with a current .0034 BIT rate and +no new kappa. Halo, CRT, final recovery, production native construction and all +five selected assumptions remain outside the asserted closure. + +## 8. Broad compatibility, separately scoped + +For the same broad Q, exact execution order is +`Dplus ; E_+B ; Dminus ; (E_+C diag(I,F)) ; Dplus`. +F is applied, never inverted. The lower macro maps +`(u_I,u_J)` to `(u_I,C0 u_I+F u_J)`. +It can use two paid #6909 transactions: extract J/apply F in J order/restore J, +then apply the original +C0 shear in E order. This avoids an unproved band +claim for F embedded back into E. Each matrix uses its actual checked band; +the maximum of their least dyadic blocks still has b<=4a and source b=O(W). + +Include both micro-factors and the macro in h. Allocate each micro-call at +`q_micro=q+ceil(log2(2(h+1)))`. Their combined complex-l1 defect is at most +`(h+1)2^-q_micro<=2^-(q+1)`, at actual intermediate radius covered by (4). +Equations (2)--(7) then apply. The extra target guard is O(log p), and the +additional action has its complete (16)--(18) bill. The broad source's own +`E_M Qideal<=1/2` and polynomial inverse-interior allowances remain explicit. +This compatibility statement is not an assertion that broad execution ran. + +## 9. Evidence and open next questions + +The check_budget.py verifier has been executed normally and with -O. +Its identical receipts contain 108 exact allocations, +4916 complete inverse/lifted-forward ceiling cases, six algebraic factor cases, +six rejecting admission/conversion controls and explicit omitted-volume, +per-context-reset, wrong-scalar, boundary-reset and Schur-only counterexamples. +Those matrix cases are explicitly algebraic controls. No assertion is used as a +required failure gate. + +The separately executed check_source_join.py uses two actual immutable +References `(15,1,alpha,2,3,192)` for alpha=2,3, two complete contexts, two axes +and side L=4. All four actual interiors have length two and nonzero off-diagonal +entries. The adapter reverses the router's high-coordinate-first source order +for the unchanged dense source's low-coordinate-first convention. Each of the +three dense calls executes all 851 emitted H/diagonal events, including genuine +idle words, on the actual preceding result. The common grid is P=777 and the +recorded common width is 1091. Sparse values follow the retained staged +per-column functions in increasing router-axis order. The original complete Q +matrices, independently inverted and tensored, supply the final target. + +Both normal and -O executions pass the five actual-input defects and their +complete propagated allowance. They reject unreversed source axes, swapped +source contexts and a one-ulp discontinuity at a sparse service boundary. +These are **semantic** replays; retained host value functions do not count as +physical tape execution. The fixture uses explicitly validated admitted +partitions and does not establish the production carve or its asymptotic rate. +Its observed dense all-boundary drift counts are zero; the all-size proof still +allows nonzero drift and requires every subsequent stage to receive actual +returned values. + +The independent check_allocation.py additionally reconstructs the source +admissions in prepared_join.py before any payload is supplied. It uses its own +pivoted matrix inverse for the original-Q factors and the four padded +bidiagonal pass norms, and recomputes the staged errors, perturbed solve radius, +all scalar-state and residual bounds, literal forward lift support, complete +V2, dense coefficient/rounding constants and internal widths. Normal and -O +receipts agree on the actual small allocation P=242,w=264,W0=253,Wd=362, +an incoming grid of 320 that forces P=320, and a two-context/two-axis nonidentity +interior allocation P=752,w=779,W0=767,Wd=1078. These are admissions, with no +physical execution claimed. Four controls reject an insufficient h, a grid +below the incoming precision, an insufficient scalar carrier, and insufficient +immutable Reference accuracy despite 192 stored entry bits. + +independent_numerics.py forms the final target by independently pivoting the +original complete Q on each actual context/axis. It does not import a producer +Schur builder, rounded page solver, physical controller or author oracle. A +joined fixture must expose all five actual inputs and outputs; exact converters +must preserve values across adjacent stages. This detects a boundary reset even +when the resulting difference fits a loose final error tolerance. + +The completed small physical receipt uses Reference `(7,1,2,1,3,64)`, original +origin 2, L=2, I={1}, K=g=1, common P=242 and w=264. Its complete original Q is +nonidentity, while its scalar interior A is exactly 1. All three dense calls +execute 63 actual H/diagonal events each; the two sparse calls are real physical +children. The independent check_physical_result.py regenerates the Reference, +the original Q and both full dense source certificates, then checks all five +externally observed transitions at their actual inputs and the final result +against an independent direct inverse of Q. The normal and -O observers agree +on the successful complete physical receipt, including its signed-width +conversions and source allowances. They do not rerun the physical controller. +In addition, they compare every returned physical word bit for bit with a +separate interpreter of all emitted dense H/diagonal events and the staged +sparse schedule. staged_oracle.py recomputes quantized diagonal blocks by its +own pivoted inverse and applies each residual and product truncation at its +actual boundary, including coefficient pre-rounding in the forward lift. It +imports no producer page builder or rounded sparse observer. No interpreter +output is supplied to the physical execution. +All three observed dense boundary drift counts are zero. The receipt's cleanup +and ownership checks are separate physical evidence, supplied by its producer +and controller review. + +This small admitted partition supplies complete execution evidence and does not +establish nonidentity interior physical performance, the production carve or +the asymptotic rate. The nonidentity interior evidence above is semantic. The +complete original-coordinate wrapper and its nonidentity layouts require their +own registered execution/review evidence. Retained native/Count/WordProduct, +codec, ownership and complete-cost premises and all five selected assumptions +remain explicit. +Subsequent questions are attachment to actual halo delivery and independent +closure of retained native/physical lifecycle/cost contracts, keeping #6895's +completed numerical source implication. Finite agreement, generic telescopes +and increased precision alone do not answer those questions. diff --git a/research/source-remaining-diagonal/retained/fft/COLD-NAMES.json b/research/source-remaining-diagonal/retained/fft/COLD-NAMES.json new file mode 100644 index 0000000000..ad8be21700 --- /dev/null +++ b/research/source-remaining-diagonal/retained/fft/COLD-NAMES.json @@ -0,0 +1,255 @@ +{ + "archive": "research/physical-fft-word/inputs/ring-export.tar", + "names": [ + "active_budget", + "active_plan", + "active_root", + "active_sources", + "arithmetic", + "audit_allcold", + "axis_stream", + "bank_packets", + "base_two_moment", + "benchmark", + "binary", + "binding", + "bindings", + "bitstream", + "bootstrap", + "bundles", + "bw_adapters", + "bw_audit_local", + "bw_check_recipes", + "bw_emit", + "bw_gauss", + "bw_phases", + "bw_tamper", + "bw_transport", + "cardinal_counts", + "cardinality", + "catalogue", + "ceiling", + "certificate", + "check_active_contracts", + "check_active_plans", + "check_active_runtime", + "check_arithmetic", + "check_bank", + "check_binary", + "check_bounds", + "check_compilation", + "check_components", + "check_composed", + "check_composed_budget", + "check_composed_failures", + "check_composed_metadata", + "check_controls", + "check_cover", + "check_dispatch", + "check_engine", + "check_failures", + "check_fourier", + "check_grid", + "check_guard_return", + "check_handoff", + "check_headers", + "check_join", + "check_layout", + "check_local_modular", + "check_machine", + "check_mixed", + "check_monomial", + "check_monomials", + "check_multidigit", + "check_native_flow", + "check_nested_model", + "check_parking", + "check_payload", + "check_phase_control", + "check_prime", + "check_recursion", + "check_root", + "check_root_plan", + "check_root_runtime", + "check_root_streams", + "check_router", + "check_runtime", + "check_scalar", + "check_selected", + "check_setup", + "check_sign", + "check_sources", + "check_spacing", + "check_sparse_budget", + "check_sparse_controls", + "check_sparse_failures", + "check_sparse_payload", + "check_sparse_sources", + "check_streams", + "check_support", + "check_t74_bounds", + "check_unused_parameter", + "checks", + "children", + "clifford_exact", + "codec", + "coefficient_engine", + "cohort", + "common", + "compact", + "compact_control", + "compact_counts", + "compact_engine", + "compact_layout", + "compact_streams", + "compare", + "compile_word", + "composed_engine", + "composed_plan", + "composed_sources", + "consumer", + "continuation_checks", + "control", + "control_checks", + "controller", + "controls", + "convolution_engine", + "counts", + "cover", + "directory", + "driver", + "emit_allcold", + "encoded", + "episode", + "exposure", + "fft_arithmetic", + "fixture_binding", + "forms", + "fourier_diagonal", + "fourier_engine", + "fourier_plan", + "fourier_sources", + "frame_checks", + "freeze_inputs", + "fresh_rows", + "gaussian_test_support", + "generated_identity", + "grid_boundary", + "integration", + "interface", + "intervals", + "layer_budget", + "layout", + "leaf_sources", + "linear_sign", + "loader", + "low_codes", + "machine", + "macro_binding", + "macro_checks", + "macro_code", + "macro_controls", + "macro_local_checks", + "macro_machine", + "macro_selected_checks", + "matrices", + "model", + "moment", + "monomial", + "monomial_engine", + "monomial_packets", + "native_program", + "native_sources", + "nested_bank_checks", + "node", + "normalizer", + "numeric", + "numerical_frame", + "oracle", + "ordinary", + "outer", + "packet", + "packet_engine", + "padding", + "pair_dispatch", + "parking", + "parking_machine", + "peel", + "phase_recipe", + "phase_sources", + "physical_words", + "plan", + "pr2226_operators", + "pr2226_replay", + "pr2753_recursive_call", + "predecessor", + "prepare_inputs", + "product_plan", + "production_native", + "provenance", + "records", + "recursive_call", + "residual", + "residual_blocks", + "retuned_machine", + "retuned_native", + "ring_check_budget", + "ring_check_convolution", + "ring_check_failures", + "ring_check_fft", + "ring_check_product", + "ring_check_sources", + "ring_check_twiddles", + "ring_check_words", + "ring_engine", + "ring_sources", + "ring_words", + "role_parking", + "root_layer", + "root_plan", + "root_streams", + "router_engine", + "router_metadata", + "router_plan", + "router_sources", + "routes", + "run_native", + "run_native_borrow", + "scalar_engine", + "scalar_packets", + "scalar_program", + "scalar_words", + "scheduler", + "scratch_pool", + "selected_binding", + "selected_source", + "selection", + "session", + "signed_linear", + "signed_phase", + "source", + "sources", + "sparse_control", + "sparse_engine", + "sparse_oracle", + "sparse_sources", + "sparse_state", + "stage", + "stream", + "stream_runner", + "streams", + "t74_machine", + "t74_root", + "tables", + "test_active_controls", + "test_controls", + "test_verify", + "topology", + "trace", + "twiddle_setup", + "verify", + "witness", + "word_product", + "words" + ] +} diff --git a/research/source-remaining-diagonal/retained/fft/PROOF.md b/research/source-remaining-diagonal/retained/fft/PROOF.md new file mode 100644 index 0000000000..60d86c8b11 --- /dev/null +++ b/research/source-remaining-diagonal/retained/fft/PROOF.md @@ -0,0 +1,351 @@ +# Exact FFT scalar ownership for the synchronized Full caller + +Prepared for **@CubeJerry**, with substantial OpenAI Codex assistance. +Apache-2.0; the retained source files preserve their authors and notices. + +This is a source-bound composition theorem. It does not introduce a scalar +multiplication algorithm or reprove the normalized FFT recovery constants. +It gives the published global Full caller an explicit exact quasi-linear +scalar owner, including its nested ownership and complete invoice. +**No new κ.** All native-H, outer, coefficient-preparation and primitive +integer-runtime assumptions stated below remain separate. + +## 1. Exact objects and inherited propositions + +The canonical base is `7c49fe32c55de02c2c873655c804b16e4c3fef0a`. +`SOURCES.json` authenticates the canonical live inputs; `VENDOR.json` +authenticates the byte-identical portions of the published Full caller at +`d51859e7816771f627033b23db0f9786ada863f8`. They are copied because the +new owner actually executes those methods and the source producer, not +merely to acquire provenance. The published tree is identical to author +tree `c7349ceff1e9fc5634db3a80cd881da40252209b`. + +The credited premises are: + +1. The Full source/emitter theorem and its complete physical service theorem. + Actual `FullRoot.lower` words, complete compiler-generated identity + padding and exact coefficient pages define one new global rounded + execution. Its complete target, prefix, word-width, source setup and + H-service hypotheses are inherited without alteration. +2. CrocSwap/integer-mult-bounds#3787, author head + `9b5474f47b0ea9a3c76bb5b1b577fb36704815e0`: the physical `FftWord` + theorem. For borrowed canonical nonnegative magnitudes a,b<2^u and a + positive declared width u, it returns exactly 2u raw LSB-first product + bits, including high zeros, and restores the borrowed values/heads. + Its complete cost is `F(u)=O(u log^2(u+2))`, with O(u) workspace and + the source's protected-return protocol. The two magnitude ports may alias. +3. The exact Count, signed codec and WordProduct premises of that source. + Its retained normalized-product child is CrocSwap/integer-mult-bounds#3709 at + `62264289adb01f3ba4930cd0154c75887f96203c`. The independently reviewed + numerical source refinement is published at + `85e0534b3a86dc0237f368ff0e5fb646fe4744ec`; it retains the exact + integer primitives and successful physical packet/ownership premises. + Neither that audit nor this composition is a formal proof-kernel result. +4. The existing physical H boundary to CrocSwap/integer-mult-bounds#3627, including its actual native, + internally funded stock, layout, ownership, word-margin and complete + tariff hypotheses. Shared types do not prove those hypotheses. + +The all-width setup result CrocSwap/integer-mult-bounds#5110 and the existing carry analyses CrocSwap/integer-mult-bounds#3808 and +CrocSwap/integer-mult-bounds#6252 are predecessors, not new claims here. CrocSwap/integer-mult-bounds#3935 already uses the scalar +lineage in an older Gaussian tensor. CrocSwap/integer-mult-bounds#6024 concerns outer convolution +reversals; the inner RingProduct already has its matching DIF/DIT schedule. +The contribution here is the specific synchronized Full owner and bill. + +### 1.1 One actual numerical cohort + +The retained FftWord archive is SHA256 +`c03d4b056ccd3db860c93579f6525e0bb1baea31cff879eb07135c99432ef159`. +Its `ring_sources.py`, `word_product.py`, `ring_words.py`, +`fft_arithmetic.py`, proof and nested `fourier-export.tar` are byte-identical +to the six canonical dependencies used by the published Full service. +The nested archive is SHA256 +`30e460df0428ea1ff72dba6528537e53aec62fcec5dc6077bf736afd5cbbc7e8`. +The original numerical plan, twiddle and engine bytes also match the source +independently reviewed for the published numerical refinement. + +`join_sources.opened` therefore opens the retained FftWord loader once, +then loads the exact Full boundary, control encoder and stage implementation +into that cohort. The composed-H source blobs are checked against the +original Full boundary pins. Runtime identity checks establish one Count, +Tape and Arithmetic class, rather than merely compatible class names. +The old Full source loader is imported only for its unchanged `need` +binding; its `opened` function is not called inside another cohort. + +Before opening, the wrapper authenticates every declared canonical input +and vendored byte. It derives every Python module stem in the authenticated +nested tar closure, checks the recorded inventory, and rejects any already +loaded such module, including the new `join_engine`. Explicitly loaded +modules have prescribed source paths; imported archived modules have hashes +from that authenticated closure. The same check runs after successful use. +One process cannot reuse a stale owner class through another `opened` +context. These are source-identity checks, not a theorem about arbitrary +host import systems or concurrent file mutation. + +For source preparation, the unchanged Full loader receives its documented +raw-source override dictionary. Its four preparation files and the nested +lowering manifest are temporarily materialized with the original relative +layout, because the unchanged code reads that manifest relative to its +own file. No code, ROOT global, arithmetic, hash format or authentication +test is patched. The three preparation aliases are removed afterward; +the prepared object's functions retain their authenticated module globals. +All source construction and this relocation/disposal are charged to setup. + +## 2. A distinct constructor with unchanged Full methods + +The old `FullPhysical.__init__` requires `type(word) is WordProduct`. +It remains byte-identical and is not called with an inadmissible word owner. +`FastFullPhysical` declares a new constructor. It invokes the retained +`GlobalBoundary` constructor, constructs an actual `FftWord`, checks its +acyclic child classes, and installs the retained signed Arithmetic wrapper. +No old constructor or source method is monkey-patched. + +The following are literally the same function objects as on FullPhysical: + +``` +note, admit_radius, lift_input, h_event, product, +coefficient_field, diagonal, run. +``` + +The two new methods are its explicit constructor and stronger `idle` check. +Inherited GlobalBoundary routing, copying, grid and return methods are also +unchanged. The source control encoder is byte-identical `PreparedFull`. +The verifier checks the function identities separately from any numerical +fixture. It does not claim that Python class inheritance alone proves the +changed child's contract; the next sections give that argument. + +### 2.1 Fixed owner inventory + +In addition to the retained H/grid/global owner, the scalar subtree contains: + +| Owner | Fixed scratch-pool roles | Other owned state | +|---|---:|---| +| FftWord | 256 | output, packed-input references, encoded plan | +| FftWord base WordProduct | 128 | canonical word roles, parking/return | +| RingProduct | 256 | output, FFT packet references, encoded plan | +| RingProduct internal WordProduct | 128 | canonical word roles, parking/return | +| Twiddles | 256 | output and encoded interval/phase setup | + +The total scalar pool inventory is 1,024 roles, independent of u and the +number of Full stages. The remaining canonical/stack/output roles are also +fixed. In particular the RingProduct child retains its own original +WordProduct; FftWord is not installed recursively inside itself. + +The inherited `private_tapes` traversal visits all references of this +constructed owner graph, with identity-based cycle suppression. It never +decodes numerical cells. The complete new forbidden-port set therefore +includes every nested pool, canonical role and protected output. The old +Full entrance guard runs before tape traffic and rejects borrowed payload, +program or metadata aliases with any such role. The verifier exercises +both payload and program aliases for one representative port of every +scalar pool and for every scalar child output. This is finite corroboration +of the graph argument, not an exhaustive test of all physical inputs. + +During a legal invocation, Count and packet temporaries use the installed +fixed pools. The parent scope is suspended before exposing borrowed views +to a child. Nested FftWord, RingProduct, WordProduct and Twiddles scopes +have disjoint preconstructed owners. Their original successful-return +contracts restore scopes, borrowed heads and scratch; no new physical +tape is allocated in the sealed invocation. + +### 2.2 Idle and protected return + +The new idle first checks the original H/grid boundary. It then calls +`FftWord.idle`, which checks its base and RingProduct children; the latter +checks its internal WordProduct and Twiddles. Finally the new idle requires +the top FftWord closed, its a/b references absent, its pool empty and its +own protected output blank. Thus a completed but unconsumed scalar return +cannot be mistaken for an idle parent. The original global protected return +must likewise be consumed before reentry. + +Every successful scalar call returns its complete 2u raw bits. The existing +Arithmetic wrapper reads exactly that extent, checks the following blank, +and clears/erases the child return in its finally clause. Its returned +signed Count is owned by the resumed caller scope. This is the same scope +and protected-output interface that the unchanged Full methods require. +The new theorem concerns successful legal calls under the retained child +contracts; arbitrary interrupted native-call recovery is not asserted. + +## 3. Exact numerical substitution + +For every admitted signed multiplication, the actual component magnitudes +are below 2^u at the supplied positive width. Negative signed extrema do +not violate this: a width-u two's-complement magnitude is at most 2^(u-1). +The FftWord return is the same padded unsigned bit string that the prior +WordProduct contract supplies. The retained Arithmetic consumes that string +and sets the sign to the original XOR of operand signs. Its exact signed +result is consequently identical, including zero and aliased squaring. + +The complex service uses four such products followed by exact signed sums: + +``` +real = ac-bd; imaginary = ad+bc. +``` + +Only after those full numerators exist does the unchanged Full `product` +method perform its temporary-width checks and one componentwise toward-zero +division by 2^F. Output-width checks and signed serialization are unchanged. +There is no new coefficient or data error at this replacement boundary. + +Induct over the chronological physical Full program. At entrance the same +input-radius squares, accumulator and comparisons give the same admission. +The lift is unchanged. At a D event every rounded suffix and data product +is identical by the exact scalar argument; the same pages are scanned and +the same state is emitted. At an H event the input bits, metadata and +boundary are unchanged, so its inherited contract supplies the same raw-H +result and frame. Thus every completed stage has the same state and the +same final protected output as the published global rounded Full execution. + +The complete source tensor error, prefix bound, data/coefficient precision, +temporary headroom and stored-inverse consequence are therefore inherited +without reducing any width or moving any rounding. This is an exact +replacement argument, not a numerical-continuity estimate for separately +rounded trajectories. + +The FFT branch used here satisfies the retained numerical audit domain. +For u above any fixed cutoff K>=2, CrocSwap/integer-mult-bounds#3787 chooses beta=ceil(log2 u), +q=ceil(u/beta), minimal r=2^ell>=2q and p0=2beta+ell. Hence p0>=2 and +1<=ell=2, but this theorem fixes K independently of input width. Allowing +an input-dependent cutoff to grow with u is outside the stated uniform +fast bound. Every retained base leaf within WordProduct remains 16. + +For u>K, CrocSwap/integer-mult-bounds#3787 includes the complete unamortized RingProduct setup: + +``` +O(r(ell+1)p0^(8/5) + r p0^3 + p0^3), +``` + +plus packing, fit checks, exact carries, full return copying and cleanup. +Since r=O(u/log u) and p0,ell=O(log u), this is +`F(u)=O(u log^2(u+2))`. Its finitely many widths u<=K satisfy the same +asymptotic bound with a constant depending on fixed K. The signed wrapper +and complete complex sums/truncations add O(u), so they preserve this rate. +No twiddle table is assumed free, shared across scalar calls, or precomputed +by a multiplication oracle. The sharper setup expression in CrocSwap/integer-mult-bounds#5110 is +consistent with, but unnecessary for, this asymptotic substitution. + +Retain the published notation: T=K_label N^g=2^n complete Gaussian records; +H,D are actual global event counts; W0 is incoming component width; W is +the common data word width; U=max(W,W_d,W_c,W_t). The complete bill is + +``` +S_Full + S_encode + S_constructor + + O(T F(W0+n+1) + T U + + D T (F(U)+U) + + poly(n + log(U+2) + log(H+D+2))) + + H C_H(n,W+g,g). (1) +``` + +The radius term includes all 2T physical squares and the exact accumulator, +whose safe width is O(W0+n). For every D event the retained geometric +suffix expansion uses fewer than 2T coefficient complex products and T +data products. Each includes four scalar calls, exact sums, one rounding, +copies, rewinds and disposal. Its encoded per-label cardinality cost is +already included by the predecessor's geometric bound; it has not become +a free random-access table. H's complete bill includes its lift, routing, +stock, return and exact sign-only shrink. + +S_Full includes actual source construction, validation, exact coefficient +heights and conversion to all F-grid pages. S_encode includes complete +page/metadata serialization; S_constructor includes both the retained +native owner and the new fixed scalar/port inventory. None is absorbed +without the predecessor's stated source-size and growing-group hypotheses. + +In the previously stated family U,W0,n=O(p), W=Theta(p), V=Theta(Tp), +equation (1)'s scalar/admission term becomes + +``` +O((D+1) V log^2(p+2)). (2) +``` + +For actual synchronized Full words D/H=(8m+3)/(8m+2)<=11/10. Under the +retained complete H tariff, the H contribution is + +``` +O(H V [g^alpha log p + (g+1)^eta (log p)^(1+eta)]), +alpha=99827101/100000000, eta=332353/332929. (3) +``` + +For any fixed 0 log2(3)-1` is no longer required. For constant or more slowly +growing g, keep the complete sum; this does not assert uniform absorption +of every logarithmic factor. The native domain n=Theta(P), g<=P^.997, +P=W+g, and any initial whole-field gather remain required. In particular +gm<=P^.997 follows eventually only under the stated strict exponent and +m=O(log p). This is a source-rate consequence, not outer admission or κ. + +### 4.1 Space and retained history + +The new scalar subtree has O(U) live payload space: r(p0+2)=O(U), a fixed +number of packed/FFT/twiddle buffers and the credited geometric word stack. +The Full owner still has O(TU) working payload space plus metadata and the +inherited H owner's allowance. Total storage also includes source +preparation peak, already-retained backing and the complete borrowed code: + +``` +S_code = 2(H+D+1) + H g b + 2D K_label g N W_d, +b=max(1,ceil(log2 n)). +``` + +Repeated scalar calls clear bodies but do not shrink host tape backing. +The extra scalar history is O(max_previous U); all prior global input, +control and H backing allowances remain in force. No statement replaces +that high-water accounting by the latest small live payload. The +all-stage code is not uniformly field-linear at fixed g and unbounded +stage count; the same growing-group absorption condition is retained. + +## 5. Passive observations + +When no observer is supplied, the constructor installs the predecessor's +fixed-key null maps for global, FftWord, base WordProduct, RingProduct and +internal WordProduct call counters. Both external and internal Arithmetic +objects use the inherited methods with a zero-valued `products` property. +Each erased `+=1` therefore has bounded finite operands. Source inspection +shows these fields are only passive diagnostic writes in the execution +methods; they do not select a branch, numerical operand or tape operation. + +Induction over the instruction sequence therefore gives identical payload +and tape actions with these observations erased. The actual fast complex +fixture runs both ways and compares complete output and all collected +read/write/move totals. Low-level retained Meter, pool-peak and callee +observation objects remain the predecessor emulator's separate observation +layer; the compiled tape algorithm does not acquire unbounded host controls +from those diagnostics. No performance theorem is inferred from timings. + +## 6. Finite evidence and limits + +The full fixture is the unchanged stored inverse of `(2+i)I_2`, target 8, +radius 2 and incoming grid 0. Its actual source allocation is F407/W608, +with 10 H and 11 D events and 92 real scalar products. The new production +owner uses its declared base branch on that fixture; it is not described +as a 608-bit FFT execution. Its full output is checked against the retained +independent rational source oracle, and every borrowed value/head, nested +scratch and protected return is checked. Its H child remains the credited +standard q2 finite fixture, not a full production GL64 payload. + +Separately, the exact inherited Full `product` method multiplies +`(-3+i)(2+i)=-7-i` at declared magnitude width 3, using fixed fixture +cutoff 2. All four real products execute FftWord's actual FFT branch. +The complete numerator is then truncated by 2 to `(-3,0)`; both components +discard nonzero low bits. This is a real signed complex-service invocation, +not a complete fast Full program or an injected convolution return. +Its observer-enabled and observer-erased executions must agree exactly. + +Cold import, nested alias and unconsumed protected-return controls target +the new source/owner boundary. Normal and optimized registered execution +compare the entire typed receipt, excluding only three measured elapsed +times. Successful fixtures do not establish the universal inherited FFT, +native, primitive-integer or source numerical theorems by themselves. + +Remaining work includes outer-cohort/domain/setup admission, independent +native semantics/word margins and a priced streaming control producer +where constant-g total storage matters. This package changes no selected +certificate and claims no unconditional integer multiplication bound. diff --git a/research/source-remaining-diagonal/retained/fft/SOURCES.json b/research/source-remaining-diagonal/retained/fft/SOURCES.json new file mode 100644 index 0000000000..60c1abe481 --- /dev/null +++ b/research/source-remaining-diagonal/retained/fft/SOURCES.json @@ -0,0 +1,270 @@ +{ + "schema_version": 1, + "base_commit": "7c49fe32c55de02c2c873655c804b16e4c3fef0a", + "files": [ + { + "path": "certificates/selected-result.json", + "usage": "provenance", + "git_blob": "d59b5035e7b4cbaa9d688a1d32dd0d6eb79c466a", + "sha256": "9b8d0eea95b3bf0dfcb7938a732a6439b87a2685dec2a5ab9e525b3b34debbfa" + }, + { + "path": "docs/research/agent-task-catalog.json", + "usage": "provenance", + "git_blob": "3404fbdd5e7529a0674eef26114b5071e4586cec", + "sha256": "ead6cdc9d0af6d58e8a49744d8ec8c7c15e13d2ba93c276c434bcf9b51b93a81" + }, + { + "path": "research/capped-phase-fusion/TENSOR-COMPILER.md", + "usage": "input", + "git_blob": "19efb9cb1c5a738e57caadf2dd6f5611af1bc78a", + "sha256": "4d3b8466598a864a234b978e25976648d4e761840aad9153dd18d73d3dfe4d15" + }, + { + "path": "research/capped-phase-fusion/evidence/inplace_algebra_ultra/check_circuits.py", + "usage": "input", + "git_blob": "f80c141c8116b163c2bb5a028c28212077c8d5a9", + "sha256": "06d1861bfe8af543908e26557ffda7e451ff176bceb9bacfaf0f04f234b336d5" + }, + { + "path": "research/capped-phase-fusion/evidence/inplace_algebra_ultra/check_tensor_compiler.py", + "usage": "input", + "git_blob": "5eb5c1ffd23932ba7ccaa0d7686a5b875a3b1809", + "sha256": "dc4b1f1884489215a2c2d0e8978a241e99e6c8c9f1d2fa2460c73d2c7d4ba30a" + }, + { + "path": "research/cubic-cyclic-inverse/vendor/PR628-NOTICE.md", + "usage": "input", + "git_blob": "22fbeb8ef0a28dd6b3feea718492091319ceb96e", + "sha256": "abeacf1ad1491d5797cfcf1f3832799bbf3b24b99597229d7bc884059a51ec68" + }, + { + "path": "research/cubic-cyclic-inverse/vendor/PR628-PROOF.md", + "usage": "input", + "git_blob": "fb8fe7cb3bd036c69047ae7b4f4009a51b11825b", + "sha256": "595893609764c64a90d9b21b9cbd6d9e61980703f3deb43361105cf8c3d1d093" + }, + { + "path": "research/cubic-cyclic-inverse/vendor/interval_kernel.py", + "usage": "input", + "git_blob": "1182175a55cb871481de0f56ea9ae56e474705fe", + "sha256": "9b7bb24640a9a7d3f83c7951dfef483ec933db4c50de6c0130b85f450eeddfbe" + }, + { + "path": "research/gaussian-height-contract/CALLER.md", + "usage": "input", + "git_blob": "9754af67d2109153ec019877f824708bf9ff988e", + "sha256": "0f6687778b0dd2b5046ced1bcda13970b2f45c35186bb00ae205c682590b8668" + }, + { + "path": "research/gaussian-height-contract/check_caller.py", + "usage": "input", + "git_blob": "db4382fbd836923aeda5b670ba71a27f6ebd9521", + "sha256": "5e16aefe99bc3f4086e41b3fa6349b2796201d1ed1bbdbc304f48e23af7fcf73" + }, + { + "path": "research/physical-fft-word/EVIDENCE.md", + "usage": "input", + "git_blob": "cefb9b6159689bba582fdc2e5cc76425d4770f2b", + "sha256": "c2314c62bbb1cfc0400dd09875926e1efb0000d1db450a984b2f86253d064997" + }, + { + "path": "research/physical-fft-word/PROOF.md", + "usage": "input", + "git_blob": "b066548b77ae99d36d11df379c6c2332caccd0f1", + "sha256": "5d7e5c3e47c4936023f191ef91ff4015d4786cb4de303d8fd3bef0fcec7a77b0" + }, + { + "path": "research/physical-fft-word/README.md", + "usage": "input", + "git_blob": "d149d6c20f47208f81f78c0f038e0201585c2ba3", + "sha256": "0a47858de0cbe7700792b52ee3dcd9ae66f3ad9eb1f99f450515e820ed099dc8" + }, + { + "path": "research/physical-fft-word/fft_word_codec.py", + "usage": "input", + "git_blob": "9444abc96a1cd44309d291589d895120e0eae6b9", + "sha256": "d13f25fc215aa28570ca750afb7153f38d7fb62f92d28e404bb84396e2a90768" + }, + { + "path": "research/physical-fft-word/fft_word_engine.py", + "usage": "input", + "git_blob": "a9e00dd0b5d26719e8d74ba53ce625e4de58b447", + "sha256": "4b2ed4bb244a4b7537432e33706caf2abe19e44ab50cbc0a78db135e9581dee1" + }, + { + "path": "research/physical-fft-word/fft_word_plan.py", + "usage": "input", + "git_blob": "a3914e8e0683f7516332d213254dbd3a8c2122fd", + "sha256": "f8fff468b77753aa5f0d446c5d4381653659253051c1fcd066cd3b345cffd7c1" + }, + { + "path": "research/physical-fft-word/fft_word_sources.py", + "usage": "input", + "git_blob": "77662c14546cc77a1ecfc05b2d404f744fa9dc45", + "sha256": "46f40da411e3779b407bb11a0f7f1526b2d8611c1c6c1ab54f12f0cc00f8ebc2" + }, + { + "path": "research/physical-fft-word/inputs/ring-export.tar", + "usage": "input", + "git_blob": "004c660f786cee08b07fd74af80c9c91146b89f4", + "sha256": "c03d4b056ccd3db860c93579f6525e0bb1baea31cff879eb07135c99432ef159" + }, + { + "path": "research/physical-ring-product/PROOF.md", + "usage": "input", + "git_blob": "2bc9926799296bb348193e68e55aed60ec6ce96d", + "sha256": "a2e43fe5f77350958c2d7d66a50389e5ec6b439a7f9620e94862b969e88fb500" + }, + { + "path": "research/physical-ring-product/fft_arithmetic.py", + "usage": "input", + "git_blob": "606bb6c5e32ca813c927fba1a45315aae3e7de52", + "sha256": "bf7deff44f15f3349fcec98d0e86a6d20820f49ca008892fef9456b3629509e0" + }, + { + "path": "research/physical-ring-product/inputs/fourier-export.tar", + "usage": "input", + "git_blob": "6f7f9d59abdf5d98cbecde1583db61103c1cd973", + "sha256": "30e460df0428ea1ff72dba6528537e53aec62fcec5dc6077bf736afd5cbbc7e8" + }, + { + "path": "research/physical-ring-product/ring_sources.py", + "usage": "input", + "git_blob": "40a4b21a6ffd89d20051fac8055998fac252f130", + "sha256": "82f469acd7f8960ab6b32698e5300a377eb3f18f015f1f129f84604181cac746" + }, + { + "path": "research/physical-ring-product/ring_words.py", + "usage": "input", + "git_blob": "1cb44ce6d95a1e0f9d2c6f78ecd5c7a8e8b39ba9", + "sha256": "6bd18c8f78c94b8a0b97512b4f45c03f88b608e895d0f120296585976e1e8104" + }, + { + "path": "research/physical-ring-product/word_product.py", + "usage": "input", + "git_blob": "67e09e91103535fd1eb0b2d7d6db1fdc13de07d2", + "sha256": "12020ed0571fa756c2d19942b6ccdd6dc5627fdaadb388051417a618c14417d6" + }, + { + "path": "research/rational-fft-fixed-h/DENSE-PROOF.md", + "usage": "input", + "git_blob": "3ee98912ec954824f2a9a0ccdecffce8583832f8", + "sha256": "aa16b3c3124f8b33846319629532cd81106ff8f2a86750c2c327b6cdf6201b85" + }, + { + "path": "research/rational-fft-fixed-h/SOURCES.json", + "usage": "input", + "git_blob": "220b267ed60866653330b7e3d2136d741e40a095", + "sha256": "8d1e091cd6a7b92519bb402d546da73e9f1aca428425ed9caf7f9db922365102" + }, + { + "path": "research/rational-fft-fixed-h/dense.py", + "usage": "input", + "git_blob": "7a48c8d2d566ff64d370c4cb8f793f5cf989c072", + "sha256": "b94d74ede0cced358f0c56646b1dc1e8cb182bbb215ebb40cf56e1d3d262a3f5" + }, + { + "path": "research/rational-fft-fixed-h/lowering.py", + "usage": "input", + "git_blob": "5c2adcfd96f1b2d5987f04242434cd30fdfc33d0", + "sha256": "93b6e86c81a8f12e80688a8f7ec8ddaffedd729fe46b02554b6ed1c135fdd397" + }, + { + "path": "research/rational-fft-fixed-h/vendor/PROVENANCE.json", + "usage": "input", + "git_blob": "22cf8bdcb94f8fff0d1f3f9a38ce9402cc0013df", + "sha256": "302a23bacdb464ef8f1c5d6c87cf72ce846c52c34bd69d245a51c1972e9852f2" + }, + { + "path": "research/rational-fft-fixed-h/vendor/full_source/FULL-PROOF.md", + "usage": "input", + "git_blob": "e650f46863115f810e27b403f916dd7f79b37786", + "sha256": "acf8c596d91b5efd35a286735d6867ff8afce64354a13f680c2fae3dab824410" + }, + { + "path": "research/rational-fft-fixed-h/vendor/full_source/GENERATOR-PROOF.md", + "usage": "input", + "git_blob": "8bef383eec887450e86f14365a6f7b07c1310e9d", + "sha256": "cddda1f944299a349c837808b349fa6e4499cbb1889f7dacc00ca8afac9b580c" + }, + { + "path": "research/rational-fft-fixed-h/vendor/full_source/PROOF.md", + "usage": "input", + "git_blob": "99a55596f67ae3b94ef02ebb159b313f33bf22af", + "sha256": "50e31e33e1275a133d10e87208ceb50dddce67d0678d2a89de9f7ba28d8380d9" + }, + { + "path": "research/rational-fft-fixed-h/vendor/full_source/PROVENANCE.json", + "usage": "input", + "git_blob": "9d848703ed1e2cae899951bb5660de7ab8335d5b", + "sha256": "209f50a6f131db73364989048188c0fec007b20f031b5719e6c8bddac1d37888" + }, + { + "path": "research/rational-fft-fixed-h/vendor/full_source/TRIANGLE-PROOF.md", + "usage": "input", + "git_blob": "f923f4ff2dfe40401fa90d83727ade62b2ef5b5f", + "sha256": "abea26e3c86a9970225b070be034c47e7970e10fe1b5686f405e0b301acf3159" + }, + { + "path": "research/rational-fft-fixed-h/vendor/full_source/full.py", + "usage": "input", + "git_blob": "7f85ad1a89e81b7dfc6b54e7bd9547120e86d5d3", + "sha256": "1f42d5f2858564ffb320e54ba6aa29651025491569823e25006bf5862457b803" + }, + { + "path": "research/rational-fft-fixed-h/vendor/full_source/generator.py", + "usage": "input", + "git_blob": "d761d3c88b1685fb64d92d69f699b8218c9ec30f", + "sha256": "827ef9fe1bd664859995892b59843c390f7969c938fb7e1e6dc585c31a54b555" + }, + { + "path": "research/rational-fft-fixed-h/vendor/full_source/triangular.py", + "usage": "input", + "git_blob": "2bd8de01a7ac80de7e6b9f8252bc69d0e0a291e8", + "sha256": "46780d95ddebfed22e8f0c18565fe2e768250afa5beeb31f450292cc06f7ec11" + }, + { + "path": "research/rational-fft-fixed-h/vendor/full_source/vendor/STEIN-PROVENANCE.json", + "usage": "input", + "git_blob": "c602fb5bb332dbe098950b14d55da05ce2cf4312", + "sha256": "e7f0e8dc517387e302b1e8bf5dff7e12b29da8aa91abc6ea597f33c1ac08ba62" + }, + { + "path": "research/rational-fft-fixed-h/vendor/full_source/vendor/stein_rational.py", + "usage": "input", + "git_blob": "71b240a460a185ee2fe926cd189b56aeac6f997f", + "sha256": "3065fc5d6d22ec44de533b08fb0c639603449456383668e561dc46629e641502" + }, + { + "path": "research/rational-fft-fixed-h/vendor/rational_fft/engine.py", + "usage": "input", + "git_blob": "e9f2f2b08dc2bc4c646e47dca92059351ca89384", + "sha256": "9e36aee0835e6b1b62997433581f88b5a434ccab8ae43e5c25d1deaaf1ebf653" + }, + { + "path": "research/rational-fft-fixed-h/vendor/rational_fft/exact.py", + "usage": "input", + "git_blob": "aae41e6acfb2e5a4fafdd85727891eb746b57b42", + "sha256": "c9b89d7357210af69865690ba12e695366961f8b501a8fab9d0fefe3fb30c479" + }, + { + "path": "research/unconditional-batched-crt/GAUSSIAN.md", + "usage": "input", + "git_blob": "adfb28c93e6b06178c901caaac39ede41a9e541b", + "sha256": "2f63c91c58f2d1cf31294812c75970ea390c61866a8da7ed700d4316a033a242" + }, + { + "path": "research/unconditional-batched-crt/vendor/GAUGEFREE-INTERIORS.md", + "usage": "input", + "git_blob": "20585e44fa4e49b13b5d8495bbf6ed254459a362", + "sha256": "d1423ac0ea0003521797209f4396e6981a66994bbee4f8b48026e5b95f8c5116" + }, + { + "path": "research/unconditional-batched-crt/vendor/SHALLOW-TOEPLITZ.md", + "usage": "input", + "git_blob": "bc4349b2daea548ffa09e1f38a31f1df86b0b7be", + "sha256": "b384b93f3fb4a8c97da2e617ebc14d55cebb0a739070e7f8dbb66f63e24e9310" + } + ] +} diff --git a/research/source-remaining-diagonal/retained/fft/VENDOR.json b/research/source-remaining-diagonal/retained/fft/VENDOR.json new file mode 100644 index 0000000000..ae23608262 --- /dev/null +++ b/research/source-remaining-diagonal/retained/fft/VENDOR.json @@ -0,0 +1,84 @@ +{ + "source_repository": "CubeJerry/integer-mult-bounds", + "public_commit": "d51859e7816771f627033b23db0f9786ada863f8", + "local_author_commit": "f94b50b92dbbbc3c41aba5b2e353e4706d5b6fca", + "tree": "c7349ceff1e9fc5634db3a80cd881da40252209b", + "files": [ + { + "path": "vendor/full/sources.py", + "source_path": "research/full-global-tensor-caller/sources.py", + "bytes": 2614, + "sha256": "fa1151e5d482a8b4c604754b6a5a14c7c22c1a017fb713ce29a3e37bd557f718", + "git_blob": "f8cebf330fd5d1b81be5bd1855d4e4e0e0070a6a" + }, + { + "path": "vendor/full/SOURCES.json", + "source_path": "research/full-global-tensor-caller/SOURCES.json", + "bytes": 9271, + "sha256": "9af528ad94beacce0a859bb1ae6af95c2419e2a0dfaf7cafbd9563ccc3b4e945", + "git_blob": "83d5d82738c3965fa2b412c450db999115b1ac37" + }, + { + "path": "vendor/full/compiler.py", + "source_path": "research/full-global-tensor-caller/compiler.py", + "bytes": 17256, + "sha256": "d16ffd1f09efda2c1ce27fd68c64b7039a07903042440c97195eb392ef8d5c68", + "git_blob": "802b917e8bc2ca6629c3fb7df9a14c55d8c9ebcd" + }, + { + "path": "vendor/full/reference.py", + "source_path": "research/full-global-tensor-caller/reference.py", + "bytes": 6690, + "sha256": "8d762677657a7ad0863096dba3214ed50d1260ca0ab1487ab44d3bef8724de0c", + "git_blob": "255bdf15079d41acca4ee27092bdabbb29a7ca70" + }, + { + "path": "vendor/full/physical_engine.py", + "source_path": "research/full-global-tensor-caller/physical_engine.py", + "bytes": 17210, + "sha256": "072306676a44c1fc130aedf9ca7ae2d1bdcca2309b77661b3bb4523bcb4fe7f3", + "git_blob": "7164f0921eb3c824e5e7bda4c72359f2928491e1" + }, + { + "path": "vendor/full/physical_controls.py", + "source_path": "research/full-global-tensor-caller/physical_controls.py", + "bytes": 4671, + "sha256": "d5fbe750e26fe71eb08ded86ebec06ca92c3390ba0d516676489f3231f93540c", + "git_blob": "83a85800306fb0d892f313230c61847a02ea906f" + }, + { + "path": "vendor/full/physical_sources.py", + "source_path": "research/full-global-tensor-caller/physical_sources.py", + "bytes": 3644, + "sha256": "b23d201c1b449301400db446f68f1b30a43049141654754d03c3e1c4c20697bc", + "git_blob": "5451de1ba3426c6122d88b20a8d157d36cf4046c" + }, + { + "path": "vendor/full/vendor/global-boundary/frontend.py", + "source_path": "research/full-global-tensor-caller/vendor/global-boundary/frontend.py", + "bytes": 11216, + "sha256": "0847d68370f72c2eb0ac07be0746b59a2f88d7a555aff21c157f0fd7a61620a5", + "git_blob": "890a67ea1ed36541d98027271f141aa8b3400c10" + }, + { + "path": "vendor/full/vendor/global-boundary/bridge.py", + "source_path": "research/full-global-tensor-caller/vendor/global-boundary/bridge.py", + "bytes": 17737, + "sha256": "445d7150a61032f83bd5406ae8083bdf0ce5b937eebdf76a3ff7291b8e31a5da", + "git_blob": "4b9f0042ebe2c62a5be515ffbcae1d62693d5ae6" + }, + { + "path": "vendor/full/verify_physical.py", + "source_path": "research/full-global-tensor-caller/verify_physical.py", + "bytes": 13283, + "sha256": "a19db64aaf7f2135818c95be0b7a7ad6db97625b094753c7ed3aa9ae978358d1", + "git_blob": "3998e503bd7bc45f091360689d2b015b13e6f1fe" + } + ], + "reason": "Actual retained source producer and physical stage methods, not copies for provenance only; original notices retained.", + "numerical_review": { + "public_commit": "85e0534b3a86dc0237f368ff0e5fb646fe4744ec", + "proof_sha256": "faafe8a28505a851367839bfa6eb06a5c67392714aeb2dfc16733816a51f990f", + "runtime_input": false + } +} diff --git a/research/source-remaining-diagonal/retained/fft/join_engine.py b/research/source-remaining-diagonal/retained/fft/join_engine.py new file mode 100644 index 0000000000..4b410a9e3b --- /dev/null +++ b/research/source-remaining-diagonal/retained/fft/join_engine.py @@ -0,0 +1,55 @@ +"""Explicit fast-scalar owner for unchanged source-emitted Full stages. + +Prepared for @CubeJerry with substantial OpenAI Codex assistance. Apache-2.0. +This is a new owner ABI. The original Karatsuba-only constructor is unchanged. +""" +from fft_word_sources import active +active() +from fft_word_engine import FftWord +from fft_arithmetic import Arithmetic +from global_h_boundary import GlobalBoundary +from physical_engine import (FullPhysical,NullCounters,UnobservedArithmetic, + private_tapes) +from ring_engine import RingProduct +from twiddle_setup import Twiddles +from word_product import WordProduct +from words import BLANK,need + +PRODUCTION_CUTOFF=4096 + + +class FastFullPhysical(FullPhysical): + """Same stage methods; an explicitly declared exact FftWord child.""" + def __init__(self,root,*,base_bits=PRODUCTION_CUTOFF,observe=None): + # This class declares its own constructor contract. It does not call, + # patch or pass an inadmissible argument to FullPhysical.__init__. + GlobalBoundary.__init__(self,root,observe) + self.word=FftWord(base_bits=base_bits) + need(type(self.word) is FftWord and type(self.word.base) is WordProduct + and type(self.word.product) is RingProduct + and type(self.word.product.word) is WordProduct + and type(self.word.product.twiddles) is Twiddles + and self.word.base is not self.word.product.word, + 'actual acyclic FFT-word owner graph') + self.arithmetic=(Arithmetic if observe is not None else UnobservedArithmetic)(self.word,self.scope) + self.full_calls=dict(admissions=0,lifts=0,H=0,diagonals=0,shrinks=0) + if observe is None: + for owner in (self,self.word,self.word.base,self.word.product,self.word.product.word): + owner.calls=NullCounters(owner.calls) + self.full_calls=NullCounters(self.full_calls) + self.word.product.arithmetic=UnobservedArithmetic(self.word.product.word, + self.word.product.scope) + self.private=private_tapes(self) + + def idle(self): + GlobalBoundary.idle(self) + self.word.idle() + need(self.word.closed and self.word.a is self.word.b is None + and not self.word.pool.live and self.word.output.read()==BLANK, + 'consumed complete exact FFT-word child') + + +def production_owner(): + """The unchanged native H owner and one fixed-cutoff exact FFT scalar.""" + from composed_engine import production_layer + return FastFullPhysical(production_layer()) diff --git a/research/source-remaining-diagonal/retained/fft/join_sources.py b/research/source-remaining-diagonal/retained/fft/join_sources.py new file mode 100644 index 0000000000..9106ff1a3a --- /dev/null +++ b/research/source-remaining-diagonal/retained/fft/join_sources.py @@ -0,0 +1,202 @@ +"""One cold authenticated Full/FftWord/H source cohort. + +Prepared for @CubeJerry with substantial OpenAI Codex assistance. Apache-2.0. +The byte-identical retained sources preserve their authors and notices. +""" +from contextlib import contextmanager +from hashlib import sha1,sha256 +import importlib +import importlib.util +import json +from pathlib import Path +import sys +import tarfile +import tempfile + +HERE=Path(__file__).resolve().parent +ROOT=HERE.parents[1] +FULL=HERE/'vendor/full' + + +def need(condition,message): + if not condition: + raise ValueError(message) + + +def blob(raw): + return sha1(b'blob '+str(len(raw)).encode()+b'\0'+raw).hexdigest() + + +def authenticate(): + rows=[r for r in json.loads((HERE/'SOURCES.json').read_text())['files'] + if r['usage']=='input'] + checked={} + for row in rows: + path=ROOT/row['path'] + need(path.is_file() and not path.is_symlink(),'regular scalar-join source: '+row['path']) + raw=path.read_bytes() + need(row['path'] not in checked and sha256(raw).hexdigest()==row['sha256'] + and blob(raw)==row['git_blob'],'exact scalar-join source: '+row['path']) + checked[row['path']]=row['sha256'] + manifest=json.loads((HERE/'VENDOR.json').read_text()) + for row in manifest['files']: + path=HERE/row['path'] + need(path.is_file() and not path.is_symlink(),'regular retained Full source') + raw=path.read_bytes() + need(len(raw)==row['bytes'] and sha256(raw).hexdigest()==row['sha256'] + and blob(raw)==row['git_blob'],'byte-identical retained Full source: '+row['path']) + return checked + + +def load(name,path): + need(name not in sys.modules,'cold scalar-join module: '+name) + spec=importlib.util.spec_from_file_location(name,path) + module=importlib.util.module_from_spec(spec) + sys.modules[name]=module + try: + spec.loader.exec_module(module) + except BaseException: + sys.modules.pop(name,None) + raise + return module + + +@contextmanager +def full_sources(): + """Use the retained loader's explicit raw-source argument unchanged.""" + authenticate() + names=('sources','compiler','reference') + need(not any(name in sys.modules for name in names),'cold Full preparation aliases') + modules={} + manifest=json.loads((FULL/'SOURCES.json').read_text()) + raw={row['path']:(ROOT/row['path']).read_bytes() for row in manifest['files'] + if row['usage']=='input'} + # Preserve the retained loader's relative layout without modifying ROOT, + # code, or any authentication operation. Its nested lowering loader reads + # its exact SOURCES.json from that layout even with explicit raw inputs. + with tempfile.TemporaryDirectory(prefix='full-source-layout-') as directory: + mirror=Path(directory) + package=mirror/'research/full-global-tensor-caller' + package.mkdir(parents=True) + for filename in (*[name+'.py' for name in names],'SOURCES.json'): + (package/filename).write_bytes((FULL/filename).read_bytes()) + lower_manifest=mirror/'research/rational-fft-fixed-h/SOURCES.json' + lower_manifest.parent.mkdir(parents=True) + lower_manifest.write_bytes(raw['research/rational-fft-fixed-h/SOURCES.json']) + try: + for name in names: + modules[name]=load(name,package/(name+'.py')) + dense,lower,source=modules['sources'].load(overrides=raw) + yield dense,lower,source,modules['compiler'],modules['reference'] + finally: + for name,module in modules.items(): + if sys.modules.get(name) is module: + del sys.modules[name] + + +def archived_python(): + """Read only metadata/source bytes in the already authenticated archive. + + All nested tar bytes are covered by its fixed outer digest. No extraction + or source execution occurs in this inventory pass. + """ + result={} + def visit(handle): + with tarfile.open(fileobj=handle,mode='r:') as archive: + for member in archive.getmembers(): + if not member.isfile(): + continue + if member.name.endswith('.py'): + name=Path(member.name).stem + if name.isidentifier(): + raw=archive.extractfile(member).read() + result.setdefault(name,set()).add(sha256(raw).hexdigest()) + elif member.name.endswith('.tar'): + with archive.extractfile(member) as nested: + visit(nested) + with (ROOT/'research/physical-fft-word/inputs/ring-export.tar').open('rb') as handle: + visit(handle) + recorded=json.loads((HERE/'COLD-NAMES.json').read_text()) + need(recorded['names']==sorted(result),'complete archived Python cold-name inventory') + return result + + +def imported_bytes(inventory): + checked=0 + for name,hashes in inventory.items(): + module=sys.modules.get(name) + if module is None: + continue + path=Path(getattr(module,'__file__','')) + need(path.is_file() and not path.is_symlink() + and sha256(path.read_bytes()).hexdigest() in hashes, + 'actual authenticated imported scalar/H source: '+name) + checked+=1 + return checked + + +@contextmanager +def opened(): + """Open the exact FftWord child, then bind unchanged Full methods to it.""" + authenticate() + inventory=archived_python() + extra=('fft_word_sources','fft_word_plan','fft_word_codec','fft_word_engine', + 'physical_sources','physical_controls','physical_engine', + 'frontend','global_h_boundary','join_engine') + need(not any(name in sys.modules for name in set(inventory).union(extra)), + 'one cold Full/FftWord/H cohort') + # These additional files are authenticated above and loaded explicitly. + explicit={name:ROOT/'research/physical-fft-word'/(name+'.py') + for name in ('fft_word_sources','fft_word_plan','fft_word_codec','fft_word_engine')} + explicit.update({name:FULL/(name+'.py') + for name in ('physical_sources','physical_controls','physical_engine')}) + explicit.update(frontend=FULL/'vendor/global-boundary/frontend.py', + global_h_boundary=FULL/'vendor/global-boundary/bridge.py') + for name,path in explicit.items(): + inventory.setdefault(name,set()).add(sha256(path.read_bytes()).hexdigest()) + old_path=sys.path[:] + try: + word_path=ROOT/'research/physical-fft-word' + sys.path.insert(0,str(word_path)) + source=load('fft_word_sources',word_path/'fft_word_sources.py') + with source.opened() as state: + for name in ('fft_word_plan','fft_word_codec','fft_word_engine'): + module=importlib.import_module(name) + need(Path(module.__file__).resolve()==(word_path/(name+'.py')).resolve(), + 'actual authenticated FFT-word source path: '+name) + for name in ('word_product','ring_words','fft_arithmetic','product_plan', + 'twiddle_setup','ring_engine'): + module=importlib.import_module(name) + need(Path(module.__file__).resolve()==(state.ring_package/(name+'.py')).resolve(), + 'actual retained normalized-product source path: '+name) + expected={ + 'composed_sources':'5b9a507a5f5eb7d32d76792cac4b876070d29e91', + 'composed_engine':'646c451a4cbdf0244c7782d958f257f6606b962f', + 'composed_plan':'300ee75d4171c8f0d97118a01a4e439b72ca01d6', + } + for name,identity in expected.items(): + module=importlib.import_module(name) + need(blob(Path(module.__file__).read_bytes())==identity, + 'identical retained raw-H source: '+name) + load('frontend',FULL/'vendor/global-boundary/frontend.py') + boundary=load('global_h_boundary',FULL/'vendor/global-boundary/bridge.py') + # The old source module supplies only its unchanged `need` here. + # Its opened() and Karatsuba-only constructor are never invoked. + load('physical_sources',FULL/'physical_sources.py') + load('physical_controls',FULL/'physical_controls.py') + full=load('physical_engine',FULL/'physical_engine.py') + from cardinal_counts import Count + from records import Tape + from fft_word_engine import FftWord + from fft_arithmetic import Arithmetic + need(full.Count is boundary.Count is Count and full.Tape is boundary.Tape is Tape + and full.Arithmetic is Arithmetic,'one exact Count/Tape/signed-arithmetic identity') + state.full_class=full.FullPhysical + state.fast_word_class=FftWord + state.full_boundary=boundary + state.fast_full=load('join_engine',HERE/'join_engine.py') + state.authenticated_imports=imported_bytes(inventory) + yield state + imported_bytes(inventory) + finally: + sys.path[:]=old_path diff --git a/research/source-remaining-diagonal/retained/fft/vendor/full/SOURCES.json b/research/source-remaining-diagonal/retained/fft/vendor/full/SOURCES.json new file mode 100644 index 0000000000..83d5d82738 --- /dev/null +++ b/research/source-remaining-diagonal/retained/fft/vendor/full/SOURCES.json @@ -0,0 +1,222 @@ +{ + "schema_version": 1, + "base_commit": "7c49fe32c55de02c2c873655c804b16e4c3fef0a", + "files": [ + { + "path": "certificates/selected-result.json", + "usage": "provenance", + "git_blob": "d59b5035e7b4cbaa9d688a1d32dd0d6eb79c466a", + "sha256": "9b8d0eea95b3bf0dfcb7938a732a6439b87a2685dec2a5ab9e525b3b34debbfa" + }, + { + "path": "docs/research/agent-task-catalog.json", + "usage": "provenance", + "git_blob": "3404fbdd5e7529a0674eef26114b5071e4586cec", + "sha256": "ead6cdc9d0af6d58e8a49744d8ec8c7c15e13d2ba93c276c434bcf9b51b93a81" + }, + { + "path": "research/capped-phase-fusion/TENSOR-COMPILER.md", + "usage": "input", + "git_blob": "19efb9cb1c5a738e57caadf2dd6f5611af1bc78a", + "sha256": "4d3b8466598a864a234b978e25976648d4e761840aad9153dd18d73d3dfe4d15" + }, + { + "path": "research/capped-phase-fusion/evidence/inplace_algebra_ultra/check_circuits.py", + "usage": "input", + "git_blob": "f80c141c8116b163c2bb5a028c28212077c8d5a9", + "sha256": "06d1861bfe8af543908e26557ffda7e451ff176bceb9bacfaf0f04f234b336d5" + }, + { + "path": "research/capped-phase-fusion/evidence/inplace_algebra_ultra/check_tensor_compiler.py", + "usage": "input", + "git_blob": "5eb5c1ffd23932ba7ccaa0d7686a5b875a3b1809", + "sha256": "dc4b1f1884489215a2c2d0e8978a241e99e6c8c9f1d2fa2460c73d2c7d4ba30a" + }, + { + "path": "research/cubic-cyclic-inverse/vendor/PR628-NOTICE.md", + "usage": "input", + "git_blob": "22fbeb8ef0a28dd6b3feea718492091319ceb96e", + "sha256": "abeacf1ad1491d5797cfcf1f3832799bbf3b24b99597229d7bc884059a51ec68" + }, + { + "path": "research/cubic-cyclic-inverse/vendor/PR628-PROOF.md", + "usage": "input", + "git_blob": "fb8fe7cb3bd036c69047ae7b4f4009a51b11825b", + "sha256": "595893609764c64a90d9b21b9cbd6d9e61980703f3deb43361105cf8c3d1d093" + }, + { + "path": "research/cubic-cyclic-inverse/vendor/interval_kernel.py", + "usage": "input", + "git_blob": "1182175a55cb871481de0f56ea9ae56e474705fe", + "sha256": "9b7bb24640a9a7d3f83c7951dfef483ec933db4c50de6c0130b85f450eeddfbe" + }, + { + "path": "research/gaussian-height-contract/CALLER.md", + "usage": "input", + "git_blob": "9754af67d2109153ec019877f824708bf9ff988e", + "sha256": "0f6687778b0dd2b5046ced1bcda13970b2f45c35186bb00ae205c682590b8668" + }, + { + "path": "research/gaussian-height-contract/check_caller.py", + "usage": "input", + "git_blob": "db4382fbd836923aeda5b670ba71a27f6ebd9521", + "sha256": "5e16aefe99bc3f4086e41b3fa6349b2796201d1ed1bbdbc304f48e23af7fcf73" + }, + { + "path": "research/physical-ring-product/PROOF.md", + "usage": "input", + "git_blob": "2bc9926799296bb348193e68e55aed60ec6ce96d", + "sha256": "a2e43fe5f77350958c2d7d66a50389e5ec6b439a7f9620e94862b969e88fb500" + }, + { + "path": "research/physical-ring-product/fft_arithmetic.py", + "usage": "input", + "git_blob": "606bb6c5e32ca813c927fba1a45315aae3e7de52", + "sha256": "bf7deff44f15f3349fcec98d0e86a6d20820f49ca008892fef9456b3629509e0" + }, + { + "path": "research/physical-ring-product/inputs/fourier-export.tar", + "usage": "input", + "git_blob": "6f7f9d59abdf5d98cbecde1583db61103c1cd973", + "sha256": "30e460df0428ea1ff72dba6528537e53aec62fcec5dc6077bf736afd5cbbc7e8" + }, + { + "path": "research/physical-ring-product/ring_sources.py", + "usage": "input", + "git_blob": "40a4b21a6ffd89d20051fac8055998fac252f130", + "sha256": "82f469acd7f8960ab6b32698e5300a377eb3f18f015f1f129f84604181cac746" + }, + { + "path": "research/physical-ring-product/ring_words.py", + "usage": "input", + "git_blob": "1cb44ce6d95a1e0f9d2c6f78ecd5c7a8e8b39ba9", + "sha256": "6bd18c8f78c94b8a0b97512b4f45c03f88b608e895d0f120296585976e1e8104" + }, + { + "path": "research/physical-ring-product/word_product.py", + "usage": "input", + "git_blob": "67e09e91103535fd1eb0b2d7d6db1fdc13de07d2", + "sha256": "12020ed0571fa756c2d19942b6ccdd6dc5627fdaadb388051417a618c14417d6" + }, + { + "path": "research/rational-fft-fixed-h/DENSE-PROOF.md", + "usage": "input", + "git_blob": "3ee98912ec954824f2a9a0ccdecffce8583832f8", + "sha256": "aa16b3c3124f8b33846319629532cd81106ff8f2a86750c2c327b6cdf6201b85" + }, + { + "path": "research/rational-fft-fixed-h/SOURCES.json", + "usage": "input", + "git_blob": "220b267ed60866653330b7e3d2136d741e40a095", + "sha256": "8d1e091cd6a7b92519bb402d546da73e9f1aca428425ed9caf7f9db922365102" + }, + { + "path": "research/rational-fft-fixed-h/dense.py", + "usage": "input", + "git_blob": "7a48c8d2d566ff64d370c4cb8f793f5cf989c072", + "sha256": "b94d74ede0cced358f0c56646b1dc1e8cb182bbb215ebb40cf56e1d3d262a3f5" + }, + { + "path": "research/rational-fft-fixed-h/lowering.py", + "usage": "input", + "git_blob": "5c2adcfd96f1b2d5987f04242434cd30fdfc33d0", + "sha256": "93b6e86c81a8f12e80688a8f7ec8ddaffedd729fe46b02554b6ed1c135fdd397" + }, + { + "path": "research/rational-fft-fixed-h/vendor/PROVENANCE.json", + "usage": "input", + "git_blob": "22cf8bdcb94f8fff0d1f3f9a38ce9402cc0013df", + "sha256": "302a23bacdb464ef8f1c5d6c87cf72ce846c52c34bd69d245a51c1972e9852f2" + }, + { + "path": "research/rational-fft-fixed-h/vendor/full_source/FULL-PROOF.md", + "usage": "input", + "git_blob": "e650f46863115f810e27b403f916dd7f79b37786", + "sha256": "acf8c596d91b5efd35a286735d6867ff8afce64354a13f680c2fae3dab824410" + }, + { + "path": "research/rational-fft-fixed-h/vendor/full_source/GENERATOR-PROOF.md", + "usage": "input", + "git_blob": "8bef383eec887450e86f14365a6f7b07c1310e9d", + "sha256": "cddda1f944299a349c837808b349fa6e4499cbb1889f7dacc00ca8afac9b580c" + }, + { + "path": "research/rational-fft-fixed-h/vendor/full_source/PROOF.md", + "usage": "input", + "git_blob": "99a55596f67ae3b94ef02ebb159b313f33bf22af", + "sha256": "50e31e33e1275a133d10e87208ceb50dddce67d0678d2a89de9f7ba28d8380d9" + }, + { + "path": "research/rational-fft-fixed-h/vendor/full_source/PROVENANCE.json", + "usage": "input", + "git_blob": "9d848703ed1e2cae899951bb5660de7ab8335d5b", + "sha256": "209f50a6f131db73364989048188c0fec007b20f031b5719e6c8bddac1d37888" + }, + { + "path": "research/rational-fft-fixed-h/vendor/full_source/TRIANGLE-PROOF.md", + "usage": "input", + "git_blob": "f923f4ff2dfe40401fa90d83727ade62b2ef5b5f", + "sha256": "abea26e3c86a9970225b070be034c47e7970e10fe1b5686f405e0b301acf3159" + }, + { + "path": "research/rational-fft-fixed-h/vendor/full_source/full.py", + "usage": "input", + "git_blob": "7f85ad1a89e81b7dfc6b54e7bd9547120e86d5d3", + "sha256": "1f42d5f2858564ffb320e54ba6aa29651025491569823e25006bf5862457b803" + }, + { + "path": "research/rational-fft-fixed-h/vendor/full_source/generator.py", + "usage": "input", + "git_blob": "d761d3c88b1685fb64d92d69f699b8218c9ec30f", + "sha256": "827ef9fe1bd664859995892b59843c390f7969c938fb7e1e6dc585c31a54b555" + }, + { + "path": "research/rational-fft-fixed-h/vendor/full_source/triangular.py", + "usage": "input", + "git_blob": "2bd8de01a7ac80de7e6b9f8252bc69d0e0a291e8", + "sha256": "46780d95ddebfed22e8f0c18565fe2e768250afa5beeb31f450292cc06f7ec11" + }, + { + "path": "research/rational-fft-fixed-h/vendor/full_source/vendor/STEIN-PROVENANCE.json", + "usage": "input", + "git_blob": "c602fb5bb332dbe098950b14d55da05ce2cf4312", + "sha256": "e7f0e8dc517387e302b1e8bf5dff7e12b29da8aa91abc6ea597f33c1ac08ba62" + }, + { + "path": "research/rational-fft-fixed-h/vendor/full_source/vendor/stein_rational.py", + "usage": "input", + "git_blob": "71b240a460a185ee2fe926cd189b56aeac6f997f", + "sha256": "3065fc5d6d22ec44de533b08fb0c639603449456383668e561dc46629e641502" + }, + { + "path": "research/rational-fft-fixed-h/vendor/rational_fft/engine.py", + "usage": "input", + "git_blob": "e9f2f2b08dc2bc4c646e47dca92059351ca89384", + "sha256": "9e36aee0835e6b1b62997433581f88b5a434ccab8ae43e5c25d1deaaf1ebf653" + }, + { + "path": "research/rational-fft-fixed-h/vendor/rational_fft/exact.py", + "usage": "input", + "git_blob": "aae41e6acfb2e5a4fafdd85727891eb746b57b42", + "sha256": "c9b89d7357210af69865690ba12e695366961f8b501a8fab9d0fefe3fb30c479" + }, + { + "path": "research/unconditional-batched-crt/GAUSSIAN.md", + "usage": "input", + "git_blob": "adfb28c93e6b06178c901caaac39ede41a9e541b", + "sha256": "2f63c91c58f2d1cf31294812c75970ea390c61866a8da7ed700d4316a033a242" + }, + { + "path": "research/unconditional-batched-crt/vendor/GAUGEFREE-INTERIORS.md", + "usage": "input", + "git_blob": "20585e44fa4e49b13b5d8495bbf6ed254459a362", + "sha256": "d1423ac0ea0003521797209f4396e6981a66994bbee4f8b48026e5b95f8c5116" + }, + { + "path": "research/unconditional-batched-crt/vendor/SHALLOW-TOEPLITZ.md", + "usage": "input", + "git_blob": "bc4349b2daea548ffa09e1f38a31f1df86b0b7be", + "sha256": "b384b93f3fb4a8c97da2e617ebc14d55cebb0a739070e7f8dbb66f63e24e9310" + } + ] +} diff --git a/research/source-remaining-diagonal/retained/fft/vendor/full/compiler.py b/research/source-remaining-diagonal/retained/fft/vendor/full/compiler.py new file mode 100644 index 0000000000..802b917e8b --- /dev/null +++ b/research/source-remaining-diagonal/retained/fft/vendor/full/compiler.py @@ -0,0 +1,308 @@ +"""Actual heterogeneous Full words emitted as one complete global program. + +This is a new global rounded execution, not a tensor power of local rounders. +Prepared for @CubeJerry with substantial OpenAI Codex assistance. Apache-2.0. +The Full/fixed-word compiler is credited to #4205/#4253; cache bounds to #4178. +""" +from dataclasses import dataclass +from fractions import Fraction as Q +from hashlib import sha256 +import json +from math import prod + +from sources import need,exact_preparation + + +def canonical(value): + return json.dumps(value,sort_keys=True,separators=(',',':')).encode() + + +def ceil_log2(value): + value = Q(value) + need(value > 0,'positive logarithm argument') + k = value.numerator.bit_length()-value.denominator.bit_length() + bound = Q(1 << k) if k >= 0 else Q(1,1 << -k) + return k if bound >= value else k+1 + + +def power_two(value): + return type(value) is int and value > 0 and value & (value-1) == 0 + + +def freeze(stages): + return tuple((kind,value if kind == 'H' else tuple((Q(z),Q(0)) if type(z) in (int,Q) + else (z.re,z.im) for z in value)) + for kind,value in stages) + + +def word_hash(stages): + return sha256(canonical([(kind,value if kind == 'H' else + [(str(a),str(b)) for a,b in value]) + for kind,value in stages])).hexdigest() + + +def signature(stages): + return tuple((kind,value if kind == 'H' else None) for kind,value in stages) + + +def truncate_fraction(value,bits): + return int(value*(1 << bits)) + + +@dataclass(frozen=True) +class Hadamard: + step: int + array_bits: int + positions: tuple[int,...] + fractional_bits: int + data_width: int + + def validate(self): + need(type(self.array_bits) is int and self.array_bits >= 1,'global field bits') + need(self.positions and len(set(self.positions)) == len(self.positions) + and all(type(p) is int and 0 <= p < self.array_bits for p in self.positions), + 'complete global H mask') + need(type(self.fractional_bits) is int and self.fractional_bits >= 1 + and type(self.data_width) is int and self.data_width >= self.fractional_bits+2, + 'global H common grid and signed width') + + +@dataclass(frozen=True) +class Diagonal: + step: int + coarse_bits: int + axis_bits: int + axes: int + fractional_bits: int + data_width: int + factor_width: int + cache_width: int + temporary_width: int + pages: tuple + + @property + def array_bits(self): + return self.coarse_bits+self.axes*self.axis_bits + + def validate(self): + need(type(self.coarse_bits) is int and self.coarse_bits >= 0 + and type(self.axis_bits) is int and self.axis_bits >= 1 + and type(self.axes) is int and self.axes >= 1,'global diagonal geometry') + need(len(self.pages) == 1 << self.coarse_bits + and all(len(block) == self.axes and all(len(row) == 1 << self.axis_bits + for row in block) for block in self.pages),'all encoded factor pages') + need(all(len(z) == 2 for block in self.pages for row in block for z in row), + 'complex encoded factor records') + need(all(type(x) is int and -(1 << (self.factor_width-1)) <= x < 1 << (self.factor_width-1) + for block in self.pages for row in block for z in row for x in z), + 'encoded factor word widths') + + +class FullTensor: + """Prepare actual Full roots; synchronize only with complete idle words. + + A service consumes complete global integer arrays on one common F-grid. + H returns exact raw H; D computes the declared rounded suffix product and + data multiplication. Physical services, not this producer, own tape work. + """ + @exact_preparation + def __init__(self,dense,lower,source,matrices,directions,*,target=16, + radius_bits=0,incoming=0,indices=None,fractional_bits=None): + self.dense,self.lower,self.source = dense,lower,source + self.labels,self.axes = len(matrices),len(matrices[0]) if matrices else 0 + need(power_two(self.labels) and self.axes >= 1 + and all(len(block) == self.axes for block in matrices),'complete coarse/axis family') + self.size = len(matrices[0][0]) + need(power_two(self.size) and self.size >= 2 + and all(len(matrix) == self.size and all(len(row) == self.size for row in matrix) + for block in matrices for matrix in block),'uniform complete dyadic Full sides') + need(len(directions) == self.labels and all(len(row) == self.axes + and all(type(x) is bool for x in row) for row in directions),'every actual Full direction') + need(type(target) is int and target >= 1 and type(radius_bits) is int and radius_bits >= 0 + and type(incoming) is int and incoming >= 0,'global exact accuracy/radius/grid') + self.directions = tuple(tuple(row) for row in directions) + self.target,self.radius_bits,self.incoming = target,radius_bits,incoming + self.radius = 1 << radius_bits + self.coarse_bits,self.axis_bits = self.labels.bit_length()-1,self.size.bit_length()-1 + self.array_bits = self.coarse_bits+self.axes*self.axis_bits + self.records = 1 << self.array_bits + self.tau = Q(1,1 << target) + if indices is None: + indices = [[list(range(self.size)) for _ in range(self.axes)] for _ in range(self.labels)] + need(len(indices) == self.labels and all(len(block) == self.axes for block in indices), + 'every source wire permutation') + admission = [[source.full.admission(source.e.Mat(matrix)) for matrix in block] for block in matrices] + endpoints = [[admission[c][a][int(self.directions[c][a])] for a in range(self.axes)] + for c in range(self.labels)] + exact_endpoint = max(x for block in endpoints for x in block) + self.preparation_target = target+ceil_log2(8*self.axes*self.radius*(exact_endpoint+1)**(self.axes-1)) + self.roots = [[dense.FullRoot(source,matrix,1,self.preparation_target,indices[c][a]) + for a,matrix in enumerate(block)] for c,block in enumerate(matrices)] + self.programs = [[root.lower(self.directions[c][a],incoming=0) + for a,root in enumerate(block)] for c,block in enumerate(self.roots)] + self.depths = tuple(tuple(p.logical_layers for p in block) for block in self.programs) + self.layers = max(n for block in self.depths for n in block) + self.padding = dense.NativeProgram(source,self.size,[[]],1,1,1,1) + self.idle_word = freeze(self.padding.raw_stages) + self.idle_seal = word_hash(self.idle_word) + self.layer_signature = signature(self.idle_word) + self.layer_stages = 16*self.axis_bits+5 + need(len(self.idle_word) == self.layer_stages,'actual complete idle compiler word') + self.words = tuple(tuple(freeze(p.raw_stages) for p in block) for block in self.programs) + self.word_seals = tuple(tuple(word_hash(w) for w in block) for block in self.words) + for c,block in enumerate(self.words): + for a,word in enumerate(block): + need(len(word) == self.depths[c][a]*self.layer_stages,'whole source matching layers') + need(signature(word) == self.layer_signature*self.depths[c][a], + 'actual coefficient-independent H signature') + self.stages = self.layers*self.layer_stages + self.diagonal_count = self.layers*(8*self.axis_bits+3) + self.h_count = self.layers*(8*self.axis_bits+2) + self.prefix = max(prod(2*p.compiled_bound for p in block) for block in self.programs) + self.endpoint = max(prod(p.endpoint for p in block) for block in self.programs) + defects=[] + for c,block in enumerate(self.programs): + suffix=[Q(1)]*(self.axes+1) + for a in range(self.axes-1,-1,-1): + suffix[a]=endpoints[c][a]*suffix[a+1] + preceding,total=Q(1),Q(0) + for a,p in enumerate(block): + total += preceding*p.upstream_error*suffix[a+1] + preceding *= p.endpoint + defects.append(total) + self.source_operator_defects=tuple(defects) + self.source_error=self.radius*max(defects) + need(self.source_error <= self.tau/8,'funded complete source tensor defect') + values = [abs(a)+abs(b) for block in self.words for word in block + for kind,page in word if kind == 'D' for a,b in page] + values += [abs(a)+abs(b) for kind,page in self.idle_word if kind == 'D' for a,b in page] + bound = max(Q(1),*values) + self.factor_bound = -(-bound.numerator//bound.denominator) + b,A,E,R,D,g = self.factor_bound+1,self.prefix,self.endpoint,self.radius,self.diagonal_count,self.axes + self.norm_conversion = 1 << ((self.array_bits+1)//2) + self.coefficient_constant = 8*E*D*A*A*g*b**(g-1)*R + self.rounding_constant = 4*E*A*D*self.norm_conversion + minimum = max(incoming,1,target+ceil_log2(4*(self.coefficient_constant+self.rounding_constant))) + self.bits = minimum if fractional_bits is None else fractional_bits + need(type(self.bits) is int and self.bits >= minimum,'funded global common grid') + self.unit = Q(1,1 << self.bits) + self.diagonal_error = 4*g*b**(g-1)*self.unit + self.perturbation = D*A*A*self.diagonal_error + self.arithmetic_error = (self.coefficient_constant+self.rounding_constant)*self.unit + need(self.perturbation <= Q(1,2) and self.arithmetic_error <= self.tau/4, + 'global perturbed-prefix and complete numerical budgets') + self.total_error = self.source_error+self.arithmetic_error + need(self.total_error < self.tau,'strict complete root target') + self.amplitude = 4*A*(R+1) + self.amplitude_bits = ceil_log2(self.amplitude) + self.cache_bits = ceil_log2(2*b**g) + self.factor_width = self.bits+ceil_log2(b)+2 + self.data_width = self.bits+self.amplitude_bits+2 + self.cache_width = self.bits+self.cache_bits+2 + self.temporary_width = 2*self.bits+max(self.amplitude_bits,ceil_log2(b))+self.cache_bits+3 + self._seal = self._allocation_seal() + self.validate() + + def _allocation_seal(self): + names = ('labels','axes','size','target','radius_bits','radius','incoming','tau', + 'coarse_bits','axis_bits','array_bits','records','preparation_target','depths', + 'layers','layer_stages','layer_signature','idle_seal','word_seals','stages', + 'diagonal_count','h_count','prefix','endpoint','source_operator_defects','source_error', + 'factor_bound','norm_conversion','coefficient_constant','rounding_constant','bits', + 'unit','diagonal_error','perturbation','arithmetic_error','total_error','amplitude', + 'amplitude_bits','cache_bits','factor_width','data_width','cache_width', + 'temporary_width','directions') + return sha256(canonical({name:str(getattr(self,name)) for name in names})).hexdigest() + + @exact_preparation + def validate(self): + need(self._allocation_seal() == self._seal,'unchanged global request/allocation') + for c,block in enumerate(self.programs): + for a,p in enumerate(block): + need(p.context is self.roots[c][a],'same actual Full root context') + p.context.validate() + need(p.contract_hash() == p.contract_seal + and self.lower.plan_hash(p.source,p.plan) == p.reference_hash + and self.lower.stage_hash(p.source,p.reference_stages) == p.reference_stage_seal + and self.lower.stage_hash(p.source,p.stages) == p.stage_seal, + 'unchanged actual Full/native source') + need(word_hash(freeze(p.raw_stages)) == self.word_seals[c][a] + and word_hash(self.words[c][a]) == self.word_seals[c][a],'immutable source raw pages') + for j,((kind,value),(kind2,reference)) in enumerate(zip(p.raw_stages,p.reference_stages)): + need(kind == kind2,'raw/compensated stage type') + if kind == 'H': + need(value == reference,'raw/compensated bit') + else: + scale = 2 if j and p.raw_stages[j-1][0] == 'H' else 1 + need(all(scale*x == y for x,y in zip(value,reference)), + 'actual immediate H0 compensation relation') + need(freeze(self.padding.raw_stages) == self.idle_word + and word_hash(self.idle_word) == self.idle_seal + and signature(self.idle_word) == self.layer_signature,'immutable compiled identity padding') + + def reference_stage(self,coarse,axis,step): + word = self.words[coarse][axis] + return word[step] if step < len(word) else self.idle_word[step % self.layer_stages] + + def events(self): + self.validate() + for step in range(self.stages): + kind,bit = self.layer_signature[step % self.layer_stages] + if kind == 'H': + event = Hadamard(step,self.array_bits,tuple(a*self.axis_bits+bit for a in range(self.axes)), + self.bits,self.data_width) + else: + pages = tuple(tuple(tuple((truncate_fraction(a,self.bits),truncate_fraction(b,self.bits)) + for a,b in self.reference_stage(c,axis,step)[1]) + for axis in range(self.axes)) for c in range(self.labels)) + event = Diagonal(step,self.coarse_bits,self.axis_bits,self.axes,self.bits,self.data_width, + self.factor_width,self.cache_width,self.temporary_width,pages) + event.validate() + yield event + self.validate() + + def execute(self,values,service): + self.validate() + original = tuple(tuple(z) for z in values) + need(len(original) == self.records and all(len(z) == 2 and all(type(x) is int for x in z) + for z in original),'complete incoming encoded field') + need(all(abs(x).bit_length()+1 <= self.incoming+self.radius_bits+2 + for z in original for x in z),'incoming signed component width') + need(sum(a*a+b*b for a,b in original) <= self.radius*self.radius*(1 << (2*self.incoming)), + 'actual global input Euclidean radius') + state = [(a << (self.bits-self.incoming),b << (self.bits-self.incoming)) for a,b in original] + counts = dict(input_real_squares=2*self.records,initial_component_lifts=2*self.records, + global_H_calls=0,global_diagonal_calls=0,generated_factor_components=0) + for event in self.events(): + if isinstance(event,Hadamard): + returned = service.apply_h(state,event) + counts['global_H_calls'] += 1 + else: + returned = service.apply_diagonal(state,event) + counts['global_diagonal_calls'] += 1 + counts['generated_factor_components'] += 2*self.labels*self.axes*self.size + need(returned is state and len(state) == self.records,'complete in-place global field return') + need(all(len(z) == 2 and all(type(x) is int and -(1 << (self.data_width-1)) <= x + < 1 << (self.data_width-1) for x in z) for z in state), + 'proved completed data width') + need(counts['global_H_calls'] == self.h_count and counts['global_diagonal_calls'] == self.diagonal_count, + 'all padded global events executed') + need(original == tuple(tuple(z) for z in values),'borrowed encoded input preserved') + self.validate() + return state,counts + + @exact_preparation + def record(self): + self.validate() + return dict(labels=self.labels,axes=self.axes,side=self.size,array_bits=self.array_bits, + records=self.records,directions=self.directions,logical_depths=self.depths, + padded_depth=self.layers,padding_layers=sum(self.layers-n for row in self.depths for n in row), + stages=self.stages,global_H_calls=self.h_count,global_diagonal_calls=self.diagonal_count, + target_bits=self.target,incoming_bits=self.incoming,radius_bits=self.radius_bits, + preparation_target_bits=self.preparation_target,global_grid=self.bits, + signed_data_width=self.data_width,factor_width=self.factor_width,cache_width=self.cache_width, + temporary_width=self.temporary_width,source_error_log2_upper=ceil_log2(self.source_error) + if self.source_error else None,arithmetic_error=str(self.arithmetic_error), + total_error=str(self.total_error),prefix_log2_upper=ceil_log2(self.prefix), + endpoint_log2_upper=ceil_log2(self.endpoint),amplitude_bits=self.amplitude_bits, + raw_word_sha256=self.word_seals,allocation_sha256=self._seal) diff --git a/research/source-remaining-diagonal/retained/fft/vendor/full/physical_controls.py b/research/source-remaining-diagonal/retained/fft/vendor/full/physical_controls.py new file mode 100644 index 0000000000..83a8580030 --- /dev/null +++ b/research/source-remaining-diagonal/retained/fft/vendor/full/physical_controls.py @@ -0,0 +1,94 @@ +"""Encode actual immutable Full events, without inspecting payload values. + +Prepared for @CubeJerry with substantial OpenAI Codex assistance. Apache-2.0. +""" +from physical_sources import need + +END, H_EVENT, D_EVENT = 0, 1, 2 +NAMES = ('n','coarse_bits','axis_bits','axes','fractional_bits','data_width', + 'factor_width','cache_width','temporary_width','incoming_bits', + 'incoming_width','radius_bits','position_width','stages','h_count','d_count') + + +def emit_unsigned(tape,value,width): + need(type(width) is int and width >= 0 and type(value) is int + and 0 <= value < 1 << width,'prepared unsigned field') + if width == 0: + return + # One linear byte conversion, then only fixed eight-bit finite arithmetic. + # Repeatedly shifting the full source integer would cost quadratic work. + octets = value.to_bytes((width+7)//8,'little') + for octet in octets[:-1]: + for bit in range(8): + tape.append((octet >> bit) & 1) + for bit in range((width-1)%8+1): + tape.append((octets[-1] >> bit) & 1) + + +def emit_signed(tape,value,width): + need(type(value) is int and -(1 << (width-1)) <= value < 1 << (width-1), + 'prepared signed source coefficient') + emit_unsigned(tape,value if value >= 0 else (1 << width)+value,width) + + +class PreparedFull: + """All online extents are Count tapes; pages come from the actual source.""" + def __init__(self,program,Tape,Count,event_types): + Hadamard,Diagonal = event_types + program.validate() + self.code,self.parameters = Tape(),() + self.event_count = self.h_count = self.d_count = self.page_components = 0 + self.metadata = dict(n=program.array_bits,coarse_bits=program.coarse_bits, + axis_bits=program.axis_bits,axes=program.axes,fractional_bits=program.bits, + data_width=program.data_width,factor_width=program.factor_width, + cache_width=program.cache_width,temporary_width=program.temporary_width, + incoming_bits=program.incoming,incoming_width=program.incoming+program.radius_bits+2, + radius_bits=program.radius_bits,position_width=max(1,(program.array_bits-1).bit_length()), + stages=program.stages,h_count=program.h_count,d_count=program.diagonal_count) + try: + for event in program.events(): + event.validate() + need(event.step == self.event_count and event.array_bits == self.metadata['n'] + and event.fractional_bits == self.metadata['fractional_bits'] + and event.data_width == self.metadata['data_width'], + 'unchanged complete source event geometry and order') + if isinstance(event,Hadamard): + need(len(event.positions) == self.metadata['axes'],'all source-selected H axes') + emit_unsigned(self.code,H_EVENT,2) + for position in event.positions: + emit_unsigned(self.code,position,self.metadata['position_width']) + self.h_count += 1 + else: + need(isinstance(event,Diagonal),'actual Full diagonal event') + for name in ('coarse_bits','axis_bits','axes','factor_width','cache_width','temporary_width'): + need(getattr(event,name) == self.metadata[name],'unchanged source diagonal '+name) + emit_unsigned(self.code,D_EVENT,2) + for block in event.pages: + for page in reversed(block): + for gaussian in page: + for component in gaussian: + emit_signed(self.code,component,event.factor_width) + self.page_components += 1 + self.d_count += 1 + self.event_count += 1 + emit_unsigned(self.code,END,2) + self.code.rewind() + need((self.event_count,self.h_count,self.d_count) == + (program.stages,program.h_count,program.diagonal_count),'all source events exactly once') + program.validate() + self.parameters = tuple(Count.literal(self.metadata[name]) for name in NAMES) + except BaseException: + self.close() + raise + + def run(self,owner,payload): + return owner.run(payload,self.code,*self.parameters) + + def close(self): + from session import erase_marker + for value in self.parameters: + value.close() + erase_marker(value.tape) + self.parameters = () + self.code.clear() + erase_marker(self.code) diff --git a/research/source-remaining-diagonal/retained/fft/vendor/full/physical_engine.py b/research/source-remaining-diagonal/retained/fft/vendor/full/physical_engine.py new file mode 100644 index 0000000000..7164f0921e --- /dev/null +++ b/research/source-remaining-diagonal/retained/fft/vendor/full/physical_engine.py @@ -0,0 +1,363 @@ +"""Whole-field raw H and exact-word rounded complex diagonals on fixed tapes. + +Prepared for @CubeJerry with substantial OpenAI Codex assistance. Apache-2.0. +Retained #3627 H, #3709 exact Karatsuba/codec and B1 raw-H source are credited. +""" +from composed_sources import active +active() +from cardinal_counts import Count, positive +from compact_counts import append_bits, copy_bits, power_two +from encoded import compare, subtract +from fft_arithmetic import Arithmetic +from global_h_boundary import GlobalBoundary, digit +from physical_controls import END, H_EVENT, D_EVENT, NAMES +from ring_words import read_signed, write_signed, truncate, power_two as linear_power_two +from router_metadata import owned +from session import borrowed_count, borrowed_tape, erase_marker, sealed_constructors +from stream import Counter +from word_product import WordProduct +from words import BLANK, Word, need +from records import Tape +from types import ModuleType + + +class NullCounters(dict): + """Finite compiled tags; a passive increment always reads zero.""" + def __init__(self,keys): + super().__init__((key,0) for key in keys) + + def __getitem__(self,key): + need(key in self,'fixed diagnostic counter tag') + return 0 + + def __setitem__(self,key,value): + need(key in self,'fixed diagnostic counter tag') + + +class UnobservedArithmetic(Arithmetic): + @property + def products(self): + return 0 + + @products.setter + def products(self,value): + pass + + +def private_tapes(owner): + """Compile the fixed owners' port inventory before sealed execution. + + This graph walk reads object references only, never numerical tape cells. + Tape-bank cardinalities are fixed by the already constructed source owner. + """ + pending,seen,result = [owner],set(),[] + while pending: + value = pending.pop() + identity = id(value) + if identity in seen: + continue + seen.add(identity) + if isinstance(value,(Tape,Word)): + result.append(value) + elif isinstance(value,dict): + pending.extend(value.values()) + elif isinstance(value,(tuple,list,set,frozenset)): + pending.extend(value) + elif not isinstance(value,(ModuleType,type)) and not callable(value): + fields = getattr(value,'__dict__',None) + if fields is not None: + pending.extend(fields.values()) + return tuple(result) + + +def maximum(*values): + result = Count(values[0]) + try: + for value in values[1:]: + if compare(value,result) > 0: + result.close() + result = Count(value) + return result + except BaseException: + result.close() + raise + + +def signed_fits(value,width): + with owned(Count.literal(1)) as (one,): + with owned(subtract(width,one)) as (sign_position,): + with owned(linear_power_two(sign_position)) as (limit,): + order = compare(value.magnitude,limit) + need(order <= 0 if value.negative else order < 0,'complete complex product temporary width') + + +class FullPhysical(GlobalBoundary): + """One protected return; no payload decoding or runtime Tape allocation.""" + def __init__(self,root,word=None,observe=None): + super().__init__(root,observe) + self.word = WordProduct() if word is None else word + need(type(self.word) is WordProduct,'actual authenticated exact Karatsuba owner') + self.arithmetic = (Arithmetic if observe is not None else UnobservedArithmetic)(self.word,self.scope) + self.full_calls = dict(admissions=0,lifts=0,H=0,diagonals=0,shrinks=0) + if observe is None: + self.word.calls = NullCounters(self.word.calls) + self.calls = NullCounters(self.calls) + self.full_calls = NullCounters(self.full_calls) + self.private = private_tapes(self) + + def idle(self): + super().idle() + need(self.word.closed and not self.word.pool.live and self.word.output.read() == BLANK + and all(tape.read() == BLANK for tape in self.word.canonical), + 'consumed complete exact word child') + + def note(self,event): + if self.observe is not None: + self.observe(event) + + def admit_radius(self,width,incoming,radius_bits,gaussians): + """Compute incoming squared magnitudes using actual word products.""" + with owned(Count(incoming),Count.literal(0)) as (exponent,total): + exponent.add(radius_bits) + exponent.multiply_small(2) + with owned(linear_power_two(exponent)) as (limit,): + remaining = Counter(gaussians) + self.current.rewind() + try: + while not remaining.finished: + for _ in (0,1): + with owned(read_signed(self.current,width)) as (value,): + with owned(self.arithmetic.multiply(value,value,width)) as (square,): + need(not square.negative,'nonnegative actual squared magnitude') + total.add(square.magnitude) + self.note('input_squares') + need(compare(total,limit) <= 0,'physical complete input Euclidean radius') + remaining.decrement() + need(self.current.read() == BLANK,'complete radius admission field') + finally: + self.current.rewind() + remaining.close() + self.full_calls['admissions'] += 1 + + def lift_input(self,input_width,incoming,fractional,data_width,gaussians): + with owned(subtract(fractional,incoming)) as (low,): + with owned(Count(input_width)) as (minimal,): + minimal.add(low) + with owned(subtract(data_width,minimal)) as (high,): + self.idle() + with self.scope.suspended(): + returned = self.grid.expand(borrowed_tape(self.current), + *(borrowed_count(x) for x in (input_width,low,high,gaussians))) + self.accept(returned) + self.full_calls['lifts'] += 1 + + def h_event(self,code,n,axes,position_width,width,gaussians): + positions = self.pool.acquire() + try: + with owned(Count.product(axes,position_width),Count.literal(1),Count.literal(0)) as (bits,one,zero): + copy_bits(code,positions,bits) + positions.rewind() + with owned(self.raw_h(positions,n,axes,position_width,width,one,one,gaussians)) as (wide,): + self.idle() + with self.scope.suspended(): + returned = self.grid.truncate(borrowed_tape(self.current), + *(borrowed_count(x) for x in (wide,zero,width,gaussians))) + self.accept(returned) + self.full_calls['H'] += 1 + self.full_calls['shrinks'] += 1 + finally: + positions.clear() + + def product(self,left,right,word_width,fractional,output_width,temporary_width,output,kind): + with owned(*self.arithmetic.complex_product(*left,*right,word_width)) as exact: + for value in exact: + signed_fits(value,temporary_width) + with owned(*(truncate(value,fractional) for value in exact)) as rounded: + for value in rounded: + write_signed(value,output,output_width) + self.note(kind) + + def coefficient_field(self,code,axes,side,fractional,factor_width,cache_width, + temporary_width,word_width): + """Highest-axis-first fresh suffix expansion; zero factors are legal.""" + current = self.pool.acquire() + following = page = None + length = Count(side) + remaining_axes = Counter(axes) + try: + # R_F(d*1)=d exactly, so copy the highest-axis F-grid page. + entries = Counter(side) + try: + while not entries.finished: + for _ in (0,1): + with owned(read_signed(code,factor_width)) as (value,): + write_signed(value,current,cache_width) + self.note('initial_coefficients') + entries.decrement() + finally: + entries.close() + current.rewind() + remaining_axes.decrement() + while not remaining_axes.finished: + page,following = self.pool.acquire(),self.pool.acquire() + with owned(Count.product(side,factor_width)) as (page_bits,): + page_bits.multiply_small(2) + copy_bits(code,page,page_bits) + page.rewind() + old_entries = Counter(length) + try: + while not old_entries.finished: + with owned(read_signed(current,cache_width),read_signed(current,cache_width)) as suffix: + page.rewind() + entries = Counter(side) + try: + while not entries.finished: + with owned(read_signed(page,factor_width),read_signed(page,factor_width)) as factor: + self.product(factor,suffix,word_width,fractional,cache_width, + temporary_width,following,'coefficient_products') + entries.decrement() + need(page.read() == BLANK,'complete reusable local factor page') + finally: + entries.close() + old_entries.decrement() + need(current.read() == BLANK,'complete old rounded suffix field') + finally: + old_entries.close() + current.clear() + page.clear() + page = None + current,following = following,None + current.rewind() + updated = Count.product(length,side) + length.close() + length = updated + remaining_axes.decrement() + result,current = current,None + return result + finally: + remaining_axes.close() + length.close() + for value in (current,following,page): + if value is not None: + value.clear() + + def diagonal(self,code,labels,axes,side,local_records,fractional,data_width, + factor_width,cache_width,temporary_width,word_width): + following = self.pool.acquire() + coefficients = None + remaining_labels = Counter(labels) + self.current.rewind() + try: + while not remaining_labels.finished: + coefficients = self.coefficient_field(code,axes,side,fractional,factor_width, + cache_width,temporary_width,word_width) + remaining = Counter(local_records) + try: + while not remaining.finished: + with owned(read_signed(self.current,data_width),read_signed(self.current,data_width)) as value: + with owned(read_signed(coefficients,cache_width),read_signed(coefficients,cache_width)) as coefficient: + self.product(value,coefficient,word_width,fractional,data_width, + temporary_width,following,'data_products') + remaining.decrement() + need(coefficients.read() == BLANK,'complete actual coarse-label coefficient field') + finally: + remaining.close() + coefficients.clear() + coefficients = None + self.note('coarse_resets') + remaining_labels.decrement() + need(self.current.read() == BLANK,'complete physical diagonal payload') + self.replace_owned(following) + following = None + self.full_calls['diagonals'] += 1 + finally: + remaining_labels.close() + for value in (following,coefficients): + if value is not None: + value.clear() + self.current.rewind() + + def run(self,payload,code,*parameters): + need(len(parameters) == len(NAMES),'fixed complete Full metadata ports') + source,program = borrowed_tape(payload),borrowed_tape(code) + values = tuple(borrowed_count(x) for x in parameters) + private = self.private + need(source is not program and source not in private and program not in private + and all(x.tape not in (*private,source,program) for x in values), + 'external distinct physical Full input and metadata ports') + n,c,m,g,F,W,factor_width,cache_width,temporary_width,F0,W0,radius_bits,position_width,stages,h_count,d_count = values + for value in (n,m,g,F,W,factor_width,cache_width,temporary_width,W0,position_width,stages): + positive(value) + need(compare(F,F0) >= 0,'nondecreasing incoming common grid') + self.rearm() + succeeded = False + source.rewind() + program.rewind() + try: + with sealed_constructors(),self.scope.installed(): + with owned(Count.product(g,m)) as (local_bits,): + with owned(Count(local_bits)) as (total_bits,): + total_bits.add(c) + need(compare(total_bits,n) == 0,'complete global tensor address geometry') + with owned(power_two(n),power_two(c),power_two(m),power_two(local_bits), + maximum(W,factor_width,cache_width)) as (gaussians,labels,side,local_records,word_width): + with owned(Count.product(gaussians,W0)) as (input_bits,): + input_bits.multiply_small(2) + self.current = self.pool.acquire() + copy_bits(source,self.current,input_bits) + need(source.read() == BLANK,'complete borrowed incoming Gaussian field') + source.rewind() + self.current.rewind() + self.admit_radius(W0,F0,radius_bits,gaussians) + self.lift_input(W0,F0,F,W,gaussians) + remaining,remaining_h,remaining_d = Counter(stages),Counter(h_count),Counter(d_count) + try: + while not remaining.finished: + opcode = digit(program) | (digit(program) << 1) + if opcode == H_EVENT: + need(not remaining_h.finished,'remaining declared H event') + remaining_h.decrement() + self.h_event(program,n,g,position_width,W,gaussians) + else: + need(opcode == D_EVENT,'complete chronological Full opcode') + need(not remaining_d.finished,'remaining declared diagonal event') + remaining_d.decrement() + self.diagonal(program,labels,g,side,local_records,F,W,factor_width, + cache_width,temporary_width,word_width) + remaining.decrement() + need(remaining_h.finished and remaining_d.finished,'all declared Full H/D events executed') + need((digit(program) | (digit(program) << 1)) == END + and program.read() == BLANK,'exact complete Full program ending') + finally: + remaining.close() + remaining_h.close() + remaining_d.close() + self.idle() + append_bits(self.current,self.output) + self.current.clear() + self.current = None + self.pool.empty() + succeeded = True + finally: + source.rewind() + program.rewind() + for value in values: + value.rewind() + if self.current is not None: + self.current.clear() + self.current = None + if not self.pool.live: + for tape in self.pool.tapes: + erase_marker(tape) + self.output.rewind() + if not succeeded: + self.output.clear() + erase_marker(self.output) + self.closed = True + return self.output + + +def production_owner(): + """Actual production H natives and exact Karatsuba at every word width.""" + from composed_engine import production_layer + return FullPhysical(production_layer(),WordProduct()) diff --git a/research/source-remaining-diagonal/retained/fft/vendor/full/physical_sources.py b/research/source-remaining-diagonal/retained/fft/vendor/full/physical_sources.py new file mode 100644 index 0000000000..5451de1ba3 --- /dev/null +++ b/research/source-remaining-diagonal/retained/fft/vendor/full/physical_sources.py @@ -0,0 +1,87 @@ +"""One authenticated word/H cohort and the byte-identical raw-H boundary. + +Prepared for @CubeJerry with substantial OpenAI Codex assistance. Apache-2.0. +The retained numerical, tape, word and ownership sources keep their notices. +""" +from contextlib import contextmanager +from hashlib import sha256 +import importlib +import importlib.util +import json +from pathlib import Path +import sys + +HERE = Path(__file__).resolve().parent +ROOT = HERE.parents[1] + + +def need(condition, message): + if not condition: + raise ValueError(message) + + +def authenticate(): + checked = {} + for row in json.loads((HERE/'PHYSICAL-SOURCES.json').read_text())['files']: + path = ROOT/row['path'] + need(path.is_file() and not path.is_symlink(), 'regular physical Full source: '+row['path']) + raw = path.read_bytes() + need(len(raw) == row['bytes'] and sha256(raw).hexdigest() == row['sha256'], + 'pinned physical Full source: '+row['path']) + checked[row['path']] = row['sha256'] + return checked + + +def load(name, path): + need(name not in sys.modules, 'cold physical Full module: '+name) + spec = importlib.util.spec_from_file_location(name, path) + module = importlib.util.module_from_spec(spec) + sys.modules[name] = module + spec.loader.exec_module(module) + return module + + +@contextmanager +def opened(): + """The exact word owner shares the unchanged #3627 H tape cohort. + + The authenticated archive also contains numerical Fourier source, but no + RingProduct or FftWord object is instantiated or called by this service. + """ + need(not any(name in sys.modules for name in ('ring_sources','composed_sources', + 'word_product','ring_words','fft_arithmetic','global_h_boundary','frontend')), + 'one cold Full/word/H cohort per process') + authenticate() + old = sys.path[:] + sys.path.insert(0, str(ROOT/'research/physical-ring-product')) + try: + import ring_sources + with ring_sources.opened() as state: + for name in ('word_product','ring_words','fft_arithmetic'): + module = importlib.import_module(name) + need(Path(module.__file__).resolve() == + (ROOT/'research/physical-ring-product'/f'{name}.py').resolve(), + 'actual authenticated exact-word module path: '+name) + # These are the exact B1 live-source Git blobs, not compatible names. + expected = { + 'composed_sources': '5b9a507a5f5eb7d32d76792cac4b876070d29e91', + 'composed_engine': '646c451a4cbdf0244c7782d958f257f6606b962f', + 'composed_plan': '300ee75d4171c8f0d97118a01a4e439b72ca01d6', + } + from hashlib import sha1 + for name, blob in expected.items(): + module = importlib.import_module(name) + raw = Path(module.__file__).read_bytes() + need(sha1(b'blob '+str(len(raw)).encode()+b'\0'+raw).hexdigest() == blob, + 'identical frozen raw-H dependency: '+name) + load('frontend', HERE/'vendor/global-boundary/frontend.py') + state.global_boundary = load('global_h_boundary', HERE/'vendor/global-boundary/bridge.py') + from cardinal_counts import Count + from records import Tape + from word_product import WordProduct + need(state.global_boundary.Count is Count and state.global_boundary.Tape is Tape, + 'one physical Count/Tape identity for H and word services') + state.full_word_class = WordProduct + yield state + finally: + sys.path[:] = old diff --git a/research/source-remaining-diagonal/retained/fft/vendor/full/reference.py b/research/source-remaining-diagonal/retained/fft/vendor/full/reference.py new file mode 100644 index 0000000000..255bdf1507 --- /dev/null +++ b/research/source-remaining-diagonal/retained/fft/vendor/full/reference.py @@ -0,0 +1,181 @@ +"""Slow independent arithmetic oracles, never a claimed physical backend. + +Fresh coefficient products deliberately cost g products per record. The +physical backend must implement and charge its own cached delivery protocol. +Prepared for @CubeJerry with substantial OpenAI Codex assistance. Apache-2.0. +""" +from fractions import Fraction as Q + +from compiler import Hadamard +from sources import need + +ZERO=(Q(0),Q(0)) +ONE=(Q(1),Q(0)) + + +def add(a,b): + return a[0]+b[0],a[1]+b[1] + + +def neg(a): + return -a[0],-a[1] + + +def mul(a,b): + return a[0]*b[0]-a[1]*b[1],a[0]*b[1]+a[1]*b[0] + + +def divide(a,b): + d=b[0]*b[0]+b[1]*b[1] + need(d>0,'nonzero independent complex divisor') + r=mul(a,(b[0],-b[1])) + return r[0]/d,r[1]/d + + +def decode(z,bits): + return Q(z[0],1 << bits),Q(z[1],1 << bits) + + +def rounded(z,bits): + return int(z[0]*(1 << bits)),int(z[1]*(1 << bits)) + + +def energy(values): + return sum((a*a+b*b for a,b in values),Q(0)) + + +def distance_squared(a,b): + return energy([add(x,neg(y)) for x,y in zip(a,b,strict=True)]) + + +def raw_h(state,positions): + for bit in positions: + step=1 << bit + for block in range(0,len(state),2*step): + for low in range(step): + i,j=block+low,block+low+step + x,y=state[i],state[j] + state[i],state[j]=add(x,y),add(x,neg(y)) + return state + + +class FreshSemanticService: + """Fraction oracle for the declared protocol; no cache or tape claims.""" + def __init__(self): + self.stats=dict(global_H_calls=0,global_diagonals=0,fresh_factor_products=0, + data_products=0,nonzero_roundings=0,maximum_numerator_bits=0) + + def apply_h(self,state,event): + event.validate() + need(len(state) == 1 << event.array_bits,'oracle complete global H field') + self.stats['global_H_calls']+=1 + return raw_h(state,event.positions) + + def apply_diagonal(self,state,event): + event.validate() + need(len(state) == 1 << event.array_bits,'oracle complete global diagonal field') + F,m,g=event.fractional_bits,event.axis_bits,event.axes + mask=(1 << m)-1 + for address,z in enumerate(state): + coarse=address >> (m*g) + coefficient=ONE + for axis in range(g-1,-1,-1): + factor=decode(event.pages[coarse][axis][(address >> (axis*m)) & mask],F) + exact=mul(factor,coefficient) + stored=rounded(exact,F) + coefficient=decode(stored,F) + self.stats['fresh_factor_products']+=1 + self.stats['nonzero_roundings']+=int(coefficient != exact) + exact=mul(decode(z,F),coefficient) + state[address]=rounded(exact,F) + self.stats['nonzero_roundings']+=int(decode(state[address],F) != exact) + self.stats['data_products']+=1 + self.stats['maximum_numerator_bits']=max(self.stats['maximum_numerator_bits'], + *(abs(x).bit_length()+1 for x in state[address])) + self.stats['global_diagonals']+=1 + return state + + +def emitted_exact(program,values): + """Exact unrounded global primitive word, independent of event encoding.""" + state=list(values) + N,g,m=program.size,program.axes,program.axis_bits + for step in range(program.stages): + kind,bit=program.layer_signature[step % program.layer_stages] + if kind == 'H': + raw_h(state,[a*m+bit for a in range(g)]) + else: + for address,z in enumerate(state): + c=address >> (g*m) + coefficient=ONE + for a in range(g): + coefficient=mul(coefficient,program.reference_stage(c,a,step)[1][(address >> (a*m)) & (N-1)]) + state[address]=mul(coefficient,z) + return state + + +def source_plan_exact(program,values): + """Apply original stored logical gates, not the compiled primitive word.""" + state=list(values) + N=program.size + local=N**program.axes + for c,block in enumerate(program.programs): + for axis,p in enumerate(block): + stride=N**axis + for layer in p.plan: + for ids,gate in layer: + matrix=[[(z.re,z.im) for z in row] for row in gate] + for high in range(0,local,N*stride): + for low in range(stride): + places=[c*local+high+low+j*stride for j in ids] + old=[state[k] for k in places] + for i,address in enumerate(places): + total=ZERO + for j,z in enumerate(old): + total=add(total,mul(matrix[i][j],z)) + state[address]=total + return state + + +def inverse(matrix): + """Separate exact complex Gauss-Jordan, without retained source routines.""" + n=len(matrix) + rows=[list(row)+[ONE if i==j else ZERO for j in range(n)] for i,row in enumerate(matrix)] + for column in range(n): + pivot=next((i for i in range(column,n) if rows[i][column] != ZERO),None) + need(pivot is not None,'independent nonsingular root') + rows[column],rows[pivot]=rows[pivot],rows[column] + divisor=rows[column][column] + rows[column]=[divide(z,divisor) for z in rows[column]] + for i in range(n): + if i==column: + continue + coefficient=rows[i][column] + rows[i]=[add(a,neg(mul(coefficient,b))) for a,b in zip(rows[i],rows[column],strict=True)] + return [row[n:] for row in rows] + + +def root_exact(program,values): + state=list(values) + N=program.size + local=N**program.axes + for c,block in enumerate(program.roots): + for axis,root in enumerate(block): + matrix=[[(z.re,z.im) for z in row] for row in root.matrix] + if program.directions[c][axis]: + matrix=inverse(matrix) + physical=[[ZERO]*N for _ in range(N)] + for i in range(N): + for j in range(N): + physical[root.indices[i]][root.indices[j]]=matrix[i][j] + stride=N**axis + for high in range(0,local,N*stride): + for low in range(stride): + places=[c*local+high+low+j*stride for j in range(N)] + old=[state[k] for k in places] + for i,address in enumerate(places): + total=ZERO + for j,z in enumerate(old): + total=add(total,mul(physical[i][j],z)) + state[address]=total + return state diff --git a/research/source-remaining-diagonal/retained/fft/vendor/full/sources.py b/research/source-remaining-diagonal/retained/fft/vendor/full/sources.py new file mode 100644 index 0000000000..f8cebf330f --- /dev/null +++ b/research/source-remaining-diagonal/retained/fft/vendor/full/sources.py @@ -0,0 +1,79 @@ +"""Authenticated unchanged Full/fixed-word source closure. + +Prepared for @CubeJerry with substantial OpenAI Codex assistance. Apache-2.0. +Full and fixed-H producers remain Jose Manuel's and Vlado Vojdanovski's work. +""" +from contextlib import contextmanager +from functools import wraps +from hashlib import sha256 +import json +from pathlib import Path +import sys +from types import ModuleType +from threading import RLock + +HERE = Path(__file__).resolve().parent +ROOT = HERE.parents[1] +PREFIX = 'research/rational-fft-fixed-h/' +_serialization_lock = RLock() + + +def need(condition, message): + if not condition: + raise ValueError(message) + + +@contextmanager +def trusted_exact_serialization(): + """Temporarily admit arbitrary-size trusted integer hashes, then restore. + + CPython's decimal-digit limit is process-wide. This serialized preparation + context preserves it in finally; it never changes arithmetic or hash format. + It encloses authenticated exact source/hash work, not input text parsing. + """ + with _serialization_lock: + previous = sys.get_int_max_str_digits() + if previous: + sys.set_int_max_str_digits(0) + try: + yield + finally: + if previous: + sys.set_int_max_str_digits(previous) + + +def exact_preparation(function): + @wraps(function) + def wrapped(*args,**kwargs): + with trusted_exact_serialization(): + return function(*args,**kwargs) + return wrapped + + +def load(overrides=None): + raw = {} + for row in json.loads((HERE/'SOURCES.json').read_text())['files']: + if row['usage'] != 'input': + continue + path = row['path'] + content = (overrides or {}).get(path) + if content is None: + content = (ROOT/path).read_bytes() + need(sha256(content).hexdigest() == row['sha256'], 'source SHA256: '+path) + raw[path] = content + previous = sys.modules.get('lowering') + lower = ModuleType('_global_retained_lowering') + lower.__file__ = str(ROOT/PREFIX/'lowering.py') + dense = ModuleType('_global_retained_dense') + dense.__file__ = str(ROOT/PREFIX/'dense.py') + try: + exec(compile(raw[PREFIX+'lowering.py'],lower.__file__,'exec',optimize=0),lower.__dict__) + sys.modules['lowering'] = lower + exec(compile(raw[PREFIX+'dense.py'],dense.__file__,'exec',optimize=0),dense.__dict__) + source = dense.DenseSources(raw) + finally: + if previous is None: + sys.modules.pop('lowering',None) + else: + sys.modules['lowering'] = previous + return dense,lower,source diff --git a/research/source-remaining-diagonal/retained/fft/vendor/full/vendor/global-boundary/bridge.py b/research/source-remaining-diagonal/retained/fft/vendor/full/vendor/global-boundary/bridge.py new file mode 100644 index 0000000000..4b9f0042eb --- /dev/null +++ b/research/source-remaining-diagonal/retained/fft/vendor/full/vendor/global-boundary/bridge.py @@ -0,0 +1,379 @@ +"""Execute source-emitted global switches through the retained physical root. + +Unbounded integers, positions and countdowns remain encoded on Count tapes. +Payload arithmetic below uses only binary digits and a one-bit carry. The +constructor and source-control preparation are outside a sealed invocation. + +Prepared for @CubeJerry with substantial OpenAI Codex assistance. Apache-2.0. +Retained physical root/router/Count/ownership implementations are credited. +""" +from composed_sources import active +active() +from composed_engine import ComposedRoot, production_layer +from cardinal_counts import Count, positive +from compact_counts import append_bits, copy_bits, power_two +from encoded import compare, subtract +from frontend import END, HADAMARD, SIGNS, HALF +from grid_boundary import GridBoundary +from records import Tape +from router_metadata import owned +from scratch_pool import ScratchPool +from session import (OuterScope, borrowed_count, borrowed_tape, erase_marker, + initialize_marker, sealed_constructors) +from stream import Counter +from words import BLANK, LEFT, need + + +def digit(source): + value = source.read() + need(value in (0, 1), "complete binary compiler control or payload") + source.step(1) + return value + + +def repeat_copy(source, target, count, flip=0): + source.rewind() + remaining = Counter(count) + try: + while not remaining.finished: + target.append(digit(source) ^ flip) + remaining.decrement() + need(source.read() == BLANK, "complete phase-product prefix") + finally: + source.rewind() + remaining.close() + + +class GlobalBoundary: + """One fixed owner; the caller consumes its protected output before reuse.""" + def __init__(self, root, observe=None): + need(isinstance(root, ComposedRoot), "actual authenticated composed-H owner") + self.root = root + # Optional checker instrumentation; return values never affect control. + # Production has no host counter update for each payload coefficient. + self.observe = observe + self.grid = GridBoundary() + self.pool = ScratchPool(128) + self.scope = OuterScope(self.pool) + self.output = Tape() + self.current = None + self.closed = True + self.calls = dict(gathers=0, raw_H=0, signs=0, exact_divisions=0) + for tape in (*self.pool.tapes, self.output): + erase_marker(tape) + + def idle(self): + self.root.idle() + need(self.root.closed and self.root.current is None and self.root.output.read() == BLANK + and self.grid.closed and self.grid.output.read() == BLANK, + "consumed complete global-H children") + + def rearm(self): + need(self.closed and self.current is None and self.output.read() == BLANK, + "consume the previous compiler-boundary output") + self.idle() + initialize_marker(self.output) + for tape in self.pool.tapes: + initialize_marker(tape) + self.closed = False + + def accept(self, returned): + following = self.pool.acquire() + try: + append_bits(returned, following) + following.rewind() + except BaseException: + following.clear() + raise + finally: + returned.clear() + erase_marker(returned) + self.current.clear() + self.current = following + + def replace_owned(self, following): + following.rewind() + self.current.clear() + self.current = following + + def gather(self, descriptor, n, precision, support, position_width, width, coefficients, rows): + self.idle() + with owned(Count.product(width, coefficients)) as (record,): + record.multiply_small(2) + with self.scope.suspended(): + returned = self.root.router.run( + borrowed_tape(self.current), borrowed_tape(descriptor), + *(borrowed_count(x) for x in (n, precision, support, position_width, record, rows))) + self.accept(returned) + self.calls["gathers"] += 1 + + def raw_h(self, positions, n, g, position_width, width, coefficients, rows, gaussians): + # P=w+g; using the physical word width, |z|<2^(w-p) is automatic. + # The g low zeros encode z/2^(w-p) on the P-grid. All H0 return + # numerators are divisible as needed, so its final truncation is exact. + with owned(Count(width), Count.literal(2)) as (precision, two): + precision.add(g) + self.idle() + with self.scope.suspended(): + returned = self.grid.expand(borrowed_tape(self.current), + *(borrowed_count(x) for x in (width, g, two, gaussians))) + self.accept(returned) + self.idle() + with self.scope.suspended(): + returned = self.root.run(borrowed_tape(self.current), borrowed_tape(positions), + *(borrowed_count(x) for x in (n, precision, g, position_width, coefficients, rows))) + self.accept(returned) + result_width = Count(precision) + result_width.add(two) + self.calls["raw_H"] += 1 + return result_width + + def product_signs(self, code, coarse_blocks, axes, axis_size): + """Sequential Kronecker expansion costs a geometric sum, not g per bit. + + The code cursor is deliberately advanced over this one diagonal's + tables. The enclosing program restores its borrowed head on return. + """ + output = self.pool.acquire() + blocks = Counter(coarse_blocks) + current = following = None + try: + while not blocks.finished: + current = self.pool.acquire() + current.append(0) + current.rewind() + length = Count.literal(1) + remaining_axes = Counter(axes) + try: + while not remaining_axes.finished: + following = self.pool.acquire() + entries = Counter(axis_size) + try: + while not entries.finished: + bit = digit(code) + if self.observe is not None: + self.observe("control_bits") + repeat_copy(current, following, length, bit) + entries.decrement() + finally: + entries.close() + current.clear() + current, following = following, None + current.rewind() + updated = Count.product(length, axis_size) + length.close() + length = updated + remaining_axes.decrement() + append_bits(current, output) + finally: + length.close() + remaining_axes.close() + if current is not None: + current.clear() + current = None + blocks.decrement() + output.rewind() + return output + except BaseException: + output.clear() + raise + finally: + blocks.close() + for value in (current, following): + if value is not None: + value.clear() + + def signed_component(self, source, output, width, negate): + remaining = Counter(width) + carry = int(negate) + old_sign = new_sign = 0 + try: + while not remaining.finished: + old_sign = digit(source) + total = (old_sign ^ int(negate)) + carry + new_sign = total & 1 + carry = total >> 1 + output.append(new_sign) + remaining.decrement() + need(not (negate and old_sign and new_sign), "signed phase headroom") + finally: + remaining.close() + + def apply_signs(self, mask, width, addresses, coefficients, rows): + following = self.pool.acquire() + remaining_rows = Counter(rows) + self.current.rewind() + try: + while not remaining_rows.finished: + mask.rewind() + remaining_addresses = Counter(addresses) + try: + while not remaining_addresses.finished: + sign = digit(mask) + if self.observe is not None: + self.observe("mask_bits") + remaining_coefficients = Counter(coefficients) + try: + while not remaining_coefficients.finished: + for _ in (0, 1): + self.signed_component(self.current, following, width, sign) + if sign and self.observe is not None: + self.observe("component_negations") + remaining_coefficients.decrement() + finally: + remaining_coefficients.close() + remaining_addresses.decrement() + need(mask.read() == BLANK, "complete original-frame product diagonal") + finally: + remaining_addresses.close() + remaining_rows.decrement() + need(self.current.read() == BLANK, "complete global diagonal payload") + self.replace_owned(following) + following = None + self.calls["signs"] += 1 + finally: + remaining_rows.close() + self.current.rewind() + mask.rewind() + if following is not None: + following.clear() + + def exact_divide(self, width, low, output_width, gaussians): + # Check discarded bits before calling a generic toward-zero codec. + # An accidentally rounded switch is not an admitted exact switch. + with owned(subtract(width, low), Count(gaussians)) as (kept, components): + components.multiply_small(2) + remaining = Counter(components) + self.current.rewind() + try: + while not remaining.finished: + discard = Counter(low) + try: + while not discard.finished: + need(digit(self.current) == 0, "exact compiled switch divisibility") + discard.decrement() + finally: + discard.close() + retain = Counter(kept) + try: + while not retain.finished: + digit(self.current) + retain.decrement() + finally: + retain.close() + remaining.decrement() + need(self.current.read() == BLANK, "complete exact switch quotient") + finally: + self.current.rewind() + remaining.close() + self.idle() + with self.scope.suspended(): + returned = self.grid.truncate(borrowed_tape(self.current), + *(borrowed_count(x) for x in (width, low, output_width, gaussians))) + self.accept(returned) + self.calls["exact_divisions"] += 1 + + def run(self, payload, forward, inverse, program, n, p, initial_width, g, local_bits, + position_width, support, coefficients, rows): + """Run one complete emitted Beneš route on every original coarse label. + + Input/output fields are signed integers with the same external p-grid. + All descriptors are borrowed; the physical result is a protected port. + """ + source, code = borrowed_tape(payload), borrowed_tape(program) + need(source is not self.output and code is not self.output and source is not code, + "distinct borrowed compiler payload and program") + for value in (n, initial_width, g, local_bits, position_width, coefficients, rows): + positive(value) + need(compare(initial_width, p) >= 0, "signed component width covers the external grid") + self.rearm() + width = positions = mask = None + source.rewind() + code.rewind() + try: + with sealed_constructors(), self.scope.installed(): + with owned(Count.literal(2)) as (two,): + need(compare(initial_width, two) >= 0, "signed component width at least two") + with owned(Count.product(g, local_bits), power_two(n), power_two(local_bits), + Count(initial_width)) as (local_total, addresses, axis_size, route_precision): + need(compare(local_total, n) <= 0, "complete microbox layout fits global address") + route_precision.add(g) + with owned(subtract(n, local_total)) as (coarse_bits,): + with owned(power_two(coarse_bits), Count.product(addresses, coefficients)) as (coarse_blocks, one_row): + with owned(Count.product(one_row, rows)) as (gaussians,): + with owned(Count.product(gaussians, initial_width)) as (total,): + total.multiply_small(2) + self.current = self.pool.acquire() + copy_bits(source, self.current, total) + need(source.read() == BLANK, "complete original global Gaussian packet") + source.rewind() + self.current.rewind() + self.gather(forward, n, route_precision, support, position_width, + initial_width, coefficients, rows) + width = Count(initial_width) + state = 0 # Four finite states per complete source switch. + while True: + opcode = digit(code) | (digit(code) << 1) + if opcode == END: + need(state == 0 and code.read() == BLANK, "complete compiled global route") + break + need(opcode == (HADAMARD, SIGNS, HADAMARD, HALF)[state], + "chronological complete source switch") + if opcode == HADAMARD: + positions = self.pool.acquire() + with owned(Count.product(g, position_width)) as (bits,): + copy_bits(code, positions, bits) + positions.rewind() + following = self.raw_h(positions, n, g, position_width, + width, coefficients, rows, gaussians) + positions.clear() + positions = None + width.close() + width = following + elif opcode == SIGNS: + mask = self.product_signs(code, coarse_blocks, g, axis_size) + self.apply_signs(mask, width, addresses, coefficients, rows) + mask.clear() + mask = None + else: + self.exact_divide(width, g, initial_width, gaussians) + width.close() + width = Count(initial_width) + state = (state+1) % 4 + self.gather(inverse, n, route_precision, support, position_width, + width, coefficients, rows) + self.idle() + append_bits(self.current, self.output) + if width is not None: + width.close() + width = None + self.current.clear() + self.current = None + self.pool.empty() + finally: + source.rewind() + code.rewind() + forward.rewind() + inverse.rewind() + for value in (width, positions, mask, self.current): + if value is not None: + value.close() if isinstance(value, Count) else value.clear() + self.current = None + # Success restores every owned role. Interrupted child execution + # retains the predecessor's narrower successful-input contract. + if not self.pool.live: + for tape in self.pool.tapes: + erase_marker(tape) + self.output.rewind() + self.closed = True + return self.output + + +def production_boundary(): + """Bind the source compiler interface to two actual fresh production natives. + + As in the predecessor, compilation has a fixed construction-dependent cost. + Finite verification uses its declared q=2 fixture rather than allocating the + full production native source. It does not change this production factory. + """ + return GlobalBoundary(production_layer()) diff --git a/research/source-remaining-diagonal/retained/fft/vendor/full/vendor/global-boundary/frontend.py b/research/source-remaining-diagonal/retained/fft/vendor/full/vendor/global-boundary/frontend.py new file mode 100644 index 0000000000..890a67ea1e --- /dev/null +++ b/research/source-remaining-diagonal/retained/fft/vendor/full/vendor/global-boundary/frontend.py @@ -0,0 +1,257 @@ +"""Export the retained local_layer Beneš prefix as one complete global program. + +Prepared for @CubeJerry with substantial OpenAI Codex assistance. Apache-2.0. +The routing compiler and fixed words are Vlado Vojdanovski's retained source. +This module prepares encoded controls; it never evaluates a payload transform. +""" +from dataclasses import dataclass, field + +END, HADAMARD, SIGNS, HALF = range(4) + + +def need(condition, message): + if not condition: + raise ValueError(message) + + +def address(value, mapping): + result = value + for old, new in mapping.items(): + result &= ~(1 << new) + result |= ((value >> old) & 1) << new + return result + + +@dataclass(frozen=True) +class Layout: + """Original complete long axes, numbered from the least significant end.""" + lengths: tuple + local_bits: int + + def __post_init__(self): + need(type(self.local_bits) is int and self.local_bits >= 1, "positive local width") + need(bool(self.lengths) and all(type(a) is int and a >= self.local_bits for a in self.lengths), + "complete original axes contain every local bit") + + @property + def n(self): + return sum(self.lengths) + + @property + def g(self): + return len(self.lengths) + + @property + def starts(self): + total = 0 + values = [] + for width in self.lengths: + values.append(total) + total += width + return tuple(values) + + @property + def local_positions(self): + return tuple(start + bit for start in self.starts for bit in range(self.local_bits)) + + @property + def gather(self): + source = self.local_positions + target = tuple(range(len(source))) + mapping = dict(zip(source, target)) + mapping.update(zip(sorted(set(target)-set(source)), sorted(set(source)-set(target)))) + need(set(mapping) == set(mapping.values()), "support-local coordinate bijection") + return mapping + + @property + def inverse(self): + return {new: old for old, new in self.gather.items()} + + def coarse_label(self, packed_label): + raw = address(packed_label << (self.g*self.local_bits), self.inverse) + return tuple((raw >> (start+self.local_bits)) & ((1 << (width-self.local_bits))-1) + for start, width in zip(self.starts, self.lengths)) + + @property + def labels(self): + return tuple(self.coarse_label(c) for c in range(1 << (self.n-self.g*self.local_bits))) + + +@dataclass(frozen=True) +class GlobalProgram: + layout: Layout + stages: tuple + permutations: tuple + source_stage_count: int + compiler: object = field(repr=False, compare=False) + + def export(self): + layout = self.layout + return { + "original_axis_lengths": list(layout.lengths), + "local_bits": layout.local_bits, + "global_binary_bits": layout.n, + "selected_axes": layout.g, + "complete_coarse_labels": [list(x) for x in layout.labels], + "forward_low_bit_gather": sorted(layout.gather.items()), + "inverse_low_bit_gather": sorted(layout.inverse.items()), + "moved_support_at_most": 2*layout.g*layout.local_bits, + "source_local_layer_prefix_stages": self.source_stage_count, + "global_stages": [ + {"kind": "H", "original_selected": [layout.starts[a]+bit for a, bit in enumerate(value)], + "caller_selected": [a*layout.local_bits+bit for a, bit in enumerate(value)], + "normalization": "raw H=(2 H0) tensor g"} + if kind == HADAMARD else + {"kind": "D", "axis_sign_tables": value, "frame": "restored caller low-bit gather"} + if kind == SIGNS else + {"kind": "D", "exact_divisor": 1 << layout.g, "output_component_bits": "original"} + for kind, value in self.stages], + "backend": "t74-support-composition.ComposedRoot.run", + "stock": "actual root plan stock; every nested Ordinary.run selects, pads and returns its own stock", + "return": "inverse low-bit gather, protected distinct output; borrowed payload and program restored", + "preparation": "complete coarse-label tables; local source prefixes regenerated in stage-major order", + } + + +def source_prefix(compiler, local_bits, permutation, identity_word): + n = 1 << local_bits + inverse = [0]*n + for old, new in enumerate(permutation): + inverse[new] = old + pairs = [(inverse[2*j], inverse[2*j+1]) for j in range(n//2)] + emitted = compiler.local_layer(n, pairs, [identity_word]*(n//2)) + depth = 2*local_bits-1 + need(len(emitted) == 8*depth+13, "actual source matching-layer shape") + return emitted[:4*depth] + + +def compile_route(compiler, layout, permutations): + """Consume actual local_layer outputs, with one network per axis and label. + + permutations[label][axis][i] is the desired image of local wire i. Label + order is the physical packed coarse-prefix order, not a silently sorted + original-label order. No selected support is accepted as an extra input. + """ + n = 1 << layout.local_bits + need(len(permutations) == len(layout.labels), "all complete coarse-label tables") + depth = 2*layout.local_bits-1 + prefixes = [] + normalized = [] + identity_word = compiler.gateword("diag", (1, 1)) + for group in permutations: + need(len(group) == layout.g, "one source circuit per actual axis") + row, saved = [], [] + for permutation in group: + need(len(permutation) == n and all(type(i) is int for i in permutation) + and sorted(permutation) == list(range(n)), "complete original local permutation") + row.append(source_prefix(compiler, layout.local_bits, permutation, identity_word)) + saved.append(tuple(permutation)) + prefixes.append(row) + normalized.append(tuple(saved)) + stages = [] + for step in range(4*depth): + nodes = [[prefixes[c][a][step] for a in range(layout.g)] for c in range(len(prefixes))] + kinds = {op[0] for row in nodes for op in row} + need(len(kinds) == 1, "one global source stage on all coarse labels") + if kinds == {"H"}: + bits = tuple(nodes[0][a][1] for a in range(layout.g)) + need(all(tuple(op[1] for op in row) == bits for row in nodes), + "label-independent Hadamard schedule") + need(all(type(bit) is int and 0 <= bit < layout.local_bits for bit in bits), + "source Hadamard bits lie in original local coordinates") + stages.append((HADAMARD, bits)) + else: + need(kinds == {"D"} and all(len(op[1]) == n for row in nodes for op in row), + "complete source diagonal tables") + values = [entry for row in nodes for op in row for entry in op[1]] + if all(entry in (-1, 1) for entry in values): + signs = tuple(tuple(tuple(0 if entry == 1 else 1 for entry in op[1]) for op in row) + for row in nodes) + stages.append((SIGNS, signs)) + else: + need(all(entry == compiler.s.Rational(1, 2) for entry in values), + "retained switch normalization only") + stages.append((HALF, None)) + need([kind for kind, _ in stages] == [HADAMARD, SIGNS, HADAMARD, HALF]*depth, + "complete emitted switch boundaries") + return GlobalProgram(layout, tuple(stages), tuple(normalized), 4*depth, compiler) + + +def encode_controls(program, tape_factory): + """Prepare control tapes by sequential passes through the local inputs. + + Regenerating one local prefix at a time avoids a constant-time global + table lookup in the preparation cost. The enclosing passes and this + deliberately conservative extra source work are paid in PROOF.md. + """ + layout = program.layout + width = max(1, (layout.n-1).bit_length()) + forward, inverse, code = (tape_factory() for _ in range(3)) + + def fixed(target, value): + need(0 <= value < 1 << width, "coordinate fits encoded position width") + for bit in range(width): + target.append((value >> bit) & 1) + + for target, mapping in ((forward, layout.gather), (inverse, layout.inverse)): + for old, new in sorted(mapping.items()): + fixed(target, old) + fixed(target, new) + target.rewind() + identity_word = program.compiler.gateword("diag", (1, 1)) + for step, (kind, value) in enumerate(program.stages): + code.append(kind & 1) + code.append(kind >> 1) + for label, group in enumerate(program.permutations): + for axis, permutation in enumerate(group): + node = source_prefix(program.compiler, layout.local_bits, permutation, identity_word)[step] + if kind == HADAMARD: + need(node[0] == "H" and node[1] == value[axis], "same emitted global H schedule") + if label == 0: + fixed(code, axis*layout.local_bits+node[1]) + elif kind == SIGNS: + need(node[0] == "D" and all(entry in (-1, 1) for entry in node[1]), + "source-produced complete sign diagonal") + for entry in node[1]: + code.append(0 if entry == 1 else 1) + else: + need(node[0] == "D" and all(entry == program.compiler.s.Rational(1, 2) + for entry in node[1]), + "source-produced exact normalization") + code.append(0) + code.append(0) + code.rewind() + return forward, inverse, code + + +class PreparedCall: + """Caller-owned source export, with all geometric Counts derived here. + + Only the numerical input format and its complete replication extents are + supplied by the caller. Selected supports, coordinate maps and the stage + order are taken from the retained compiler's GlobalProgram. + """ + def __init__(self, program, p, width, coefficients, rows, tape_factory, count_type): + need(isinstance(program, GlobalProgram), "source-derived global program") + need(all(type(x) is int for x in (p, width, coefficients, rows)) and + 0 <= p <= width and width >= 2 and coefficients >= 1 and rows >= 1, + "complete signed-grid input format") + self.program = program + self.controls = encode_controls(program, tape_factory) + layout = program.layout + numbers = (layout.n, p, width, layout.g, layout.local_bits, + max(1, (layout.n-1).bit_length()), len(layout.gather), coefficients, rows) + self.parameters = tuple(count_type.literal(value) for value in numbers) + self.closed = False + + def run(self, boundary, payload): + need(not self.closed, "live caller-owned compiler export") + return boundary.run(payload, *self.controls, *self.parameters) + + def close(self): + if not self.closed: + for tape in self.controls: + tape.clear() + for count in self.parameters: + count.close() + self.closed = True diff --git a/research/source-remaining-diagonal/retained/fft/vendor/full/verify_physical.py b/research/source-remaining-diagonal/retained/fft/vendor/full/verify_physical.py new file mode 100644 index 0000000000..3998e503bd --- /dev/null +++ b/research/source-remaining-diagonal/retained/fft/vendor/full/verify_physical.py @@ -0,0 +1,271 @@ +#!/usr/bin/env python3 +"""Physical caller replay; host arithmetic is confined to the independent oracle. + +Prepared for @CubeJerry with substantial OpenAI Codex assistance. Apache-2.0. +""" +import argparse +from collections import Counter as Observations +from contextlib import contextmanager +from hashlib import sha256 +import json +from pathlib import Path +import sys +import time +from unittest.mock import patch + +HERE = Path(__file__).resolve().parent +sys.path.insert(0,str(HERE)) +from physical_sources import need,opened + + +def prepared_source(mode): + from sources import load + from compiler import FullTensor,Hadamard,Diagonal + from reference import FreshSemanticService,decode,root_exact,distance_squared + dense,lower,source = load() + C = source.e.C + if mode == 'scalar': + scalar = C(2,1) + matrices,directions = [[[[scalar,0],[0,scalar]]]],[[True]] + values = [(1,1),(-1,0)] + else: + scalars = ((C(2,1),C(3,-1)),(C(3,1),C(2,-1))) + matrices = [[[[z,0],[0,z]] for z in block] for block in scalars] + directions = [[True,False],[False,True]] + values = [(1,1),(-1,0),(0,0),(0,0),(0,1),(0,0),(0,0),(0,0)] + program = FullTensor(dense,lower,source,matrices,directions, + target=8,radius_bits=1,incoming=0) + oracle = FreshSemanticService() + expected,semantic_work = program.execute(values,oracle) + target = root_exact(program,[decode(z,program.incoming) for z in values]) + error = distance_squared([decode(z,program.bits) for z in expected],target) + need(error <= program.total_error**2 and error < program.tau**2, + 'source oracle meets complete Full target') + result = dict(label=mode,program=program,values=values,expected=expected, + event_types=(Hadamard,Diagonal),allocation=program.record(), + semantic_work=semantic_work,oracle_work=oracle.stats, + root_error_squared_sha256=sha256(str(error).encode()).hexdigest()) + # Release only our preparation aliases; private program globals are retained. + for name in ('sources','compiler','reference'): + sys.modules.pop(name,None) + return result + + +def floor_table(bases): + table = {} + for a,b in ((997,1000),(1,500)): + for n in sorted(set(bases)): + target = n**a + lo,hi = 0,n+1 + while hi-lo > 1: + mid = (lo+hi)//2 + if mid**b <= target: + lo = mid + else: + hi = mid + need(lo**b <= target < (lo+1)**b,'exact finite metadata floor certificate') + table[(a,b,n)] = lo + certify_table(table,bases) + return table + + +def certify_table(table,bases): + need(set(table) == {(a,b,n) for a,b in ((997,1000),(1,500)) for n in set(bases)}, + 'complete finite metadata floor domain') + for (a,b,n),root in table.items(): + need(type(root) is int and root >= 0 and root**b <= n**a < (root+1)**b, + 'exact finite metadata floor certificate') + + +@contextmanager +def certified_floors(bases): + """Checker-only finite specialization; the general helper is unchanged.""" + import active_plan + import composed_plan + from cardinal_counts import Count + from encoded import compare + from router_metadata import owned + table = floor_table(bases) + uses,misses = Observations(),[] + original_active,original_exposure = active_plan.floor_power,composed_plan.floor_power + def folded(value,a,b,delegate): + for base in sorted(set(bases)): + if (a,b,base) not in table: + continue + with owned(Count.literal(base)) as (candidate,): + if compare(value,candidate) == 0: + uses[(a,b,base)] += 1 + return Count.literal(table[(a,b,base)]) + misses.append([a,b]) + return delegate(value,a,b) + with patch.object(active_plan,'floor_power',lambda value,a,b:folded(value,a,b,original_active)), \ + patch.object(composed_plan,'floor_power',lambda value,a,b:folded(value,a,b,original_exposure)): + yield table,uses,misses + + +def reject(function,part): + try: + function() + except ValueError as error: + need(part in str(error),'expected rejection reason: '+part) + return str(error) + raise ValueError('negative control accepted: '+part) + + +def actual(case,progress=False,diagnostics=True,reuse=False): + from cardinal_counts import Count + from check_support import bits,no_decode + import check_composed + from physical_controls import PreparedFull,emit_signed + from physical_engine import FullPhysical + from records import Tape + from session import erase_marker + from word_product import WordProduct + from words import BLANK + program,values = case['program'],case['values'] + root,visits = check_composed.fixture('standard',False) + observations = Observations() + owner = FullPhysical(root,WordProduct(),(lambda event:observations.update([event])) if diagnostics else None) + prepared = PreparedFull(program,Tape,Count,case['event_types']) + payload = Tape() + for pair in values: + for value in pair: + emit_signed(payload,value,prepared.metadata['incoming_width']) + payload.rewind() + borrowed = (payload,prepared.code,*(value.tape for value in prepared.parameters)) + before = [(bytes(tape.cells),tape.head) for tape in borrowed] + expected = check_composed.encode(case['expected'],program.data_width) + aliases = [] + for private in (owner.pool.tapes[0],owner.output,owner.word.output,root.output, + root.router.output,root.root.current,root.root.plan.roles['precision']): + meters = tuple((tape.meter.reads,tape.meter.writes,tape.meter.moves) + for tape in (*borrowed,*owner.pool.tapes)) + aliases.append(reject(lambda private=private:prepared.run(owner,private), + 'external distinct physical Full input and metadata ports')) + bad_count = object.__new__(Count) + bad_count.tape = private + replaced = (bad_count,*prepared.parameters[1:]) + aliases.append(reject(lambda replaced=replaced:owner.run(payload,prepared.code,*replaced), + 'external distinct physical Full input and metadata ports')) + need(meters == tuple((tape.meter.reads,tape.meter.writes,tape.meter.moves) + for tape in (*borrowed,*owner.pool.tapes)), + 'private port rejected before borrowed or wrapper tape traffic') + start = time.monotonic() + old_h,old_d = owner.h_event,owner.diagonal + def report(kind,method,*args): + result = method(*args) + if progress: + print(json.dumps(dict(event=kind,completed=owner.full_calls, + elapsed_seconds=time.monotonic()-start)),file=sys.stderr,flush=True) + return result + owner.h_event = lambda *args:report('H',old_h,*args) + owner.diagonal = lambda *args:report('D',old_d,*args) + bases = (program.axes,program.data_width+program.axes,program.data_width+2*program.axes) + meters = {} + for tape in (*owner.private,*borrowed): + meter = getattr(tape,'meter',None) + if meter is None and hasattr(tape,'arena'): + meter = tape.arena.meter + if meter is not None: + meters[id(meter)] = meter + def totals(): + return {key:sum(getattr(meter,key) for meter in meters.values()) + for key in ('reads','writes','moves')} + try: + with certified_floors(bases) as (table,uses,misses): + initial_actions = totals() + with no_decode(): + returned = prepared.run(owner,payload) + final_actions = totals() + output = bits(returned) + need(output == expected,'actual complete physical Full endpoint equals independent oracle') + need(before == [(bytes(tape.cells),tape.head) for tape in borrowed], + 'all Full borrowed payload, controls and metadata restored') + owner.idle() + need(owner.closed and owner.current is None and not owner.pool.live, + 'closed complete physical Full owner') + need(all(tape.head == 1 and all(bit == BLANK for bit in tape.cells) + for tape in (*owner.pool.tapes,*owner.word.pool.tapes,*owner.word.canonical)), + 'all wrapper and exact-word owned bodies and markers erased') + protected = reject(lambda:prepared.run(owner,payload), + 'consume the previous compiler-boundary output') + need(not misses,'all finite fixture floor substitutions declared') + result = dict(status='PASS_PHYSICAL_FULL',label=case['label'],allocation=case['allocation'], + input=values,output_sha256=sha256(output).hexdigest(),output_bits=len(output), + source_semantic_work=case['semantic_work'],source_oracle_work=case['oracle_work'], + root_error_squared_sha256=case['root_error_squared_sha256'], + actual_calls=dict(owner.full_calls) if diagnostics else None, + word_scalar_products=owner.arithmetic.products if diagnostics else None, + word_recursion=dict(owner.word.calls) if diagnostics else None, + wrapper_calls=dict(owner.calls) if diagnostics else None, + passive_state=dict(word_products=owner.arithmetic.products,word_calls=dict(owner.word.calls), + wrapper_calls=dict(owner.calls),program_calls=dict(owner.full_calls)), + actual_H_backend_calls=dict(root.calls),recursive_visits=dict(visits), + observed_delivery=dict(observations),wrapper_pool_peak=owner.pool.peak, + word_pool_peak=owner.word.pool.peak,prepared_page_components=prepared.page_components, + prepared_control_bits=len(bits(prepared.code)), + private_port_inventory=len(owner.private),private_port_controls=len(aliases), + diagnostics_enabled=diagnostics, + physical_tape_actions={key:final_actions[key]-initial_actions[key] for key in initial_actions}, + exact_kernel='physical-ring-product.WordProduct, fixed leaf16 at every width', + fixture='source standard q2 native binding; actual metadata plan with certified finite floors', + finite_floor_certificates=[dict(n=n,numerator=a,denominator=b,result=value, + calls=uses[(a,b,n)]) for (a,b,n),value in sorted(table.items())], + protected_return_control=protected, + actual_elapsed_seconds=time.monotonic()-start) + returned.clear() + erase_marker(returned) + owner.idle() + if reuse: + with no_decode(): + returned = prepared.run(owner,payload) + need(bits(returned) == expected,'same physical owner completes another protected return') + need(before == [(bytes(tape.cells),tape.head) for tape in borrowed], + 'reused physical owner restores borrowed frames') + owner.idle() + need(owner.closed and owner.current is None and not owner.pool.live, + 'reused physical owner closes its scratch') + returned.clear() + erase_marker(returned) + result['same_owner_reuse'] = dict(status='PASS',output_sha256=sha256(expected).hexdigest()) + return result + except ValueError as error: + if ('physical complete input Euclidean radius' in str(error) + or 'actual complete physical Full endpoint equals independent oracle' in str(error)): + need(owner.closed and owner.current is None and not owner.pool.live, + 'declared rejecting control closes parent ownership') + owner.idle() + need(before == [(bytes(tape.cells),tape.head) for tape in borrowed], + 'declared rejecting control restores borrowed frames') + need(all(tape.head == 1 and all(bit == BLANK for bit in tape.cells) + for tape in (*owner.pool.tapes,*owner.word.pool.tapes,*owner.word.canonical)), + 'declared rejecting control restores wrapper and word scratch') + raise + finally: + if owner.output.read() != BLANK: + owner.output.clear() + erase_marker(owner.output) + prepared.close() + payload.clear() + erase_marker(payload) + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument('--mode',choices=('scalar','tensor'),default='scalar') + parser.add_argument('--progress',action='store_true') + parser.add_argument('--write-result',type=Path) + args = parser.parse_args() + case = prepared_source(args.mode) + if args.progress: + print(json.dumps(dict(prepared=case['allocation'])),file=sys.stderr,flush=True) + with opened(): + result = actual(case,args.progress) + raw = json.dumps(result,sort_keys=True,indent=2)+'\n' + if args.write_result: + args.write_result.write_text(raw) + print(raw,end='') + + +if __name__ == '__main__': + main() diff --git a/research/source-remaining-diagonal/retained/ledger/PROOF.md b/research/source-remaining-diagonal/retained/ledger/PROOF.md new file mode 100644 index 0000000000..3e580dee35 --- /dev/null +++ b/research/source-remaining-diagonal/retained/ledger/PROOF.md @@ -0,0 +1,321 @@ +# Spend the existing Gaussian normalizer once + +Prepared for @CubeJerry with substantial OpenAI assistance. Apache-2.0. +**Conditional source-interface lemma; no new kappa.** Canonical base: +`7c49fe32c55de02c2c873655c804b16e4c3fef0a`. + +## 1. Actual boundary, predecessor work and the two scale policies + +The current complete-Core / first-face bridge returns, on one actual original +field, a rounded approximation to + +`B_j = tensor_(i in G_j) (H_i^-1 / 2^u_i)`, + +where the real rational H_i are the same immutable augmented narrow References +on both sides of the splice. Put `U_j=sum_(i in G_j) u_i` and `U=sum_j U_j`. +The admitted real row-gap bound gives `||H_i^-1||_infinity<=1/delta_i`. +Because H_i is real, the same absolute row sums bound the component-l1 +supremum norm. Consequently +`||B_j||_*<=product_(i in G_j)(2^-u_i/delta_i)<=1`. +The bridge's single final truncation is on the common component grid 2^-q. +Its exact source, whole-field radius and error contracts are retained at +[public commit 73d5adab](https://github.com/CubeJerry/integer-mult-bounds/tree/73d5adaba2b7dc662e86eb901e81369a3f73be9f/research/core-halo-source-bridge). +This package retains its unchanged allocation function and proof. The complete +Core numerical contract is the cited premise at +[6fb9ab77](https://github.com/CubeJerry/integer-mult-bounds/blob/6fb9ab776b7d0956b8bcc2d3cfde0f3034421630/research/complete-core-physical-join/NUMERICS.md). + +The canonical `unconditional-batched-crt/PROOF.md`, under "Exact Gaussian and +source-transform identity", defines + +`(Cv)_j=v_(q_j)`, `D_jj=exp(pi alpha^2 beta_j^2)`, `N=C T_gauss D`, +`P_s F_s = D N^-1 C P_t F_t S_gauss`. + +It already normalizes **completed** S_gauss and D N^-1 C maps by dyadic powers +of p and restores their accumulated exponent gamma. The same package's +GAUSSIAN.md specifies a sufficient dyadic p^100 bound per completed axis and +combines normalizers within group diagonals. Its proof claims are provenance, +not accepted here as an unconditional multiplier. In particular, we retain +the source comparison H versus ideal N, coefficient preparation and physical +execution as premises. + +Let K_j be the already-declared compression normalizer exponent for group j. +On the padded target grid let Dtilde_i equal the actual D diagonal at selected +addresses and equal 1 at holes. Final extraction C drops holes and has norm +at most one. Since the actual Reference has no coupling to a hole, extraction +of `Dtilde_i H_i^-1` is exactly the corresponding source rational compression +map. The separate replacement of this rational map by the ideal N map is +not proved here. The source's normalized rational target is + +`G_j = 2^-K_j Dtilde_(G_j) tensor_(i in G_j) H_i^-1`. (1) + +This is a protocol on the complete padded target field: extraction is deferred +until after the groups. The exact extraction on an axis commutes with every +map acting only on another group's disjoint axes, so this preserves the +exact source factorization. We do not commute arbitrary rounded operations; +their actual all-input errors are controlled below. The inherited prime-product +admission `T/S<2` in GAUSSIAN.md bounds this padding volume. Physical adaptation +must still preserve the same original coordinates and pay the full padded +field. Without that admission retain T explicitly rather than identifying +its cost with the compressed source volume S. + +There are two valid accounting policies: + +* **Spend existing normalization.** Following B_j, apply + `A_j=2^-(K_j-U_j) Dtilde_(G_j)`. Then `A_j B_j=G_j` and the existing + final restoration `2^gamma` is unchanged. Require K_j>=U_j; a stronger + condition below makes A_j a contraction on arbitrary hole errors too. +* **Add a new normalization.** Keep the old remaining diagonal + `2^-K_j Dtilde_(G_j)`. The completed group is then `G_j/2^U_j`. + To recover the same old target the final exponent must become `gamma+U`. + +Adding U to gamma in the first policy is wrong; retaining gamma in the second +is wrong. These statements are exact identities, including all source holes. +The policy must be bound to the actual remaining coefficients and final +scale. Labels such as "normalized Core" cannot establish this binding. +The written theorem below uses the first policy. The second has the same +proof with its actual smaller remaining maps and final exponent gamma+U. + +#6880 already gives one-group splice bounds and warns that recovery scales +must be paid. #5325 joins a different physical Tensor using its own 1/8 +compression and gamma. The Gaussian normalization stream concerns powers of +(1-i)/2; the mixed-native audit concerns JSON commitments; sparse-dyadic +normalization concerns Bezout acquisition. None supplies this particular +source's remaining-diagonal contract or consumes its p^100 budget. We claim +that source-specific join and its exact admission rule, not a new generic +perturbation inequality, Gaussian identity or asymptotic p^100 argument. + +## 2. The actual D bound leaves room for the bridge normalizer + +Use the source family with p>=2 and `pi alpha^2<=5 log(16p)`; this upper bound +is an explicitly inherited eventual Gaussian admission. Original nearest +half-up rounding gives `|beta_j|<=1/2`. Therefore + +`1<=D_jj<=exp(pi alpha^2/4)<=(16p)^(5/4)<=(16p)^2`. + +Let `l=ceil(log2 p)`. A safe per-axis dyadic norm exponent is +`v_i=2l+8`. It covers the value 1 assigned to holes as well as all selected +diagonal entries. For a group put V_j=sum v_i. In the component-l1 supremum +norm used by the bridge, + +`||A_j|| <= c_j := 2^(U_j+V_j-K_j)`. + +Thus the exact finite admission `K_j>=U_j+V_j` makes both A_j and G_j +contractions. The bound holds on arbitrary numerical errors, including hole +errors, rather than only on an exact source-image subspace. + +The source gap `delta_i>=1/(16p^2)` permits the least dyadic normalizer +`u_i=ceil(log2(delta_i^-1))<=2l+4`. The looser `u_i<=2l+5` also suffices. +Consequently the concrete choice `k_i=100l` has + +`k_i-u_i-v_i >= 96l-13 > 0`, p>=2. (2) + +This is one sufficient dyadic polynomial budget compatible with the source +p^100 prescription. A caller's actual smaller k_i must pass the finite +inequality; its name or asymptotic order is insufficient. A caller choosing +oversized a_i instead of the least dyadic must fund those actual exponents. +Equation (2) does not certify the numerical D coefficients or implement their +physical stream. + +## 3. Actual rounded states, remaining error and explicit precision + +Let m>=1 groups partition the actual inverse axes. Each bridge is admitted on +every incoming q-grid state of component-l1 radius at most R_b=2R_0, with +integer R_0>=1. Its same-reference global error bound is + +`E_j=max( 2^(-t_j-U_j)+2^(1-q)+2 R_b Lambda_j, + L_j(R_b) 2^-q + R_b Lambda_j )`, (3) + +where + +`Lambda_j=sum_(i in G_j) (1-delta_i)^J_i/(2^u_i delta_i)`, +`L_j(R_b)=sum_(i in G_j) ((2W_i+1)R_b+2)/delta_i`. + +This is the retained actual bridge allocation, including complex component +conversion, whole Core error and the final q-grid truncation. It applies at +the actual input of each group; a rounded bridge is not assumed linear or +Lipschitz. Its internal native radius must still include `R_b sqrt(T_j)` for +the full field of that call. With a common upper volume `T_j<=2^n_addr`, where +n_addr denotes the field's address width, the sufficient exponent is +`ceil(log2 R_b)+ceil(n_addr/2)`. + +The actual remaining-diagonal implementation must return to the same q grid +and satisfy, on every actual input of radius at most R_w=3R_0, + +`||Ahat_j(z)-A_j z||_* <= e_A,j`. (4) + +This is a paid source/compiler/rounding obligation. It includes diagonal +coefficient error, products, copies, final grid conversion and any scale +operation. It is not inferred from (2). If Q_q is the final componentwise +toward-zero truncation and the preceding diagonal computation has error +e_D,j, then `e_A,j<=e_D,j+2^(1-q)`. No precision is silently preserved after +the remaining division. + +Set `w_j=c_j E_j+e_A,j`, with c_j<=1. If + +`sum_j w_j<=R_0`, `E_j<=R_0`, (5) + +the actual completed-group states all remain within R_b. Indeed a group +input of radius at most `R_0+sum_(k=1 and gamma>=0; a larger exact suffix can be covered by +adding an integer bound on log2(max(1,L_s)) to tau. Put + +`h=ceil(log2 m)`, `z=tau+gamma+h+1`, `eta=2^-z`. + +For each group require + +`t_j>=max(1,z+2-U_j)`, +`q>=max_i u_i`, `q>=z+ceil(log2(max(8,2 max_j L_j(R_b))))`, +`Lambda_j<=eta/(4R_b)`, `e_A,j<=eta`. (8) + +Then the Core term and final rounding in the kept branch of (3) are each +at most eta/4, and its tail is at most eta/2. The halo coefficient term is +at most eta/2 and its tail at most eta/4. Hence E_j<=eta, w_j<=2eta, and + +`sum w_j<=2m eta<=2^(-tau-gamma)<=1/2<=R_0`. + +All actual-domain guards (5) and the final tolerance follow. One sufficient +axis-tail admission is +`(1-delta_i)^J_i/(2^u_i delta_i)<=eta/(4R_b |G_j|)`. +The exact rational powers give a finite acceptance check. If delta_i=1 the +tail is zero at J_i=1, without taking a logarithm of zero. W_i=0 and holes +remain ordinary source cases. Every inherited Core/halo geometry admission, +original coordinate binding and production-context certificate stays required. + +Equation (8)'s q budget also leaves room for the final remaining-diagonal +truncation: `2^(1-q)<=eta/4`. It therefore suffices to obtain +`e_D,j<=3eta/4` before that truncation. This records a concrete still-open +diagonal error target rather than setting it to zero for free. + +## 4. Global dimension and complete costs + +The public Core's conservative family uses balanced group sizes between +g and 2g, `g=Theta(p^(39/40))`, and the actual number of axes +`d=Theta(p^epsilon)`, `epsilon=1-10^-30`. The canonical outer source gives +`n_addr=log2 T=Theta(p)`, `ell_original=Theta(p^(1-epsilon))`; these are explicit family +premises, not consequences of a finite fixture. +The source's own n denotes the integer input length, with V=Tp=Theta(n); +it is not the address-width symbol n_addr used here. + +Under uniform `u_i=O(log p)`, `k_i=O(log p)`, both global totals obey + +`U=O(d log p)=o(p)`, `gamma=O(d log p)=o(p)`. (9) + +The first-policy gamma also includes all preexisting expansion normalizers. +The second-policy exponent gamma+U has the same eventual order. A single +group's `U_j=o(p)` alone would not establish (9); the full d relation is +essential. We do not claim a contradiction for the canonical near-one +epsilon. The statement is asymptotic and can have a very large initial range. + +For a quantitative interpretation, suppose a combined scale bound has the +explicit form `B p^(1-a) log2 p`, where a=1-epsilon>0 and B is a uniform +constant after some admitted p_0. Elementary maximization gives +`log2 p <= (2/a) p^(a/2)` for p>=1. To make this scale at most c p, it +suffices that + +`p>=max(p_0,(2B/(a c))^(2/a))`. (10) + +With a=10^-30 this sufficient onset is enormous. Neither the proof nor its +small controls claim practical production parameters at this onset. + +Let `tau=O(p)`, `log R_0=O(p)`, `W_i=O(sqrt(p) polylog p)` and +`delta_i>=1/(16p^2)`. Then log L_j=O(p+log p+log g), log m=O(log p), and +(8) gives common q and all t_j of O(p). The fixed conservative choice +`J_i=16p^4` gives `(1-delta_i)^J_i<=exp(-p^2)` and meets the tail guards +eventually, including the total restored scale in (9). It retains +`b_i=(J_i-1)W_i<16p^5=p^400` and first-face containment remain. + +The inherited Core formats then use their actual q, t_j and full radius +R_b sqrt(T_j); their proofs give P_j,w_j=O(p) under the same uniform source +height/prefix premises. Here the word width w_j is unrelated to the local +error notation of (5). The bridge codec retains its complete O(T_j F_j) +invoice, with + +`F_j=d_record+w_native,j+(P_j-q)+(P_j+U_j-q)+1=O(p)`, + +where `d_record=q+R_b.bit_length()+1` and `w_native,j` denotes the actual +native signed-carrier width. Thus its sum is O(V m), V=Theta(Tp) for a +common upper field volume T. A separate final exact scale or an unfused +remaining dyadic shift costs a full O(V) pass, or O(Vm) for one per group; +it is not free. Exact positive final shifts retain O(p) signed headroom. +Exact downward shifts must retain the extra fractional bits or charge their +rounding through (4). Old backing and every source/halo/callee owner remain. + +All **diagonal numerical products**, coefficient tables, source formation, +validation and physical access retain their existing complete invoices. This +proof adds no per-record free scalar multiplication and provides no new +diagonal engine. Funding (4) at O(p) bits preserves a claimed existing tariff +only if its actual source contract supports that precision and cost. The +Core's full K-context setup and the halo archive bill remain; the new scale +ledger neither drops K nor creates a cache. A fixed number of global scalar +admission calculations per axis has polynomial descriptor cost; exact tail +checks may have polynomial(p) rational height and are setup, not online O(1). + +## 5. Failure controls and exact remaining implication + +The actual Reference._narrow returns identity whenever either address is a +hole. Thus a tensor coordinate consisting of holes is an exact eigenvector +of every H_i and its inverse with eigenvalue one. This is an admitted +all-input source direction, regardless of whether a particular outer prefix +reaches it. Its normalized bridge action is exactly multiplication by 2^-U_j. + +Take two groups with U_1=U_2=8, caller K_j=U_j, remaining diagonal identity, +and a unit value on such a coordinate. At q=15, each individual shift fits +q>=u_i, but the sequential q-grid values are `2^-8` and then zero, because +`2^-16<2^-15`. Restoring by 2^16 still returns zero instead of one. At q=16 +the unit survives exactly. This is a cumulative-grid erasure control for an +ideal exact hole action followed by the actual specified truncation; it is +not a native Gaussian execution or proof that a particular complete outer +caller reaches that input. Final C deletes this hole-supported direction: +the control concerns the **pre-extraction bridge interface**, and is not a +counterexample to the completed extracted compression output. It does not +prove a necessary q>=U condition for every final caller or reachable input. +It exposes why individual group shifts and an ideal-state radius check do +not certify the bridge's declared all-input global budget. + +Taking the actual Reference source halfwidth w=0 would make its selected +off-diagonal entries vanish, but does not supply a stronger admitted example: +the unchanged constructor's `narrow_tail` starts with +`2/(1-exp(-2 pi alpha^2))>2` at w=0. Its certified `narrow_gap` is then +negative. The actual bridge demands a positive bound no larger than that +certificate. We therefore do not promote this structurally identity +zero-source-halfwidth reference to an admitted selected-coordinate or +final-output counterexample. + +The independent checker also distinguishes omitted compensation from double +compensation, underfunded remaining diagonal norm, ideal-only wrapper radius, +missing wrapper truncation, source corruption, zero tails and the full-field +radius conversion. Exact finite recurrence cases corroborate the written +proof and the unchanged bridge allocation; they do not establish analytic +source or native execution premises. + +The new implication is now explicit: an actual remaining-diagonal service +meeting (4), bound to the source's chosen K_j and the proper policy, plus the +already admitted bridge at (8), yields a complete normalized compression-group +contract on actual states and the final contribution (7). The source's +polynomial normalizer budget passes its exact norm gate. Its source-page, +rounded-diagonal and physical delivery obligations still need execution and +verification; this is not a complete Gaussian/Tensor/FFT or multiplication +theorem. All five foundational assumptions and the accepted kappa remain. diff --git a/research/source-remaining-diagonal/verify.py b/research/source-remaining-diagonal/verify.py new file mode 100644 index 0000000000..41140b7d98 --- /dev/null +++ b/research/source-remaining-diagonal/verify.py @@ -0,0 +1,311 @@ +#!/usr/bin/env python3 +"""Independent rational coefficient oracle and bounded actual physical join. + +No floating-point acceptance, no copied interval implementation, and no online +host numerical callback. Prepared for @CubeJerry with OpenAI assistance. +""" +import argparse +from collections import Counter +from fractions import Fraction as Q +from functools import lru_cache +from hashlib import sha256 +import itertools +import json +from pathlib import Path +import sys +import time + +HERE = Path(__file__).resolve().parent +sys.path.insert(0, str(HERE)) +from diagonal_sources import authenticate, bridge, load, native, references +from coefficients import Layout, RemainingProgram, need, upper_grid + + +def reject(function, fragment): + try: + function() + except ValueError as error: + need(fragment in str(error), "expected rejection: " + fragment) + return 1 + raise ValueError("negative control accepted: " + fragment) + + +@lru_cache(None) +def oracle_pi(bits): + """Exact rational alternating sums, without the retained dyadic interval code.""" + def atan_inverse(d): + partial = Q(0) + for i in range(bits + 2): + partial += Q((-1) ** i, (2 * i + 1) * d ** (2 * i + 1)) + i = bits + 2 + following = partial + Q((-1) ** i, (2 * i + 1) * d ** (2 * i + 1)) + return min(partial, following), max(partial, following) + a, b = atan_inverse(5), atan_inverse(239) + return 16 * a[0] - 4 * b[1], 16 * a[1] - 4 * b[0] + + +@lru_cache(None) +def oracle_positive(exponent, bits): + """Direct positive Taylor remainder, not reciprocal/range-reduced exp(-x).""" + pilo, pihi = oracle_pi(bits) + lo, hi = exponent * pilo, exponent * pihi + termlo = termhi = sumlo = sumhi = Q(1) + for n in range(1, 8 * (bits + 1) + 100): + termlo, termhi = termlo * lo / n, termhi * hi / n + sumlo, sumhi = sumlo + termlo, sumhi + termhi + if hi < n + 2: + tail = termhi * hi / (n + 1) / (1 - hi / (n + 2)) + if tail < Q(1, 1 << (bits + 16)): + return sumlo, sumhi + tail + raise ValueError("bounded positive exponential oracle did not finish") + + +def prepare(): + with references() as (source, raw): + ref = source.Reference(raw, 15, 1, 2, 1, 3, 128) + other = source.Reference(raw, 15, 1, 2, 1, 3, 128) + cls = source.Reference + with native() as exact: + with exact.full_sources() as (_, _, _, compiler, _): + event_types = compiler.Hadamard, compiler.Diagonal + single = RemainingProgram(cls, (ref,), (1,), Layout((1, 4), (1,)), 9, 12, 3, compiler.Diagonal) + pair = RemainingProgram(cls, (ref, other), (1, 1), Layout((4, 1, 4), (2, 0)), + 18, 12, 3, compiler.Diagonal) + return single, pair, event_types + + +def coefficients(programs): + checked = trajectories = controls = 0 + beta, alpha, eta = Q(39, 40), Q(99827101, 100000000), Q(332353, 332929) + need(eta * Q(1, 10 ** 30) < beta * (alpha - eta), + "full original-period route exponent is strictly subordinate to existing dense exponent") + for R0 in range(1, 129): + need(3 * R0 + 2 <= 2 * (2 * R0 + 2), "public ledger q guard funds actual remaining error") + for ell in range(1, 257): + need(100 * ell - (2 * ell + 4) - (4 * ell + 16) > 0, + "source completed p^100 dyadic budget funds actual coefficient contraction") + for program in programs: + need(program.axis_bits == sum(program.layout.lengths[a] for a in program.layout.selected), + "full original period, never Core-side bit count") + unit = Q(1, 1 << program.bits) + scale = Q(1, 1 << (program.completed_bits - program.U)) + original_maps = [] + for ref in program.references: + S, e = ref.spec.source_size, ref.spec.excess + original_maps.append({j + (2 * e * j + S) // (2 * S): + Q(e * j, S) - (2 * e * j + S) // (2 * S) + for j in range(S)}) + for index, receipt in enumerate(program.receipts): + coordinates, stride = [], 1 + for axis in program.layout.selected: + side = 1 << program.layout.lengths[axis] + coordinates.append((index // stride) % side) + stride *= side + exponent = sum(ref.spec.alpha ** 2 * mapping.get(k, Q(0)) ** 2 + for ref, mapping, k in zip(program.references, original_maps, coordinates)) + need(tuple(coordinates) == receipt["coordinates"] and exponent == receipt["exponent"], + "independent forward enumeration binds full original coordinates, beta, and hole exponent") + lo, hi = oracle_positive(receipt["exponent"], program.bits) + lo, hi = scale * lo, scale * hi + c = receipt["value"] * unit + need(0 <= lo <= hi <= 1 and hi >= receipt["lower"] and lo <= receipt["upper"], + "independent direct exponential overlaps actual reciprocal enclosure") + need(max(abs(c - lo), abs(c - hi)) <= unit, "independent one-ulp coefficient error") + for real, imag in ((0, 0), (3, 0), (-3, 0), (0, -3), (1, 2), (-1, -2), + (Q(1, 4096), Q(-4095, 4096))): + a, b = int(real / unit), int(imag / unit) + outa, outb = int(Q(a * receipt["value"], 1 << program.bits)), int(Q(b * receipt["value"], 1 << program.bits)) + error = max(abs(outa * unit - real * lo), abs(outa * unit - real * hi)) + error += max(abs(outb * unit - imag * lo), abs(outb * unit - imag * hi)) + need(error <= (program.radius + 2) * unit, "actual truncation plus coefficient error") + trajectories += 1 + checked += 1 + # Original-axis order is independently checked by bit-address construction. + for address in range(1 << program.layout.n): + packed = 0 + for old in range(program.layout.n): + packed |= ((address >> old) & 1) << program.layout.gather.get(old, old) + original_coords = [] + for axis in program.layout.selected: + offset = sum(program.layout.lengths[:axis]) + original_coords.append((address >> offset) & ((1 << program.layout.lengths[axis]) - 1)) + need(program.layout.coordinates(packed & ((1 << program.layout.h) - 1)) == tuple(original_coords), + "actual gather maps every original selected coordinate") + original = program.completed_bits + program.completed_bits += 1 + controls += reject(program.validate, "allocation") + program.completed_bits = original + original = program.page + program.page = ((1, 1), *program.page[1:]) + controls += reject(program.validate, "coefficient period") + program.page = original + original = program.references[0].target_size + program.references[0].target_size += 1 + controls += reject(program.validate, "full original target axis") + program.references[0].target_size = original + program.validate() + zerobeta = program.receipts[0]["value"] * unit + if program.completed_bits - program.U < program.bits: + need(abs(zerobeta - Q(1, 1 << program.completed_bits)) > unit, + "omitted original U compensation negative control") + controls += 1 + # Adversarial enclosures straddling grid boundaries, including clipping. + quantizers = 0 + for bits in range(1, 13): + unit = Q(1, 1 << bits) + for k in range(min(1 << bits, 24)): + for lowpart, width in itertools.product((Q(0), Q(1, 10), Q(9, 10)), (Q(0), Q(1, 2), Q(1))): + lower, upper = (k + lowpart) * unit, (k + lowpart + width) * unit + if lower > 1: + continue + c = upper_grid(lower, upper, bits) * unit + need(max(abs(c - lower), abs(c - min(Q(1), upper))) <= unit, "all rational quantizer endpoints") + quantizers += 1 + lower, upper = Q(9, 10 * 4096), Q(19, 10 * 4096) + bad = (lower * 4096).__floor__() / Q(4096) + need(upper - bad > Q(1, 4096), "lower-floor negative control loses more than one ulp") + controls += 1 + controls += reject(lambda: upper_grid(Q(0), Q(2), 3), "one-ulp width") + return dict(coefficient_entries=checked, independent_grid_trajectories=trajectories, + rational_quantizer_cases=quantizers, negative_controls=controls, + programs=[p.record() for p in programs]) + + +def encode_external(values, width): + return "".join("".join(str(int(value < 0)) + format(abs(value), "0" + str(width - 1) + "b") + for value in pair) + "#" for pair in values) + + +def physical(program, event_types): + with native() as exact: + with exact.opened() as state: + from cardinal_counts import Count + from encoded import compare + from records import Tape + from session import initialize_marker, erase_marker + from words import BLANK + from physical_controls import PreparedFull + from check_support import no_decode + import check_composed + owner_module = load("remaining_physical_owner", HERE / "diagonal_owner.py") + B, codec_module = bridge() + root, visits = check_composed.fixture("standard", False) + observations = Counter() + owner = owner_module.RemainingOwner(root, lambda name: observations.update((name,))) + prepared = PreparedFull(program, Tape, Count, event_types) + expected_parameters = (program.layout.n, program.layout.n - program.layout.h, + program.layout.h, 1, program.bits, program.data_width, program.bits + 2, + program.bits + 2, 2 * program.data_width + 3, program.bits, + program.data_width, program.radius_bits, + max(1, (program.layout.n - 1).bit_length()), 1, 0, 1) + for actual, expected_parameter in zip(prepared.parameters, expected_parameters): + expected_count = Count.literal(expected_parameter) + try: + need(compare(actual, expected_count) == 0, "all16 original physical metadata positions") + finally: + expected_count.close() + erase_marker(expected_count.tape) + radius_log = program.radius_bits - (program.layout.n + 1) // 2 + accumulator_bits = 2 * program.bits + 2 * radius_log + program.layout.n + need(program.temporary_width - accumulator_bits >= 7, + "full-field accumulator bound has at least seven temporary margin bits") + routes = owner_module.PreparedRoutes(program.layout, program.data_width) + fmt = codec_module.Format(program.bits + program.radius.bit_length() + 1, program.bits, + program.data_width, program.bits, 0) + codec = codec_module.Codec(B, Tape, BLANK, initialize_marker, erase_marker, fmt) + bound = owner_module.BoundRemaining(codec, owner, routes, prepared) + values = [] + for index in range(1 << program.layout.n): + numerator = ((index * 613) % (3 << program.bits)) - (3 << (program.bits - 1)) + values.append((numerator, int((-1) ** index) * ((index * 31) % 1024))) + need(all(abs(a) + abs(b) <= program.radius << program.bits for a, b in values), "fixture actual input radius") + source = B.Tape("original external actual-state input", encode_external(values, fmt.external_bits)) + B.home(source) + before = source.inspect() + ports = (routes.forward, routes.inverse, prepared.code, + *(x.tape for x in routes.parameters), *(x.tape for x in prepared.parameters)) + snapshots = tuple((bytes(t.cells), t.head) for t in ports) + alias_controls = 0 + for private in (owner.output, owner.pool.tapes[0], owner.diagonal.output, + owner.diagonal.word.output, root.router.output): + alias_controls += reject(lambda private=private: owner.run(private, routes.forward, + routes.inverse, routes.parameters, prepared.code, prepared.parameters), + "external remaining-diagonal source/control ports") + need(tuple((bytes(t.cells), t.head) for t in ports) == snapshots, + "private aliases rejected before borrowed control traffic") + expected = [] + # Direct original-coordinate extraction, independent of route implementation. + for index, pair in enumerate(values): + coordinate = (index >> 1) & 15 + coefficient = program.page[coordinate][0] + expected.append(tuple(int(Q(value * coefficient, 1 << program.bits)) for value in pair)) + started = time.monotonic() + with no_decode(): + returned = bound.run(source) + elapsed = time.monotonic() - started + need(returned.inspect() == encode_external(expected, fmt.external_bits), + "unchanged native products and exact zero-drop codec match independent all-record oracle") + need(source.inspect() == before and source._head == 1, "preserved original external field") + need(tuple((bytes(t.cells), t.head) for t in ports) == snapshots, "all borrowed control heads and bytes restored") + need(observations["input_squares"] == 2 << program.layout.n and + observations["data_products"] == 1 << program.layout.n and + observations["coefficient_products"] == 0 and owner.calls["gathers"] == 2 + and owner.diagonal.arithmetic.products == 6 << program.layout.n, + "actual full radius, all products, and both original-frame routes") + result = dict(elapsed_seconds=round(elapsed, 3), native_observations=dict(observations), + gathers=owner.calls["gathers"], page_components=prepared.page_components, + scalar_products=owner.diagonal.arithmetic.products, + parameter_positions_checked=16, + accumulator_margin_bits=program.temporary_width - accumulator_bits, + negative_controls=alias_controls + reject(lambda: bound.run(source), + "consume previous external remaining-diagonal output"), + scalar_cutoff=owner.diagonal.word.base_bits, + native_grid=fmt.native_grid, external_grid=fmt.external_grid, codec_drop=fmt.drop, + input_sha256=sha256(before.encode()).hexdigest(), + output_sha256=sha256(returned.inspect().encode()).hexdigest(), + external_tapes=[t.bill() for t in (*codec.templates, *codec.work)], + authenticated_native_imports=state.authenticated_imports, + retained_native_cells=sum(len(t.cells) for t in owner.private), + private_tape_roles=len(owner.private)) + bound.consume() + need(not owner.pending and not bound.pending and owner.closed and owner.output.read() == BLANK + and all(t.inspect() == "" for t in codec.work), "consumed protected return and cleared owned payloads") + owner.idle() + prepared.close() + routes.close() + return result + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument("--physical", action="store_true") + parser.add_argument("--output") + args = parser.parse_args() + inputs = authenticate() + single, pair, event_types = prepare() + result = dict(status="PASS", source_inputs=len(inputs), coefficient=coefficients((single, pair))) + if args.physical: + result["physical"] = physical(single, event_types) + encoded = json.dumps(result, indent=2, sort_keys=True) + "\n" + # Normalize tuple/list representation before comparing a JSON receipt. + result = json.loads(encoded) + if args.output: + Path(args.output).write_text(encoded) + else: + recorded = json.loads((HERE / "evidence/REPLAY.json").read_text()) + need(result["coefficient"] == recorded["coefficient"] and + result["source_inputs"] == recorded["source_inputs"], "complete frozen coefficient/source receipt") + if args.physical: + stable = lambda row: {k: v for k, v in row.items() if k != "elapsed_seconds"} + need(stable(result["physical"]) == stable(recorded["physical"]), + "complete frozen actual native/codec receipt except elapsed time") + print(json.dumps(dict(status="PASS_SOURCE_REMAINING_DIAGONAL", source_inputs=len(inputs), + coefficients=result["coefficient"]["coefficient_entries"], + independent_grid_trajectories=result["coefficient"]["independent_grid_trajectories"], + coefficient_controls=result["coefficient"]["negative_controls"], + physical_scalar_calls=result.get("physical", {}).get("scalar_products"), + physical_controls=result.get("physical", {}).get("negative_controls")), sort_keys=True)) + + +if __name__ == "__main__": + main()