# replay-tool: result ## Files changed (all under `tools/magic-replay/`) - `tools/magic-replay/replay.py`: the tool (Python 3, standard library only). - `tools/magic-replay/README.md`: the tool contract and usage. - `tools/magic-replay/archives.tsv`: the receipt. It has 839 rows, 149721 bytes, SHA256 `0946208ddd39a20ecff44d551ef72bfff36bd5046e2386d6f21a3b93217b9cb5`, which matches the pin. No Lean source and no file outside `tools/magic-replay/` was modified. I did not add a new theorem. The tool replays the merged `MagicResearch.Center` exactly as it is on trunk. ## How the receipt was produced I fetched the bridge input `api.imd.fun/artifacts/9336882d…a06758` (its SHA256 matched). From it I extracted `Select.lean` (SHA256 `88d9ad94…`) and `download.py` (SHA256 `ecfe4b43…`); both match the digests in report `28eca342…`. I ran them with Lean 4.33.1: - Release SHA256 `890afd18…aecaf235`, OK. - The Mathlib root files are pinned at `0df444a3…`. - The package bases come from Mathlib's pinned manifest. - `keys.txt` came out at 839 lines. - `download.py` produced an `archives.tsv` of 149721 bytes whose SHA256 equals the pinned `0946208d…`. Only individual source files and individual `.ltar` files were fetched. No repository archive and no submodule. ## Tool contract - **`replay.py prepare DIR`** (online) writes three things: - `DIR/lean-4.33.1-linux.tar.zst`, checked at 570405234 bytes and SHA256 `890afd18…`; - `DIR/archives.tsv`, the checked-in receipt, whose digest is checked; - `DIR/ltar/.ltar` for each row, each with its size and SHA256 checked. Files that are already valid are reused. - **`replay.py check DIR Module... [--scratch D] [--axioms DECL]...`** (offline, no network calls) treats DIR as read-only and ignores extra entries such as a published `compiled/` folder. It runs these steps: 1. Verifies the receipt digest, its 839 rows and their sort order, the release digest, and the size and digest of all 839 archives. 2. Extracts the compiler and the cache (`leantar -x`) into scratch, which must be outside DIR. 3. Compiles the named modules plus their local transitive imports in dependency order with `lean -DwarningAsError=true`. Oleans go to scratch only. 4. Runs `leanchecker --verbose`, then `#print axioms` for each `--axioms`. Any failure exits 1. ## Commands run and outcomes (on this checkout) 1. `python3 tools/magic-replay/replay.py prepare test/scratch/D`, with the release pre-seeded from a verified copy: 839 archives fetched, 68585420 bytes. `prepare: PASS`. 2. `python3 tools/magic-replay/replay.py prepare test/scratch/D2`, a fully fresh run that includes the 570 MB release download: `prepare: PASS`. `cmp` shows its `archives.tsv` is identical to the checked-in one. 3. `chmod -R a-w test/scratch/D`, then `PYTHONPATH= python3 tools/magic-replay/replay.py check test/scratch/D MagicResearch.Center --scratch test/scratch/S1 --axioms MagicResearch.HasMagicSum --axioms MagicResearch.center_and_opposite_pairs` exited 0. Output: ``` receipt: 839 rows, SHA256 OK / release: size and SHA256 OK / archives: all 839 size and SHA256 OK cache: 839 archives unpacked Lean (version 4.33.1, x86_64-unknown-linux-gnu, commit 819816b2e0a3bf405af45ae5c7af2491d8f5bee6, Release) build order: MagicResearch.Center replaying MagicResearch.Center 'MagicResearch.HasMagicSum' depends on axioms: [propext] 'MagicResearch.center_and_opposite_pairs' depends on axioms: [propext, Quot.sound] check: PASS ``` 4. Mathlib path: I ran check on a scratch module `test.scratch.Probe`, which imports `MagicResearch.Center`, `Mathlib.Algebra.BigOperators.Fin` and `Mathlib.Algebra.Group.Even` and proves `∑ i, f i = f 0 + f 1 + f 2` via `Fin.sum_univ_three`. It exited 0. The build order was `MagicResearch.Center, test.scratch.Probe`, leanchecker replayed it, and the axioms were `[propext, Classical.choice, Quot.sound]`. 5. Warnings as errors: a scratch module with an unused variable makes check exit 1. Lean reports the `unusedVariables` linter error. 6. Tampering: a receipt with one altered byte gives `FAIL: receipt SHA256 mismatch`, exit 1. All of the axiom sets above are within propext, Classical.choice and Quot.sound. None of these modules use sorry, admit, native_decide or extra axioms. ## Limitations - The sandbox does not allow `unshare -rn` ("Operation not permitted"), so check was not run inside a network namespace. It makes no network calls by construction: there is no urllib or curl in the check path, and the subprocesses are only `lean`, `leantar` and `leanchecker`. - This machine has no `zstd` binary and runs Python 3.12. I extracted the release with the PyPI `zstandard` 0.25.0 wheel, unpacked into scratch and put on `PYTHONPATH`. The tool also accepts a `zstd` binary or Python 3.14+ `compression.zstd`. I did not add the dependency to the repository. - The checks above cover the paths and bytes I actually ran. No independent verifier has run them.