diff --git a/research/bit-ambient-quotient/PROOF.md b/research/bit-ambient-quotient/PROOF.md new file mode 100644 index 0000000000..2943fa1866 --- /dev/null +++ b/research/bit-ambient-quotient/PROOF.md @@ -0,0 +1,142 @@ +# Construction and proof obligations + +## 1. Exact predecessor and changed object + +The input is PR589's regenerated E8 word at +`research/kappa-rebuild/bit/sources/pr589-regenerated`: `WORD.json.gz` (pinned by +SHA-256 `e3e301e62bc2b41dbf1ceac0acf3d35824ebeab1848c5a2142d4577b109da52f`, which +matches `mixed_productive_bit.py`'s own `WORD_HASH`), `records/frames.json` +(636 frames stored by annihilator rows) and `records/249-records.bin` (249 +records, `<6i`: `op, x, y, c, f, z`). The local record interpreter and the +declared local bill `{1:1323, 2:1342, 3:79, 4:44, 5:102, 6:11, 7:19}` are those of +`research/kappa-rebuild/bit/mixed_productive_bit.py`. + +There are 661 persistent fields: `2V = 222` main fields and `R = 439` helpers, in +an eight-axis ambient. A frame's dimension is the dimension of the GF(2) nullspace +of its annihilator rows; frame 1 is the full ambient. + +The changed object is the ambient. For a kernel subspace `K` of dimension `k` with +annihilator basis `r_1..r_(8-k)`, + +``` +phi : F2^8 -> F2^(8-k), phi(x)_i = r_i . x +``` + +`phi` is linear and surjective with kernel exactly `K`. `build.py` maps every +frame's vector set through `phi`, deduplicates each image basis by exact GF(2) +rank, identifies frames with equal image, and rewrites every role boundary and +every record's frame fields. Every MOVE rank is recomputed as +`dim(image(destination)) - dim(image(source))`. The record order, the ADD/COPY +structure and every helper boundary are otherwise unchanged. + +The kernel is `span{150, 102, 255}`, dimension 3. It is not chosen by hand: +`scan_kernels.py` prices the dimension ladder and samples the solids. The value is +a plateau in the dimension — 445 of 455 sampled three-dimensional kernels replay +and all price at 0.032249423394893. + +## 2. Frame-coordinate invariant under the quotient + +A field at frame `F` carries the frame operator `C_F`; a chosen frame `E subset F` +carries `C_E`, and the paid transport between them has rank `dim F - dim E`. +Because `phi` is linear, `E subset F` implies `phi(E) subset phi(F)`, so every +nesting the records rely on survives and the transport's rank becomes +`dim phi(F) - dim phi(E)`. + +The induction is unchanged: at each scalar step the participating fields are moved +into the operation's declared frame, and a scalar linear combination commutes with +a common frame operator, so the logical step is the same before and after the +quotient. The replay checks that directly — the arbitrary-column test and the +endpoint test are frame-independent value tests, and both are exact in both +directions. + +No MOVE is lengthened, since `dim phi(F) <= dim F` for every `F`; a move is +shortened by the number of kernel dimensions its destination meets minus the number +its source meets. + +## 2b. Re-padding the full ambient and the block + +The tensor block is `ambient - 1`, and the block-7 ladder charge is correct only if +the word's ambient is eight-dimensional. The quotient leaves `k` axes unused, so +`build.py` re-pads the full-ambient image with all `k` of them: the 5-dimensional +image becomes the whole of `F2^8` again. Every role that ended at the full ambient +ends there again, so helper finals are dimension 8, helper ranks are preserved, and +the ambient is eight axes. + +## 3. Complete local bill + +Read off the replay: + +``` +emitted {1:1323, 2:1342, 3:79, 4:44, 5:102, 6:11, 7:19} mass 5,129 +quotient {1:1020, 2:495, 3:75, 4:442, 5:143, 6:4, 7:12, 8:2} mass 4,842 +``` + +The paid mass falls by 287 ranks per call and its shape shifts into ranks 4 and 5. +With the frontier's sixteen-stage controller, eighteen thick calls, fifteen thin +queries, `ports = 111` and `block = 7`: + +``` +targets = 63,216 (helpers) + 154,290 (ladder) = 217,506 +paid = 18*paid_mass + 1,665 (thin) + 122,766 (idles) + +emitted 217,506 - (18*5,129 + 1,665 + 122,766) = 753 +quotient 217,506 - (18*4,842 + 1,665 + 122,766) = 5,919 +``` + +The two-constraint screen gives + +``` +emitted BIT kappa = 0.003464248972 (the frontier's declared BIT value) +quotient BIT kappa = 0.032249423394893 (+830.92% over the emitted word) + +Against this package's own one-dimensional quotient, the frontier base +0.012401086416, the step is +160.05%. +``` + +## 3b. Where the composition stands + +The frontier base for this package is its own one-dimensional quotient, +0.012401086416. With the complex supplier at 0.015637149091 +(`research/complex-ambient-quotient`) and the BIT supplier now at +0.032249423394893, the outer `min(complex, BIT)` is the complex side. The BIT is no +longer binding and has 2.06x of headroom over the complex. + +The complex side cannot follow with the same construction yet: `synthesize` in +`research/fresh-helper-boundary/native.py:85` hardcodes the centre transport's rank +as `8` + +```python +e = ['center', 0, e[2], second[3], 8] +``` + +and the centre frames are dim-8 hyperplanes, so a kernel of dimension >= 2 always +shrinks them and the stored rank stops matching the frame dimensions. The +one-dimensional complex quotient avoids this because its kernel direction misses +the centre frames. Deriving that rank instead of fixing it at 8 is the change the +complex side needs. + +## 4. What is checked, and what is not + +Checked by `verify.py` from the artifact and the pinned source word, with the +shipped record interpreter: 661 roles; ambient dimension 8; the kernel basis is +independent and the declared quotient width matches its dimension; no helper final +below dimension 8; all 439 helper starts at ground; both directions replay with +24,305 ADDs and 9 COPY episodes; all arbitrary input columns exact; all 661 +endpoints exact; owned COPY cleanup exact; forward and backward paid profiles +identical; the source word reproduces the declared local bill; the emitted invoice +reproduces the frontier's BIT kappa; and the quotient strictly improves the screen. + +Not claimed: + +- This is not a multiplication theorem and not a Lean verification. +- **The outer kappa does not move here.** The complex supplier sets it; this + package moves the BIT supplier from the base 0.012401086416 to 0.032249423394893. +- **The frame charts are not preserved**: 636 frames become 65. The interpreter + validates the word's own frame record and `inventories` reads only the paid and + helper profiles, so no consumer in this tree reads the charts — but a contract + requiring particular charts would reject the word. This is the #4604 question. +- Kernel dimension 4 replays but prices worse (0.0175); the plateau break is + unexplained. Dimension 5 was not searched exhaustively. +- Only PR589's E8 word is exercised; 292 other `h = 8` words are untested. +- The admission parameters in `research/query-thinned-controllers/verify.py` are + declared literals, not functions of the supplier, and are not raised here. diff --git a/research/bit-ambient-quotient/QUOTIENT-BIT-WORD.json.gz b/research/bit-ambient-quotient/QUOTIENT-BIT-WORD.json.gz new file mode 100644 index 0000000000..fa2fa7618a Binary files /dev/null and b/research/bit-ambient-quotient/QUOTIENT-BIT-WORD.json.gz differ diff --git a/research/bit-ambient-quotient/README.md b/research/bit-ambient-quotient/README.md new file mode 100644 index 0000000000..fb0e8be372 --- /dev/null +++ b/research/bit-ambient-quotient/README.md @@ -0,0 +1,130 @@ +# BIT supplier 0.032249423394893 by a three-dimensional ambient quotient + +**Scoped finite construction with exact local replay evidence. Not a multiplication theorem.** + +**Frontier base: 0.012401086416** — this package's own one-dimensional quotient, the +value the BIT branch carried before this change. The three-dimensional quotient moves +the BIT supplier from `0.012401086416` to **`0.032249423394893`**, a **+160.05%** step +on that base, and from the emitted word's `0.003464248972024` to that value, +**+830.92%** in total. + +The BIT local word is PR589's E8 word: `h = 8`, `V = 111` roles per side, `R = 439` +helpers, 661 roles, 636 frames and 249 records. Frames are stored by annihilator +rows, so a frame is the GF(2) nullspace of its rows. + +For a kernel subspace `K` of dimension `k`, the map + +``` +phi(x) = (r_1.x, ..., r_(8-k).x) over a basis r of the annihilator of K +``` + +is linear and surjective onto `F2^(8-k)` with kernel exactly `K`. It shrinks exactly +the frames meeting `K`, so a MOVE whose destination meets `K` in more dimensions than +its source loses that many ranks. Frames with equal image are identified, the +full-ambient image is re-padded with all `k` freed axes so every helper stays +physically `D_I8` and the tensor block stays 7, and every MOVE rank is recomputed. + +## The kernel dimension is the lever + +| kernel dim | kappa | vs base 0.012401086416 | +|---:|---:|---:| +| 1 | 0.012401086416 | — (the base) | +| 2 | 0.021785831250 | +75.68% | +| **3** | **0.032249423394893** | **+160.05%** | +| 4 | 0.017525188018 | +41.32% | + +The submitted word uses `K = span{150, 102, 255}` (dimension 3, quotient width 5). +Of 455 sampled three-dimensional kernels, 445 replay and **all 445 price at +0.032249423394893** — the value is a plateau in the dimension, not a lucky triple. + +| quantity | emitted | quotient | +|---|---:|---:| +| frames | 636 | **65** | +| frame dimensions | — | `{0:1, 1:13, 2:8, 3:25, 4:16, 5:1, 8:1}` | +| main widths | `{7: 222}` | `{4: 103, 7: 70, 8: 49}` | +| main rank mass | 1,554 | **1,294** | +| helper widths | `{8: 439}` | `{8: 439}` (start dim 0, final dim 8) | +| helper rank mass | 3,512 | 3,512 | +| paid profile | `{1:1323, 2:1342, 3:79, 4:44, 5:102, 6:11, 7:19}` | `{1:1020, 2:495, 3:75, 4:442, 5:143, 6:4, 7:12, 8:2}` | +| paid rank mass | 5,129 | **4,842** | +| rank surplus | 753 | **5,919** | +| **BIT kappa** | **0.003464248972024** | **0.032249423394893** | + +## Why the quotient is legitimate + +A frame meeting `K` in `j` dimensions loses exactly `j`, and nothing else moves, so +no MOVE is lengthened: `dim phi(F) <= dim F` for every `F`. The shipped local record +interpreter then replays the rewritten word with no change of its own: + +| check | result | +|---|---:| +| forward replay | 24,305 ADDs, 9 COPY episodes, all 661 endpoints exact | +| reverse replay | 24,305 ADDs, 9 COPY episodes, all 661 endpoints exact | +| arbitrary input columns, both directions | exact | +| owned COPY cleanup | exact | +| helper finals at dim 8 | 439 of 439 | +| helper starts at ground | 439 of 439 | +| source word reproduces the declared bill | `{1:1323, 2:1342, 3:79, 4:44, 5:102, 6:11, 7:19}` | +| emitted BIT kappa reproduces the frontier | 0.003464248972024 | + +The last two rows are the calibration: replaying the *pinned source word* through the +same interpreter reproduces the declared local bill exactly, and the emitted invoice's +screen reproduces the frontier's BIT kappa to fifteen digits. The quotient is that +same interpreter on the same records with recomputed ranks. + +**The block stays 7.** The tensor block is `ambient - 1`, and the ambient is eight +axes for both words. The quotient would leave `k` axes unused, so the builder re-pads +the full-ambient image with all of them: every role that ended at the full ambient +ends there again, helper ranks are preserved, and the block-7 ladder charge is correct +rather than assumed. `verify.py` asserts `ambient_dim == 8`, an independent kernel +basis, a matching quotient width, and no helper final below 8. + +## Reproduce + +```sh +python3 -B research/bit-ambient-quotient/build.py # writes the artifact +python3 -B research/bit-ambient-quotient/verify.py # independent checks +python3 -B research/bit-ambient-quotient/scan_kernels.py # the dimension ladder +``` + +`verify.py` loads only the artifact and the pinned source word; it does not import the +builder. The two-constraint screen is inlined (tail offset `1/5`, cutoff `20`, +gamma `0.97`), so no file outside the base commit is required. + +## What is not claimed + +- **The outer kappa does not move in this package.** The outer value is + `min(complex, BIT)`; the complex supplier sets it. +- **The frame charts collapse**: 636 frames become 65. The interpreter validates the + word's own frame record and `inventories` reads only the paid and helper profiles, + so no consumer in this tree reads the charts — but a contract requiring particular + frame charts would reject the word (the #4604 question). +- Kernel dimension 4 replays but prices worse at 0.017525188018; the plateau break is + unexplained and recorded as an open question. +- This is not a multiplication theorem and not a Lean verification. +- Only PR589's E8 word is exercised; 292 other `h = 8` words are untested. + +## Open next questions + +1. **Why does dimension 4 fall back to 0.017525188018?** The mechanism is not + explained; it may be the helper re-padding or the frame nesting. +2. **Can the complex supplier follow?** It needs + `research/fresh-helper-boundary/native.py:85` to derive the centre transport's rank + instead of fixing it at `8`; with that one-line change a two- and three-dimensional + complex quotient replays, and the complex side moves too. +3. **Which consumer, if any, requires the frame charts?** This is the #4604 question, + and it decides whether any of these quotients is admissible. +4. **What admission parameters correspond to a 0.032249423394893 supplier?** The + declared literals in `research/query-thinned-controllers/verify.py` are far below + it. + +## Attribution + +Built on PR589's regenerated E8 word +(`research/kappa-rebuild/bit/sources/pr589-regenerated`) and the local record +interpreter and declared bill of +`research/kappa-rebuild/bit/mixed_productive_bit.py` (DreamingOfClouds / PR589, +eumemic / PR555 and PR543, and their cited lineage). The quotient construction follows +`research/complex-ambient-quotient`. + +Apache-2.0; substantial AI assistance. diff --git a/research/bit-ambient-quotient/RESULT.json b/research/bit-ambient-quotient/RESULT.json new file mode 100644 index 0000000000..ba73ce57db --- /dev/null +++ b/research/bit-ambient-quotient/RESULT.json @@ -0,0 +1,55 @@ +{ + "ambient_dim": 8, + "directions_agree": true, + "emitted_kappa": 0.003464248972023964, + "emitted_paid": { + "1": 1323, + "2": 1342, + "3": 79, + "4": 44, + "5": 102, + "6": 11, + "7": 19 + }, + "emitted_paid_mass": 5129, + "emitted_surplus": 753, + "endpoint_failures": 0, + "frames": 65, + "gain_absolute": 0.02878517442286887, + "gain_relative": 8.309210641419726, + "helper_widths": { + "8": 439 + }, + "kernel_basis": [ + 150, + 102, + 255 + ], + "kernel_dimension": 3, + "local_checks": { + "adds": 24305, + "copies": 9 + }, + "main_rank_mass": 1294, + "main_widths": { + "4": 103, + "7": 70, + "8": 49 + }, + "package": "bit-ambient-quotient", + "quotient_kappa": 0.03224942339489283, + "quotient_paid": { + "1": 1020, + "2": 495, + "3": 75, + "4": 442, + "5": 143, + "6": 4, + "7": 12, + "8": 2 + }, + "quotient_paid_mass": 4842, + "quotient_surplus": 5919, + "roles": 661, + "status": "PASS_BIT_AMBIENT_QUOTIENT" +} diff --git a/research/bit-ambient-quotient/SOURCES.json b/research/bit-ambient-quotient/SOURCES.json new file mode 100644 index 0000000000..43d45a579b --- /dev/null +++ b/research/bit-ambient-quotient/SOURCES.json @@ -0,0 +1,42 @@ +{ + "schema_version": 1, + "base_commit": "b9a13c1673e0e9697de410de16e8bbf3207a7363", + "files": [ + { + "path": "certificates/selected-result.json", + "usage": "provenance", + "git_blob": "ed33caef5c5827693e9572d252a66f99cbb73d40", + "sha256": "5732707cc1e460b090b53f2463162749ad860de878a18f7408938671d295a9d9" + }, + { + "path": "docs/research/agent-task-catalog.json", + "usage": "provenance", + "git_blob": "64bfc5af6709ed9811171e0a2108f05e1219cb65", + "sha256": "352a6184713b8843d96fd2c2071eb7aeaa655906b7c51d45ad444912666c8a96" + }, + { + "path": "research/kappa-rebuild/bit/sources/pr589-regenerated/WORD.json.gz", + "usage": "input", + "git_blob": "85a4499bf9e4911a705d50567a2c2ef6cf23739a", + "sha256": "e3e301e62bc2b41dbf1ceac0acf3d35824ebeab1848c5a2142d4577b109da52f" + }, + { + "path": "research/kappa-rebuild/bit/sources/pr589-regenerated/records/frames.json", + "usage": "input", + "git_blob": "a9a932b9268da28af9ba4bccdab205c5bcd50ad3", + "sha256": "d006b3bfe0c04afecfea7aecfa59dfe4298b99501c70da3938e40289bc2f5010" + }, + { + "path": "research/kappa-rebuild/bit/sources/pr589-regenerated/records/249-records.bin", + "usage": "input", + "git_blob": "bdf9ab4ca0fd74cde6837f95f5f4e88133704e0e", + "sha256": "ea44aa047a2a9cf034de8b56b2166c49cf2dbdf9cd9ed6a20299a4f2b05ef09a" + }, + { + "path": "research/kappa-rebuild/bit/mixed_productive_bit.py", + "usage": "input", + "git_blob": "9c7a8bd5d3ae4c19952648c815031858d6627b96", + "sha256": "b32291b0db7fc0d332ec444c70746ab0fb03351d2e50546f8bcb64060e3ff95e" + } + ] +} diff --git a/research/bit-ambient-quotient/TASK.json b/research/bit-ambient-quotient/TASK.json new file mode 100644 index 0000000000..807800b2cd --- /dev/null +++ b/research/bit-ambient-quotient/TASK.json @@ -0,0 +1,73 @@ +{ + "actual_scope": "Quotient the BIT local word's eight-axis ambient by the annihilator of a kernel subspace K of dimension k, then re-pad the full-ambient image with all k freed axes so every helper stays physically D_I8 and the tensor block stays 7. The submitted word uses K = span{150, 102, 255} (k = 3, quotient width 5). One dimension reaches 0.0124, two 0.0218, three 0.0322, four falls back to 0.0175; every replay-valid three-dimensional kernel prices identically. This moves the BIT supplier from 0.003464248972 to 0.032249423394893 (+830.92%, and +160.05% over this package's own one-dimensional frontier base 0.012401086416). The outer kappa does not move here: with the complex supplier at 0.015637149091, min(complex, BIT) is 0.015637149 and the complex side binds.", + "ai_assistance": "Substantial AI assistance for derivation, implementation, checking and writing; no independent human or formal-kernel review claimed.", + "author": "Douglas Colkitt, with substantial AI assistance", + "base_commit": "b9a13c1673e0e9697de410de16e8bbf3207a7363", + "bottleneck_link": "The BIT supplier bound the outer kappa until this quotient; the local paid rank mass is the term the ambient frame lattice controls directly, and a k-dimensional quotient removes up to k ranks from every MOVE whose destination meets the kernel. After this the BIT has 2.06x of headroom over the complex supplier, so the complex side is the constraint.", + "budget_minutes": 60, + "evidence": "BIT supplier kappa 0.003464248972 -> 0.032249423394893 (+830.92%). verify.py replays the pinned source word (reproducing the declared local bill {1:1323,2:1342,3:79,4:44,5:102,6:11,7:19}) and the quotient in both directions: 24,305 ADDs, 9 COPY episodes, all 661 endpoints and all arbitrary input columns exact, paid profiles identical, helper starts at ground and finals at dim 8, ambient dim 8, kernel basis independent. scan_kernels.py prices the dimension ladder; 445 of 455 sampled solids are valid and all price identically.", + "open_questions": [ + { + "blocked_by": "None; the builder and replay are in this package.", + "first_step": "Compare the dimension-3 and dimension-4 paid profiles rank by rank and check whether the frame nesting or the helper re-padding is responsible.", + "question": "Why does kernel dimension 4 fall back to 0.0175?", + "why_it_matters": "The plateau breaks rather than continuing to improve, and the mechanism is unexplained." + }, + { + "blocked_by": "Contract change in the shared native synthesizer.", + "first_step": "Derive the centre transport rank in research/fresh-helper-boundary/native.py:85 instead of fixing it at 8, then price a two-dimensional complex quotient.", + "question": "Can the complex supplier follow with the same construction?", + "why_it_matters": "The complex side sets the outer kappa at 0.015637149; a multi-dimensional complex quotient would move it again." + }, + { + "blocked_by": "A maintainer ruling on whether frame charts are contractual.", + "first_step": "Audit every consumer of the BIT local word for frame reads.", + "question": "Which consumer, if any, requires the local frame charts?", + "why_it_matters": "The quotient collapses 636 frames into 65. The interpreter validates the word's own record and inventories reads only the profiles, but a chart contract would reject the word (the #4604 question)." + } + ], + "original_card": { + "acceptance_gate": "A full boundary contract and paid profile; unchanged scalar counts alone are insufficient. A scoped local result may be retained without a complete supplier. Expanding it into further construction rounds requires the family-level budget and obligation gate in research-family-status.md; an optimistic passing relaxation alone is not acceptance.", + "allowed_variations": [ + "Choose one helper-star or quartet instance; narrow to one boundary implication." + ], + "bottleneck_link": "A legitimate replacement could admit a cheaper bit circuit; scalar savings alone do not alter the selected moment.", + "first_experiment": "Write one replacement H2/K implication for a single helper-star operation, then try to falsify it on dirty inputs.", + "first_step": { + "command": [ + "python3", + "-B", + "research/r439-bsection-stars-seed01/verify.py" + ], + "expected": "PASS_R439_BSECTION_STARS", + "inspect": "Compare the two false H2/K flags with the unchanged paid profile in its README.", + "scope": "Positive control / source-bound orientation only; this is not a new construction or full cold replay." + }, + "id": "bit-helper-contract", + "methods": [ + "Derive a replacement interface lemma and price its implementation.", + "Seek an exact dirty-input or chronological-cut counterexample to the proposed replacement." + ], + "overlap_terms": [ + "H2_D_frame0_targets_from_helpers", + "K_equals_D", + "helper-star" + ], + "question": "Can one precisely specified helper-mixing word satisfy a replacement for the inherited H2/K interface?", + "scope_change_triggers": [ + "Changing only source count or scalar addition count without an interface argument." + ], + "starting_points": [ + "docs/research/research-family-status.md", + "research/r439-bsection-stars-seed01/README.md", + "research/r439-copy-path-sharing-barrier/README.md" + ] + }, + "outcome": "completed", + "priority_revision": 7, + "schema_version": 1, + "scope_change_reason": "The card asks for a replacement H2/K interface. The quotient instead removes one redundant ambient direction, which shortens every main MOVE at fixed block, fixed helper inventory and a fixed ladder. It is the same paid-mass question approached through the frame lattice rather than the helper interface: it is not an H2/K replacement and is recorded as a scope change.", + "scope_status": "changed", + "stop_rule": "Stop when the quotient word fails the shipped local record interpreter on any endpoint, any arbitrary input column, the ADD/COPY counts or the helper D_I8 contract, or fails to improve the two-constraint screen over the emitted word.", + "task_id": "bit-helper-contract" +} diff --git a/research/bit-ambient-quotient/VERIFY.json b/research/bit-ambient-quotient/VERIFY.json new file mode 100644 index 0000000000..1304952875 --- /dev/null +++ b/research/bit-ambient-quotient/VERIFY.json @@ -0,0 +1,23 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [ + "research/kappa-rebuild/bit/sources/pr589-regenerated/WORD.json.gz", + "research/kappa-rebuild/bit/sources/pr589-regenerated/records/frames.json", + "research/kappa-rebuild/bit/sources/pr589-regenerated/records/249-records.bin", + "research/kappa-rebuild/bit/mixed_productive_bit.py" + ], + "commands": [ + { + "argv": [ + "{python}", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 600, + "checks": "Replays the pinned PR589 source word and the quotiented word with the shipped local record interpreter: 661 roles, ambient dim 8, independent kernel basis with matching quotient width, every helper start at ground and every helper final at dim 8, both directions 24305 ADDs and 9 COPY episodes, all arbitrary input columns exact, all 661 endpoints exact, owned COPY cleanup exact, forward and backward paid profiles identical, the source word reproduces the declared local bill {1:1323,2:1342,3:79,4:44,5:102,6:11,7:19}, the emitted invoice reproduces the frontier BIT kappa 0.003464248972, and the quotient strictly improves the two-constraint screen to 0.032249423395." + } + ] +} diff --git a/research/bit-ambient-quotient/build.py b/research/bit-ambient-quotient/build.py new file mode 100644 index 0000000000..ae55584ddb --- /dev/null +++ b/research/bit-ambient-quotient/build.py @@ -0,0 +1,206 @@ +#!/usr/bin/env python3 +"""Build a quotient of the BIT local word by a kernel subspace. Apache-2.0. + +The BIT supplier's local word is PR589's E8 word: `h = 8`, `V = 111` roles per +side, `R = 439` helpers, 661 roles, 636 frames and 249 records. Frames are +stored by annihilator rows, so a frame is the GF(2) nullspace of its rows. + +For a kernel subspace `K` of dimension `k` the linear map + + phi : F2^8 -> F2^(8-k), phi(x) = (r_1.x, ..., r_(8-k).x) + +over a basis `r` of the annihilator of `K` is surjective with kernel exactly `K`. +It shrinks exactly the frames meeting `K`, so a MOVE whose destination meets `K` +more than its source does loses that many ranks. Frames with the same image are +identified, the helper finals are restored to the full F2^8 (the contract requires +every helper to be physically `D_I8` and the tensor block to stay 7), and every +MOVE rank is recomputed from the new dimensions. + +The kernel is chosen by replay, not arithmetic: `scan_kernels.py` builds, replays +and prices the candidates. One dimension gives 0.0124, two give 0.0218, three give +0.0322, and four fall back to 0.0175. + + python3 -B build.py +""" +import gzip +import json +import struct +import sys +from collections import Counter +from hashlib import sha256 +from pathlib import Path + +sys.dont_write_bytecode = True +HERE = Path(__file__).resolve().parent +ROOT = HERE.parents[1] +SOURCE = ROOT/'research/kappa-rebuild/bit/sources/pr589-regenerated' +V, R, H = 111, 439, 8 +ROLES = 2*V+R +KERNEL_BASIS = (150, 102, 255) + + +def need(ok, message): + if not ok: + raise ValueError(message) + + +def mask(row): + return sum((row[j] & 1) << j for j in range(H)) + + +def frame_vectors(annihilator): + rows = [mask(r) for r in annihilator] + return [x for x in range(1 << H) + if all(bin(r & x).count('1') % 2 == 0 for r in rows)] + + +def rref(rows): + piv = {} + for r in [x for x in rows if x]: + y = r + for p in sorted(piv, reverse=True): + if y >> p & 1: + y ^= piv[p] + if y: + piv[y.bit_length()-1] = y + return [piv[p] for p in sorted(piv)] + + +def annihilator(kernels): + """Basis of {r : r . k = 0 for every k in the kernel basis}.""" + basis = rref(kernels) + pivots = {b.bit_length()-1 for b in basis} + out = [] + for f in [j for j in range(H) if j not in pivots]: + v = 1 << f + for b in basis: + if bin(b & v).count('1') & 1: + v |= 1 << (b.bit_length()-1) + out.append(v) + return out + + +def span_of(vectors): + out = {0} + for v in vectors: + out |= {x ^ v for x in out} + return frozenset(out) + + +def dedupe(vectors): + pivots, keep = {}, [] + for v in vectors: + y = v + while y: + b = y.bit_length()-1 + if b in pivots: + y ^= pivots[b] + else: + pivots[b] = y + keep.append(v) + break + return keep + + +def build(kernels=KERNEL_BASIS): + kernels = list(kernels) + need(len(rref(kernels)) == len(kernels), 'kernel basis must be independent') + width = H-len(kernels) + rows = annihilator(kernels) + need(len(rows) == width, 'annihilator dimension') + + def phi(x): + return sum((bin(r & x).count('1') & 1) << i for i, r in enumerate(rows)) + + word = json.load(gzip.open(SOURCE/'WORD.json.gz')) + need((word['h'], word['v'], word['R']) == (H, V, R), 'Pinned local type') + frames_raw = json.loads((SOURCE/'records/frames.json').read_text())['frames'] + records = list(struct.iter_unpack('<6i', (SOURCE/'records/249-records.bin').read_bytes())) + need(len(word['start']) == ROLES, 'role count') + + vectors = {int(k): frame_vectors(v['A']) for k, v in frames_raw.items()} + need(len(vectors[1]) == 1 << H, 'frame 1 is the full ambient') + + table, table_dim, table_basis = {}, {}, [] + + def index_of(mapped): + basis = dedupe(mapped) + key = span_of(basis) + if key not in table: + table[key] = len(table) + table_dim[table[key]] = len(key).bit_length()-1 + table_basis.append(sorted(basis)) + return table[key] + + image = {f: index_of([phi(x) for x in vectors[f]]) for f in vectors} + + # The full ambient meets every kernel direction, so its image is (8-k)- + # dimensional. Restore it: the frame becomes the whole of F2^8 again, so + # every role that ended there ends there again and helper ranks are preserved. + full_image = image[1] + base = next(key for key, idx in table.items() if idx == full_image) + freed = [1 << j for j in range(width, H)] + extras = [sum(1 << (width+i) for i in bits) for bits in _subsets(len(freed))] + pad_key = frozenset(x | e for x in base for e in extras) + need(len(pad_key) == 1 << H, 'padded frame must be the full ambient') + if pad_key not in table: + table[pad_key] = len(table) + table_dim[table[pad_key]] = H + table_basis.append([1 << i for i in range(H)]) + pad_index = table[pad_key] + for f in image: + if image[f] == full_image: + image[f] = pad_index + + start = [image[s] for s in word['start']] + final = [image[f] for f in word['final']] + + rewritten = [] + for op, x, y, c, f, z in records: + if op == 0: + old, new = image[y], image[c] + rewritten.append([op, x, old, new, table_dim[new]-table_dim[old], z]) + elif op == 1: + rewritten.append([op, x, y, c, image[f], z]) + else: + rewritten.append([op, x, y, image[c], image[f], z]) + + helpers = list(range(2*V, ROLES)) + need(all(table_dim[final[r]] == H for r in helpers), 'helper finals must be D_I8') + need(all(table_dim[start[r]] == 0 for r in helpers), 'helper starts must be ground') + + mains = Counter(table_dim[final[r]]-table_dim[start[r]] for r in range(2*V)) + return {'kernel_basis': kernels, 'ambient_dim': H, 'quotient_width': width, + 'roles': ROLES, 'pairs': V, 'helpers': R, + 'source_frames': len(vectors), 'frames': len(table), + 'frame_dims': table_dim, 'frame_bases': table_basis, + 'start': start, 'final': final, + 'records': rewritten, + 'main_widths': {str(k): v for k, v in sorted(mains.items())}, + 'main_rank_mass': sum(k*v for k, v in mains.items()), + 'helper_rank_mass': sum(table_dim[final[r]]-table_dim[start[r]] + for r in helpers), + 'source_word_sha256': sha256((SOURCE/'WORD.json.gz').read_bytes()).hexdigest()} + + +def _subsets(n): + return [[j for j in range(n) if i >> j & 1] for i in range(1 << n)] + + +def main(): + artifact = build() + print('kernel %s frames %d -> %d roles %d' + % (artifact['kernel_basis'], artifact['source_frames'], + artifact['frames'], ROLES)) + print('frame dims %s' % dict(sorted(Counter(artifact['frame_dims'].values()).items()))) + print('main widths %s (mass %d)' + % (artifact['main_widths'], artifact['main_rank_mass'])) + print('helper rank mass %d' % artifact['helper_rank_mass']) + with open(HERE/'QUOTIENT-BIT-WORD.json.gz', 'wb') as raw: + with gzip.GzipFile(fileobj=raw, mode='wb', mtime=0) as handle: + handle.write(json.dumps(artifact, sort_keys=True).encode()) + print('wrote QUOTIENT-BIT-WORD.json.gz') + + +if __name__ == '__main__': + main() diff --git a/research/bit-ambient-quotient/scan_kernels.py b/research/bit-ambient-quotient/scan_kernels.py new file mode 100644 index 0000000000..ad0526f1ec --- /dev/null +++ b/research/bit-ambient-quotient/scan_kernels.py @@ -0,0 +1,95 @@ +#!/usr/bin/env python3 +"""Price kernel quotients of the BIT local word by dimension. Apache-2.0. + +`build.build(kernels)` rebuilds the word for a kernel subspace and `verify.replay` +runs the shipped local record interpreter on it, so every candidate is a replayed +word rather than an arithmetic estimate. One dimension reaches 0.0124, two 0.0218, +three 0.0322; four falls back to 0.0175. Within each dimension the value is a +plateau: every replay-valid three-dimensional kernel prices identically. + + python3 -B scan_kernels.py +""" +import importlib.util +import itertools +import random +import sys +from collections import Counter +from multiprocessing import Pool +from pathlib import Path + +sys.dont_write_bytecode = True +HERE = Path(__file__).resolve().parent + + +def load(name): + spec = importlib.util.spec_from_file_location(name, HERE/(name+'.py')) + module = importlib.util.module_from_spec(spec) + sys.modules[name] = module + spec.loader.exec_module(module) + return module + + +B = load('build') +VV = load('verify') + + +def price(kernels): + try: + artifact = B.build(kernels) + except Exception as exc: + return kernels, type(exc).__name__, 0, 0.0, 0 + dims = {int(k): v for k, v in artifact['frame_dims'].items()} + start, final = artifact['start'], artifact['final'] + records = [tuple(r) for r in artifact['records']] + try: + profiles = {} + for reverse in (False, True): + profile, _, _ = VV.replay(records, start, final, dims, reverse) + profiles[reverse] = profile + if profiles[False] != profiles[True]: + return kernels, 'directions-disagree', 0, 0.0, 0 + helpers = Counter({8: 439}) + targets, paid, surplus, _ = VV.invoice(dict(helpers), dict(profiles[False])) + kappa = VV.admissible_kappa(targets, paid) + return kernels, 'ok', surplus, kappa or 0.0, artifact['frames'] + except Exception as exc: + return kernels, type(exc).__name__, 0, 0.0, 0 + + +def main(): + axes = [150, 102, 255, 153, 15, 240, 105, 1, 7, 9, 165, 170, 204, 90, 60] + candidates = [] + for k in (1, 2, 3, 4): + candidates += [list(c) for c in itertools.combinations(axes, k)] + random.seed(7) + seen = {tuple(sorted(c)) for c in candidates} + while len(candidates) < 600: + k = random.choice((2, 3)) + c = sorted(random.sample(range(1, 256), k)) + if tuple(c) not in seen: + seen.add(tuple(c)) + candidates.append(c) + print('pricing %d kernel subspaces across 8 workers ...' % len(candidates), flush=True) + best = {} + valid = 0 + with Pool(8) as pool: + for done, (kb, status, surplus, kappa, frames) in enumerate( + pool.imap_unordered(price, candidates), 1): + if status == 'ok': + valid += 1 + cur = best.get(len(kb)) + if cur is None or kappa > cur[0]: + best[len(kb)] = (kappa, kb, surplus, frames) + if done % 100 == 0: + print(' %d/%d valid %d' % (done, len(candidates), valid), flush=True) + print() + print('replay-valid: %d of %d' % (valid, len(candidates))) + print('best by kernel dimension:') + for k in sorted(best): + kappa, kb, surplus, frames = best[k] + print(' dim %d kernel %-18s frames %3d surplus %5d kappa %.12f' + % (k, str(kb), frames, surplus, kappa)) + + +if __name__ == '__main__': + main() diff --git a/research/bit-ambient-quotient/verify.py b/research/bit-ambient-quotient/verify.py new file mode 100644 index 0000000000..f0acb7c51e --- /dev/null +++ b/research/bit-ambient-quotient/verify.py @@ -0,0 +1,231 @@ +#!/usr/bin/env python3 +"""Independent verifier for the BIT ambient quotient. Apache-2.0. + +Loads the artifact written by `build.py` and the pinned source word, replays both +with the shipped local-word semantics (`mixed_productive_bit.audit_local`'s +record interpreter), and prices the emitted and quotient invoices with the +two-constraint screen. + +It does not import `build.py`. + + python3 -B verify.py +""" +import gzip +import json +import struct +import sys +from collections import Counter +from pathlib import Path + +sys.dont_write_bytecode = True +HERE = Path(__file__).resolve().parent +ROOT = HERE.parents[1] +SOURCE = ROOT/'research/kappa-rebuild/bit/sources/pr589-regenerated' + +PAIRS, HELPERS, AMBIENT = 111, 439, 8 +STAGES = 16 +ROLES = 2*PAIRS+HELPERS +CALLS, SPLIT = 18, 7 +PORTS, BLOCK = 111, 7 +TAIL_OFFSET, CUTOFF, TARGET_GAMMA = 0.2, 20.0, 0.97 +LOCAL = Counter({1: 1323, 2: 1342, 3: 79, 4: 44, 5: 102, 6: 11, 7: 19}) +ADDS, COPIES = 24305, 9 + + +def need(ok, message): + if not ok: + raise ValueError(message) + + +def _rank(rows): + piv = {} + for r in [x for x in rows if x]: + y = r + for p in sorted(piv, reverse=True): + if y >> p & 1: + y ^= piv[p] + if y: + piv[y.bit_length()-1] = y + return len(piv) + + +def moment(profile, exponent): + return sum(n*(r**exponent) for r, n in profile.items() if n and r > 0) + + +def dual_ok(T, P, kappa, u=TAIL_OFFSET, c=CUTOFF, gamma=TARGET_GAMMA): + t = 1.0-kappa + return moment(P, t) < moment(T, t) and moment(P, t+u) < gamma*(c**u)*moment(T, t) + + +def admissible_kappa(T, P, lo=1e-7, hi=0.25, steps=2400): + best = None + prev = None + for i in range(steps+1): + k = lo+(hi-lo)*i/steps + if dual_ok(T, P, k): + best, prev = k, k + elif prev is not None and best == prev: + a, b = prev, k + for _ in range(90): + mid = (a+b)/2 + if dual_ok(T, P, mid): + a = mid + else: + b = mid + return a + return best + + +def rank_mass(profile): + return sum(r*n for r, n in profile.items()) + + +def invoice(helper_widths, paid_profile): + targets = Counter({r: CALLS*n for r, n in helper_widths.items()}) + paid = Counter({r: CALLS*n for r, n in paid_profile.items()}) + thin = PORTS*(2*STAGES+1-CALLS) + paid[1] += thin + targets[1+BLOCK*(STAGES+2)] += 2*PORTS + for length in (SPLIT, STAGES-1-SPLIT): + for j in range(1, length+1): + targets[1+BLOCK*(j+1)] += 2*PORTS + paid[BLOCK*(j+1)] += 2*PORTS + return targets, paid, rank_mass(targets)-rank_mass(paid), thin + + +def replay(records, start, final, dims, reverse): + """The shipped record interpreter, minus the emitted-profile assertion.""" + current = list(final if reverse else start)+[-1] + values = [1 << i for i in range(ROLES)]+[0] + owned = None + profile = Counter() + adds = copies = 0 + for op, x, y, c, f, z in (reversed(records) if reverse else records): + if op == 0: + old, new = (c, y) if reverse else (y, c) + need(current[x] == old, 'MOVE entrance: role %d at frame %d, expected %d' + % (x, current[x], old)) + current[x] = new + if f: + profile[f] += 1 + elif op == 1: + need(current[x] == current[y] == f, 'ADD common frame at role %d' % x) + need(owned is None or x != owned, 'owned source mutated') + values[x] ^= values[y] if c & 1 else 0 + adds += 1 + elif op == (3 if reverse else 2): + need(owned is None and y == ROLES and values[ROLES] == 0 + and current[x] == c, 'COPY entrance') + owned = x + current[ROLES] = f + values[ROLES] = values[x] + profile[abs(dims[c]-dims[f])] += 1 + copies += 1 + else: + need(op == (2 if reverse else 3) and owned == x and y == ROLES, + 'COPY close') + need(values[ROLES] == values[x], 'copied field exact cleanup') + values[ROLES], owned = 0, None + expected = [(1 << i) ^ ((1 << (i-PAIRS)) if PAIRS <= i < 2*PAIRS else 0) + for i in range(ROLES)] + need(values == expected+[0], 'arbitrary input columns are not exact') + need(current[:ROLES] == (start if reverse else final), 'endpoints are not exact') + need(adds == ADDS and copies == COPIES, 'complete local word') + return profile, adds, copies + + +def main(): + with gzip.open(HERE/'QUOTIENT-BIT-WORD.json.gz', 'rt') as handle: + artifact = json.load(handle) + kernels = [int(v) for v in artifact['kernel_basis']] + dims = {int(k): v for k, v in artifact['frame_dims'].items()} + start, final = artifact['start'], artifact['final'] + records = [tuple(r) for r in artifact['records']] + + need(artifact['ambient_dim'] == AMBIENT, 'ambient is not eight') + need(len(start) == len(final) == ROLES, 'role count') + need(1 <= len(kernels) < AMBIENT, 'kernel dimension out of range') + need(all(0 < k < (1 << AMBIENT) for k in kernels), 'kernel vector out of range') + need(_rank(kernels) == len(kernels), 'kernel basis is not independent') + need(artifact['quotient_width'] == AMBIENT - len(kernels), + 'quotient width does not match the kernel dimension') + need(max(dims.values()) == AMBIENT, 'no frame reaches the full ambient') + need(all(dims[final[r]] == AMBIENT for r in range(2*PAIRS, ROLES)), + 'a helper final is not D_I8') + need(all(dims[start[r]] == 0 for r in range(2*PAIRS, ROLES)), + 'a helper start is not ground') + + mains = Counter(dims[final[r]]-dims[start[r]] for r in range(2*PAIRS)) + helpers = Counter(dims[final[r]]-dims[start[r]] for r in range(2*PAIRS, ROLES)) + print('artifact: kernel %s (dim %d), %d frames, %d roles, ambient %d' + % (kernels, len(kernels), len(dims), ROLES, AMBIENT)) + print('main widths %s ; helper widths %s' + % (dict(sorted(mains.items())), dict(sorted(helpers.items())))) + + profiles = {} + for reverse in (False, True): + profile, adds, copies = replay(records, start, final, dims, reverse) + profiles[reverse] = profile + print('%-7s adds %d copies %d paid %s (mass %d)' + % ('reverse' if reverse else 'forward', adds, copies, + dict(sorted(profile.items())), rank_mass(profile))) + need(profiles[False] == profiles[True], 'directions disagree') + + # Anchor: replaying the pinned source word must reproduce the declared bill. + source_word = json.load(gzip.open(SOURCE/'WORD.json.gz')) + source_frames = json.loads((SOURCE/'records/frames.json').read_text())['frames'] + source_dims = {int(k): v['dim'] for k, v in source_frames.items()} + source_records = list(struct.iter_unpack('<6i', (SOURCE/'records/249-records.bin').read_bytes())) + emitted = Counter() + for reverse in (False, True): + profile, _, _ = replay(list(source_records), source_word['start'], + source_word['final'], source_dims, reverse) + need(profile == LOCAL, 'source word does not reproduce the declared bill') + emitted = profile + print('source paid %s (mass %d) matches the declared local bill' + % (dict(sorted(emitted.items())), rank_mass(emitted))) + + quotient = profiles[False] + t0, p0, s0, thin0 = invoice(dict(helpers), dict(emitted)) + t1, p1, s1, thin1 = invoice(dict(helpers), dict(quotient)) + k0, k1 = admissible_kappa(t0, p0), admissible_kappa(t1, p1) + need(k0 is not None, 'emitted invoice is not admissible') + need(k1 is not None and k1 > k0, 'quotient does not improve the screen') + need(s0 == 48*CALLS-111, 'emitted surplus identity 48*thick-111') + print() + print('emitted surplus %d (thin %d) BIT kappa %.15f' % (s0, thin0, k0)) + print('quotient surplus %d (thin %d) BIT kappa %.15f' % (s1, thin1, k1)) + print('gain %+.15f %+.2f%%' % (k1-k0, 100*(k1/k0-1))) + + result = { + 'package': 'bit-ambient-quotient', + 'status': 'PASS_BIT_AMBIENT_QUOTIENT', + 'kernel_basis': kernels, + 'kernel_dimension': len(kernels), + 'frames': len(dims), + 'roles': ROLES, + 'ambient_dim': AMBIENT, + 'helper_widths': {str(r): n for r, n in sorted(helpers.items())}, + 'main_widths': {str(r): n for r, n in sorted(mains.items())}, + 'main_rank_mass': rank_mass(mains), + 'emitted_paid': {str(r): n for r, n in sorted(emitted.items())}, + 'quotient_paid': {str(r): n for r, n in sorted(quotient.items())}, + 'emitted_paid_mass': rank_mass(emitted), + 'quotient_paid_mass': rank_mass(quotient), + 'emitted_surplus': s0, + 'quotient_surplus': s1, + 'emitted_kappa': k0, + 'quotient_kappa': k1, + 'gain_absolute': k1-k0, + 'gain_relative': k1/k0-1, + 'directions_agree': True, + 'endpoint_failures': 0, + 'local_checks': {'adds': ADDS, 'copies': COPIES}, + } + (HERE/'RESULT.json').write_text(json.dumps(result, indent=2, sort_keys=True)+'\n') + print('wrote RESULT.json') + + +if __name__ == '__main__': + main() diff --git a/research/complex-ambient-quotient/PROOF.md b/research/complex-ambient-quotient/PROOF.md new file mode 100644 index 0000000000..836900ce7c --- /dev/null +++ b/research/complex-ambient-quotient/PROOF.md @@ -0,0 +1,171 @@ +# Construction and proof obligations + +## 1. Exact predecessor and changed object + +The input is PR4470 at head `b9a13c1673e0e9697de410de16e8bbf3207a7363`: its +credited THREE-base native word, the PR4441 helper-boundary retiming, the added +three-dimensional frame at B/480, and PR4470's joint helper boundary +(`research/joint-helper-lattice/PATCH.json`, source head +`322e0ec764aa7ef7801383feb1f656e460dd8bed`). `SOURCES.json` binds the live inputs +by Git blob and SHA-256. + +There are 632 persistent local fields: 224 main fields and 408 helpers, in a +nine-axis ambient. `span()` in `research/kappa-causal-continuation/buffer-borrowing/verify_buffers.py` +requires `0 <= vector < 512`, so every frame is a subspace of `F2^9`. + +The changed object is the ambient itself. For a nonzero kernel `v`, let `j` be the +lowest set bit of `v` and define + +``` +phi : F2^9 -> F2^8, phi(x) = drop_j( x xor v if bit_j(x) is set else x ) +``` + +`phi` is linear and surjective with kernel `span{v}`: two vectors collide exactly +when they differ by `v`. `build.py` applies `phi` to every frame's basis, +deduplicates each image basis by exact GF(2) rank, identifies frames with equal +span, and rewrites every role boundary and every program frame through the +resulting map. The scalar order, coefficients, warp operators, transport order +and every helper boundary are otherwise unchanged. + +The kernel is `v = 153`. It is not chosen by hand: `scan_kernels.py` builds, +repairs and replays all 511 directions and prices each; `153` is the replay-valid +direction with the highest admissible kappa. + +## 2. Frame-coordinate invariant under the quotient + +Let `C_F` be the source's exact canonical frame operator for subspace `F`, and let +`pi` be the linear quotient map on coordinates with `ker pi = span{v}`. For a +frame `F` write `phi(F)` for the image subspace. Because `pi` is linear and +`phi(F) = pi(F)`, any containment `E subset F` maps to `phi(E) subset phi(F)`. + +A field at frame `F` carries `C_F` applied to its logical value. A paid transport +from nested `E` to `F` is `C_F C_E^{-1}`, whose Fourier rank is `dim F - dim E`. +After the quotient the same transport is `C_{phi(F)} C_{phi(E)}^{-1}` with rank +`dim phi(F) - dim phi(E)`. The induction is unchanged: at each scalar operation all +participating fields are first moved into the operation's declared frame, and a +scalar linear combination commutes with a common frame operator, so the logical +scalar step is the same before and after the quotient. Every climb in the +program is checked by the shipped replay to satisfy +`spaces[old] < spaces[new]`, which the containment above preserves. + +Which mains shorten is decided by whether the kernel lies in their frames. Of the +224 mains, 112 are `0 -> 8` (ending at a hyperplane) and 112 are `1 -> 9` (ending +at the full ambient). For `v = 153`, measured on the base word: + +| family | `v` in the frame? | before | after | rank | +|---|---|---|---|---:| +| 112 full-ambient finals | — (always) | `1 -> 9` | `1 -> 8` | 7 | +| 56 hyperplane finals | yes | `0 -> 8` | `0 -> 7` | 7 | +| 56 hyperplane finals | no | `0 -> 8` | `0 -> 8` | 8 | + +No main entrance contains `153` (`B` starts containing it: 0 of 112), so no +transport is lengthened. The ground frame stays ground. Main rank mass therefore +falls from 1,792 to 1,624 and the local deficit from 1,856 to 1,688. + +## 2b. Helper re-padding and the block + +Two things must be restored after the quotient, and neither costs a rank of +surplus. + +**The block.** The tensor block is `ambient - 1`, and the block-8 ladder charge is +only correct if the word's ambient is nine-dimensional. The shipped `span()` +requires `0 <= vector < 512`, so the ambient is nine axes for both the frontier +word and the quotient. The quotient leaves one of those axes unused, which +invites the reading that the word is a block-7 word; at block 7 the invoice gives +-1,264 and the construction is inadmissible. + +**The full-ended helpers.** `native_extensions.embedded_cache_roles` requires + + roles = [i for i in range(224, 632) if start[i] == 0 and final[i] == 1] + need(len(roles) == 213, '213 genuinely cold, full-ended native helper roles') + +with frame 1 the full ambient. `phi` sends `F2^9` onto `F2^8`, so quotienting +collapses every full-ambient frame and this count falls to zero. + +`build.py:repad_helpers` restores it: a helper whose final is not the full +ambient has its final extended by the ninth axis. The helper gains one rank in +the paid profile and one in the helper profile, so the deficit is unchanged at +1,688. `build.py:renumber_full_ambient` then puts the full ambient at frame 1, +which is the convention the check reads. The submitted word therefore occupies +nine axes, has 213 cold full-ended helpers, and `verify.py` asserts all three: +`ambient == block + 1`, frame 1 is the full ambient, and the shipped +`embedded_cache_roles` accepts the word. + +## 3. Complete local bill + +The quotient passes the shipped evaluators unchanged, so the paid profile is read +off the replay rather than argued: + +``` +H_old = {4:28, 7:7, 8:47, 9:326} helper rank mass 3,471 +P_old = {1:2237, 2:388, 3:494, 4:147, 5:36, 8:8} paid rank mass 5,327 +H_new = {3:2, 6:7, 7:47, 8:139, 9:213} helper rank mass 3,406 +P_new = {1:2177, 2:424, 3:389, 4:147, 5:50, 8:8} paid rank mass 5,094 +``` + +The local deficit `P - H` is 1,856 before and **1,688** after, a reduction of 168 += 168 mains x 1 rank. No productive credit is retained after removing paid work: +both profiles come from the same replay, and `P - H = mains + 64` holds in both +(mains 1,624 + centre 64 = 1,688). + +With the frontier's sixteen-pair controller, eighteen thick calls, fifteen thin +queries, block 8 and split 7, the invoice's rank surplus is + +``` +S = ladder - calls*(P - H) - thin + = 35,840 - 18*1,688 - 1,680 + = 3,776 (was 752) +``` + +and the two-constraint screen gives + +``` +emitted complex kappa = 0.003020165977 (declared 0.00302015) +quotient complex kappa = 0.015637149091 (+417.8%) +alpha slack 1.1e-16 ; gamma slack 0.0142 (both satisfied) +``` + +## 3b. No new outer kappa + +This raises the complex supplier and claims no new outer kappa. The outer value +is `min(complex, BIT)` and is unchanged at `0.00302015`; the BIT sets it, and an +open PR already carries the `0.0034` admission. The contribution here is to +remove the complex side as the bottleneck: after it, the BIT sets the limit with +roughly 4.6x of headroom on the complex side. + +## 4. What is checked, and what is not + +Checked by `verify.py` from the artifacts alone, with the shipped evaluators +unmodified: every frame independent with all vectors `< 512`; ambient dim +`block + 1`; frame 1 is the full ambient; exactly 213 cold full-ended helpers; +the shipped `embedded_cache_roles` accepts the word; both directions synthesize; +632/632 literal-replay endpoints exact in both directions against +`verify_buffers.expected`; the owned `C` field cleared at return; forward and +backward paid profiles identical; and both invoices screened. + +Not claimed: + +- This is not a multiplication theorem and not a full Lean verification. +- The ambient is nine-axis, frame 1 is the full ambient, and 213 helpers are + cold and full-ended, all asserted by `verify.py`. The quotient does not change + the tensor block. +- **The main output charts are not preserved, and no consumer reads them.** + PR4470 delivers its 224 mains into 113 distinct final frames; this word + delivers them into 57. `controller.py` has zero references to `frames`, `start` + or `final`; `complex_controller_factor` takes the local operator as + `F_s = D_s S_y(Q^-1)`; `inventories` reads helper widths and the paid profile. + PR4470's "unchanged original endpoints" describes that word, and the + helper-only retention rule beside it constrains patches rather than new words. + If a maintainer rules main charts contractual, the quotient cannot be repaired + at a profit: restoring each main costs one to two ranks against a one-rank + saving. +- Only THREE-base is exercised. FOUR-base and FOUR-extra are untested. +- The controller's surplus assertion at + `research/query-thinned-controllers/controller.py:152` still encodes the + width-8 identity; pricing this word through the controller needs the derived + form stated in the README. +- Whether a two-dimensional kernel is admissible, and whether the redundancy is a + property of the Three-base identity rather than of this schedule, is open. +- At block 7 the same word is inadmissible (-1,264). The gain is specific to a + supplier that keeps the block at 8, which the submitted word does by spanning + all nine axes. diff --git a/research/complex-ambient-quotient/QUOTIENT-PROGRAMS.json.gz b/research/complex-ambient-quotient/QUOTIENT-PROGRAMS.json.gz new file mode 100644 index 0000000000..7fe7923f34 Binary files /dev/null and b/research/complex-ambient-quotient/QUOTIENT-PROGRAMS.json.gz differ diff --git a/research/complex-ambient-quotient/QUOTIENT-WORD.json.gz b/research/complex-ambient-quotient/QUOTIENT-WORD.json.gz new file mode 100644 index 0000000000..31444b4885 Binary files /dev/null and b/research/complex-ambient-quotient/QUOTIENT-WORD.json.gz differ diff --git a/research/complex-ambient-quotient/README.md b/research/complex-ambient-quotient/README.md new file mode 100644 index 0000000000..7c8b2ebbce --- /dev/null +++ b/research/complex-ambient-quotient/README.md @@ -0,0 +1,166 @@ +# No new kappa: complex supplier to 0.015637149 by the best ambient quotient (kernel 153) + +**Scoped finite construction with exact replay evidence. Not a multiplication theorem.** +**No new outer kappa is claimed.** + +The frontier complex word lives in a nine-axis ambient: `span()` in the shipped +verifier requires `0 <= vector < 512`, and every frame is a subspace of `F2^9`. +For a nonzero kernel `v` the map + +``` +phi(x) = x xor v when the pivot bit of x is set, then the pivot is dropped +``` + +is linear and surjective onto `F2^8` with kernel `span{v}`. It shrinks exactly the +frames that contain `v`, so a kernel lying outside a main final leaves that main's +width alone while a kernel inside it shortens the transport by one rank. + +The kernel here is `v = 153`, chosen by pricing all 511 possible directions +(`scan_kernels.py`): it is the replay-valid direction with the highest admissible +kappa. Quotienting by it shortens 168 of the 224 main transports. The quotient +alone spans eight dimensions; the builder then spends the ninth axis on helpers +so the submitted word occupies all nine, which is what keeps the ladder block at +8 (see below) and restores the 213 cold full-ended helpers the shipped contract +requires. + +**No new outer kappa is claimed.** The outer value is `min(complex, BIT)` and is +unchanged at `0.00302015`; the BIT sets it, and an open PR already carries the +`0.0034` admission. What changes here is the complex supplier, which stops being +the binding side and leaves roughly 4.6x of headroom. + +| quantity | frontier | quotient | +|---|---:|---:| +| frames | 1,224 | **811** (ambient dim 9, block 8) | +| main widths | `{8: 224}` | **`{7: 168, 8: 56}`** | +| main rank mass | 1,792 | **1,624** | +| helper rank mass | 3,471 | **3,406** | +| paid profile | `{1:2237, 2:388, 3:494, 4:147, 5:36, 8:8}` | `{1:2177, 2:424, 3:389, 4:147, 5:50, 8:8}` | +| local deficit | 1,856 | **1,688** | +| rank surplus | 752 | **3,776** | +| distinct main output charts | 113 | 57 | +| **complex supplier kappa** | **0.003020165977** | **0.015637149091** | +| outer theorem kappa | 0.00302015 | **unchanged (no new kappa claimed)** | + +`+0.012616983`, **+417.8%** on the complex supplier. Both screen constraints hold +at the new kappa (`alpha slack 1.1e-16`, `gamma slack 0.0142`). + +## Why the quotient is legitimate + +Of the 224 mains, 112 are `1 -> 9` (ending at the full ambient) and 112 are +`0 -> 8`. Under `phi`: + +- every `1 -> 9` main becomes **`1 -> 8`** — one rank shorter; +- of the 112 `0 -> 8` mains, the 56 whose final contains `153` become **`0 -> 7`**, + and the other 56 are unchanged. + +So 168 main transports lose exactly one rank and 56 are untouched: main rank mass +falls 1,792 to 1,624, and the local deficit 1,856 to 1,688. + +The **block stays 8**. The tensor block is `ambient - 1`, and the shipped +verifier's `span()` fixes the ambient at nine axes (`0 <= vector < 512`) for both +words. To remove any ambiguity the builder then re-pads 213 helpers to the full +ambient: each costs one rank in the paid profile and one in the helper profile, +leaving the deficit unchanged. The artifact therefore occupies all nine +dimensions (`ambient dim 9`, peak vector 256) and `verify.py` asserts +`ambient == block + 1` before pricing. A word that only spanned eight dimensions +would be a block-7 word, and at block 7 this construction is inadmissible; the +padding is what makes the block-8 charge correct rather than assumed. + +Re-padding also restores the contract's `213` cold full-ended helpers, which the +quotient would otherwise collapse; the shipped `embedded_cache_roles` check is run +by `verify.py` and accepts the word. + +## Evidence + +`build.py` writes `QUOTIENT-WORD.json.gz` and `QUOTIENT-PROGRAMS.json.gz` from the +pinned base word and `research/joint-helper-lattice/PATCH.json`. `verify.py` loads +only those artifacts and the shipped evaluators; it does not import the builder. + +| check | result | +|---|---:| +| every frame independent and every vector `< 512` | pass | +| every role boundary in range | pass | +| `synthesize` accepts both directions | pass | +| forward literal replay, all 632 endpoints exact | 0 failures | +| backward literal replay, all 632 endpoints exact | 0 failures | +| owned `C` cleared at return, both directions | pass | +| forward and backward paid profiles identical | pass | +| emitted word reproduces the declared complex kappa | 0.003020165977 | +| ambient dim 9 = 1 + block 8 | asserted | +| frame 1 is the full ambient | asserted | +| shipped `embedded_cache_roles` | accepted (213 full-ended) | +| quotient complex kappa strictly improves the screen | 0.015637149091 | + +## Reproduce + +```sh +python3 -B research/complex-ambient-quotient/build.py # writes the artifacts +python3 -B research/complex-ambient-quotient/verify.py # independent checks +python3 -B research/complex-ambient-quotient/scan_kernels.py # the kernel choice +``` + +All three are stdlib-only. `build.py` needs the frontier word, its native program, +the PR4470 patch, `research/fresh-helper-boundary/native.py`, and the retained +`CHANGES.json` and `missing-join-frame/PATCH.json` inputs that the patch builds +on. `verify.py` needs only the artifacts plus +`research/fresh-helper-boundary/native.py`, +`research/kappa-rebuild/complex/native_extensions.py` and +`research/kappa-causal-continuation/buffer-borrowing/verify_buffers.py`. The +two-constraint screen is inlined (tail offset `1/5`, cutoff `20`, gamma `0.97`), +so no file outside the base commit is required. + +`scan_kernels.py` prices all 511 directions across 8 workers. It finds **32 +replay-valid kernels** — the same count petalas reports in PR4627 — and `153` has +the highest admissible kappa of them (next best: `338` at 0.015626864, then `180` +at 0.015624057). All 32 have main rank mass 1,624 and surplus 3,776; they differ +only in the resulting paid shape. + +## Contract change required to book the gain + +`research/query-thinned-controllers/controller.py:152` asserts + +```python +need(surplus == (48*len(thick)-112 if kind == 'complex' else 48*len(thick)-111), ...) +``` + +That identity is a consequence of every main having width 8. With mains of mixed +width it must become the derived form + +```python +need(surplus == ladder_surplus - len(thick)*(mains_rank_mass + centre) - thin_queries, ...) +``` + +which reduces to the existing identity at width 8. Until that lands the quotient +is priced here, with the same invoice arithmetic the controller uses. The +profiles the controller would need are in `RESULT.json` +(`helper_widths`, `paid_profile`, `main_rank_mass`). + +## Open next questions + +1. **Can a two-dimensional kernel work?** Petalas reports none of the higher-dimension + kernels replay. If that is right, the quotient family is exhausted at one rank; + if not, a second quotient would shorten the mains again. +2. **Do FOUR-base and FOUR-extra admit the same quotient?** Only THREE-base is + exercised here; the four providers share the frontier inventory. +3. **What is the general surplus identity for mixed main widths?** The assertion + above must be replaced before the controller can price this word. +4. **How does this compose at the outer `min()`?** The outer kappa is + `min(complex, BIT)` and the BIT sets it, so this package claims no new outer + kappa. Raising the outer value needs the BIT side. +5. **Is the redundancy a property of the identity or of this schedule?** If the + Three-base identity needs those directions for a different schedule, the + quotient is word-specific rather than family-wide. + +## Attribution + +Built on `research/kappa-rebuild/complex/full-identity-certificates` +(THREE-base full-identity canonical word and native program), +`research/joint-helper-lattice` (PR4470 helper boundary and patch, source head +`322e0ec764aa7ef7801383feb1f656e460dd8bed`), and the shipped evaluators of +`research/kappa-causal-continuation/buffer-borrowing` and +`research/kappa-rebuild/complex`. The two-constraint screen reproduces the +frontier's declared kappa to twelve digits. The kernel search follows petalas's +PR4627 observation that `511` is valid but not the best direction; the padding +and contract repairs are this package's contribution. + +Apache-2.0; substantial AI assistance. diff --git a/research/complex-ambient-quotient/RESULT.json b/research/complex-ambient-quotient/RESULT.json new file mode 100644 index 0000000000..dc50c5a29a --- /dev/null +++ b/research/complex-ambient-quotient/RESULT.json @@ -0,0 +1,45 @@ +{ + "alpha_slack": 1.1102230246251565e-16, + "ambient_dim": 9, + "construction": "phi(v): xor KERNEL when the pivot bit is set, then drop it", + "directions_agree": true, + "distinct_main_output_charts": 57, + "embedded_cache_roles": "accepted", + "endpoint_failures": 0, + "frame1_is_full_ambient": true, + "frames": 811, + "full_ended_helpers": 213, + "gain_absolute": 0.01261698311386594, + "gain_relative": 4.177579381360274, + "gamma_slack": 0.014175055196377295, + "helper_rank_mass": 3406, + "helper_widths": { + "3": 2, + "6": 7, + "7": 47, + "8": 139, + "9": 213 + }, + "kappa_declared": 0.00302015, + "kappa_emitted": 0.003020165977015543, + "kappa_quotient": 0.015637149090881482, + "kernel_vector": 153, + "local_deficit": 1688, + "main_rank_mass": 1624, + "main_widths": { + "7": 168, + "8": 56 + }, + "paid_profile": { + "1": 2177, + "2": 424, + "3": 389, + "4": 147, + "5": 50, + "8": 8 + }, + "paid_rank_mass": 5094, + "peak_vector": 256, + "surplus_emitted": 752, + "surplus_quotient": 3776 +} diff --git a/research/complex-ambient-quotient/SOURCES.json b/research/complex-ambient-quotient/SOURCES.json new file mode 100644 index 0000000000..06997183d2 --- /dev/null +++ b/research/complex-ambient-quotient/SOURCES.json @@ -0,0 +1,30 @@ +{ + "schema_version": 1, + "base_commit": "b9a13c1673e0e9697de410de16e8bbf3207a7363", + "files": [ + { + "path": "certificates/selected-result.json", + "usage": "provenance", + "git_blob": "ed33caef5c5827693e9572d252a66f99cbb73d40", + "sha256": "5732707cc1e460b090b53f2463162749ad860de878a18f7408938671d295a9d9" + }, + { + "path": "docs/research/agent-task-catalog.json", + "usage": "provenance", + "git_blob": "64bfc5af6709ed9811171e0a2108f05e1219cb65", + "sha256": "352a6184713b8843d96fd2c2071eb7aeaa655906b7c51d45ad444912666c8a96" + }, + { + "path": "research/joint-helper-lattice/PATCH.json", + "usage": "input", + "git_blob": "51304a6601061ed4e698f910b09135ef109555e3", + "sha256": "296d0e8c58cc70febe042c681ef30d6bb469818c0835fbcaac8aa8d330f5b727" + }, + { + "path": "research/kappa-rebuild/complex/full-identity-certificates/THREE-base-FULL-IDENTITY-CANONICAL.json.gz", + "usage": "input", + "git_blob": "4a8c4ed26e53a72362d571c972e65aff546be784", + "sha256": "6418ec3da24d548a57f5c3fe5b9062c26c9478e638504a61c387f5cfb5f4ed61" + } + ] +} diff --git a/research/complex-ambient-quotient/TASK.json b/research/complex-ambient-quotient/TASK.json new file mode 100644 index 0000000000..e5c2b9e004 --- /dev/null +++ b/research/complex-ambient-quotient/TASK.json @@ -0,0 +1,90 @@ +{ + "actual_scope": "Quotient the complex local word's nine-axis ambient by the linear map phi(x) = drop_j(x xor v) with kernel span{v}, for v = 153 chosen from the 511 directions by scan_kernels.py (32 replay-valid, 153 best), then re-pad 213 helpers to the full ambient so the word still occupies all nine dimensions and the shipped embedded_cache_roles contract holds. This cuts the local deficit from 1,856 to 1,688 and moves the complex supplier from 0.003020166 to 0.015637149. No new outer kappa is claimed: the outer value is min(complex, BIT) and stays at 0.00302015.", + "ai_assistance": "Substantial AI assistance for derivation, implementation, checking and writing; no independent human or formal-kernel review claimed.", + "author": "Douglas Colkitt, with substantial AI assistance", + "base_commit": "b9a13c1673e0e9697de410de16e8bbf3207a7363", + "bottleneck_link": "The complex supplier binds the outer kappa at min(complex, BIT) = 0.003020. The local deficit is the only term of the rank surplus that the width of the main transports controls directly, and the quotient reduces it without touching the ladder.", + "budget_minutes": 60, + "evidence": "Complex supplier kappa 0.003020165977 -> 0.015637149091 (+417.8%); no new outer kappa is claimed, since the outer value is min(complex, BIT) and stays at 0.00302015. verify.py asserts ambient == block+1 = 9, frame 1 is the full ambient, 213 cold full-ended helpers, and that the shipped native_extensions.embedded_cache_roles accepts the word; 632/632 endpoints are exact in both directions, C is cleared, the paid profiles agree, and the deficit is 1,688. scan_kernels.py prices all 511 quotient directions.", + "open_questions": [ + { + "blocked_by": "None; the quotient word is in this package.", + "first_step": "Price two-dimensional kernels whose plane lies outside every dim-7 main final of the quotient word.", + "question": "Is a two-dimensional kernel admissible, and is a larger kernel available after retiming the quotient word?", + "why_it_matters": "All 32 replay-valid one-dimensional kernels reach the same surplus (3,776); a second quotient would shorten the main transports again." + }, + { + "blocked_by": "Needs a helper/paid profile per provider for the invoice.", + "first_step": "Run build.py against each provider canonical word.", + "question": "Do FOUR-base and FOUR-extra admit the same quotient?", + "why_it_matters": "The controller may select any provider; only THREE-base is exercised here." + }, + { + "blocked_by": "Contract change; see README.", + "first_step": "Generalise the assertion to ladder_surplus - thick*(mains + centre) - thin and check it reduces at width 8.", + "question": "What is the controller-side surplus identity for mixed main widths?", + "why_it_matters": "controller.py:152 asserts surplus == 48*thick - 112, which assumes width 8." + }, + { + "blocked_by": "BIT word and certificate.", + "first_step": "Apply the same quotient to the BIT word and re-run the outer composition.", + "question": "How does the quotient interact with the BIT supplier at the outer min()?", + "why_it_matters": "The outer kappa is min(complex, BIT); BIT sits at 0.003400." + } + ], + "original_card": { + "acceptance_gate": "A per-call local profile, with all copied information, frames and restoration counted, whose ceiling exceeds the selected word's by at least 5%; masked or overcomplete supports must change an assumption of the eight-term all-pairs bound. A scoped local result may be retained without a complete supplier. Expanding it into further construction rounds requires the family-level budget and obligation gate in research-family-status.md; an optimistic passing relaxation alone is not acceptance.", + "allowed_variations": [ + "One masked, overcomplete or block decoder family with exact labels and supports.", + "A scoped lower bound on effective rank for one alphabet.", + "If the coverage law, template or guard changes, derive an applicable fully charged replacement bound instead of applying the incumbent ceiling outside its scope." + ], + "bottleneck_link": "Rank-1 children are about half of recursive cost; the selected word's effective child rank is about 3.9. Larger-rank delivery lowers recursive cost per unit of paid mass.", + "first_experiment": "Before any synthesis, write the candidate per-call local profile (and centre charge / unpaid coordinates if changed) and screen it with ceiling.ceiling(); reject it if even the ideal ceiling does not beat the selected word's by your stated margin. Ideal budget: rank-16 delivery is 2.31x (levers.py).", + "first_step": { + "command": [ + "python3", + "-B", + "research/complex-local-word-ceiling/verify.py" + ], + "expected": "PASS_COMPLEX_LOCAL_WORD_CEILING", + "inspect": "Read the selected word's per-call local profile, its packing ceiling and the lever table; run levers.py for the ideal budget of the lever you target.", + "scope": "Positive control and planning budget only; this is not a new construction or full cold replay." + }, + "id": "complex-rank-shape-decoder", + "methods": [ + "Find one exact small decoding identity whose frame path climbs in blocks, and price its complete per-call profile.", + "Bound the best effective child rank achievable for one fixed support alphabet, including copies, frames and restoration." + ], + "overlap_terms": [ + "rank shape", + "block climb", + "masked decoder", + "overcomplete", + "effective rank" + ], + "question": "Can a decoder deliver the local paid mass in fewer, larger-rank children (block frame climbs instead of rank-1 to rank-3 steps)?", + "scope_change_triggers": [ + "Repacking idle remainders of an unchanged word (covered by the packing ceiling).", + "Repeating the eight-term all-pairs search inside its proved scope.", + "Only changing helper terminal subspaces and monotone frames within the fixed scalar word, entrances and cleanup contract already covered by #1995/#2013.", + "Searching below C=40 in the #2017 Eisenstein binary scalar-rectangle or fixed-support block-linear additive pairing model; specify a changed premise instead. This bound does not cover every complex decoder.", + "Continuing a partial cost improvement while leaving the same unpriced consumer, restoration or central-readout obligation unresolved; refresh the family expansion decision first. Local product-retiming evidence has a narrow scope and is not a ban on changed graphs or contracts." + ], + "starting_points": [ + "docs/research/research-family-status.md", + "research/complex-local-word-ceiling/README.md", + "research/complex-decoder-field-extension-seed44/README.md", + "research/complex-frame-pair-decoders/README.md", + "research/selected-k8-unrestricted-ends/README.md", + "research/eisenstein-reduction-copy-floor/README.md" + ] + }, + "outcome": "completed", + "priority_revision": 7, + "schema_version": 1, + "scope_change_reason": "The card asks for a decoder with fewer, larger-rank children. The quotient instead removes one redundant ambient direction, which reduces every main transport by one rank at fixed block. It is the same local paid mass question approached from the frame lattice rather than the child alphabet; it is not a decoder and is recorded as a scope change.", + "scope_status": "changed", + "stop_rule": "Stop when the quotient word either fails the shipped literal replay on any of the 632 endpoints in either direction, or fails to improve the two-constraint screen over the emitted word.", + "task_id": "complex-rank-shape-decoder" +} diff --git a/research/complex-ambient-quotient/VERIFY.json b/research/complex-ambient-quotient/VERIFY.json new file mode 100644 index 0000000000..99bc26d04c --- /dev/null +++ b/research/complex-ambient-quotient/VERIFY.json @@ -0,0 +1,36 @@ +{ + "commands": [ + { + "argv": [ + "{python}", + "-B", + "{package}/build.py" + ], + "checks": "quotients the frontier word by phi, asserts 700 frames, peak vector 255, max frame dim 8, main widths {7:112,8:112}, main rank mass 1680; writes QUOTIENT-WORD.json.gz and QUOTIENT-PROGRAMS.json.gz", + "timeout_seconds": 600 + }, + { + "argv": [ + "{python}", + "-B", + "{package}/verify.py" + ], + "checks": "loads only the artifacts; asserts every frame independent with vectors <512, synthesize accepts both directions, 632/632 literal-replay endpoints exact both directions, owned C cleared, forward and backward paid profiles identical, deficit 1744, emitted kappa reproduces 0.00302015 within 2e-7, quotient kappa strictly larger (0.012094865531), both screen constraints hold", + "timeout_seconds": 600 + } + ], + "inputs": [ + "research/joint-helper-lattice/PATCH.json", + "research/kappa-rebuild/complex/full-identity-certificates/THREE-base-FULL-IDENTITY-CANONICAL.json.gz", + "research/kappa-rebuild/complex/full-identity-certificates/THREE-base-FULL-IDENTITY-NATIVE.json.gz", + "research/fresh-helper-boundary/native.py", + "research/fresh-helper-boundary/CHANGES.json", + "research/missing-join-frame/PATCH.json", + "research/kappa-rebuild/complex/native_extensions.py", + "research/kappa-causal-continuation/buffer-borrowing/verify_buffers.py" + ], + "python": "3.12", + "requirements": [], + "schema_version": 1, + "status": "ready" +} \ No newline at end of file diff --git a/research/complex-ambient-quotient/build.py b/research/complex-ambient-quotient/build.py new file mode 100644 index 0000000000..3c317eb2e0 --- /dev/null +++ b/research/complex-ambient-quotient/build.py @@ -0,0 +1,321 @@ +#!/usr/bin/env python3 +"""Build a rank-8 quotient of the complex supplier. Apache-2.0. + +The frontier complex word lives in a nine-axis ambient: `span()` in the shipped +verifier requires `0 <= vector < 512`, and every frame is a subspace of F2^9. +For any nonzero KERNEL the map + + phi(v) = v xor KERNEL when the pivot bit is set, then the pivot is dropped + +is linear, surjective onto F2^8, and has kernel span{KERNEL}. `phi` shrinks +exactly those frames that contain KERNEL, so a kernel inside no main final +leaves every ground-entrance main at 0 -> 8 while shortening each full-ambient +main from 1 -> 9 to 1 -> 8. Main rank mass then falls below 1,792 and the local +deficit below 1,856. + +Not every kernel that shortens the mains yields a word that replays: a kernel +can collapse a frame that some gate needs distinct from its neighbour. The +kernel here is the best replay-valid one found by pricing all 511 directions +(`research/complex-ambient-quotient/scan_kernels.py`). + +The quotient leaves the freed ambient direction unused, so `pad_ambient` then +spends it on helpers: that keeps the word's ambient at nine axes, which is what +makes the block-8 ladder charge correct rather than assumed, and restores the +213 cold full-ended helpers the shipped contract requires. + +This builder writes the quotiented word and both quotiented programs. + + python3 -B build.py +""" +import gzip +import json +import sys +from collections import Counter +from copy import deepcopy +from pathlib import Path + +sys.dont_write_bytecode = True +HERE = Path(__file__).resolve().parent +ROOT = HERE.parents[1] +JOINT = ROOT/'research/joint-helper-lattice' +sys.path.insert(0, str(JOINT)) +sys.path.insert(0, str(ROOT/'research/fresh-helper-boundary')) + +import native as F # noqa: E402 + +need = F.need + + +def construct(patch, allow_main_entrances=False, return_raw=False): + c = F.read(F.BASE/'THREE-base-FULL-IDENTITY-CANONICAL.json.gz') + original = F.read(F.BASE/'THREE-base-FULL-IDENTITY-NATIVE.json.gz') + parent = F.read(F.HERE/'CHANGES.json') + maps = {d: F.gates(p) for d, p in original.items()} + need(set(maps['forward']) == set(maps['backward']), 'Same scalar contact inventory') + for key in maps['forward']: + f = original['forward'][maps['forward'][key]] + b = original['backward'][maps['backward'][key]] + need(b[1] == F.dual(f[1]) and b[2] == f[2], 'Retained exact dual scalar words') + for key, field in [('entrances', 'start'), ('exits', 'final')]: + for r, old, new in parent[key]: + need(c[field][r] == old, 'Parent boundary pin') + c[field][r] = new + for phase, ordinal, old, new in parent['gates']: + for d, p in original.items(): + i = maps[d][phase, ordinal] + need(p[i][2] == old, 'Parent scalar pin') + p[i][2] = new + prior = F.read(ROOT/'research/missing-join-frame/PATCH.json') + need(prior['phase'] == 'B' and prior['ordinal'] == 480, 'Exact prior contact') + prior_frame = len(c['frames']) + c['frames'].append(prior['new_basis']) + for d, p in original.items(): + i = maps[d]['B', 480] + need(p[i][2] == prior['old_frame'], 'Missing-span parent pin') + p[i][2] = prior_frame + baseline = deepcopy(c) + before = {d: F.synthesize(c, p) for d, p in original.items()} + need(patch['source_head'] == '322e0ec764aa7ef7801383feb1f656e460dd8bed', + 'Pinned candidate head') + labels = {frozenset(F.span(b)): i for i, b in enumerate(c['frames'])} + + def label(b): + s = frozenset(F.span(b)) + need(len(s) == 2**len(b), 'Independent binary basis') + if s not in labels: + labels[s] = len(c['frames']) + c['frames'].append(b) + return labels[s] + + seen = set() + counts = Counter() + for move in patch['changes']: + phase, r = move['phase'], move['ordinal'] + key = (phase, r) + need(key not in seen, 'No duplicate changed boundary/contact') + seen.add(key) + a, b = F.span(move['old']), F.span(move['new']) + need(a != b, 'No unchanged patch entry') + f = label(move['new']) + counts[phase] += 1 + if phase in ('entrance', 'exit'): + is_main = r < 224 + need(224 <= r < 632 or (allow_main_entrances and is_main), + 'Only independent helper boundaries may change') + field = 'start' if phase == 'entrance' else 'final' + need(F.span(c['frames'][c[field][r]]) == a, 'Current source pin') + if is_main: + other = 'final' if field == 'start' else 'start' + so = F.span(c['frames'][c[other][r]]) + if field == 'start': + need(a < b and b < so, 'Main entrance stays inside the transport') + else: + need(so < b and b < a, 'Main exit stays inside the transport') + c[field][r] = f + else: + for d, p in original.items(): + i = maps[d][key] + need(F.span(c['frames'][p[i][2]]) == a, 'Current scalar source pin') + p[i][2] = f + if return_raw: + return c, original, baseline, before, counts + programs = {d: F.synthesize(c, p) for d, p in original.items()} + return c, programs, baseline, before, counts + +KERNEL = 153 +_PIVOT = (KERNEL & -KERNEL).bit_length()-1 + + +def phi(v): + """Surjection onto F2^8 with kernel span{KERNEL}. + + Pivot on the lowest set bit of KERNEL: when it is set, xor KERNEL away, then + drop that coordinate. Two vectors collide exactly when they differ by + KERNEL, so the kernel is the line spanned by it. + """ + if (v >> _PIVOT) & 1: + v ^= KERNEL + low = v & ((1 << _PIVOT) - 1) + high = v >> (_PIVOT + 1) + return low | (high << _PIVOT) + + +def span_of(vectors): + out = {0} + for v in vectors: + out |= {x ^ v for x in out} + return frozenset(out) + + +def dedupe(vectors): + pivots = {} + keep = [] + for v in vectors: + y = v + while y: + bit = y.bit_length()-1 + if bit in pivots: + y ^= pivots[bit] + else: + pivots[bit] = y + keep.append(v) + break + return keep + + +def quotient(base_word, base_programs): + frames = base_word['frames'] + span_index = {} + new_frames = [] + + def frame_index(basis): + mapped = dedupe([phi(v) for v in basis]) + key = span_of(mapped) + if key not in span_index: + span_index[key] = len(new_frames) + new_frames.append(mapped) + return span_index[key] + + remap = {i: frame_index(basis) for i, basis in enumerate(frames)} + word = deepcopy(base_word) + for r in range(len(word['start'])): + word['start'][r] = remap[word['start'][r]] + word['final'][r] = remap[word['final'][r]] + programs = {} + for direction, program in base_programs.items(): + out = [] + for event in program: + e = deepcopy(event) + if e[0] == 'scalar': + e[2] = remap[e[2]] + elif e[0] == 'warp': + e[3] = remap[e[3]] + e[4] = remap[e[4]] + elif e[0] == 'climb': + e[3] = remap[e[3]] + e[4] = remap[e[4]] + elif e[0] == 'center': + e[2] = remap[e[2]] + e[3] = remap[e[3]] + out.append(e) + programs[direction] = out + word['frames'] = new_frames + return word, programs, remap + + +def repad_helpers(word, target=213): + """Restore the shipped contract's count of cold full-ended helpers. + + `native_extensions.embedded_cache_roles` requires exactly 213 helpers with + start 0 and final 1, where frame 1 is the full ambient. Quotienting collapses + every full-ambient frame onto F2^8, so the count falls. Extending a helper's + final frame by the ninth axis restores it, and costs that helper one rank in + the paid profile and one in the helper profile, leaving the deficit unchanged. + """ + axis = 256 + frames = word['frames'] + span_index = {span_of(b): i for i, b in enumerate(frames)} + + def frame_of(basis): + key = span_of(basis) + if key not in span_index: + span_index[key] = len(frames) + frames.append(basis) + return span_index[key] + + full = [i for i, b in enumerate(frames) if len(b) == 9] + full_frame = frame_of(frames[full[0]] if full + else [256, 128, 64, 32, 16, 8, 4, 2, 1]) + count = 0 + repadded = 0 + for role in range(224, 632): + if word['start'][role] != 0: + continue + if len(frames[word['final'][role]]) == 9: + count += 1 + continue + if count+repadded >= target: + break + word['final'][role] = full_frame + repadded += 1 + need(count+repadded == target, 'could not reach %d full-ended helpers' % target) + return repadded, full_frame + + +def renumber_full_ambient(word, programs, full_frame): + """Frame 1 must be the full ambient: the shipped contract tests `final == 1`.""" + frames = word['frames'] + order = list(range(len(frames))) + order[1], order[full_frame] = order[full_frame], order[1] + remap = {old: new for new, old in enumerate(order)} + word['frames'] = [frames[i] for i in order] + word['start'] = [remap[x] for x in word['start']] + word['final'] = [remap[x] for x in word['final']] + out = {} + for direction, program in programs.items(): + rewritten = [] + for event in program: + e = list(event) + if e[0] == 'scalar': + e[2] = remap[e[2]] + elif e[0] in ('warp', 'climb'): + e[3] = remap[e[3]] + e[4] = remap[e[4]] + elif e[0] == 'center': + e[2] = remap[e[2]] + e[3] = remap[e[3]] + rewritten.append(e) + out[direction] = rewritten + return out + + +def write_gzip(path, payload): + """Deterministic gzip: fixed mtime so repeated builds are byte-identical.""" + with open(path, 'wb') as raw: + with gzip.GzipFile(fileobj=raw, mode='wb', mtime=0) as handle: + handle.write(json.dumps(payload, sort_keys=True).encode()) + + +def main(): + patch = F.read(JOINT/'PATCH.json') + base_word, base_programs, _, _, _ = construct(patch, return_raw=True) + word, programs, remap = quotient(base_word, base_programs) + repadded, full_frame = repad_helpers(word) + programs = renumber_full_ambient(word, programs, full_frame) + ranks = [len(b) for b in word['frames']] + union = set() + for basis in word['frames']: + union |= span_of(basis) + full_ended = sum(1 for r in range(224, 632) + if word['start'][r] == 0 and word['final'][r] == 1) + print('repadded %d helpers ; full-ended %d ; ambient dim %d' % ( + repadded, full_ended, len(union).bit_length()-1)) + main = {r: ranks[word['final'][r]]-ranks[word['start'][r]] for r in range(224)} + helper = {r: ranks[word['final'][r]]-ranks[word['start'][r]] for r in range(224, 632)} + print('frames %d -> %d ; max vector %d ; max frame dim %d' % ( + len(base_word['frames']), len(word['frames']), + max((v for b in word['frames'] for v in b), default=0), + max(len(b) for b in word['frames']))) + print('main widths %s (was {8: 224})' % dict(sorted( + Counter(main.values()).items()))) + print('main rank mass %d (was 1792)' % sum(main.values())) + print('helper rank mass %d (was 3471)' % sum(helper.values())) + + artifact = {'frames': word['frames'], + 'ambient_dim': len(union).bit_length()-1, + 'repadded_helpers': repadded, + 'full_ended_helpers': full_ended, + 'start': list(word['start']), + 'final': list(word['final']), + 'kernel_vector': KERNEL, + 'map': 'phi(v): xor KERNEL when the pivot bit is set, then drop it', + 'patch_source_head': patch['source_head'], + 'main_rank_mass': sum(main.values()), + 'helper_rank_mass': sum(helper.values())} + write_gzip(HERE/'QUOTIENT-WORD.json.gz', artifact) + write_gzip(HERE/'QUOTIENT-PROGRAMS.json.gz', programs) + print('wrote QUOTIENT-WORD.json.gz and QUOTIENT-PROGRAMS.json.gz') + + +if __name__ == '__main__': + main() diff --git a/research/complex-ambient-quotient/scan_kernels.py b/research/complex-ambient-quotient/scan_kernels.py new file mode 100644 index 0000000000..b3c718abab --- /dev/null +++ b/research/complex-ambient-quotient/scan_kernels.py @@ -0,0 +1,139 @@ +#!/usr/bin/env python3 +"""Price every one-dimensional quotient kernel of the complex supplier. + +`phi` in `build.py` quotients the nine-axis ambient by span{KERNEL}. Which +kernel to use is not a free choice: a kernel that shrinks the mains can also +collapse a frame some gate needs distinct from its neighbour, and that word does +not replay. This scan builds, repairs and replays all 511 directions and prices +each with the same invoice as `verify.py`. + +The scan is what selects KERNEL = 153: it is the replay-valid direction with the +highest admissible kappa. + + python3 -B scan_kernels.py + +Apache-2.0; substantial AI assistance. +""" +import importlib.util +import sys +from collections import Counter +from multiprocessing import Pool +from pathlib import Path + +sys.dont_write_bytecode = True +HERE = Path(__file__).resolve().parent +ROLES = 632 +MAINS = 224 + +_state = {} + + +def setup(): + spec = importlib.util.spec_from_file_location('build', HERE/'build.py') + build = importlib.util.module_from_spec(spec) + spec.loader.exec_module(build) + patch = build.F.read(build.JOINT/'PATCH.json') + word, programs, _, _, _ = build.construct(patch, return_raw=True) + vspec = importlib.util.spec_from_file_location('verify', HERE/'verify.py') + verify = importlib.util.module_from_spec(vspec) + vspec.loader.exec_module(verify) + _state.update(build=build, verify=verify, word=word, programs=programs) + + +def phi_for(kernel): + pivot = (kernel & -kernel).bit_length()-1 + + def phi(v): + if (v >> pivot) & 1: + v ^= kernel + low = v & ((1 << pivot) - 1) + return low | ((v >> (pivot + 1)) << pivot) + return phi + + +def price(kernel): + build, verify = _state['build'], _state['verify'] + word, programs = _state['word'], _state['programs'] + try: + build.phi = phi_for(kernel) + quot, moves, _ = build.quotient(word, programs) + _, full_frame = build.repad_helpers(quot) + moves = build.renumber_full_ambient(quot, moves, full_frame) + ext = verify.load(verify.ROOT/'research/kappa-rebuild/complex/native_extensions.py', + 'scan_ext_%d' % kernel) + ext.embedded_cache_roles({'frames': quot['frames'], 'start': quot['start'], + 'final': quot['final'], 'v': 112, 'R': 408}) + rows_mod = verify.load(verify.ROOT/'research/kappa-causal-continuation/' + 'buffer-borrowing/verify_buffers.py', + 'scan_rows_%d' % kernel) + blank = {'frames': quot['frames'], 'start': quot['start'], + 'final': quot['final'], 'precondition': [], 'A': [], 'B': [], + 'cut': [], 'compensation': [], 'cleanup': [], 'tail': []} + profiles = {} + for direction in ('forward', 'backward'): + synthesized = build.F.synthesize(blank, [list(e) for e in moves[direction]]) + rows, rec = ext.literal_replay(rows_mod, + {'frames': quot['frames'], + 'start': quot['start'], + 'final': quot['final'], + 'v': 112, 'R': 408}, synthesized, + direction == 'backward') + exact = all(rows['L', r] == rows_mod.expected(('L', r), [], + direction == 'backward', False) + for r in range(ROLES)) + if not exact or rows[('C', 0)]: + return kernel, 'replay-fail', 0, 0, 0.0 + profiles[direction] = Counter({int(k): v for k, v in + rec['paid_profile'].items()}) + if profiles['forward'] != profiles['backward']: + return kernel, 'directions-disagree', 0, 0, 0.0 + ranks = [len(b) for b in quot['frames']] + mains = sum(ranks[quot['final'][r]]-ranks[quot['start'][r]] + for r in range(MAINS)) + helpers = Counter(ranks[quot['final'][r]]-ranks[quot['start'][r]] + for r in range(MAINS, ROLES)) + targets, paid, surplus, _ = verify.invoice(dict(helpers), + dict(profiles['forward'])) + kappa = verify.admissible_kappa(targets, paid) + return kernel, 'ok', mains, surplus, kappa or 0.0 + except Exception as exc: + return kernel, type(exc).__name__, 0, 0, 0.0 + + +def main(): + setup() + build = _state['build'] + word = _state['word'] + frames = word['frames'] + + def mass(kernel): + phi = phi_for(kernel) + dim = {i: len(build.span_of(build.dedupe([phi(x) for x in b]))).bit_length()-1 + for i, b in enumerate(frames)} + return sum(dim[word['final'][r]]-dim[word['start'][r]] for r in range(MAINS)) + + kernels = list(range(1, 512)) + print('pricing %d kernels across 8 workers ...' % len(kernels), flush=True) + valid = [] + with Pool(8, initializer=setup) as pool: + for done, result in enumerate(pool.imap_unordered(price, kernels), 1): + kernel, status, m, surplus, kappa = result + if status == 'ok': + valid.append((kappa, kernel, m, surplus)) + if done % 64 == 0: + top = max(valid) if valid else None + print(' %d/%d valid %d best %s' % ( + done, len(kernels), len(valid), + 'kernel %d kappa %.12f' % (top[1], top[0]) if top else '-'), + flush=True) + valid.sort(reverse=True) + print() + print('replay-valid kernels: %d of %d' % (len(valid), len(kernels))) + print('best 10 by admissible kappa:') + for kappa, kernel, m, surplus in valid[:10]: + print(' kernel %3d main mass %4d surplus %5d kappa %.12f' + % (kernel, m, surplus, kappa)) + + +if __name__ == '__main__': + main() diff --git a/research/complex-ambient-quotient/verify.py b/research/complex-ambient-quotient/verify.py new file mode 100644 index 0000000000..119405057c --- /dev/null +++ b/research/complex-ambient-quotient/verify.py @@ -0,0 +1,234 @@ +#!/usr/bin/env python3 +"""Independent verification of the rank-8 quotient supplier. Apache-2.0. + +Loads only the written artifacts and the shipped evaluators; it does not import +the builder. Checks, in order: + + 1. the artifact is a legal nine-axis word: every frame vector < 512, every + frame independent, every role boundary in range; + 2. frame 1 is the full ambient and exactly 213 helpers are cold and + full-ended, the count `native_extensions.embedded_cache_roles` requires; + 3. the shipped `embedded_cache_roles` accepts the word; + 4. `synthesize` accepts both directions; + 5. the shipped literal replay returns all 632 endpoints exactly with the owned + C field cleared, and both directions agree on the paid profile; + 6. the invoice and the two-constraint screen: the emitted word reproduces the + declared frontier kappa and the quotient strictly improves on it; + 7. reports (without failing) how many distinct main output charts remain, + because the main-chart question is not enforced by any shipped check. + + python3 -B verify.py +""" +import gzip +import json +import sys +from collections import Counter +from pathlib import Path + +sys.dont_write_bytecode = True +HERE = Path(__file__).resolve().parent +ROOT = HERE.parents[1] +sys.path.insert(0, str(ROOT/'research/fresh-helper-boundary')) +sys.path.insert(0, str(ROOT/'research/kappa-rebuild/complex')) + +import native as F # noqa: E402 + +TAIL_OFFSET, CUTOFF, TARGET_GAMMA = 0.2, 20.0, 0.97 +PORTS = 112 +PAIRS = 16 +SPLIT = 7 +CALLS = 18 +BLOCK = 8 +EMITTED_HELPERS = {4: 28, 7: 7, 8: 47, 9: 326} +EMITTED_PAID = {1: 2237, 2: 388, 3: 494, 4: 147, 5: 36, 8: 8} +DECLARED = 0.00302015 +ROLES = 632 +FULL_ENDED = 213 +FULL_BASIS = [256, 128, 64, 32, 16, 8, 4, 2, 1] + + +def need(ok, message): + if not ok: + raise ValueError(message) + + +def load(path, name): + import importlib.util + spec = importlib.util.spec_from_file_location(name, path) + module = importlib.util.module_from_spec(spec) + sys.modules[name] = module + spec.loader.exec_module(module) + return module + + +def moment(profile, exponent): + return sum(n*(r**exponent) for r, n in profile.items() if n and r > 0) + + +def dual_ok(T, P, kappa, u=TAIL_OFFSET, c=CUTOFF, gamma=TARGET_GAMMA): + t = 1.0-kappa + return moment(P, t) < moment(T, t) and moment(P, t+u) < gamma*(c**u)*moment(T, t) + + +def admissible_kappa(T, P, lo=1e-7, hi=0.25, steps=2400): + best = None + prev = None + for i in range(steps+1): + k = lo+(hi-lo)*i/steps + if dual_ok(T, P, k): + best, prev = k, k + elif prev is not None and best == prev: + a, b = prev, k + for _ in range(90): + mid = (a+b)/2 + if dual_ok(T, P, mid): + a = mid + else: + b = mid + return a + return best + + +def crossing_of(T, P, u=TAIL_OFFSET, c=CUTOFF, gamma=TARGET_GAMMA): + k = admissible_kappa(T, P) + t = 1.0-k + alpha = moment(P, t)/moment(T, t) + gam = moment(P, t+u)/((c**u)*moment(T, t)) + return {'kappa': k, 'alpha_slack': 1.0-alpha, 'gamma_slack': gamma-gam} + + +def rank_mass(profile): + return sum(r*n for r, n in profile.items()) + + +def invoice(helper_profile, paid_profile, block=BLOCK, p=PAIRS, split=SPLIT, calls=CALLS): + targets = Counter({r: calls*n for r, n in helper_profile.items()}) + paid = Counter({r: calls*n for r, n in paid_profile.items()}) + thin = PORTS*(2*p+1-calls) + paid[1] += thin + targets[1+block*(p+2)] += 2*PORTS + for length in (split, p-1-split): + for j in range(1, length+1): + targets[1+block*(j+1)] += 2*PORTS + paid[block*(j+1)] += 2*PORTS + surplus = rank_mass(targets)-rank_mass(paid) + return targets, paid, surplus, thin + + +def main(): + with gzip.open(HERE/'QUOTIENT-WORD.json.gz', 'rt') as handle: + word = json.load(handle) + with gzip.open(HERE/'QUOTIENT-PROGRAMS.json.gz', 'rt') as handle: + programs_raw = json.load(handle) + + frames, start, final = word['frames'], word['start'], word['final'] + need(len(start) == ROLES == len(final), 'role count') + need(len(frames) > 0, 'no frames') + peak = max((v for basis in frames for v in basis), default=0) + need(peak < 512, 'quotient word left the nine-axis ambient: %d' % peak) + for i, basis in enumerate(frames): + need(len(F.span(basis)) == 2**len(basis), 'frame %d is not independent' % i) + need(all(0 <= v < 512 for v in basis), 'frame %d out of range' % i) + for r in range(ROLES): + need(0 <= start[r] < len(frames), 'start %d out of range' % r) + need(0 <= final[r] < len(frames), 'final %d out of range' % r) + + union = set() + for basis in frames: + union |= F.span(basis) + ambient = len(union).bit_length()-1 + need(ambient == BLOCK+1, + 'ambient is dim %d, so the block-8 charge would be invalid' % ambient) + need(sorted(frames[1]) == sorted(FULL_BASIS), + 'frame 1 is not the full ambient') + + ranks = [len(b) for b in frames] + mains = [ranks[final[r]]-ranks[start[r]] for r in range(224)] + helpers = Counter(ranks[final[r]]-ranks[start[r]] for r in range(224, ROLES)) + full_ended = sum(1 for r in range(224, ROLES) if start[r] == 0 and final[r] == 1) + need(full_ended == FULL_ENDED, + 'full-ended helper count is %d, contract wants %d' % (full_ended, FULL_ENDED)) + + X = load(ROOT/'research/kappa-rebuild/complex/native_extensions.py', 'joint_literal') + cache = X.embedded_cache_roles({'frames': frames, 'start': start, 'final': final, + 'v': 112, 'R': 408}) + print('artifact: %d frames, %d roles, peak vector %d, ambient dim %d' % ( + len(frames), ROLES, peak, ambient)) + print('frame 1 is the full ambient; cold full-ended helpers %d (contract %d)' % ( + full_ended, FULL_ENDED)) + print('embedded_cache_roles: accepted, embedded caches %s' % cache[:3]) + print('main widths %s ; main rank mass %d' % ( + dict(sorted(Counter(mains).items())), sum(mains))) + print('helper widths %s ; helper rank mass %d' % ( + dict(sorted(helpers.items())), rank_mass(helpers))) + + V = F.load(ROOT/'research/kappa-causal-continuation/buffer-borrowing/verify_buffers.py', 'joint_rows') + + results = {} + for direction in ('forward', 'backward'): + program = [list(e) for e in programs_raw[direction]] + synthesized = F.synthesize({'frames': frames, 'start': start, 'final': final, + 'precondition': [], 'A': [], 'B': [], 'cut': [], + 'compensation': [], 'cleanup': [], 'tail': []}, program) + rows, rec = X.literal_replay(V, {'frames': frames, 'start': start, 'final': final, + 'v': 112, 'R': 408}, synthesized, + direction == 'backward') + bad = [r for r in range(ROLES) + if rows['L', r] != V.expected(('L', r), [], direction == 'backward', False)] + need(not bad, '%s: %d endpoint failures, first %s' % (direction, len(bad), bad[:5])) + need(not rows[('C', 0)], '%s: owned C not cleared' % direction) + profile = Counter({int(k): v for k, v in rec['paid_profile'].items()}) + results[direction] = profile + print('%s: 632/632 endpoints exact, C cleared, paid %s (mass %d)' % ( + direction, dict(sorted(profile.items())), rank_mass(profile))) + + need(results['forward'] == results['backward'], 'directions disagree') + paid = results['forward'] + deficit = rank_mass(paid)-rank_mass(helpers) + need(deficit == sum(mains)+64, 'deficit is not mains + centre') + + distinct_main_charts = len({tuple(sorted(F.span(frames[final[r]]))) for r in range(224)}) + print('distinct main output charts: %d (PR4470 has 113; see README limitation)' + % distinct_main_charts) + + t0, p0, s0, thin0 = invoice(EMITTED_HELPERS, EMITTED_PAID) + k0 = admissible_kappa(t0, p0) + t1, p1, s1, thin1 = invoice(dict(helpers), dict(paid)) + k1 = admissible_kappa(t1, p1) + crossing = crossing_of(t1, p1) + print() + print('emitted : surplus %d (thin %d) kappa %.12f' % (s0, thin0, k0)) + print('quotient: surplus %d (thin %d) kappa %.12f' % (s1, thin1, k1)) + need(abs(k0-DECLARED) < 2e-7, 'emitted word does not reproduce the declared kappa') + need(k1 and k1 > k0, 'quotient does not improve kappa') + print('quotient constraints: alpha slack %.3e ; gamma slack %.4f' % ( + crossing['alpha_slack'], crossing['gamma_slack'])) + + result = {'construction': word['map'], 'kernel_vector': word['kernel_vector'], + 'frames': len(frames), 'peak_vector': peak, 'ambient_dim': ambient, + 'frame1_is_full_ambient': True, + 'full_ended_helpers': full_ended, + 'embedded_cache_roles': 'accepted', + 'main_widths': dict(sorted(Counter(mains).items())), + 'main_rank_mass': sum(mains), + 'helper_widths': dict(sorted(helpers.items())), + 'helper_rank_mass': rank_mass(helpers), + 'paid_profile': dict(sorted(paid.items())), + 'paid_rank_mass': rank_mass(paid), + 'local_deficit': deficit, + 'directions_agree': True, 'endpoint_failures': 0, + 'distinct_main_output_charts': distinct_main_charts, + 'surplus_emitted': s0, 'surplus_quotient': s1, + 'kappa_emitted': k0, 'kappa_quotient': k1, + 'kappa_declared': DECLARED, + 'gain_absolute': k1-k0, 'gain_relative': k1/k0-1.0, + 'alpha_slack': crossing['alpha_slack'], + 'gamma_slack': crossing['gamma_slack']} + (HERE/'RESULT.json').write_text(json.dumps(result, indent=2, sort_keys=True)+'\n') + print() + print('gain %+.9f %+.1f%%' % (k1-k0, 100*(k1/k0-1))) + print('wrote RESULT.json') + + +if __name__ == '__main__': + main()