diff --git a/research/productive-lever-reprice/README.md b/research/productive-lever-reprice/README.md new file mode 100644 index 0000000000..4cb841dfb4 --- /dev/null +++ b/research/productive-lever-reprice/README.md @@ -0,0 +1,94 @@ +# The #1240 lever table, re-priced on the productive-helper invoices + +**Side result, no new κ.** [Priority revision 7](../../docs/research/current-priorities.md) +notes that its allocation and lever budgets predate the productive-helper +selection (#4359) and have not been reassessed. The one-at-a-time lever table +from [#1240](../complex-local-word-ceiling/README.md) (`levers.py`: centre free +2.80×, rank-16 children 2.31×, two unpaid coordinates 3.77×, combined 6.5×) was +computed on the old #1094 word. This package recomputes the same kind of ideal +budgets on the current complete invoices: + +- complex: [#4470](../joint-helper-lattice/README.md) `RESULT.json` (κ = 0.00302015); +- BIT: [query-thinned-controllers](../query-thinned-controllers/README.md) `bit_invoice`, + which #4470 retains unchanged. + +The model is #4470's own fixed-profile root: a supplier's raw saving `C` solves +`Σ T_r r^(1−C) = Σ P_r r^(1−C)` over its complete target and paid profiles. +Every lever is an **ideal relaxation**: the named work is removed or merged and +nothing new is charged. Outer rows, strictification, tails and the BIT ordinary +conversion are not recomputed, so every figure is a raw ceiling, not a gain. + +## 1. Where the paid moment goes + +| Paid part | complex jobs | complex mass | complex share | BIT jobs | BIT mass | BIT share | +|---|---:|---:|---:|---:|---:|---:| +| whole-idle stages | 3,360 | 141,568 | **58.97%** | 3,330 | 122,766 | **56.38%** | +| small local jobs (18 full calls) | 59,436 | 94,734 | **39.84%** | 52,560 | 92,322 | **42.84%** | +| query-only shears (one rank-one job per port) | 1,680 | 1,680 | 0.71% | 1,665 | 1,665 | 0.77% | +| owned centre (rank 8) | 144 | 1,152 | 0.48% | — | — | — | + +Both sides have the same shape and the same thin margin: target minus paid rank +mass is 752 (complex, `48·18 − 112`) and 753 (BIT). The owned centre, the +largest lever on the old word, is now under half a percent of the bill. + +## 2. Ideal lever ceilings + +Certified raw roots (brackets of width 1e-10 in `RESULT.json`): + +| Lever (ideal) | old (#1240) | complex root | ×base | BIT raw root | ×base | +|---|---:|---:|---:|---:|---:| +| baseline | — | 0.0030201660 | 1 | 0.0034642490 | 1 | +| centre path free | 2.80× | 0.0076503 | 2.53 | n/a (no centre) | — | +| centre shared by two calls | 1.90× | 0.0053347 | 1.77 | n/a | — | +| rank-16 local children (small local jobs merged at equal mass) | 2.31× | 0.0173942 | 5.76 | 0.0332377 | 9.60 | +| two unpaid coordinates per idle family (each whole-idle job 2 ranks cheaper) | 3.77× | 0.0282012 | 9.34 | 0.0318657 | 9.20 | +| centre free and rank-16 children | 6.5× | 0.0478100 | 15.83 | 0.0332377 | 9.60 | +| query-only shears free | — | 0.0099146 | 3.28 | 0.0113100 | 3.27 | +| no rank-one local jobs (merged pairwise into rank 2) | — | 0.0034041 | 1.13 | 0.0037510 | 1.08 | +| whole-idle stages free | — | > 1/6 | — | > 1/6 | — | + +"Two unpaid coordinates per family" has no literal counterpart in the new +invoice. The row above is one reading (each idle family pays two fewer ranks) +and should be taken as such. + +## 3. What follows + +1. **One-sided levers stop at the other side.** κ is limited by + `min(complex, BIT)`. Any lever on the complex side alone is capped by the + admitted BIT 0.0034 (+12.6% over 0.00302015); a BIT-only lever leaves complex + binding. Every lever that matters must be built on both suppliers. +2. **Applied symmetrically, complex still binds** in every row of the table. +3. **The margin is thin, so mass matters more than shape.** Complex reaches the + BIT level with about 94 units of paid moment removed (0.04% of 237,321), and + 0.005 / 0.01 with about 488 / 1,700. But the surplus `48·18 − 112` is set by the + controller; repacking at fixed rank mass is weak, since pairing every one of + the 40,266 complex rank-one local jobs only reaches 0.003404. +4. **The bill is in the controller.** Whole-idle stages (56–59%) and the 15 + query-only shears are fixed by the p16 controller of #4440/#4470, not by the + local word, and #4546/#4567/#4581/#4585/#4587 already close local window + rewrites of #4470. Controller-level changes on both sides are therefore the + targets this screen points to. A companion package examines the query shears. + +## Scope + +Raw fixed-profile roots only. The levers are hypothetical; none is claimed to +be constructible, and costs that a real construction would add are not +charged. The root bisection proposes the first sign change and exact interval +moments certify the bracket; uniqueness is not certified (the rank-16 BIT case +turns positive again before C = 1). No selected-record change is proposed. + +## Open next questions + +- Can a changed controller reduce whole-idle mass or the 15 query-only shears on + both suppliers at once? Screen any candidate with this verifier's `assemble` + and `root` on both invoices before building it. No changed topology is known, + and local window rewrites of #4470 are already closed (#4567, #4581). + +## Reproduce + +```sh +python3.12 -B scripts/research_package.py --package research/productive-lever-reprice +``` + +The verifier is standard library only. Prepared by +Matarener (Mark) with Claude Code assistance. Apache-2.0. diff --git a/research/productive-lever-reprice/RESULT.json b/research/productive-lever-reprice/RESULT.json new file mode 100644 index 0000000000..c2b443d16e --- /dev/null +++ b/research/productive-lever-reprice/RESULT.json @@ -0,0 +1,152 @@ +{ + "model": "raw root of sum T r^(1-C) = sum P r^(1-C); ideal levers, no new charges", + "sides": { + "bit": { + "baseline_root_bracket": [ + "0.0034642489", + "0.0034642490" + ], + "levers": { + "centre_free_and_rank16_children": { + "no_root_below_one_sixth": false, + "ratio_to_baseline": "9.595", + "raw_root_bracket": [ + "0.0332377393", + "0.0332377394" + ] + }, + "idle_stages_free": { + "no_root_below_one_sixth": true, + "ratio_to_baseline": null, + "raw_root_bracket": null + }, + "no_rank1_local_jobs_merge_to_rank2": { + "no_root_below_one_sixth": false, + "ratio_to_baseline": "1.083", + "raw_root_bracket": [ + "0.0037510074", + "0.0037510075" + ] + }, + "query_shears_free": { + "no_root_below_one_sixth": false, + "ratio_to_baseline": "3.265", + "raw_root_bracket": [ + "0.0113100143", + "0.0113100144" + ] + }, + "rank16_local_children": { + "no_root_below_one_sixth": false, + "ratio_to_baseline": "9.595", + "raw_root_bracket": [ + "0.0332377393", + "0.0332377394" + ] + }, + "two_unpaid_coordinates_per_idle_family": { + "no_root_below_one_sixth": false, + "ratio_to_baseline": "9.198", + "raw_root_bracket": [ + "0.0318657371", + "0.0318657372" + ] + } + }, + "paid_moment_share": { + "idle": "56.3820%", + "local": "42.8435%", + "shears": "0.7745%" + }, + "paid_parts_mass": { + "centre": 0, + "idle": 122766, + "local": 92322, + "shears": 1665 + }, + "surplus_mass": 753 + }, + "complex": { + "baseline_root_bracket": [ + "0.0030201659", + "0.0030201660" + ], + "levers": { + "centre_free": { + "no_root_below_one_sixth": false, + "ratio_to_baseline": "2.533", + "raw_root_bracket": [ + "0.0076503452", + "0.0076503453" + ] + }, + "centre_free_and_rank16_children": { + "no_root_below_one_sixth": false, + "ratio_to_baseline": "15.830", + "raw_root_bracket": [ + "0.0478099845", + "0.0478099846" + ] + }, + "centre_shared_by_two_calls": { + "no_root_below_one_sixth": false, + "ratio_to_baseline": "1.766", + "raw_root_bracket": [ + "0.0053347436", + "0.0053347437" + ] + }, + "idle_stages_free": { + "no_root_below_one_sixth": true, + "ratio_to_baseline": null, + "raw_root_bracket": null + }, + "no_rank1_local_jobs_merge_to_rank2": { + "no_root_below_one_sixth": false, + "ratio_to_baseline": "1.127", + "raw_root_bracket": [ + "0.0034041376", + "0.0034041377" + ] + }, + "query_shears_free": { + "no_root_below_one_sixth": false, + "ratio_to_baseline": "3.283", + "raw_root_bracket": [ + "0.0099145983", + "0.0099145984" + ] + }, + "rank16_local_children": { + "no_root_below_one_sixth": false, + "ratio_to_baseline": "5.759", + "raw_root_bracket": [ + "0.0173941762", + "0.0173941763" + ] + }, + "two_unpaid_coordinates_per_idle_family": { + "no_root_below_one_sixth": false, + "ratio_to_baseline": "9.338", + "raw_root_bracket": [ + "0.0282011775", + "0.0282011776" + ] + } + }, + "paid_moment_share": { + "centre": "0.4824%", + "idle": "58.9664%", + "local": "39.8433%", + "shears": "0.7079%" + }, + "paid_parts_mass": { + "centre": 1152, + "idle": 141568, + "local": 94734, + "shears": 1680 + }, + "surplus_mass": 752 + } + } +} diff --git a/research/productive-lever-reprice/SOURCES.json b/research/productive-lever-reprice/SOURCES.json new file mode 100644 index 0000000000..ae08c213ce --- /dev/null +++ b/research/productive-lever-reprice/SOURCES.json @@ -0,0 +1,36 @@ +{ + "schema_version": 1, + "base_commit": "f626db5c3a3d781d8f7695038776c621651f75e1", + "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/RESULT.json", + "usage": "input", + "git_blob": "edf41a49a0350862c23378f837c7397fc5dc7596", + "sha256": "c7b2388f6511c19976b337d8c8ac374610af616866a249d75dace704eb5d9e21" + }, + { + "path": "research/kappa-rebuild/architecture/mixed_target_probe.py", + "usage": "input", + "git_blob": "4fc05ab08138218ba9f09e5c89b649afae7c914e", + "sha256": "011c3c9d0cf81103dc84d709a0e36793eb7c5ae3f23c85eac27650ef13afa04a" + }, + { + "path": "research/query-thinned-controllers/RESULT.json", + "usage": "input", + "git_blob": "e0695152c98d727edfd0d2034b58a1c7e8682c0c", + "sha256": "6ebfc8c0f09166f4834e9d7427410cb31aefff2cd4d4ce588c8e52c9c70e9a0f" + } + ] +} diff --git a/research/productive-lever-reprice/TASK.json b/research/productive-lever-reprice/TASK.json new file mode 100644 index 0000000000..ae65fa1000 --- /dev/null +++ b/research/productive-lever-reprice/TASK.json @@ -0,0 +1,66 @@ +{ + "schema_version": 1, + "task_id": "complex-new-helper-inventory", + "priority_revision": 7, + "base_commit": "f626db5c3a3d781d8f7695038776c621651f75e1", + "original_card": { + "id": "complex-new-helper-inventory", + "question": "Can a new local cost interface change the deficit-to-recursive-cost ratio beyond current packing?", + "starting_points": [ + "docs/research/research-family-status.md", + "research/complex-local-word-ceiling/README.md", + "research/heterogeneous-owner-assembly/README.md", + "certificates/selected-result.json", + "research/selected-k8-unrestricted-ends/README.md" + ], + "methods": [ + "Propose a changed helper inventory and derive an optimistic exact moment.", + "Design a small completed instance and independently verify its endpoint and rank bill." + ], + "acceptance_gate": "A new physically realizable contract outside the frozen catalogue whose per-call profile, screened with ceiling.ceiling(), beats the selected word's packing ceiling; a lower cap does not establish identical circuitry or order attainable optima, and is insufficient to pass the stronger-budget target under this model. 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.", + "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." + }, + "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.", + "bottleneck_link": "Packing of the selected word is capped at +0.87% (ceiling model); only a lower local excess spend or a changed coverage law raises the cap.", + "allowed_variations": [ + "Narrow to one changed boundary or helper type with explicit counts.", + "If the coverage law, template or guard changes, derive an applicable fully charged replacement bound instead of applying the incumbent ceiling outside its scope." + ], + "scope_change_triggers": [ + "Mixing only providers already inside the pinned catalogue.", + "Only changing helper terminal subspaces and monotone frames within the fixed scalar word, entrances and cleanup contract already covered by #1995/#2013.", + "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." + ], + "overlap_terms": [ + "helper inventory", + "heterogeneous-owner", + "mutable leaver" + ] + }, + "scope_status": "changed", + "actual_scope": "Recompute the #1240 one-at-a-time ideal lever budgets (levers.py) on the complete productive-helper invoices of #4470 (complex) and the retained query-thinned BIT invoice, with exact interval roots, and decompose the paid moment by physical source.", + "scope_change_reason": "The card asks for a new local cost interface; this package builds none. It updates the planning screen that the card's first step uses, because priority revision 7 states the old lever budgets predate #4359.", + "bottleneck_link": "Side result for allocation: shows that one-sided levers are capped by the other supplier (+12.6% for complex-only), that the margin is the controller-fixed surplus 752/753, and that 56-59% of the paid moment is whole-idle controller work.", + "budget_minutes": 120, + "stop_rule": "Stop after the decomposition and the lever table on both sides; no lever is constructed.", + "outcome": "completed", + "evidence": "RESULT.json: certified raw roots (width 1e-10) for both baselines and every lever, paid masses and shares, surplus masses 752/753. README.md gives the table, readings and scope.", + "author": "Matarener (Mark), with Claude Code assistance", + "ai_assistance": "Substantial Claude Code assistance in analysis, code and writing; exact standard-library interval arithmetic from mixed_target_probe; no independent human review.", + "open_questions": [ + { + "question": "Can a controller reduce whole-idle mass or the 15 query-only shears on both suppliers at once?", + "why_it_matters": "They are 56-59% and 0.7% of the paid moment; free shears alone give a raw ceiling near 0.0099 on both sides, while complex-only levers stop at BIT 0.0034.", + "first_step": "Screen any changed p16 controller with this verifier's assemble/root on both invoices before building it.", + "blocked_by": "No changed controller topology is known; local window rewrites of #4470 are already closed (#4567, #4581)." + } + ] +} diff --git a/research/productive-lever-reprice/VERIFY.json b/research/productive-lever-reprice/VERIFY.json new file mode 100644 index 0000000000..66a13d3c96 --- /dev/null +++ b/research/productive-lever-reprice/VERIFY.json @@ -0,0 +1,22 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [ + "research/joint-helper-lattice/RESULT.json", + "research/kappa-rebuild/architecture/mixed_target_probe.py", + "research/query-thinned-controllers/RESULT.json" + ], + "commands": [ + { + "argv": [ + "{python}", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 600, + "checks": "Rebuild complex (#4470) and BIT (query-thinned) complete profiles from local calls, query shears, whole-idle stages and owned centre; certified raw roots 0.0030201660 / 0.0034642490 (complex bracket meets #4470's); surplus masses 752/753; paid-moment shares; certified raw roots of eight ideal levers per side. Controls: empty lever reproduces baseline; one extra paid rank-one job lowers the root; free idle stages keep the surplus positive through C=1/6." + } + ] +} diff --git a/research/productive-lever-reprice/verify.py b/research/productive-lever-reprice/verify.py new file mode 100644 index 0000000000..906f677cf7 --- /dev/null +++ b/research/productive-lever-reprice/verify.py @@ -0,0 +1,225 @@ +#!/usr/bin/env python3 +"""Re-price the one-at-a-time lever table of #1240 on the productive-helper invoices of #4470. + +Model (#4470 PROOF.md section 5): a supplier's raw saving C is the root of + sum_r T_r r^(1-C) = sum_r P_r r^(1-C) +over its complete target (productive) and paid profiles. Complex profiles are +research/joint-helper-lattice/RESULT.json; the BIT profile is the unchanged +research/query-thinned-controllers/RESULT.json bit_invoice. kappa is limited by +min(complex, BIT). Every lever is an ideal relaxation, like the #1240 table: +the changed work is removed or merged with no new charge. + +Checks, with exact interval arithmetic (mixed_target_probe log/exp series, rounded outward): +1. Both complete profiles are rebuilt from their physical parts: 18 full local + calls, 15 query-only shears (one rank-one job per port), whole-idle stages, + and for complex the 8 rank-8 owned-centre jobs per call. +2. Baseline raw roots: complex 0.0030201660 (#4470 bracket), BIT 0.0034642490. +3. Paid-moment shares of each part at t = 1 - C. +4. Raw roots of every lever on each side, with certified brackets. +Roots: a float bisection proposes the first sign change, and exact interval +moments certify the sign on both ends of a 1e-10 bracket. Uniqueness of the +root is not certified. "No root below 1/6" means the certified surplus is still +positive at C = 1/6 (the interval engine needs C log r < 1). +Controls: an empty lever reproduces the baseline bracket; one extra paid +rank-one job lowers the complex root. +Standard library only. Prepared by Matarener with Claude Code assistance. +Apache-2.0. +""" +from collections import Counter +from fractions import Fraction as Q +from pathlib import Path +import importlib.util +import json +import sys + +sys.dont_write_bytecode = True +HERE = Path(__file__).resolve().parent +ROOT = HERE.parents[1] +PORTS = {'complex': 112, 'bit': 111} +CAP = Q(1, 6) # h_interval needs C*log(r) < 1 for r <= 145 + + +def need(ok, why): + if not ok: + raise SystemExit('FAIL: ' + why) + + +def load(path, name): + spec = importlib.util.spec_from_file_location(name, path) + module = importlib.util.module_from_spec(spec) + sys.modules[name] = module + spec.loader.exec_module(module) + return module + + +E = load(ROOT/'research/kappa-rebuild/architecture/mixed_target_probe.py', 'lever_probe') + + +def ints(d): + return Counter({int(k): v for k, v in d.items()}) + + +SCALE = 2**128 + + +def outward(x, up): + n = x*SCALE + k = n.numerator//n.denominator + return Q(k+(1 if up and k != n else 0), SCALE) + + +def h_interval(r, c): + """Enclosure of r^(1-c) from mixed_target_probe's log/exp series, rounded outward to 2^-128.""" + if r in (0, 1): + return Q(r), Q(r) + a, b = E.log_interval(r) + lo_x, hi_x = outward(c*a, False), outward(c*b, True) + low, _ = E.exp_interval(lo_x) + _, high = E.exp_interval(hi_x) + return outward(Q(r)/high, False), outward(Q(r)/low, True) + + +def moment(prof, c): + low = high = Q(0) + for r, n in prof.items(): + if n: + a, b = h_interval(r, c) + low += n*(a if n >= 0 else b) + high += n*(b if n >= 0 else a) + return low, high + + +def surplus(T, P, c): + a, b = moment(T, c), moment(P, c) + return a[0]-b[1], a[1]-b[0] + + +def float_surplus(T, P, c): + return (sum(float(n)*r**(1-c) for r, n in T.items() if n) + - sum(float(n)*r**(1-c) for r, n in P.items() if n)) + + +def root(T, P, width=Q(1, 10**10)): + """Certified bracket (pos, neg) of the raw root, or None when the surplus stays positive at C=CAP. + + A float bisection proposes the root; exact interval moments then certify the sign on + both ends of a bracket of the given width. + """ + need(surplus(T, P, Q(0))[0] > 0, 'surplus positive at C=0') + if surplus(T, P, CAP)[0] > 0: + return None + lo, hi = 0.0, float(CAP) + for _ in range(80): + mid = (lo+hi)/2 + lo, hi = (mid, hi) if float_surplus(T, P, mid) > 0 else (lo, mid) + guess = Q(lo).limit_denominator(10**13) + pos, neg = max(Q(0), guess-width/2), guess+width/2 + need(surplus(T, P, pos)[0] > 0 and surplus(T, P, neg)[1] < 0, 'certified root bracket') + return pos, neg + + +def merge(prof, size): + out = Counter({r: n for r, n in prof.items() if r >= size}) + out[size] += Q(sum(r*n for r, n in prof.items() if r < size), size) + return out + + +def complex_parts(): + d = json.loads((ROOT/'research/joint-helper-lattice/RESULT.json').read_text()) + T, P = ints(d['targets']), ints(d['paid']) + calls, shears = d['full_calls'], d['query_shears'] + lp = ints(d['local_paid']) + need((calls, shears) == (18, 15), 'complex: 18 full calls and 15 query shears') + parts = {'centre': Counter({8: calls*lp[8]}), + 'local': Counter({r: calls*n for r, n in lp.items() if r != 8}), + 'shears': Counter({1: shears*PORTS['complex']})} + idle = Counter(P) + for p in parts.values(): + idle.subtract(p) + parts['idle'] = +idle + need(min(idle.values()) >= 0 and min(parts['idle']) >= 16, 'complex idle ranks are the whole-idle 16..72') + helpers = Counter({r: calls*n for r, n in ints(d['local_helpers']).items()}) + main = Counter(T) + main.subtract(helpers) + need(min(main.values()) >= 0 and all((r-1) % 8 == 0 for r in +main), 'complex main targets have rank 1+8k') + return T, parts + + +def bit_parts(): + d = json.loads((ROOT/'research/query-thinned-controllers/RESULT.json').read_text())['bit_invoice'] + T, P = ints(d['targets']), ints(d['paid']) + idle = ints(d['whole_idle']) + shears = Counter({1: d['thin_queries']}) + need((d['thick_calls'], d['thin_queries']) == (18, 15*PORTS['bit']), 'BIT: 18 thick calls and 15 x 111 queries') + local = Counter(P) + local.subtract(idle) + local.subtract(shears) + local = +local + need(local == Counter({r: 18*n for r, n in {1: 1323, 2: 1342, 3: 79, 4: 44, 5: 102, 6: 11, 7: 19}.items()}), + 'BIT local paid = 18 x PR589 local profile') + need(T[8] == 18*439, 'BIT helpers: 18 x 439 of rank 8') + return T, {'centre': Counter(), 'local': local, 'shears': shears, 'idle': idle} + + +def assemble(parts, **change): + P = Counter() + for k, p in parts.items(): + P.update(change.get(k, p)) + return +P + + +LEVERS = { + 'centre_free': lambda p: {'centre': Counter()}, + 'centre_shared_by_two_calls': lambda p: {'centre': Counter({r: Q(n, 2) for r, n in p['centre'].items()})}, + 'rank16_local_children': lambda p: {'local': merge(p['local'], 16)}, + 'two_unpaid_coordinates_per_idle_family': lambda p: {'idle': Counter({r-2: n for r, n in p['idle'].items()})}, + 'centre_free_and_rank16_children': lambda p: {'centre': Counter(), 'local': merge(p['local'], 16)}, + 'query_shears_free': lambda p: {'shears': Counter()}, + 'idle_stages_free': lambda p: {'idle': Counter()}, + 'no_rank1_local_jobs_merge_to_rank2': lambda p: {'local': merge(p['local'], 2)}, +} +EXPECTED_BASE = {'complex': '0.0030201659', 'bit': '0.0034642489'} + + +def fmt(r): + return None if r is None else [f'{float(r[0]):.10f}', f'{float(r[1]):.10f}'] + + +def main(): + out = {'model': 'raw root of sum T r^(1-C) = sum P r^(1-C); ideal levers, no new charges', 'sides': {}} + for side, (T, parts) in (('complex', complex_parts()), ('bit', bit_parts())): + P = assemble(parts) + base = root(T, P) + need(fmt(base)[0].startswith(EXPECTED_BASE[side]), f'{side} baseline root') + if side == 'complex': + need(base[0] <= Q('0.0030201659771') and base[1] >= Q('0.0030201659770'), 'complex bracket meets #4470 root') + extra = Counter(P) + extra[1] += 1 + need(root(T, extra)[1] <= base[1] and root(T, extra)[0] < base[0], 'one extra paid job lowers the root (control)') + need(root(T, assemble(parts, **{})) == base, f'{side}: empty lever reproduces baseline (control)') + t = 1-base[0] + total = moment(P, base[0])[0] + shares = {k: f'{float(moment(p, base[0])[0]/total):.4%}' for k, p in parts.items() if p} + mass = {k: int(sum(r*n for r, n in p.items())) for k, p in parts.items()} + levers = {} + for name, f in LEVERS.items(): + if side == 'bit' and 'centre' in name and name != 'centre_free_and_rank16_children': + continue + r = root(T, assemble(parts, **f(parts))) + levers[name] = {'raw_root_bracket': fmt(r), 'no_root_below_one_sixth': r is None, + 'ratio_to_baseline': None if r is None else f'{float(r[0]/base[0]):.3f}'} + out['sides'][side] = {'baseline_root_bracket': fmt(base), 'paid_parts_mass': mass, + 'paid_moment_share': shares, 'surplus_mass': int(sum(r*n for r, n in T.items()) - sum(r*n for r, n in P.items())), + 'levers': levers} + print(side, fmt(base), shares, flush=True) + for k, v in levers.items(): + print(' ', k, v, flush=True) + need(out['sides']['complex']['surplus_mass'] == 752 and out['sides']['bit']['surplus_mass'] == 753, 'surplus masses 752/753') + need(all(out['sides'][x]['levers']['idle_stages_free']['no_root_below_one_sixth'] for x in out['sides']), + 'free idle stages keep the surplus positive through C = 1/6 on both sides (reported)') + (HERE/'RESULT.json').write_text(json.dumps(out, indent=2, sort_keys=True)+'\n', newline='\n') + print('PASS_PRODUCTIVE_LEVER_REPRICE', flush=True) + + +if __name__ == '__main__': + main()