# Question: do the independently executed T29 spectra match #161, and does # equal-residue adjacency supply a counterexample to #201's per-gap iff? import json,re,math,hashlib from pathlib import Path p=Path(__file__).parent lines=(p/'T29-check.txt').read_text().splitlines();archive=(p/'original/out-L-ext.txt').read_text() expected={31:{1:413380422,2:7999018,3:12992,4:4},37:{1:422845276,2:3285526,3:374},41:{1:427334298,2:1041576},113:{1:429417406,2:22},127:{1:429417450}} checked=[] for line in lines: if not line.startswith('p '):continue q=int(line.split()[1]);spec={int(k):int(v) for k,v in re.findall(r'(\d+):(\d+)',line)} assert spec==expected[q] if q!=127: table=next(x for x in archive.splitlines() if re.match(r'\s*p='+str(q)+r'\s',x));captured={int(k):int(v) for k,v in re.findall(r'(\d+):(\d+)',table)};assert spec==captured else: row=next(x for x in archive.splitlines() if re.match(r'\s+127\s',x));assert row.split()[-1]=='1' checked.append({'p':q,'spectrum':spec,'matches_captured':True}) W=6469693230;s=6693131;t=6693317;q=31;g=t-s assert math.gcd(s,W)==math.gcd(s+2,W)==math.gcd(t,W)==math.gcd(t+2,W)==1 interior=[] for n in range(s+1,t): a=math.gcd(n,W);b=math.gcd(n+2,W);assert a>1 or b>1 interior.append([n,a,b]) assert g==186 and s%q==t%q and (g*g-4)%q==27 lift=(-s*pow(W,-1,q))%q;A=s+lift*W;B=t+lift*W;assert A%q==B%q==0 and 0<=lift