"""JAM 4: exact transition collisions for both L=6, M=54 states. The earlier probe checked only whether an identified state occurred in generations with different ignition outcomes. A predictive quotient also requires the identified histories to have the same next state. These two witnesses live on Hofstadter Q's single realized trajectory. """ M = 54 L = 6 Q_PAIR = (188_410, 1_404_394) E_PAIR = (95, 191) N = max(*Q_PAIR, *E_PAIR) + 1 q = [0] * (N + 1) q[1] = q[2] = 1 for n in range(3, N + 1): a = n - q[n - 1] b = n - q[n - 2] assert 1 <= a < n and 1 <= b < n q[n] = q[a] + q[b] def generation_of(n: int) -> int: k = 2 while 3 * (1 << k) <= n: k += 1 return k def phase(n: int) -> int: return (3 * (1 << generation_of(n)) - n) % M def q_descriptor(n: int) -> tuple[int, ...]: tail = tuple(q[j] % M for j in range(n - L + 1, n + 1)) return (phase(n), *tail) def error_descriptor(n: int) -> tuple[int, ...]: tail = tuple( (2 * q[j] - j) % (2 * M) for j in range(n - L + 1, n + 1) ) return (phase(n), *tail) def show(name, pair, descriptor, next_residue): a, b = pair state_a, state_b = descriptor(a), descriptor(b) next_a, next_b = descriptor(a + 1), descriptor(b + 1) assert state_a == state_b assert next_a != next_b print(name) print(f" positions: {a}, {b}") print(f" common state: {state_a}") print( " next incoming residues:", next_residue(a + 1), next_residue(b + 1), ) print(f" next states differ: {next_a != next_b}") show( "D_Q = (phase, last six Q values mod 54)", Q_PAIR, q_descriptor, lambda n: q[n] % M, ) show( "D_e = (phase, last six doubled errors mod 108)", E_PAIR, error_descriptor, lambda n: (2 * q[n] - n) % (2 * M), ) print("VERDICT: both L=6, M=54 descriptors fail next-transition consistency.")