Skip to content

Implement staged544 rank-five residual with reversible dirty scratch - #4017

Open
Clear1nsight wants to merge 1 commit into
CrocSwap:mainfrom
Clear1nsight:research/staged544-reversible-lattice-macro-20261019
Open

Clear1nsight wants to merge 1 commit into
CrocSwap:mainfrom
Clear1nsight:research/staged544-reversible-lattice-macro-20261019

Conversation

@Clear1nsight

Copy link
Copy Markdown
Contributor

The actual helper 277 rank-five residual in both pinned PR3945 providers can be implemented on a finite Gaussian lattice using one arbitrary dirty workspace word instead of one clean word, with every borrowed bit restored. This contribution pairs reversible numerical lifting with finite-state circuit synthesis and explicitly prices the tradeoff. It closes a bounded implementation obligation left open by PR3994; it does not substitute a new provider or claim a new kappa.

The comparison is an explicitly constructed clean-accumulator baseline, not an undocumented predecessor implementation. Each C pair changes from 14 to 18 real-word arithmetic operations while removing the zero-initialization requirement for b+1 scratch bits. Both compute the same rounded map. Complete serialized L/R monomial routing is included. Per512-coordinate spectator lane:1280 pairs,23040 arithmetic operations,3792 real swaps,2304 negations, and one reusable dirty word. The construction emits literal X/CNOT/Toffoli circuits, with no additional workspace; the classical borrowed-bit decomposition is credited to Barenco et al., Lemma7.2. At b=32 the full macro costs 442109184 Toffolis, plus 5482752 X and1031936 CNOT, versus 380425984 Toffolis plus the separately reported gates for the clean comparison. This is a clean-space improvement at an explicit time cost, not a speedup.

For f spectator lanes the completed error is at most80sqrt(f) grid units under the explicit no-data-wrap condition. Scratch overflow is allowed and handled exactly. The bound maps to PR3994's aggregate logical-cut allowance with p>=beta+32+ceil(log2sqrt(f)); b=p+4 suffices for the stated signed range. No selected stock coefficient is inferred.

The package also finds the decisive substitution limit: on this actual source-bound macro, a dirty helper h=s=e0 gives Q(h+s)-Q(h)-Q(s) nonzero at 24 coordinates. Local exact inversion therefore does not preserve the provider's linear compensation proof after intervening arithmetic. Whole-word nonlinear recovery, actual recursive-child tariff/owner admission, tensor dimension, stock/tape and all-size obligations remain open. The paid rank-five child is not silently repriced as the scalar circuit above.

Validation: source/recipe authentication; both actual provider bindings; credited canonical-frame oracle on 512 basis columns;279552 modular half-sum cases;67584 pair states;17408 literal bit half-sum cases;2048 bit-pair states;10912 dirty-ladder states;2112 complete elementary-circuit states; actual full-macro forward/inverse/error checks; source corruption, parity, sign-extension, phase and missing-uncompute controls. Normal and optimized repository-registered replay pass. Read-only Git-free replay, committed-byte/history and official export results are recorded in the publication handoff. A separate agent independently compiled the elementary pair implementation; root performed a bounded proof/code review. No independent human or proof-kernel review is claimed.

Only research/staged544-reversible-lattice-macro/ is added. Canonical main 20ecf28 and priority revision 6 remain unchanged. Root shell fetch encountered DNS failure; the GitHub connector confirmed canonical main and the exact existing object was used. Overlap:702 complete open-PR bodies at 08:39:35UTC and718 at 09:04; Discussion coverage partial. No exhaustive novelty claim. PR3881's numerical residue lane was inspected and concerns a different producer/consumer.

Credit Dugongue, dataisfire, Jeremy Kothe, Sagar Thakrar, roger-sato, Arham Tahir, DreamingOfClouds, chafreaky, Cinna Davis, Barenco et al., and the complete retained native/owner/outer lineage. Exact predecessor notices are preserved. Chris R / Clear1nsight with substantial OpenAI Codex assistance across a coordinated agent team.

