""" Ramsey FINAL v2 - type-separated, certificate-checked re-execution. For each multiplier-invariant space: A) every candidate tested: local K_s count (#K_s through vertex 0) B) candidates with count>0 -> 'clique-rejected'; track MIN (compare to claim) C) candidates with count=0 -> must contain independent t-set (alpha>=t); searcher must return an explicit certificate, which we edge-scan verify. Verdict: paper's 'no (s,t)-free candidate' holds iff C never fails. Also: min over (B) == claimed best_violations? """ import json, re, os, sys, time, random sys.setrecursionlimit(100000) BODIES = r"C:\Users\jack\rc_corpus\bodies" FULL = lambda n: (1 << n) - 1 def rot(x,k,n): return x if k==0 else ((x<>(n-k))) & FULL(n) def popcount(x): return bin(x).count("1") def class_orbits(n,a): cls={} for r in range(1,n//2+1): cls[r]=r; cls[n-r]=r seen=set(); orbs=[] for r in range(1,n//2+1): if r in seen: continue o=set(); x=r while True: c=cls[x] if c in o: break o.add(c); x=(a*x)%n orbs.append(o); seen|=o return orbs def adj_from_m0(m0,n): return [rot(m0,v,n) for v in range(n)] def local_Ks_count(adj,m0,s): """#K_s through vertex 0 = #K_{s-1} in N(0).""" N=m0 if s==3: cnt=0 for u in bits_iter(N): cnt+=popcount(adj[u]&N&((1<budget_s: raise TO() if len(C)>=t: return list(C) order,bounds=color_sort(P) for i in range(len(order)-1,-1,-1): if len(C)+bounds[i]>w & 1: return False return True def brute_alpha_small(adj,n): import itertools for k in range(n,0,-1): for sub in itertools.combinations(range(n),k): if all(not(adj[a]>>b&1) for a,b in itertools.combinations(sub,2)): return k return 0 # ---- validate searcher at operating point on small ground truths ---- rng=random.Random(11); val_ok=0; val_n=0; certs_ok=0 for _ in range(40): n=rng.choice([12,13,14,15,16]) S=set(rng.sample(range(1,n//2+1), rng.randint(2,5))) m0=0 for c in S: m0|=(1<\s*(\d+)x",sp["invariant_under"]).group(1)) orbs=class_orbits(n,a); k=len(orbs) orb_masks=[sum((1<0: if min_clique is None or lv