Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 87 additions & 0 deletions research/signed-leibniz-replay/MEASUREMENT.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
{
"cpu_count": 18,
"errors": 0,
"load_average": [
3.1376953125,
3.8837890625,
2.8388671875
],
"platform": "macOS-27.0.1-arm64-arm-64bit",
"python": "3.12.15 (main, Oct 14 2026, 00:55:37) [Clang 23.1.3 ]",
"reduction": 0.09829787936083867,
"samples": [
{
"elapsed_ns": 142122583,
"engine": "reference",
"stdout_sha256": "d0ee4265d505e6433c2eb13cc54edfe144167c5f61d0a4add50a6e513c4febb5"
},
{
"elapsed_ns": 121716458,
"engine": "scheduled",
"stdout_sha256": "d0ee4265d505e6433c2eb13cc54edfe144167c5f61d0a4add50a6e513c4febb5"
},
{
"elapsed_ns": 130969667,
"engine": "reference",
"stdout_sha256": "d0ee4265d505e6433c2eb13cc54edfe144167c5f61d0a4add50a6e513c4febb5"
},
{
"elapsed_ns": 118456500,
"engine": "scheduled",
"stdout_sha256": "d0ee4265d505e6433c2eb13cc54edfe144167c5f61d0a4add50a6e513c4febb5"
},
{
"elapsed_ns": 131713167,
"engine": "reference",
"stdout_sha256": "d0ee4265d505e6433c2eb13cc54edfe144167c5f61d0a4add50a6e513c4febb5"
},
{
"elapsed_ns": 119808625,
"engine": "scheduled",
"stdout_sha256": "d0ee4265d505e6433c2eb13cc54edfe144167c5f61d0a4add50a6e513c4febb5"
},
{
"elapsed_ns": 131461458,
"engine": "reference",
"stdout_sha256": "d0ee4265d505e6433c2eb13cc54edfe144167c5f61d0a4add50a6e513c4febb5"
},
{
"elapsed_ns": 118718833,
"engine": "scheduled",
"stdout_sha256": "d0ee4265d505e6433c2eb13cc54edfe144167c5f61d0a4add50a6e513c4febb5"
},
{
"elapsed_ns": 134855917,
"engine": "reference",
"stdout_sha256": "d0ee4265d505e6433c2eb13cc54edfe144167c5f61d0a4add50a6e513c4febb5"
},
{
"elapsed_ns": 118766042,
"engine": "scheduled",
"stdout_sha256": "d0ee4265d505e6433c2eb13cc54edfe144167c5f61d0a4add50a6e513c4febb5"
}
],
"source_hashes": {
"research/dyadic-helper-channel-capacity/RESULT.json": "31975ba943d585843b185bc32ea6a5bff20d9d8f1cca2c041be6e8517c7f91ec",
"research/dyadic-helper-channel-capacity/SOURCES.json": "f480b7e6f7021278faad4bdc6eb0e3909ef673d88c4d9cc836636feacedb7dea",
"research/dyadic-helper-channel-capacity/capacity.py": "1cd82b0beab7983d955cfc1d1e562af490f90bcaad6e3ec7d07e0c5a33608834",
"research/dyadic-helper-channel-capacity/verify.py": "d008dcf6de6d76c160989126453371b4cff09beeaab5c523e57ad6d8c6009af7",
"research/p104-coupled-helper-bases/PROOF.md": "d9049aa75f065c3c21b0f55246c433c643584bca8969f2f382a83c425c4a2927",
"research/signed-leibniz-replay/SOURCES.json": "7d57b2617574606e98c45b20c7211ce9df7e1cea00360100751d8b553a6322f6",
"research/signed-leibniz-replay/adapter.py": "b37d88e4972a9d6af8e7b6e63d156935d6ad58a5e5f513b81509fd8aa67ad5ce",
"research/signed-leibniz-replay/benchmark.py": "f9653d5eb1d0eda9fe1360daca3bfcd902ca5a8a577d959261f1d8aa1e2dfc66",
"research/signed-leibniz-replay/kernel.py": "12d88b1657496699a8da76b94052a4ce8755ae586985d06207adaf6d4d8d93f9"
},
"summary": {
"reference": {
"max_ns": 142122583,
"median_ns": 131713167,
"min_ns": 130969667
},
"scheduled": {
"max_ns": 121716458,
"median_ns": 118766042,
"min_ns": 118456500
}
}
}
102 changes: 102 additions & 0 deletions research/signed-leibniz-replay/PROOF.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# Exact evaluator and complete-caller preservation

