From 81f0b0b9a920bd1c9da583cbc3612efd5e75ea94 Mon Sep 17 00:00:00 2001 From: Jerry Jiaheng Chen <80299683+CubeJerry@users.noreply.github.com> Date: Thu, 12 Nov 2026 10:23:32 +0800 Subject: [PATCH] Locate every chronological compiler leaf and preserve persistent owner identities --- .../chronological-leaf-owner-index/NOTICE.md | 24 ++ .../OVERLAP.json | 125 +++++++ .../PR-TITLE.txt | 1 + research/chronological-leaf-owner-index/PR.md | 80 +++++ .../chronological-leaf-owner-index/PROOF.md | 275 +++++++++++++++ .../chronological-leaf-owner-index/README.md | 123 +++++++ .../SOURCES.json | 61 ++++ .../chronological-leaf-owner-index/TASK.json | 15 + .../VALIDATION.json | 215 ++++++++++++ .../independent/RESULT.json | 44 +++ .../independent/REVIEW.md | 170 +++++++++ .../independent/SOURCE-BINDINGS.json | 61 ++++ .../independent/direct_recursion.py | 203 +++++++++++ .../inputs/groups.py | 286 ++++++++++++++++ .../source_index/inputs/pascal_codec.py | 222 ++++++++++++ .../inputs/source_index/source_index.py | 205 +++++++++++ .../inputs/library.py | 305 +++++++++++++++++ .../leaf_index.py | 255 ++++++++++++++ .../literal_oracle.py | 172 ++++++++++ .../reference/FINITE-PRECOMPILATION.md | 313 +++++++++++++++++ .../reference/library-PROOF.md | 297 ++++++++++++++++ .../reference/source-port-PROOF.md | 324 ++++++++++++++++++ .../reference/symbolic-batch-PROOF.md | 98 ++++++ .../chronological-leaf-owner-index/verify.py | 248 ++++++++++++++ 24 files changed, 4122 insertions(+) create mode 100644 research/chronological-leaf-owner-index/NOTICE.md create mode 100644 research/chronological-leaf-owner-index/OVERLAP.json create mode 100644 research/chronological-leaf-owner-index/PR-TITLE.txt create mode 100644 research/chronological-leaf-owner-index/PR.md create mode 100644 research/chronological-leaf-owner-index/PROOF.md create mode 100644 research/chronological-leaf-owner-index/README.md create mode 100644 research/chronological-leaf-owner-index/SOURCES.json create mode 100644 research/chronological-leaf-owner-index/TASK.json create mode 100644 research/chronological-leaf-owner-index/VALIDATION.json create mode 100644 research/chronological-leaf-owner-index/independent/RESULT.json create mode 100644 research/chronological-leaf-owner-index/independent/REVIEW.md create mode 100644 research/chronological-leaf-owner-index/independent/SOURCE-BINDINGS.json create mode 100644 research/chronological-leaf-owner-index/independent/direct_recursion.py create mode 100644 research/chronological-leaf-owner-index/inputs/groups.py create mode 100644 research/chronological-leaf-owner-index/inputs/inputs/source_index/inputs/pascal_codec.py create mode 100644 research/chronological-leaf-owner-index/inputs/inputs/source_index/source_index.py create mode 100644 research/chronological-leaf-owner-index/inputs/library.py create mode 100644 research/chronological-leaf-owner-index/leaf_index.py create mode 100644 research/chronological-leaf-owner-index/literal_oracle.py create mode 100644 research/chronological-leaf-owner-index/reference/FINITE-PRECOMPILATION.md create mode 100644 research/chronological-leaf-owner-index/reference/library-PROOF.md create mode 100644 research/chronological-leaf-owner-index/reference/source-port-PROOF.md create mode 100644 research/chronological-leaf-owner-index/reference/symbolic-batch-PROOF.md create mode 100644 research/chronological-leaf-owner-index/verify.py diff --git a/research/chronological-leaf-owner-index/NOTICE.md b/research/chronological-leaf-owner-index/NOTICE.md new file mode 100644 index 0000000000..8c2eed103a --- /dev/null +++ b/research/chronological-leaf-owner-index/NOTICE.md @@ -0,0 +1,24 @@ +# Attribution and license + +Prepared for Jerry Chen / @CubeJerry with substantial OpenAI assistance. +New material is Apache-2.0. Retained source files are unchanged and retain +their original notices. + +Jacob Alan Sussman supplies the mixed integer/Pascal flow; zxv supplies its +finite chronological native compiler and source contracts. Mihir Srivastava's +CrocSwap/integer-mult-bounds#4507 supplies least chronological batching; +JoyboyBrian's CrocSwap/integer-mult-bounds#5071 supplies its exact separated +recurrences and description-size boundary. The earlier widths and native +lineage credited by CrocSwap/integer-mult-bounds#7345 remain credited. + +Jerry Chen / CubeJerry's CrocSwap/integer-mult-bounds#7345, #7346, #7347 and +#7348 supply the exact rank library, occurrence/owner codec, source rows and +source-complement ports reused here. Their separate AI review credit is +preserved; no human or formal-kernel review is implied. The occurrence-layout +and physical/compiler interfaces retain their complete predecessor credit. + +The new weighted exit-suffix index, recursive leaf locator and persistent +field/return composition are distinct from those counts and local codecs. +The separate literal program oracle is new verification code and imports +none of those production algorithms. It is still author-side AI-assisted +evidence until separately reviewed. diff --git a/research/chronological-leaf-owner-index/OVERLAP.json b/research/chronological-leaf-owner-index/OVERLAP.json new file mode 100644 index 0000000000..cb78020c35 --- /dev/null +++ b/research/chronological-leaf-owner-index/OVERLAP.json @@ -0,0 +1,125 @@ +{ + "base": "e54523517d0f03e58352e647c403a5af3e525a57", + "date_utc": "2026-11-12", + "scope": "Expanded separated-compiler paid-leaf projection and persistent source/owned fields", + "coverage": "Bounded exact-source reading and two targeted PR-body searches; not exhaustive repository, diff or discussion coverage.", + "queries": [ + { + "query": "\"lazy\" \"compiler\"", + "results": [ + { + "number": 6498, + "title": "Allow Jensen integrity checks without POSIX resource (no κ)", + "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/6498" + }, + { + "number": 6435, + "title": "Preserve 55 bounded-kernel assertions under optimized Python (no κ)", + "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/6435" + }, + { + "number": 5995, + "title": "Reduce complete H25 certificate qualification time by 28%", + "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/5995" + }, + { + "number": 6029, + "title": "Reduce complete H25 bookkeeping time by 21%", + "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/6029" + }, + { + "number": 4049, + "title": "research: actual native f=1 phase fusion avoids 1024 writes", + "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/4049" + }, + { + "number": 5219, + "title": "research: encoded CRT entry initialization and complete lifecycle", + "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/5219" + }, + { + "number": 4792, + "title": "Add a 72-work literature map with exact native encoder and compiler tests", + "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/4792" + }, + { + "number": 4002, + "title": "Derive explicit native-lift phase tags and signed-word certificates", + "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/4002" + }, + { + "number": 3825, + "title": "Bit-free complex supplier for the selected word: exact pricing, every variant negative", + "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/3825" + }, + { + "number": 3650, + "title": "Add a source-shaped Lean bridge for compiler retention", + "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/3650" + } + ] + }, + { + "query": "\"leaf\" \"owner\" \"index\"", + "results": [ + { + "number": 6732, + "title": "Record finite GNU-time source contract and readable retention inputs", + "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/6732" + }, + { + "number": 3967, + "title": "Refresh R437/OQ4 adapter and bind actual rank26/COPY515 physical returns", + "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/3967" + }, + { + "number": 5516, + "title": "Research: streamed R437 leaf/XOR ownership under the canonical caller's installed pool", + "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/5516" + }, + { + "number": 673, + "title": "Research: dirty echo, verifier repair, and priced bit-sharing boundaries", + "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/673" + }, + { + "number": 2389, + "title": "Research: adaptive QQ16 reads still need 66 ports; 45 optimal sets", + "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/2389" + }, + { + "number": 2140, + "title": "Certify one selected BIT q-adic route and its carry failure mode", + "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/2140" + } + ] + } + ], + "closest_predecessors": [ + { + "pr": 7345, + "result": "Evaluated rank-library metadata; no emitted native instruction stream." + }, + { + "pr": 7346, + "result": "Direct Pascal occurrence and single-level owner codec." + }, + { + "pr": 7347, + "result": "Contiguous source-row rank/unrank." + }, + { + "pr": 7348, + "result": "True-rank source-complement port map; exit emission remains open." + }, + { + "pr": 4507, + "result": "Least chronological batch divisibility; no new divisor theorem here." + }, + { + "pr": 5071, + "result": "Exact separated recurrence and one-array exit cuts already proved." + } + ], + "rejected_scope": "An exit-only replica divmod wrapper was rejected as insufficient novelty." +} diff --git a/research/chronological-leaf-owner-index/PR-TITLE.txt b/research/chronological-leaf-owner-index/PR-TITLE.txt new file mode 100644 index 0000000000..738e73fc4d --- /dev/null +++ b/research/chronological-leaf-owner-index/PR-TITLE.txt @@ -0,0 +1 @@ +Locate every expanded compiler leaf and preserve its source or owned-bank identity through recursive return diff --git a/research/chronological-leaf-owner-index/PR.md b/research/chronological-leaf-owner-index/PR.md new file mode 100644 index 0000000000..1c46830eb3 --- /dev/null +++ b/research/chronological-leaf-owner-index/PR.md @@ -0,0 +1,80 @@ +## What changes and why + +The exact source/occurrence codecs and evaluated smaller-rank library do not +by themselves identify an instruction in the fully expanded compiler. Different +chronological cuts can revisit the same physical field, while nested smaller +programs introduce further source-row translations and their own owned banks. + +This package constructs the complete **ordered rank-one paid-leaf projection**: +given any leaf ordinal, recover its exact nested whole-call path, canonical +base axis and original source-row or owned-bank identity. The inverse recovers +the ordinal. Every nested whole-call input vector maps injectively to its +persistent caller fields, with the same inverse correspondence on return. +Global leaf-to-owner injection is explicitly false and is tested as a control. + +## Exact result and novelty + +A new weighted paid-path suffix table stores only (depth, rank-product) +counts, with the actual smaller-program widths and leaf counts at its bottom. +It selects the precise chronological cut without enumerating preceding paths +or replicas. Upward source/complement/exit translations compose through +strict rank descent and preserve the full owned-bank invocation namespace. + +Credit CrocSwap/integer-mult-bounds#7345 for evaluated library metadata; +CrocSwap/integer-mult-bounds#7346, CrocSwap/integer-mult-bounds#7347 and +CrocSwap/integer-mult-bounds#7348 for the occurrence, source and complement +port codecs. CrocSwap/integer-mult-bounds#4507 and +CrocSwap/integer-mult-bounds#5071 already prove batching and singleton exit +cuts. An exit-only replica-divmod wrapper was rejected as insufficient novelty. +The new result is their recursive chronological leaf/field composition. + +Canonical base: `e54523517d0f03e58352e647c403a5af3e525a57`. +All eight retained files have exact commit, Git blob and SHA256 pins in +`SOURCES.json`. The package replays without Git or network dependencies. + +## Verification and reproduction + +```sh +python3 -I -W error -B research/chronological-leaf-owner-index/verify.py +python3 -I -O -W error -B research/chronological-leaf-owner-index/verify.py +``` + +Expected: `PASS_CHRONOLOGICAL_LEAF_OWNER_INDEX`. +The distinct literal oracle imports no production source/owner/suffix codec. +It materializes classes and actual parent/child slot lists, then recursively +expands every smaller program. It checks 4,102 leaves, 2,970 complete calls +and 3,746 input ports over 78 ranks, with 1,183 owned-field leaves and 106 +cross-replica complement batches. Fifteen controls detect merged cuts, +replicas and namespaces, dropped paid multiplicities, wrong returns and +invalid library/port boundaries. + +A separate direct digit/last-owned-site oracle checks selected queries among +68,719,476,736 chronological cuts using 13 suffix states and 12 source states. +Another nonexpanded fixture has 94,591,411,200,000 source rows. These are +formal metadata examples, not native supplier witnesses. The written proof +supplies the universal interval and ownership arguments and explicit indexed +and serialized-tape metadata costs with all supplied integer bit lengths. + +Separate peer proof review and a direct nonminimal-library recursion oracle +check 24,137 further leaves, 24,205 calls and 25,120 ports, with three detected +semantic mutants. See `independent/REVIEW.md` and its reproducible receipt. + +## Limits and kappa status + +**No new kappa.** The selected conditional 0.00363005817 and all five framework +assumptions remain. This emits the paid-leaf projection, not the interleaved +scalar/phase/adapter word or global axis embeddings. The actual selected +native manifest/library, physical gathering/return, owned-storage realization, +numerical endpoints and full fixed-tape dispatcher remain open. + +The general interface permits A above every target rank but accepts a supplied +valid library and charges its actual bits. The default library generator's +stronger width bound is not transferred to that case. Indexed source names +do not grant free payload access. All unchanged native correctness, adapter, +arbitrary-input and completed-return contracts remain inherited. + +Prepared for **@CubeJerry**, with substantial **OpenAI assistance** in research, +proof, implementation and verification. Jacob Alan Sussman, zxv, Mihir +Srivastava, JoyboyBrian and the complete credited compiler/physical lineage +retain attribution. Independent human or formal-kernel acceptance is not +claimed. No selected certificate, frozen predecessor or unrelated file changes. diff --git a/research/chronological-leaf-owner-index/PROOF.md b/research/chronological-leaf-owner-index/PROOF.md new file mode 100644 index 0000000000..d255ba9a27 --- /dev/null +++ b/research/chronological-leaf-owner-index/PROOF.md @@ -0,0 +1,275 @@ +# Locate expanded compiler leaves with their persistent field identities + +Prepared for Jerry Chen / @CubeJerry with substantial OpenAI assistance. +Canonical base: `e54523517d0f03e58352e647c403a5af3e525a57`. +Written logical-emission theorem with finite exact corroboration. No new kappa. + +## 1. Exact domain and emitted object + +Use sections 3--4 of the retained +[FINITE-PRECOMPILATION.md](reference/FINITE-PRECOMPILATION.md) and the exact +occurrence/source/source-complement codecs in CrocSwap/integer-mult-bounds#7346, +CrocSwap/integer-mult-bounds#7347 and CrocSwap/integer-mult-bounds#7348. +`SOURCES.json` pins their unchanged code, commits, Git blobs and SHA256 hashes. +Their logical bijections and metadata-cost proofs are imported; no payload +access is free merely because its source row is known. + +A rule has ordered productive roles of ranks k>=2, J ordered paid positions +of positive ranks r(j)=k_max be the actual +ambient cap. A need not be a target rank. At n>=A put + +`G_n=max{g:A*k_min^g<=n}`. + +Units have the inherited descriptors `(p,alpha,v)`, with +`|p|+|alpha|=G_n`, `vk_max, repeated roles/sites, coincident products, +cross-replica complements, inherited banks and ungrouped native role lists. +It also compares default-library integers with the unchanged #7345 generator. + +A large singleton-rank fixture has 68,719,476,736 cuts. Base-eight digits and +the last owned paid site give a distinct direct oracle for selected queries +without expansion. Another fixture queries a library with huge replication +and row counts. These formal metadata rules are not asserted realizable +native suppliers. Executed coverage is recorded exactly in `VALIDATION.json`. + +Controls detect lost paid multiplicity, merged cuts/replicas, dropped owned +call namespaces, wrong totals/axes/returns, invalid zero complements and +range errors. A same-owner/different-cut fixture refutes the stronger global +leaf-owner injection. Universal force comes from the interval, identity +and rank-induction proofs, not extrapolation from finite checks. + +This closes a recursive logical-emission obligation: counts and source ports +compose into the complete ordered rank-one leaf projection with persistent +field names and inverse locations. The selected actual role manifest/library, +full scalar/phase/adapter stream, physical gather/return, numerical endpoints, +owned-storage realization and complete fixed-tape dispatcher remain open. +All five selected assumptions and kappa remain unchanged. diff --git a/research/chronological-leaf-owner-index/README.md b/research/chronological-leaf-owner-index/README.md new file mode 100644 index 0000000000..d2990eb26e --- /dev/null +++ b/research/chronological-leaf-owner-index/README.md @@ -0,0 +1,123 @@ +# Locate every expanded compiler leaf and its persistent source or owned field + +**Scoped compiler-emission theorem; no new kappa.** This package joins the +published source/occurrence codecs to the evaluated smaller-rank library. +Given any ordinal in the fully expanded compiler's rank-one paid-leaf +projection, it returns the exact chronological smaller-call path, canonical +base axis, and original source-row or owned-bank identity. The inverse +recovers the ordinal. It also resolves every input port of a whole nested +call to its persistent caller field, preserving return order. + +The new weighted suffix table compresses chronological exit counts by +`(depth,paid-rank product)`, with bottom weights from each actual smaller +program. Equal-rank paths still receive distinct chronological intervals. +Upward source/exit port translation composes through rank descent; encountering +an already existing parent's owned bank retains its original namespace. + +This is an emitted **leaf projection**, not the complete scalar/phase/adapter +word. The actual selected native manifest and winning huge library are not +materialized. Whole-job adapters, payload gathering/return, numerical child +correctness, initialization/erasure and fixed-tape payload costs remain +separate obligations. The selected conditional kappa remains 0.00363005817, +and all five foundational assumptions remain. + +## Why chronological identity matters + +With one rank-two productive role x and two paid rank-one sites on x, two +distinct exit leaves visit the **same physical source row**. Their cut keys +are `(0,)` and `(1,)`, and their leaf ordinals differ. A map keyed only by +physical owner or rank loses an instruction. The new inverse retains the +full cut and call path. Nonaliasing is proved for the input ports of **one +whole invocation**, never globally across all leaves. + +## Exact scope and cost + +The written [proof](PROOF.md) covers every separated fixed finite rule and +every supplied valid rank library, including an ambient cap A larger than +all target ranks. The unchanged default library generator from #7345 is used +only in its A=max(target rank) specialization. Its sharper width bound is +not transferred to the larger-A case. + +After paying for the N-row input library, node-local setup and indexed leaf +queries have deterministic polynomial bounds in log N and actual supplied +integer bit lengths, for fixed rank alphabets. Every source bucket rebuild, +large replica quotient, path copy and retained table is charged. A separate +serialized-table simulation charges full scans, cursor returns and erasure; +it grants no free random access or payload move. + +## Reproduction and verification + +Python 3.12 and the standard library, from the repository root: + +```sh +python3 -I -W error -B research/chronological-leaf-owner-index/verify.py +python3 -I -O -W error -B research/chronological-leaf-owner-index/verify.py +``` + +Expected status: `PASS_CHRONOLOGICAL_LEAF_OWNER_INDEX`. Default replay compares +the complete fresh evidence with `VALIDATION.json`; `--write` is an explicit +authoring option. Frozen source bytes are authenticated before use. + +The separate literal oracle imports no production source codec, owner +resolver or suffix DP. It materializes classes, matches actual ordered +parent/child slot lists, then fully expands all smaller calls. The checks +compare **4,102 leaves**, **2,970 whole calls**, and **3,746 child input ports** +over 78 ranks, including 1,183 owned-field leaves and 106 complement batches +crossing replica boundaries. Fifteen failure controls cover lost site +multiplicity, merged cuts/replicas, lost owned namespaces, wrong totals, +return identities and invalid ports. + +A separate direct base-eight/last-owned-site oracle checks queries into +**68,719,476,736 chronological cuts**, represented by 13 suffix-count states +and 12 source-count states. Another queried library has 4,729,570,560,000 +replicas, 94,591,411,200,000 source rows and 5,158,340,373,946,848 leaves. +Those instances are not expanded or asserted to be realizable native +suppliers. The universal result comes from the proof, not these finite sizes. + +## Independent peer review + +A separate agent reviewed the full proof and exact implementation, then used +its own deliberately nonminimal libraries and direct source-vector recursion +at ambient 3 and 5. It checked 24,137 leaves, 24,205 whole calls and 25,120 +ports, and detected three semantic mutants. The script, receipt, reviewed +hashes and proof review are in [independent/](independent/). The root separately +authenticated each source commit/path binding. This is separate AI review, +not human or formal-kernel acceptance. + +TASK.json and SOURCES.json are standalone scope/provenance manifests; this +package does not claim the optional registered replay schema. + +## Novelty, source pins and prior credit + +The compiler, Pascal matching, minimal gcd/LCM replication and source counts +are credited predecessor results. #7345 evaluates rank-library counts; +#7346 resolves one occurrence's owner; #7347 gives contiguous source rows; +#7348 supplies source-complement ports. This package supplies the missing +recursive composition into chronological leaf locations and persistent +physical-field identities. An exit-only `divmod` wrapper was explicitly +rejected as insufficient novelty. + +Base: `e54523517d0f03e58352e647c403a5af3e525a57`. +Exact code dependencies are the #7345--#7348 published heads recorded in +[SOURCES.json](SOURCES.json). No network or Git object is needed for replay. +The broader full-emitter task in the selected occurrence-layout package +remains open beyond this precise projection. + +## Open next questions + +1. Emit the interleaved scalar, phase, owned-lifecycle and whole-job adapter + instructions at these exact call paths. Start with one supplied finite + native word and preserve the same cut/owner return invariant. Native + instruction encoding and adapter construction are additional inputs. +2. Join this port map to a physical whole-field gather/return implementation + and price it, including suspended banks and complete restoration. An + indexed field name alone does not provide that interface. +3. Produce and bind the actual selected finite rule and library at ambient + `153^1920`. The abstract larger-cap interface does not construct those + inputs or transfer the default library's sharper growth estimate. + +Prepared for **Jerry Chen / @CubeJerry** with substantial **OpenAI assistance** +in derivation, code, proofs and checks. Jacob Alan Sussman, zxv, Mihir +Srivastava, JoyboyBrian and the cited compiler/physical lineage retain credit. +Separate AI checks are not independent human or formal-kernel acceptance. +New material is Apache-2.0; all retained headers remain unchanged. diff --git a/research/chronological-leaf-owner-index/SOURCES.json b/research/chronological-leaf-owner-index/SOURCES.json new file mode 100644 index 0000000000..b4db29c817 --- /dev/null +++ b/research/chronological-leaf-owner-index/SOURCES.json @@ -0,0 +1,61 @@ +{ + "base": "e54523517d0f03e58352e647c403a5af3e525a57", + "files": [ + { + "local": "inputs/groups.py", + "git_blob": "bbf54125523bdf8cd6fd7239938a0a42f53a5344", + "url": "https://github.com/CubeJerry/integer-mult-bounds/blob/bd63147b1a193f68b5713e5814ac3b2c743beff8/research/source-complement-port-index/groups.py", + "sha256": "871b166c174958bb467952bebe9a2b776a0582f0c427b7dea9a94a128edad171", + "bytes": 12449 + }, + { + "local": "inputs/inputs/source_index/source_index.py", + "git_blob": "4e3cb2a53fb1c5c90e01202eb4e51a559c8727f7", + "url": "https://github.com/CubeJerry/integer-mult-bounds/blob/c5bcb6dc792f5fe4d8abe89a2a2854f148b09f2c/research/lockstep-source-row-index/source_index.py", + "sha256": "e978025591b06770026b9879f1e5b10827424f410794fb2b1e1f10a720f49176", + "bytes": 8485 + }, + { + "local": "inputs/inputs/source_index/inputs/pascal_codec.py", + "git_blob": "2fb4426cc821a7e029e5c697787e235c79b4e756", + "url": "https://github.com/CubeJerry/integer-mult-bounds/blob/91246e5131152ccb1f64a969c36706360861f821/research/pascal-occurrence-codec/codec.py", + "sha256": "cec2c8b5e153a264127e8301ed59591fe97c9a46078ff2343b3784d177c6984d", + "bytes": 8243 + }, + { + "local": "inputs/library.py", + "git_blob": "e1e34aa0e6ee47999784c834ede4f8c9998c5647", + "url": "https://github.com/CubeJerry/integer-mult-bounds/blob/022461f115369efd988ef8c459907f5544bb8bb3/research/quantitative-rank-library/library.py", + "sha256": "06e3b44704048461de0ff0ab55fe158b95df412688324b88fd3d81b929ef0d92", + "bytes": 11110 + }, + { + "local": "reference/FINITE-PRECOMPILATION.md", + "git_blob": "4badb40f0919c515823cb07e44c6470d4d6469ca", + "url": "https://github.com/CrocSwap/integer-mult-bounds/blob/e54523517d0f03e58352e647c403a5af3e525a57/research/kappa-rebuild/architecture/FINITE-PRECOMPILATION.md", + "sha256": "4cb32f6b8e388ecf6ed41b5bbdeeb4539cb40c8424f194974afea58f7e0921e8", + "bytes": 15898 + }, + { + "local": "reference/symbolic-batch-PROOF.md", + "git_blob": "6702d6aba2ad4149f9efc8570012a66aae640c8c", + "url": "https://github.com/CrocSwap/integer-mult-bounds/blob/e54523517d0f03e58352e647c403a5af3e525a57/research/symbolic-integer-batch-width/PROOF.md", + "sha256": "f6fed469b53137c41d8543822b08e2381ebdfb6503c26663d01f56a2e8ab76bc", + "bytes": 9251 + }, + { + "local": "reference/source-port-PROOF.md", + "git_blob": "18592cc2a945f7f713403d555e5d8101f21fe9dc", + "url": "https://github.com/CubeJerry/integer-mult-bounds/blob/bd63147b1a193f68b5713e5814ac3b2c743beff8/research/source-complement-port-index/PROOF.md", + "sha256": "c966ddff4b9f8cb7c2c428adc9ab6e0496fb2fa40e9d05a1397ec96f96327272", + "bytes": 16673 + }, + { + "local": "reference/library-PROOF.md", + "git_blob": "36df15159497eca40d8a9c92023e7f4e91ba62d8", + "url": "https://github.com/CubeJerry/integer-mult-bounds/blob/022461f115369efd988ef8c459907f5544bb8bb3/research/quantitative-rank-library/PROOF.md", + "sha256": "05a04e5ba1db71b9e40397e3220f047411906a5e8a70609c7a879499e6325e88", + "bytes": 13441 + } + ] +} diff --git a/research/chronological-leaf-owner-index/TASK.json b/research/chronological-leaf-owner-index/TASK.json new file mode 100644 index 0000000000..845e3dc7c5 --- /dev/null +++ b/research/chronological-leaf-owner-index/TASK.json @@ -0,0 +1,15 @@ +{ + "track": 50, + "wave": 1, + "base": "e54523517d0f03e58352e647c403a5af3e525a57", + "assumption": "compiler", + "claim": "Construct the exact ordered rank-one paid-leaf projection and persistent source/owned field of each leaf in the fully recursively expanded separated compiler, with an ordinal inverse and whole-call input-port injection.", + "scope_refinement": "The initial exit-only division-wrapper scope was rejected as too thin; the orchestrator approved nested leaf/owner composition.", + "new_kappa": null, + "selected_kappa": "0.00363005817", + "remaining": ["actual selected native manifest and winning library", "full scalar/phase/adapter instruction stream", "physical payload gather and inverse return", "owned-storage realization", "numerical child endpoint and complete fixed-tape dispatcher"], + "method": "Weighted chronological suffix counts, finite interval inverses and upward port composition through strict rank descent.", + "verification": "Separate explicit class/slot/call expansion; independent direct large-path owner formula; invalid cuts, namespaces, multiplicities, replicas and returns.", + "stop_rule": "Stop at the paid-leaf/field logical interface; do not infer payload execution, a native multiplier or a new kappa from counts or labels.", + "credit": "Prepared for @CubeJerry with substantial OpenAI assistance and retained compiler/source-codec predecessor credit." +} diff --git a/research/chronological-leaf-owner-index/VALIDATION.json b/research/chronological-leaf-owner-index/VALIDATION.json new file mode 100644 index 0000000000..645a4d0c5c --- /dev/null +++ b/research/chronological-leaf-owner-index/VALIDATION.json @@ -0,0 +1,215 @@ +{ + "expanded_trace_sha256": "590e13d0d53160aa8a723d46ed8e0b3f33686ffea621d00289040d05a4e328d7", + "fixtures": [ + { + "ambient": 2, + "leaves": 22, + "maximum": 12, + "roles": [ + [ + "x", + 2 + ] + ], + "rounds": [ + [ + 1, + "x" + ] + ] + }, + { + "ambient": 3, + "leaves": 330, + "maximum": 12, + "roles": [ + [ + "x", + 2 + ], + [ + "y", + 3 + ] + ], + "rounds": [ + [ + 1, + "x" + ], + [ + 1, + "bank" + ] + ] + }, + { + "ambient": 5, + "leaves": 1030, + "maximum": 16, + "roles": [ + [ + "x", + 3 + ], + [ + "y", + 5 + ] + ], + "rounds": [ + [ + 1, + "x" + ], + [ + 2, + "bank" + ], + [ + 2, + "y" + ] + ] + }, + { + "ambient": 4, + "leaves": 1891, + "maximum": 12, + "roles": [ + [ + "x", + 2 + ], + [ + "y", + 2 + ], + [ + "z", + 4 + ] + ], + "rounds": [ + [ + 1, + "x" + ], + [ + 1, + "bank" + ], + [ + 1, + "y" + ] + ] + }, + { + "ambient": 6, + "leaves": 651, + "maximum": 14, + "roles": [ + [ + "x", + 2 + ], + [ + "y", + 3 + ] + ], + "rounds": [ + [ + 1, + "x" + ], + [ + 1, + "bank" + ] + ] + }, + { + "ambient": 8, + "leaves": 178, + "maximum": 12, + "roles": [ + [ + "high", + 8 + ], + [ + "low", + 4 + ], + [ + "mid", + 4 + ] + ], + "rounds": [ + [ + 2, + "low" + ], + [ + 3, + "private" + ], + [ + 2, + "private" + ], + [ + 1, + "high" + ] + ] + } + ], + "large_cut_fixture": { + "chronological_cuts": 68719476736, + "expanded": false, + "leaves": 68719476736, + "queries": 10, + "rank": 4096, + "source_states": 12, + "suffix_states": 13 + }, + "large_replication_fixture": { + "expanded": false, + "leaves": 5158340373946848, + "queries": 6, + "rank": 256, + "replication": 4729570560000, + "width": 94591411200000 + }, + "negative_controls": [ + "negative leaf", + "one-past leaf", + "wrong base axis", + "wrong physical return", + "rank-zero program", + "missing complete cut", + "wrong child row", + "zero complement call", + "wrong expanded leaf total", + "wrong sequential base", + "owner-only key loses a leaf", + "drop repeated paid-site multiplicity", + "merge chronological cuts", + "merge replicas at exit", + "drop owned invocation namespace" + ], + "new_kappa": null, + "status": "PASS_CHRONOLOGICAL_LEAF_OWNER_INDEX", + "totals": { + "calls": 2970, + "cross_replica_complements": 106, + "leaves": 4102, + "owned_leaves": 1183, + "ports": 3746, + "ranks": 78 + } +} diff --git a/research/chronological-leaf-owner-index/independent/RESULT.json b/research/chronological-leaf-owner-index/independent/RESULT.json new file mode 100644 index 0000000000..b84568bcc7 --- /dev/null +++ b/research/chronological-leaf-owner-index/independent/RESULT.json @@ -0,0 +1,44 @@ +{ + "cases": [ + { + "ambient": 3, + "calls": 21435, + "leaves": 21193, + "maximum": 36, + "nested_owner_namespace_leaves": 4329, + "owned_leaves": 15163, + "ports": 21988, + "trace_sha256": "1855fb2eaa6687b11673a212b3fbb043e69357c0e6771396f6f20f056224b19b", + "wide_calls": 188 + }, + { + "ambient": 5, + "calls": 2770, + "leaves": 2944, + "maximum": 18, + "nested_owner_namespace_leaves": 659, + "owned_leaves": 1213, + "ports": 3132, + "trace_sha256": "e9be5a4b763bc06b784cfc82d6dafdf63ce3af20fbc9c899ea82b7c75e197176", + "wide_calls": 84 + } + ], + "mutants": [ + { + "failure": "direct chronological leaf/field mismatch", + "mutation": "complement_invocation" + }, + { + "failure": "direct chronological leaf/field mismatch", + "mutation": "base_axis" + }, + { + "failure": "direct chronological leaf/field mismatch", + "mutation": "owned_call_prefix" + } + ], + "program_sha256": "fed9b8fe71f69d02bd1dc796f13d4311b8460d24860c246ce246997d5ca96724", + "scope": "single rank-two role, three ordered rank-one sites, nonminimal supplied libraries; no selected native instantiation", + "source_pins": 8, + "status": "PASS_INDEPENDENT_DIRECT_RECURSION" +} diff --git a/research/chronological-leaf-owner-index/independent/REVIEW.md b/research/chronological-leaf-owner-index/independent/REVIEW.md new file mode 100644 index 0000000000..28f709fca1 --- /dev/null +++ b/research/chronological-leaf-owner-index/independent/REVIEW.md @@ -0,0 +1,170 @@ +# Independent review of chronological leaf and persistent owner indexing + +Reviewer: the separate `literal_layer_boundary` research agent for Jerry +Chen / @CubeJerry, with OpenAI assistance. This is separate mathematical and +implementation review, not human acceptance or a proof-kernel certificate. + +## Decision and frozen artifact + +**Accept the stated lazy leaf-projection and per-invocation owner theorem.** +No scientific defect or required correction was found. This decision does +not accept a complete native compiler, physical payload implementation, +selected huge library, removal of a whole assumption, or a new kappa. + +Base: `e54523517d0f03e58352e647c403a5af3e525a57`. + +- `leaf_index.py` SHA256: + `fed9b8fe71f69d02bd1dc796f13d4311b8460d24860c246ce246997d5ca96724`. +- `PROOF.md` SHA256: + `e394711ee942e0779e041d0cc04adddc43ad10f2094d72fcd8bea53e1d8154b4`. +- Eight retained source files independently matched their lengths, SHA256 + values and Git blob identities. This authenticates the frozen local bytes + against the declared pins; remote provenance/ancestry is the root's gate. + +The review read the complete new implementation and proof, predecessor +source-group interfaces, and the relevant finite-precompilation order. The +separate execution below does not run the author's verifier, literal oracle, +library generator, source DP or owner resolver to form expected results. +The tested implementation naturally imports its retained codec dependencies. + +## Ordered leaves and the weighted suffix proof + +The preliminary source-complement phase followed by depth-first lockstep +paid-site calls is permitted by retained FINITE-PRECOMPILATION sections 3--4. +The earlier complementary coordinates commute with the source job; whole +child calls must complete before parent resumption. The new theorem explicitly +fixes this permitted order instead of claiming a canonical arbitrary native +word. It indexes its chronological projection onto base paid leaves only. + +At deepest height G, every ordered paid prefix is present: its capacity is +at most A r_max^G, bounded by A k_min^G <= n. The zero target point then +has multiplicity one. Consequently an exit cut is the full length-G+1 paid +word, not a rank or owner. Each individual cut contributes a/B_e whole calls +of P_e leaves. The recurrence H(h,rho) is a finite ordered-tree suffix count; +merging equal products is safe for arithmetic because the selection still +visits every distinct paid site in its original order. Repeated equal ranks +retain their multiplicities. Product coincidences do not merge paths. + +The complement intervals have whole-call widths P_(n-s), and each exit +subinterval has whole-call width P_e. The exact supplied leaf recurrence +proves coverage without gaps or overlaps. Successive subtraction selects +one ordered interval and divmod selects one invocation/local ordinal. The +inverse sums those same preceding intervals. Strong induction on the +strictly smaller child rank establishes full path/ordinal inversion. + +The code implements this proof: `prefixes` is the sorted complement order; +`locate` subtracts actual paid-site intervals; `step_data` reconstructs the +before-call offset from actual preceding sites and invocation; `rank_leaf` +adds these offsets from inside out. Its field check is additional identity +validation, not a replacement for the path. Base rank n=2, +the stated A ceil(log2(N+1)) bound safely limits the number of call edges. +The proof appropriately treats A as fixed for fixed-rule polynomial claims; +it does not describe this factor as polynomial in log A. + +The Z cap includes all supplied library integer lengths, role/site lists, +namespace and path digits. Source counts are bounded by B_n, positive suffix +counts/offsets by P_n, and operand widths needed by intermediate products and +divisions fit its stated O(Z) allowance. Actual huge replication is therefore +not a unit-cost hidden parameter. A path requires O(DZ) bits. + +The new suffix levels have at most binom(G+q+1,q) product records. Sorting +and comparison costs are included, rather than relying on expected hash +behavior. Source setup, bucket replacement and queries explicitly use the +retained predecessor envelopes. Per-node setup adds the new weighted levels, +bottom quotients and complement intervals. Per-query work covers each rank's +source translation, paid-site scans, group scans and path copies. Repeated +`step_data` and `validate_calls` traversals in owner resolution fit the +conservative D/path terms; they are not hidden constant-time operations. + +The complete bound includes O(NZ) initialization of all N supplied rows and +the N-entry cache. Retained cache space permits all N source/node tables, +not merely those touched by the first query. The predecessor table envelope +includes transient replacement storage; new level and suffix storage is +covered by the additional (q+1)HZ term. The serialized companion explicitly +replaces logical metadata access with full scans/copies and O(L^2) local +actions, retaining historical space after erasure. This is a constructive +loose simulation envelope, not a literal state table or a multiplier tariff. + +The general interface assumes a valid evaluated library; its recurrence is +checked as new nodes are built. The unchanged generator's sharper bounds +are imported only at A=k_max. No transfer to arbitrary A or the selected +153^1920 instance is claimed. These distinctions are essential and present. + +## Separately written direct recursion oracle + +The new `direct_recursion.py` specializes to one productive role of rank two, +three ordered rank-one sites on `(x, bank, x)`, and ambient A=3 or A=5. +Thus A exceeds all target ranks. This family has one fresh source at +s=2^(G+1), one positive complement e=n-s, and 3^(G+1) qualified exits. +It is simple enough to derive expected answers without any source codec. + +Rather than adopting the author's minimal library, the oracle chooses +`t_n=1+(n mod 3)` and `a_n=t_n B_e`, with `B_n=a_n` and +`P_n=t_n P_e+a_n 3^(G+1)`. This is a valid, often nonminimal supplied library. +Direct recursion first slices the explicit current source vector into t_n +consecutive whole child blocks. It then literally enumerates all ternary +paid words and replicas; each bank site changes the carried field to that +unit's explicit new bank, while x sites preserve it. It never asks the +production resolver for an expected owner. Expected inverse descriptors are +constructed directly, not copied from the implementation's locate result. + +The executed domains are every rank 1--36 at A=3 and every rank 1--18 at A=5: + +- 24,137 complete leaf locations, full paths, base axes and physical fields; +- 24,205 whole-call occurrences, including root invocations; +- 25,120 input ports, including 272 invocations of width greater than one; +- 16,376 owned-field leaves, including 4,988 with a nonempty allocating-call + namespace (nested bank namespaces, rather than a claim of every possible + parent-owned-to-recursive-child configuration); +- all eight source pins and three independently inserted semantic mutants. + +The mutants lose the complement invocation number, rotate the base axis, +or omit the allocating call prefix. Each is rejected by direct expected +leaf/field mismatch. Equal-owner/different-instruction behavior is retained; +per-call port vectors are separately checked for injectivity. + +This finite family supplements the universal proof and the author's broader +heterogeneous-rank literal oracle. It does not establish all rules by finite +extrapolation or assert these formal metadata fixtures are selected native +suppliers. Reproduce from the repository root after placing the independent +script in the package, or supply its scratch path directly: + +```sh +python3 -I -W error -B research/chronological-leaf-owner-index/independent/direct_recursion.py research/chronological-leaf-owner-index/leaf_index.py +``` + +Expected status: `PASS_INDEPENDENT_DIRECT_RECURSION`. Exact domain counts, +trace hashes and mutant failures are recorded in `RESULT.json`. The script +prints its receipt and does not write package files or mutate scientific +sources. diff --git a/research/chronological-leaf-owner-index/independent/SOURCE-BINDINGS.json b/research/chronological-leaf-owner-index/independent/SOURCE-BINDINGS.json new file mode 100644 index 0000000000..3c37e48b0a --- /dev/null +++ b/research/chronological-leaf-owner-index/independent/SOURCE-BINDINGS.json @@ -0,0 +1,61 @@ +{ + "status": "PASS_COMMIT_PATH_AND_BYTES", + "files": [ + { + "path": "research/source-complement-port-index/groups.py", + "commit": "bd63147b1a193f68b5713e5814ac3b2c743beff8", + "blob": "bbf54125523bdf8cd6fd7239938a0a42f53a5344", + "bytes": 12449, + "status": "MATCH" + }, + { + "path": "research/lockstep-source-row-index/source_index.py", + "commit": "c5bcb6dc792f5fe4d8abe89a2a2854f148b09f2c", + "blob": "4e3cb2a53fb1c5c90e01202eb4e51a559c8727f7", + "bytes": 8485, + "status": "MATCH" + }, + { + "path": "research/pascal-occurrence-codec/codec.py", + "commit": "91246e5131152ccb1f64a969c36706360861f821", + "blob": "2fb4426cc821a7e029e5c697787e235c79b4e756", + "bytes": 8243, + "status": "MATCH" + }, + { + "path": "research/quantitative-rank-library/library.py", + "commit": "022461f115369efd988ef8c459907f5544bb8bb3", + "blob": "e1e34aa0e6ee47999784c834ede4f8c9998c5647", + "bytes": 11110, + "status": "MATCH" + }, + { + "path": "research/kappa-rebuild/architecture/FINITE-PRECOMPILATION.md", + "commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "blob": "4badb40f0919c515823cb07e44c6470d4d6469ca", + "bytes": 15898, + "status": "MATCH" + }, + { + "path": "research/symbolic-integer-batch-width/PROOF.md", + "commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "blob": "6702d6aba2ad4149f9efc8570012a66aae640c8c", + "bytes": 9251, + "status": "MATCH" + }, + { + "path": "research/source-complement-port-index/PROOF.md", + "commit": "bd63147b1a193f68b5713e5814ac3b2c743beff8", + "blob": "18592cc2a945f7f713403d555e5d8101f21fe9dc", + "bytes": 16673, + "status": "MATCH" + }, + { + "path": "research/quantitative-rank-library/PROOF.md", + "commit": "022461f115369efd988ef8c459907f5544bb8bb3", + "blob": "36df15159497eca40d8a9c92023e7f4e91ba62d8", + "bytes": 13441, + "status": "MATCH" + } + ] +} diff --git a/research/chronological-leaf-owner-index/independent/direct_recursion.py b/research/chronological-leaf-owner-index/independent/direct_recursion.py new file mode 100644 index 0000000000..c64857fa85 --- /dev/null +++ b/research/chronological-leaf-owner-index/independent/direct_recursion.py @@ -0,0 +1,203 @@ +"""Independent direct chronology/field oracle; no author oracle or library DP. + +The tested implementation is loaded only to compare its public results. +""" +from dataclasses import dataclass +from hashlib import sha1, sha256 +from importlib.util import module_from_spec, spec_from_file_location +from itertools import product +import json +from pathlib import Path +import sys +import types + +EXPECTED = 'fed9b8fe71f69d02bd1dc796f13d4311b8460d24860c246ce246997d5ca96724' + + +def need(truth, message): + if not truth: + raise ValueError(message) + + +@dataclass(frozen=True) +class Row: + replication: int + width: int + leaves: int + + +def height(rank, ambient): + h = 0 + while ambient*2**(h+1) <= rank: + h += 1 + return h + + +def library(ambient, maximum): + """One rank-two role, three rank-one sites; intentionally nonminimal a.""" + rows = [None] + for n in range(1, maximum+1): + if n < ambient: + rows.append(Row(1, 1, n)) + else: + h = height(n, ambient) + e = n-2**(h+1) + # Sole fresh source has rank 2**(h+1). All later x slots inherit. + t = 1+n % 3 + a = t*rows[e].width + rows.append(Row(a, a, t*rows[e].leaves+a*3**(h+1))) + return rows + + +def direct(ambient, rows, rank, namespace): + """Materialize ordered calls and leaves using explicit physical vectors.""" + leaves, calls = [], [] + sites = ('x', 'bank', 'x') + + def visit(n, path, fields): + calls.append((path, tuple(fields))) + if n < ambient: + need(len(fields) == 1, 'direct base width') + for axis in range(n): + leaves.append((path, n, axis, fields[0])) + return + h = height(n, ambient) + s, e = 2**(h+1), n-2**(h+1) + a, child_width = rows[n].replication, rows[e].width + need(a == len(fields), 'direct source width') + for v in range(a//child_width): + step = (n, 'complement', s, v) + block = fields[v*child_width:(v+1)*child_width] + visit(e, path+(step,), block) + for cut in product(range(3), repeat=h+1): + for replica in range(a): + field = fields[replica] + # A bank site selects this unit's fresh field. Later x sites + # carry that identity. No production owner routine is used. + for at, site in enumerate(cut): + if sites[site] == 'bank': + field = ('owned', namespace, path, replica, + cut[:at], (h-at,), 0, 'bank') + visit(1, path+((n, 'exit', cut, replica),), [field]) + + visit(rank, (), [('source', namespace, row) for row in range(rows[rank].width)]) + need(len(leaves) == rows[rank].leaves, 'direct recurrence count') + return leaves, calls + + +def canonical_steps(steps): + return tuple((s.parent, s.kind, s.key, s.invocation) for s in steps) + + +def canonical_field(value): + if hasattr(value, 'row'): + return ('source', value.namespace, value.row) + return ('owned', value.namespace, canonical_steps(value.calls), value.replica, + value.path, value.point, value.ordinal, value.role) + + +def canonical_leaf(value): + return canonical_steps(value.calls), value.rank, value.axis, canonical_field(value.field) + + +def reconstructed_leaf(module, expected): + calls, rank, axis, field = expected + calls = tuple(module.Step(*s) for s in calls) + if field[0] == 'source': + identity = module.SourceRow(field[1], field[2]) + else: + _, namespace, prefix, replica, path, point, ordinal, role = field + identity = module.OwnedBank(namespace, tuple(module.Step(*s) for s in prefix), + replica, path, point, ordinal, role) + return module.Leaf(calls, rank, axis, identity) + + +def load(path, name, mutation=None): + if mutation is None: + spec = spec_from_file_location(name, path) + module = module_from_spec(spec) + sys.modules[name] = module + spec.loader.exec_module(module) + return module + source = path.read_text() + old, new = mutation + need(source.count(old) == 1, 'unique independent mutant seam') + module = types.ModuleType(name) + module.__file__ = str(path) + sys.modules[name] = module + exec(compile(source.replace(old, new), str(path), 'exec'), module.__dict__) + return module + + +def check(module, ambient, maximum, all_ranks=True): + rows = library(ambient, maximum) + namespace = 'independent-A'+str(ambient) + rule = module.C.Rule((('x', 2),), ((1, 'x'), (1, 'bank'), (1, 'x')), + ('bank',), ambient) + engine = module.Compiler(rule, rows, namespace) + totals = {'leaves': 0, 'calls': 0, 'ports': 0, 'wide_calls': 0, + 'owned_leaves': 0, 'nested_owner_namespace_leaves': 0} + digest = sha256() + for rank in (range(1, maximum+1) if all_ranks else (maximum,)): + expected, calls = direct(ambient, rows, rank, namespace) + for ordinal, want in enumerate(expected): + actual = engine.locate(ordinal, rank) + need(canonical_leaf(actual) == want, 'direct chronological leaf/field mismatch') + need(engine.rank_leaf(reconstructed_leaf(module, want), rank) == ordinal, + 'independently formed descriptor inverse') + if want[3][0] == 'owned': + totals['owned_leaves'] += 1 + totals['nested_owner_namespace_leaves'] += int(len(want[3][2]) > 0) + digest.update((repr(want)+'\n').encode()) + for path, fields in calls: + typed = tuple(module.Step(*s) for s in path) + actual = tuple(canonical_field(engine.resolve_row(typed, i, rank)) + for i in range(len(fields))) + need(actual == fields, 'direct input-vector return map') + need(len(set(actual)) == len(actual), 'one whole call aliases fields') + totals['wide_calls'] += int(len(fields) > 1) + totals['ports'] += len(fields) + totals['calls'] += len(calls) + totals['leaves'] += len(expected) + totals['trace_sha256'] = digest.hexdigest() + totals['ambient'] = ambient + totals['maximum'] = maximum + return totals + + +def run(path): + need(sha256(path.read_bytes()).hexdigest() == EXPECTED, 'frozen program changed') + manifest = json.loads((path.parent/'SOURCES.json').read_text()) + for item in manifest['files']: + data = (path.parent/item['local']).read_bytes() + need(len(data) == item['bytes'], 'source size') + need(sha256(data).hexdigest() == item['sha256'], 'source SHA256') + blob = sha1(b'blob '+str(len(data)).encode()+b'\0'+data).hexdigest() + need(blob == item['git_blob'], 'source Git blob') + module = load(path, 'independent_subject') + records = [check(module, 3, 36), check(module, 5, 18)] + mutations = ( + ('complement_invocation', + 'step.invocation, child_row))', '0, child_row))'), + ('base_axis', + 'return Leaf(calls, rank, ordinal, self.resolve_row', + 'return Leaf(calls, rank, (ordinal+1)%rank, self.resolve_row'), + ('owned_call_prefix', 'calls[:at], replica,', '(), replica,'), + ) + detected = [] + for number, (label, old, new) in enumerate(mutations): + mutant = load(path, 'independent_mutant_'+str(number), (old, new)) + try: + check(mutant, 3, 20) + except ValueError as error: + detected.append({'mutation': label, 'failure': str(error)}) + else: + raise ValueError('independent oracle failed to detect '+label) + return {'status': 'PASS_INDEPENDENT_DIRECT_RECURSION', + 'program_sha256': EXPECTED, 'source_pins': len(manifest['files']), + 'cases': records, 'mutants': detected, + 'scope': 'single rank-two role, three ordered rank-one sites, nonminimal supplied libraries; no selected native instantiation'} + + +if __name__ == '__main__': + print(json.dumps(run(Path(sys.argv[1]).resolve()), sort_keys=True, indent=2)) diff --git a/research/chronological-leaf-owner-index/inputs/groups.py b/research/chronological-leaf-owner-index/inputs/groups.py new file mode 100644 index 0000000000..bbf5412552 --- /dev/null +++ b/research/chronological-leaf-owner-index/inputs/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/chronological-leaf-owner-index/inputs/inputs/source_index/inputs/pascal_codec.py b/research/chronological-leaf-owner-index/inputs/inputs/source_index/inputs/pascal_codec.py new file mode 100644 index 0000000000..2fb4426cc8 --- /dev/null +++ b/research/chronological-leaf-owner-index/inputs/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/chronological-leaf-owner-index/inputs/inputs/source_index/source_index.py b/research/chronological-leaf-owner-index/inputs/inputs/source_index/source_index.py new file mode 100644 index 0000000000..4e3cb2a53f --- /dev/null +++ b/research/chronological-leaf-owner-index/inputs/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/chronological-leaf-owner-index/inputs/library.py b/research/chronological-leaf-owner-index/inputs/library.py new file mode 100644 index 0000000000..e1e34aa0e6 --- /dev/null +++ b/research/chronological-leaf-owner-index/inputs/library.py @@ -0,0 +1,305 @@ +"""Exact separated chronological compiler metadata; Apache-2.0. + +Prepared for CubeJerry with substantial OpenAI assistance. This reference +evaluates integers, not native programs. PROOF.md prices indexed arithmetic +and a separately described sequential implementation. +""" +from dataclasses import dataclass +from math import comb, gcd + + +class BudgetError(ValueError): + """The bounded executable refuses an unevaluated larger instance.""" + + +@dataclass(frozen=True) +class Limits: + max_rank: int = 4096 + max_records: int = 200000 + max_bits: int = 16384 + + def __post_init__(self): + if any(type(x) is not int or x < 1 for x in + (self.max_rank, self.max_records, self.max_bits)): + raise ValueError("positive integer capacities required") + + def integer(self, value): + if abs(value).bit_length() > self.max_bits: + raise BudgetError("integer bit capacity") + return value + + def records(self, count): + if count > self.max_records: + raise BudgetError("local record capacity") + + +@dataclass(frozen=True) +class Rule: + targets: tuple + paid: tuple + + def __post_init__(self): + for alphabet in (self.targets, self.paid): + if type(alphabet) is not tuple or not alphabet: + raise ValueError("nonempty tuple histograms required") + previous = 0 + for entry in alphabet: + if type(entry) is not tuple or len(entry) != 2: + raise ValueError("rank/count pairs required") + rank, count = entry + if (type(rank) is not int or type(count) is not int or + rank <= previous or count < 1): + raise ValueError("sorted distinct positive ranks/counts required") + previous = rank + if self.targets[0][0] < 2 or self.paid[-1][0] >= self.targets[0][0]: + raise ValueError("strict separation required") + + @property + def m(self): + return self.targets[-1][0] + + @property + def kmin(self): + return self.targets[0][0] + + @property + def bits(self): + def gamma_length(v): + return 2 * v.bit_length() - 1 + total = 0 + for alphabet in (self.targets, self.paid): + total += gamma_length(len(alphabet)) + total += sum(gamma_length(x) for row in alphabet for x in row) + return total + + +@dataclass(frozen=True) +class Row: + replication: int + width: int + leaves: int + units: int + + +@dataclass(frozen=True) +class Census: + rank: int + height: int + units: int + sources: tuple + exits: tuple + + +@dataclass +class Work: + product_records: int = 0 + candidate_pairs: int = 0 + source_contributions: int = 0 + complement_constraints: int = 0 + exit_constraints: int = 0 + completed_rows: int = 0 + + +@dataclass(frozen=True) +class Library: + rule: Rule + rows: tuple + work: Work + + +def height(rule, rank): + if rank < rule.m: + raise ValueError("height requires a nonbase rank") + threshold = rule.m + result = 0 + while threshold * rule.kmin <= rank: + threshold *= rule.kmin + result += 1 + return result + + +def merge_records(records, limits): + """Deterministic sort/add; input length and temporary integers charged.""" + limits.records(len(records)) + records.sort(key=lambda item: item[0]) + result = [] + key, value = None, 0 + for next_key, next_value in records: + if key is not None and next_key != key: + if value < 0: + raise ValueError("negative aggregate") + if value: + result.append((key, value)) + value = 0 + key = next_key + value = limits.integer(value + next_value) + if key is not None: + if value < 0: + raise ValueError("negative aggregate") + if value: + result.append((key, value)) + return tuple(result) + + +def product_tables(alphabet, degree, limits, work): + tables = [((1, 1),)] + for _ in range(degree): + limits.records(len(tables[-1]) * len(alphabet)) + candidates = [] + for product, count in tables[-1]: + for rank, multiplicity in alphabet: + candidates.append((limits.integer(product * rank), + limits.integer(count * multiplicity))) + work.product_records += len(candidates) + tables.append(merge_records(candidates, limits)) + return tuple(tables) + + +def census(rule, rank, targets, paid, limits, work): + gmax = height(rule, rank) + d, q = len(rule.targets), len(rule.paid) + bound = (d + q) * comb(gmax + d + q - 1, d + q - 1) + limits.records(bound) + contributions = [] + units = 0 + for depth in range(gmax + 1): + for rho, paths in paid[depth]: + for column, words in targets[gmax - depth]: + work.candidate_pairs += 1 + size = limits.integer(rho * column) + if limits.integer(rule.m * size) > rank: + continue + copies = limits.integer(paths * words) + units = limits.integer(units + copies) + for k, multiplicity in rule.targets: + contributions.append((limits.integer(size * k), + limits.integer(copies * multiplicity))) + if depth < gmax: + for r, multiplicity in rule.paid: + contributions.append((limits.integer(size * r), + -limits.integer(copies * multiplicity))) + work.source_contributions += len(contributions) + sources = merge_records(contributions, limits) + if not sources or any(not rank < rule.m * s <= rule.m * rank + for s, _ in sources): + raise ValueError("source band failure") + exits = paid[gmax + 1] + if any(not 0 < e * rule.m <= (rule.m - 1) * rank for e, _ in exits): + raise ValueError("exit contraction failure") + return Census(rank, gmax, units, sources, exits) + + +def child(rows, parent, rank): + if not 1 <= rank < parent or rank >= len(rows) or rows[rank] is None: + raise ValueError("positive previously completed child required") + return rows[rank] + + +def replication(flow, rows, limits, work): + result = 1 + for source, count in flow.sources: + if source == flow.rank: + continue + width = child(rows, flow.rank, flow.rank - source).width + factor = width // gcd(width, count) + result = limits.integer((result // gcd(result, factor)) * factor) + work.complement_constraints += 1 + for exit_rank, multiplicity in flow.exits: + factor = child(rows, flow.rank, exit_rank).width + result = limits.integer((result // gcd(result, factor)) * factor) + work.exit_constraints += 1 + return result + + +def whole_copies(arrays, width): + copies, remainder = divmod(arrays, width) + if remainder: + raise ValueError("nonintegral chronological child batch") + return copies + + +def finish_row(flow, rows, scale, limits): + width = limits.integer(scale * sum(count for _, count in flow.sources)) + leaves = 0 + units = limits.integer(scale * flow.units) + for source, count in flow.sources: + if source == flow.rank: + continue + old = child(rows, flow.rank, flow.rank - source) + copies = whole_copies(limits.integer(scale * count), old.width) + leaves = limits.integer(leaves + limits.integer(copies * old.leaves)) + units = limits.integer(units + limits.integer(copies * old.units)) + for exit_rank, multiplicity in flow.exits: + old = child(rows, flow.rank, exit_rank) + per_cut = whole_copies(scale, old.width) + copies = limits.integer(multiplicity * per_cut) + leaves = limits.integer(leaves + limits.integer(copies * old.leaves)) + units = limits.integer(units + limits.integer(copies * old.units)) + return Row(scale, width, leaves, units) + + +def compile_library(rule, maximum, limits=Limits()): + if type(maximum) is not int or maximum < 1: + raise ValueError("positive maximum rank required") + if maximum > limits.max_rank: + raise BudgetError("maximum rank capacity") + limits.records(len(rule.targets) + len(rule.paid)) + for alphabet in (rule.targets, rule.paid): + for record in alphabet: + for value in record: + limits.integer(value) + work = Work() + rows = [None] # no B_0 program is constructed or queried + if maximum >= rule.m: + gmax = height(rule, maximum) + mt = comb(gmax + len(rule.targets), len(rule.targets)) + mr = comb(gmax + len(rule.paid) + 1, len(rule.paid)) + limits.records(mt + mr) + targets = product_tables(rule.targets, gmax, limits, work) + paid = product_tables(rule.paid, gmax + 1, limits, work) + for rank in range(1, maximum + 1): + if rank < rule.m: + row = Row(1, 1, rank, 0) + else: + flow = census(rule, rank, targets, paid, limits, work) + scale = replication(flow, rows, limits, work) + row = finish_row(flow, rows, scale, limits) + rows.append(row) + work.completed_rows += 1 + return Library(rule, tuple(rows), work) + + +def envelope(rule, maximum): + """Return explicit integer bounds, not the enormous powers B or F**D.""" + if type(maximum) is not int or maximum < rule.m: + raise ValueError("nonbase maximum required for this envelope") + d, q = len(rule.targets), len(rule.paid) + w = sum(count for _, count in rule.targets) + p = sum(count for _, count in rule.paid) + g = height(rule, maximum) + length = maximum.bit_length() + ubar = (g + 1) * max(w, p) ** g + sbar = w * ubar + f = 1 + (w + 1) * ubar + p ** (g + 1) + depth = rule.m * length + generators = [] + for rank in sorted(k for alphabet in (rule.targets, rule.paid) + for k, _ in alphabet if k >= 2): + if not generators or generators[-1] != rank: + generators.append(rank) + tau = rule.m * (rule.kmin - 1).bit_length() + beta = tau * (length + 1) ** len(generators) * sbar.bit_length() + mt, mr = comb(g + d, d), comb(g + q + 1, q) + pairs = comb(g + d + q - 1, d + q - 1) + exits = comb(g + q, q - 1) + operations = ((rule.bits + 1) ** 2 + d * mt + q * mr + + (maximum + 1) * ((d + q + 2) * pairs + exits + g + 2)) + bit_cap = 8 * (rule.bits + length + (g + 2) * (rule.m + w + p + 2).bit_length() + + beta + rule.m.bit_length() + depth * f.bit_length() + + operations.bit_length() + 2) + local_records = mt + mr + (d + q + 2) * pairs + exits + g + rule.bits + 2 + return {"height": g, "target_records": mt, "paid_records": mr, + "pairs": pairs, "exit_records": exits, "width_log_bound": beta, + "combined_output_bits": beta + rule.m.bit_length() + depth * f.bit_length() + 1, + "F": f, "D": depth, "K": operations, "Z": bit_cap, + "J": local_records, "L_local": local_records * bit_cap} diff --git a/research/chronological-leaf-owner-index/leaf_index.py b/research/chronological-leaf-owner-index/leaf_index.py new file mode 100644 index 0000000000..946fcf914a --- /dev/null +++ b/research/chronological-leaf-owner-index/leaf_index.py @@ -0,0 +1,255 @@ +"""Lazy chronological rank-one leaf locations and persistent field identities. + +Prepared for CubeJerry with substantial OpenAI assistance. Apache-2.0. +Logical descriptors only: no payload execution or unpriced adapters. +""" +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 +SOURCE = HERE / 'inputs/groups.py' +if sha256(SOURCE.read_bytes()).hexdigest() != '871b166c174958bb467952bebe9a2b776a0582f0c427b7dea9a94a128edad171': + raise ValueError('frozen complement-port source') +spec = spec_from_file_location('leaf_groups', SOURCE) +G = module_from_spec(spec) +sys.modules[spec.name] = G +spec.loader.exec_module(G) +C, I = G.C, G.I + + +@dataclass(frozen=True) +class Step: + parent: int + kind: str + key: object # source rank, or full ordered exit path + invocation: int + + +@dataclass(frozen=True) +class SourceRow: + namespace: str + row: int + + +@dataclass(frozen=True) +class OwnedBank: + namespace: str + calls: tuple + replica: int + path: tuple + point: tuple + ordinal: int + role: str + + +@dataclass(frozen=True) +class Leaf: + calls: tuple + rank: int + axis: int + field: object + + +class Node: + """One rank's source and weighted chronological-cut metadata.""" + def __init__(self, compiler, rank): + self.compiler, self.rank = compiler, rank + self.row = compiler.row(rank) + self.groups = G.SourceGroups(compiler.rule, rank, self.row.replication, 'local') + self.height = self.groups.index.height + C.require(self.row.width == self.row.replication*self.groups.index.size, + 'compiled source width recurrence') + library = tuple((rank-s, compiler.row(rank-s).width) + for s in self.groups.ranks if s < rank) + self.complements = G.ComplementRouter(self.groups, library) + prefixes, self.pre = [], 0 + for source in self.groups.ranks: + if source == rank: + continue + child = compiler.row(rank-source) + size = self.complements.invocations(source)*child.leaves + prefixes.append((source, self.pre, size)) + self.pre += size + self.prefixes = tuple(prefixes) + levels = [(1,)] + for _ in range(self.height+1): + levels.append(tuple(I.sorted_unique(rho*r for rho in levels[-1] + for r in self.groups.index.paid))) + keys = tuple((h, rho) for h, level in enumerate(levels) for rho in level) + self.suffix = I.SortedStateTable(keys) + for h in range(self.height+1, -1, -1): + for rho in levels[h]: + if h == self.height+1: + child = compiler.row(rho) + copies, remainder = divmod(self.row.replication, child.width) + C.require(remainder == 0, 'every individual exit cut is integral') + value = copies*child.leaves + else: + value = sum(count*self.suffix[h+1, rho*r] + for r, count in self.groups.index.paid.items()) + self.suffix[h, rho] = value + C.require(self.pre+self.suffix[0, 1] == self.row.leaves, + 'complete ordered leaf count recurrence') + + def exit_rank(self, cut): + C.require(type(cut) is tuple and len(cut) == self.height+1, + 'complete chronological exit cut') + return self.groups.index.flow.dilation(cut) + + def exit_owner(self, cut, replica): + self.exit_rank(cut) + C.natural(replica, 'replica') + C.require(replica < self.row.replication, 'exit replica range') + unit = C.Unit(cut[:-1], (0,)*len(self.groups.index.types), 0) + return self.groups.index.flow.paid_owner(unit, cut[-1], 'local', replica) + + def exit_port(self, cut, owner): + e = self.exit_rank(cut) + C.require(type(owner) is tuple and len(owner) == 7, 'complete owner identifier') + replica = owner[1] + C.require(owner == self.exit_owner(cut, replica), 'owner at this cut') + return divmod(replica, self.compiler.row(e).width) + + def step_data(self, step): + """Validate one call; return (child rank, before-call leaf offset).""" + C.require(type(step) is Step and step.parent == self.rank, 'correct parent rank') + C.natural(step.invocation, 'whole invocation ordinal') + if step.kind == 'complement': + C.natural(step.key, 'complement source rank') + for source, offset, _ in self.prefixes: + if source == step.key: + child = self.compiler.row(self.rank-source) + C.require(step.invocation < self.complements.invocations(source), + 'complement invocation range') + return self.rank-source, offset+step.invocation*child.leaves + raise ValueError('positive complement source absent') + C.require(step.kind == 'exit', 'typed chronological call') + e = self.exit_rank(step.key) + child = self.compiler.row(e) + C.require(step.invocation < self.row.replication//child.width, + 'exit invocation range') + rho, offset = 1, self.pre + for h, chosen in enumerate(step.key): + for r, _ in self.compiler.rule.rounds[:chosen]: + offset += self.suffix[h+1, rho*r] + rho *= self.compiler.rule.rounds[chosen][0] + return e, offset+step.invocation*child.leaves + + def locate(self, ordinal): + C.natural(ordinal, 'leaf ordinal') + C.require(ordinal < self.row.leaves, 'leaf ordinal range') + for source, offset, size in self.prefixes: + if ordinal < offset+size: + child = self.compiler.row(self.rank-source) + invocation, local = divmod(ordinal-offset, child.leaves) + return Step(self.rank, 'complement', source, invocation), local + local, rho, path = ordinal-self.pre, 1, () + for h in range(self.height+1): + for chosen, (r, _) in enumerate(self.compiler.rule.rounds): + size = self.suffix[h+1, rho*r] + if local < size: + path += (chosen,) + rho *= r + break + local -= size + else: + raise ValueError('weighted cut count disagreement') + invocation, local = divmod(local, self.compiler.row(rho).leaves) + return Step(self.rank, 'exit', path, invocation), local + + def caller_owner(self, step, child_row): + e, _ = self.step_data(step) + C.natural(child_row, 'child productive row') + C.require(child_row < self.compiler.row(e).width, 'child productive row range') + if step.kind == 'complement': + row = self.complements.row(G.ComplementPort('local', step.key, + step.invocation, child_row)) + return self.groups.index.owner(row) + replica = step.invocation*self.compiler.row(e).width+child_row + return self.exit_owner(step.key, replica) + + +class Compiler: + """Supplied exact library plus unexpanded logical occurrence metadata. + + A may exceed every target rank. Base ranks n= 2 and rows[0] is None, 'no rank-zero library') + self.rule, self.rows, self.namespace = rule, tuple(rows), namespace + self.maximum = len(rows)-1 + self.nodes = [None]*len(rows) + for rank, row in enumerate(rows[1:], 1): + for value in (row.replication, row.width, row.leaves): + C.natural(value, 'evaluated library integer') + C.require(value > 0, 'positive library integer') + if rank < rule.ambient: + C.require((row.replication, row.width, row.leaves) == (1, 1, rank), + 'sequential base library') + + def row(self, rank): + C.natural(rank, 'library rank') + C.require(0 < rank <= self.maximum, 'positive available library rank') + return self.rows[rank] + + def node(self, rank): + self.row(rank) + C.require(rank >= self.rule.ambient, 'nonbase flow only') + if self.nodes[rank] is None: + self.nodes[rank] = Node(self, rank) + return self.nodes[rank] + + def validate_calls(self, calls, root=None): + C.require(type(calls) is tuple, 'tuple call path') + rank = self.maximum if root is None else root + self.row(rank) + for step in calls: + rank, _ = self.node(rank).step_data(step) + return rank + + def resolve_row(self, calls, row, root=None): + """Map a call's productive port to persistent root/owned identity.""" + rank = self.validate_calls(calls, root) + C.natural(row, 'productive row') + C.require(row < self.row(rank).width, 'productive row range') + for at in range(len(calls)-1, -1, -1): + step = calls[at] + node = self.node(step.parent) + owner = node.caller_owner(step, row) + if owner[2] == 'owned': + _, replica, _, path, point, ordinal, role = owner + return OwnedBank(self.namespace, calls[:at], replica, + path, point, ordinal, role) + row = node.groups.index.row(owner) + return SourceRow(self.namespace, row) + + def locate(self, ordinal, root=None): + rank = self.maximum if root is None else root + C.natural(ordinal, 'leaf ordinal') + C.require(ordinal < self.row(rank).leaves, 'leaf ordinal range') + calls = () + while rank >= self.rule.ambient: + step, ordinal = self.node(rank).locate(ordinal) + calls += (step,) + rank, _ = self.node(rank).step_data(step) + return Leaf(calls, rank, ordinal, self.resolve_row(calls, 0, root)) + + def rank_leaf(self, leaf, root=None): + C.require(type(leaf) is Leaf, 'typed leaf descriptor') + rank = self.validate_calls(leaf.calls, root) + C.require(rank == leaf.rank and rank < self.rule.ambient, 'correct base rank') + C.natural(leaf.axis, 'base axis') + C.require(leaf.axis < rank, 'base axis range') + C.require(leaf.field == self.resolve_row(leaf.calls, 0, root), + 'leaf physical field identity') + ordinal = leaf.axis + for step in reversed(leaf.calls): + _, offset = self.node(step.parent).step_data(step) + ordinal += offset + return ordinal diff --git a/research/chronological-leaf-owner-index/literal_oracle.py b/research/chronological-leaf-owner-index/literal_oracle.py new file mode 100644 index 0000000000..cd61ca640f --- /dev/null +++ b/research/chronological-leaf-owner-index/literal_oracle.py @@ -0,0 +1,172 @@ +"""Separate finite oracle: materialize every class, match slot lists, expand calls. + +No production codec, source DP, weighted suffix DP or owner resolver is imported. +Prepared for CubeJerry with substantial OpenAI assistance. Apache-2.0. +""" +from collections import Counter, defaultdict +from dataclasses import dataclass +from itertools import product +from math import gcd, prod + + +@dataclass(frozen=True) +class Row: + replication: int + width: int + leaves: int + units: int + + +class LiteralFlow: + def __init__(self, roles, rounds, owned, ambient, rank, cap=100000): + self.roles, self.rounds, self.owned = roles, rounds, owned + self.ambient, self.rank = ambient, rank + self.types = tuple(sorted({k for _, k in roles})) + type_index = {k: i for i, k in enumerate(self.types)} + threshold, self.height = ambient, 0 + while threshold*min(self.types) <= rank: + threshold *= min(self.types) + self.height += 1 + points = [] + for degree in range(self.height+1): + if len(roles)**degree > cap: + raise ValueError('literal role-word capacity') + counts = Counter() + for word in product(range(len(roles)), repeat=degree): + alpha = [0]*len(self.types) + for letter in word: + alpha[type_index[roles[letter][1]]] += 1 + counts[tuple(alpha)] += 1 + points.append(sorted(counts.items())) + self.classes, self.owners, self.fresh = {}, {}, [] + self.units = 0 + + def construct(path, incoming=None): + rho = prod(rounds[j][0] for j in path) + units, buckets = [], defaultdict(list) + for alpha, count in points[self.height-len(path)]: + column = prod(k**a for k, a in zip(self.types, alpha)) + if ambient*rho*column > rank: + continue + for ordinal in range(count): + unit = path, alpha, ordinal + units.append(unit) + for name, k in roles: + slot = unit+(name,) + beta = list(alpha) + beta[type_index[k]] += 1 + buckets[tuple(beta)].append(slot) + self.units += len(units) + if self.units > cap: + raise ValueError('literal unit capacity') + self.classes[path] = units + if incoming is not None: + for alpha, supply in incoming.items(): + targets = buckets[alpha] + if len(supply) != len(targets): + raise ValueError('literal Pascal list mismatch') + for value, target in zip(supply, targets): + self.owners[target] = value + for unit in units: + for name, k in roles: + slot = unit+(name,) + if slot not in self.owners: + self.owners[slot] = ('source', slot) + self.fresh.append((slot, rho*prod(t**a for t, a in + zip(self.types, unit[1]))*k)) + if len(path) < self.height: + for j, (_, name) in enumerate(rounds): + supply = defaultdict(list) + for unit in units: + value = (('owned', unit, name) if name in owned else + self.owners[unit+(name,)]) + supply[unit[1]].append(value) + construct(path+(j,), supply) + construct(()) + self.fresh_index = {slot: i for i, (slot, _) in enumerate(self.fresh)} + if len(rounds)**(self.height+1) > cap: + raise ValueError('literal cut capacity') + self.cuts = tuple(product(range(len(rounds)), repeat=self.height+1)) + + def exit(self, cut): + unit = self.classes[cut[:-1]][0] + if len(self.classes[cut[:-1]]) != 1 or any(unit[1]): + raise ValueError('deepest single-unit condition') + name = self.rounds[cut[-1]][1] + value = (('owned', unit, name) if name in self.owned else + self.owners[unit+(name,)]) + return prod(self.rounds[j][0] for j in cut), value + + +def library(roles, rounds, owned, ambient, maximum): + rows, flows = [None], {} + for n in range(1, maximum+1): + if n < ambient: + rows.append(Row(1, 1, n, 0)) + continue + flow = LiteralFlow(roles, rounds, owned, ambient, n) + flows[n] = flow + sources = Counter(s for _, s in flow.fresh) + batches = [(n-s, count) for s, count in sorted(sources.items()) if s < n] + batches += [(flow.exit(cut)[0], 1) for cut in flow.cuts] + a = 1 + for q, count in batches: + if not 0 < q < n: + raise ValueError('literal rank descent') + factor = rows[q].width//gcd(rows[q].width, count) + a = a//gcd(a, factor)*factor + leaves = sum(a*count//rows[q].width*rows[q].leaves for q, count in batches) + units = a*flow.units+sum(a*count//rows[q].width*rows[q].units + for q, count in batches) + rows.append(Row(a, a*len(flow.fresh), leaves, units)) + return tuple(rows), flows + + +def expand(roles, rounds, owned, ambient, rows, flows, root, namespace='compiler', + leaf_cap=100000): + """Return fully expanded leaf descriptors and whole-call input receipts.""" + if rows[root].leaves > leaf_cap or rows[root].width > leaf_cap: + raise ValueError('literal expanded-program capacity') + leaves, calls = [], [] + + def visit(n, chain, fields): + if len(fields) != rows[n].width or len(set(fields)) != len(fields): + raise ValueError('literal whole-input alias/width') + if n < ambient: + for axis in range(n): + leaves.append((chain, n, axis, fields[0])) + return + flow, a = flows[n], rows[n].replication + + def lift(replica, value): + if value[0] == 'source': + return fields[replica*len(flow.fresh)+flow.fresh_index[value[1]]] + _, unit, role = value + path, point, ordinal = unit + return ('owned', namespace, chain, replica, path, point, ordinal, role) + + def invoke(q, kind, key, batch): + width = rows[q].width + if len(batch) % width: + raise ValueError('literal incomplete child') + for at in range(0, len(batch), width): + step = n, kind, key, at//width + child_chain = chain+(step,) + inputs = tuple(batch[at:at+width]) + calls.append((child_chain, q, inputs)) + visit(q, child_chain, inputs) + + for s in sorted({s for _, s in flow.fresh}): + if s < n: + batch = [fields[b*len(flow.fresh)+i] + for b in range(a) for i, (_, rank) in enumerate(flow.fresh) + if rank == s] + invoke(n-s, 'complement', s, batch) + for cut in flow.cuts: + e, value = flow.exit(cut) + invoke(e, 'exit', cut, [lift(b, value) for b in range(a)]) + + visit(root, (), tuple(('source', namespace, row) for row in range(rows[root].width))) + if len(leaves) != rows[root].leaves: + raise ValueError('literal expanded count') + return leaves, calls diff --git a/research/chronological-leaf-owner-index/reference/FINITE-PRECOMPILATION.md b/research/chronological-leaf-owner-index/reference/FINITE-PRECOMPILATION.md new file mode 100644 index 0000000000..4badb40f09 --- /dev/null +++ b/research/chronological-leaf-owner-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)=m. A depth-h path has paid +product rho; a unit profile of degree G_n-h has target product c and +multiplicity u(alpha). It is present iff `m*rho*c<=n`. Its target k and +paid r jobs have true ranks rho*c*k and rho*c*r. Pascal matching is a +bijection of formal occurrences, never a quotient by equal products. + +The outputs are evaluated binary integers: replication a_n, productive +width B_n, expanded rank-one leaf count P_n and expanded mixed-unit count +O_n. O_n is not peak live storage. If an actual unit contract supplies h +owned fields, h*O_n is a safe no-reuse count, before their physical extent. +Base rows are `a_n=B_n=1, P_n=n, O_n=0` for 1<=n0. (1) +``` + +Proof: A counts all target slots with their complete formal multiplicity. +Every nondeepest paid demand is matched: after removing target factor k, +its child has dilation rho*r and column c/k, and +`m*rho*r*c/k < m*rho*c<=n`. The Pascal identity partitions the parent +occurrences among these child slots, including their first role. Conversely +every matched target slot has this incoming demand at the same true rank. +Subtracting counts leaves exactly the fresh targets, hence S_s>=0. A root +unit of column k_min^G exists, so S>0. This is a universal matching proof; +an executable nonnegativity assertion would not replace it. + +Every deepest path is present because +`rho<=r_max^G<=k_min^G<=n/m`. It has one degree-zero unit and all its paid +jobs exit. Therefore + +``` +E_e=R_(G+1)(e) (2) +``` + +counts distinct one-job cuts of rank e. E_e is not the number of arrays +available at any one cut. These counts agree with the source-row and +complement-port codecs' fresh physical identities; this evaluator does +not enumerate or route their physical rows. + +## 3. Every batch constraint and expanded-count recurrence + +Source complements occur upfront, so each s0} + union {B_e:E_e>0}), +B_n=a_n*S, (3) +P_n=sum_(s=k_min^(G+1)>floor(n/m)` and integrality gives s>n/m. A nonroot +fresh source has a missing parent above the cap; multiplying that parent's +integer product by its positive last paid rank gives the same s>n/m. +Fit gives s<=n. Thus positive complement ranks obey +`n-s<(m-1)n/m`. Each exit obeys `e<=r_max*n/m<=(m-1)n/m`. +Set alpha=(m-1)/m: every recursive edge contracts by alpha. + +Evaluating (1)--(4) for n=1,...,N therefore gives exactly the separated +literal flow's least-chronological library metadata. Native arbitrary-input +correctness, all-column lift, adapters, disjoint splitting and physical +finite closure remain the source's separate hypotheses. + +## 4. Fully evaluated output sizes, without positive rank surplus + +Assume N>=m; otherwise all rows are base rows. For positive x let +ell(x)=bit_length(x). Put L=ell(N), G=G_N, K0=max(W,P), and + +``` +Ubar=(G+1)*K0^G, Sbar=W*Ubar, +F=1+(W+1)*Ubar+P^(G+1), D=m*L. (5) +``` + +Deleting eligibility tests gives +`U_n<=sum_(h=0)^G P^h W^(G-h)<=Ubar`, and hence S_n<=Sbar. +The sum of smaller-batch multiplicities is at most Sbar+P^(G+1). +These bounds hold for every n<=N since G_n<=G. + +### A cited width divisor, with no factorization cost + +Let b count distinct integers >=2 among all target and paid ranks. +The rank semigroup has at most (L+1)^b products <=floor(N/m): each has +a representation whose b generator exponents are <=L. Repeated +representations only loosen this upper bound. Rank one is omitted. + +#4638 proves, for this default policy, the all-prime divisor +`B_n | product_gamma S(gamma)^tau` for every n<=N, over source-count +plateaus up to the cap, with `tau=m*ceil(log2 k_min)`. Substituting the +generator-box and Sbar bounds yields the explicit integer envelope + +``` +beta=tau*(L+1)^b*ell(Sbar), +log2 B_n<=beta, log2 a_n<=beta. (6) +``` + +This uses all primes of the source counts, including new ones absent from +rank factors. No factorization, valuation algorithm or shared unevaluated +expression is used. The sharper multiplicative-rank result of #5962 is +available but unnecessary. Equation (6) instantiates an existing theorem; +it is not a new width asymptotic. It does not apply to the old nested +choice a_n=B_(n-1), which can have Theta(N log N) width bits. + +### Expanded leaves and mixed-unit occurrences + +Set Y_n=(B_n+P_n+O_n)/B_n. From (4), positivity and S>=1, + +``` +Y_n=1+U_n/S+sum_batches(t/S)*(P_q+O_q)/B_q + <=(1+U_n+sum_batches t)*max_child Y_q + <=F*max_child Y_q. (7) +``` + +There is a deepest exit since P>0, so the maximum is nonempty. Base +ratios are n+1<=m. Bernoulli gives alpha^m<1/2; after D=m*ell(N) +contracting edges a positive rank would be below one. Every actual chain +therefore reaches a base rank in at most D edges. Iterating (7) gives + +``` +B_n+P_n+O_n<=B_n*m*F^D, +ell(B_n+P_n+O_n)<=beta+ell(m)+D*ell(F)+1. (8) +``` + +This holds also for formal rules with zero or negative rank surplus. +No saving, moment-root or native-existence assertion is needed. All +replicated child copies remain counted. + +## 5. Record counts and an explicit common bit cap + +The total product-table and current-rank record counts are bounded by + +``` +M_T=binomial(G+d,d), M_R=binomial(G+q+1,q), +V=binomial(G+d+q-1,d+q-1), E=binomial(G+q,q-1). (9) +``` + +M_T covers target degrees 0..G; M_R covers paid degrees 0..G+1. For +h+g=G, stars and bars and convolution give at most V product pairs, +including rejected fits. The signed source list has at most (d+q)V +contributions before deduplication; E bounds distinct exits. Coincident +products do not increase these bounds. G=0 and singleton alphabets are +included in the displayed formulas. + +Let S_bit encode both nonempty lists as Gamma(list length), followed by +Gamma(rank) and Gamma(multiplicity) for each entry. This counts supplied +histogram bits, not an independently supplied native word. Define + +``` +K=(S_bit+1)^2+d*M_T+q*M_R + +(N+1)*((d+q+2)*V+E+G+2), +Z=8*(S_bit+L+(G+2)*ell(m+W+P+2) + +beta+ell(m)+D*ell(F)+ell(K)+2), +J=M_T+M_R+(d+q+2)*V+E+G+S_bit+2, +L_local=J*Z. (10) +``` + +Z bounds ordinary integer fields and arithmetic temporaries. Word-product +keys are at most m^(G+1). Weighted counts are at most the corresponding +powers of W and P. All target contributions together are <=W*Ubar; +matched incoming contributions are no larger, so signed partial sums +have magnitude <=2*W*Ubar. Equations (6)--(8) bound library values. +Division numerators such as a*S_s have at most the sum of operand bit +lengths, while each nonnegative completed summand is <=its final sum. +Loop counters and record addresses are covered by L, S_bit and ell(K). +Binomial bounds can be computed by successive exact multiply/divide +steps, whose intermediates add at most one factor's length. The generous +factor eight absorbs these fixed additions. No bound is emitted in unary. + +Build each T/R degree by generating fixed-rank extensions, sorting and +adding equal keys. At most d*M_T+q*M_R records are generated. At each n, +enumerate (9), aggregate signed source records by sorting, and evaluate +(3)--(4) against the earlier completed library rows. All zero candidates, +all actual recursive ranks and every chronological exit divisor are paid. + +## 6. Indexed and sequential construction models + +### Indexed metadata + +Specify indexed storage explicitly: fetching/storing an O(Z)-bit record +with an O(Z)-bit address costs O(Z) bit work. Schoolbook multiplication +and division cost O(Z^2). Euclid takes O(Z) divisions, so a conservative +gcd charge is O(Z^3). Comparison sorting k records costs O(k log k) +comparisons; log k=O(Z), so its bit bill fits O(k Z^2). Thus + +``` +T_indexed=O(K*Z^3). (11) +``` + +The reference integer operations can be replaced by these elementary +algorithms. This is not a literal CPython-runtime guarantee or a claim +of free random access to native payloads. + +### Sequential companion, with library access charged + +Keep completed library rows in an append-only sequence with rank tags. +For every child access, scan at most N records, copy the selected row to +arithmetic tapes, and return the library head. Comparisons, copying and +return together cost O(N*Z). The earlier child values remain immutable. + +Keep product tables and current-rank contributions in fixed local regions +of total extent O(L_local). Full scans and insertion sorting, including +copies, counter updates and head resets, cost at most O(L_local^2) per +generated record or recurrence operation. Elementary arithmetic uses +O(Z) workspace and O(Z^3) time per operation. Erase and reuse the same +local regions; their historical backing remains charged. These explicit +scan recipes give a fixed-number-of-tapes companion with + +``` +T_sequential=O(K*(N*Z+L_local^2+Z^3)). (12) +``` + +Python list access is not asserted to be a tape instruction. The four +library values, rank tags and work regions use O((N+J)*Z) historical +cells. Optionally retaining every per-rank source/exit census adds at +most O(K*Z) output bits; their writing fits both time bounds and their +backing is retained. Neither erasure nor streaming makes written output +free. Uniform parsing, validation and bound setup fit the S_bit term and +the explicitly counted arithmetic; alphabet-size dependence is retained. + +For each fixed rule, G=O(log N) and all parameters in (9)--(10), apart +from N in K, are fixed powers of log N. Thus the indexed bound is +N*polylog N and the sequential bound is N^2*polylog N. Every output is a +fully evaluated integer of polylogarithmic bit length. Constants and +powers depend on the fixed rule through the displayed formulas. This +is not polynomial in log N: the output contains N library rows. + +## 7. Scope and remaining obligations + +This quantitatively evaluates the complete formal rank-induction +metadata for the separated default-height least-chronological policy. +It includes every source complement and each original exit divisor, +without enumerating P^G paid paths or W^G unit slots. The new computation +uses the existing width theorem; the normalized count estimate also +bounds expanded leaves/units when no positive rank surplus is assumed. + +Actual scalar-word size is not determined by rank counts. It additionally +depends on the native word's instruction/constant encodings and on +whole-job adapter production. Such production bounds must be supplied +before an encoded native word or its physical runtime can be bounded. +An evaluated B_q is not proof of a valid smaller program. No arrays are +routed by this evaluator, and the native/all-column, ownership, precision, +fixed-tape payload, analytic and outer interfaces remain conditional. +No selected astronomical rank library or 1920-fold word is materialized. +There is no new kappa or foundational assumption discharge. + +Credit #4507/#5071 for batch recurrences, #4638/#5962 for width envelopes, +Jacob Alan Sussman and zxv for the lockstep/Pascal flow, and the published +source-row/port packages for exact occurrence binding. All original source +notices are retained. Prepared for CubeJerry with substantial OpenAI +assistance; independent human or proof-kernel acceptance is not claimed. diff --git a/research/chronological-leaf-owner-index/reference/source-port-PROOF.md b/research/chronological-leaf-owner-index/reference/source-port-PROOF.md new file mode 100644 index 0000000000..18592cc2a9 --- /dev/null +++ b/research/chronological-leaf-owner-index/reference/source-port-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<=b0, 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/chronological-leaf-owner-index/verify.py b/research/chronological-leaf-owner-index/verify.py new file mode 100644 index 0000000000..2279035777 --- /dev/null +++ b/research/chronological-leaf-owner-index/verify.py @@ -0,0 +1,248 @@ +"""Bounded exact program expansion and failure controls; no native admission.""" +import argparse +from dataclasses import replace +from hashlib import sha256 +from importlib.util import module_from_spec, spec_from_file_location +import json +from pathlib import Path +import sys +import types + +HERE = Path(__file__).resolve().parent +sys.path.insert(0, str(HERE)) + + +def require(condition, message): + if not condition: + raise ValueError(message) + + +def load(name, path): + spec = spec_from_file_location(name, path) + module = module_from_spec(spec) + sys.modules[spec.name] = module + spec.loader.exec_module(module) + return module + + +def steps(seq): + return tuple((s.parent, s.kind, s.key, s.invocation) for s in seq) + + +def field(value): + if hasattr(value, 'row'): + return ('source', value.namespace, value.row) + return ('owned', value.namespace, steps(value.calls), value.replica, + value.path, value.point, value.ordinal, value.role) + + +def leaf(value): + return steps(value.calls), value.rank, value.axis, field(value.field) + + +CASES = ( + ((('x', 2),), ((1, 'x'),), (), 2, 12), + ((('x', 2), ('y', 3)), ((1, 'x'), (1, 'bank')), ('bank',), 3, 12), + ((('x', 3), ('y', 5)), ((1, 'x'), (2, 'bank'), (2, 'y')), ('bank',), 5, 16), + ((('x', 2), ('y', 2), ('z', 4)), ((1, 'x'), (1, 'bank'), (1, 'y')), ('bank',), 4, 12), + ((('x', 2), ('y', 3)), ((1, 'x'), (1, 'bank')), ('bank',), 6, 14), + ((('high', 8), ('low', 4), ('mid', 4)), + ((2, 'low'), (3, 'private'), (2, 'private'), (1, 'high')), ('private',), 8, 12), +) + + +def run(): + manifest = json.loads((HERE/'SOURCES.json').read_text()) + for source in manifest['files']: + data = (HERE/source['local']).read_bytes() + require(sha256(data).hexdigest() == source['sha256'], 'source byte pin') + require(sha256(b'changed'+data).hexdigest() != source['sha256'], 'source mutation') + X = load('checked_leaf_index', HERE/'leaf_index.py') + O = load('independent_literal_oracle', HERE/'literal_oracle.py') + L = load('retained_rank_library', HERE/'inputs/library.py') + totals = {'ranks': 0, 'leaves': 0, 'calls': 0, 'ports': 0, + 'owned_leaves': 0, 'cross_replica_complements': 0} + records, fixtures = [], [] + digest = sha256() + for roles, rounds, owned, ambient, maximum in CASES: + rows, flows = O.library(roles, rounds, owned, ambient, maximum) + rule = X.C.Rule(roles, rounds, owned, ambient) + engine = X.Compiler(rule, rows) + if ambient == max(k for _, k in roles): + target = tuple((k, sum(t == k for _, t in roles)) for k in sorted({k for _, k in roles})) + paid = tuple((r, sum(t == r for t, _ in rounds)) for r in sorted({r for r, _ in rounds})) + old = L.compile_library(L.Rule(target, paid), maximum) + require([(r.replication, r.width, r.leaves, r.units) for r in rows[1:]] == + [(r.replication, r.width, r.leaves, r.units) for r in old.rows[1:]], + 'separate complete rank library') + count = 0 + for n in range(1, maximum+1): + expected, calls = O.expand(roles, rounds, owned, ambient, rows, flows, n) + for ordinal, want in enumerate(expected): + got = engine.locate(ordinal, n) + require(leaf(got) == want, 'complete expanded leaf/owner order') + require(engine.rank_leaf(got, n) == ordinal, 'ordinal inverse') + totals['owned_leaves'] += int(want[3][0] == 'owned') + digest.update((repr(want)+'\n').encode()) + for chain, q, inputs in calls: + path = tuple(X.Step(*s) for s in chain) + actual = tuple(field(engine.resolve_row(path, row, n)) + for row in range(len(inputs))) + require(actual == inputs, 'nested whole-child port vector') + require(len(set(actual)) == len(actual), 'whole-input nonaliasing') + totals['ports'] += len(inputs) + if n >= ambient: + node = engine.node(n) + for source, _, _ in node.prefixes: + q, width = n-source, rows[n-source].width + size = node.groups.count(source) + for invocation in range(node.complements.invocations(source)): + first, last = invocation*width, (invocation+1)*width-1 + totals['cross_replica_complements'] += int(first//size != last//size) + for cut in flows[n].cuts: + for b in range(rows[n].replication): + owner = node.exit_owner(cut, b) + invocation, slot = node.exit_port(cut, owner) + step = X.Step(n, 'exit', cut, invocation) + require(node.caller_owner(step, slot) == owner, + 'exit cut owner/port inverse') + totals['ranks'] += 1 + totals['calls'] += len(calls) + totals['leaves'] += len(expected) + count += len(expected) + records.append({'ambient': ambient, 'maximum': maximum, + 'roles': roles, 'rounds': rounds, 'leaves': count}) + fixtures.append((roles, rounds, owned, ambient, rows, flows, maximum)) + + controls = [] + + def rejects(label, action): + try: + action() + except (ValueError, TypeError, IndexError): + controls.append(label) + return + raise ValueError('negative control accepted: '+label) + + roles, rounds, owned, a, rows, flows, n = fixtures[1] + engine = X.Compiler(X.C.Rule(roles, rounds, owned, a), rows) + item = engine.locate(rows[n].leaves-1) + rejects('negative leaf', lambda: engine.locate(-1)) + rejects('one-past leaf', lambda: engine.locate(rows[n].leaves)) + rejects('wrong base axis', lambda: engine.rank_leaf(replace(item, axis=item.rank))) + rejects('wrong physical return', lambda: engine.rank_leaf(replace(item, field=X.SourceRow('wrong', 0)))) + rejects('rank-zero program', lambda: engine.row(0)) + rejects('missing complete cut', lambda: engine.node(n).exit_rank(())) + rejects('wrong child row', lambda: engine.resolve_row(item.calls, 1)) + rejects('zero complement call', lambda: engine.node(n).step_data(X.Step(n, 'complement', n, 0))) + bad = list(rows) + bad[n] = replace(bad[n], leaves=bad[n].leaves+1) + rejects('wrong expanded leaf total', lambda: X.Compiler(engine.rule, bad).node(n)) + bad = list(rows) + bad[1] = replace(bad[1], width=2) + rejects('wrong sequential base', lambda: X.Compiler(engine.rule, bad)) + + # Distinct cuts can revisit the SAME field. Only the qualified descriptor + # is invertible; a global field->leaf map would be false. + same_rule = X.C.Rule((('x', 2),), ((1, 'x'), (1, 'x')), ()) + same_rows, _ = O.library(same_rule.roles, same_rule.rounds, (), 2, 2) + same = X.Compiler(same_rule, same_rows) + left, right = same.locate(0), same.locate(1) + require(left.field == right.field and left.calls != right.calls, + 'same owner at distinct chronological cuts') + require(same.rank_leaf(left) != same.rank_leaf(right), 'cut qualification necessary') + controls.append('owner-only key loses a leaf') + + # Source-preserving mutations of NEW code are checked against the separate + # explicit recursive expansion, not against a second run of the index. + original = (HERE/'leaf_index.py').read_text() + mutations = ( + ('drop repeated paid-site multiplicity', + 'sum(count*self.suffix[h+1, rho*r]', 'sum(self.suffix[h+1, rho*r]'), + ('merge chronological cuts', 'path += (chosen,)', 'path += (0,)'), + ('merge replicas at exit', + 'replica = step.invocation*self.compiler.row(e).width+child_row', + 'replica = child_row'), + ('drop owned invocation namespace', 'calls[:at], replica,', '(), replica,'), + ) + for number, (label, old, new) in enumerate(mutations): + require(original.count(old) == 1, 'unique mutation seam') + mutant = types.ModuleType('leaf_mutant_'+str(number)) + mutant.__file__ = str(HERE/'leaf_index.py') + sys.modules[mutant.__name__] = mutant + exec(compile(original.replace(old, new), mutant.__file__, 'exec'), mutant.__dict__) + detected = False + for roles, rounds, owned, ambient, rows, flows, maximum in fixtures[1:4]: + try: + machine = mutant.Compiler(mutant.C.Rule(roles, rounds, owned, ambient), rows) + expected, _ = O.expand(roles, rounds, owned, ambient, rows, flows, maximum) + for ordinal, want in enumerate(expected): + if leaf(machine.locate(ordinal)) != want: + detected = True + break + except ValueError: + detected = True + if detected: + break + require(detected, 'undetected semantic mutation: '+label) + controls.append(label) + + # Large chronological cut set, with a direct base-eight/last-owned oracle. + n, paid_count = 4096, 8 + roles = (('x', 2),) + rounds = tuple((1, 'bank' if j % 3 == 1 else 'x') for j in range(paid_count)) + lib = L.compile_library(L.Rule(((2, 1),), ((1, paid_count),)), n) + engine = X.Compiler(X.C.Rule(roles, rounds, ('bank',)), lib.rows, 'large-cuts') + node = engine.node(n) + size = lib.rows[n].leaves + require(size == paid_count**(node.height+1), 'large explicit cut count') + samples = sorted({0, 1, 7, 8, 9, size//3, size//2, size-2, size-1, 123456789}) + for ordinal in samples: + value, cut = ordinal, [0]*(node.height+1) + for j in range(node.height, -1, -1): + value, cut[j] = divmod(value, paid_count) + cut = tuple(cut) + got = engine.locate(ordinal) + want_call = ((n, 'exit', cut, 0),) + bank = next((j for j in range(node.height, -1, -1) + if rounds[cut[j]][1] == 'bank'), None) + want_field = (('source', 'large-cuts', 0) if bank is None else + ('owned', 'large-cuts', (), 0, cut[:bank], + (node.height-bank,), 0, 'bank')) + require(leaf(got) == (want_call, 1, 0, want_field), 'large direct path/owner oracle') + require(engine.rank_leaf(got) == ordinal, 'large ordinal inverse') + large = {'rank': n, 'leaves': size, 'chronological_cuts': size, + 'suffix_states': len(node.suffix), 'source_states': len(node.groups.states), + 'queries': len(samples), 'expanded': False} + + # Independent explicit fields above are supplemented by a large replication + # query; no enumeration or native interpretation is attached to this case. + lib = L.compile_library(L.Rule(((3, 1), (5, 1)), ((1, 1), (2, 2))), 256) + engine = X.Compiler(X.C.Rule((('x', 3), ('y', 5)), + ((1, 'x'), (2, 'bank'), (2, 'y')), ('bank',)), lib.rows) + row = lib.rows[-1] + positions = [0, 1, row.leaves//3, row.leaves//2, row.leaves-2, row.leaves-1] + for ordinal in positions: + require(engine.rank_leaf(engine.locate(ordinal)) == ordinal, 'large replica round trip') + replication = {'rank': 256, 'replication': row.replication, 'width': row.width, + 'leaves': row.leaves, 'queries': len(positions), 'expanded': False} + require(totals['cross_replica_complements'] > 0, 'cross-replica coverage') + return {'status': 'PASS_CHRONOLOGICAL_LEAF_OWNER_INDEX', 'totals': totals, + 'fixtures': records, 'expanded_trace_sha256': digest.hexdigest(), + 'negative_controls': controls, 'large_cut_fixture': large, + 'large_replication_fixture': replication, 'new_kappa': None} + + +if __name__ == '__main__': + parser = argparse.ArgumentParser() + parser.add_argument('--write', action='store_true') + args = parser.parse_args() + # JSON is the receipt's declared representation; tuples in input fixtures + # are normalized to arrays before comparing, without changing science. + result = json.loads(json.dumps(run(), sort_keys=True)) + destination = HERE/'VALIDATION.json' + if args.write: + destination.write_text(json.dumps(result, indent=2, sort_keys=True)+'\n') + else: + require(result == json.loads(destination.read_text()), 'committed receipt disagreement') + print(json.dumps(result, sort_keys=True))