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
5 changes: 5 additions & 0 deletions research/p112-free-sink-audit97/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ histogram and 4,030 minors. Controls report `mathematical=6 package=5`.
Python standard library only; no solver, NumPy or native compiler required.
Use `verify.py --write` to regenerate the certificate.

After `research/p112-signed-modular-production/`, `independent.py` uses the
proved modulo-521 signed recovery for eligible minors (identical receipts;
rational fallback retained). Pairwise Fraction-only bytes are vendored in that
production package's `baseline.py`.

The immutable input inventory in SOURCES.json is exact: missing or extra
entries fail. Text hashes normalize CRLF to LF. BASE-SELECTED.json freezes
context at base `2921874911956718fcaaaf9396fe8267b3cfa9f0`; replay does not
Expand Down
58 changes: 57 additions & 1 deletion research/p112-free-sink-audit97/independent.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
The source-pin and geometry readers are shared, but this checker does not
call the producer's row-code basis, modular elimination, Bareiss or build.
Contributor @woklerx with substantial OpenAI Codex assistance.

Production path: after research/p112-signed-modular-production/,
fraction_determinant uses the proved modulo-521 signed recovery from
research/p112-signed-modular86/ when rows are eligible, with the original
rational elimination retained as fallback. Pairwise Fraction-only bytes are
vendored in that production package's baseline.py.
"""
import importlib.util
import json
Expand All @@ -16,8 +22,12 @@
spec.loader.exec_module(source)
require = source.require

PRIME = 521
if not all(PRIME % d for d in range(2, 23)):
raise ValueError('fixed modulus is not prime')

def fraction_determinant(rows):

def rational_determinant(rows):
a = [list(map(Fraction, row)) for row in rows]
answer = Fraction(1)
for col in range(len(a)):
Expand All @@ -37,6 +47,52 @@ def fraction_determinant(rows):
return int(answer)


def _eligible(rows):
n = len(rows)
return n <= 8 and all(
len(row) == n and all(type(x) is int for x in row) and sum(x * x for x in row) <= 4
for row in rows
)


def _recover(residue, modulus, bound):
if modulus <= 2 * bound or not 0 <= residue < modulus:
raise ValueError('insufficient modulus or invalid residue')
result = residue if residue <= modulus // 2 else residue - modulus
if abs(result) > bound:
raise ValueError('balanced determinant exceeds checked Hadamard bound')
return result


def _modular_determinant(rows):
n = len(rows)
a = [[x % PRIME for x in row] for row in rows]
answer = 1
for k in range(n):
pivot = next((i for i in range(k, n) if a[i][k]), None)
if pivot is None:
return 0
if pivot != k:
a[k], a[pivot] = a[pivot], a[k]
answer = -answer
value = a[k][k]
answer = answer * value % PRIME
inv = pow(value, -1, PRIME)
for i in range(k + 1, n):
factor = a[i][k] * inv % PRIME
if factor:
for j in range(k + 1, n):
a[i][j] = (a[i][j] - factor * a[k][j]) % PRIME
a[i][k] = 0
return _recover(answer, PRIME, 2 ** n)


def fraction_determinant(rows):
if not _eligible(rows):
return rational_determinant(rows)
return _modular_determinant(rows)


def audit(certificate):
lines, decoder = source.geometry()
words = {0}
Expand Down
17 changes: 17 additions & 0 deletions research/p112-signed-modular-production/NOTICE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Notice

Production wiring of the proved modulo-521 signed-determinant kernel into
`research/p112-free-sink-audit97/independent.py`.

## Credit

- woklerx / [CrocSwap/integer-mult-bounds#1144](https://github.com/CrocSwap/integer-mult-bounds/pull/1144)
(`research/p112-signed-modular86/`): proved opt-in modulo-521 recovery with
identical free-sink audit receipts and Hadamard envelope controls.
- woklerx / [CrocSwap/integer-mult-bounds#1035](https://github.com/CrocSwap/integer-mult-bounds/pull/1035)
(`research/p112-free-sink-audit97/`): exact independent Fraction audit.
- Joel Pulikkan (PR620) and DreamingOfClouds (PR595): free-sink geometry model.
- martinxxx9 (PR976): related modular rank acceleration for a different auditor.

Prepared by Wentao Li (VictorLiwentao, @Is__Victor, wentaol4@illinois.edu)
with substantial AI assistance. Apache-2.0.
96 changes: 96 additions & 0 deletions research/p112-signed-modular-production/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# Production signed modular determinants for the P112 free-sink audit

**Tooling improvement; no new kappa.** At base
`0b1cccf86e2f5132ed286a26ef0a681a495740ea`,
`research/p112-free-sink-audit97/independent.py` still computed every signed
minor with rational `Fraction` elimination. woklerx’s opt-in adapter
`research/p112-signed-modular86/` (incorporated
[#1144](https://github.com/CrocSwap/integer-mult-bounds/pull/1144)) already
proved a modulo-521 kernel that recovers each full signed determinant inside a
checked Hadamard envelope, with identical complete audit receipts. This package
wires that equivalent rewrite into the **production** independent checker.

The original rational elimination is retained as `rational_determinant` and as
the fallback for rows outside the envelope. Pairwise Fraction-only bytes are
vendored in `baseline.py`. The opt-in package vendors the same baseline for its
reference engine.

## Reproduce

Python **3.12**, standard library only, from the repository root:

```sh
python3.12 -I -B research/p112-signed-modular-production/verify.py
python3.12 -I -O -B research/p112-signed-modular-production/verify.py
python3.12 -B scripts/research_package.py --package research/p112-signed-modular-production
taskset -c 0 python3.12 -I -B research/p112-signed-modular-production/benchmark.py --rounds 5 --write-result
```

Expected:

```text
PASS_P112_SIGNED_MODULAR_PRODUCTION cases=28560 minors=4030 signed_matrices=19767 controls=… no_new_kappa
PASS_REGISTERED_RESEARCH_PACKAGE research/p112-signed-modular-production outcome=completed
PASS_IDENTICAL_P112_SIGNED_MODULAR_PRODUCTION_RECEIPTS
```

Default verify is read-only. Temp-copy certificate determinant-flip foil rejects
via audit failure. Package gates under `-O` still load checkers with
`compile(..., optimize=0)`. Full `make verify`, selected cold replay, Lean, and
multiplication-theorem obligations were not rerun for this isolated
historical-checker change.

## Result

On Linux / CPython 3.12.3 with `taskset -c 0`, five alternating in-process pairs
over the complete 28,560-case / 4,030-minor audit gave median wall time
**0.681 → 0.143 s (4.754×)** with per-round ratios **4.618–4.880×**. Details are
in [`RESULT.json`](RESULT.json). Timing is host-descriptive and is not a
correctness gate. Every audit receipt matches the pairwise baseline.

## Why the modular path is equivalent

Every frozen square minor has dimension at most eight and integer rows of
squared Euclidean norm at most four. Hadamard’s inequality gives
`|det A| ≤ 2^n ≤ 256`. Modulus 521 is prime and greater than twice 256, so
balanced modular recovery uniquely determines the signed integer determinant.
Inputs outside the envelope retain the original rational routine. See
`research/p112-signed-modular86/PROOF.md`.

## Open next questions

1. **Question:** Should other historical Fraction-only minor auditors that share
the same E8 root-line envelope adopt the same modulo-521 recovery?
**Why it matters:** Related sink / joint-frame auditors still pay rational
elimination on bounded integer minors.
**First step:** List auditors that already check `n≤8` and row-norm `≤4` on
every fast-path call.
**Blocked by:** One-object stop rule.

2. **Question:** Should `research/p112-signed-modular86` be marked superseded as
an opt-in monkey-patch now that production ships the modular path?
**Why it matters:** The opt-in still usefully vendors the Fraction baseline
and engine controls.
**First step:** Decide whether maintainers prefer a provenance note or a
soft-deprecation banner.
**Blocked by:** Maintainer preference.

## Overlap and credit

Closest priors (different delivery):

- `research/p112-signed-modular86/` / [#1144](https://github.com/CrocSwap/integer-mult-bounds/pull/1144)
— opt-in modulo-521 signed recovery; this is the production wiring.
- [CrocSwap/integer-mult-bounds#756](https://github.com/CrocSwap/integer-mult-bounds/pull/756)
— identical-receipt tooling quality bar.
- Leave-alone tooling through [#2412](https://github.com/CrocSwap/integer-mult-bounds/pull/2412)
and pending `cursor/omission-lanes-production-60b9` / deferred
`ck-dyadic-replay-production` / `scalar-fused-dyadic-production` were not
reopened. Related mod-101 rank work (#976) does not recover these signed
determinants.

Credit Joel Pulikkan / DreamingOfClouds (geometry), woklerx (exact free-sink
audit and opt-in modular kernel), and martinxxx9 (related modular rank tooling).
Prepared by Wentao Li ([VictorLiwentao](https://github.com/VictorLiwentao),
[Is__Victor](https://x.com/Is__Victor)) with substantial AI assistance.
Apache-2.0.
47 changes: 47 additions & 0 deletions research/p112-signed-modular-production/RESULT.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"schema_version": 1,
"status": "PASS_IDENTICAL_P112_SIGNED_MODULAR_PRODUCTION_RECEIPTS",
"package": "research/p112-signed-modular-production",
"base_commit": "0b1cccf86e2f5132ed286a26ef0a681a495740ea",
"workload": "complete P112 free-sink independent audit (28560 cases, 4030 signed minors)",
"rounds": 5,
"baseline_seconds": [
0.6967329520000476,
0.6670023249999986,
0.6874446699999908,
0.67393680400005,
0.6814277839999932
],
"production_seconds": [
0.1427796609999632,
0.14443707299994912,
0.14335003200005758,
0.1412491000000955,
0.14388054099993042
],
"per_round_ratio": [
4.879777323467851,
4.61794407174281,
4.795566909951681,
4.771264411593378,
4.736066317684493
],
"median_baseline_seconds": 0.6814277839999932,
"median_production_seconds": 0.14335003200005758,
"median_speedup": 4.7535935255300075,
"min_per_round_ratio": 4.61794407174281,
"max_per_round_ratio": 4.879777323467851,
"audit_receipt": {
"cases": 28560,
"rank_histogram": {
"7": 448,
"8": 28112
},
"exact_minors": 4030
},
"baseline_sha256": "46806efe1ee7744c810a69981d471b42dfceaa336fee226991c55ba1edfd129f",
"production_sha256": "c77cf3dd1234c26cfb7df2d356752721e8b1b37169f20543678fe2f4d07a53f8",
"python": "3.12.3 (main, Aug 31 2026, 10:18:26) [GCC 13.3.0]",
"platform": "Linux-6.12.94+-x86_64-with-glibc2.39",
"note": "Host-descriptive; not a correctness gate. Times cover audit() after module load (geometry, code coverage, all exact minors/cases); exclude interpreter startup and package pin hashing. Receipts identical each round."
}
43 changes: 43 additions & 0 deletions research/p112-signed-modular-production/SOURCES.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"schema_version": 1,
"base_commit": "0b1cccf86e2f5132ed286a26ef0a681a495740ea",
"files": [
{
"path": "certificates/selected-result.json",
"usage": "provenance",
"git_blob": "ae6a99f28aa468649eb66a361e764d769363bf11",
"sha256": "10b9e340fd8e354a37a0c4813c90e5de1dd42044b5f6aca4a3fc5a42b685fa32"
},
{
"path": "docs/research/agent-task-catalog.json",
"usage": "provenance",
"git_blob": "06c96f5579bb67ed1b86d334e78fbed7da6945f1",
"sha256": "6686ad58f1fbdbc87134a78901b60fd53a20d3984355e91defbbebc9e9fa8075"
},
{
"path": "research/p112-free-sink-audit97/independent.py",
"usage": "provenance",
"git_blob": "c65f3fbfe130a4f8cf07b9d2fa4d180cde2957c5",
"sha256": "46806efe1ee7744c810a69981d471b42dfceaa336fee226991c55ba1edfd129f",
"note": "Pairwise-era Fraction-only bytes at base_commit; working tree carries the modulo-521 rewrite. Live equivalence uses package baseline.py plus working production path."
},
{
"path": "research/p112-free-sink-audit97/CERTIFICATE.json",
"usage": "input",
"git_blob": "fd4959b7d21eb835f6638a4ead69125891b2297b",
"sha256": "45abf8c46b54ab752a16573cc6e03a225a6d76a853b093f186d52bd2b51ec9c6"
},
{
"path": "research/p112-free-sink-audit97/verify.py",
"usage": "input",
"git_blob": "686a8fd137da8a406a552064cb9312a3930bc2d3",
"sha256": "91dbe1ad0fa7c4b46ef571cccb7eb5f7a2239995f889147277ea6719674adc5b"
},
{
"path": "research/p112-signed-modular86/engine.py",
"usage": "input",
"git_blob": "ed6238bf53751e319a88e5d65cc5c3b040740745",
"sha256": "b74c6dd99e9cad0eb4cb252c810acea74c1cba979c7766d194933e4bc35a35fa"
}
]
}
70 changes: 70 additions & 0 deletions research/p112-signed-modular-production/TASK.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{
"schema_version": 1,
"task_id": "replay-runtime",
"priority_revision": 4,
"base_commit": "0b1cccf86e2f5132ed286a26ef0a681a495740ea",
"chooser_seed": "8855876a99eb27f1d1fbdeca162a1663",
"original_card": {
"id": "replay-runtime",
"question": "Can one measured replay bottleneck be sped up without dropping coverage?",
"starting_points": [
"scripts/run_isolated_tests.py",
"scripts/verify_replay_coverage.py",
"certificates/selected-result.json"
],
"methods": [
"Profile one isolated replay and optimize the measured bottleneck.",
"Design source-bound reuse with explicit dependency invalidation and negative controls."
],
"acceptance_gate": "Report before/after wall time on the same fixture, retained checks and invalidation behavior.",
"first_step": {
"command": [
"python3",
"-B",
"scripts/research_baseline.py"
],
"expected": "PASS_RESEARCH_BASELINE_BINDINGS_ONLY",
"inspect": "Read the selected reproduction command and choose a single replay stage for profiling.",
"scope": "Positive control / source-bound orientation only; this is not a new construction or full cold replay."
},
"first_experiment": "Measure one unchanged fixture, preserve check coverage, and test one optimization with invalidation controls.",
"bottleneck_link": "Faster trustworthy replays increase review throughput and let mechanism candidates be checked sooner.",
"allowed_variations": [
"Profile one stage or design one source-bound cache boundary."
],
"scope_change_triggers": [
"Skipping coverage or comparing different fixtures to claim speedup."
],
"overlap_terms": [
"replay runtime",
"cache invalidation",
"isolated tests"
]
},
"scope_status": "refined",
"actual_scope": "Can the production p112-free-sink-audit97 independent.py adopt the proved modulo-521 signed-determinant kernel from research/p112-signed-modular86/ so the shipped free-sink audit is faster while every case/minor receipt stays identical, without reopening leave-alone tooling through #2412 or pending omission-lanes / deferred dyadic production packages?",
"scope_change_reason": "The catalogue card asks for one measured replay bottleneck with before/after wall time and retained checks. Expertise override selected verifier-engineering after surveying remaining proved opt-in adapters. Leave-alone objects through #2412, pending cursor/omission-lanes-production-60b9, and deferred ck-dyadic-replay-production / scalar-fused-dyadic-production were skipped. woklerx's merged #1144 opt-in already proved ~3.87\u00d7 (host remeasure ~4.4\u00d7) with identical receipts; production independent.py still used Fraction elimination. This session wires that equivalent rewrite into the shipped checker, vendors pairwise baseline bytes, and retargets the opt-in reference to the vendored baseline.",
"bottleneck_link": "Side result on review throughput: the P112 free-sink independent audit is reused by historical sink tooling. A faster identical receipt does not change kappa or the binding complex supplier.",
"budget_minutes": 60,
"stop_rule": "Ship an equivalence-preserving production independent.py modular-determinant change with frozen baseline, identical audit outcomes, corruption controls, pin discipline, registered replay and a measured before/after median clearly above ~1.5\u00d7 with stable per-round ratios. Do not invent kappa, reopen leave-alone objects, or open an upstream CrocSwap PR from this worker.",
"outcome": "completed",
"evidence": "PASS_P112_SIGNED_MODULAR_PRODUCTION via research/p112-signed-modular-production/verify.py (also under -O); PASS_REGISTERED_RESEARCH_PACKAGE; PASS_IDENTICAL_P112_SIGNED_MODULAR_PRODUCTION_RECEIPTS via pinned-CPU benchmark.py --rounds 5 (median 0.681\u21920.143 s, 4.754\u00d7; per-round 4.618\u20134.880\u00d7); opt-in p112-signed-modular86 retargeted to vendored baseline.py.",
"author": "Wentao Li",
"github": "VictorLiwentao",
"email": "wentaol4@illinois.edu",
"ai_assistance": "Substantial AI assistance for orientation, overlap search, profiling, production wiring, packaging, benchmarking and writing. Not independent human peer review.",
"open_questions": [
{
"question": "Should other historical Fraction-only minor auditors that share the same E8 root-line envelope adopt the same modulo-521 recovery?",
"why_it_matters": "Related sink / joint-frame auditors still pay rational elimination on bounded integer minors.",
"first_step": "List auditors that already check n\u22648 and row-norm \u22644 on every fast-path call.",
"blocked_by": "Out of this session's one-object stop rule."
},
{
"question": "Should research/p112-signed-modular86 be marked superseded as an opt-in monkey-patch now that production ships the modular path?",
"why_it_matters": "The opt-in still usefully vendors the Fraction baseline and engine controls.",
"first_step": "Decide whether maintainers prefer a provenance note or a soft-deprecation banner.",
"blocked_by": "Maintainer preference."
}
]
}
25 changes: 25 additions & 0 deletions research/p112-signed-modular-production/VERIFY.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"schema_version": 1,
"status": "ready",
"python": "3.12",
"requirements": [],
"inputs": [
"research/p112-signed-modular-production/baseline.py",
"research/p112-free-sink-audit97/independent.py",
"research/p112-free-sink-audit97/CERTIFICATE.json",
"research/p112-free-sink-audit97/verify.py",
"research/p112-signed-modular86/engine.py"
],
"commands": [
{
"argv": ["{python}", "-I", "-B", "{package}/verify.py"],
"timeout_seconds": 300,
"checks": "Exact baseline copy of the base-commit independent.py; production equals the modulo-521 transform; identical complete audit outcomes; temp-copy certificate determinant-flip corruption control; duplicate JSON-key check; read-only default verify."
},
{
"argv": ["{python}", "-I", "-O", "-B", "{package}/verify.py"],
"timeout_seconds": 300,
"checks": "Same equivalence and pin discipline under -O (require() gates remain; checkers load with compile(..., optimize=0))."
}
]
}
Loading
Loading