Let A be a square matrix over the integers or rationals, of dimension
0 <= n <= 5. The reference determinant enumerates every permutation p and
evaluates

```text
sum_p (-1)^(number of inversions of p) product_i A[i,p[i]].
```

The replacement returns A[0,0] for n=1 and
A[0,0]A[1,1]-A[0,1]A[1,0] for n=2. These are exactly the one and two
Leibniz terms. For every other allowed dimension it uses the same permutation
enumeration, exact products and sum, taking the sign from a table initialized
by the same inversion formula. The empty product and single empty permutation
give determinant one at n=0. Thus the evaluators agree on the entire stated
arithmetic and dimension domain, including singular and negative determinants.
No division, rounding, rank assumption or nonzero-pivot assumption enters.

The table contains sum(n!, n=0..5)=154 permutation/sign pairs. It depends only
on dimension. Matrix values are read again at every call; a changed matrix
cannot reuse an earlier determinant. A separate cycle-decomposition check
uses sign(p)=(-1)^(n-number_of_cycles) and verifies table completeness and
uniqueness. It is a conformance check, not the basis of the equality proof.

The source-bound complete caller has no determinant request outside sizes
one through five. Comparison mode evaluates both functions on every actual
request, checks exact equality, and hashes the ordered matrix/value stream.
Its 19,654 calls include every determinant requested by both the unimodular
certificate checks and the independent gcd of every minor. All remaining
functions and all control flow execute from the original authenticated source.

Consequently the changed caller computes the same unimodular conditions,
Smith identities, diagonal and divisibility conditions, independent minor gcds,
constructive unit blocks, nonunit obstructions and corrupted-certificate
decisions. It performs all original work with a cheaper exact evaluator.
This implication preserves the source caller's checks; it does not independently
prove the mathematical capacity algorithm or its physical applicability.

# Measurement contract

The benchmark launches five alternating reference/scheduled pairs, each as a
fresh CPython process. The reference arm is the original complete script.
The scheduled arm is the isolated adapter, including its source authentication
and additional imports. The timer encloses process creation, full execution,
captured output and successful termination. Timeout is thirty seconds. Every
arm must exit successfully, emit no stderr, reach the original success marker
and produce identical complete stdout. No scientific output or result is cached.

Bytecode-cache namespaces are fresh for every process. The adapter additionally
loads the two authenticated predecessor modules directly from source. Both
arms use the same interpreter, warnings and disabled cache-write settings.
There is no baseline-only profiler, tracer, extra guard or repetition inside
the timed region. Measurement summaries and source hashes are generated after
timing. Profile runs are separate and never included in the ten samples.

The diagnostic reference profile put roughly 22% of its total profiled time
inside determinant evaluation. The scheduled evaluator reduces that work;
unchanged Fraction arithmetic, matrix products and certificate checks limit
the complete gain. The measured 9.83% reduction is below that optimistic
removable share. This is a local observation, not an asymptotic or portable
speed guarantee. No performance threshold is asserted by CI.

# Implementation bounds and deviations

New loops are finite. Schedule initialization has six dimensions and 154
permutations, with at most ten inversion comparisons each. A scheduled
determinant has at most 120 terms of at most five factors. Conformance grids
have 1,248 values; source controls have eight copied files and five separately
mutated inputs. The manifest is limited to sixteen rows and each input to
one megabyte. The production caller is fixed by five input hashes.
The benchmark has exactly ten subprocesses, with thirty-second limits.
The normal and optimized registered checks each have a 120-second limit.

Functions are shorter than sixty physical lines. New control flow is iterative,
with explicit exceptions active under optimization. Temporary exports and
bytecode namespaces use context-managed cleanup. The source loader restores
the original capacity module binding on success and failure. Neither a kernel
exception nor a source mismatch is turned into scientific success.

Power of Ten deviations:

- Rule 2, inherited Smith reduction: the frozen predecessor has an unbounded
Euclidean loop. Preserving its exact source and checks prevents changing it
here. The caller's fixed finite input domain is unchanged, and each executed
subprocess and registered check has a wall-clock timeout. This limits a
stalled replay but is not a newly proved iteration bound. A separate change
to that source needs its own bound and preservation evidence.
- Rule 3, managed allocation: CPython integers, Fractions, tuples and captured
stdout allocate dynamically. The fixed grids, five-row matrices, 154-entry
table and bounded source files limit live data in these scripts. No service
loop or unbounded cache exists. Reassess storage before enlarging dimensions
or accepting external matrices.
- Rules 8 and 9, source imports and callable replacement: the adapter uses the
standard source loader for exactly two authenticated module paths and replaces
one determinant function with one of three explicit engines. It bypasses
bytecode. Comparison and corruption controls exercise the alternate targets;
no arbitrary plugin, code generator or runtime expression is accepted.

