diff --git a/research/deferred-k-q-placement-audit/README.md b/research/deferred-k-q-placement-audit/README.md new file mode 100644 index 0000000000..e5ce1832ae --- /dev/null +++ b/research/deferred-k-q-placement-audit/README.md @@ -0,0 +1,88 @@ +# Independent mode-0 check of deferred-K Q placement + +**No new κ.** The selected conditional result stays the value pinned in +`certificates/selected-result.json` at base +`32890bc5de034ab8fc93ac88ead7279a6a416d04`. This does not admit a global +caller and does not change the eight-H1 deferred-K invoice. + +## Scope and evidence + +The merged component in `research/deferred-k-query-sharing-component` +removes eight old-h queries and pays 120 bare current-source queries. +Its proof states that `q = R D^{-1}` is bare positive `C1` on physical +axis 0, and that mode-0 `Km0` is a width-one counterexample to wrapping +those queries by `K`. The component checker records that counterexample +as inherited from the frozen source audit and not recomputed by an engine. + +This package recomputes it. The literal word, read from the pinned report +`REPORT-v1.md` (SHA256 +`fb60187fea8346539abb61a08b1c525825cc84bd7c2847eb44a7c9590f3abee3`), is + +```text +D(quadratic=0, linear=[2,2,2,2,0,0,0,0,0]) +P(rows=[7,13,11,14,16,32,64,128,256]) +X(0) +phase(0). +``` + +Apply `D`, then `P`, then `X`, then the phase. On nine bits: + +- `K|0⟩ = |0⟩` and `K^{-1}|1⟩ = -|7⟩`. +- `K^{-1} X_1 K = -X_7` on every computational basis vector. +- Bare `Q = a I + b X_1`, with `a = (1+i)/2` and `b = (1-i)/2`, sends + `|0⟩` to `a|0⟩ + b|1⟩`. +- The wrapped operator sends `|0⟩` to `a|0⟩ - b|7⟩`. +- Writing composition with the rightmost factor applied first, + `R = D Q` on every basis vector: `Q` is one positive `C` on axis 0 and + `D` is the positive `C` product on axes 1 through 8, low axis first. + So bare `Q` is `D^{-1} R`, which is the report's `R D^{-1}` in that + application order. +- The same `K` commutes with this `R` and fails to commute with bare `Q`, + on every basis vector. +- Source axes `[0,9,10,11,12,13,14,15,16]` send local mask 7 to global + mask `1537 = 2^0 + 2^9 + 2^10` and leave local mask 1 at global mask 1. + +Clearing the first linear phase is a negative control: `K^{-1}|1⟩` is then +not `-|7⟩`. + +The check is an operator identity for this word. It does not rerun the +native body, install Q120, or price a caller. + +## Reproduce + +From the repository root: + +```sh +python3 scripts/research_package.py --package research/deferred-k-q-placement-audit --check-only +python3 -B scripts/research_package.py --package research/deferred-k-q-placement-audit +``` + +Direct command: `python3 -I -Werror -B research/deferred-k-q-placement-audit/verify.py`. +Expected token: `PASS_DEFERRED_K_Q_PLACEMENT`. One mode is about one minute +on CPython 3.12. + +## Open next questions + +Can a version-correct global occurrence ledger fund a gain from this +overlay? The component's own economics note still requires at least 28 +further H1 deletions or genuine reuses at `C = .00330007` if only H1 +counts change, and the standalone profile loses for every `0 < C < 1`. +The first step is to bind one real caller occurrence by input version, +owner, chart, phase, axes, and lifetime. No such caller is in this +package. + +Can the helper and owned raw inverse-transpose be emitted? Start from the +ordered routes. The mode-0 calculation does not supply them. + +## Credit + +The deferred-K component, literal word, and inherited counterexample are +Chris R / Clear1nsight's PR #5423, with the peer fused-T placement, +Dillon Amburgey / dillona #5402, Ali Romman #5411, zxv #5419, and the +retained native, helper, and precision authors named in that package. +The source-frame audit that first read `Km0` is the pinned +`BALANCED-J-CURRENT-Q-FRAME-audit` report. This package only recomputes +that operator witness. + +Prepared by unpaidmoon with substantial Cursor Grok assistance. +Apache-2.0. This is not a formal verification of the multiplication theorem. diff --git a/research/deferred-k-q-placement-audit/SOURCES.json b/research/deferred-k-q-placement-audit/SOURCES.json new file mode 100644 index 0000000000..d97875f2e6 --- /dev/null +++ b/research/deferred-k-q-placement-audit/SOURCES.json @@ -0,0 +1,30 @@ +{ + "schema_version": 1, + "base_commit": "32890bc5de034ab8fc93ac88ead7279a6a416d04", + "files": [ + { + "path": "certificates/selected-result.json", + "usage": "provenance", + "git_blob": "fc3d4ba105e1f097d0d7d051a308281e86ab1446", + "sha256": "66974efdced4083c00025f97d95d83909a226cdf801edb9301c195c6641f6903" + }, + { + "path": "docs/research/agent-task-catalog.json", + "usage": "provenance", + "git_blob": "f126dd2e2dad2b669e75d1d0d0bd05c600725602", + "sha256": "f7a48bfa2659b88378282a8eee7d9fe52cdf505594124c4d1686b58510fffd72" + }, + { + "path": "research/deferred-k-query-sharing-component/PROOF.md", + "usage": "input", + "git_blob": "9ec973a52ad67eb6fe31709961c005630c3d2190", + "sha256": "4cff7aad4cd31479bcbce7eeb23015fa6ae60bc78640756ad3dc5f39544b108d" + }, + { + "path": "research/deferred-k-query-sharing-component/verification/inputs/outputs/kappa0033-race-20261024/plan/BALANCED-J-CURRENT-Q-FRAME-audit/REPORT-v1.md", + "usage": "input", + "git_blob": "b2cc05dcf9f4136803ee49bfa63555509b69c5b2", + "sha256": "fb60187fea8346539abb61a08b1c525825cc84bd7c2847eb44a7c9590f3abee3" + } + ] +} diff --git a/research/deferred-k-q-placement-audit/TASK.json b/research/deferred-k-q-placement-audit/TASK.json new file mode 100644 index 0000000000..d3b81563b3 --- /dev/null +++ b/research/deferred-k-q-placement-audit/TASK.json @@ -0,0 +1,106 @@ +{ + "schema_version": 1, + "task_id": "independent-moment", + "priority_revision": 7, + "base_commit": "32890bc5de034ab8fc93ac88ead7279a6a416d04", + "original_card": { + "id": "independent-moment", + "question": "Does a new paid-profile or mixture-ceiling claim have independent source-bound coverage of its actual changed ledger?", + "starting_points": [ + "docs/research/research-family-status.md", + "certificates/selected-result.json", + "research/staged544-mixed-fourth-entry/README.md", + "research/staged-fourth-mixture-ceiling/README.md", + "research/r437-two-window-carrier/README.md" + ], + "methods": [ + "Independently reconstruct one changed paid ledger or pooled dual with exact source and model binding.", + "Check a genuinely uncovered moment implication with a different enclosure method and semantic controls." + ], + "acceptance_gate": "Demonstrate independence, source binding, positive cases and semantic failure controls. Name the existing checks and the missing coverage. More digits or another equivalent evaluation of an unchanged root is not by itself new verification coverage.", + "first_step": { + "command": [ + "python3", + "-B", + "scripts/research_baseline.py" + ], + "expected": "PASS_RESEARCH_BASELINE_BINDINGS_ONLY", + "inspect": "Choose one uncovered implication in #4088 literal mixed fill, #4091 pooled dual/model binding or #4067 changed frame/host bill. #4091 pins an earlier #4088 head: validate word, capacity and stock equivalence before applying that ceiling to the later fill.", + "scope": "Source-binding orientation only; no scientific replay, theorem acceptance or supplier admission. Budget any heavy replay separately." + }, + "first_experiment": "Independently reconstruct one changed ledger or pooled certificate with a positive case and a semantic failure control. Compare exact sources and name what existing checks miss. Keep this separate from supplier-boundary-audit (ordinary/outer dispatch) and uniform-transfer-audit (all-size proof). Stop after the chosen implication; more digits of an unchanged root are not additional mechanism coverage.", + "bottleneck_link": "Independent pricing prevents unsupported frontier claims and can reveal genuine accounting slack.", + "allowed_variations": [ + "Reconstruct either a source ledger or a numeric enclosure with a different method." + ], + "scope_change_triggers": [ + "Importing the primary function and calling its output independent verification.", + "Calling an aggregate histogram or source archive an independently accepted physical supplier." + ], + "overlap_terms": [ + "independent moment", + "rank histogram", + "exact enclosure", + "2979", + "rank7 joint endframes", + "paired extraction", + "joint lowering", + "4088", + "4091", + "4067", + "staged544-mixed-fourth-entry", + "staged-fourth-mixture-ceiling", + "r437-two-window-carrier" + ], + "existing_checks": [ + { + "scope": "PR #4088: mixed local/owner/phase ledger and moment reported.", + "evidence": "research/staged544-mixed-fourth-entry/README.md", + "remaining": "Independent binding of changed construction to paid histogram, distinct from full admission.", + "status": "author-checked", + "source_commit": "72d7efc181edb21806a878f174847c96dd410ab0", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + }, + { + "scope": "PR #4091: sharp pooled ceiling proposed for fixed THREE/FOUR words and inventory.", + "evidence": "research/staged-fourth-mixture-ceiling/README.md", + "remaining": "Validate dual, exhaustive pattern scope and exact source equivalence before applying to newer fills.", + "status": "author-checked", + "source_commit": "a29bdd8f56cd18b805917775cdec09ff935eddc4", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + }, + { + "scope": "PR #4067: paid (2,2) to (1,3) exchange and fixed OQ4 host reported.", + "evidence": "research/r437-two-window-carrier/README.md", + "remaining": "Independent full cost delta; remaining caller/precision/stock obligations are separate.", + "status": "author-checked", + "source_commit": "a95f11c52e3ca1e4c5171b3c20d8f4b0815aee2e", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + } + ] + }, + "scope_status": "changed", + "actual_scope": "Independently recompute the mode-0 Km0 counterexample to K-conjugated current-source Q in the merged deferred-K component, including the 512-state identity K^{-1} X_1 K = -X_7 and the placement R = D Q. No global occurrence ledger and no new kappa.", + "scope_change_reason": "Handoff discussioncomment-19160035 asks first for an independent inspection of the literal correction and source-phase Q placement. The component checker records that Km0 witness as inherited and not recomputed. This package closes that operator check only. It does not reconstruct a mixture ceiling or bind the missing global caller ledger.", + "bottleneck_link": "A K-wrapped query implements a different map from the bare current-source Q that the eight-H1 overlay uses. Billing that wrapped route in a later global invoice would charge an operator the component does not execute. The local saving still does not fund kappa until a version-correct occurrence ledger exists.", + "budget_minutes": 60, + "stop_rule": "Stop after the pinned mode-0 word, the all-basis conjugation, and the R = D Q placement. Do not emit a global caller ledger or rerun native, phase, or pricing engines.", + "outcome": "completed", + "evidence": "research/deferred-k-q-placement-audit/verify.py prints PASS_DEFERRED_K_Q_PLACEMENT. Positive case is the pinned literal word on all 512 computational basis states. The failure control clears one linear phase and no longer yields -|7>.", + "author": "unpaidmoon", + "ai_assistance": "Prepared by unpaidmoon with substantial Cursor Grok assistance.", + "open_questions": [ + { + "question": "Can one version-correct global occurrence ledger fund a gain from the eight-H1 deferred-K overlay?", + "why_it_matters": "The local profile still loses for every 0." + }, + { + "argv": [ + "{python}", + "-I", + "-O", + "-Werror", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 180, + "checks": "Same operator identities under optimized bytecode. No native, phase-table, emitter, or economic replay." + } + ] +} diff --git a/research/deferred-k-q-placement-audit/verify.py b/research/deferred-k-q-placement-audit/verify.py new file mode 100644 index 0000000000..435bb114cb --- /dev/null +++ b/research/deferred-k-q-placement-audit/verify.py @@ -0,0 +1,254 @@ +#!/usr/bin/env python3 +"""Independent replay of the mode-0 K-conjugated Q counterexample. + +The deferred-K checker records this witness as inherited and not recomputed. +This program reads the pinned literal word and evaluates the operators itself. +""" +from fractions import Fraction +import pathlib +import re + +ROOT = pathlib.Path(__file__).resolve().parents[2] +PACKAGE = ROOT / "research/deferred-k-query-sharing-component" +REPORT = PACKAGE / ( + "verification/inputs/outputs/kappa0033-race-20261024/plan/" + "BALANCED-J-CURRENT-Q-FRAME-audit/REPORT-v1.md" +) +PROOF = PACKAGE / "PROOF.md" +N = 9 +DIM = 1 << N +EMBED = (0, 9, 10, 11, 12, 13, 14, 15, 16) +WORD = ( + "D(quadratic=0, linear=[2,2,2,2,0,0,0,0,0])\n" + "P(rows=[7,13,11,14,16,32,64,128,256])\n" + "X(0)\n" + "phase(0)." +) + + +def parity(value): + return value.bit_count() & 1 + + +def mv(rows, state): + return sum(parity(row & state) << index for index, row in enumerate(rows)) + + +def mul_i(real, imag, power): + power %= 4 + if power == 0: + return real, imag + if power == 1: + return -imag, real + if power == 2: + return -real, -imag + return imag, -real + + +def zero(): + return [(Fraction(0), Fraction(0)) for _ in range(DIM)] + + +def basis(index): + state = zero() + state[index] = (Fraction(1), Fraction(0)) + return state + + +def apply_d(state, alpha): + out = [] + for label, amplitude in enumerate(state): + power = sum(alpha[bit] for bit in range(N) if label >> bit & 1) % 4 + out.append(mul_i(amplitude[0], amplitude[1], power)) + return out + + +def apply_p(state, rows): + out = zero() + for label, amplitude in enumerate(state): + out[mv(rows, label)] = amplitude + return out + + +def apply_p_inverse(state, rows): + out = zero() + for label, amplitude in enumerate(state): + out[label] = state[mv(rows, label)] + return out + + +def apply_x(state, shift): + return [state[label ^ shift] for label in range(DIM)] + + +def apply_c(state, axis_mask, sign=1): + out = [None] * DIM + for label, (real, imag) in enumerate(state): + other_real, other_imag = state[label ^ axis_mask] + out[label] = ( + (real - sign * imag + other_real + sign * other_imag) / 2, + (imag + sign * real + other_imag - sign * other_real) / 2, + ) + return out + + +def apply_phase(state, power): + return [mul_i(real, imag, power) for real, imag in state] + + +def fourier(axes, sign=1): + def run(state): + for axis in axes: + state = apply_c(state, 1 << axis, sign) + return state + return run + + +def fourier_inverse(axes): + # Adjoint reverses axis order and flips each C sign, matching clifford_exact. + def run(state): + for axis in reversed(axes): + state = apply_c(state, 1 << axis, -1) + return state + return run + + +def parse_word(text): + match = re.search( + r"D\(quadratic=(\d+), linear=\[([0-9,\s]+)\]\)\s*" + r"P\(rows=\[([0-9,\s]+)\]\)\s*" + r"X\((\d+)\)\s*" + r"phase\((\d+)\)\.", + text, + ) + if match is None: + raise SystemExit("literal mode-0 K word not found in the pinned report") + quadratic = int(match.group(1)) + linear = [int(item) for item in match.group(2).split(",")] + rows = [int(item) for item in match.group(3).split(",")] + shift = int(match.group(4)) + phase = int(match.group(5)) + if (quadratic, linear, rows, shift, phase) != ( + 0, [2, 2, 2, 2, 0, 0, 0, 0, 0], + [7, 13, 11, 14, 16, 32, 64, 128, 256], 0, 0, + ): + raise SystemExit("pinned report word differs from the stated mode-0 word") + if match.group(0) != WORD: + raise SystemExit("pinned report word text differs from the expected block") + return linear, rows, shift, phase + + +def apply_k(state, linear, rows, shift, phase): + state = apply_d(state, linear) + state = apply_p(state, rows) + state = apply_x(state, shift) + return apply_phase(state, phase) + + +def apply_k_inverse(state, linear, rows, shift, phase): + state = apply_phase(state, (-phase) % 4) + state = apply_x(state, shift) + state = apply_p_inverse(state, rows) + adjoint_linear = [(-entry) % 4 for entry in linear] + return apply_d(state, adjoint_linear) + + +def support(state): + return [(index, real, imag) for index, (real, imag) in enumerate(state) + if real != 0 or imag != 0] + + +def equal(left, right): + return all(a == b for a, b in zip(left, right)) + + +def require(condition, message): + if not condition: + raise SystemExit("FAIL: " + message) + + +def main(): + text = REPORT.read_text(encoding="utf-8") + proof = PROOF.read_text(encoding="utf-8") + linear, rows, shift, phase = parse_word(text) + require("K^-1 X1 K = -X7" in text, "report no longer states the conjugation identity") + require("a|0> - b|7>" in text, "report no longer states the routed output") + require("Km0 supplies a width-one counterexample" in proof, + "PROOF.md no longer names the Km0 counterexample") + require("bare positive C1" in proof, "PROOF.md no longer states bare positive C1") + + # G maps basis vector e_i to rows[i] when rows are the linear forms of output bits. + # The stated action G(1)=7 is the image of mask 1. + require(mv(rows, 1) == 7, "G(1) is not 7") + require(mv(rows, 7) == 1, "G(7) is not 1") + for mask in range(16): + require(mv(rows, mv(rows, mask)) == mask, "G is not an involution on the low nibble") + for bit in range(4, N): + require(mv(rows, 1 << bit) == (1 << bit), "a high basis vector moved") + + k_zero = apply_k(basis(0), linear, rows, shift, phase) + require(support(k_zero) == [(0, Fraction(1), Fraction(0))], "K|0> is not |0>") + + k_inv_one = apply_k_inverse(basis(1), linear, rows, shift, phase) + require(support(k_inv_one) == [(7, Fraction(-1), Fraction(0))], "K^-1|1> is not -|7>") + + # K^-1 X_1 K = -X_7 on every computational basis vector. + for label in range(DIM): + routed = apply_k_inverse( + apply_x(apply_k(basis(label), linear, rows, shift, phase), 1), + linear, rows, shift, phase, + ) + target = apply_phase(apply_x(basis(label), 7), 2) + require(equal(routed, target), "conjugation failed at basis " + str(label)) + + bare = apply_c(basis(0), 1, 1) + require(support(bare) == [ + (0, Fraction(1, 2), Fraction(1, 2)), + (1, Fraction(1, 2), Fraction(-1, 2)), + ], "bare Q|0> is not a|0>+b|1>") + wrapped = apply_k_inverse( + apply_c(apply_k(basis(0), linear, rows, shift, phase), 1, 1), + linear, rows, shift, phase, + ) + require(support(wrapped) == [ + (0, Fraction(1, 2), Fraction(1, 2)), + (7, Fraction(-1, 2), Fraction(1, 2)), + ], "routed Q|0> is not a|0>-b|7>") + require(not equal(bare, wrapped), "bare and routed outputs unexpectedly agree") + + # Source placement: R is C on axes 0..8, low axis first; D is axes 1..8. + # Rightmost-first composition R = D Q means Q first, then D. + for label in range(DIM): + left = fourier(range(1, N))(apply_c(basis(label), 1, 1)) + right = fourier(range(N))(basis(label)) + require(equal(left, right), "R != D Q at basis " + str(label)) + kr = apply_k(right, linear, rows, shift, phase) + rk = fourier(range(N))(apply_k(basis(label), linear, rows, shift, phase)) + require(equal(kr, rk), "K does not commute with R at basis " + str(label)) + kq = apply_k(apply_c(basis(label), 1, 1), linear, rows, shift, phase) + qk = apply_c(apply_k(basis(label), linear, rows, shift, phase), 1, 1) + require(not equal(kq, qk), "K unexpectedly commutes with Q at basis " + str(label)) + + local7 = 7 + global7 = sum(1 << EMBED[bit] for bit in range(N) if local7 >> bit & 1) + require(global7 == 1537, "local 7 does not lift to global mask 1537") + require(sum(1 << EMBED[bit] for bit in range(N) if 1 >> bit & 1) == 1, + "local 1 does not stay global mask 1") + + # Failure control: clearing one linear phase removes the minus on |7>. + mutated = list(linear) + mutated[0] = 0 + mutated_image = apply_k_inverse(basis(1), mutated, rows, shift, phase) + require(support(mutated_image) != [(7, Fraction(-1), Fraction(0))], + "phase mutation still produced -|7>") + + print("PASS_DEFERRED_K_Q_PLACEMENT") + print("bare_Q_zero=a|0>+b|1>") + print("routed_Q_zero=a|0>-b|7>") + print("conjugation=K^-1 X1 K=-X7 on all 512 basis states") + print("placement=R=D Q on all 512 basis states; K commutes with R and not with Q") + print("lift_local7=1537") + + +if __name__ == "__main__": + main()