Open next question: bind one actual helper lifetime and caller allowance to this circuit and its nonlinear witness before optimizing or attempting full-provider adoption. No merges, selected-frontier changes or other packages are included.

Frozen publication checks: scientific commit 527c80c4e20d699abf6c089d825bb9be01288f94, one canonical-parent commit,26 files. Registered normal/optimized replay passed; final read-only Git-free replay of all26 exact package files passed in8.703s with unchanged bytes. Committed-byte/source-history checks and official committed-export integrity pass. Hosted CI pending at publication. Scope changed from selected-stock-envelope under the explicit staged544 assignment; no selected m73 stock claim. Source heads: PR3945 91f81d131252db704f945891da1ea54e29d46b8b, PR3987 fc536202fdaa924158789a5ef59ac079bbe21922, PR3994 eb2ac25838a3d39ac8fd6acfa62b8b613c847629.

@Clear1nsight

Copy link
Copy Markdown
Contributor Author

CLAIM — taking the concrete helper277 lifetime/recovery handoff from PR4017. Until 2026-10-19 11:46 UTC, I am examining one literal helper277 lifetime in PR3945 at 91f81d131252db704f945891da1ea54e29d46b8b, with PR4017's published rounded macro at 527c80c4e20d699abf6c089d825bb9be01288f94.

The question is whether a finite rounding-error cocycle or reversible recovery record can preserve the actual intervening additions and cleanup within an explicitly derived caller allowance. First reconstruct the chronological lifetime and required record/recovery cost; local invertibility and one abstract rank-five charge do not pay the scalar circuit by declaration. Pair reversible numerical analysis with finite-state/information accounting. Stop if the complete bill fails or the caller's allowance cannot be supplied; at most one bounded changed-contract pivot. This is a scoped implementation/proof question, not a selected-frontier or supplier-admission claim. Source snapshots, frozen notices and predecessor credit will be retained. Local evidence will be labelled until a focused artifact is published. Chris R / Clear1nsight, substantial OpenAI Codex assistance.

@Clear1nsight

Copy link
Copy Markdown
Contributor Author

Source-bound cost clarification to PR4017 at 527c80c4e20d699abf6c089d825bb9be01288f94: PROOF.md's sentence “The source's charged object is a rank-five recursive child” conflates the completed residual width with the actual chronological execution charges.

For helper277 in both PR3945 providers at 91f81d131252db704f945891da1ea54e29d46b8b, independently replaying the pinned BORROW-WORD frame trace gives five positive climbs, each rank ONE: immediately before A[2340] (0→1), A[2381] (1→2), A[2391] (2→3), A[2409] (3→4), and the terminal end event (4→5). Indices are zero-based. There are49 scalar touches in A/B and no warp on this helper. Its terminal residual is nevertheless exactly the rank-five map T_U = L C_[5] R, U=[388,74,40,26,1], from empty entrance. The rank-five residual/owner width must not be treated as a scalar-gate allowance or as one paid chronological call.

The finite macro permutation, source recipe, dirty scratch restoration, literal gate counts, completed numerical error bound and generic nonadditivity witness in PR4017 are unaffected. That witness does not by itself prove failure of this complete literal helper lifetime: helper277 is logically restored before cleanup, and the inverse cleanup uses separate private buffer981. The original work correctly withheld whole-provider replacement, recursive affordability and supplier admission; those remain withheld. Frozen evidence and the published head are preserved. The successor investigation binds that missing lifecycle and prices an exact odd-modulus alternative. Chris R / Clear1nsight, substantial OpenAI Codex assistance.

@Clear1nsight

Copy link
Copy Markdown
Contributor Author

FINDING / DONE — the helper 277 lifetime investigation is complete. In both pinned PR3945 providers, helper 277 has 49 scalar touches and five rank-one physical climbs; rank five is its completed residual/owner width. It is restored before inverse cleanup, which uses separate buffer 981 with 49 touching instructions. This explicitly corrects PR4017’s paid-rank-five shorthand; its finite macro theorems and counts remain valid, and its generic nonadditivity witness was not a complete-lifetime failure proof.

