#!/usr/bin/env python3 """Job #2546 -- independent checks for the prior-art report on return #153. No corpus validator is reused. Three independent checks: A. The factor identity (4) and the sign rule (5) of research/global-factor-signs.md, exact in the free Z-module on {log p} (elements are dicts prime -> Fraction). G is built from the *ungrouped* definition G(n) = Lambda_{>W}(n) - sum_{r|n, r>W, r 1: f[n] = f.get(n, 0) + 1 return f def divisors(n): ds = [1] for p, e in factor(n).items(): ds = [d * p ** k for d in ds for k in range(e + 1)] return sorted(ds) def mu(n): f = factor(n) return 0 if any(e > 1 for e in f.values()) else (-1) ** len(f) W = 30 D = 400 def rho(d): """A non-degenerate divisor profile supported on d < W with rho(1)=1. The serving note's (4)-(5) are stated for any rho supported on d < b = W. rho(d) = d is chosen so that F(s) = prod_{p|s}(1-p) is not identically 0; rho(1)=1 is forced by G(p)=0 at every prime p > W. """ return Fraction(d) if d < W else Fraction(0) def F(m): return sum(mu(d) * rho(d) for d in divisors(m)) def s_of(n): f = factor(n) s = 1 for p, e in f.items(): if p <= W: s *= p ** e return s def t_of(n): f = factor(n) t = 1 for p, e in f.items(): if p > W: t *= p ** e return t def H(n): """log t_W(n) in Z[log p].""" return {p: Fraction(e) for p, e in factor(t_of(n)).items()} def Lambda_gt_W(n): if len(factor(n)) == 1 and next(iter(factor(n))) > W: return lam(n) return {} def G_ungrouped(n): """gfs (3): G(n) = Lambda_{>W}(n) - sum_{r|n, r>W} Lambda(r) F(n/r). The r=n term is INCLUDED (it is the "Lambda term is the r=n correction" of the note); (4) absorbs it into E_W. gca (8) instead excludes r=n, which differs from (3) by Lambda_{<=W}(n) and hence agrees on regular n. """ out = {} for r in divisors(n): if r > W: out = add(out, mul_scalar(lam(r), F(n // r))) return add(Lambda_gt_W(n), mul_scalar(out, -1)) def G_gca8(n): """gca (8): G(n) = -sum_{r|n, r>W, r W and r < n: out = add(out, mul_scalar(lam(r), F(n // r))) return mul_scalar(out, -1) def E_W(n): out = {} for p, e in factor(n).items(): if p <= W: for j in range(2, e + 1): if p ** j > W: out = add(out, mul_scalar(lam(p), F(n // p ** j))) return out def G_grouped(n): return add(add(Lambda_gt_W(n), mul_scalar(H(n), -F(s_of(n)))), mul_scalar(E_W(n), -1)) def is_regular(n): return all(p ** e <= W or p > W for p, e in factor(n).items()) def check_A(): bad4 = bad5 = 0 nreg_comp = nreg_pp = nreg_disc = 0 for n in range(2, D): if G_ungrouped(n) != G_grouped(n): bad4 += 1 print(" (4) FAILS at n =", n, G_ungrouped(n), G_grouped(n)) if is_regular(n): nreg_disc += 1 if G_ungrouped(n) != G_gca8(n): bad5 += 1 print(" (3)/(8) disagree on regular n =", n) if is_regular(n) and len(factor(n)) > 1 and t_of(n) > 1: rhs = mul_scalar(H(n), -F(s_of(n))) if G_ungrouped(n) != rhs: bad5 += 1 print(" (5) FAILS at n =", n) nreg_comp += 1 if is_regular(n) and len(factor(n)) == 1 and t_of(n) > 1: # regular proper prime power p^k > W: G = -(k-1) log p p, k = next(iter(factor(n).items())) rhs = mul_scalar(lam(p), -(k - 1)) if G_ungrouped(n) != rhs: bad5 += 1 print(" (5)-pp FAILS at n =", n) nreg_pp += 1 print(f"A: identity (4): {D-2} values of n checked, {bad4} failures") print(f"A: sign rule (5): {nreg_comp} regular composites + {nreg_pp} " f"regular proper prime powers, {bad5} failures") print(f"A: (3) vs gca (8): identical on all {nreg_disc} regular n") assert bad4 == 0 and bad5 == 0 and nreg_comp > 50 and nreg_pp > 0 def check_B(): P = [101, 103, 107, 109, 113, 127, 131, 137, 139, 149] a, b, q = 4_000_000, 6_000_000, 10_000_019 assert all(is_prime(p) for p in P) and is_prime(q) pairs = [P[i] * P[j] for i in range(10) for j in range(i + 1, 10)] triples = [P[i] * P[j] * P[k] for i in range(10) for j in range(i + 1, 10) for k in range(j + 1, 10)] quads = [P[i] * P[j] * P[k] * P[l] for i in range(10) for j in range(i + 1, 10) for k in range(j + 1, 10) for l in range(k + 1, 10)] print(f"B: max pair {max(pairs)} < a={a}; max triple {max(triples)} < a; " f"min quadruple {min(quads)} > b={b}") # every subset product lands either below a (< b) or above b, so rho=1 or 0 s = 1 for p in P: s *= p Fval = sum((-1) ** k * comb(10, k) for k in range(4)) print(f"B: F(s) = 1-10+45-120 = {Fval}; pair-trigger RHS = " f"{sum(1 for x in pairs if x > a)} (zero for every K)") assert max(pairs) < a and max(triples) < a and min(quads) > b assert Fval == -84 == (-1) ** 3 * comb(9, 3) # closed form and growth: depth-3 Bonferroni partial sum = (-1)^3 C(r-1,3) for r in (10, 50, 500): val = sum((-1) ** k * comb(r, k) for k in range(4)) assert val == (-1) ** 3 * comb(r - 1, 3) print(f"B: r={r:4d} F={val:>12d} |F|/C(r,2)={(abs(val)/comb(r,2)):8.3f}") print("B: |F|/C(r,2) = (r-3)/3 -> infinity, so no constant K exists") def is_prime(n): if n < 2: return False d = 2 while d * d <= n: if n % d == 0: return False d += 1 return True def check_C(): """GKM arXiv:1606.06781v4, (1.5)-(1.6), symbolically. n = p1 p2 p3 m with m = q a prime > p3. With f(t) = t^3 and h_j = log p_j/log R, (1.6) reads M_f(n;R) = (-1)^r sum_{d|m} mu(d) Delta^{(r)} f(log d/log R; h_1..h_r), where Delta^{(r)} f(x;h) = sum_{A subset [r]} (-1)^{r-|A|} f(x + sum_{j in A} h_j). Every squarefree divisor of n is a subset product of {p1,p2,p3,q}, so M_f(n;R) = sum_{D subset} (-1)^{|D|} f(log prod(D)/log R). """ R = Symbol('R', positive=True) ps = [symbols(f'p{i}', positive=True) for i in (1, 2, 3)] pm = symbols('q', positive=True) lR = log(R) f = lambda t: t ** 3 def Delta(r, x, hs): from itertools import combinations tot = 0 for size in range(r + 1): for A in combinations(range(r), size): tot += (-1) ** (r - size) * f(x + sum(hs[j] for j in A)) return tot hs = [log(p) / lR for p in ps] allp = ps + [pm] lhs = 0 for bits in range(16): D = 1 for j in range(4): if bits >> j & 1: D *= allp[j] lhs += (-1) ** bin(bits).count('1') * f(log(D) / lR) rhs = sum((-1) ** bin(bits).count('1') * Delta(3, log(D) / lR, hs) for bits, D in ((0, 1), (1, pm))) * (-1) ** 3 diff = expand(simplify(lhs - rhs)) print("C: GKM (1.6) residual LHS - RHS =", diff) assert diff == 0 if __name__ == "__main__": check_A() check_B() check_C() print("ALL CHECKS PASSED")