From 6b14e212a1aba401d29f2bf7378e745ee2aed7f2 Mon Sep 17 00:00:00 2001 From: Abhinav Ramachandran Date: Thu, 15 Oct 2026 10:29:30 -0700 Subject: [PATCH] Add H2-F framed-transfer admission for the R439 target-feeding wrap Scoped interface audit on the pinned selected R439 word: PR1194's H2-sem condition 2 is not used by the framed transfer. The F4-shaped target-feeding-helper wrap passes every semantic premise and conclusion component and fails only the three recorded syntactic flags; three new target-class negative controls carry the clause's protective role. No pricing, no supplier adoption, no new kappa. Task bit-helper-contract, claim thread discussions/2684. --- .../CERTIFICATE.json | 40 +++ .../README.md | 116 ++++++++ .../SOURCES.json | 54 ++++ .../TASK.json | 67 +++++ .../VERIFY.json | 25 ++ .../verify.py | 265 ++++++++++++++++++ 6 files changed, 567 insertions(+) create mode 100644 research/r439-h2sem-cond2-framed-transfer/CERTIFICATE.json create mode 100644 research/r439-h2sem-cond2-framed-transfer/README.md create mode 100644 research/r439-h2sem-cond2-framed-transfer/SOURCES.json create mode 100644 research/r439-h2sem-cond2-framed-transfer/TASK.json create mode 100644 research/r439-h2sem-cond2-framed-transfer/VERIFY.json create mode 100644 research/r439-h2sem-cond2-framed-transfer/verify.py diff --git a/research/r439-h2sem-cond2-framed-transfer/CERTIFICATE.json b/research/r439-h2sem-cond2-framed-transfer/CERTIFICATE.json new file mode 100644 index 0000000000..b923dfc8a2 --- /dev/null +++ b/research/r439-h2sem-cond2-framed-transfer/CERTIFICATE.json @@ -0,0 +1,40 @@ +{ + "status": "PASS_R439_H2SEM_COND2_FRAMED_TRANSFER", + "assignment_nonce": "2276dce171053917945d67a485ce77f3", + "task_id": "bit-helper-contract", + "scope_status": "refined", + "columns": 661, + "word_canonical_sha256": "5642fd0e35a1acc11acff8d0c08350c1617e95f310d4d35ad63a651f9eeeba0b", + "h2f_admission_f4_target_feed_wrap": { + "cond1_zero_frame_distinct_operands": true, + "cond2_no_target_feeds_helper_or_source": false, + "boundary_operator_exact": true, + "frames_at_cut_equal": true, + "semantic_K_equals_raw_K": true, + "h1_restricted_to_W0_and_C": true, + "conclusion_U_J_Uinv_flags_pass": true, + "inherited_flag_failures": [ + "H1_no_target_feeds_z", + "H2_D_frame0_targets_from_helpers", + "K_equals_D" + ], + "compensated_a_rows_before_fed_gate": 67, + "d_source_reads": 18154 + }, + "predecessor_f4_record_matches_pinned_certificate": true, + "f5_source_feed_still_excluded": { + "raw_operator_exact": true, + "cond1_zero_frame_distinct_operands": false, + "cond2_no_target_feeds_helper_or_source": true, + "framed_replay_rejection": "climb not nested: register 0 from frame 2 (dim 1) to frame 0 (dim 0)" + }, + "negative_and_positive_controls": [ + "baseline word passes all inherited flags and the virtual-splice premises", + "F4 target-feeding wrap admitted under H2-F; only the global syntactic flags H1_no_target_feeds_z, H2_D_frame0_targets_from_helpers, K_equals_D fail, as pinned", + "N1 uncompensated feed rejected: 67 target columns moved by the fed target's dirt (first: 111)", + "N2 wrong compensation target rejected on 67 target columns", + "N3 late restore (span crossing the fed target's own gate) rejected; the fed helper's identity row breaks", + "F5 source-feeding wrap still rejected without condition 2: condition 1 and the framed replay's nested-climb check refuse it" + ], + "kappa_claim": "none" +} diff --git a/research/r439-h2sem-cond2-framed-transfer/README.md b/research/r439-h2sem-cond2-framed-transfer/README.md new file mode 100644 index 0000000000..1649a6df45 --- /dev/null +++ b/research/r439-h2sem-cond2-framed-transfer/README.md @@ -0,0 +1,116 @@ +# H2-F: the H2-sem no-target-feedback clause is not used by the framed transfer (no new kappa) + +**Scoped interface admission on the pinned selected R439 word; no circuit pricing, no supplier adoption.** +The selected result, the selected bit supplier and `upstream/` are unchanged. + +The merged package `research/r439-copyshare-h2sem-admission` (Aaron Wang) records its F4-shaped +target-feeding-helper wrap as operator-exact but rejected only by PR1194's H2-sem condition 2, and +leaves open whether that clause is needed at the framed level, with the exact use of H1 in the +interleaved lemma named as the check to make. This package makes that check and answers it. + +## What this package establishes + +H1's role in the interleaved scalar-interface lemma (`research/e8-bit-r420/README.md`, the #543 +lemma inherited by the selected word's checker) is confined to the z-gate transvection induction +over the gates of W0 = (A, scatter, B) and the cleanup C: "A z-gate reads only z registers +(H1, H3), so it multiplies U_k on the left by an elementary transvection". The D section enters +the lemma only as the operator y -> y + N s. Under the PR1194 substitution bridge the lemma is +invoked on the virtual splice word, which keeps the original target-only D, and the actual D +prefix is transferred by coefficient-matrix equality on all basis columns at the zero frame with +identical state and frames at the D/A cut. None of these steps consults whether a +target-feeding gate occurs inside the actual D. + +The instance check: the F4 wrap is rebuilt through the pinned predecessor machinery (its own +unmodified module, its pinned certificate facts reproduced field for field), and every semantic +premise and conclusion component passes: + +| component | F4 wrap | +|---|---| +| H2-sem condition 1 (zero frame, distinct operands from targets and helpers) | pass | +| complete D operator on all 661 basis columns | exact | +| state and frames at the D/A cut | equal to baseline | +| semantic N = K | pass | +| H1 restricted to W0 and C (byte-equal sections; baseline flags all pass) | pass | +| U, J, Uinv conclusion flags of the unchanged checker | pass | +| inherited flag failures | exactly H1_no_target_feeds_z, H2_D_frame0_targets_from_helpers, K_equals_D | +| D source reads | 18154, as pinned | + +Only the three global syntactic flags fail — the same three recorded in the predecessor +certificate. Removing condition 2 therefore does not change what the transfer verifies. F5-shaped +source feeds remain inadmissible through condition 1 together with the framed replay's +nested-climb legality (`climb not nested: register 0 from frame 2 (dim 1) to frame 0 (dim 0)`), +which is re-checked here without condition 2. + +The protective work condition 2 was conservatively doing is shown to be carried by the semantic +conditions, through three new negative controls: + +| control | outcome | +|---|---| +| N1 uncompensated feed (body rows keep reading the dirtied helper) | rejected: 67 target columns moved by the fed target's dirt, first column 111 | +| N2 feed compensated by the wrong target | rejected on 67 target columns | +| N3 restore moved past the fed target's own gate (span crossing it) | rejected: the fed helper's identity row breaks | + +## Reproduce + +Standard library only, about two minutes, from the repository root: + +```sh +python3 -I -B research/r439-h2sem-cond2-framed-transfer/verify.py +python3 scripts/research_package.py --package research/r439-h2sem-cond2-framed-transfer --check-only +``` + +Expected final line: + +```text +PASS_R439_H2SEM_COND2_FRAMED_TRANSFER columns=661 compensated_rows=67 n1_columns=67 n2_columns=67 controls=6 no_new_kappa +``` + +The verifier pins every consumed source by SHA-256 (`SOURCES.json`), rebuilds the F4 wrap +deterministically through the predecessor package's own unmodified module, replays all 661 basis +columns through the unchanged `xcheck_p.py` owner checker, compares the inherited flag failures +and read counts field for field against the pinned predecessor certificate, runs the three +negative controls and the F5 exclusion, and compares the complete report against `CERTIFICATE.json`. + +## Scope and what is not claimed + +* **No pricing.** The F4 wrap is an operator-preserving admissibility probe (it adds 69 reads), + not a saving. Whether any target-feedback implementation beats its restricted alternative in a + priced model is the census side: open #2567 (at most eight registers, unit-cost single-source + gates) and discussions/1290, /1544. This package adds no evidence on savings either way. +* **Admission, not supplier adoption.** No word is proposed for the selected chain; F/B positive + envelopes, the 104/192-bit guards, hosted costs and the paid profile were not recomputed for + any variant. The outer assembly, all-size compiler, hosting, precision/tape, recovery and + analytic obligations are untouched. +* **Scoped to the transfer argument.** The result is about the necessity of condition 2 inside the + framed transfer for the interleaved-lemma conclusion, under this word's D-prefix equivalence + discipline. It does not restate the whole H2-sem contract for other architectures, other words + or nonzero-frame placements. +* The chronological substitution bridge, the module argument and the semantic D contract are + PR1194's and are consumed unmodified; this package adds the necessity analysis and the instance + evidence. + +## Open next questions + +* Does a target-feedback wrap with a genuine positive saving exist in a priced model? Why it + matters: the enlarged admissible class only pays off if a priced construction uses it. First + step: extend the #2567 dirty-shear census's cost model with multi-operand compensated reads (the + F4 class is two-operand), beyond its single-source unit-cost gates. Blocked by: that census's + model and at-most-eight-register domain are #2567's scope; extending the model is a separate + priced search. +* Should the inherited checker expose per-section H1 flags? Why it matters: consumers must + currently re-derive "H1 on W0 and C" from byte-equality of the non-D sections plus the baseline + flags, as this verifier does. First step: a backward-compatible optional per-section flag in + `xcheck_p.py`'s interface report. Blocked by: the checker is a pinned source for many merged + packages; any edit must be a separate reviewed change. + +## Credit and disclosure + +Prepared by Abhinav Ramachandran (geckods) with substantial assistance from a Hermes agent +(Nous Research, GLM-5.3) under the standard donation prompt. Credit: **Aaron Wang, +r439-copyshare-h2sem-admission** (the F4/F5 constructions, the pinned certificate and machinery +reused unmodified), **woklerx, PR1194** (`research/r439-semantic-d-contract-seed10/PROOF.md`: the +H2-sem contract and the chronological substitution bridge), **eumemic PR555** and +**DreamingOfClouds PR589** (the R439 word), the R420/#543 interleaved-lemma lineage, and the +pinned `xcheck_p.py` owner checker. Apache-2.0; no independent human review is claimed. +Assignment nonce `2276dce171053917945d67a485ce77f3` (task `bit-helper-contract`, priority +revision 5); claim and investigation thread: discussions/2684. diff --git a/research/r439-h2sem-cond2-framed-transfer/SOURCES.json b/research/r439-h2sem-cond2-framed-transfer/SOURCES.json new file mode 100644 index 0000000000..2bda2d98aa --- /dev/null +++ b/research/r439-h2sem-cond2-framed-transfer/SOURCES.json @@ -0,0 +1,54 @@ +{ + "schema_version": 1, + "base_commit": "b4560d9e7216f72b73c5aa940ac099c05e33ccf9", + "files": [ + { + "path": "certificates/selected-result.json", + "usage": "provenance", + "git_blob": "ae6a99f28aa468649eb66a361e764d769363bf11", + "sha256": "10b9e340fd8e354a37a0c4813c90e5de1dd42044b5f6aca4a3fc5a42b685fa32" + }, + { + "path": "docs/research/agent-task-catalog.json", + "usage": "provenance", + "git_blob": "889b95d936746df124872133ae1e7cc339adcb92", + "sha256": "7d185cd8c2af35988d638d969748ad7b670f902606444dbfc748e4402c340df6" + }, + { + "path": "research/e8-bit-p111-tuned/code/xcheck_p.py", + "usage": "input", + "git_blob": "184f5dcf94a486cc7db91ca4db5865916bf26009", + "sha256": "af3decc877e27c00001cf56f50c6c09566e8e101297ab34c7860aed96a06d80e" + }, + { + "path": "research/e8-bit-p111-tuned/tune/bitE8mut-p111-tuned.json.gz", + "usage": "input", + "git_blob": "85a4499bf9e4911a705d50567a2c2ef6cf23739a", + "sha256": "e3e301e62bc2b41dbf1ceac0acf3d35824ebeab1848c5a2142d4577b109da52f" + }, + { + "path": "research/e8-bit-r420/README.md", + "usage": "input", + "git_blob": "6751eba6f617292fc919e58d5a9f9f06ab037391", + "sha256": "9807be57c6adf26b30e4f54e2f8160075bbc05091f1a6d157e43d2a4620c1c9f" + }, + { + "path": "research/r439-copyshare-h2sem-admission/CERTIFICATE.json", + "usage": "input", + "git_blob": "a874a9840acd80474c92ca01e035929163bc08aa", + "sha256": "2678eaa3049cb208c6914be61cff93a72965b44e3abdf847c17595c9b7013594" + }, + { + "path": "research/r439-copyshare-h2sem-admission/verify.py", + "usage": "input", + "git_blob": "e24e90390acc3f032041da98340288c21ad398b3", + "sha256": "09400f88e9e598bc6022ba32fcc6f9d1f048c5106b4d73b02a6f9f318be1c812" + }, + { + "path": "research/r439-semantic-d-contract-seed10/PROOF.md", + "usage": "input", + "git_blob": "2707fdb0d2f34c1c6c4ea41c2a68e44904a3e4fd", + "sha256": "dfbca8c61a92fdf0db8af450dc4466849da37fc296e28b67f357e196e87327db" + } + ] +} diff --git a/research/r439-h2sem-cond2-framed-transfer/TASK.json b/research/r439-h2sem-cond2-framed-transfer/TASK.json new file mode 100644 index 0000000000..653211d616 --- /dev/null +++ b/research/r439-h2sem-cond2-framed-transfer/TASK.json @@ -0,0 +1,67 @@ +{ + "schema_version": 1, + "task_id": "bit-helper-contract", + "priority_revision": 5, + "base_commit": "b4560d9e7216f72b73c5aa940ac099c05e33ccf9", + "original_card": { + "id": "bit-helper-contract", + "question": "Can one precisely specified helper-mixing word satisfy a replacement for the inherited H2/K interface?", + "starting_points": [ + "docs/research/research-family-status.md", + "research/r439-bsection-stars-seed01/README.md", + "research/r439-copy-path-sharing-barrier/README.md" + ], + "methods": [ + "Derive a replacement interface lemma and price its implementation.", + "Seek an exact dirty-input or chronological-cut counterexample to the proposed replacement." + ], + "acceptance_gate": "A full boundary contract and paid profile; unchanged scalar counts alone are insufficient. A scoped local result may be retained without a complete supplier. Expanding it into further construction rounds requires the family-level budget and obligation gate in research-family-status.md; an optimistic passing relaxation alone is not acceptance.", + "first_step": { + "command": [ + "python3", + "-B", + "research/r439-bsection-stars-seed01/verify.py" + ], + "expected": "PASS_R439_BSECTION_STARS", + "inspect": "Compare the two false H2/K flags with the unchanged paid profile in its README.", + "scope": "Positive control / source-bound orientation only; this is not a new construction or full cold replay." + }, + "first_experiment": "Write one replacement H2/K implication for a single helper-star operation, then try to falsify it on dirty inputs.", + "bottleneck_link": "A legitimate replacement could admit a cheaper bit circuit; scalar savings alone do not alter the selected moment.", + "allowed_variations": [ + "Choose one helper-star or quartet instance; narrow to one boundary implication." + ], + "scope_change_triggers": [ + "Changing only source count or scalar addition count without an interface argument." + ], + "overlap_terms": [ + "H2_D_frame0_targets_from_helpers", + "K_equals_D", + "helper-star" + ] + }, + "scope_status": "refined", + "actual_scope": "Framed-level necessity of PR1194's H2-sem condition 2: proof-role extraction of H1 in the interleaved scalar-interface lemma, plus instance admission of the F4-shaped target-feeding-helper wrap on the pinned selected R439 word through the merged h2sem package's unmodified machinery, with three new target-class negative controls (uncompensated feed, wrong compensation target, span crossing the fed target's own gate).", + "scope_change_reason": "The card's headline experiment (one replacement H2/K implication for a helper-mixing word) is completed on main by research/r439-copyshare-h2sem-admission for helper-feeding wraps; this session takes that merged package's recorded second open next question (is condition 2 needed at the framed level) on the same word and machinery, which the card's acceptance gate admits as a scoped local result.", + "bottleneck_link": "The result does not itself change the selected moment; it enlarges the admissible wrap class for the selected bit word's D section, where the next priced bit constructions are selected, and closes a recorded open question on the inherited interface contract.", + "budget_minutes": 60, + "stop_rule": "Stop after the admission verdict (every semantic premise and conclusion component passes under the weakened contract, or one exact failing component on dirty columns is recorded) plus the target-class negative controls; no priced search and no census extension.", + "outcome": "completed", + "evidence": "CERTIFICATE.json: PASS_R439_H2SEM_COND2_FRAMED_TRANSFER; all 661 basis columns replayed through the unchanged xcheck_p.py; predecessor F4 record reproduced field for field (flags, reads 18154); conditional admission with controls=6 and no new kappa; reproduce via python3 -B research/r439-h2sem-cond2-framed-transfer/verify.py.", + "author": "Abhinav Ramachandran", + "ai_assistance": "Prepared by Abhinav Ramachandran (geckods) with substantial end-to-end assistance from a Hermes agent (Nous Research, GLM-5.3) under the standard donation prompt in autoresearch.md.", + "open_questions": [ + { + "question": "Does a target-feedback wrap with a genuine positive saving exist in a priced model?", + "why_it_matters": "The enlarged admissible class only pays off if a priced construction uses it; otherwise the admission remains contract-level only.", + "first_step": "Extend the #2567 dirty-shear census's cost model with multi-operand compensated reads (the F4 class is two-operand), beyond its single-source unit-cost gates.", + "blocked_by": "That census's model and at-most-eight-register domain are #2567's scope; extending the model is a separate priced search." + }, + { + "question": "Should the inherited checker expose per-section H1 flags?", + "why_it_matters": "Consumers currently re-derive H1 on W0 and C from byte-equality of the non-D sections plus the baseline flags, as this verifier does.", + "first_step": "A backward-compatible optional per-section flag in xcheck_p.py's interface report.", + "blocked_by": "The checker is a pinned source for many merged packages; any edit must be a separate reviewed change." + } + ] +} diff --git a/research/r439-h2sem-cond2-framed-transfer/VERIFY.json b/research/r439-h2sem-cond2-framed-transfer/VERIFY.json new file mode 100644 index 0000000000..bbc3f198a4 --- /dev/null +++ b/research/r439-h2sem-cond2-framed-transfer/VERIFY.json @@ -0,0 +1,25 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [ + "research/e8-bit-p111-tuned/code/xcheck_p.py", + "research/e8-bit-p111-tuned/tune/bitE8mut-p111-tuned.json.gz", + "research/e8-bit-r420/README.md", + "research/r439-copyshare-h2sem-admission/CERTIFICATE.json", + "research/r439-copyshare-h2sem-admission/verify.py", + "research/r439-semantic-d-contract-seed10/PROOF.md" + ], + "commands": [ + { + "argv": [ + "{python}", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 600, + "checks": "SHA-256 source pins; exact 661-column framed replay through the unchanged xcheck_p.py; predecessor F4 certificate facts reproduced field for field; conditional admission of the F4 wrap under the weakened H2-F contract with only the three recorded syntactic flags failing; three target-class negative controls rejected (N1, N2, N3); F5 source feed still rejected by condition 1 and the nested-climb replay; frozen CERTIFICATE.json byte match." + } + ] +} diff --git a/research/r439-h2sem-cond2-framed-transfer/verify.py b/research/r439-h2sem-cond2-framed-transfer/verify.py new file mode 100644 index 0000000000..ecb7bbf757 --- /dev/null +++ b/research/r439-h2sem-cond2-framed-transfer/verify.py @@ -0,0 +1,265 @@ +#!/usr/bin/env python3 +"""H2-F: PR1194's H2-sem condition 2 is not used by the framed transfer. + +On the pinned selected R439 word and the unchanged xcheck_p owner checker, the +F4-shaped target-feeding-helper wrap of research/r439-copyshare-h2sem-admission +passes every semantic premise of the substitution bridge (zero-frame condition +1, complete boundary operator on all 661 basis columns, identical state and +frames at the D/A cut, semantic N = K) and every conclusion component of the +interleaved scalar-interface lemma (U, J, Uinv on W0; K semantically), and +fails only the global syntactic flags H1_no_target_feeds_z, +H2_D_frame0_targets_from_helpers and K_equals_D, exactly as recorded in the +predecessor certificate. The hypothesis restriction "no target feeds a helper +inside D" (H2-sem condition 2) is therefore not exercised anywhere in the +transfer: by the R420/#543 lemma text, H1's proof role is confined to the +z-gate transvection induction over the gates of W0 = (A, scatter, B) (and +C = U^-1), all of which are outside D and byte-identical to the baseline whose +flags all pass. F5-shaped source feeds stay inadmissible through condition 1 +(distinct operands drawn from targets and helpers) and the framed replay's +nested-climb legality, not through condition 2. + +New negative controls show the semantic conditions carry the load that +condition 2 was conservatively holding for target-column dirt: an +uncompensated feed (the fed helper's row reads stay dirty), a feed compensated +by the wrong target, and a restore moved past the fed target's own gate all +break the complete-operator check on explicit columns, while the F4 wrap +itself remains exact. + +Apache-2.0. Prepared by Abhinav Ramachandran (geckods) with substantial +assistance from a Hermes agent (GLM-5.3). The word, checker and the +predecessor package research/r439-copyshare-h2sem-admission (its verify.py, +CERTIFICATE.json and F4/F5 construction) and +research/r439-semantic-d-contract-seed10/PROOF.md are consumed as pinned, +unmodified sources. +""" +import copy +import gzip +import hashlib +import importlib.util +import json +from pathlib import Path + +HERE = Path(__file__).resolve().parent +ROOT = HERE.parent.parent +H2SEM_DIR = ROOT / "research/r439-copyshare-h2sem-admission" +H2SEM_CERT = H2SEM_DIR / "CERTIFICATE.json" +WORD = ROOT / "research/e8-bit-p111-tuned/tune/bitE8mut-p111-tuned.json.gz" + + +def need(ok, message): + if not ok: + raise ValueError(message) + + +def load_module(path, name): + spec = importlib.util.spec_from_file_location(name, path) + module = importlib.util.module_from_spec(spec) + spec.loader.exec_module(module) + return module + + +def check_pins(): + pins = json.loads((HERE / "SOURCES.json").read_text()) + for entry in pins["files"]: + if entry["usage"] != "input": + continue + data = (ROOT / entry["path"]).read_bytes() + need(hashlib.sha256(data).hexdigest() == entry["sha256"], + "source pin mismatch: " + entry["path"]) + + +def build_feed(word, a, t_reg, k, comp_reg=None, compensate=True, restore_after_k=False): + """The F4 target-feeding-helper wrap, factor for factor as in the + predecessor package's inline construction, plus the dial positions used + by the negative controls. + + prep: a ^= t_reg (the feed; a becomes a0 ^ t0 on basis columns). + body: every row i < k that reads a gains t_reg as an extra operand when + compensate=True, so its a-read is compensated (a ^ t = a0); with + comp_reg set, the wrong target is used instead. + restore: a ^= t_reg, placed before gate k (reading the still-unmodified + target) or, when restore_after_k=True, after it (reading t_new). + """ + if comp_reg is None: + comp_reg = t_reg + need(comp_reg not in set().union(*(set(g[2]) for g in word["D"])), + "compensation target already read by D") + body = [] + for i, g in enumerate(word["D"]): + row = set(g[2]) + if compensate and i < k and a in row: + row.add(comp_reg) + body.append([g[0], g[1], sorted(row)]) + feed = copy.deepcopy(word) + if restore_after_k: + feed["D"] = [[0, a, [t_reg]]] + body[:k] + body[k:] + [[0, a, [t_reg]]] + else: + feed["D"] = [[0, a, [t_reg]]] + body[:k] + [[0, a, [t_reg]]] + body[k:] + return feed + + +def main(): + need(__debug__, "run without -O: the inherited checker requires assertions") + check_pins() + word = json.loads(gzip.decompress(WORD.read_bytes())) + h2sem = load_module(H2SEM_DIR / "verify.py", "h2sem_verify") + checker = h2sem.load_checker() + cert = json.loads(H2SEM_CERT.read_text())["f4_target_feed_probe"] + controls = [] + + # Baseline: the pinned word passes every inherited flag; this is the + # PR1194 virtual splice (literal A/scatter/B/C with the original + # target-only D), on which the interleaved lemma is invoked. + val0, cur0, shape0, N0 = h2sem.d_shape(word, checker) + need(shape0, "baseline D operator is not (x, y + N h, h)") + _, _, _, H0, C0, _ = checker.check(word) + need(all(H0.values()) and all(C0.values()), "baseline flags failed") + K0 = h2sem.raw_K(word, checker) + need(N0 == K0, "baseline semantic N != raw K") + controls.append("baseline word passes all inherited flags and the virtual-splice premises") + + matching, census = h2sem.nominate_d(word, 42) + need(census["best_pair"] == [277, 434] and census["best_saving"] == 65, + "PR848 best pair moved") + a, _b = matching[0] + t_reg = word["D"][-1][1] + k = len(word["D"]) - 1 + need(sum(1 for g in word["D"] if g[1] == t_reg) == 1, "fed target not written exactly once") + + # (I) the F4-shaped target-feeding wrap, rebuilt through the same + # construction as the predecessor certificate: every semantic premise and + # every conclusion component holds; only the global syntactic flags fail. + feed = build_feed(word, a, t_reg, k) + cond1, cond2 = h2sem.h2sem_conditions(feed) + val, cur, shape_ok, N = h2sem.d_shape(feed, checker) + _, _, _, H, C, _ = checker.check(feed) + failed = sorted(k2 for k2, v2 in list(H.items()) + list(C.items()) if not v2) + need(cond1, "F4 fails zero-frame/direct-operand condition 1") + need(not cond2, "F4 unexpectedly satisfies condition 2") + need(shape_ok and val == val0 and cur == cur0, "F4 breaks the D-prefix equivalence") + need(N == N0 == K0, "F4 breaks the semantic K equality") + need(failed == cert["inherited_flag_failures"], + "F4 inherited failures diverge from the pinned certificate: " + repr(failed)) + need(h2sem.reads(feed) == cert["d_source_reads"], "F4 source reads diverge") + need(all(feed[key] == word[key] for key in word if key != "D"), + "F4 modified a non-D section") + need(H0["H1_no_target_feeds_z"], "baseline global H1 did not pass") + h1_w0c = all(feed[key] == word[key] for key in word if key != "D") and \ + H0["H1_no_target_feeds_z"] + need(h1_w0c, "H1 restricted to W0 and C failed") + compensated_rows = sum(1 for i, g in enumerate(word["D"]) if i < k and a in set(g[2])) + admission = { + "cond1_zero_frame_distinct_operands": cond1, + "cond2_no_target_feeds_helper_or_source": False, + "boundary_operator_exact": bool(shape_ok and val == val0), + "frames_at_cut_equal": cur == cur0, + "semantic_K_equals_raw_K": bool(N == K0 == N0), + "h1_restricted_to_W0_and_C": True, + "conclusion_U_J_Uinv_flags_pass": all(C[f] for f in C if f != "K_equals_D"), + "inherited_flag_failures": failed, + "compensated_a_rows_before_fed_gate": compensated_rows, + "d_source_reads": h2sem.reads(feed), + } + need(admission["boundary_operator_exact"] and admission["frames_at_cut_equal"] + and admission["semantic_K_equals_raw_K"] and admission["h1_restricted_to_W0_and_C"], + "H2-F admission premises failed") + controls.append("F4 target-feeding wrap admitted under H2-F; " + "only the global syntactic flags H1_no_target_feeds_z, " + "H2_D_frame0_targets_from_helpers, K_equals_D fail, as pinned") + + # N1: uncompensated feed. The fed helper stays dirty (a0 ^ t0) through the + # body, every a-reading row shifts on the fed target's column, and the + # complete-operator check must catch it: target-column dirt through the + # helper is exactly what conditions 3 (boundary) sees. + n1 = build_feed(word, a, t_reg, k, compensate=False) + val1, _, shape1, _ = h2sem.d_shape(n1, checker) + diff1 = sorted(i for i in range(len(val0)) if val1[i] != val0[i]) + need(val1 != val0, "uncompensated feed preserved the operator") + need(diff1 and all(word["v"] <= d < 2 * word["v"] for d in diff1), + "uncompensated feed broke something other than target columns: " + repr(diff1)) + controls.append("N1 uncompensated feed rejected: %d target columns moved by the " + "fed target's dirt (first: %d)" % (len(diff1), diff1[0])) + + # N2: feed compensated by the wrong target. The compensation operand is + # pinned by the complete-column check, not by any gate-local rule. + a_row_dsts = {g[1] for g in word["D"] if a in set(g[2])} + other_t = next(g[1] for g in word["D"] if g[1] != t_reg and g[1] not in a_row_dsts) + need(other_t != t_reg, "no second target available") + n2 = build_feed(word, a, t_reg, k, comp_reg=other_t) + val2, _, _, _ = h2sem.d_shape(n2, checker) + diff2 = sorted(i for i in range(len(val0)) if val2[i] != val0[i]) + need(val2 != val0, "wrong compensation target preserved the operator") + need(diff2 and all(word["v"] <= d < 2 * word["v"] for d in diff2), + "wrong compensation target broke something other than target columns") + controls.append("N2 wrong compensation target rejected on %d target columns" % len(diff2)) + + # N3: restore moved past the fed target's own gate (span crosses the + # boundary the F4 shape respects). The restore now reads t_new, so the + # helper row itself is no longer identity: the cut-state clauses bite. + n3 = build_feed(word, a, t_reg, k, restore_after_k=True) + val3, _, shape3, _ = h2sem.d_shape(n3, checker) + diff3 = sorted(i for i in range(len(val0)) if val3[i] != val0[i]) + need(val3 != val0, "late restore preserved the operator") + need(not shape3 and a in diff3, + "late restore must break the fed helper's identity row") + controls.append("N3 late restore (span crossing the fed target's own gate) rejected; " + "the fed helper's identity row breaks") + + # F5 recheck: source-feeding wrap. The raw operator is exact, but the + # framed replay rejects the frame-0 source read outright, and condition 1 + # (operands drawn from targets and helpers) already excludes it. What + # condition 2 was conservatively covering is covered here without it. + s_reg = 0 + body5 = [] + for g in word["D"]: + row = set(g[2]) + if a in row: + row.add(s_reg) + body5.append([g[0], g[1], sorted(row)]) + sfeed = copy.deepcopy(word) + sfeed["D"] = [[0, a, [s_reg]]] + body5 + [[0, a, [s_reg]]] + val_s, _, _ = checker.Word(sfeed).replay(sections=("D",), frames_on=False) + need(val_s == val0, "F5 was supposed to preserve the raw scalar operator") + cond1_s, cond2_s = h2sem.h2sem_conditions(sfeed) + need(not cond1_s and cond2_s, "F5 unexpected condition pattern") + try: + h2sem.d_shape(sfeed, checker) + except checker.Reject as exc: + f5_reject = str(exc) + need("climb not nested" in f5_reject, "F5 rejected for an unexpected reason: " + f5_reject) + else: + raise ValueError("negative control accepted: source-feeding helper wrap") + controls.append("F5 source-feeding wrap still rejected without condition 2: " + "condition 1 and the framed replay's nested-climb check refuse it") + + report = { + "status": "PASS_R439_H2SEM_COND2_FRAMED_TRANSFER", + "assignment_nonce": "2276dce171053917945d67a485ce77f3", + "task_id": "bit-helper-contract", + "scope_status": "refined", + "columns": 2 * word["v"] + word["R"], + "word_canonical_sha256": hashlib.sha256(json.dumps(word, sort_keys=True, separators=(",", ":")).encode()).hexdigest(), + "h2f_admission_f4_target_feed_wrap": admission, + "predecessor_f4_record_matches_pinned_certificate": True, + "f5_source_feed_still_excluded": { + "raw_operator_exact": True, + "cond1_zero_frame_distinct_operands": cond1_s, + "cond2_no_target_feeds_helper_or_source": cond2_s, + "framed_replay_rejection": f5_reject, + }, + "negative_and_positive_controls": controls, + "kappa_claim": "none", + } + certificate = HERE / "CERTIFICATE.json" + if certificate.exists(): + need(report == json.loads(certificate.read_text()), "certificate mismatch") + else: + (HERE / "DRAFT-REPORT.json").write_text(json.dumps(report, indent=2) + "\n") + print("draft report written; inspect DRAFT-REPORT.json, then freeze as CERTIFICATE.json") + print("PASS_R439_H2SEM_COND2_FRAMED_TRANSFER columns=%d compensated_rows=%d " + "n1_columns=%d n2_columns=%d controls=%d no_new_kappa" + % (2 * word["v"] + word["R"], compensated_rows, len(diff1), len(diff2), len(controls))) + + +if __name__ == "__main__": + main()