The new exact Mersenne-residue construction preserves source additivity and arbitrary dirty canonical-residue restoration, with explicit total Boolean behavior for unused codes and no additional workspace. Numerical endpoint recovery is exact on grid Delta/32 when M > 2048A. The finer grid is an explicit changed contract. At b=32, the five climbs plus 98 touches cost 29,766,862,848 Toffoli before the charged decoder and other provider work. This is not a speedup or recursive fit. Consumer acceptance, denominator growth, input encoding, full owner/stock/tape and a conversion from recursive charges to scalar-gate allowances remain open; no supplier admission, sigma or kappa claim.

Exact head: 95c8edf315397a7f113d3a165f94716359c60c93. Normal/optimized, final read-only Git-free, source-history/byte and official export checks passed. Frozen sources and full predecessor credit are retained. Claim released; hosted CI status is reported separately.

Published separately as PR4050. All29 public files /373594 bytes match the frozen verification package. Hosted run39244696775 is separately pending.

@rcfc-jreed

Copy link
Copy Markdown
Contributor

Independent scoped audit of the staged544 reversible dirty-scratch residual package at 527c80c4: no defect found in the finite seal / census / arithmetic-identity layer

Code-disjoint reimplementation; does not import package verify.py / lattice.py / circuit.py. Package bytes from head 527c80c4e20d699abf6c089d825bb9be01288f94 via GitHub contents API. CLAIM. Package pins base_commit to 20ecf289…. Live verify.py re-execution was not run here (VALIDATION records git-free/registered PASS).

What passes (17 of 17):

  1. Pins / honesty. VERIFY ready; RESULT PASS_FINITE_MACRO_NOT_PROVIDER_REPLACEMENT; MACRO residual rank-5 helper 277 on base+extra; VALIDATION unrun excludes whole-provider replacement / new κ search.
  2. Seals. All 9 FROZEN-SOURCES digests match; git blobs match where declared.
  3. Census / routing. 1280 pairs; dirty 23040 (=1280·18) vs clean 17920 (=1280·14); L+R swaps/negs + pairs = 3792/2304; case counts 279552/67584/17408/2048/24; rank5 error² num 2212864.
  4. Gate polys / bills. Dirty/clean polys match; elementary dirty bills at b=8/32/64 ≤ (6b+4)·poly; LEDGER totals agree; VALIDATION git-free stdout echoes status/cases.

Not covered: live verify re-execution; provider replacement; recursive tariff admission; new κ.

This is a finite replay of committed receipts, not a formal proof.

check_4017.py
#!/usr/bin/env python3
"""Independent finite controls for PR4017 (staged544 reversible dirty scratch).

Recomputes FROZEN seals, RESULT arithmetic identities, and honesty pins.
Does not import package verify.py / lattice.py / circuit.py.

Package head 527c80c4e20d699abf6c089d825bb9be01288f94 via GitHub API.
Package base_commit is 20ecf289… (not 12fa8c5c…).

James Reed (@rcfc-jreed), with substantial AI assistance (Claude, in Cursor).
Apache-2.0.
"""
from __future__ import annotations

import argparse, hashlib, json, sys
from pathlib import Path

HEAD = "527c80c4e20d699abf6c089d825bb9be01288f94"
BASE = "20ecf2891d80b5acf18d980b2164fb44ea7faa90"
results = []


def check(name, ok, detail=""):
    results.append((name, bool(ok), detail))
    print(("PASS " if ok else "FAIL ") + name + ((": " + str(detail)) if detail else ""), flush=True)
    return bool(ok)


def load(pkg, name):
    return json.loads((pkg / name).read_text(encoding="utf-8"))


def sha(path: Path):
    return hashlib.sha256(path.read_bytes()).hexdigest()


