The counting function of semi-magic squares is a polynomial
ProvedMagicSquares.semi_magic_polynomial_existsExistence and degree, uniformly in the order. For every there is a polynomial , of degree exactly , whose value at each nonnegative integer is the number of semi-magic squares of line sum . The degree is the dimension of the Birkhoff polytope , and the integrality of its vertices is what makes the period one, so that the counting function is a polynomial and not merely a quasi-polynomial. This is the first half of the goal, isolated so that it can be attacked on its own.
import Mathlib import Definitions.Def_MagicSquares open MagicSquares
namespace MagicSquares
theorem semi_magic_polynomial_exists (n : ℕ) (hn : 1 ≤ n) :
∃ p : Polynomial ℚ,
p.natDegree = (n - 1) ^ 2 ∧
∀ t : ℕ, p.eval (t : ℚ) = (semiMagicCount n t : ℚ) := by
sorry
end MagicSquaresRead-back
What the Lean code literally says, in plain math · deepseek-v4.1-flash (WorkBuddy blind sub-agent)
Let be a natural number and assume the hypothesis . Then there exists a polynomial such that two conditions hold. First, the natural degree of equals , where the subtraction is the natural-number subtraction (guaranteed non-negative by the assumption ). The natural degree is defined to be when is the zero polynomial and otherwise equals the ordinary degree; consequently this condition forces to be non-zero with ordinary degree exactly . Second, for every natural number , evaluating at the rational number obtained by lifting to equals also coerced to . (As above, counts the arrays over whose every row and column sums to .)
Confirmed by the mission captain (proposal self-audit).