Seoryxa / research /exact_ranks.py
PureOne's picture
Release Seoryxa research and verification data
10d1f61 verified
Raw History Blame Contribute Delete
5.66 kB
"""Exact scalar Gram ranks and a second polynomial calculation of the nine-point defect."""
from collections import Counter
from fractions import Fraction
from functools import cache
from itertools import product
from math import prod
import sympy as sp
def dot(u, v):
return sum(x * y for x, y in zip(u, v))
def difference(u, v):
return tuple(x - y for x, y in zip(u, v))
SOLIDS = {
"triangle": ([(2, -1, -1), (-1, 2, -1), (-1, -1, 2)], (2, 3)),
"square": ([(a, b, 0) for a, b in product((-1, 1), repeat=2)], (2, 4)),
"tetrahedron": ([v for v in product((-1, 1), repeat=3) if prod(v) == 1], (3, 4)),
"octahedron": ([tuple(s if i == j else 0 for i in range(3))
for j in range(3) for s in (-1, 1)], (4, 6)),
"cube": (list(product((-1, 1), repeat=3)), (4, 6)),
}
NINE = [tuple(s if i == j else 0 for i in range(3))
for j in range(3) for s in (1, 2, -3)]
@cache
def solid_kernel(degree, inner, radius_product):
if degree == 0:
return Fraction(1)
if degree == 1:
return Fraction(inner)
previous = solid_kernel(degree - 1, inner, radius_product)
previous2 = solid_kernel(degree - 2, inner, radius_product)
return ((2 * degree - 1) * inner * previous
- (degree - 1) * radius_product * previous2) / degree
def pair_statistics(first, second):
return Counter((dot(u, v), dot(u, u) * dot(v, v)) for u in first for v in second)
def h_series(degree, weights):
a, b = weights
return sum((degree - a * i) % b == 0 for i in range(degree // a + 1))
def orbit_gram_scan(max_degree=36):
tables = {}
for name, (points, weights) in SOLIDS.items():
shells = {}
for x in points:
for y in points:
if x != y:
u = difference(x, y)
shells.setdefault(dot(u, u), []).append(u)
# For these five regular figures, each fixed-distance directed shell is one orbit.
families = [shells[key] for key in sorted(shells)] + [points]
stats = [[pair_statistics(a, b) for b in families] for a in families]
rows = []
for degree in range(1, max_degree + 1):
gram = sp.Matrix([[sum(count * solid_kernel(degree, *key)
for key, count in cell.items()) for cell in row]
for row in stats])
ambient = h_series(degree, weights)
static = int(gram[0, 0] != 0)
all_chords = gram[:-1, :-1].rank()
synchronous = gram.rank()
assert static <= all_chords <= synchronous <= ambient
rows.append(dict(degree=degree, allowed=ambient, edge=static,
complete_chords=int(all_chords), synchronous=int(synchronous)))
tables[name] = rows
expected = {"triangle": (3, 9), "square": (4, 8), "tetrahedron": (3, 15),
"octahedron": (12, 24), "cube": (12, 36)}
for name, (first_static, first_sync) in expected.items():
rows = tables[name]
assert next(r["degree"] for r in rows if r["edge"] < r["allowed"]) == first_static
assert next(r["degree"] for r in rows if r["synchronous"] < r["allowed"]) == first_sync
return tables
def partitions3(n):
if n < 0:
return []
return [(a, b, n - a - b) for a in range(n + 1) for b in range(a, n + 1)
if b <= n - a - b]
def nine_polynomial_scan(max_degree=24):
# The coefficient of every monomial is constant on coordinate permutations.
# One row at each orbit representative suffices to impose the Laplacian.
rows = []
for degree in range(max_degree + 1):
basis = partitions3(degree)
lap_rows = []
for low in partitions3(degree - 2):
row = [0] * len(basis)
for index in range(3):
high = list(low)
high[index] += 2
row[basis.index(tuple(sorted(high)))] += high[index] * (high[index] - 1)
lap_rows.append(row)
lap = sp.Matrix(lap_rows) if lap_rows else sp.zeros(0, len(basis))
harmonic_dimension = len(basis) - lap.rank()
# Vanishing on z=0, x=0, y=0 removes coefficients with a zero exponent.
odd_candidates = [i for i, exponent in enumerate(basis) if min(exponent) > 0]
restricted = lap.extract(range(lap.rows), odd_candidates)
kernel_dimension = len(odd_candidates) - restricted.rank()
theory = h_series(degree - 3, (4, 6)) if degree >= 3 else 0
assert harmonic_dimension == degree // 3 + 1
assert kernel_dimension == theory
rows.append(dict(degree=degree, allowed=int(harmonic_dimension),
pair_plane=int(harmonic_dimension - kernel_dimension),
missing=int(kernel_dimension)))
return rows
def direct_cubic_witness():
# Check two symmetric cubic harmonics and their restrictions explicitly.
x, y, z = sp.symbols("x y z")
linear = x + y + z
radius2 = x*x + y*y + z*z
second = 5 * (x**3 + y**3 + z**3) - 3 * radius2 * linear
for polynomial in [x*y*z, second]:
assert sp.expand(sum(sp.diff(polynomial, v, 2) for v in (x, y, z))) == 0
assert second.subs({x: 1, y: 0, z: 0}) == 2
assert all((x*y*z).subs(v, 0) == 0 for v in (x, y, z))
return {"invisible": "xyz", "visible_independent_harmonic":
"5(x^3+y^3+z^3)-3(x^2+y^2+z^2)(x+y+z)"}
if __name__ == "__main__":
tables = orbit_gram_scan()
print({k: next(r for r in v if r['synchronous'] < r['allowed']) for k, v in tables.items()})
print(nine_polynomial_scan()[3], direct_cubic_witness())