#!/usr/bin/env python3 """Exact finite checks for the literal inputs printed in the manuscript. Uses the Python standard library only. Independent of repository recipes, NumPy, saved expanded sequences and previously generated certificates. """ import json # BEGIN_T_INPUT T = { 631: (458, 21, [ (0, 1), (1, 1), (2, -3), (3, 3), (4, 3), (5, 1), (6, -4), (7, 1), (8, -4), (9, 2), (10, -2), (12, 1), (13, -1), (14, 2), (17, 4), (18, -1), (20, 3), (23, 2), (24, 1), (25, -1), (26, -1), (27, 3), (28, -2), (35, 3), (36, -4), (46, -2), (50, -2), (52, -3), (56, 4), (70, 2), (140, -4), ]), 127: (22, 9, [ (0, 1), (1, 1), (2, 3), (3, 1), (4, -1), (5, 4), (8, 2), (10, -2), (11, 4), (13, -1), (16, 1), (20, -2), (23, -3), (33, 3), (39, -2), ]), } # END_T_INPUT # BEGIN_W_INPUT W = { 3: ('+++', '+--', '+--', '+--'), 7: ('+--++--', '+-+--+-', '++----+', '+------'), 9: ('+---++---', '+--+--+--', '+-+----+-', '++------+'), 13: ('++++-+--+-+++', '+---+-++-+---', '++---+--+---+', '++---+--+---+'), 17: ('+---+++----+++---', '++-+---+--+---+-+', '+--+-++++++++-+--', '+-++-+++--+++-++-'), 23: ('++---+---+-++-+---+---+', '+-++-++--++++++--++-++-', '+++---++-+-++-+-++---++', '+++-+++-+------+-+++-++'), 29: ('+++---++--+-+----+-+--++---++', '+-+---++--+-++++++-+--++---+-', '++++-++-+---++++++---+-++-+++', '++--+--+-+++-++++-+++-+--+--+'), 31: ('++++++-+--+---++++---+--+-+++++', '+--++---+-+-++----++-+-+---++--', '+--++---+-+-++----++-+-+---++--', '+-----+-++-+++----+++-++-+-----'), 37: ('+--+-+-+-++---+--++++--+---++-+-+-+--', '+---++-++--+-+-++----++-+-+--++-++---', '+++++-+-----++----++----++-----+-++++', '+--+++-+-----+----++----+-----+-+++--'), 39: ('+++--+-+-----+--++----++--+-----+-+--++', '+++--++-+---+-+--+----+--+-+---+-++--++', '++++---+--++----+-+--+-+----++--+---+++', '+---++-+-+-----+++-++-+++-----+-+-++---'), 43: ('++---++++-+--+--++--------++--+--+-++++---+', '+++-+-++--+-+-++++-+----+-++++-+-+--++-+-++', '++-++++++----+-+--++-++-++--+-+----++++++-+', '+---++--++++-+-+++-++--++-+++-+-++++--++---'), 51: ('+---+++-++-+-+++--+++++--++--+++++--+++-+-++-+++---', '----+++-++-+-+++--+++++--++--+++++--+++-+-++-+++---', '-+--+----+-+++-+-+++++--+--+--+++++-+-+++-+----+--+', '-+--+----+-+++-+-+++++--+--+--+++++-+-+++-+----+--+'), 61: ('++--+--++--+-+-++++--+-----+------+-----+--++++-+-+--++--+--+', '++--+--++--+-+-++++--+-----+------+-----+--++++-+-+--++--+--+', '+---+-+-++++---++--+-++-+---++++++---+-++-+--++---++++-+-+---', '++++-+-+----+++--++-+--+-+++------+++-+--+-++--+++----+-+-+++'), } # END_W_INPUT # BEGIN_PRIMES def prime(n): if n < 2: return False d = 2 while d*d <= n: if n % d == 0: return False d += 1 return True assert all(prime(n) for n in (127, 631, 885923, 9314821)) # END_PRIMES # BEGIN_T_CHECK for p, (mu, m, data) in T.items(): assert pow(mu, m, p) == 1 assert all(pow(mu, k, p) != 1 for k in range(1, m)) b = [None] * p b[0] = (1, 0, 0, 0) assert data[0] == (0, 1) for r, t in data[1:]: assert 0 < r < p and 1 <= abs(t) <= 4 j, sign = abs(t)-1, (1 if t > 0 else -1) for k in range(m): u = (r * pow(mu, k, p)) % p assert b[u] is None a = 0 if j == 0 else 1 + (j-1+k) % 3 b[u] = tuple(sign if i == a else 0 for i in range(4)) assert all(v is not None and sum(z*z for z in v) == 1 for v in b) for s in range(p): c = sum(b[x][j] * b[(x+s) % p][j] for x in range(p) for j in range(4)) assert c == (p if s == 0 else 0) # END_T_CHECK # BEGIN_W_CHECK for w, words in W.items(): assert len(words) == 4 assert all(len(h) == w and set(h) <= {'+', '-'} for h in words) rows = [[1 if z == '+' else -1 for z in h] for h in words] assert all(h[x] == h[-x % w] for h in rows for x in range(w)) for s in range(w): c = sum(h[x] * h[(x+s) % w] for h in rows for x in range(w)) assert c == (4*w if s == 0 else 0) # END_W_CHECK # The five stronger recurrence starters. starters = { 13: ( '+-++++-', '+-++++-', '+--++--', '---++--', ), 17: ( '+--++++--', '+--++++--', '+-+----+-', '--+----+-', ), 61: ( '++++++-+--+---++++---+--+-+++++', '-+++++-+--+---++++---+--+-+++++', '+--++---+-+-++----++-+-+---++--', '+--++---+-+-++----++-+-+---++--', ), 101: ( '+---+++-++-+-+++--+++++--++--+++++--+++-+-++-+++---', '----+++-++-+-+++--+++++--++--+++++--+++-+-++-+++---', '-+--+----+-+++-+-+++++--+--+--+++++-+-+++-+----+--+', '-+--+----+-+++-+-+++++--+--+--+++++-+-+++-+----+--+', ), 121: ( '++--+--++--+-+-++++--+-----+------+-----+--++++-+-+--++--+--+', '++--+--++--+-+-++++--+-----+------+-----+--++++-+-+--++--+--+', '+---+-+-++++---++--+-++-+---++++++---+-++-+--++---++++-+-+---', '----+-+-++++---++--+-++-+---++++++---+-++-+--++---++++-+-+---', ), } for q, words in starters.items(): w = (q + 1) // 2 assert len(words) == 4 assert all(len(h) == w and set(h) <= {'+', '-'} for h in words) a = [[1 if z == '+' else -1 for z in h] for h in words] assert all(h[x] == h[-x % w] for h in a for x in range(w)) minus = [[a[0][x] - a[1][x] for x in range(w)], [a[2][x] - a[3][x] for x in range(w)]] plus = [[a[0][x] + a[1][x] for x in range(w)], [a[2][x] + a[3][x] for x in range(w)]] for s in range(w): def corr(rows): return sum(h[x] * h[(x+s) % w] for h in rows for x in range(w)) assert corr(minus) == (4 if s == 0 else 0) assert corr(plus) == (4*q if s == 0 else 0) # Literal order-13 pair printed in the manuscript. A_WORDS = ('+------------', '---+++++++---', '----++++++--+', '---+++-+++--+', '---++++-++--+', '--++--++--+++', '-++-+---++++-', '-+++--++--+-+', '-++-++--+-++-', '-+-+--++--+++', '-++--+--++++-', '-+++--++---++', '-++-++---+++-') B_WORDS = ('+++++++++++++', '+++++++------', '+++----+++--+', '+---++-+--+++', '+--+--+-++++-', '+-+++---+-+-+', '+-+-+-+--+-++', '+-+--+++-++--', '+-++-+-++--+-', '++-+-+---+-++', '++---++-+-+-+', '++--+-+++--+-', '++-++--+-++--') A = [[1 if z == '+' else -1 for z in h] for h in A_WORDS] B = [[1 if z == '+' else -1 for z in h] for h in B_WORDS] assert len(A) == len(B) == 13 assert all(len(h) == 13 for h in A+B) def dot(x, y): return sum(a*b for a, b in zip(x, y)) for i in range(13): for j in range(13): assert dot(A[i], B[j]) == dot(B[i], A[j]) assert dot(A[i], A[j]) + 3*dot(B[i], B[j]) == 52*(i == j) print(json.dumps({"all_checks_passed": True, "T_lengths": sorted(T), "Williamson_orders": sorted(W), "strong_starters": 5, "cubic_seed_order": 13, "known_Paley_parameters_prime": [885923, 9314821]}))