From c4cfec4ec86b118fa7500f407a22b4b392c04bdc Mon Sep 17 00:00:00 2001 From: josie Date: Wed, 14 Oct 2026 06:36:03 -0400 Subject: [PATCH 1/3] WIP: dependency-respecting diagonal batching of rank-1 climbs (audit of PR1779) Co-Authored-By: Claude Opus 5.5 --- research/diagonal-batch-commutation/batch.py | 220 +++++++++++++++++++ 1 file changed, 220 insertions(+) create mode 100644 research/diagonal-batch-commutation/batch.py diff --git a/research/diagonal-batch-commutation/batch.py b/research/diagonal-batch-commutation/batch.py new file mode 100644 index 0000000000..e8c7c25d1a --- /dev/null +++ b/research/diagonal-batch-commutation/batch.py @@ -0,0 +1,220 @@ +#!/usr/bin/env python3 +"""Dependency-respecting diagonal batching of rank-1 climbs in the selected gauge44 provider. + +A rank-1 climb on register L r reads and writes only L r. It may therefore be moved past any event +that touches no L r, inside its own phase. This script moves rank-1 climbs (only those; every other +event keeps its relative order), groups them into disjoint batches of 16 on distinct destinations +by an earliest-deadline greedy, emits the reordered programs, and replays their frame semantics. + +usage: batch.py LOCAL-PROGRAMS.json.gz CANONICAL-WORD.json.gz +Prepared for Josie Elliston with Claude (Anthropic) assistance. Apache-2.0. +""" +from __future__ import annotations + +import collections +import gzip +import json +import sys + +BATCH = 16 + + +def touched(event): + """Registers ('L', r) or ('C', k) that an event reads or writes.""" + tag = event[0] + if tag == 'climb': + return {('L', event[2])} + if tag in ('adapter', 'residual_adapter'): + return {('L', event[2])} + if tag == 'center': + return {('C', event[1])} + if tag == 'scalar': + e = event[1] + regs = {tuple(e[1])} + if e[0] in ('copy', 'add'): + regs.add(tuple(e[2])) + return regs + return set() + + +def is_r1(event): + return event[0] == 'climb' and event[5] == 1 + + +def split_phases(events): + """[(phase_event_or_None, [events...])] in order.""" + out = [(None, [])] + for e in events: + if e[0] == 'phase': + out.append((e, [])) + else: + out[-1][1].append(e) + return out + + +def batch_phase(body): + """Return (new_body, batches) for one phase body.""" + skel = [e for e in body if not is_r1(e)] + s = len(skel) + # original skeleton gap of each rank-1 climb and its legal window [lo, hi] + climbs = [] # (orig_order, gap, event) + gap = 0 + for e in body: + if is_r1(e): + climbs.append((len(climbs), gap, e)) + else: + gap += 1 + touch_pos = collections.defaultdict(list) + for i, e in enumerate(skel): + for reg in touched(e): + touch_pos[reg].append(i) + import bisect + win = {} + for k, g, e in climbs: + pos = touch_pos[('L', e[2])] + j = bisect.bisect_left(pos, g) # skeleton events at index < g lie before the climb + lo = pos[j - 1] + 1 if j > 0 else 0 + hi = pos[j] if j < len(pos) else s + win[k] = (lo, hi) + # same-register climbs sharing a window must keep their order: exclude them from batching + by_win = collections.Counter((e[2], win[k]) for k, g, e in climbs) + movable = [k for k, g, e in climbs if by_win[(e[2], win[k])] == 1] + ev = {k: e for k, g, e in climbs} + orig_gap = {k: g for k, g, e in climbs} + # earliest-deadline greedy sweep over gaps + start_at = collections.defaultdict(list) + for k in movable: + start_at[win[k][0]].append(k) + avail = set() + batches = collections.defaultdict(list) # gap -> list of batches + batched = set() + for g in range(s + 1): + avail.update(start_at[g]) + while any(win[k][1] == g for k in avail) and len(avail) >= BATCH: + pick = sorted(avail, key=lambda k: (win[k][1], k))[:BATCH] + batches[g].append(pick) + batched.update(pick) + avail.difference_update(pick) + avail = {k for k in avail if win[k][1] > g} + # emit: at each gap, batches first, then unbatched climbs that originally sat there + stay = collections.defaultdict(list) + for k, g, e in climbs: + if k not in batched: + stay[g].append(k) + out = [] + for g in range(s + 1): + for b in batches[g]: + out.extend(ev[k] for k in b) + out.extend(ev[k] for k in stay[g]) + if g < s: + out.append(skel[g]) + flat = [b for g in sorted(batches) for b in batches[g]] + for b in flat: + assert len({ev[k][2] for k in b}) == BATCH + return out, [[ev[k] for k in b] for b in flat], len(climbs), len(movable) + + +def replay_frames(events, word): + """Frame-semantics replay (the subset of hpe_audit_local's checks that reordering can affect).""" + frames = word['frames'] + + def contains(a, b): + for x in a: + for y in b: + if x >> (y.bit_length() - 1) & 1: + x ^= y + if x: + return False + return True + + cur = list(word['start']) + phase = None + private = {} + for e in events: + tag = e[0] + if tag == 'phase': + phase = e[1] + assert not private + elif tag == 'climb': + _, part, r, a, b, rank = e + assert not private and phase == part and cur[r] == a + assert contains(frames[a], frames[b]) and rank == len(frames[b]) - len(frames[a]) > 0 + cur[r] = b + elif tag == 'scalar': + _, op, f = e + target = tuple(op[1]) + source = tuple(op[2]) if op[0] in ('copy', 'add') else None + if target[0] == 'C' and op[0] == 'clear': + private.pop(target, None) + continue + for reg in (target, source): + if reg is None: + continue + if reg[0] == 'L': + assert cur[reg[1]] == f, ('common frame', reg, cur[reg[1]], f) + else: + if reg == target and reg not in private: + private[reg] = f + assert private[reg] == f + elif tag == 'center': + assert phase == 'centers' + private[('C', e[1])] = e[3] + assert cur == word['final'], 'terminal frames' + + +def rank_one_runs_1779(events): + """PR1779's contiguous-run batch rule, re-implemented: phases skipped, any other event breaks a run.""" + runs, current = [], [] + for e in events: + if e[0] == 'phase': + continue + if is_r1(e): + current.append(e) + else: + if current: + runs.append(current) + current = [] + if current: + runs.append(current) + n = 0 + for run in runs: + for g in range(len(run) // BATCH): + block = run[g * BATCH:(g + 1) * BATCH] + if len({e[2] for e in block}) == BATCH: + n += 1 + return n + + +def main(prog_path, word_path, out_path=None): + programs = json.load(gzip.open(prog_path)) + reordered = {} + word = json.load(gzip.open(word_path)) + result = {} + for orient, events in programs.items(): + replay_frames(events, word) # positive control: original program + new_events, per_phase = [], [] + nb = 0 + for ph, body in split_phases(events): + if ph is not None: + new_events.append(ph) + nb_body, batches, n1, nmov = batch_phase(body) + new_events.extend(nb_body) + if n1: + per_phase.append((ph[1] if ph else None, n1, nmov, len(batches))) + nb += len(batches) + assert collections.Counter(json.dumps(e) for e in new_events) == collections.Counter(json.dumps(e) for e in events) + assert [e for e in new_events if not is_r1(e)] == [e for e in events if not is_r1(e)] + replay_frames(new_events, word) + reordered[orient] = new_events + result[orient] = dict(batches=nb, per_phase=per_phase, + pr1779_rule_original=rank_one_runs_1779(events), + pr1779_rule_reordered=rank_one_runs_1779(new_events)) + if out_path: + with gzip.open(out_path, 'wt') as fh: + json.dump(reordered, fh, separators=(',', ':')) + print(json.dumps(result, indent=1)) + return result + + +if __name__ == '__main__': + main(*sys.argv[1:4]) From 394ae06528a0f4913a25c9727ec1f4dd498d9e05 Mon Sep 17 00:00:00 2001 From: josie Date: Wed, 14 Oct 2026 06:40:16 -0400 Subject: [PATCH 2/3] Diagonal rank-16 batches under register commutation: 134 per orientation (audit of PR1779) Co-Authored-By: Claude Opus 5.5 --- research/diagonal-batch-commutation/README.md | 87 +++++++ .../diagonal-batch-commutation/RESULT.json | 117 ++++++++++ .../diagonal-batch-commutation/SOURCES.json | 36 +++ research/diagonal-batch-commutation/TASK.json | 78 +++++++ .../diagonal-batch-commutation/VERIFY.json | 23 ++ research/diagonal-batch-commutation/verify.py | 213 ++++++++++++++++++ 6 files changed, 554 insertions(+) create mode 100644 research/diagonal-batch-commutation/README.md create mode 100644 research/diagonal-batch-commutation/RESULT.json create mode 100644 research/diagonal-batch-commutation/SOURCES.json create mode 100644 research/diagonal-batch-commutation/TASK.json create mode 100644 research/diagonal-batch-commutation/VERIFY.json create mode 100644 research/diagonal-batch-commutation/verify.py diff --git a/research/diagonal-batch-commutation/README.md b/research/diagonal-batch-commutation/README.md new file mode 100644 index 0000000000..7368b075c9 --- /dev/null +++ b/research/diagonal-batch-commutation/README.md @@ -0,0 +1,87 @@ +# Diagonal rank-16 batches are not limited by the selected chronology + +**Audit of one implication in open PR #1779. No new κ; the selected record is unchanged.** + +[PR #1779](https://github.com/CrocSwap/integer-mult-bounds/pull/1779) (1337isnot1337, head `1e3128bf`) batches +sixteen rank-1 climbs on distinct destinations into one rank-16 diagonal child. In the selected gauge44 provider it +finds 8 such batches (128 rank-1 climbs). That raises the zero-charge ceiling by 1.72%, below the card's 5% gate. +Its count uses only **contiguous** runs: any computational event breaks a run, and chunks are 16-aligned. + +That restriction, not the provider, makes the count small. A rank-1 climb on `L r` reads and writes only `L r`. +Inside its own phase it can move past any event that touches no `L r`. Allowing that move, and nothing else, +gives this: + +| | per orientation | +|---|---:| +| Disjoint 16-batches on distinct destinations (earliest-deadline greedy) | **134** (2,144 of 2,412 rank-1 climbs) | +| Per-phase cap ⌊rank-1 count / 16⌋ | 149 | +| By phase: A / B / cleanup_tail / final | 58/58, 52/67, 4/4, 20/20 | +| PR #1779's contiguous rule, re-implemented: original → reordered programs | 8 → 134 | + +**The retained checker accepts the reordered programs unchanged.** Only rank-1 climbs move; every other event +keeps its relative order. The [independent local checker](../complex-571-cold14-k492b/code/hpe_audit_local.py) +replays scalars, frames and wrappers literally and runs 25 mutation controls. It passes both reordered +orientations with a receipt (`local` block and paid profiles) equal to the original programs'. The original's +receipt equals the pinned selected `INDEPENDENT-LOCAL-REPLAY.json`. Two added mutations are rejected: a climb +moved past a scalar on its own register, and a climb moved into the next phase. + +## Exact ceilings (#1779's convention) + +Rank mass is preserved and every interface charge is waived. Ceilings come from +[`ceiling.py`](../complex-local-word-ceiling/ceiling.py) with 73 columns, 896 families, nine stages, centre 64 and +grid 10⁻¹⁵. The gate is `1.05 × 0.001690054109089`. + +| rank-16 batches | a ceiling (upper) | gain | +5% gate | +|---:|---:|---:|---| +| 8 (#1779) | 0.001719107428154 | +1.72% | fails | +| 22 | 0.001772433845132 | +4.87% | fails | +| 23 | 0.001776370006187 | +5.11% | passes | +| 134 (legal here) | 0.002358018698467 | +39.5% | passes | +| 149 (phase cap) | 0.002467305908467 | +46.0% | passes | + +**Charge headroom.** With 134 batches, at most **1,258 extra rank-1 children per call** keep the gate (1,259 +fail; sharp). That is about 9.4 per batch, under the idle-displacing convention of discussion 1596: extra paid +work replaces equal idle mass. Charging overhead on top of the idle bill instead, as #1605 does, would give less; +that convention is not computed here. + +## What this does and does not show + +- It removes one stated reason the diagonal-batch route fails. The source chronology allows 134 batches, so the + zero-charge screen clears the 5% gate by a wide margin. +- The route is decided by what #1779 waived. Gathering 16 registers at *different* frames into one diagonal + rank-16 child needs copies, frames, hosting, output storage, precision and arbitrary-dirty restoration. This + package inherits #1779's premise that a diagonal rank-16 child realizes 16 independent rank-1 climbs, and + does not examine it. +- Batch counts are a greedy lower bound. 149 is the trivial phase cap, not an attained value. +- The bit supplier binds well before +39% (#1605), so the complex ceiling alone does not set κ. + +## Reproduce + +```sh +python3 -I -B research/diagonal-batch-commutation/verify.py # ~12 s, PASS_DIAGONAL_BATCH_COMMUTATION +python3 scripts/research_package.py --package research/diagonal-batch-commutation +``` + +`verify.py --write` regenerates `RESULT.json`. `batch.py PROGRAMS CANONICAL-WORD [OUT]` runs the reorder on +extracted members and can write the reordered programs. Both use the standard library only. Checked on Python +3.10 and 3.12. + +## Open next questions + +- **What can a diagonal rank-16 child of frame climbs cost?** Its gathering and restoration charge now decides + the route. The first step is to specify the contract for 16 registers at different frames `a_i → b_i`, then + price it against the 1,258-unit headroom above. The blocker is that no such contract is written down; #1779's + diagonal identity is the only premise. +- **On-top charge convention.** The same headroom with overhead added on top of the idle bill (#1605's + convention) needs a moment term outside `ceiling()`'s local-profile interface. +- **Exact phase-B maximum (52 ≤ max ≤ 67).** This only moves the zero-charge ceiling between +39.5% and +46%. + It is low priority next to the charge question. The windows are already computed by `batch.py`, so it is an + interval-stabbing integer program. + +## Credit + +The diagonal batching premise and the contiguous count are 1337isnot1337's (#1779). The rank-shape budgets are +Arham Tahir's (#1605, discussion 1596). The packing ceiling is Douglas Colkitt's (#1240), and the coverage law +is PR1012's. The local checker is from the icekylinx / PR514 / PR433 lineage, retained in +`complex-571-cold14-k492b`. Selected construction credits are in its review. Prepared for Josie Elliston by +Claude Code (Claude Opus 5.5) in one donated session, without independent review. Apache-2.0. diff --git a/research/diagonal-batch-commutation/RESULT.json b/research/diagonal-batch-commutation/RESULT.json new file mode 100644 index 0000000000..25f8d3b8e3 --- /dev/null +++ b/research/diagonal-batch-commutation/RESULT.json @@ -0,0 +1,117 @@ +{ + "base_ceiling": [ + "52814190909/31250000000000", + "1690054109089/1000000000000000" + ], + "ceilings_by_batches": { + "134": { + "a_hi": "2358018698467/1000000000000000", + "a_lo": "1179009349233/500000000000000", + "gain_pct_hi": "39.5233", + "passes_5pct_gate": true + }, + "149": { + "a_hi": "2467305908467/1000000000000000", + "a_lo": "1233652954233/500000000000000", + "gain_pct_hi": "45.9898", + "passes_5pct_gate": true + }, + "22": { + "a_hi": "443108461283/250000000000000", + "a_lo": "1772433845131/1000000000000000", + "gain_pct_hi": "4.8744", + "passes_5pct_gate": false + }, + "23": { + "a_hi": "1776370006187/1000000000000000", + "a_lo": "888185003093/500000000000000", + "gain_pct_hi": "5.1073", + "passes_5pct_gate": true + }, + "8": { + "a_hi": "859553714077/500000000000000", + "a_lo": "1719107428153/1000000000000000", + "gain_pct_hi": "1.7191", + "passes_5pct_gate": false + } + }, + "charge_headroom": { + "a_hi_at_1259": "1774507425129/1000000000000000", + "a_lo_at_1258": "1774856134331/1000000000000000", + "convention": "idle-displacing extra rank-1 children per call, 134 batches, +5% gate", + "max_extra_rank1": 1258, + "per_batch": "1258/134" + }, + "checker_controls_rejected": [ + "climb_past_own_scalar", + "climb_across_phase" + ], + "gate_target_a": "35491136290869/20000000000000000", + "orientations": { + "backward": { + "batches": 134, + "per_phase": { + "A": { + "batches": 58, + "cap": 58, + "movable": 936, + "rank1": 936 + }, + "B": { + "batches": 52, + "cap": 67, + "movable": 1072, + "rank1": 1072 + }, + "cleanup_tail": { + "batches": 4, + "cap": 4, + "movable": 78, + "rank1": 78 + }, + "final": { + "batches": 20, + "cap": 20, + "movable": 326, + "rank1": 326 + } + }, + "phase_cap": 149, + "pr1779_rule_original": 8, + "pr1779_rule_reordered": 134 + }, + "forward": { + "batches": 134, + "per_phase": { + "A": { + "batches": 58, + "cap": 58, + "movable": 936, + "rank1": 936 + }, + "B": { + "batches": 52, + "cap": 67, + "movable": 1072, + "rank1": 1072 + }, + "cleanup_tail": { + "batches": 4, + "cap": 4, + "movable": 78, + "rank1": 78 + }, + "final": { + "batches": 20, + "cap": 20, + "movable": 326, + "rank1": 326 + } + }, + "phase_cap": 149, + "pr1779_rule_original": 8, + "pr1779_rule_reordered": 134 + } + }, + "status": "PASS_DIAGONAL_BATCH_COMMUTATION" +} diff --git a/research/diagonal-batch-commutation/SOURCES.json b/research/diagonal-batch-commutation/SOURCES.json new file mode 100644 index 0000000000..3780fbefe4 --- /dev/null +++ b/research/diagonal-batch-commutation/SOURCES.json @@ -0,0 +1,36 @@ +{ + "schema_version": 1, + "base_commit": "0b1cccf86e2f5132ed286a26ef0a681a495740ea", + "files": [ + { + "path": "certificates/selected-result.json", + "usage": "provenance", + "git_blob": "ae6a99f28aa468649eb66a361e764d769363bf11", + "sha256": "10b9e340fd8e354a37a0c4813c90e5de1dd42044b5f6aca4a3fc5a42b685fa32" + }, + { + "path": "docs/research/agent-task-catalog.json", + "usage": "provenance", + "git_blob": "06c96f5579bb67ed1b86d334e78fbed7da6945f1", + "sha256": "6686ad58f1fbdbc87134a78901b60fd53a20d3984355e91defbbebc9e9fa8075" + }, + { + "path": "research/community-frontier1094-audit/selected-replay.tar.gz", + "usage": "input", + "git_blob": "c24daf067f9c543421d89ca2eeaa4eb78a57fb6f", + "sha256": "f1da80610bf33c58527f18ad63b4350d0b864e1d4486141ee17ac9bed4d529d6" + }, + { + "path": "research/complex-571-cold14-k492b/code/hpe_audit_local.py", + "usage": "input", + "git_blob": "17bccb64fdca54f329a3ce16e369449cb76c2802", + "sha256": "6bd9a1e279c9c9e4f3767d9f82e537b559292906feb2ddab02f380fb6523a810" + }, + { + "path": "research/complex-local-word-ceiling/ceiling.py", + "usage": "input", + "git_blob": "6c0f54527d879396f689523bfde19928a9b6157c", + "sha256": "86a1432870b3b21d8454106ec9162fddc0471472d9214c590a1420f2426cedfc" + } + ] +} diff --git a/research/diagonal-batch-commutation/TASK.json b/research/diagonal-batch-commutation/TASK.json new file mode 100644 index 0000000000..1b5288de6f --- /dev/null +++ b/research/diagonal-batch-commutation/TASK.json @@ -0,0 +1,78 @@ +{ + "schema_version": 1, + "task_id": "complex-rank-shape-decoder", + "priority_revision": 3, + "base_commit": "0b1cccf86e2f5132ed286a26ef0a681a495740ea", + "original_card": { + "id": "complex-rank-shape-decoder", + "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)?", + "starting_points": [ + "research/complex-local-word-ceiling/README.md", + "research/complex-decoder-field-extension-seed44/README.md", + "research/complex-frame-pair-decoders/README.md" + ], + "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." + ], + "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.", + "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. Ideal budget: rank-16 delivery is 2.31x (levers.py).", + "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.", + "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." + ], + "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." + ], + "overlap_terms": [ + "rank shape", + "block climb", + "masked decoder", + "overcomplete", + "effective rank" + ] + }, + "scope_status": "refined", + "actual_scope": "Audit of one implication in open PR1779 (1337isnot1337, head 1e3128bf): its 8-batch maximum counts only contiguous runs of rank-1 climbs in the selected gauge44 provider. Count disjoint 16-batches of rank-1 climbs on distinct destinations when a rank-1 climb may move, inside its phase, past events that do not touch its register; check the reordered programs with the retained independent local checker; price the counts with ceiling.ceiling() under PR1779's zero-charge, mass-preserving convention.", + "scope_change_reason": "PR1605/discussion 1596 already price rank-shape budgets; PR1779 presents the source chronology as bounding the diagonal-batch subfamily below the card's 5% gate. Whether that bound is a property of the provider or of the contiguity rule decides whether this route is closed.", + "bottleneck_link": "Rank-1 children are about half of the complex recursive cost; this decides whether the selected provider's chronology itself blocks rank-16 batching (it does not: 134 legal batches, +39.5% zero-charge ceiling), moving the question to the waived gathering/restoration charge.", + "budget_minutes": 60, + "stop_rule": "Stop at a certified legal batch count with checker replay and exact ceilings; do not construct a physical diagonal rank-16 child or price its gathering.", + "outcome": "completed", + "evidence": "verify.py: archive and member pins; batch.py reorder (non-rank-1 event order unchanged, same multiset) gives 134 batches per orientation, per-phase cap 149; retained hpe_audit_local.py accepts the reordered programs with a receipt equal to the original's (and the original's equals the pinned selected receipt); two mutation controls rejected; PR1779's contiguous rule re-implemented counts 8 -> 134; exact ceilings: 22 batches miss the +5% gate, 23 pass, 134 give a_hi 0.002358018698467.", + "author": "Claude Code (Claude Opus 5.5) for JosieElliston", + "ai_assistance": "Claude Code (Claude Opus 5.5) wrote the code and text in one donated session; no independent human or Codex review.", + "open_questions": [ + { + "question": "What per-batch gathering/restoration charge can 134 diagonal rank-16 batches afford while still passing the +5% gate (and other targets)?", + "why_it_matters": "With the chronology no longer binding, the waived charge is what decides the diagonal-batch route.", + "first_step": "Specify the contract for 16 registers at different frames a_i -> b_i and price it against the sharp idle-displacing headroom (1,258 extra rank-1 children per call at 134 batches, verify.py).", + "blocked_by": "The physical contract of a diagonal rank-16 child over registers at different frames is not specified (inherited unexamined from PR1779)." + }, + { + "question": "Charge headroom under PR1605's on-top convention (overhead added on top of the idle bill).", + "why_it_matters": "The idle-displacing headroom is an accounting upper bracket; the on-top one is the conservative bracket.", + "first_step": "Add the overhead moment term outside ceiling()'s local-profile interface and bisect.", + "blocked_by": "ceiling() only takes a local profile; needs a small extension." + }, + { + "question": "What is the exact maximum batch count in phase B (greedy 52, cap 67)?", + "why_it_matters": "It bounds this route's zero-charge ceiling between +39.5% and +46.0%; small next to the charge question.", + "first_step": "Interval-stabbing integer program per phase (windows are already computed by batch.py).", + "blocked_by": "Nothing; low priority." + } + ] +} diff --git a/research/diagonal-batch-commutation/VERIFY.json b/research/diagonal-batch-commutation/VERIFY.json new file mode 100644 index 0000000000..e3154d38eb --- /dev/null +++ b/research/diagonal-batch-commutation/VERIFY.json @@ -0,0 +1,23 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [ + "research/community-frontier1094-audit/selected-replay.tar.gz", + "research/complex-571-cold14-k492b/code/hpe_audit_local.py", + "research/complex-local-word-ceiling/ceiling.py" + ], + "commands": [ + { + "argv": [ + "{python}", + "-I", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 120, + "checks": "Source pins; 134 legal batches per orientation (cap 149); retained local checker accepts reordered programs with an identical receipt; two mutation controls rejected; PR1779 rule 8 -> 134; exact ceilings at 8/22/23/134/149 batches; RESULT.json receipt." + } + ] +} diff --git a/research/diagonal-batch-commutation/verify.py b/research/diagonal-batch-commutation/verify.py new file mode 100644 index 0000000000..ef679974f0 --- /dev/null +++ b/research/diagonal-batch-commutation/verify.py @@ -0,0 +1,213 @@ +#!/usr/bin/env python3 +"""Verify the dependency-respecting diagonal-batch count and its exact ceilings. + +1. Pins: selected replay archive and the gauge44 LOCAL-PROGRAMS / CANONICAL-WORD members (PR1779's pins). +2. batch.py reorders rank-1 climbs inside their phase past events that do not touch their register and + groups them into 16-batches on distinct destinations: 134 per orientation; per-phase cap 149. +3. The retained independent local checker (hpe_audit_local.py, unchanged) accepts the reordered + programs, and its 'local' block and paid profiles equal those of the original programs. +4. Controls: a climb moved past a scalar on its own register, and a climb moved into another phase, + are both rejected by the retained checker; PR1779's contiguous-run rule counts 8 on the original. +5. Exact ceilings (ceiling.py, grid 1e-15): 22 batches miss the +5% gate, 23 pass, 134 give a < 0.002358... + +usage: verify.py [--write] +Prepared for Josie Elliston with Claude (Anthropic) assistance. Apache-2.0. +""" +from __future__ import annotations + +import copy +import gzip +import hashlib +import io +import json +import subprocess +import sys +import tarfile +import tempfile +from fractions import Fraction as Q +from pathlib import Path + +HERE = Path(__file__).resolve().parent +ROOT = HERE.parents[1] +sys.path.insert(0, str(HERE)) +sys.path.insert(0, str(ROOT / 'research/complex-local-word-ceiling')) +import batch as B # noqa: E402 +import ceiling as C # noqa: E402 + +ARCHIVE = ROOT / 'research/community-frontier1094-audit/selected-replay.tar.gz' +ARCHIVE_SHA256 = 'f1da80610bf33c58527f18ad63b4350d0b864e1d4486141ee17ac9bed4d529d6' +PREFIX = 'candidate/strict/global/base/providers/gauge44/' +MEMBERS = { + 'LOCAL-PROGRAMS.json.gz': '241fde27d4e43f5a9cb6b128f9f76c5131a53d09f0371676163f914d0b0fef3a', + 'CANONICAL-WORD.json.gz': '16bc0ebb04b4be6c0ade74badc6a0c0cdba4215eda86e4ff9f13abf8ecebd219', + 'INDEPENDENT-LOCAL-REPLAY.json': '13dd18297162569532983db1a2ab67926b064330cd7edd3587e7b546b2dedf17', +} +CHECKER = ROOT / 'research/complex-571-cold14-k492b/code/hpe_audit_local.py' +CHECKER_PASS = 'PASS_INDEPENDENT_LOCAL_SCALAR_FRAME_AND_WRAPPER_REPLAY' +BASE = {1: 2412, 2: 418, 3: 432, 4: 142, 5: 82, 8: 8} +GRID = Q(1, 10 ** 15) + + +def require(ok, why): + if not ok: + raise SystemExit('FAIL: ' + why) + + +def members(): + raw = ARCHIVE.read_bytes() + require(hashlib.sha256(raw).hexdigest() == ARCHIVE_SHA256, 'selected replay archive pin') + out = {} + with tarfile.open(fileobj=io.BytesIO(raw), mode='r:gz') as tar: + for name, sha in MEMBERS.items(): + data = tar.extractfile(PREFIX + name).read() + require(hashlib.sha256(data).hexdigest() == sha, 'member pin ' + name) + out[name] = data + return out + + +def run_checker(word_gz, programs): + """Run the retained checker unchanged on (word, programs); return its receipt or None if it rejects.""" + with tempfile.TemporaryDirectory() as tmp: + d = Path(tmp) + (d / 'CANONICAL-WORD.json.gz').write_bytes(word_gz) + with gzip.open(d / 'LOCAL-PROGRAMS.json.gz', 'wt') as fh: + json.dump(programs, fh, separators=(',', ':')) + p = subprocess.run([sys.executable, '-I', '-B', str(CHECKER), str(d)], capture_output=True, text=True) + if p.returncode != 0 or CHECKER_PASS not in p.stdout: + return None + return json.loads((d / 'INDEPENDENT-LOCAL-REPLAY.json').read_text()) + + +def reorder(programs, word): + reordered, summary = {}, {} + for orient, events in programs.items(): + new_events, per_phase, nb = [], {}, 0 + for ph, body in B.split_phases(events): + if ph is not None: + new_events.append(ph) + body2, batches, n1, nmov = B.batch_phase(body) + new_events.extend(body2) + if n1: + per_phase[ph[1]] = {'rank1': n1, 'movable': nmov, 'batches': len(batches), 'cap': n1 // B.BATCH} + nb += len(batches) + require(sorted(map(json.dumps, new_events)) == sorted(map(json.dumps, events)), orient + ' same multiset') + require([e for e in new_events if not B.is_r1(e)] == [e for e in events if not B.is_r1(e)], + orient + ' non-rank-1 order unchanged') + B.replay_frames(new_events, word) + reordered[orient] = new_events + summary[orient] = { + 'batches': nb, + 'phase_cap': sum(v['cap'] for v in per_phase.values()), + 'per_phase': per_phase, + 'pr1779_rule_original': B.rank_one_runs_1779(events), + 'pr1779_rule_reordered': B.rank_one_runs_1779(new_events), + } + return reordered, summary + + +def bad_move_past_own_scalar(events): + """Move the first rank-1 climb whose immediately preceding event is a scalar on its register before it.""" + es = copy.deepcopy(events) + for i in range(1, len(es)): + e, prev = es[i], es[i - 1] + if B.is_r1(e) and prev[0] == 'scalar' and ('L', e[2]) in B.touched(prev): + es[i - 1], es[i] = es[i], es[i - 1] + return es + raise SystemExit('FAIL: no control site') + + +def bad_move_across_phase(events): + """Move the last rank-1 climb of phase A to just after the next phase marker.""" + es = copy.deepcopy(events) + b = es.index(['phase', 'centers']) + i = max(k for k in range(b) if B.is_r1(es[k])) + ev = es.pop(i) + es.insert(es.index(['phase', 'centers']) + 1, ev) + return es + + +def bracket(nb): + p = dict(BASE) + p[1] -= B.BATCH * nb + if nb: + p[16] = nb + return C.ceiling(p, 73, 896, 9, 64, grid=GRID) + + +def main(): + m = members() + programs = json.loads(gzip.decompress(m['LOCAL-PROGRAMS.json.gz'])) + word = json.loads(gzip.decompress(m['CANONICAL-WORD.json.gz'])) + for orient, events in programs.items(): + B.replay_frames(events, word) + + reordered, summary = reorder(programs, word) + for orient in ('forward', 'backward'): + s = summary[orient] + require(s['batches'] == 134 and s['phase_cap'] == 149, orient + ' batch count / cap') + require(s['pr1779_rule_original'] == 8, orient + " PR1779's contiguous rule on the original") + require(s['pr1779_rule_reordered'] == 134, orient + " PR1779's contiguous rule on the reordered") + require(summary['forward'] == summary['backward'], 'orientation agreement') + + pinned = json.loads(m['INDEPENDENT-LOCAL-REPLAY.json']) + orig = run_checker(m['CANONICAL-WORD.json.gz'], programs) + require(orig is not None, 'retained checker accepts the original programs') + require(orig['local'] == pinned['local'] and orig['paid_profiles'] == pinned['paid_profiles'], + 'original receipt equals the pinned selected receipt') + new = run_checker(m['CANONICAL-WORD.json.gz'], reordered) + require(new is not None, 'retained checker accepts the reordered programs') + require(new['local'] == orig['local'] and new['paid_profiles'] == orig['paid_profiles'], + 'reordered receipt equals the original') + + controls = [] + for name, mut in (('climb_past_own_scalar', bad_move_past_own_scalar), + ('climb_across_phase', bad_move_across_phase)): + bad = dict(reordered) + bad['forward'] = mut(reordered['forward']) + require(run_checker(m['CANONICAL-WORD.json.gz'], bad) is None, 'control accepted: ' + name) + controls.append(name) + + base = bracket(0) + target = base[1] * Q(105, 100) + rows = {} + for nb in (8, 22, 23, 134, 149): + lo, hi = bracket(nb) + rows[str(nb)] = {'a_lo': str(lo), 'a_hi': str(hi), 'passes_5pct_gate': lo > target, + 'gain_pct_hi': f'{float(100 * (hi / base[1] - 1)):.4f}'} + require(not rows['22']['passes_5pct_gate'] and Q(rows['22']['a_hi']) < target, '22 batches miss the gate') + require(rows['23']['passes_5pct_gate'], '23 batches pass the gate') + require(Q(rows['8']['a_hi']) == Q(1719107428154, 10 ** 15), "PR1779's 8-batch ceiling reproduced") + + # Idle-displacing charge headroom at 134 batches (discussion 1596 convention): E extra rank-1 + # children per call replace E units of idle mass. Sharp: E = 1258 passes the gate, 1259 fails. + def charged(extra): + p = dict(BASE) + p[1] += extra - B.BATCH * 134 + p[16] = 134 + return C.ceiling(p, 73, 896, 9, 64, grid=GRID) + pass_e, fail_e = charged(1258), charged(1259) + require(pass_e[0] > target and fail_e[1] < target, 'sharp idle-displacing charge headroom 1258') + headroom = {'convention': 'idle-displacing extra rank-1 children per call, 134 batches, +5% gate', + 'max_extra_rank1': 1258, 'per_batch': '1258/134', + 'a_lo_at_1258': str(pass_e[0]), 'a_hi_at_1259': str(fail_e[1])} + + result = { + 'status': 'PASS_DIAGONAL_BATCH_COMMUTATION', + 'base_ceiling': [str(base[0]), str(base[1])], + 'gate_target_a': str(target), + 'orientations': summary, + 'ceilings_by_batches': rows, + 'checker_controls_rejected': controls, + 'charge_headroom': headroom, + } + text = json.dumps(result, indent=1, sort_keys=True) + '\n' + out = HERE / 'RESULT.json' + if '--write' in sys.argv: + out.write_text(text) + require(out.read_text() == text, 'RESULT.json receipt') + print(f"PASS_DIAGONAL_BATCH_COMMUTATION batches=134 phase_cap=149 pr1779_rule=8->134 " + f"gate_min=23 a_hi_134={float(Q(rows['134']['a_hi'])):.12f} controls={len(controls)}") + + +if __name__ == '__main__': + main() From ac3a759e874e8e526bc884fc2cb8eb114695b063 Mon Sep 17 00:00:00 2001 From: josie Date: Wed, 14 Oct 2026 06:42:33 -0400 Subject: [PATCH 3/3] README: state that global hosting/idle-frame audits were not re-run on the reordered programs Co-Authored-By: Claude Opus 5.5 --- research/diagonal-batch-commutation/README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/research/diagonal-batch-commutation/README.md b/research/diagonal-batch-commutation/README.md index 7368b075c9..f5e00678bd 100644 --- a/research/diagonal-batch-commutation/README.md +++ b/research/diagonal-batch-commutation/README.md @@ -52,6 +52,9 @@ that convention is not computed here. rank-16 child needs copies, frames, hosting, output storage, precision and arbitrary-dirty restoration. This package inherits #1779's premise that a diagonal rank-16 child realizes 16 independent rank-1 climbs, and does not examine it. +- The reorder is checked only at the local level. Every register's frame at each phase marker is unchanged + because climbs stay inside their phase. The check does not establish that global hosting and the idle-remainder + frame audit (`global/hosted`, `global/audit` in the replay archive) are insensitive to positions inside a phase. - Batch counts are a greedy lower bound. 149 is the trivial phase cap, not an attained value. - The bit supplier binds well before +39% (#1605), so the complex ceiling alone does not set κ.