From bd63147b1a193f68b5713e5814ac3b2c743beff8 Mon Sep 17 00:00:00 2001 From: Jerry Jiaheng Chen <80299683+CubeJerry@users.noreply.github.com> Date: Wed, 11 Nov 2026 22:46:31 +0800 Subject: [PATCH] Map every source row to its whole complement invocation and child input slot without expanding replicas --- .../source-complement-port-index/NOTICE.md | 22 + .../source-complement-port-index/PR-TITLE.txt | 1 + research/source-complement-port-index/PR.md | 94 +++++ .../source-complement-port-index/PROOF.md | 324 +++++++++++++++ .../source-complement-port-index/README.md | 147 +++++++ .../source-complement-port-index/SOURCES.json | 75 ++++ .../source-complement-port-index/TASK.json | 20 + .../VALIDATION.json | 90 +++++ .../source-complement-port-index/groups.py | 286 +++++++++++++ .../independent/RESULT.json | 328 +++++++++++++++ .../independent/REVIEW.md | 165 ++++++++ .../independent/check.py | 260 ++++++++++++ .../inputs/finite_dag_audit.py | 379 ++++++++++++++++++ .../source_index/inputs/pascal_codec.py | 222 ++++++++++ .../inputs/source_index/source_index.py | 205 ++++++++++ .../reference/FINITE-PRECOMPILATION.md | 313 +++++++++++++++ .../reference/chronological-batch-README.md | 265 ++++++++++++ .../reference/symbolic-batch-PROOF.md | 98 +++++ .../source-complement-port-index/verify.py | 261 ++++++++++++ 19 files changed, 3555 insertions(+) create mode 100644 research/source-complement-port-index/NOTICE.md create mode 100644 research/source-complement-port-index/PR-TITLE.txt create mode 100644 research/source-complement-port-index/PR.md create mode 100644 research/source-complement-port-index/PROOF.md create mode 100644 research/source-complement-port-index/README.md create mode 100644 research/source-complement-port-index/SOURCES.json create mode 100644 research/source-complement-port-index/TASK.json create mode 100644 research/source-complement-port-index/VALIDATION.json create mode 100644 research/source-complement-port-index/groups.py create mode 100644 research/source-complement-port-index/independent/RESULT.json create mode 100644 research/source-complement-port-index/independent/REVIEW.md create mode 100644 research/source-complement-port-index/independent/check.py create mode 100644 research/source-complement-port-index/inputs/finite_dag_audit.py create mode 100644 research/source-complement-port-index/inputs/source_index/inputs/pascal_codec.py create mode 100644 research/source-complement-port-index/inputs/source_index/source_index.py create mode 100644 research/source-complement-port-index/reference/FINITE-PRECOMPILATION.md create mode 100644 research/source-complement-port-index/reference/chronological-batch-README.md create mode 100644 research/source-complement-port-index/reference/symbolic-batch-PROOF.md create mode 100644 research/source-complement-port-index/verify.py diff --git a/research/source-complement-port-index/NOTICE.md b/research/source-complement-port-index/NOTICE.md new file mode 100644 index 0000000000..08b2c8733a --- /dev/null +++ b/research/source-complement-port-index/NOTICE.md @@ -0,0 +1,22 @@ +# Notice and retained credit + +New true-rank local count reduction, source-bucket indexing, whole-complement +port map, proof and checker: prepared for Jerry Chen / @CubeJerry with +substantial OpenAI assistance, 2026. Apache-2.0. + +The exact source-row index at CubeJerry commit +c5bcb6dc792f5fe4d8abe89a2a2854f148b09f2c is retained byte-for-byte under +inputs/source_index/. Its unchanged Pascal codec originates at CubeJerry +commit 91246e5131152ccb1f64a969c36706360861f821. Their headers and independent +review lineage remain credited. + +inputs/finite_dag_audit.py and the reference notes are exact canonical e545 +bytes with original notices. Jacob Alan Sussman supplies Theorem 1G and its +Pascal flow; zxv supplies the native finite compiler and literal DAG source; +Mihir Srivastava supplies chronological-batch-width (#4507); JoyboyBrian +supplies symbolic-integer-batch-width (#5071). Their source formulas, +batch-factor minimality and operator hypotheses are inherited results. + +The checks are AI-assisted author evidence, with any separate peer review +identified separately. No human scientific review or formal-kernel +acceptance is claimed. diff --git a/research/source-complement-port-index/PR-TITLE.txt b/research/source-complement-port-index/PR-TITLE.txt new file mode 100644 index 0000000000..5bd414f11e --- /dev/null +++ b/research/source-complement-port-index/PR-TITLE.txt @@ -0,0 +1 @@ +Map every source row to its whole complement invocation and child input slot without expanding replicas diff --git a/research/source-complement-port-index/PR.md b/research/source-complement-port-index/PR.md new file mode 100644 index 0000000000..d945092b1b --- /dev/null +++ b/research/source-complement-port-index/PR.md @@ -0,0 +1,94 @@ +## Change and mathematical scope + +The published [source-row index](https://github.com/CubeJerry/integer-mult-bounds/tree/c5bcb6dc792f5fe4d8abe89a2a2854f148b09f2c/research/lockstep-source-row-index) +left source-rank grouping and complement batches open. This supplies an +exact inverse map between its replicated row integers and every whole +complement invocation/input slot in FINITE-PRECOMPILATION section 4. +Sources of rank N receive an explicit no-complement label; no B_0 is invoked. + +For true job rank s, freshness simplifies to A*s>N*r_last and unit fit to +A*s<=N*k_i. Shared product tables then supply each class's rank-s source +count in d lookups. Each bucket retains occurrence order and supports exact +rank/unrank. Given the supplied complete smaller-program width B_(N-s), +quotient/remainder of b*S_s+j selects the invocation and its input slot. +The inverse recovers the original replica-major source row. + +**No new kappa, width improvement or full assumption discharge.** Selected +conditional kappa remains 0.00363005817. + +## Why this is new + +#4507 and #5071 already prove the source census, whole-batch divisibility and +least gcd/LCM replication factors. Those results are credited. This adds the +individual source-occurrence/child-port identification without expanding +all replicas, unit ordinals or class paths. Equal true ranks and coincident +products share counts while retaining separate source fields. The complete +deterministic metadata cost includes candidate ranks with zero sources and +a paid serialized-table access model. + +## Verification + +```sh +python3 -I -W error -B research/source-complement-port-index/verify.py +python3 -I -W error -O -B research/source-complement-port-index/verify.py +``` + +Normal and optimized receipts agree: 26 literal flows, 755 sources, 1,334 +replicated rows, four fitting product-collision classes and 18 rejecting +controls. A source-pinned literal DAG oracle checks every bucket/port inverse. +A height-24 case indexes 216,192,013,559,808 sources per replica with 601 +states and 266 candidate ranks. An independent target-minus-incoming census +checks all 206 nonempty rank counts; six large replicated positions round-trip. + +A concrete rank-5 width-three complement uses old rows (2,3,6), then +(7,10,11), crossing replica boundaries. Full-rank rows (1,5,9) skip the +complement. Mutations reject incorrect freshness equality, overwritten +product coincidences, merged paid sites and merged replicas. + +Canonical base: e54523517d0f03e58352e647c403a5af3e525a57. +Source-index dependency: c5bcb6dc792f5fe4d8abe89a2a2854f148b09f2c. +Occurrence-codec origin: 91246e5131152ccb1f64a969c36706360861f821. +Exact input blobs and byte hashes are recorded in SOURCES.json. + +## Limitations and next obligations + +This is a logical grouping/dispatch interface. Payload permutation, adapters, +copy/restoration/erasure, actual smaller programs and the selected native +manifest remain supplied obligations. Complement divisibility does not +replace separate chronological exit-cut constraints. No owned bank becomes +an independent productive source. The complete multiplier, five framework +assumptions and all numerical/precision/tape costs remain conditional. + +Next: bind one real smaller-program library and whole-field adapter to these +ports, then price actual grouping and return. Separate exit-port indexing +must preserve its chronological cut boundaries. + +## Credit + +Prepared for Jerry Chen / **@CubeJerry** with substantial OpenAI assistance. +Credit the two published codecs and their separate AI reviews; Jacob Alan +Sussman's integer Pascal flow; zxv's native compiler/literal oracle; +Mihir Srivastava's #4507; JoyboyBrian's #5071; and the cited adaptive-width +predecessors. Original source headers are unchanged. Apache-2.0. + +## Independent acceptance checks + +The orchestrator read the full proof and implementation, checked the exact +source substitutions, candidate-rank bound, interval inverses and the complete +metadata cost distinction. The separate [peer review](independent/REVIEW.md) +constructs expected sources by literal role-word parent edges without using +the author census, freshness predicate or parent resolver. It passes 22 flows, +328 sources, 3,900 replicated rows, 2,707 whole invocation rectangles, 51 +NoComplement rows and 11 rejection controls. Both cross-replica batches are +recovered independently. A minor transient old/new bucket wording correction +was incorporated; the executable files were unchanged. + +```sh +python3 -I -W error -B research/source-complement-port-index/independent/check.py +``` + +Expected: `PASS_SOURCE_GROUPS_PEER_REVIEW cases=22 sources=328 rows=3900 controls=11`. +The exact reviewed hashes and test domain are in `independent/RESULT.json`. +Author normal and optimized replays pass identically from this final package. +These are independent AI checks, not human or formal-kernel acceptance. +The complete proposed PR description is committed in `PR.md`. diff --git a/research/source-complement-port-index/PROOF.md b/research/source-complement-port-index/PROOF.md new file mode 100644 index 0000000000..18592cc2a9 --- /dev/null +++ b/research/source-complement-port-index/PROOF.md @@ -0,0 +1,324 @@ +# True source-rank buckets and whole complement invocation ports + +Prepared for Jerry Chen / @CubeJerry with substantial OpenAI assistance. +Canonical base: `e54523517d0f03e58352e647c403a5af3e525a57`. +This is an offline logical interface theorem. No new kappa, physical +permutation, actual selected template or complete assumption discharge is +claimed. + +## 1. Pinned obligation and exact domain + +Use the separated finite rule and source-row codec at CubeJerry commit +`c5bcb6dc792f5fe4d8abe89a2a2854f148b09f2c`, +`research/lockstep-source-row-index/`. Its occurrence-codec dependency is +`91246e5131152ccb1f64a969c36706360861f821`. Both executable inputs are retained +unchanged and checked by hash. The parent note is canonical +`research/kappa-rebuild/architecture/FINITE-PRECOMPILATION.md`, sections 3-4, +Git blob `4badb40f0919c515823cb07e44c6470d4d6469ca`. + +Let k_i>=2 be d distinct target ranks with productive-role multiplicities +W_i; W=sum W_i. There are P actual ordered paid positions, with q distinct +positive ranks r and multiplicities P_r, all strictly below k_min. Actual +productive role names, paid positions and owned roles retain their identities. +Let A>=k_max be the ambient cap, N>=A, and + + G=max{g: A*k_min^g<=N}. + +The source note uses A=k_max; the inherited source codec also admits the +displayed larger ambient cap, which we retain explicitly. At path p of +depth h, put rho=product_(j in p) r_j. A unit has multiindex alpha with +|alpha|=G-h, column rho*c(alpha), multiplicity ordinal v N. (2) + +These are inherited exact flow identities, not a new interpretation of +the finite compiler. + +Write S_s for the number of actual fresh sources with job rank s and +S=sum_s S_s. The source note requires each of the a*S_s corresponding +independent arrays to receive its complementary rank-(N-s) job before the +flow starts. For each positive e=N-s, the supplied smaller program has a +positive productive width B_e, so whole invocations require + + B_(N-s) divides a*S_s. (3) + +The least factor B_e/gcd(B_e,S_s), and the LCM across these and the separate +chronological exit batches, are predecessor results: chronological-batch-width +([#4507](https://github.com/CrocSwap/integer-mult-bounds/pull/4507)) and +symbolic-integer-batch-width/PROOF.md +([#5071](https://github.com/CrocSwap/integer-mult-bounds/pull/5071)). They are not claimed anew. +This package accepts a supplied a and tests (3). It does not treat a factor +clearing only complements as sufficient for exits, or pool separate exits. + +When s=N the complementary rank is zero. Section 4 says zero-rank terms +vanish. **No B_0 is supplied, constructed or invoked.** Such sources receive +an explicit `NoComplement` label below. + +## 2. A true-rank local count without a profile scan + +Fix a proposed job rank s. At a state (h,rho,r), the fresh-source test (2) +simplifies exactly to + + h=0 or A*s>N*r. (4) + +For a role of rank k_i, the unit-fit test simplifies to + + A*s<=N*k_i. (5) + +Both statements follow by substituting (1), with positive r at h>0. +Neither test depends on the unit ordinal or on the particular target +multiindex once s, rho and i are fixed. The last paid rank remains essential +in (4); equal-depth equal-dilation states may still differ. + +Let F_g(c) count ordered words of g productive role names whose rank product +is c. It is the inherited multiplicative-polynomial census: + + F_0(1)=1, + F_g(c)=sum_i W_i*F_(g-1)(c/k_i), + +with a noninteger argument or an absent product contributing zero. Equivalently +F_g(c)=sum_(|alpha|=g,c(alpha)=c) u(alpha). Product coincidences add their +counts; they do not identify different words, role names or source arrays. + +Define C_s(h,rho,r) to be zero if (4) fails. Otherwise put + + C_s(h,rho,r) + = sum_(i: A*s<=N*k_i) W_i * F_(G-h)(s/(rho*k_i)). (6) + +Equation (6) counts exactly the fresh sources of true rank s in that +class. For each role type i, the quotient fixes the unit column product; +F sums precisely its eligible multiindices and their u(alpha) ordinals; +W_i restores the distinct native role names. Condition (5) guarantees fit +for every such multiindex, while (4) guarantees freshness for every slot. +The converse assigns each actual source to exactly one term. + +Thus one C_s value needs d product-table lookups rather than scanning all +multiindices. This identity is the useful additional count interface; the +inherited total-source recurrence alone does not identify true-rank ports. + +## 3. Candidate ranks and per-bucket subtree counts + +Every source lies in the band + + N/A < s <= N. (7) + +For a nonroot source, (4) and r>=1 give the strict lower bound. At the root, +c(alpha)*k_i>=k_min^(G+1)>N/A by the definition of G. For the upper bound, +unit fit and k_i<=A give rho*c(alpha)*k_i<=N. Equality at either capacity +test must be treated as a fitting parent, not a new source. + +Every possible s is the product of a depth-h paid dilation and a target +word product of degree G-h+1, because alpha+e_i has that degree. Distinct +paid dilations at depth h number at most binom(h+q-1,q-1); target products +of the latter degree number at most binom(G-h+d,d-1). Therefore the entire +candidate list before coincidence deduplication has length at most + + Q0 = sum_(h=0..G) binom(h+q-1,q-1)*binom(G-h+d,d-1) + = binom(G+q+d,q+d-1)-binom(G+q,q-1). (8) + +The equality counts weak compositions of G+1 across q paid types and d +target types, excluding those with zero target degree. In particular G=0 +gives Q0=d, and q=d=1 gives Q0=G+1. Multiplicative coincidences only lower +the actual number. The implementation extracts distinct (h,rho) from the +already sorted state keys, forms these products, applies (7), sorts and +deduplicates. It does not enumerate paid paths. Some remaining candidates +can still have no source; their work is charged using Q0. + +For one candidate s, retain the predecessor's state keys (h,rho,r), at most + + R=1+q*binom(G+q-1,q), (9) + +with value one at G=0. Set T_s=C_s at h=G, and otherwise use + + T_s(h,rho,r)=C_s(h,rho,r)+sum_t P_t*T_s(h+1,rho*t,t). (10) + +Induction down the finite class tree proves (10). Equal paid ranks may +share statistical counts; their actual paid positions retain separate child +intervals. The root total is S_s. Candidates with S_s=0 are dropped only +after this work. The catalogue satisfies sum_s S_s=S because true job rank +partitions the inherited source set. + +The implementation builds each bucket's two count arrays separately and +stores only (s,S_s) in the catalogue. At most one bucket remains cached +after a query. Constructing its replacement can briefly retain both the +old and new buckets, still using O(R) count storage; the construction +loop can similarly retain the preceding temporary bucket. Holding every +bucket simultaneously is not included in the stated workspace bound. + +## 4. Canonical within-rank order + +For each s, restrict the predecessor's source order to actual rank-s slots: +depth-first class preorder with actual paid-site order; then lexicographic +multiindex, ordinal, and native role-list order. This is stable filtering +of occurrences, not a reordering of native jobs or a change to owner identity. + +At a class state, scan its stored degree-G-h multiindices. A point contributes +only if k=s/(rho*c(alpha)) is an existing target rank, the quotient is an +integer, unit fit holds and (4) holds. Its block contains u(alpha)*W_k slots +in ordinal/native-role order. All coincident-product multiindices retain +their separate positions in this scan. + +To rank a source, descend its actual paid path, adding the current class's +C_s and each preceding actual child's T_s. At the destination add preceding +point blocks, then v*W_k and the role's index among native names of rank k. +Reject a matched slot, a different true job rank or an invalid unit. + +To unrank j in [0,S_s), first distinguish the local interval C_s from the +ordered child intervals T_s. In the local interval scan the point blocks, +then use division by W_k to recover the unit ordinal and native role. In +a child interval descend that actual paid position. Each descent increases +h and there are at most G. Zero-size blocks are skipped. + +The same finite half-open interval induction as the inherited codec proves +both inverses. Write r_s(u) for this rank of a source occurrence u. Neither +an equal true rank nor equal count-state statistics merge two occurrences. + +## 5. Whole complement ports and their inverse + +Let r(u) in [0,S) be the already published source-row index. Its replicated +row order is replica-major: + + row(b,u)=b*S+r(u), 0<=bN*r_last`, and the unit-fit condition becomes `A*s<=N*k_i`. +Shared ordered-word product counts therefore compute each class's rank-s +source count in d lookups, without scanning all multiindex profiles at every +state. Product coincidences add counts; physical fields remain distinct. + +Each true-rank bucket has an exact rank/unrank in the preceding source +order. If j is that bucket index, b the replica and S_s its size, then +`x=b*S_s+j`. For a nonzero complement e=N-s, the supplied width B_e must +divide a*S_s, and `divmod(x,B_e)` is exactly its invocation and input slot. +The inverse recovers b,j and the old row. Rank N skips this division and +supplies no complement call. + +The metadata construction has a deterministic polynomial bound for fixed +native rank alphabets. It uses sorted product/count tables and retains only +one active rank-bucket DP. The full cost includes predecessor indexing, +candidate ranks that turn out empty, large integer arithmetic, queries that +change buckets, and the supplied width/replication bit lengths. A separate +conservative serialized-table simulation charges scans, cursor returns, +updates and erasure. See [PROOF.md](PROOF.md), section 6. + +## A batch that crosses replica boundaries + +For productive roles (small,2),(large,5), paid sites (1,small),(1,bank), +A=5,N=10, the four unreplicated source ranks in the fixed row order are +4,10,5,5. At three replicas, the rank-5 bucket has six arrays. With a +supplied complement rank-5 program of width three, its invocations use: + +| Complement invocation | Existing source-row integers | +| --- | --- | +| 0 | 2, 3, 6 | +| 1 | 7, 10, 11 | +| No complement, source rank 10 | 1, 5, 9 | + +The first invocation crosses from replica zero into replica one. Dividing +the old source-row integer directly by three would give the wrong fields. +The rank-4 sources use the separately supplied rank-6 width-one program. +This example specifies addresses; executing the gathering and restoration +still has its physical cost. + +## Reproduction and evidence + +After placing the package at `research/source-complement-port-index/`, run: + +```sh +python3 -I -W error -B research/source-complement-port-index/verify.py +python3 -I -W error -O -B research/source-complement-port-index/verify.py +``` + +Both standard-library commands print `PASS_TRUE_SOURCE_COMPLEMENT_PORTS`; +the executed normal and optimized outputs agree exactly. The unchanged +literal DAG oracle supplies **26 flows, 755 source fields and 1,334 replicated +rows**. Every bucket order, class-local/subtree count and whole-complement +port inverse agrees. Four fitting classes contain distinct multiindices +with the same column product. Eighteen rejecting controls cover wrong +freshness equality, dropped product multiplicity, repeated paid sites, +replica merging, zero complements, divisibility, namespaces and bounds. + +A height-24 example uses **601 count states** and **266 candidate source +ranks**, with 206 nonempty buckets, to index +**216,192,013,559,808 source arrays per replica**. Its chronological tree +would have 423,644,304,721 classes. A separate method verifies every rank +count by subtracting actual incoming paid jobs from the full target census; +it uses no rank-bucket freshness test or subtree DP. Six replicated row +positions round-trip. Finite checks corroborate the written theorem; they +are not an asymptotic experiment or formal-kernel proof. + +[SOURCES.json](SOURCES.json) pins all reused code and reference bytes. +[VALIDATION.json](VALIDATION.json) records the executed receipt. Namespace, +actual occurrence, true job rank and integer row position remain distinct. + +## Prior work and limits + +[#4507](https://github.com/CrocSwap/integer-mult-bounds/pull/4507) and +[#5071](https://github.com/CrocSwap/integer-mult-bounds/pull/5071) already prove +the source/complement census, least gcd/LCM factors and the need to preserve +individual chronological exit cuts. [#4638](https://github.com/CrocSwap/integer-mult-bounds/pull/4638) +extends batching to adaptive-height forests. [#6086](https://github.com/CrocSwap/integer-mult-bounds/pull/6086) +and [#6612](https://github.com/CrocSwap/integer-mult-bounds/pull/6612) improve +different width bounds; this contribution claims no width improvement. +The new work is the individual source-occurrence/child-port map and its +costed true-rank counting interface. + +The supplied a is checked only against complement divisibility. The full +compiler must also clear every separate ordered exit batch. All smaller +programs and their whole-job adapters remain supplied premises. The map +does not execute a payload permutation, copy inputs, create a source from an +owned bank, construct the selected astronomical native manifest, or price +the complete native/tape/numerical caller. The selected conditional +**kappa=0.00363005817** and all five foundational assumptions remain. + +Next work should join one real smaller-program library and its explicit +whole-field adapter to these ports, then price the actual grouping/return +permutation. Separate chronological exit-port indexing is another remaining +emitter obligation; source grouping does not authorize pooling those exits. + +## Credit + +Prepared for **Jerry Chen / @CubeJerry**, with substantial OpenAI assistance. +The preceding two published codecs retain their proof and independent AI +review credit. Jacob Alan Sussman supplies the Pascal/lockstep flow; zxv its +native finite compiler and literal DAG audit; Mihir Srivastava supplies +#4507's chronological gcd/LCM policy; JoyboyBrian supplies #5071's exact +separated batch/bit-size formulation. codyw912 and the other cited authors +retain the adaptive-width and native lineage. All reused headers remain. +Apache-2.0; see [NOTICE.md](NOTICE.md). + +## Independent acceptance checks + +The orchestrator read the full proof and implementation, checked the exact +source substitutions, candidate-rank bound, interval inverses and the complete +metadata cost distinction. The separate [peer review](independent/REVIEW.md) +constructs expected sources by literal role-word parent edges without using +the author census, freshness predicate or parent resolver. It passes 22 flows, +328 sources, 3,900 replicated rows, 2,707 whole invocation rectangles, 51 +NoComplement rows and 11 rejection controls. Both cross-replica batches are +recovered independently. A minor transient old/new bucket wording correction +was incorporated; the executable files were unchanged. + +```sh +python3 -I -W error -B research/source-complement-port-index/independent/check.py +``` + +Expected: `PASS_SOURCE_GROUPS_PEER_REVIEW cases=22 sources=328 rows=3900 controls=11`. +The exact reviewed hashes and test domain are in `independent/RESULT.json`. +Author normal and optimized replays pass identically from this final package. +These are independent AI checks, not human or formal-kernel acceptance. +The complete proposed PR description is committed in `PR.md`. diff --git a/research/source-complement-port-index/SOURCES.json b/research/source-complement-port-index/SOURCES.json new file mode 100644 index 0000000000..f4fe08aa98 --- /dev/null +++ b/research/source-complement-port-index/SOURCES.json @@ -0,0 +1,75 @@ +{ + "base_commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "selected_kappa": "0.00363005817", + "new_kappa": null, + "inputs": [ + { + "local_path": "inputs/source_index/source_index.py", + "repository": "CubeJerry/integer-mult-bounds", + "commit": "c5bcb6dc792f5fe4d8abe89a2a2854f148b09f2c", + "source_path": "research/lockstep-source-row-index/source_index.py", + "git_blob": "4e3cb2a53fb1c5c90e01202eb4e51a559c8727f7", + "sha256": "e978025591b06770026b9879f1e5b10827424f410794fb2b1e1f10a720f49176", + "bytes": 8485, + "usage": "runtime" + }, + { + "local_path": "inputs/source_index/inputs/pascal_codec.py", + "repository": "CubeJerry/integer-mult-bounds", + "commit": "91246e5131152ccb1f64a969c36706360861f821", + "source_path": "research/pascal-occurrence-codec/codec.py", + "git_blob": "2fb4426cc821a7e029e5c697787e235c79b4e756", + "sha256": "cec2c8b5e153a264127e8301ed59591fe97c9a46078ff2343b3784d177c6984d", + "bytes": 8243, + "usage": "runtime" + }, + { + "local_path": "inputs/finite_dag_audit.py", + "repository": "CrocSwap/integer-mult-bounds", + "commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "source_path": "research/kappa-rebuild/transfer-audit/finite_dag_audit.py", + "git_blob": "c1798bfa9c1d47a40313a276a8ce639c232143e5", + "sha256": "f842f0e07ca40a181782a565a381b0ee20c6a4b08b8c2b8a4d5d630381bd1e8e", + "bytes": 19149, + "usage": "independent literal oracle" + }, + { + "local_path": "reference/FINITE-PRECOMPILATION.md", + "repository": "CrocSwap/integer-mult-bounds", + "commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "source_path": "research/kappa-rebuild/architecture/FINITE-PRECOMPILATION.md", + "git_blob": "4badb40f0919c515823cb07e44c6470d4d6469ca", + "sha256": "4cb32f6b8e388ecf6ed41b5bbdeeb4539cb40c8424f194974afea58f7e0921e8", + "bytes": 15898, + "usage": "exact parent source" + }, + { + "local_path": "reference/symbolic-batch-PROOF.md", + "repository": "CrocSwap/integer-mult-bounds", + "commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "source_path": "research/symbolic-integer-batch-width/PROOF.md", + "git_blob": "6702d6aba2ad4149f9efc8570012a66aae640c8c", + "sha256": "f6fed469b53137c41d8543822b08e2381ebdfb6503c26663d01f56a2e8ab76bc", + "bytes": 9251, + "usage": "credited #5071 proof" + }, + { + "local_path": "reference/chronological-batch-README.md", + "repository": "CrocSwap/integer-mult-bounds", + "commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "source_path": "research/chronological-batch-width/README.md", + "git_blob": "c85304a601f858774f425d5f3869ac0a6f85ec29", + "sha256": "0cf276c77016a98a0dabba822d27bb9cb94c0bf86ec353a16499fe85e6032c20", + "bytes": 13825, + "usage": "credited #4507 proof" + } + ], + "overlap": [ + 4507, + 4638, + 5071, + 6086, + 6612, + 7271 + ] +} diff --git a/research/source-complement-port-index/TASK.json b/research/source-complement-port-index/TASK.json new file mode 100644 index 0000000000..7f5f969b4e --- /dev/null +++ b/research/source-complement-port-index/TASK.json @@ -0,0 +1,20 @@ +{ + "base_commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "dependency_commit": "c5bcb6dc792f5fe4d8abe89a2a2854f148b09f2c", + "track": 57, + "wave": 3, + "claim": "exact true-source occurrence to whole complement invocation/slot bijection, with no-complement labels at rank N", + "scope": "separated finite flow; supplied smaller program widths and replication; deterministic metadata costs only", + "source_law": "FINITE-PRECOMPILATION sections 3-4", + "registered_hook": false, + "novelty": "individual occurrence-to-port inverse and fixed-rank local count reduction; gcd/LCM factors and censuses retained", + "status": "Root mathematical/code review and separate literal-word oracle accepted; final packaged normal/optimized replays pass", + "publication": "root only; no upstream pull request submission", + "remaining": [ + "separate ordered exit ports", + "actual smaller native programs and whole-job adapters", + "physical grouping and return", + "selected astronomical manifest", + "all five framework assumptions" + ] +} diff --git a/research/source-complement-port-index/VALIDATION.json b/research/source-complement-port-index/VALIDATION.json new file mode 100644 index 0000000000..a1b6b5eb84 --- /dev/null +++ b/research/source-complement-port-index/VALIDATION.json @@ -0,0 +1,90 @@ +{ + "python": "3.12.14", + "normal_exit": 0, + "optimized_exit": 0, + "mode_outputs_equal": true, + "result": { + "cross_replica_example": { + "first_invocation_rows": [ + 2, + 3, + 6 + ], + "no_complement_rows": [ + 1, + 5, + 9 + ], + "second_invocation_rows": [ + 7, + 10, + 11 + ], + "source_rank": 5 + }, + "large": { + "candidate_ranks": 266, + "class_paths_not_enumerated": "423644304721", + "height": 24, + "independently_checked_rank_counts": 206, + "positive_rank_buckets": 206, + "replicas": 6, + "round_trip_samples": 6, + "source_rows_per_replica": "216192013559808", + "states": 601 + }, + "literal": { + "cases": 26, + "literal_classes": 188, + "literal_sources": 755, + "no_complement_rows": 93, + "positive_buckets": 84, + "product_collision_classes": 4, + "replicated_rows": 1334, + "states": 90 + }, + "negative_controls": [ + "fabricated B_0", + "nonintegral complement batch", + "missing positive complement library", + "zero-rank invocation", + "zero-rank invocation census", + "skipped positive complement", + "invocation upper endpoint", + "slot upper endpoint", + "no-complement upper endpoint", + "foreign invocation namespace", + "absent true source rank", + "replicated row upper endpoint", + "wrong source-rank label", + "matched slot with same rank as a real source", + "non-strict parent cutoff mutation", + "overwritten product collision", + "merged equal-rank paid occurrences", + "merged replicated source arrays" + ], + "scope": "logical whole-complement port bijection; no physical routing or new kappa", + "source_pins": 6, + "status": "PASS_TRUE_SOURCE_COMPLEMENT_PORTS" + }, + "frozen_core": { + "groups.py": "871b166c174958bb467952bebe9a2b776a0582f0c427b7dea9a94a128edad171", + "PROOF.md": "c966ddff4b9f8cb7c2c428adc9ab6e0496fb2fa40e9d05a1397ec96f96327272", + "verify.py": "c691d89f6349c1482f11433921be3b3b6643e4f8e137ef4721d3f4a9ceab5ad6" + }, + "human_review": false, + "formal_kernel": false, + "actual_smaller_native_programs": false, + "payload_permutation": false, + "selected_manifest_emitted": false, + "independent_review": { + "status": "PASS", + "review": "independent/REVIEW.md", + "receipt": "independent/RESULT.json", + "cases": 22, + "sources": 328, + "rows": 3900, + "controls": 11 + }, + "final_package_replay": "normal and optimized author outputs equal; portable independent checker passed" +} diff --git a/research/source-complement-port-index/groups.py b/research/source-complement-port-index/groups.py new file mode 100644 index 0000000000..bbf5412552 --- /dev/null +++ b/research/source-complement-port-index/groups.py @@ -0,0 +1,286 @@ +"""True source-rank buckets and exact whole-complement invocation ports. + +Offline metadata only; no payload movement or smaller native program is free. +Prepared for CubeJerry with substantial OpenAI assistance. Apache-2.0. +""" +from bisect import bisect_left +from dataclasses import dataclass +from hashlib import sha256 +from importlib.util import module_from_spec, spec_from_file_location +from pathlib import Path +import sys + +HERE = Path(__file__).resolve().parent +INPUT = HERE/'inputs/source_index/source_index.py' +EXPECTED = 'e978025591b06770026b9879f1e5b10827424f410794fb2b1e1f10a720f49176' +if sha256(INPUT.read_bytes()).hexdigest() != EXPECTED: + raise ValueError('frozen source-row index hash') +spec = spec_from_file_location('grouping_source_index', INPUT) +I = module_from_spec(spec) +sys.modules[spec.name] = I +spec.loader.exec_module(I) +C = I.C + + +class ProductCounts: + """Sorted integer products and exact word counts; absent products count zero.""" + def __init__(self, rows): + ordered = sorted(rows) + keys, values = [], [] + for key, value in ordered: + if keys and key == keys[-1]: + values[-1] += value + else: + keys.append(key) + values.append(value) + self.keys, self.values = tuple(keys), tuple(values) + + def get(self, key): + at = bisect_left(self.keys, key) + return self.values[at] if at < len(self.keys) and self.keys[at] == key else 0 + + def items(self): + return zip(self.keys, self.values) + + +class _RankBucket: + """One retained true-rank subtree table; every physical path stays distinct.""" + def __init__(self, groups, source_rank): + self.groups, self.rank = groups, source_rank + self.local = I.SortedStateTable(groups.states) + self.total = I.SortedStateTable(groups.states) + for state in reversed(groups.states): + h, rho, previous = state + local = self._local(state) + total = local + if h < groups.index.height: + for rank, multiplicity in groups.index.paid.items(): + total += multiplicity*self.total[h+1, rho*rank, rank] + self.local[state], self.total[state] = local, total + self.size = self.total[0, 1, 0] + + def fresh(self, state): + h, _, previous = state + return h == 0 or self.groups.rule.ambient*self.rank > self.groups.rank*previous + + def _local(self, state): + if not self.fresh(state): + return 0 + h, rho, _ = state + words = self.groups.products[self.groups.index.height-h] + count = 0 + for rank, weight in zip(self.groups.index.types, self.groups.index.weights): + divisor = rho*rank + if (self.groups.rule.ambient*self.rank <= self.groups.rank*rank + and self.rank % divisor == 0): + count += weight*words.get(self.rank//divisor) + return count + + def blocks(self, state): + if not self.fresh(state): + return + h, rho, _ = state + for point, column, units in self.groups.index.point_data[self.groups.index.height-h]: + product = rho*column + if self.rank % product: + continue + role_rank = self.rank//product + i = bisect_left(self.groups.index.types, role_rank) + if (i < len(self.groups.index.types) and self.groups.index.types[i] == role_rank + and self.groups.rule.ambient*product <= self.groups.rank): + yield point, column, units, self.groups.index.weights[i], role_rank + + def roles(self, rank): + return tuple(name for name, value in self.groups.rule.roles if value == rank) + + def rank_source(self, unit, role): + self.groups.index.flow.validate_unit(unit) + C.require(self.groups.job_rank(unit, role) == self.rank, 'true source-rank mismatch') + state, offset = (0, 1, 0), 0 + for chosen in unit.path: + h, rho, _ = state + offset += self.local[state] + for rank, _ in self.groups.rule.rounds[:chosen]: + offset += self.total[h+1, rho*rank, rank] + rank = self.groups.rule.rounds[chosen][0] + state = (h+1, rho*rank, rank) + for point, _, units, weight, rank in self.blocks(state): + if point < unit.point: + offset += units*weight + elif point == unit.point: + return offset+unit.ordinal*weight+self.roles(rank).index(role) + else: + break + raise ValueError('not a fresh source of this rank') + + def unrank_source(self, ordinal): + C.natural(ordinal, 'rank-bucket ordinal') + C.require(ordinal < self.size, 'rank-bucket ordinal range') + state, path = (0, 1, 0), () + while True: + if ordinal < self.local[state]: + for point, _, units, weight, rank in self.blocks(state): + if ordinal < units*weight: + unit, role = divmod(ordinal, weight) + return C.Unit(path, point, unit), self.roles(rank)[role] + ordinal -= units*weight + raise ValueError('local rank-bucket count disagreement') + ordinal -= self.local[state] + h, rho, _ = state + C.require(h < self.groups.index.height, 'rank-bucket has no further child') + for site, (rank, _) in enumerate(self.groups.rule.rounds): + child = h+1, rho*rank, rank + if ordinal < self.total[child]: + state, path = child, path+(site,) + break + ordinal -= self.total[child] + else: + raise ValueError('rank-bucket subtree count disagreement') + + +class SourceGroups: + """All true source-rank counts, with at most one retained bucket DP.""" + def __init__(self, rule, rank, replicas=1, namespace='flow'): + self.rule, self.rank = rule, rank + self.index = I.SourceIndex(rule, rank, replicas, namespace) + self.states = tuple(self.index.total) + self.products = [ProductCounts(((1, 1),))] + for _ in range(self.index.height+1): + self.products.append(ProductCounts( + (product*k, count*weight) + for product, count in self.products[-1].items() + for k, weight in zip(self.index.types, self.index.weights))) + candidates = [] + previous = None + for h, rho, _ in self.states: + if (h, rho) == previous: + continue + previous = h, rho + for product in self.products[self.index.height-h+1].keys: + source_rank = rho*product + if rule.ambient*source_rank > rank and source_rank <= rank: + candidates.append(source_rank) + candidates = I.sorted_unique(candidates) + self.candidate_count = len(candidates) + self.ranks, self.counts = [], [] + for source_rank in candidates: + bucket = _RankBucket(self, source_rank) + if bucket.size: + self.ranks.append(source_rank) + self.counts.append(bucket.size) + self.ranks, self.counts = tuple(self.ranks), tuple(self.counts) + C.require(sum(self.counts) == self.index.size, 'true-rank buckets partition sources') + self._active = None + + def _position(self, source_rank): + C.natural(source_rank, 'source rank') + at = bisect_left(self.ranks, source_rank) + C.require(at < len(self.ranks) and self.ranks[at] == source_rank, + 'source rank absent from catalogue') + return at + + def count(self, source_rank): + return self.counts[self._position(source_rank)] + + def _prepare(self, source_rank): + self._position(source_rank) + if self._active is None or self._active.rank != source_rank: + self._active = _RankBucket(self, source_rank) + return self._active + + def job_rank(self, unit, role): + i = self.rule.type_of(role) + return self.index.flow.dilation(unit.path)*C.column(self.rule, unit.point)*self.index.types[i] + + def rank_source(self, source_rank, unit, role): + return self._prepare(source_rank).rank_source(unit, role) + + def unrank_source(self, source_rank, ordinal): + return self._prepare(source_rank).unrank_source(ordinal) + + +@dataclass(frozen=True) +class ComplementPort: + namespace: str + source_rank: int + invocation: int + slot: int + + +@dataclass(frozen=True) +class NoComplement: + namespace: str + source_rank: int + ordinal: int + + +class ComplementRouter: + """Logical child-port bijection for the positive complement phase only. + + library lists exactly the needed positive (complement rank, program width) + pairs. These are supplied widths, not a proof of the smaller programs. + Exit-cut feasibility and all payload moves remain separate obligations. + """ + def __init__(self, groups, library): + self.groups = groups + pairs = sorted(library) + for rank, width in pairs: + C.natural(rank, 'complement rank') + C.natural(width, 'complement program width') + C.require(0 < rank < groups.rank and width > 0, + 'positive smaller complement only; no B_0') + C.require(all(a[0] < b[0] for a, b in zip(pairs, pairs[1:])), + 'distinct complement library ranks') + required = tuple(sorted(groups.rank-s for s in groups.ranks if s < groups.rank)) + C.require(tuple(rank for rank, _ in pairs) == required, + 'exact positive complement library') + self.library_ranks = tuple(rank for rank, _ in pairs) + self.library_widths = tuple(width for _, width in pairs) + for source_rank in groups.ranks: + if source_rank < groups.rank: + C.require(groups.index.replicas*groups.count(source_rank) % self.width(source_rank) == 0, + 'whole complement batch divisibility') + + def width(self, source_rank): + rank = self.groups.rank-source_rank + at = bisect_left(self.library_ranks, rank) + C.require(at < len(self.library_ranks) and self.library_ranks[at] == rank, + 'positive complement program absent') + return self.library_widths[at] + + def invocations(self, source_rank): + count = self.groups.count(source_rank) + C.require(source_rank < self.groups.rank, 'zero complement has no invocation') + return self.groups.index.replicas*count//self.width(source_rank) + + def locate(self, row): + namespace, replica, _, path, point, ordinal, role = self.groups.index.owner(row) + unit = C.Unit(path, point, ordinal) + source_rank = self.groups.job_rank(unit, role) + local = self.groups.rank_source(source_rank, unit, role) + grouped = replica*self.groups.count(source_rank)+local + if source_rank == self.groups.rank: + return NoComplement(namespace, source_rank, grouped) + invocation, slot = divmod(grouped, self.width(source_rank)) + return ComplementPort(namespace, source_rank, invocation, slot) + + def row(self, location): + C.require(type(location) in (ComplementPort, NoComplement), 'typed complement location') + C.require(location.namespace == self.groups.index.namespace, 'invocation namespace') + source_rank = location.source_rank + count = self.groups.count(source_rank) + if type(location) is NoComplement: + C.require(source_rank == self.groups.rank, 'no-complement rank must be N') + C.natural(location.ordinal, 'no-complement ordinal') + grouped = location.ordinal + else: + C.require(source_rank < self.groups.rank, 'zero complement has no invocation') + C.natural(location.invocation, 'complement invocation') + C.natural(location.slot, 'complement slot') + width = self.width(source_rank) + C.require(location.slot < width, 'complement slot range') + grouped = location.invocation*width+location.slot + C.require(grouped < self.groups.index.replicas*count, 'complement group range') + replica, local = divmod(grouped, count) + unit, role = self.groups.unrank_source(source_rank, local) + return replica*self.groups.index.size+self.groups.index.rank_source(unit, role) diff --git a/research/source-complement-port-index/independent/RESULT.json b/research/source-complement-port-index/independent/RESULT.json new file mode 100644 index 0000000000..6967f888c9 --- /dev/null +++ b/research/source-complement-port-index/independent/RESULT.json @@ -0,0 +1,328 @@ +{ + "cases": [ + { + "N": "9", + "height": 0, + "literal_paths": 1, + "literal_units": 1, + "matched_fields": 0, + "no_complement_rows": 0, + "physical_rows": 48, + "replicas": 12, + "sources": 4, + "true_ranks": 3, + "whole_complement_invocations": 18 + }, + { + "N": "17", + "height": 0, + "literal_paths": 1, + "literal_units": 1, + "matched_fields": 0, + "no_complement_rows": 0, + "physical_rows": 48, + "replicas": 12, + "sources": 4, + "true_ranks": 3, + "whole_complement_invocations": 18 + }, + { + "N": "18", + "height": 1, + "literal_paths": 3, + "literal_units": 4, + "matched_fields": 4, + "no_complement_rows": 0, + "physical_rows": 144, + "replicas": 12, + "sources": 12, + "true_ranks": 3, + "whole_complement_invocations": 48 + }, + { + "N": "35", + "height": 1, + "literal_paths": 3, + "literal_units": 4, + "matched_fields": 4, + "no_complement_rows": 0, + "physical_rows": 144, + "replicas": 12, + "sources": 12, + "true_ranks": 3, + "whole_complement_invocations": 36 + }, + { + "N": "36", + "height": 2, + "literal_paths": 7, + "literal_units": 14, + "matched_fields": 20, + "no_complement_rows": 0, + "physical_rows": 432, + "replicas": 12, + "sources": 36, + "true_ranks": 3, + "whole_complement_invocations": 432 + }, + { + "N": "71", + "height": 2, + "literal_paths": 7, + "literal_units": 14, + "matched_fields": 20, + "no_complement_rows": 0, + "physical_rows": 432, + "replicas": 12, + "sources": 36, + "true_ranks": 3, + "whole_complement_invocations": 108 + }, + { + "N": "72", + "height": 3, + "literal_paths": 15, + "literal_units": 48, + "matched_fields": 80, + "no_complement_rows": 0, + "physical_rows": 1344, + "replicas": 12, + "sources": 112, + "true_ranks": 3, + "whole_complement_invocations": 1344 + }, + { + "N": "13", + "height": 0, + "literal_paths": 1, + "literal_units": 1, + "matched_fields": 0, + "no_complement_rows": 0, + "physical_rows": 36, + "replicas": 12, + "sources": 3, + "true_ranks": 2, + "whole_complement_invocations": 12 + }, + { + "N": "19", + "height": 0, + "literal_paths": 1, + "literal_units": 1, + "matched_fields": 0, + "no_complement_rows": 0, + "physical_rows": 36, + "replicas": 12, + "sources": 3, + "true_ranks": 2, + "whole_complement_invocations": 36 + }, + { + "N": "91", + "height": 1, + "literal_paths": 5, + "literal_units": 6, + "matched_fields": 8, + "no_complement_rows": 0, + "physical_rows": 120, + "replicas": 12, + "sources": 10, + "true_ranks": 6, + "whole_complement_invocations": 52 + }, + { + "N": "97", + "height": 1, + "literal_paths": 5, + "literal_units": 6, + "matched_fields": 8, + "no_complement_rows": 0, + "physical_rows": 120, + "replicas": 12, + "sources": 10, + "true_ranks": 6, + "whole_complement_invocations": 94 + }, + { + "N": "637", + "height": 2, + "literal_paths": 21, + "literal_units": 31, + "matched_fields": 60, + "no_complement_rows": 0, + "physical_rows": 396, + "replicas": 12, + "sources": 33, + "true_ranks": 13, + "whole_complement_invocations": 167 + }, + { + "N": "643", + "height": 2, + "literal_paths": 21, + "literal_units": 31, + "matched_fields": 60, + "no_complement_rows": 0, + "physical_rows": 396, + "replicas": 12, + "sources": 33, + "true_ranks": 13, + "whole_complement_invocations": 284 + }, + { + "N": "8", + "height": 0, + "literal_paths": 1, + "literal_units": 1, + "matched_fields": 0, + "no_complement_rows": 0, + "physical_rows": 12, + "replicas": 12, + "sources": 1, + "true_ranks": 1, + "whole_complement_invocations": 3 + }, + { + "N": "39", + "height": 0, + "literal_paths": 1, + "literal_units": 1, + "matched_fields": 0, + "no_complement_rows": 0, + "physical_rows": 12, + "replicas": 12, + "sources": 1, + "true_ranks": 1, + "whole_complement_invocations": 4 + }, + { + "N": "40", + "height": 1, + "literal_paths": 5, + "literal_units": 5, + "matched_fields": 4, + "no_complement_rows": 0, + "physical_rows": 12, + "replicas": 12, + "sources": 1, + "true_ranks": 1, + "whole_complement_invocations": 3 + }, + { + "N": "199", + "height": 1, + "literal_paths": 5, + "literal_units": 5, + "matched_fields": 4, + "no_complement_rows": 0, + "physical_rows": 12, + "replicas": 12, + "sources": 1, + "true_ranks": 1, + "whole_complement_invocations": 4 + }, + { + "N": "200", + "height": 2, + "literal_paths": 21, + "literal_units": 21, + "matched_fields": 20, + "no_complement_rows": 0, + "physical_rows": 12, + "replicas": 12, + "sources": 1, + "true_ranks": 1, + "whole_complement_invocations": 3 + }, + { + "N": "2401", + "height": 3, + "literal_paths": 85, + "literal_units": 85, + "matched_fields": 84, + "no_complement_rows": 12, + "physical_rows": 12, + "replicas": 12, + "sources": 1, + "true_ranks": 1, + "whole_complement_invocations": 0 + }, + { + "N": "45", + "height": 2, + "literal_paths": 7, + "literal_units": 8, + "matched_fields": 8, + "no_complement_rows": 12, + "physical_rows": 96, + "replicas": 12, + "sources": 8, + "true_ranks": 7, + "whole_complement_invocations": 36 + }, + { + "N": "5", + "height": 0, + "literal_paths": 1, + "literal_units": 1, + "matched_fields": 0, + "no_complement_rows": 24, + "physical_rows": 24, + "replicas": 12, + "sources": 2, + "true_ranks": 1, + "whole_complement_invocations": 0 + }, + { + "N": "10", + "height": 1, + "literal_paths": 3, + "literal_units": 3, + "matched_fields": 2, + "no_complement_rows": 3, + "physical_rows": 12, + "replicas": 3, + "sources": 4, + "true_ranks": 3, + "whole_complement_invocations": 5 + } + ], + "cases_count": 22, + "core_sha256": { + "PROOF.md": "c966ddff4b9f8cb7c2c428adc9ab6e0496fb2fa40e9d05a1397ec96f96327272", + "groups.py": "871b166c174958bb467952bebe9a2b776a0582f0c427b7dea9a94a128edad171", + "verify.py": "c691d89f6349c1482f11433921be3b3b6643e4f8e137ef4721d3f4a9ceab5ad6" + }, + "cross_replica_rows": [ + [ + 2, + 3, + 6 + ], + [ + 7, + 10, + 11 + ] + ], + "negative_controls": [ + "no fabricated B_0", + "nonintegral whole batch", + "no rank-zero invocation", + "positive complement cannot skip", + "foreign namespace", + "NoComplement upper endpoint", + "physical row upper endpoint", + "strict parent equality", + "coincident target products", + "equal-rank paid positions", + "replica identity" + ], + "no_complement_rows_checked": 51, + "oracle": "literal ordered role words and parent-word first-role/suffix matching; no author census, freshness or parent helper", + "physical_rows_checked": 3900, + "scope": "logical true-rank metadata and whole complement ports; no physical payload routing or new kappa", + "sources_checked": 328, + "status": "PASS_SOURCE_GROUPS_PEER_REVIEW", + "whole_invocations_checked": 2707 +} diff --git a/research/source-complement-port-index/independent/REVIEW.md b/research/source-complement-port-index/independent/REVIEW.md new file mode 100644 index 0000000000..c63bb5d700 --- /dev/null +++ b/research/source-complement-port-index/independent/REVIEW.md @@ -0,0 +1,165 @@ +# Independent source-rank grouping and whole-complement-port review + +Prepared for Jerry Chen / CubeJerry with substantial OpenAI assistance. +Canonical research base: `e54523517d0f03e58352e647c403a5af3e525a57`. +The reviewed package is `research/source-complement-port-index` +(working path `work/compiler_source_groups/package`). The final published +directory name may be chosen by the orchestrator; the exact core byte hashes +below and in RESULT.json identify this review. + +## Verdict and exact scope + +The true-job-rank reduction, bucket subtree recurrence, stable source-order +filtering and typed whole-complement-port bijection are valid at their +declared offline metadata boundary. No blocking mathematical or executable +defect was found. One nonblocking memory-wording clarification was incorporated: +constructing a replacement bucket briefly retains the previous bucket too, +although only one stays cached after the query. The final proof now states +this explicitly. The stated O(R) active-count space remains valid with that +constant factor. Runtime code and verifier are unchanged by that clarification. + +This is independent AI review of the stated source-relative result. It is +not independent human or proof-kernel acceptance, a physical payload router, +a native supplier admission, an assumption discharge or a new kappa claim. + +The review is independent of the author's verifier. `check.py` imports the +actual runtime package but does not import or call its verifier, literal DAG +oracle, count/profile generators, freshness predicate or parent resolver to +construct the expected source set. It does not modify author code. + +Final frozen reviewed hashes, confirmed directly with the author and after +the clarification replay: + +| File | SHA256 | +| --- | --- | +| `groups.py` | `871b166c174958bb467952bebe9a2b776a0582f0c427b7dea9a94a128edad171` | +| `PROOF.md` | `c966ddff4b9f8cb7c2c428adc9ab6e0496fb2fa40e9d05a1397ec96f96327272` | +| `verify.py` | `c691d89f6349c1482f11433921be3b3b6643e4f8e137ef4721d3f4a9ceab5ad6` | + +## Universal argument reviewed + +For a productive role with rank k, an occurrence at paid path p, dilation +rho and target profile alpha has actual job rank s=rho*c(alpha)*k. +Substituting that expression into the inherited parent-fit condition gives +the exact nonroot freshness test A*s>N*r_last. Substituting into the unit-fit +condition gives A*s<=N*k. Both substitutions use positive divisors; equality +is admitted as parent fit and therefore is not fresh. The role's bare k, +the profile degree and the source-row index cannot replace s. + +At fixed state and s, the required target word product is s/(rho*k). +The weighted product table counts all ordered native role words with that +product. Multiplicative collisions add counts, and W_k retains distinct +productive role names. Thus the local formula counts exactly the eligible +source occurrences. There is no loss of profile or role identity when those +statistics share a count table; ranking later scans the separate ordered +profile intervals. The subtree recurrence adds each actual paid child's +source interval; equal paid ranks are multiplied by their occurrence count. +The last paid rank remains in the state and freshness test. + +The candidate rank set is complete: an actual source product combines h +paid factors with G-h+1 target factors, the latter degree being positive. +Stars and bars gives the displayed Q0 bound including its omitted zero-target +term. At the root, k_min^(G+1)>N/A. At nonroots freshness and r_last>=1 give +the same strict lower band; fit and k<=A give s<=N. Neither filtering step +drops a source. Constructing and charging zero-count candidate DPs is explicit. + +The restricted order is exactly the inherited source order filtered by s: +actual paid-path preorder, then profile, unit ordinal and native role-list +order. The local blocks and actual child intervals form disjoint half-open +intervals. Ranking adds preceding intervals; unranking selects the unique +containing interval and decreases the remaining subtree depth. This proves +the inverse maps without treating equal products or rank statistics as equal +physical occurrences. + +For replica b, original source u, bucket ordinal r_s(u) and bucket count S_s, +the grouped ordinal is x=b*S_s+r_s(u). Its image is [0,a*S_s). If s (first role, suffix) +edges, not author count/profile/freshness/parent helpers. Production modules +are imported only after constructing a separate literal specification. +Prepared for CubeJerry with substantial OpenAI assistance. Apache-2.0. +""" +from collections import Counter, defaultdict +from hashlib import sha256 +from itertools import product +from math import prod +from pathlib import Path +from types import ModuleType +import json +import sys + +HERE = Path(__file__).resolve().parent +PACKAGE = next((p for p in HERE.parents if (p/'groups.py').is_file()), + HERE.parents[1]/'work/compiler_source_groups/package') + + +def need(ok, message): + if not ok: + raise ValueError(message) + + +def load_source(name='peer_source_groups', mutation=None): + path = PACKAGE/'groups.py' + text = path.read_text() + if mutation: + before, after = mutation + need(text.count(before) == 1, 'unique review mutation') + text = text.replace(before, after) + module = ModuleType(name) + module.__file__ = str(path) + sys.modules[name] = module + exec(compile(text,str(path),'exec'), module.__dict__) + return module + + +def literal(roles, rounds, ambient, rank): + """Build finite words and literal matched target fields before counting.""" + types = sorted({k for _, k in roles}) + smallest = min(types) + height = 0 + while ambient*smallest**(height+1) <= rank: + height += 1 + units, point_words, paths = {}, {}, [] + for depth in range(height+1): + for path in product(range(len(rounds)),repeat=depth): + paths.append(path) + rho = prod(rounds[j][0] for j in path) + words = set() + buckets = defaultdict(list) + for word in product(range(len(roles)),repeat=height-depth): + ranks = tuple(roles[j][1] for j in word) + if ambient*rho*prod(ranks) <= rank: + words.add(word) + point = tuple(ranks.count(k) for k in types) + buckets[point].append(word) + units[path], point_words[path] = words, buckets + matched = set() + for path in paths: + if len(path) == height: + continue + for word in units[path]: + first, suffix = word[0], word[1:] + for site in range(len(rounds)): + child = path+(site,) + need(suffix in units[child], 'every parent paid job has an actual child') + edge = child,suffix,first + need(edge not in matched, 'literal incoming target uniqueness') + matched.add(edge) + sources, interior = [], [] + local = Counter() + for path in paths: + rho = prod(rounds[j][0] for j in path) + for point, words in point_words[path].items(): + column = prod(roles[j][1] for j in words[0]) + for ri,(role,k) in enumerate(roles): + flags = [(path,word,ri) in matched for word in words] + need(all(flags) or not any(flags), 'whole Pascal source block') + for ordinal in range(len(words)): + record = path,point,ordinal,ri,role,rho*column*k + if flags[0]: + interior.append(record) + else: + sources.append(record) + local[path,record[-1]] += 1 + sources.sort() + subtree = Counter() + for path,_,_,_,_,s in sources: + for end in range(len(path)+1): + subtree[path[:end],s] += 1 + return {'height':height,'paths':paths,'sources':sources,'interior':interior, + 'local':local,'subtree':subtree,'matched':len(matched), + 'units':sum(map(len,units.values()))} + + +def check(module, roles, rounds, ambient, rank, replicas=12, library=None): + wanted = literal(roles,rounds,ambient,rank) + rule = module.C.Rule(roles,rounds,owned=('bank','aux'),ambient=ambient) + groups = module.SourceGroups(rule,rank,replicas=replicas,namespace='peer') + expected = wanted['sources'] + by_rank = defaultdict(list) + for record in expected: + by_rank[record[-1]].append(record) + ranks = tuple(sorted(by_rank)) + need(groups.ranks == ranks, 'literal source-rank catalogue') + need(groups.index.height == wanted['height'], 'independent integer height') + need(groups.counts == tuple(len(by_rank[s]) for s in ranks), 'literal rank census') + need(groups.index.size == len(expected), 'literal complete source width') + if library is None: + library = tuple(sorted((rank-s,1+(rank-s)%4) for s in ranks if s self.groups.rank*previous', + 'self.groups.rule.ambient*self.rank >= self.groups.rank*previous','strict parent equality'), + ('values[-1] += value','values[-1] = value','coincident target products'), + ('total += multiplicity*self.total[h+1, rho*rank, rank]', + 'total += self.total[h+1, rho*rank, rank]','equal-rank paid positions'), + ('grouped = replica*self.groups.count(source_rank)+local', + 'grouped = local','replica identity'), + ) + for i,(before,after,label) in enumerate(mutations): + bad=load_source('mutated_peer_groups_'+str(i),(before,after)) + if i==0: + args=((('a',3),('b',5)),((1,'a'),(2,'bank')),5,45) + elif i==1: + args=(family[0][0],family[0][1],9,72) + else: + args=(roles,rounds,5,10) + negative.append(rejected(lambda: check(bad,*args),label)) + result={'status':'PASS_SOURCE_GROUPS_PEER_REVIEW', + 'core_sha256':{name:sha256((PACKAGE/name).read_bytes()).hexdigest() + for name in ('groups.py','PROOF.md','verify.py')}, + 'oracle':'literal ordered role words and parent-word first-role/suffix matching; no author census, freshness or parent helper', + 'cases':cases,'cases_count':len(cases), + 'sources_checked':sum(x['sources'] for x in cases), + 'physical_rows_checked':sum(x['physical_rows'] for x in cases), + 'whole_invocations_checked':sum(x['whole_complement_invocations'] for x in cases), + 'no_complement_rows_checked':sum(x['no_complement_rows'] for x in cases), + 'cross_replica_rows':[first,second],'negative_controls':negative, + 'scope':'logical true-rank metadata and whole complement ports; no physical payload routing or new kappa'} + (HERE/'RESULT.json').write_text(json.dumps(result,sort_keys=True,indent=2)+'\n') + print(result['status'],'cases='+str(len(cases)), + 'sources='+str(result['sources_checked']), + 'rows='+str(result['physical_rows_checked']), + 'controls='+str(len(negative))) + + +if __name__=='__main__': + main() diff --git a/research/source-complement-port-index/inputs/finite_dag_audit.py b/research/source-complement-port-index/inputs/finite_dag_audit.py new file mode 100644 index 0000000000..c1798bfa9c --- /dev/null +++ b/research/source-complement-port-index/inputs/finite_dag_audit.py @@ -0,0 +1,379 @@ +#!/usr/bin/env python3 +"""Independent integer and field-identity audit of finite mixed-job compilation. + +Apache-2.0. Substantial OpenAI assistance. The mathematical lockstep flow is +Jacob Alan Sussman's Theorem 1G; attribution and limits are in AUDIT.md. +No implementation from its tree_flow.py or explicit_sim.py is imported. +This checks scheduling and exact finite batching under a mixed-unit contract; +it does not manufacture that operator contract from a rank histogram. +""" +from collections import Counter, defaultdict, deque +from dataclasses import dataclass +from fractions import Fraction +from functools import lru_cache +from hashlib import sha256 +from math import factorial, gcd, lcm, prod +from pathlib import Path +import argparse +import gzip +import json + +HERE = Path(__file__).resolve().parent +ROOT = HERE.parents[2] + + +def need(test, message): + if not test: + raise AssertionError(message) + + +def read(path): + raw = Path(path).read_bytes() + return json.loads(gzip.decompress(raw) if str(path).endswith('.gz') else raw) + + +def digest(path): + return sha256(Path(path).read_bytes()).hexdigest() + + +def rational(value): + value = Fraction(value) + return f'{value.numerator}/{value.denominator}' + + +@dataclass(frozen=True) +class Rule: + # Productive target roles have fixed names and positive ranks. + roles: tuple + # A paid round is (rank, exact productive or owned role name). + rounds: tuple + owned: tuple = ('owned-C0',) + + def __post_init__(self): + names = [name for name, rank in self.roles] + need(len(set(names)) == len(names), 'Distinct productive roles') + need(set(names).isdisjoint(self.owned), 'Owned roles uncredited') + need(all(rank > 0 for name, rank in self.roles), 'Positive target ranks') + need(all(rank > 0 and name in set(names) | set(self.owned) + for rank, name in self.rounds), 'Every paid call has a real role') + need(max(rank for rank, name in self.rounds) < min(rank for name, rank in self.roles), + 'Strict mixed hierarchy') + + @property + def targets(self): + return Counter(rank for name, rank in self.roles) + + @property + def dimension(self): + return max(self.targets) + + +class IntegerTree: + """Literal classes, units, field names, and dependency edges at one rank.""" + + def __init__(self, rule, rank): + self.rule, self.rank = rule, rank + self.types = tuple(sorted(rule.targets)) + self.weights = tuple(rule.targets[k] for k in self.types) + self.points = self.lattice(1) + need(bool(self.points), 'At least one mixed unit fits') + self.depth = max(map(sum, self.points)) + self.units = [] + self.classes = [] + self.sources = [] + self.exits = [] + self.edges = set() + self.nodes = set() + self.source_counter = Counter() + self._class((), 1, []) + self.validate_fields() + need(self.topological_size() == len(self.nodes), 'Native-order dependency DAG') + + def lattice(self, dilation): + bound = self.rank // (self.rule.dimension * dilation) + out = [] + + def visit(index, powers, value): + if index == len(self.types): + out.append(tuple(powers)) + return + exponent = 0 + while value <= bound: + visit(index+1, powers+[exponent], value) + exponent += 1 + value *= self.types[index] + + if bound: + visit(0, [], 1) + return out + + def column(self, point): + return prod(k**a for k, a in zip(self.types, point)) + + def multiplicity(self, point): + return factorial(sum(point)) // prod(factorial(a) for a in point) * prod( + w**a for w, a in zip(self.weights, point)) + + def edge(self, before, after): + self.nodes.update((before, after)) + self.edges.add((before, after)) + + def after(self, uid, round_index): + return ('issue', uid, round_index+1) if round_index+1 < len(self.rule.rounds) else ('finish', uid) + + def _class(self, path, dilation, incoming): + depth = len(path) + class_units = [] + demands = defaultdict(list) + for point in self.lattice(dilation): + if sum(point) != self.depth-depth: + continue + column = dilation*self.column(point) + need(self.rule.dimension*column <= self.rank, 'All ambient axes fit') + for repetition in range(self.multiplicity(point)): + uid = len(self.units) + unit = {'uid': uid, 'path': path, 'point': point, 'column': column, + 'fields': {}, 'owned': {name: ('owned', uid, name) for name in self.rule.owned}} + self.units.append(unit) + class_units.append(unit) + for name, target in self.rule.roles: + index = self.types.index(target) + point_next = tuple(a+int(i == index) for i, a in enumerate(point)) + demands[point_next].append((unit, name, target*column)) + self.edge(('start', uid), ('issue', uid, 0)) + for j in range(len(self.rule.rounds)): + self.edge(('issue', uid, j), self.after(uid, j)) + self.classes.append((path, tuple(u['uid'] for u in class_units))) + supply = defaultdict(list) + for job in incoming: + supply[job['point']].append(job) + need(set(supply) <= set(demands), 'No paid output is abandoned') + for point, slots in demands.items(): + jobs = supply.get(point, []) + need(len(jobs) <= len(slots), 'No target is double funded') + for index, (unit, name, target) in enumerate(slots): + if index < len(jobs): + job = jobs[index] + need(job['rank'] == target, 'Exact target rank equality') + unit['fields'][name] = job['field'] + self.edge(('issue', job['uid'], job['round']), ('start', unit['uid'])) + self.edge(('finish', unit['uid']), self.after(job['uid'], job['round'])) + else: + field = ('source', len(self.sources)) + unit['fields'][name] = field + self.sources.append({'field': field, 'rank': target, 'unit': unit['uid'], 'role': name}) + self.source_counter[target] += 1 + need(self.rank < self.rule.dimension*target <= self.rule.dimension*self.rank, + 'Whole source lies in the proved source band') + all_fields = [field for unit in class_units for field in unit['fields'].values()] + need(len(all_fields) == len(set(all_fields)), 'Simultaneous units have disjoint arbitrary inputs') + need(all(len(unit['fields']) == len(self.rule.roles) for unit in class_units), 'Every input slot filled') + for j, (paid_rank, paid_role) in enumerate(self.rule.rounds): + outgoing = [] + for unit in class_units: + field = unit['fields'].get(paid_role, unit['owned'].get(paid_role)) + need(field is not None, 'Paid call remains on its physical owner') + outgoing.append({'field': field, 'rank': paid_rank*unit['column'], + 'point': unit['point'], 'uid': unit['uid'], 'round': j}) + need(len({job['field'] for job in outgoing}) == len(outgoing), 'Ordered round has no field alias') + if depth < self.depth: + self._class(path+(j,), dilation*paid_rank, outgoing) + else: + need(all(sum(job['point']) == 0 for job in outgoing), 'Only zero-generation exits') + need(len({job['rank'] for job in outgoing}) == 1, 'One rank per ordered exit batch') + for job in outgoing: + need(job['rank'] < self.rank, 'Every recursive exit strictly smaller') + complete = ('exit', len(self.exits), job['uid']) + self.edge(('issue', job['uid'], j), complete) + self.edge(complete, self.after(job['uid'], j)) + self.exits.append(outgoing) + + def topological_size(self, extra_edges=()): + successors = defaultdict(list) + indegrees = {node: 0 for node in self.nodes} + for before, after in self.edges | set(extra_edges): + successors[before].append(after) + indegrees[after] += 1 + ready = deque(node for node in self.nodes if not indegrees[node]) + count = 0 + while ready: + before = ready.popleft() + count += 1 + for after in successors[before]: + indegrees[after] -= 1 + if not indegrees[after]: + ready.append(after) + return count + + def validate_fields(self): + need(len({row['field'] for row in self.sources}) == len(self.sources), + 'Every source is a distinct arbitrary field') + for path, unit_ids in self.classes: + fields = [field for uid in unit_ids for field in self.units[uid]['fields'].values()] + need(len(fields) == len(set(fields)), 'No duplicated independent input in a class') + + def summary(self): + return {'rank': self.rank, 'generations': self.depth, 'classes': len(self.classes), + 'units': len(self.units), 'source_fields': len(self.sources), + 'source_ranks': dict(sorted(self.source_counter.items())), + 'exit_ranks': dict(sorted(Counter(job['rank'] for group in self.exits for job in group).items())), + 'ordered_exit_batches': len(self.exits), 'event_nodes': len(self.nodes), + 'dependency_edges': len(self.edges), 'acyclic': True, + 'every_paid_call_real_owner': True, 'class_input_disjointness': True, + 'owned_fields_uncredited_conservative_allocation': len(self.units)*len(self.rule.owned)} + + +class Compiler: + def __init__(self, rule): + self.rule = rule + self.trees = {} + + @lru_cache(None) + def compile(self, rank): + if rank < self.rule.dimension: + return {'rank': rank, 'width': 1, 'leaves': rank, 'units': 0, 'per_array': Fraction(rank), + 'all_productive_fields_full_rank': True} + tree = IntegerTree(self.rule, rank) + self.trees[rank] = tree + multiplier = 1 + requirements = [] + for jobs in tree.exits: + smaller = self.compile(jobs[0]['rank']) + required = smaller['width']//gcd(smaller['width'], len(jobs)) + multiplier = lcm(multiplier, required) + requirements.append(('ordered_exit', jobs[0]['rank'], len(jobs), smaller['width'])) + for source_rank, count in tree.source_counter.items(): + smaller = self.compile(rank-source_rank) + required = smaller['width']//gcd(smaller['width'], count) + multiplier = lcm(multiplier, required) + requirements.append(('source_complement', rank-source_rank, count, smaller['width'])) + need(all(multiplier*count % width == 0 for kind, size, count, width in requirements), + 'Each ordered batch is independently integral') + width = multiplier*len(tree.sources) + normalized_leaves = sum((Fraction(len(jobs))*self.compile(jobs[0]['rank'])['per_array'] + for jobs in tree.exits), Fraction(0)) + normalized_leaves += sum((count*self.compile(rank-source_rank)['per_array'] + for source_rank, count in tree.source_counter.items()), Fraction(0)) + leaves = multiplier*normalized_leaves + need(leaves.denominator == 1, 'Integral actual leaf count') + unit_count = Fraction(len(tree.units)) + for kind, size, count, child_width in requirements: + child = self.compile(size) + unit_count += Fraction(count*child['units'], child_width) + unit_count *= multiplier + need(unit_count.denominator == 1, 'Integral conservative owned allocation') + for source in tree.sources: + source_axes = set(range(source['rank'])) + complement = set(range(source['rank'], rank)) + need(source_axes.isdisjoint(complement) and source_axes | complement == set(range(rank)), + 'Each independent source receives the full rank-N job exactly once') + return {'rank': rank, 'width': width, 'leaves': leaves.numerator, 'units': unit_count.numerator, + 'per_array': leaves/width, 'replication': multiplier, 'ordered_requirements': requirements, + 'all_productive_fields_full_rank': True, + 'owned_fields_uncredited': unit_count.numerator*len(self.rule.owned), + 'strict_uniform_child_rank': 1, 'native_halving_guard': rank*rank > 2} + + +def actual_rule(): + """Extract every paid owner in chronology from the source-bound p2 word.""" + controller_path = ROOT/'research/kappa-rebuild/controller/GLOBAL-IDENTITY-COVER.json.gz' + controller = read(controller_path) + case = controller['all_three'] + roles = [(f'{side}{pair}:{port}', 41) for pair in range(2) for side in ('X', 'Y') for port in range(112)] + roles += [(row['owner'], row['target_rank']) for row in case['fresh_outputs']] + native_path = ROOT/'research/kappa-rebuild/complex/full-identity-certificates/THREE-base-FULL-IDENTITY-NATIVE.json.gz' + native = read(native_path) + rounds = [] + stages = ((0, 'forward'), (0, 'backward'), (0, 'forward'), (1, 'backward'), (1, 'forward')) + for stage, (pair, direction) in enumerate(stages): + helper = {row['role']: row['owner'] for row in case['helper_bindings'] if row['stage'] == stage} + for event in native[direction]: + if event[0] == 'climb': + _, part, role, old, new, rank = event + owner = f'X{pair}:{role}' if role < 112 else f'Y{pair}:{role-112}' if role < 224 else helper[role] + rounds.append((rank, owner)) + elif event[0] == 'center': + rounds.append((event[-1], 'owned-C0')) + for residual in case['paid_residuals']: + if residual['after_stage'] == stage: + rounds.append((residual['rank'], residual['owner'])) + need(Counter(rank for rank, name in rounds) == Counter({int(k): v for k, v in case['paid'].items()}), + 'Literal native paid-call extraction agrees with complete bill') + rule = Rule(tuple(roles), tuple(rounds)) + need(rule.targets == Counter({6:146, 9:803, 41:448}), 'Actual independent output jobs') + return rule, {str(path.relative_to(ROOT)): digest(path) for path in (controller_path, native_path)} + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument('--output', type=Path, default=HERE/'FINITE-DAG-AUDIT.json') + args = parser.parse_args() + # This synthetic contract tests only the generic compiler; no native circuit + # is claimed for its deliberately repeated/owned paid-role sequence. + toy = Rule((('a', 3), ('b', 3), ('c', 4)), + ((1, 'a'), (1, 'owned-C0'), (1, 'b'), (1, 'a'), (2, 'c'), (2, 'owned-C0'))) + compiler = Compiler(toy) + toy_results = [] + for rank in (4, 7, 12, 16, 28, 40): + compiled = compiler.compile(rank) + row = {k: rational(v) if isinstance(v, Fraction) else v for k, v in compiled.items() + if k != 'ordered_requirements'} + row['tree'] = compiler.trees[rank].summary() + toy_results.append(row) + tree = compiler.trees[16] + child = next(unit for unit in tree.units if unit['path'] == (0,)) + parent = next(unit for unit in tree.units if unit['path'] == ()) + cyclic = tree.topological_size([(('issue', parent['uid'], 1), ('start', child['uid']))]) < len(tree.nodes) + need(cyclic, 'Later-round dependency negative control creates a cycle') + fields = tree.units[0]['fields'] + first, second = tuple(fields)[:2] + old = fields[second] + fields[second] = fields[first] + illegal_alias = False + try: + tree.validate_fields() + except AssertionError: + illegal_alias = True + finally: + fields[second] = old + need(illegal_alias, 'Independent fields cannot share a source token') + cleared = compiler.compile(16) + bad_multiplier = cleared['replication']-1 + uncleared_rejected = any(bad_multiplier*count % width + for kind, size, count, width in cleared['ordered_requirements']) + need(uncleared_rejected, 'One fewer replica fails a real ordered batch divisibility requirement') + uniform = compiler.compile(40) + need(uniform['leaves']**10 < uniform['width']**10 * 40**9, + 'Exact finite toy supplier beats exponent 9/10, including all complements') + actual, pins = actual_rule() + actual_compiler = Compiler(actual) + finite = actual_compiler.compile(41) + actual_row = {k: rational(v) if isinstance(v, Fraction) else v for k, v in finite.items() + if k != 'ordered_requirements'} + actual_row['tree'] = actual_compiler.trees[41].summary() + need(finite['width'] == 1397 and finite['leaves'] == 57149, + 'Independent full-rank completion bill including every complementary axis') + need(41*1397-finite['leaves'] == 128, 'No credit from partial fields or owned center') + output = {'schema':'independent-finite-mixed-job-compilation-audit/1', + 'status':'PASS_FINITE_DAG_FIELD_OWNERS_BATCH_CLEARING_AND_FULL_RANK_COMPLETION', + 'source_sha256':digest(__file__), 'pinned_native_inputs':pins, + 'synthetic_rule_tests':toy_results, 'actual_p2_rank41':actual_row, + 'negative_controls':{'future_round_deadlock_rejected':cyclic, + 'aliased_independent_source_rejected':illegal_alias, + 'uncleared_ordered_batch_rejected':uncleared_rejected, + 'partial_source_not_full': set(range(6)) != set(range(41)), + 'owned_center_not_counted': len(actual.roles) == 1397}, + 'toy_strict_uniform_moment':{'rank':40,'exponent':'9/10', + 'integer_power_comparison':True}, + 'scope':['Independent finite flow and owner identities, not a proof of an abstract unit from its histogram.', + 'Actual p2 paid calls extracted in native order with original owners.', + 'Full F_N completion is a compositional proof under the pinned native endpoint contract.', + 'No winning near-threshold large-N supplier was materialized; the existence theorem is separate.', + 'No dynamic RAM transfer or new kappa is claimed.']} + args.output.write_text(json.dumps(output, indent=2, sort_keys=True)+'\n') + print(json.dumps({'status':output['status'], 'toy_ranks':[row['rank'] for row in toy_results], + 'actual_full_rank':41, 'actual_width':finite['width'], 'actual_paid_rank1':finite['leaves']})) + + +if __name__ == '__main__': + main() diff --git a/research/source-complement-port-index/inputs/source_index/inputs/pascal_codec.py b/research/source-complement-port-index/inputs/source_index/inputs/pascal_codec.py new file mode 100644 index 0000000000..2fb4426cc8 --- /dev/null +++ b/research/source-complement-port-index/inputs/source_index/inputs/pascal_codec.py @@ -0,0 +1,222 @@ +"""Exact Pascal interval codec for a separated lockstep flow. + +Apache-2.0. Prepared for CubeJerry with substantial OpenAI assistance. +This is an offline logical occurrence codec, not a fixed-tape dispatcher. +""" +from dataclasses import dataclass + + +def require(condition, message): + if not condition: + raise ValueError(message) + + +def natural(value, message): + require(type(value) is int and value >= 0, message) + + +@dataclass(frozen=True) +class Rule: + roles: tuple + rounds: tuple + owned: tuple = ("bank",) + ambient: int | None = None + + def __post_init__(self): + require(bool(self.roles) and bool(self.rounds), "nonempty rule") + names = tuple(name for name, _ in self.roles) + require(len(set(names)) == len(names), "duplicate productive role") + require(len(set(self.owned)) == len(self.owned), "duplicate owned role") + require(not set(names) & set(self.owned), "owned/productive alias") + require(all(type(k) is int and k >= 2 for _, k in self.roles), + "target ranks are integers at least two") + require(all(type(r) is int and 1 <= r < min(k for _, k in self.roles) + and owner in names + self.owned for r, owner in self.rounds), + "positive separated paid rank and real owner") + if self.ambient is None: + object.__setattr__(self, "ambient", max(k for _, k in self.roles)) + require(type(self.ambient) is int and + self.ambient >= max(k for _, k in self.roles), "ambient cap") + + @property + def types(self): + return tuple(sorted(set(k for _, k in self.roles))) + + @property + def weights(self): + return tuple(sum(k == rank for _, k in self.roles) for rank in self.types) + + def type_of(self, role): + names = tuple(name for name, _ in self.roles) + require(role in names, "unknown productive role") + rank = self.roles[names.index(role)][1] + return self.types.index(rank) + + def same_type_roles(self, i): + return tuple(name for name, k in self.roles if k == self.types[i]) + + +@dataclass(frozen=True) +class Unit: + path: tuple + point: tuple + ordinal: int + + +def validate_point(rule, point): + require(len(point) == len(rule.types), "point dimension") + for a in point: + natural(a, "nonnegative integer point") + + +def column(rule, point): + validate_point(rule, point) + out = 1 + for k, a in zip(rule.types, point): + for _ in range(a): + out *= k + return out + + +def multiplicity(rule, point): + """Multinomial times weights, using exact small-factor arithmetic.""" + validate_point(rule, point) + remaining, out = sum(point), 1 + for a, weight in zip(point, rule.weights): + choose = 1 + for j in range(1, a + 1): + choose = choose * (remaining - j + 1) // j + out *= choose + for _ in range(a): + out *= weight + remaining -= a + return out + + +def remove_letter(point, i): + require(0 <= i < len(point) and point[i] > 0, "missing target letter") + return tuple(a - int(j == i) for j, a in enumerate(point)) + + +def encode(rule, parent_point, child_ordinal, role): + """Exact ordinal in the parent's Pascal bucket.""" + validate_point(rule, parent_point) + i = rule.type_of(role) + child_point = remove_letter(parent_point, i) + natural(child_ordinal, "child ordinal") + require(child_ordinal < multiplicity(rule, child_point), "child ordinal range") + offset = 0 + for j in range(i): + if parent_point[j]: + offset += rule.weights[j] * multiplicity(rule, remove_letter(parent_point, j)) + same = rule.same_type_roles(i) + return offset + len(same) * child_ordinal + same.index(role) + + +def decode(rule, parent_point, parent_ordinal): + """Inverse: (child point, child ordinal, productive role).""" + validate_point(rule, parent_point) + require(sum(parent_point) > 0, "no Pascal split of an empty word") + natural(parent_ordinal, "parent ordinal") + require(parent_ordinal < multiplicity(rule, parent_point), "parent ordinal range") + residual = parent_ordinal + for i, a in enumerate(parent_point): + if not a: + continue + child = remove_letter(parent_point, i) + names = rule.same_type_roles(i) + size = len(names) * multiplicity(rule, child) + if residual < size: + ordinal, role_index = divmod(residual, len(names)) + return child, ordinal, names[role_index] + residual -= size + raise ValueError("Pascal identity failed") + + +class FlowCodec: + def __init__(self, rule, rank): + natural(rank, "ambient rank") + require(rank >= rule.ambient, "at least one unit fits") + self.rule, self.rank = rule, rank + capacity, self.height = rank // rule.ambient, 0 + power, smallest = 1, min(rule.types) + while power <= capacity // smallest: + power *= smallest + self.height += 1 + + def dilation(self, path): + value = 1 + for j in path: + natural(j, "paid occurrence") + require(j < len(self.rule.rounds), "paid occurrence range") + value *= self.rule.rounds[j][0] + return value + + def validate_unit(self, unit): + validate_point(self.rule, unit.point) + require(len(unit.path) + sum(unit.point) == self.height, "class degree") + natural(unit.ordinal, "unit ordinal") + require(unit.ordinal < multiplicity(self.rule, unit.point), "unit ordinal range") + require(self.rule.ambient * self.dilation(unit.path) * + column(self.rule, unit.point) <= self.rank, "absent unit") + + def parent(self, unit, role): + """None means a fresh source, otherwise the exact issuing parent.""" + self.validate_unit(unit) + i = self.rule.type_of(role) + if not unit.path: + return None + point = tuple(a + int(j == i) for j, a in enumerate(unit.point)) + path = unit.path[:-1] + if self.rule.ambient * self.dilation(path) * column(self.rule, point) > self.rank: + return None + return Unit(path, point, encode(self.rule, point, unit.ordinal, role)) + + def owner(self, unit, role, namespace="flow", replica=0): + """Resolve a canonical field identity without any occurrence table.""" + natural(replica, "replica") + self.validate_unit(unit) + self.rule.type_of(role) + while True: + parent = self.parent(unit, role) + if parent is None: + return (namespace, replica, "source", unit.path, unit.point, unit.ordinal, role) + parent_owner = self.rule.rounds[unit.path[-1]][1] + if parent_owner in self.rule.owned: + return (namespace, replica, "owned", parent.path, parent.point, + parent.ordinal, parent_owner) + unit, role = parent, parent_owner + + def paid_owner(self, unit, j, namespace="flow", replica=0): + self.validate_unit(unit) + natural(j, "paid occurrence") + require(j < len(self.rule.rounds), "paid occurrence range") + owner = self.rule.rounds[j][1] + if owner in self.rule.owned: + return (namespace, replica, "owned", unit.path, unit.point, unit.ordinal, owner) + return self.owner(unit, owner, namespace, replica) + + def iter_points(self, path): + """Stream the predecessor's lexicographic lattice order.""" + degree = self.height - len(path) + require(degree >= 0, "path too deep") + limit = self.rank // (self.rule.ambient * self.dilation(path)) + types = self.rule.types + + def visit(i, left, value, prefix): + if i == len(types): + if left == 0: + yield tuple(prefix) + return + for a in range(left + 1): + if value > limit: + break + yield from visit(i + 1, left - a, value, prefix + [a]) + value *= types[i] + + yield from visit(0, degree, 1, []) + + def iter_units(self, path): + for point in self.iter_points(path): + for ordinal in range(multiplicity(self.rule, point)): + yield Unit(path, point, ordinal) diff --git a/research/source-complement-port-index/inputs/source_index/source_index.py b/research/source-complement-port-index/inputs/source_index/source_index.py new file mode 100644 index 0000000000..4e3cb2a53f --- /dev/null +++ b/research/source-complement-port-index/inputs/source_index/source_index.py @@ -0,0 +1,205 @@ +"""Contiguous source rows by aggregated lockstep-subtree counting. + +Apache-2.0. Prepared for CubeJerry with substantial OpenAI assistance. +This is offline indexing, not a fixed-tape payload implementation. +""" +from collections import Counter +from bisect import bisect_left +import hashlib +import importlib.util +from pathlib import Path +import sys + +HERE = Path(__file__).resolve().parent +CODEC_HASH = "cec2c8b5e153a264127e8301ed59591fe97c9a46078ff2343b3784d177c6984d" +CODEC_PATH = HERE / "inputs/pascal_codec.py" +if hashlib.sha256(CODEC_PATH.read_bytes()).hexdigest() != CODEC_HASH: + raise ValueError("frozen occurrence codec hash") +spec = importlib.util.spec_from_file_location("source_index_codec", CODEC_PATH) +C = importlib.util.module_from_spec(spec) +sys.modules[spec.name] = C +spec.loader.exec_module(C) + + +def points(degree, dimensions): + """Lexicographic nonnegative multiindices of one exact degree.""" + if dimensions == 1: + yield (degree,) + return + for first in range(degree + 1): + for rest in points(degree - first, dimensions - 1): + yield (first,) + rest + + +def sorted_unique(items): + """Deterministic comparison sort and adjacent deduplication; no hashing.""" + ordered = sorted(items) + unique = [] + for item in ordered: + if not unique or item != unique[-1]: + unique.append(item) + return unique + + +class SortedStateTable: + """Fixed sorted integer keys, binary-search lookup and indexed values. + + The two count tables share one immutable key tuple. No growing state + set/dictionary and no expected hash-table time enters the theorem. + """ + def __init__(self, keys): + C.require(all(a < b for a, b in zip(keys, keys[1:])), + "strictly sorted distinct state keys") + self._keys = keys + self._values = [None] * len(keys) + + def position(self, key): + at = bisect_left(self._keys, key) + C.require(at < len(self._keys) and self._keys[at] == key, + "state key absent from fixed table") + return at + + def __getitem__(self, key): + value = self._values[self.position(key)] + C.require(value is not None, "state count not initialized") + return value + + def __setitem__(self, key, value): + self._values[self.position(key)] = value + + def __len__(self): + return len(self._keys) + + def __iter__(self): + return iter(self._keys) + + def keys(self): + return iter(self._keys) + + def values(self): + return iter(self._values) + + def items(self): + return zip(self._keys, self._values) + + +class SourceIndex: + def __init__(self, rule, rank, replicas=1, namespace="flow"): + C.natural(replicas, "replica count") + C.require(replicas > 0, "positive replica count") + self.flow = C.FlowCodec(rule, rank) + self.rule, self.rank = rule, rank + self.replicas, self.namespace = replicas, namespace + self.height = self.flow.height + self.types, self.weights = rule.types, rule.weights + self.paid = Counter(r for r, _ in rule.rounds) + # Counter is confined to the fixed input list; its worst-case + # collision cost is covered by the specification-size factor. + self.point_data = [] + for g in range(self.height + 1): + self.point_data.append(tuple((a, C.column(rule, a), C.multiplicity(rule, a)) + for a in points(g, len(self.types)))) + levels = [[(1, 0)]] + for _ in range(self.height): + # Adjacent equal dilations differ only in their last rank. + # Deduplicate them before generating children: (rho*r,r) is + # injective in rho at fixed r, and distinct r give distinct keys. + dilations = [] + for rho, _ in levels[-1]: + if not dilations or rho != dilations[-1]: + dilations.append(rho) + levels.append(sorted_unique((rho*r, r) for rho in dilations + for r in self.paid)) + keys = tuple((h, rho, previous) for h, level in enumerate(levels) + for rho, previous in level) + self.local, self.total = SortedStateTable(keys), SortedStateTable(keys) + for h in range(self.height, -1, -1): + for rho, previous in levels[h]: + state = (h, rho, previous) + local = sum(u*count for _, _, u, count in self.blocks(state)) + total = local + if h < self.height: + total += sum(mult*self.total[h+1, rho*r, r] + for r, mult in self.paid.items()) + self.local[state], self.total[state] = local, total + self.size = self.total[0, 1, 0] + C.require(self.size > 0, "nonempty source interval") + + def fresh_type(self, state, column, i): + h, rho, previous = state + return h == 0 or self.rule.ambient * (rho // previous) * column * self.types[i] > self.rank + + def blocks(self, state): + h, rho, _ = state + for point, column, units in self.point_data[self.height-h]: + if self.rule.ambient * rho * column <= self.rank: + count = sum(w for i, w in enumerate(self.weights) + if self.fresh_type(state, column, i)) + if count: + yield point, column, units, count + + def fresh_roles(self, state, column): + return tuple(name for name, k in self.rule.roles + if self.fresh_type(state, column, self.types.index(k))) + + def rank_source(self, unit, role): + self.flow.validate_unit(unit) + self.rule.type_of(role) + state, offset = (0, 1, 0), 0 + for chosen in unit.path: + h, rho, _ = state + offset += self.local[state] + for r, _ in self.rule.rounds[:chosen]: + offset += self.total[h+1, rho*r, r] + r = self.rule.rounds[chosen][0] + state = (h+1, rho*r, r) + for point, column, units, count in self.blocks(state): + if point < unit.point: + offset += units*count + continue + if point == unit.point: + roles = self.fresh_roles(state, column) + C.require(role in roles, "slot is matched, not a fresh source") + return offset + unit.ordinal*count + roles.index(role) + break + raise ValueError("slot is matched, not a fresh source") + + def unrank_source(self, index): + C.natural(index, "source index") + C.require(index < self.size, "source index range") + state, path = (0, 1, 0), () + while True: + if index < self.local[state]: + for point, column, units, count in self.blocks(state): + if index < units*count: + ordinal, role = divmod(index, count) + return C.Unit(path, point, ordinal), self.fresh_roles(state, column)[role] + index -= units*count + raise ValueError("local count/index disagreement") + index -= self.local[state] + h, rho, _ = state + C.require(h < self.height, "no child beyond the last class") + for j, (r, _) in enumerate(self.rule.rounds): + child = (h+1, rho*r, r) + if index < self.total[child]: + state, path = child, path + (j,) + break + index -= self.total[child] + else: + raise ValueError("subtree count/index disagreement") + + def row(self, owner): + C.require(type(owner) is tuple and len(owner) == 7, "complete field identifier") + namespace, replica, kind, path, point, ordinal, role = owner + C.require(namespace == self.namespace, "invocation namespace") + C.natural(replica, "replica") + C.require(replica < self.replicas, "replica range") + C.require(kind == "source", "owned bank has no productive source row") + return replica*self.size + self.rank_source(C.Unit(path, point, ordinal), role) + + def owner(self, row): + C.natural(row, "physical row index") + C.require(row < self.replicas*self.size, "physical row index range") + replica, index = divmod(row, self.size) + unit, role = self.unrank_source(index) + return (self.namespace, replica, "source", unit.path, unit.point, unit.ordinal, role) diff --git a/research/source-complement-port-index/reference/FINITE-PRECOMPILATION.md b/research/source-complement-port-index/reference/FINITE-PRECOMPILATION.md new file mode 100644 index 0000000000..4badb40f09 --- /dev/null +++ b/research/source-complement-port-index/reference/FINITE-PRECOMPILATION.md @@ -0,0 +1,313 @@ +# Finite precompilation of a mixed-target rule + +Status: constructive bridge under the precise native hypotheses below, +independently audited in `../transfer-audit/AUDIT.md`. This is a written +argument, not a formal proof or a completed integer-multiplication admission. +The companion finite scheduler checks actual integer flow and ordering. +The original immediate-normalization BIT interface failed hypothesis 3. +`../bit/DELAYED-COVER-BRIDGE.md` supplies the distinct delayed-cover +implementation, with a finite local-ring check and the native binding in +`../bit/BIT-P3-NATIVE-BINDING.json`. Its fixed rational cover routes are a +costed program schema, not dense coordinate gates in a plain native word. + +Substantial OpenAI assistance. Apache-2.0. The mixed-target asymptotic flow is +Jacob Alan Sussman's Theorem 1G, PR4268, with the detailed proof at commit +`563b4e6e913625637f36ba7869bf5fcd0dd4975a` of +[`wht-power-saving-lean`](https://github.com/jacobalansussman/wht-power-saving-lean). +The source, exact scheduling code and notices are preserved under `sources/`. +The contribution proposed here is clearing the finite flow into a single +uniform native supplier before applying the inherited outer theorem. + +## 1. What needs to be assumed + +Let a job of rank `s` apply a specified tensor operator to `s` selected +coordinate blocks of one array, fixing all other coordinates. A block has +an arbitrary positive tensor multiplicity `f`. A completed rank `s` job +therefore acts on `s*f` axes. All productive inputs are arbitrary. + +Fix one mixed unit with productive targets `W_k` of ranks `k`, a chronological +list of paid child ranks `r_j`, and a finite number of scalar and routing +passes. These assumptions are required, separately from the moment inequality: + +1. **An all-column native word.** At every integer column count `c`, the unit + computes exactly its independent rank `k*c` output jobs. Its paid rounds + are rank `r_j*c` jobs in the stated order. All borrowed data return to the + declared endpoint, and owned storage is explicitly initialized and erased. + Its finite operation count is uniform in `c`. +2. **Disjoint splitting and spectators.** A rank `a+b` job is a rank `a` job + followed by a rank `b` job on disjoint coordinates. The resulting programs + preserve arbitrary complete spectator fields and accept arbitrary data. +3. **Whole-job adapters.** Any job passed between two units has an explicitly + priced, permitted embedding into its destination. For the intended complex + application these are fixed monomial binary address maps and unit quadratic + phases, together with role permutations. The adapters must work at every + tensor multiplicity. Rank equality by itself is insufficient. +4. **Finite-program closure.** A finite composition of these words and + adapters is again a permitted finite supplier. Constantly many owned fields + may be supplied with their full cost and no productive output credit. + The eventual ordinary recursion must have the same arbitrary-input, + restoration, scalar and precision interface as the retained supplier. + +Put `m=max{k:W_k>0}`, `k_min=min{k:W_k>0}`, and +`r_max=max{r_j}`. Require `r_max g*S`, keeps one +external weight throughout the entire finite circuit, and lowers only its +final rank-one leaves. All rational matchers, role routes and their inverses +are fixed before choosing the odd prime and its exclusions. Every route +uses complete equal-multiplicity cover fibers and the retained, costed row +permutation primitive. This gives the same finite DAG argument in the +rational-cover program category. The BIT binding supplies the actual native +projectors; a rank count alone would not provide this implementation. + +## 2. Proposed conclusion + +Suppose the preceding hypotheses hold and the mixed balance has root +`tau` in `(0,1)`: + +``` +sum_j r_j^tau = sum_k W_k k^tau. +``` + +For every `z` with `tau=2`, a fixed number `B_N` of productive arrays, +and only rank-one paid children, whose number `P_N` satisfies + +``` +P_N < B_N * N^z. +``` + +Every productive output is the full rank-`N` job. The construction may have +an enormous finite scalar word, role inventory and owned-storage requirement. +Those quantities affect constants and the eventual input threshold. They are +not omitted and are not credited as extra output jobs. + +If this uniform supplier is admitted under the retained native, precision and +fixed-tape premises, the existing uniform recursion applies directly. A new +dynamic RAM-to-Turing-machine simulation is not being assumed here. + +## 3. The integer lockstep flow at a fixed rank + +This is the part of Theorem 1G used by the compiler. At one fixed top rank +`N`, its units, source jobs and exit jobs have integer multiplicities. +For a multi-index `a` on the target types define + +``` +c(a) = product_k k^(a_k), +u(a) = multinomial(|a|;a) * product_k W_k^(a_k). +``` + +The exact Pascal identity is + +``` +u(b) = sum_{k:b_k>0} W_k*u(b-e_k). +``` + +Let `G` be the largest `|a|` with `m*c(a)<=N`. A class is indexed by a +sequence of paid rounds `s` of length `d<=G`; its dilation is +`rho_s=product r_j`. It contains `u(a)` units at column `rho_s*c(a)` for +each `a` with `|a|=G-d` and `m*rho_s*c(a)<=N`. + +For one parent paid round, the Pascal bijection matches its job copies to +target roles of the child class, at exactly equal integer ranks. Missing +demands are top sources. Separation ensures every parent job is consumed. +The source ranks lie in `(N/m,N]`; only the deepest classes produce exit +jobs, all strictly smaller than `N` once `N` is outside the finite base range. + +Process a class in word order. At round `j`, suspend every unit of that +class, complete the entire child class fed by that round, and only then +advance the parents to round `j+1`. This forbids a unit from requiring both +an earlier and a later round of the same suspended parent. The resulting +dependency graph is finite and acyclic. Its edges carry complete array jobs, +not individual scalar values copied for free. + +These integer quantities exist before normalizing the sources to total +weight one. Let `S_s` be the number of source jobs of rank `s`, let +`S=sum_s S_s`, and let the ordered exit batches be `(e,t)` with `t` jobs +of rank `e` each. This finite integer flow is the compiler input. + +## 4. Clear every batch denominator constructively + +Induct on the integer top rank `N`. For each smaller rank `e` the compiler +has already constructed a uniform program on `B_e` arbitrary arrays, +computing full rank `e` with `P_e` paid rank-one calls. For a sufficiently +small rank use the ordinary sequential program: `B_e=1`, `P_e=e`. + +For the current flow choose an integer `a` divisible by every `B_e` needed +for an exit and every `B_(N-s)` needed for a nonzero source remainder. +The product of those finitely many positive integers is a valid choice; +their least common multiple is a smaller optional choice. Set + +``` +B_N = a*S. +``` + +Assign `a*S_s` of the input arrays to each source rank `s`. On each of those +arrays, first complete its `N-s` complementary coordinates using the +already-compiled smaller uniform program. All such batches are integral +because `a` is divisible by their program widths. This preliminary action +commutes with the intended `s`-coordinate job and fixes its input coordinates. + +Make `a` copies of the integer lockstep flow. Route its source arrays to +their exact input slots using permitted whole-array adapters. At a deepest +exit batch, `a*t` is divisible by `B_e`; replace that batch by copies of +the smaller uniform rank-`e` program. Restore its role ordering and adapters +before resuming the suspended parent class. Execute the finite DAG in the +lockstep order, and finally restore the original source-array ordering. + +Every array has now received its disjoint complementary job and source job, +hence the full rank-`N` transform. No copied scalar input or blank helper is +treated as another independent output. Every original array occurs exactly +once as a source; interior target slots are jobs on those arrays, not new +productive inputs. + +Induction removes all recursive calls: the only remaining paid children +have rank one. Clearing denominators multiplies productive arrays and paid +operations equally, so it preserves the per-array leaf count. In formulas, + +``` +P_N/B_N = (1/S) * [ + sum_s S_s * (P_(N-s)/B_(N-s)) + + sum_(ordered exit batches e,t) t * (P_e/B_e) +]. +``` + +Zero-rank terms vanish. Any plain rank-one exits are the ordinary base +program. Scalar and routing passes have their own analogous nonnegative +count and must be included in the asymptotic cost used to choose `N`. + +This construction uses full integer batches; it does not assume that +fractional pieces of a physical array can be routed at zero cost. Its exact +replication factors can be impractically large, which is acceptable for a +fixed finite supplier existence statement but must be disclosed. + +## 5. Why some fixed N has the required saving + +The independent audit sharpened this step to a direct count of paid leaves. +It does not require a running-time comparison between a RAM flow and native +tapes. Let `L(n)=P_n/B_n`, let `w_s=S_s/S`, and let `x_e` be the exit counts +normalized by the number S of source arrays. The actual integer compiler +satisfies + +``` +L(n) = sum_s w_s L(n-s) + sum_e x_e L(e), +sum_s w_s = 1, +sum_e x_e e^tau = sum_s w_s s^tau. +``` + +The last equality follows by canceling every internal matched job in the +exact tau-potential balance. The source ranks satisfy `n/m0`, concavity gives + +``` +n^z0 - sum_s w_s (n-s)^z0 >= eta * sum_s w_s s^z0. +``` + +Indeed, for `t=s/n` in `[1/m,1]`, +`1-(1-t)^z0 >= z0*t >= eta*t^z0`. For every sufficiently large n the +exit coefficient is less than `eta/2`. Every complement and exit has +smaller rank than n, so strong induction on the exact recurrence proves +`L(n)<=A*n^z0`, with finite A chosen to cover the smaller ranks. Eventually +`L(N) 0`. Put `B_0 = 1` and give a +zero-rank complement zero cost. + +The allowed batching policy is: + +1. Before the flow, group **all source complements** by rank `n-s`. These + act on distinct original arrays before any enters the chronological flow. + Each group has `a S_s` arrays after common replication by `a`. +2. At **one parent-round cut in one path class**, group equal-rank unmatched + exits across that class's units. Complete every group before returning + from that cut. A cut with `q` exits of rank `e` has `a q` arrays. + Separate paths or paid positions are separate cuts, even when their + ranks and multipliers agree. +3. Match and resume native calls exactly as in #4436. Replicated copies of + a given class run in lockstep. No unfinished job is pooled with a later + cut; no extra productive input is credited. + +Record batches `(e,q)`: complements have `(n-s,S_s)` and exits have their +**per-cut** counts. For this finite list define + +```text +a_n = lcm over batches (e,q) of B_e / gcd(B_e,q), +B_n = S * a_n. +``` + +**Lemma.** These widths are valid under the inherited source contracts, and +`a_n` is the least positive replication factor for this policy and the +prescribed smaller widths. + +**Proof.** A whole rank-`e` supplier invocation handles `B_e` arrays. +Partitioning `a q` arrays into whole invocations is possible exactly when +`B_e | a q`. With `g = gcd(B_e,q)`, coprimality of `B_e/g` and `q/g` +makes this equivalent to `(B_e/g) | a`. All conditions hold exactly when +their LCM divides `a`, proving necessity, sufficiency and minimality. +Every recursive rank is below `n`: the source proves `0 < s <= n` and +`0 < e < n`. Strong induction therefore supplies every invoked program. +Complements run first; every exit finishes before its parent resumes. +The same disjoint inputs, owners, adapters and completed endpoints as +the source give a full rank-`n` transform on `a_n S` productive arrays. +No fractional invocation is used. QED. + +Minimality is **local to this policy and the chosen smaller library**. +It does not optimize earlier libraries jointly, permit fractional suppliers, +vary replication independently between classes, or optimize every schedule +and physical implementation. New widths need not be nested or monotone. + +## 3. Counting the chronological cuts + +`batches.py` is a new multiplicative-polynomial implementation. Let `F_h(c)` +count ordered target words of length `h` with product `c`, with `W_k` +distinguishable copies of target rank `k`. Then + +```text +F_0(1) = 1, +F_h(c) = sum_k W_k F_(h-1)(c/k), +``` + +where noninteger quotients contribute zero. This equals the sum of the +source's multinomial counts over exponent vectors with the same product. +Product collisions are summed. Only products at most `floor(n/m)` need +storage, since all target factors are at least 2. + +At depth `d` and path multiplier `rho`, a present parent supplies +`F_(G-d)(c)` units when `m rho c <= n`. At a rank-`r` paid position the +child demands the subset of Pascal terms with `m rho r c/k <= n`. For +a present parent, demand is at most supply. A positive difference is the +per-cut batch at rank `rho r c`; an absent parent is supplied by new sources. +At depth `G`, each present class contains one unit, so each paid position +has a **single** exit before replication. + +Equal-`rho` paths may be compressed for counting. The stored `copies` field +counts occurrences, including repeated paid positions. It multiplies the +total exit and cost census but **never the per-cut batch size** in the LCM. +The checker independently enumerates literal ordered target words and paid +positions in 101 fixtures, comparing complete source/exit counts and the +multiset of cuts. Target ranks 2, 4 and 8 exercise product collisions. + +## 4. Cost preservation and inherited width bound + +Write `P_e` for the complete rank-one leaf count of a width-`B_e` supplier. +Complement groups contribute `sum_s (a S_s/B_(n-s)) P_(n-s)` leaves; +exit groups contribute `sum_cuts (a q/B_e) P_e`, with all occurrences +retained. Dividing by `B_n = a S` gives the predecessor's exact recurrence: + +```text +L(n) = [sum_s S_s L(n-s) + sum_e E_e L(e)] / S. +``` + +The factor `a` cancels. With the same base `B_e=1, P_e=e` for `e0, U_N the number of unit instances in the unreplicated finite flow, and `(label,e,t)` the ordered exit batches. Labels include paid **positions**, so repeated equal paid ranks remain separate rounds. Every nonzero complement q=N-s and every exit e is strictly between 0 and N. The base programs at 1<=n0}, m=max{k:W_k>0}, W=sum_k W_k and J=number of ordered paid positions. Assume m>=k_min>=2 and 1<=r_j=m, let G=floor(log_{k_min}(N/m)), computed by integer multiplication if evaluated. For a paid-position path p of length d, rho_p is the product of its paid ranks. For each multi-index a with |a|=G-d and m*rho_p*c(a)<=N, put + +``` +c(a) = product_k k^a_k, +u(a) = (|a|! / product_k a_k!) product_k W_k^a_k. +``` + +There are u(a) units in that class. A target role of rank k*rho_p*c(a) is a source exactly when p is empty or + +``` +m * (rho_p/r_last) * c(a) * k > N. +``` + +Otherwise the corresponding parent multi-index a+e_k is present and the Pascal bijection consumes all W_k*u(a) such roles. This is the precise missing-demand condition used by the verifier. Its independent literal construction represents each unit by a word of target **roles**, matches each eligible parent word to `(first role, suffix)` in the next class, and rejects any unconsumed parent demand. Distinct roles retain W_k multiplicity. + +At depth G there is just a=0, u(a)=1. Every one of the J^G deepest classes is present because m*r_max^G<=m*k_min^G<=N. Thus each of its J paid rounds is a separate exit batch with t=1. In particular all J^(G+1) labels are retained even if their product ranks agree. In this exact unsplit Section-3 flow, the exit factors in a_N are therefore B_e themselves; the gcd improvement can only arise from source-complement multiplicities. The more general batchwise statement above also applies if a valid upstream flow supplies larger individual exit batches, but does not authorize merging them. + +The code implements this source formula and compares it with the independently enumerated role-word construction for N=4,...,25. These fixtures support the implementation; the all-N statements depend on the source hypotheses and the argument above, not extrapolation from the fixture range. + +## 3. Bit bounds without materializing the word + +Let b_n=ceil(log2 B_n), o_n=ceil(log2(O_n+1)), both zero in the base range. The number of bits in B_n or O_n+1 is at most the corresponding bound plus one. Because a_N divides the uniform lcm and that lcm divides the product over **distinct child ranks**, + +``` +b_N <= ceil(log2 S_N) + sum_{q in D_N} b_q. +``` + +Let H_N=sum_{(q,t) in R_N} t. Since B_q>=1 and a_N>=1, the O recurrence gives + +``` +O_N+1 <= a_N (U_N+H_N+1) max_{q in D_N}(O_q+1), +o_N <= sum_{q in D_N} b_q + + ceil(log2(U_N+H_N+1)) + max_{q in D_N} o_q. +``` + +Take the maximum over an empty child set to be zero in the logarithmic formula. These provide direct recursive upper bounds using only the finite flow and smaller bounds, even when exact B_N or O_N are too large to emit. + +For a closed bound at an arbitrary finite N, put K=max(W,J) and + +``` +G_N = floor(log_{k_min}(N/m)), +C_N = ceil(log2 W) + ceil(log2(G_N+1)) + G_N ceil(log2 K), +D_N^* = 1 + ceil(log2(2+W+J)) + ceil(log2(G_N+1)) + + G_N ceil(log2 K). +``` + +Here D_N^* is a scalar bound, distinct from the child-rank set D_N. At depth d, deleting eligibility constraints bounds the total units by J^d W^(G_N-d), so U_N<=(G_N+1)K^G_N. There are at most W targets per unit and exactly J^(G_N+1) exits. Therefore S_N<=W U_N, H_N<=S_N+J^(G_N+1), and + +``` +ceil(log2 S_N) <= C_N, +ceil(log2(U_N+H_N+1)) <= D_N^*. +``` + +Both constants are nondecreasing in N. Since every child rank q25 before flow construction. It is not a general untrusted-input compiler; the recorded targets and paid list are small pinned constants. No giant N, compiled word, physical array or native product is materialized. diff --git a/research/source-complement-port-index/verify.py b/research/source-complement-port-index/verify.py new file mode 100644 index 0000000000..8234a02b52 --- /dev/null +++ b/research/source-complement-port-index/verify.py @@ -0,0 +1,261 @@ +#!/usr/bin/env python3 +"""Literal source-field oracle and independent whole-flow rank cancellation.""" +from collections import Counter +from hashlib import sha1, sha256 +from importlib.util import module_from_spec, spec_from_file_location +from math import comb, gcd, lcm +from pathlib import Path +from types import ModuleType +import json +import sys + +HERE=Path(__file__).resolve().parent + + +def need(ok,message): + if not ok: raise ValueError(message) + + +def load(name,path): + spec=spec_from_file_location(name,path) + module=module_from_spec(spec) + sys.modules[name]=module + spec.loader.exec_module(module) + return module + + +G=load('source_grouping',HERE/'groups.py') +C=G.C +oracle_path=HERE/'inputs/finite_dag_audit.py' +need(sha256(oracle_path.read_bytes()).hexdigest()== + 'f842f0e07ca40a181782a565a381b0ee20c6a4b08b8c2b8a4d5d630381bd1e8e', + 'unchanged literal source oracle') +O=load('grouping_literal',oracle_path) + + +class AmbientRule(O.Rule): + @property + def dimension(self): return self._ambient + + +def literal(rule,rank): + old=AmbientRule(rule.roles,rule.rounds,rule.owned) + object.__setattr__(old,'_ambient',rule.ambient) + tree=O.IntegerTree(old,rank) + occurrences=Counter() + units={} + for record in tree.units: + key=record['path'],record['point'] + units[record['uid']]=C.Unit(*key,occurrences[key]) + occurrences[key]+=1 + order={role:i for i,(role,_) in enumerate(rule.roles)} + sources=[(units[row['unit']],row['role'],row['rank']) for row in tree.sources] + sources.sort(key=lambda row:(row[0].path,row[0].point,row[0].ordinal,order[row[1]])) + return sources,tree + + +def check(rule,rank): + expected,tree=literal(rule,rank) + by_rank={s:[(unit,role) for unit,role,rank_s in expected if rank_s==s] + for s in sorted({s for _,_,s in expected})} + library=tuple(sorted((rank-s,2+(rank-s)%2) for s in by_rank if s1 for points in collision.values())) + + +def independent_histogram(rule,rank,height): + """Target census minus all actual incoming paid jobs, not freshness tests.""" + words=[Counter({1:1})] + paths=[Counter({1:1})] + for _ in range(height): + next_words,next_paths=Counter(),Counter() + for product,count in words[-1].items(): + for _,k in rule.roles: next_words[product*k]+=count + for rho,count in paths[-1].items(): + for r,_ in rule.rounds: next_paths[rho*r]+=count + words.append(next_words) + paths.append(next_paths) + sources=Counter() + for h in range(height+1): + for rho,copies in paths[h].items(): + for column,units in words[height-h].items(): + if rule.ambient*rho*column<=rank: + for _,k in rule.roles: sources[rho*column*k]+=copies*units + if h: + for rho,copies in paths[h-1].items(): + for column,units in words[height-h+1].items(): + if rule.ambient*rho*column<=rank: + for r,_ in rule.rounds: sources[rho*column*r]-=copies*units + need(all(count>=0 for count in sources.values()),'rank-wise incoming subtraction nonnegative') + return {s:count for s,count in sorted(sources.items()) if count} + + +def reject(action,label): + try: action() + except (ValueError,AssertionError,IndexError): return label + raise ValueError('negative control accepted: '+label) + + +def mutated(old,new,name): + text=(HERE/'groups.py').read_text() + need(text.count(old)==1,'unique group mutation site') + module=ModuleType(name) + module.__file__=str(HERE/'groups.py') + sys.modules[name]=module + exec(compile(text.replace(old,new),name,'exec'),module.__dict__) + return module + + +def controls(): + rule=C.Rule((('small',2),('large',5)),((1,'small'),(1,'bank'))) + groups=G.SourceGroups(rule,10,replicas=3) + router=G.ComplementRouter(groups,((5,3),(6,1))) + need(groups.count(5)==2,'cross-replica source bucket') + first=[router.row(G.ComplementPort('flow',5,0,slot)) for slot in range(3)] + second=[router.row(G.ComplementPort('flow',5,1,slot)) for slot in range(3)] + need(first==[2,3,6] and second==[7,10,11],'actual whole batches cross replica boundary') + need([router.row(G.NoComplement('flow',10,j)) for j in range(3)]==[1,5,9], + 'full-rank sources skip complement entirely') + out=[reject(lambda: G.ComplementRouter(groups,((0,1),(5,3),(6,1))), 'fabricated B_0'), + reject(lambda: G.ComplementRouter(groups,((5,4),(6,1))), 'nonintegral complement batch'), + reject(lambda: G.ComplementRouter(groups,((5,3),)), 'missing positive complement library'), + reject(lambda: router.row(G.ComplementPort('flow',10,0,0)), 'zero-rank invocation'), + reject(lambda: router.invocations(10), 'zero-rank invocation census'), + reject(lambda: router.row(G.NoComplement('flow',5,0)), 'skipped positive complement'), + reject(lambda: router.row(G.ComplementPort('flow',5,2,0)), 'invocation upper endpoint'), + reject(lambda: router.row(G.ComplementPort('flow',5,0,3)), 'slot upper endpoint'), + reject(lambda: router.row(G.NoComplement('flow',10,3)), 'no-complement upper endpoint'), + reject(lambda: router.row(G.ComplementPort('other',5,0,0)), 'foreign invocation namespace'), + reject(lambda: groups.count(11), 'absent true source rank'), + reject(lambda: router.locate(3*groups.index.size), 'replicated row upper endpoint')] + unit,role=groups.unrank_source(5,0) + out.append(reject(lambda: groups.rank_source(4,unit,role),'wrong source-rank label')) + other=G.SourceGroups(C.Rule((('a',3),('b',5)),((1,'a'),(2,'bank'))),45) + out.append(reject(lambda: other.rank_source(10,C.Unit((0,1),(0,0),0),'b'), + 'matched slot with same rank as a real source')) + need(other.rank_source(10,C.Unit((1,0),(0,0),0),'b')>=0,'last paid rank retains freshness') + bad=mutated('self.groups.rule.ambient*self.rank > self.groups.rank*previous', + 'self.groups.rule.ambient*self.rank >= self.groups.rank*previous','bad_fresh_equality') + out.append(reject(lambda: bad.SourceGroups(C.Rule((('a',3),('b',5)),((1,'a'),(2,'bank'))),45), + 'non-strict parent cutoff mutation')) + bad=mutated('values[-1] += value','values[-1] = value','bad_product_collision') + out.append(reject(lambda: bad.SourceGroups(C.Rule((('a',3),('b',5)),((1,'a'),)),75), + 'overwritten product collision')) + bad=mutated('total += multiplicity*self.total[h+1, rho*rank, rank]', + 'total += self.total[h+1, rho*rank, rank]','bad_paid_multiplicity') + out.append(reject(lambda: bad.SourceGroups(rule,10), 'merged equal-rank paid occurrences')) + bad=mutated('grouped = replica*self.groups.count(source_rank)+local', + 'grouped = local','bad_replica_merge') + badgroups=bad.SourceGroups(rule,10,replicas=3) + badrouter=bad.ComplementRouter(badgroups,((5,3),(6,1))) + out.append(reject(lambda: need(badrouter.row(badrouter.locate(6))==6,'replica identity'), + 'merged replicated source arrays')) + only=G.SourceGroups(C.Rule((('one',3),),((1,'one'),)),3,replicas=5) + idle=G.ComplementRouter(only,()) + need(all(idle.row(idle.locate(i))==i for i in range(5)), 'empty positive complement library') + collision=G.SourceGroups(C.Rule((('a',2),('extra',2),('b',4),('c',8)),((1,'a'),)),128) + need(collision.products[2].get(16)==5, + 'two rank-2 role names with rank 8 plus the rank-4 square') + return out,{'source_rank':5,'first_invocation_rows':first,'second_invocation_rows':second, + 'no_complement_rows':[1,5,9]} + + +def main(): + pins=json.loads((HERE/'SOURCES.json').read_text())['inputs'] + need(tuple(pin['local_path'] for pin in pins)==( + 'inputs/source_index/source_index.py','inputs/source_index/inputs/pascal_codec.py', + 'inputs/finite_dag_audit.py','reference/FINITE-PRECOMPILATION.md', + 'reference/symbolic-batch-PROOF.md','reference/chronological-batch-README.md'), + 'complete frozen input inventory') + for pin in pins: + raw=(HERE/pin['local_path']).read_bytes() + need(len(raw)==pin['bytes'] and sha256(raw).hexdigest()==pin['sha256'] and + sha1(b'blob '+str(len(raw)).encode()+b'\0'+raw).hexdigest()==pin['git_blob'], + 'frozen input bytes') + cases=[ + (C.Rule((('a',2),('b',4),('c',8),('extra',2)),((1,'a'),(1,'bank'))), + (8,15,16,31,32,63,64,128)), + (C.Rule((('large',5),('small',3),('extra',3)),((1,'small'),(1,'bank'),(2,'large')),ambient=7), + (7,20,21,62,63,188,189)), + (C.Rule((('a',4),('b',7)),((1,'a'),(2,'bank'),(3,'b'),(1,'a')),ambient=8), + (8,31,32,127,128)), + (C.Rule((('single',3),),((1,'single'),)),(3,8,9,10,26,27)), + ] + total=Counter() + for rule,ranks in cases: + for rank in ranks: total.update(check(rule,rank)) + need(total['product_collision_classes']>0,'literal fitting product coincidences exercised') + large_rule=C.Rule((('a',3),('b',3),('c',5),('d',5)), + ((1,'a'),(1,'bank'),(2,'c')),ambient=7) + large=G.SourceGroups(large_rule,7*3**24,replicas=6) + independent=independent_histogram(large_rule,large.rank,large.index.height) + need(independent==dict(zip(large.ranks,large.counts)),'independent all-rank cancellation census') + library=tuple(sorted((large.rank-s,2+(large.rank-s)%2) + for s in large.ranks if s