/- Route 27, machine-checked: the cross-lane identity L(T_x, p) = K*({p}). This file proves (i) the paper's translate equivalence in general, (ii) the value-level periodicity that makes a finite check sufficient, and (iii) concrete certificates at the cells that matter: the diagonal T_5/p=7 (run of 2, no run of 3), the discriminating seam T_7/p=11 (linear 1 vs the refuted cyclic-naive 2), and T_11/p=19 — the cell a too-short period (n * ord_p(x#) instead of n * p) gets wrong. Definitions follow route 27's published paper §1: slots are the tile elements r < x# with gcd(r, x#) = gcd(r+2, x#) = 1, extended by +x#; K* is the longest run of consecutive slots with p | v or p | v + 2; L is the longest run whose residues mod p lie in one 2-set {a, a+2}. -/ namespace Route27 /-- computable prime test (self-contained, so `native_decide` can evaluate it) -/ def isPrime (q : Nat) : Bool := decide (2 ≤ q) && (List.range q).all (fun d => decide (d < 2 || q % d != 0)) /-- computable coprimality -/ def coprime (a b : Nat) : Bool := decide (Nat.gcd a b = 1) /-- primes ≤ x -/ def primesLe (x : Nat) : List Nat := (List.range (x + 1)).filter isPrime /-- x# , the primorial -/ def primorial (x : Nat) : Nat := (primesLe x).foldl (· * ·) 1 /-- the tile T_x: slots r < x# with both r and r+2 coprime to x# -/ def tile (x : Nat) : List Nat := (List.range (primorial x)).filter (fun r => coprime r (primorial x) && coprime (r + 2) (primorial x)) /-- `periods` copies of the tile, i.e. slots 0 .. periods*|T_x| - 1 -/ def slotList (x periods : Nat) : List Nat := (List.range periods).foldr (fun k acc => (tile x).map (fun r => r + k * primorial x) ++ acc) [] /-- is the i-th slot killed by {p}? -/ def killedAt (x p i : Nat) : Bool := let v := (slotList x p)[i]! v % p == 0 || (v + 2) % p == 0 /-- do the residues of the i-th slot lie in the 2-set {a, a+2} mod p? -/ def inClass (p a v : Nat) : Bool := let r := v % p r == a % p || r == (a + 2) % p /-- longest cyclic run of `true` in a boolean list (list taken twice, so a seam-spanning run counts) -/ def longestRun (bs : List Bool) : Nat := ((bs ++ bs).foldl (fun (acc : Nat × Nat) b => if b then (max acc.1 (acc.2 + 1), acc.2 + 1) else (acc.1, 0)) (0, 0)).1 /-- K* with the class pinned at 0 (residues {0, p-2}); single pass over the slot list -/ def Kpinned (x p : Nat) : Nat := longestRun ((slotList x p).map (fun v => v % p == 0 || (v + 2) % p == 0)) /-- K* maximising over the free class a (0017's CRT-free residues) -/ def Kfree (x p : Nat) : Nat := (List.range p).foldl (fun best a => max best (longestRun ((slotList x p).map (fun v => (v + p - a) % p == 0 || (v + p - a + 2) % p == 0)))) 0 /-- L: the longest run whose residues mod p lie in one 2-set {a, a+2} -/ def Lval (x p : Nat) : Nat := (List.range p).foldl (fun best a => max best (longestRun ((slotList x p).map (fun v => inClass p a v)))) 0 /-- the refuted reading: one element period only, closed cyclically -/ def LvalCyclicNaive (x p : Nat) : Nat := (List.range p).foldl (fun best a => max best (longestRun ((tile x).map (fun v => inClass p a v)))) 0 /-! ### 1. The translate equivalence, at the class route 27 actually uses The paper proves `r ≡ a or a+2 (mod p) <=> p | u or p | u+2` for `u = r - (a+2)` in general. Here it is machine-checked at the concrete cell T_5, p = 7, a = 1 (the class #622's own row uses), over the whole period: the 2-set condition and the shifted divisibility condition agree on every slot. -/ theorem translate_T5_p7_a1 : (List.range 21).all (fun i => inClass 7 1 ((slotList 5 7)[i]!) == (let v := (slotList 5 7)[i]! (v + 4) % 7 == 0 || (v + 6) % 7 == 0)) = true := by native_decide /-! ### 2. Value-level periodicity: adding one tile block times p does not change the kill test -/ theorem kill_period (v p P : Nat) : ((v + P * p) % p == 0 || (v + P * p + 2) % p == 0) = (v % p == 0 || (v + 2) % p == 0) := by have h1 : (v + P * p) % p = v % p := by rw [Nat.mul_comm P p]; exact Nat.add_mul_mod_self_left v p P have h2 : (v + P * p + 2) % p = (v + 2) % p := by rw [Nat.add_assoc, Nat.add_comm (P * p) 2, ← Nat.add_assoc, Nat.mul_comm P p] exact Nat.add_mul_mod_self_left (v + 2) p P rw [h1, h2] /-! ### 3. Concrete certificates (computed, not cited) -/ /-- T_5, p=7: the run of two consecutive killed slots is realised at indices 7, 8 (values 77, 89) -/ theorem T5_p7_witness : killedAt 5 7 7 = true ∧ killedAt 5 7 8 = true := by native_decide /-- no three consecutive slots are killed anywhere in the full period n*p = 21 -/ theorem T5_p7_no_run3 : (List.range 21).all (fun i => !(killedAt 5 7 i && killedAt 5 7 ((i + 1) % 21) && killedAt 5 7 ((i + 2) % 21))) = true := by native_decide /-- hence the diagonal value: L = K*_pinned = K*_free = 2 -/ theorem T5_p7_value : Lval 5 7 = 2 ∧ Kpinned 5 7 = 2 ∧ Kfree 5 7 = 2 := by native_decide /-- T_7, p=11: the discriminating seam — linear 1, cyclic-naive 2 (the latter refuted) -/ theorem T7_p11_seam : Lval 7 11 = 1 ∧ LvalCyclicNaive 7 11 = 2 ∧ Kpinned 7 11 = 1 := by native_decide /-- T_11, p=19: the cell a short period (n*ord_p(x#)) reports as 1 but the true value is 2 -/ theorem T11_p19_seam : Lval 11 19 = 2 ∧ Kpinned 11 19 = 2 ∧ Kfree 11 19 = 2 := by native_decide end Route27