import Std /-! # Polynomial certificates for the width-five and width-six gap models Use the centre-spacing theorem as input. There are m = w - 2 interior columns. After a centre in column i, starting the next centre in column j requires at least g(i,j) = 4 - max(0,j-i) more rows. The continuation series v_i satisfy (1-x) v_i - sum_j x^g(i,j) v_j = 1. Writing v_i = A_i / Q and H = P / Q for the positive-height board series gives the two polynomial identities below. In particular the aggregate equation is (1-x)P = x Q + x^3 sum_i A_i. All coefficients are checked in the Lean kernel using only 'decide'. The geometric classification of admissible boards is a separate argument. -/ namespace WidthCounts /-- Dense integer coefficients, in ascending order of degree. -/ abbrev Poly := List Int def add : Poly → Poly → Poly | [], q => q | p, [] => p | a :: p, b :: q => (a+b) :: add p q def sub (p q : Poly) : Poly := add p (q.map (- ·)) /-- Coefficients of x^k p, up to trailing zero coefficients. -/ def shift (k : Nat) (p : Poly) : Poly := List.replicate k 0 ++ p def trim (p : Poly) : Poly := (p.reverse.dropWhile (· == 0)).reverse def sum (terms : List Poly) : Poly := terms.foldr add [] def gap (i j : Nat) : Nat := 4 - (j - i) def residual (v : List Poly) (i : Nat) : Poly := let weighted := (List.range v.length).map fun j => shift (gap i j) v[j]! trim (sub (sub v[i]! (shift 1 v[i]!)) (sum weighted)) def aggregateLeft (p : Poly) : Poly := trim (sub p (shift 1 p)) def aggregateRight (q : Poly) (v : List Poly) : Poly := trim (add (shift 1 q) (shift 3 (sum v))) def states5 : List Poly := [[1,0,1,2,0,0,1], [1,0,0,1], [1]] def states6 : List Poly := [[1,1,2,3,0,2,3,0,0,1], [1,0,1,2,0,0,1], [1,0,0,1], [1]] def Q5 : Poly := [1,-1,0,0,-3,0,-1,-3,0,0,-1] def P5 : Poly := [0,1,0,3,3,1,4,3,0,1,1] def Q6 : Poly := [1,-1,0,0,-4,-1,-3,-6,0,-2,-4,0,0,-1] def P6 : Poly := [0,1,0,4,5,4,9,6,2,6,4,0,1,1] set_option maxRecDepth 8192 set_option maxHeartbeats 4000000 theorem widthFiveStateEquations : ∀ i : Fin 3, residual states5 i.val = Q5 := by decide theorem widthSixStateEquations : ∀ i : Fin 4, residual states6 i.val = Q6 := by decide theorem widthFiveOutput : aggregateLeft P5 = aggregateRight Q5 states5 := by decide theorem widthSixOutput : aggregateLeft P6 = aggregateRight Q6 states6 := by decide /-- Constant terms needed for inversion in the ring of formal power series. -/ theorem denominatorConstants : Q5.head? = some 1 ∧ Q6.head? = some 1 := by decide #print axioms widthFiveStateEquations #print axioms widthSixStateEquations #print axioms widthFiveOutput #print axioms widthSixOutput #print axioms denominatorConstants /-- The numerator is that of the positive-height generating function. The following coefficient identity gives coprimality over the rationals. -/ def coprimeWitness (p q : Poly) : Poly := trim (add (shift 1 p) (add q (shift 1 q))) theorem widthFiveBezout : coprimeWitness P5 Q5 = [1] := by decide theorem widthSixBezout : coprimeWitness P6 Q6 = [1] := by decide #print axioms widthFiveBezout #print axioms widthSixBezout end WidthCounts