#!/usr/bin/env python3 """Does the re-scoped next-step space contain ANY deficit-capable row? Proven (return #1267 Thm 3): d = A - B <= floor(2A/p). Hence d >= 2 requires p <= A. For an R-set, write p_min(R) = smallest admissible prime (<=97, coprime to P, not in R). If p_min(R) > A(R) then EVERY admissible p satisfies p > A, so d <= 1 for that R-set. Reads hard_rows_readingB.json (every (R, hard-p) row of the M<=3e8 named cells). """ import json from collections import defaultdict PR=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97] rows=json.load(open("hard_rows_readingB.json")) by=defaultdict(list) for r in rows: by[(r['P'],r['k'],tuple(r['R']))].append(r) def pmin(P,R): R=set(R) return min(q for q in PR if P%q!=0 and q not in R) nrows=len(rows); cap_rows=[r for r in rows if r['p']<=r['A']] print(f"hard rows (p<=2A) in the named re-scoped space: {nrows}") print(f"deficit-capable rows (p<=A, the PROVEN prerequisite for d>=2): {len(cap_rows)}") print(f" their sum(Mp) = {sum(r['Mp'] for r in cap_rows):.4e}") print() bad=[] for (P,k,R),rs in sorted(by.items()): A=rs[0]['A']; pm=pmin(P,R) if pm<=A: bad.append((P,k,R,A,pm)) print(f"R-sets in the space: {len(by)}") print(f"R-sets with p_min(R) <= A(R) (i.e. d>=2 not excluded by the proven bound): {len(bad)}") for b in bad[:20]: print(" ", b) print() print("Per cell: max A, min over R-sets of p_min(R), and whether any R-set admits p<=A") cell=defaultdict(lambda:{'Amax':0,'pmin':10**9,'cap':0,'n':0}) for (P,k,R),rs in by.items(): c=cell[(P,k)]; A=rs[0]['A']; pm=pmin(P,R) c['Amax']=max(c['Amax'],A); c['pmin']=min(c['pmin'],pm); c['n']+=1 if pm<=A: c['cap']+=1 for key in sorted(cell): c=cell[key] print(f" P={key[0]:6d} |R|={key[1]}: R-sets={c['n']:5d} max A={c['Amax']:3d} " f"min p_min={c['pmin']:3d} R-sets admitting p<=A: {c['cap']}")