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
2 changes: 1 addition & 1 deletion research/copied-fixed/certificate.json
Original file line number Diff line number Diff line change
Expand Up @@ -17769,7 +17769,7 @@
"research/copied-fixed/comparison-pr46.json": "f7a34054403075c51289e58b583c05ff42c43e72d286b9c3ff4fc5ae7f4bca44",
"research/copied-fixed/comparison-pr47.json": "d15ecc820d540a2bfea10bc7d72688240aea89245ff27de263b1de0e74e4273a",
"research/copied-fixed/data-corners.json": "82dc2d3e116fc003348d6e9ff0cce90fd70d3d6c156580b769ff3d38b3399e17",
"research/copied-fixed/data_corners.cpp": "d134f43d31b896daf504511991be8608c6ba9d20a6606c57e2e12d4b203b7d44",
"research/copied-fixed/data_corners.cpp": "406a850d496589cd1216eb709baa84fdd8633048b648f05022ae184d1f279448",
"research/copied-fixed/data_recovery.py": "0de7e0fc4f38b066ec319e4dde43bce8f20edd207be9f9736610babf95030253",
"research/copied-fixed/links-23.uses": "b215350929d15711b502cdcf5878aeedb2cc7dc81dc764977a28d37ece17f86f",
"research/copied-fixed/links-25.uses": "80dd63ea393931211bece7a44329a9da4e2936575cdc3f48c27690bedc2ad0ae",
Expand Down
5 changes: 4 additions & 1 deletion research/copied-fixed/data_corners.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,12 @@ int main(){
for(int j=c+1;j<d;j++)if(available[j]){assert(!M[i][j]);zeros++;}
determinant=mul(determinant,value);checked++;available[c]=false;
int inv=power(value,prime-2);
int columns[d],length=0;
for(int j=0;j<d;j++)if(available[j]&&M[i][j])columns[length++]=j;
for(int r=i+1;r<d;r++)if(M[r][c]){
int ratio=mul(M[r][c],inv);
for(int j=0;j<d;j++)if(available[j]&&M[i][j]){
for(int k=0;k<length;k++){
int j=columns[k];
int z=M[r][j]-mul(ratio,M[i][j]);M[r][j]=z<0?z+prime:z;
}
M[r][c]=0;
Expand Down
12 changes: 8 additions & 4 deletions research/data-corner-performance/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
# Exact data-corner replay with cached update columns

**Tooling improvement; no new κ or construction claim.** This optional runner
accelerates the historical `research/copied-fixed/data_corners.cpp` checker.
It preserves the complete domain of 4,073,300 pairs of triples, every existing
assertion, and the complete output receipt, including all ten modular failures.
At the recorded base, the selected #626/#543 conditional result was
proved a per-pivot cached update-column loop for the historical
`research/copied-fixed/data_corners.cpp` checker. After
`research/data-corner-production/`, that loop is the **production** default;
this package vendors the pairwise-era source as `baseline.cpp` and differential
replays baseline versus production. It preserves the complete domain of
4,073,300 pairs of triples, every existing assertion, and the complete output
receipt, including all ten modular failures. At the recorded base, the selected
#626/#543 conditional result was
κ = 51110230636731/31250000000000000 = 0.001635527380375392.

## Reproduce
Expand Down
16 changes: 11 additions & 5 deletions research/data-corner-performance/SOURCE.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
{
"base_commit": "66849e1475c930fd7732b1a0067ffee7e1e95f60",
"sha256": {
"research/copied-fixed/data_corners.cpp": "d134f43d31b896daf504511991be8608c6ba9d20a6606c57e2e12d4b203b7d44",
"research/copied-fixed/data-corners.json": "82dc2d3e116fc003348d6e9ff0cce90fd70d3d6c156580b769ff3d38b3399e17"
"research/data-corner-performance/baseline.cpp": "d134f43d31b896daf504511991be8608c6ba9d20a6606c57e2e12d4b203b7d44",
"research/copied-fixed/data-corners.json": "82dc2d3e116fc003348d6e9ff0cce90fd70d3d6c156580b769ff3d38b3399e17",
"research/copied-fixed/data_corners.cpp": "406a850d496589cd1216eb709baa84fdd8633048b648f05022ae184d1f279448"
},
"git_blob": {
"research/copied-fixed/data_corners.cpp": "251f6c87cca42619a0c1b6d83705df5cad0e9c33",
"research/copied-fixed/data-corners.json": "4cb7a2b26fc48afd020b7966c43fd30cf2321514"
}
"research/data-corner-performance/baseline.cpp": "251f6c87cca42619a0c1b6d83705df5cad0e9c33",
"research/copied-fixed/data-corners.json": "4cb7a2b26fc48afd020b7966c43fd30cf2321514",
"research/copied-fixed/data_corners.cpp": "51cef05c6ebfd86a5c3784c644492dcc9ae1ce3c"
},
"provenance_sha256": {
"research/copied-fixed/data_corners.cpp@pre-production": "d134f43d31b896daf504511991be8608c6ba9d20a6606c57e2e12d4b203b7d44"
},
"note": "After research/data-corner-production/, working data_corners.cpp is the cached-column production source. baseline.cpp vendors the pairwise-era bytes; replay compares baseline vs production without re-transforming production."
}
77 changes: 77 additions & 0 deletions research/data-corner-performance/baseline.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
// Exhaustive rational nonvanishing certificates via a proved finite prime.
// Adapted from Rohan Arun PR39 geometry.cpp, with James Chang PR34's pivots.
// Both factors are now fixed I+J; every one of the 4,073,300 triple pairs is
// checked. A failed residue test gets a charged 47-singleton fallback.
// Zero identities are proved separately by the inherited exact rank cuts.
// Apache-2.0. Prepared with OpenAI Codex assistance.
#include <cstdint>
#include <iostream>
#include <vector>
#include <array>
#include <cassert>
using namespace std;
constexpr int prime=1000003,a=23,b=25,d=47;
int mul(int x,int y){return int(int64_t(x)*y%prime);}
int power(int x,int n){int z=1;for(;n;n>>=1,x=mul(x,x))if(n&1)z=mul(z,x);return z;}
int main(){
for(int i=2;i*i<=prime;++i)assert(prime%i);
vector<int> R,C,piv;
for(int i=0;i<a;i++)R.push_back(i),C.push_back(i);
R.push_back(a-1);C.push_back(0);
for(int i=0;i<a;i++)R.push_back(i),C.push_back(i);
piv.push_back(2*a);
for(int i=1;i<a-1;i++)piv.push_back(i+a+1);
for(int i=a-1;i<a+5;i++)piv.push_back(2*a-i);
for(int i=a+5;i<2*a-1;i++)piv.push_back(i-a-3);
piv.push_back(1);piv.push_back(0);
assert(piv.size()==d);
const int xin=mul(3*(a+1),power(2*(3*(a+1)-10),prime-2));
const int xout=prime-mul(a+1,power(5,prime-2));
const int yin=mul(3*(b+1),power(2*(3*(b+1)-10),prime-2));
const int yout=prime-mul(b+1,power(5,prime-2));
int count=0,good=0;int64_t checked=0,zeros=0;
vector<array<int,7>> rejected;
cout<<"{\"prime\":"<<prime<<",\"dimensions\":[23,25],\"records\":[\n";
int records=0;
for(int aa=0;aa<a;aa++)for(int bb=aa+1;bb<a;bb++)for(int cc=bb+1;cc<a;cc++){
int xs[a];for(int i=0;i<a;i++)xs[i]=(i==aa||i==bb||i==cc)?xin:xout;
int rowgood=0,product=1;
for(int u=0;u<b;u++)for(int v=u+1;v<b;v++)for(int w=v+1;w<b;w++){
int ys[b],M[d][d];bool available[d];
for(int i=0;i<b;i++)ys[i]=(i==u||i==v||i==w)?yin:yout;
for(int i=0;i<d;i++){available[i]=true;for(int j=0;j<d;j++){
int z=prime-1;if(R[i]==C[j])z+=xs[R[i]];
if(i%b==(a*b-d+j)%b)z+=ys[i%b];M[i][j]=z%prime;
}}
bool ok=true;int determinant=1;
for(int i=0;i<d;i++){
int c=piv[i],value=M[i][c];assert(available[c]);
if(!value){rejected.push_back({aa,bb,cc,u,v,w,i});ok=false;break;}
for(int j=c+1;j<d;j++)if(available[j]){assert(!M[i][j]);zeros++;}
determinant=mul(determinant,value);checked++;available[c]=false;
int inv=power(value,prime-2);
for(int r=i+1;r<d;r++)if(M[r][c]){
int ratio=mul(M[r][c],inv);
for(int j=0;j<d;j++)if(available[j]&&M[i][j]){
int z=M[r][j]-mul(ratio,M[i][j]);M[r][j]=z<0?z+prime:z;
}
M[r][c]=0;
}
}
count++;
if(ok){good++;rowgood++;product=mul(product,determinant);}
}
assert(product);
if(records++)cout<<",\n";
cout<<"["<<aa<<","<<bb<<","<<cc<<","<<rowgood<<","<<product<<"]";
if(records%250==0)cerr<<"checked first triples "<<records<<" of 1771\n";
}
assert(count==4073300 && records==1771);
cout<<"\n],\"pairs\":"<<count<<",\"good\":"<<good<<",\"fallback\":"<<rejected.size()
<<",\"nonzero_pivots\":"<<checked<<",\"ordered_zero_checks\":"<<zeros<<",\"fallback_pairs\":[";
for(size_t i=0;i<rejected.size();i++){
if(i)cout<<",";cout<<"[";
for(int j=0;j<7;j++){if(j)cout<<",";cout<<rejected[i][j];}cout<<"]";
}
cout<<"]}\n";
}
19 changes: 14 additions & 5 deletions research/data-corner-performance/replay.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
#!/usr/bin/env python3
"""Source-pinned, opt-in replay of the complete historical data-corner check."""
"""Source-pinned replay of the historical data-corner check.

After research/data-corner-production/, working
research/copied-fixed/data_corners.cpp already carries the cached-column loop.
This runner vendors the pairwise-era source as baseline.cpp and compares it to
production without re-applying the transform to the working tree.
"""
import argparse
from hashlib import sha256
import json
Expand Down Expand Up @@ -79,16 +85,19 @@ def main():
require(args.benchmark >= 0, 'Negative benchmark pair count')
require(not args.output or not args.output.exists(), 'Output already exists')
manifest, blobs = admitted_inputs()
source = blobs['research/copied-fixed/data_corners.cpp'].decode()
baseline = blobs['research/data-corner-performance/baseline.cpp'].decode()
production = blobs['research/copied-fixed/data_corners.cpp'].decode()
require(production == transform(baseline),
'production data_corners.cpp must equal transform(baseline.cpp)')
expected = json.loads(blobs['research/copied-fixed/data-corners.json'])
compiler = shlex.split(os.environ.get('CXX', 'c++'))
version = subprocess.check_output([*compiler, '--version'], text=True)
samples = []
with tempfile.TemporaryDirectory(prefix='data-corner-') as directory:
work = Path(directory)
compile_program(transform(source), work / 'optimized', compiler)
compile_program(production, work / 'optimized', compiler)
if args.benchmark:
compile_program(source, work / 'original', compiler)
compile_program(baseline, work / 'original', compiler)
common_stdout = None
for pair in range(args.benchmark or 1):
modes = (['original', 'optimized'] if pair % 2 == 0 else
Expand All @@ -102,7 +111,7 @@ def main():
print(f'PASS pair={pair} {mode} wall={sample["wall_seconds"]:.3f}s', flush=True)
evidence = dict(status='PASS_DATA_CORNER_REPLAY', base_commit=manifest['base_commit'],
source_sha256=manifest['sha256'], implementation_sha256=sha256(Path(__file__).read_bytes()).hexdigest(),
generated_source_sha256=sha256((GUARD + transform(source)).encode()).hexdigest(),
generated_source_sha256=sha256((GUARD + production).encode()).hexdigest(),
platform=platform.platform(), python=platform.python_version(), compiler=compiler,
compiler_version=version, flags=['-O3', '-std=c++17'],
coverage={k: expected[k] for k in ('pairs', 'good', 'fallback', 'nonzero_pivots', 'ordered_zero_checks')},
Expand Down
6 changes: 4 additions & 2 deletions research/data-corner-performance/test_replay.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,11 @@ def setUpClass(cls):
cls.directory = tempfile.TemporaryDirectory(prefix='corner-controls-')
cls.work = Path(cls.directory.name)
_, cls.blobs = replay.admitted_inputs()
cls.source = cls.blobs['research/copied-fixed/data_corners.cpp'].decode()
cls.source = cls.blobs['research/data-corner-performance/baseline.cpp'].decode()
cls.production = cls.blobs['research/copied-fixed/data_corners.cpp'].decode()
cls.expected = json.loads(cls.blobs['research/copied-fixed/data-corners.json'])
optimized = replay.transform(cls.source)
assert cls.production == replay.transform(cls.source)
optimized = cls.production
variants = dict(original=cls.source, optimized=optimized,
reversed=optimized.replace('for(int k=0;k<length;k++)', 'for(int k=length-1;k>=0;k--)'),
missing_left=optimized.replace('columns[length++]=j;', 'if(j>c)columns[length++]=j;'))
Expand Down
18 changes: 18 additions & 0 deletions research/data-corner-production/NOTICE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Attribution and license

Prepared by Wentao Li ([VictorLiwentao](https://github.com/VictorLiwentao),
[@Is__Victor](https://x.com/Is__Victor), wentaol4@illinois.edu) with substantial
AI assistance for orientation, overlap search, profiling, production wiring,
packaging, benchmarking and writing. Not independent human peer review.
Apache-2.0; see the repository root `LICENSE`.

The cached update-column algorithm and its equivalence argument were introduced
in the opt-in adapter `research/data-corner-performance/` (see that package's
NOTICE.md). This package wires an equivalent loop into the production
`research/copied-fixed/data_corners.cpp` path used by
`make copied-fixed-verify`.

The historical copied-fixed data-corner checker, receipt and certificate lineage
retain their original author credits in `research/copied-fixed/SOURCE.json` and
`research/copied-fixed/PROOF.md`. Upstream material retains its own source
notices and license.
108 changes: 108 additions & 0 deletions research/data-corner-production/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
# Production cached update columns for the historical data-corner checker

**Tooling improvement; no new kappa.** At base
`0fdd7d82de03e43c9e5a1000dfbcd380d1b687d2`,
`research/copied-fixed/data_corners.cpp` still rescanned all 47 columns for
every lower-row update. The opt-in adapter `research/data-corner-performance/`
already proved an exact per-pivot cached-column list with identical receipts.
This package wires that equivalent loop into the **production** checker used by
`research/copied-fixed/producer.py` / `make copied-fixed-verify`.

Only the `local_sha256` entry for `research/copied-fixed/data_corners.cpp`
changes inside `research/copied-fixed/certificate.json`. The complete domain of
4,073,300 pairs, every assertion, modular fallback recovery and the pinned
`data-corners.json` receipt stay identical. Selected frontier untouched.

The pairwise-era digest in `research/data-corner-performance/SOURCE.json` is
demoted: that package now vendors `baseline.cpp` and treats working
`data_corners.cpp` as the optimized production source, so research-packages /
local replay do not fail working-source drift.

## Reproduce

Python **3.12**, a C++17 compiler (`CXX`, default `c++`), standard library only,
from the repository root:

```sh
python3.12 -I -B research/data-corner-production/verify.py
python3.12 -I -O -B research/data-corner-production/verify.py
python3.12 -B scripts/research_package.py --package research/data-corner-production
python3.12 -I -B research/data-corner-production/benchmark.py --rounds 5 --out /tmp/data-corner-production-result.json
```

Expected:

```text
PASS_DATA_CORNER_PRODUCTION pairs=4073300 good=4073290 fallback=10 corruption=… certs=1 no_new_kappa
PASS_REGISTERED_RESEARCH_PACKAGE research/data-corner-production outcome=completed
PASS_IDENTICAL_DATA_CORNER_PRODUCTION_RECEIPTS
```

Default verify is read-only. Temp-copy column-fill foil rejects via receipt
mismatch or subprocess failure. Package gates under `-O` still launch
assertion-enabled C++ children (`NDEBUG` is rejected at compile time). 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 g++ (taskset CPU 0), five alternating
fresh-process pairs gave median wall time **170.101 → 110.463 seconds
(1.54×)**. Timing is host-descriptive and is not a correctness gate; all
samples and environment pins are in [`RESULT.json`](RESULT.json). Every stdout
receipt matches the pinned `data-corners.json` fieldwise. An unpinned multi-core
screen on the same host was noisier (~1.38×); the reported figure is the pinned
five-pair series.

## Why the cached columns are equivalent

After accepting pivot `(i,c)`, neither `available` nor pivot row `M[i]` changes
during the lower-row update loop. Collecting

```text
columns = [j | available[j] && M[i][j]]
```

once per pivot, then iterating that list for every lower row `r` with
`M[r][c] != 0`, performs the same modular updates in the same column order as
the historical nested scan. See `research/data-corner-performance/README.md`.

## Overlap and credit

Closest priors (different delivery):

- `research/data-corner-performance/` — opt-in cached-column adapter; this is
the production wiring.
- [CrocSwap/integer-mult-bounds#756](https://github.com/CrocSwap/integer-mult-bounds/pull/756)
— identical-receipt tooling quality bar.
- Open leave-alone tooling on other objects (#1922 joint frames, #2039/#2054
shared-point, #2100 ternary, #2117 DisjointTensor, #2150 mixed-point,
#2194/#2210/#2231/#2239/#2257/#2263/#2276 production rewrites; #1076
quadratic-affine) was not reopened. Soft note: #2263/#2276 touch
`e8-bit-r420/MANIFEST.sha256`; this tip does not.

Credit the authors of `research/data-corner-performance/` and the copied-fixed
lineage. Prepared by Wentao Li
([VictorLiwentao](https://github.com/VictorLiwentao),
[@Is__Victor](https://x.com/Is__Victor)) with substantial AI assistance, under
Apache-2.0.

## Open next questions

1. **Question:** Should adjacent historical copies under `research/pair-assembly/`,
`research/skip-strips/`, and `research/split-skip/` adopt the same cached
columns in a follow-up tip?
**Why it matters:** Those trees still pin pairwise-era digests without a
registered VERIFY matrix; a coordinated refresh would remove stale inventory
digests without changing receipts.
**First step:** Diff each `data_corners.cpp` against the production transform
site and list which SOURCE inventories would need provenance demotion.
**Blocked by:** Out of this session’s one-object stop rule.

2. **Question:** Should `make copied-fixed-verify` grow a microbenchmark gate
for the full 4,073,300-pair replay?
**Why it matters:** A future edit could restore the nested scan without
failing equivalence tests.
**First step:** Decide whether RESULT.json medians belong in CI or remain
descriptive.
**Blocked by:** Maintainer CI-budget preference.
Loading
Loading