"""Independent checks for the December 4 Jordan/divisor factorial manuscript. Python 3 with SymPy; does not import manuscript code or read the research tree. """ from collections import Counter from fractions import Fraction from functools import cache from itertools import combinations, product from math import factorial, gcd, lcm, prod from sympy import Matrix, divisors, factorint, isprime, mobius, primerange from sympy.ntheory.modular import crt FIELD = 1_000_000_007 FAMILIES = ((0, "one"), (0, "tau"), (1, "sigma"), (1, "Jordan"), (2, "sigma"), (2, "Jordan")) def taylor_coefficient(i, j): """Compute [z^(i-j)] by multiplying truncated geometric series.""" coefficients = [1] + [0] * (i - j) for v in range(1, j + 1): for k in range(1, len(coefficients)): coefficients[k] += v * coefficients[k - 1] return coefficients[-1] @cache def values(n): factors = factorint(n) assert prod(p**a for p, a in factors.items()) == n assert all(isprime(p) for p in factors) divisors_of_n = [1] for p, exponent in factors.items(): divisors_of_n = [int(d * p**i) for d in divisors_of_n for i in range(exponent + 1)] result = [] for degree, name in FAMILIES: if name == "one": result.append(1) elif name == "Jordan": result.append(sum(int(mobius(d)) * (n // d)**degree for d in divisors_of_n)) else: result.append(sum(d**degree for d in divisors_of_n)) return result def pivots_and_determinant(rows, prime=FIELD): """Left-to-right elimination; determinant uses just the selected columns.""" matrix = [r.copy() for r in rows] pivots, det = [], 1 for col in range(len(matrix[0])): k = len(pivots) if k == len(matrix): break pivot = next((i for i in range(k, len(matrix)) if matrix[i][col] % prime), None) if pivot is None: continue if pivot != k: matrix[k], matrix[pivot] = matrix[pivot], matrix[k] det = -det q = matrix[k][col] % prime det = det*q % prime inverse = pow(q, -1, prime) for i in range(k + 1, len(matrix)): a = matrix[i][col] * inverse % prime if a: for j in range(col, len(matrix[0])): matrix[i][j] = (matrix[i][j] - a*matrix[k][j]) % prime pivots.append(col) return pivots, det def check_full_grid(): vertices = list(product(range(11), repeat=2)) gap = prod(primerange(2, 61)) center = prod(primerange(61, 121)) p = [center + (u + 11*v - 60) * gap for u, v in vertices] t = [(u + 22*v) * gap for u, v in vertices] shifts = [[(j+1)*n - a for n, a in zip(p, t)] for j in range(3)] assert len(set(shifts[-1])) == len(vertices) assert set(shifts[-1]).isdisjoint(shifts[0] + shifts[1]) assert min(min(level) for level in shifts) > 0 assert all(gcd(i,j)==1 for i,j in combinations(p,2)) assert all(n%6==1 for n in p) rows = [] counts = Counter() for f, (degree, _) in enumerate(FAMILIES): for i in range(degree + 1): if degree == i == 2: continue for j in range(i+1): c = taylor_coefficient(i,j) if c == 0: continue weights = [c * pow(n, i+1, FIELD) * pow(values(n)[f], -1, FIELD) % FIELD for n in p] for s in sorted(set(shifts[j])): rows.append([w if arg == s else 0 for w,arg in zip(weights,shifts[j])]) counts[j] += 1 pivot, det = pivots_and_determinant(rows) free = next(i for i in range(len(vertices)) if i not in pivot) assert counts=={0:66,1:44} and len(rows)==len(pivot)==110 and vertices[free]==(9,7) assert isprime(FIELD) and det print(f"All six functions: {len(rows)} by {len(vertices)}; ranks {len(pivot)} mod {FIELD} and over Q.") print(f"Row blocks {dict(counts)}; pivot minor {det} modulo {FIELD} in this row order; first free vertex {vertices[free]}.") q = 6*prod(n*n for n in p) a = int(crt([6]+[n*n for n in p],[2]+t)[0]) ell = 2**127 - 1 target = shifts[2][free] assert gcd(q,ell)==1 and isprime(ell) and ell>max(map(max,shifts)) for exponent, offset in enumerate([0,ell-target,ell**2-target]): N, period = crt([q,ell**3],[a,offset]) N = int(N+period) assert (N+target) % ell**exponent==0 and (N+target) % ell**(exponent+1) assert all((N+s)%ell for level in shifts for s in level if s!=target) for n,h in zip(p,t): index, remainder = divmod(N-h,n) assert index>0 and not remainder and index%6==2 and index%n==0 assert all(gcd(index+i,n)==1 for i in (1,2,3)) print("All three refinements preserve every CRT constraint and isolate the chosen last shift.") @cache def finite_pair(n,k): ds = tuple(int(d) for d in divisors(n)) return (sum(Fraction(1,d**k) for d in ds), sum(Fraction(int(mobius(d)),d**k) for d in ds)) def finite_means(): ell, step, period = 7, 12*7**3, 360*7**3 ds = [int(d) for d in divisors(period)] total = 0 for k,a,s in product(range(1,6),range(12),(1,2,4)): pairs = [] for r in (0,ell-2,ell**2-2): b = int(crt([12,ell**3],[a,r])[0]) samples = [finite_pair(gcd(n+s,period),k) for n in range(b,period,step)] mean = tuple(sum(vals)/len(samples) for vals in zip(*samples)) # Compute the same finite expectation independently by divisor densities. density_weights = {d: Fraction(gcd(step,d),d**(k+1)) for d in ds if (b+s)%gcd(step,d)==0} expected = (sum(density_weights.values()),sum(int(mobius(d))*w for d,w in density_weights.items())) assert mean == expected pairs.append(mean) (d0,p0),(d1,p1),(d2,p2) = pairs if s==2: x=Fraction(1,ell**k) assert ((d1-d0,p1-p0),(d2-d1,p2-p1)) == ((x*d0,-x*p0),(x*x*d0,0)) assert d0>=1 and p0>0 else: assert pairs[0]==pairs[1]==pairs[2] total += 1 print(f"Reproduced {total} finite triples by enumeration and by divisor-density sums.") def smaller_example(): vs=list(product(range(7),range(5))) p=[64793+210*(i+77*j) for i,j in vs] fractions = [] for axis, levels, fns in ((1, 5, (2, 3, 4, 5)), (0, 7, (4, 5))): for level, family in product(range(levels), fns): fractions.append([ Fraction(n**(2-axis), values(n)[family]) if vertex[axis] == level else Fraction() for vertex, n in zip(vs, p) ]) rows = [[q.numerator * pow(q.denominator, -1, FIELD) % FIELD for q in row] for row in fractions] piv, det = pivots_and_determinant([row[1:] for row in rows]) assert len(piv) == 34 and det == 423522710 # Scale columns to integers and recover the original null vector afterwards. scales = [lcm(*(q.denominator for q in col)) for col in zip(*fractions)] integral = Matrix([[int(scale*q) for scale, q in zip(scales, row)] for row in fractions]) null = integral.to_DM().nullspace().to_Matrix() assert null.shape == (1, 35) original = [int(null[0, i])*scale for i,scale in enumerate(scales)] common = gcd(*original) * (1 if original[0] > 0 else -1) weights = [z//common for z in original] assert all(sum(q*z for q,z in zip(row,weights)) == 0 for row in fractions) assert sum(bool(z) for z in weights) == 34 and len(str(max(map(abs, weights)))) == 462 target = 3*p[0] multipliers = [Fraction(p[0]**3, values(p[0])[family]) for family in (4,5)] assert target == 194379 and multipliers == [Fraction(272009621685257,4198132850), Fraction(272009621685257,4198132848)] # The reduced example imposes no second-position rows for degree one. leftovers = [sum(Fraction(z*n**2,values(n)[f]) for z,n,(u,v) in zip(weights,p,vs) if u==a) for a in range(7) for f in (2,3)] assert any(leftovers) print(f"Supplementary 34 by 35 example: minor omitting first column {det} modulo {FIELD}.") print(f"Its primitive kernel has 34 nonzero entries and a 462-digit maximum magnitude. " f"Last shift {target}; normalized multipliers {multipliers[0]}, {multipliers[1]}.") print(f"Smaller example leaves {sum(bool(v) for v in leftovers)} of 14 degree-one second-position line sums nonzero.") def primitive_counts(): for n in range(1,26): observed=sum(gcd(a,b,n)==1 for a,b in product(range(n),repeat=2)) assert observed==values(n)[5] for k in range(1,10): # n^k in the falling-factorial basis via forward differences at zero. differences = [n**k for n in range(k+1)] blocks = [] for j in range(k+1): blocks.append(Fraction(differences[0],factorial(j))) differences = [b-a for a,b in zip(differences,differences[1:])] assert blocks[0]==0 and sum(blocks) == [1,2,5,15,52,203,877,4140,21147][k-1] print("Primitive-pair counts for 1 through 25, and Bell factors for k=1 through 9, verified.") if __name__ == "__main__": primitive_counts() finite_means() smaller_example() check_full_grid()