# The omitted branch can leave a whole-tile prime set unchanged even though # its per-gap iff and pair count are wrong; check that distinction at T29. import re,json,math from pathlib import Path line=next(x for x in Path('T29-check.txt').read_text().splitlines() if x.startswith('gaps ')) gaps={int(k):int(v) for k,v in re.findall(r'(\d+):(\d+)',line)} ps=[p for p in range(31,1010) if all(p%d for d in range(2,math.isqrt(p)+1))] old=[p for p in ps if any((g*g-4)%p==0 for g in gaps)] new=[p for p in ps if any(g*(g*g-4)%p==0 for g in gaps)] assert old==new;assert max(new)==113 out={'T29_old_and_corrected_resonance_prime_sets_equal':True,'active_primes_above29':new,'last_active_prime':113,'next_prime':127,'per_gap_missing_equal_residue_counts':{str(p):sum(c for g,c in gaps.items() if g%p==0) for p in ps if any(g%p==0 for g in gaps)},'scope':'The per-gap iff is false; the T29 terminal-one onset remains unchanged.'} Path('onset-check.json').write_text(json.dumps(out,indent=2)+'\n')