#!/usr/bin/env python3 """Cycle 64, Gate B -- second-path checks for the in-file proof in FINDINGS.md (the (T-both-odd) closure via (ML-62b)). The proof itself is the in-file argument of FINDINGS.md secs 3-5. This script checks its two load-bearing steps on finite ranges; it proves nothing by itself and no claim in FINDINGS.md rests on it alone. Exact integer arithmetic only. Part A (the Jacobi step, FINDINGS sec 4). Exhaustive over all odd U, V with 1 <= U, V <= 99 and 4 | U+V, and every e1 >= 1 with e1 | (U+V)/4 and gcd(e1, U*V) == 1: - assert U*V % 4 == 3; - assert jacobi(-e1, U*V) == -1; - if v2(e1) is odd, assert U*V % 8 == 7 (the sec 4(iii) step). Part B (the descent divisibility step, FINDINGS sec 3). Exhaustive over all odd U, V with 1 <= U, V <= 45 and every E in {4, 8, ..., 180} with E | U+V: for every odd prime p with p | e1 = E/4, p | U and p*p | e1: - assert p | V (sec 3 step (1)); - assert (E / p^2) | (U/p + V/p) (sec 3 step (4)). Stated bounds: 99 (Part A), 45 and 180 (Part B). No other caps. """ import math def jacobi(a, n): """Jacobi symbol (a / n), n odd positive, exact integers.""" a %= n result = 1 while a != 0: while a % 2 == 0: a //= 2 r = n % 8 if r == 3 or r == 5: result = -result a, n = n, a if a % 4 == 3 and n % 4 == 3: result = -result a %= n if n == 1: return result return 0 def v2(x): c = 0 while x % 2 == 0: x //= 2 c += 1 return c def small_primes(limit): sieve = [True] * (limit + 1) sieve[0] = False sieve[1] = False for i in range(2, limit + 1): if sieve[i]: for j in range(i * i, limit + 1, i): sieve[j] = False return [i for i in range(2, limit + 1) if sieve[i]] def part_a(): cases = 0 odd_v2_cases = 0 for U in range(1, 100, 2): for V in range(1, 100, 2): if (U + V) % 4 != 0: continue s4 = (U + V) // 4 n = U * V assert n % 4 == 3 for e1 in range(1, s4 + 1): if s4 % e1 != 0: continue if math.gcd(e1, n) != 1: continue cases += 1 assert jacobi(-e1, n) == -1, (U, V, e1) if v2(e1) % 2 == 1: odd_v2_cases += 1 assert n % 8 == 7, (U, V, e1) assert cases > 0 and odd_v2_cases > 0 return cases, odd_v2_cases def part_b(): primes = small_primes(180) cases = 0 for U in range(1, 46, 2): for V in range(1, 46, 2): for E in range(4, 181, 4): if (U + V) % E != 0: continue e1 = E // 4 for p in primes: if p == 2: continue if e1 % p != 0 or U % p != 0: continue if e1 % (p * p) != 0: continue cases += 1 assert V % p == 0, (U, V, E, p) assert (U // p + V // p) % (E // (p * p)) == 0, \ (U, V, E, p) assert cases > 0 return cases def main(): a_cases, a_odd = part_a() b_cases = part_b() print("PART A PASS: %d (U, V, e1) cases, jacobi(-e1, U*V) == -1 " "in all; %d cases with v2(e1) odd, U*V %% 8 == 7 in all" % (a_cases, a_odd)) print("PART B PASS: %d (U, V, E, p) cases, descent divisibility " "holds in all" % b_cases) print("ALL CHECKS PASS") main()