def blob(path: Path):
    data = path.read_bytes()
    return hashlib.sha1(b"blob " + str(len(data)).encode() + b"\0" + data).hexdigest()


def poly_eval(coeffs, b: int) -> int:
    return int(coeffs[0]) * b * b + int(coeffs[1]) * b + int(coeffs[2])


def run(pkg: Path):
    sources = load(pkg, "SOURCES.json")
    result = load(pkg, "RESULT.json")
    verify = load(pkg, "VERIFY.json")
    frozen = load(pkg, "FROZEN-SOURCES.json")
    ledger = load(pkg, "LEDGER.json")
    macro = load(pkg, "MACRO.json")
    validation = load(pkg, "VALIDATION.json")

    check("I1 SOURCES base_commit == 20ecf289…; VERIFY ready",
          sources["base_commit"] == BASE and verify["status"] == "ready")
    check("I2 RESULT PASS_FINITE_MACRO_NOT_PROVIDER_REPLACEMENT; not a new provider/κ",
          result["status"] == "PASS_FINITE_MACRO_NOT_PROVIDER_REPLACEMENT"
          and "provider" in result["status"].lower()
          and any("provider" in x.lower() or "kappa" in x.lower() or "tariff" in x.lower()
                  for x in validation.get("unrun", [])))
    check("I3 MACRO residual rank-5 helper 277 on base+extra; terminal [388,74,40,26,1]",
          macro["kind"] == "residual"
          and macro["recipe"]["rank"] == 5
          and macro["terminal"] == [388, 74, 40, 26, 1]
          and {c["provider"] for c in macro["coverage"]} == {"base", "extra"}
          and all(c["helper"] == 277 for c in macro["coverage"]))

    # FROZEN seals
    bad = []
    for row in frozen:
        p = pkg / row["path"]
        if not p.exists() or sha(p) != row["sha256"]:
            bad.append(row["path"]); continue
        src = row.get("source") or {}
        if "git_blob" in src and blob(p) != src["git_blob"]:
            bad.append(row["path"] + ":blob")
    check("S1 FROZEN-SOURCES (9) sha256 match package bytes; git_blob where declared",
          not bad and len(frozen) == 9, bad)

    # RESULT arithmetic
    pairs = result["pair_count_per_spectator"]
    rt = result["routing"]
    check("C1 pairs=1280; dirty adds=1280·18=23040; clean comparison=1280·14=17920",
          pairs == 1280
          and result["real_word_add_primitives_per_spectator"] == pairs * 18 == 23040
          and result["clean_comparison_word_add_primitives"] == pairs * 14 == 17920)
    check("C2 routing L+R real_swaps+pairs == total 3792; L+R negs+pairs == total 2304",
          rt["left"]["real_swaps"] + rt["right"]["real_swaps"] + pairs
          == result["total_real_swaps_per_spectator"] == 3792
          and rt["left"]["real_negations"] + rt["right"]["real_negations"] + pairs
          == result["total_real_negations_per_spectator"] == 2304)
    check("C3 phase_histogram both sides [128]*4; cycles L16/R8; complex swaps 496/504",
          rt["left"]["phase_histogram"] == rt["right"]["phase_histogram"] == [128, 128, 128, 128]
          and rt["left"]["cycles"] == 16 and rt["right"]["cycles"] == 8
          and rt["left"]["complex_swaps"] == 496 and rt["right"]["complex_swaps"] == 504)
    check("C4 census cases: half 279552 / pair 67584 / literal half 17408 / pair 2048 / rank5 24",
          result["half_exhaustive_cases"] == 279552
          and result["pair_exhaustive_cases"] == 67584
          and result["literal_bit_half_cases"] == 17408
          and result["literal_bit_pair_cases"] == 2048
          and result["rank5_full_cases"] == 24
          and result["nonlinear_nonzero_coordinates"] == 24
          and result["credited_exact_canonical_recipe_columns"] == 512)
    check("C5 rank5 max error² numerator/1024 == 2212864; dirty_ladder 10912; elementary pairs 2112",
          result["rank5_max_error_squared_numerator_over_1024"] == 2212864
          and result["dirty_ladder_full_states"] == 10912
          and result["elementary_full_pair_states"] == 2112)

    dpoly = result["dirty_gate_polynomial_coefficients"]
    cpoly = result["clean_gate_polynomial_coefficients"]
    check("P1 dirty/clean gate polys [10240,41584,10240] / [8960,35184,10240]",
          dpoly == [10240, 41584, 10240] and cpoly == [8960, 35184, 10240])
    bill = result["elementary_bill_per_spectator"]
    fanin_ok = True
    detail = {}
    for bs in ("8", "32", "64"):
        b = int(bs)
        bound = (6 * b + 4) * poly_eval(dpoly, b)  # f=1 spectator in bill
        detail[bs] = {"poly": poly_eval(dpoly, b), "fanin_bound": bound,
                      "bill_sum": sum(bill[bs]["dirty"].values())}
        # bill is exact elementary count; must be <= fanin upper bound string form
        if sum(bill[bs]["dirty"].values()) > bound:
            fanin_ok = False
    check("P2 elementary dirty bills at b=8/32/64 are ≤ (6b+4)·dirty_poly(b) (f=1)",
          fanin_ok and set(bill) == {"8", "32", "64"}, detail)
    check("P3 bounded_fanin_upper_bound string cites dirty poly coeffs",
          "10240b^2+41584b+10240" in result["bounded_fanin_upper_bound"]
          and "(6b+4)" in result["bounded_fanin_upper_bound"])

    # LEDGER consistency with RESULT
    proved = ledger["proved"]["arithmetic_primitives_per_lane"]
    check("L1 LEDGER arithmetic_primitives match RESULT spectator totals",
          proved["dirty_add_sub_conditional_decrement"] == 23040
          and proved["constructed_clean_add_sub"] == 17920
          and proved["real_swaps"] == 3792
          and proved["real_negations"] == 2304)
    check("L2 LEDGER / VALIDATION exclude whole-provider replacement and new κ search",
          ("No further implementation expansion" in ledger["family_gate_decision"]
           or "no further" in ledger["family_gate_decision"].lower())
          and any("provider replacement" in x.lower() for x in validation["unrun"]))

    # VALIDATION recorded replay echoes RESULT status/cases
    gf = validation["git_free_replay"]
    check("V1 VALIDATION git_free_replay both runs exit 0 with RESULT status and case counts",
          gf.get("Git_free") is True and gf.get("bytes_unchanged") is True
          and all(run["exit"] == 0 and "PASS_FINITE_MACRO_NOT_PROVIDER_REPLACEMENT" in run["stdout"]
                  and "279552" in run["stdout"] and "67584" in run["stdout"] and '"full_cases": 24' in run["stdout"]
                  for run in gf["runs"])
          and validation["registered_replay"]["status"] == "PASS")

    check("N1 scratch claim: dirty b+1 restored; error_bound 80√f; naive_roundtrip present",
          "b+1" in result["dirty_scratch_bits"] and "restored" in result["dirty_scratch_bits"]
          and result["error_bound"].startswith("80")
          and result["naive_roundtrip"] == [[0, -1], [-1, -1]])

    failed = [name for name, ok, _ in results if not ok]
    print(f"\n{len(results) - len(failed)}/{len(results)} PASS", flush=True)
    if failed:
        print("FAILED:", ", ".join(failed), flush=True)
        return 1
    return 0


def main():
    ap = argparse.ArgumentParser()
    ap.add_argument("--pkg", required=True)
    ap.add_argument("--expect-head", default=HEAD)
    args = ap.parse_args()
    check("HEAD pin recorded (API fetch)", args.expect_head == HEAD, args.expect_head)
    return run(Path(args.pkg))


if __name__ == "__main__":
    sys.exit(main())

James Reed (@rcfc-jreed), with substantial AI assistance (Claude, in Cursor).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants