diff --git a/research/qq16-f0-dirty-ray-magnitude/README.md b/research/qq16-f0-dirty-ray-magnitude/README.md new file mode 100644 index 0000000000..cc4743dd9d --- /dev/null +++ b/research/qq16-f0-dirty-ray-magnitude/README.md @@ -0,0 +1,94 @@ +# Intermediate magnitudes on one F0 dirty-helper ray + +**Scoped scalar ledger. No new exponent.** + +On the common-chart scalar projection of the literal reviewed `programs.F_0` +word, the initial state `L359 = T` (every data and private register zero) +reaches intermediate coefficient **128T in data register L103** and **68T in +helper L609**. The same word then restores that input exactly. The published +cut used by the restoration-preserving fault is only **4T**. Selected κ stays +`0.001672660197076918`. + +This is the intermediate ledger asked for by one ray. It is not a bound for +every dirty helper, not a Hilbert-norm certificate, and not an F17 consumer bill. + +## Statement + +Expand `programs.F_0` exactly as the scalar fault audit does: 26,099 events, +of which 21,025 are scalar. Non-scalar events do not change this projection. +Coefficients below are for `T = 1`; the word is linear and homogeneous, so the +`T` ray is the same scan multiplied by `T`. + +| Class | Peak absolute coefficient | First attained | Gate, frame annotation | +| --- | ---: | --- | --- | +| Data `L0..L223` | 128 | after event 24280, `L103 = -128` | `L103 += 64 L354`, annotation `1` | +| Helpers `L224..L703` | 68 | after event 24338, `L609 = 68` | `L609 += -34 L354`, annotation `1` | +| Private `C0..C7` | 0 | — | never written on this ray | + +Immediately before the data-peak add, `L103 = -64` and `L354 = -1`. A relative +destination defect `u(|d| + |c| |s|)` at that add therefore has allowance +**128 u T**. The coefficient `-128` then sits only in `L103` across the next +154 scalar states. At the published fault index 24438 the pre-state is still +`L39 = -4`, `L359 = 1`, and the final state is exactly the input. + +The data ray `L112 = 1` is the control. Its largest absolute coefficient is 1, +every helper and private register stays 0, and it also restores exactly. At +event 24438 that ray contributes nothing to `L39` or `L359`. + +A unit injection into `L103` after event 24280 does **not** preserve helper +restoration. Its final image has 78 nonzero data fields, maximum `1/16`, and +71 nonzero helpers, maximum `17/32`. The published fault at event 24438 is a +different site: there the helpers restore and the completed data factor is +`4 u T`. The intermediate peak does not replace that necessary reserve. + +## What this does not say + +`||F|| <= 58` in the #2965 completed-output contract is a bound on the finished +data map. An intermediate register coefficient 128 does not contradict it. +Frame annotation `1` is the word's label at the two peak adds. This package +does not load native frame vectors, so it does not promote 128T or 68T to +payload Hilbert norms. Exact execution of this ray has completed data error 0; +the peak is not an exhibited rounding failure. + +Open [PR #3552](https://github.com/CrocSwap/integer-mult-bounds/pull/3552) +compares four stored final magnitudes with the #2965 tolerance and does not +replay intermediate states. The scalar-projection digest here equals that +package's published `scalar_projection_sha256`. + +## Reproduce + +From the repository root, CPython 3.12: + +```sh +python3.12 -B research/qq16-f0-dirty-ray-magnitude/verify.py +python3.12 -B research/qq16-f0-dirty-ray-magnitude/test_verify.py +python3.12 -B scripts/research_package.py --package research/qq16-f0-dirty-ray-magnitude +``` + +`verify.py` is read-only. Dense lists and sparse dictionaries are separate +forward scans; both must report the same peaks, cut and final state. The tests +use a three-operation synthetic word and change the peak coefficient from 64 +to 63. The full literal scan takes well under a minute. + +## Open next questions + +1. Do the frame annotations `1` at events 24280 and 24338 denote the constant + payload vector, so the Hilbert norms are exactly 128T and 68T? The native + dirty-fault package already checks frame 1's canonical vector on its own + witness; this ledger does not. +2. Is register 359 special, or does another helper force an intermediate data + coefficient at least this large? A uniform dirty range has to cover the + worst ray. Only this ray was scanned. + +## Credit + +The literal F0 word and scalar projection are the reviewed joint-query +program. Arham Tahir's `qq16-producer-dirty-fault` package supplies the +expansion, the cut `(-4, 1)`, and the final-defect formula this ledger does +not replace. Nick Petalas's #2965 contract supplies the completed-output norm +`||F|| <= 58` and the open producer-interior question. Ali Romman and the +joint-query lineage retain the program. Tekalign's native binding is the +frame-vector predecessor named above and is not replayed here. + +Prepared by unpaidmoon, with substantial assistance from Grok 4.7 in Cursor. +Apache-2.0. No independent human review is claimed. diff --git a/research/qq16-f0-dirty-ray-magnitude/SOURCES.json b/research/qq16-f0-dirty-ray-magnitude/SOURCES.json new file mode 100644 index 0000000000..2878bab22a --- /dev/null +++ b/research/qq16-f0-dirty-ray-magnitude/SOURCES.json @@ -0,0 +1,36 @@ +{ + "schema_version": 1, + "base_commit": "bb4bccbf42844d2801487450727c2f63e10d1d0f", + "files": [ + { + "path": "certificates/selected-result.json", + "usage": "provenance", + "git_blob": "b1fea0c94436b236cc2b7d41a7be032811b94c81", + "sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + }, + { + "path": "docs/research/agent-task-catalog.json", + "usage": "provenance", + "git_blob": "67f085acd86acd7d4e03922d9cf4b26bca66fed5", + "sha256": "47b42433f5a85809a3aadd29c2c339da2c6ed728e4f7762df6b88bccb7874cf0" + }, + { + "path": "research/joint-query/certificate.json.gz", + "usage": "input", + "git_blob": "c6e876d8b48d768214deee265ade428f8983b566", + "sha256": "a5ed85fac5ebf3c091482a113ab0d351eb5a7892fe2841a35e16017ec1ff49f7" + }, + { + "path": "research/qq16-producer-defect-transfer/README.md", + "usage": "input", + "git_blob": "16903a0090c020d033d24712cce11c633031e688", + "sha256": "30cf4389425f7704b1ed45af6cf4b5165e7b5c04af5077640ac96399c61cd703" + }, + { + "path": "research/qq16-producer-dirty-fault/RESULT.json", + "usage": "input", + "git_blob": "fbead079e26a5e29f2d7926311f392d6a64d5c2b", + "sha256": "e48a14b6b8505cbd4721e379b26f80ace7d96f360a409cc6b18a9701153f3282" + } + ] +} diff --git a/research/qq16-f0-dirty-ray-magnitude/TASK.json b/research/qq16-f0-dirty-ray-magnitude/TASK.json new file mode 100644 index 0000000000..7f2fcb7e39 --- /dev/null +++ b/research/qq16-f0-dirty-ray-magnitude/TASK.json @@ -0,0 +1,86 @@ +{ + "schema_version": 1, + "task_id": "joint-query-controller", + "priority_revision": 6, + "base_commit": "bb4bccbf42844d2801487450727c2f63e10d1d0f", + "original_card": { + "id": "joint-query-controller", + "question": "Can a literal QQ16 producer meet the proposed completed-output error budgets with dirty helpers and an affordable physical consumer?", + "starting_points": [ + "docs/research/research-family-status.md", + "research/joint-query/README.md", + "research/joint-query/evidence/QQ16-SELECTED-WITNESS.md", + "research/joint-query/evidence/JOINT-QUERY-TRANSFER.md", + "docs/research/community-efficient1000-review.md", + "research/qq16-producer-defect-transfer/README.md" + ], + "methods": [ + "Derive one literal producer's completed-output defects and intermediate dirty-helper bounds, with its physical bill.", + "Design or audit one consumer, retention or hosting boundary and its complete cost for the pinned producer/decoder." + ], + "acceptance_gate": "Name the changed premise of the fixed F0/B1 observation obstruction. Show exactly which query is recovered, legal native reads and restoration, and a full favorable budget including cover maps, helpers and endpoints. Local inverse identities alone do not close the global controller. 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", + "scripts/research_baseline.py" + ], + "expected": "PASS_RESEARCH_BASELINE_BINDINGS_ONLY", + "inspect": "Read the revision-6 family record and #2965 producer-defect transfer after the local QQ16 decoder contract. Its author-checked output-error estimate does not implement producer interiors, bound dirty helpers, or pay for the consumer; independently check the implication used.", + "scope": "Source-bound orientation only. Read the named package and review before relying on its local evidence; this command is not its replay or supplier admission." + }, + "first_experiment": "Pin one literal F0/B1 producer and its native-child contracts; derive the actual intermediate magnitude ledger and completed-output defects, including dirty helpers and correlations. Compare with #2965 budgets and price storage, movement, cleanup and F17 consumption. Stop with a precise missing bound if no producer contract supplies it; do not optimize another decoder precision constant in isolation.", + "bottleneck_link": "The native local words exist; retained query information and its physical access are the missing link to a composed recursive interface.", + "allowed_variations": [ + "One paid query, one changed first pair, or one precisely specified affine helper state.", + "A counterexample or lower bound for that exact proposed repair.", + "One unresolved obligation of a newer local decoder, with exact source heads and a distinct claim/domain." + ], + "scope_change_triggers": [ + "Retaining the fixed first pair and ordinary schedule while allowing only homogeneous selected-only control, already excluded by the witness.", + "Treating cover-map counts as zero-cost physical address operations.", + "Recreating the pending complete local decoder or early-record/output-bank coalescing already under investigation without a distinct audit or changed premise.", + "Treating a completed-output defect inequality as a producer-interior, dirty-range or physical-cost certificate." + ], + "overlap_terms": [ + "QQ16", + "joint-query", + "changing-chart controller", + "selected observation", + "1969", + "2540", + "early record", + "output-bank retention", + "complete native decoder", + "2965", + "producer defect", + "dirty-helper range", + "F17 consumer" + ] + }, + "scope_status": "refined", + "actual_scope": "On the common-chart scalar projection of the literal reviewed F0 word, ledger the intermediate coefficient magnitudes of the single dirty-helper ray L359=T with all data and private inputs zero, and of the data ray L112=1.", + "scope_change_reason": "The card asks for one literal producer's intermediate magnitude ledger, including dirty helpers. Open PR #3552 already compares the four stored final L359 magnitudes with the #2965 F0 tolerance and does not replay the word. This package replays the scalar projection far enough to name the intermediate peaks. It does not build the F0/B1 physical producer, a dirty-input range for every helper, or an F17 consumer bill.", + "bottleneck_link": "PR #2965 prices completed outputs and leaves producer interiors and dirty-helper ranges open. On this ray the exact scalar word restores its input, but a data register reaches coefficient 128T and a helper reaches 68T first. The completed-output statement ||F||<=58 does not bound those intermediate registers, so a relative-defect budget that looks only at the published cut coefficient 4T understates the local allowance at the data-peak add.", + "budget_minutes": 60, + "stop_rule": "Stop after these two rays and the unit injection at the data-peak add. Do not search other helpers, replay native 512-vectors, or price F17 consumption.", + "outcome": "completed", + "evidence": "Dense and sparse forward scans agree. Dirty ray peaks are data 128 at L103 after event 24280, helper 68 at L609 after event 24338, and private 0. The data peak is the ADD L103 += 64*L354 from (-64,-1) in frame annotation 1; its relative allowance is 128 u T. That coefficient 128 then occupies only L103 for 154 following scalar states. The published cut at event 24438 is still (-4,1), and the final state is exactly the input. The data ray peaks at 1 and leaves every helper and private register zero. A unit injection after event 24280 ends in 78 data fields, maximum 1/16, and 71 nonzero helpers, maximum 17/32, so this site is not the restoration-preserving fault at event 24438. Selected kappa is unchanged.", + "author": "unpaidmoon", + "ai_assistance": "Substantial assistance from Grok 4.7 in Cursor for the ledger, checker and writeup.", + "open_questions": [ + { + "question": "Do frame annotations 1 at events 24280 and 24338 denote the constant payload vector, so the Hilbert norms are exactly 128T and 68T?", + "why_it_matters": "The scalar coefficients are proved here. A physical norm needs the native frame vector at those events; frame label 1 is the annotation, not this package's vector identity.", + "first_step": "Bind these two scalar events to the frame-1 canonical vector already checked by research/qq16-native-dirty-fault, without replaying the whole native word.", + "blocked_by": "This package does not load native recipes or frame vectors." + }, + { + "question": "Does every one of the 480 helpers force an intermediate data coefficient at least this large, or is L359 special?", + "why_it_matters": "A uniform dirty-helper range has to cover the worst ray. One ray shows that 4T, the published cut coefficient, is not an intermediate bound.", + "first_step": "Repeat the sparse scan for one other helper index and compare its data peak with 128.", + "blocked_by": "Only register 359 was scanned." + } + ], + "no_new_kappa": true +} diff --git a/research/qq16-f0-dirty-ray-magnitude/VERIFY.json b/research/qq16-f0-dirty-ray-magnitude/VERIFY.json new file mode 100644 index 0000000000..55f7992c9a --- /dev/null +++ b/research/qq16-f0-dirty-ray-magnitude/VERIFY.json @@ -0,0 +1,23 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [ + "research/joint-query/certificate.json.gz", + "research/qq16-producer-defect-transfer/README.md", + "research/qq16-producer-dirty-fault/RESULT.json" + ], + "commands": [ + { + "argv": ["{python}", "-B", "{package}/verify.py"], + "timeout_seconds": 120, + "checks": "Dense and sparse forward scans of the F0 scalar projection: dirty-ray peaks 128 and 68, data-ray peak 1, exact restoration, and the non-restoring unit injection at event 24280." + }, + { + "argv": ["{python}", "-B", "{package}/test_verify.py"], + "timeout_seconds": 180, + "checks": "Synthetic peak, coefficient-63 mutation of event 24280, and the published ledger constants." + } + ] +} diff --git a/research/qq16-f0-dirty-ray-magnitude/test_verify.py b/research/qq16-f0-dirty-ray-magnitude/test_verify.py new file mode 100644 index 0000000000..ebd1393167 --- /dev/null +++ b/research/qq16-f0-dirty-ray-magnitude/test_verify.py @@ -0,0 +1,52 @@ +#!/usr/bin/env python3 +"""Failure controls for the F0 dirty-ray magnitude ledger.""" +import importlib.util +from fractions import Fraction as Q +from pathlib import Path + +HERE = Path(__file__).resolve().parent +spec = importlib.util.spec_from_file_location("dirty_ray", HERE / "verify.py") +verify = importlib.util.module_from_spec(spec) +spec.loader.exec_module(verify) + + +def synthetic(): + word = [["phase", 0] for _ in range(verify.WIDTH)] + word[0] = ["scalar", ["add", ["L", 1], ["L", 2], 3, 1], 4] + word[1] = ["scalar", ["add", ["L", 400], ["L", 2], -5, 2], 4] + # Keep the published fault index inside the word without using it. + while len(word) <= verify.FAULT: + word.append(["phase", 0]) + word[verify.FAULT] = ["scalar", ["add", ["L", 39], ["L", 359], 4, 1], 1] + return word + + +def main(): + word = synthetic() + summary = verify.project(word, 2, sparse=False) + other = verify.project(word, 2, sparse=True) + if summary["peaks"] != other["peaks"]: + raise SystemExit("synthetic representations disagree") + if summary["peaks"]["data"] != 3 or summary["peaks"]["helper"] != Q(5, 2): + raise SystemExit("synthetic peak moved") + if summary["peaks"]["data"] == 128: + raise SystemExit("synthetic word reused the F0 constant") + packet, _receipt = verify.load(verify.ROOT) + literal = verify.expand(packet) + tampered = [event[:] for event in literal] + gate = tampered[24280][1][:] + gate[3] = 63 + tampered[24280] = ["scalar", gate, 1] + moved = verify.project(tampered, verify.DIRTY, sparse=True) + if moved["peaks"]["data"] == 128: + raise SystemExit("coefficient 63 still reported the published peak") + result = verify.audit(verify.ROOT) + if result["dirty_peaks"] != {"data": "128", "helper": "68", "private": "0"}: + raise SystemExit("published ledger moved") + if result["data_ray_peaks"]["data"] != "1": + raise SystemExit("data-ray control moved") + print("PASS_QQ16_F0_DIRTY_RAY_MAGNITUDE_TESTS groups=3") + + +if __name__ == "__main__": + main() diff --git a/research/qq16-f0-dirty-ray-magnitude/verify.py b/research/qq16-f0-dirty-ray-magnitude/verify.py new file mode 100644 index 0000000000..fb4197f899 --- /dev/null +++ b/research/qq16-f0-dirty-ray-magnitude/verify.py @@ -0,0 +1,316 @@ +#!/usr/bin/env python3 +"""Intermediate scalar magnitudes of one literal F0 dirty-helper ray. + +The reviewed F0 word is projected onto its common-chart scalar operations. +No predecessor executable is imported. This is not a physical Hilbert-norm +certificate and not a new exponent. +""" +import argparse +from collections import Counter +from fractions import Fraction as Q +import gzip +import hashlib +import json +from pathlib import Path + +HERE = Path(__file__).resolve().parent +ROOT = HERE.parents[1] +WIDTH = 712 +FAULT = 24438 +DIRTY = 359 +DATA = 112 +SCALAR_SHA = "4c17e407bca2520b85cdfb1cc90b301aa4aad36902b95d7e967d3082259630e2" + + +def need(condition, message): + if not condition: + raise ValueError(message) + + +def canonical(value): + return json.dumps(value, sort_keys=True, separators=(",", ":")).encode() + + +def reg(token): + need(isinstance(token, list) and len(token) == 2, "register token") + kind, index = token + need(type(index) is int and kind in ("L", "C"), "register kind") + need(0 <= index < (704 if kind == "L" else 8), "register range") + return index + (704 if kind == "C" else 0) + + +def classify(index): + if index < 224: + return "data" + if index < 704: + return "helper" + return "private" + + +def expand(packet): + need(packet["schema"] == "conserved-qq16-full-cover-native-words-v1", "schema") + word = [] + for event in packet["programs"]["F_0"]: + op = event[0] + if op == "retained_core": + need(event[1:3] == ["forward", 0], "F0 core") + word.extend(packet["core_words"]["forward"]) + elif op in ("cover_sweep", "private_sweep"): + word.extend(event[2]) + else: + word.append(event) + need(len(word) == 26099, "expanded event count") + need(Counter(event[0] for event in word) == { + "scalar": 21025, "climb": 3486, "adapter": 1090, + "residual_adapter": 480, "phase": 10, "native_line": 8, + }, "F0 event inventory") + need(word[FAULT] == ["scalar", ["add", ["L", 39], ["L", 359], 4, 1], 1], + "published fault event") + return word + + +def apply_dense(state, gate): + op, dst = gate[0], reg(gate[1]) + if op == "add": + src = reg(gate[2]) + need(src != dst and len(gate) == 5 and gate[3] != 0, "ADD operands") + state[dst] += Q(gate[3], gate[4]) * state[src] + elif op == "scale": + need(len(gate) == 4 and gate[2] != 0, "SCALE operands") + state[dst] *= Q(gate[2], gate[3]) + elif op == "clear": + need(dst >= 704 and len(gate) == 2, "owned CLEAR") + state[dst] = Q(0) + else: + raise ValueError("unknown scalar operation") + + +def apply_sparse(state, gate): + op, dst = gate[0], reg(gate[1]) + if op == "add": + src = reg(gate[2]) + need(src != dst and len(gate) == 5 and gate[3] != 0, "ADD operands") + value = state.get(dst, Q(0)) + Q(gate[3], gate[4]) * state.get(src, Q(0)) + if value: + state[dst] = value + else: + state.pop(dst, None) + elif op == "scale": + need(len(gate) == 4 and gate[2] != 0, "SCALE operands") + value = Q(gate[2], gate[3]) * state.get(dst, Q(0)) + if value: + state[dst] = value + else: + state.pop(dst, None) + elif op == "clear": + need(dst >= 704 and len(gate) == 2, "owned CLEAR") + state.pop(dst, None) + else: + raise ValueError("unknown scalar operation") + + +def blank(seed, sparse): + if sparse: + return {seed: Q(1)} + state = [Q(0)] * WIDTH + state[seed] = Q(1) + return state + + +def items(state, sparse): + if sparse: + return state.items() + return ((index, value) for index, value in enumerate(state) if value) + + +def project(word, seed, sparse=False): + """Exact forward image of one initial basis register. + + Magnitudes are recorded before and after every scalar operation. Non-scalar + events do not change this projection's state. + """ + state = blank(seed, sparse) + peaks = {kind: Q(0) for kind in ("data", "helper", "private")} + first = {} + seen = set() + data_peak_states = 0 + data_peak_registers = set() + cut = None + for index, event in enumerate(word): + if index == FAULT: + cut = (state[39] if not sparse else state.get(39, Q(0)), + state[359] if not sparse else state.get(359, Q(0))) + if event[0] != "scalar": + continue + need(len(event) == 3, "scalar frame annotation") + for register, value in items(state, sparse): + magnitude = abs(value) + seen.add(magnitude) + kind = classify(register) + if magnitude > peaks[kind] or (magnitude == peaks[kind] and kind not in first): + if magnitude > peaks[kind]: + peaks[kind] = magnitude + first[kind] = { + "event": index, + "phase": "before", + "register": register, + "value": value, + "frame": event[2], + "gate": event[1], + } + before = dict(state) if sparse else list(state) + (apply_sparse if sparse else apply_dense)(state, event[1]) + hit_registers = [] + for register, value in items(state, sparse): + magnitude = abs(value) + seen.add(magnitude) + kind = classify(register) + if magnitude > peaks[kind]: + source = None + if event[1][0] == "add": + source_register = reg(event[1][2]) + source = before[source_register] if not sparse else before.get(source_register, Q(0)) + peaks[kind] = magnitude + first[kind] = { + "event": index, + "phase": "after", + "register": register, + "value": value, + "frame": event[2], + "gate": event[1], + "before": (before[register] if not sparse else before.get(register, Q(0))), + "source": source, + } + if kind == "data" and magnitude == 128: + hit_registers.append(register) + if hit_registers: + data_peak_states += 1 + data_peak_registers.update(hit_registers) + need(event[2] == 1, "data-peak frame annotation") + final = {index: value for index, value in items(state, sparse)} + return {"peaks": peaks, "first": first, "absolute_values": seen, + "data_peak_states": data_peak_states, + "data_peak_registers": data_peak_registers, + "cut": cut, "final": final} + + +def load(root): + manifest = json.loads((HERE / "SOURCES.json").read_text(encoding="utf-8")) + for item in manifest["files"]: + if item["usage"] == "input": + raw = (root / item["path"]).read_bytes() + need(hashlib.sha256(raw).hexdigest() == item["sha256"], "source pin " + item["path"]) + certificate = root / "research/joint-query/certificate.json.gz" + raw = certificate.read_bytes() + need(len(raw) < 1024 * 1024, "compressed certificate cap") + payload = gzip.decompress(raw) + need(len(payload) < 16 * 1024 * 1024, "certificate payload cap") + receipt = json.loads((root / "research/qq16-producer-dirty-fault/RESULT.json").read_text(encoding="utf-8")) + contract = (root / "research/qq16-producer-defect-transfer/README.md").read_text(encoding="utf-8") + need("||F|| <= 58" in contract, "pinned completed-output norm statement") + return json.loads(payload), receipt + + +def response(word, event_index, increment): + """Zero input, with one constant added to the scalar destination after event_index.""" + state = [Q(0)] * WIDTH + for index, event in enumerate(word): + if event[0] == "scalar": + apply_dense(state, event[1]) + if index == event_index: + state[reg(event[1][1])] += increment + return state + + +def audit(root): + packet, receipt = load(root) + word = expand(packet) + scalars = [event[1] for event in word if event[0] == "scalar"] + need(hashlib.sha256(canonical(scalars)).hexdigest() == SCALAR_SHA, "scalar projection digest") + need(receipt["scalar_projection_sha256"] == SCALAR_SHA, "published scalar projection") + need(receipt["prefix_dirty_target_coefficient"] == "-4", "published cut coefficient") + dense = project(word, DIRTY, sparse=False) + sparse = project(word, DIRTY, sparse=True) + need(dense["peaks"] == sparse["peaks"], "dense/sparse peak agreement") + need(dense["final"] == sparse["final"], "dense/sparse final agreement") + need(dense["cut"] == sparse["cut"] == (Q(-4), Q(1)), "dirty cut coefficients") + need(dense["absolute_values"] == sparse["absolute_values"], "dense/sparse magnitude set") + need(dense["peaks"] == {"data": Q(128), "helper": Q(68), "private": Q(0)}, "dirty peaks") + need(len(dense["absolute_values"]) == 37, "distinct dirty magnitudes") + need(max(dense["absolute_values"]) == 128, "no larger dirty coefficient") + data_hit = dense["first"]["data"] + need(data_hit["phase"] == "after" and data_hit["event"] == 24280, "first data peak event") + need(data_hit["register"] == 103 and data_hit["value"] == Q(-128), "data peak register") + need(data_hit["frame"] == 1 and data_hit["gate"] == ["add", ["L", 103], ["L", 354], 64, 1], + "data peak gate") + need(data_hit["before"] == Q(-64) and data_hit["source"] == Q(-1), "pre-peak operands") + helper_hit = dense["first"]["helper"] + need(helper_hit["phase"] == "after" and helper_hit["event"] == 24338, "first helper peak event") + need(helper_hit["register"] == 609 and helper_hit["value"] == Q(68), "helper peak register") + need(helper_hit["gate"] == ["add", ["L", 609], ["L", 354], -34, 1], "helper peak gate") + need(helper_hit["before"] == Q(34) and helper_hit["source"] == Q(-1), "helper peak operands") + need(helper_hit["frame"] == 1, "helper peak frame") + need(dense["data_peak_states"] == 154 and dense["data_peak_registers"] == {103}, + "data peak support") + need(dense["final"] == {DIRTY: Q(1)}, "exact dirty restoration") + # |destination| + |coefficient| |source| at the creating ADD. + need(abs(data_hit["before"]) + 64 * abs(data_hit["source"]) == 128, "local allowance units") + data_dense = project(word, DATA, sparse=False) + data_sparse = project(word, DATA, sparse=True) + need(data_dense["peaks"] == data_sparse["peaks"] == { + "data": Q(1), "helper": Q(0), "private": Q(0)}, "data-ray peaks") + need(data_dense["final"] == data_sparse["final"] == {DATA: Q(1)}, "exact data restoration") + need(data_dense["cut"] == (Q(0), Q(0)), "data ray misses the dirty cut") + # A unit injection at the data-peak ADD is not the published restoration-preserving fault. + injected = response(word, 24280, Q(1)) + data_terms = [(index, value) for index, value in enumerate(injected[:224]) if value] + helper_terms = [(index, value) for index, value in enumerate(injected[224:704]) if value] + need(len(data_terms) == 78 and max(abs(value) for _, value in data_terms) == Q(1, 16), + "peak-site data response") + need(len(helper_terms) == 71 and max(abs(value) for _, value in helper_terms) == Q(17, 32), + "peak-site helper response") + need(not any(injected[704:]), "peak-site private response") + return { + "schema_version": 1, + "status": "PASS_QQ16_F0_DIRTY_RAY_MAGNITUDE", + "scope": "common-chart scalar projection of literal F0; one dirty ray and one data ray", + "scalar_projection_sha256": SCALAR_SHA, + "dirty_input": DIRTY, + "data_input": DATA, + "dirty_peaks": {kind: str(value) for kind, value in dense["peaks"].items()}, + "dirty_distinct_absolute_coefficients": len(dense["absolute_values"]), + "data_peak_event": 24280, + "data_peak_register": 103, + "data_peak_value": "-128", + "data_peak_gate": ["add", ["L", 103], ["L", 354], 64, 1], + "data_peak_states": 154, + "helper_peak_event": 24338, + "helper_peak_register": 609, + "helper_peak_value": "68", + "fault_cut": ["-4", "1"], + "local_allowance_at_data_peak": "128*u*T", + "data_ray_peaks": {kind: str(value) for kind, value in data_dense["peaks"].items()}, + "restores_both_rays": True, + "peak_site_unit_injection": { + "event": 24280, + "data_support": 78, + "data_max": "1/16", + "helper_support": 71, + "helper_max": "17/32", + "private_support": 0, + }, + "completed_output_norm_statement": "||F|| <= 58 is a completed-output bound, not this intermediate ledger", + } + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("--root", type=Path, default=ROOT) + args = parser.parse_args() + result = audit(args.root.resolve()) + print(result["status"]) + print("dirty peaks data=128 helper=68 private=0; data ray peak=1; both rays restore") + + +if __name__ == "__main__": + main()