From 7e362114fa41570bffe74dbb32896f13354a54cd Mon Sep 17 00:00:00 2001 From: Matarener Date: Thu, 22 Oct 2026 13:07:48 +0300 Subject: [PATCH] research/bit-row-stock-atom-audit: independent audit of the #4359 BIT row stock and its #4470 atom change (no new kappa) Checks the ordinary BIT conversion, cover prime, W(w)^D reserve split, borrowed-digit threshold, outer reserve q0 and h/16 shrink, and re-implements the delayed-cover audit. Records the delta-general q0 display (the written h^0.003 form is not valid at atom 0.004) and notes tautological checks. Co-Authored-By: Claude Opus 5.5 (1M context) --- research/bit-row-stock-atom-audit/README.md | 119 +++++++ .../bit-row-stock-atom-audit/SOURCES.json | 60 ++++ research/bit-row-stock-atom-audit/TASK.json | 88 +++++ research/bit-row-stock-atom-audit/VERIFY.json | 35 ++ .../bit-row-stock-atom-audit/test_verify.py | 62 ++++ research/bit-row-stock-atom-audit/verify.py | 311 ++++++++++++++++++ 6 files changed, 675 insertions(+) create mode 100644 research/bit-row-stock-atom-audit/README.md create mode 100644 research/bit-row-stock-atom-audit/SOURCES.json create mode 100644 research/bit-row-stock-atom-audit/TASK.json create mode 100644 research/bit-row-stock-atom-audit/VERIFY.json create mode 100644 research/bit-row-stock-atom-audit/test_verify.py create mode 100644 research/bit-row-stock-atom-audit/verify.py diff --git a/research/bit-row-stock-atom-audit/README.md b/research/bit-row-stock-atom-audit/README.md new file mode 100644 index 0000000000..6d6c9c4d98 --- /dev/null +++ b/research/bit-row-stock-atom-audit/README.md @@ -0,0 +1,119 @@ +# Audit of the #4359 BIT row stock and its #4470 atom change + +**Audit with a positive scoped result; no new κ.** The selected κ is unchanged. + +Base: `f626db5c3` (main after the #4470 review). This package independently +checks the BIT row-stock formulas that #4359 introduced, and the way the +#4440 → #4470 chain reuses them after raising the atom power from `0.003` to +`0.004`. The intake review of #4359 (`docs/research/pr-intake-evidence/pr4359/PROOF-REVIEW.md` §4) +argued the outer reserve in prose; no numerical or finite check of these +formulas existed. + +## Statements checked + +| Statement | Source | Outcome | +|---|---|---| +| `a_BIT = (1-δ)C1 + δ a_old` with `δ > a_BIT` (linear adapter paid), `δ < 1-a_BIT` (stock lower order) and the middle-exponent identity | DELAYED-COVER-BRIDGE §8; `query-thinned-controllers/verify.py` | Holds exactly: `0.0027418653797` (#4359, δ=.003) and `0.0034363538396` (#4470, δ=.004). With δ=.003 the #4470 adapter would fail, as its verifier says. | +| Cover prime `q > (256/d) N^5` gives fallback moment `(1+d/4)/(1+d/2) < 1` | DELAYED-COVER-BRIDGE §7 | Holds for `25,600,000` (#4359) and `2^26` (#4470). | +| Reserve `W(w)^D S_old`, `W(w) = B|GL_N(F_q)| q^(N^2(w-1))`, `D = floor(log_N ceil(e/w))` | DELAYED-COVER-BRIDGE §8 | Holds. `|GL_N(Z/q^w)| = |GL_N(F_q)| q^(N^2(w-1))` is brute-forced on small rings. The reserve divides exactly through D levels, and floor recursion has depth `floor(log_N n)`. The high-matrix factor is present, unlike the #4100 wording noted in #4432. | +| Borrowed digits `k = O(w log e) = o(e)` | DELAYED-COVER-BRIDGE §8 | Holds. With `log2 N = 6552928412` (#4359) or `25986965159937` (#4470 BIT), `2k < e` from `log2 e ≈ 2 log2 N/(1-δ)`: `1.3145·10^10` and `5.2183·10^13`. It keeps holding afterwards. | +| BIT-call width `≤ C h (log p)^2` | OUTER-TRANSFER-AUDIT §5, from SUPPLIER-SUPPORT-AUDIT | Holds with an explicit `C`. The exposed support is `2hK` and the three reservoirs add `9kG` with `k = 2hK`. With `K = 128G` and `G = 4⌈log2 p⌉+6`, the width is at most `2hK(1+9G) ≤ 232960 h L^2` for every `L ≥ 1`. | +| Its stock `O(h^δ (log p)^(1+2δ))`, nesting `log h`, plus complex `O(log h)`, giving `q0 ≤ C(log2 h + h^δ L^3 + 1)` | OUTER-TRANSFER-AUDIT §5 | Holds for both δ, because `2+2δ ≤ 3`. The comparison `e^δ log e ≤ C_w^δ(log2 C_w+3) h^δ L^(1+2δ)` is proved below and checked on a grid. | +| Threshold `H(p) = [1024 C L^3]^(1/(1-δ))`, `q0+O(1) ≤ h/64`, `R(h) ≤ 3h/128 + q0 + O(1) ≤ h/16` | OUTER-TRANSFER-AUDIT §5 | Holds. For `C ≥ 1` the displayed threshold already suffices; no extra multiple is needed. The phase sum is at most `1.067` times the first phase. | +| Old ordinary interchanges (`a_old`) act only on atom-width fields, so `S_old` is lower order | `notes/three-stage-cover-bit.tex` (weighted leaves; routing) | Holds. Its role split `W(w) = W_0 q^(m^2(w-1))` agrees with DELAYED-COVER-BRIDGE. | +| Delayed cover audit: cover size, routing bijection, projector matching, affine high-row carry | `delayed_cover_bridge.py` | Re-implemented independently for `GL_2(Z/9)` (3,888 rows) and `GL_3(Z/4)` (86,016 rows), with true inverses mod `p^w` and the carry for general `w`. Locally I also checked `GL_2(Z/27)` (314,928 rows) and `GL_2(Z/25)` (300,000 rows). All pass. | + +## Corrections (wording only; no exponent changes) + +1. **The written outer reserve is not updated for #4470.** OUTER-TRANSFER-AUDIT + §5 writes `q0(h,p) ≤ C(log2 h + h^0.003 (log2 p)^3 + 1)` and the threshold + `[1024 C (log2 p)^3]^(1/(1-0.003))`. The #4440/#4470 chain only says that + the new constants are substituted, and it adds the check `β(1-0.004) > 0`. + With atom `0.004` the literal display is false for large `h`, since it + would need `h^0.001 ≤ C L^0.992`. The argument does not depend on δ. The + correct statement for any atom `δ ≤ 1/2` is + + ``` + q0(h,p) <= C*(log2 h + h^δ*(log2 p)^3 + 1), + H(p) = [1024*C*(log2 p)^3]^(1/(1-δ)), + ``` + + with `δ = 3/1000` for #4359 and `δ = 4/1000` for #4440/#4470. Every + conclusion (`R(h) ≤ h/16`, polylog threshold, fit in `p^β`) is unchanged. + The pinned file is source-bound by hash in the #4359 receipts, so it is + left untouched; this package records the corrected display. +2. **`β(1-atom) > 0` is weaker than its name.** It is equivalent to `atom < 1`. + It accepts, for example, atom `0.99999`, where `δ < 1-a_BIT` fails. The + real condition `atom < 1-ordinary` is checked separately in + `query-thinned-controllers/verify.py` and `joint-helper-lattice/verify.py`. + No gap results. +3. **Three checks in `delayed_cover_bridge.py` cannot fail.** The projector + matching `g P g^-1 = (gS) Q (gS)^-1` is equivalent to `P S = S Q`. Once + `P = S Q S^-1` it holds for every `g`, so the 7,776 checks test arithmetic. + The weight equality follows from projector equality. The 6,561-address + scalar-gauge check builds `before` and `after` from the same expression. + The cover size, routing bijection, carry formula and the two negative + controls are genuine checks. The companion note's conjugacy argument, not + the finite run, carries the claim, as the note itself says. + +## Proofs + +*Exponents.* The root costs are `e^(1-δ)`, `e^((1-δ)(1-C1)+δ(1-a_old))` and +`e^δ log e`. The middle exponent equals `1-a_BIT` by expansion. The first is +at most `1-a_BIT` iff `δ ≥ a_BIT`. The third is lower order iff `δ < 1-a_BIT`. + +*Reserve split.* A level's rows are indexed by (role, low class in +`GL_N(F_q)`, high matrix in `(Z/q^(w-1))^(N^2)`, rest). This is a mixed-radix +digit of size `W(w)`. Ancestors own distinct digits, so `W^D S_old` rows give +every simultaneously live level its own digit and leave `S_old` at the leaves. + +*Borrowed digits.* `|GL_N(F_q)| < q^(N^2)` gives +`k ≤ D(N^2 w + log_q B + 1) + log_q S_old + 1`, with `D ≤ log2 e/log2 N`. +Hence `k/(w log2 e) ≤ (N^2 + o(1))/log2 N`. + +*Outer stock.* Let `e = C_w h L^2` with `1 ≤ h ≤ p` and `L = log2 p`. Then +`log2 e ≤ log2 C_w + 3L` and +`e^δ log2 e ≤ C_w^δ (log2 C_w + 3) h^δ L^(1+2δ)`. The `log h ≤ L` nesting +factor and the complex `O(log h)` give `L^(2+2δ) ≤ L^3`. + +*Threshold.* If `h^(1-δ) ≥ 1024 C L^3`, then `C h^δ L^3 ≤ h/1024`, and +`C(log2 h + 2) ≤ h/1024` there as well. The derivative of `h/64 - q0` is +positive above `H`. So `q0 + O(1) ≤ h/64` and +`R ≤ 3h/128 + h/64 = 5h/128 ≤ h/16`. + +## Scope + +Conditional, like #4359 and #4470. Inherited and not re-proved here: the +outer analytic decomposition and fixed-tape model; that the finite compiler +really gives each live child distinct physical roles (DELAYED-COVER-BRIDGE +open question 1); the size of the fixed constant `C`. Thresholds in the +table use `log2 C ≈ 2 log2 N + 64` only for illustration. The astronomically +large templates are not materialized. + +## Reproduce + +```sh +python3 -B research/bit-row-stock-atom-audit/verify.py # about 50 s +python3 -B research/bit-row-stock-atom-audit/test_verify.py # 7 rejecting controls +``` + +The controls cover: the old atom with #4470's `C1`; the literal `h^0.003` +display at atom `.004`; a broken atom that passes `β(1-atom) > 0`; omitting +the high-matrix lift; a max instead of a product of stocks; an omitted carry; +and widths below the borrowed-digit threshold. + +## Open next questions + +1. Bind the constant `C` of the outer reserve to the actual #4470 template + (`N`, `B`, `q`, centers). This would turn the illustrative thresholds into + bound ones. +2. Audit DELAYED-COVER-BRIDGE open question 1. Does the lockstep compiler give + each simultaneously live child role a distinct physical array? The + row-digit argument above assumes that it does. + +## Credit + +zxv for #4359 and the delayed-cover bridge; Cinna Davis and zxv for the +#4440/#4470 controller chain; the capped-phase-fusion support-router and +three-stage-cover authors credited in those sources. Audit by Mark +(Matarener), prepared with substantial Claude Code assistance. diff --git a/research/bit-row-stock-atom-audit/SOURCES.json b/research/bit-row-stock-atom-audit/SOURCES.json new file mode 100644 index 0000000000..99c66b9bf8 --- /dev/null +++ b/research/bit-row-stock-atom-audit/SOURCES.json @@ -0,0 +1,60 @@ +{ + "schema_version": 1, + "base_commit": "f626db5c3a3d781d8f7695038776c621651f75e1", + "files": [ + { + "path": "certificates/selected-result.json", + "usage": "provenance", + "git_blob": "ed33caef5c5827693e9572d252a66f99cbb73d40", + "sha256": "5732707cc1e460b090b53f2463162749ad860de878a18f7408938671d295a9d9" + }, + { + "path": "docs/research/agent-task-catalog.json", + "usage": "provenance", + "git_blob": "64bfc5af6709ed9811171e0a2108f05e1219cb65", + "sha256": "352a6184713b8843d96fd2c2071eb7aeaa655906b7c51d45ad444912666c8a96" + }, + { + "path": "notes/three-stage-cover-bit.tex", + "usage": "input", + "git_blob": "f05225d21f92cf8cef21b6e12601d5b4d61991f0", + "sha256": "47123a756f823c83a0d48cca2bf5add6472cd88410b13aed345e70c8834fb511" + }, + { + "path": "research/capped-phase-fusion/SUPPLIER-SUPPORT-AUDIT.md", + "usage": "input", + "git_blob": "ae676a6504cc7987863da1827551c18e7ec20ce1", + "sha256": "c41a2571b9c4c1d7920633f10c3ed2c74da39ca3bc8d6a910e6ffed380327413" + }, + { + "path": "research/joint-helper-lattice/verify.py", + "usage": "input", + "git_blob": "0006dd15ca5597edfa506559124d2cdf3c493ae4", + "sha256": "8eb13f77a94315f811612cb557a17edeecb6b9d9a75dfa238b112dd6520c336f" + }, + { + "path": "research/kappa-rebuild/bit/DELAYED-COVER-BRIDGE.md", + "usage": "input", + "git_blob": "a58774e237c9362869a60a22bda35be09fb85872", + "sha256": "9731b93026717f5fa15851e3633cbb4bdc76eba2bffb9d6b4a3b69f7dd502443" + }, + { + "path": "research/kappa-rebuild/bit/delayed_cover_bridge.py", + "usage": "input", + "git_blob": "c541a7ea45a5dac49b62078e3aa15585565ad665", + "sha256": "96ea0f49a6fc07687e2f932859e5ce18e2b3f42d6e826fdc555c48069560a2ec" + }, + { + "path": "research/kappa-rebuild/transfer-audit/OUTER-TRANSFER-AUDIT.md", + "usage": "input", + "git_blob": "e8b7ef8956ece5bd493cbf52113916e5dc288535", + "sha256": "67569961d068633c6ff3ac9dfde47a0c17f0da6d20432799dcc920cff92b5779" + }, + { + "path": "research/query-thinned-controllers/verify.py", + "usage": "input", + "git_blob": "f1114036fff66f57014e5c1256141fb78ff4c4a9", + "sha256": "07dea601d6bbaa4d90e576f20c8607c37fb01e8778c798d919fa9df435049950" + } + ] +} diff --git a/research/bit-row-stock-atom-audit/TASK.json b/research/bit-row-stock-atom-audit/TASK.json new file mode 100644 index 0000000000..3948234de9 --- /dev/null +++ b/research/bit-row-stock-atom-audit/TASK.json @@ -0,0 +1,88 @@ +{ + "schema_version": 1, + "task_id": "selected-stock-envelope", + "priority_revision": 7, + "base_commit": "f626db5c3a3d781d8f7695038776c621651f75e1", + "original_card": { + "id": "selected-stock-envelope", + "question": "What explicit uniform stock envelope does the actual selected stopped producer supply at one bootstrap stage?", + "starting_points": [ + "research/selected-bootstrap-stock-audit/README.md", + "research/bootstrap-cutoff-time-space-split/README.md", + "certificates/selected-result.json", + "docs/research/community-efficient1000-review.md", + "research/stock-margin-chain/README.md" + ], + "methods": [ + "Derive a source-bound reserve recurrence at the actual selected atom widths, separating parent stock from completed inner borrowing.", + "Find an exact missing implication or counterexample to a proposed selected-stage stock envelope." + ], + "acceptance_gate": "Bind every coefficient and depth factor to the selected producer and state the width domain. Compare a proved envelope with the sufficient cutoff guard; a large numerical headroom or a historical m=120 coefficient is not a selected m=73 proof.", + "first_step": { + "command": [ + "python3", + "-B", + "scripts/research_baseline.py" + ], + "expected": "PASS_RESEARCH_BASELINE_BINDINGS_ONLY", + "inspect": "Read #2972 stock-margin chain and the selected stock audit. The new source archive reports the remaining cutoff comparisons, but leaves every actual stock coefficient unresolved; it is not an independently validated reserve envelope.", + "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": "Choose one actual selected producer/stage and derive its parent reserve and depth coefficient from source. Check whether newer handoffs already cover that exact obligation. Stop with the missing implementation lemma if it cannot be bounded; do not rerun #2972 cutoff/headroom arithmetic as a new contribution.", + "bottleneck_link": "This reduces a concrete inherited implementation obligation without confusing unchanged kappa arithmetic with a completed theorem.", + "allowed_variations": [ + "One stage or one explicit reserve/depth implication.", + "An independently checked same-domain proof repair, retaining all remaining assumptions." + ], + "scope_change_triggers": [ + "Importing the historical 57604 or 252 allowance without a selected-producer binding.", + "Calling a conditional fit lemma a full outer-proof adoption.", + "Replacing an actual selected stock coefficient with cutoff comparisons or a conditional fit inequality." + ], + "overlap_terms": [ + "selected stock", + "stock envelope", + "bootstrap cutoff", + "1956", + "1965", + "1990", + "2972", + "stock-margin-chain", + "actual_stock_coefficient" + ], + "existing_checks": [ + { + "scope": "Retained stock audit identifies missing actual selected-stage coefficients; later cutoff-chain arithmetic does not supply them.", + "evidence": "docs/research/research-family-status.md#revision-6-handoffs-source-archives-awaiting-independent-validation", + "remaining": "Derive one actual reserve/depth coefficient from the selected producer.", + "status": "reviewed", + "source_commit": "836b19bfa309ceafbc8ee32a15e8c4b10dde7e11", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + } + ] + }, + "scope_status": "refined", + "actual_scope": "The BIT row-stock formulas of the selected #4359 producer (DELAYED-COVER-BRIDGE sections 7-8, OUTER-TRANSFER-AUDIT section 5) and their reuse with atom 0.004 in the #4440/#4470 chain.", + "scope_change_reason": "The selected producer changed with #4359; its new BIT reserve and outer row stock had only a prose intake check, and #4470 changed the atom power without restating the reserve.", + "bottleneck_link": "Side result for the selected-result audit: confirms the stock layer of the conditional kappa line and corrects one display; it does not move the frontier.", + "budget_minutes": 120, + "stop_rule": "Stop after the stock, depth, borrowed-digit, outer-reserve and delayed-cover finite statements are checked; do not audit the outer analytic decomposition or materialize templates.", + "outcome": "completed", + "evidence": "README.md proofs; verify.py binds the source statements and checks them exactly or on stated grids; test_verify.py has seven rejecting controls.", + "author": "Mark (Matarener)", + "ai_assistance": "Prepared with substantial Claude Code (Claude) assistance.", + "open_questions": [ + { + "question": "What is the actual constant C of the outer reserve for the #4470 template?", + "why_it_matters": "It fixes the eventual thresholds; the package uses log2 C ~ 2 log2 N + 64 only for illustration.", + "first_step": "Sum the BIT digit count D(N^2 w + log_q B + 1) with the complex ceil(log2 W) D and the router constants for the #4470 N, B, q.", + "blocked_by": "none" + }, + { + "question": "Does the lockstep compiler give every simultaneously live child role a distinct physical array?", + "why_it_matters": "The row-digit reserve argument assumes it (DELAYED-COVER-BRIDGE open question 1).", + "first_step": "Replay the finite compiler's role assignment on the materialized rank-50 BIT example and check digit ownership along every root-leaf path.", + "blocked_by": "none" + } + ] +} diff --git a/research/bit-row-stock-atom-audit/VERIFY.json b/research/bit-row-stock-atom-audit/VERIFY.json new file mode 100644 index 0000000000..4acbeb5c99 --- /dev/null +++ b/research/bit-row-stock-atom-audit/VERIFY.json @@ -0,0 +1,35 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [ + "notes/three-stage-cover-bit.tex", + "research/capped-phase-fusion/SUPPLIER-SUPPORT-AUDIT.md", + "research/joint-helper-lattice/verify.py", + "research/kappa-rebuild/bit/DELAYED-COVER-BRIDGE.md", + "research/kappa-rebuild/bit/delayed_cover_bridge.py", + "research/kappa-rebuild/transfer-audit/OUTER-TRANSFER-AUDIT.md", + "research/query-thinned-controllers/verify.py" + ], + "commands": [ + { + "argv": [ + "{python}", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 180, + "checks": "Bind source statements; exact ordinary BIT conversion and cover prime for #4359 and #4470; GL lift, reserve split and depth; borrowed-digit threshold; outer reserve width, stock, threshold and h/16; independent delayed-cover audit on GL_2(Z/9) and GL_3(Z/4); tautological gauge check." + }, + { + "argv": [ + "{python}", + "-B", + "{package}/test_verify.py" + ], + "timeout_seconds": 60, + "checks": "Rejecting controls: old atom at #4470, literal h^0.003 at atom .004, broken atom passing beta*(1-atom), missing high-matrix lift, max instead of product, omitted carry, widths below threshold." + } + ] +} diff --git a/research/bit-row-stock-atom-audit/test_verify.py b/research/bit-row-stock-atom-audit/test_verify.py new file mode 100644 index 0000000000..aedf39f158 --- /dev/null +++ b/research/bit-row-stock-atom-audit/test_verify.py @@ -0,0 +1,62 @@ +#!/usr/bin/env python3 +"""Rejecting controls for verify.py.""" +import math +import unittest +from fractions import Fraction as Q + +import verify as v + + +class Controls(unittest.TestCase): + def test_old_atom_fails_adapter_for_4470(self): + c = v.CASES["pr4470"] + a = v.ordinary_saving(c["C1"], Q(3, 1000)) + self.assertLessEqual(Q(3, 1000), a) + + def test_literal_h0003_bound_false_at_atom_0004(self): + # h^.004 L^2.008 <= C h^.003 L^3 fails once h^.001 > C L^.992 + logC, L = 2 * v.CASES["pr4470"]["log2N"] + 64, 10.0 ** 18 + logh = 0.99 * L + lhs = 0.004 * logh + 2.008 * math.log2(L) + rhs = logC + 0.003 * logh + 3 * math.log2(L) + self.assertGreater(lhs, rhs) + + def test_beta_predicate_passes_broken_atom(self): + atom = Q(99999, 100000) + a = v.ordinary_saving(v.CASES["pr4470"]["C1"], atom) + self.assertGreater(v.CASES["pr4470"]["beta"] * (1 - atom), 0) + self.assertFalse(atom < 1 - a) + + def test_omitting_high_matrix_lift_underreserves(self): + N, q, w, B, S, D = 2, 3, 2, 5, 7, 3 + full = B * v.gl_order(N, q) * q ** (N * N * (w - 1)) + wrong = B * v.gl_order(N, q) + R = wrong ** D * S + levels = 0 + while R % full == 0 and R >= full: + R //= full + levels += 1 + self.assertLess(levels, D) + + def test_max_instead_of_product_underreserves(self): + bit, cx = 12 ** 3, 48 ** 2 + self.assertLess(max(bit, cx), bit * cx) + + def test_omitted_carry_breaks_high_row(self): + p, m = 3, 9 + g, S = ((2, 7), (4, 5)), ((1, 1), (1, 0)) + h = v.mat_mul(g, S, m) + g0 = [[x % p for x in r] for r in g] + G1 = [[(x - y) // p for x, y in zip(r, s)] for r, s in zip(g, g0)] + no_carry = tuple(tuple(sum(G1[i][k] * S[k][j] for k in range(2)) % p for j in range(2)) for i in range(2)) + self.assertNotEqual(tuple(tuple(x // p for x in r) for r in h), no_carry) + + def test_stock_threshold_fails_below(self): + c = v.CASES["pr4359"] + Le = 1.5 * c["log2N"] + k = v.log2_k(Le, float(c["delta"]), float(c["log2N"])) + self.assertTrue(k is None or k + 1 >= Le) + + +if __name__ == "__main__": + unittest.main() diff --git a/research/bit-row-stock-atom-audit/verify.py b/research/bit-row-stock-atom-audit/verify.py new file mode 100644 index 0000000000..9ff0450975 --- /dev/null +++ b/research/bit-row-stock-atom-audit/verify.py @@ -0,0 +1,311 @@ +#!/usr/bin/env python3 +"""Independent audit of the BIT row-stock formulas of #4359 and their #4470 atom change. + +Standard library only. Exit status 0 means every check passed; the summary is printed +as JSON. See README.md for the statements and proofs. +""" +import itertools +import json +import math +import sys +import time +from fractions import Fraction as Q +from pathlib import Path + +HERE = Path(__file__).resolve().parent +ROOT = HERE.parents[1] +A_OLD = Q(384599, 10 ** 10) +CASES = { + "pr4359": dict(C0=Q(69, 25000), C1=Q(11, 4000), delta=Q(3, 1000), admitted=Q(27, 10000), + prime=Q(25_600_000), log2N=6552928412, beta=Q(99997, 100000), + a_expected=Q(27418653797, 10 ** 13)), + "pr4470": dict(C0=Q(3459, 10 ** 6), C1=Q(69, 20000), delta=Q(1, 250), admitted=Q(34, 10000), + prime=Q(2 ** 26), log2N=25986965159937, beta=1 - 3 * Q(1, 1_400_000_000), + a_expected=Q(8590884599, 2500000000000)), +} +BINDINGS = { + "research/kappa-rebuild/transfer-audit/OUTER-TRANSFER-AUDIT.md": [ + "q0(h,p) <= C*(log2 h + h^0.003*(log2 p)^3 + 1)", + "[1024*C*(log2 p)^3]^(1/(1-0.003))", + "R(h) <= 3h/128 + q0(h,p) + O(1) <= h/16", + "`O(h^0.003*(log p)^(2*0.003+1))`", + "has width at most `C*h*(log p)^2`", + ], + "research/kappa-rebuild/bit/DELAYED-COVER-BRIDGE.md": [ + r"W(w)=B|\operatorname{GL}_N(\mathbb F_q)|q^{N^2(w-1)}", + "A safe reserve is `W(w)^D * S_old`", + r"a_{\rm BIT}=(1-\delta)C_1+\delta a_{\rm old}", + r"q>\frac{256N^5}{d}=25,600,000N^5.", + ], + "research/kappa-rebuild/bit/delayed_cover_bridge.py": [ + "before={(0,mapped),(1,mapped)}", + "after={(role,act(gauge,address)) for role in (0,1)}", + ], + "research/capped-phase-fusion/SUPPLIER-SUPPORT-AUDIT.md": [ + "G=4 ceil(log2 p)+6", + "With K=128G", + "Three disjoint 3kG-bit reservoirs", + "Q_rows=W_complex^D_complex W_bit^D_bit", + ], + "notes/three-stage-cover-bit.tex": [ + r"$a_{\rm old}=384599/10^{10}$", + r"old width-$O(w)$ interchanges", + r"$W(w)=W_0q^{m^2(w-1)}$", + ], + "research/query-thinned-controllers/verify.py": [ + "Q('.004')", + "params['beta']*(1-atom)", + "atom < 1-ordinary", + ], + "research/joint-helper-lattice/verify.py": [ + "atom==Q('.004')", + ], +} + + +def need(cond, msg): + if not cond: + raise AssertionError(msg) + + +def bind_sources(): + found = {} + for path, needles in BINDINGS.items(): + text = (ROOT / path).read_text(encoding="utf-8") + for s in needles: + need(s in text, f"source statement missing in {path}: {s}") + found[path] = len(needles) + return found + + +# ---------------------------------------------------------------- conversion +def ordinary_saving(C1, delta): + return (1 - delta) * C1 + delta * A_OLD + + +def conversion(): + out = {} + for name, c in CASES.items(): + d, C0, C1 = c["delta"], c["C0"], c["C1"] + a = ordinary_saving(C1, d) + gap = C0 - C1 + need(a == c["a_expected"], f"{name}: exact ordinary saving") + need(d > a, f"{name}: linear adapter term e^(1-delta) is paid") + need(d < 1 - a, f"{name}: stock e^delta log e is lower order") + need((1 - d) * (1 - C1) + d * (1 - A_OLD) == 1 - a, f"{name}: middle exponent identity") + need(a > c["admitted"], f"{name}: admitted saving below ordinary") + need(c["prime"] >= 256 / gap, f"{name}: prime coefficient >= 256/(C0-C1)") + need(64 / c["prime"] <= gap / 4, f"{name}: fallback surcharge 64N^5/q <= gap/4") + need((1 + gap / 4) / (1 + gap / 2) < 1, f"{name}: complete fallback moment < 1") + # N^gap >= 2^gap = exp(gap ln 2) >= 1 + gap ln 2 > 1 + gap/2 (ln 2 > 1/2) + need(math.log(2) > 0.5, "ln 2 > 1/2") + out[name] = {"a_BIT": str(a), "a_BIT_decimal": f"{float(a):.13f}", + "adapter_margin": str(d - a), "stock_margin": str(1 - d - a)} + old_at_new = ordinary_saving(CASES["pr4470"]["C1"], Q(3, 1000)) + need(not Q(3, 1000) > old_at_new, "#4470: the old atom 0.003 cannot pay the adapter") + return out + + +# ---------------------------------------------------------------- stock algebra +def gl_order(n, p): + out = 1 + for i in range(n): + out *= p ** n - p ** i + return out + + +def det(a, m): + n = len(a) + if n == 1: + return a[0][0] % m + if n == 2: + return (a[0][0] * a[1][1] - a[0][1] * a[1][0]) % m + return (a[0][0] * (a[1][1] * a[2][2] - a[1][2] * a[2][1]) + - a[0][1] * (a[1][0] * a[2][2] - a[1][2] * a[2][0]) + + a[0][2] * (a[1][0] * a[2][1] - a[1][1] * a[2][0])) % m + + +def stock_algebra(): + gl = {} + for n, p, w in ((1, 3, 3), (2, 3, 2), (2, 2, 3), (1, 5, 2)): + m = p ** w + cnt = sum(det([list(e[i * n:(i + 1) * n]) for i in range(n)], p) != 0 + for e in itertools.product(range(m), repeat=n * n)) + need(cnt == gl_order(n, p) * p ** (n * n * (w - 1)), f"|GL_{n}(Z/{p}^{w})| lift formula") + gl[f"n{n}_p{p}_w{w}"] = cnt + for N, q, w, B, S in ((2, 3, 2, 5, 7), (3, 5, 2, 11, 4), (2, 7, 3, 2, 9)): + Wf = B * gl_order(N, q) * q ** (N * N * (w - 1)) + for D in (1, 2, 3, 4): + R = Wf ** D * S + for _ in range(D): + R, r = divmod(R, Wf) + need(r == 0, "reserve splits exactly at every level") + need(R == S, "the last level keeps S_old") + for N in range(2, 13): + for n in range(1, 20001): + d, x = 0, n + while x >= N: + x, d = x // N, d + 1 + need(N ** d <= n < N ** (d + 1), "D(n) = floor(log_N n)") + need(all(6 * (2 * m) * (2 * m - 1) + 3 * (2 * m) + 6 * (2 * m - 1) < 32 * m * m + for m in range(1, 20001)), "fallback child count < 32 m^2") + return {"gl_lift_counts": gl, "split_cases": 12, "depth_scan": "N=2..12, n<=2e4"} + + +# ---------------------------------------------------------------- borrowed digits +def log2_k(Le, delta, log2N): + """log2 of D (N^2 w + 2), the main part of the borrowed base-q digit count, at e = 2^Le.""" + logw = delta * Le + D = math.floor((Le - logw) / log2N) + if D < 1: + return None + return math.log2(D) + 2 * log2N + logw + + +def borrowed_digits(): + out = {} + for name, c in CASES.items(): + d, L = float(c["delta"]), float(c["log2N"]) + good = lambda Le: (lambda k: k is not None and k + 1 < Le)(log2_k(Le, d, L)) + lo, hi = L, 4 * L + while not good(hi): + hi *= 2 + for _ in range(200): + mid = (lo + hi) / 2 + lo, hi = (lo, mid) if good(mid) else (mid, hi) + need(all(good(hi * (1 + t / 100) ** 3) for t in range(1, 2001)), f"{name}: 2k 0, "h/64 - q0 increasing above H") + out["threshold_multiple_needed"] = 1 + out["phase_sum_factor_x=0.997"] = 1 / (1 - 16 ** -0.997) + return out + + +# ---------------------------------------------------------------- cover +def mat_mul(a, b, m): + n = len(a) + return tuple(tuple(sum(a[i][k] * b[k][j] for k in range(n)) % m for j in range(n)) for i in range(n)) + + +def adjugate(a): + n = len(a) + if n == 2: + return ((a[1][1], -a[0][1]), (-a[1][0], a[0][0])) + cof = [[0] * 3 for _ in range(3)] + for i in range(3): + for j in range(3): + r = [x for x in range(3) if x != i] + c = [x for x in range(3) if x != j] + cof[i][j] = (-1) ** (i + j) * (a[r[0]][c[0]] * a[r[1]][c[1]] - a[r[0]][c[1]] * a[r[1]][c[0]]) + return tuple(tuple(cof[j][i] for j in range(3)) for i in range(3)) + + +def inv(a, m): + di = pow(det(a, m), -1, m) + return tuple(tuple(x * di % m for x in row) for row in adjugate(a)) + + +def cover_audit(): + cases = { + (2, 3, 2): ([((1, 0), (0, 0)), ((1, 0), (1, 0))], [((1, 1), (1, 0)), ((0, 1), (1, -1))]), + (3, 2, 2): ([((1, 0, 0), (0, 1, 0), (0, 0, 0)), ((1, 0, 0), (1, 0, 0), (0, 0, 1))], + [((1, 1, 0), (0, 1, 0), (0, 1, 1)), ((0, 1, 0), (0, 0, 1), (1, 0, 0))]), + } + out = {} + for (N, p, w), (children, matchers) in cases.items(): + m, hm = p ** w, p ** (w - 1) + cov = [] + for e in itertools.product(range(m), repeat=N * N): + g = tuple(tuple(e[i * N:(i + 1) * N]) for i in range(N)) + if det(g, p): + cov.append(g) + need(len(cov) == gl_order(N, p) * p ** (N * N * (w - 1)), "cover size") + covset = set(cov) + for Qc, S in zip(children, matchers): + S = tuple(tuple(x % m for x in r) for r in S) + need(mat_mul(Qc, Qc, m) == tuple(tuple(x % m for x in r) for r in Qc), "child projector") + P = mat_mul(mat_mul(S, Qc, m), inv(S, m), m) + images, ctrl = set(), False + for g in cov: + h = mat_mul(g, S, m) + images.add(h) + gi = inv(g, m) + lhs = mat_mul(mat_mul(g, P, m), gi, m) + need(lhs == mat_mul(mat_mul(h, Qc, m), inv(h, m), m), "projector matching") + ctrl |= mat_mul(mat_mul(g, Qc, m), gi, m) != lhs + g0 = tuple(tuple(x % p for x in r) for r in g) + G1 = tuple(tuple((x - y) // p for x, y in zip(r, s)) for r, s in zip(g, g0)) + raw = [[sum(g0[i][k] * S[k][j] for k in range(N)) for j in range(N)] for i in range(N)] + carry = [[x // p for x in r] for r in raw] + pred = tuple(tuple((sum(G1[i][k] * S[k][j] for k in range(N)) + carry[i][j]) % hm + for j in range(N)) for i in range(N)) + need(tuple(tuple(x // p for x in r) for r in h) == pred, "affine high-row carry") + need(images == covset, "right routing is a bijection of the cover") + need(ctrl, "omitting the matcher changes the projector") + out[f"N{N}_p{p}_w{w}"] = len(cov) + return out + + +def tautology_check(): + # The original 6561-address gauge check compares two identical constructions. + act = lambda x: ((2 * x[0]) % 9, (4 * x[1]) % 9) + tuple(x[2:]) + for address in itertools.product(range(9), repeat=4): + mapped = act(address) + before = {(0, mapped), (1, mapped)} + after = {(role, act(address)) for role in (0, 1)} + need(before == after, "identical by construction") + return "the delayed_cover_bridge.py scalar-gauge check cannot fail; it is not evidence" + + +def main(): + start = time.monotonic() + result = {"schema": "bit-row-stock-atom-audit/1", "sources": bind_sources(), + "conversion": conversion(), "stock_algebra": stock_algebra(), + "borrowed_digits": borrowed_digits(), "outer_reserve": outer_reserve(), + "cover": cover_audit(), "tautology": tautology_check()} + result["status"] = "PASS_BIT_ROW_STOCK_AUDIT_NO_NEW_KAPPA" + result["seconds"] = round(time.monotonic() - start, 1) + print(json.dumps(result, indent=2, sort_keys=True)) + + +if __name__ == "__main__": + try: + main() + except AssertionError as exc: + print(f"FAIL: {exc}", file=sys.stderr) + sys.exit(1)