Warning-strict normal and optimized execution, source corruption checks,
committed-byte/source-history preflight and AST inspection are the available
diagnostics. No external static analyzer or formal proof kernel is claimed.
113 changes: 113 additions & 0 deletions research/signed-leibniz-replay/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# Faster complete dyadic-capacity replay

This contribution was produced by Nick Petalas. Apache-2.0.

Claim type: scoped implementation-preservation proof and local performance
result. The complete [Ali Romman PR5615](https://github.com/CrocSwap/integer-mult-bounds/pull/5615)
capacity replay takes **9.83% less median wall time** with a bounded exact
Leibniz evaluator. Five alternating fresh-process pairs measured
0.131713167 s to 0.118766042 s. Reference range is 0.130969667 to
0.142122583 s; scheduled range is 0.118456500 to 0.121716458 s.
All ten complete scientific outputs are identical, with zero errors.

The change evaluates sizes one and two directly and initializes the 154 signed
permutations through size five once. It caches no matrix entries, determinants,
certificate decisions or scientific outputs. The original capacity algorithm,
independent minor oracle, source checks and complete caller remain unchanged.
This is an isolated opt-in adapter; no shared default command is changed.

The first signed-schedule-only experiment was inconclusive after adapter
overhead. Profiling then identified the 18,778 size-one and size-two requests.
Direct evaluation supplied the first clear improvement; optimization stopped.
The final generated [measurement](MEASUREMENT.json) binds the executing source
and all five declared inputs. It includes process startup, imports, source
authentication and the complete caller, rather than only the determinant loop.
Its final five-pair rerun records the numbers above. Timing is descriptive and
does not gate CI or promise a speedup on another host.

## Evidence

[PROOF.md](PROOF.md) shows exact equality of the evaluator for square integer
and rational matrices of sizes zero through five, and why replacing that one
function preserves each original certificate predicate.

The standalone verifier checks, in each normal or optimized run:

- All 19,654 requested determinants against the original evaluator, with an
ordered matrix/value transcript. The dimension counts are
`[0, 10331, 8447, 705, 138, 33]`.
- The complete source caller in reference, scheduled and comparison modes,
retaining its 2,401 integer matrices, 75 rectangular dyadic matrices, causal
and joint witnesses, and five original rejection controls.
- 154 signed schedules with a separate cycle-parity check; 1,248 explicit
conformance values, including rational, large-integer and mutable inputs.
- Six domain or evaluator corruption controls, plus five actual corrupted-input
executions. Every declared input is corrupted separately in a disposable
Git-free export and rejected before scientific execution. The unchanged
export also completes with an empty PATH.
- All ten recorded benchmark outputs, the source hashes, sample order and
summary arithmetic. Receipts are generated by the scripts, never handwritten.

The complete determinant transcript has SHA256
`868f3a5d2c37364d7a93986027182bc08b620f98d2ddb6daf7ec945875edea39`.
No predecessor mathematical theorem is re-audited as this contribution.

## Reproduce

From the repository root, with CPython 3.12 and the standard library:

```sh
/Users/nick/git/integer-mult-bounds/.venv/bin/python3.12 -I -W error -B research/signed-leibniz-replay/verify.py
/Users/nick/git/integer-mult-bounds/.venv/bin/python3.12 -I -O -W error -B research/signed-leibniz-replay/verify.py
/Users/nick/git/integer-mult-bounds/.venv/bin/python3.12 -B scripts/research_package.py --package research/signed-leibniz-replay
/Users/nick/git/integer-mult-bounds/.venv/bin/python3.12 -B scripts/check_research_commit.py --package research/signed-leibniz-replay --check-source-history
```

Another CPython 3.12 path may replace the local path. Direct checks print
`PASS_SIGNED_LEIBNIZ_REPLAY` in JSON. The registered launcher prints
`PASS_REGISTERED_RESEARCH_PACKAGE`. Both registered checks have 120-second
limits and take less than five seconds locally. They write no package files.
Set TMPDIR to a chosen scratch directory to place disposable exports there.

To measure a different host, supply a fresh path outside the checkout:

```sh
/Users/nick/git/integer-mult-bounds/.venv/bin/python3.12 -W error -B research/signed-leibniz-replay/benchmark.py --output /absolute/scratch/measurement.json
```

The reference arm runs the original script directly. The scheduled arm runs
`adapter.py --engine scheduled`. Each process has a private empty bytecode
namespace; both use warning-strict execution and disabled bytecode writes.
Source imports in the adapter explicitly bypass cached bytecode.
The benchmark never overwrites an existing output.

## Scope and credit

The measured host is macOS arm64, CPython 3.12.15, with eighteen logical CPUs.
Other work was running; alternating arms expose both to that load. See the
generated receipt for environment and load details. This is one fixed complete
caller and a small local runtime improvement. It is neither a new capacity
theorem nor an independent scientific acceptance of PR5615.

Credit Ali Romman for PR5615's algorithm, independent minor oracle, complete
caller and fixtures; PR5602/5599 and the retained helper, native and compiler
lineage. PR5615 also credits PR5609/5611 and Nick Petalas's earlier PR5115
row preparation. Leibniz expansion and permutation parity are classical.
All predecessor sources and credits retain their bytes.

No new kappa, physical channel, native supplier, selected-frontier change or
complete multiplication theorem is claimed. Native realization, dirty
restoration, caller costs, compiler closure, precision, storage and the five
selected framework assumptions retain their status. No selected cold replay,
Lean or Docker run is required or performed. Independent human and formal
proof-kernel review are unclaimed.

## Open next questions

Can another complete source caller use the same fixed schedules without
reducing its determinant domain? First profile that distinct caller and derive
its exact dimension and arithmetic contract. No broader caller or performance
claim is supplied here. A larger determinant domain needs a new storage and
runtime bound before reuse.

[Advance claim](https://github.com/CrocSwap/integer-mult-bounds/discussions/1166#discussioncomment-19299774).
48 changes: 48 additions & 0 deletions research/signed-leibniz-replay/SOURCES.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"schema_version": 1,
"base_commit": "2485805a6d47f36ea83ddde6327d453ac82d44dc",
"files": [
{
"path": "certificates/selected-result.json",
"usage": "provenance",
"git_blob": "d59b5035e7b4cbaa9d688a1d32dd0d6eb79c466a",
"sha256": "9b8d0eea95b3bf0dfcb7938a732a6439b87a2685dec2a5ab9e525b3b34debbfa"
},
{
"path": "docs/research/agent-task-catalog.json",
"usage": "provenance",
"git_blob": "3404fbdd5e7529a0674eef26114b5071e4586cec",
"sha256": "ead6cdc9d0af6d58e8a49744d8ec8c7c15e13d2ba93c276c434bcf9b51b93a81"
},
{
"path": "research/dyadic-helper-channel-capacity/RESULT.json",
"usage": "input",
"git_blob": "a602ab1c755d5d245ed948c9b38d444c5b691c8d",
"sha256": "31975ba943d585843b185bc32ea6a5bff20d9d8f1cca2c041be6e8517c7f91ec"
},
{
"path": "research/dyadic-helper-channel-capacity/SOURCES.json",
"usage": "input",
"git_blob": "187717b4e0d62a8c9101fc3dcf0b85995f67b310",
"sha256": "f480b7e6f7021278faad4bdc6eb0e3909ef673d88c4d9cc836636feacedb7dea"
},
{
"path": "research/dyadic-helper-channel-capacity/capacity.py",
"usage": "input",
"git_blob": "d882eb6d049125c67d4c0d47dced60bf0e181268",
"sha256": "1cd82b0beab7983d955cfc1d1e562af490f90bcaad6e3ec7d07e0c5a33608834"
},
{
"path": "research/dyadic-helper-channel-capacity/verify.py",
"usage": "input",
"git_blob": "dad6052e1c791883e7266c6ad5ec2d6ccc07db77",
"sha256": "d008dcf6de6d76c160989126453371b4cff09beeaab5c523e57ad6d8c6009af7"
},
{
"path": "research/p104-coupled-helper-bases/PROOF.md",
"usage": "input",
"git_blob": "168733f6c486d689e58de15c6c34ce1b5ae6b12d",
"sha256": "d9049aa75f065c3c21b0f55246c433c643584bca8969f2f382a83c425c4a2927"
}
]
}
Loading