diff --git a/Makefile b/Makefile index 66f00cfb30..270ea1c724 100644 --- a/Makefile +++ b/Makefile @@ -604,3 +604,10 @@ frontier890-verify: selected-record-check frontier942-verify: selected-record-check @work=$$(mktemp -d "$${TMPDIR:-/tmp}/integer-mult-frontier942.XXXXXX"); \ python3 -B scripts/verify_frontier942.py --work "$$work/replay" + +# Research note: width packing of the selected PR589 bit hosting (no new kappa). +.PHONY: bit589-width-packing-verify +bit589-width-packing-verify: + @work=$$(mktemp -d "$${TMPDIR:-/tmp}/integer-mult-bit589-packing.XXXXXX"); \ + python3 -B research/bit589-width-packing/verify.py --work "$$work/replay" && \ + python3 -B -m unittest discover -s research/bit589-width-packing -p test_package.py diff --git a/research/bit589-width-packing/CLAIM.json b/research/bit589-width-packing/CLAIM.json new file mode 100644 index 0000000000..cd69b702b7 --- /dev/null +++ b/research/bit589-width-packing/CLAIM.json @@ -0,0 +1,41 @@ +{ + "ai_assistance": "substantial: Claude (Anthropic) via Claude Code", + "assignment_seed": 16, + "base_commit": "2921874911956718fcaaaf9396fe8267b3cfa9f0", + "bit_bound_kappa_caps": { + "selected": "865213734911801/500000000000000000", + "width7_all_optimistic": "426919181844469/200000000000000000", + "width7_all_pessimistic": "406314394605613/200000000000000000", + "width7_k10_optimistic": "349047987845817/200000000000000000", + "width7_k10_pessimistic": "1742786661941923/1000000000000000000", + "width7_k1_optimistic": "173184178486967/100000000000000000", + "width7_k1_pessimistic": "865799952969731/500000000000000000", + "width7_k37_optimistic": "111651901215299/62500000000000000", + "width7_k37_pessimistic": "888674029610291/500000000000000000", + "width7_k74_optimistic": "461572653313689/250000000000000000", + "width7_k74_pessimistic": "1827854925395469/1000000000000000000", + "width8_free_concentration_42": "485875782209319/250000000000000000", + "width8_free_concentration_45": "1952100603477031/1000000000000000000" + }, + "claims": [ + "The frozen PR589 nine-stage hosting has the unique slot model {7:666, 14:444, 28:444, 42:444} per replica (41958 coordinates, equal to the coverage pending capacity).", + "No no-bank placement of the width-8 residuals raises the bit endpoint on the 1e-24 grid: at c0+1e-24 a fully idle 42-slot is the certified unique cheapest unit of the 45 slack units per replica.", + "Width-7 residuals fill all slots exactly; converting all 439 helpers gives bit c in [0.002035707659654698, 0.002139162156009728] with idle {42:340, 21:1} per replica; partial conversions k=1,10,37,74 give +0.068..0.082%, +0.72..0.86%, +2.7..3.2%, +5.6..6.7%.", + "Supporting evidence: all six one-level windows of the selected complex T37 hosting on the same nine-stage template are fully hosted." + ], + "contributor": "Sagar Thakrar (thakrarsagar)", + "expected_last_line": "PASS_BIT589_WIDTH_PACKING_REPLAY", + "license": "Apache-2.0", + "not_claimed": [ + "a width-7 bit construction", + "window timing for bit one-level windows", + "a new selected kappa (kappa is complex-bound)", + "optimality of the partial-conversion placements", + "any inherited all-size, realization, hosting, precision/tape, analytic or bit H1-H5 assumption" + ], + "reproduce": "make bit589-width-packing-verify", + "seed_source": "Python secrets (OS CSPRNG)", + "selected_kappa_unchanged": "1661960547713947/1000000000000000000", + "status": "research note / scoped negative result (bit supplier); no new kappa", + "track": "00-19 bit supplier" +} diff --git a/research/bit589-width-packing/README.md b/research/bit589-width-packing/README.md new file mode 100644 index 0000000000..a915381a7a --- /dev/null +++ b/research/bit589-width-packing/README.md @@ -0,0 +1,153 @@ +# Width packing of the selected PR589 bit hosting + +**Status: research note and scoped negative result (bit supplier). No new κ; the selected result is +unchanged and complex-bound.** +Track 00–19 (bit supplier), assignment seed 16 (OS CSPRNG via Python `secrets`). +Base commit `2921874911956718fcaaaf9396fe8267b3cfa9f0`. + +## Question + +The selected bit supplier is DreamingOfClouds' PR589 on eumemic's PR555, with +c = 0.001733427039589844234749. It hosts all 3,951 width-8 helper residuals per replica in the +nine-stage idle windows, with no banks, yet its idle remainders are fragmented: +`{2:435, 4:444, 6:444, 7:666, 42:9}` per replica. Can re-hosting improve the bit profile, and +what would a different helper width be worth? + +## Findings + +1. **Slot model (exact, unique).** The nine slot indices of the frozen selection hold one pair's + 222 families each. Their capacities are `{14, 7, 28, 7, 42, 7, 42, 28, 14}`, so per replica there + are 666 slots of capacity 7, 444 of 14, 444 of 28 and 444 of 42. The total, 41,958 coordinates, + equals the coverage-identity pending capacity `2v·42 + 6v·49`. These are the template's one-, + two-, four- and six-level windows at 7 coordinates per level, the same window structure the + complex template has at 8 per level. The deficit satisfies `live − 63·calls = 10,272`. +2. **Width-8 re-hosting cannot help (certified).** + - 8 divides no capacity, so every slot keeps a remainder of at least 7, 6, 4 or 2. Every + no-bank placement therefore has exactly one idle child per slot. + - Only 45 width-8 units of slack exist per replica (1,440 in total). + - At c* = c0 + 10⁻²⁴, the per-unit cost of a fully idle capacity-42 slot is certified strictly + below every other (capacity, unused units) option. The runner-up is (42, 4), behind by a + certified 0.0026 in units of g(r) = r(64/r)^c. + - So the selected placement, with 9 fully idle 42-slots per replica, minimizes the moment. + No re-hosting raises the bit endpoint on the 10⁻²⁴ grid, and the +12.3% + "free-concentration" relaxation is unreachable at width 8. +3. **Width-7 residuals fill every slot exactly.** A helper of width 7 (a hyperplane end or a + rank-one entrance) leaves no remainder in a 7k slot. Converting all 439 helpers per call leaves + 2,043 units of slack per replica. The majorization optimum then leaves only `{42: 340, 21: 1}` + idle children per replica, against 1,998 now. The bit c rises by +17.4% to +23.4%. +4. **Partial conversion already pays.** Converting k helper indices in every call, with their + width-7 residuals filling empty 7-slots and the freed width-8 slack going to fully idle + 42-slots, gives the table below. +5. **Window timing: supporting evidence only.** The 7-slots are the template's one-level windows. + In the selected complex T37 hosting on the same nine-stage template, all six one-level windows + (children 1, 3, 5, 7, 9 and 11) are completely hosted: 198,912 coordinates, 0 idle. That + suggests one-level windows admit hosted residuals, but the bit-side timing check is not done. + +## Exact prices + +Each bit endpoint is certified by both pinned engines, with the inherited bad-residue surcharge: +the moment is below one at c and above one at c + 10⁻²⁴. The κ cap is the selected T37 outer +witness with the bit side binding: 7 bootstrap steps, all 47 inequalities, and κ + 10⁻¹⁸ +rejected. The selected κ stays 0.001661960547713947 because the complex side binds. + +| Scenario (one unit removed from one local child per converted helper) | Bit c | Gain | Bit-bound κ cap | +|---|---|---:|---| +| selected PR589 profile (reproduced exactly) | 0.0017334270395898442 | — | 0.001730427469823602 | +| 1 helper per call width 7, rank-one child removed / largest child trimmed | 0.0017348463 / 0.0017346035 | +0.082% / +0.068% | 0.001731841784869670 / 0.001731599905939462 | +| 10 helpers per call | 0.0017482911 / 0.0017458293 | +0.857% / +0.715% | 0.001745239939229085 / 0.001742786661941923 | +| 37 helpers per call | 0.0017896275 / 0.0017805126 | +3.24% / +2.72% | 0.001786430419444784 / 0.001777348059220582 | +| 74 helpers per call (all 666 empty 7-slots used) | 0.0018497057 / 0.0018312021 | +6.71% / +5.64% | 0.001846290613254756 / 0.001827854925395469 | +| all 439 helpers width 7, slot-exact optimum | 0.0021391622 / 0.0020357077 | +23.41% / +17.44% | 0.002134595909222345 / 0.002031571973028065 | +| relaxation: width-8 idle mass in rank-42 children | 0.0019472877 | +12.34% | 0.001943503128837276 | + +The bracket gives two bounds for a conversion that removes exactly one unit from one local child. +Removing a rank-one child gives the largest gain and trimming the largest children gives the +smallest, because g is concave. The partial rows use one constructive slot-exact placement, so +for those k they are achievable values in the slot model, not optima. The last row ignores the +slot structure that finding 2 proves binding. + +## What this means + +- These numbers are **bit headroom**. They give the κ that the selected outer recipe would allow if + the complex side improved past the bit side. Today's bit cap, 0.001730427469823602, matches the + value recorded in PR974. +- No hosting or owner work on the current bit word can raise c. The lever is helper width. + Converting one helper index in every call, with its residuals in empty 7-slots, is worth about + +0.07% to +0.08% bit c, more than the whole PR589 tuning step (+0.0216%). +- Width-7 mechanisms already exist on the complex side: hyperplane-ended helpers (PR601, PR593) + and width-seven entrance promotions (PR569). Their bit analogues are the natural next + construction targets. The first obstruction is the bit word's literal reverse cleanup at the + full frame (interface hypothesis H4): a hyperplane end needs that helper's cleanup retimed. + +## Remaining obligations (none attempted) + +1. Construct width-7 bit helpers, either as hyperplane ends with cleanup retiming or as rank-one + entrances with kernels. Keep H1–H5 or state a replacement interface, with exact scalar and + dirty-state checks. +2. Check window timing: the one-level bit windows must admit the converted residuals, with owner + inactivity and one helper per family per call, through the PR510/PR463 hosting audit. +3. Re-emit the hosted template and rerun the hosted audit, the finite invoice (prefix bits, row + coefficient) and the bit assembly. +4. A real conversion may change more than one unit of one child, which the bracket does not cover. + +## Scope and limits + +- The slot model comes from the frozen selection and the pinned record. It is the unique solution + consistent with the observed remainders and the coverage capacity. Findings 2–4 do not impose + window timing or per-call ownership rules; the baseline placement satisfies them as selected. +- Finding 2 compares no-bank placements only. Banks add live stock without free coordinates. +- All inherited assumptions remain: all-size compilation, common-label/mutable-source + realization, whole-call hosting, precision/tape, analytic transfer, bit H1–H5 and the bit + bad-residue surcharge, which every price above keeps. This is not a construction and not a + formal proof of the multiplication theorem. + +## Reproduce + +```sh +make bit589-width-packing-verify +``` + +The same check without make: + +```sh +python3 -B research/bit589-width-packing/verify.py --work /new/empty/dir +python3 -B -m unittest discover -s research/bit589-width-packing -p test_package.py -v +``` + +The expected last line is `PASS_BIT589_WIDTH_PACKING_REPLAY`, followed by 6 tests OK. It runs in +about 3 s on standard-library Python 3.10+ with no network. + +- `verify.py` regenerates `RESULT.json` and requires it to equal the committed file. +- It checks the T37 one-level-window evidence from the pinned T37 archive, read in memory. +- It runs six negative controls: + +| Control | Rejected because | +|---|---| +| C1 one residual moved between slot indices | stage and pattern totals disagree | +| C2 a capacity divisible by 8 | the per-unit argument refuses exact width-8 fits | +| C3 corrupted record pin | digest mismatch | +| C4 bit endpoint c + 10⁻²⁴ | both engines exceed one, surcharge included | +| C5 a width-7 profile that drops the freed coordinates | rank mass changes | +| C6 more converted residuals than empty 7-slots | the constructive placement refuses | + +## Sources and pins + +See [`SOURCES.json`](SOURCES.json). + +- **Bit record.** `research/e8-bit-p111-tuned/tune/EXPECTED.json` (`b9f0e5ca…`). This digest is + the `package:inputs/PR589-EXPECTED.json` input of the selected `ASSEMBLY.json`. +- **Hosting selection.** `research/e8-bit-p111-tuned/data/selection9-p111.json` (`4ab1ed45…`). +- **Engines.** The pinned engines recorded in the selected assembly. +- **Outer witness.** Transcribed from the selected T37 archive. +- **Supporting evidence.** The selected T37 hosted template (payload `956e0c0e…`). + +## Credit + +- DreamingOfClouds: the PR589 word and the PR510/PR463 nine-stage bit template. +- eumemic: the PR555 punctured unit and selection. +- DaysSky: the idle-axis hosting of PR442. +- Jeremy Kothe: hyperplane-ended helpers (PR601). +- Dominik Scholz: width-seven complex providers (PR569, `research/larger-gain`). +- avirazza: the bit cap value of PR974. +- Prepared by Sagar Thakrar (thakrarsagar) with substantial AI assistance from Claude + (Anthropic) via Claude Code. New material is Apache-2.0. diff --git a/research/bit589-width-packing/RESULT.json b/research/bit589-width-packing/RESULT.json new file mode 100644 index 0000000000..f11f6e569c --- /dev/null +++ b/research/bit589-width-packing/RESULT.json @@ -0,0 +1,348 @@ +{ + "base_commit": "2921874911956718fcaaaf9396fe8267b3cfa9f0", + "scenarios": { + "selected": { + "bit_bound_kappa_cap": "865213734911801/500000000000000000", + "bit_bound_kappa_cap_decimal": "0.001730427469823602", + "bit_decimal": "0.001733427039589844234749", + "bit_gain_percent": "0", + "bit_lower": "1733427039589844234749/1000000000000000000000000", + "children": 904896, + "description": "Selected PR589 profile (reproduced exactly).", + "profile": { + "1": 381024, + "2": 400416, + "3": 22752, + "4": 26880, + "42": 288, + "5": 29376, + "6": 17376, + "7": 26784 + } + }, + "width7_all_optimistic": { + "bit_bound_kappa_cap": "426919181844469/200000000000000000", + "bit_bound_kappa_cap_decimal": "0.002134595909222345", + "bit_decimal": "0.002139162156009727616613", + "bit_gain_percent": "23.4065297906", + "bit_lower": "2139162156009727616613/1000000000000000000000000", + "children": 725440, + "description": "All 439 helpers width 7; each removes one rank-one child; slot-exact packing with all slack in fully idle 42-slots.", + "profile": { + "1": 254592, + "2": 386496, + "21": 32, + "3": 22752, + "4": 12672, + "42": 10880, + "5": 29376, + "6": 3168, + "7": 5472 + } + }, + "width7_all_pessimistic": { + "bit_bound_kappa_cap": "406314394605613/200000000000000000", + "bit_bound_kappa_cap_decimal": "0.002031571973028065", + "bit_decimal": "0.002035707659654698161741", + "bit_gain_percent": "17.4383238037", + "bit_lower": "2035707659654698161741/1000000000000000000000000", + "children": 851872, + "description": "Same packing; each converted helper trims one of the 439 largest distinct local children by one.", + "profile": { + "1": 434016, + "2": 356256, + "21": 32, + "3": 12672, + "4": 29376, + "42": 10880, + "5": 3168, + "6": 5472 + } + }, + "width7_k10_optimistic": { + "bit_bound_kappa_cap": "349047987845817/200000000000000000", + "bit_bound_kappa_cap_decimal": "0.001745239939229085", + "bit_decimal": "0.001748291126728852518913", + "bit_gain_percent": "0.857497131378", + "bit_lower": "1748291126728852518913/1000000000000000000000000", + "children": 899136, + "description": "10 helpers per call width 7 (each removes one rank-one child); their residuals fill empty 7-slots; width-8 slack in fully idle 42-slots.", + "profile": { + "1": 378144, + "2": 399840, + "3": 22752, + "4": 26880, + "42": 864, + "5": 29376, + "6": 17376, + "7": 23904 + } + }, + "width7_k10_pessimistic": { + "bit_bound_kappa_cap": "1742786661941923/1000000000000000000", + "bit_bound_kappa_cap_decimal": "0.001742786661941923", + "bit_decimal": "0.001745829269907545754175", + "bit_gain_percent": "0.715474608071", + "bit_lower": "69833170796301830167/40000000000000000000000", + "children": 902016, + "description": "Same placement; each of the 10 converted helpers trims one of the largest distinct children.", + "profile": { + "1": 381024, + "2": 399840, + "3": 22752, + "4": 26880, + "42": 864, + "5": 29376, + "6": 20256, + "7": 21024 + } + }, + "width7_k1_optimistic": { + "bit_bound_kappa_cap": "173184178486967/100000000000000000", + "bit_bound_kappa_cap_decimal": "0.00173184178486967", + "bit_decimal": "0.001734846264120199151475", + "bit_gain_percent": "0.0818739120794", + "bit_lower": "69393850564807966059/40000000000000000000000", + "children": 904320, + "description": "1 helpers per call width 7 (each removes one rank-one child); their residuals fill empty 7-slots; width-8 slack in fully idle 42-slots.", + "profile": { + "1": 380736, + "2": 400352, + "3": 22752, + "34": 32, + "4": 26880, + "42": 320, + "5": 29376, + "6": 17376, + "7": 26496 + } + }, + "width7_k1_pessimistic": { + "bit_bound_kappa_cap": "865799952969731/500000000000000000", + "bit_bound_kappa_cap_decimal": "0.001731599905939462", + "bit_decimal": "0.001734603545275303824122", + "bit_gain_percent": "0.0678716587771", + "bit_lower": "867301772637651912061/500000000000000000000000", + "children": 904608, + "description": "Same placement; each of the 1 converted helpers trims one of the largest distinct children.", + "profile": { + "1": 381024, + "2": 400352, + "3": 22752, + "34": 32, + "4": 26880, + "42": 320, + "5": 29376, + "6": 17664, + "7": 26208 + } + }, + "width7_k37_optimistic": { + "bit_bound_kappa_cap": "111651901215299/62500000000000000", + "bit_bound_kappa_cap_decimal": "0.001786430419444784", + "bit_decimal": "0.001789627464386638781647", + "bit_gain_percent": "3.24215692459", + "bit_lower": "1789627464386638781647/1000000000000000000000000", + "children": 883584, + "description": "37 helpers per call width 7 (each removes one rank-one child); their residuals fill empty 7-slots; width-8 slack in fully idle 42-slots.", + "profile": { + "1": 370368, + "2": 398272, + "26": 32, + "3": 22752, + "4": 26880, + "42": 2400, + "5": 29376, + "6": 17376, + "7": 16128 + } + }, + "width7_k37_pessimistic": { + "bit_bound_kappa_cap": "888674029610291/500000000000000000", + "bit_bound_kappa_cap_decimal": "0.001777348059220582", + "bit_decimal": "0.001780512649923341060004", + "bit_gain_percent": "2.71633067087", + "bit_lower": "445128162480835265001/250000000000000000000000", + "children": 894240, + "description": "Same placement; each of the 37 converted helpers trims one of the largest distinct children.", + "profile": { + "1": 381024, + "2": 398272, + "26": 32, + "3": 22752, + "4": 28896, + "42": 2400, + "5": 30528, + "6": 19680, + "7": 10656 + } + }, + "width7_k74_optimistic": { + "bit_bound_kappa_cap": "461572653313689/250000000000000000", + "bit_bound_kappa_cap_decimal": "0.001846290613254756", + "bit_decimal": "0.001849705707539871039662", + "bit_gain_percent": "6.70802204502", + "bit_lower": "924852853769935519831/500000000000000000000000", + "children": 862272, + "description": "74 helpers per call width 7 (each removes one rank-one child); their residuals fill empty 7-slots; width-8 slack in fully idle 42-slots.", + "profile": { + "1": 359712, + "10": 32, + "2": 396128, + "3": 22752, + "4": 26880, + "42": 4544, + "5": 29376, + "6": 17376, + "7": 5472 + } + }, + "width7_k74_pessimistic": { + "bit_bound_kappa_cap": "1827854925395469/1000000000000000000", + "bit_bound_kappa_cap_decimal": "0.001827854925395469", + "bit_decimal": "0.001831202097168172884608", + "bit_gain_percent": "5.64056377022", + "bit_lower": "14306266384126350661/7812500000000000000000", + "children": 883584, + "description": "Same placement; each of the 74 converted helpers trims one of the largest distinct children.", + "profile": { + "1": 381024, + "10": 32, + "2": 396128, + "3": 22752, + "4": 39552, + "42": 4544, + "5": 19872, + "6": 19680 + } + }, + "width8_free_concentration_42": { + "bit_bound_kappa_cap": "485875782209319/250000000000000000", + "bit_bound_kappa_cap_decimal": "0.001943503128837276", + "bit_decimal": "0.001947287688552724683212", + "bit_gain_percent": "12.3374473848", + "bit_lower": "486821922138181170803/250000000000000000000000", + "children": 848864, + "description": "Relaxation: the width-8 idle mass placed in children of rank 42, ignoring slots and windows.", + "profile": { + "1": 381024, + "18": 32, + "2": 386496, + "3": 22752, + "4": 12672, + "42": 7872, + "5": 29376, + "6": 3168, + "7": 5472 + } + }, + "width8_free_concentration_45": { + "bit_bound_kappa_cap": "1952100603477031/1000000000000000000", + "bit_bound_kappa_cap_decimal": "0.001952100603477031", + "bit_decimal": "0.001955918753656396649358", + "bit_gain_percent": "12.8353665303", + "bit_lower": "977959376828198324679/500000000000000000000000", + "children": 848320, + "description": "Relaxation: the width-8 idle mass placed in children of rank 45, ignoring slots and windows.", + "profile": { + "1": 381024, + "2": 386496, + "3": 22752, + "4": 12672, + "45": 7360, + "5": 29376, + "6": 3168, + "7": 5472 + } + } + }, + "slot_model": { + "capacity_by_slot_index": { + "0": 14, + "1": 7, + "2": 28, + "3": 7, + "4": 42, + "5": 7, + "6": 42, + "7": 28, + "8": 14 + }, + "deficit": 10272, + "deficit_identity": "live - 63*calls = 10272", + "idle_per_replica": { + "2": 435, + "4": 444, + "42": 9, + "6": 444, + "7": 666 + }, + "pending_per_replica": 41958, + "slots_per_replica": { + "14": 444, + "28": 444, + "42": 444, + "7": 666 + } + }, + "status": "PASS_BIT589_WIDTH_PACKING", + "width7": { + "idle_children_per_replica": 341, + "optimal_idle_per_replica": { + "21": 1, + "42": 340 + }, + "selected_idle_children_per_replica": 1998, + "slack_units_per_replica": 2043 + }, + "width8_optimality": { + "cheapest": "capacity 42, fully idle (u = 5)", + "margin_lower_bound": "0.0025867731454302305368", + "minimal_remainders": { + "14": 6, + "28": 4, + "42": 2, + "7": 7 + }, + "per_unit_cost_at_c_star": { + "14:1": [ + "8.012261730616606358486452070", + "8.012261730616606358486452070" + ], + "28:1": [ + "8.015600568842465243344660769", + "8.015600568842465243344660769" + ], + "28:2": [ + "8.010547414397666181811023064", + "8.010547414397666181811023064" + ], + "28:3": [ + "8.006960601958642312442335658", + "8.006960601958642312442335658" + ], + "42:1": [ + "8.020178032381055354399300654", + "8.020178032381055354399300654" + ], + "42:2": [ + "8.013785937960316489456745112", + "8.013785937960316489456745112" + ], + "42:3": [ + "8.009525996458196087319239566", + "8.009525996458196087319239566" + ], + "42:4": [ + "8.006311939489351423735407976", + "8.006311939489351423735407976" + ], + "42:5": [ + "8.003725166343921193198598107", + "8.003725166343921193198598107" + ] + }, + "runner_up": "capacity 42, u = 4", + "slack_units_per_replica": 45 + } +} diff --git a/research/bit589-width-packing/SOURCES.json b/research/bit589-width-packing/SOURCES.json new file mode 100644 index 0000000000..f6a97de326 --- /dev/null +++ b/research/bit589-width-packing/SOURCES.json @@ -0,0 +1,32 @@ +{ + "base_commit": "2921874911956718fcaaaf9396fe8267b3cfa9f0", + "inputs": { + "bit_record": { + "path": "research/e8-bit-p111-tuned/tune/EXPECTED.json", + "sha256": "b9f0e5ca038abe837b0007c8fe006f366a6f02009244ac57705a8a200e2301f4", + "binding": "equals input_sha256['package:inputs/PR589-EXPECTED.json'] of the selected ASSEMBLY.json" + }, + "selection": { + "path": "research/e8-bit-p111-tuned/data/selection9-p111.json", + "sha256": "4ab1ed4529683cd184987f8bc3031fb7408b9cd22c25ab9cf541a8aaf896eaf1", + "binding": "the frozen nine-stage hosting selection used by the PR589 pipeline (tune/README: same frozen hosting selections)" + }, + "selected_assembly": { + "path": "research/community-frontier942-audit/ASSEMBLY.json", + "sha256": "4b2894956e594e408e111d806c842f2ed2c32aefcadff93fad69ff0b46f1991a" + } + }, + "engines": { + "directory": "research/native-complex-moment552/engines", + "moment.py": "81cbc864e106418fc7854322746f72180cb8110ff39f74450a3b8d55a82c1482", + "base_two_moment.py": "aee70c242a2f1d225528fabe2002e1564d1dc884797c07d28a831c7878ee9098", + "outer.py": "c1ebb52163a7219504c728a5c2b098bf1e50bf20148a2879c5a74c3cadc7c03c", + "binding": "the same digests are recorded under input_sha256 of the selected ASSEMBLY.json" + }, + "outer_witness": { + "source": "outer_witness in runtime/code/assemble.py of research/community-frontier942-audit/t37-replay.tar.gz (sha256 d89ed7a6...)", + "eta": "1/1000000000000000000000000", + "bootstrap_start": "384599/10000000000", + "bootstrap_steps": 7 + } +} diff --git a/research/bit589-width-packing/packing.py b/research/bit589-width-packing/packing.py new file mode 100644 index 0000000000..a6079ee0dd --- /dev/null +++ b/research/bit589-width-packing/packing.py @@ -0,0 +1,329 @@ +# SPDX-License-Identifier: Apache-2.0 +"""Width packing of the selected PR589 nine-stage bit hosting. + +Usage: packing.py OUT.json + +1. Derives the idle-slot model of the frozen nine-stage hosting selection from the + pinned PR589 record (profile, local histogram) and its selection file. +2. Certifies that no other no-bank placement of the 439 width-8 residuals per call + raises the bit endpoint on the 10^-24 grid (per-unit cost argument at c0 + 10^-24). +3. Prices width-7 residuals (hyperplane-ended or rank-one-entrance helpers), which fill + the 7k-capacity slots exactly, with a two-sided bracket for the local change. +Standard library only; the rational engines are the pinned ones of the selected assembly. +""" +import hashlib +import importlib.util +import json +import sys +from collections import Counter +from decimal import Decimal, localcontext +from fractions import Fraction as Q +from pathlib import Path + +HERE = Path(__file__).resolve().parent +ROOT = HERE.parents[1] +SOURCES = json.loads((HERE / 'SOURCES.json').read_text()) +M_BIT = 64 # 1 + 7L with L = 9 stages +T = 32 # replicas +STAGES = 9 + + +def require(ok, message): + if not ok: + raise ValueError(message) + + +def sha256(data): + return hashlib.sha256(data).hexdigest() + + +def pinned_json(key): + src = SOURCES['inputs'][key] + data = (ROOT / src['path']).read_bytes() + require(sha256(data) == src['sha256'], f'{key}: digest mismatch') + return json.loads(data) + + +def engine(name): + path = ROOT / SOURCES['engines']['directory'] / (name + '.py') + require(sha256(path.read_bytes()) == SOURCES['engines'][name + '.py'], f'engine pin {name}') + spec = importlib.util.spec_from_file_location('pinned_' + name, path) + mod = importlib.util.module_from_spec(spec) + spec.loader.exec_module(mod) + return mod + + +MOMENT, BASE_TWO, OUTER = engine('moment'), engine('base_two_moment'), engine('outer') + + +def cj(c): + return {str(k): c[k] for k in sorted(c) if c[k]} + + +# --------------------------------------------------------------------------- +# 1. Slot model. + +def slot_model(record, selection): + word, nine = record['word'], record['nine'] + v, R = word['v'], word['R'] + require(nine['bit']['live'] == 2 * 4 * v * T, 'live stock is 2KvT') + H = Counter({int(k): n for k, n in nine['profile'].items()}) + local = Counter({int(k): n for k, n in word['local_histogram'].items()}) + calls = STAGES * T + idle = Counter(H) + idle.subtract(Counter({r: n * calls for r, n in local.items()})) + idle = +idle + require(all(n % T == 0 for n in idle.values()), 'idle profile is replica-uniform') + idle_rep = Counter({r: n // T for r, n in idle.items()}) + pats = selection['bit']['patterns'] + fams = Counter() + hosted = {} + for s, widths, count in pats: + require(all(w == 8 for w in widths), 'every PR589 residual has width 8') + fams[s] += count + hosted.setdefault(s, []).append((8 * len(widths), count)) + require(set(fams.values()) == {2 * v}, 'each slot index holds one pair (2v families)') + st = Counter() + for s, w, stage, count in selection['bit']['stages']: + st[s] += w * count + require(st == Counter({s: sum(h * n for h, n in L) for s, L in hosted.items()}), 'stage and pattern totals agree') + require(sum(st.values()) == 8 * STAGES * R, 'every residual is hosted, no banks') + # Capacity of each slot index: a multiple of 7 whose remainders reproduce the idle profile. + ranks = set(idle_rep) + options = {} + for s, L in hosted.items(): + options[s] = [c for c in range(7, 8 * 7, 7) if all(c >= h and c - h in ranks for h, _ in L)] + solutions = [] + + def search(keys, chosen): + if not keys: + rem = Counter() + for s, c in chosen.items(): + for h, n in hosted[s]: + rem[c - h] += n + if rem == idle_rep: + solutions.append(dict(chosen)) + return + for c in options[keys[0]]: + search(keys[1:], {**chosen, keys[0]: c}) + search(sorted(hosted), {}) + require(len(solutions) == 1, f'capacity model is not unique: {solutions}') + caps = solutions[0] + pending = sum(c * fams[s] for s, c in caps.items()) + # Coverage: data families get 7 coordinates per invocation plus one free coordinate. + require(pending == 2 * v * (M_BIT - 1 - 7 * 3) + 6 * v * (M_BIT - 1 - 7 * 2), 'pending capacity matches coverage') + slots = Counter() + for s, c in caps.items(): + slots[c] += fams[s] + return dict(v=v, R=R, calls=calls, H=H, local=local, idle_rep=idle_rep, caps=caps, slots=slots, + pending=pending, deficit=M_BIT * nine['bit']['live'] - sum(r * n for r, n in H.items())) + + +# --------------------------------------------------------------------------- +# Certified values of g(r) = r (m/r)^c with the engine's outward-rounded series. + +def g_interval(r, c): + lo_l, hi_l = MOMENT.logarithm(Q(M_BIT, r)) + lo_e, hi_e = MOMENT.exponential(c * lo_l, c * hi_l) + return r * lo_e, r * hi_e + + +def width8_optimality(model, c_star): + """Every no-bank width-8 placement has the same number of idle children, one per slot. + Its idle part exceeds the selected one by sum_slots u_s * rho(t_s, u_s), where u_s is the + number of unused width-8 places. If rho is minimal only at (42, 5), the selected placement, + which spends all slack on fully idle 42-slots, minimizes the moment at c_star.""" + rmin = {c: c % 8 for c in model['slots']} + umax = {c: c // 8 for c in model['slots']} + require(all(rmin[c] > 0 for c in rmin), 'no slot capacity is divisible by 8') + slack = sum(umax[c] * n for c, n in model['slots'].items()) - STAGES * model['R'] + require(slack == 45, 'slack per replica') + sel = Counter({c: n for c, n in model['idle_rep'].items()}) + require(sel == Counter({7: 666, 6: 444, 4: 444, 2: 435, 42: 9}), 'selected remainders') + rho = {} + for c in sorted(model['slots']): + for u in range(1, umax[c] + 1): + a_lo, a_hi = g_interval(rmin[c] + 8 * u, c_star) + b_lo, b_hi = g_interval(rmin[c], c_star) + rho[(c, u)] = ((a_lo - b_hi) / u, (a_hi - b_lo) / u) + best = rho[(42, 5)] + others = {k: v for k, v in rho.items() if k != (42, 5)} + require(all(best[1] < lo for lo, _ in others.values()), 'fully idle 42-slots are the unique cheapest units') + second = min(others, key=lambda k: others[k][0]) + return dict(slack_units_per_replica=slack, minimal_remainders={str(c): rmin[c] for c in sorted(rmin)}, + per_unit_cost_at_c_star={f'{c}:{u}': [str(Decimal(lo.numerator) / Decimal(lo.denominator))[:32], + str(Decimal(hi.numerator) / Decimal(hi.denominator))[:32]] + for (c, u), (lo, hi) in sorted(rho.items())}, + cheapest='capacity 42, fully idle (u = 5)', runner_up=f'capacity {second[0]}, u = {second[1]}', + margin_lower_bound=str(Decimal((others[second][0] - best[1]).numerator) / + Decimal((others[second][0] - best[1]).denominator))[:24]) + + +def width7_idle(model): + """All residuals of width 7: exact fits; the slack majorization optimum (6,...,6,rest).""" + units = sum((c // 7) * n for c, n in model['slots'].items()) - STAGES * model['R'] + q, rest = divmod(units, 6) + out = Counter({42: q}) + if rest: + out[7 * rest] += 1 + return units, out + + +def width7_partial_idle(model, k): + """k converted helpers per call (9k width-7 residuals per replica), constructive placement: + width-7 residuals fill empty capacity-7 slots exactly; width-8 residuals keep the minimal + remainders, and all width-8 slack goes to fully idle 42-slots (the certified cheapest units), + with at most one partially idle 42-slot.""" + slots = model['slots'] + require(STAGES * k <= slots[7], 'this construction places width-7 residuals in 7-slots only') + slack = 45 + STAGES * k + full, part = divmod(slack, 5) + idle = Counter({7: slots[7] - STAGES * k, 6: slots[14], 4: slots[28], 42: full}) + rest42 = slots[42] - full - (1 if part else 0) + require(rest42 >= 0, 'enough 42-slots') + idle[2] += rest42 + if part: + idle[2 + 8 * part] += 1 + hosted8 = sum((c // 8) * n for c, n in slots.items()) - slack + require(hosted8 == STAGES * (model['R'] - k), 'every width-8 residual hosted') + return +idle + + +def local_bracket(local, k): + """Remove one unit from one child for each of k converted helpers per call.""" + opt = Counter(local) + require(opt[1] >= k, 'enough rank-one children') + opt[1] -= k + pes = Counter(local) + left = k + for r in sorted(local, reverse=True): + take = min(left, local[r]) + pes[r] -= take + if r > 1: + pes[r - 1] += take + left -= take + if not left: + break + require(left == 0, 'enough children') + return +opt, +pes + + +def endpoint(H, W): + b = Q(MOMENT.certify(H, M_BIT, W, True)['lower']) + for z, accept in ((b, True), (b + Q(1, 10 ** 24), False)): + lo, hi = MOMENT.moment(H, M_BIT, W, z, True) + blo, bhi = BASE_TWO.moment(M_BIT, W, list(H.items()), z) + flo, fhi = BASE_TWO.moment(M_BIT, W, [(1, 32 * M_BIT * M_BIT * sum(H.values()))], z) + blo += flo / 10 ** 16 + bhi += fhi / 10 ** 16 + require((hi < 1 and bhi < 1) if accept else (lo > 1 and blo > 1), 'bit endpoint certification') + return b + + +def kappa_cap(c): + """kappa of the selected T37 outer witness when the bit side binds (complex b = 2c).""" + ow = SOURCES['outer_witness'] + eta = beta = Q(ow['eta']) + bb = 2 * c + s = min(c, (1 - beta) * bb) - Q(1, 10 ** 27) + chain = [Q(ow['bootstrap_start'])] + for _ in range(ow['bootstrap_steps']): + old = chain[-1] + a = (1 - s) * s + s * old + require(old < a < s < 1 - a, 'bootstrap step') + chain.append(a) + q = chain[-1] * (1 - 2 * eta) + ticks = (1 - eta) * q / (1 + q) * 10 ** 18 + k = Q((ticks.numerator - 1) // ticks.denominator, 10 ** 18) + bridge = {'semantic': {'C0': {'base': 2, 'exponent': 210000}, 'strict_literal_gap': 1}, + 'rows': {'degree_gap': Q(10 ** 6) - Q(51 * 20161, 25)}} + out = OUTER.assembly(chain[-1], bb, bridge, k, eta=eta, beta=beta) + require(all(x > 0 for x in out['strict_constraints'].values()), 'outer inequalities') + try: + OUTER.assembly(chain[-1], bb, bridge, k + Q(1, 10 ** 18), eta=eta, beta=beta) + except AssertionError: + return k + raise ValueError('next grid point accepted') + + +def dec(x, prec=40): + with localcontext() as ctx: + ctx.prec = prec + return str(Decimal(x.numerator) / Decimal(x.denominator)) + + +def main(): + record = pinned_json('bit_record') + selection = pinned_json('selection') + assembly = pinned_json('selected_assembly') + require(SOURCES['inputs']['bit_record']['sha256'] == assembly['input_sha256']['package:inputs/PR589-EXPECTED.json'], + 'bit record is the input of the selected assembly') + model = slot_model(record, selection) + W = record['nine']['bit']['live'] + H0 = dict(model['H']) + c0 = endpoint(H0, W) + require(str(c0) == assembly['bit_lower'] == record['nine']['bit_lower'], 'baseline bit endpoint') + c_star = c0 + Q(1, 10 ** 24) + optimality = width8_optimality(model, c_star) + calls = model['calls'] + rows = {} + + def add(key, local, idle_rep, description): + H = Counter({r: n * calls for r, n in local.items()}) + H.update({r: n * T for r, n in idle_rep.items()}) + H = +H + require(M_BIT * M_BIT > 2 * max(H) ** 2, f'{key}: halving guard') + require(sum(r * n for r, n in H.items()) == sum(r * n for r, n in H0.items()), f'{key}: rank mass changes') + c = endpoint(dict(H), W) + k = kappa_cap(c) + rows[key] = dict(description=description, profile=cj(H), children=sum(H.values()), bit_lower=str(c), + bit_decimal=dec(c), bit_gain_percent=dec(100 * (c - c0) / c0, 12), + bit_bound_kappa_cap=str(k), bit_bound_kappa_cap_decimal=dec(k)) + + add('selected', model['local'], model['idle_rep'], 'Selected PR589 profile (reproduced exactly).') + units, idle7 = width7_idle(model) + opt, pes = local_bracket(model['local'], model['R']) + add('width7_all_optimistic', opt, idle7, + 'All 439 helpers width 7; each removes one rank-one child; slot-exact packing with all slack in ' + 'fully idle 42-slots.') + add('width7_all_pessimistic', pes, idle7, + 'Same packing; each converted helper trims one of the 439 largest distinct local children by one.') + for k in (1, 10, 37, 74): + opt_k, pes_k = local_bracket(model['local'], k) + idle_k = width7_partial_idle(model, k) + add(f'width7_k{k}_optimistic', opt_k, idle_k, + f'{k} helpers per call width 7 (each removes one rank-one child); their residuals fill ' + f'empty 7-slots; width-8 slack in fully idle 42-slots.') + add(f'width7_k{k}_pessimistic', pes_k, idle_k, + f'Same placement; each of the {k} converted helpers trims one of the largest distinct children.') + for cap in (42, 45): + mass = sum(r * n for r, n in model['idle_rep'].items()) + q, rest = divmod(mass, cap) + idle = Counter({cap: q}) + if rest: + idle[rest] += 1 + add(f'width8_free_concentration_{cap}', model['local'], idle, + f'Relaxation: the width-8 idle mass placed in children of rank {cap}, ignoring slots and windows.') + result = dict(status='PASS_BIT589_WIDTH_PACKING', base_commit=SOURCES['base_commit'], + slot_model=dict(capacity_by_slot_index={str(s): c for s, c in sorted(model['caps'].items())}, + slots_per_replica=cj(model['slots']), pending_per_replica=model['pending'], + idle_per_replica=cj(model['idle_rep']), deficit=model['deficit'], + deficit_identity='live - 63*calls = %d' % (W - 63 * calls)), + width8_optimality=optimality, + width7=dict(slack_units_per_replica=units, optimal_idle_per_replica=cj(idle7), + idle_children_per_replica=sum(idle7.values()), + selected_idle_children_per_replica=sum(model['idle_rep'].values())), + scenarios=rows) + require(model['deficit'] == W - 63 * calls, 'deficit identity') + with open(sys.argv[1], 'w') as f: + f.write(json.dumps(result, indent=1, sort_keys=True) + '\n') + print(result['status']) + print('slots per replica', cj(model['slots']), 'slack', optimality['slack_units_per_replica'], + 'runner-up', optimality['runner_up'], 'margin', optimality['margin_lower_bound']) + for key, row in rows.items(): + print(f"{key:30s} c {row['bit_decimal'][:22]} gain {row['bit_gain_percent'][:9]}% " + f"bit-bound kappa cap {row['bit_bound_kappa_cap_decimal'][:21]}") + + +if __name__ == '__main__': + main() diff --git a/research/bit589-width-packing/test_package.py b/research/bit589-width-packing/test_package.py new file mode 100644 index 0000000000..25196ada9b --- /dev/null +++ b/research/bit589-width-packing/test_package.py @@ -0,0 +1,79 @@ +# SPDX-License-Identifier: Apache-2.0 +"""Unit tests for the PR589 width-packing note. + +Run: python3 -B -m unittest discover -s research/bit589-width-packing -p test_package.py -v +""" +import itertools +import json +import sys +import unittest +from collections import Counter +from fractions import Fraction as Q +from pathlib import Path + +HERE = Path(__file__).resolve().parent +sys.path.insert(0, str(HERE)) + +import packing # noqa: E402 + + +class SlotModelTests(unittest.TestCase): + @classmethod + def setUpClass(cls): + cls.model = packing.slot_model(packing.pinned_json('bit_record'), packing.pinned_json('selection')) + + def test_capacities(self): + self.assertEqual(self.model['caps'], {0: 14, 1: 7, 2: 28, 3: 7, 4: 42, 5: 7, 6: 42, 7: 28, 8: 14}) + self.assertEqual(self.model['slots'], Counter({7: 666, 14: 444, 28: 444, 42: 444})) + self.assertEqual(self.model['deficit'], 28416 - 63 * 288) + + def test_width8_optimality_and_refusal(self): + c_star = Q(1733427039589844234750, 10 ** 24) + out = packing.width8_optimality(self.model, c_star) + self.assertEqual(out['slack_units_per_replica'], 45) + bad = dict(self.model) + bad['slots'] = Counter(self.model['slots']) + Counter({40: 1}) + with self.assertRaisesRegex(ValueError, 'divisible by 8'): + packing.width8_optimality(bad, c_star) + + def test_width7_placements(self): + units, idle = packing.width7_idle(self.model) + self.assertEqual((units, idle), (2043, Counter({42: 340, 21: 1}))) + idle1 = packing.width7_partial_idle(self.model, 1) + self.assertEqual(idle1, Counter({7: 657, 6: 444, 4: 444, 42: 10, 2: 433, 34: 1})) + mass = lambda c: sum(r * n for r, n in c.items()) + self.assertEqual(mass(idle1), mass(self.model['idle_rep']) + 9) + + def test_local_bracket(self): + opt, pes = packing.local_bracket(Counter({1: 3, 2: 2, 7: 1}), 2) + self.assertEqual(opt, Counter({1: 1, 2: 2, 7: 1})) + self.assertEqual(pes, Counter({1: 4, 6: 1, 2: 1})) + + +class MajorizationTests(unittest.TestCase): + def test_greedy_fill_is_optimal_for_concave_children(self): + """Exhaustive check of the slot-exact width-7 placement rule on small instances.""" + g = lambda r: r * (64 / r) ** 0.002 if r else 0.0 + for caps in ([1, 2, 2, 4], [6, 6, 4, 2, 1], [6, 4, 4, 1, 1]): + for units in range(1, sum(caps)): + best = min(sum(g(7 * u) for u in us) + for us in itertools.product(*[range(c + 1) for c in caps]) if sum(us) == units) + bigs = sorted(caps, reverse=True) + greedy, left = [], units + for c in bigs: + take = min(c, left) + greedy.append(take) + left -= take + self.assertAlmostEqual(best, sum(g(7 * u) for u in greedy), places=12) + + +class ResultTests(unittest.TestCase): + def test_committed_baseline(self): + res = json.loads((HERE / 'RESULT.json').read_text()) + rec = packing.pinned_json('bit_record') + self.assertEqual(res['scenarios']['selected']['bit_lower'], rec['nine']['bit_lower']) + self.assertEqual(res['scenarios']['selected']['bit_bound_kappa_cap_decimal'], '0.001730427469823602') + + +if __name__ == '__main__': + unittest.main() diff --git a/research/bit589-width-packing/verify.py b/research/bit589-width-packing/verify.py new file mode 100644 index 0000000000..e2e0850c54 --- /dev/null +++ b/research/bit589-width-packing/verify.py @@ -0,0 +1,136 @@ +# SPDX-License-Identifier: Apache-2.0 +"""Replay the PR589 width-packing note and its negative controls. + +Usage: python3 -B research/bit589-width-packing/verify.py --work NEW_EMPTY_DIR +Expected last line: PASS_BIT589_WIDTH_PACKING_REPLAY +""" +import argparse +import copy +import gzip +import json +import subprocess +import sys +import tarfile +from collections import Counter +from fractions import Fraction as Q +from pathlib import Path + +import packing +from packing import HERE, ROOT, require, sha256 + +T37_ARCHIVE = ('research/community-frontier942-audit/t37-replay.tar.gz', + '48285025105210b56a32d3d4d57a21b7591760acc709d38073e4dca339eb06fe') +T37_TEMPLATE = ('strict/global/hosted/GLOBAL-TEMPLATE.json.gz', + '956e0c0e9b083806268bf93525441ccea143d5f78e46c5f6b793b22cfe11113d') + + +def rejects(name, fn, reason): + try: + fn() + except ValueError as exc: + require(reason in str(exc), f'control {name} rejected for another reason: {exc}') + return name + raise SystemExit(f'FAIL control {name} was accepted') + + +def one_level_windows_in_t37(): + """Supporting evidence on the same nine-stage template: in the selected complex T37 hosting, + every one-level idle window (capacity one level = 8 coordinates) is completely hosted.""" + path = ROOT / T37_ARCHIVE[0] + require(sha256(path.read_bytes()) == T37_ARCHIVE[1], 'T37 archive digest') + with tarfile.open(path, 'r:gz') as tar: + payload = gzip.decompress(tar.extractfile(tar.getmember(T37_TEMPLATE[0])).read()) + require(sha256(payload) == T37_TEMPLATE[1], 'T37 template digest') + t = json.loads(payload) + cap = Counter() + hosted = Counter() + for s in t['hosting']['pooled_slots']: + cap[(s['family'], s['child'])] += s['width'] + hosted[s['child']] += s['width'] + for c in t['idle_children']: + cap[(c['family'], c['child'])] += c['rank'] + by_child = {} + for (f, ch), c in cap.items(): + by_child.setdefault(ch, Counter())[c] += 1 + one_level = sorted(ch for ch, cs in by_child.items() if set(cs) == {8}) + idle_in_one_level = sum(c['rank'] for c in t['idle_children'] if c['child'] in one_level) + require(len(one_level) == 6 and idle_in_one_level == 0, 'one-level windows of T37 are fully hosted') + return dict(one_level_children=one_level, families_per_child=sorted({sum(by_child[ch].values()) for ch in one_level}), + hosted_coordinates=sum(hosted[ch] for ch in one_level), idle_coordinates=idle_in_one_level) + + +def controls(): + record = packing.pinned_json('bit_record') + selection = packing.pinned_json('selection') + model = packing.slot_model(record, selection) + passed = [] + # C1: one width-8 residual moved between slot indices breaks the capacity reconstruction. + sel = copy.deepcopy(selection) + sel['bit']['patterns'][0][1] = [8, 8] + + def c1(): + packing.slot_model(record, sel) + passed.append(rejects('C1_pattern_moved', c1, 'stage and pattern totals agree')) + # C2: the per-unit argument refuses a slot capacity divisible by 8. + m2 = dict(model) + m2['slots'] = Counter(model['slots']) + m2['slots'][48] = 1 + passed.append(rejects('C2_capacity_divisible_by_8', + lambda: packing.width8_optimality(m2, Q(1, 600)), + 'no slot capacity is divisible by 8')) + # C3: a corrupted record digest is rejected. + src = dict(packing.SOURCES['inputs']['bit_record']) + good = packing.SOURCES['inputs']['bit_record'] + packing.SOURCES['inputs']['bit_record'] = dict(src, sha256='0' * 64) + try: + passed.append(rejects('C3_record_pin', lambda: packing.pinned_json('bit_record'), 'digest mismatch')) + finally: + packing.SOURCES['inputs']['bit_record'] = good + # C4: the next bit grid point is rejected by both engines (with the bad-residue surcharge). + W = record['nine']['bit']['live'] + H = dict(model['H']) + c0 = Q(record['nine']['bit_lower']) + z = c0 + Q(1, 10 ** 24) + lo, _ = packing.MOMENT.moment(H, 64, W, z, True) + blo, _ = packing.BASE_TWO.moment(64, W, list(H.items()), z) + flo, _ = packing.BASE_TWO.moment(64, W, [(1, 32 * 64 * 64 * sum(H.values()))], z) + blo += flo / 10 ** 16 # the bit model keeps the inherited bad-residue surcharge + require(lo > 1 and blo > 1, 'both engines exceed one at the next bit endpoint') + + def c4(): + require(lo < 1, 'next bit endpoint rejected') + passed.append(rejects('C4_next_bit_endpoint', c4, 'next bit endpoint rejected')) + # C5: a width-7 profile that forgets the freed coordinates changes rank mass. + opt, _ = packing.local_bracket(model['local'], 1) + + def c5(): + Hx = Counter({r: n * model['calls'] for r, n in opt.items()}) + Hx.update({r: n * packing.T for r, n in model['idle_rep'].items()}) + require(sum(r * n for r, n in Hx.items()) == sum(r * n for r, n in model['H'].items()), 'rank mass changes') + passed.append(rejects('C5_lost_coordinates', c5, 'rank mass changes')) + # C6: more converted helpers than empty 7-slots is refused by the constructive placement. + passed.append(rejects('C6_too_many_for_7_slots', lambda: packing.width7_partial_idle(model, 75), + 'width-7 residuals in 7-slots only')) + return passed + + +def main(): + ap = argparse.ArgumentParser() + ap.add_argument('--work', required=True) + work = Path(ap.parse_args().work).resolve() + require(not work.exists(), 'work directory must not exist') + work.mkdir(parents=True) + proc = subprocess.run([sys.executable, '-B', str(HERE / 'packing.py'), str(work / 'RESULT.json')], + cwd=HERE, capture_output=True, text=True) + sys.stdout.write(proc.stdout) + require(proc.returncode == 0, 'packing.py failed:\n' + proc.stderr) + require(json.loads((work / 'RESULT.json').read_text()) == json.loads((HERE / 'RESULT.json').read_text()), + 'RESULT.json differs from the committed result') + evidence = one_level_windows_in_t37() + print('T37 one-level windows fully hosted:', evidence) + print('controls rejected as expected:', ', '.join(controls())) + print('PASS_BIT589_WIDTH_PACKING_REPLAY') + + +if __name__ == '__main__': + main()